From 6fce49ab085f8ee00cd1668d9dcf5c28d9c9a9fc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Jul 2018 19:49:49 +0200 Subject: Theme: desaturate colors Having everything tinted gives isn't good for color perception. --- release/datafiles/userdef/userdef_default_theme.c | 457 +++++++++++----------- 1 file changed, 228 insertions(+), 229 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index f26ace08ed5..98f787ff32b 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -20,20 +20,20 @@ const bTheme U_theme_default = { .name = "Default", .tui = { .wcol_regular = { - .outline = RGBA(0x38393eff), - .inner = RGBA(0x505158ff), + .outline = RGBA(0x3e3e3eff), + .inner = RGBA(0x585858ff), .inner_sel = RGBA(0x80858aff), - .item = RGBA(0x38393eff), + .item = RGBA(0x3e3e3eff), .text = RGBA(0xebebebff), .text_sel = RGBA(0xffffffff), .shadedown = -5, .roundness = 0.2f, }, .wcol_tool = { - .outline = RGBA(0x2f2f34ff), - .inner = RGBA(0x505158ff), - .inner_sel = RGBA(0x2f2f34ff), - .item = RGBA(0xe6ebffff), + .outline = RGBA(0x343434ff), + .inner = RGBA(0x585858ff), + .inner_sel = RGBA(0x343434ff), + .item = RGBA(0xffffffff), .text = RGBA(0xf2f2f2ff), .text_sel = RGBA(0xffffffff), .shadedown = -5, @@ -41,18 +41,18 @@ const bTheme U_theme_default = { }, .wcol_toolbar_item = { .outline = RGBA(0x191919ff), - .inner = RGBA(0x505158ff), - .inner_sel = RGBA(0x2d2d33ff), + .inner = RGBA(0x585858ff), + .inner_sel = RGBA(0x333333ff), .item = RGBA(0x191919ff), .text = RGBA(0xffffffff), .text_sel = RGBA(0xffffffff), .roundness = 0.25f, }, .wcol_text = { - .outline = RGBA(0x43454dff), - .inner = RGBA(0x2d2e33ff), - .inner_sel = RGBA(0x717280ff), - .item = RGBA(0x599eb3ff), + .outline = RGBA(0x4d4d4dff), + .inner = RGBA(0x333333ff), + .inner_sel = RGBA(0x808080ff), + .item = RGBA(0xb3b3b3ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shaded = 1, @@ -60,9 +60,9 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_radio = { - .outline = RGBA(0x424352ff), - .inner = RGBA(0x505158ff), - .inner_sel = RGBA(0x2d2d33ff), + .outline = RGBA(0x525252ff), + .inner = RGBA(0x585858ff), + .inner_sel = RGBA(0x333333ff), .item = RGBA(0xffffffff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -71,9 +71,9 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_option = { - .outline = RGBA(0x424352ff), - .inner = RGBA(0x5c5c66cc), - .inner_sel = RGBA(0x70707cff), + .outline = RGBA(0x525252ff), + .inner = RGBA(0x666666cc), + .inner_sel = RGBA(0x7c7c7cff), .item = RGBA(0xffffffff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -81,29 +81,29 @@ const bTheme U_theme_default = { .roundness = 0.25f, }, .wcol_toggle = { - .outline = RGBA(0x43434dff), - .inner = RGBA(0x595966ff), - .inner_sel = RGBA(0x3f7d80ff), + .outline = RGBA(0x4d4d4dff), + .inner = RGBA(0x666666ff), + .inner_sel = RGBA(0x808080ff), .item = RGBA(0x191919ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .roundness = 0.25f, }, .wcol_num = { - .outline = RGBA(0x46464dff), - .inner = RGBA(0x505158ff), - .inner_sel = RGBA(0x3f7780ff), - .item = RGBA(0x46464dff), + .outline = RGBA(0x4d4d4dff), + .inner = RGBA(0x585858ff), + .inner_sel = RGBA(0x808080ff), + .item = RGBA(0x4d4d4dff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shaded = 1, .roundness = 0.3f, }, .wcol_numslider = { - .outline = RGBA(0x46464dff), - .inner = RGBA(0x3f3f47ff), - .inner_sel = RGBA(0x3f7780ff), - .item = RGBA(0x505158ff), + .outline = RGBA(0x4d4d4dff), + .inner = RGBA(0x474747ff), + .inner_sel = RGBA(0x808080ff), + .item = RGBA(0x585858ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shaded = 1, @@ -111,18 +111,18 @@ const bTheme U_theme_default = { .roundness = 0.4f, }, .wcol_tab = { - .outline = RGBA(0x28292dff), - .inner = RGBA(0x323239ff), - .inner_sel = RGBA(0x43444bff), - .item = RGBA(0x28292dff), + .outline = RGBA(0x2d2d2dff), + .inner = RGBA(0x323232ff), + .inner_sel = RGBA(0x4b4b4bff), + .item = RGBA(0x2d2d2dff), .text = RGBA(0xbebebeff), .text_sel = RGBA(0xffffffff), .roundness = 0.15f, }, .wcol_menu = { - .outline = RGBA(0x43454dff), - .inner = RGBA(0x29282eff), - .inner_sel = RGBA(0x505158ff), + .outline = RGBA(0x4d4d4dff), + .inner = RGBA(0x2e2e2eff), + .inner_sel = RGBA(0x585858ff), .item = RGBA(0xe6e6e6ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xccccccff), @@ -131,10 +131,10 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_pulldown = { - .outline = RGBA(0x43454dff), - .inner = RGBA(0x29282e99), - .inner_sel = RGBA(0x505158ff), - .item = RGBA(0x696a72ff), + .outline = RGBA(0x4d4d4dff), + .inner = RGBA(0x2e2e2e99), + .inner_sel = RGBA(0x585858ff), + .item = RGBA(0x727272ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shadetop = 25, @@ -142,10 +142,10 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_menu_back = { - .outline = RGBA(0x29282eff), + .outline = RGBA(0x2e2e2eff), .inner = RGBA(0x1f1f1fef), - .inner_sel = RGBA(0x505158ff), - .item = RGBA(0x696a72ff), + .inner_sel = RGBA(0x585858ff), + .item = RGBA(0x727272ff), .text = RGBA(0xb3b3b3ff), .text_sel = RGBA(0xffffffff), .shadetop = 25, @@ -153,7 +153,7 @@ const bTheme U_theme_default = { .roundness = 0.25f, }, .wcol_menu_item = { - .inner_sel = RGBA(0x505158ff), + .inner_sel = RGBA(0x585858ff), .item = RGBA(0xacacac80), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -161,7 +161,7 @@ const bTheme U_theme_default = { .roundness = 0.25f, }, .wcol_tooltip = { - .outline = RGBA(0x2f3035ff), + .outline = RGBA(0x353535ff), .inner = RGBA(0x19191aef), .inner_sel = RGBA(0x19191aef), .item = RGBA(0x19191aef), @@ -172,19 +172,19 @@ const bTheme U_theme_default = { .roundness = 0.25f, }, .wcol_box = { - .outline = RGBA(0x2d2e33ff), - .inner = RGBA(0x43454dff), - .inner_sel = RGBA(0x3f7780ff), + .outline = RGBA(0x333333ff), + .inner = RGBA(0x4d4d4dff), + .inner_sel = RGBA(0x808080ff), .item = RGBA(0x191919ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .roundness = 0.2f, }, .wcol_scroll = { - .outline = RGBA(0x2f3035ff), - .inner = RGBA(0x585a6700), - .inner_sel = RGBA(0x599eb3ff), - .item = RGBA(0x585a67ff), + .outline = RGBA(0x353535ff), + .inner = RGBA(0x67676700), + .inner_sel = RGBA(0xb3b3b3ff), + .item = RGBA(0x676767ff), .text = RGBA(0xffffffff), .text_sel = RGBA(0xffffffff), .shadetop = 5, @@ -195,25 +195,25 @@ const bTheme U_theme_default = { .outline = RGBA(0xb3b3b3ff), .inner = RGBA(0xccccccff), .inner_sel = RGBA(0x646464b4), - .item = RGBA(0x599eb3ff), + .item = RGBA(0xb3b3b3ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .roundness = 0.25f, }, .wcol_list_item = { - .outline = RGBA(0x28292dff), - .inner = RGBA(0x28292d00), - .inner_sel = RGBA(0x5f616fff), - .item = RGBA(0x599eb3ff), + .outline = RGBA(0x2d2d2dff), + .inner = RGBA(0x2d2d2d00), + .inner_sel = RGBA(0x6f6f6fff), + .item = RGBA(0xb3b3b3ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .roundness = 0.2f, }, .wcol_pie_menu = { - .outline = RGBA(0x29282eff), - .inner = RGBA(0x29282eff), - .inner_sel = RGBA(0x505158ff), - .item = RGBA(0x696a72ff), + .outline = RGBA(0x2e2e2eff), + .inner = RGBA(0x2e2e2eff), + .inner_sel = RGBA(0x585858ff), + .item = RGBA(0x727272ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shadetop = 10, @@ -232,7 +232,7 @@ const bTheme U_theme_default = { .widget_emboss = RGBA(0x00000005), .menu_shadow_fac = 0.3f, .menu_shadow_width = 4, - .editor_outline = RGBA(0x1c1d20ff), + .editor_outline = RGBA(0x202020ff), .icon_alpha = 1.0f, .icon_saturation = 0.4f, .xaxis = RGBA(0xff3352ff), @@ -245,24 +245,24 @@ const bTheme U_theme_default = { .manipulator_b = RGBA(0xa33535ff), }, .tbuts = { - .back = RGBA(0x3a3c4200), + .back = RGBA(0x42424200), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -275,30 +275,29 @@ const bTheme U_theme_default = { .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c4200), + .header = RGBA(0x42424200), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303500), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353500), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, }, .gradients = { - .gradient = RGBA(0x2d2d2e00), - .high_gradient = RGBA(0x474748ff), - .show_grad = 1, + .gradient = RGBA(0x39393900), + .high_gradient = RGBA(0x393939ff), }, - .grid = RGBA(0x1f1f23ff), + .grid = RGBA(0x232323ff), .wire = RGBA(0x000000ff), .wire_edit = RGBA(0x111111ff), .select = RGBA(0xed5700ff), @@ -365,24 +364,24 @@ const bTheme U_theme_default = { .paint_curve_handle = RGBA(0x7fff7f7f), }, .tfile = { - .back = RGBA(0x2f303500), + .back = RGBA(0x35353500), .title = RGBA(0xffffffff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x29282eff), + .header = RGBA(0x2e2e2eff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -393,35 +392,35 @@ const bTheme U_theme_default = { .facedot_size = 4, }, .tipo = { - .back = RGBA(0x2f303500), + .back = RGBA(0x35353500), .title = RGBA(0xffffffff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x29282eff), + .header = RGBA(0x2e2e2eff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), - .list = RGBA(0x29282eff), + .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xffffffff), .list_text = RGBA(0xccccccff), .list_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, }, .shade1 = RGBA(0x96969600), - .shade2 = RGBA(0x29282e64), - .grid = RGBA(0x17171aff), + .shade2 = RGBA(0x2e2e2e64), + .grid = RGBA(0x1a1a1aff), .group = RGBA(0x247f0dff), .group_active = RGBA(0x46a431ff), .vertex_select = RGBA(0xff8500ff), @@ -444,24 +443,24 @@ const bTheme U_theme_default = { .handle_vertex_size = 5, }, .tinfo = { - .back = RGBA(0x3a3c4200), + .back = RGBA(0x42424200), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -480,28 +479,28 @@ const bTheme U_theme_default = { .info_debug = RGBA(0xd3d3d3ff), }, .tact = { - .back = RGBA(0x3a3c4200), + .back = RGBA(0x42424200), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), - .list = RGBA(0x29282eff), + .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xd8d8d8ff), .list_text = RGBA(0xffffffff), .list_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -509,7 +508,7 @@ const bTheme U_theme_default = { .shade1 = RGBA(0xc0c0c000), .shade2 = RGBA(0x70707064), .hilite = RGBA(0x60c040ff), - .grid = RGBA(0x17171aff), + .grid = RGBA(0x1a1a1aff), .group = RGBA(0x278c0eff), .group_active = RGBA(0x4eb335ff), .strip = RGBA(0x1a151580), @@ -535,28 +534,28 @@ const bTheme U_theme_default = { .anim_active = RGBA(0x66310066), }, .tnla = { - .back = RGBA(0x2f303500), + .back = RGBA(0x35353500), .title = RGBA(0xffffffff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x29282eff), + .header = RGBA(0x212121ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), - .list = RGBA(0x29282eff), + .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xffffffff), .list_text = RGBA(0xccccccff), .list_text_hi = RGBA(0xccccccff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -584,24 +583,24 @@ const bTheme U_theme_default = { .nla_sound_sel = RGBA(0x1f7a7aff), }, .tseq = { - .back = RGBA(0x3a3c4200), + .back = RGBA(0x42424200), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -632,20 +631,20 @@ const bTheme U_theme_default = { .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -684,24 +683,24 @@ const bTheme U_theme_default = { .metadatatext = RGBA(0xffffffff), }, .text = { - .back = RGBA(0x22242700), + .back = RGBA(0x27272700), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -722,24 +721,24 @@ const bTheme U_theme_default = { .syntaxr = RGBA(0xc4753bff), }, .toops = { - .back = RGBA(0x3a3c4200), + .back = RGBA(0x42424200), .title = RGBA(0xffffffff), .text = RGBA(0xdededeff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3f3f45ff), + .header = RGBA(0x454545ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -756,28 +755,28 @@ const bTheme U_theme_default = { .facedot_size = 4, }, .tnode = { - .back = RGBA(0x2a2c3200), + .back = RGBA(0x32323200), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), - .list = RGBA(0x29282eff), + .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xffffffff), .list_text = RGBA(0xccccccff), .list_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -791,7 +790,7 @@ const bTheme U_theme_default = { .vertex_size = 3, .outline_width = 1, .facedot_size = 4, - .syntaxl = RGBA(0x5a5c66ff), + .syntaxl = RGBA(0x666666ff), .syntaxs = RGBA(0x977474ff), .syntaxb = RGBA(0xffcb4dff), .syntaxn = RGBA(0xff6675ff), @@ -812,24 +811,24 @@ const bTheme U_theme_default = { .gp_vertex_select = RGBA(0xff8500ff), }, .tuserpref = { - .back = RGBA(0x3a3c4200), + .back = RGBA(0x42424200), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -839,24 +838,24 @@ const bTheme U_theme_default = { .facedot_size = 4, }, .tconsole = { - .back = RGBA(0x22242700), + .back = RGBA(0x27272700), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -872,26 +871,26 @@ const bTheme U_theme_default = { .facedot_size = 4, }, .tclip = { - .back = RGBA(0x3a3c4200), + .back = RGBA(0x42424200), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x3a3c42ff), + .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .list = RGBA(0x666666ff), .list_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -918,24 +917,24 @@ const bTheme U_theme_default = { .gp_vertex_size = 1, }, .ttopbar = { - .back = RGBA(0x43444b00), + .back = RGBA(0x4b4b4b00), .title = RGBA(0xffffffff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x1f1f23ff), + .header = RGBA(0x232323ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f303599), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x35353599), .button_title = RGBA(0xffffffff), .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -946,22 +945,22 @@ const bTheme U_theme_default = { .gp_vertex_size = 3, }, .tstatusbar = { - .back = RGBA(0x29282e00), - .title = RGBA(0xe4e8ffff), - .text = RGBA(0x747a83ff), + .back = RGBA(0x2e2e2e00), + .title = RGBA(0xffffffff), + .text = RGBA(0x838383ff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x1f1f23ff), - .header_text = RGBA(0x959eaaff), + .header = RGBA(0x232323ff), + .header_text = RGBA(0xaaaaaaff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x43444bff), - .tab_inactive = RGBA(0x323239ff), - .tab_back = RGBA(0x1f1f23ff), - .tab_outline = RGBA(0x28292dff), - .button = RGBA(0x2f3035ff), + .tab_active = RGBA(0x4b4b4bff), + .tab_inactive = RGBA(0x323232ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x353535ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x3a3c42cc), - .back = RGBA(0x2c2e33b3), + .header = RGBA(0x424242cc), + .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, -- cgit v1.2.3 From 8c7ddf944e7901659c97249f3750a0071408e47e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Jul 2018 19:58:39 +0200 Subject: Theme: use highlight from flatty light Also make text & number editing use same colors. --- release/datafiles/userdef/userdef_default_theme.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 98f787ff32b..6e2678fe9f2 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -22,7 +22,7 @@ const bTheme U_theme_default = { .wcol_regular = { .outline = RGBA(0x3e3e3eff), .inner = RGBA(0x585858ff), - .inner_sel = RGBA(0x80858aff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0x3e3e3eff), .text = RGBA(0xebebebff), .text_sel = RGBA(0xffffffff), @@ -32,7 +32,7 @@ const bTheme U_theme_default = { .wcol_tool = { .outline = RGBA(0x343434ff), .inner = RGBA(0x585858ff), - .inner_sel = RGBA(0x343434ff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xffffffff), .text = RGBA(0xf2f2f2ff), .text_sel = RGBA(0xffffffff), @@ -52,7 +52,7 @@ const bTheme U_theme_default = { .outline = RGBA(0x4d4d4dff), .inner = RGBA(0x333333ff), .inner_sel = RGBA(0x808080ff), - .item = RGBA(0xb3b3b3ff), + .item = RGBA(0x333333ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shaded = 1, @@ -62,7 +62,7 @@ const bTheme U_theme_default = { .wcol_radio = { .outline = RGBA(0x525252ff), .inner = RGBA(0x585858ff), - .inner_sel = RGBA(0x333333ff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xffffffff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -73,7 +73,7 @@ const bTheme U_theme_default = { .wcol_option = { .outline = RGBA(0x525252ff), .inner = RGBA(0x666666cc), - .inner_sel = RGBA(0x7c7c7cff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xffffffff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -83,7 +83,7 @@ const bTheme U_theme_default = { .wcol_toggle = { .outline = RGBA(0x4d4d4dff), .inner = RGBA(0x666666ff), - .inner_sel = RGBA(0x808080ff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0x191919ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -93,7 +93,7 @@ const bTheme U_theme_default = { .outline = RGBA(0x4d4d4dff), .inner = RGBA(0x585858ff), .inner_sel = RGBA(0x808080ff), - .item = RGBA(0x4d4d4dff), + .item = RGBA(0x333333ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shaded = 1, @@ -133,7 +133,7 @@ const bTheme U_theme_default = { .wcol_pulldown = { .outline = RGBA(0x4d4d4dff), .inner = RGBA(0x2e2e2e99), - .inner_sel = RGBA(0x585858ff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0x727272ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -153,7 +153,7 @@ const bTheme U_theme_default = { .roundness = 0.25f, }, .wcol_menu_item = { - .inner_sel = RGBA(0x585858ff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xacacac80), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -203,7 +203,7 @@ const bTheme U_theme_default = { .wcol_list_item = { .outline = RGBA(0x2d2d2dff), .inner = RGBA(0x2d2d2d00), - .inner_sel = RGBA(0x6f6f6fff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xb3b3b3ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -213,7 +213,7 @@ const bTheme U_theme_default = { .outline = RGBA(0x2e2e2eff), .inner = RGBA(0x2e2e2eff), .inner_sel = RGBA(0x585858ff), - .item = RGBA(0x727272ff), + .item = RGBA(0x5680c2ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shadetop = 10, -- cgit v1.2.3 From 2203b041e1d2d770e22e37bb4c235bc07f5e7340 Mon Sep 17 00:00:00 2001 From: Macelaru Tiberiu Date: Mon, 2 Jul 2018 18:35:50 +0200 Subject: Sculpting: add Manual detail mode for dynamic topology. In this mode mesh detail does not change on each stroke, but only when using flood fill. Differential Revision: https://developer.blender.org/D3515 --- .../scripts/startup/bl_ui/space_view3d_toolbar.py | 4 +-- source/blender/editors/sculpt_paint/sculpt.c | 29 ++++++++++++---------- source/blender/makesdna/DNA_scene_types.h | 1 + source/blender/makesrna/intern/rna_sculpt_paint.c | 4 ++- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 864dcc4b0e9..8d78d674922 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -924,7 +924,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel): sub = col.column() sub.active = (brush and brush.sculpt_tool != 'MASK') - if (sculpt.detail_type_method == 'CONSTANT'): + if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}: row = sub.row(align=True) row.prop(sculpt, "constant_detail_resolution") row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER') @@ -942,7 +942,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel): col.prop(sculpt, "symmetrize_direction") col.operator("sculpt.symmetrize") col.operator("sculpt.optimize") - if (sculpt.detail_type_method == 'CONSTANT'): + if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}: col.operator("sculpt.detail_flood_fill") diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a5871c90d56..bb2000d1651 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3522,13 +3522,16 @@ static void sculpt_topology_update(Sculpt *sd, Object *ob, Brush *brush, Unified PBVHTopologyUpdateMode mode = 0; float location[3]; - if (sd->flags & SCULPT_DYNTOPO_SUBDIVIDE) - mode |= PBVH_Subdivide; + if (!(sd->flags & SCULPT_DYNTOPO_DETAIL_MANUAL)) { + if (sd->flags & SCULPT_DYNTOPO_SUBDIVIDE) { + mode |= PBVH_Subdivide; + } - if ((sd->flags & SCULPT_DYNTOPO_COLLAPSE) || - (brush->sculpt_tool == SCULPT_TOOL_SIMPLIFY)) - { - mode |= PBVH_Collapse; + if ((sd->flags & SCULPT_DYNTOPO_COLLAPSE) || + (brush->sculpt_tool == SCULPT_TOOL_SIMPLIFY)) + { + mode |= PBVH_Collapse; + } } for (n = 0; n < totnode; n++) { @@ -4952,7 +4955,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st sculpt_update_cache_variants(C, sd, ob, itemptr); sculpt_restore_mesh(sd, ob); - if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) { + if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) { BKE_pbvh_bmesh_detail_size_set(ss->pbvh, 1.0f / sd->constant_detail); } else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) { @@ -5852,13 +5855,13 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } - -static bool sculpt_and_dynamic_topology_constant_detail_poll(bContext *C) +static bool sculpt_and_constant_or_manual_detail_poll(bContext *C) { Object *ob = CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - return sculpt_mode_poll(C) && ob->sculpt->bm && (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT); + return sculpt_mode_poll(C) && ob->sculpt->bm && + (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)); } static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op)) @@ -5920,7 +5923,7 @@ static void SCULPT_OT_detail_flood_fill(wmOperatorType *ot) /* api callbacks */ ot->exec = sculpt_detail_flood_fill_exec; - ot->poll = sculpt_and_dynamic_topology_constant_detail_poll; + ot->poll = sculpt_and_constant_or_manual_detail_poll; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -6018,7 +6021,7 @@ static void SCULPT_OT_sample_detail_size(wmOperatorType *ot) ot->invoke = sculpt_sample_detail_size_invoke; ot->exec = sculpt_sample_detail_size_exec; ot->modal = sculpt_sample_detail_size_modal; - ot->poll = sculpt_and_dynamic_topology_constant_detail_poll; + ot->poll = sculpt_and_constant_or_manual_detail_poll; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6036,7 +6039,7 @@ static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op)) WM_operator_properties_create_ptr(&props_ptr, ot); - if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) { + if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) { set_brush_rc_props(&props_ptr, "sculpt", "constant_detail_resolution", NULL, 0); RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.constant_detail_resolution"); } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index dc3dee8f9a3..f8d7e657b76 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1948,6 +1948,7 @@ typedef enum eSculptFlags { /* If set, dynamic-topology detail size will be constant in object space */ SCULPT_DYNTOPO_DETAIL_CONSTANT = (1 << 13), SCULPT_DYNTOPO_DETAIL_BRUSH = (1 << 14), + SCULPT_DYNTOPO_DETAIL_MANUAL = (1 << 16), /* Don't display mask in viewport, but still use it for strokes. */ SCULPT_HIDE_MASK = (1 << 15), diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index e68c4c284c6..6f3a1afc156 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -577,8 +577,10 @@ static void rna_def_sculpt(BlenderRNA *brna) "Relative Detail", "Mesh detail is relative to the brush size and detail size"}, {SCULPT_DYNTOPO_DETAIL_CONSTANT, "CONSTANT", 0, "Constant Detail", "Mesh detail is constant in object space according to detail size"}, - {SCULPT_DYNTOPO_DETAIL_BRUSH, "BRUSH", 0, + {SCULPT_DYNTOPO_DETAIL_BRUSH, "BRUSH", 0, "Brush Detail", "Mesh detail is relative to brush radius"}, + {SCULPT_DYNTOPO_DETAIL_MANUAL, "MANUAL", 0, + "Manual Detail", "Mesh detail does not change on each stroke, only when using Flood Fill"}, {0, NULL, 0, NULL, NULL} }; -- cgit v1.2.3 From 5b5e23cec3a75c056bb3029f872bbea87034a40d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 2 Jul 2018 19:25:29 +0200 Subject: Splash: add "Alpha" text and link to the development fund. --- source/blender/windowmanager/intern/wm_operators.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index fb4ff4ddb28..5628d39e5f8 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1959,7 +1959,13 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar /* label for 'a' bugfix releases, or 'Release Candidate 1'... * avoids recreating splash for version updates */ - if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) { + if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha")) { + version_suffix = "Alpha"; + } + else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "beta")) { + version_suffix = "Beta"; + } + else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) { version_suffix = "Release Candidate"; } else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) { @@ -2027,10 +2033,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar split = uiLayoutSplit(layout, 0.0f, false); col = uiLayoutColumn(split, false); uiItemL(col, IFACE_("Links"), ICON_NONE); -#if 0 - uiItemStringO(col, IFACE_("Support an Open Animation Movie"), ICON_URL, "WM_OT_url_open", "url", - "https://cloud.blender.org/join"); -#endif + uiItemStringO(col, IFACE_("Join the Development Fund"), ICON_URL, "WM_OT_url_open", "url", + "https://www.blender.org/foundation/development-fund/"); uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/foundation/donation-payment/"); uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", -- cgit v1.2.3 From 98d205508977a6f72bf554ae244328da9191f4b3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 2 Jul 2018 20:25:59 +0200 Subject: Fix ugly half alignment in timeline header. --- release/scripts/startup/bl_ui/space_time.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index 179f1c90d2e..9db2afd62b4 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -91,20 +91,24 @@ class TIME_MT_editor_menus(Menu): @staticmethod def draw_menus(layout, context): - layout.popover( + row = layout.row() + sub = row.row(align=True) + sub.popover( space_type='DOPESHEET_EDITOR', region_type='HEADER', panel_type="TIME_PT_playback", text="Playback", ) - layout.popover( + sub.popover( space_type='DOPESHEET_EDITOR', region_type='HEADER', panel_type="TIME_PT_keyframing_settings", text="Keying", ) - layout.menu("TIME_MT_view") - layout.menu("TIME_MT_marker") + + sub = row.row(align=True) + sub.menu("TIME_MT_view") + sub.menu("TIME_MT_marker") class TIME_MT_marker(Menu): -- cgit v1.2.3 From be5482ba2fa788279434f46eacf504821d1c6223 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 3 Jul 2018 00:46:02 +0200 Subject: UI: Dim color of shortcut label in menus and toolbar The shortcut labels now use the "Item" theme color. Its contrast for hovered items is a bit low, but not too bad. Note that this also changes the color of the little toolbar triangle to be grey (the same color we use for the keymap label). IMHO that looks better though. This doesn't update any themes other than the default one. Part of T54711. --- release/datafiles/userdef/userdef_default_theme.c | 4 ++-- source/blender/editors/interface/interface_widgets.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 6e2678fe9f2..aea7e40573a 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -43,7 +43,7 @@ const bTheme U_theme_default = { .outline = RGBA(0x191919ff), .inner = RGBA(0x585858ff), .inner_sel = RGBA(0x333333ff), - .item = RGBA(0x191919ff), + .item = RGBA(0xffffff8f), .text = RGBA(0xffffffff), .text_sel = RGBA(0xffffffff), .roundness = 0.25f, @@ -154,7 +154,7 @@ const bTheme U_theme_default = { }, .wcol_menu_item = { .inner_sel = RGBA(0x5680c2ff), - .item = RGBA(0xacacac80), + .item = RGBA(0xffffff8f), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shadetop = 38, diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index dbd65ade307..4bf2ac4271b 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1961,9 +1961,12 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b /* part text right aligned */ if (drawstr_right) { + const char *col = but->block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS) ? + wcol->item : wcol->text; + fstyle->align = UI_STYLE_TEXT_RIGHT; rect->xmax -= UI_TEXT_CLIP_MARGIN; - UI_fontstyle_draw(fstyle, rect, drawstr_right, (unsigned char *)wcol->text); + UI_fontstyle_draw(fstyle, rect, drawstr_right, (const uchar *)col); } } -- cgit v1.2.3 From e856eb7e8b65a7391c89b0938de49bb7d781f5dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 05:57:27 +0200 Subject: UI: don't change the theme area when setting theme --- source/blender/editors/interface/resources.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index fb4d6e0ea14..d1d069be595 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -755,7 +755,9 @@ void ui_theme_init_default(void) UI_SetTheme(0, 0); /* make sure the global used in this file is set */ + const int active_theme_area = btheme->active_theme_area; memcpy(btheme, &U_theme_default, sizeof(*btheme)); + btheme->active_theme_area = active_theme_area; } void ui_style_init_default(void) -- cgit v1.2.3 From b66aa0b0a6b123e833d4038a77a5d3f04c37a9a0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 06:27:53 +0200 Subject: Cleanup: pep8 --- release/scripts/modules/addon_utils.py | 2 + .../scripts/modules/bl_app_override/__init__.py | 1 + release/scripts/modules/bl_i18n_utils/merge_po.py | 19 +-- .../bl_previews_utils/bl_previews_render.py | 2 +- release/scripts/modules/blend_render_info.py | 1 + release/scripts/modules/bpy/ops.py | 1 + release/scripts/modules/bpy/path.py | 3 + release/scripts/modules/bpy_extras/__init__.py | 2 +- release/scripts/modules/bpy_extras/anim_utils.py | 2 +- release/scripts/modules/bpy_extras/image_utils.py | 2 +- release/scripts/modules/bpy_extras/io_utils.py | 131 +++++++++++---------- .../scripts/modules/bpy_extras/keyconfig_utils.py | 8 +- release/scripts/modules/bpy_extras/mesh_utils.py | 10 +- release/scripts/modules/bpy_extras/object_utils.py | 32 ++--- release/scripts/modules/bpyml.py | 1 + release/scripts/modules/console/complete_import.py | 4 +- release/scripts/modules/console_python.py | 1 + release/scripts/modules/console_shell.py | 3 +- release/scripts/modules/graphviz_export.py | 3 +- release/scripts/modules/keyingsets_utils.py | 3 +- release/scripts/modules/nodeitems_utils.py | 4 +- release/scripts/modules/rna_keymap_ui.py | 21 ++-- .../startup/bl_operators/bmesh/find_adjacent.py | 7 +- release/scripts/startup/keyingsets_builtins.py | 5 + release/scripts/startup/nodeitems_builtins.py | 73 ++++++------ 25 files changed, 184 insertions(+), 157 deletions(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 97fc45189f2..c4097bed33b 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -209,6 +209,8 @@ def modules(module_cache=addons_fake_modules, *, refresh=True): ) ) return mod_list + + modules._is_first = True diff --git a/release/scripts/modules/bl_app_override/__init__.py b/release/scripts/modules/bl_app_override/__init__.py index f17878b4822..2104b10bf85 100644 --- a/release/scripts/modules/bl_app_override/__init__.py +++ b/release/scripts/modules/bl_app_override/__init__.py @@ -172,6 +172,7 @@ def ui_draw_filter_register( class Wrapper(cls_real): __slots__ = () + def __getattribute__(self, attr): if attr == "layout": return UILayout_Fake(self_real.layout) diff --git a/release/scripts/modules/bl_i18n_utils/merge_po.py b/release/scripts/modules/bl_i18n_utils/merge_po.py index ecb26123999..7e3c8a42b17 100755 --- a/release/scripts/modules/bl_i18n_utils/merge_po.py +++ b/release/scripts/modules/bl_i18n_utils/merge_po.py @@ -43,14 +43,17 @@ else: # XXX This is a quick hack to make it work with new I18n... objects! To be reworked! def main(): import argparse - parser = argparse.ArgumentParser(description= - "Merge one or more .po files into the first dest one.\n" - "If a msgkey (msgctxt, msgid) is present in more than one merged po, the one in the first file " - "wins, unless it’s marked as fuzzy and one later is not.\n" - "The fuzzy flag is removed if necessary.\n" - "All other comments are never modified.\n" - "Commented messages in dst will always remain commented, and commented messages are never merged " - "from sources.") + parser = argparse.ArgumentParser( + description=( + "Merge one or more .po files into the first dest one.\n" + "If a msgkey (msgctxt, msgid) is present in more than one merged po, the one in the first file " + "wins, unless it’s marked as fuzzy and one later is not.\n" + "The fuzzy flag is removed if necessary.\n" + "All other comments are never modified.\n" + "Commented messages in dst will always remain commented, and commented messages are never merged " + "from sources." + ), + ) parser.add_argument('-s', '--stats', action="store_true", help="Show statistics info.") parser.add_argument('-r', '--replace', action="store_true", help="Replace existing messages of same \"level\" already in dest po.") diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py index 32266e972bb..4159121cd90 100644 --- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py +++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py @@ -442,7 +442,7 @@ def do_previews(do_objects, do_groups, do_scenes, do_data_intern): if not has_camera: # We had to add a temp camera, now we need to place it to see interesting objects! objects = tuple((ob.name, ob.library.filepath if ob.library else None) for ob in scene.objects - if (not ob.hide_render) and (ob.type in OBJECT_TYPES_RENDER)) + if (not ob.hide_render) and (ob.type in OBJECT_TYPES_RENDER)) preview_render_do(render_context, 'scenes', scene.name, objects) diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py index 30c3ed2388b..3b4fb255005 100755 --- a/release/scripts/modules/blend_render_info.py +++ b/release/scripts/modules/blend_render_info.py @@ -98,5 +98,6 @@ def main(): for value in read_blend_rend_chunk(arg): print("%d %d %s" % value) + if __name__ == '__main__': main() diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py index d3d9255123b..7c5c76ffdbe 100644 --- a/release/scripts/modules/bpy/ops.py +++ b/release/scripts/modules/bpy/ops.py @@ -225,4 +225,5 @@ class BPyOpsSubModOp: return ("" % (self._module, self._func, id(self))) + ops_fake_module = BPyOps() diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index a88e60d0022..6af78bbb4c0 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -183,6 +183,8 @@ def clean_name(name, replace="_"): trans = maketrans_init() return name.translate(trans) + + clean_name._trans_cache = {} @@ -223,6 +225,7 @@ def display_name(name): name = _clean_utf8(name) return name + def display_name_to_filepath(name): """ Performs the reverse of display_name using literal versions of characters diff --git a/release/scripts/modules/bpy_extras/__init__.py b/release/scripts/modules/bpy_extras/__init__.py index c8d12070de8..d2578e1812a 100644 --- a/release/scripts/modules/bpy_extras/__init__.py +++ b/release/scripts/modules/bpy_extras/__init__.py @@ -30,4 +30,4 @@ __all__ = ( "keyconfig_utils", "mesh_utils", "view3d_utils", - ) +) diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index 75d2065a3d1..7216add2c2c 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -174,7 +174,7 @@ def bake_action_iter( # Bendy Bones if pbone.bone.bbone_segments > 1: - bbones[name] = {bb_prop : getattr(pbone, bb_prop) for bb_prop in BBONE_PROPS} + bbones[name] = {bb_prop: getattr(pbone, bb_prop) for bb_prop in BBONE_PROPS} return matrix, bbones if do_parents_clear: diff --git a/release/scripts/modules/bpy_extras/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py index f772aab2b14..49fce7d27c7 100644 --- a/release/scripts/modules/bpy_extras/image_utils.py +++ b/release/scripts/modules/bpy_extras/image_utils.py @@ -20,7 +20,7 @@ __all__ = ( "load_image", - ) +) # limited replacement for BPyImage.comprehensiveImageLoad diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index 8a516f12b17..e2c2e4c9b93 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -32,7 +32,7 @@ __all__ = ( "path_reference_copy", "path_reference_mode", "unique_name" - ) +) import bpy from bpy.props import ( @@ -53,23 +53,23 @@ def _check_axis_conversion(op): class ExportHelper: filepath = StringProperty( - name="File Path", - description="Filepath used for exporting the file", - maxlen=1024, - subtype='FILE_PATH', - ) + name="File Path", + description="Filepath used for exporting the file", + maxlen=1024, + subtype='FILE_PATH', + ) check_existing = BoolProperty( - name="Check Existing", - description="Check and warn on overwriting existing files", - default=True, - options={'HIDDEN'}, - ) + name="Check Existing", + description="Check and warn on overwriting existing files", + default=True, + options={'HIDDEN'}, + ) # needed for mix-ins order = [ "filepath", "check_existing", - ] + ] # subclasses can override with decorator # True == use ext, False == no ext, None == do nothing. @@ -113,16 +113,16 @@ class ExportHelper: class ImportHelper: filepath = StringProperty( - name="File Path", - description="Filepath used for importing the file", - maxlen=1024, - subtype='FILE_PATH', - ) + name="File Path", + description="Filepath used for importing the file", + maxlen=1024, + subtype='FILE_PATH', + ) # needed for mix-ins order = [ "filepath", - ] + ] def invoke(self, context, event): context.window_manager.fileselect_add(self) @@ -138,43 +138,45 @@ def orientation_helper_factory(name, axis_forward='Y', axis_up='Z'): def _update_axis_forward(self, context): if self.axis_forward[-1] == self.axis_up[-1]: self.axis_up = (self.axis_up[0:-1] + - 'XYZ'[('XYZ'.index(self.axis_up[-1]) + 1) % 3]) + 'XYZ'[('XYZ'.index(self.axis_up[-1]) + 1) % 3]) members['axis_forward'] = EnumProperty( - name="Forward", - items=(('X', "X Forward", ""), - ('Y', "Y Forward", ""), - ('Z', "Z Forward", ""), - ('-X', "-X Forward", ""), - ('-Y', "-Y Forward", ""), - ('-Z', "-Z Forward", ""), - ), - default=axis_forward, - update=_update_axis_forward, - ) + name="Forward", + items=( + ('X', "X Forward", ""), + ('Y', "Y Forward", ""), + ('Z', "Z Forward", ""), + ('-X', "-X Forward", ""), + ('-Y', "-Y Forward", ""), + ('-Z', "-Z Forward", ""), + ), + default=axis_forward, + update=_update_axis_forward, + ) def _update_axis_up(self, context): if self.axis_up[-1] == self.axis_forward[-1]: self.axis_forward = (self.axis_forward[0:-1] + - 'XYZ'[('XYZ'.index(self.axis_forward[-1]) + 1) % 3]) + 'XYZ'[('XYZ'.index(self.axis_forward[-1]) + 1) % 3]) members['axis_up'] = EnumProperty( - name="Up", - items=(('X', "X Up", ""), - ('Y', "Y Up", ""), - ('Z', "Z Up", ""), - ('-X', "-X Up", ""), - ('-Y', "-Y Up", ""), - ('-Z', "-Z Up", ""), - ), - default=axis_up, - update=_update_axis_up, - ) + name="Up", + items=( + ('X', "X Up", ""), + ('Y', "Y Up", ""), + ('Z', "Z Up", ""), + ('-X', "-X Up", ""), + ('-Y', "-Y Up", ""), + ('-Z', "-Z Up", ""), + ), + default=axis_up, + update=_update_axis_up, + ) members["order"] = [ "axis_forward", "axis_up", - ] + ] return type(name, (object,), members) @@ -205,7 +207,7 @@ _axis_convert_matrix = ( ((1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, -1.0)), ((1.0, 0.0, 0.0), (0.0, 0.0, 1.0), (0.0, -1.0, 0.0)), ((1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, 1.0, 0.0)), - ) +) # store args as a single int # (X Y Z -X -Y -Z) --> (0, 1, 2, 3, 4, 5) @@ -282,7 +284,7 @@ _axis_convert_lut = ( {0x408, 0x810, 0xA20, 0x228, 0x081, 0x891, 0x699, 0x2A9, 0x102, 0x50A, 0x71A, 0xB22, 0x4CB, 0x8D3, 0xAE3, 0x2EB, 0x144, 0x954, 0x75C, 0x36C, 0x045, 0x44D, 0x65D, 0xA65}, - ) +) _axis_convert_num = {'X': 0, 'Y': 1, 'Z': 2, '-X': 3, '-Y': 4, '-Z': 5} @@ -303,11 +305,11 @@ def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'): "can't use up/forward on the same axis") value = reduce(int.__or__, (_axis_convert_num[a] << (i * 3) - for i, a in enumerate((from_forward, - from_up, - to_forward, - to_up, - )))) + for i, a in enumerate((from_forward, + from_up, + to_forward, + to_up, + )))) for i, axis_lut in enumerate(_axis_convert_lut): if value in axis_lut: @@ -392,20 +394,21 @@ def unpack_face_list(list_of_tuples): path_reference_mode = EnumProperty( - name="Path Mode", - description="Method used to reference paths", - items=(('AUTO', "Auto", "Use Relative paths with subdirectories only"), - ('ABSOLUTE', "Absolute", "Always write absolute paths"), - ('RELATIVE', "Relative", "Always write relative paths " - "(where possible)"), - ('MATCH', "Match", "Match Absolute/Relative " - "setting with input path"), - ('STRIP', "Strip Path", "Filename only"), - ('COPY', "Copy", "Copy the file to the destination path " - "(or subdirectory)"), - ), - default='AUTO', - ) + name="Path Mode", + description="Method used to reference paths", + items=( + ('AUTO', "Auto", "Use Relative paths with subdirectories only"), + ('ABSOLUTE', "Absolute", "Always write absolute paths"), + ('RELATIVE', "Relative", "Always write relative paths " + "(where possible)"), + ('MATCH', "Match", "Match Absolute/Relative " + "setting with input path"), + ('STRIP', "Strip Path", "Filename only"), + ('COPY', "Copy", "Copy the file to the destination path " + "(or subdirectory)"), + ), + default='AUTO', +) def path_reference(filepath, diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index 9d206afb2c5..92674bfc5f6 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -177,8 +177,8 @@ def addon_keymap_register(wm, keymaps_description): for km_info, km_items in keymaps_description: km_name, km_sptype, km_regtype, km_ismodal = km_info kmap = [k for k in kconf.keymaps - if k.name == km_name and k.region_type == km_regtype and - k.space_type == km_sptype and k.is_modal == km_ismodal] + if k.name == km_name and k.region_type == km_regtype and + k.space_type == km_sptype and k.is_modal == km_ismodal] if kmap: kmap = kmap[0] else: @@ -202,8 +202,8 @@ def addon_keymap_unregister(wm, keymaps_description): for km_info, km_items in keymaps_description: km_name, km_sptype, km_regtype, km_ismodal = km_info kmaps = (k for k in kconf.keymaps - if k.name == km_name and k.region_type == km_regtype and - k.space_type == km_sptype and k.is_modal == km_ismodal) + if k.name == km_name and k.region_type == km_regtype and + k.space_type == km_sptype and k.is_modal == km_ismodal) for kmap in kmaps: for kmi_kwargs, props in km_items: idname = kmi_kwargs["idname"] diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index 4293930e823..43b02e5c881 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -27,7 +27,7 @@ __all__ = ( "edge_loops_from_edges", "ngon_tessellate", "face_random_points", - ) +) def mesh_linked_uv_islands(mesh): @@ -286,7 +286,7 @@ def edge_loops_from_edges(mesh, edges=None): ok = True while ok: ok = False - #for i, ed in enumerate(edges): + # for i, ed in enumerate(edges): i = len(edges) while i: i -= 1 @@ -303,7 +303,7 @@ def edge_loops_from_edges(mesh, edges=None): vert_end = line_poly[-1] ok = 1 del edges[i] - #break + # break elif v1 == vert_start: line_poly.insert(0, v2) vert_start = line_poly[0] @@ -315,7 +315,7 @@ def edge_loops_from_edges(mesh, edges=None): vert_start = line_poly[0] ok = 1 del edges[i] - #break + # break line_polys.append(line_poly) return line_polys @@ -481,7 +481,7 @@ def ngon_tessellate(from_data, indices, fix_loops=True): ii += len(verts) fill = tessellate_polygon([[v[0] for v in loop] for loop in loop_list]) - #draw_loops(loop_list) + # draw_loops(loop_list) #raise Exception("done loop") # map to original indices fill = [[vert_map[i] for i in reversed(f)] for f in fill] diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index 9d9b5df1f9a..0a48d99b529 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -26,7 +26,7 @@ __all__ = ( "object_add_grid_scale_apply_operator", "object_image_guess", "world_to_camera_view", - ) +) import bpy @@ -218,24 +218,24 @@ class AddObjectHelper: self.rotation.zero() view_align = BoolProperty( - name="Align to View", - default=False, - update=view_align_update_callback, - ) + name="Align to View", + default=False, + update=view_align_update_callback, + ) location = FloatVectorProperty( - name="Location", - subtype='TRANSLATION', - ) + name="Location", + subtype='TRANSLATION', + ) rotation = FloatVectorProperty( - name="Rotation", - subtype='EULER', - ) + name="Rotation", + subtype='EULER', + ) layers = BoolVectorProperty( - name="Layers", - size=20, - subtype='LAYER', - options={'HIDDEN', 'SKIP_SAVE'}, - ) + name="Layers", + size=20, + subtype='LAYER', + options={'HIDDEN', 'SKIP_SAVE'}, + ) @classmethod def poll(self, context): diff --git a/release/scripts/modules/bpyml.py b/release/scripts/modules/bpyml.py index f2a73501672..3cdbf848a24 100644 --- a/release/scripts/modules/bpyml.py +++ b/release/scripts/modules/bpyml.py @@ -153,6 +153,7 @@ def topretty_py(py_data, indent=" "): return "\n".join(lines) + if __name__ == "__main__": # testing code. diff --git a/release/scripts/modules/console/complete_import.py b/release/scripts/modules/console/complete_import.py index e7218594a86..b9b7c6cb779 100644 --- a/release/scripts/modules/console/complete_import.py +++ b/release/scripts/modules/console/complete_import.py @@ -19,12 +19,12 @@ # ##### END GPL LICENSE BLOCK ##### # Original copyright (see docstring): -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2001-2006 Fernando Perez # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. -#***************************************************************************** +# **************************************************************************** # diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py index a740f31c830..68ff1ed60a7 100644 --- a/release/scripts/modules/console_python.py +++ b/release/scripts/modules/console_python.py @@ -224,6 +224,7 @@ def execute(context, is_interactive): return {'FINISHED'} + execute.hooks = [] diff --git a/release/scripts/modules/console_shell.py b/release/scripts/modules/console_shell.py index 83367e72e67..474e2c6ff81 100644 --- a/release/scripts/modules/console_shell.py +++ b/release/scripts/modules/console_shell.py @@ -40,6 +40,7 @@ def shell_run(text): add_scrollback(output, style) + PROMPT = "$ " @@ -64,7 +65,7 @@ def execute(context, is_interactive): def autocomplete(context): - #~ sc = context.space_data + # sc = context.space_data # TODO return {'CANCELLED'} diff --git a/release/scripts/modules/graphviz_export.py b/release/scripts/modules/graphviz_export.py index 88f8b15a728..fbe23a05940 100644 --- a/release/scripts/modules/graphviz_export.py +++ b/release/scripts/modules/graphviz_export.py @@ -140,7 +140,7 @@ def graph_armature(obj, filepath, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=Tr return None #rna_path_bone = rna_path[:rna_path.index("]") + 1] - #return obj.path_resolve(rna_path_bone) + # return obj.path_resolve(rna_path_bone) bone_name = rna_path.split("[")[1].split("]")[0] return obj.pose.bones[bone_name[1:-1]] @@ -179,6 +179,7 @@ def graph_armature(obj, filepath, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=Tr print("\nSaved:", filepath) return True + if __name__ == "__main__": import os tmppath = "/tmp/test.dot" diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py index e5075a9b085..de8da450125 100644 --- a/release/scripts/modules/keyingsets_utils.py +++ b/release/scripts/modules/keyingsets_utils.py @@ -36,7 +36,7 @@ __all__ = ( "RKS_GEN_rotation", "RKS_GEN_scaling", "RKS_GEN_bendy_bones", - ) +) import bpy @@ -219,6 +219,7 @@ def RKS_GEN_scaling(ksi, context, ks, data): # ------ + # Property identifiers for Bendy Bones bbone_property_ids = ( "bbone_curveinx", diff --git a/release/scripts/modules/nodeitems_utils.py b/release/scripts/modules/nodeitems_utils.py index 117e35dd028..699b6ce0528 100644 --- a/release/scripts/modules/nodeitems_utils.py +++ b/release/scripts/modules/nodeitems_utils.py @@ -121,7 +121,7 @@ def register_node_categories(identifier, cat_list): "category": cat, "poll": cat.poll, "draw": draw_node_item, - }) + }) panel_type = type("NODE_PT_category_" + cat.identifier, (bpy.types.Panel,), { "bl_space_type": 'NODE_EDITOR', "bl_region_type": 'TOOLS', @@ -130,7 +130,7 @@ def register_node_categories(identifier, cat_list): "category": cat, "poll": cat.poll, "draw": draw_node_item, - }) + }) menu_types.append(menu_type) panel_types.append(panel_type) diff --git a/release/scripts/modules/rna_keymap_ui.py b/release/scripts/modules/rna_keymap_ui.py index aa1aa4925a3..e151a81913b 100644 --- a/release/scripts/modules/rna_keymap_ui.py +++ b/release/scripts/modules/rna_keymap_ui.py @@ -25,7 +25,7 @@ __all__ = ( "draw_filtered", "draw_hierarchy", "draw_keymaps", - ) +) import bpy @@ -174,7 +174,7 @@ def draw_kmi(display_keymaps, kc, km, kmi, layout, level): sub.prop(kmi, "propvalue", text="") else: # One day... - #~ sub.prop_search(kmi, "idname", bpy.context.window_manager, "operators_all", text="") + # sub.prop_search(kmi, "idname", bpy.context.window_manager, "operators_all", text="") sub.prop(kmi, "idname", text="") if map_type not in {'TEXTINPUT', 'TIMER'}: @@ -207,6 +207,7 @@ def draw_kmi(display_keymaps, kc, km, kmi, layout, level): draw_km(display_keymaps, kc, kmm, None, layout, level + 1) layout.context_pointer_set("keymap", km) + _EVENT_TYPES = set() _EVENT_TYPE_MAP = {} _EVENT_TYPE_MAP_EXTRA = {} @@ -234,10 +235,10 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout): "RMB": 'RIGHTMOUSE', "LMB": 'LEFTMOUSE', "MMB": 'MIDDLEMOUSE', - }) + }) _EVENT_TYPE_MAP_EXTRA.update({ "%d" % i: "NUMPAD_%d" % i for i in range(10) - }) + }) # done with once off init filter_text_split = filter_text.strip() @@ -251,7 +252,7 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout): "cmd": "oskey", "oskey": "oskey", "any": "any", - } + } # KeyMapItem like dict, use for comparing against # attr: {states, ...} kmi_test_dict = {} @@ -260,8 +261,8 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout): kmi_test_type = [] # initialize? - so if a if a kmi has a MOD assigned it wont show up. - #~ for kv in key_mod.values(): - #~ kmi_test_dict[kv] = {False} + # for kv in key_mod.values(): + # kmi_test_dict[kv] = {False} # altname: attr for kk, kv in key_mod.items(): @@ -374,7 +375,7 @@ def draw_keymaps(context, layout): row = subcol.row(align=True) - #~ row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config") + # row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config") text = bpy.path.display_name(wm.keyconfigs.active.name) if not text: text = "Blender (default)" @@ -382,8 +383,8 @@ def draw_keymaps(context, layout): row.operator("wm.keyconfig_preset_add", text="", icon='ZOOMIN') row.operator("wm.keyconfig_preset_add", text="", icon='ZOOMOUT').remove_active = True - #~ layout.context_pointer_set("keyconfig", wm.keyconfigs.active) - #~ row.operator("wm.keyconfig_remove", text="", icon='X') + # layout.context_pointer_set("keyconfig", wm.keyconfigs.active) + # row.operator("wm.keyconfig_remove", text="", icon='X') row.separator() rowsub = row.split(align=True, percentage=0.33) # postpone drawing into rowsub, so we can set alert! diff --git a/release/scripts/startup/bl_operators/bmesh/find_adjacent.py b/release/scripts/startup/bl_operators/bmesh/find_adjacent.py index 2e2d4c948d2..5d8011249bc 100644 --- a/release/scripts/startup/bl_operators/bmesh/find_adjacent.py +++ b/release/scripts/startup/bl_operators/bmesh/find_adjacent.py @@ -26,7 +26,7 @@ import bmesh __all__ = ( "select_prev", "select_next", - ) +) def other_edges_over_face(e): @@ -303,8 +303,9 @@ def select_next(bm, report): for fn in (pass_fn, set, sum_set, len): uuid_cmp_test = fn(uuid_cmp) ele_pair_next_uuid_test = [ - (ele, uuid) for (ele, uuid) in ele_pair_next_uuid - if uuid_cmp_test == fn(uuid)] + (ele, uuid) for (ele, uuid) in ele_pair_next_uuid + if uuid_cmp_test == fn(uuid) + ] if len(ele_pair_next_uuid_test) > 1: ele_pair_next_uuid = ele_pair_next_uuid_test elif len(ele_pair_next_uuid_test) == 1: diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py index 390c043bb31..0d904de1d27 100644 --- a/release/scripts/startup/keyingsets_builtins.py +++ b/release/scripts/startup/keyingsets_builtins.py @@ -527,6 +527,8 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo): ksi.addProp(ks, bone, prop) # All properties that are likely to get animated in a character rig, only selected bones. + + class BUILTIN_KSI_WholeCharacterSelected(KeyingSetInfo): """Insert a keyframe for all properties that are likely to get animated in a character rig """ """(only selected bones)""" @@ -557,6 +559,8 @@ class BUILTIN_KSI_WholeCharacterSelected(KeyingSetInfo): ############################### # Delta Location + + class BUILTIN_KSI_DeltaLocation(KeyingSetInfo): """Insert keyframes for additional location offset""" bl_label = "Delta Location" @@ -643,6 +647,7 @@ class BUILTIN_KSI_DeltaScale(KeyingSetInfo): ############################### + # Note that this controls order of options in 'insert keyframe' menu. # Better try to keep some logical order here beyond mere alphabetical one, also because of menu entries shortcut. # See also T51867. diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 3826b2b10de..92411aeb0ef 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -69,12 +69,13 @@ def group_tools_draw(self, layout, context): layout.operator("node.group_ungroup") layout.separator() + # maps node tree type to group node type node_tree_group_type = { 'CompositorNodeTree': 'CompositorNodeGroup', 'ShaderNodeTree': 'ShaderNodeGroup', 'TextureNodeTree': 'TextureNodeGroup', - } +} # generic node group items generator for shader, compositor and texture node groups @@ -159,25 +160,25 @@ shader_node_categories = [ NodeItem("ShaderNodeParticleInfo"), NodeItem("ShaderNodeObjectInfo"), NodeItem("NodeGroupInput", poll=group_input_output_item_poll), - ]), + ]), ShaderOldNodeCategory("SH_OUTPUT", "Output", items=[ NodeItem("ShaderNodeOutput"), NodeItem("NodeGroupOutput", poll=group_input_output_item_poll), - ]), + ]), ShaderOldNodeCategory("SH_OP_COLOR", "Color", items=[ NodeItem("ShaderNodeMixRGB"), NodeItem("ShaderNodeRGBCurve"), NodeItem("ShaderNodeInvert"), NodeItem("ShaderNodeHueSaturation"), NodeItem("ShaderNodeGamma"), - ]), + ]), ShaderOldNodeCategory("SH_OP_VECTOR", "Vector", items=[ NodeItem("ShaderNodeNormal"), NodeItem("ShaderNodeMapping"), NodeItem("ShaderNodeVectorCurve"), NodeItem("ShaderNodeVectorTransform"), NodeItem("ShaderNodeNormalMap"), - ]), + ]), ShaderOldNodeCategory("SH_CONVERTOR", "Converter", items=[ NodeItem("ShaderNodeValToRGB"), NodeItem("ShaderNodeRGBToBW"), @@ -188,12 +189,12 @@ shader_node_categories = [ NodeItem("ShaderNodeCombineRGB"), NodeItem("ShaderNodeSeparateHSV"), NodeItem("ShaderNodeCombineHSV"), - ]), + ]), ShaderOldNodeCategory("SH_GROUP", "Group", items=node_group_items), ShaderOldNodeCategory("SH_LAYOUT", "Layout", items=[ NodeItem("NodeFrame"), NodeItem("NodeReroute"), - ]), + ]), # New Shader Nodes (Cycles) ShaderNewNodeCategory("SH_NEW_INPUT", "Input", items=[ @@ -216,14 +217,14 @@ shader_node_categories = [ NodeItem("ShaderNodeUVMap"), NodeItem("ShaderNodeUVAlongStroke", poll=line_style_shader_nodes_poll), NodeItem("NodeGroupInput", poll=group_input_output_item_poll), - ]), + ]), ShaderNewNodeCategory("SH_NEW_OUTPUT", "Output", items=[ NodeItem("ShaderNodeOutputMaterial", poll=object_shader_nodes_poll), NodeItem("ShaderNodeOutputLamp", poll=object_shader_nodes_poll), NodeItem("ShaderNodeOutputWorld", poll=world_shader_nodes_poll), NodeItem("ShaderNodeOutputLineStyle", poll=line_style_shader_nodes_poll), NodeItem("NodeGroupOutput", poll=group_input_output_item_poll), - ]), + ]), ShaderNewNodeCategory("SH_NEW_SHADER", "Shader", items=[ NodeItem("ShaderNodeMixShader"), NodeItem("ShaderNodeAddShader"), @@ -245,7 +246,7 @@ shader_node_categories = [ NodeItem("ShaderNodeVolumeAbsorption"), NodeItem("ShaderNodeVolumeScatter"), NodeItem("ShaderNodeVolumePrincipled"), - ]), + ]), ShaderNewNodeCategory("SH_NEW_TEXTURE", "Texture", items=[ NodeItem("ShaderNodeTexImage"), NodeItem("ShaderNodeTexEnvironment"), @@ -260,7 +261,7 @@ shader_node_categories = [ NodeItem("ShaderNodeTexBrick"), NodeItem("ShaderNodeTexPointDensity"), NodeItem("ShaderNodeTexIES"), - ]), + ]), ShaderNewNodeCategory("SH_NEW_OP_COLOR", "Color", items=[ NodeItem("ShaderNodeMixRGB"), NodeItem("ShaderNodeRGBCurve"), @@ -269,7 +270,7 @@ shader_node_categories = [ NodeItem("ShaderNodeHueSaturation"), NodeItem("ShaderNodeGamma"), NodeItem("ShaderNodeBrightContrast"), - ]), + ]), ShaderNewNodeCategory("SH_NEW_OP_VECTOR", "Vector", items=[ NodeItem("ShaderNodeMapping"), NodeItem("ShaderNodeBump"), @@ -279,7 +280,7 @@ shader_node_categories = [ NodeItem("ShaderNodeNormal"), NodeItem("ShaderNodeVectorCurve"), NodeItem("ShaderNodeVectorTransform"), - ]), + ]), ShaderNewNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[ NodeItem("ShaderNodeMath"), NodeItem("ShaderNodeValToRGB"), @@ -293,16 +294,16 @@ shader_node_categories = [ NodeItem("ShaderNodeCombineHSV"), NodeItem("ShaderNodeWavelength"), NodeItem("ShaderNodeBlackbody"), - ]), + ]), ShaderNewNodeCategory("SH_NEW_SCRIPT", "Script", items=[ NodeItem("ShaderNodeScript"), - ]), + ]), ShaderNewNodeCategory("SH_NEW_GROUP", "Group", items=node_group_items), ShaderNewNodeCategory("SH_NEW_LAYOUT", "Layout", items=[ NodeItem("NodeFrame"), NodeItem("NodeReroute"), - ]), - ] + ]), +] compositor_node_categories = [ # Compositor Nodes @@ -318,7 +319,7 @@ compositor_node_categories = [ NodeItem("CompositorNodeTime"), NodeItem("CompositorNodeTrackPos"), NodeItem("NodeGroupInput", poll=group_input_output_item_poll), - ]), + ]), CompositorNodeCategory("CMP_OUTPUT", "Output", items=[ NodeItem("CompositorNodeComposite"), NodeItem("CompositorNodeViewer"), @@ -326,7 +327,7 @@ compositor_node_categories = [ NodeItem("CompositorNodeOutputFile"), NodeItem("CompositorNodeLevels"), NodeItem("NodeGroupOutput", poll=group_input_output_item_poll), - ]), + ]), CompositorNodeCategory("CMP_OP_COLOR", "Color", items=[ NodeItem("CompositorNodeMixRGB"), NodeItem("CompositorNodeAlphaOver"), @@ -340,7 +341,7 @@ compositor_node_categories = [ NodeItem("CompositorNodeColorCorrection"), NodeItem("CompositorNodeTonemap"), NodeItem("CompositorNodeZcombine"), - ]), + ]), CompositorNodeCategory("CMP_CONVERTOR", "Converter", items=[ NodeItem("CompositorNodeMath"), NodeItem("CompositorNodeValToRGB"), @@ -357,7 +358,7 @@ compositor_node_categories = [ NodeItem("CompositorNodeSepYCCA"), NodeItem("CompositorNodeCombYCCA"), NodeItem("CompositorNodeSwitchView"), - ]), + ]), CompositorNodeCategory("CMP_OP_FILTER", "Filter", items=[ NodeItem("CompositorNodeBlur"), NodeItem("CompositorNodeBilateralblur"), @@ -372,14 +373,14 @@ compositor_node_categories = [ NodeItem("CompositorNodeDBlur"), NodeItem("CompositorNodePixelate"), NodeItem("CompositorNodeSunBeams"), - ]), + ]), CompositorNodeCategory("CMP_OP_VECTOR", "Vector", items=[ NodeItem("CompositorNodeNormal"), NodeItem("CompositorNodeMapValue"), NodeItem("CompositorNodeMapRange"), NodeItem("CompositorNodeNormalize"), NodeItem("CompositorNodeCurveVec"), - ]), + ]), CompositorNodeCategory("CMP_MATTE", "Matte", items=[ NodeItem("CompositorNodeKeying"), NodeItem("CompositorNodeKeyingScreen"), @@ -393,7 +394,7 @@ compositor_node_categories = [ NodeItem("CompositorNodeChromaMatte"), NodeItem("CompositorNodeColorMatte"), NodeItem("CompositorNodeDoubleEdgeMask"), - ]), + ]), CompositorNodeCategory("CMP_DISTORT", "Distort", items=[ NodeItem("CompositorNodeScale"), NodeItem("CompositorNodeLensdist"), @@ -408,14 +409,14 @@ compositor_node_categories = [ NodeItem("CompositorNodeStabilize"), NodeItem("CompositorNodePlaneTrackDeform"), NodeItem("CompositorNodeCornerPin"), - ]), + ]), CompositorNodeCategory("CMP_GROUP", "Group", items=node_group_items), CompositorNodeCategory("CMP_LAYOUT", "Layout", items=[ NodeItem("NodeFrame"), NodeItem("NodeReroute"), NodeItem("CompositorNodeSwitch"), - ]), - ] + ]), +] texture_node_categories = [ # Texture Nodes @@ -425,12 +426,12 @@ texture_node_categories = [ NodeItem("TextureNodeTexture"), NodeItem("TextureNodeImage"), NodeItem("NodeGroupInput", poll=group_input_output_item_poll), - ]), + ]), TextureNodeCategory("TEX_OUTPUT", "Output", items=[ NodeItem("TextureNodeOutput"), NodeItem("TextureNodeViewer"), NodeItem("NodeGroupOutput", poll=group_input_output_item_poll), - ]), + ]), TextureNodeCategory("TEX_OP_COLOR", "Color", items=[ NodeItem("TextureNodeMixRGB"), NodeItem("TextureNodeCurveRGB"), @@ -438,11 +439,11 @@ texture_node_categories = [ NodeItem("TextureNodeHueSaturation"), NodeItem("TextureNodeCompose"), NodeItem("TextureNodeDecompose"), - ]), + ]), TextureNodeCategory("TEX_PATTERN", "Pattern", items=[ NodeItem("TextureNodeChecker"), NodeItem("TextureNodeBricks"), - ]), + ]), TextureNodeCategory("TEX_TEXTURE", "Textures", items=[ NodeItem("TextureNodeTexNoise"), NodeItem("TextureNodeTexDistNoise"), @@ -454,26 +455,26 @@ texture_node_categories = [ NodeItem("TextureNodeTexWood"), NodeItem("TextureNodeTexMusgrave"), NodeItem("TextureNodeTexStucci"), - ]), + ]), TextureNodeCategory("TEX_CONVERTOR", "Converter", items=[ NodeItem("TextureNodeMath"), NodeItem("TextureNodeValToRGB"), NodeItem("TextureNodeRGBToBW"), NodeItem("TextureNodeValToNor"), NodeItem("TextureNodeDistance"), - ]), + ]), TextureNodeCategory("TEX_DISTORT", "Distort", items=[ NodeItem("TextureNodeScale"), NodeItem("TextureNodeTranslate"), NodeItem("TextureNodeRotate"), NodeItem("TextureNodeAt"), - ]), + ]), TextureNodeCategory("TEX_GROUP", "Group", items=node_group_items), TextureNodeCategory("TEX_LAYOUT", "Layout", items=[ NodeItem("NodeFrame"), NodeItem("NodeReroute"), - ]), - ] + ]), +] def register(): -- cgit v1.2.3 From 8c15d612a5cdfe39233c7f2b7556742091c82558 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 06:47:49 +0200 Subject: Cleanup: pep8 --- doc/blender_file_format/BlendFileDnaExporter_25.py | 168 ++++++++++----------- doc/blender_file_format/BlendFileReader.py | 126 ++++++++-------- doc/manpage/blender.1.py | 1 + doc/python_api/sphinx_doc_gen.py | 7 +- source/blender/datatoc/datatoc_icon_split.py | 86 ++++++----- .../blender/datatoc/datatoc_icon_split_to_png.py | 1 + source/blender/makesrna/rna_cleanup/rna_cleaner.py | 105 +++++++------ .../makesrna/rna_cleanup/rna_cleaner_merge.py | 78 +++++----- source/blender/python/rna_dump.py | 5 +- source/blender/python/simple_enum_gen.py | 6 +- tests/check_deprecated.py | 1 + tests/python/alembic_tests.py | 1 - tests/python/bl_alembic_import_test.py | 1 - tests/python/bl_load_addons.py | 9 +- tests/python/bl_load_py_modules.py | 11 +- tests/python/bl_mesh_modifiers.py | 165 +++++++++++--------- tests/python/bl_mesh_validate.py | 46 +++--- tests/python/bl_pyapi_bpy_utils_units.py | 39 ++--- tests/python/bl_pyapi_idprop.py | 1 + tests/python/bl_pyapi_idprop_datablock.py | 7 +- tests/python/bl_pyapi_mathutils.py | 27 ++-- tests/python/bl_rna_defaults.py | 3 +- tests/python/bl_rna_manual_reference.py | 1 + tests/python/bl_run_operators.py | 14 +- .../collada/animation/test_animation_simple.py | 53 ++++--- tests/python/collada/mesh/test_mesh_simple.py | 27 ++-- tests/python/modules/render_report.py | 18 +-- tests/python/modules/test_utils.py | 3 +- tests/python/opengl_draw_tests.py | 3 + tests/python/pep8.py | 7 +- tests/python/rna_array.py | 76 ++++++---- 31 files changed, 602 insertions(+), 494 deletions(-) diff --git a/doc/blender_file_format/BlendFileDnaExporter_25.py b/doc/blender_file_format/BlendFileDnaExporter_25.py index 64c92c7cf80..a9da79f04d8 100755 --- a/doc/blender_file_format/BlendFileDnaExporter_25.py +++ b/doc/blender_file_format/BlendFileDnaExporter_25.py @@ -7,7 +7,7 @@ # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, +# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. @@ -22,21 +22,21 @@ # # Name: # dna.py -# +# # Description: # Creates a browsable DNA output to HTML. -# +# # Author: # Jeroen Bakker -# +# # Version: # v0.1 (12-05-2009) - migration of original source code to python. # Added code to support blender 2.5 branch # v0.2 (25-05-2009) - integrated with BlendFileReader.py -# +# # Input: # blender build executable -# +# # Output: # dna.html # dna.css (will only be created when not existing) @@ -76,12 +76,12 @@ class DNACatalogHTML: DNACatalog is a catalog of all information in the DNA1 file-block ''' - def __init__(self, catalog, bpy_module = None): + def __init__(self, catalog, bpy_module=None): self.Catalog = catalog self.bpy = bpy_module - + def WriteToHTML(self, handle): - + dna_html_template = """ @@ -105,10 +105,10 @@ class DNACatalogHTML: ${structs_content} """ - + header = self.Catalog.Header bpy = self.bpy - + # ${version} and ${revision} if bpy: version = '.'.join(map(str, bpy.app.version)) @@ -116,7 +116,7 @@ class DNACatalogHTML: else: version = str(header.Version) revision = 'Unknown' - + # ${bitness} if header.PointerSize == 8: bitness = '64 bit' @@ -125,10 +125,10 @@ class DNACatalogHTML: # ${endianness} if header.LittleEndianness: - endianess= 'Little endianness' + endianess = 'Little endianness' else: - endianess= 'Big endianness' - + endianess = 'Big endianness' + # ${structs_list} log.debug("Creating structs index") structs_list = '' @@ -136,7 +136,7 @@ class DNACatalogHTML: structureIndex = 0 for structure in self.Catalog.Structs: structs_list += list_item.format(structureIndex, structure.Type.Name) - structureIndex+=1 + structureIndex += 1 # ${structs_content} log.debug("Creating structs content") @@ -144,20 +144,20 @@ class DNACatalogHTML: for structure in self.Catalog.Structs: log.debug(structure.Type.Name) structs_content += self.Structure(structure) - + d = dict( - version = version, - revision = revision, - bitness = bitness, - endianness = endianess, - structs_list = structs_list, - structs_content = structs_content + version=version, + revision=revision, + bitness=bitness, + endianness=endianess, + structs_list=structs_list, + structs_content=structs_content ) dna_html = Template(dna_html_template).substitute(d) dna_html = self.format(dna_html) handle.write(dna_html) - + def Structure(self, structure): struct_table_template = """ @@ -178,23 +178,23 @@ class DNACatalogHTML:


""" - + d = dict( - struct_name = structure.Type.Name, - fields = self.StructureFields(structure, None, 0), - size = str(structure.Type.Size) + struct_name=structure.Type.Name, + fields=self.StructureFields(structure, None, 0), + size=str(structure.Type.Size) ) - + struct_table = Template(struct_table_template).substitute(d) return struct_table - + def StructureFields(self, structure, parentReference, offset): fields = '' for field in structure.Fields: fields += self.StructureField(field, structure, parentReference, offset) offset += field.Size(self.Catalog.Header) return fields - + def StructureField(self, field, structure, parentReference, offset): structure_field_template = """ @@ -205,7 +205,7 @@ class DNACatalogHTML: ${offset} ${size} """ - + if field.Type.Structure is None or field.Name.IsPointer(): # ${reference} @@ -216,37 +216,37 @@ class DNACatalogHTML: struct = '{0}'.format(structure.Type.Name) else: struct = structure.Type.Name - + # ${type} type = field.Type.Name - + # ${name} name = field.Name.Name - + # ${offset} # offset already set - + # ${size} size = field.Size(self.Catalog.Header) - + d = dict( - reference = reference, - struct = struct, - type = type, - name = name, - offset = offset, - size = size + reference=reference, + struct=struct, + type=type, + name=name, + offset=offset, + size=size ) - + structure_field = Template(structure_field_template).substitute(d) - + elif field.Type.Structure is not None: reference = field.Name.AsReference(parentReference) - structure_field = self.StructureFields(field.Type.Structure, reference, offset) + structure_field = self.StructureFields(field.Type.Structure, reference, offset) return structure_field - def indent(self, input, dent, startswith = ''): + def indent(self, input, dent, startswith=''): output = '' if dent < 0: for line in input.split('\n'): @@ -257,19 +257,19 @@ class DNACatalogHTML: output += line.lstrip() + '\n' # remove indentation completely elif dent > 0: for line in input.split('\n'): - output += ' '* dent + line + '\n' + output += ' ' * dent + line + '\n' return output - + def format(self, input): diff = { - '\n' :'', - '\n' :'', - '' :' ', - '\n' :'', - '\n' :'', - '\n' :'' + '\n': '', + '\n': '', + '': ' ', + '\n': '', + '\n': '', + '\n': '' } output = self.indent(input, 0) for key, value in diff.items(): @@ -283,17 +283,17 @@ class DNACatalogHTML: ''' css = """ @CHARSET "ISO-8859-1"; - + body { font-family: verdana; font-size: small; } - + div.title { font-size: large; text-align: center; } - + h1 { page-break-before: always; } @@ -304,7 +304,7 @@ class DNACatalogHTML: margin-right: 3%; padding-left: 40px; } - + h1:hover{ background-color: #EBEBEB; } @@ -312,7 +312,7 @@ class DNACatalogHTML: h3 { padding-left: 40px; } - + table { border-width: 1px; border-style: solid; @@ -321,21 +321,21 @@ class DNACatalogHTML: width: 94%; margin: 20px 3% 10px; } - + caption { margin-bottom: 5px; } - + th { background-color: #000000; color:#ffffff; padding-left:5px; padding-right:5px; } - + tr { } - + td { border-width: 1px; border-style: solid; @@ -343,12 +343,12 @@ class DNACatalogHTML: padding-left:5px; padding-right:5px; } - + label { float:right; margin-right: 3%; } - + ul.multicolumn { list-style:none; float:left; @@ -361,18 +361,18 @@ class DNACatalogHTML: width:200px; margin-right:0px; } - + a { color:#a000a0; text-decoration:none; } - + a:hover { color:#a000a0; text-decoration:underline; } """ - + css = self.indent(css, 0) handle.write(css) @@ -389,13 +389,13 @@ def usage(): print("\tdefault: % blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py") print("\twith options: % blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py -- --dna-keep-blend --dna-debug\n") - + ###################################################### # Main ###################################################### def main(): - + import os, os.path try: @@ -408,37 +408,37 @@ def main(): else: filename = 'dna' dir = os.path.dirname(__file__) - Path_Blend = os.path.join(dir, filename + '.blend') # temporary blend file - Path_HTML = os.path.join(dir, filename + '.html') # output html file - Path_CSS = os.path.join(dir, 'dna.css') # output css file + Path_Blend = os.path.join(dir, filename + '.blend') # temporary blend file + Path_HTML = os.path.join(dir, filename + '.html') # output html file + Path_CSS = os.path.join(dir, 'dna.css') # output css file # create a blend file for dna parsing if not os.path.exists(Path_Blend): log.info("1: write temp blend file with SDNA info") log.info(" saving to: " + Path_Blend) try: - bpy.ops.wm.save_as_mainfile(filepath = Path_Blend, copy = True, compress = False) + bpy.ops.wm.save_as_mainfile(filepath=Path_Blend, copy=True, compress=False) except: log.error("Filename {0} does not exist and can't be created... quitting".format(Path_Blend)) return else: log.info("1: found blend file with SDNA info") log.info(" " + Path_Blend) - + # read blend header from blend file log.info("2: read file:") - + if not dir in sys.path: sys.path.append(dir) import BlendFileReader - + handle = BlendFileReader.openBlendFile(Path_Blend) blendfile = BlendFileReader.BlendFile(handle) catalog = DNACatalogHTML(blendfile.Catalog, bpy) # close temp file handle.close() - + # deleting or not? if '--dna-keep-blend' in sys.argv: # keep the blend, useful for studying hexdumps @@ -449,7 +449,7 @@ def main(): log.info("5: close and delete temp blend:") log.info(" {0}".format(Path_Blend)) os.remove(Path_Blend) - + # export dna to xhtml log.info("6: export sdna to xhtml file: %r" % Path_HTML) handleHTML = open(Path_HTML, "w") @@ -466,12 +466,12 @@ def main(): if not bpy.app.background: log.info("7: quit blender") bpy.ops.wm.exit_blender() - + except ImportError: log.warning(" skipping, not running in Blender") usage() sys.exit(2) - + if __name__ == '__main__': main() diff --git a/doc/blender_file_format/BlendFileReader.py b/doc/blender_file_format/BlendFileReader.py index a4d2f494c5b..d4aed722578 100644 --- a/doc/blender_file_format/BlendFileReader.py +++ b/doc/blender_file_format/BlendFileReader.py @@ -7,7 +7,7 @@ # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, +# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. @@ -34,6 +34,7 @@ log = logging.getLogger("BlendFileReader") # module global routines ###################################################### + def ReadString(handle, length): ''' ReadString reads a String of given length or a zero terminating String @@ -45,7 +46,7 @@ def ReadString(handle, length): # length == 0 means we want a zero terminating string result = "" s = ReadString(handle, 1) - while s!="\0": + while s != "\0": result += s s = ReadString(handle, 1) return result @@ -57,7 +58,7 @@ def Read(type, handle, fileheader): ''' def unpacked_bytes(type_char, size): return struct.unpack(fileheader.StructPre + type_char, handle.read(size))[0] - + if type == 'ushort': return unpacked_bytes("H", 2) # unsigned short elif type == 'short': @@ -94,10 +95,10 @@ def openBlendFile(filename): log.debug("decompressing started") fs = gzip.open(filename, "rb") handle = tempfile.TemporaryFile() - data = fs.read(1024*1024) - while data: - handle.write(data) - data = fs.read(1024*1024) + data = fs.read(1024 * 1024) + while data: + handle.write(data) + data = fs.read(1024 * 1024) log.debug("decompressing finished") fs.close() log.debug("resetting decompressed file") @@ -112,7 +113,7 @@ def Align(handle): offset = handle.tell() trim = offset % 4 if trim != 0: - handle.seek(4-trim, os.SEEK_CUR) + handle.seek(4 - trim, os.SEEK_CUR) ###################################################### @@ -121,14 +122,14 @@ def Align(handle): class BlendFile: ''' - Reads a blendfile and store the header, all the fileblocks, and catalogue + Reads a blendfile and store the header, all the fileblocks, and catalogue structs foound in the DNA fileblock - + - BlendFile.Header (BlendFileHeader instance) - BlendFile.Blocks (list of BlendFileBlock instances) - BlendFile.Catalog (DNACatalog instance) ''' - + def __init__(self, handle): log.debug("initializing reading blend-file") self.Header = BlendFileHeader(handle) @@ -141,13 +142,13 @@ class BlendFile: found_dna_block = True else: fileblock.Header.skip(handle) - + self.Blocks.append(fileblock) fileblock = BlendFileBlock(handle, self) - + # appending last fileblock, "ENDB" self.Blocks.append(fileblock) - + # seems unused? """ def FindBlendFileBlocksWithCode(self, code): @@ -164,27 +165,27 @@ class BlendFileHeader: BlendFileHeader allocates the first 12 bytes of a blend file. It contains information about the hardware architecture. Header example: BLENDER_v254 - + BlendFileHeader.Magic (str) BlendFileHeader.PointerSize (int) BlendFileHeader.LittleEndianness (bool) BlendFileHeader.StructPre (str) see http://docs.python.org/py3k/library/struct.html#byte-order-size-and-alignment BlendFileHeader.Version (int) ''' - + def __init__(self, handle): log.debug("reading blend-file-header") - + self.Magic = ReadString(handle, 7) log.debug(self.Magic) - + pointersize = ReadString(handle, 1) log.debug(pointersize) if pointersize == "-": self.PointerSize = 8 if pointersize == "_": self.PointerSize = 4 - + endianness = ReadString(handle, 1) log.debug(endianness) if endianness == "v": @@ -193,11 +194,11 @@ class BlendFileHeader: if endianness == "V": self.LittleEndianness = False self.StructPre = ">" - + version = ReadString(handle, 3) log.debug(version) self.Version = int(version) - + log.debug("{0} {1} {2} {3}".format(self.Magic, self.PointerSize, self.LittleEndianness, version)) @@ -206,11 +207,11 @@ class BlendFileBlock: BlendFileBlock.File (BlendFile) BlendFileBlock.Header (FileBlockHeader) ''' - + def __init__(self, handle, blendfile): self.File = blendfile self.Header = FileBlockHeader(handle, blendfile.Header) - + def Get(self, handle, path): log.debug("find dna structure") dnaIndex = self.Header.SDNAIndex @@ -232,7 +233,7 @@ class FileBlockHeader: Count (int) FileOffset (= file pointer of datablock) ''' - + def __init__(self, handle, fileheader): self.Code = ReadString(handle, 4).strip() if self.Code != "ENDB": @@ -257,28 +258,28 @@ class FileBlockHeader: class DNACatalog: ''' DNACatalog is a catalog of all information in the DNA1 file-block - + Header = None Names = None Types = None Structs = None ''' - + def __init__(self, fileheader, handle): log.debug("building DNA catalog") - self.Names=[] - self.Types=[] - self.Structs=[] + self.Names = [] + self.Types = [] + self.Structs = [] self.Header = fileheader - + SDNA = ReadString(handle, 4) - + # names NAME = ReadString(handle, 4) numberOfNames = Read('uint', handle, fileheader) log.debug("building #{0} names".format(numberOfNames)) for i in range(numberOfNames): - name = ReadString(handle,0) + name = ReadString(handle, 0) self.Names.append(DNAName(name)) Align(handle) @@ -287,7 +288,7 @@ class DNACatalog: numberOfTypes = Read('uint', handle, fileheader) log.debug("building #{0} types".format(numberOfTypes)) for i in range(numberOfTypes): - type = ReadString(handle,0) + type = ReadString(handle, 0) self.Types.append(DNAType(type)) Align(handle) @@ -321,24 +322,24 @@ class DNACatalog: class DNAName: ''' DNAName is a C-type name stored in the DNA. - + Name = str ''' - + def __init__(self, name): self.Name = name - + def AsReference(self, parent): if parent is None: result = "" else: - result = parent+"." - + result = parent + "." + result = result + self.ShortName() return result def ShortName(self): - result = self.Name; + result = self.Name result = result.replace("*", "") result = result.replace("(", "") result = result.replace(")", "") @@ -346,12 +347,12 @@ class DNAName: if Index != -1: result = result[0:Index] return result - + def IsPointer(self): - return self.Name.find("*")>-1 + return self.Name.find("*") > -1 def IsMethodPointer(self): - return self.Name.find("(*")>-1 + return self.Name.find("(*") > -1 def ArraySize(self): result = 1 @@ -360,10 +361,10 @@ class DNAName: while Index != -1: Index2 = Temp.find("]") - result*=int(Temp[Index+1:Index2]) - Temp = Temp[Index2+1:] + result *= int(Temp[Index + 1:Index2]) + Temp = Temp[Index2 + 1:] Index = Temp.find("[") - + return result @@ -375,46 +376,46 @@ class DNAType: Size = int Structure = DNAStructure ''' - + def __init__(self, aName): self.Name = aName - self.Structure=None + self.Structure = None class DNAStructure: ''' DNAType is a C-type structure stored in the DNA - + Type = DNAType Fields = [DNAField] ''' - + def __init__(self, aType): self.Type = aType self.Type.Structure = self - self.Fields=[] - + self.Fields = [] + def GetField(self, header, handle, path): splitted = path.partition(".") name = splitted[0] rest = splitted[2] - offset = 0; + offset = 0 for field in self.Fields: if field.Name.ShortName() == name: - log.debug("found "+name+"@"+str(offset)) + log.debug("found " + name + "@" + str(offset)) handle.seek(offset, os.SEEK_CUR) return field.DecodeField(header, handle, rest) else: offset += field.Size(header) - log.debug("error did not find "+path) + log.debug("error did not find " + path) return None class DNAField: ''' DNAField is a coupled DNAType and DNAName. - + Type = DNAType Name = DNAName ''' @@ -422,25 +423,24 @@ class DNAField: def __init__(self, aType, aName): self.Type = aType self.Name = aName - + def Size(self, header): if self.Name.IsPointer() or self.Name.IsMethodPointer(): - return header.PointerSize*self.Name.ArraySize() + return header.PointerSize * self.Name.ArraySize() else: - return self.Type.Size*self.Name.ArraySize() + return self.Type.Size * self.Name.ArraySize() def DecodeField(self, header, handle, path): if path == "": if self.Name.IsPointer(): return Read('pointer', handle, header) - if self.Type.Name=="int": + if self.Type.Name == "int": return Read('int', handle, header) - if self.Type.Name=="short": + if self.Type.Name == "short": return Read('short', handle, header) - if self.Type.Name=="float": + if self.Type.Name == "float": return Read('float', handle, header) - if self.Type.Name=="char": + if self.Type.Name == "char": return ReadString(handle, self.Name.ArraySize()) else: return self.Type.Structure.GetField(header, handle, path) - diff --git a/doc/manpage/blender.1.py b/doc/manpage/blender.1.py index 52856717b4a..0890547906a 100755 --- a/doc/manpage/blender.1.py +++ b/doc/manpage/blender.1.py @@ -42,6 +42,7 @@ def man_format(data): data = data.replace("\t", " ") return data + if len(sys.argv) != 3: import getopt raise getopt.GetoptError("Usage: %s " % sys.argv[0]) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 50b07cabff4..93ffad12bd6 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -73,6 +73,8 @@ def rna_info_BuildRNAInfo_cache(): if rna_info_BuildRNAInfo_cache.ret is None: rna_info_BuildRNAInfo_cache.ret = rna_info.BuildRNAInfo() return rna_info_BuildRNAInfo_cache.ret + + rna_info_BuildRNAInfo_cache.ret = None # --- end rna_info cache @@ -431,7 +433,7 @@ else: BLENDER_VERSION_DOTS = ".".join(blender_version_strings) if BLENDER_REVISION != "Unknown": # '2.62a SHA1' (release) or '2.62.1 SHA1' (non-release) - BLENDER_VERSION_DOTS += " " + BLENDER_REVISION + BLENDER_VERSION_DOTS += " " + BLENDER_REVISION if is_release: # '2_62a_release' @@ -513,6 +515,8 @@ def escape_rst(text): """ Escape plain text which may contain characters used by RST. """ return text.translate(escape_rst.trans) + + escape_rst.trans = str.maketrans({ "`": "\\`", "|": "\\|", @@ -1015,6 +1019,7 @@ def pymodule2sphinx(basepath, module_name, module, title): file.close() + # Changes in Blender will force errors here context_type_map = { "active_base": ("ObjectBase", False), diff --git a/source/blender/datatoc/datatoc_icon_split.py b/source/blender/datatoc/datatoc_icon_split.py index aae907ec340..faf8d57be77 100755 --- a/source/blender/datatoc/datatoc_icon_split.py +++ b/source/blender/datatoc/datatoc_icon_split.py @@ -68,7 +68,7 @@ def image_from_file(filepath): if bpy is not None: pixels, pixel_w, pixel_h = image_from_file__bpy(filepath) - #else: + # else: # pixels, pixel_w, pixel_h = image_from_file__py(filepath) return pixels, pixel_w, pixel_h @@ -95,12 +95,14 @@ def write_subimage(sub_x, sub_y, sub_w, sub_h, with open(filepath, 'wb') as f: - f.write(struct.pack('<6I', + f.write( + struct.pack( + '<6I', sub_w, sub_h, sub_x, sub_y, # redundant but including to maintain consistency - pixel_w, pixel_h, - )) + pixel_w, pixel_h, + )) for y in range(sub_h): for x in range(sub_w): @@ -113,8 +115,9 @@ def write_subimage(sub_x, sub_y, sub_w, sub_h, _dice_icon_name_cache = {} -def dice_icon_name(x, y, parts_x, parts_y, - name_style=None, prefix=""): +def dice_icon_name( + x, y, parts_x, parts_y, + name_style=None, prefix=""): """ How to name icons, this is mainly for what name we get in git, the actual names don't really matter, its just nice to have the @@ -143,7 +146,7 @@ def dice_icon_name(x, y, parts_x, parts_y, icon_name = _dice_icon_name_cache[index] # for debugging its handy to sort by number - #~ id_str = "%03d_%s%s.dat" % (index, prefix, icon_name) + # ~ id_str = "%03d_%s%s.dat" % (index, prefix, icon_name) id_str = "%s%s.dat" % (prefix, icon_name) @@ -158,16 +161,18 @@ def dice_icon_name(x, y, parts_x, parts_y, return id_str -def dice(filepath, output, output_prefix, name_style, - parts_x, parts_y, - minx, miny, maxx, maxy, - minx_icon, miny_icon, maxx_icon, maxy_icon, - spacex_icon, spacey_icon, - ): +def dice( + filepath, output, output_prefix, name_style, + parts_x, parts_y, + minx, miny, maxx, maxy, + minx_icon, miny_icon, maxx_icon, maxy_icon, + spacex_icon, spacey_icon, +): - is_simple = (max(minx, miny, maxx, maxy, - minx_icon, miny_icon, maxx_icon, maxy_icon, - spacex_icon, spacey_icon) == 0) + is_simple = (max( + minx, miny, maxx, maxy, + minx_icon, miny_icon, maxx_icon, maxy_icon, + spacex_icon, spacey_icon) == 0) pixels, pixel_w, pixel_h = image_from_file(filepath) @@ -199,9 +204,11 @@ def dice(filepath, output, output_prefix, name_style, for x in range(parts_x): for y in range(parts_y): - id_str = dice_icon_name(x, y, - parts_x, parts_y, - name_style=name_style, prefix=output_prefix) + id_str = dice_icon_name( + x, y, + parts_x, parts_y, + name_style=name_style, prefix=output_prefix + ) filepath = os.path.join(output, id_str) if VERBOSE: print(" writing:", filepath) @@ -235,25 +242,35 @@ def main(): parser = argparse.ArgumentParser(description=__doc__, epilog=epilog) # File path options - parser.add_argument("--image", dest="image", metavar='FILE', - help="Image file") - - parser.add_argument("--output", dest="output", metavar='DIR', - help="Output directory") - - parser.add_argument("--output_prefix", dest="output_prefix", metavar='STRING', - help="Output prefix") + parser.add_argument( + "--image", dest="image", metavar='FILE', + help="Image file", + ) + parser.add_argument( + "--output", dest="output", metavar='DIR', + help="Output directory", + ) + parser.add_argument( + "--output_prefix", dest="output_prefix", metavar='STRING', + help="Output prefix", + ) # Icon naming option - parser.add_argument("--name_style", dest="name_style", metavar='ENUM', type=str, - choices=('', 'UI_ICONS'), - help="The metod used for naming output data") + parser.add_argument( + "--name_style", dest="name_style", metavar='ENUM', type=str, + choices=('', 'UI_ICONS'), + help="The metod used for naming output data", + ) # Options for dicing up the image - parser.add_argument("--parts_x", dest="parts_x", metavar='INT', type=int, - help="Grid X parts") - parser.add_argument("--parts_y", dest="parts_y", metavar='INT', type=int, - help="Grid Y parts") + parser.add_argument( + "--parts_x", dest="parts_x", metavar='INT', type=int, + help="Grid X parts", + ) + parser.add_argument( + "--parts_y", dest="parts_y", metavar='INT', type=int, + help="Grid Y parts", + ) _help = "Inset from the outer edge (in pixels)" parser.add_argument("--minx", dest="minx", metavar='INT', type=int, help=_help) @@ -287,5 +304,6 @@ def main(): args.spacex_icon, args.spacey_icon, ) + if __name__ == "__main__": main() diff --git a/source/blender/datatoc/datatoc_icon_split_to_png.py b/source/blender/datatoc/datatoc_icon_split_to_png.py index 39bbf1110fb..b583b10b9ff 100755 --- a/source/blender/datatoc/datatoc_icon_split_to_png.py +++ b/source/blender/datatoc/datatoc_icon_split_to_png.py @@ -67,5 +67,6 @@ def main(): icondata_to_png(file_src, file_dst) + if __name__ == "__main__": main() diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner.py b/source/blender/makesrna/rna_cleanup/rna_cleaner.py index f1cd46f3d57..a936e6499bc 100755 --- a/source/blender/makesrna/rna_cleanup/rna_cleaner.py +++ b/source/blender/makesrna/rna_cleanup/rna_cleaner.py @@ -56,19 +56,19 @@ def check_commandline(): """ import sys # Usage - if len(sys.argv)==1 or len(sys.argv)>3: + if len(sys.argv) == 1 or len(sys.argv) > 3: usage() if sys.argv[1] == '-h': help() elif not sys.argv[1].endswith((".txt", ".py")): - print ('\nBad input file extension... exiting.') + print('\nBad input file extension... exiting.') usage() else: inputfile = sys.argv[1] if len(sys.argv) == 2: sort_priority = default_sort_choice - print ('\nSecond parameter missing: choosing to order by %s.' % font_bold(sort_priority)) - elif len(sys.argv)==3: + print('\nSecond parameter missing: choosing to order by %s.' % font_bold(sort_priority)) + elif len(sys.argv) == 3: sort_priority = sys.argv[2] if sort_priority not in sort_choices: print('\nWrong sort_priority... exiting.') @@ -93,9 +93,11 @@ def check_prefix(prop, btype): return "" -def check_if_changed(a,b): - if a != b: return 'changed' - else: return 'same' +def check_if_changed(a, b): + if a != b: + return 'changed' + else: + return 'same' def get_props_from_txt(input_filename): @@ -103,12 +105,12 @@ def get_props_from_txt(input_filename): If the file is *.txt, the script assumes it is formatted as outlined in this script docstring """ - file=open(input_filename,'r') - file_lines=file.readlines() + file = open(input_filename, 'r') + file_lines = file.readlines() file.close() - props_list=[] - props_length_max=[0,0,0,0,0,0,0,0] + props_list = [] + props_length_max = [0, 0, 0, 0, 0, 0, 0, 0] done_text = "+" done = 0 @@ -117,7 +119,7 @@ def get_props_from_txt(input_filename): for iii, line in enumerate(file_lines): # debug - #print(line) + # print(line) line_strip = line.strip() # empty line or comment if not line_strip: @@ -136,7 +138,7 @@ def get_props_from_txt(input_filename): if '*' in bclass: comment, bclass = [x.strip() for x in bclass.split('*', 1)] else: - comment= '' + comment = '' # skipping the header if we have one. # the header is assumed to be "NOTE * CLASS.FROM -> TO: TYPE DESCRIPTION" @@ -155,7 +157,7 @@ def get_props_from_txt(input_filename): # make life easy and strip quotes description = description.replace("'", "").replace('"', "").replace("\\", "").strip() except ValueError: - btype, description = [tail,'NO DESCRIPTION'] + btype, description = [tail, 'NO DESCRIPTION'] # keyword-check kwcheck = check_prefix(bto, btype) @@ -164,17 +166,17 @@ def get_props_from_txt(input_filename): changed = check_if_changed(bfrom, bto) # lists formatting - props=[comment, changed, bclass, bfrom, bto, kwcheck, btype, description] + props = [comment, changed, bclass, bfrom, bto, kwcheck, btype, description] props_list.append(props) - props_length_max=list(map(max,zip(props_length_max,list(map(len,props))))) + props_length_max = list(map(max, zip(props_length_max, list(map(len, props))))) if done_text in comment: done += 1 tot += 1 - print("Total done %.2f" % (done / tot * 100.0) ) + print("Total done %.2f" % (done / tot * 100.0)) - return (props_list,props_length_max) + return (props_list, props_length_max) def get_props_from_py(input_filename): @@ -185,25 +187,25 @@ def get_props_from_py(input_filename): # adds the list "rna_api" to this function's scope rna_api = __import__(input_filename[:-3]).rna_api - props_length_max = [0 for i in rna_api[0]] # this way if the vector will take more elements we are safe - for index,props in enumerate(rna_api): + props_length_max = [0 for i in rna_api[0]] # this way if the vector will take more elements we are safe + for index, props in enumerate(rna_api): comment, changed, bclass, bfrom, bto, kwcheck, btype, description = props kwcheck = check_prefix(bto, btype) # keyword-check changed = check_if_changed(bfrom, bto) # changed? description = repr(description) description = description.replace("'", "").replace('"', "").replace("\\", "").strip() rna_api[index] = [comment, changed, bclass, bfrom, bto, kwcheck, btype, description] - props_length = list(map(len,props)) # lengths - props_length_max = list(map(max,zip(props_length_max,props_length))) # max lengths - return (rna_api,props_length_max) + props_length = list(map(len, props)) # lengths + props_length_max = list(map(max, zip(props_length_max, props_length))) # max lengths + return (rna_api, props_length_max) def get_props(input_filename): if input_filename.endswith(".txt"): - props_list,props_length_max = get_props_from_txt(input_filename) + props_list, props_length_max = get_props_from_txt(input_filename) elif input_filename.endswith(".py"): - props_list,props_length_max = get_props_from_py(input_filename) - return (props_list,props_length_max) + props_list, props_length_max = get_props_from_py(input_filename) + return (props_list, props_length_max) def sort(props_list, sort_priority): @@ -222,7 +224,7 @@ def sort(props_list, sort_priority): else: props_list = sorted(props_list, key=lambda p: p[i]) - print ('\nSorted by %s.' % font_bold(sort_priority)) + print('\nSorted by %s.' % font_bold(sort_priority)) return props_list @@ -250,30 +252,35 @@ def write_files(basename, props_list, props_length_max): * rna_api.py: unformatted, just as final output """ - f_rna = open("rna_api.py",'w') - f_txt = open(basename + '_work.txt','w') - f_py = open(basename + '_work.py','w') + f_rna = open("rna_api.py", 'w') + f_txt = open(basename + '_work.txt', 'w') + f_py = open(basename + '_work.py', 'w') # reminder: props=[comment, changed, bclass, bfrom, bto, kwcheck, btype, description] # [comment *] ToolSettings.snap_align_rotation -> use_snap_align_rotation: boolean [Align rotation with the snapping target] rna = py = txt = '' props_list = [['NOTE', 'CHANGED', 'CLASS', 'FROM', 'TO', 'KEYWORD-CHECK', 'TYPE', 'DESCRIPTION']] + props_list for props in props_list: - #txt + # txt # quick way we can tell if it changed - if props[3] == props[4]: txt += "#" - else: txt += " " + if props[3] == props[4]: + txt += "#" + else: + txt += " " - if props[0] != '': txt += '%s * ' % props[0] # comment - txt += '%s.%s -> %s: %s "%s"\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check + if props[0] != '': + txt += '%s * ' % props[0] # comment + txt += '%s.%s -> %s: %s "%s"\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check # rna_api - if props[0] == 'NOTE': indent = '# ' - else: indent = ' ' - rna += indent + '("%s", "%s", "%s", "%s", "%s"),\n' % tuple(props[2:5] + props[6:]) # description is already string formatted + if props[0] == 'NOTE': + indent = '# ' + else: + indent = ' ' + rna += indent + '("%s", "%s", "%s", "%s", "%s"),\n' % tuple(props[2:5] + props[6:]) # description is already string formatted # py - blanks = [' '* (x[0]-x[1]) for x in zip(props_length_max,list(map(len,props)))] - props = [('"%s"%s' if props[-1] != x[0] else "%s%s") % (x[0],x[1]) for x in zip(props,blanks)] + blanks = [' ' * (x[0] - x[1]) for x in zip(props_length_max, list(map(len, props)))] + props = [('"%s"%s' if props[-1] != x[0] else "%s%s") % (x[0], x[1]) for x in zip(props, blanks)] py += indent + '(%s, %s, %s, %s, %s, %s, %s, "%s"),\n' % tuple(props) f_txt.write(txt) @@ -290,7 +297,7 @@ def write_files(basename, props_list, props_length_max): f_py.close() f_rna.close() - print ('\nSaved %s, %s and %s.\n' % (font_bold(f_txt.name), font_bold(f_py.name), font_bold(f_rna.name) ) ) + print('\nSaved %s, %s and %s.\n' % (font_bold(f_txt.name), font_bold(f_py.name), font_bold(f_rna.name))) def main(): @@ -298,21 +305,21 @@ def main(): global sort_choices, default_sort_choice global kw_prefixes, kw - sort_choices = ['note','changed','class','from','to','kw', 'class.to'] + sort_choices = ['note', 'changed', 'class', 'from', 'to', 'kw', 'class.to'] default_sort_choice = sort_choices[-1] - kw_prefixes = [ 'active','apply','bl','exclude','has','invert','is','lock', \ - 'pressed','show','show_only','use','use_only','layers','states', 'select'] - kw = ['active','hide','invert','select','layers','mute','states','use','lock'] + kw_prefixes = ['active', 'apply', 'bl', 'exclude', 'has', 'invert', 'is', 'lock', + 'pressed', 'show', 'show_only', 'use', 'use_only', 'layers', 'states', 'select'] + kw = ['active', 'hide', 'invert', 'select', 'layers', 'mute', 'states', 'use', 'lock'] input_filename, sort_priority = check_commandline() - props_list,props_length_max = get_props(input_filename) - props_list = sort(props_list,sort_priority) + props_list, props_length_max = get_props(input_filename) + props_list = sort(props_list, sort_priority) output_basename = file_basename(input_filename) - write_files(output_basename, props_list,props_length_max) + write_files(output_basename, props_list, props_length_max) -if __name__=='__main__': +if __name__ == '__main__': import sys if not sys.version.startswith("3"): print("Incorrect python version, use python 3!") diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py index a5d5cebcbb7..236313f1f5c 100755 --- a/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py +++ b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py @@ -6,56 +6,58 @@ import sys Example usage: python3 rna_cleaner_merge.py out_work.py rna_booleans_work.py ''' + + def main(): - def work_line_id(line): - return line[2].split("|")[-1], line[3] # class/from + def work_line_id(line): + return line[2].split("|")[-1], line[3] # class/from + if not (sys.argv[-1].endswith(".py") and sys.argv[-2].endswith(".py")): + print("Only accepts 2 py files as arguments.") - if not (sys.argv[-1].endswith(".py") and sys.argv[-2].endswith(".py")): - print("Only accepts 2 py files as arguments.") + sys.path.insert(0, ".") - sys.path.insert(0, ".") + mod_from = __import__(sys.argv[-1][:-3]) + mod_to = __import__(sys.argv[-2][:-3]) - mod_from = __import__(sys.argv[-1][:-3]) - mod_to = __import__(sys.argv[-2][:-3]) + mod_to_dict = dict([(work_line_id(line), line) for line in mod_to.rna_api]) + mod_from_dict = dict([(work_line_id(line), line) for line in mod_from.rna_api]) - mod_to_dict = dict([(work_line_id(line), line) for line in mod_to.rna_api]) - mod_from_dict = dict([(work_line_id(line), line) for line in mod_from.rna_api]) + rna_api_new = [] - rna_api_new = [] + for key, val_orig in mod_to_dict.items(): + try: + val_new = mod_from_dict.pop(key) + except: + # print("not found", key) + val_new = val_orig - for key, val_orig in mod_to_dict.items(): - try: - val_new = mod_from_dict.pop(key) - except: - # print("not found", key) - val_new = val_orig + # always take the class from the base + val = list(val_orig) + val[0] = val_new[0] # comment + val[4] = val_new[4] # -> to + val = tuple(val) + rna_api_new.append(val) - # always take the class from the base - val = list(val_orig) - val[0] = val_new[0] # comment - val[4] = val_new[4] # -> to - val = tuple(val) - rna_api_new.append(val) + def write_work_file(file_path, rna_api): + rna_api = list(rna_api) + rna_api.sort(key=work_line_id) + file_out = open(file_path, "w") + file_out.write("rna_api = [\n") + for line in rna_api: + file_out.write(" %s,\n" % (repr(line))) + file_out.write("]\n") + file_out.close() - def write_work_file(file_path, rna_api): - rna_api = list(rna_api) - rna_api.sort(key=work_line_id) - file_out = open(file_path, "w") - file_out.write("rna_api = [\n") - for line in rna_api: - file_out.write(" %s,\n" % (repr(line))) - file_out.write("]\n") - file_out.close() + file_path = sys.argv[-2][:-3] + "_merged.py" + write_work_file(file_path, rna_api_new) - file_path = sys.argv[-2][:-3] + "_merged.py" - write_work_file(file_path, rna_api_new) + if mod_from_dict: + file_path = sys.argv[-2][:-3] + "_lost.py" + write_work_file(file_path, list(mod_from_dict.values())) + print("Warning '%s' contains lost %d items from module %s.py" % (file_path, len(mod_from_dict), mod_from.__name__)) - if mod_from_dict: - file_path = sys.argv[-2][:-3] + "_lost.py" - write_work_file(file_path, list(mod_from_dict.values())) - print("Warning '%s' contains lost %d items from module %s.py" % (file_path, len(mod_from_dict), mod_from.__name__)) if __name__ == "__main__": - main() + main() diff --git a/source/blender/python/rna_dump.py b/source/blender/python/rna_dump.py index 7259ceb67a0..3c09175910e 100644 --- a/source/blender/python/rna_dump.py +++ b/source/blender/python/rna_dump.py @@ -129,6 +129,7 @@ def seek(r, txt, recurs): newtxt = txt + '[' + str(i) + ']' seek(r[i], newtxt, recurs + 1) + seek(bpy.data, 'bpy.data', 0) # seek(bpy.types, 'bpy.types', 0) ''' @@ -140,8 +141,8 @@ for d in dir(bpy.types): seek(r, 'bpy.types.' + d + '.bl_rna', 0) ''' -#print dir(bpy) +# print dir(bpy) #import sys -#sys.exit() +# sys.exit() print("iter over ", seek_count, "rna items") diff --git a/source/blender/python/simple_enum_gen.py b/source/blender/python/simple_enum_gen.py index 1c68a7c0e7a..8ac5c782821 100644 --- a/source/blender/python/simple_enum_gen.py +++ b/source/blender/python/simple_enum_gen.py @@ -50,8 +50,10 @@ for d in defs.split('\n'): if not w: continue - try: w.remove("#define") - except: pass + try: + w.remove("#define") + except: + pass # print w diff --git a/tests/check_deprecated.py b/tests/check_deprecated.py index 6e07f8fdb31..7595bb4ff81 100644 --- a/tests/check_deprecated.py +++ b/tests/check_deprecated.py @@ -142,5 +142,6 @@ def main(): else: print("\nnone found!") + if __name__ == '__main__': main() diff --git a/tests/python/alembic_tests.py b/tests/python/alembic_tests.py index b9dc78a821f..d872e699cea 100755 --- a/tests/python/alembic_tests.py +++ b/tests/python/alembic_tests.py @@ -33,7 +33,6 @@ from modules.test_utils import (with_tempdir, ) - class AbcPropError(Exception): """Raised when AbstractAlembicTest.abcprop() finds an error.""" diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py index 1b526b3ebba..17754169279 100644 --- a/tests/python/bl_alembic_import_test.py +++ b/tests/python/bl_alembic_import_test.py @@ -107,7 +107,6 @@ class SimpleImportTest(AbstractAlembicTest): self.assertAlmostEqual(0, y) self.assertAlmostEqual(2, z) - def test_select_after_import(self): # Add a sphere, so that there is something in the scene, selected, and active, # before we do the Alembic import. diff --git a/tests/python/bl_load_addons.py b/tests/python/bl_load_addons.py index 29304400005..16ddea24756 100644 --- a/tests/python/bl_load_addons.py +++ b/tests/python/bl_load_addons.py @@ -33,7 +33,7 @@ import imp BLACKLIST_DIRS = ( os.path.join(bpy.utils.resource_path('USER'), "scripts"), - ) + tuple(addon_utils.paths()[1:]) +) + tuple(addon_utils.paths()[1:]) BLACKLIST_ADDONS = set() @@ -54,9 +54,10 @@ def _init_addon_blacklist(): def addon_modules_sorted(): modules = addon_utils.modules({}) modules[:] = [ - mod for mod in modules - if not (mod.__file__.startswith(BLACKLIST_DIRS)) - if not (mod.__name__ in BLACKLIST_ADDONS)] + mod for mod in modules + if not (mod.__file__.startswith(BLACKLIST_DIRS)) + if not (mod.__name__ in BLACKLIST_ADDONS) + ] modules.sort(key=lambda mod: mod.__name__) return modules diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py index 39e7bd33d44..437a425a36d 100644 --- a/tests/python/bl_load_py_modules.py +++ b/tests/python/bl_load_py_modules.py @@ -39,20 +39,20 @@ BLACKLIST = { # The unpacked wheel is only loaded when actually used, not directly on import: os.path.join("io_blend_utils", "blender_bam-unpacked.whl"), - } +} # Some modules need to add to the `sys.path`. MODULE_SYS_PATHS = { # Runs in a Python subprocess, so its expected its basedir can be imported. "io_blend_utils.blendfile_pack": ".", - } +} if not bpy.app.build_options.freestyle: BLACKLIST.add("render_freestyle_svg") BLACKLIST_DIRS = ( os.path.join(bpy.utils.resource_path('USER'), "scripts"), - ) + tuple(addon_utils.paths()[1:]) +) + tuple(addon_utils.paths()[1:]) def module_names_recursive(mod_dir, *, parent=None): @@ -168,7 +168,7 @@ def load_modules(): os.sep + "presets" + os.sep, os.sep + "templates" + os.sep, ] + ([(os.sep + f + os.sep) for f in BLACKLIST] + - [(os.sep + f + ".py") for f in BLACKLIST]) + [(os.sep + f + ".py") for f in BLACKLIST]) # # now submodules @@ -185,7 +185,7 @@ def load_modules(): sys.path.extend([ os.path.normpath(os.path.join(mod_dir, f)) for f in MODULE_SYS_PATHS.get(mod_name_full, ()) - ]) + ]) try: __import__(mod_name_full) @@ -248,6 +248,7 @@ def main(): load_addons() load_modules() + if __name__ == "__main__": # So a python error exits(1) try: diff --git a/tests/python/bl_mesh_modifiers.py b/tests/python/bl_mesh_modifiers.py index bff2c31984c..619fdc77801 100644 --- a/tests/python/bl_mesh_modifiers.py +++ b/tests/python/bl_mesh_modifiers.py @@ -61,11 +61,11 @@ def render_gl(context, filepath, shade): ctx_viewport_shade(context, shade) - #~ # stop to inspect! - #~ if filepath == "test_cube_shell_solidify_subsurf_wp_wire": - #~ assert(0) - #~ else: - #~ return + # stop to inspect! + # if filepath == "test_cube_shell_solidify_subsurf_wp_wire": + # assert(0) + # else: + # return bpy.ops.render.opengl(write_still=True, view_context=True) @@ -219,6 +219,7 @@ def mesh_bmesh_poly_elems(poly, elems): vert_total = poly.loop_total return elems[vert_start:vert_start + vert_total] + def mesh_bmesh_poly_vertices(poly): return [loop.vertex_index for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)] @@ -505,7 +506,7 @@ cube_like_vertices = ( (-1, 1, 3), (0, 1, 3), (0, 0, 3), - ) +) cube_like_faces = ( @@ -547,7 +548,7 @@ cube_like_faces = ( (31, 30, 36, 33), (32, 31, 33, 34), (35, 34, 33, 36), - ) +) # useful since its a shell for solidify and it can be mirrored @@ -564,7 +565,7 @@ cube_shell_vertices = ( (0, -1, 0), (0, 0, -1), (0, 1, -1), - ) +) cube_shell_face = ( @@ -577,7 +578,7 @@ cube_shell_face = ( (6, 5, 11), (7, 4, 9, 8), (10, 7, 6, 11), - ) +) def make_cube(scene): @@ -678,59 +679,77 @@ def make_monkey_extra(scene): global_tests = [] -global_tests.append(("none", - (), - )) - +global_tests.append( + ("none", + (), + ) +) # single -global_tests.append(("subsurf_single", - ((modifier_subsurf_add, dict(levels=2)), ), - )) - - -global_tests.append(("armature_single", - ((modifier_armature_add, dict()), ), - )) - - -global_tests.append(("mirror_single", - ((modifier_mirror_add, dict()), ), - )) - -global_tests.append(("hook_single", - ((modifier_hook_add, dict()), ), - )) - -global_tests.append(("decimate_single", - ((modifier_decimate_add, dict()), ), - )) - -global_tests.append(("build_single", - ((modifier_build_add, dict()), ), - )) - -global_tests.append(("mask_single", - ((modifier_mask_add, dict()), ), - )) +global_tests.append( + ("subsurf_single", + ((modifier_subsurf_add, dict(levels=2)), ), + ) +) + +global_tests.append( + ("armature_single", + ((modifier_armature_add, dict()), ), + ) +) + +global_tests.append( + ("mirror_single", + ((modifier_mirror_add, dict()), ), + ) +) + +global_tests.append( + ("hook_single", + ((modifier_hook_add, dict()), ), + ) +) + +global_tests.append( + ("decimate_single", + ((modifier_decimate_add, dict()), ), + ) +) + +global_tests.append( + ("build_single", + ((modifier_build_add, dict()), ), + ) +) + +global_tests.append( + ("mask_single", + ((modifier_mask_add, dict()), ), + ) +) # combinations -global_tests.append(("mirror_subsurf", - ((modifier_mirror_add, dict()), - (modifier_subsurf_add, dict(levels=2))), - )) - -global_tests.append(("solidify_subsurf", - ((modifier_solidify_add, dict()), - (modifier_subsurf_add, dict(levels=2))), - )) - - -def apply_test(test, scene, obj, - render_func=None, - render_args=None, - render_kwargs=None, - ): +global_tests.append( + ("mirror_subsurf", + ((modifier_mirror_add, dict()), + (modifier_subsurf_add, dict(levels=2))), + ) +) + +global_tests.append( + ("solidify_subsurf", + ((modifier_solidify_add, dict()), + (modifier_subsurf_add, dict(levels=2))), + ) +) + + +def apply_test( + test, scene, obj, + render_func=None, + render_args=None, + render_kwargs=None, +): test_name, test_funcs = test @@ -756,10 +775,12 @@ def test_cube(context, test): obj = make_cube_extra(scene) ctx_camera_setup(context, location=(3, 3, 3)) - apply_test(test, scene, obj, - render_func=render_gl_all_modes, - render_args=(context, obj), - render_kwargs=dict(filepath=whoami())) + apply_test( + test, scene, obj, + render_func=render_gl_all_modes, + render_args=(context, obj), + render_kwargs=dict(filepath=whoami()) + ) def test_cube_like(context, test): @@ -767,10 +788,12 @@ def test_cube_like(context, test): obj = make_cube_like_extra(scene) ctx_camera_setup(context, location=(5, 5, 5)) - apply_test(test, scene, obj, - render_func=render_gl_all_modes, - render_args=(context, obj), - render_kwargs=dict(filepath=whoami())) + apply_test( + test, scene, obj, + render_func=render_gl_all_modes, + render_args=(context, obj), + render_kwargs=dict(filepath=whoami()) + ) def test_cube_shell(context, test): @@ -778,10 +801,12 @@ def test_cube_shell(context, test): obj = make_cube_shell_extra(scene) ctx_camera_setup(context, location=(4, 4, 4)) - apply_test(test, scene, obj, - render_func=render_gl_all_modes, - render_args=(context, obj), - render_kwargs=dict(filepath=whoami())) + apply_test( + test, scene, obj, + render_func=render_gl_all_modes, + render_args=(context, obj), + render_kwargs=dict(filepath=whoami()) + ) # ----------------------------------------------------------------------------- diff --git a/tests/python/bl_mesh_validate.py b/tests/python/bl_mesh_validate.py index ac5be7d08d7..e1dd097b2e0 100644 --- a/tests/python/bl_mesh_validate.py +++ b/tests/python/bl_mesh_validate.py @@ -45,20 +45,20 @@ MESHES = { ( # Edges ), ( # Loops - 0, 1, 4, 3, - 3, 4, 6, - 1, 2, 5, 4, - 3, 4, 6, - 4, 7, 6, - 4, 5, 9, 4, 8, 7, + 0, 1, 4, 3, + 3, 4, 6, + 1, 2, 5, 4, + 3, 4, 6, + 4, 7, 6, + 4, 5, 9, 4, 8, 7, ), ( # Polygons - (0, 4), - (4, 3), - (7, 4), - (11, 3), - (14, 3), - (16, 6), + (0, 4), + (4, 3), + (7, 4), + (11, 3), + (14, 3), + (16, 6), ), ), ), @@ -66,17 +66,17 @@ MESHES = { BUILTINS = ( - "primitive_plane_add", - "primitive_cube_add", - "primitive_circle_add", - "primitive_uv_sphere_add", - "primitive_ico_sphere_add", - "primitive_cylinder_add", - "primitive_cone_add", - "primitive_grid_add", - "primitive_monkey_add", - "primitive_torus_add", - ) + "primitive_plane_add", + "primitive_cube_add", + "primitive_circle_add", + "primitive_uv_sphere_add", + "primitive_ico_sphere_add", + "primitive_cylinder_add", + "primitive_cone_add", + "primitive_grid_add", + "primitive_monkey_add", + "primitive_torus_add", +) BUILTINS_NBR = 4 BUILTINS_NBRCHANGES = 5 diff --git a/tests/python/bl_pyapi_bpy_utils_units.py b/tests/python/bl_pyapi_bpy_utils_units.py index 251419cb9ef..88d5cb941bd 100644 --- a/tests/python/bl_pyapi_bpy_utils_units.py +++ b/tests/python/bl_pyapi_bpy_utils_units.py @@ -5,25 +5,26 @@ import unittest from bpy.utils import units + class UnitsTesting(unittest.TestCase): # From user typing to 'internal' Blender value. INPUT_TESTS = ( # system, type, ref, input, value - ##### LENGTH + # LENGTH ('IMPERIAL', 'LENGTH', "", "1ft", 0.3048), ('IMPERIAL', 'LENGTH', "", "(1+1)ft", 0.3048 * 2), ('IMPERIAL', 'LENGTH', "", "1mi4\"", 1609.344 + 0.0254 * 4), - ('METRIC', 'LENGTH', "", "0.005µm", 0.000001 * 0.005), - ('METRIC', 'LENGTH', "", "1e6km", 1000.0 * 1e6), + ('METRIC', 'LENGTH', "", "0.005µm", 0.000001 * 0.005), + ('METRIC', 'LENGTH', "", "1e6km", 1000.0 * 1e6), ('IMPERIAL', 'LENGTH', "", "1ft5cm", 0.3048 + 0.01 * 5), - ('METRIC', 'LENGTH', "", "1ft5cm", 0.3048 + 0.01 * 5), + ('METRIC', 'LENGTH', "", "1ft5cm", 0.3048 + 0.01 * 5), # Using reference string to find a unit when none is given. ('IMPERIAL', 'LENGTH', "33.3ft", "1", 0.3048), - ('METRIC', 'LENGTH', "33.3dm", "1", 0.1), + ('METRIC', 'LENGTH', "33.3dm", "1", 0.1), ('IMPERIAL', 'LENGTH', "33.3cm", "1", 0.3048), # ref unit is not in IMPERIAL system, default to feet... ('IMPERIAL', 'LENGTH', "33.3ft", "1\"", 0.0254), # unused ref unit, since one is given already! ('IMPERIAL', 'LENGTH', "", "1+1ft", 0.3048 * 2), # default unit taken from current string (feet). - ('METRIC', 'LENGTH', "", "1+1ft", 1.3048), # no metric units, we default to meters. + ('METRIC', 'LENGTH', "", "1+1ft", 1.3048), # no metric units, we default to meters. ('IMPERIAL', 'LENGTH', "", "3+1in+1ft", 0.3048 * 4 + 0.0254), # bigger unit becomes default one! ('IMPERIAL', 'LENGTH', "", "(3+1)in+1ft", 0.3048 + 0.0254 * 4), ) @@ -31,18 +32,18 @@ class UnitsTesting(unittest.TestCase): # From 'internal' Blender value to user-friendly printing OUTPUT_TESTS = ( # system, type, prec, sep, compat, value, output - ##### LENGTH + # LENGTH # Note: precision handling is a bit complicated when using multi-units... ('IMPERIAL', 'LENGTH', 3, False, False, 0.3048, "1'"), - ('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"), - ('IMPERIAL', 'LENGTH', 4, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""), + ('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"), + ('IMPERIAL', 'LENGTH', 4, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""), ('IMPERIAL', 'LENGTH', 3, False, False, 1609.344 * 1e6, "1000000mi"), ('IMPERIAL', 'LENGTH', 6, False, False, 1609.344 * 1e6, "1000000mi"), - ('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2km 2cm"), - ('METRIC', 'LENGTH', 5, True, False, 1234.56789, "1km 234.6m"), - ('METRIC', 'LENGTH', 6, True, False, 1234.56789, "1km 234.57m"), - ('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.234568km"), - ('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1km 0.123mm"), + ('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2km 2cm"), + ('METRIC', 'LENGTH', 5, True, False, 1234.56789, "1km 234.6m"), + ('METRIC', 'LENGTH', 6, True, False, 1234.56789, "1km 234.57m"), + ('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.234568km"), + ('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1km 0.123mm"), ) def test_units_inputs(self): @@ -63,9 +64,13 @@ class UnitsTesting(unittest.TestCase): def test_units_outputs(self): for usys, utype, prec, sep, compat, val, output in self.OUTPUT_TESTS: opt_str = units.to_string(usys, utype, val, prec, sep, compat) - self.assertEqual(opt_str, output, - msg="%s, %s: %f (precision: %d, separate units: %d, compat units: %d) => " - "\"%s\", expected \"%s\"" % (usys, utype, val, prec, sep, compat, opt_str, output)) + self.assertEqual( + opt_str, output, + msg=( + "%s, %s: %f (precision: %d, separate units: %d, compat units: %d) => " + "\"%s\", expected \"%s\"" + ) % (usys, utype, val, prec, sep, compat, opt_str, output) + ) if __name__ == '__main__': diff --git a/tests/python/bl_pyapi_idprop.py b/tests/python/bl_pyapi_idprop.py index 7bf68c16cc7..063d68fae20 100644 --- a/tests/python/bl_pyapi_idprop.py +++ b/tests/python/bl_pyapi_idprop.py @@ -198,6 +198,7 @@ class TestBufferProtocol(TestHelper, unittest.TestCase): self.assertEqual(list(view1), list(view2)) self.assertEqual(view1.tobytes(), view2.tobytes()) + if __name__ == '__main__': import sys sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []) diff --git a/tests/python/bl_pyapi_idprop_datablock.py b/tests/python/bl_pyapi_idprop_datablock.py index 4acfb83bd95..4b46bea7c00 100644 --- a/tests/python/bl_pyapi_idprop_datablock.py +++ b/tests/python/bl_pyapi_idprop_datablock.py @@ -61,8 +61,10 @@ class TestClass(bpy.types.PropertyGroup): def get_scene(lib_name, sce_name): for s in bpy.data.scenes: if s.name == sce_name: - if (s.library and s.library.name == lib_name) or \ - (lib_name == None and s.library == None): + if ( + (s.library and s.library.name == lib_name) or + (lib_name is None and s.library is None) + ): return s @@ -309,6 +311,7 @@ def test_restrictions2(): class TestUIList(UIList): test = bpy.props.PointerProperty(type=bpy.types.Object) + def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): layout.prop(item, "name", text="", emboss=False, icon_value=icon) diff --git a/tests/python/bl_pyapi_mathutils.py b/tests/python/bl_pyapi_mathutils.py index b2d3d79fd56..57bbbc7e73e 100644 --- a/tests/python/bl_pyapi_mathutils.py +++ b/tests/python/bl_pyapi_mathutils.py @@ -21,22 +21,22 @@ vector_data = ( (-0.854645, 0.518036, 0.033936), (0.42514, -0.437866, -0.792114), (-0.358948, 0.597046, 0.717377), - (-0.985413,0.144714, 0.089294), - ) + (-0.985413, 0.144714, 0.089294), +) # get data at different scales vector_data = sum( (tuple(tuple(a * scale for a in v) for v in vector_data) - for scale in (s * sign for s in (0.0001, 0.1, 1.0, 10.0, 1000.0, 100000.0) - for sign in (1.0, -1.0))), ()) + ((0.0, 0.0, 0.0),) + for scale in (s * sign for s in (0.0001, 0.1, 1.0, 10.0, 1000.0, 100000.0) + for sign in (1.0, -1.0))), ()) + ((0.0, 0.0, 0.0),) class MatrixTesting(unittest.TestCase): def test_matrix_column_access(self): - #mat = - #[ 1 2 3 4 ] - #[ 1 2 3 4 ] - #[ 1 2 3 4 ] + # mat = + # [ 1 2 3 4 ] + # [ 1 2 3 4 ] + # [ 1 2 3 4 ] mat = Matrix(((1, 11, 111), (2, 22, 222), (3, 33, 333), @@ -81,11 +81,11 @@ class MatrixTesting(unittest.TestCase): self.assertIn(item, indices) def test_matrix_to_3x3(self): - #mat = - #[ 1 2 3 4 ] - #[ 2 4 6 8 ] - #[ 3 6 9 12 ] - #[ 4 8 12 16 ] + # mat = + # [ 1 2 3 4 ] + # [ 2 4 6 8 ] + # [ 3 6 9 12 ] + # [ 4 8 12 16 ] mat = Matrix(tuple((i, 2 * i, 3 * i, 4 * i) for i in range(1, 5))) mat_correct = Matrix(((1, 2, 3), (2, 4, 6), (3, 6, 9))) self.assertEqual(mat.to_3x3(), mat_correct) @@ -372,7 +372,6 @@ class KDTreeTesting(unittest.TestCase): ret_filter = k_all.find(co, lambda i: (i % 2) == 0) self.assertAlmostEqualVector(ret_regular, ret_filter) - # filter out all values (search odd tree for even values and the reverse) co = (0,) * 3 ret_filter = k_odd.find(co, lambda i: (i % 2) == 0) diff --git a/tests/python/bl_rna_defaults.py b/tests/python/bl_rna_defaults.py index 72f50a827f0..6038ef34d78 100644 --- a/tests/python/bl_rna_defaults.py +++ b/tests/python/bl_rna_defaults.py @@ -8,7 +8,7 @@ DUMMY_NAME = "Untitled" DUMMY_PATH = __file__ GLOBALS = { "error_num": 0, - } +} def as_float_32(f): @@ -142,5 +142,6 @@ def main(): print("Error (total): %d" % GLOBALS["error_num"]) + if __name__ == "__main__": main() diff --git a/tests/python/bl_rna_manual_reference.py b/tests/python/bl_rna_manual_reference.py index c67b6c1532b..00e40fe571b 100644 --- a/tests/python/bl_rna_manual_reference.py +++ b/tests/python/bl_rna_manual_reference.py @@ -155,5 +155,6 @@ def main(): test_language_coverage() test_urls() + if __name__ == "__main__": main() diff --git a/tests/python/bl_run_operators.py b/tests/python/bl_run_operators.py index 7b6b97e5ad1..aae78a84132 100644 --- a/tests/python/bl_run_operators.py +++ b/tests/python/bl_run_operators.py @@ -36,7 +36,7 @@ RANDOM_MULTIPLY = 10 STATE = { "counter": 0, - } +} op_blacklist = ( @@ -91,7 +91,7 @@ op_blacklist = ( "wm.keymap_restore", # another annoying one "wm.addon_*", # harmless, but dont change state "console.*", # just annoying - but harmless - ) +) def blend_list(mainpath): @@ -114,6 +114,7 @@ def blend_list(mainpath): return list(sorted(file_list(mainpath, is_blend))) + if USE_FILES: USE_FILES_LS = blend_list(USE_FILES) # print(USE_FILES_LS) @@ -176,7 +177,7 @@ if USE_ATTRSET: CLS_BLACKLIST = ( bpy.types.BrushTextureSlot, bpy.types.Brush, - ) + ) property_typemap = build_property_typemap(CLS_BLACKLIST) bpy_struct_type = bpy.types.Struct.__base__ @@ -228,7 +229,7 @@ if USE_ATTRSET: {0: "", 1: "hello", 2: "test"}, {"": 0, "hello": 1, "test": 2}, set(), {"", "test", "."}, {None, ..., type}, range(10), (" " * i for i in range(10)), - ) + ) def attrset_data(): for attr in dir(bpy.data): @@ -480,8 +481,9 @@ def main(): print("Finished %r" % __file__) + if __name__ == "__main__": - #~ for i in range(200): - #~ RANDOM_SEED[0] += 1 + # ~ for i in range(200): + # ~ RANDOM_SEED[0] += 1 #~ main() main() diff --git a/tests/python/collada/animation/test_animation_simple.py b/tests/python/collada/animation/test_animation_simple.py index bdfae03aafb..6b18313c3cd 100644 --- a/tests/python/collada/animation/test_animation_simple.py +++ b/tests/python/collada/animation/test_animation_simple.py @@ -31,6 +31,7 @@ import difflib import pathlib from pathlib import Path + def with_tempdir(wrapped): """Creates a temporary directory for the function, cleaning up after it returns normally. @@ -56,8 +57,10 @@ def with_tempdir(wrapped): return decorator + LINE = "+----------------------------------------------------------------" + class AbstractColladaTest(unittest.TestCase): @classmethod @@ -71,33 +74,33 @@ class AbstractColladaTest(unittest.TestCase): ref = open(reference) exp = open(export) - diff=difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0) + diff = difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0) ref.close() exp.close() - diff_count = 0; + diff_count = 0 for line in diff: error = True for prefix in ('---', '+++', '@@'): # Ignore diff metadata if line.startswith(prefix): - error=False + error = False break else: # Ignore time stamps for ignore in ('', '', ''): if line[1:].strip().startswith(ignore): - error=False + error = False break if error: - diff_count +=1 + diff_count += 1 pline = line.strip() if diff_count == 1: print("\n%s" % LINE) print("|Test has errors:") print(LINE) pre = "reference" if pline[0] == "-" else "generated" - print ("| %s:%s"% (pre, pline[1:])) + print("| %s:%s" % (pre, pline[1:])) if diff_count > 0: print(LINE) @@ -107,14 +110,16 @@ class AbstractColladaTest(unittest.TestCase): return diff_count == 0 + class MeshExportTest4(AbstractColladaTest): @with_tempdir def test_export_animation_suzannes_sample_matrix(self, tempdir: pathlib.Path): test = "suzannes_parent_inverse_sample_10_matrix" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type='DEFAULT', @@ -142,20 +147,23 @@ class MeshExportTest4(AbstractColladaTest): export_texture_type_selection='mat', open_sim=False, limit_precision=True, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): self.fail() + class MeshExportTest3(AbstractColladaTest): @with_tempdir def test_export_animation_suzannes_sample_locrotscale(self, tempdir: pathlib.Path): test = "suzannes_parent_inverse_sample_10_channels" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type='DEFAULT', @@ -183,20 +191,23 @@ class MeshExportTest3(AbstractColladaTest): export_texture_type_selection='mat', open_sim=False, limit_precision=True, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): self.fail() + class MeshExportTest2(AbstractColladaTest): @with_tempdir def test_export_animation_suzannes_keyframe_matrix(self, tempdir: pathlib.Path): test = "suzannes_parent_inverse_keyframes_matrix" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type='DEFAULT', @@ -224,20 +235,23 @@ class MeshExportTest2(AbstractColladaTest): export_texture_type_selection='mat', open_sim=False, limit_precision=True, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): self.fail() + class MeshExportTest1(AbstractColladaTest): @with_tempdir def test_export_animation_suzannes_keyframe_locrotscale(self, tempdir: pathlib.Path): test = "suzannes_parent_inverse_keyframes_channels" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type='DEFAULT', @@ -265,7 +279,8 @@ class MeshExportTest1(AbstractColladaTest): export_texture_type_selection='mat', open_sim=False, limit_precision=True, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): @@ -277,4 +292,4 @@ if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--testdir', required=True) args, remaining = parser.parse_known_args() - unittest.main(argv=sys.argv[0:1]+remaining) + unittest.main(argv=sys.argv[0:1] + remaining) diff --git a/tests/python/collada/mesh/test_mesh_simple.py b/tests/python/collada/mesh/test_mesh_simple.py index 213c6177fde..5899d986a14 100644 --- a/tests/python/collada/mesh/test_mesh_simple.py +++ b/tests/python/collada/mesh/test_mesh_simple.py @@ -31,6 +31,7 @@ import difflib import pathlib from pathlib import Path + def with_tempdir(wrapped): """Creates a temporary directory for the function, cleaning up after it returns normally. @@ -56,8 +57,10 @@ def with_tempdir(wrapped): return decorator + LINE = "+----------------------------------------------------------------" + class AbstractColladaTest(unittest.TestCase): @classmethod @@ -71,33 +74,33 @@ class AbstractColladaTest(unittest.TestCase): ref = open(reference) exp = open(export) - diff=difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0) + diff = difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0) ref.close() exp.close() - diff_count = 0; + diff_count = 0 for line in diff: error = True for prefix in ('---', '+++', '@@'): # Ignore diff metadata if line.startswith(prefix): - error=False + error = False break else: # Ignore time stamps for ignore in ('', '', ''): if line[1:].strip().startswith(ignore): - error=False + error = False break if error: - diff_count +=1 + diff_count += 1 pline = line.strip() if diff_count == 1: print("\n%s" % LINE) print("|Test has errors:") print(LINE) pre = "reference" if pline[0] == "-" else "generated" - print ("| %s:%s"% (pre, pline[1:])) + print("| %s:%s" % (pre, pline[1:])) if diff_count > 0: print(LINE) @@ -107,14 +110,16 @@ class AbstractColladaTest(unittest.TestCase): return diff_count == 0 + class MeshExportTest(AbstractColladaTest): @with_tempdir def test_export_single_mesh(self, tempdir: pathlib.Path): test = "mesh_simple_001" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type="DEFAULT", @@ -140,15 +145,17 @@ class MeshExportTest(AbstractColladaTest): export_texture_type_selection="mat", open_sim=False, limit_precision=False, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): self.fail() + if __name__ == '__main__': sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []) parser = argparse.ArgumentParser() parser.add_argument('--testdir', required=True) args, remaining = parser.parse_known_args() - unittest.main(argv=sys.argv[0:1]+remaining) + unittest.main(argv=sys.argv[0:1] + remaining) diff --git a/tests/python/modules/render_report.py b/tests/python/modules/render_report.py index 67c1108941d..6c71e8dcb74 100755 --- a/tests/python/modules/render_report.py +++ b/tests/python/modules/render_report.py @@ -23,6 +23,7 @@ class COLORS_DUMMY: GREEN = '' ENDC = '' + COLORS = COLORS_DUMMY @@ -55,10 +56,12 @@ def blend_list(dirpath): filepath = os.path.join(dirpath, filename) yield filepath + def test_get_name(filepath): filename = os.path.basename(filepath) return os.path.splitext(filename)[0] + def test_get_images(output_dir, filepath): testname = test_get_name(filepath) dirpath = os.path.dirname(filepath) @@ -96,7 +99,7 @@ class Report: 'update', 'failed_tests', 'passed_tests' - ) + ) def __init__(self, title, output_dir, idiff): self.title = title @@ -257,7 +260,6 @@ class Report: else: self.passed_tests += test_html - def _diff_output(self, filepath, tmp_filepath): old_img, ref_img, new_img, diff_img = test_get_images(self.output_dir, filepath) @@ -280,7 +282,7 @@ class Report: "-failpercent", "1", ref_img, tmp_filepath, - ) + ) try: subprocess.check_output(command) failed = False @@ -307,7 +309,7 @@ class Report: "-abs", "-scale", "16", ref_img, tmp_filepath - ) + ) try: subprocess.check_output(command) @@ -317,7 +319,6 @@ class Report: return not failed - def _run_test(self, filepath, render_cb): testname = test_get_name(filepath) print_message(testname, 'SUCCESS', 'RUN') @@ -344,7 +345,7 @@ class Report: return error elif error == "NO_START": print_message('Can not perform tests because blender fails to start.', - 'Make sure INSTALL target was run.') + 'Make sure INSTALL target was run.') return error elif error == 'VERIFY': print_message("Rendered result is different from reference image") @@ -354,7 +355,6 @@ class Report: 'FAILURE', 'FAILED') return error - def _run_all_tests(self, dirname, dirpath, render_cb): passed_tests = [] failed_tests = [] @@ -387,8 +387,8 @@ class Report: 'SUCCESS', 'PASSED') if failed_tests: print_message("{} tests, listed below:" . - format(len(failed_tests)), - 'FAILURE', 'FAILED') + format(len(failed_tests)), + 'FAILURE', 'FAILED') failed_tests.sort() for test in failed_tests: print_message("{}" . format(test), 'FAILURE', "FAILED") diff --git a/tests/python/modules/test_utils.py b/tests/python/modules/test_utils.py index 2b762b4122c..47d720684ba 100755 --- a/tests/python/modules/test_utils.py +++ b/tests/python/modules/test_utils.py @@ -62,7 +62,6 @@ class AbstractBlenderRunnerTest(unittest.TestCase): blender: pathlib.Path = None testdir: pathlib.Path = None - def run_blender(self, filepath: str, python_script: str, timeout: int=300) -> str: """Runs Blender by opening a blendfile and executing a script. @@ -92,7 +91,7 @@ class AbstractBlenderRunnerTest(unittest.TestCase): '-E', 'CYCLES', '--python-exit-code', '47', '--python-expr', python_script, - ] + ] ) proc = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, diff --git a/tests/python/opengl_draw_tests.py b/tests/python/opengl_draw_tests.py index 999304570df..ae7f0dabf74 100755 --- a/tests/python/opengl_draw_tests.py +++ b/tests/python/opengl_draw_tests.py @@ -8,6 +8,7 @@ import shutil import subprocess import sys + def screenshot(): import bpy @@ -19,6 +20,7 @@ def screenshot(): bpy.ops.wm.quit_blender() + # When run from inside Blender, take screenshot and exit. try: import bpy @@ -93,5 +95,6 @@ def main(): sys.exit(not ok) + if __name__ == "__main__": main() diff --git a/tests/python/pep8.py b/tests/python/pep8.py index ebf2c5eabb7..ccc2dddbbd9 100644 --- a/tests/python/pep8.py +++ b/tests/python/pep8.py @@ -93,7 +93,7 @@ def check_files_flake8(files): # times types are compared, # I rather keep them specific "E721", - ) + ) for f, pep8_type in files: @@ -129,10 +129,10 @@ def check_files_pylint(files): "C0413," # import should be placed at the top "W0613," # unused argument, may add this back # but happens a lot for 'context' for eg. - "W0232," # class has no __init__, Operator/Panel/Menu etc + "W0232," # class has no __init__, Operator/Panel/Menu etc "W0142," # Used * or ** magic # even needed in some cases - "R0902," # Too many instance attributes + "R0902," # Too many instance attributes "R0903," # Too many statements "R0911," # Too many return statements "R0912," # Too many branches @@ -204,6 +204,5 @@ def main(): print("Skipping pylint checks (command not found)") - if __name__ == "__main__": main() diff --git a/tests/python/rna_array.py b/tests/python/rna_array.py index 0f6c0ce0a57..e0d63cf75ea 100644 --- a/tests/python/rna_array.py +++ b/tests/python/rna_array.py @@ -3,7 +3,7 @@ import unittest import random -test= bpy.data.test +test = bpy.data.test # farr - 1-dimensional array of float # fdarr - dynamic 1-dimensional array of float @@ -12,6 +12,7 @@ test= bpy.data.test # same as above for other types except that the first letter is "i" for int and "b" for bool + class TestArray(unittest.TestCase): # test that assignment works by: assign -> test value # - rvalue = list of float @@ -20,14 +21,14 @@ class TestArray(unittest.TestCase): # bpy.data.test.farr[3], iarr[3], barr[...], fmarr, imarr, bmarr def setUp(self): - test.farr= (1.0, 2.0, 3.0) - test.iarr= (7, 8, 9) - test.barr= (False, True, False) + test.farr = (1.0, 2.0, 3.0) + test.iarr = (7, 8, 9) + test.barr = (False, True, False) # test access # test slice access, negative indices def test_access(self): - rvals= ([1.0, 2.0, 3.0], [7, 8, 9], [False, True, False]) + rvals = ([1.0, 2.0, 3.0], [7, 8, 9], [False, True, False]) for arr, rval in zip((test.farr, test.iarr, test.barr), rvals): self.assertEqual(prop_to_list(arr), rval) self.assertEqual(arr[0:3], rval) @@ -39,12 +40,12 @@ class TestArray(unittest.TestCase): # fail when index out of bounds def test_access_fail(self): for arr in (test.farr, test.iarr, test.barr): - self.assertRaises(IndexError, lambda : arr[4]) + self.assertRaises(IndexError, lambda: arr[4]) # test assignment of a whole array def test_assign_array(self): # should accept int as float - test.farr= (1, 2, 3) + test.farr = (1, 2, 3) # fail when: unexpected no. of items, invalid item type def test_assign_array_fail(self): @@ -55,20 +56,20 @@ class TestArray(unittest.TestCase): self.assertRaises(ValueError, assign_empty_list, arr) def assign_invalid_float(): - test.farr= (1.0, 2.0, "3.0") + test.farr = (1.0, 2.0, "3.0") def assign_invalid_int(): - test.iarr= ("1", 2, 3) + test.iarr = ("1", 2, 3) def assign_invalid_bool(): - test.barr= (True, 0.123, False) + test.barr = (True, 0.123, False) for func in [assign_invalid_float, assign_invalid_int, assign_invalid_bool]: self.assertRaises(TypeError, func) # shouldn't accept float as int def assign_float_as_int(): - test.iarr= (1, 2, 3.0) + test.iarr = (1, 2, 3.0) self.assertRaises(TypeError, assign_float_as_int) # non-dynamic arrays cannot change size @@ -81,14 +82,14 @@ class TestArray(unittest.TestCase): def test_assign_item(self): for arr, rand_func in zip((test.farr, test.iarr, test.barr), (rand_float, rand_int, rand_bool)): for i in range(len(arr)): - val= rand_func() + val = rand_func() arr[i] = val self.assertEqual(arr[i], val) # float prop should accept also int for i in range(len(test.farr)): - val= rand_int() + val = rand_int() test.farr[i] = val self.assertEqual(test.farr[i], float(val)) @@ -112,7 +113,7 @@ class TestArray(unittest.TestCase): # test various lengths here for arr, rand_func in zip(("fdarr", "idarr", "bdarr"), (rand_float, rand_int, rand_bool)): for length in range(1, 64): - rval= make_random_array(length, rand_func) + rval = make_random_array(length, rand_func) setattr(test, arr, rval) self.assertEqual(prop_to_list(getattr(test, arr)), rval) @@ -136,7 +137,7 @@ class TestMArray(unittest.TestCase): def test_assign_array(self): for arr, func in zip(("fmarr", "imarr", "bmarr"), (rand_float, rand_int, rand_bool)): # assignment of [3][4][5] - rval= make_random_3d_array((3, 4, 5), func) + rval = make_random_3d_array((3, 4, 5), func) setattr(test, arr, rval) self.assertEqual(prop_to_list(getattr(test, arr)), rval) @@ -144,7 +145,7 @@ class TestMArray(unittest.TestCase): def test_assign_array_fail(self): def assign_empty_array(): - test.fmarr= () + test.fmarr = () self.assertRaises(ValueError, assign_empty_array) def assign_invalid_size(arr, rval): @@ -152,19 +153,19 @@ class TestMArray(unittest.TestCase): # assignment of 3,4,4 or 3,3,5 should raise ex for arr, func in zip(("fmarr", "imarr", "bmarr"), (rand_float, rand_int, rand_bool)): - rval= make_random_3d_array((3, 4, 4), func) + rval = make_random_3d_array((3, 4, 4), func) self.assertRaises(ValueError, assign_invalid_size, arr, rval) - rval= make_random_3d_array((3, 3, 5), func) + rval = make_random_3d_array((3, 3, 5), func) self.assertRaises(ValueError, assign_invalid_size, arr, rval) - rval= make_random_3d_array((3, 3, 3), func) + rval = make_random_3d_array((3, 3, 3), func) self.assertRaises(ValueError, assign_invalid_size, arr, rval) def test_assign_item(self): # arr[i] = x for arr, func in zip(("fmarr", "imarr", "bmarr", "fdmarr", "idmarr", "bdmarr"), (rand_float, rand_int, rand_bool) * 2): - rval= make_random_2d_array((4, 5), func) + rval = make_random_2d_array((4, 5), func) for i in range(3): getattr(test, arr)[i] = rval @@ -173,23 +174,22 @@ class TestMArray(unittest.TestCase): # arr[i][j] = x for arr, func in zip(("fmarr", "imarr", "bmarr", "fdmarr", "idmarr", "bdmarr"), (rand_float, rand_int, rand_bool) * 2): - arr= getattr(test, arr) - rval= make_random_array(5, func) + arr = getattr(test, arr) + rval = make_random_array(5, func) for i in range(3): for j in range(4): arr[i][j] = rval self.assertEqual(prop_to_list(arr[i][j]), rval) - def test_assign_item_fail(self): def assign_wrong_size(arr, i, rval): getattr(test, arr)[i] = rval # assign wrong size at level 2 for arr, func in zip(("fmarr", "imarr", "bmarr"), (rand_float, rand_int, rand_bool)): - rval1= make_random_2d_array((3, 5), func) - rval2= make_random_2d_array((4, 3), func) + rval1 = make_random_2d_array((3, 5), func) + rval2 = make_random_2d_array((4, 3), func) for i in range(3): self.assertRaises(ValueError, assign_wrong_size, arr, i, rval1) @@ -198,22 +198,22 @@ class TestMArray(unittest.TestCase): def test_dynamic_assign_array(self): for arr, func in zip(("fdmarr", "idmarr", "bdmarr"), (rand_float, rand_int, rand_bool)): # assignment of [3][4][5] - rval= make_random_3d_array((3, 4, 5), func) + rval = make_random_3d_array((3, 4, 5), func) setattr(test, arr, rval) self.assertEqual(prop_to_list(getattr(test, arr)), rval) # [2][4][5] - rval= make_random_3d_array((2, 4, 5), func) + rval = make_random_3d_array((2, 4, 5), func) setattr(test, arr, rval) self.assertEqual(prop_to_list(getattr(test, arr)), rval) # [1][4][5] - rval= make_random_3d_array((1, 4, 5), func) + rval = make_random_3d_array((1, 4, 5), func) setattr(test, arr, rval) self.assertEqual(prop_to_list(getattr(test, arr)), rval) - # test access + def test_access(self): pass @@ -221,26 +221,32 @@ class TestMArray(unittest.TestCase): def test_access_fail(self): pass + random.seed() + def rand_int(): return random.randint(-1000, 1000) + def rand_float(): return float(rand_int()) + def rand_bool(): return bool(random.randint(0, 1)) + def make_random_array(len, rand_func): - arr= [] + arr = [] for i in range(len): arr.append(rand_func()) return arr + def make_random_2d_array(dimsize, rand_func): - marr= [] + marr = [] for i in range(dimsize[0]): marr.append([]) @@ -249,8 +255,9 @@ def make_random_2d_array(dimsize, rand_func): return marr + def make_random_3d_array(dimsize, rand_func): - marr= [] + marr = [] for i in range(dimsize[0]): marr.append([]) @@ -262,8 +269,9 @@ def make_random_3d_array(dimsize, rand_func): return marr + def prop_to_list(prop): - ret= [] + ret = [] for x in prop: if type(x) not in {bool, int, float}: @@ -273,8 +281,10 @@ def prop_to_list(prop): return ret + def suite(): return unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestArray), unittest.TestLoader().loadTestsFromTestCase(TestMArray)]) + if __name__ == "__main__": unittest.TextTestRunner(verbosity=2).run(suite()) -- cgit v1.2.3 From 646f8bdb4801b0376b3e4bd01bbac49a51c99940 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 07:12:24 +0200 Subject: Cleanup: pep8 --- tests/python/eevee_render_tests.py | 2 + tests/python/view_layer/test_active_collection.py | 26 ++--- .../python/view_layer/test_collection_new_sync.py | 12 +-- tests/python/view_layer/test_group_d.py | 1 - tests/python/view_layer/test_layer_linking.py | 2 +- tests/python/view_layer/test_layer_syncing.py | 2 +- tests/python/view_layer/test_make_single_user.py | 2 +- .../test_move_above_below_layer_collection_f.py | 52 +++++----- .../test_move_above_below_layer_collection_g.py | 30 +++--- .../test_move_above_below_layer_collection_i.py | 24 ++--- .../test_move_above_below_layer_collection_l.py | 24 ++--- .../test_move_above_below_scene_collection_a.py | 30 +++--- .../test_move_above_below_scene_collection_b.py | 30 +++--- .../test_move_above_below_scene_collection_c.py | 30 +++--- .../test_move_above_below_scene_collection_d.py | 30 +++--- .../test_move_above_below_scene_collection_e.py | 30 +++--- .../test_move_above_below_scene_collection_f.py | 28 ++--- ...est_move_above_below_scene_collection_sync_a.py | 30 +++--- ...est_move_above_below_scene_collection_sync_b.py | 30 +++--- ...est_move_above_below_scene_collection_sync_c.py | 30 +++--- ...est_move_above_below_scene_collection_sync_d.py | 30 +++--- ...est_move_above_below_scene_collection_sync_e.py | 30 +++--- ...est_move_above_below_scene_collection_sync_f.py | 28 ++--- .../test_move_into_layer_collection_a.py | 54 +++++----- .../test_move_into_layer_collection_f.py | 52 +++++----- .../test_move_into_layer_collection_g.py | 22 ++-- .../test_move_into_layer_collection_h.py | 32 +++--- .../test_move_into_scene_collection_a.py | 30 +++--- .../test_move_into_scene_collection_b.py | 32 +++--- .../test_move_into_scene_collection_c.py | 28 ++--- .../test_move_into_scene_collection_e.py | 28 ++--- .../test_move_into_scene_collection_f.py | 30 +++--- .../test_move_into_scene_collection_g.py | 20 ++-- .../test_move_into_scene_collection_h.py | 32 +++--- .../test_move_into_scene_collection_i.py | 28 ++--- .../test_move_into_scene_collection_sync_b.py | 32 +++--- .../test_move_into_scene_collection_sync_c.py | 28 ++--- .../test_move_into_scene_collection_sync_e.py | 28 ++--- .../test_move_into_scene_collection_sync_f.py | 30 +++--- .../test_move_into_scene_collection_sync_g.py | 20 ++-- .../test_move_into_scene_collection_sync_h.py | 32 +++--- .../test_move_into_scene_collection_sync_i.py | 28 ++--- tests/python/view_layer/test_object_copy.py | 2 +- tests/python/view_layer/test_operator_context.py | 18 ++-- tests/python/view_layer/test_scene_copy_a.py | 6 +- tests/python/view_layer/test_scene_copy_b.py | 6 +- tests/python/view_layer/test_scene_copy_c.py | 6 +- tests/python/view_layer/test_scene_copy_d.py | 6 +- tests/python/view_layer/test_scene_write_read.py | 36 +++---- tests/python/view_layer/view_layer_common.py | 114 +++++++++++---------- 50 files changed, 658 insertions(+), 655 deletions(-) diff --git a/tests/python/eevee_render_tests.py b/tests/python/eevee_render_tests.py index 74e716dc8e6..48751e6bbcb 100755 --- a/tests/python/eevee_render_tests.py +++ b/tests/python/eevee_render_tests.py @@ -8,6 +8,7 @@ import shutil import subprocess import sys + def setup(): import bpy @@ -29,6 +30,7 @@ def setup(): mat.use_screen_refraction = True mat.use_screen_subsurface = True + # When run from inside Blender, render and exit. try: import bpy diff --git a/tests/python/view_layer/test_active_collection.py b/tests/python/view_layer/test_active_collection.py index 10df71f77ce..1c6c3cd1983 100644 --- a/tests/python/view_layer/test_active_collection.py +++ b/tests/python/view_layer/test_active_collection.py @@ -42,23 +42,23 @@ class UnitTesting(ViewLayerTesting): layer.collections.link(subzero) lookup = [ - 'Master Collection', - '1', - 'sub-zero', - 'scorpion', - '2', - '3', - '4', - '5', - 'sub-zero', - 'scorpion'] + 'Master Collection', + '1', + 'sub-zero', + 'scorpion', + '2', + '3', + '4', + '5', + 'sub-zero', + 'scorpion'] for i, name in enumerate(lookup): layer.collections.active_index = i self.assertEqual( - name, layer.collections.active.name, - "Collection index mismatch: [{0}] : {1} != {2}".format( - i, name, layer.collections.active.name)) + name, layer.collections.active.name, + "Collection index mismatch: [{0}] : {1} != {2}".format( + i, name, layer.collections.active.name)) # ############################################################ diff --git a/tests/python/view_layer/test_collection_new_sync.py b/tests/python/view_layer/test_collection_new_sync.py index 582e6c13d89..46b63c64f45 100644 --- a/tests/python/view_layer/test_collection_new_sync.py +++ b/tests/python/view_layer/test_collection_new_sync.py @@ -26,16 +26,16 @@ class UnitTesting(ViewLayerTesting): self.assertEqual(view_layer.collections[0].collection, scene.master_collection) self.assertEqual( - {collection.name for collection in view_layer.collections[0].collections}, - {'Collection 1'}) + {collection.name for collection in view_layer.collections[0].collections}, + {'Collection 1'}) self.assertEqual( - bpy.ops.outliner.collection_new(), - {'FINISHED'}) + bpy.ops.outliner.collection_new(), + {'FINISHED'}) self.assertEqual( - {collection.name for collection in view_layer.collections[0].collections}, - {'Collection 1', 'Collection 2'}) + {collection.name for collection in view_layer.collections[0].collections}, + {'Collection 1', 'Collection 2'}) # ############################################################ diff --git a/tests/python/view_layer/test_group_d.py b/tests/python/view_layer/test_group_d.py index 6f54ca5340a..709d27df184 100644 --- a/tests/python/view_layer/test_group_d.py +++ b/tests/python/view_layer/test_group_d.py @@ -46,7 +46,6 @@ class UnitTesting(ViewLayerTesting): self.assertEqual(1, bpy.data.groups[0].users) self.assertEqual(3, len(bpy.data.groups[0].objects)) - # empty the group of objects group = bpy.data.groups[0] while group.objects: diff --git a/tests/python/view_layer/test_layer_linking.py b/tests/python/view_layer/test_layer_linking.py index 4c66c564d7c..43c88aa65f9 100644 --- a/tests/python/view_layer/test_layer_linking.py +++ b/tests/python/view_layer/test_layer_linking.py @@ -67,7 +67,7 @@ class UnitTesting(ViewLayerTesting): self.assertTrue(compare_files( filepath_nested_json, filepath_json, - ), + ), "Scene dump files differ") def test_syncing_layer_new(self): diff --git a/tests/python/view_layer/test_layer_syncing.py b/tests/python/view_layer/test_layer_syncing.py index d8175c4850f..9baf25f9e9e 100644 --- a/tests/python/view_layer/test_layer_syncing.py +++ b/tests/python/view_layer/test_layer_syncing.py @@ -68,7 +68,7 @@ class UnitTesting(ViewLayerTesting): self.assertTrue(compare_files( filepath_nested_json, filepath_json, - ), + ), "Scene dump files differ") def test_syncing_link(self): diff --git a/tests/python/view_layer/test_make_single_user.py b/tests/python/view_layer/test_make_single_user.py index 2a8a479bab2..292c2d50605 100644 --- a/tests/python/view_layer/test_make_single_user.py +++ b/tests/python/view_layer/test_make_single_user.py @@ -33,7 +33,7 @@ class UnitTesting(ViewLayerTesting): while master_collection.collections: master_collection.collections.remove( - master_collection.collections[0]) + master_collection.collections[0]) view_layer.collections.link(master_collection) ob.select_set('SELECT') diff --git a/tests/python/view_layer/test_move_above_below_layer_collection_f.py b/tests/python/view_layer/test_move_above_below_layer_collection_f.py index 77d65ef8671..036486bf55a 100644 --- a/tests/python/view_layer/test_move_above_below_layer_collection_f.py +++ b/tests/python/view_layer/test_move_above_below_layer_collection_f.py @@ -16,36 +16,36 @@ from view_layer_common import * class UnitTesting(MoveLayerCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ['2', None], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ['2', None], + ]], + ] return reference_tree_map def get_reference_layers_tree_map(self): reference_layers_map = [ - ['Layer 1', [ - 'Master Collection', - 'C', - '3', - ]], - ['Layer 2', [ - 'C', - 'dog', - 'cat', - ]], - ] + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + 'C', + 'dog', + 'cat', + ]], + ] return reference_layers_map def test_layer_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_layer_collection_g.py b/tests/python/view_layer/test_move_above_below_layer_collection_g.py index 16cd628edfc..aca6c5d5ff6 100644 --- a/tests/python/view_layer/test_move_above_below_layer_collection_g.py +++ b/tests/python/view_layer/test_move_above_below_layer_collection_g.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveLayerCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['cat', None], - ['dog', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['cat', None], + ['dog', None], + ]], + ]], + ] return reference_tree_map def get_reference_layers_tree_map(self): diff --git a/tests/python/view_layer/test_move_above_below_layer_collection_i.py b/tests/python/view_layer/test_move_above_below_layer_collection_i.py index 0134d11adcd..dada882a412 100644 --- a/tests/python/view_layer/test_move_above_below_layer_collection_i.py +++ b/tests/python/view_layer/test_move_above_below_layer_collection_i.py @@ -20,18 +20,18 @@ class UnitTesting(MoveLayerCollectionTesting): def get_reference_layers_tree_map(self): reference_layers_map = [ - ['Layer 1', [ - 'Master Collection', - 'C', - '3', - ]], - ['Layer 2', [ - '3', - 'C', - 'dog', - 'cat', - ]], - ] + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + '3', + 'C', + 'dog', + 'cat', + ]], + ] return reference_layers_map def test_layer_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_layer_collection_l.py b/tests/python/view_layer/test_move_above_below_layer_collection_l.py index 2bc1054ec7e..a8fad414685 100644 --- a/tests/python/view_layer/test_move_above_below_layer_collection_l.py +++ b/tests/python/view_layer/test_move_above_below_layer_collection_l.py @@ -20,18 +20,18 @@ class UnitTesting(MoveLayerCollectionTesting): def get_reference_layers_tree_map(self): reference_layers_map = [ - ['Layer 1', [ - 'Master Collection', - 'C', - '3', - ]], - ['Layer 2', [ - 'C', - 'cat', - '3', - 'dog', - ]], - ] + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + 'C', + 'cat', + '3', + 'dog', + ]], + ] return reference_layers_map def test_layer_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_a.py b/tests/python/view_layer/test_move_above_below_scene_collection_a.py index 3e45102e0b2..f558491527e 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_a.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_a.py @@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): # original tree, no changes reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_b.py b/tests/python/view_layer/test_move_above_below_scene_collection_b.py index 83980705846..037ee01e205 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_b.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_b.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['3', [ - ['dog', None], - ['cat', None], - ]], - ['1', None], - ['2', None], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['3', [ + ['dog', None], + ['cat', None], + ]], + ['1', None], + ['2', None], + ]], + ] return reference_tree_map def test_scene_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_c.py b/tests/python/view_layer/test_move_above_below_scene_collection_c.py index cceb2bb235b..07b67092d3e 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_c.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_c.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ]], + ] return reference_tree_map def test_scene_collection_move(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_d.py b/tests/python/view_layer/test_move_above_below_scene_collection_d.py index 5917e9ceb6c..9923d917abf 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_d.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_d.py @@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): # original tree, no changes reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['B', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['B', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_e.py b/tests/python/view_layer/test_move_above_below_scene_collection_e.py index 12778ff9131..b9076826551 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_e.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_e.py @@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): # original tree, no changes reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['iii', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['iii', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_f.py b/tests/python/view_layer/test_move_above_below_scene_collection_f.py index b9d5e8eff24..3343d0d774b 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_f.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_f.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['dog', None], - ['cat', None], - ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], ]], - ] + ['dog', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_move(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py index d36930dcbc5..73c79b0de87 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_a.py @@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): # original tree, no changes reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py index 79718e1168a..552ca0d5c9b 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_b.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['3', [ - ['dog', None], - ['cat', None], - ]], - ['1', None], - ['2', None], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['3', [ + ['dog', None], + ['cat', None], + ]], + ['1', None], + ['2', None], + ]], + ] return reference_tree_map def test_scene_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py index ef23b722b8b..c54115b0d13 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_c.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ]], + ] return reference_tree_map def test_scene_collection_move(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py index 05c3bcdbcbb..bb770f61344 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_d.py @@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): # original tree, no changes reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['B', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['B', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py index ebab970ba19..88a77bf8385 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_e.py @@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): # original tree, no changes reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['iii', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['iii', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_move_a(self): diff --git a/tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py b/tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py index 7e4f0bc4a9c..013165986f4 100644 --- a/tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py +++ b/tests/python/view_layer/test_move_above_below_scene_collection_sync_f.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['dog', None], - ['cat', None], - ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], ]], - ] + ['dog', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_move(self): diff --git a/tests/python/view_layer/test_move_into_layer_collection_a.py b/tests/python/view_layer/test_move_into_layer_collection_a.py index ef5a839a44a..85e24e53463 100644 --- a/tests/python/view_layer/test_move_into_layer_collection_a.py +++ b/tests/python/view_layer/test_move_into_layer_collection_a.py @@ -17,38 +17,38 @@ class UnitTesting(MoveLayerCollectionTesting): def get_reference_scene_tree_map(self): # original tree, no changes reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def get_reference_layers_tree_map(self): # original tree, no changes reference_layers_map = [ - ['Layer 1', [ - 'Master Collection', - 'C', - '3', - ]], - ['Layer 2', [ - 'C', - '3', - 'dog', - 'cat', - ]], - ] + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + 'C', + '3', + 'dog', + 'cat', + ]], + ] return reference_layers_map def test_layer_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_layer_collection_f.py b/tests/python/view_layer/test_move_into_layer_collection_f.py index 7bf007d2724..7595619f42a 100644 --- a/tests/python/view_layer/test_move_into_layer_collection_f.py +++ b/tests/python/view_layer/test_move_into_layer_collection_f.py @@ -16,36 +16,36 @@ from view_layer_common import * class UnitTesting(MoveLayerCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ]], + ] return reference_tree_map def get_reference_layers_tree_map(self): reference_layers_map = [ - ['Layer 1', [ - 'Master Collection', - 'C', - ]], - ['Layer 2', [ - 'C', - '3', - 'dog', - 'cat', - ]], - ] + ['Layer 1', [ + 'Master Collection', + 'C', + ]], + ['Layer 2', [ + 'C', + '3', + 'dog', + 'cat', + ]], + ] return reference_layers_map def test_layer_collection_into_a(self): diff --git a/tests/python/view_layer/test_move_into_layer_collection_g.py b/tests/python/view_layer/test_move_into_layer_collection_g.py index efcdd44da97..90f6739d249 100644 --- a/tests/python/view_layer/test_move_into_layer_collection_g.py +++ b/tests/python/view_layer/test_move_into_layer_collection_g.py @@ -20,17 +20,17 @@ class UnitTesting(MoveLayerCollectionTesting): def get_reference_layers_tree_map(self): reference_layers_map = [ - ['Layer 1', [ - 'Master Collection', - 'C', - '3', - ]], - ['Layer 2', [ - 'C', - 'dog', - 'cat', - ]], - ] + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + 'C', + 'dog', + 'cat', + ]], + ] return reference_layers_map def test_layer_collection_into_a(self): diff --git a/tests/python/view_layer/test_move_into_layer_collection_h.py b/tests/python/view_layer/test_move_into_layer_collection_h.py index 82f5d70dceb..0e5a86c57ae 100644 --- a/tests/python/view_layer/test_move_into_layer_collection_h.py +++ b/tests/python/view_layer/test_move_into_layer_collection_h.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveLayerCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', [ - ['dog', None], - ]], - ['2', None], - ['3', [ - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', [ + ['dog', None], + ]], + ['2', None], + ['3', [ + ['cat', None], + ]], + ]], + ] return reference_tree_map def get_reference_layers_tree_map(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_a.py b/tests/python/view_layer/test_move_into_scene_collection_a.py index c5671d46316..ab997ddf9b6 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_a.py +++ b/tests/python/view_layer/test_move_into_scene_collection_a.py @@ -17,21 +17,21 @@ class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): # original tree, no changes reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_b.py b/tests/python/view_layer/test_move_into_scene_collection_b.py index 08cacde6f0c..4254a736b40 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_b.py +++ b/tests/python/view_layer/test_move_into_scene_collection_b.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', [ - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ['C', [ - ['1', None], - ['2', None], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', [ + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ['C', [ + ['1', None], + ['2', None], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_c.py b/tests/python/view_layer/test_move_into_scene_collection_c.py index 83b1d2fc52b..1c9aa295f72 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_c.py +++ b/tests/python/view_layer/test_move_into_scene_collection_c.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', [ ['cat', None], - ]], - ]], ]], - ] + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_e.py b/tests/python/view_layer/test_move_into_scene_collection_e.py index 00a4274c564..f8d37eb769d 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_e.py +++ b/tests/python/view_layer/test_move_into_scene_collection_e.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', [ ['B', None], - ]], - ]], ]], - ] + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_f.py b/tests/python/view_layer/test_move_into_scene_collection_f.py index 4cba04c35a5..a89c7dd81e9 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_f.py +++ b/tests/python/view_layer/test_move_into_scene_collection_f.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', None], - ['B', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', None], + ['B', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_g.py b/tests/python/view_layer/test_move_into_scene_collection_g.py index 5ca2658407f..04919ca720b 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_g.py +++ b/tests/python/view_layer/test_move_into_scene_collection_g.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', [ + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', [ ['A', [ ['i', None], ['ii', None], ['iii', None], - ]], ]], - ['cat', None], - ]], ]], - ] + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_h.py b/tests/python/view_layer/test_move_into_scene_collection_h.py index 1524dbad7bc..57b15c4ef44 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_h.py +++ b/tests/python/view_layer/test_move_into_scene_collection_h.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', [ - ['ii', None], - ]], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', [ + ['ii', None], + ]], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_i.py b/tests/python/view_layer/test_move_into_scene_collection_i.py index 2240ba50d75..7b4076f3fd9 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_i.py +++ b/tests/python/view_layer/test_move_into_scene_collection_i.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', [ + ['A', [ + ['i', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', [ ['ii', None], - ]], - ['cat', None], - ]], ]], - ] + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_b.py b/tests/python/view_layer/test_move_into_scene_collection_sync_b.py index a4d05b57f77..a485d7160d6 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_sync_b.py +++ b/tests/python/view_layer/test_move_into_scene_collection_sync_b.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', [ - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ['C', [ - ['1', None], - ['2', None], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', [ + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ['C', [ + ['1', None], + ['2', None], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_c.py b/tests/python/view_layer/test_move_into_scene_collection_sync_c.py index 3f125d513ce..e68e1d04a56 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_sync_c.py +++ b/tests/python/view_layer/test_move_into_scene_collection_sync_c.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', [ ['cat', None], - ]], - ]], ]], - ] + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_e.py b/tests/python/view_layer/test_move_into_scene_collection_sync_e.py index 689b4976dab..fac8d46e471 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_sync_e.py +++ b/tests/python/view_layer/test_move_into_scene_collection_sync_e.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', [ ['B', None], - ]], - ]], ]], - ] + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_f.py b/tests/python/view_layer/test_move_into_scene_collection_sync_f.py index e486f48aac1..bce9e45a764 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_sync_f.py +++ b/tests/python/view_layer/test_move_into_scene_collection_sync_f.py @@ -16,21 +16,21 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', None], - ['B', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', None], + ['B', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_g.py b/tests/python/view_layer/test_move_into_scene_collection_sync_g.py index 3792e9429a3..8b08eb9f210 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_sync_g.py +++ b/tests/python/view_layer/test_move_into_scene_collection_sync_g.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', [ + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', [ ['A', [ ['i', None], ['ii', None], ['iii', None], - ]], ]], - ['cat', None], - ]], ]], - ] + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_h.py b/tests/python/view_layer/test_move_into_scene_collection_sync_h.py index 8b3ceb14d73..f7eeb00b150 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_sync_h.py +++ b/tests/python/view_layer/test_move_into_scene_collection_sync_h.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', [ - ['ii', None], - ]], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', [ + ['ii', None], + ]], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_move_into_scene_collection_sync_i.py b/tests/python/view_layer/test_move_into_scene_collection_sync_i.py index 8262dcc06c1..373665dd732 100644 --- a/tests/python/view_layer/test_move_into_scene_collection_sync_i.py +++ b/tests/python/view_layer/test_move_into_scene_collection_sync_i.py @@ -16,22 +16,22 @@ from view_layer_common import * class UnitTesting(MoveSceneCollectionSyncTesting): def get_reference_scene_tree_map(self): reference_tree_map = [ - ['A', [ - ['i', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', [ + ['A', [ + ['i', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', [ ['ii', None], - ]], - ['cat', None], - ]], ]], - ] + ['cat', None], + ]], + ]], + ] return reference_tree_map def test_scene_collection_into(self): diff --git a/tests/python/view_layer/test_object_copy.py b/tests/python/view_layer/test_object_copy.py index 15d863f3138..19a7c56b989 100644 --- a/tests/python/view_layer/test_object_copy.py +++ b/tests/python/view_layer/test_object_copy.py @@ -68,7 +68,7 @@ class UnitTesting(ViewLayerTesting): self.assertTrue(compare_files( filepath_objects_json, filepath_json, - ), + ), "Scene dump files differ") def test_copy_object(self): diff --git a/tests/python/view_layer/test_operator_context.py b/tests/python/view_layer/test_operator_context.py index 38379aa2a75..d11666de118 100644 --- a/tests/python/view_layer/test_operator_context.py +++ b/tests/python/view_layer/test_operator_context.py @@ -27,19 +27,19 @@ class UnitTesting(ViewLayerTesting): bl_label = "Sample Operator" view_layer = bpy.props.StringProperty( - default="Not Set", - options={'SKIP_SAVE'}, - ) + default="Not Set", + options={'SKIP_SAVE'}, + ) scene_collection = bpy.props.StringProperty( - default="", - options={'SKIP_SAVE'}, - ) + default="", + options={'SKIP_SAVE'}, + ) use_verbose = bpy.props.BoolProperty( - default=False, - options={'SKIP_SAVE'}, - ) + default=False, + options={'SKIP_SAVE'}, + ) def execute(self, context): view_layer = context.view_layer diff --git a/tests/python/view_layer/test_scene_copy_a.py b/tests/python/view_layer/test_scene_copy_a.py index 8cccb26a92d..8f0f2316ce1 100644 --- a/tests/python/view_layer/test_scene_copy_a.py +++ b/tests/python/view_layer/test_scene_copy_a.py @@ -23,9 +23,9 @@ class UnitTesting(ViewLayerTesting): filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full_simple.json') self.do_scene_copy( - filepath_layers_json_copy, - 'FULL_COPY', - (get_scene_collections,)) + filepath_layers_json_copy, + 'FULL_COPY', + (get_scene_collections,)) # ############################################################ diff --git a/tests/python/view_layer/test_scene_copy_b.py b/tests/python/view_layer/test_scene_copy_b.py index 1d53b56719d..73c6976c32c 100644 --- a/tests/python/view_layer/test_scene_copy_b.py +++ b/tests/python/view_layer/test_scene_copy_b.py @@ -24,9 +24,9 @@ class UnitTesting(ViewLayerTesting): # note: nothing should change, so using `layers_simple.json` filepath_layers_json_copy = os.path.join(ROOT, 'layers_simple.json') self.do_scene_copy( - filepath_layers_json_copy, - 'LINK_OBJECTS', - (get_scene_collections,)) + filepath_layers_json_copy, + 'LINK_OBJECTS', + (get_scene_collections,)) # ############################################################ diff --git a/tests/python/view_layer/test_scene_copy_c.py b/tests/python/view_layer/test_scene_copy_c.py index c9bb0924848..57c875c047c 100644 --- a/tests/python/view_layer/test_scene_copy_c.py +++ b/tests/python/view_layer/test_scene_copy_c.py @@ -23,9 +23,9 @@ class UnitTesting(ViewLayerTesting): filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full.json') self.do_scene_copy( - filepath_layers_json_copy, - 'FULL_COPY', - (get_scene_collections, get_layers)) + filepath_layers_json_copy, + 'FULL_COPY', + (get_scene_collections, get_layers)) # ############################################################ diff --git a/tests/python/view_layer/test_scene_copy_d.py b/tests/python/view_layer/test_scene_copy_d.py index 6efd93c7659..6db3fb797e5 100644 --- a/tests/python/view_layer/test_scene_copy_d.py +++ b/tests/python/view_layer/test_scene_copy_d.py @@ -23,9 +23,9 @@ class UnitTesting(ViewLayerTesting): filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_link.json') self.do_scene_copy( - filepath_layers_json_copy, - 'LINK_OBJECTS', - (get_scene_collections, get_layers)) + filepath_layers_json_copy, + 'LINK_OBJECTS', + (get_scene_collections, get_layers)) # ############################################################ diff --git a/tests/python/view_layer/test_scene_write_read.py b/tests/python/view_layer/test_scene_write_read.py index 6c750d87987..92f3395d819 100644 --- a/tests/python/view_layer/test_scene_write_read.py +++ b/tests/python/view_layer/test_scene_write_read.py @@ -46,7 +46,7 @@ class UnitTesting(ViewLayerTesting): self.assertTrue(compare_files( filepath_doversion_json, filepath_layers_json, - ), + ), "Run: test_scene_write_layers") if do_read: @@ -65,7 +65,7 @@ class UnitTesting(ViewLayerTesting): self.assertTrue(compare_files( filepath_read_json, filepath_layers_json, - ), + ), "Scene dump files differ") def test_scene_write_collections(self): @@ -79,10 +79,10 @@ class UnitTesting(ViewLayerTesting): filepath_layers_json = os.path.join(ROOT, 'layers_simple.json') self.do_scene_write_read( - filepath_layers, - filepath_layers_json, - (get_scene_collections,), - False) + filepath_layers, + filepath_layers_json, + (get_scene_collections,), + False) def test_scene_write_layers(self): """ @@ -95,10 +95,10 @@ class UnitTesting(ViewLayerTesting): filepath_layers_json = os.path.join(ROOT, 'layers.json') self.do_scene_write_read( - filepath_layers, - filepath_layers_json, - (get_scene_collections, get_layers), - False) + filepath_layers, + filepath_layers_json, + (get_scene_collections, get_layers), + False) def test_scene_read_collections(self): """ @@ -112,10 +112,10 @@ class UnitTesting(ViewLayerTesting): filepath_layers_json = os.path.join(ROOT, 'layers_simple.json') self.do_scene_write_read( - filepath_layers, - filepath_layers_json, - (get_scene_collections,), - True) + filepath_layers, + filepath_layers_json, + (get_scene_collections,), + True) def test_scene_read_layers(self): """ @@ -129,10 +129,10 @@ class UnitTesting(ViewLayerTesting): filepath_layers_json = os.path.join(ROOT, 'layers.json') self.do_scene_write_read( - filepath_layers, - filepath_layers_json, - (get_scene_collections, get_layers), - True) + filepath_layers, + filepath_layers_json, + (get_scene_collections, get_layers), + True) # ############################################################ diff --git a/tests/python/view_layer/view_layer_common.py b/tests/python/view_layer/view_layer_common.py index 8dcc094a1c6..25cf7c80d96 100644 --- a/tests/python/view_layer/view_layer_common.py +++ b/tests/python/view_layer/view_layer_common.py @@ -157,11 +157,11 @@ def query_scene(filepath, name, callbacks): def dump(data): import json return json.dumps( - data, - sort_keys=True, - indent=4, - separators=(',', ': '), - ) + data, + sort_keys=True, + indent=4, + separators=(',', ': '), + ) # ############################################################ @@ -170,7 +170,7 @@ def dump(data): PDB = False DUMP_DIFF = True -UPDATE_DIFF = False # HACK used to update tests when something change +UPDATE_DIFF = False # HACK used to update tests when something change def compare_files(file_a, file_b): @@ -188,7 +188,6 @@ def compare_files(file_a, file_b): import subprocess subprocess.call(["cp", "-u", file_a, file_b]) - if PDB: import pdb print("Files differ:", file_b, file_a) @@ -239,8 +238,8 @@ class ViewLayerTesting(unittest.TestCase): def path_exists(self, filepath): import os self.assertTrue( - os.path.exists(filepath), - "Test file \"{0}\" not found".format(filepath)) + os.path.exists(filepath), + "Test file \"{0}\" not found".format(filepath)) def do_object_add(self, filepath_json, add_mode): """ @@ -307,7 +306,7 @@ class ViewLayerTesting(unittest.TestCase): self.assertTrue(compare_files( filepath_objects_json, filepath_json, - ), + ), "Scene dump files differ") def do_object_add_no_collection(self, add_mode): @@ -356,7 +355,7 @@ class ViewLayerTesting(unittest.TestCase): (self.path_exists(f) for f in ( filepath_layers, filepath_json_reference, - )) + )) filepath_saved = os.path.join(dirpath, '{0}.blend'.format(copy_mode)) filepath_json = os.path.join(dirpath, "{0}.json".format(copy_mode)) @@ -376,7 +375,7 @@ class ViewLayerTesting(unittest.TestCase): self.assertTrue(compare_files( filepath_json, filepath_json_reference, - ), + ), "Scene copy \"{0}\" test failed".format(copy_mode.title())) def do_object_delete(self, del_mode): @@ -437,7 +436,7 @@ class ViewLayerTesting(unittest.TestCase): self.assertTrue(compare_files( filepath_generated_json, filepath_reference_json, - ), + ), "Scene dump files differ") def do_visibility_object_add(self, add_mode): @@ -517,23 +516,24 @@ class MoveSceneCollectionTesting(ViewLayerTesting): """ To be used by tests of view_layer_move_into_scene_collection """ + def get_initial_scene_tree_map(self): collections_map = [ - ['A', [ - ['i', None], - ['ii', None], - ['iii', None], - ]], - ['B', None], - ['C', [ - ['1', None], - ['2', None], - ['3', [ - ['dog', None], - ['cat', None], - ]], - ]], - ] + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ] return collections_map def build_scene_tree(self, tree_map, collection=None, ret_dict=None): @@ -565,8 +565,8 @@ class MoveSceneCollectionTesting(ViewLayerTesting): """ self.cleanup_tree() self.assertTrue( - hasattr(self, "get_initial_scene_tree_map"), - "Test class has no get_initial_scene_tree_map method implemented") + hasattr(self, "get_initial_scene_tree_map"), + "Test class has no get_initial_scene_tree_map method implemented") return self.build_scene_tree(self.get_initial_scene_tree_map()) @@ -605,20 +605,21 @@ class MoveSceneCollectionSyncTesting(MoveSceneCollectionTesting): """ To be used by tests of view_layer_move_into_scene_collection_sync """ + def get_initial_layers_tree_map(self): layers_map = [ - ['Layer 1', [ - 'Master Collection', - 'C', - '3', - ]], - ['Layer 2', [ - 'C', - '3', - 'dog', - 'cat', - ]], - ] + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + 'C', + '3', + 'dog', + 'cat', + ]], + ] return layers_map def get_reference_layers_tree_map(self): @@ -634,8 +635,8 @@ class MoveSceneCollectionSyncTesting(MoveSceneCollectionTesting): scene = bpy.context.scene self.assertTrue( - hasattr(self, "get_initial_layers_tree_map"), - "Test class has no get_initial_layers_tree_map method implemented") + hasattr(self, "get_initial_layers_tree_map"), + "Test class has no get_initial_layers_tree_map method implemented") layers_map = self.get_initial_layers_tree_map() @@ -684,6 +685,7 @@ class MoveLayerCollectionTesting(MoveSceneCollectionSyncTesting): """ To be used by tests of view_layer_move_into_layer_collection """ + def parse_move(self, path, sep='.'): """ convert 'Layer 1.C.2' into: @@ -739,15 +741,15 @@ class Clay: # store the variables self._scene_collections = { - 'grandma': scene_collection_grandma, - 'mom': scene_collection_mom, - 'kid': scene_collection_kid, - } + 'grandma': scene_collection_grandma, + 'mom': scene_collection_mom, + 'kid': scene_collection_kid, + } self._layer_collections = { - 'grandma': layer_collection_grandma, - 'mom': layer_collection_mom, - 'kid': layer_collection_kid, - } + 'grandma': layer_collection_grandma, + 'mom': layer_collection_mom, + 'kid': layer_collection_kid, + } if extra_kid_layer: layer_collection_extra = self._layer.collections.link(scene_collection_kid) @@ -765,7 +767,7 @@ class Clay: # remove all the other collections while self._scene.master_collection.collections: self._scene.master_collection.collections.remove( - self._scene.master_collection.collections[0]) + self._scene.master_collection.collections[0]) layer = self._scene.view_layers.new('Evaluation Test') layer.collections.unlink(layer.collections[0]) @@ -790,9 +792,9 @@ class Clay: # change scene settings self._properties = { - 'scene': self._scene.collection_properties[ENGINE], - 'object': self._object.collection_properties[ENGINE], - } + 'scene': self._scene.collection_properties[ENGINE], + 'object': self._object.collection_properties[ENGINE], + } for key, value in self._layer_collections.items(): self._properties[key] = self._layer_collections[key].engine_overrides[ENGINE] -- cgit v1.2.3 From 105192e5a288472fd7670a43499e44805f35b252 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 07:13:27 +0200 Subject: Cleanup: pep8 --- release/scripts/modules/bpy_extras/node_utils.py | 4 +++- release/scripts/modules/bpy_extras/object_utils.py | 20 ++++++++++---------- release/scripts/modules/bpy_types.py | 1 - release/scripts/startup/bl_ui/space_dopesheet.py | 1 - release/scripts/startup/bl_ui/space_outliner.py | 1 - source/blender/datatoc/datatoc_icon_split.py | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/release/scripts/modules/bpy_extras/node_utils.py b/release/scripts/modules/bpy_extras/node_utils.py index 9a2be5b9f68..d459b99ddd0 100644 --- a/release/scripts/modules/bpy_extras/node_utils.py +++ b/release/scripts/modules/bpy_extras/node_utils.py @@ -21,7 +21,7 @@ __all__ = ( "find_node_input", "find_output_node", - ) +) # XXX Names are not unique. Returns the first match. @@ -34,6 +34,8 @@ def find_node_input(node, name): # Return the output node to display in the UI. In case multiple node types are # specified, node types earlier in the list get priority. + + def find_output_node(ntree, nodetypes): if ntree: output_node = None diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index 8eec912da93..fcecb4cdd61 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -195,18 +195,18 @@ class AddObjectHelper: self.rotation.zero() view_align = BoolProperty( - name="Align to View", - default=False, - update=view_align_update_callback, - ) + name="Align to View", + default=False, + update=view_align_update_callback, + ) location = FloatVectorProperty( - name="Location", - subtype='TRANSLATION', - ) + name="Location", + subtype='TRANSLATION', + ) rotation = FloatVectorProperty( - name="Rotation", - subtype='EULER', - ) + name="Rotation", + subtype='EULER', + ) @classmethod def poll(self, context): diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index ee49e8a6630..4cc792c7cb3 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -942,7 +942,6 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): props = row.operator(add_operator, text="", icon='ZOOMIN') props.name = wm.preset_name - def draw_preset(self, context): """ Define these on the subclass: diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index e03d53a1870..aeda521ba04 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -280,7 +280,6 @@ class DOPESHEET_HT_editor_buttons(Header): sub.active = toolsettings.use_proportional_action sub.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True) - row = layout.row(align=True) row.operator("action.copy", text="", icon='COPYDOWN') row.operator("action.paste", text="", icon='PASTEDOWN') diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index 19f3bcd3b1f..f19b0304afa 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -134,7 +134,6 @@ class OUTLINER_MT_edit_datablocks(Menu): layout.operator("outliner.drivers_delete_selected") - class OUTLINER_MT_collection_view_layer(Menu): bl_label = "View Layer" diff --git a/source/blender/datatoc/datatoc_icon_split.py b/source/blender/datatoc/datatoc_icon_split.py index faf8d57be77..e7cc3a71446 100755 --- a/source/blender/datatoc/datatoc_icon_split.py +++ b/source/blender/datatoc/datatoc_icon_split.py @@ -101,7 +101,7 @@ def write_subimage(sub_x, sub_y, sub_w, sub_h, sub_w, sub_h, sub_x, sub_y, # redundant but including to maintain consistency - pixel_w, pixel_h, + pixel_w, pixel_h, )) for y in range(sub_h): -- cgit v1.2.3 From eb7286bfd2f8dc21cbd019b9085489652c392eba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 07:22:26 +0200 Subject: Python: Print file:line when editing UI source --- source/blender/editors/interface/interface_ops.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index cd7d2e27d9a..9a4ea41141a 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -730,11 +730,14 @@ void UI_editsource_active_but_test(uiBut *but) static int editsource_text_edit( bContext *C, wmOperator *op, - char filepath[FILE_MAX], int line) + const char filepath[FILE_MAX], const int line) { struct Main *bmain = CTX_data_main(C); Text *text; + /* Developers may wish to copy-paste to an external editor. */ + printf("%s:%d\n", filepath, line); + for (text = bmain->text.first; text; text = text->id.next) { if (text->name && BLI_path_cmp(text->name, filepath) == 0) { break; -- cgit v1.2.3 From 1ff5cc8c1ac7e4262b131a63c7e0fbb7d4fa8a8d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 07:58:10 +0200 Subject: addons: disable addons with versions below 2.8 --- release/scripts/modules/addon_utils.py | 10 ++++++++++ release/scripts/startup/bl_ui/space_userpref.py | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 1b6dae68684..c96acb002af 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -351,6 +351,16 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non _addon_remove(module_name) return None + # 1.1) fail when add-on is too old + # This is a temporary 2.8x migration check, so we can manage addons that are supported. + try: + print(mod.bl_info.get("blender", (0, 0, 0))) + if mod.bl_info.get("blender", (0, 0, 0)) < (2, 80, 0): + raise Exception(f"Add-on '{module_name:s}' has not been upgraded to 2.8, ignoring") + except Exception as ex: + handle_error(ex) + return None + # 2) try register collected modules # removed, addons need to handle own registration now. diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 4ce14f5ac89..1f00f8af1ff 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1473,7 +1473,15 @@ class USERPREF_PT_addons(Panel): sub = row.row() sub.active = is_enabled sub.label(text="%s: %s" % (info["category"], info["name"])) - if info["warning"]: + + + # WARNING: 2.8x exception, may be removed + # use disabled state for old add-ons, chances are they are broken. + if info.get("blender", (0,)) < (2, 80): + sub.label(text="upgrade to 2.8x required") + sub.label(icon='ERROR') + # Remove code above after 2.8x migration is complete. + elif info["warning"]: sub.label(icon='ERROR') # icon showing support level. -- cgit v1.2.3 From d7982f71e95e5caecb31dca54eb3cf0670aabbb3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 09:02:50 +0200 Subject: Keymap: remove 'Screen Editing' from 2.7x map Uses action-zones which aren't currently working in keymap presets. --- release/scripts/presets/keyconfig/blender_27x.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index 9410c20bac2..e6c036d04d7 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -412,26 +412,6 @@ if platform == "darwin": kmi = km.keymap_items.new('screen.userpref_show', 'COMMA', 'PRESS', oskey=True) kmi = km.keymap_items.new('screen.userpref_show', 'U', 'PRESS', ctrl=True, alt=True) -# Map Screen Editing -km = kc.keymaps.new('Screen Editing', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('screen.actionzone', 'LEFTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'modifier', 0) -kmi = km.keymap_items.new('screen.actionzone', 'LEFTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'modifier', 1) -kmi = km.keymap_items.new('screen.actionzone', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'modifier', 2) -kmi = km.keymap_items.new('screen.area_split', 'NONE', 'ANY') -kmi = km.keymap_items.new('screen.area_join', 'NONE', 'ANY') -kmi = km.keymap_items.new('screen.area_dupli', 'NONE', 'ANY', shift=True) -kmi = km.keymap_items.new('screen.area_swap', 'NONE', 'ANY', ctrl=True) -kmi = km.keymap_items.new('screen.region_scale', 'NONE', 'ANY') -kmi = km.keymap_items.new('screen.screen_full_area', 'NONE', 'ANY') -kmi_props_setattr(kmi.properties, 'use_hide_panels', True) -kmi = km.keymap_items.new('screen.area_move', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('screen.area_options', 'RIGHTMOUSE', 'PRESS') -kmi = km.keymap_items.new('screen.header', 'F9', 'PRESS', alt=True) - # Map User Interface km = kc.keymaps.new('User Interface', space_type='EMPTY', region_type='WINDOW', modal=False) -- cgit v1.2.3 From 39678442e1ed515f84d62ac75b11086699d4e8b3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 09:08:00 +0200 Subject: Cleanup: typos --- source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h | 2 +- source/blender/draw/engines/eevee/eevee_lightprobes.c | 6 +++--- source/blender/draw/engines/eevee/eevee_lights.c | 4 ++-- source/blender/draw/engines/eevee/eevee_private.h | 2 +- source/blender/draw/intern/DRW_render.h | 2 +- source/blender/draw/intern/draw_armature.c | 2 +- source/blender/draw/intern/draw_cache_impl_curve.c | 2 +- source/blender/draw/intern/draw_cache_impl_mesh.c | 2 +- source/blender/draw/intern/draw_manager_exec.c | 4 ++-- source/blender/editors/space_outliner/outliner_ops.c | 2 +- source/creator/creator.c | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h index 8fca90e9f5b..40b1f94c7bc 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h @@ -34,7 +34,7 @@ struct ID; -/* Unkomment this to have verbose log about original and CoW pointers +/* Uncomment this to have verbose log about original and CoW pointers * logged, with detailed information when they are allocated, expanded * and remapped. */ diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index a45d69794f3..346938b19f8 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -1250,9 +1250,9 @@ static void render_scene_to_probe( /* Move to capture position */ negate_v3_v3(posmat[3], pos); - /* 1 - Render to each cubeface individually. + /* 1 - Render to each cube-face individually. * We do this instead of using geometry shader because a) it's faster, - * b) it's easier than fixing the nodetree shaders (for view dependant effects). */ + * b) it's easier than fixing the node-tree shaders (for view dependent effects). */ pinfo->layer = 0; perspective_m4(winmat, -clipsta, clipsta, -clipsta, clipsta, clipsta, clipend); @@ -1349,7 +1349,7 @@ static void render_scene_to_planar( EEVEE_draw_shadows(sldata, psl); /* Since we are rendering with an inverted view matrix, we need - * to invert the facing for backface culling to be the same. */ + * to invert the facing for back-face culling to be the same. */ DRW_state_invert_facing(); /* Set clipping plan */ copy_v4_v4(sldata->clip_data.clip_planes[0], ped->planer_eq_offset); diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index f5673d1a616..880519911ed 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -1086,7 +1086,7 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl) DRW_uniformbuffer_update(sldata->shadow_render_ubo, srd); /* Render shadow cube */ - /* Render 6 faces separatly: seems to be faster for the general case. + /* Render 6 faces separately: seems to be faster for the general case. * The only time it's more beneficial is when the CPU culling overhead * outweight the instancing overhead. which is rarelly the case. */ for (int j = 0; j < 6; j++) { @@ -1193,7 +1193,7 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl) invert_m4_m4(render_mats.mat[DRW_MAT_VIEWINV], viewmat); /* Render shadow cascades */ - /* Render cascade separatly: seems to be faster for the general case. + /* Render cascade separately: seems to be faster for the general case. * The only time it's more beneficial is when the CPU culling overhead * outweight the instancing overhead. which is rarelly the case. */ for (int j = 0; j < la->cascade_count; j++) { diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index fa9d2453934..d077668197d 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -587,7 +587,7 @@ typedef struct EEVEE_EffectsInfo { /* Common uniform buffer containing all "constant" data over the whole drawing pipeline. */ /* !! CAUTION !! - * - [i]vec3 need to be paded to [i]vec4 (even in ubo declaration). + * - [i]vec3 need to be padded to [i]vec4 (even in ubo declaration). * - Make sure that [i]vec4 start at a multiple of 16 bytes. * - Arrays of vec2/vec3 are padded as arrays of vec4. * - sizeof(bool) == sizeof(int) in GLSL so use int in C */ diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index d6187e32036..fdb1b87589e 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -431,7 +431,7 @@ void DRW_viewport_matrix_override_set_all(DRWMatrixState *state); void DRW_viewport_matrix_override_unset(DRWViewportMatrixType type); void DRW_viewport_matrix_override_unset_all(void); -/* Thoses are in viewspace so negative if in persp. +/* These are in view-space so negative if in perspective. * Extract near and far clip distance from the projection matrix. */ float DRW_viewport_near_distance_get(void); float DRW_viewport_far_distance_get(void); diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index 82662d77020..3faf8a352b2 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -1298,7 +1298,7 @@ static void draw_bone_line( drw_shgroup_bone_stick(BONE_VAR(eBone, pchan, disp_mat), col_wire, col_bone, col_head, col_tail); } else { - /* In selection mode, draw bone, root and tip separatly. */ + /* In selection mode, draw bone, root and tip separately. */ DRW_select_load_id(select_id | BONESEL_BONE); drw_shgroup_bone_stick(BONE_VAR(eBone, pchan, disp_mat), col_wire, col_bone, no_display, no_display); diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 3939ea062e9..1bf34953dc6 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -61,7 +61,7 @@ enum { * TODO * - Ensure `CurveCache`, `SEQUENCER_DAG_WORKAROUND`. * - Check number of verts/edges to see if cache is valid. - * - Check if 'overlay.edges' can use single attribyte per edge, not 2 (for selection drawing). + * - Check if 'overlay.edges' can use single attribute per edge, not 2 (for selection drawing). */ static void curve_batch_cache_clear(Curve *cu); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index df91af8123a..eafcfb007e7 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -1595,7 +1595,7 @@ typedef struct MeshBatchCache { int edges_face_overlay_tri_count; /* Number of tri in edges_face_overlay(_adj)_tx */ /* Maybe have shaded_triangles_data split into pos_nor and uv_tangent - * to minimise data transfer for skinned mesh. */ + * to minimize data transfer for skinned mesh. */ Gwn_VertFormat shaded_triangles_format; Gwn_VertBuf *shaded_triangles_data; Gwn_IndexBuf **shaded_triangles_in_order; diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 3b7d19ac361..03692fd9475 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -923,7 +923,7 @@ static void release_texture_slots(bool with_persist) } } - /* Reset so that slots are consistenly assigned for different shader + /* Reset so that slots are consistently assigned for different shader * draw calls, to avoid shader specialization/patching by the driver. */ DST.RST.bind_tex_inc = 0; } @@ -940,7 +940,7 @@ static void release_ubo_slots(bool with_persist) } } - /* Reset so that slots are consistenly assigned for different shader + /* Reset so that slots are consistently assigned for different shader * draw calls, to avoid shader specialization/patching by the driver. */ DST.RST.bind_ubo_inc = 0; } diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 4d8c0c5bd38..38640a0e23d 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -467,7 +467,7 @@ static wmKeyMap *outliner_item_drag_drop_modal_keymap(wmKeyConfig *keyconf) {OUTLINER_ITEM_DRAG_CONFIRM, "CONFIRM", 0, "Confirm/Drop", ""}, {0, NULL, 0, NULL, NULL} }; - const char *map_name = "Outliner Item Drap & Drop Modal Map"; + const char *map_name = "Outliner Item Drag & Drop Modal Map"; wmKeyMap *keymap = WM_modalkeymap_get(keyconf, map_name); diff --git a/source/creator/creator.c b/source/creator/creator.c index 6fd5771434c..18396149342 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -236,7 +236,7 @@ int main( struct CreatorAtExitData app_init_data = {NULL}; BKE_blender_atexit_register(callback_main_atexit, &app_init_data); - /* Unbuffered stdout makes stdout and stderr better synchronised, and helps + /* Unbuffered stdout makes stdout and stderr better synchronized, and helps * when stepping through code in a debugger (prints are immediately * visible). */ setvbuf(stdout, NULL, _IONBF, 0); -- cgit v1.2.3 From 8dc18b54adcba4ba78821f3f50f4755b052c2350 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 3 Jul 2018 09:13:34 +0200 Subject: Workbench: Fix ghosting and crash in X-Ray mode When playing animations the anti-aliasing was not reset, resulting in ghosts from previous frames to be drawn. Also when playing animations and switching to X-Ray mode for the first time would most likely result in a write to uninitialized memory. --- source/blender/draw/engines/workbench/transparent_mode.c | 8 +++++++- source/blender/draw/engines/workbench/workbench_effect_taa.c | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/source/blender/draw/engines/workbench/transparent_mode.c b/source/blender/draw/engines/workbench/transparent_mode.c index 3c4f7796c2b..195b8371165 100644 --- a/source/blender/draw/engines/workbench/transparent_mode.c +++ b/source/blender/draw/engines/workbench/transparent_mode.c @@ -76,6 +76,12 @@ static void workbench_transparent_engine_free(void) workbench_forward_engine_free(); } +static void workbench_transparent_view_update(void *vedata) +{ + WORKBENCH_Data *data = vedata; + workbench_taa_view_updated(data); +} + static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data); DrawEngineType draw_engine_workbench_transparent = { @@ -89,7 +95,7 @@ DrawEngineType draw_engine_workbench_transparent = { &workbench_transparent_cache_finish, &workbench_transparent_draw_background, &workbench_transparent_draw_scene, - NULL, + &workbench_transparent_view_update, NULL, NULL, }; diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c index 0b4cc0a4e5b..33dce443935 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_taa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c @@ -287,6 +287,13 @@ void workbench_taa_draw_scene_end(WORKBENCH_Data *vedata) void workbench_taa_view_updated(WORKBENCH_Data *vedata) { - WORKBENCH_EffectInfo *effect_info = vedata->stl->effects; - effect_info->view_updated = true; + WORKBENCH_StorageList *stl = vedata->stl; + if (stl) + { + WORKBENCH_EffectInfo *effect_info = stl->effects; + if (effect_info) + { + effect_info->view_updated = true; + } + } } -- cgit v1.2.3 From 6016abc1a34550c76dab7a24d2e739cef2d0944f Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 3 Jul 2018 09:54:25 +0200 Subject: Workbench: Fix texture drawing Somehow not sure when the test for textures was performed on an uninitialized variable resulting in never showing the textures at all --- source/blender/draw/engines/workbench/workbench_private.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 3bec6bb6d53..f50d4a7f0cd 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -41,7 +41,7 @@ #define M_GOLDEN_RATION_CONJUGATE 0.618033988749895 #define MAX_SHADERS (1 << 10) -#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->color_type & V3D_SHADING_TEXTURE_COLOR) +#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->shading.color_type & V3D_SHADING_TEXTURE_COLOR) #define FLAT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_FLAT) #define STUDIOLIGHT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_STUDIO) #define MATCAP_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_MATCAP) @@ -59,7 +59,6 @@ #define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd) || SPECULAR_HIGHLIGHT_ENABLED(wpd)) #define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) || CAVITY_ENABLED(wpd)) #define NORMAL_ENCODING_ENABLED() (true) -#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->color_type & V3D_SHADING_TEXTURE_COLOR) typedef struct WORKBENCH_FramebufferList { @@ -153,7 +152,6 @@ typedef struct WORKBENCH_PrivateData { View3DShading shading; StudioLight *studio_light; UserDef *user_preferences; - int color_type; struct GPUUniformBuffer *world_ubo; struct DRWShadingGroup *shadow_shgrp; struct DRWShadingGroup *depth_shgrp; -- cgit v1.2.3 From 4bc11b72e5a13ddb4b7d15eb9e33dad7a93edbf6 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 3 Jul 2018 10:25:07 +0200 Subject: Workbench: CleanUp whitespaces --- .../draw/engines/workbench/workbench_effect_taa.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c index 33dce443935..302cb27cbb9 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_taa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c @@ -287,13 +287,13 @@ void workbench_taa_draw_scene_end(WORKBENCH_Data *vedata) void workbench_taa_view_updated(WORKBENCH_Data *vedata) { - WORKBENCH_StorageList *stl = vedata->stl; - if (stl) - { - WORKBENCH_EffectInfo *effect_info = stl->effects; - if (effect_info) - { - effect_info->view_updated = true; - } - } + WORKBENCH_StorageList *stl = vedata->stl; + if (stl) + { + WORKBENCH_EffectInfo *effect_info = stl->effects; + if (effect_info) + { + effect_info->view_updated = true; + } + } } -- cgit v1.2.3 From a9211e808c10fa267dbca2baa705560a5d980526 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 10:15:26 +0200 Subject: UI: hide empty status mouse button when dragging --- source/blender/editors/interface/interface_templates.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index fbfa64cbdbd..271eef051c6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -4357,7 +4357,9 @@ void uiTemplateInputStatus(uiLayout *layout, struct bContext *C) const char *msg = WM_window_cursor_keymap_status_get(win, i, 0); const char *msg_drag = WM_window_cursor_keymap_status_get(win, i, 1); - uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i)); + if (msg || (msg_drag == NULL)) { + uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i)); + } if (msg_drag) { uiItemL(row, msg_drag, (ICON_MOUSE_LMB_DRAG + i)); -- cgit v1.2.3 From a94d582a40ffc06b19f0e4af6ba107c1433fcb1e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 3 Jul 2018 11:04:12 +0200 Subject: Sculpt: Fix possible race condition with undo nodes it is possible that two threads will request same undo node, only one of them will initialize the node. The issue is that initialization is happening outside of a lock, which was making one thread to use non- initialized node. If this change is ever a bottleneck, make a lock inside of node. --- source/blender/editors/sculpt_paint/sculpt_undo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index bc22147b15d..61f7c3bd0d9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -931,9 +931,10 @@ SculptUndoNode *sculpt_undo_push_node( unode = sculpt_undo_alloc_node(ob, node, type); - BLI_thread_unlock(LOCK_CUSTOM1); - - /* copy threaded, hopefully this is the performance critical part */ + /* NOTE: If this ever becomes a bottleneck, make a lock inside of the node. + * so we release global lock sooner, but keep data locked for until it is + * fully initialized. + */ if (unode->grids) { int totgrid, *grids; @@ -970,6 +971,8 @@ SculptUndoNode *sculpt_undo_push_node( if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); else unode->shapeName[0] = '\0'; + BLI_thread_unlock(LOCK_CUSTOM1); + return unode; } -- cgit v1.2.3 From b4ccec67429b4bd9f738c11627240c07f60d6bd0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Jul 2018 12:15:25 +0200 Subject: Fix ID buttons not working in popover menus. --- .../editors/interface/interface_templates.c | 27 ++++------------------ 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 271eef051c6..a14d12492ec 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -394,32 +394,15 @@ void UI_context_active_but_prop_get_templateID( PointerRNA *r_ptr, PropertyRNA **r_prop) { TemplateID *template_ui; - ARegion *ar = CTX_wm_region(C); - uiBlock *block; - uiBut *but; - - memset(r_ptr, 0, sizeof(*r_ptr)); - *r_prop = NULL; - - if (!ar) - return; + uiBut *but = UI_context_active_but_get(C); - for (block = ar->uiblocks.first; block; block = block->next) { - for (but = block->buttons.first; but; but = but->next) { - /* find the button before the active one */ - if ((but->flag & (UI_BUT_LAST_ACTIVE | UI_ACTIVE))) { - if (but->func_argN) { - template_ui = but->func_argN; - *r_ptr = template_ui->ptr; - *r_prop = template_ui->prop; - return; - } - } - } + if (but && but->func_argN) { + template_ui = but->func_argN; + *r_ptr = template_ui->ptr; + *r_prop = template_ui->prop; } } - static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) { TemplateID *template_ui = (TemplateID *)arg_litem; -- cgit v1.2.3 From 72a051f9578a92ef1d3977c060c6465b43175886 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Jul 2018 12:18:06 +0200 Subject: Cleanup: remove generation context from image new operator. --- .../scripts/startup/bl_ui/space_view3d_toolbar.py | 15 +-- source/blender/editors/space_image/image_ops.c | 114 +++++++++------------ 2 files changed, 53 insertions(+), 76 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 8d78d674922..62cff9d6e42 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -247,18 +247,14 @@ class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel): col.label("Missing Canvas", icon='INFO') col.label("Add or assign a canvas image below") col.label("Canvas Image:") - # todo this should be combinded into a single row - col.template_ID(toolsettings, "canvas", open="image.open") - col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS' + col.template_ID(toolsettings, "canvas", new="image.new", open="image.open") if toolsettings.missing_stencil: col.separator() col.label("Missing Stencil", icon='INFO') col.label("Add or assign a stencil image below") col.label("Stencil Image:") - # todo this should be combinded into a single row - col.template_ID(toolsettings, "stencil_image", open="image.open") - col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL' + col.template_ID(toolsettings, "stencil_image", new="image.new", open="image.open") # TODO, move to space_view3d.py @@ -585,9 +581,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel): mesh = ob.data uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else "" col.label("Canvas Image:") - # todo this should be combinded into a single row - col.template_ID(settings, "canvas", open="image.open") - col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS' + col.template_ID(settings, "canvas", new="image.new", open="image.open") col.label("UV Map:") col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False) @@ -635,8 +629,7 @@ class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel): colsub.alignment = 'RIGHT' colsub.label("Stencil Image") colsub = split.column() - colsub.template_ID(ipaint, "stencil_image", open="image.open") - colsub.operator("image.new", text="New").gen_context = 'PAINT_STENCIL' + colsub.template_ID(ipaint, "stencil_image", new="image.new", open="image.open") row = col.row(align=True) row.prop(ipaint, "stencil_color", text="Display Color") diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 3efdce3ea6d..f852f601db2 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1231,7 +1231,6 @@ static int image_open_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); ImageUser *iuser = NULL; ImageOpenData *iod = op->customdata; - PointerRNA idptr; Image *ima = NULL; char filepath[FILE_MAX]; int frame_seq_len = 0; @@ -1297,8 +1296,9 @@ static int image_open_exec(bContext *C, wmOperator *op) * pointer use also increases user, so this compensates it */ id_us_min(&ima->id); - RNA_id_pointer_create(&ima->id, &idptr); - RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, idptr); + PointerRNA imaptr; + RNA_id_pointer_create(&ima->id, &imaptr); + RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, imaptr); RNA_property_update(C, &iod->pprop.ptr, iod->pprop.prop); } @@ -2382,6 +2382,30 @@ enum { GEN_CONTEXT_PAINT_STENCIL = 2 }; +typedef struct ImageNewData { + PropertyPointerRNA pprop; +} ImageNewData; + +static ImageNewData *image_new_init(bContext *C, wmOperator *op) +{ + if (op->customdata) { + return op->customdata; + } + + ImageNewData *data = MEM_callocN(sizeof(ImageNewData), __func__); + UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop); + op->customdata = data; + return data; +} + +static void image_new_free(wmOperator *op) +{ + if (op->customdata) { + MEM_freeN(op->customdata); + op->customdata = NULL; + } +} + static int image_new_exec(bContext *C, wmOperator *op) { SpaceImage *sima; @@ -2389,13 +2413,11 @@ static int image_new_exec(bContext *C, wmOperator *op) Object *obedit; Image *ima; Main *bmain; - PointerRNA ptr, idptr; PropertyRNA *prop; char name_buffer[MAX_ID_NAME - 2]; const char *name; float color[4]; int width, height, floatbuf, gen_type, alpha; - int gen_context; int stereo3d; /* retrieve state */ @@ -2419,7 +2441,6 @@ static int image_new_exec(bContext *C, wmOperator *op) gen_type = RNA_enum_get(op->ptr, "generated_type"); RNA_float_get_array(op->ptr, "color", color); alpha = RNA_boolean_get(op->ptr, "alpha"); - gen_context = RNA_enum_get(op->ptr, "gen_context"); stereo3d = RNA_boolean_get(op->ptr, "use_stereo_3d"); if (!alpha) @@ -2427,79 +2448,44 @@ static int image_new_exec(bContext *C, wmOperator *op) ima = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d); - if (!ima) + if (!ima) { + image_new_free(op); return OPERATOR_CANCELLED; + } /* hook into UI */ - UI_context_active_but_prop_get_templateID(C, &ptr, &prop); + ImageNewData *data = image_new_init(C, op); - if (prop) { + if (data->pprop.prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer use also increases user, so this compensates it */ id_us_min(&ima->id); - RNA_id_pointer_create(&ima->id, &idptr); - RNA_property_pointer_set(&ptr, prop, idptr); - RNA_property_update(C, &ptr, prop); + PointerRNA imaptr; + RNA_id_pointer_create(&ima->id, &imaptr); + RNA_property_pointer_set(&data->pprop.ptr, data->pprop.prop, imaptr); + RNA_property_update(C, &data->pprop.ptr, data->pprop.prop); } else if (sima) { ED_space_image_set(bmain, sima, scene, obedit, ima); } - else if (gen_context == GEN_CONTEXT_PAINT_CANVAS) { - bScreen *sc; - Object *ob = CTX_data_active_object(C); - - if (scene->toolsettings->imapaint.canvas) - id_us_min(&scene->toolsettings->imapaint.canvas->id); - scene->toolsettings->imapaint.canvas = ima; - - for (sc = bmain->screen.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { - SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_IMAGE) { - SpaceImage *sima_other = (SpaceImage *)sl; - - if (!sima_other->pin) { - ED_space_image_set(bmain, sima_other, scene, obedit, ima); - } - } - } - } - } - BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); - } - else if (gen_context == GEN_CONTEXT_PAINT_STENCIL) { - Object *ob = CTX_data_active_object(C); - if (scene->toolsettings->imapaint.stencil) - id_us_min(&scene->toolsettings->imapaint.stencil->id); - scene->toolsettings->imapaint.stencil = ima; - BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); - } - else { - Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - if (tex && tex->type == TEX_IMAGE) { - if (tex->ima) - id_us_min(&tex->ima->id); - tex->ima = ima; - ED_area_tag_redraw(CTX_wm_area(C)); - } - } BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE); WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima); + image_new_free(op); + return OPERATOR_FINISHED; } -/* XXX, Ton is not a fan of OK buttons but using this function to avoid undo/redo bug while in mesh-editmode, - campbell */ -/* XXX Note: the WM_operator_props_dialog_popup() doesn't work for UI_context_active_but_prop_get_templateID(), image is not being that way */ static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { + /* Get property in advance, it doesn't work after WM_operator_props_dialog_popup. */ + ImageNewData *data; + op->customdata = data = MEM_callocN(sizeof(ImageNewData), __func__); + UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop); + /* Better for user feedback. */ RNA_string_set(op->ptr, "name", DATA_(IMA_DEF_NAME)); return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, 5 * UI_UNIT_Y); @@ -2552,18 +2538,16 @@ static void image_new_draw(bContext *UNUSED(C), wmOperator *op) #endif } +static void image_new_cancel(bContext *UNUSED(C), wmOperator *op) +{ + image_new_free(op); +} + void IMAGE_OT_new(wmOperatorType *ot) { PropertyRNA *prop; static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - static const EnumPropertyItem gen_context_items[] = { - {GEN_CONTEXT_NONE, "NONE", 0, "None", ""}, - {GEN_CONTEXT_PAINT_CANVAS, "PAINT_CANVAS", 0, "Paint Canvas", ""}, - {GEN_CONTEXT_PAINT_STENCIL, "PAINT_STENCIL", 0, "Paint Stencil", ""}, - {0, NULL, 0, NULL, NULL} - }; - /* identifiers */ ot->name = "New Image"; ot->description = "Create a new image"; @@ -2573,6 +2557,7 @@ void IMAGE_OT_new(wmOperatorType *ot) ot->exec = image_new_exec; ot->invoke = image_new_invoke; ot->ui = image_new_draw; + ot->cancel = image_new_cancel; /* flags */ ot->flag = OPTYPE_UNDO; @@ -2590,7 +2575,6 @@ void IMAGE_OT_new(wmOperatorType *ot) RNA_def_enum(ot->srna, "generated_type", rna_enum_image_generated_type_items, IMA_GENTYPE_BLANK, "Generated Type", "Fill the image with a grid for UV map testing"); RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth"); - prop = RNA_def_enum(ot->srna, "gen_context", gen_context_items, 0, "Gen Context", "Generation context"); RNA_def_property_flag(prop, PROP_HIDDEN); prop = RNA_def_boolean(ot->srna, "use_stereo_3d", 0, "Stereo 3D", "Create an image with left and right views"); RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); -- cgit v1.2.3 From cf2096cfd93f55b7e0fb096c3ca74946c83b32f1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 2 Jul 2018 18:53:04 +0200 Subject: Nodes: add new image button to image nodes. --- source/blender/editors/space_node/drawnode.c | 10 +++++----- source/blender/nodes/composite/nodes/node_composite_image.c | 1 + .../blender/nodes/shader/nodes/node_shader_tex_environment.c | 1 + source/blender/nodes/shader/nodes/node_shader_tex_image.c | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 12da5086c52..da49a772688 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -743,7 +743,7 @@ static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user"); uiLayoutSetContextPointer(layout, "image_user", &iuserptr); - uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); + uiTemplateID(layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); uiItemR(layout, ptr, "interpolation", 0, "", ICON_NONE); uiItemR(layout, ptr, "projection", 0, "", ICON_NONE); @@ -774,7 +774,7 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin uiLayoutSetContextPointer(layout, "image_user", &iuserptr); uiTemplateID( layout, C, ptr, "image", - NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); + "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr, false); @@ -792,7 +792,7 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P uiLayoutSetContextPointer(layout, "image_user", &iuserptr); uiTemplateID( layout, C, ptr, "image", - ima ? NULL : "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); + "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); if (!ima) return; @@ -1253,7 +1253,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * uiLayoutSetContextPointer(layout, "image_user", &iuserptr); uiTemplateID( layout, C, ptr, "image", - NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); + "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); if (!node->id) return; imaptr = RNA_pointer_get(ptr, "image"); @@ -2794,7 +2794,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr) { - uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); + uiTemplateID(layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); } static void node_texture_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 8bdaa39f3b7..a754066dea3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -442,6 +442,7 @@ void register_node_type_cmp_rlayers(void) node_type_storage(&ntype, NULL, node_composit_free_rlayers, node_composit_copy_rlayers); node_type_update(&ntype, cmp_node_rlayers_update, NULL); node_type_init(&ntype, node_cmp_rlayers_outputs); + node_type_size_preset(&ntype, NODE_SIZE_LARGE); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index d441a674838..02b784ca540 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -103,6 +103,7 @@ void register_node_type_sh_tex_environment(void) node_type_storage(&ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage); node_type_gpu(&ntype, node_shader_gpu_tex_environment); node_type_label(&ntype, node_image_label); + node_type_size_preset(&ntype, NODE_SIZE_LARGE); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index 2c958c6478d..e27cf02f445 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -127,6 +127,7 @@ void register_node_type_sh_tex_image(void) node_type_storage(&ntype, "NodeTexImage", node_free_standard_storage, node_copy_standard_storage); node_type_gpu(&ntype, node_shader_gpu_tex_image); node_type_label(&ntype, node_image_label); + node_type_size_preset(&ntype, NODE_SIZE_LARGE); nodeRegisterType(&ntype); } -- cgit v1.2.3 From 268bcb8027161ea5fe367c2df6cf2e94450eb50a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 3 Jul 2018 12:28:45 +0200 Subject: Sculpt: Fix ghosting artifacts when sculpting in workbench engine --- source/blender/editors/sculpt_paint/sculpt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index bb2000d1651..946757d5d20 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4870,6 +4870,8 @@ static void sculpt_flush_update(bContext *C) if (mmd) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + DEG_id_tag_update(&ob->id, DEG_TAG_SHADING_UPDATE); + if (ss->kb || ss->modifiers_active) { DEG_id_tag_update(&ob->id, OB_RECALC_DATA); ED_region_tag_redraw(ar); -- cgit v1.2.3 From 6d0e172fefdc659e981e6856509db8a4e962993b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 3 Jul 2018 12:49:57 +0200 Subject: Sculpt: Cleanup, spelling --- source/blender/blenkernel/intern/paint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 404a1a656d9..a32bdee2b2c 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -857,7 +857,7 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob) } /** - * \param need_mask So taht the evaluated mesh that is returned has mask data. + * \param need_mask So that the evaluated mesh that is returned has mask data. */ void BKE_sculpt_update_mesh_elements( Depsgraph *depsgraph, Scene *scene, Sculpt *sd, Object *ob, -- cgit v1.2.3 From b868e58d9b7cfc1338296b995ddc8c619d28763d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 3 Jul 2018 12:53:29 +0200 Subject: Sculpt: Fix wrong object used for crazy space calculation Was applying modifiers twice, when it should not have. Is expected to solve mesh corruption when in sculpt mode. --- source/blender/blenkernel/intern/paint.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index a32bdee2b2c..4d3a0587a0b 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -68,6 +68,7 @@ #include "BKE_subsurf.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "bmesh.h" @@ -947,13 +948,14 @@ void BKE_sculpt_update_mesh_elements( if (ss->modifiers_active) { if (!ss->orig_cos) { + Object *object_orig = DEG_get_original_object(ob); int a; BKE_sculptsession_free_deformMats(ss); ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL); - BKE_crazyspace_build_sculpt(depsgraph, scene, ob, &ss->deform_imats, &ss->deform_cos); + BKE_crazyspace_build_sculpt(depsgraph, scene, object_orig, &ss->deform_imats, &ss->deform_cos); BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos, me->totvert); for (a = 0; a < me->totvert; ++a) { -- cgit v1.2.3 From 48c93640d22ec9aea9f429808911dccfbd8a72f3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Jul 2018 12:59:02 +0200 Subject: Cleanup: fix compiler warning. --- source/blender/makesrna/intern/rna_group.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index b3afba36a9f..7797de9ad4b 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -116,6 +116,7 @@ static bool rna_Collection_objects_override_apply( PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src, PointerRNA *UNUSED(ptr_item_storage), IDOverrideStaticPropertyOperation *opop) { + (void)opop; BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_REPLACE && "Unsupported RNA override operation on collections' objects"); @@ -199,6 +200,7 @@ static bool rna_Collection_children_override_apply( PointerRNA *ptr_item_dst, PointerRNA *ptr_item_src, PointerRNA *UNUSED(ptr_item_storage), IDOverrideStaticPropertyOperation *opop) { + (void)opop; BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_REPLACE && "Unsupported RNA override operation on collections' objects"); -- cgit v1.2.3 From c50e1216a654a93ba8a05f5a1b573e6bdc28c3bd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Jul 2018 13:04:21 +0200 Subject: Fix dimmed shortcut key display issues in toolbar menu and color picker. Draw with alpha * 0.5 instead of using item them color, this doesn't work well in the toolbar menu and highlighted menu items otherwise. --- source/blender/editors/include/UI_interface.h | 2 ++ source/blender/editors/interface/interface.c | 1 + source/blender/editors/interface/interface_widgets.c | 9 ++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index e5218e287d4..1ab1c5227ea 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -233,6 +233,8 @@ enum { UI_BUT_ACTIVE_LEFT = (1 << 21), /* Active left part of number button */ UI_BUT_ACTIVE_RIGHT = (1 << 22), /* Active right part of number button */ + + UI_BUT_HAS_SHORTCUT = (1 << 23), /* Button has shortcut text */ }; /* scale fixed button widths by this to account for DPI */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3b2a2e9d3ed..427f5621177 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -943,6 +943,7 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str MEM_freeN(butstr_orig); but->str = but->strdata; but->flag |= UI_BUT_HAS_SEP_CHAR; + but->drawflag |= UI_BUT_HAS_SHORTCUT; ui_but_update(but); } } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 4bf2ac4271b..1c6d5c70933 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1878,7 +1878,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b #endif /* cut string in 2 parts - only for menu entries */ - if ((but->block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)) && + if ((but->drawflag & UI_BUT_HAS_SHORTCUT) && (but->editstr == NULL)) { if (but->flag & UI_BUT_HAS_SEP_CHAR) { @@ -1961,8 +1961,11 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b /* part text right aligned */ if (drawstr_right) { - const char *col = but->block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS) ? - wcol->item : wcol->text; + char col[4]; + copy_v4_v4_char(col, wcol->text); + if (but->drawflag & UI_BUT_HAS_SHORTCUT) { + col[3] *= 0.5f; + } fstyle->align = UI_STYLE_TEXT_RIGHT; rect->xmax -= UI_TEXT_CLIP_MARGIN; -- cgit v1.2.3 From 7a8403dbb003b0a79fb917b3f23c329f72522ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 2 Jul 2018 19:34:44 +0200 Subject: Revert "GHOST: Fix uninitialized values." This reverts commit aca403c819c4fc9e1e7197bbe3027d43d114bfd6. --- intern/ghost/intern/GHOST_ContextGLX.cpp | 3 +-- intern/ghost/intern/GHOST_ContextWGL.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp index 1a995eb2cbc..c94151a1a0e 100644 --- a/intern/ghost/intern/GHOST_ContextGLX.cpp +++ b/intern/ghost/intern/GHOST_ContextGLX.cpp @@ -72,8 +72,7 @@ GHOST_ContextGLX::GHOST_ContextGLX( m_contextMinorVersion(contextMinorVersion), m_contextFlags(contextFlags), m_contextResetNotificationStrategy(contextResetNotificationStrategy), - m_context(None), - m_init(false) + m_context(None) { assert(m_display != NULL); } diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp index 0047a88fa1d..883c06ecf78 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cpp +++ b/intern/ghost/intern/GHOST_ContextWGL.cpp @@ -70,8 +70,7 @@ GHOST_ContextWGL::GHOST_ContextWGL( m_contextFlags(contextFlags), m_alphaBackground(alphaBackground), m_contextResetNotificationStrategy(contextResetNotificationStrategy), - m_hGLRC(NULL), - m_init(false) + m_hGLRC(NULL) #ifndef NDEBUG , m_dummyVendor(NULL), -- cgit v1.2.3 From d78bcf90557a157555b0fafcf3f8d03e5b6496ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 2 Jul 2018 19:35:09 +0200 Subject: Revert "GHOST: Fix uninitialized var" This reverts commit 27b673402228aeede8369d99bf64f3da21541058. --- intern/ghost/intern/GHOST_ContextGLX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp index c94151a1a0e..1365a1a9c24 100644 --- a/intern/ghost/intern/GHOST_ContextGLX.cpp +++ b/intern/ghost/intern/GHOST_ContextGLX.cpp @@ -305,7 +305,7 @@ const bool GLXEW_ARB_create_context_robustness = fprintf(stderr, "Warning! GLX_ARB_create_context not available.\n"); } - GHOST_TSuccess success = GHOST_kSuccess; + GHOST_TSuccess success; if (m_context != NULL) { if (!s_sharedContext) -- cgit v1.2.3 From 6c9fe9cd8ca0ac0bfbe00463d73d3c79b1bff6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 2 Jul 2018 19:39:02 +0200 Subject: Revert "GHOST: WGL: Delay context initialization for offscreen contexts." This reverts commit 800c3c5ca581d5427c4270c60f022c3ccdd8b312. # Conflicts: # intern/ghost/intern/GHOST_ContextWGL.cpp --- intern/ghost/intern/GHOST_ContextWGL.cpp | 28 +++++++--------------------- intern/ghost/intern/GHOST_ContextWGL.h | 2 -- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp index 883c06ecf78..035b0c268c6 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cpp +++ b/intern/ghost/intern/GHOST_ContextWGL.cpp @@ -139,10 +139,6 @@ GHOST_TSuccess GHOST_ContextWGL::getSwapInterval(int &intervalOut) GHOST_TSuccess GHOST_ContextWGL::activateDrawingContext() { - if (m_init == false) { - initContext(); - } - if (WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) { return GHOST_kSuccess; } @@ -892,23 +888,8 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() goto error; } - initContext(); - - initClearGL(); - ::SwapBuffers(m_hDC); - - return GHOST_kSuccess; -error: - ::wglMakeCurrent(prevHDC, prevHGLRC); - return GHOST_kFailure; - -} - - -GHOST_TSuccess GHOST_ContextWGL::initContext() -{ if (!WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) { - return GHOST_kFailure; + goto error; } initContextGLEW(); @@ -922,7 +903,8 @@ GHOST_TSuccess GHOST_ContextWGL::initContext() glEnable(GL_POINT_SPRITE); } - m_init = true; + initClearGL(); + ::SwapBuffers(m_hDC); #ifndef NDEBUG const char *vendor = reinterpret_cast(glGetString(GL_VENDOR)); @@ -937,6 +919,10 @@ GHOST_TSuccess GHOST_ContextWGL::initContext() #endif return GHOST_kSuccess; +error: + ::wglMakeCurrent(prevHDC, prevHGLRC); + return GHOST_kFailure; + } diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h index 7711f90a9e9..2ffe9523008 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.h +++ b/intern/ghost/intern/GHOST_ContextWGL.h @@ -140,13 +140,11 @@ private: bool needStencil, bool sRGB, int swapMethod); - GHOST_TSuccess initContext(); void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD); HWND m_hWnd; HDC m_hDC; - bool m_init; const int m_contextProfileMask; const int m_contextMajorVersion; -- cgit v1.2.3 From 433e3db8d89130531424e2468dedcfb36f6eb592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 2 Jul 2018 19:39:50 +0200 Subject: Revert "GHOST: Delay opengl context initialization" This reverts commit 128926a41b368e166af63515370d9c9367e3dda2. --- intern/gawain/src/gwn_vertex_array_id.cpp | 5 ++--- intern/ghost/intern/GHOST_ContextGLX.cpp | 30 ++++++------------------------ intern/ghost/intern/GHOST_ContextGLX.h | 2 -- source/blender/draw/intern/draw_manager.c | 2 -- 4 files changed, 8 insertions(+), 31 deletions(-) diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp index 2ab38a8fe18..ad60dea7542 100644 --- a/intern/gawain/src/gwn_vertex_array_id.cpp +++ b/intern/gawain/src/gwn_vertex_array_id.cpp @@ -18,7 +18,7 @@ #include #include -#if 0 +#if TRUST_NO_ONE extern "C" { extern int BLI_thread_is_main(void); // Blender-specific function } @@ -68,8 +68,7 @@ static void clear_orphans(Gwn_Context* ctx) Gwn_Context* GWN_context_create(void) { #if TRUST_NO_ONE - /* We cannot rely on this anymore. */ - // assert(thread_is_main()); + assert(thread_is_main()); #endif Gwn_Context* ctx = new Gwn_Context; glGenVertexArrays(1, &ctx->default_vao); diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp index 1365a1a9c24..815189b9098 100644 --- a/intern/ghost/intern/GHOST_ContextGLX.cpp +++ b/intern/ghost/intern/GHOST_ContextGLX.cpp @@ -110,9 +110,6 @@ GHOST_TSuccess GHOST_ContextGLX::swapBuffers() GHOST_TSuccess GHOST_ContextGLX::activateDrawingContext() { - if (m_init == false) { - initContext(); - } if (m_display) { return ::glXMakeCurrent(m_display, m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure; } @@ -187,8 +184,7 @@ const bool GLXEW_ARB_create_context_robustness = glxewInit(); #endif /* USE_GLXEW_INIT_WORKAROUND */ - /* Only init the non-offscreen context directly */ - const bool do_init = (m_window != None); + if (GLXEW_ARB_create_context) { int profileBitCore = m_contextProfileMask & GLX_CONTEXT_CORE_PROFILE_BIT_ARB; @@ -308,27 +304,12 @@ const bool GLXEW_ARB_create_context_robustness = GHOST_TSuccess success; if (m_context != NULL) { + const unsigned char *version; + if (!s_sharedContext) s_sharedContext = m_context; s_sharedCount++; - } - - if (do_init) { - success = initContext(); - } - - GHOST_X11_ERROR_HANDLERS_RESTORE(handler_store); - - return success; -} - -GHOST_TSuccess GHOST_ContextGLX::initContext() -{ - GHOST_TSuccess success; - - if (m_context != NULL) { - const unsigned char *version; glXMakeCurrent(m_display, m_window, m_context); @@ -360,12 +341,13 @@ GHOST_TSuccess GHOST_ContextGLX::initContext() success = GHOST_kFailure; } - /* We tag as init even if it fails. */ - m_init = true; + + GHOST_X11_ERROR_HANDLERS_RESTORE(handler_store); return success; } + GHOST_TSuccess GHOST_ContextGLX::releaseNativeHandles() { m_window = 0; diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h index b4d6a841d72..ded1b293659 100644 --- a/intern/ghost/intern/GHOST_ContextGLX.h +++ b/intern/ghost/intern/GHOST_ContextGLX.h @@ -116,7 +116,6 @@ public: private: void initContextGLXEW(); - GHOST_TSuccess initContext(); Display *m_display; GLXFBConfig m_fbconfig; @@ -129,7 +128,6 @@ private: const int m_contextResetNotificationStrategy; GLXContext m_context; - bool m_init; /** The first created OpenGL context (for sharing display lists) */ static GLXContext s_sharedContext; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 504e53fd206..b7326ca5842 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2184,8 +2184,6 @@ void DRW_opengl_context_create(void) } /* This changes the active context. */ DST.gl_context = WM_opengl_context_create(); - /* Make the context active for this thread (main thread) */ - WM_opengl_context_activate(DST.gl_context); /* Be sure to create gawain.context too. */ DST.gwn_context = GWN_context_create(); if (!G.background) { -- cgit v1.2.3 From e30f25ba22efae0c749c3dcecf6fb4ecf60e853e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 3 Jul 2018 12:32:01 +0200 Subject: GHOST: Fix assert and rebind previous ogl context. --- intern/gawain/src/gwn_vertex_array_id.cpp | 2 +- source/blender/render/intern/source/pipeline.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp index ad60dea7542..5294c6c8e23 100644 --- a/intern/gawain/src/gwn_vertex_array_id.cpp +++ b/intern/gawain/src/gwn_vertex_array_id.cpp @@ -68,7 +68,7 @@ static void clear_orphans(Gwn_Context* ctx) Gwn_Context* GWN_context_create(void) { #if TRUST_NO_ONE - assert(thread_is_main()); + // assert(thread_is_main()); #endif Gwn_Context* ctx = new Gwn_Context; glGenVertexArrays(1, &ctx->default_vao); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 361324bf07c..82595527d30 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -64,6 +64,7 @@ #include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */ #include "BKE_camera.h" #include "BKE_colortools.h" +#include "BKE_context.h" /* XXX needed by wm_window.h */ #include "BKE_global.h" #include "BKE_image.h" #include "BKE_layer.h" @@ -95,6 +96,7 @@ #include "RE_render_ext.h" #include "../../../windowmanager/WM_api.h" /* XXX */ +#include "../../../windowmanager/wm_window.h" /* XXX */ #include "../../../intern/gawain/gawain/gwn_context.h" #ifdef WITH_FREESTYLE @@ -1034,6 +1036,8 @@ void RE_gl_context_create(Render *re) { /* Needs to be created in the main ogl thread. */ re->gl_context = WM_opengl_context_create(); + /* So we activate the window's one afterwards. */ + wm_window_reset_drawable(); } void RE_gl_context_destroy(Render *re) -- cgit v1.2.3 From 967b84534a746ea2f5b37ad0c80ad680362b571a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 3 Jul 2018 12:29:48 +0200 Subject: Workbench: Fix wrong shading shadoow direction. --- .../draw/engines/workbench/shaders/workbench_data_lib.glsl | 2 +- .../workbench/shaders/workbench_deferred_composite_frag.glsl | 6 ++---- .../engines/workbench/shaders/workbench_world_light_lib.glsl | 1 - source/blender/draw/engines/workbench/workbench_data.c | 11 ++++++----- source/blender/draw/engines/workbench/workbench_private.h | 4 ++-- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl index 99bacea4b27..eadc5e4b0d0 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl @@ -8,7 +8,7 @@ struct WorldData { vec4 background_color_low; vec4 background_color_high; vec4 object_outline_color; - vec4 light_direction_vs; + vec4 shadow_direction_vs; LightData lights[3]; int num_lights; int matcap_orientation; diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl index c72df6b677d..bf856fbb212 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl @@ -106,12 +106,10 @@ void main() #endif #ifdef V3D_SHADING_SHADOW - float light_factor = -dot(normal_viewport, world_data.lights[0].light_direction_vs.xyz); + float light_factor = -dot(normal_viewport, world_data.shadow_direction_vs.xyz); /* The step function might be ok for meshes but it's * clearly not the case for hairs. Do smoothstep in this case. */ - float shadow_mix = (diffuse_color.a == 1.0 || diffuse_color.a == 0.0) - ? step(-shadowShift, -light_factor) - : smoothstep(1.0, shadowShift, light_factor); + float shadow_mix = smoothstep(1.0, shadowShift, light_factor); float light_multiplier = mix(lightMultiplier, shadowMultiplier, shadow_mix); #else /* V3D_SHADING_SHADOW */ diff --git a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl index 3eda4455487..82d0d1fcd02 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl @@ -89,7 +89,6 @@ vec3 get_world_specular_light(vec4 specular_data, LightData light_data, vec3 N, vec3 get_world_specular_lights(WorldData world_data, vec4 specular_data, vec3 N, vec3 I) { vec3 specular_light = vec3(0.0); - specular_light += get_world_specular_light(specular_data, world_data.lights[0], N, I); for (int i = 0 ; i < world_data.num_lights ; i ++) { specular_light += get_world_specular_light(specular_data, world_data.lights[i], N, I); } diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index 0f0d879aae8..4c68e41d010 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -121,7 +121,7 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) } } -void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float light_direction[3]) +void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float r_light_direction[3]) { const DRWContextState *draw_ctx = DRW_context_state_get(); Scene *scene = draw_ctx->scene; @@ -129,13 +129,16 @@ void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, floa float view_matrix[4][4]; DRW_viewport_matrix_get(view_matrix, DRW_MAT_VIEW); + copy_v3_v3(r_light_direction, scene->display.light_direction); + negate_v3(r_light_direction); + { WORKBENCH_UBO_Light *light = &wd->lights[0]; - mul_v3_mat3_m4v3(light->light_direction_vs, view_matrix, light_direction); + mul_v3_mat3_m4v3(light->light_direction_vs, view_matrix, r_light_direction); light->light_direction_vs[3] = 0.0f; copy_v3_fl(light->specular_color, 1.0f); light->energy = 1.0f; - copy_v4_v4(wd->light_direction_vs, light->light_direction_vs); + copy_v4_v4(wd->shadow_direction_vs, light->light_direction_vs); wd->num_lights = 1; } @@ -154,8 +157,6 @@ void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, floa wd->num_lights = light_index; } - copy_v3_v3(light_direction, scene->display.light_direction); - negate_v3(light_direction); DRW_uniformbuffer_update(wpd->world_ubo, wd); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index f50d4a7f0cd..a8fa1beb3b7 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -128,7 +128,7 @@ typedef struct WORKBENCH_UBO_World { float background_color_low[4]; float background_color_high[4]; float object_outline_color[4]; - float light_direction_vs[4]; + float shadow_direction_vs[4]; WORKBENCH_UBO_Light lights[3]; int num_lights; int matcap_orientation; @@ -282,7 +282,7 @@ bool studiolight_camera_in_object_shadow(WORKBENCH_PrivateData *wpd, Object *ob, void workbench_effect_info_init(WORKBENCH_EffectInfo *effect_info); void workbench_private_data_init(WORKBENCH_PrivateData *wpd); void workbench_private_data_free(WORKBENCH_PrivateData *wpd); -void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float light_direction[3]); +void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float r_light_direction[3]); extern DrawEngineType draw_engine_workbench_solid; extern DrawEngineType draw_engine_workbench_transparent; -- cgit v1.2.3 From c118b852b7e20a9728880b869b84f282adfd4312 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 13:51:11 +0200 Subject: Tool System: move transform into a top-level tool Also rename move to grab. --- release/scripts/startup/bl_ui/space_toolsystem_toolbar.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 110611cf7ab..a6e1d511b4c 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -130,7 +130,7 @@ class _defs_transform: @ToolDef.from_fn def translate(): return dict( - text="Move", + text="Grab", # cursor='SCROLL_XY', icon="ops.transform.translate", widget="TRANSFORM_WGT_manipulator", @@ -939,10 +939,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): # for reuse _tools_transform = ( - ( - _defs_transform.translate, - _defs_transform.transform, - ), + _defs_transform.transform, + _defs_transform.translate, _defs_transform.rotate, ( _defs_transform.scale, -- cgit v1.2.3 From 952ae7010954d252b080faa10ae1f4286e54468f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 13:53:20 +0200 Subject: Cleanup: unused function --- intern/gawain/src/gwn_vertex_array_id.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp index 5294c6c8e23..d4b89a0f62b 100644 --- a/intern/gawain/src/gwn_vertex_array_id.cpp +++ b/intern/gawain/src/gwn_vertex_array_id.cpp @@ -19,6 +19,7 @@ #include #if TRUST_NO_ONE +#if 0 extern "C" { extern int BLI_thread_is_main(void); // Blender-specific function } @@ -29,6 +30,7 @@ static bool thread_is_main() return BLI_thread_is_main(); } #endif +#endif struct Gwn_Context { GLuint default_vao; -- cgit v1.2.3 From a2ce6af2f5a870a131e521abe5f67a2f4b59e341 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 14:20:05 +0200 Subject: Correct tool rename Needed to update manipulator too. --- source/blender/editors/transform/transform_manipulator_3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index 8f547fb7451..94bd1c92130 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -1420,7 +1420,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; man->use_twtype_refresh = true; } - else if (STREQ(tref->idname, "Move")) { + else if (STREQ(tref->idname, "Grab")) { man->twtype |= SCE_MANIP_TRANSLATE; } else if (STREQ(tref->idname, "Rotate")) { -- cgit v1.2.3 From 03ca4a57c72d986e498c59fba43e350cccf011ca Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Jul 2018 14:05:07 +0200 Subject: Cleanup: move snap/pivot/orientation popovers to proper file. --- release/scripts/startup/bl_ui/space_topbar.py | 95 ----------------------- release/scripts/startup/bl_ui/space_view3d.py | 106 ++++++++++++++++++++++++-- 2 files changed, 100 insertions(+), 101 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 52d180c36b0..fef71ba6227 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -206,98 +206,6 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") -class TOPBAR_PT_pivot_point(Panel): - bl_space_type = 'TOPBAR' - bl_region_type = 'HEADER' - bl_label = "Pivot Point" - - def draw(self, context): - toolsettings = context.tool_settings - obj = context.active_object - mode = context.mode - - layout = self.layout - col = layout.column() - col.label("Pivot Point") - col.prop(toolsettings, "transform_pivot_point", expand=True) - - col.separator() - - if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}): - col.prop( - toolsettings, - "use_transform_pivot_point_align", - text="Center Points Only", - ) - - -class TOPBAR_PT_snapping(Panel): - bl_space_type = 'TOPBAR' - bl_region_type = 'HEADER' - bl_label = "Snapping" - - def draw(self, context): - toolsettings = context.tool_settings - snap_elements = toolsettings.snap_elements - obj = context.active_object - mode = context.mode - object_mode = 'OBJECT' if obj is None else obj.mode - - layout = self.layout - col = layout.column() - col.label("Snapping") - col.prop(toolsettings, "snap_elements", expand=True) - - col.separator() - if 'INCREMENT' in snap_elements: - col.prop(toolsettings, "use_snap_grid_absolute") - - if snap_elements != {'INCREMENT'}: - col.label("Target") - row = col.row(align=True) - row.prop(toolsettings, "snap_target", expand=True) - - if obj: - if object_mode == 'EDIT': - col.prop(toolsettings, "use_snap_self") - if object_mode in {'OBJECT', 'POSE', 'EDIT'}: - col.prop(toolsettings, "use_snap_align_rotation", text="Align Rotation") - - if 'FACE' in snap_elements: - col.prop(toolsettings, "use_snap_project", text="Project Elements") - - if 'VOLUME' in snap_elements: - col.prop(toolsettings, "use_snap_peel_object") - - -class TOPBAR_PT_transform_orientations(Panel): - bl_space_type = 'TOPBAR' - bl_region_type = 'HEADER' - bl_label = "Transform Orientations" - bl_options = {'DEFAULT_CLOSED'} - - @classmethod - def poll(cls, context): - view = context.space_data - return (view) - - def draw(self, context): - layout = self.layout - layout.label("Tranform Orientations") - - scene = context.scene - orientation = scene.current_orientation - - col = layout.split(percentage=0.9) - col.prop(scene, "transform_orientation", expand=True) - col.operator("transform.create_orientation", text="", icon='ZOOMIN', emboss=False) - - if orientation: - row = layout.row(align=False) - row.prop(orientation, "name", text="") - row.operator("transform.delete_orientation", text="", icon='X', emboss=False) - - class INFO_MT_editor_menus(Menu): bl_idname = "INFO_MT_editor_menus" bl_label = "" @@ -655,9 +563,6 @@ class TOPBAR_MT_window_specials(Menu): classes = ( TOPBAR_HT_upper_bar, TOPBAR_HT_lower_bar, - TOPBAR_PT_pivot_point, - TOPBAR_PT_snapping, - TOPBAR_PT_transform_orientations, TOPBAR_MT_file_specials, TOPBAR_MT_window_specials, INFO_MT_editor_menus, diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index e5e903f5338..0217008f569 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -133,9 +133,9 @@ class VIEW3D_HT_header(Header): row = layout.row(align=True) row.popover( - space_type='TOPBAR', + space_type='VIEW_3D', region_type='HEADER', - panel_type="TOPBAR_PT_transform_orientations", + panel_type="VIEW3D_PT_transform_orientations", text=trans_name, icon=trans_icon, ) @@ -172,9 +172,9 @@ class VIEW3D_HT_header(Header): sub = row.row(align=True) sub.popover( - space_type='TOPBAR', + space_type='VIEW_3D', region_type='HEADER', - panel_type="TOPBAR_PT_snapping", + panel_type="VIEW3D_PT_snapping", icon=icon, text="" ) @@ -216,9 +216,9 @@ class VIEW3D_HT_header(Header): act_pivot_point = bpy.types.ToolSettings.bl_rna.properties["transform_pivot_point"].enum_items[pivot_point] row = layout.row(align=True) row.popover( - space_type='TOPBAR', + space_type='VIEW_3D', region_type='HEADER', - panel_type="TOPBAR_PT_pivot_point", + panel_type="VIEW3D_PT_pivot_point", icon=act_pivot_point.icon, text="", ) @@ -4076,6 +4076,97 @@ class VIEW3D_PT_overlay_paint(Panel): col.prop(overlay, "show_paint_wire") +class VIEW3D_PT_pivot_point(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_label = "Pivot Point" + + def draw(self, context): + toolsettings = context.tool_settings + obj = context.active_object + mode = context.mode + + layout = self.layout + col = layout.column() + col.label("Pivot Point") + col.prop(toolsettings, "transform_pivot_point", expand=True) + + col.separator() + + if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}): + col.prop( + toolsettings, + "use_transform_pivot_point_align", + text="Center Points Only", + ) + + +class VIEW3D_PT_snapping(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_label = "Snapping" + + def draw(self, context): + toolsettings = context.tool_settings + snap_elements = toolsettings.snap_elements + obj = context.active_object + mode = context.mode + object_mode = 'OBJECT' if obj is None else obj.mode + + layout = self.layout + col = layout.column() + col.label("Snapping") + col.prop(toolsettings, "snap_elements", expand=True) + + col.separator() + if 'INCREMENT' in snap_elements: + col.prop(toolsettings, "use_snap_grid_absolute") + + if snap_elements != {'INCREMENT'}: + col.label("Target") + row = col.row(align=True) + row.prop(toolsettings, "snap_target", expand=True) + + if obj: + if object_mode == 'EDIT': + col.prop(toolsettings, "use_snap_self") + if object_mode in {'OBJECT', 'POSE', 'EDIT'}: + col.prop(toolsettings, "use_snap_align_rotation", text="Align Rotation") + + if 'FACE' in snap_elements: + col.prop(toolsettings, "use_snap_project", text="Project Elements") + + if 'VOLUME' in snap_elements: + col.prop(toolsettings, "use_snap_peel_object") + + +class VIEW3D_PT_transform_orientations(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_label = "Transform Orientations" + + @classmethod + def poll(cls, context): + view = context.space_data + return (view) + + def draw(self, context): + layout = self.layout + layout.label("Tranform Orientations") + + scene = context.scene + orientation = scene.current_orientation + + col = layout.split(percentage=0.9) + col.prop(scene, "transform_orientation", expand=True) + col.operator("transform.create_orientation", text="", icon='ZOOMIN', emboss=False) + + if orientation: + row = layout.row(align=False) + row.prop(orientation, "name", text="") + row.operator("transform.delete_orientation", text="", icon='X', emboss=False) + + class VIEW3D_PT_quad_view(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' @@ -4330,6 +4421,9 @@ classes = ( VIEW3D_PT_overlay_pose, VIEW3D_PT_overlay_paint, VIEW3D_PT_overlay_sculpt, + VIEW3D_PT_pivot_point, + VIEW3D_PT_snapping, + VIEW3D_PT_transform_orientations, VIEW3D_PT_context_properties, ) -- cgit v1.2.3 From 76d7186d613e218d098c23a2267a7d60cb6bd283 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Jul 2018 14:23:47 +0200 Subject: UI: use new transform orientation when created. --- release/scripts/startup/bl_ui/space_view3d.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 0217008f569..1927f95670f 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4157,9 +4157,10 @@ class VIEW3D_PT_transform_orientations(Panel): scene = context.scene orientation = scene.current_orientation - col = layout.split(percentage=0.9) + row = layout.row() + col = row.column() col.prop(scene, "transform_orientation", expand=True) - col.operator("transform.create_orientation", text="", icon='ZOOMIN', emboss=False) + row.operator("transform.create_orientation", text="", icon='ZOOMIN', emboss=False).use = True if orientation: row = layout.row(align=False) -- cgit v1.2.3 From 33a5cde313105a46d5e7b743819be3800cb3be3a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 14:45:25 +0200 Subject: Keymap: Adjust animate and manipulator toggle keys Make room for Alt-A to be used for de-select. Discussed with artists in studio & @venomgfx, - Use Ctrl-Space for animation. - Use Ctrl-Tab to toggle manipulator. - Remove mirror transform binding. --- source/blender/editors/screen/screen_ops.c | 12 +++++++++++- source/blender/editors/space_view3d/view3d_ops.c | 4 ++++ source/blender/editors/transform/transform_ops.c | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 188592d6129..5ad70e84615 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4956,9 +4956,19 @@ void ED_keymap_screen(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "next", false); +#ifdef USE_WM_KEYMAP_27X /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, "reverse", true); + RNA_boolean_set( + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, + "reverse", true); +#else + /* play (forward and backwards) */ + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_CTRL, 0); + RNA_boolean_set( + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0)->ptr, + "reverse", true); +#endif WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", MEDIAPLAY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index b16327d2a4a..7eb2debf94a 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -528,7 +528,11 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "tool_settings.transform_pivot_point"); RNA_string_set(kmi->ptr, "value", "ACTIVE_ELEMENT"); +#ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* new in 2.5 */ +#else + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); +#endif RNA_string_set(kmi->ptr, "data_path", "space_data.show_manipulator"); transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index a8853743a57..f95229ef503 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -1113,10 +1113,12 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, "TRANSFORM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0); +#ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "use", true); WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0); +#endif kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap"); -- cgit v1.2.3 From c0c0eb7e7eb55361dc01f9d91ab47cdf16177d1f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Jul 2018 14:51:35 +0200 Subject: Fix typo in transform orientations. --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 1927f95670f..672a5d081bf 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4152,7 +4152,7 @@ class VIEW3D_PT_transform_orientations(Panel): def draw(self, context): layout = self.layout - layout.label("Tranform Orientations") + layout.label("Transform Orientations") scene = context.scene orientation = scene.current_orientation -- cgit v1.2.3 From fbafa4352b82c09599b5e5160e23e02cb5e3bcd2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 15:07:22 +0200 Subject: Keymap: Select/De-Select now use A, Alt-A There are still some keys to update because some operators only support toggle. --- source/blender/editors/animation/anim_markers.c | 6 +++++- source/blender/editors/armature/armature_ops.c | 8 ++++++-- source/blender/editors/curve/curve_ops.c | 4 +++- source/blender/editors/gpencil/gpencil_ops.c | 4 +++- source/blender/editors/lattice/lattice_ops.c | 4 +++- source/blender/editors/mask/mask_edit.c | 4 +++- source/blender/editors/mesh/mesh_ops.c | 4 +++- source/blender/editors/metaball/mball_ops.c | 4 +++- source/blender/editors/object/object_ops.c | 4 +++- source/blender/editors/physics/physics_ops.c | 4 +++- source/blender/editors/sculpt_paint/paint_ops.c | 8 ++++++-- source/blender/editors/space_clip/space_clip.c | 9 +++++++-- source/blender/editors/space_node/node_ops.c | 4 +++- source/blender/editors/space_sequencer/sequencer_ops.c | 4 +++- source/blender/editors/uvedit/uvedit_ops.c | 4 +++- 15 files changed, 57 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 05350ffd18e..5f03704f9f5 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1670,7 +1670,11 @@ void ED_keymap_marker(wmKeyConfig *keyconf) #endif WM_keymap_verify_item(keymap, "MARKER_OT_select_border", BKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, 0, 0); + + kmi = WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); WM_keymap_add_item(keymap, "MARKER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MARKER_OT_delete", DELKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 067b9fd76a8..07db63e6dc7 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -219,7 +219,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); @@ -333,7 +335,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf) #endif kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 29124f9c895..925358b5304 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -245,7 +245,9 @@ void ED_keymap_curve(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "wait_for_input", false); kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index f22d653800e..3f114a4dd4a 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -184,7 +184,9 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) /* Selection ------------------------------------- */ /* select all */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/lattice/lattice_ops.c b/source/blender/editors/lattice/lattice_ops.c index 4f2e87c11c1..a04da538b03 100644 --- a/source/blender/editors/lattice/lattice_ops.c +++ b/source/blender/editors/lattice/lattice_ops.c @@ -62,7 +62,9 @@ void ED_keymap_lattice(wmKeyConfig *keyconf) keymap->poll = ED_operator_editlattice; kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); WM_keymap_add_item(keymap, "LATTICE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 85f5836ecd7..7d5fc5126ef 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -555,7 +555,9 @@ void ED_keymap_mask(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "toggle", true); kmi = WM_keymap_add_item(keymap, "MASK_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "MASK_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "MASK_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index ff94223c815..dc3ee4cbb53 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -380,7 +380,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "use_fill", true); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 567ef3150bf..ab7098eeb53 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -89,7 +89,9 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MBALL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index b52ef7a1abc..5d44eec7187 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -313,7 +313,9 @@ void ED_keymap_object(wmKeyConfig *keyconf) ED_keymap_proportional_obmode(keyconf, keymap); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 73bb2d14505..a1a61b08dc9 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -117,7 +117,9 @@ static void keymap_particle(wmKeyConfig *keyconf) keymap->poll = PE_poll; kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 9f14a821613..0f796020d9e 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -1393,7 +1393,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "Weight Paint Vertex Selection", 0, 0); keymap->poll = vert_paint_poll; kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0); @@ -1436,7 +1438,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap->poll = facemask_paint_poll; kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index c66a9a42292..fc550499157 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -645,8 +645,11 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", false); kmi = WM_keymap_add_item(keymap, "CLIP_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "CLIP_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); WM_keymap_add_item(keymap, "CLIP_OT_select_border", BKEY, KM_PRESS, 0, 0); @@ -763,7 +766,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", true); kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select_all_markers", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select_all_markers", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "CLIP_OT_graph_select_all_markers", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 069d8a500ca..ed96bb21412 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -311,7 +311,9 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_delete_reconnect", DELKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 234989ef244..1a3cb8560e4 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -151,7 +151,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 8a00b542eed..9701f920706 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -4445,7 +4445,9 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "UV_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "UV_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "UV_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); kmi = WM_keymap_add_item(keymap, "UV_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); -- cgit v1.2.3 From 1c5b375390cdf0062794f0a9021cc788de0812ae Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 3 Jul 2018 15:36:23 +0200 Subject: UI: Default theme update for contrast Selected color is now .9 alpha so keyed/animated/driven statuses show through when widget is active. Assign color for overriden state. Also fix progress bar not visible. --- release/datafiles/userdef/userdef_default_theme.c | 94 ++++++++++++----------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index aea7e40573a..4c117dca354 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -20,9 +20,9 @@ const bTheme U_theme_default = { .name = "Default", .tui = { .wcol_regular = { - .outline = RGBA(0x3e3e3eff), + .outline = RGBA(0x444444ff), .inner = RGBA(0x585858ff), - .inner_sel = RGBA(0x5680c2ff), + .inner_sel = RGBA(0x5680c2e6), .item = RGBA(0x3e3e3eff), .text = RGBA(0xebebebff), .text_sel = RGBA(0xffffffff), @@ -30,7 +30,7 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_tool = { - .outline = RGBA(0x343434ff), + .outline = RGBA(0x444444ff), .inner = RGBA(0x585858ff), .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xffffffff), @@ -40,29 +40,29 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_toolbar_item = { - .outline = RGBA(0x191919ff), + .outline = RGBA(0x444444ff), .inner = RGBA(0x585858ff), - .inner_sel = RGBA(0x333333ff), + .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xffffff8f), .text = RGBA(0xffffffff), .text_sel = RGBA(0xffffffff), .roundness = 0.25f, }, .wcol_text = { - .outline = RGBA(0x4d4d4dff), - .inner = RGBA(0x333333ff), + .outline = RGBA(0x444444ff), + .inner = RGBA(0x2c2c2cff), .inner_sel = RGBA(0x808080ff), .item = RGBA(0x333333ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shaded = 1, .shadetop = -3, - .roundness = 0.2f, + .roundness = 0.1f, }, .wcol_radio = { - .outline = RGBA(0x525252ff), - .inner = RGBA(0x585858ff), - .inner_sel = RGBA(0x5680c2ff), + .outline = RGBA(0x444444ff), + .inner = RGBA(0x595959ff), + .inner_sel = RGBA(0x5680c2e6), .item = RGBA(0xffffffff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -71,9 +71,9 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_option = { - .outline = RGBA(0x525252ff), - .inner = RGBA(0x666666cc), - .inner_sel = RGBA(0x5680c2ff), + .outline = RGBA(0x444444ff), + .inner = RGBA(0x666666ff), + .inner_sel = RGBA(0x5680c2e6), .item = RGBA(0xffffffff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -82,17 +82,17 @@ const bTheme U_theme_default = { }, .wcol_toggle = { .outline = RGBA(0x4d4d4dff), - .inner = RGBA(0x666666ff), - .inner_sel = RGBA(0x5680c2ff), + .inner = RGBA(0x595959ff), + .inner_sel = RGBA(0x5680c2e6), .item = RGBA(0x191919ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .roundness = 0.25f, }, .wcol_num = { - .outline = RGBA(0x4d4d4dff), - .inner = RGBA(0x585858ff), - .inner_sel = RGBA(0x808080ff), + .outline = RGBA(0x444444ff), + .inner = RGBA(0x595959ff), + .inner_sel = RGBA(0xb3b3b366), .item = RGBA(0x333333ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -100,8 +100,8 @@ const bTheme U_theme_default = { .roundness = 0.3f, }, .wcol_numslider = { - .outline = RGBA(0x4d4d4dff), - .inner = RGBA(0x474747ff), + .outline = RGBA(0x444444ff), + .inner = RGBA(0x3b3b3bff), .inner_sel = RGBA(0x808080ff), .item = RGBA(0x585858ff), .text = RGBA(0xeeeeeeff), @@ -115,12 +115,12 @@ const bTheme U_theme_default = { .inner = RGBA(0x323232ff), .inner_sel = RGBA(0x4b4b4bff), .item = RGBA(0x2d2d2dff), - .text = RGBA(0xbebebeff), + .text = RGBA(0xa4a4a4ff), .text_sel = RGBA(0xffffffff), .roundness = 0.15f, }, .wcol_menu = { - .outline = RGBA(0x4d4d4dff), + .outline = RGBA(0x444444ff), .inner = RGBA(0x2e2e2eff), .inner_sel = RGBA(0x585858ff), .item = RGBA(0xe6e6e6ff), @@ -142,7 +142,7 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_menu_back = { - .outline = RGBA(0x2e2e2eff), + .outline = RGBA(0x19191aff), .inner = RGBA(0x1f1f1fef), .inner_sel = RGBA(0x585858ff), .item = RGBA(0x727272ff), @@ -161,7 +161,7 @@ const bTheme U_theme_default = { .roundness = 0.25f, }, .wcol_tooltip = { - .outline = RGBA(0x353535ff), + .outline = RGBA(0x19191aff), .inner = RGBA(0x19191aef), .inner_sel = RGBA(0x19191aef), .item = RGBA(0x19191aef), @@ -169,11 +169,11 @@ const bTheme U_theme_default = { .text_sel = RGBA(0xffffffff), .shadetop = 25, .shadedown = -20, - .roundness = 0.25f, + .roundness = 0.4f, }, .wcol_box = { .outline = RGBA(0x333333ff), - .inner = RGBA(0x4d4d4dff), + .inner = RGBA(0x4d4d4dcc), .inner_sel = RGBA(0x808080ff), .item = RGBA(0x191919ff), .text = RGBA(0xeeeeeeff), @@ -181,7 +181,7 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_scroll = { - .outline = RGBA(0x353535ff), + .outline = RGBA(0x424242ff), .inner = RGBA(0x67676700), .inner_sel = RGBA(0xb3b3b3ff), .item = RGBA(0x676767ff), @@ -192,10 +192,10 @@ const bTheme U_theme_default = { .roundness = 0.5f, }, .wcol_progress = { - .outline = RGBA(0xb3b3b3ff), - .inner = RGBA(0xccccccff), - .inner_sel = RGBA(0x646464b4), - .item = RGBA(0xb3b3b3ff), + .outline = RGBA(0x585858ff), + .inner = RGBA(0x2c2c2cff), + .inner_sel = RGBA(0x5680c2ff), + .item = RGBA(0x5680c2ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .roundness = 0.25f, @@ -211,7 +211,7 @@ const bTheme U_theme_default = { }, .wcol_pie_menu = { .outline = RGBA(0x2e2e2eff), - .inner = RGBA(0x2e2e2eff), + .inner = RGBA(0x212121ff), .inner_sel = RGBA(0x585858ff), .item = RGBA(0x5680c2ff), .text = RGBA(0xeeeeeeff), @@ -227,14 +227,16 @@ const bTheme U_theme_default = { .inner_key_sel = RGBA(0xd7d34bff), .inner_driven = RGBA(0xb400ffff), .inner_driven_sel = RGBA(0x9900e6ff), + .inner_overridden = RGBA(0x19c3c300), + .inner_overridden_sel = RGBA(0x118f8f00), .blend = 0.5f, }, .widget_emboss = RGBA(0x00000005), .menu_shadow_fac = 0.3f, .menu_shadow_width = 4, - .editor_outline = RGBA(0x202020ff), + .editor_outline = RGBA(0x1f1f1fff), .icon_alpha = 1.0f, - .icon_saturation = 0.4f, + .icon_saturation = 0.5f, .xaxis = RGBA(0xff3352ff), .yaxis = RGBA(0x8bdc00ff), .zaxis = RGBA(0x2890ffff), @@ -246,8 +248,8 @@ const bTheme U_theme_default = { }, .tbuts = { .back = RGBA(0x42424200), - .title = RGBA(0xeeeeeeff), - .text = RGBA(0xffffffff), + .title = RGBA(0xd4d4d4ff), + .text = RGBA(0xe5e5e5ff), .text_hi = RGBA(0xffffffff), .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), @@ -261,7 +263,7 @@ const bTheme U_theme_default = { .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x424242cc), + .header = RGBA(0x42424200), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, @@ -508,7 +510,7 @@ const bTheme U_theme_default = { .shade1 = RGBA(0xc0c0c000), .shade2 = RGBA(0x70707064), .hilite = RGBA(0x60c040ff), - .grid = RGBA(0x1a1a1aff), + .grid = RGBA(0x272727ff), .group = RGBA(0x278c0eff), .group_active = RGBA(0x4eb335ff), .strip = RGBA(0x1a151580), @@ -687,7 +689,7 @@ const bTheme U_theme_default = { .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x424242ff), + .header = RGBA(0x42424200), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), .tab_active = RGBA(0x4b4b4bff), @@ -699,7 +701,7 @@ const bTheme U_theme_default = { .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x424242cc), + .header = RGBA(0x42424200), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, @@ -721,9 +723,9 @@ const bTheme U_theme_default = { .syntaxr = RGBA(0xc4753bff), }, .toops = { - .back = RGBA(0x42424200), + .back = RGBA(0x35353500), .title = RGBA(0xffffffff), - .text = RGBA(0xdededeff), + .text = RGBA(0xc3c3c3ff), .text_hi = RGBA(0xffffffff), .header = RGBA(0x454545ff), .header_text = RGBA(0xeeeeeeff), @@ -747,7 +749,7 @@ const bTheme U_theme_default = { .outline_width = 1, .facedot_size = 4, .match = RGBA(0x337f334c), - .selected_highlight = RGBA(0x747a834c), + .selected_highlight = RGBA(0x696e764c), }, .ttime = { .vertex_size = 3, @@ -827,7 +829,7 @@ const bTheme U_theme_default = { .button_text = RGBA(0xffffffff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x424242cc), + .header = RGBA(0x42424200), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), .show_header = 1, @@ -949,7 +951,7 @@ const bTheme U_theme_default = { .title = RGBA(0xffffffff), .text = RGBA(0x838383ff), .text_hi = RGBA(0xffffffff), - .header = RGBA(0x232323ff), + .header = RGBA(0x303030ff), .header_text = RGBA(0xaaaaaaff), .header_text_hi = RGBA(0xffffffff), .tab_active = RGBA(0x4b4b4bff), -- cgit v1.2.3 From 14b0510d218e9f29c1f404c10abab82d42c656cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 3 Jul 2018 15:38:21 +0200 Subject: Edit Mesh Overlay: Fix floating point instability artifacts This was visible when vertices were very close to the near clip plane. --- source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl index 09d0b0a910d..fe9062a8d50 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl @@ -36,11 +36,10 @@ out vec4 FragColor; void distToEdgeAndPoint(vec2 dir, vec2 ori, out float edge, out float point) { dir = normalize(dir.xy); + dir = vec2(-dir.y, dir.x); vec2 of = gl_FragCoord.xy - ori; - point = dot(of, of); - float dof = dot(dir, of); - edge = sqrt(abs(point - dof * dof)); - point = sqrt(point); + point = sqrt(dot(of, of)); + edge = abs(dot(dir, of)); } void colorDist(vec4 color, float dist) -- cgit v1.2.3 From 69e512243c781129a7eca853a7a0c2c2d58dd709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 3 Jul 2018 15:39:16 +0200 Subject: Cleanup: Remove unused variable --- .../draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl index e0ec6e50dc2..f19c203a70d 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl @@ -96,11 +96,11 @@ void doLoopStrip(int v, vec3 offset) void main() { /* Edge */ - ivec3 eflag; vec3 ecrease, ebweight; + ivec3 eflag; for (int v = 0; v < 3; ++v) { flag[v] = eflag[v] = vData[v].y | (vData[v].x << 8); - edgesCrease[v] = ecrease[v] = vData[v].z / 255.0; - edgesBweight[v] = ebweight[v] = vData[v].w / 255.0; + edgesCrease[v] = vData[v].z / 255.0; + edgesBweight[v] = vData[v].w / 255.0; } /* Face */ @@ -112,10 +112,9 @@ void main() faceColor = colorFace; /* Vertex */ - vec2 pos[3]; - ssPos[0] = pos[0] = proj(pPos[0]); - ssPos[1] = pos[1] = proj(pPos[1]); - ssPos[2] = pos[2] = proj(pPos[2]); + ssPos[0] = proj(pPos[0]); + ssPos[1] = proj(pPos[1]); + ssPos[2] = proj(pPos[2]); doVertex(0); doVertex(1); -- cgit v1.2.3 From 48d7cf680ebe8ea7c09ef3e0e4abd1dc93d3fa5f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 15:44:56 +0200 Subject: Keymap: Select/De-Select support for anim-editors Also update menu items, adding select/de-select. --- .../startup/bl_ui/properties_mask_common.py | 8 +- release/scripts/startup/bl_ui/space_dopesheet.py | 6 +- release/scripts/startup/bl_ui/space_graph.py | 7 +- release/scripts/startup/bl_ui/space_image.py | 15 +-- release/scripts/startup/bl_ui/space_nla.py | 6 +- release/scripts/startup/bl_ui/space_sequencer.py | 8 +- release/scripts/startup/bl_ui/space_view3d.py | 115 +++++++++++++-------- .../blender/editors/animation/anim_channels_edit.c | 40 +++++-- .../blender/editors/space_action/action_intern.h | 2 +- source/blender/editors/space_action/action_ops.c | 12 ++- .../blender/editors/space_action/action_select.c | 31 ++++-- source/blender/editors/space_file/file_intern.h | 2 +- source/blender/editors/space_file/file_ops.c | 4 +- source/blender/editors/space_file/space_file.c | 4 +- source/blender/editors/space_graph/graph_intern.h | 2 +- source/blender/editors/space_graph/graph_ops.c | 12 ++- source/blender/editors/space_graph/graph_select.c | 30 ++++-- source/blender/editors/space_nla/nla_intern.h | 2 +- source/blender/editors/space_nla/nla_ops.c | 14 +-- source/blender/editors/space_nla/nla_select.c | 31 ++++-- 20 files changed, 226 insertions(+), 125 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py index 450ca80bbc2..c766c8dedbc 100644 --- a/release/scripts/startup/bl_ui/properties_mask_common.py +++ b/release/scripts/startup/bl_ui/properties_mask_common.py @@ -378,6 +378,12 @@ class MASK_MT_select(Menu): def draw(self, context): layout = self.layout + layout.operator("mask.select_all", text="All").action = 'SELECT' + layout.operator("mask.select_all", text="None").action = 'DESELECT' + layout.operator("mask.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("mask.select_border") layout.operator("mask.select_circle") @@ -388,8 +394,6 @@ class MASK_MT_select(Menu): layout.separator() - layout.operator("mask.select_all").action = 'TOGGLE' - layout.operator("mask.select_all", text="Inverse").action = 'INVERT' layout.operator("mask.select_linked", text="Select Linked") diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index aeda521ba04..93fbc7799bf 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -358,9 +358,9 @@ class DOPESHEET_MT_select(Menu): def draw(self, context): layout = self.layout - # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None - layout.operator("action.select_all_toggle").invert = False - layout.operator("action.select_all_toggle", text="Invert Selection").invert = True + layout.operator("action.select_all", text="All").action = 'SELECT' + layout.operator("action.select_all", text="None").action = 'DESELECT' + layout.operator("action.select_all", text="Invert").action = 'INVERT' layout.separator() layout.operator("action.select_border").axis_range = False diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index 0a6077e6b57..de5dcdbc36d 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -165,11 +165,12 @@ class GRAPH_MT_select(Menu): def draw(self, context): layout = self.layout - # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None - layout.operator("graph.select_all_toggle").invert = False - layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True + layout.operator("graph.select_all", text="All").action = 'SELECT' + layout.operator("graph.select_all", text="None").action = 'DESELECT' + layout.operator("graph.select_all", text="Invert").action = 'INVERT' layout.separator() + props = layout.operator("graph.select_border") props.axis_range = False props.include_handles = False diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index ba63b2b216e..e20c3ccd7f5 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -139,14 +139,20 @@ class IMAGE_MT_select(Menu): def draw(self, context): layout = self.layout + layout.operator("uv.select_all", text="All").action = 'SELECT' + layout.operator("uv.select_all", text="None").action = 'DESELECT' + layout.operator("uv.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("uv.select_border").pinned = False layout.operator("uv.select_border", text="Border Select Pinned").pinned = True layout.operator("uv.circle_select") layout.separator() - layout.operator("uv.select_all").action = 'TOGGLE' - layout.operator("uv.select_all", text="Inverse").action = 'INVERT' + layout.operator("uv.select_less", text="Less") + layout.operator("uv.select_more", text="More") layout.separator() @@ -155,11 +161,6 @@ class IMAGE_MT_select(Menu): layout.separator() - layout.operator("uv.select_less", text="Less") - layout.operator("uv.select_more", text="More") - - layout.separator() - layout.operator("uv.select_split") diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 304fc799fea..4bf338b89d6 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -126,9 +126,9 @@ class NLA_MT_select(Menu): def draw(self, context): layout = self.layout - # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None - layout.operator("nla.select_all_toggle").invert = False - layout.operator("nla.select_all_toggle", text="Invert Selection").invert = True + layout.operator("nla.select_all", text="All").action = 'SELECT' + layout.operator("nla.select_all", text="None").action = 'DESELECT' + layout.operator("nla.select_all", text="Invert").action = 'INVERT' layout.separator() layout.operator("nla.select_border").axis_range = False diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index dc966850b69..0bdfcc39ed9 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -249,6 +249,12 @@ class SEQUENCER_MT_select(Menu): def draw(self, context): layout = self.layout + layout.operator("sequencer.select_all", text="All").action = 'SELECT' + layout.operator("sequencer.select_all", text="None").action = 'DESELECT' + layout.operator("sequencer.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT' layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT' props = layout.operator("sequencer.select", text="All Strips to the Left") @@ -267,8 +273,6 @@ class SEQUENCER_MT_select(Menu): layout.operator("sequencer.select_linked") layout.operator("sequencer.select_less") layout.operator("sequencer.select_more") - layout.operator("sequencer.select_all").action = 'TOGGLE' - layout.operator("sequencer.select_all", text="Inverse").action = 'INVERT' class SEQUENCER_MT_marker(Menu): diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 672a5d081bf..f5d451a1189 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -739,15 +739,19 @@ class VIEW3D_MT_select_object(Menu): def draw(self, context): layout = self.layout + layout.operator("object.select_all", text="All").action = 'SELECT' + layout.operator("object.select_all", text="None").action = 'DESELECT' + layout.operator("object.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("view3d.select_border") layout.operator("view3d.select_circle") layout.separator() - layout.operator("object.select_all", text="Select/Deselect All").action = 'TOGGLE' layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...") layout.operator("object.select_camera", text="Select Active Camera") - layout.operator("object.select_all", text="Inverse Selection").action = 'INVERT' layout.operator("object.select_mirror", text="Mirror Selection") layout.operator("object.select_random", text="Select Random") @@ -795,13 +799,17 @@ class VIEW3D_MT_select_pose(Menu): def draw(self, context): layout = self.layout + layout.operator("pose.select_all", text="All").action = 'SELECT' + layout.operator("pose.select_all", text="None").action = 'DESELECT' + layout.operator("pose.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("view3d.select_border") layout.operator("view3d.select_circle") layout.separator() - layout.operator("pose.select_all").action = 'TOGGLE' - layout.operator("pose.select_all", text="Inverse").action = 'INVERT' layout.operator("pose.select_mirror", text="Flip Active") layout.separator() @@ -825,14 +833,18 @@ class VIEW3D_MT_select_particle(Menu): def draw(self, context): layout = self.layout + layout.operator("particle.select_all", text="All").action = 'SELECT' + layout.operator("particle.select_all", text="None").action = 'DESELECT' + layout.operator("particle.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("view3d.select_border") layout.operator("view3d.select_circle") layout.separator() - layout.operator("particle.select_all").action = 'TOGGLE' layout.operator("particle.select_linked") - layout.operator("particle.select_all", text="Inverse").action = 'INVERT' layout.separator() @@ -926,14 +938,15 @@ class VIEW3D_MT_select_edit_mesh(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + # primitive + layout.operator("mesh.select_all", text="All").action = 'SELECT' + layout.operator("mesh.select_all", text="None").action = 'DESELECT' + layout.operator("mesh.select_all", text="Invert").action = 'INVERT' layout.separator() - # primitive - layout.operator("mesh.select_all", text="Select/Deselect All").action = 'TOGGLE' - layout.operator("mesh.select_all", text="Inverse Selection").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -979,13 +992,14 @@ class VIEW3D_MT_select_edit_curve(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("curve.select_all", text="All").action = 'SELECT' + layout.operator("curve.select_all", text="None").action = 'DESELECT' + layout.operator("curve.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("curve.select_all").action = 'TOGGLE' - layout.operator("curve.select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1013,13 +1027,14 @@ class VIEW3D_MT_select_edit_surface(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("curve.select_all", text="All").action = 'SELECT' + layout.operator("curve.select_all", text="None").action = 'DESELECT' + layout.operator("curve.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("curve.select_all").action = 'TOGGLE' - layout.operator("curve.select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1065,13 +1080,14 @@ class VIEW3D_MT_select_edit_metaball(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("mball.select_all", text="All").action = 'SELECT' + layout.operator("mball.select_all", text="None").action = 'DESELECT' + layout.operator("mball.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("mball.select_all").action = 'TOGGLE' - layout.operator("mball.select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1088,13 +1104,14 @@ class VIEW3D_MT_select_edit_lattice(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("lattice.select_all", text="All").action = 'SELECT' + layout.operator("lattice.select_all", text="None").action = 'DESELECT' + layout.operator("lattice.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("lattice.select_all").action = 'TOGGLE' - layout.operator("lattice.select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1112,13 +1129,17 @@ class VIEW3D_MT_select_edit_armature(Menu): def draw(self, context): layout = self.layout + layout.operator("armature.select_all", text="All").action = 'SELECT' + layout.operator("armature.select_all", text="None").action = 'DESELECT' + layout.operator("armature.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("view3d.select_border") layout.operator("view3d.select_circle") layout.separator() - layout.operator("armature.select_all").action = 'TOGGLE' - layout.operator("armature.select_all", text="Inverse").action = 'INVERT' layout.operator("armature.select_mirror", text="Mirror").extend = False layout.separator() @@ -1156,13 +1177,14 @@ class VIEW3D_MT_select_gpencil(Menu): def draw(self, context): layout = self.layout - layout.operator("gpencil.select_border") - layout.operator("gpencil.select_circle") + layout.operator("gpencil.select_all", text="All").action = 'SELECT' + layout.operator("gpencil.select_all", text="None").action = 'DESELECT' + layout.operator("gpencil.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("gpencil.select_all", text="(De)select All").action = 'TOGGLE' - layout.operator("gpencil.select_all", text="Inverse").action = 'INVERT' + layout.operator("gpencil.select_border") + layout.operator("gpencil.select_circle") layout.separator() @@ -1186,13 +1208,14 @@ class VIEW3D_MT_select_paint_mask(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("paint.face_select_all", text="All").action = 'SELECT' + layout.operator("paint.face_select_all", text="None").action = 'DESELECT' + layout.operator("paint.face_select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("paint.face_select_all").action = 'TOGGLE' - layout.operator("paint.face_select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1205,13 +1228,14 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("paint.vert_select_all", text="All").action = 'SELECT' + layout.operator("paint.vert_select_all", text="None").action = 'DESELECT' + layout.operator("paint.vert_select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("paint.vert_select_all").action = 'TOGGLE' - layout.operator("paint.vert_select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -2278,6 +2302,13 @@ class VIEW3D_MT_particle_specials(Menu): if particle_edit.select_mode == 'POINT': layout.separator() + + layout.operator("particle.select_all", text="All").action = 'SELECT' + layout.operator("particle.select_all", text="None").action = 'DESELECT' + layout.operator("particle.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("particle.select_roots") layout.operator("particle.select_tips") @@ -2292,9 +2323,7 @@ class VIEW3D_MT_particle_specials(Menu): layout.separator() - layout.operator("particle.select_all").action = 'TOGGLE' layout.operator("particle.select_linked") - layout.operator("particle.select_all", text="Inverse").action = 'INVERT' class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu): diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index f629c20b04a..f11c850a12b 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2339,10 +2339,24 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* 'standard' behavior - check if selected, then apply relevant selection */ - if (RNA_boolean_get(op->ptr, "invert")) - ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT); - else - ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD); + const int action = RNA_enum_get(op->ptr, "action"); + switch (action) { + case SEL_TOGGLE: + ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD); + break; + case SEL_SELECT: + ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_ADD); + break; + case SEL_DESELECT: + ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_CLEAR); + break; + case SEL_INVERT: + ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT); + break; + default: + BLI_assert(0); + break; + } /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); @@ -2350,11 +2364,11 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot) +static void ANIM_OT_channels_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; - ot->idname = "ANIM_OT_channels_select_all_toggle"; + ot->idname = "ANIM_OT_channels_select_all"; ot->description = "Toggle selection of all animation channels"; /* api callbacks */ @@ -2364,8 +2378,8 @@ static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* props */ - ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", ""); + /* properties */ + WM_operator_properties_select_all(ot); } /* ******************** Borderselect Operator *********************** */ @@ -3146,7 +3160,7 @@ static void ANIM_OT_channel_select_keys(wmOperatorType *ot) void ED_operatortypes_animchannels(void) { - WM_operatortype_append(ANIM_OT_channels_select_all_toggle); + WM_operatortype_append(ANIM_OT_channels_select_all); WM_operatortype_append(ANIM_OT_channels_select_border); WM_operatortype_append(ANIM_OT_channels_click); @@ -3199,8 +3213,12 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); /* deselect all */ - WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", true); + kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); /* borderselect */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index fc1f40cdb5a..bb8de677b57 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -62,7 +62,7 @@ void timeline_draw_cache(struct SpaceAction *saction, struct Object *ob, struct /* ***************************************** */ /* action_select.c */ -void ACTION_OT_select_all_toggle(struct wmOperatorType *ot); +void ACTION_OT_select_all(struct wmOperatorType *ot); void ACTION_OT_select_border(struct wmOperatorType *ot); void ACTION_OT_select_lasso(struct wmOperatorType *ot); void ACTION_OT_select_circle(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index bf7f75db95c..2f2e8c6f49f 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -57,7 +57,7 @@ void action_operatortypes(void) /* keyframes */ /* selection */ WM_operatortype_append(ACTION_OT_clickselect); - WM_operatortype_append(ACTION_OT_select_all_toggle); + WM_operatortype_append(ACTION_OT_select_all); WM_operatortype_append(ACTION_OT_select_border); WM_operatortype_append(ACTION_OT_select_lasso); WM_operatortype_append(ACTION_OT_select_circle); @@ -169,10 +169,12 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT); /* deselect all */ - kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", false); - kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", true); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); /* borderselect */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 11145e29627..b6431596323 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -157,10 +157,24 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* 'standard' behavior - check if selected, then apply relevant selection */ - if (RNA_boolean_get(op->ptr, "invert")) - deselect_action_keys(&ac, 0, SELECT_INVERT); - else - deselect_action_keys(&ac, 1, SELECT_ADD); + const int action = RNA_enum_get(op->ptr, "action"); + switch (action) { + case SEL_TOGGLE: + deselect_action_keys(&ac, 1, SELECT_ADD); + break; + case SEL_SELECT: + deselect_action_keys(&ac, 0, SELECT_ADD); + break; + case SEL_DESELECT: + deselect_action_keys(&ac, 0, SELECT_SUBTRACT); + break; + case SEL_INVERT: + deselect_action_keys(&ac, 0, SELECT_INVERT); + break; + default: + BLI_assert(0); + break; + } /* set notifier that keyframe selection have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); @@ -168,11 +182,11 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void ACTION_OT_select_all_toggle(wmOperatorType *ot) +void ACTION_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; - ot->idname = "ACTION_OT_select_all_toggle"; + ot->idname = "ACTION_OT_select_all"; ot->description = "Toggle selection of all keyframes"; /* api callbacks */ @@ -182,9 +196,8 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* props */ - ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); - RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); + /* properties */ + WM_operator_properties_select_all(ot); } /* ******************** Border Select Operator **************************** */ diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 6eaf2dda084..48acbdb137d 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -72,7 +72,7 @@ typedef enum WalkSelectDirection { void FILE_OT_highlight(struct wmOperatorType *ot); void FILE_OT_select(struct wmOperatorType *ot); void FILE_OT_select_walk(struct wmOperatorType *ot); -void FILE_OT_select_all_toggle(struct wmOperatorType *ot); +void FILE_OT_select_all(struct wmOperatorType *ot); void FILE_OT_select_border(struct wmOperatorType *ot); void FILE_OT_select_bookmark(struct wmOperatorType *ot); void FILE_OT_bookmark_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 7c080044aee..b19b2ff6cd5 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -808,12 +808,12 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void FILE_OT_select_all_toggle(wmOperatorType *ot) +void FILE_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "(De)select All Files"; ot->description = "Select or deselect all files"; - ot->idname = "FILE_OT_select_all_toggle"; + ot->idname = "FILE_OT_select_all"; /* api callbacks */ ot->exec = file_select_all_exec; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 853d31edebf..0e39ea725ae 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -462,7 +462,7 @@ static void file_operatortypes(void) { WM_operatortype_append(FILE_OT_select); WM_operatortype_append(FILE_OT_select_walk); - WM_operatortype_append(FILE_OT_select_all_toggle); + WM_operatortype_append(FILE_OT_select_all); WM_operatortype_append(FILE_OT_select_border); WM_operatortype_append(FILE_OT_select_bookmark); WM_operatortype_append(FILE_OT_highlight); @@ -588,7 +588,7 @@ static void file_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "FILE_OT_previous", BUTTON4MOUSE, KM_CLICK, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_next", BUTTON5MOUSE, KM_CLICK, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "FILE_OT_select_all", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_border", EVT_TWEAK_L, KM_ANY, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index c50e0497519..398561927dd 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -58,7 +58,7 @@ void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, str void deselect_graph_keys(struct bAnimContext *ac, bool test, short sel, bool do_channels); -void GRAPH_OT_select_all_toggle(struct wmOperatorType *ot); +void GRAPH_OT_select_all(struct wmOperatorType *ot); void GRAPH_OT_select_border(struct wmOperatorType *ot); void GRAPH_OT_select_lasso(struct wmOperatorType *ot); void GRAPH_OT_select_circle(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 8ac2c61b8e9..5e269a9c99d 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -427,7 +427,7 @@ void graphedit_operatortypes(void) /* keyframes */ /* selection */ WM_operatortype_append(GRAPH_OT_clickselect); - WM_operatortype_append(GRAPH_OT_select_all_toggle); + WM_operatortype_append(GRAPH_OT_select_all); WM_operatortype_append(GRAPH_OT_select_border); WM_operatortype_append(GRAPH_OT_select_lasso); WM_operatortype_append(GRAPH_OT_select_circle); @@ -550,10 +550,12 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); /* deselect all */ - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", false); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", true); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); /* borderselect */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 9a6b733a5ff..e91bb192d3c 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -162,10 +162,24 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op) ale_active = get_active_fcurve_channel(&ac); /* 'standard' behavior - check if selected, then apply relevant selection */ - if (RNA_boolean_get(op->ptr, "invert")) - deselect_graph_keys(&ac, 0, SELECT_INVERT, true); - else - deselect_graph_keys(&ac, 1, SELECT_ADD, true); + const int action = RNA_enum_get(op->ptr, "action"); + switch (action) { + case SEL_TOGGLE: + deselect_graph_keys(&ac, 1, SELECT_ADD, true); + break; + case SEL_SELECT: + deselect_graph_keys(&ac, 0, SELECT_ADD, true); + break; + case SEL_DESELECT: + deselect_graph_keys(&ac, 0, SELECT_SUBTRACT, true); + break; + case SEL_INVERT: + deselect_graph_keys(&ac, 0, SELECT_INVERT, true); + break; + default: + BLI_assert(0); + break; + } /* restore active F-Curve... */ if (ale_active) { @@ -186,11 +200,11 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void GRAPH_OT_select_all_toggle(wmOperatorType *ot) +void GRAPH_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; - ot->idname = "GRAPH_OT_select_all_toggle"; + ot->idname = "GRAPH_OT_select_all"; ot->description = "Toggle selection of all keyframes"; /* api callbacks */ @@ -200,8 +214,8 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* props */ - ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); + /* properties */ + WM_operator_properties_select_all(ot); } /* ******************** Border Select Operator **************************** */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index a00e71a192d..e59395cac6b 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -65,7 +65,7 @@ enum eNlaEdit_LeftRightSelect_Mode { /* --- */ -void NLA_OT_select_all_toggle(wmOperatorType *ot); +void NLA_OT_select_all(wmOperatorType *ot); void NLA_OT_select_border(wmOperatorType *ot); void NLA_OT_select_leftright(wmOperatorType *ot); void NLA_OT_click_select(wmOperatorType *ot); diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 5bfd73b8163..c5dd85b7c4d 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -124,7 +124,7 @@ void nla_operatortypes(void) /* select */ WM_operatortype_append(NLA_OT_click_select); WM_operatortype_append(NLA_OT_select_border); - WM_operatortype_append(NLA_OT_select_all_toggle); + WM_operatortype_append(NLA_OT_select_all); WM_operatortype_append(NLA_OT_select_leftright); /* view */ @@ -223,13 +223,13 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT); - /* deselect all */ - /* TODO: uniformize with other select_all ops? */ - kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", false); - kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", true); + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); /* borderselect */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index f22c211af64..5d32b23ad67 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -167,10 +167,24 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* 'standard' behavior - check if selected, then apply relevant selection */ - if (RNA_boolean_get(op->ptr, "invert")) - deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_INVERT); - else - deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD); + const int action = RNA_enum_get(op->ptr, "action"); + switch (action) { + case SEL_TOGGLE: + deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD); + break; + case SEL_SELECT: + deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_ADD); + break; + case SEL_DESELECT: + deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_SUBTRACT); + break; + case SEL_INVERT: + deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_INVERT); + break; + default: + BLI_assert(0); + break; + } /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); @@ -178,11 +192,11 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void NLA_OT_select_all_toggle(wmOperatorType *ot) +void NLA_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "(De)select All"; - ot->idname = "NLA_OT_select_all_toggle"; + ot->idname = "NLA_OT_select_all"; ot->description = "Select or deselect all NLA-Strips"; /* api callbacks */ @@ -192,9 +206,8 @@ void NLA_OT_select_all_toggle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; - /* props */ - ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); - RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); + /* properties */ + WM_operator_properties_select_all(ot); } /* ******************** Border Select Operator **************************** */ -- cgit v1.2.3 From cde6bbfea18d6c1f7e3cacff99a26f6b3d1ffb2e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 16:34:12 +0200 Subject: Keymap: update 2.7x map --- release/scripts/presets/keyconfig/blender_27x.py | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index e6c036d04d7..e047364a9e3 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -597,10 +597,10 @@ kmi_props_setattr(kmi.properties, 'extend', False) kmi = km.keymap_items.new('action.select_leftright', 'RIGHT_BRACKET', 'PRESS') kmi_props_setattr(kmi.properties, 'mode', 'RIGHT') kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('action.select_all_toggle', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'invert', False) -kmi = km.keymap_items.new('action.select_all_toggle', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'invert', True) +kmi = km.keymap_items.new('action.select_all', 'A', 'PRESS') +kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') +kmi = km.keymap_items.new('action.select_all', 'I', 'PRESS', ctrl=True) +kmi_props_setattr(kmi.properties, 'action', 'INVERT') kmi = km.keymap_items.new('action.select_border', 'B', 'PRESS') kmi_props_setattr(kmi.properties, 'axis_range', False) kmi = km.keymap_items.new('action.select_border', 'B', 'PRESS', alt=True) @@ -2548,9 +2548,10 @@ kmi = km.keymap_items.new('anim.channel_select_keys', 'LEFTMOUSE', 'DOUBLE_CLICK kmi = km.keymap_items.new('anim.channel_select_keys', 'LEFTMOUSE', 'DOUBLE_CLICK', shift=True) kmi_props_setattr(kmi.properties, 'extend', True) kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('anim.channels_select_all_toggle', 'A', 'PRESS') -kmi = km.keymap_items.new('anim.channels_select_all_toggle', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'invert', True) +kmi = km.keymap_items.new('anim.channels_select_all', 'A', 'PRESS') +kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') +kmi = km.keymap_items.new('anim.channels_select_all', 'I', 'PRESS', ctrl=True) +kmi_props_setattr(kmi.properties, 'action', 'INVERT') kmi = km.keymap_items.new('anim.channels_select_border', 'B', 'PRESS') kmi = km.keymap_items.new('anim.channels_select_border', 'EVT_TWEAK_L', 'ANY') kmi = km.keymap_items.new('anim.channels_delete', 'X', 'PRESS') @@ -2825,10 +2826,10 @@ kmi_props_setattr(kmi.properties, 'extend', False) kmi = km.keymap_items.new('graph.select_leftright', 'RIGHT_BRACKET', 'PRESS') kmi_props_setattr(kmi.properties, 'mode', 'RIGHT') kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('graph.select_all_toggle', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'invert', False) -kmi = km.keymap_items.new('graph.select_all_toggle', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'invert', True) +kmi = km.keymap_items.new('graph.select_all', 'A', 'PRESS') +kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') +kmi = km.keymap_items.new('graph.select_all', 'I', 'PRESS', ctrl=True) +kmi_props_setattr(kmi.properties, 'action', 'INVERT') kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS') kmi_props_setattr(kmi.properties, 'axis_range', False) kmi_props_setattr(kmi.properties, 'include_handles', False) @@ -3319,10 +3320,10 @@ kmi_props_setattr(kmi.properties, 'extend', False) kmi = km.keymap_items.new('nla.select_leftright', 'RIGHT_BRACKET', 'PRESS') kmi_props_setattr(kmi.properties, 'mode', 'RIGHT') kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('nla.select_all_toggle', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'invert', False) -kmi = km.keymap_items.new('nla.select_all_toggle', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'invert', True) +kmi = km.keymap_items.new('nla.select_all', 'A', 'PRESS') +kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') +kmi = km.keymap_items.new('nla.select_all', 'I', 'PRESS', ctrl=True) +kmi_props_setattr(kmi.properties, 'action', 'INVERT') kmi = km.keymap_items.new('nla.select_border', 'B', 'PRESS') kmi_props_setattr(kmi.properties, 'axis_range', False) kmi = km.keymap_items.new('nla.select_border', 'B', 'PRESS', alt=True) -- cgit v1.2.3 From 4632e4fde42a4c741fd8bb40a924a37440b4689f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 16:37:15 +0200 Subject: Keymap: Use easily accessible key for animation Based on animator feedback, this key is accessed many times a day. Swap Shift-Space /w Ctrl-Space (full-screen area). --- source/blender/editors/screen/screen_ops.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 5ad70e84615..a0e8357b8f3 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4856,8 +4856,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf) RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1); #endif - WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_SHIFT, 0); - kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "use_hide_panels", true); #ifdef USE_WM_KEYMAP_27X @@ -4964,9 +4964,9 @@ void ED_keymap_screen(wmKeyConfig *keyconf) "reverse", true); #else /* play (forward and backwards) */ - WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set( - WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0)->ptr, + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "reverse", true); #endif WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0); -- cgit v1.2.3 From f14680b1bea4f8aeca3e21a327edc5647c78c3a7 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 3 Jul 2018 16:43:00 +0200 Subject: UI: Default theme, more tweaks Also make the selected list items not as bright, boxes darker and adjustments for contrast and accessibility. --- release/datafiles/userdef/userdef_default_theme.c | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 4c117dca354..e14d154819f 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -20,7 +20,7 @@ const bTheme U_theme_default = { .name = "Default", .tui = { .wcol_regular = { - .outline = RGBA(0x444444ff), + .outline = RGBA(0x373737ff), .inner = RGBA(0x585858ff), .inner_sel = RGBA(0x5680c2e6), .item = RGBA(0x3e3e3eff), @@ -30,7 +30,7 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_tool = { - .outline = RGBA(0x444444ff), + .outline = RGBA(0x373737ff), .inner = RGBA(0x585858ff), .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xffffffff), @@ -40,7 +40,7 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_toolbar_item = { - .outline = RGBA(0x444444ff), + .outline = RGBA(0x373737ff), .inner = RGBA(0x585858ff), .inner_sel = RGBA(0x5680c2ff), .item = RGBA(0xffffff8f), @@ -50,7 +50,7 @@ const bTheme U_theme_default = { }, .wcol_text = { .outline = RGBA(0x444444ff), - .inner = RGBA(0x2c2c2cff), + .inner = RGBA(0x1f1f1fff), .inner_sel = RGBA(0x808080ff), .item = RGBA(0x333333ff), .text = RGBA(0xeeeeeeff), @@ -60,7 +60,7 @@ const bTheme U_theme_default = { .roundness = 0.1f, }, .wcol_radio = { - .outline = RGBA(0x444444ff), + .outline = RGBA(0x373737ff), .inner = RGBA(0x595959ff), .inner_sel = RGBA(0x5680c2e6), .item = RGBA(0xffffffff), @@ -71,7 +71,7 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_option = { - .outline = RGBA(0x444444ff), + .outline = RGBA(0x373737ff), .inner = RGBA(0x666666ff), .inner_sel = RGBA(0x5680c2e6), .item = RGBA(0xffffffff), @@ -81,7 +81,7 @@ const bTheme U_theme_default = { .roundness = 0.25f, }, .wcol_toggle = { - .outline = RGBA(0x4d4d4dff), + .outline = RGBA(0x373737ff), .inner = RGBA(0x595959ff), .inner_sel = RGBA(0x5680c2e6), .item = RGBA(0x191919ff), @@ -101,8 +101,8 @@ const bTheme U_theme_default = { }, .wcol_numslider = { .outline = RGBA(0x444444ff), - .inner = RGBA(0x3b3b3bff), - .inner_sel = RGBA(0x808080ff), + .inner = RGBA(0x2c2c2cff), + .inner_sel = RGBA(0x1f1f1fff), .item = RGBA(0x585858ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -121,11 +121,11 @@ const bTheme U_theme_default = { }, .wcol_menu = { .outline = RGBA(0x444444ff), - .inner = RGBA(0x2e2e2eff), - .inner_sel = RGBA(0x585858ff), + .inner = RGBA(0x2c2c2cff), + .inner_sel = RGBA(0x696e76ff), .item = RGBA(0xe6e6e6ff), .text = RGBA(0xeeeeeeff), - .text_sel = RGBA(0xccccccff), + .text_sel = RGBA(0xffffffff), .shadetop = 10, .shadedown = -10, .roundness = 0.2f, @@ -172,9 +172,9 @@ const bTheme U_theme_default = { .roundness = 0.4f, }, .wcol_box = { - .outline = RGBA(0x333333ff), - .inner = RGBA(0x4d4d4dcc), - .inner_sel = RGBA(0x808080ff), + .outline = RGBA(0x444444ff), + .inner = RGBA(0x00000033), + .inner_sel = RGBA(0x696e76ff), .item = RGBA(0x191919ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -203,9 +203,9 @@ const bTheme U_theme_default = { .wcol_list_item = { .outline = RGBA(0x2d2d2dff), .inner = RGBA(0x2d2d2d00), - .inner_sel = RGBA(0x5680c2ff), + .inner_sel = RGBA(0x696e76ff), .item = RGBA(0xb3b3b3ff), - .text = RGBA(0xeeeeeeff), + .text = RGBA(0xe1e1e1ff), .text_sel = RGBA(0xffffffff), .roundness = 0.2f, }, @@ -264,8 +264,8 @@ const bTheme U_theme_default = { .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x42424200), - .back = RGBA(0x333333b3), - .sub_back = RGBA(0x0000003e), + .back = RGBA(0x00000028), + .sub_back = RGBA(0x00000024), .show_header = 1, .show_back = 1, }, -- cgit v1.2.3 From 3da9d365548f9652a0a15d304ca52cece8864c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 3 Jul 2018 16:50:12 +0200 Subject: Fix T55709: Pose Library - Add New Pose crashes --- source/blender/editors/animation/keyframing.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index e234a3a131a..7f045fa477f 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1107,7 +1107,12 @@ short insert_keyframe( } if (ret) { - DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE); + if (act != NULL) { + DEG_id_tag_update(&act->id, DEG_TAG_COPY_ON_WRITE); + } + if (adt != NULL && adt->action != NULL && adt->action != act) { + DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE); + } } return ret; -- cgit v1.2.3 From 00db85ea81dd8b743dec3b196bff34f396353dcc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 17:46:23 +0200 Subject: Theme: use alpha for lamp wire Needed for showing helper line to plane. --- release/datafiles/userdef/userdef_default_theme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index e14d154819f..8981612afe8 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -303,7 +303,7 @@ const bTheme U_theme_default = { .wire = RGBA(0x000000ff), .wire_edit = RGBA(0x111111ff), .select = RGBA(0xed5700ff), - .lamp = RGBA(0x000000ff), + .lamp = RGBA(0x00000028), .speaker = RGBA(0x000000ff), .empty = RGBA(0x000000ff), .camera = RGBA(0x000000ff), -- cgit v1.2.3 From 51acd547605a9c3b1644fba9d6e3168e37973c68 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 18:02:16 +0200 Subject: Fix tool-system error running in background mode --- source/blender/editors/object/object_edit.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0ca797e43b6..ef9d32f7148 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -709,7 +709,9 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode); - WM_toolsystem_update_from_context_view3d(C); + if (G.background == false) { + WM_toolsystem_update_from_context_view3d(C); + } return OPERATOR_FINISHED; } @@ -809,7 +811,9 @@ static int posemode_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode); - WM_toolsystem_update_from_context_view3d(C); + if (G.background == false) { + WM_toolsystem_update_from_context_view3d(C); + } return OPERATOR_FINISHED; } -- cgit v1.2.3 From 81a23d1f2db5d3c21e3c35cf3128f5e6326df54a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 18:33:52 +0200 Subject: Tool System: add operator for introspection In some cases we want associate use an operator for a tool for introspection, so we can for eg, automatically use the same binding for in the popup toolbar. Space-G/R/S for transform now work as accelerator keys again. Also Space-E for extrude. --- .../startup/bl_ui/space_toolsystem_common.py | 26 +++++++++++++++------- .../startup/bl_ui/space_toolsystem_toolbar.py | 5 +++++ source/blender/makesdna/DNA_workspace_types.h | 9 +++++--- source/blender/makesrna/intern/rna_workspace_api.c | 3 +++ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 20db56af416..2d7afb7a56a 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -88,6 +88,8 @@ ToolDef = namedtuple( # Optional data-block assosiated with this tool. # (Typically brush name, usage depends on mode, we could use for non-brush ID's in other modes). "data_block", + # Optional primary operator (for introspection only). + "operator", # Optional draw settings (operator options, toolsettings). "draw_settings", ) @@ -107,6 +109,7 @@ def from_dict(kw_args): "widget": None, "keymap": None, "data_block": None, + "operator": None, "draw_settings": None, } kw.update(kw_args) @@ -568,6 +571,7 @@ def _activate_by_item(context, space_type, item, index): cursor=item.cursor or 'DEFAULT', manipulator_group=item.widget or "", data_block=item.data_block or "", + operator=item.operator or "", index=index, ) @@ -643,15 +647,21 @@ def keymap_from_context(context, space_type): kmi.properties.name = item.text continue - if not item.keymap: - continue - # Only check the first item in the tools key-map (a little arbitrary). - kmi_first = item.keymap[0].keymap_items[0] - kmi_found = wm.keyconfigs.find_item_from_operator( - idname=kmi_first.idname, - # properties=kmi_first.properties, # prevents matches, don't use. - )[1] + if item.operator is not None: + kmi_found = wm.keyconfigs.find_item_from_operator( + idname=item.operator, + )[1] + elif item.keymap is not None: + kmi_first = item.keymap[0].keymap_items[0] + kmi_found = wm.keyconfigs.find_item_from_operator( + idname=kmi_first.idname, + # properties=kmi_first.properties, # prevents matches, don't use. + )[1] + del kmi_first + else: + kmi_found = None + if kmi_found is not None: kmi_found_type = kmi_found.type # Only for single keys. diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index a6e1d511b4c..b0bff84b8eb 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -134,6 +134,7 @@ class _defs_transform: # cursor='SCROLL_XY', icon="ops.transform.translate", widget="TRANSFORM_WGT_manipulator", + operator="transform.translate", # TODO, implement as optional fallback manipulator # keymap=( # ("transform.translate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), @@ -147,6 +148,7 @@ class _defs_transform: # cursor='SCROLL_XY', icon="ops.transform.rotate", widget="TRANSFORM_WGT_manipulator", + operator="transform.rotate", # TODO, implement as optional fallback manipulator # keymap=( # ("transform.rotate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), @@ -160,6 +162,7 @@ class _defs_transform: # cursor='SCROLL_XY', icon="ops.transform.resize", widget="TRANSFORM_WGT_manipulator", + operator="transform.resize", # TODO, implement as optional fallback manipulator # keymap=( # ("transform.resize", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), @@ -172,6 +175,7 @@ class _defs_transform: text="Scale Cage", icon="ops.transform.resize.cage", widget="VIEW3D_WGT_xform_cage", + operator="transform.resize", ) @ToolDef.from_fn @@ -459,6 +463,7 @@ class _defs_edit_mesh: text="Extrude Region", icon="ops.mesh.extrude_region_move", widget="MESH_WGT_extrude", + operator="view3d.edit_mesh_extrude_move_normal", keymap=( ("mesh.extrude_context_move", dict(TRANSFORM_OT_translate=dict(release_confirm=True)), dict(type='EVT_TWEAK_A', value='ANY')), diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h index 585794fbe97..f07dc195455 100644 --- a/source/blender/makesdna/DNA_workspace_types.h +++ b/source/blender/makesdna/DNA_workspace_types.h @@ -58,12 +58,15 @@ typedef struct bToolRef_Runtime { int cursor; - /* One of these 3 must be defined. */ + /** One of these 3 must be defined. */ char keymap[64]; char manipulator_group[64]; char data_block[64]; - /* index when a tool is a member of a group */ + /** Use to infer primary operator to use when setting accelerator keys. */ + char operator[64]; + + /** Index when a tool is a member of a group. */ int index; } bToolRef_Runtime; @@ -76,7 +79,7 @@ typedef struct bToolRef { /** Use to avoid initializing the same tool multiple times. */ short tag; - /** bToolKey (spacetype, mode), used in 'WM_api.h' */ + /** #bToolKey (spacetype, mode), used in 'WM_api.h' */ short space_type; /** * Value depends ont the 'space_type', object mode for 3D view, image editor has own mode too. diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c index 0db192e8347..eceaaeec3a4 100644 --- a/source/blender/makesrna/intern/rna_workspace_api.c +++ b/source/blender/makesrna/intern/rna_workspace_api.c @@ -53,6 +53,7 @@ static void rna_WorkspaceTool_setup( const char *keymap, const char *manipulator_group, const char *data_block, + const char *operator, int index) { bToolRef_Runtime tref_rt = {0}; @@ -61,6 +62,7 @@ static void rna_WorkspaceTool_setup( STRNCPY(tref_rt.keymap, keymap); STRNCPY(tref_rt.manipulator_group, manipulator_group); STRNCPY(tref_rt.data_block, data_block); + STRNCPY(tref_rt.operator, operator); tref_rt.index = index; WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, name); @@ -110,6 +112,7 @@ void RNA_api_workspace_tool(StructRNA *srna) RNA_def_string(func, "keymap", NULL, KMAP_MAX_NAME, "Key Map", ""); RNA_def_string(func, "manipulator_group", NULL, MAX_NAME, "Manipulator Group", ""); RNA_def_string(func, "data_block", NULL, MAX_NAME, "Data Block", ""); + RNA_def_string(func, "operator", NULL, MAX_NAME, "Operator", ""); RNA_def_int(func, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX); /* Access tool operator options (optionally create). */ -- cgit v1.2.3 From 79152371c3c259fed9d1106aa8003beef28168e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 18:41:06 +0200 Subject: UI: add tool properties contexts Currently unused, create for add-ons to populate. --- release/scripts/startup/bl_ui/space_topbar.py | 8 ++++++++ source/blender/editors/space_buttons/space_buttons.c | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index fef71ba6227..beb59d2c512 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -147,8 +147,14 @@ class TOPBAR_HT_lower_bar(Header): layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".weightpaint", category="") elif mode == 'PAINT_TEXTURE': layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".imagepaint", category="") + elif mode == 'EDIT_TEXT': + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".text_edit", category="") elif mode == 'EDIT_ARMATURE': layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".armature_edit", category="") + elif mode == 'EDIT_METABALL': + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".mball_edit", category="") + elif mode == 'EDIT_LATTICE': + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".lattice_edit", category="") elif mode == 'EDIT_CURVE': layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".curve_edit", category="") elif mode == 'EDIT_MESH': @@ -157,6 +163,8 @@ class TOPBAR_HT_lower_bar(Header): layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".posemode", category="") elif mode == 'PARTICLE': layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".particlemode", category="") + elif mode == 'OBJECT': + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".objectmode", category="") class _draw_left_context_mode: diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index a951c2a8524..ba9045346c7 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -225,16 +225,16 @@ static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts, ARRAY_SET_ITEMS(contexts, ".curve_edit"); break; case CTX_MODE_EDIT_TEXT: - ARRAY_SET_ITEMS(contexts, ".todo"); + ARRAY_SET_ITEMS(contexts, ".text_edit"); break; case CTX_MODE_EDIT_ARMATURE: ARRAY_SET_ITEMS(contexts, ".armature_edit"); break; case CTX_MODE_EDIT_METABALL: - ARRAY_SET_ITEMS(contexts, ".todo"); + ARRAY_SET_ITEMS(contexts, ".mball_edit"); break; case CTX_MODE_EDIT_LATTICE: - ARRAY_SET_ITEMS(contexts, ".todo"); + ARRAY_SET_ITEMS(contexts, ".lattice_edit"); break; case CTX_MODE_POSE: ARRAY_SET_ITEMS(contexts, ".posemode"); @@ -255,7 +255,7 @@ static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts, ARRAY_SET_ITEMS(contexts, ".particlemode"); break; case CTX_MODE_OBJECT: - ARRAY_SET_ITEMS(contexts, ".todo"); + ARRAY_SET_ITEMS(contexts, ".objectmode"); break; } } -- cgit v1.2.3 From bb9355e7031404a4e0374ad49928e0fcad1f0aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 3 Jul 2018 19:22:00 +0200 Subject: View3D: Remove v3d->zbuf This is because depth test is set before drawing anything now. There is no case where we want to draw without depth test that is not selection and this case is not handle by v3d->zbuf anymore. UI assume depth test is off by default. The DRWManager assume it's on. This should fix T55623. --- source/blender/draw/intern/draw_manager.c | 15 ++------------- source/blender/draw/intern/draw_manager_text.c | 20 ++------------------ source/blender/draw/intern/draw_manager_text.h | 4 +--- source/blender/draw/intern/draw_view.c | 4 ---- source/blender/editors/curve/editcurve_paint.c | 21 ++++++--------------- source/blender/editors/mesh/editmesh_knife.c | 8 ++++---- source/blender/editors/mesh/editmesh_loopcut.c | 10 ++++------ source/blender/editors/space_view3d/view3d_draw.c | 6 ++---- .../editors/space_view3d/view3d_draw_legacy.c | 22 +++++++--------------- source/blender/editors/space_view3d/view3d_view.c | 2 -- source/blender/editors/transform/transform.c | 14 ++++---------- source/blender/editors/transform/transform_snap.c | 4 +--- source/blender/makesdna/DNA_view3d_types.h | 3 ++- 13 files changed, 35 insertions(+), 98 deletions(-) diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index b7326ca5842..ea25739e52d 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -877,7 +877,7 @@ static void drw_engines_draw_text(void) PROFILE_START(stime); if (data->text_draw_cache) { - DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.v3d, DST.draw_ctx.ar, false); + DRW_text_cache_draw(data->text_draw_cache, DST.draw_ctx.ar); } PROFILE_END_UPDATE(data->render_time, stime); @@ -1237,9 +1237,7 @@ void DRW_draw_render_loop_ex( RegionView3D *rv3d = ar->regiondata; DST.draw_ctx.evil_C = evil_C; - DST.viewport = viewport; - v3d->zbuf = true; /* Setup viewport */ GPU_viewport_engines_data_validate(DST.viewport, DRW_engines_get_hash()); @@ -1658,8 +1656,6 @@ void DRW_draw_select_loop( GPU_viewport_size_set(viewport, (const int[2]){BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)}); DST.viewport = viewport; - v3d->zbuf = true; - DST.options.is_select = true; /* Get list of enabled engines */ @@ -1853,10 +1849,7 @@ void DRW_draw_depth_loop( GPU_framebuffer_bind(g_select_buffer.framebuffer); GPU_framebuffer_clear_depth(g_select_buffer.framebuffer, 1.0f); - bool cache_is_dirty; DST.viewport = viewport; - v3d->zbuf = true; - DST.options.is_depth = true; /* Get list of enabled engines */ @@ -1866,7 +1859,6 @@ void DRW_draw_depth_loop( } /* Setup viewport */ - cache_is_dirty = true; /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */ DST.draw_ctx = (DRWContextState){ @@ -1885,10 +1877,7 @@ void DRW_draw_depth_loop( drw_engines_init(); DRW_hair_init(); - /* TODO : tag to refresh by the dependency graph */ - /* ideally only refresh when objects are added/removed */ - /* or render properties / materials change */ - if (cache_is_dirty) { + { drw_engines_cache_init(); DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c index 56255af98ce..1f385b958b8 100644 --- a/source/blender/draw/intern/draw_manager_text.c +++ b/source/blender/draw/intern/draw_manager_text.c @@ -111,9 +111,7 @@ void DRW_text_cache_add( } } -void DRW_text_cache_draw( - DRWTextStore *dt, - View3D *v3d, ARegion *ar, bool depth_write) +void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar) { RegionView3D *rv3d = ar->regiondata; ViewCachedString *vos; @@ -149,13 +147,6 @@ void DRW_text_cache_draw( gpuPushMatrix(); gpuLoadIdentity(); - if (depth_write) { - if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - } - else { - glDepthMask(GL_FALSE); - } - const int font_id = BLF_default(); const uiStyle *style = UI_style_get(); @@ -171,7 +162,7 @@ void DRW_text_cache_draw( BLF_position( font_id, - (float)(vos->sco[0] + vos->xoffs), (float)(vos->sco[1]), (depth_write) ? 0.0f : 2.0f); + (float)(vos->sco[0] + vos->xoffs), (float)(vos->sco[1]), 2.0f); ((vos->flag & DRW_TEXT_CACHE_ASCII) ? BLF_draw_ascii : @@ -182,13 +173,6 @@ void DRW_text_cache_draw( } } - if (depth_write) { - if (v3d->zbuf) glEnable(GL_DEPTH_TEST); - } - else { - glDepthMask(GL_TRUE); - } - gpuPopMatrix(); gpuLoadProjectionMatrix(original_proj); diff --git a/source/blender/draw/intern/draw_manager_text.h b/source/blender/draw/intern/draw_manager_text.h index a58e167be0d..a675a200924 100644 --- a/source/blender/draw/intern/draw_manager_text.h +++ b/source/blender/draw/intern/draw_manager_text.h @@ -36,9 +36,7 @@ void DRW_text_cache_add( short xoffs, short flag, const unsigned char col[4]); -void DRW_text_cache_draw( - struct DRWTextStore *dt, - struct View3D *v3d, struct ARegion *ar, bool depth_write); +void DRW_text_cache_draw(struct DRWTextStore *dt, struct ARegion *ar); enum { DRW_TEXT_CACHE_ASCII = (1 << 0), diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index a666ec5395f..347932619b9 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -744,8 +744,6 @@ void DRW_draw_cursor(void) void DRW_draw_manipulator_3d(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); - View3D *v3d = draw_ctx->v3d; - v3d->zbuf = false; ARegion *ar = draw_ctx->ar; /* draw depth culled manipulators - manipulators need to be updated *after* view matrix was set up */ @@ -760,8 +758,6 @@ void DRW_draw_manipulator_3d(void) void DRW_draw_manipulator_2d(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); - View3D *v3d = draw_ctx->v3d; - v3d->zbuf = false; ARegion *ar = draw_ctx->ar; WM_manipulatormap_draw( diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index e679b04f25d..5e3fec93340 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -373,7 +373,6 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS return; } - View3D *v3d = cdd->vc.v3d; Object *obedit = cdd->vc.obedit; Curve *cu = obedit->data; @@ -434,37 +433,29 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + GPU_depth_test(false); GPU_blend(true); GPU_line_smooth(true); + GPU_line_width(3.0f); imm_cpack(0x0); immBegin(GWN_PRIM_LINE_STRIP, stroke_len); - GPU_line_width(3.0f); - - if (v3d->zbuf) { - GPU_depth_test(false); - } - for (int i = 0; i < stroke_len; i++) { immVertex3fv(pos, coord_array[i]); } - immEnd(); - imm_cpack(0xffffffff); - immBegin(GWN_PRIM_LINE_STRIP, stroke_len); GPU_line_width(1.0f); + imm_cpack(0xffffffff); + immBegin(GWN_PRIM_LINE_STRIP, stroke_len); for (int i = 0; i < stroke_len; i++) { immVertex3fv(pos, coord_array[i]); } - immEnd(); - if (v3d->zbuf) { - GPU_depth_test(true); - } - + /* Reset defaults */ + GPU_depth_test(true); GPU_blend(false); GPU_line_smooth(false); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index a511100ff4e..8f8400e2d20 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1037,12 +1037,11 @@ static void knife_init_colors(KnifeColors *colors) } /* modal loop selection drawing callback */ -static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) +static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg) { - View3D *v3d = CTX_wm_view3d(C); const KnifeTool_OpData *kcd = arg; - if (v3d->zbuf) GPU_depth_test(false); + GPU_depth_test(false); glPolygonOffset(1.0f, 1.0f); @@ -1196,7 +1195,8 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) gpuPopMatrix(); - if (v3d->zbuf) GPU_depth_test(true); + /* Reset default */ + GPU_depth_test(true); } /** diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 8493d15a3b1..b437bdca111 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -106,14 +106,12 @@ typedef struct RingSelOpData { } RingSelOpData; /* modal loop selection drawing callback */ -static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) +static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg) { - View3D *v3d = CTX_wm_view3d(C); RingSelOpData *lcd = arg; if ((lcd->totedge > 0) || (lcd->totpoint > 0)) { - if (v3d && v3d->zbuf) - GPU_depth_test(false); + GPU_depth_test(false); gpuPushMatrix(); gpuMultMatrix(lcd->ob->obmat); @@ -150,8 +148,8 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) gpuPopMatrix(); - if (v3d && v3d->zbuf) - GPU_depth_test(true); + /* Reset default */ + GPU_depth_test(true); } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 0d5240d8e86..a428b60643d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -703,7 +703,6 @@ void ED_view3d_draw_depth( Scene *scene = DEG_get_evaluated_scene(depsgraph); RegionView3D *rv3d = ar->regiondata; - short zbuf = v3d->zbuf; short flag = v3d->flag; float glalphaclip = U.glalphaclip; int obcenter_dia = U.obcenter_dia; @@ -727,7 +726,6 @@ void ED_view3d_draw_depth( /* get surface depth without bias */ rv3d->rflag |= RV3D_ZOFFSET_DISABLED; - v3d->zbuf = true; GPU_depth_test(true); DRW_draw_depth_loop(depsgraph, ar, v3d); @@ -737,8 +735,8 @@ void ED_view3d_draw_depth( } rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED; - v3d->zbuf = zbuf; - if (!v3d->zbuf) GPU_depth_test(false); + /* Reset default for UI */ + GPU_depth_test(false); U.glalphaclip = glalphaclip; v3d->flag = flag; diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 06cdba3f537..cfeb199de15 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -210,7 +210,9 @@ static void backdrawview3d( } #endif +#if 0 /* v3d->zbuf deprecated */ if (v3d->drawtype > OB_WIRE) v3d->zbuf = true; +#endif /* dithering and AA break color coding, so disable */ glDisable(GL_DITHER); @@ -249,14 +251,8 @@ static void backdrawview3d( GPU_scissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct)); GPU_clear_color(0.0, 0.0, 0.0, 0.0); - if (v3d->zbuf) { - GPU_depth_test(true); - GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); - } - else { - GPU_clear(GPU_COLOR_BIT); - GPU_depth_test(false); - } + GPU_depth_test(true); + GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); if (rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_set(rv3d); @@ -273,7 +269,6 @@ static void backdrawview3d( v3d->flag &= ~V3D_INVALID_BACKBUF; G.f &= ~G_BACKBUFSEL; - v3d->zbuf = false; GPU_depth_test(false); glEnable(GL_DITHER); @@ -684,7 +679,7 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, ibuf = ibuf->mipmap[mip - 1]; } - if (v3d->zbuf) GPU_depth_test(false); + GPU_depth_test(false); glDepthMask(GL_FALSE); GPU_blend(true); @@ -718,7 +713,7 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, GPU_blend(false); glDepthMask(GL_TRUE); - if (v3d->zbuf) GPU_depth_test(true); + GPU_depth_test(true); if (freeibuf) IMB_freeImBuf(freeibuf); @@ -878,22 +873,19 @@ void ED_view3d_draw_depth_gpencil( Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d) { ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); - bool zbuf = v3d->zbuf; /* Setup view matrix. */ ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL); GPU_clear(GPU_DEPTH_BIT); - v3d->zbuf = true; GPU_depth_test(true); if (v3d->flag2 & V3D_SHOW_GPENCIL) { ED_gpencil_draw_view3d(NULL, scene, view_layer, depsgraph, v3d, ar, true); } - v3d->zbuf = zbuf; - if (!zbuf) GPU_depth_test(false); + GPU_depth_test(false); } /* *********************** customdata **************** */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index aad2ac7284f..c9e915a6415 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1004,7 +1004,6 @@ int view3d_opengl_select( ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect); if (v3d->drawtype > OB_WIRE) { - v3d->zbuf = true; GPU_depth_test(true); } @@ -1050,7 +1049,6 @@ int view3d_opengl_select( ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL); if (v3d->drawtype > OB_WIRE) { - v3d->zbuf = 0; GPU_depth_test(false); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index cab478413eb..d26da986a6c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -6972,11 +6972,9 @@ static void drawEdgeSlide(TransInfo *t) /* Even mode */ if ((slp->use_even == true) || (is_clamp == false)) { - View3D *v3d = t->view; const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; - if (v3d && v3d->zbuf) - GPU_depth_test(false); + GPU_depth_test(false); GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); @@ -7074,8 +7072,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_blend(false); - if (v3d && v3d->zbuf) - GPU_depth_test(true); + GPU_depth_test(true); } } } @@ -7603,7 +7600,6 @@ static void drawVertSlide(TransInfo *t) /* Non-Prop mode */ { - View3D *v3d = t->view; TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; TransDataVertSlideVert *sv; const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; @@ -7611,8 +7607,7 @@ static void drawVertSlide(TransInfo *t) const int alpha_shade = -160; int i; - if (v3d && v3d->zbuf) - GPU_depth_test(false); + GPU_depth_test(false); GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); @@ -7706,8 +7701,7 @@ static void drawVertSlide(TransInfo *t) gpuPopMatrix(); - if (v3d && v3d->zbuf) - GPU_depth_test(true); + GPU_depth_test(true); } } } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 48ec664d634..9ffd14ad956 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -155,7 +155,6 @@ void drawSnapping(const struct bContext *C, TransInfo *t) if (t->spacetype == SPACE_VIEW3D) { if (validSnap(t)) { TransSnapPoint *p; - View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); float imat[4][4]; float size; @@ -201,8 +200,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) immUnbindProgram(); - if (v3d->zbuf) - GPU_depth_test(true); + GPU_depth_test(true); } } else if (t->spacetype == SPACE_IMAGE) { diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 6dbed4d5d6f..d78c731764e 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -238,7 +238,8 @@ typedef struct View3D { short flag3; /* drawflags, denoting state */ - char zbuf, transp, xray; + char zbuf DNA_DEPRECATED; + char transp, xray; char multiview_eye; /* multiview current eye - for internal use */ -- cgit v1.2.3 From 16878072a499d1b328e8f2eb968e5fd4829d996b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 19:38:27 +0200 Subject: T55441: Pop-over large arrow offset when wide --- source/blender/editors/interface/interface_widgets.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 1c6d5c70933..d5e152ccc79 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -4386,11 +4386,11 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) * because we need to pass in the original location so we know where to show the arrow. */ static void ui_draw_popover_back_impl( - const uiWidgetColors *wcol, rcti *rect, int direction, + const uiWidgetColors *wcol, rcti *rect, int direction, const float unit_size, const float mval_origin[2]) { /* tsk, this isn't nice. */ - const float unit_half = (BLI_rcti_size_x(rect) / UI_POPOVER_WIDTH_UNITS) / 2; + const float unit_half = unit_size / 2; const float cent_x = mval_origin ? mval_origin[0] : BLI_rcti_cent_x(rect); rect->ymax -= unit_half; rect->ymin += unit_half; @@ -4443,7 +4443,7 @@ void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, r if (block) { float mval_origin[2] = {block->mx, block->my}; ui_window_to_block_fl(ar, block, &mval_origin[0], &mval_origin[1]); - ui_draw_popover_back_impl(wt->wcol_theme, rect, block->direction, mval_origin); + ui_draw_popover_back_impl(wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin); } else { wt->state(wt, 0); -- cgit v1.2.3 From 9e5002adedf4e701a4761c4d7f2754dcdcbb4067 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 19:50:00 +0200 Subject: UI: optional ui-unit-width for popovers Some popovers don't fit well with the default width, allow panels to adjust as needed. --- release/scripts/modules/bpy_types.py | 10 ++++++++-- source/blender/blenkernel/BKE_screen.h | 6 ++++-- source/blender/editors/include/UI_interface.h | 2 +- .../editors/interface/interface_region_popover.c | 23 ++++++++++++++++++---- source/blender/makesrna/intern/rna_ui.c | 5 +++++ source/blender/makesrna/intern/rna_wm_api.c | 5 +++-- 6 files changed, 40 insertions(+), 11 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 4cc792c7cb3..b14565e2a9a 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -144,9 +144,15 @@ class WindowManager(bpy_types.ID): finally: self.popmenu_end__internal(popup) - def popover(self, draw_func, keymap=None): + def popover( + self, draw_func, *, + ui_units_x=0, + keymap=None, + ): import bpy - popup = self.popover_begin__internal() + popup = self.popover_begin__internal( + ui_units_x=ui_units_x, + ) try: draw_func(popup, bpy.context) diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 861b47aebc6..5bfa2a8a8fe 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -204,8 +204,10 @@ typedef struct PanelType { char category[BKE_ST_MAXNAME]; /* for category tabs */ char owner_id[BKE_ST_MAXNAME]; /* for work-spaces to selectively show. */ char parent_id[BKE_ST_MAXNAME]; /* parent idname for subpanels */ - int space_type; - int region_type; + short space_type; + short region_type; + /* For popovers, 0 for default. */ + int ui_units_x; int flag; diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 1ab1c5227ea..8a758d01809 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -446,7 +446,7 @@ int UI_popover_panel_invoke( struct bContext *C, int space_id, int region_id, const char *idname, bool keep_open, struct ReportList *reports); -uiPopover *UI_popover_begin(struct bContext *C) ATTR_NONNULL(1); +uiPopover *UI_popover_begin(struct bContext *C, int menu_width) ATTR_NONNULL(1); void UI_popover_end(struct bContext *C, struct uiPopover *head, struct wmKeyMap *keymap); struct uiLayout *UI_popover_layout(uiPopover *head); void UI_popover_once_clear(uiPopover *pup); diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c index fb14ca745c6..35856b6c8b2 100644 --- a/source/blender/editors/interface/interface_region_popover.c +++ b/source/blender/editors/interface/interface_region_popover.c @@ -87,6 +87,9 @@ struct uiPopover { uiMenuCreateFunc menu_func; void *menu_arg; + /* Size in pixels (ui scale applied). */ + int ui_size_x; + #ifdef USE_UI_POPOVER_ONCE bool is_once; #endif @@ -94,12 +97,13 @@ struct uiPopover { static void ui_popover_create_block(bContext *C, uiPopover *pup, int opcontext) { - uiStyle *style = UI_style_get_dpi(); + BLI_assert(pup->ui_size_x != 0); + uiStyle *style = UI_style_get_dpi(); pup->block = UI_block_begin(C, NULL, __func__, UI_EMBOSS); pup->layout = UI_block_layout( pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, - U.widget_unit * UI_POPOVER_WIDTH_UNITS, 0, MENU_PADDING, style); + pup->ui_size_x, 0, MENU_PADDING, style); uiLayoutSetOperatorContext(pup->layout, opcontext); @@ -234,6 +238,13 @@ uiPopupBlockHandle *ui_popover_panel_create( /* Create popover, buttons are created from callback. */ uiPopover *pup = MEM_callocN(sizeof(uiPopover), __func__); pup->but = but; + + /* FIXME: maybe one day we want non panel popovers? */ + { + int ui_units_x = ((PanelType *)arg)->ui_units_x; + pup->ui_size_x = U.widget_unit * (ui_units_x ? ui_units_x : UI_POPOVER_WIDTH_UNITS); + } + pup->menu_func = menu_func; pup->menu_arg = arg; @@ -288,7 +299,7 @@ int UI_popover_panel_invoke( ui_popover_panel_create(C, NULL, NULL, ui_item_paneltype_func, pt); } else { - uiPopover *pup = UI_popover_begin(C); + uiPopover *pup = UI_popover_begin(C, U.widget_unit * pt->ui_units_x); layout = UI_popover_layout(pup); UI_paneltype_draw(C, pt, layout); UI_popover_end(C, pup, NULL); @@ -306,9 +317,13 @@ int UI_popover_panel_invoke( /** * Only return handler, and set optional title. */ -uiPopover *UI_popover_begin(bContext *C) +uiPopover *UI_popover_begin(bContext *C, int ui_size_x) { uiPopover *pup = MEM_callocN(sizeof(uiPopover), "popover menu"); + if (ui_size_x == 0) { + ui_size_x = U.widget_unit * UI_POPOVER_WIDTH_UNITS; + } + pup->ui_size_x = ui_size_x; /* Opertor context default same as menus, change if needed. */ ui_popover_create_block(C, pup, WM_OP_EXEC_REGION_WIN); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index bb7af5f327d..9d13cb8f7f0 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -1165,6 +1165,11 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_ui_text(prop, "Parent ID Name", "If this is set, the panel becomes a subpanel"); + prop = RNA_def_property(srna, "bl_ui_units_x", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "type->ui_units_x"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text(prop, "Units X", "When set, defines popup panel width"); + prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_PIN); RNA_def_property_ui_text(prop, "Pin", ""); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index afb12f48e28..f398c4143ae 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -376,12 +376,12 @@ static void rna_PopMenuEnd(bContext *C, PointerRNA *handle) } /* popover wrapper */ -static PointerRNA rna_PopoverBegin(bContext *C) +static PointerRNA rna_PopoverBegin(bContext *C, int ui_units_x) { PointerRNA r_ptr; void *data; - data = (void *)UI_popover_begin(C); + data = (void *)UI_popover_begin(C, U.widget_unit * ui_units_x); RNA_pointer_create(NULL, &RNA_UIPopover, data, &r_ptr); @@ -602,6 +602,7 @@ void RNA_api_wm(StructRNA *srna) /* wrap UI_popover_begin */ func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); + RNA_def_property(func, "ui_units_x", PROP_INT, PROP_UNSIGNED); /* return */ parm = RNA_def_pointer(func, "menu", "UIPopover", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); -- cgit v1.2.3 From 46bdbc6c78be09230b9611df52e011d92268f754 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 19:55:51 +0200 Subject: UI: adjust popover width for overlays & toolbar --- release/scripts/startup/bl_operators/wm.py | 2 +- release/scripts/startup/bl_ui/space_view3d.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 440beaaa240..f31ae721fd3 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -2400,7 +2400,7 @@ class WM_OT_toolbar(Operator): layout = popover.layout cls.draw_cls(layout, context, detect_layout=False, scale_y=1.0) - wm.popover(draw_menu, keymap=keymap) + wm.popover(draw_menu, ui_units_x=8, keymap=keymap) return {'FINISHED'} diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index f5d451a1189..342d31d2df6 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3805,6 +3805,7 @@ class VIEW3D_PT_overlay(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_label = "Overlays" + bl_ui_units_x = 14 @classmethod def poll(cls, context): -- cgit v1.2.3 From 969111f9b5b075470a6de995f048d19e25c1b9ea Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 22:35:37 +0200 Subject: Cleanup: pep8 --- doc/python_api/sphinx_doc_gen_monkeypatch.py | 2 +- doc/python_api/sphinx_doc_update.py | 7 ++++--- release/scripts/modules/bpy/utils/__init__.py | 11 ++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/python_api/sphinx_doc_gen_monkeypatch.py b/doc/python_api/sphinx_doc_gen_monkeypatch.py index 9fdbf613d96..58d09f71e9a 100644 --- a/doc/python_api/sphinx_doc_gen_monkeypatch.py +++ b/doc/python_api/sphinx_doc_gen_monkeypatch.py @@ -21,7 +21,7 @@ # bpy_types_Operator_bl_property__doc__ = ( -""" + """ The name of a property to use as this operators primary property. Currently this is only used to select the default property when expanding an operator into a menu. diff --git a/doc/python_api/sphinx_doc_update.py b/doc/python_api/sphinx_doc_update.py index 561e58dec66..d43806d128a 100755 --- a/doc/python_api/sphinx_doc_update.py +++ b/doc/python_api/sphinx_doc_update.py @@ -29,7 +29,7 @@ You'll need to specify your user login and password, obviously. Example usage: - ./sphinx_doc_update.py --mirror ../../../docs/remote_api_backup/ --source ../.. --blender ../../../build_cmake/bin/blender --user foobar --password barfoo + ./sphinx_doc_update.py --mirror ../../../docs/remote_api_backup/ --source ../.. --blender ../../../build_cmake/bin/blender --user foobar --password barfoo """ @@ -114,7 +114,7 @@ def main(): # III) Get Blender version info. getver_file = os.path.join(tmp_dir, "blendver.txt") - getver_script = ("" + getver_script = ( "import sys, bpy\n" "with open(sys.argv[-1], 'w') as f:\n" " is_release = bpy.app.version_cycle in {'rc', 'release'}\n" @@ -124,7 +124,8 @@ def main(): " f.write('%d.%d%s\\n' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n" " if is_release else '%s\\n' % branch)\n" " f.write('%d_%d%s_release' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n" - " if is_release else '%d_%d_%d' % bpy.app.version)\n") + " if is_release else '%d_%d_%d' % bpy.app.version)\n" + ) get_ver_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1", "--python-expr", getver_script, "--", getver_file) subprocess.run(get_ver_cmd) diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index c3175f93f4e..5e5a35b9518 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -488,11 +488,11 @@ def smpte_from_frame(frame, fps=None, fps_base=None): return ( "%s%02d:%02d:%02d:%02d" % ( - sign, - int(frame / (3600 * fps)), # HH - int((frame / (60 * fps)) % 60), # MM - int((frame / fps) % 60), # SS - int(frame % fps), # FF + sign, + int(frame / (3600 * fps)), # HH + int((frame / (60 * fps)) % 60), # MM + int((frame / fps) % 60), # SS + int(frame % fps), # FF )) @@ -773,6 +773,7 @@ def _blender_default_map(): del _sys.modules["rna_manual_reference"] return ret + # hooks for doc lookups _manual_map = [_blender_default_map] -- cgit v1.2.3 From 405c6c077f6e4a8c9760afef693219859d6df3ba Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 4 Jul 2018 02:23:52 +0200 Subject: UI: Adjust width of Pivot, Shading and Transform Orientations popovers --- release/scripts/startup/bl_ui/space_view3d.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 342d31d2df6..7b71d41e678 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3672,6 +3672,7 @@ class VIEW3D_PT_shading(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_label = "Shading" + bl_ui_units_x = 11 @classmethod def poll(cls, context): @@ -4110,6 +4111,7 @@ class VIEW3D_PT_pivot_point(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_label = "Pivot Point" + bl_ui_units_x = 8 def draw(self, context): toolsettings = context.tool_settings @@ -4174,6 +4176,7 @@ class VIEW3D_PT_transform_orientations(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_label = "Transform Orientations" + bl_ui_units_x = 8 @classmethod def poll(cls, context): -- cgit v1.2.3 From 13ec4be594e11d39bc28c986446eade86b148129 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 10:31:31 +0200 Subject: Fix T55750: Crash on moving sequencer strip Custom-data free callback was freeing transform data too. --- source/blender/editors/transform/transform_conversions.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index c622a50ff11..83b568b494c 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5463,10 +5463,6 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c MEM_freeN(custom_data->data); custom_data->data = NULL; } - if (tc->data) { - MEM_freeN(tc->data); // XXX postTrans usually does this - tc->data = NULL; - } } static void createTransSeqData(bContext *C, TransInfo *t) -- cgit v1.2.3 From 75b5ff6698f5c1d50152cfb68530ac6a4ead999e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 3 Jul 2018 18:20:44 +0200 Subject: Softbody: unified copy functions This unifies two almost-identical functions at the expense of having to add one single 'flag' value at one call. This makes copy_softbody() aware of the source/dest objects, allowing it to make a distinction between doing depsgraph evaluation copies and real object copies. This will be used in an upcoming commit to ensure that the pointcache is shared between CoW copies, similar to the current approach for rigidbody simulation. --- source/blender/blenkernel/BKE_object.h | 3 +-- source/blender/blenkernel/intern/object.c | 23 ++++++++++------------- source/blender/editors/object/object_edit.c | 4 +--- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index a54b244f5fd..0122185fd2a 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -56,10 +56,9 @@ void BKE_object_workob_clear(struct Object *workob); void BKE_object_workob_calc_parent(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct Object *workob); void BKE_object_transform_copy(struct Object *ob_tar, const struct Object *ob_src); -struct SoftBody *copy_softbody(const struct SoftBody *sb, const int flag); +void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src, const int flag); struct ParticleSystem *BKE_object_copy_particlesystem(struct ParticleSystem *psys, const int flag); void BKE_object_copy_particlesystems(struct Object *ob_dst, const struct Object *ob_src, const int flag); -void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src); void BKE_object_free_particlesystems(struct Object *ob); void BKE_object_free_softbody(struct Object *ob); void BKE_object_free_curve_cache(struct Object *ob); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 8295fccc810..09e1ca62b92 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -275,7 +275,7 @@ void BKE_object_link_modifiers(Scene *scene, struct Object *ob_dst, const struct switch (md->type) { case eModifierType_Softbody: - BKE_object_copy_softbody(ob_dst, ob_src); + BKE_object_copy_softbody(ob_dst, ob_src, 0); break; case eModifierType_Skin: /* ensure skin-node customdata exists */ @@ -836,11 +836,16 @@ Object *BKE_object_add_from( return ob; } -SoftBody *copy_softbody(const SoftBody *sb, const int flag) +void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src, const int flag) { + SoftBody *sb = ob_src->soft; SoftBody *sbn; - if (sb == NULL) return(NULL); + ob_dst->softflag = ob_src->softflag; + if (sb == NULL) { + ob_dst->soft = NULL; + return; + } sbn = MEM_dupallocN(sb); @@ -878,7 +883,7 @@ SoftBody *copy_softbody(const SoftBody *sb, const int flag) if (sb->effector_weights) sbn->effector_weights = MEM_dupallocN(sb->effector_weights); - return sbn; + ob_dst->soft = sbn; } ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys, const int flag) @@ -967,14 +972,6 @@ void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src, const } } -void BKE_object_copy_softbody(Object *ob_dst, const Object *ob_src) -{ - if (ob_src->soft) { - ob_dst->softflag = ob_src->softflag; - ob_dst->soft = copy_softbody(ob_src->soft, 0); - } -} - static void copy_object_pose(Object *obn, const Object *ob, const int flag) { bPoseChannel *chan; @@ -1202,7 +1199,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_ ob_dst->pd->rng = MEM_dupallocN(ob_src->pd->rng); } } - ob_dst->soft = copy_softbody(ob_src->soft, flag_subdata); + BKE_object_copy_softbody(ob_dst, ob_src, flag_subdata); ob_dst->rigidbody_object = BKE_rigidbody_copy_object(ob_src, flag_subdata); ob_dst->rigidbody_constraint = BKE_rigidbody_copy_constraint(ob_src, flag_subdata); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index ef9d32f7148..7dc4aa1d1b3 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1050,10 +1050,8 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev DEG_relations_tag_update(bmain); } else if (event == 23) { - base->object->softflag = ob->softflag; if (base->object->soft) sbFree(base->object->soft); - - base->object->soft = copy_softbody(ob->soft, 0); + BKE_object_copy_softbody(base->object, ob, 0); if (!modifiers_findByType(base->object, eModifierType_Softbody)) { BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody)); -- cgit v1.2.3 From 9e4d667c2cfd4a81f9a69628b69facd8fd4e0a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 4 Jul 2018 11:21:31 +0200 Subject: SoftBody: refactored sbFree() This prevents having to wrap each call to sbFree() in an if(ob->soft) condition and assign ob->soft = NULL after calling. Furthermore, passing `Object *` allows us to change freeing behaviour depending on whether the object is an evaluated copy or an original (not done in this commit yet). --- source/blender/blenkernel/BKE_softbody.h | 2 +- source/blender/blenkernel/intern/object.c | 10 ++-------- source/blender/blenkernel/intern/softbody.c | 9 ++++++++- source/blender/editors/object/object_edit.c | 2 +- source/blender/editors/object/object_modifier.c | 5 ++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index ff9d079c8e1..b173c995727 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -54,7 +54,7 @@ typedef struct BodyPoint { extern struct SoftBody *sbNew(struct Scene *scene); /* frees internal data and softbody itself */ -extern void sbFree(struct SoftBody *sb); +extern void sbFree(struct Object *ob); /* frees simulation data to reset simulation */ extern void sbFreeSimulation(struct SoftBody *sb); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 09e1ca62b92..3f5464156c5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -165,10 +165,7 @@ void BKE_object_free_particlesystems(Object *ob) void BKE_object_free_softbody(Object *ob) { - if (ob->soft) { - sbFree(ob->soft); - ob->soft = NULL; - } + sbFree(ob); } void BKE_object_free_curve_cache(Object *ob) @@ -452,10 +449,7 @@ void BKE_object_free(Object *ob) BKE_rigidbody_free_object(ob, NULL); BKE_rigidbody_free_constraint(ob); - if (ob->soft) { - sbFree(ob->soft); - ob->soft = NULL; - } + sbFree(ob); for (ObjectEngineData *oed = ob->drawdata.first; oed; oed = oed->next) { if (oed->free != NULL) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index a61b71f50eb..4960714b47c 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3287,14 +3287,21 @@ SoftBody *sbNew(Scene *scene) } /* frees all */ -void sbFree(SoftBody *sb) +void sbFree(Object *ob) { + SoftBody *sb = ob->soft; + if (sb == NULL) { + return; + } + free_softbody_intern(sb); BKE_ptcache_free_list(&sb->ptcaches); sb->pointcache = NULL; if (sb->effector_weights) MEM_freeN(sb->effector_weights); MEM_freeN(sb); + + ob->soft = NULL; } void sbFreeSimulation(SoftBody *sb) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 7dc4aa1d1b3..a6c3c86922d 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1050,7 +1050,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev DEG_relations_tag_update(bmain); } else if (event == 23) { - if (base->object->soft) sbFree(base->object->soft); + sbFree(base->object); BKE_object_copy_softbody(base->object, ob, 0); if (!modifiers_findByType(base->object, eModifierType_Softbody)) { diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 2889f798dd8..31a53bed201 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -293,9 +293,8 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, } else if (md->type == eModifierType_Softbody) { if (ob->soft) { - sbFree(ob->soft); - ob->soft = NULL; - ob->softflag = 0; + sbFree(ob); + ob->softflag = 0; /* TODO(Sybren): this should probably be moved into sbFree() */ } } else if (md->type == eModifierType_Collision) { -- cgit v1.2.3 From 769c57b38a707397ac7fdda15b1deb561194b66c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 4 Jul 2018 11:22:15 +0200 Subject: SoftBody: share point cache between CoW copies This is the same approach as 98a0bcd4252e952fa5438e9d1b69b0204f8a8746 applied to soft body simulation. In short, CoW copies share the point cache, and treat it as read-only except when the depsgraph is active. --- source/blender/blenkernel/intern/bpath.c | 2 +- source/blender/blenkernel/intern/object.c | 6 +++++- source/blender/blenkernel/intern/pointcache.c | 6 +++--- source/blender/blenkernel/intern/softbody.c | 23 ++++++++++++++++------- source/blender/blenloader/intern/readfile.c | 13 ++++++++++++- source/blender/blenloader/intern/versioning_280.c | 19 +++++++++++++++++++ source/blender/blenloader/intern/writefile.c | 8 ++++++-- source/blender/makesdna/DNA_object_force_types.h | 15 +++++++++++++-- source/blender/makesrna/intern/rna_modifier.c | 2 +- 9 files changed, 76 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index 7c9e57b039e..34f54704f75 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -513,7 +513,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int } if (ob->soft) { - BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches); + BPATH_TRAVERSE_POINTCACHE(ob->soft->shared->ptcaches); } for (psys = ob->particlesystem.first; psys; psys = psys->next) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3f5464156c5..61d38a4e937 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -834,6 +834,7 @@ void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src { SoftBody *sb = ob_src->soft; SoftBody *sbn; + bool tagged_no_main = ob_dst->id.tag & LIB_TAG_NO_MAIN; ob_dst->softflag = ob_src->softflag; if (sb == NULL) { @@ -872,7 +873,10 @@ void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src sbn->scratch = NULL; - sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches, flag); + if (tagged_no_main == 0) { + sbn->shared = MEM_dupallocN(sb->shared); + sbn->shared->pointcache = BKE_ptcache_copy_list(&sbn->shared->ptcaches, &sb->shared->ptcaches, flag); + } if (sb->effector_weights) sbn->effector_weights = MEM_dupallocN(sb->effector_weights); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index a8c6091124a..17e90d688a2 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1389,9 +1389,9 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) pid->ob= ob; pid->calldata= sb; pid->type= PTCACHE_TYPE_SOFTBODY; - pid->cache= sb->pointcache; - pid->cache_ptr= &sb->pointcache; - pid->ptcaches= &sb->ptcaches; + pid->cache= sb->shared->pointcache; + pid->cache_ptr= &sb->shared->pointcache; + pid->ptcaches= &sb->shared->ptcaches; pid->totpoint= pid->totwrite= ptcache_softbody_totpoint; pid->error = ptcache_softbody_error; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 4960714b47c..d3429622573 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3276,7 +3276,8 @@ SoftBody *sbNew(Scene *scene) sb->shearstiff = 1.0f; sb->solverflags |= SBSO_OLDERR; - sb->pointcache = BKE_ptcache_add(&sb->ptcaches); + sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared"); + sb->shared->pointcache = BKE_ptcache_add(&sb->shared->ptcaches); if (!sb->effector_weights) sb->effector_weights = BKE_add_effector_weights(NULL); @@ -3295,8 +3296,13 @@ void sbFree(Object *ob) } free_softbody_intern(sb); - BKE_ptcache_free_list(&sb->ptcaches); - sb->pointcache = NULL; + + if ((ob->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0) { + /* Only free shared data on non-CoW copies */ + BKE_ptcache_free_list(&sb->shared->ptcaches); + sb->shared->pointcache = NULL; + MEM_freeN(sb->shared); + } if (sb->effector_weights) MEM_freeN(sb->effector_weights); MEM_freeN(sb); @@ -3608,7 +3614,7 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c float dtime, timescale; int framedelta, framenr, startframe, endframe; int cache_result; - cache= sb->pointcache; + cache= sb->shared->pointcache; framenr= (int)cfra; framedelta= framenr - cache->simframe; @@ -3676,7 +3682,8 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c } /* try to read from cache */ - bool can_simulate = (framenr == sb->last_frame + 1) && !(cache->flag & PTCACHE_BAKED); + bool can_write_cache = DEG_is_active(depsgraph); + bool can_simulate = (framenr == sb->last_frame + 1) && !(cache->flag & PTCACHE_BAKED) && can_write_cache; cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, can_simulate); @@ -3687,7 +3694,7 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c BKE_ptcache_validate(cache, framenr); - if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) + if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED && can_write_cache) BKE_ptcache_write(&pid, framenr); sb->last_frame = framenr; @@ -3699,7 +3706,9 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c } else if (/*ob->id.lib || */(cache->flag & PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */ /* if baked and nothing in cache, do nothing */ - BKE_ptcache_invalidate(cache); + if (can_write_cache) { + BKE_ptcache_invalidate(cache); + } return; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 79a552a5b86..2a48bf8fc5a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5437,7 +5437,18 @@ static void direct_link_object(FileData *fd, Object *ob) if (!sb->effector_weights) sb->effector_weights = BKE_add_effector_weights(NULL); - direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, 0); + sb->shared = newdataadr(fd, sb->shared); + if (sb->shared == NULL) { + /* Link deprecated caches if they exist, so we can use them for versioning. + * We should only do this when sb->shared == NULL, because those pointers + * are always set (for compatibility with older Blenders). We mustn't link + * the same pointcache twice. */ + direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, false); + } + else { + /* link caches */ + direct_link_pointcache_list(fd, &sb->shared->ptcaches, &sb->shared->pointcache, false); + } } ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */ diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 3fa059989a3..757e17ce82b 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1559,5 +1559,24 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!DNA_struct_elem_find(fd->filesdna, "SoftBody", "SoftBody_Shared", "*shared")) { + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { + SoftBody *sb = ob->soft; + if (sb == NULL) { + continue; + } + if (sb->shared == NULL) { + sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared"); + } + + /* Move shared pointers from deprecated location to current location */ + sb->shared->pointcache = sb->pointcache; + sb->shared->ptcaches = sb->ptcaches; + + sb->pointcache = NULL; + BLI_listbase_clear(&sb->ptcaches); + } + } + } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index e7bca4c7e5b..146494e6196 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1816,9 +1816,13 @@ static void write_object(WriteData *wd, Object *ob) write_motionpath(wd, ob->mpath); writestruct(wd, DATA, PartDeflect, 1, ob->pd); - writestruct(wd, DATA, SoftBody, 1, ob->soft); if (ob->soft) { - write_pointcaches(wd, &ob->soft->ptcaches); + /* Set deprecated pointers to prevent crashes of older Blenders */ + ob->soft->pointcache = ob->soft->shared->pointcache; + ob->soft->ptcaches = ob->soft->shared->ptcaches; + writestruct(wd, DATA, SoftBody, 1, ob->soft); + writestruct(wd, DATA, SoftBody_Shared, 1, ob->soft->shared); + write_pointcaches(wd, &(ob->soft->shared->ptcaches)); writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights); } diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h index ac7c969a810..3538abcff1a 100644 --- a/source/blender/makesdna/DNA_object_force_types.h +++ b/source/blender/makesdna/DNA_object_force_types.h @@ -37,6 +37,7 @@ extern "C" { #endif #include "DNA_listBase.h" +#include "DNA_defs.h" /* pd->forcefield: Effector Fields types */ typedef enum ePFieldType { @@ -218,6 +219,15 @@ typedef struct SBVertex { float vec[4]; } SBVertex; +/* Container for data that is shared among CoW copies. + * + * This is placed in a separate struct so that values can be changed + * without having to update all CoW copies. */ +typedef struct SoftBody_Shared { + struct PointCache *pointcache; + struct ListBase ptcaches; +} SoftBody_Shared; + typedef struct SoftBody { /* dynamic data */ int totpoint, totspring; @@ -289,8 +299,9 @@ typedef struct SoftBody { float shearstiff; float inpush; - struct PointCache *pointcache; - struct ListBase ptcaches; + struct SoftBody_Shared *shared; + struct PointCache *pointcache DNA_DEPRECATED; /* Moved to SoftBody_Shared */ + struct ListBase ptcaches DNA_DEPRECATED; /* Moved to SoftBody_Shared */ struct Collection *collision_group; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index f0001852da2..a2a21a194ea 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -716,7 +716,7 @@ static PointerRNA rna_SoftBodyModifier_settings_get(PointerRNA *ptr) static PointerRNA rna_SoftBodyModifier_point_cache_get(PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; - return rna_pointer_inherit_refine(ptr, &RNA_PointCache, ob->soft->pointcache); + return rna_pointer_inherit_refine(ptr, &RNA_PointCache, ob->soft->shared->pointcache); } static PointerRNA rna_CollisionModifier_settings_get(PointerRNA *ptr) -- cgit v1.2.3 From b575c50753d70292647a7a3a63fe450ac52fe162 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 4 Jul 2018 12:09:35 +0200 Subject: CMake: Add missing header file to list of sources --- source/blender/blenkernel/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index d2654e32fa7..0578a3ecc69 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -276,6 +276,7 @@ set(SRC BKE_mesh_iterators.h BKE_mesh_mapping.h BKE_mesh_remap.h + BKE_mesh_runtime.h BKE_mesh_tangent.h BKE_modifier.h BKE_movieclip.h -- cgit v1.2.3 From f9660a78ea92c31f8337907e5f7afe7ac9674347 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 12:48:50 +0200 Subject: Keymap: use add key instead of verify Caused Xkey to be added but not delete key. --- .../blender/editors/space_outliner/outliner_ops.c | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 38640a0e23d..099cff7e5d6 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -542,26 +542,26 @@ void outliner_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "open", false); /* close */ - WM_keymap_verify_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0); /* keying sets - only for databrowse */ - WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_remove_selected", KKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_keyingset_remove_selected", KKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete", IKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "ANIM_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "ANIM_OT_keyframe_delete", IKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_new", CKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_collection_new", CKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_delete", XKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_delete", DELKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_collection_delete", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_collection_delete", DELKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "select", false); -- cgit v1.2.3 From 67f4e9783b248dba099cf9c890616acadf8d0502 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 4 Jul 2018 12:53:33 +0200 Subject: UI: Fix node triangle always using selected color Now uses the text color instead. Thanks to devtalk community for spotting this. --- source/blender/editors/space_node/node_draw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 01e22ec5245..c4ed35faabd 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -960,6 +960,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); UI_block_emboss_set(node->block, UI_EMBOSS); + UI_GetThemeColor4fv(TH_TEXT, color); /* custom draw function for this button */ UI_draw_icon_tri(rct->xmin + 0.5f * U.widget_unit, rct->ymax - NODE_DY / 2.0f, 'v', color); } @@ -1079,6 +1080,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); UI_block_emboss_set(node->block, UI_EMBOSS); + UI_GetThemeColor4fv(TH_TEXT, color); /* custom draw function for this button */ UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h', color); } -- cgit v1.2.3 From 8da2e97ec31385a357ffcd9ff57252865e070342 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 4 Jul 2018 12:53:58 +0200 Subject: UI: Default theme use color for value slider item Matches Flatty Light --- release/datafiles/userdef/userdef_default_theme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 8981612afe8..58defc4f17a 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -96,14 +96,13 @@ const bTheme U_theme_default = { .item = RGBA(0x333333ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), - .shaded = 1, .roundness = 0.3f, }, .wcol_numslider = { .outline = RGBA(0x444444ff), - .inner = RGBA(0x2c2c2cff), - .inner_sel = RGBA(0x1f1f1fff), - .item = RGBA(0x585858ff), + .inner = RGBA(0x595959ff), + .inner_sel = RGBA(0x333333ff), + .item = RGBA(0x5680c2e6), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shaded = 1, -- cgit v1.2.3 From 72e090a3cf05eaa797b6aad86a86a3cc407c973a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 12:55:02 +0200 Subject: Keymap: Remove pie menu from tab-key Based on discussion with @eyecandy & @venomgfx, we agreed that Tab drag/click, is too easy to accidentally press while moving the cursor. It's also not typical to activate the operator on release which introduces a small lag switching edit-mode. This is a shame since in some ways its a nice way to re-use the key, overall it just feels a little too unpredictable for such an important action. This commit makes the following changes. - Tab: toggles edit-mode. - Ctrl-Tab: opens pie menu. - Ctrl-AccentGrave: toggles manipulator. Note, while AccentGrave isn't always available this shortcut is not essential. --- source/blender/editors/object/object_ops.c | 4 ++-- source/blender/editors/space_view3d/view3d_ops.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 5d44eec7187..cae8005c86c 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -293,11 +293,11 @@ void ED_keymap_object(wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0); /* modes */ - kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_CLICK, 0, 0); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT); RNA_boolean_set(kmi->ptr, "toggle", true); - kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_object_mode_pie", TABKEY, KM_CLICK_DRAG, 0, 0); + kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_object_mode_pie", TABKEY, KM_PRESS, KM_CTRL, 0); #ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 7eb2debf94a..f93ea7bf618 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -531,7 +531,7 @@ void view3d_keymap(wmKeyConfig *keyconf) #ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* new in 2.5 */ #else - kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); #endif RNA_string_set(kmi->ptr, "data_path", "space_data.show_manipulator"); -- cgit v1.2.3 From 8aa1ef26754ea8b3806ac5bdf7d1ad12710dbd3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 13:46:07 +0200 Subject: Keymap: Add back Ctrl-M for mirror --- source/blender/editors/transform/transform_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index f95229ef503..889be92f1f2 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -1116,9 +1116,9 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac #ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "use", true); +#endif WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0); -#endif kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap"); -- cgit v1.2.3 From 7d355008bfeb80e4e8f337c1015bc5447e0bb9f5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 13:54:22 +0200 Subject: Fix NLA transform crash --- source/blender/editors/transform/transform_generics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index db8bbe05c69..b007a8d1b99 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -463,13 +463,13 @@ static void recalcData_graphedit(TransInfo *t) /* helper for recalcData() - for NLA Editor transforms */ static void recalcData_nla(TransInfo *t) { - TransDataNla *tdn = t->custom.type.data; SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first; Scene *scene = t->scene; double secf = FPS; int i; TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); + TransDataNla *tdn = tc->custom.type.data; /* for each strip we've got, perform some additional validation of the values that got set before * using RNA to set the value (which does some special operations when setting these values to make -- cgit v1.2.3 From 88b297da99ee61630c36df63fb2f63ca32d8de54 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 14:00:21 +0200 Subject: Keymap: resolve group/un-group inconsistencies Apply grouping changes proposed in T55162 - Ctrl-G to make a group. - Ctrl-Alt-G to ungroup. --- source/blender/editors/animation/anim_channels_edit.c | 2 +- source/blender/editors/space_nla/nla_ops.c | 4 ++-- source/blender/editors/space_node/node_ops.c | 2 +- source/blender/editors/space_sequencer/sequencer_ops.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index f11c850a12b..d768be49ad4 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -3253,7 +3253,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) /* grouping */ WM_keymap_add_item(keymap, "ANIM_OT_channels_group", GKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); } /* ************************************************************************** */ diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index c5dd85b7c4d..8a776ad32e9 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -256,8 +256,8 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "NLA_OT_soundclip_add", KKEY, KM_PRESS, KM_SHIFT, 0); /* meta-strips */ - WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); /* duplicate */ kmi = WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index ed96bb21412..2a585c42395 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -333,7 +333,7 @@ void node_keymap(struct wmKeyConfig *keyconf) /* node group operators */ WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "NODE_OT_group_separate", PKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "NODE_OT_group_edit", TABKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "exit", false); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 1a3cb8560e4..f60bd98c4d6 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -200,7 +200,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_toggle", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_make", GKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", GKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); #ifdef WITH_INPUT_NDOF -- cgit v1.2.3 From b10c64bd2f1dae93c38e2d1cc656ea08151ab704 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 4 Jul 2018 14:22:38 +0200 Subject: Cycles Denoising: Split main function into logical steps --- intern/cycles/device/device_cpu.cpp | 4 +- intern/cycles/device/device_cuda.cpp | 4 +- intern/cycles/device/device_denoising.cpp | 267 +++++++++++++++------------ intern/cycles/device/device_denoising.h | 14 +- intern/cycles/device/opencl/opencl_base.cpp | 2 - intern/cycles/device/opencl/opencl_mega.cpp | 2 +- intern/cycles/device/opencl/opencl_split.cpp | 2 +- 7 files changed, 159 insertions(+), 136 deletions(-) diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 6be60f8bbb6..81a084c03b2 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -732,8 +732,6 @@ public: task.map_neighbor_tiles(rtiles, this); denoising.tiles_from_rendertiles(rtiles); - denoising.init_from_devicetask(task); - denoising.run_denoising(); task.unmap_neighbor_tiles(rtiles, this); @@ -766,7 +764,7 @@ public: } RenderTile tile; - DenoisingTask denoising(this); + DenoisingTask denoising(this, task); while(task.acquire_tile(this, tile)) { if(tile.task == RenderTile::PATH_TRACE) { diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index bf5a95dd233..34c64feb80a 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1632,8 +1632,6 @@ public: task.map_neighbor_tiles(rtiles, this); denoising.tiles_from_rendertiles(rtiles); - denoising.init_from_devicetask(task); - denoising.run_denoising(); task.unmap_neighbor_tiles(rtiles, this); @@ -2074,7 +2072,7 @@ public: /* keep rendering tiles until done */ RenderTile tile; - DenoisingTask denoising(this); + DenoisingTask denoising(this, *task); while(task->acquire_tile(this, tile)) { if(tile.task == RenderTile::PATH_TRACE) { diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp index 644cf6cd10e..4d2ba508aec 100644 --- a/intern/cycles/device/device_denoising.cpp +++ b/intern/cycles/device/device_denoising.cpp @@ -20,12 +20,24 @@ CCL_NAMESPACE_BEGIN -DenoisingTask::DenoisingTask(Device *device) +DenoisingTask::DenoisingTask(Device *device, const DeviceTask &task) : tiles_mem(device, "denoising tiles_mem", MEM_READ_WRITE), storage(device), buffer(device), device(device) { + radius = task.denoising_radius; + nlm_k_2 = powf(2.0f, lerp(-5.0f, 3.0f, task.denoising_strength)); + if(task.denoising_relative_pca) { + pca_threshold = -powf(10.0f, lerp(-8.0f, 0.0f, task.denoising_feature_strength)); + } + else { + pca_threshold = powf(10.0f, lerp(-5.0f, 3.0f, task.denoising_feature_strength)); + } + + render_buffer.pass_stride = task.pass_stride; + render_buffer.denoising_data_offset = task.pass_denoising_data; + render_buffer.denoising_clean_offset = task.pass_denoising_clean; } DenoisingTask::~DenoisingTask() @@ -41,26 +53,6 @@ DenoisingTask::~DenoisingTask() tiles_mem.free(); } -void DenoisingTask::init_from_devicetask(const DeviceTask &task) -{ - radius = task.denoising_radius; - nlm_k_2 = powf(2.0f, lerp(-5.0f, 3.0f, task.denoising_strength)); - if(task.denoising_relative_pca) { - pca_threshold = -powf(10.0f, lerp(-8.0f, 0.0f, task.denoising_feature_strength)); - } - else { - pca_threshold = powf(10.0f, lerp(-5.0f, 3.0f, task.denoising_feature_strength)); - } - - render_buffer.pass_stride = task.pass_stride; - render_buffer.denoising_data_offset = task.pass_denoising_data; - render_buffer.denoising_clean_offset = task.pass_denoising_clean; - - /* Expand filter_area by radius pixels and clamp the result to the extent of the neighboring tiles */ - rect = rect_from_shape(filter_area.x, filter_area.y, filter_area.z, filter_area.w); - rect = rect_expand(rect, radius); - rect = rect_clip(rect, make_int4(tiles->x[0], tiles->y[0], tiles->x[3], tiles->y[3])); -} void DenoisingTask::tiles_from_rendertiles(RenderTile *rtiles) { @@ -88,120 +80,142 @@ void DenoisingTask::tiles_from_rendertiles(RenderTile *rtiles) functions.set_tiles(buffers); } -bool DenoisingTask::run_denoising() +void DenoisingTask::setup_denoising_buffer() { - /* Allocate denoising buffer. */ + /* Expand filter_area by radius pixels and clamp the result to the extent of the neighboring tiles */ + rect = rect_from_shape(filter_area.x, filter_area.y, filter_area.z, filter_area.w); + rect = rect_expand(rect, radius); + rect = rect_clip(rect, make_int4(tiles->x[0], tiles->y[0], tiles->x[3], tiles->y[3])); + buffer.passes = 14; buffer.width = rect.z - rect.x; buffer.stride = align_up(buffer.width, 4); buffer.h = rect.w - rect.y; - buffer.pass_stride = align_up(buffer.stride * buffer.h, divide_up(device->mem_sub_ptr_alignment(), sizeof(float))); - buffer.mem.alloc_to_device(buffer.pass_stride * buffer.passes, false); + int alignment_floats = divide_up(device->mem_sub_ptr_alignment(), sizeof(float)); + buffer.pass_stride = align_up(buffer.stride * buffer.h, alignment_floats); + /* Pad the total size by four floats since the SIMD kernels might go a bit over the end. */ + int mem_size = align_up(buffer.pass_stride * buffer.passes + 4, alignment_floats); + buffer.mem.alloc_to_device(mem_size, false); +} +void DenoisingTask::prefilter_shadowing() +{ device_ptr null_ptr = (device_ptr) 0; - /* Prefilter shadow feature. */ - { - device_sub_ptr unfiltered_a (buffer.mem, 0, buffer.pass_stride); - device_sub_ptr unfiltered_b (buffer.mem, 1*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr sample_var (buffer.mem, 2*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr sample_var_var (buffer.mem, 3*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr buffer_var (buffer.mem, 5*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr filtered_var (buffer.mem, 6*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_1(buffer.mem, 7*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_2(buffer.mem, 8*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_3(buffer.mem, 9*buffer.pass_stride, buffer.pass_stride); - - nlm_state.temporary_1_ptr = *nlm_temporary_1; - nlm_state.temporary_2_ptr = *nlm_temporary_2; - nlm_state.temporary_3_ptr = *nlm_temporary_3; - - /* Get the A/B unfiltered passes, the combined sample variance, the estimated variance of the sample variance and the buffer variance. */ - functions.divide_shadow(*unfiltered_a, *unfiltered_b, *sample_var, *sample_var_var, *buffer_var); - - /* Smooth the (generally pretty noisy) buffer variance using the spatial information from the sample variance. */ - nlm_state.set_parameters(6, 3, 4.0f, 1.0f); - functions.non_local_means(*buffer_var, *sample_var, *sample_var_var, *filtered_var); - - /* Reuse memory, the previous data isn't needed anymore. */ - device_ptr filtered_a = *buffer_var, - filtered_b = *sample_var; - /* Use the smoothed variance to filter the two shadow half images using each other for weight calculation. */ - nlm_state.set_parameters(5, 3, 1.0f, 0.25f); - functions.non_local_means(*unfiltered_a, *unfiltered_b, *filtered_var, filtered_a); - functions.non_local_means(*unfiltered_b, *unfiltered_a, *filtered_var, filtered_b); - - device_ptr residual_var = *sample_var_var; - /* Estimate the residual variance between the two filtered halves. */ - functions.combine_halves(filtered_a, filtered_b, null_ptr, residual_var, 2, rect); - - device_ptr final_a = *unfiltered_a, - final_b = *unfiltered_b; - /* Use the residual variance for a second filter pass. */ - nlm_state.set_parameters(4, 2, 1.0f, 0.5f); - functions.non_local_means(filtered_a, filtered_b, residual_var, final_a); - functions.non_local_means(filtered_b, filtered_a, residual_var, final_b); - - /* Combine the two double-filtered halves to a final shadow feature. */ - device_sub_ptr shadow_pass(buffer.mem, 4*buffer.pass_stride, buffer.pass_stride); - functions.combine_halves(final_a, final_b, *shadow_pass, null_ptr, 0, rect); - } + device_sub_ptr unfiltered_a (buffer.mem, 0, buffer.pass_stride); + device_sub_ptr unfiltered_b (buffer.mem, 1*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr sample_var (buffer.mem, 2*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr sample_var_var (buffer.mem, 3*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr buffer_var (buffer.mem, 5*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr filtered_var (buffer.mem, 6*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr nlm_temporary_1(buffer.mem, 7*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr nlm_temporary_2(buffer.mem, 8*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr nlm_temporary_3(buffer.mem, 9*buffer.pass_stride, buffer.pass_stride); + + nlm_state.temporary_1_ptr = *nlm_temporary_1; + nlm_state.temporary_2_ptr = *nlm_temporary_2; + nlm_state.temporary_3_ptr = *nlm_temporary_3; + + /* Get the A/B unfiltered passes, the combined sample variance, the estimated variance of the sample variance and the buffer variance. */ + functions.divide_shadow(*unfiltered_a, *unfiltered_b, *sample_var, *sample_var_var, *buffer_var); + + /* Smooth the (generally pretty noisy) buffer variance using the spatial information from the sample variance. */ + nlm_state.set_parameters(6, 3, 4.0f, 1.0f); + functions.non_local_means(*buffer_var, *sample_var, *sample_var_var, *filtered_var); + + /* Reuse memory, the previous data isn't needed anymore. */ + device_ptr filtered_a = *buffer_var, + filtered_b = *sample_var; + /* Use the smoothed variance to filter the two shadow half images using each other for weight calculation. */ + nlm_state.set_parameters(5, 3, 1.0f, 0.25f); + functions.non_local_means(*unfiltered_a, *unfiltered_b, *filtered_var, filtered_a); + functions.non_local_means(*unfiltered_b, *unfiltered_a, *filtered_var, filtered_b); + + device_ptr residual_var = *sample_var_var; + /* Estimate the residual variance between the two filtered halves. */ + functions.combine_halves(filtered_a, filtered_b, null_ptr, residual_var, 2, rect); + + device_ptr final_a = *unfiltered_a, + final_b = *unfiltered_b; + /* Use the residual variance for a second filter pass. */ + nlm_state.set_parameters(4, 2, 1.0f, 0.5f); + functions.non_local_means(filtered_a, filtered_b, residual_var, final_a); + functions.non_local_means(filtered_b, filtered_a, residual_var, final_b); + + /* Combine the two double-filtered halves to a final shadow feature. */ + device_sub_ptr shadow_pass(buffer.mem, 4*buffer.pass_stride, buffer.pass_stride); + functions.combine_halves(final_a, final_b, *shadow_pass, null_ptr, 0, rect); +} - /* Prefilter general features. */ - { - device_sub_ptr unfiltered (buffer.mem, 8*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr variance (buffer.mem, 9*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_1(buffer.mem, 10*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_2(buffer.mem, 11*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_3(buffer.mem, 12*buffer.pass_stride, buffer.pass_stride); - - nlm_state.temporary_1_ptr = *nlm_temporary_1; - nlm_state.temporary_2_ptr = *nlm_temporary_2; - nlm_state.temporary_3_ptr = *nlm_temporary_3; - - int mean_from[] = { 0, 1, 2, 12, 6, 7, 8 }; - int variance_from[] = { 3, 4, 5, 13, 9, 10, 11}; - int pass_to[] = { 1, 2, 3, 0, 5, 6, 7}; - for(int pass = 0; pass < 7; pass++) { - device_sub_ptr feature_pass(buffer.mem, pass_to[pass]*buffer.pass_stride, buffer.pass_stride); - /* Get the unfiltered pass and its variance from the RenderBuffers. */ - functions.get_feature(mean_from[pass], variance_from[pass], *unfiltered, *variance); - /* Smooth the pass and store the result in the denoising buffers. */ - nlm_state.set_parameters(2, 2, 1.0f, 0.25f); - functions.non_local_means(*unfiltered, *unfiltered, *variance, *feature_pass); - } +void DenoisingTask::prefilter_features() +{ + device_sub_ptr unfiltered (buffer.mem, 8*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr variance (buffer.mem, 9*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr nlm_temporary_1(buffer.mem, 10*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr nlm_temporary_2(buffer.mem, 11*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr nlm_temporary_3(buffer.mem, 12*buffer.pass_stride, buffer.pass_stride); + + nlm_state.temporary_1_ptr = *nlm_temporary_1; + nlm_state.temporary_2_ptr = *nlm_temporary_2; + nlm_state.temporary_3_ptr = *nlm_temporary_3; + + int mean_from[] = { 0, 1, 2, 12, 6, 7, 8 }; + int variance_from[] = { 3, 4, 5, 13, 9, 10, 11}; + int pass_to[] = { 1, 2, 3, 0, 5, 6, 7}; + for(int pass = 0; pass < 7; pass++) { + device_sub_ptr feature_pass(buffer.mem, pass_to[pass]*buffer.pass_stride, buffer.pass_stride); + /* Get the unfiltered pass and its variance from the RenderBuffers. */ + functions.get_feature(mean_from[pass], variance_from[pass], *unfiltered, *variance); + /* Smooth the pass and store the result in the denoising buffers. */ + nlm_state.set_parameters(2, 2, 1.0f, 0.25f); + functions.non_local_means(*unfiltered, *unfiltered, *variance, *feature_pass); } +} - /* Copy color passes. */ - { - int mean_from[] = {20, 21, 22}; - int variance_from[] = {23, 24, 25}; - int mean_to[] = { 8, 9, 10}; - int variance_to[] = {11, 12, 13}; - int num_color_passes = 3; - - storage.temporary_color.alloc_to_device(3*buffer.pass_stride, false); - - for(int pass = 0; pass < num_color_passes; pass++) { - device_sub_ptr color_pass(storage.temporary_color, pass*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr color_var_pass(buffer.mem, variance_to[pass]*buffer.pass_stride, buffer.pass_stride); - functions.get_feature(mean_from[pass], variance_from[pass], *color_pass, *color_var_pass); - } - - { - device_sub_ptr depth_pass (buffer.mem, 0, buffer.pass_stride); - device_sub_ptr color_var_pass(buffer.mem, variance_to[0]*buffer.pass_stride, 3*buffer.pass_stride); - device_sub_ptr output_pass (buffer.mem, mean_to[0]*buffer.pass_stride, 3*buffer.pass_stride); - functions.detect_outliers(storage.temporary_color.device_pointer, *color_var_pass, *depth_pass, *output_pass); - } +void DenoisingTask::prefilter_color() +{ + int mean_from[] = {20, 21, 22}; + int variance_from[] = {23, 24, 25}; + int mean_to[] = { 8, 9, 10}; + int variance_to[] = {11, 12, 13}; + int num_color_passes = 3; + + storage.temporary_color.alloc_to_device(3*buffer.pass_stride, false); + device_sub_ptr nlm_temporary_1(storage.temporary_color, 0*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr nlm_temporary_2(storage.temporary_color, 1*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr nlm_temporary_3(storage.temporary_color, 2*buffer.pass_stride, buffer.pass_stride); + + nlm_state.temporary_1_ptr = *nlm_temporary_1; + nlm_state.temporary_2_ptr = *nlm_temporary_2; + nlm_state.temporary_3_ptr = *nlm_temporary_3; + + for(int pass = 0; pass < num_color_passes; pass++) { + device_sub_ptr color_pass(storage.temporary_color, pass*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr color_var_pass(buffer.mem, variance_to[pass]*buffer.pass_stride, buffer.pass_stride); + functions.get_feature(mean_from[pass], variance_from[pass], *color_pass, *color_var_pass); } + device_sub_ptr depth_pass (buffer.mem, 0, buffer.pass_stride); + device_sub_ptr color_var_pass(buffer.mem, variance_to[0]*buffer.pass_stride, 3*buffer.pass_stride); + device_sub_ptr output_pass (buffer.mem, mean_to[0]*buffer.pass_stride, 3*buffer.pass_stride); + functions.detect_outliers(storage.temporary_color.device_pointer, *color_var_pass, *depth_pass, *output_pass); + + storage.temporary_color.free(); +} + +void DenoisingTask::construct_transform() +{ storage.w = filter_area.z; storage.h = filter_area.w; + storage.transform.alloc_to_device(storage.w*storage.h*TRANSFORM_SIZE, false); storage.rank.alloc_to_device(storage.w*storage.h, false); functions.construct_transform(); +} + +void DenoisingTask::reconstruct() +{ device_only_memory temporary_1(device, "Denoising NLM temporary 1"); device_only_memory temporary_2(device, "Denoising NLM temporary 2"); @@ -222,13 +236,22 @@ bool DenoisingTask::run_denoising() reconstruction_state.source_w = rect.z-rect.x; reconstruction_state.source_h = rect.w-rect.y; - { - device_sub_ptr color_ptr (buffer.mem, 8*buffer.pass_stride, 3*buffer.pass_stride); - device_sub_ptr color_var_ptr(buffer.mem, 11*buffer.pass_stride, 3*buffer.pass_stride); - functions.reconstruct(*color_ptr, *color_var_ptr, render_buffer.ptr); - } + device_sub_ptr color_ptr (buffer.mem, 8*buffer.pass_stride, 3*buffer.pass_stride); + device_sub_ptr color_var_ptr(buffer.mem, 11*buffer.pass_stride, 3*buffer.pass_stride); + functions.reconstruct(*color_ptr, *color_var_ptr, render_buffer.ptr); +} + +void DenoisingTask::run_denoising() +{ + setup_denoising_buffer(); + + prefilter_shadowing(); + prefilter_features(); + prefilter_color(); + + construct_transform(); + reconstruct(); - return true; } CCL_NAMESPACE_END diff --git a/intern/cycles/device/device_denoising.h b/intern/cycles/device/device_denoising.h index 77a82d0ad04..a802151703b 100644 --- a/intern/cycles/device/device_denoising.h +++ b/intern/cycles/device/device_denoising.h @@ -138,12 +138,10 @@ public: {} } storage; - DenoisingTask(Device *device); + DenoisingTask(Device *device, const DeviceTask &task); ~DenoisingTask(); - void init_from_devicetask(const DeviceTask &task); - - bool run_denoising(); + void run_denoising(); struct DenoiseBuffers { int pass_stride; @@ -160,6 +158,14 @@ public: protected: Device *device; + + void set_render_buffer(RenderTile *rtiles); + void setup_denoising_buffer(); + void prefilter_shadowing(); + void prefilter_features(); + void prefilter_color(); + void construct_transform(); + void reconstruct(); }; CCL_NAMESPACE_END diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index bfa2702ad62..ca7a23efb24 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -1095,8 +1095,6 @@ void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising, cons task.map_neighbor_tiles(rtiles, this); denoising.tiles_from_rendertiles(rtiles); - denoising.init_from_devicetask(task); - denoising.run_denoising(); task.unmap_neighbor_tiles(rtiles, this); diff --git a/intern/cycles/device/opencl/opencl_mega.cpp b/intern/cycles/device/opencl/opencl_mega.cpp index ef39cfb5f7d..61c353d7a8a 100644 --- a/intern/cycles/device/opencl/opencl_mega.cpp +++ b/intern/cycles/device/opencl/opencl_mega.cpp @@ -107,7 +107,7 @@ public: } else if(task->type == DeviceTask::RENDER) { RenderTile tile; - DenoisingTask denoising(this); + DenoisingTask denoising(this, *task); /* Keep rendering tiles until done. */ while(task->acquire_tile(this, tile)) { diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index 51d3c7bb10f..86181af7fe0 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -129,7 +129,7 @@ public: } else if(task->type == DeviceTask::RENDER) { RenderTile tile; - DenoisingTask denoising(this); + DenoisingTask denoising(this, *task); /* Allocate buffer for kernel globals */ device_only_memory kgbuffer(this, "kernel_globals"); -- cgit v1.2.3 From 97a0d6fcc736e604113487196ff3c3578306fc6c Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 4 Jul 2018 14:26:15 +0200 Subject: Cycles Denoising: Refactor denoiser tile handling This deduplicates the calls for tile (un)mapping and allows to have a target buffer that is different from the source buffer (needed for baking and animation denoising). --- intern/cycles/device/device_cpu.cpp | 21 +++++---------- intern/cycles/device/device_cuda.cpp | 17 ++++--------- intern/cycles/device/device_denoising.cpp | 38 ++++++++++++++++++---------- intern/cycles/device/device_denoising.h | 20 ++++++++++----- intern/cycles/device/opencl/opencl.h | 2 +- intern/cycles/device/opencl/opencl_base.cpp | 15 +++-------- intern/cycles/device/opencl/opencl_mega.cpp | 2 +- intern/cycles/device/opencl/opencl_split.cpp | 2 +- intern/cycles/render/session.cpp | 3 +++ 9 files changed, 59 insertions(+), 61 deletions(-) diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 81a084c03b2..b824cddd87b 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -635,7 +635,7 @@ public: (float*) buffer_variance_ptr, &task->rect.x, task->render_buffer.pass_stride, - task->render_buffer.denoising_data_offset); + task->render_buffer.offset); } } return true; @@ -658,7 +658,7 @@ public: (float*) variance_ptr, &task->rect.x, task->render_buffer.pass_stride, - task->render_buffer.denoising_data_offset); + task->render_buffer.offset); } } return true; @@ -711,7 +711,7 @@ public: } } - void denoise(DeviceTask &task, DenoisingTask& denoising, RenderTile &tile) + void denoise(DenoisingTask& denoising, RenderTile &tile) { tile.sample = tile.start_sample + tile.num_samples; @@ -727,16 +727,7 @@ public: denoising.filter_area = make_int4(tile.x, tile.y, tile.w, tile.h); denoising.render_buffer.samples = tile.sample; - RenderTile rtiles[9]; - rtiles[4] = tile; - task.map_neighbor_tiles(rtiles, this); - denoising.tiles_from_rendertiles(rtiles); - - denoising.run_denoising(); - - task.unmap_neighbor_tiles(rtiles, this); - - task.update_progress(&tile, tile.w*tile.h); + denoising.run_denoising(&tile); } void thread_render(DeviceTask& task) @@ -777,7 +768,9 @@ public: } } else if(tile.task == RenderTile::DENOISE) { - denoise(task, denoising, tile); + denoise(denoising, tile); + + task.update_progress(&tile, tile.w*tile.h); } task.release_tile(tile); diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 34c64feb80a..1e7883f612b 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1542,7 +1542,7 @@ public: &buffer_variance_ptr, &task->rect, &task->render_buffer.pass_stride, - &task->render_buffer.denoising_data_offset}; + &task->render_buffer.offset}; CUDA_LAUNCH_KERNEL(cuFilterDivideShadow, args); cuda_assert(cuCtxSynchronize()); @@ -1575,7 +1575,7 @@ public: &variance_ptr, &task->rect, &task->render_buffer.pass_stride, - &task->render_buffer.denoising_data_offset}; + &task->render_buffer.offset}; CUDA_LAUNCH_KERNEL(cuFilterGetFeature, args); cuda_assert(cuCtxSynchronize()); @@ -1613,7 +1613,7 @@ public: return !have_error(); } - void denoise(RenderTile &rtile, DenoisingTask& denoising, const DeviceTask &task) + void denoise(RenderTile &rtile, DenoisingTask& denoising) { denoising.functions.construct_transform = function_bind(&CUDADevice::denoising_construct_transform, this, &denoising); denoising.functions.reconstruct = function_bind(&CUDADevice::denoising_reconstruct, this, _1, _2, _3, &denoising); @@ -1627,14 +1627,7 @@ public: denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h); denoising.render_buffer.samples = rtile.sample; - RenderTile rtiles[9]; - rtiles[4] = rtile; - task.map_neighbor_tiles(rtiles, this); - denoising.tiles_from_rendertiles(rtiles); - - denoising.run_denoising(); - - task.unmap_neighbor_tiles(rtiles, this); + denoising.run_denoising(&rtile); } void path_trace(DeviceTask& task, RenderTile& rtile, device_vector& work_tiles) @@ -2087,7 +2080,7 @@ public: else if(tile.task == RenderTile::DENOISE) { tile.sample = tile.start_sample + tile.num_samples; - denoise(tile, denoising, *task); + denoise(tile, denoising); task->update_progress(&tile, tile.w*tile.h); } diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp index 4d2ba508aec..fe6b53fc374 100644 --- a/intern/cycles/device/device_denoising.cpp +++ b/intern/cycles/device/device_denoising.cpp @@ -36,8 +36,13 @@ DenoisingTask::DenoisingTask(Device *device, const DeviceTask &task) } render_buffer.pass_stride = task.pass_stride; - render_buffer.denoising_data_offset = task.pass_denoising_data; - render_buffer.denoising_clean_offset = task.pass_denoising_clean; + render_buffer.offset = task.pass_denoising_data; + + target_buffer.pass_stride = task.pass_stride; + target_buffer.denoising_clean_offset = task.pass_denoising_clean; + + functions.map_neighbor_tiles = function_bind(task.map_neighbor_tiles, _1, device); + functions.unmap_neighbor_tiles = function_bind(task.unmap_neighbor_tiles, _1, device); } DenoisingTask::~DenoisingTask() @@ -53,8 +58,7 @@ DenoisingTask::~DenoisingTask() tiles_mem.free(); } - -void DenoisingTask::tiles_from_rendertiles(RenderTile *rtiles) +void DenoisingTask::set_render_buffer(RenderTile *rtiles) { tiles = (TilesInfo*) tiles_mem.alloc(sizeof(TilesInfo)/sizeof(int)); @@ -73,9 +77,9 @@ void DenoisingTask::tiles_from_rendertiles(RenderTile *rtiles) tiles->y[2] = rtiles[7].y; tiles->y[3] = rtiles[7].y + rtiles[7].h; - render_buffer.offset = rtiles[4].offset; - render_buffer.stride = rtiles[4].stride; - render_buffer.ptr = rtiles[4].buffer; + target_buffer.offset = rtiles[9].offset; + target_buffer.stride = rtiles[9].stride; + target_buffer.ptr = rtiles[9].buffer; functions.set_tiles(buffers); } @@ -228,21 +232,26 @@ void DenoisingTask::reconstruct() storage.XtWY.alloc_to_device(storage.w*storage.h*XTWY_SIZE, false); reconstruction_state.filter_window = rect_from_shape(filter_area.x-rect.x, filter_area.y-rect.y, storage.w, storage.h); - int tile_coordinate_offset = filter_area.y*render_buffer.stride + filter_area.x; - reconstruction_state.buffer_params = make_int4(render_buffer.offset + tile_coordinate_offset, - render_buffer.stride, - render_buffer.pass_stride, - render_buffer.denoising_clean_offset); + int tile_coordinate_offset = filter_area.y*target_buffer.stride + filter_area.x; + reconstruction_state.buffer_params = make_int4(target_buffer.offset + tile_coordinate_offset, + target_buffer.stride, + target_buffer.pass_stride, + target_buffer.denoising_clean_offset); reconstruction_state.source_w = rect.z-rect.x; reconstruction_state.source_h = rect.w-rect.y; device_sub_ptr color_ptr (buffer.mem, 8*buffer.pass_stride, 3*buffer.pass_stride); device_sub_ptr color_var_ptr(buffer.mem, 11*buffer.pass_stride, 3*buffer.pass_stride); - functions.reconstruct(*color_ptr, *color_var_ptr, render_buffer.ptr); + functions.reconstruct(*color_ptr, *color_var_ptr, target_buffer.ptr); } -void DenoisingTask::run_denoising() +void DenoisingTask::run_denoising(RenderTile *tile) { + RenderTile rtiles[10]; + rtiles[4] = *tile; + functions.map_neighbor_tiles(rtiles); + set_render_buffer(rtiles); + setup_denoising_buffer(); prefilter_shadowing(); @@ -252,6 +261,7 @@ void DenoisingTask::run_denoising() construct_transform(); reconstruct(); + functions.unmap_neighbor_tiles(rtiles); } CCL_NAMESPACE_END diff --git a/intern/cycles/device/device_denoising.h b/intern/cycles/device/device_denoising.h index a802151703b..21af1b10fc5 100644 --- a/intern/cycles/device/device_denoising.h +++ b/intern/cycles/device/device_denoising.h @@ -32,20 +32,24 @@ public: float nlm_k_2; float pca_threshold; - /* Pointer and parameters of the RenderBuffers. */ + /* Parameters of the RenderBuffers. */ struct RenderBuffers { - int denoising_data_offset; - int denoising_clean_offset; + int offset; int pass_stride; + int samples; + } render_buffer; + + /* Pointer and parameters of the target buffer. */ + struct TargetBuffer { int offset; int stride; + int pass_stride; + int denoising_clean_offset; device_ptr ptr; - int samples; - } render_buffer; + } target_buffer; TilesInfo *tiles; device_vector tiles_mem; - void tiles_from_rendertiles(RenderTile *rtiles); int4 rect; int4 filter_area; @@ -86,6 +90,8 @@ public: device_ptr output_ptr )> detect_outliers; function set_tiles; + function map_neighbor_tiles; + function unmap_neighbor_tiles; } functions; /* Stores state of the current Reconstruction operation, @@ -141,7 +147,7 @@ public: DenoisingTask(Device *device, const DeviceTask &task); ~DenoisingTask(); - void run_denoising(); + void run_denoising(RenderTile *tile); struct DenoiseBuffers { int pass_stride; diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index 85ef14ee29a..7526f1e15a1 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -362,7 +362,7 @@ public: void film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half); void shader(DeviceTask& task); - void denoise(RenderTile& tile, DenoisingTask& denoising, const DeviceTask& task); + void denoise(RenderTile& tile, DenoisingTask& denoising); class OpenCLDeviceTask : public DeviceTask { public: diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index ca7a23efb24..4e49e0ef166 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -991,7 +991,7 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr, buffer_variance_mem, task->rect, task->render_buffer.pass_stride, - task->render_buffer.denoising_data_offset); + task->render_buffer.offset); enqueue_kernel(ckFilterDivideShadow, task->rect.z-task->rect.x, task->rect.w-task->rect.y); @@ -1021,7 +1021,7 @@ bool OpenCLDeviceBase::denoising_get_feature(int mean_offset, variance_mem, task->rect, task->render_buffer.pass_stride, - task->render_buffer.denoising_data_offset); + task->render_buffer.offset); enqueue_kernel(ckFilterGetFeature, task->rect.z-task->rect.x, task->rect.w-task->rect.y); @@ -1076,7 +1076,7 @@ bool OpenCLDeviceBase::denoising_set_tiles(device_ptr *buffers, return true; } -void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising, const DeviceTask &task) +void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising) { denoising.functions.set_tiles = function_bind(&OpenCLDeviceBase::denoising_set_tiles, this, _1, &denoising); denoising.functions.construct_transform = function_bind(&OpenCLDeviceBase::denoising_construct_transform, this, &denoising); @@ -1090,14 +1090,7 @@ void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising, cons denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h); denoising.render_buffer.samples = rtile.sample; - RenderTile rtiles[9]; - rtiles[4] = rtile; - task.map_neighbor_tiles(rtiles, this); - denoising.tiles_from_rendertiles(rtiles); - - denoising.run_denoising(); - - task.unmap_neighbor_tiles(rtiles, this); + denoising.run_denoising(&rtile); } void OpenCLDeviceBase::shader(DeviceTask& task) diff --git a/intern/cycles/device/opencl/opencl_mega.cpp b/intern/cycles/device/opencl/opencl_mega.cpp index 61c353d7a8a..e004c0b44f4 100644 --- a/intern/cycles/device/opencl/opencl_mega.cpp +++ b/intern/cycles/device/opencl/opencl_mega.cpp @@ -141,7 +141,7 @@ public: } else if(tile.task == RenderTile::DENOISE) { tile.sample = tile.start_sample + tile.num_samples; - denoise(tile, denoising, *task); + denoise(tile, denoising); task->update_progress(&tile, tile.w*tile.h); } diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index 86181af7fe0..66a4aa7e891 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -159,7 +159,7 @@ public: } else if(tile.task == RenderTile::DENOISE) { tile.sample = tile.start_sample + tile.num_samples; - denoise(tile, denoising, *task); + denoise(tile, denoising); task->update_progress(&tile, tile.w*tile.h); } diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index bb636dd962a..3106ee53832 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -502,6 +502,9 @@ void Session::map_neighbor_tiles(RenderTile *tiles, Device *tile_device) assert(tiles[4].buffers); device->map_neighbor_tiles(tile_device, tiles); + + /* The denoised result is written back to the original tile. */ + tiles[9] = tiles[4]; } void Session::unmap_neighbor_tiles(RenderTile *tiles, Device *tile_device) -- cgit v1.2.3 From 9db8bdbc653eb783707a748a271797510144a8eb Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 4 Jul 2018 14:26:42 +0200 Subject: Cycles Denoising: Cleanup: Rename tiles to tile_info --- intern/cycles/device/device_cpu.cpp | 18 +++++----- intern/cycles/device/device_cuda.cpp | 14 ++++---- intern/cycles/device/device_denoising.cpp | 30 ++++++++-------- intern/cycles/device/device_denoising.h | 6 ++-- intern/cycles/device/opencl/opencl.h | 4 +-- intern/cycles/device/opencl/opencl_base.cpp | 28 +++++++-------- intern/cycles/kernel/filter/filter_defines.h | 4 +-- intern/cycles/kernel/filter/filter_prefilter.h | 20 +++++------ intern/cycles/kernel/kernels/cpu/filter_cpu.h | 4 +-- intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h | 8 ++--- intern/cycles/kernel/kernels/cuda/filter.cu | 8 ++--- intern/cycles/kernel/kernels/opencl/filter.cl | 42 +++++++++++----------- 12 files changed, 93 insertions(+), 93 deletions(-) diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index b824cddd87b..c54ac1e5933 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -179,8 +179,8 @@ public: KernelFunctions convert_to_byte_kernel; KernelFunctions shader_kernel; - KernelFunctions filter_divide_shadow_kernel; - KernelFunctions filter_get_feature_kernel; + KernelFunctions filter_divide_shadow_kernel; + KernelFunctions filter_get_feature_kernel; KernelFunctions filter_detect_outliers_kernel; KernelFunctions filter_combine_halves_kernel; @@ -459,14 +459,14 @@ public: } }; - bool denoising_set_tiles(device_ptr *buffers, DenoisingTask *task) + bool denoising_set_tile_info(device_ptr *buffers, DenoisingTask *task) { - TilesInfo *tiles = (TilesInfo*) task->tiles_mem.host_pointer; + TileInfo *tile_info = (TileInfo*) task->tile_info_mem.host_pointer; for(int i = 0; i < 9; i++) { - tiles->buffers[i] = buffers[i]; + tile_info->buffers[i] = buffers[i]; } - task->tiles_mem.copy_to_device(); + task->tile_info_mem.copy_to_device(); return true; } @@ -626,7 +626,7 @@ public: for(int y = task->rect.y; y < task->rect.w; y++) { for(int x = task->rect.x; x < task->rect.z; x++) { filter_divide_shadow_kernel()(task->render_buffer.samples, - task->tiles, + task->tile_info, x, y, (float*) a_ptr, (float*) b_ptr, @@ -650,7 +650,7 @@ public: for(int y = task->rect.y; y < task->rect.w; y++) { for(int x = task->rect.x; x < task->rect.z; x++) { filter_get_feature_kernel()(task->render_buffer.samples, - task->tiles, + task->tile_info, mean_offset, variance_offset, x, y, @@ -722,7 +722,7 @@ public: denoising.functions.combine_halves = function_bind(&CPUDevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising); denoising.functions.get_feature = function_bind(&CPUDevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising); denoising.functions.detect_outliers = function_bind(&CPUDevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising); - denoising.functions.set_tiles = function_bind(&CPUDevice::denoising_set_tiles, this, _1, &denoising); + denoising.functions.set_tile_info = function_bind(&CPUDevice::denoising_set_tile_info, this, _1, &denoising); denoising.filter_area = make_int4(tile.x, tile.y, tile.w, tile.h); denoising.render_buffer.samples = tile.sample; diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 1e7883f612b..c8e0ea4d896 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1251,14 +1251,14 @@ public: } } - bool denoising_set_tiles(device_ptr *buffers, DenoisingTask *task) + bool denoising_set_tile_info(device_ptr *buffers, DenoisingTask *task) { - TilesInfo *tiles = (TilesInfo*) task->tiles_mem.host_pointer; + TileInfo *tile_info = (TileInfo*) task->tile_info_mem.host_pointer; for(int i = 0; i < 9; i++) { - tiles->buffers[i] = buffers[i]; + tile_info->buffers[i] = buffers[i]; } - task->tiles_mem.copy_to_device(); + task->tile_info_mem.copy_to_device(); return !have_error(); } @@ -1534,7 +1534,7 @@ public: task->rect.w-task->rect.y); void *args[] = {&task->render_buffer.samples, - &task->tiles_mem.device_pointer, + &task->tile_info_mem.device_pointer, &a_ptr, &b_ptr, &sample_variance_ptr, @@ -1568,7 +1568,7 @@ public: task->rect.w-task->rect.y); void *args[] = {&task->render_buffer.samples, - &task->tiles_mem.device_pointer, + &task->tile_info_mem.device_pointer, &mean_offset, &variance_offset, &mean_ptr, @@ -1622,7 +1622,7 @@ public: denoising.functions.combine_halves = function_bind(&CUDADevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising); denoising.functions.get_feature = function_bind(&CUDADevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising); denoising.functions.detect_outliers = function_bind(&CUDADevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising); - denoising.functions.set_tiles = function_bind(&CUDADevice::denoising_set_tiles, this, _1, &denoising); + denoising.functions.set_tile_info = function_bind(&CUDADevice::denoising_set_tile_info, this, _1, &denoising); denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h); denoising.render_buffer.samples = rtile.sample; diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp index fe6b53fc374..318b14ab499 100644 --- a/intern/cycles/device/device_denoising.cpp +++ b/intern/cycles/device/device_denoising.cpp @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN DenoisingTask::DenoisingTask(Device *device, const DeviceTask &task) -: tiles_mem(device, "denoising tiles_mem", MEM_READ_WRITE), +: tile_info_mem(device, "denoising tile info mem", MEM_READ_WRITE), storage(device), buffer(device), device(device) @@ -55,33 +55,33 @@ DenoisingTask::~DenoisingTask() storage.temporary_2.free(); storage.temporary_color.free(); buffer.mem.free(); - tiles_mem.free(); + tile_info_mem.free(); } void DenoisingTask::set_render_buffer(RenderTile *rtiles) { - tiles = (TilesInfo*) tiles_mem.alloc(sizeof(TilesInfo)/sizeof(int)); + tile_info = (TileInfo*) tile_info_mem.alloc(sizeof(TileInfo)/sizeof(int)); device_ptr buffers[9]; for(int i = 0; i < 9; i++) { buffers[i] = rtiles[i].buffer; - tiles->offsets[i] = rtiles[i].offset; - tiles->strides[i] = rtiles[i].stride; + tile_info->offsets[i] = rtiles[i].offset; + tile_info->strides[i] = rtiles[i].stride; } - tiles->x[0] = rtiles[3].x; - tiles->x[1] = rtiles[4].x; - tiles->x[2] = rtiles[5].x; - tiles->x[3] = rtiles[5].x + rtiles[5].w; - tiles->y[0] = rtiles[1].y; - tiles->y[1] = rtiles[4].y; - tiles->y[2] = rtiles[7].y; - tiles->y[3] = rtiles[7].y + rtiles[7].h; + tile_info->x[0] = rtiles[3].x; + tile_info->x[1] = rtiles[4].x; + tile_info->x[2] = rtiles[5].x; + tile_info->x[3] = rtiles[5].x + rtiles[5].w; + tile_info->y[0] = rtiles[1].y; + tile_info->y[1] = rtiles[4].y; + tile_info->y[2] = rtiles[7].y; + tile_info->y[3] = rtiles[7].y + rtiles[7].h; target_buffer.offset = rtiles[9].offset; target_buffer.stride = rtiles[9].stride; target_buffer.ptr = rtiles[9].buffer; - functions.set_tiles(buffers); + functions.set_tile_info(buffers); } void DenoisingTask::setup_denoising_buffer() @@ -89,7 +89,7 @@ void DenoisingTask::setup_denoising_buffer() /* Expand filter_area by radius pixels and clamp the result to the extent of the neighboring tiles */ rect = rect_from_shape(filter_area.x, filter_area.y, filter_area.z, filter_area.w); rect = rect_expand(rect, radius); - rect = rect_clip(rect, make_int4(tiles->x[0], tiles->y[0], tiles->x[3], tiles->y[3])); + rect = rect_clip(rect, make_int4(tile_info->x[0], tile_info->y[0], tile_info->x[3], tile_info->y[3])); buffer.passes = 14; buffer.width = rect.z - rect.x; diff --git a/intern/cycles/device/device_denoising.h b/intern/cycles/device/device_denoising.h index 21af1b10fc5..1063d43d039 100644 --- a/intern/cycles/device/device_denoising.h +++ b/intern/cycles/device/device_denoising.h @@ -48,8 +48,8 @@ public: device_ptr ptr; } target_buffer; - TilesInfo *tiles; - device_vector tiles_mem; + TileInfo *tile_info; + device_vector tile_info_mem; int4 rect; int4 filter_area; @@ -89,7 +89,7 @@ public: device_ptr depth_ptr, device_ptr output_ptr )> detect_outliers; - function set_tiles; + function set_tile_info; function map_neighbor_tiles; function unmap_neighbor_tiles; } functions; diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index 7526f1e15a1..c550d738bd5 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -436,8 +436,8 @@ protected: device_ptr depth_ptr, device_ptr output_ptr, DenoisingTask *task); - bool denoising_set_tiles(device_ptr *buffers, - DenoisingTask *task); + bool denoising_set_tile_info(device_ptr *buffers, + DenoisingTask *task); device_ptr mem_alloc_sub_ptr(device_memory& mem, int offset, int size); void mem_free_sub_ptr(device_ptr ptr); diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index 4e49e0ef166..50d371e4c55 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -246,7 +246,7 @@ bool OpenCLDeviceBase::load_kernels(const DeviceRequestedFeatures& requested_fea denoising_program.add_kernel(ustring("filter_nlm_normalize")); denoising_program.add_kernel(ustring("filter_nlm_construct_gramian")); denoising_program.add_kernel(ustring("filter_finalize")); - denoising_program.add_kernel(ustring("filter_set_tiles")); + denoising_program.add_kernel(ustring("filter_set_tile_info")); vector programs; programs.push_back(&base_program); @@ -977,13 +977,13 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr, cl_mem sv_variance_mem = CL_MEM_PTR(sv_variance_ptr); cl_mem buffer_variance_mem = CL_MEM_PTR(buffer_variance_ptr); - cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer); + cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer); cl_kernel ckFilterDivideShadow = denoising_program(ustring("filter_divide_shadow")); kernel_set_args(ckFilterDivideShadow, 0, task->render_buffer.samples, - tiles_mem, + tile_info_mem, a_mem, b_mem, sample_variance_mem, @@ -1008,13 +1008,13 @@ bool OpenCLDeviceBase::denoising_get_feature(int mean_offset, cl_mem mean_mem = CL_MEM_PTR(mean_ptr); cl_mem variance_mem = CL_MEM_PTR(variance_ptr); - cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer); + cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer); cl_kernel ckFilterGetFeature = denoising_program(ustring("filter_get_feature")); kernel_set_args(ckFilterGetFeature, 0, task->render_buffer.samples, - tiles_mem, + tile_info_mem, mean_offset, variance_offset, mean_mem, @@ -1056,29 +1056,29 @@ bool OpenCLDeviceBase::denoising_detect_outliers(device_ptr image_ptr, return true; } -bool OpenCLDeviceBase::denoising_set_tiles(device_ptr *buffers, - DenoisingTask *task) +bool OpenCLDeviceBase::denoising_set_tile_info(device_ptr *buffers, + DenoisingTask *task) { - task->tiles_mem.copy_to_device(); + task->tile_info_mem.copy_to_device(); - cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer); + cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer); - cl_kernel ckFilterSetTiles = denoising_program(ustring("filter_set_tiles")); + cl_kernel ckFilterSetTileInfo = denoising_program(ustring("filter_set_tile_info")); - kernel_set_args(ckFilterSetTiles, 0, tiles_mem); + kernel_set_args(ckFilterSetTileInfo, 0, tile_info_mem); for(int i = 0; i < 9; i++) { cl_mem buffer_mem = CL_MEM_PTR(buffers[i]); - kernel_set_args(ckFilterSetTiles, i+1, buffer_mem); + kernel_set_args(ckFilterSetTileInfo, i+1, buffer_mem); } - enqueue_kernel(ckFilterSetTiles, 1, 1); + enqueue_kernel(ckFilterSetTileInfo, 1, 1); return true; } void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising) { - denoising.functions.set_tiles = function_bind(&OpenCLDeviceBase::denoising_set_tiles, this, _1, &denoising); + denoising.functions.set_tile_info = function_bind(&OpenCLDeviceBase::denoising_set_tile_info, this, _1, &denoising); denoising.functions.construct_transform = function_bind(&OpenCLDeviceBase::denoising_construct_transform, this, &denoising); denoising.functions.reconstruct = function_bind(&OpenCLDeviceBase::denoising_reconstruct, this, _1, _2, _3, &denoising); denoising.functions.divide_shadow = function_bind(&OpenCLDeviceBase::denoising_divide_shadow, this, _1, _2, _3, _4, _5, &denoising); diff --git a/intern/cycles/kernel/filter/filter_defines.h b/intern/cycles/kernel/filter/filter_defines.h index ce96f733aff..57d3d90594f 100644 --- a/intern/cycles/kernel/filter/filter_defines.h +++ b/intern/cycles/kernel/filter/filter_defines.h @@ -22,7 +22,7 @@ #define XTWX_SIZE (((DENOISE_FEATURES+1)*(DENOISE_FEATURES+2))/2) #define XTWY_SIZE (DENOISE_FEATURES+1) -typedef struct TilesInfo { +typedef struct TileInfo { int offsets[9]; int strides[9]; int x[4]; @@ -33,6 +33,6 @@ typedef struct TilesInfo { #else long long int buffers[9]; #endif -} TilesInfo; +} TileInfo; #endif /* __FILTER_DEFINES_H__*/ diff --git a/intern/cycles/kernel/filter/filter_prefilter.h b/intern/cycles/kernel/filter/filter_prefilter.h index 4af209341f6..9513bf46bd7 100644 --- a/intern/cycles/kernel/filter/filter_prefilter.h +++ b/intern/cycles/kernel/filter/filter_prefilter.h @@ -26,7 +26,7 @@ CCL_NAMESPACE_BEGIN * bufferVariance: The buffer-based variance of the shadow feature. Unbiased, but quite noisy. */ ccl_device void kernel_filter_divide_shadow(int sample, - ccl_global TilesInfo *tiles, + ccl_global TileInfo *tile_info, int x, int y, ccl_global float *unfilteredA, ccl_global float *unfilteredB, @@ -37,13 +37,13 @@ ccl_device void kernel_filter_divide_shadow(int sample, int buffer_pass_stride, int buffer_denoising_offset) { - int xtile = (x < tiles->x[1])? 0: ((x < tiles->x[2])? 1: 2); - int ytile = (y < tiles->y[1])? 0: ((y < tiles->y[2])? 1: 2); + int xtile = (x < tile_info->x[1])? 0: ((x < tile_info->x[2])? 1: 2); + int ytile = (y < tile_info->y[1])? 0: ((y < tile_info->y[2])? 1: 2); int tile = ytile*3+xtile; - int offset = tiles->offsets[tile]; - int stride = tiles->strides[tile]; - const ccl_global float *ccl_restrict center_buffer = (ccl_global float*) tiles->buffers[tile]; + int offset = tile_info->offsets[tile]; + int stride = tile_info->strides[tile]; + const ccl_global float *ccl_restrict center_buffer = (ccl_global float*) tile_info->buffers[tile]; center_buffer += (y*stride + x + offset)*buffer_pass_stride; center_buffer += buffer_denoising_offset + 14; @@ -79,7 +79,7 @@ ccl_device void kernel_filter_divide_shadow(int sample, * - rect: The prefilter area (lower pixels inclusive, upper pixels exclusive). */ ccl_device void kernel_filter_get_feature(int sample, - ccl_global TilesInfo *tiles, + ccl_global TileInfo *tile_info, int m_offset, int v_offset, int x, int y, ccl_global float *mean, @@ -87,10 +87,10 @@ ccl_device void kernel_filter_get_feature(int sample, int4 rect, int buffer_pass_stride, int buffer_denoising_offset) { - int xtile = (x < tiles->x[1])? 0: ((x < tiles->x[2])? 1: 2); - int ytile = (y < tiles->y[1])? 0: ((y < tiles->y[2])? 1: 2); + int xtile = (x < tile_info->x[1])? 0: ((x < tile_info->x[2])? 1: 2); + int ytile = (y < tile_info->y[1])? 0: ((y < tile_info->y[2])? 1: 2); int tile = ytile*3+xtile; - ccl_global float *center_buffer = ((ccl_global float*) tiles->buffers[tile]) + (tiles->offsets[tile] + y*tiles->strides[tile] + x)*buffer_pass_stride + buffer_denoising_offset; + ccl_global float *center_buffer = ((ccl_global float*) tile_info->buffers[tile]) + (tile_info->offsets[tile] + y*tile_info->strides[tile] + x)*buffer_pass_stride + buffer_denoising_offset; int buffer_w = align_up(rect.z - rect.x, 4); int idx = (y-rect.y)*buffer_w + (x - rect.x); diff --git a/intern/cycles/kernel/kernels/cpu/filter_cpu.h b/intern/cycles/kernel/kernels/cpu/filter_cpu.h index 4231aba88d7..b62aa9663ec 100644 --- a/intern/cycles/kernel/kernels/cpu/filter_cpu.h +++ b/intern/cycles/kernel/kernels/cpu/filter_cpu.h @@ -17,7 +17,7 @@ /* Templated common declaration part of all CPU kernels. */ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample, - TilesInfo *tiles, + TileInfo *tile_info, int x, int y, float *unfilteredA, @@ -30,7 +30,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample, int buffer_denoising_offset); void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample, - TilesInfo *tiles, + TileInfo *tile_info, int m_offset, int v_offset, int x, diff --git a/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h b/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h index 504622ecfd9..26777fdabb2 100644 --- a/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h +++ b/intern/cycles/kernel/kernels/cpu/filter_cpu_impl.h @@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN /* Denoise filter */ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample, - TilesInfo *tiles, + TileInfo *tile_info, int x, int y, float *unfilteredA, @@ -49,7 +49,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample, #ifdef KERNEL_STUB STUB_ASSERT(KERNEL_ARCH, filter_divide_shadow); #else - kernel_filter_divide_shadow(sample, tiles, + kernel_filter_divide_shadow(sample, tile_info, x, y, unfilteredA, unfilteredB, @@ -63,7 +63,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_divide_shadow)(int sample, } void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample, - TilesInfo *tiles, + TileInfo *tile_info, int m_offset, int v_offset, int x, @@ -76,7 +76,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_get_feature)(int sample, #ifdef KERNEL_STUB STUB_ASSERT(KERNEL_ARCH, filter_get_feature); #else - kernel_filter_get_feature(sample, tiles, + kernel_filter_get_feature(sample, tile_info, m_offset, v_offset, x, y, mean, variance, diff --git a/intern/cycles/kernel/kernels/cuda/filter.cu b/intern/cycles/kernel/kernels/cuda/filter.cu index 035f0484488..0561c40e6b1 100644 --- a/intern/cycles/kernel/kernels/cuda/filter.cu +++ b/intern/cycles/kernel/kernels/cuda/filter.cu @@ -29,7 +29,7 @@ extern "C" __global__ void CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS) kernel_cuda_filter_divide_shadow(int sample, - TilesInfo *tiles, + TileInfo *tile_info, float *unfilteredA, float *unfilteredB, float *sampleVariance, @@ -43,7 +43,7 @@ kernel_cuda_filter_divide_shadow(int sample, int y = prefilter_rect.y + blockDim.y*blockIdx.y + threadIdx.y; if(x < prefilter_rect.z && y < prefilter_rect.w) { kernel_filter_divide_shadow(sample, - tiles, + tile_info, x, y, unfilteredA, unfilteredB, @@ -59,7 +59,7 @@ kernel_cuda_filter_divide_shadow(int sample, extern "C" __global__ void CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS) kernel_cuda_filter_get_feature(int sample, - TilesInfo *tiles, + TileInfo *tile_info, int m_offset, int v_offset, float *mean, @@ -72,7 +72,7 @@ kernel_cuda_filter_get_feature(int sample, int y = prefilter_rect.y + blockDim.y*blockIdx.y + threadIdx.y; if(x < prefilter_rect.z && y < prefilter_rect.w) { kernel_filter_get_feature(sample, - tiles, + tile_info, m_offset, v_offset, x, y, mean, variance, diff --git a/intern/cycles/kernel/kernels/opencl/filter.cl b/intern/cycles/kernel/kernels/opencl/filter.cl index 2b77807c38b..d553ee6833c 100644 --- a/intern/cycles/kernel/kernels/opencl/filter.cl +++ b/intern/cycles/kernel/kernels/opencl/filter.cl @@ -23,7 +23,7 @@ /* kernels */ __kernel void kernel_ocl_filter_divide_shadow(int sample, - ccl_global TilesInfo *tiles, + ccl_global TileInfo *tile_info, ccl_global float *unfilteredA, ccl_global float *unfilteredB, ccl_global float *sampleVariance, @@ -51,7 +51,7 @@ __kernel void kernel_ocl_filter_divide_shadow(int sample, } __kernel void kernel_ocl_filter_get_feature(int sample, - ccl_global TilesInfo *tiles, + ccl_global TileInfo *tile_info, int m_offset, int v_offset, ccl_global float *mean, @@ -277,26 +277,26 @@ __kernel void kernel_ocl_filter_finalize(ccl_global float *buffer, } } -__kernel void kernel_ocl_filter_set_tiles(ccl_global TilesInfo* tiles, - ccl_global float *buffer_1, - ccl_global float *buffer_2, - ccl_global float *buffer_3, - ccl_global float *buffer_4, - ccl_global float *buffer_5, - ccl_global float *buffer_6, - ccl_global float *buffer_7, - ccl_global float *buffer_8, - ccl_global float *buffer_9) +__kernel void kernel_ocl_filter_set_tile_info(ccl_global TileInfo* tile_info, + ccl_global float *buffer_1, + ccl_global float *buffer_2, + ccl_global float *buffer_3, + ccl_global float *buffer_4, + ccl_global float *buffer_5, + ccl_global float *buffer_6, + ccl_global float *buffer_7, + ccl_global float *buffer_8, + ccl_global float *buffer_9) { if((get_global_id(0) == 0) && (get_global_id(1) == 0)) { - tiles->buffers[0] = buffer_1; - tiles->buffers[1] = buffer_2; - tiles->buffers[2] = buffer_3; - tiles->buffers[3] = buffer_4; - tiles->buffers[4] = buffer_5; - tiles->buffers[5] = buffer_6; - tiles->buffers[6] = buffer_7; - tiles->buffers[7] = buffer_8; - tiles->buffers[8] = buffer_9; + tile_info->buffers[0] = buffer_1; + tile_info->buffers[1] = buffer_2; + tile_info->buffers[2] = buffer_3; + tile_info->buffers[3] = buffer_4; + tile_info->buffers[4] = buffer_5; + tile_info->buffers[5] = buffer_6; + tile_info->buffers[6] = buffer_7; + tile_info->buffers[7] = buffer_8; + tile_info->buffers[8] = buffer_9; } } -- cgit v1.2.3 From f1525cf53462b5841f2f50283ae2926ab990170e Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 4 Jul 2018 13:19:12 +0200 Subject: Cycles Denoising: Correctly handle target buffer in tile unmapping and move device swap logic to the device_memory --- intern/cycles/device/device_memory.cpp | 20 ++++++++++++++++ intern/cycles/device/device_memory.h | 7 ++++++ intern/cycles/device/device_multi.cpp | 44 ++++++++++------------------------ intern/cycles/render/buffers.h | 1 + 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/intern/cycles/device/device_memory.cpp b/intern/cycles/device/device_memory.cpp index c6248fcf88b..482af685011 100644 --- a/intern/cycles/device/device_memory.cpp +++ b/intern/cycles/device/device_memory.cpp @@ -104,6 +104,26 @@ void device_memory::device_zero() } } +void device_memory::swap_device(Device *new_device, + size_t new_device_size, + device_ptr new_device_ptr) +{ + original_device = device; + original_device_size = device_size; + original_device_ptr = device_pointer; + + device = new_device; + device_size = new_device_size; + device_pointer = new_device_ptr; +} + +void device_memory::restore_device() +{ + device = original_device; + device_size = original_device_size; + device_pointer = original_device_ptr; +} + /* Device Sub Ptr */ device_sub_ptr::device_sub_ptr(device_memory& mem, int offset, int size) diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h index d8fe41e78bb..1138964f18c 100644 --- a/intern/cycles/device/device_memory.h +++ b/intern/cycles/device/device_memory.h @@ -200,6 +200,9 @@ public: virtual ~device_memory(); + void swap_device(Device *new_device, size_t new_device_size, device_ptr new_device_ptr); + void restore_device(); + protected: friend class CUDADevice; @@ -222,6 +225,10 @@ protected: void device_copy_to(); void device_copy_from(int y, int w, int h, int elem); void device_zero(); + + device_ptr original_device_ptr; + size_t original_device_size; + Device *original_device; }; /* Device Only Memory diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index 3a4c08b6eb2..1353797edb4 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -282,26 +282,27 @@ public: mem.copy_from_device(0, mem.data_size, 1); } - Device *original_device = mem.device; - device_ptr original_ptr = mem.device_pointer; - size_t original_size = mem.device_size; - - mem.device = sub_device; - mem.device_pointer = 0; - mem.device_size = 0; + mem.swap_device(sub_device, 0, 0); mem.copy_to_device(); tiles[i].buffer = mem.device_pointer; + tiles[i].device_size = mem.device_size; - mem.device = original_device; - mem.device_pointer = original_ptr; - mem.device_size = original_size; + mem.restore_device(); } } } void unmap_neighbor_tiles(Device * sub_device, RenderTile * tiles) { + /* Copy denoised result back to the host. */ + device_vector &mem = tiles[9].buffers->buffer; + mem.swap_device(sub_device, tiles[9].device_size, tiles[9].buffer); + mem.copy_from_device(0, mem.data_size, 1); + mem.restore_device(); + /* Copy denoised result to the original device. */ + mem.copy_to_device(); + for(int i = 0; i < 9; i++) { if(!tiles[i].buffers) { continue; @@ -309,28 +310,9 @@ public: device_vector &mem = tiles[i].buffers->buffer; if(mem.device != sub_device) { - Device *original_device = mem.device; - device_ptr original_ptr = mem.device_pointer; - size_t original_size = mem.device_size; - - mem.device = sub_device; - mem.device_pointer = tiles[i].buffer; - - /* Copy denoised tile to the host. */ - if(i == 4) { - mem.copy_from_device(0, mem.data_size, 1); - } - + mem.swap_device(sub_device, tiles[i].device_size, tiles[i].buffer); sub_device->mem_free(mem); - - mem.device = original_device; - mem.device_pointer = original_ptr; - mem.device_size = original_size; - - /* Copy denoised tile to the original device. */ - if(i == 4) { - mem.copy_to_device(); - } + mem.restore_device(); } } } diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h index dfc98fe2061..ee7c0490dfd 100644 --- a/intern/cycles/render/buffers.h +++ b/intern/cycles/render/buffers.h @@ -137,6 +137,7 @@ public: int tile_index; device_ptr buffer; + int device_size; RenderBuffers *buffers; -- cgit v1.2.3 From c9608047472ae2b08d2d4b188fca5211a6c0b925 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 4 Jul 2018 14:02:38 +0200 Subject: Cycles Denoising: Pass tile buffers to every OpenCL kernel to conform to standard and get rid of set_tile_info --- intern/cycles/device/device_cpu.cpp | 13 ------- intern/cycles/device/device_cuda.cpp | 13 ------- intern/cycles/device/device_denoising.cpp | 5 ++- intern/cycles/device/device_denoising.h | 1 - intern/cycles/device/opencl/opencl.h | 2 -- intern/cycles/device/opencl/opencl_base.cpp | 48 +++++++++++--------------- intern/cycles/kernel/filter/filter_defines.h | 25 ++++++++++++++ intern/cycles/kernel/filter/filter_prefilter.h | 8 ++--- intern/cycles/kernel/kernels/opencl/filter.cl | 32 +++-------------- 9 files changed, 55 insertions(+), 92 deletions(-) diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index c54ac1e5933..be0dcc20755 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -459,18 +459,6 @@ public: } }; - bool denoising_set_tile_info(device_ptr *buffers, DenoisingTask *task) - { - TileInfo *tile_info = (TileInfo*) task->tile_info_mem.host_pointer; - for(int i = 0; i < 9; i++) { - tile_info->buffers[i] = buffers[i]; - } - - task->tile_info_mem.copy_to_device(); - - return true; - } - bool denoising_non_local_means(device_ptr image_ptr, device_ptr guide_ptr, device_ptr variance_ptr, device_ptr out_ptr, DenoisingTask *task) { @@ -722,7 +710,6 @@ public: denoising.functions.combine_halves = function_bind(&CPUDevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising); denoising.functions.get_feature = function_bind(&CPUDevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising); denoising.functions.detect_outliers = function_bind(&CPUDevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising); - denoising.functions.set_tile_info = function_bind(&CPUDevice::denoising_set_tile_info, this, _1, &denoising); denoising.filter_area = make_int4(tile.x, tile.y, tile.w, tile.h); denoising.render_buffer.samples = tile.sample; diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index c8e0ea4d896..8294af340e8 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1251,18 +1251,6 @@ public: } } - bool denoising_set_tile_info(device_ptr *buffers, DenoisingTask *task) - { - TileInfo *tile_info = (TileInfo*) task->tile_info_mem.host_pointer; - for(int i = 0; i < 9; i++) { - tile_info->buffers[i] = buffers[i]; - } - - task->tile_info_mem.copy_to_device(); - - return !have_error(); - } - #define CUDA_GET_BLOCKSIZE(func, w, h) \ int threads_per_block; \ cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, func)); \ @@ -1622,7 +1610,6 @@ public: denoising.functions.combine_halves = function_bind(&CUDADevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising); denoising.functions.get_feature = function_bind(&CUDADevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising); denoising.functions.detect_outliers = function_bind(&CUDADevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising); - denoising.functions.set_tile_info = function_bind(&CUDADevice::denoising_set_tile_info, this, _1, &denoising); denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h); denoising.render_buffer.samples = rtile.sample; diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp index 318b14ab499..c0d4634262d 100644 --- a/intern/cycles/device/device_denoising.cpp +++ b/intern/cycles/device/device_denoising.cpp @@ -62,11 +62,10 @@ void DenoisingTask::set_render_buffer(RenderTile *rtiles) { tile_info = (TileInfo*) tile_info_mem.alloc(sizeof(TileInfo)/sizeof(int)); - device_ptr buffers[9]; for(int i = 0; i < 9; i++) { - buffers[i] = rtiles[i].buffer; tile_info->offsets[i] = rtiles[i].offset; tile_info->strides[i] = rtiles[i].stride; + tile_info->buffers[i] = rtiles[i].buffer; } tile_info->x[0] = rtiles[3].x; tile_info->x[1] = rtiles[4].x; @@ -81,7 +80,7 @@ void DenoisingTask::set_render_buffer(RenderTile *rtiles) target_buffer.stride = rtiles[9].stride; target_buffer.ptr = rtiles[9].buffer; - functions.set_tile_info(buffers); + tile_info_mem.copy_to_device(); } void DenoisingTask::setup_denoising_buffer() diff --git a/intern/cycles/device/device_denoising.h b/intern/cycles/device/device_denoising.h index 1063d43d039..e0da52867f1 100644 --- a/intern/cycles/device/device_denoising.h +++ b/intern/cycles/device/device_denoising.h @@ -89,7 +89,6 @@ public: device_ptr depth_ptr, device_ptr output_ptr )> detect_outliers; - function set_tile_info; function map_neighbor_tiles; function unmap_neighbor_tiles; } functions; diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index c550d738bd5..22e0503365c 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -436,8 +436,6 @@ protected: device_ptr depth_ptr, device_ptr output_ptr, DenoisingTask *task); - bool denoising_set_tile_info(device_ptr *buffers, - DenoisingTask *task); device_ptr mem_alloc_sub_ptr(device_memory& mem, int offset, int size); void mem_free_sub_ptr(device_ptr ptr); diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index 50d371e4c55..9a50d217321 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -246,7 +246,6 @@ bool OpenCLDeviceBase::load_kernels(const DeviceRequestedFeatures& requested_fea denoising_program.add_kernel(ustring("filter_nlm_normalize")); denoising_program.add_kernel(ustring("filter_nlm_construct_gramian")); denoising_program.add_kernel(ustring("filter_finalize")); - denoising_program.add_kernel(ustring("filter_set_tile_info")); vector programs; programs.push_back(&base_program); @@ -981,9 +980,16 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr, cl_kernel ckFilterDivideShadow = denoising_program(ustring("filter_divide_shadow")); - kernel_set_args(ckFilterDivideShadow, 0, - task->render_buffer.samples, - tile_info_mem, + int arg_ofs = kernel_set_args(ckFilterDivideShadow, 0, + task->render_buffer.samples, + tile_info_mem); + cl_mem buffers[9]; + for(int i = 0; i < 9; i++) { + buffers[i] = CL_MEM_PTR(task->tile_info->buffers[i]); + arg_ofs += kernel_set_args(ckFilterDivideShadow, arg_ofs, + buffers[i]); + } + kernel_set_args(ckFilterDivideShadow, arg_ofs, a_mem, b_mem, sample_variance_mem, @@ -1012,9 +1018,16 @@ bool OpenCLDeviceBase::denoising_get_feature(int mean_offset, cl_kernel ckFilterGetFeature = denoising_program(ustring("filter_get_feature")); - kernel_set_args(ckFilterGetFeature, 0, - task->render_buffer.samples, - tile_info_mem, + int arg_ofs = kernel_set_args(ckFilterGetFeature, 0, + task->render_buffer.samples, + tile_info_mem); + cl_mem buffers[9]; + for(int i = 0; i < 9; i++) { + buffers[i] = CL_MEM_PTR(task->tile_info->buffers[i]); + arg_ofs += kernel_set_args(ckFilterGetFeature, arg_ofs, + buffers[i]); + } + kernel_set_args(ckFilterGetFeature, arg_ofs, mean_offset, variance_offset, mean_mem, @@ -1056,29 +1069,8 @@ bool OpenCLDeviceBase::denoising_detect_outliers(device_ptr image_ptr, return true; } -bool OpenCLDeviceBase::denoising_set_tile_info(device_ptr *buffers, - DenoisingTask *task) -{ - task->tile_info_mem.copy_to_device(); - - cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer); - - cl_kernel ckFilterSetTileInfo = denoising_program(ustring("filter_set_tile_info")); - - kernel_set_args(ckFilterSetTileInfo, 0, tile_info_mem); - for(int i = 0; i < 9; i++) { - cl_mem buffer_mem = CL_MEM_PTR(buffers[i]); - kernel_set_args(ckFilterSetTileInfo, i+1, buffer_mem); - } - - enqueue_kernel(ckFilterSetTileInfo, 1, 1); - - return true; -} - void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising) { - denoising.functions.set_tile_info = function_bind(&OpenCLDeviceBase::denoising_set_tile_info, this, _1, &denoising); denoising.functions.construct_transform = function_bind(&OpenCLDeviceBase::denoising_construct_transform, this, &denoising); denoising.functions.reconstruct = function_bind(&OpenCLDeviceBase::denoising_reconstruct, this, _1, _2, _3, &denoising); denoising.functions.divide_shadow = function_bind(&OpenCLDeviceBase::denoising_divide_shadow, this, _1, _2, _3, _4, _5, &denoising); diff --git a/intern/cycles/kernel/filter/filter_defines.h b/intern/cycles/kernel/filter/filter_defines.h index 57d3d90594f..d48ea3ac1d6 100644 --- a/intern/cycles/kernel/filter/filter_defines.h +++ b/intern/cycles/kernel/filter/filter_defines.h @@ -35,4 +35,29 @@ typedef struct TileInfo { #endif } TileInfo; +#ifdef __KERNEL_OPENCL__ +# define CCL_FILTER_TILE_INFO ccl_global TileInfo* tile_info, \ + ccl_global float *tile_buffer_1, \ + ccl_global float *tile_buffer_2, \ + ccl_global float *tile_buffer_3, \ + ccl_global float *tile_buffer_4, \ + ccl_global float *tile_buffer_5, \ + ccl_global float *tile_buffer_6, \ + ccl_global float *tile_buffer_7, \ + ccl_global float *tile_buffer_8, \ + ccl_global float *tile_buffer_9 +# define CCL_FILTER_TILE_INFO_ARG tile_info, \ + tile_buffer_1, tile_buffer_2, tile_buffer_3, \ + tile_buffer_4, tile_buffer_5, tile_buffer_6, \ + tile_buffer_7, tile_buffer_8, tile_buffer_9 +# define ccl_get_tile_buffer(id) (tile_buffer_ ## id) +#else +# ifdef __KERNEL_CUDA__ +# define CCL_FILTER_TILE_INFO ccl_global TileInfo* tile_info +# else +# define CCL_FILTER_TILE_INFO TileInfo* tile_info +# endif +# define ccl_get_tile_buffer(id) (tile_info->buffers[id]) +#endif + #endif /* __FILTER_DEFINES_H__*/ diff --git a/intern/cycles/kernel/filter/filter_prefilter.h b/intern/cycles/kernel/filter/filter_prefilter.h index 9513bf46bd7..3507f80df46 100644 --- a/intern/cycles/kernel/filter/filter_prefilter.h +++ b/intern/cycles/kernel/filter/filter_prefilter.h @@ -26,7 +26,7 @@ CCL_NAMESPACE_BEGIN * bufferVariance: The buffer-based variance of the shadow feature. Unbiased, but quite noisy. */ ccl_device void kernel_filter_divide_shadow(int sample, - ccl_global TileInfo *tile_info, + CCL_FILTER_TILE_INFO, int x, int y, ccl_global float *unfilteredA, ccl_global float *unfilteredB, @@ -43,7 +43,7 @@ ccl_device void kernel_filter_divide_shadow(int sample, int offset = tile_info->offsets[tile]; int stride = tile_info->strides[tile]; - const ccl_global float *ccl_restrict center_buffer = (ccl_global float*) tile_info->buffers[tile]; + const ccl_global float *ccl_restrict center_buffer = (ccl_global float*) ccl_get_tile_buffer(tile); center_buffer += (y*stride + x + offset)*buffer_pass_stride; center_buffer += buffer_denoising_offset + 14; @@ -79,7 +79,7 @@ ccl_device void kernel_filter_divide_shadow(int sample, * - rect: The prefilter area (lower pixels inclusive, upper pixels exclusive). */ ccl_device void kernel_filter_get_feature(int sample, - ccl_global TileInfo *tile_info, + CCL_FILTER_TILE_INFO, int m_offset, int v_offset, int x, int y, ccl_global float *mean, @@ -90,7 +90,7 @@ ccl_device void kernel_filter_get_feature(int sample, int xtile = (x < tile_info->x[1])? 0: ((x < tile_info->x[2])? 1: 2); int ytile = (y < tile_info->y[1])? 0: ((y < tile_info->y[2])? 1: 2); int tile = ytile*3+xtile; - ccl_global float *center_buffer = ((ccl_global float*) tile_info->buffers[tile]) + (tile_info->offsets[tile] + y*tile_info->strides[tile] + x)*buffer_pass_stride + buffer_denoising_offset; + ccl_global float *center_buffer = ((ccl_global float*) ccl_get_tile_buffer(tile)) + (tile_info->offsets[tile] + y*tile_info->strides[tile] + x)*buffer_pass_stride + buffer_denoising_offset; int buffer_w = align_up(rect.z - rect.x, 4); int idx = (y-rect.y)*buffer_w + (x - rect.x); diff --git a/intern/cycles/kernel/kernels/opencl/filter.cl b/intern/cycles/kernel/kernels/opencl/filter.cl index d553ee6833c..3c75754fb39 100644 --- a/intern/cycles/kernel/kernels/opencl/filter.cl +++ b/intern/cycles/kernel/kernels/opencl/filter.cl @@ -23,7 +23,7 @@ /* kernels */ __kernel void kernel_ocl_filter_divide_shadow(int sample, - ccl_global TileInfo *tile_info, + CCL_FILTER_TILE_INFO, ccl_global float *unfilteredA, ccl_global float *unfilteredB, ccl_global float *sampleVariance, @@ -37,7 +37,7 @@ __kernel void kernel_ocl_filter_divide_shadow(int sample, int y = prefilter_rect.y + get_global_id(1); if(x < prefilter_rect.z && y < prefilter_rect.w) { kernel_filter_divide_shadow(sample, - tiles, + CCL_FILTER_TILE_INFO_ARG, x, y, unfilteredA, unfilteredB, @@ -51,7 +51,7 @@ __kernel void kernel_ocl_filter_divide_shadow(int sample, } __kernel void kernel_ocl_filter_get_feature(int sample, - ccl_global TileInfo *tile_info, + CCL_FILTER_TILE_INFO, int m_offset, int v_offset, ccl_global float *mean, @@ -64,7 +64,7 @@ __kernel void kernel_ocl_filter_get_feature(int sample, int y = prefilter_rect.y + get_global_id(1); if(x < prefilter_rect.z && y < prefilter_rect.w) { kernel_filter_get_feature(sample, - tiles, + CCL_FILTER_TILE_INFO_ARG, m_offset, v_offset, x, y, mean, variance, @@ -276,27 +276,3 @@ __kernel void kernel_ocl_filter_finalize(ccl_global float *buffer, buffer_params, sample); } } - -__kernel void kernel_ocl_filter_set_tile_info(ccl_global TileInfo* tile_info, - ccl_global float *buffer_1, - ccl_global float *buffer_2, - ccl_global float *buffer_3, - ccl_global float *buffer_4, - ccl_global float *buffer_5, - ccl_global float *buffer_6, - ccl_global float *buffer_7, - ccl_global float *buffer_8, - ccl_global float *buffer_9) -{ - if((get_global_id(0) == 0) && (get_global_id(1) == 0)) { - tile_info->buffers[0] = buffer_1; - tile_info->buffers[1] = buffer_2; - tile_info->buffers[2] = buffer_3; - tile_info->buffers[3] = buffer_4; - tile_info->buffers[4] = buffer_5; - tile_info->buffers[5] = buffer_6; - tile_info->buffers[6] = buffer_7; - tile_info->buffers[7] = buffer_8; - tile_info->buffers[8] = buffer_9; - } -} -- cgit v1.2.3 From 60b9d413dbf1afc24b428dbe3bfea4bc0ec164c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 4 Jul 2018 12:45:30 +0200 Subject: Pass copy flag to modifier copyData function This will allow modifiers to decide whether to copy or share caches between ModifierData copies. --- source/blender/blenkernel/BKE_modifier.h | 6 ++++-- source/blender/blenkernel/intern/modifier.c | 4 ++-- source/blender/modifiers/intern/MOD_armature.c | 4 ++-- source/blender/modifiers/intern/MOD_cloth.c | 2 +- source/blender/modifiers/intern/MOD_correctivesmooth.c | 4 ++-- source/blender/modifiers/intern/MOD_dynamicpaint.c | 2 +- source/blender/modifiers/intern/MOD_explode.c | 4 ++-- source/blender/modifiers/intern/MOD_fluidsim.c | 2 +- source/blender/modifiers/intern/MOD_hook.c | 4 ++-- source/blender/modifiers/intern/MOD_laplaciandeform.c | 4 ++-- source/blender/modifiers/intern/MOD_meshdeform.c | 4 ++-- source/blender/modifiers/intern/MOD_meshsequencecache.c | 4 ++-- source/blender/modifiers/intern/MOD_ocean.c | 2 +- source/blender/modifiers/intern/MOD_particlesystem.c | 4 ++-- source/blender/modifiers/intern/MOD_smoke.c | 2 +- source/blender/modifiers/intern/MOD_subsurf.c | 4 ++-- source/blender/modifiers/intern/MOD_surfacedeform.c | 4 ++-- source/blender/modifiers/intern/MOD_warp.c | 4 ++-- source/blender/modifiers/intern/MOD_weightvgedit.c | 4 ++-- 19 files changed, 35 insertions(+), 33 deletions(-) diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index c9f724a9bc4..987bb59cba3 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -162,8 +162,10 @@ typedef struct ModifierTypeInfo { /* Copy instance data for this modifier type. Should copy all user * level settings to the target modifier. + * + * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ - void (*copyData)(const struct ModifierData *md, struct ModifierData *target); + void (*copyData)(const struct ModifierData *md, struct ModifierData *target, const int flag); /********************* Deform modifier functions *********************/ /* DEPRECATED */ @@ -387,7 +389,7 @@ void modifier_free(struct ModifierData *md); bool modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md); -void modifier_copyData_generic(const struct ModifierData *md, struct ModifierData *target); +void modifier_copyData_generic(const struct ModifierData *md, struct ModifierData *target, const int flag); void modifier_copyData(struct ModifierData *md, struct ModifierData *target); void modifier_copyData_ex(struct ModifierData *md, struct ModifierData *target, const int flag); bool modifier_dependsOnTime(struct ModifierData *md); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 4c2a58e7126..b877a08b6cf 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -293,7 +293,7 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData) /* callback's can use this * to avoid copying every member. */ -void modifier_copyData_generic(const ModifierData *md_src, ModifierData *md_dst) +void modifier_copyData_generic(const ModifierData *md_src, ModifierData *md_dst, const int UNUSED(flag)) { const ModifierTypeInfo *mti = modifierType_getInfo(md_src->type); @@ -326,7 +326,7 @@ void modifier_copyData_ex(ModifierData *md, ModifierData *target, const int flag target->flag = md->flag; if (mti->copyData) { - mti->copyData(md, target); + mti->copyData(md, target, flag); } if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 09ba865cce3..a069b261067 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -64,14 +64,14 @@ static void initData(ModifierData *md) amd->deformflag = ARM_DEF_VGROUP; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { #if 0 const ArmatureModifierData *amd = (const ArmatureModifierData *) md; #endif ArmatureModifierData *tamd = (ArmatureModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); tamd->prevCos = NULL; } diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 58979fa201b..34f571f5e30 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -155,7 +155,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag)) { const ClothModifierData *clmd = (const ClothModifierData *) md; ClothModifierData *tclmd = (ClothModifierData *) target; diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index 879b07de6d9..d59360896e8 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -80,12 +80,12 @@ static void initData(ModifierData *md) } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { const CorrectiveSmoothModifierData *csmd = (const CorrectiveSmoothModifierData *)md; CorrectiveSmoothModifierData *tcsmd = (CorrectiveSmoothModifierData *)target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); if (csmd->bind_coords) { tcsmd->bind_coords = MEM_dupallocN(csmd->bind_coords); diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 9131bc0659f..61219096b43 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -57,7 +57,7 @@ static void initData(ModifierData *md) pmd->type = MOD_DYNAMICPAINT_TYPE_CANVAS; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag)) { const DynamicPaintModifierData *pmd = (const DynamicPaintModifierData *)md; DynamicPaintModifierData *tpmd = (DynamicPaintModifierData *)target; diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 948aaf0751e..04bfe96bc59 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -70,14 +70,14 @@ static void freeData(ModifierData *md) MEM_SAFE_FREE(emd->facepa); } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { #if 0 const ExplodeModifierData *emd = (const ExplodeModifierData *) md; #endif ExplodeModifierData *temd = (ExplodeModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); temd->facepa = NULL; } diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index ffa74be0b33..272cc5c17f4 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -65,7 +65,7 @@ static void freeData(ModifierData *md) fluidsim_free(fluidmd); } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag)) { const FluidsimModifierData *fluidmd = (const FluidsimModifierData *) md; FluidsimModifierData *tfluidmd = (FluidsimModifierData *) target; diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index a5013bb38c6..4b34bdd2c16 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -63,12 +63,12 @@ static void initData(ModifierData *md) hmd->flag = 0; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { const HookModifierData *hmd = (const HookModifierData *) md; HookModifierData *thmd = (HookModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); thmd->curfalloff = curvemapping_copy(hmd->curfalloff); diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index e5b96c633f7..0224d412ba6 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -704,12 +704,12 @@ static void initData(ModifierData *md) lmd->flag = 0; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { const LaplacianDeformModifierData *lmd = (const LaplacianDeformModifierData *)md; LaplacianDeformModifierData *tlmd = (LaplacianDeformModifierData *)target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); tlmd->vertexco = MEM_dupallocN(lmd->vertexco); tlmd->cache_system = NULL; diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index af37b30b7aa..05e1568f780 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -81,12 +81,12 @@ static void freeData(ModifierData *md) if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */ } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { const MeshDeformModifierData *mmd = (const MeshDeformModifierData *) md; MeshDeformModifierData *tmmd = (MeshDeformModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); if (mmd->bindinfluences) tmmd->bindinfluences = MEM_dupallocN(mmd->bindinfluences); if (mmd->bindoffsets) tmmd->bindoffsets = MEM_dupallocN(mmd->bindoffsets); diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c index a6c9f865e4c..fd8676d6653 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.c +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c @@ -55,14 +55,14 @@ static void initData(ModifierData *md) mcmd->read_flag = MOD_MESHSEQ_READ_ALL; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { #if 0 const MeshSeqCacheModifierData *mcmd = (const MeshSeqCacheModifierData *)md; #endif MeshSeqCacheModifierData *tmcmd = (MeshSeqCacheModifierData *)target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); tmcmd->reader = NULL; } diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 702e557ccb1..58454782b2e 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -163,7 +163,7 @@ static void freeData(ModifierData *md) #endif /* WITH_OCEANSIM */ } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag)) { #ifdef WITH_OCEANSIM #if 0 diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 1821a0fced0..6f9a44cd9e6 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -79,14 +79,14 @@ static void freeData(ModifierData *md) psmd->psys->flag |= PSYS_DELETE; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { #if 0 const ParticleSystemModifierData *psmd = (const ParticleSystemModifierData *) md; #endif ParticleSystemModifierData *tpsmd = (ParticleSystemModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); tpsmd->mesh_final = NULL; tpsmd->mesh_original = NULL; diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index e81c760ed67..9a27f31adaa 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -71,7 +71,7 @@ static void initData(ModifierData *md) smd->time = -1; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag)) { const SmokeModifierData *smd = (const SmokeModifierData *)md; SmokeModifierData *tsmd = (SmokeModifierData *)target; diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 3de04e878ac..5a5b596eaab 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -65,14 +65,14 @@ static void initData(ModifierData *md) smd->flags |= eSubsurfModifierFlag_SubsurfUv; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { #if 0 const SubsurfModifierData *smd = (const SubsurfModifierData *) md; #endif SubsurfModifierData *tsmd = (SubsurfModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); tsmd->emCache = tsmd->mCache = NULL; } diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index a3ab2d74602..0c58d47d53f 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -136,12 +136,12 @@ static void freeData(ModifierData *md) } } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { const SurfaceDeformModifierData *smd = (const SurfaceDeformModifierData *)md; SurfaceDeformModifierData *tsmd = (SurfaceDeformModifierData *)target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); if (smd->verts) { tsmd->verts = MEM_dupallocN(smd->verts); diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 54f8ce8c515..69bf44d8b68 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -65,12 +65,12 @@ static void initData(ModifierData *md) wmd->flag = 0; } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { const WarpModifierData *wmd = (const WarpModifierData *) md; WarpModifierData *twmd = (WarpModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); twmd->curfalloff = curvemapping_copy(wmd->curfalloff); } diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index a26cb73d823..a2f9319ad51 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -81,12 +81,12 @@ static void freeData(ModifierData *md) curvemapping_free(wmd->cmap_curve); } -static void copyData(const ModifierData *md, ModifierData *target) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { const WeightVGEditModifierData *wmd = (const WeightVGEditModifierData *) md; WeightVGEditModifierData *twmd = (WeightVGEditModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve); } -- cgit v1.2.3 From 175fe29e58156da93e484c25aa6f5767a46106f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 4 Jul 2018 12:46:03 +0200 Subject: Cloth simulation: share point cache between CoW copies of objects --- source/blender/makesdna/DNA_modifier_types.h | 6 ++++++ source/blender/modifiers/intern/MOD_cloth.c | 23 ++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 712958deca1..49d72eddd09 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -119,6 +119,8 @@ typedef struct ModifierData { typedef enum { /* This modifier has been inserted in local override, and hence can be fully edited. */ eModifierFlag_StaticOverride_Local = (1 << 0), + /* This modifier does not own its caches, but instead shares them with another modifier. */ + eModifierFlag_SharedCaches = (1 << 1), } ModifierFlag; typedef enum { @@ -608,8 +610,12 @@ typedef struct ClothModifierData { struct Cloth *clothObject; /* The internal data structure for cloth. */ struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */ struct ClothCollSettings *coll_parms; /* definition is in DNA_cloth_types.h */ + + /* PointCache can be shared with other instances of ClothModifierData. + * Inspect (modifier.flag & eModifierFlag_SharedCaches) to find out. */ struct PointCache *point_cache; /* definition is in DNA_object_force_types.h */ struct ListBase ptcaches; + /* XXX nasty hack, remove once hair can be separated from cloth modifier data */ struct ClothHairData *hairdata; /* grid geometry values of hair continuum */ diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 34f571f5e30..53e71bfc1a4 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -42,6 +42,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_cloth.h" @@ -155,7 +156,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag)) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { const ClothModifierData *clmd = (const ClothModifierData *) md; ClothModifierData *tclmd = (ClothModifierData *) target; @@ -170,14 +171,21 @@ static void copyData(const ModifierData *md, ModifierData *target, const int UNU MEM_freeN(tclmd->coll_parms); BKE_ptcache_free_list(&tclmd->ptcaches); - tclmd->point_cache = NULL; + if (flag & LIB_ID_CREATE_NO_MAIN) { + /* Share the cache with the original object's modifier. */ + tclmd->modifier.flag |= eModifierFlag_SharedCaches; + tclmd->ptcaches = clmd->ptcaches; + tclmd->point_cache = clmd->point_cache; + } + else { + tclmd->point_cache = BKE_ptcache_add(&tclmd->ptcaches); + tclmd->point_cache->step = 1; + } tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms); if (clmd->sim_parms->effector_weights) tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights); tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms); - tclmd->point_cache = BKE_ptcache_add(&tclmd->ptcaches); - tclmd->point_cache->step = 1; tclmd->clothObject = NULL; tclmd->hairdata = NULL; tclmd->solver_result = NULL; @@ -206,7 +214,12 @@ static void freeData(ModifierData *md) if (clmd->coll_parms) MEM_freeN(clmd->coll_parms); - BKE_ptcache_free_list(&clmd->ptcaches); + if (md->flag & eModifierFlag_SharedCaches) { + BLI_listbase_clear(&clmd->ptcaches); + } + else { + BKE_ptcache_free_list(&clmd->ptcaches); + } clmd->point_cache = NULL; if (clmd->hairdata) -- cgit v1.2.3 From d663ec48c06a083de74e90dd9c605e98b28baa37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 4 Jul 2018 15:10:45 +0200 Subject: Fluid Sim: Removed unused PointCache pointer The only uses were setting it to NULL and asserting it is NULL. --- source/blender/makesdna/DNA_modifier_types.h | 1 - source/blender/modifiers/intern/MOD_fluidsim.c | 5 ----- source/blender/modifiers/intern/MOD_fluidsim_util.c | 4 ---- 3 files changed, 10 deletions(-) diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 49d72eddd09..42b22e45495 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -815,7 +815,6 @@ typedef struct FluidsimModifierData { ModifierData modifier; struct FluidsimSettings *fss; /* definition is in DNA_object_fluidsim_types.h */ - struct PointCache *point_cache; /* definition is in DNA_object_force_types.h */ } FluidsimModifierData; typedef struct ShrinkwrapModifierData { diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index 272cc5c17f4..6e322dc7016 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -76,11 +76,6 @@ static void copyData(const ModifierData *md, ModifierData *target, const int UNU tfluidmd->fss->meshVelocities = MEM_dupallocN(tfluidmd->fss->meshVelocities); } } - - /* Seems to never be used, but for sqke of consistency... */ - BLI_assert(fluidmd->point_cache == NULL); - BLI_assert(tfluidmd->point_cache == NULL); - tfluidmd->point_cache = NULL; } diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index cea9e69526c..ed5d08a95d4 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -160,10 +160,6 @@ void fluidsim_free(FluidsimModifierData *fluidmd) MEM_SAFE_FREE(fluidmd->fss); } - /* Seems to never be used, but for sqke of consistency... */ - BLI_assert(fluidmd->point_cache == NULL); - fluidmd->point_cache = NULL; - return; } -- cgit v1.2.3 From fd341dd6f74e7145d5df725170e886f0f3ef51b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 4 Jul 2018 15:15:08 +0200 Subject: Added copyData flag to ocean modifier --- source/blender/modifiers/intern/MOD_ocean.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 58454782b2e..e9dc7e068ca 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -163,7 +163,7 @@ static void freeData(ModifierData *md) #endif /* WITH_OCEANSIM */ } -static void copyData(const ModifierData *md, ModifierData *target, const int UNUSED(flag)) +static void copyData(const ModifierData *md, ModifierData *target, const int flag) { #ifdef WITH_OCEANSIM #if 0 @@ -171,7 +171,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int UNU #endif OceanModifierData *tomd = (OceanModifierData *) target; - modifier_copyData_generic(md, target); + modifier_copyData_generic(md, target, flag); tomd->refresh = 0; @@ -186,6 +186,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int UNU /* unused */ (void)md; (void)target; + (void)flag; #endif /* WITH_OCEANSIM */ } -- cgit v1.2.3 From 1545657d7a496e417a6ccff99f4b633ad9b0f5d8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 15:35:33 +0200 Subject: Cleanup: remove unused zbuf member --- source/blender/makesdna/DNA_view3d_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index d78c731764e..70f06b2eda0 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -238,7 +238,7 @@ typedef struct View3D { short flag3; /* drawflags, denoting state */ - char zbuf DNA_DEPRECATED; + char _pad2; char transp, xray; char multiview_eye; /* multiview current eye - for internal use */ -- cgit v1.2.3 From f03079eff0d2c43552872f7ee1c51be4d86a0729 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 4 Jul 2018 15:37:36 +0200 Subject: UI: Fix channels using editor header color as background Channels were using TH_HEADER which is usually gray and unrelated to channels list. Use sub channel color instead (light blue in the default theme). --- source/blender/editors/animation/anim_channels_defines.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index f0bde9dcdfb..6bd333294c5 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -223,7 +223,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa else { // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)? int colOfs = 20 - 20 * indent; - UI_GetThemeColorShade3fv(TH_HEADER, colOfs, r_color); + UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, colOfs, r_color); } } -- cgit v1.2.3 From a232b4926f94a0412375f7fca246f7d1f65ff1d2 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 4 Jul 2018 15:39:26 +0200 Subject: UI: Default theme tweaks to animation channels --- release/datafiles/userdef/userdef_default_theme.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 58defc4f17a..30b80863585 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -410,7 +410,7 @@ const bTheme U_theme_default = { .button_text_hi = RGBA(0xffffffff), .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xffffffff), - .list_text = RGBA(0xccccccff), + .list_text = RGBA(0x000000ff), .list_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -422,8 +422,8 @@ const bTheme U_theme_default = { .shade1 = RGBA(0x96969600), .shade2 = RGBA(0x2e2e2e64), .grid = RGBA(0x1a1a1aff), - .group = RGBA(0x247f0dff), - .group_active = RGBA(0x46a431ff), + .group = RGBA(0x44992eff), + .group_active = RGBA(0x5ccd3eff), .vertex_select = RGBA(0xff8500ff), .cframe = RGBA(0x308837ff), .lastsel_point = RGBA(0xffffffff), @@ -435,8 +435,8 @@ const bTheme U_theme_default = { .handle_sel_vect = RGBA(0x40c030ff), .handle_sel_align = RGBA(0xf090a0ff), .handle_sel_auto_clamped = RGBA(0xf0af90ff), - .ds_channel = RGBA(0x26537fff), - .ds_subchannel = RGBA(0x6a90b2ff), + .ds_channel = RGBA(0x5a85b2ff), + .ds_subchannel = RGBA(0x7d98b3ff), .vertex_size = 6, .outline_width = 1, .facedot_size = 4, @@ -497,7 +497,7 @@ const bTheme U_theme_default = { .button_text_hi = RGBA(0xffffffff), .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xd8d8d8ff), - .list_text = RGBA(0xffffffff), + .list_text = RGBA(0x000000ff), .list_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -510,13 +510,13 @@ const bTheme U_theme_default = { .shade2 = RGBA(0x70707064), .hilite = RGBA(0x60c040ff), .grid = RGBA(0x272727ff), - .group = RGBA(0x278c0eff), - .group_active = RGBA(0x4eb335ff), + .group = RGBA(0x44992eff), + .group_active = RGBA(0x5ccd3eff), .strip = RGBA(0x1a151580), .strip_select = RGBA(0xff8c00ff), .cframe = RGBA(0x308837ff), - .ds_channel = RGBA(0x2e6399ff), - .ds_subchannel = RGBA(0x5a7996ff), + .ds_channel = RGBA(0x5a85b2ff), + .ds_subchannel = RGBA(0x7d98b3ff), .keytype_keyframe = RGBA(0xe8e8e8ff), .keytype_extreme = RGBA(0xe8b3ccff), .keytype_breakdown = RGBA(0xb3dbe8ff), @@ -532,7 +532,7 @@ const bTheme U_theme_default = { .facedot_size = 4, .keyframe_scale_fac = 1.0f, .handle_vertex_size = 4, - .anim_active = RGBA(0x66310066), + .anim_active = RGBA(0xa14d0066), }, .tnla = { .back = RGBA(0x35353500), -- cgit v1.2.3 From c76752372784ce44d1647df77109b2813bdd67eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 4 Jul 2018 15:40:56 +0200 Subject: Eevee: Fix incorrect padding in octahedral mapping This fixes T54439 --- source/blender/draw/engines/eevee/eevee_lightprobes.c | 15 +-------------- .../eevee/shaders/lightprobe_filter_diffuse_frag.glsl | 3 +-- .../eevee/shaders/lightprobe_filter_glossy_frag.glsl | 3 +-- .../eevee/shaders/lightprobe_filter_visibility_frag.glsl | 3 +-- .../draw/engines/eevee/shaders/octahedron_lib.glsl | 3 +-- 5 files changed, 5 insertions(+), 22 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 346938b19f8..0b97496700a 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -1091,20 +1091,7 @@ static void glossy_filter_probe( float bias = (i == 0) ? -1.0f : 1.0f; pinfo->texel_size = 1.0f / mipsize; pinfo->padding_size = powf(2.0f, (float)(maxlevel - min_lod_level - 1 - i)); - /* XXX : WHY THE HECK DO WE NEED THIS ??? */ - /* padding is incorrect without this! float precision issue? */ - if (pinfo->padding_size > 32) { - pinfo->padding_size += 5; - } - if (pinfo->padding_size > 16) { - pinfo->padding_size += 4; - } - else if (pinfo->padding_size > 8) { - pinfo->padding_size += 2; - } - else if (pinfo->padding_size > 4) { - pinfo->padding_size += 1; - } + pinfo->padding_size *= pinfo->texel_size; pinfo->layer = probe_idx; pinfo->roughness = (float)i / ((float)maxlevel - 4.0f); pinfo->roughness *= pinfo->roughness; /* Disney Roughness */ diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl index 14fd6d3dff5..7cf4259a938 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl @@ -131,8 +131,7 @@ void main() /* Add a N pixel border to ensure filtering is correct * for N mipmap levels. */ - uvs += uvs * texelSize * paddingSize * 2.0; - uvs -= texelSize * paddingSize; + uvs = (uvs - texelSize * paddingSize) / (1.0 - 2.0 * texelSize * paddingSize); /* edge mirroring : only mirror if directly adjacent * (not diagonally adjacent) */ diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl index e4199e6a5ed..bb23051b7e5 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl @@ -30,8 +30,7 @@ void main() { /* Add a N pixel border to ensure filtering is correct * for N mipmap levels. */ - uvs += uvs * texelSize * paddingSize * 2.0; - uvs -= texelSize * paddingSize; + uvs = (uvs - paddingSize) / (1.0 - 2.0 * paddingSize); /* edge mirroring : only mirror if directly adjacent * (not diagonally adjacent) */ diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl index 211fa8f0ce8..083d2313337 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl @@ -49,8 +49,7 @@ void main() cos.xy = (vec2(texel) + 0.5) * storedTexelSize; /* add a 2 pixel border to ensure filtering is correct */ - cos.xy *= 1.0 + storedTexelSize * 2.0; - cos.xy -= storedTexelSize; + cos.xy = (cos.xy - storedTexelSize) / (1.0 - 2.0 * storedTexelSize); float pattern = 1.0; diff --git a/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl b/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl index 631b325ae37..ec13c885bbb 100644 --- a/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl @@ -13,8 +13,7 @@ vec2 mapping_octahedron(vec3 cubevec, vec2 texel_size) vec2 uvs = cubevec.xy * (0.5) + 0.5; /* edge filtering fix */ - uvs *= 1.0 - 2.0 * texel_size; - uvs += texel_size; + uvs = (1.0 - 2.0 * texel_size) * uvs + texel_size; return uvs; } -- cgit v1.2.3 From 03ff3aebc4e12a5274644e5595c8995fc2fc8638 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 16:27:23 +0200 Subject: Weight Paint: draw from original mesh Selection changes weren't showing. --- source/blender/draw/modes/paint_weight_mode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index 2b510a9a4c9..14fae743d8c 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -38,6 +38,8 @@ #include "BKE_mesh.h" +#include "DEG_depsgraph_query.h" + extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */ extern struct GlobalsUboStorage ts; /* draw_common.c */ @@ -181,6 +183,8 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob) const View3D *v3d = draw_ctx->v3d; if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) { + /* We're always painting on original, display original data. */ + ob = DEG_get_original_object(ob); const Mesh *me = ob->data; const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; const bool use_surface = v3d->overlay.weight_paint_mode_opacity != 0.0f; -- cgit v1.2.3 From 4bbbfdb26ab22797e99039274a5b2c5a401e7be0 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 4 Jul 2018 16:33:39 +0200 Subject: UI: Default Theme: editor tabs more prominent Workaround for now until all editors tabs share the dedicated Tab theme settings under User Interface (which the top bar is currently using). Thanks SimonStorl-Schulke from devtalk forum for feedback. --- release/datafiles/userdef/userdef_default_theme.c | 130 +++++++++++----------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 30b80863585..78908fc4358 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -253,13 +253,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x42424200), @@ -279,13 +279,13 @@ const bTheme U_theme_default = { .header = RGBA(0x42424200), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), .button = RGBA(0x35353500), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -372,13 +372,13 @@ const bTheme U_theme_default = { .header = RGBA(0x2e2e2eff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -400,13 +400,13 @@ const bTheme U_theme_default = { .header = RGBA(0x2e2e2eff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xffffffff), @@ -451,13 +451,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -487,13 +487,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xd8d8d8ff), @@ -542,13 +542,13 @@ const bTheme U_theme_default = { .header = RGBA(0x212121ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xffffffff), @@ -591,13 +591,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -635,13 +635,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -691,13 +691,13 @@ const bTheme U_theme_default = { .header = RGBA(0x42424200), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x42424200), @@ -729,13 +729,13 @@ const bTheme U_theme_default = { .header = RGBA(0x454545ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -763,13 +763,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .list = RGBA(0x2e2e2eff), .list_title = RGBA(0xffffffff), @@ -819,13 +819,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x42424200), @@ -846,13 +846,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -879,13 +879,13 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .list = RGBA(0x666666ff), .list_text_hi = RGBA(0xffffffff), @@ -925,13 +925,13 @@ const bTheme U_theme_default = { .header = RGBA(0x232323ff), .header_text = RGBA(0xeeeeeeff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), - .button = RGBA(0x35353599), + .button = RGBA(0x424242ff), .button_title = RGBA(0xffffffff), - .button_text = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { .header = RGBA(0x424242cc), @@ -953,8 +953,8 @@ const bTheme U_theme_default = { .header = RGBA(0x303030ff), .header_text = RGBA(0xaaaaaaff), .header_text_hi = RGBA(0xffffffff), - .tab_active = RGBA(0x4b4b4bff), - .tab_inactive = RGBA(0x323232ff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), .tab_back = RGBA(0x232323ff), .tab_outline = RGBA(0x2d2d2dff), .button = RGBA(0x353535ff), -- cgit v1.2.3 From 56ace4b2099da3e26e864b41fa4594499ba2bbc2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 4 Jul 2018 16:41:37 +0200 Subject: Depsgraph: Log entry operations which are directly modified and tagged --- source/blender/depsgraph/intern/eval/deg_eval_flush.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index e9f11f8e089..bd31931d0a9 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -140,6 +140,9 @@ BLI_INLINE void flush_schedule_entrypoints(Depsgraph *graph, FlushQueue *queue) { queue->push_back(op_node); op_node->scheduled = true; + DEG_DEBUG_PRINTF((::Depsgraph *)graph, + EVAL, "Operation is entry point for update: %s\n", + op_node->identifier().c_str()); } GSET_FOREACH_END(); } -- cgit v1.2.3 From 7c47b338c0e039c4dbcbc35ef682b55aaa0ef871 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 4 Jul 2018 16:43:00 +0200 Subject: Depsgraph: Don't force copy-on-write when shading changes Shading is supposed to be dealing with draw manager batch cached thingamajigs, but was causing full object update. This was causing both flickering in sculpt mode (PBVH was removed, why it was SOMETIMES restored before draw is a mystery), and was also causing things to be really slow. --- source/blender/depsgraph/intern/nodes/deg_node_component.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h index 5e79dc1c685..e4a77f2e72b 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h @@ -189,7 +189,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles); DEG_COMPONENT_NODE_DECLARE_GENERIC(Proxy); DEG_COMPONENT_NODE_DECLARE_GENERIC(Pose); DEG_COMPONENT_NODE_DECLARE_GENERIC(Sequencer); -DEG_COMPONENT_NODE_DECLARE_GENERIC(Shading); +DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(Shading); DEG_COMPONENT_NODE_DECLARE_GENERIC(ShadingParameters); DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform); DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer); -- cgit v1.2.3 From 49fdf0b946869932a04e816986d1577b924cfb99 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 17:10:41 +0200 Subject: Keymap: Resolve inconsistencies, T55162 --- source/blender/editors/armature/armature_ops.c | 2 +- source/blender/editors/mesh/mesh_ops.c | 4 ++++ source/blender/editors/uvedit/uvedit_ops.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 07db63e6dc7..8ea03fa242d 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -359,7 +359,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "POSE_OT_select_mirror", FKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + WM_keymap_add_item(keymap, "POSE_OT_select_mirror", MKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index dc3ee4cbb53..910076011d4 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -406,6 +406,8 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0); #endif + WM_keymap_add_item(keymap, "MESH_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); /* hide */ @@ -512,7 +514,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_vertices", VKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_vertex_group_remove_from", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); #ifdef USE_WM_KEYMAP_27X /* useful stuff from object-mode */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 9701f920706..faccb44767f 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -4463,7 +4463,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "clear", true); /* unwrap */ - WM_keymap_add_item(keymap, "UV_OT_unwrap", EKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "UV_OT_unwrap", UKEY, KM_PRESS, 0, 0); #ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "UV_OT_minimize_stretch", VKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "UV_OT_pack_islands", PKEY, KM_PRESS, KM_CTRL, 0); -- cgit v1.2.3 From 46d8aa6d944a097a453f4de778ae860dcd5e2a73 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 4 Jul 2018 17:24:10 +0200 Subject: UI: Default theme tweaks for Node editor --- release/datafiles/userdef/userdef_default_theme.c | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 78908fc4358..04a34cfd1ae 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -756,7 +756,7 @@ const bTheme U_theme_default = { .facedot_size = 4, }, .tnode = { - .back = RGBA(0x32323200), + .back = RGBA(0x23232300), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), @@ -784,31 +784,32 @@ const bTheme U_theme_default = { }, .shade2 = RGBA(0x7f707064), .wire = RGBA(0x808080ff), - .select = RGBA(0x099be6ff), + .select = RGBA(0xed5700ff), .active = RGBA(0xffffffff), .edge_select = RGBA(0xffffffff), - .console_output = RGBA(0xdfc300ff), + .console_output = RGBA(0x1a1a1aff), .vertex_size = 3, .outline_width = 1, .facedot_size = 4, - .syntaxl = RGBA(0x666666ff), - .syntaxs = RGBA(0x977474ff), - .syntaxb = RGBA(0xffcb4dff), - .syntaxn = RGBA(0xff6675ff), + .syntaxl = RGBA(0x565656ff), + .syntaxs = RGBA(0x975b5bff), + .syntaxb = RGBA(0xccb83dff), + .syntaxn = RGBA(0xe64555ff), .syntaxv = RGBA(0x66c4ffff), - .syntaxc = RGBA(0x59b36aff), + .syntaxc = RGBA(0x49b300ff), .syntaxd = RGBA(0x749797ff), .syntaxr = RGBA(0x808080ff), - .nodeclass_output = RGBA(0xff6675ff), - .nodeclass_filter = RGBA(0x6c696fff), - .nodeclass_vector = RGBA(0x9999ffff), - .nodeclass_texture = RGBA(0xffc399ff), - .nodeclass_shader = RGBA(0xa7ff99ff), - .nodeclass_script = RGBA(0x6c696fff), + .nodeclass_output = RGBA(0xb33641ff), + .nodeclass_filter = RGBA(0x584d80ff), + .nodeclass_vector = RGBA(0x9b80ffff), + .nodeclass_texture = RGBA(0xe68745ff), + .nodeclass_shader = RGBA(0x39bf6dff), + .nodeclass_script = RGBA(0x084d4dff), .nodeclass_pattern = RGBA(0x6c696fff), .nodeclass_layout = RGBA(0x6c696fff), .movie = RGBA(0x9b9b9ba0), .gp_vertex_size = 3, + .gp_vertex = RGBA(0x97979700), .gp_vertex_select = RGBA(0xff8500ff), }, .tuserpref = { -- cgit v1.2.3 From 7e0ceb2ff63b65c790476d880e6b6cedd0c9fb5a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 17:25:58 +0200 Subject: Keymap: outliner changes from T55162 --- source/blender/editors/space_outliner/outliner_ops.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 099cff7e5d6..b061e8537c2 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -552,8 +552,9 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ANIM_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_keyframe_delete", IKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0); + /* Note: was D, Alt-D, keep these free for duplicate. */ + WM_keymap_add_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "OUTLINER_OT_collection_new", CKEY, KM_PRESS, 0, 0); -- cgit v1.2.3 From 1df1514d313676d3210f72a4e3e85cb5d24690a4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 17:48:09 +0200 Subject: Kemap: mirror, flip changes from T55162 --- source/blender/editors/lattice/lattice_ops.c | 2 +- source/blender/editors/space_action/action_ops.c | 2 +- source/blender/editors/space_graph/graph_ops.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/lattice/lattice_ops.c b/source/blender/editors/lattice/lattice_ops.c index a04da538b03..e7d9fc146ce 100644 --- a/source/blender/editors/lattice/lattice_ops.c +++ b/source/blender/editors/lattice/lattice_ops.c @@ -72,7 +72,7 @@ void ED_keymap_lattice(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "LATTICE_OT_flip", FKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "LATTICE_OT_flip", FKEY, KM_PRESS, KM_ALT, 0); /* menus */ WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 2f2e8c6f49f..5b1250e1cde 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -210,7 +210,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* menu + single-step transform */ WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0); /* menu + set setting */ WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 5e269a9c99d..80aba98104a 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -600,7 +600,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* menu + single-step transform */ WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_handle_type", VKEY, KM_PRESS, 0, 0); -- cgit v1.2.3 From a8b5658437a690977904bf3259ae82afcaaa478f Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 4 Jul 2018 18:00:03 +0200 Subject: UI: Node Link Menu to use same colors as regular menus Node link menus (like shader settings in Material properties) used a slightly brighter variant of the menu widget. Making it hard to style and match the rest. Make it use widget_menuiconbut, which is just the menu widget with an icon and no arrows. Thanks Brecht for the help! --- .../blender/editors/interface/interface_widgets.c | 30 +--------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index d5e152ccc79..19aff48e2c1 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -3458,30 +3458,6 @@ static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat widgetbase_draw(&wtb, wcol); } -static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) -{ - /* silly node link button hacks */ - uiWidgetBase wtb; - uiWidgetColors wcol_backup = *wcol; - float rad; - - widget_init(&wtb); - - rad = wcol->roundness * U.widget_unit; - round_box_edges(&wtb, roundboxalign, rect, rad); - - wcol->inner[0] = min_ii(wcol->inner[0] + 15, 255); - wcol->inner[1] = min_ii(wcol->inner[1] + 15, 255); - wcol->inner[2] = min_ii(wcol->inner[2] + 15, 255); - wcol->outline[0] = min_ii(wcol->outline[0] + 15, 255); - wcol->outline[1] = min_ii(wcol->outline[1] + 15, 255); - wcol->outline[2] = min_ii(wcol->outline[2] + 15, 255); - - /* decoration */ - widgetbase_draw(&wtb, wcol); - *wcol = wcol_backup; -} - static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { float back[4]; @@ -3882,6 +3858,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) break; case UI_WTYPE_MENU_ICON_RADIO: + case UI_WTYPE_MENU_NODE_LINK: wt.wcol_theme = &btheme->tui.wcol_menu; wt.draw = widget_menuiconbut; break; @@ -3891,11 +3868,6 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) wt.draw = widget_menubut; break; - case UI_WTYPE_MENU_NODE_LINK: - wt.wcol_theme = &btheme->tui.wcol_menu; - wt.draw = widget_menunodebut; - break; - case UI_WTYPE_PULLDOWN: wt.wcol_theme = &btheme->tui.wcol_pulldown; wt.draw = widget_pulldownbut; -- cgit v1.2.3 From 59415598e42787ac16a180754233e25b6f3bddbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 4 Jul 2018 18:07:34 +0200 Subject: Fix Pose Mode selection overlay breaking other overlay. Fix T55758 --- source/blender/draw/modes/pose_mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index ad9567cd9c0..84c3bff406a 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -87,7 +87,7 @@ static bool POSE_is_bone_selection_overlay_active(void) { const DRWContextState *dcs = DRW_context_state_get(); const View3D *v3d = dcs->v3d; - return v3d && (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECTION); + return v3d && (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECTION) && OBPOSE_FROM_OBACT(dcs->obact); } static void POSE_engine_init(void *UNUSED(vedata)) -- cgit v1.2.3 From 54fba73812fe71e2087a0cdd3c819ae06c3f8ef9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 18:04:45 +0200 Subject: Keymap: proportional edit keys --- source/blender/editors/space_action/action_ops.c | 2 +- source/blender/editors/space_graph/graph_ops.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 5b1250e1cde..a4bbfd5cd7f 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -222,7 +222,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_menu(keymap, "DOPESHEET_MT_specials", WKEY, KM_PRESS, 0, 0); /* destructive */ - WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", DELKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 80aba98104a..54b35b6acb6 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -49,6 +49,7 @@ #include "ED_markers.h" #include "ED_screen.h" #include "ED_transform.h" +#include "ED_object.h" #include "graph_intern.h" @@ -609,7 +610,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* destructive */ WM_keymap_add_item(keymap, "GRAPH_OT_smooth", OKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_bake", CKEY, KM_PRESS, KM_ALT, 0); @@ -664,6 +665,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_fcurve"); + ED_keymap_proportional_cycle(keyconf, keymap); /* pivot point settings */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0); -- cgit v1.2.3 From 5a1aa5b935f036a0493badae8cb835d13265a5e1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Jul 2018 18:37:27 +0200 Subject: Keymap: movie-clip center frame, match graph view --- source/blender/editors/space_clip/space_clip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index fc550499157..fbdb137e260 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -786,7 +786,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) #ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); #endif - WM_keymap_add_item(keymap, "CLIP_OT_graph_center_current_frame", PADPERIOD, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CLIP_OT_graph_center_current_frame", PAD0, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.lock_time_cursor"); -- cgit v1.2.3 From 2bef8ca1b8e0e51f1e09216d2a42f7fc0b7d723a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Jul 2018 15:14:57 +0200 Subject: Cleanup: pass window to listeners, instead of screen + workspace. --- source/blender/blenkernel/BKE_screen.h | 7 +++---- source/blender/editors/include/ED_screen.h | 5 ++--- source/blender/editors/interface/interface_region_popup.c | 2 +- source/blender/editors/screen/area.c | 8 ++++---- source/blender/editors/space_action/space_action.c | 11 +++++------ source/blender/editors/space_buttons/space_buttons.c | 5 ++--- source/blender/editors/space_clip/space_clip.c | 15 +++++++-------- source/blender/editors/space_console/space_console.c | 2 +- source/blender/editors/space_file/space_file.c | 9 ++++----- source/blender/editors/space_graph/space_graph.c | 5 ++--- source/blender/editors/space_image/space_image.c | 13 ++++++------- source/blender/editors/space_info/space_info.c | 4 ++-- source/blender/editors/space_nla/space_nla.c | 9 ++++----- source/blender/editors/space_node/space_node.c | 5 ++--- source/blender/editors/space_outliner/space_outliner.c | 4 ++-- source/blender/editors/space_script/space_script.c | 2 +- source/blender/editors/space_sequencer/space_sequencer.c | 9 ++++----- source/blender/editors/space_statusbar/space_statusbar.c | 2 +- source/blender/editors/space_text/space_text.c | 3 +-- source/blender/editors/space_topbar/space_topbar.c | 4 ++-- source/blender/editors/space_userpref/space_userpref.c | 4 ++-- source/blender/editors/space_view3d/space_view3d.c | 9 ++++----- source/blender/windowmanager/intern/wm_event_system.c | 6 +++--- 23 files changed, 65 insertions(+), 78 deletions(-) diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 5bfa2a8a8fe..23f57586ed1 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -88,9 +88,8 @@ typedef struct SpaceType { /* exit is called when the area is hidden or removed */ void (*exit)(struct wmWindowManager *wm, struct ScrArea *sa); /* Listeners can react to bContext changes */ - void (*listener)(struct bScreen *sc, struct ScrArea *sa, - struct wmNotifier *wmn, struct Scene *scene, - struct WorkSpace *workspace); + void (*listener)(struct wmWindow *win, struct ScrArea *sa, + struct wmNotifier *wmn, struct Scene *scene); /* refresh context, called after filereads, ED_area_tag_refresh() */ void (*refresh)(const struct bContext *C, struct ScrArea *sa); @@ -146,7 +145,7 @@ typedef struct ARegionType { /* snap the size of the region (can be NULL for no snapping). */ int (*snap_size)(const struct ARegion *ar, int size, int axis); /* contextual changes should be handled here */ - void (*listener)(struct bScreen *sc, struct ScrArea *sa, struct ARegion *ar, + void (*listener)(struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar, struct wmNotifier *wmn, const struct Scene *scene); /* Optional callback to generate subscriptions. */ void (*message_subscribe)( diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 0e335f89fb4..1fdbd46bacf 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -67,7 +67,7 @@ struct PropertyRNA; /* regions */ void ED_region_do_listen( - struct bScreen *sc, struct ScrArea *sa, struct ARegion *ar, + struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar, struct wmNotifier *note, const Scene *scene); void ED_region_do_layout(struct bContext *C, struct ARegion *ar); void ED_region_do_draw(struct bContext *C, struct ARegion *ar); @@ -137,8 +137,7 @@ void ED_area_exit(struct bContext *C, struct ScrArea *sa); int ED_screen_area_active(const struct bContext *C); void ED_screen_global_areas_create( struct wmWindow *win); -void ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, Scene *scene, - struct WorkSpace *workspace); +void ED_area_do_listen(struct wmWindow *win, ScrArea *sa, struct wmNotifier *note, Scene *scene); void ED_area_tag_redraw(ScrArea *sa); void ED_area_tag_redraw_no_rebuild(ScrArea *sa); void ED_area_tag_redraw_regiontype(ScrArea *sa, int type); diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 0ac4d4d28ec..320ee1f4616 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -342,7 +342,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) * Use to refresh centered popups on screen resizing (for splash). */ static void ui_block_region_popup_window_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { switch (wmn->category) { case NC_WINDOW: diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 46bbc0fdf4f..5cb440d315b 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -150,7 +150,7 @@ void ED_region_pixelspace(ARegion *ar) } /* only exported for WM */ -void ED_region_do_listen(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *note, const Scene *scene) +void ED_region_do_listen(wmWindow *win, ScrArea *sa, ARegion *ar, wmNotifier *note, const Scene *scene) { /* generic notes first */ switch (note->category) { @@ -164,15 +164,15 @@ void ED_region_do_listen(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *note } if (ar->type && ar->type->listener) - ar->type->listener(sc, sa, ar, note, scene); + ar->type->listener(win, sa, ar, note, scene); } /* only exported for WM */ -void ED_area_do_listen(bScreen *sc, ScrArea *sa, wmNotifier *note, Scene *scene, WorkSpace *workspace) +void ED_area_do_listen(wmWindow *win, ScrArea *sa, wmNotifier *note, Scene *scene) { /* no generic notes? */ if (sa->type && sa->type->listener) { - sa->type->listener(sc, sa, note, scene, workspace); + sa->type->listener(win, sa, note, scene); } } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 876b73a4a76..363c30427db 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -341,7 +341,7 @@ static void action_header_region_draw(const bContext *C, ARegion *ar) } static void action_channel_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -432,7 +432,7 @@ static void saction_channel_region_message_subscribe( } static void action_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -531,8 +531,7 @@ static void saction_main_region_message_subscribe( /* editor level listener */ static void action_listener( - bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) + wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; @@ -686,7 +685,7 @@ static void action_listener( } static void action_header_region_listener( - bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar, + wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; @@ -760,7 +759,7 @@ static void action_buttons_area_draw(const bContext *C, ARegion *ar) } static void action_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index ba9045346c7..55ca3524a61 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -283,7 +283,7 @@ static void buttons_main_region_layout(const bContext *C, ARegion *ar) } static void buttons_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -361,8 +361,7 @@ static void buttons_area_redraw(ScrArea *sa, short buttons) /* reused! */ static void buttons_area_listener( - bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) + wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { SpaceButs *sbuts = sa->spacedata.first; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index fbdb137e260..4ac9010d3b5 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -323,8 +323,7 @@ static SpaceLink *clip_duplicate(SpaceLink *sl) return (SpaceLink *)scn; } -static void clip_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) +static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { @@ -1212,7 +1211,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar) } static void clip_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -1343,7 +1342,7 @@ static void clip_preview_region_draw(const bContext *C, ARegion *ar) } static void clip_preview_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) { } @@ -1386,7 +1385,7 @@ static void clip_channels_region_draw(const bContext *C, ARegion *ar) } static void clip_channels_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) { } @@ -1405,7 +1404,7 @@ static void clip_header_region_draw(const bContext *C, ARegion *ar) } static void clip_header_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -1447,7 +1446,7 @@ static void clip_tools_region_draw(const bContext *C, ARegion *ar) /****************** tool properties region ******************/ static void clip_props_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -1494,7 +1493,7 @@ static void clip_properties_region_draw(const bContext *C, ARegion *ar) } static void clip_properties_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 4b577a7cb7e..23ef2e50b5f 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -370,7 +370,7 @@ static void console_header_region_draw(const bContext *C, ARegion *ar) } static void console_main_region_listener( - bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar, + wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { // SpaceInfo *sinfo = sa->spacedata.first; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 0e39ea725ae..116cd700cc0 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -298,8 +298,7 @@ static void file_refresh(const bContext *C, ScrArea *sa) ED_area_tag_redraw(sa); } -static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) +static void file_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; @@ -339,7 +338,7 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *ar) } static void file_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -642,7 +641,7 @@ static void file_tools_region_draw(const bContext *C, ARegion *ar) } static void file_tools_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) { #if 0 @@ -706,7 +705,7 @@ static void file_ui_region_draw(const bContext *C, ARegion *ar) } static void file_ui_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 878c4815f73..c94f2b00db2 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -430,7 +430,7 @@ static void graph_buttons_region_draw(const bContext *C, ARegion *ar) } static void graph_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -568,8 +568,7 @@ static void graph_region_message_subscribe( } /* editor level listener */ -static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) +static void graph_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 907b7e51c42..5c95d5944d1 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -434,8 +434,7 @@ static void image_refresh(const bContext *C, ScrArea *sa) } } -static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene, - WorkSpace *workspace) +static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { SpaceImage *sima = (SpaceImage *)sa->spacedata.first; @@ -529,7 +528,7 @@ static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sc case ND_TRANSFORM: case ND_MODIFIER: { - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *ob = OBACT(view_layer); if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) { if (sima->lock && (sima->flag & SI_DRAWSHADOW)) { @@ -821,7 +820,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) } static void image_main_region_listener( - bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar, + wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -877,7 +876,7 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar) } static void image_buttons_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -952,7 +951,7 @@ static void image_tools_region_draw(const bContext *C, ARegion *ar) } static void image_tools_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -1020,7 +1019,7 @@ static void image_header_region_draw(const bContext *C, ARegion *ar) } static void image_header_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 5f9de037409..7f4d2a7f6c7 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -243,7 +243,7 @@ static void info_header_region_draw(const bContext *C, ARegion *ar) } static void info_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { // SpaceInfo *sinfo = sa->spacedata.first; @@ -260,7 +260,7 @@ static void info_main_region_listener( } static void info_header_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 62144db0577..6633dbdf08e 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -365,7 +365,7 @@ static void nla_buttons_region_draw(const bContext *C, ARegion *ar) } static void nla_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -400,7 +400,7 @@ static void nla_region_listener( static void nla_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -493,7 +493,7 @@ static void nla_main_region_message_subscribe( } static void nla_channel_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -564,8 +564,7 @@ static void nla_channel_region_message_subscribe( } /* editor level listener */ -static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) +static void nla_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index fa6fa02cdc5..a87a68392c7 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -384,8 +384,7 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) } -static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) +static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { /* note, ED_area_tag_refresh will re-execute compositor */ SpaceNode *snode = sa->spacedata.first; @@ -750,7 +749,7 @@ static void node_header_region_draw(const bContext *C, ARegion *ar) /* used for header + main region */ static void node_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { wmManipulatorMap *mmap = ar->manipulator_map; diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index e1baaf54163..e4e99f88bf4 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -310,7 +310,7 @@ static void outliner_main_region_free(ARegion *UNUSED(ar)) } static void outliner_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -459,7 +459,7 @@ static void outliner_header_region_free(ARegion *UNUSED(ar)) } static void outliner_header_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 8b6100cd9e0..fe7261f7bbd 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -178,7 +178,7 @@ static void script_header_region_draw(const bContext *C, ARegion *ar) } static void script_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 04be1f82a60..8fb526bf502 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -340,8 +340,7 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl) } static void sequencer_listener( - bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) + wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { @@ -496,7 +495,7 @@ static void sequencer_main_region_draw(const bContext *C, ARegion *ar) } static void sequencer_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -644,7 +643,7 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *ar) } static void sequencer_preview_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -712,7 +711,7 @@ static void sequencer_buttons_region_draw(const bContext *C, ARegion *ar) } static void sequencer_buttons_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c index 5ff32b98f90..35eb6c69585 100644 --- a/source/blender/editors/space_statusbar/space_statusbar.c +++ b/source/blender/editors/space_statusbar/space_statusbar.c @@ -109,7 +109,7 @@ static void statusbar_keymap(struct wmKeyConfig *UNUSED(keyconf)) } static void statusbar_header_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index c3e2945f3ff..ac43d7de408 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -126,8 +126,7 @@ static SpaceLink *text_duplicate(SpaceLink *sl) return (SpaceLink *)stextn; } -static void text_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) +static void text_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { SpaceText *st = sa->spacedata.first; diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c index c7ef6591c0d..e45159124e8 100644 --- a/source/blender/editors/space_topbar/space_topbar.c +++ b/source/blender/editors/space_topbar/space_topbar.c @@ -151,7 +151,7 @@ static void topbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar) ED_region_header_init(ar); } -static void topbar_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, +static void topbar_main_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -171,7 +171,7 @@ static void topbar_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) } } -static void topbar_header_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, +static void topbar_header_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index fc5182fcb4f..06c6e612f13 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -137,14 +137,14 @@ static void userpref_header_region_draw(const bContext *C, ARegion *ar) } static void userpref_main_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) { /* context changes */ } static void userpref_header_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) { /* context changes */ diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 4660255cc6c..77beadccd5d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -776,7 +776,7 @@ static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, const Scene } static void view3d_main_region_listener( - bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar, + wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar, wmNotifier *wmn, const Scene *scene) { View3D *v3d = sa->spacedata.first; @@ -1150,7 +1150,7 @@ static void view3d_header_region_draw(const bContext *C, ARegion *ar) } static void view3d_header_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -1228,7 +1228,7 @@ static void view3d_buttons_region_draw(const bContext *C, ARegion *ar) } static void view3d_buttons_region_listener( - bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ @@ -1358,8 +1358,7 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *ar) /* area (not region) level listener */ static void space_view3d_listener( - bScreen *UNUSED(sc), ScrArea *sa, struct wmNotifier *wmn, Scene *UNUSED(scene), - WorkSpace *UNUSED(workspace)) + wmWindow *UNUSED(win), ScrArea *sa, struct wmNotifier *wmn, Scene *UNUSED(scene)) { View3D *v3d = sa->spacedata.first; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 2a92eedf456..6fd23dc6b08 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -473,13 +473,13 @@ void wm_event_do_notifiers(bContext *C) ED_screen_do_listen(C, note); for (ar = screen->regionbase.first; ar; ar = ar->next) { - ED_region_do_listen(screen, NULL, ar, note, scene); + ED_region_do_listen(win, NULL, ar, note, scene); } ED_screen_areas_iter(win, screen, sa) { - ED_area_do_listen(screen, sa, note, scene, workspace); + ED_area_do_listen(win, sa, note, scene); for (ar = sa->regionbase.first; ar; ar = ar->next) { - ED_region_do_listen(screen, sa, ar, note, scene); + ED_region_do_listen(win, sa, ar, note, scene); } } } -- cgit v1.2.3 From 4e2228525fc9bbcff58e315c5e3bbc193cd63a0b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 3 Jul 2018 15:34:26 +0200 Subject: Workspaces: add main and child windows. * Main windows show a topbar and statusbar, and select a workspace and scene. They are created with Window > New Main Window. * Child windows do not show a topbar or statusbar. These follow the workspace and scene of their parent main window. Created with Window > New Window or View > Duplicate Area into New Window. * The purpose of this change is to support multi monitor setups where you just want to put more editors on the other monitors. Without multiple topbars and statusbars, working within a single workspace and scene. Creating multiple main windows is intended to be a concious choice to do different tasks in different workspaces and scenes. * Note these changes do not currently affect how the operating system treats the windows. * When changing the workspace, the layout in all child windows changes. This makes sense if we consider child windows to be just a way to extend the main window across more monitors. In some case it may be useful to keep the same layout though, we can add an option for this depending on user feedback. --- release/scripts/startup/bl_ui/space_topbar.py | 4 + source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenloader/intern/readfile.c | 4 +- source/blender/editors/include/ED_scene.h | 5 +- source/blender/editors/include/ED_screen.h | 5 +- source/blender/editors/scene/scene_edit.c | 40 +---- source/blender/editors/screen/screen_edit.c | 49 ++++++- source/blender/editors/screen/screen_ops.c | 2 +- source/blender/editors/screen/workspace_edit.c | 4 +- .../editors/space_outliner/outliner_select.c | 6 +- .../editors/space_outliner/outliner_tools.c | 6 +- source/blender/makesdna/DNA_windowmanager_types.h | 6 +- source/blender/makesrna/intern/rna_main_api.c | 2 +- source/blender/makesrna/intern/rna_wm.c | 5 +- source/blender/windowmanager/WM_api.h | 4 +- source/blender/windowmanager/intern/wm.c | 9 +- .../blender/windowmanager/intern/wm_event_system.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 15 +- source/blender/windowmanager/intern/wm_stereo.c | 4 +- source/blender/windowmanager/intern/wm_window.c | 161 +++++++++++++-------- source/blender/windowmanager/wm_window.h | 7 +- 21 files changed, 207 insertions(+), 135 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index beb59d2c512..5cf28578217 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -465,6 +465,10 @@ class INFO_MT_window(Menu): layout = self.layout layout.operator("wm.window_new") + layout.operator("wm.window_new_main") + + layout.separator() + layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER') layout.separator() diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a38384f8f2b..1b309d76f61 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -906,7 +906,7 @@ Object *BKE_scene_object_find_by_name(Scene *scene, const char *name) /** * Sets the active scene, mainly used when running in background mode (``--scene`` command line argument). * This is also called to set the scene directly, bypassing windowing code. - * Otherwise #WM_window_change_active_scene is used when changing scenes by the user. + * Otherwise #WM_window_set_active_scene is used when changing scenes by the user. */ void BKE_scene_set_background(Main *bmain, Scene *scene) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2a48bf8fc5a..4fa897bb689 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6926,9 +6926,11 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) link_list(fd, &wm->windows); for (win = wm->windows.first; win; win = win->next) { - WorkSpaceInstanceHook *hook = win->workspace_hook; + win->parent = newdataadr(fd, win->parent); + WorkSpaceInstanceHook *hook = win->workspace_hook; win->workspace_hook = newdataadr(fd, hook); + /* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */ oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0); diff --git a/source/blender/editors/include/ED_scene.h b/source/blender/editors/include/ED_scene.h index 9b48187e541..116d9bd24fc 100644 --- a/source/blender/editors/include/ED_scene.h +++ b/source/blender/editors/include/ED_scene.h @@ -31,10 +31,7 @@ enum eSceneCopyMethod; struct Scene *ED_scene_add(struct Main *bmain, struct bContext *C, struct wmWindow *win, enum eSceneCopyMethod method) ATTR_NONNULL(); bool ED_scene_delete(struct bContext *C, struct Main *bmain, struct wmWindow *win, struct Scene *scene) ATTR_NONNULL(); -void ED_scene_change_update( - struct Main *bmain, struct bContext *C, - struct wmWindow *win, const struct bScreen *screen, - struct Scene *scene_old, struct Scene *scene_new) ATTR_NONNULL(); +void ED_scene_change_update(struct Main *bmain, struct Scene *scene, struct ViewLayer *layer) ATTR_NONNULL(); bool ED_scene_view_layer_delete( struct Main *bmain, struct Scene *scene, struct ViewLayer *layer, struct ReportList *reports) ATTR_NONNULL(1, 2, 3); diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 1fdbd46bacf..cc80108e20c 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -184,10 +184,7 @@ void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win); void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *win, struct bScreen *screen); void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note); bool ED_screen_change(struct bContext *C, struct bScreen *sc); -void ED_screen_update_after_scene_change( - const struct bScreen *screen, - struct Scene *scene_new, - struct ViewLayer *view_layer); +void ED_screen_scene_change(struct bContext *C, struct wmWindow *win, struct Scene *scene); void ED_screen_set_active_region(struct bContext *C, struct wmWindow *win, const int xy[2]); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); void ED_screen_animation_timer(struct bContext *C, int redraws, int refresh, int sync, int enable); diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c index 677fc0a068e..0ebbd770c9f 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -80,7 +80,7 @@ Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod me } } - WM_window_change_active_scene(bmain, C, win, scene_new); + WM_window_set_active_scene(bmain, C, win, scene_new); WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, scene_new); @@ -102,7 +102,7 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene) else return false; - WM_window_change_active_scene(bmain, C, win, scene_new); + WM_window_set_active_scene(bmain, C, win, scene_new); BKE_libblock_remap(bmain, scene, scene_new, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE); @@ -114,43 +114,17 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene) return true; } -static ViewLayer *scene_change_get_new_view_layer(const WorkSpace *workspace, const Scene *scene_new) +/* Depsgraph updates after scene becomes active in a window. */ +void ED_scene_change_update(Main *bmain, Scene *scene, ViewLayer *layer) { - ViewLayer *layer_new = BKE_workspace_view_layer_exists(workspace, scene_new); - return layer_new ? layer_new : BKE_view_layer_default_view(scene_new); -} + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, layer, true); -void ED_scene_change_update( - Main *bmain, bContext *C, - wmWindow *win, const bScreen *screen, Scene *UNUSED(scene_old), Scene *scene_new) -{ - WorkSpace *workspace = CTX_wm_workspace(C); - ViewLayer *layer_new = scene_change_get_new_view_layer(workspace, scene_new); - Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene_new, layer_new, true); - Object *obact_new = OBACT(layer_new); - UNUSED_VARS(obact_new); - -#if 0 - /* mode syncing */ - eObjectMode object_mode_old = workspace->object_mode; - ViewLayer *layer_old = BKE_view_layer_from_workspace_get(scene_old, workspace); - Object *obact_old = OBACT(layer_old); - UNUSED_VARS(obact_old, object_mode_old); -#endif - - win->scene = scene_new; - CTX_data_scene_set(C, scene_new); - BKE_workspace_view_layer_set(workspace, layer_new, scene_new); - BKE_scene_set_background(bmain, scene_new); - DEG_graph_relations_update(depsgraph, bmain, scene_new, layer_new); + BKE_scene_set_background(bmain, scene); + DEG_graph_relations_update(depsgraph, bmain, scene, layer); DEG_on_visible_update(bmain, false); - ED_screen_update_after_scene_change(screen, scene_new, layer_new); ED_render_engine_changed(bmain); ED_update_for_newframe(bmain, depsgraph); - - /* complete redraw */ - WM_event_add_notifier(C, NC_WINDOW, NULL); } static bool view_layer_remove_poll( diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 6bc8a6c10cf..50609815168 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -477,8 +477,8 @@ void ED_screens_initialize(Main *bmain, wmWindowManager *wm) wmWindow *win; for (win = wm->windows.first; win; win = win->next) { - if (WM_window_get_active_workspace(win) == NULL) { - WM_window_set_active_workspace(win, bmain->workspaces.first); + if (BKE_workspace_active_get(win->workspace_hook) == NULL) { + BKE_workspace_active_set(win->workspace_hook, bmain->workspaces.first); } if (BLI_listbase_is_empty(&win->global_areas.areabase)) { @@ -792,11 +792,19 @@ static void screen_global_statusbar_area_create(wmWindow *win) void ED_screen_global_areas_create(wmWindow *win) { + /* Don't create global areas for child windows. */ + if (win->parent) { + return; + } + + /* Don't create global area for temporary windows. */ bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - if (screen->temp == 0) { - screen_global_topbar_area_create(win); - screen_global_statusbar_area_create(win); + if (screen->temp) { + return; } + + screen_global_topbar_area_create(win); + screen_global_statusbar_area_create(win); } @@ -936,13 +944,40 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre } } -void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new, ViewLayer *view_layer) +static ViewLayer *scene_change_get_new_view_layer(const WorkSpace *workspace, const Scene *scene_new) +{ + ViewLayer *layer_new = BKE_workspace_view_layer_exists(workspace, scene_new); + return layer_new ? layer_new : BKE_view_layer_default_view(scene_new); +} + +void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene) { + const bScreen *screen = WM_window_get_active_screen(win); + WorkSpace *workspace = CTX_wm_workspace(C); + ViewLayer *view_layer = scene_change_get_new_view_layer(workspace, scene); + +#if 0 + /* mode syncing */ + Object *obact_new = OBACT(view_layer); + UNUSED_VARS(obact_new); + eObjectMode object_mode_old = workspace->object_mode; + ViewLayer *layer_old = BKE_view_layer_from_workspace_get(scene_old, workspace); + Object *obact_old = OBACT(layer_old); + UNUSED_VARS(obact_old, object_mode_old); +#endif + + BKE_workspace_view_layer_set(workspace, view_layer, scene); + + win->scene = scene; + if (CTX_wm_window(C) == win) { + CTX_data_scene_set(C, scene); + } + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - screen_set_3dview_camera(scene_new, view_layer, sa, v3d); + screen_set_3dview_camera(scene, view_layer, sa, v3d); } } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index a0e8357b8f3..ab0fbfacf93 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1130,7 +1130,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) newwin->scene = scene; - WM_window_set_active_workspace(newwin, workspace); + BKE_workspace_active_set(newwin->workspace_hook, workspace); /* allocs new screen and adds to newly created window, using window size */ layout_new = ED_workspace_layout_add(bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old)); newsc = BKE_workspace_layout_screen_get(layout_new); diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 9d329355500..9ba9b70a6e8 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -191,8 +191,8 @@ bool ED_workspace_change( BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new); if (screen_new) { - WM_window_set_active_layout(win, workspace_new, layout_new); - WM_window_set_active_workspace(win, workspace_new); + BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new); + BKE_workspace_active_set(win->workspace_hook, workspace_new); /* update screen *after* changing workspace - which also causes the * actual screen change and updates context (including CTX_wm_workspace) */ diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 6668ea1faeb..8a5df196c7b 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -262,7 +262,7 @@ static eOLDrawState tree_element_set_active_object( sce = (Scene *)outliner_search_back(soops, te, ID_SCE); if (sce && scene != sce) { - WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce); + WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce); scene = sce; } @@ -431,7 +431,7 @@ static eOLDrawState tree_element_active_world( if (set != OL_SETSEL_NONE) { /* make new scene active */ if (sce && scene != sce) { - WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce); + WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), sce); } } @@ -950,7 +950,7 @@ static void do_outliner_item_activate_tree_element( /* editmode? */ if (te->idcode == ID_SCE) { if (scene != (Scene *)tselem->id) { - WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), (Scene *)tselem->id); + WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), (Scene *)tselem->id); } } else if (te->idcode == ID_GR) { diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 9952db5e652..b23ea8e4dae 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -580,7 +580,7 @@ void outliner_do_object_operation_ex( // when objects selected in other scenes... dunno if that should be allowed Scene *scene_owner = (Scene *)outliner_search_back(soops, te, ID_SCE); if (scene_owner && scene_act != scene_owner) { - WM_window_change_active_scene(CTX_data_main(C), C, CTX_wm_window(C), scene_owner); + WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), scene_owner); } /* important to use 'scene_owner' not scene_act else deleting objects can crash. * only use 'scene_act' when 'scene_owner' is NULL, which can happen when the @@ -956,7 +956,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) Scene *sce = scene; // to be able to delete, scenes are set... outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_select_cb); if (scene != sce) { - WM_window_change_active_scene(bmain, C, win, sce); + WM_window_set_active_scene(bmain, C, win, sce); } str = "Select Objects"; @@ -967,7 +967,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) Scene *sce = scene; // to be able to delete, scenes are set... outliner_do_object_operation_ex(C, op->reports, scene, soops, &soops->tree, object_select_hierarchy_cb, false); if (scene != sce) { - WM_window_change_active_scene(bmain, C, win, sce); + WM_window_set_active_scene(bmain, C, win, sce); } str = "Select Object Hierarchy"; DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE); diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index c6ad1470561..0ef9e9b134a 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -186,8 +186,10 @@ typedef struct wmWindow { void *ghostwin; /* don't want to include ghost.h stuff */ void *gwnctx; /* don't want to include gawin stuff */ - struct Scene *scene; /* The scene displayed in this window. */ - struct Scene *new_scene; /* temporary when switching */ + struct wmWindow *parent; /* Parent window */ + + struct Scene *scene; /* The scene displayed in this window. */ + struct Scene *new_scene; /* temporary when switching */ struct WorkSpaceInstanceHook *workspace_hook; diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index fff53aafcc7..5fca91064b6 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -185,7 +185,7 @@ static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports BPy_BEGIN_ALLOW_THREADS; #endif - WM_window_change_active_scene(bmain, C, win, scene_new); + WM_window_set_active_scene(bmain, C, win, scene_new); #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 1c94582c57e..569bc20d435 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -675,7 +675,7 @@ static void rna_Window_scene_update(bContext *C, PointerRNA *ptr) BPy_BEGIN_ALLOW_THREADS; #endif - WM_window_change_active_scene(bmain, C, win, win->new_scene); + WM_window_set_active_scene(bmain, C, win, win->new_scene); #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -2041,6 +2041,9 @@ static void rna_def_window(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Window", "Open window"); RNA_def_struct_sdna(srna, "wmWindow"); + prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Parent Window", "Active workspace and scene follow this window"); + rna_def_window_stereo3d(brna); prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 3d1ee273108..0ed23a8fb20 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -111,10 +111,10 @@ struct Scene *WM_windows_scene_get_from_screen(const struct wmWindowManager *wm, struct WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; struct Scene *WM_window_get_active_scene(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; -void WM_window_change_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win, +void WM_window_set_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win, struct Scene *scene_new) ATTR_NONNULL(); struct WorkSpace *WM_window_get_active_workspace(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; -void WM_window_set_active_workspace(struct wmWindow *win, struct WorkSpace *workspace) ATTR_NONNULL(1); +void WM_window_set_active_workspace(struct bContext *C, struct wmWindow *win, struct WorkSpace *workspace) ATTR_NONNULL(1); struct WorkSpaceLayout *WM_window_get_active_layout(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; void WM_window_set_active_layout( struct wmWindow *win, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL(1); diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 701ad49b520..9ef0883cbbf 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -461,10 +461,10 @@ void wm_add_default(Main *bmain, bContext *C) WorkSpaceLayout *layout = BKE_workspace_layout_find_global(bmain, screen, &workspace); CTX_wm_manager_set(C, wm); - win = wm_window_new(C); + win = wm_window_new(C, NULL); win->scene = CTX_data_scene(C); - WM_window_set_active_workspace(win, workspace); - WM_window_set_active_layout(win, workspace, layout); + BKE_workspace_active_set(win->workspace_hook, workspace); + BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace, layout); screen->winid = win->winid; wm->winactive = win; @@ -484,7 +484,8 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) wm_autosave_timer_ended(wm); while ((win = BLI_pophead(&wm->windows))) { - WM_window_set_active_workspace(win, NULL); /* prevent draw clear to use screen */ + /* prevent draw clear to use screen */ + BKE_workspace_active_set(win->workspace_hook, NULL); wm_window_free(C, wm, win); } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 6fd23dc6b08..3aee57d5801 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -384,7 +384,7 @@ void wm_event_do_notifiers(bContext *C) UI_popup_handlers_remove_all(C, &win->modalhandlers); - ED_workspace_change(ref_ws, C, wm, win); + WM_window_set_active_workspace(C, win, ref_ws); if (G.debug & G_DEBUG_EVENTS) printf("%s: Workspace set %p\n", __func__, note->reference); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 5628d39e5f8..1983c0e6b84 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2298,7 +2298,7 @@ static void WM_OT_window_close(wmOperatorType *ot) { ot->name = "Close Window"; ot->idname = "WM_OT_window_close"; - ot->description = "Close the current Blender window"; + ot->description = "Close the current window"; ot->exec = wm_window_close_exec; ot->poll = WM_operator_winactive; @@ -2308,12 +2308,22 @@ static void WM_OT_window_new(wmOperatorType *ot) { ot->name = "New Window"; ot->idname = "WM_OT_window_new"; - ot->description = "Create a new Blender window"; + ot->description = "Create a new window"; ot->exec = wm_window_new_exec; ot->poll = wm_operator_winactive_normal; } +static void WM_OT_window_new_main(wmOperatorType *ot) +{ + ot->name = "New Main Window"; + ot->idname = "WM_OT_window_new_main"; + ot->description = "Create a new main window with its own workspace and scene selection"; + + ot->exec = wm_window_new_main_exec; + ot->poll = wm_operator_winactive_normal; +} + static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot) { ot->name = "Toggle Window Fullscreen"; @@ -3703,6 +3713,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_window_close); WM_operatortype_append(WM_OT_window_new); + WM_operatortype_append(WM_OT_window_new_main); WM_operatortype_append(WM_OT_read_history); WM_operatortype_append(WM_OT_read_homefile); WM_operatortype_append(WM_OT_read_factory_settings); diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c index 4450d18a5df..2c779ba9c7c 100644 --- a/source/blender/windowmanager/intern/wm_stereo.c +++ b/source/blender/windowmanager/intern/wm_stereo.c @@ -404,7 +404,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op) prev_display_mode != win_src->stereo3d_format->display_mode) { /* in case the hardward supports pageflip but not the display */ - if ((win_dst = wm_window_copy_test(C, win_src, false))) { + if ((win_dst = wm_window_copy_test(C, win_src, false, false))) { /* pass */ } else { @@ -423,7 +423,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op) ok = false; } /* pageflip requires a new window to be created with the proper OS flags */ - else if ((win_dst = wm_window_copy_test(C, win_src, false))) { + else if ((win_dst = wm_window_copy_test(C, win_src, false, false))) { if (wm_stereo3d_quadbuffer_supported()) { BKE_report(op->reports, RPT_INFO, "Quad-buffer window successfully created"); } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 43231855162..d28d2c6b001 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -256,7 +256,7 @@ static int find_free_winid(wmWindowManager *wm) } /* don't change context itself */ -wmWindow *wm_window_new(bContext *C) +wmWindow *wm_window_new(bContext *C, wmWindow *parent) { Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); @@ -265,6 +265,7 @@ wmWindow *wm_window_new(bContext *C) BLI_addtail(&wm->windows, win); win->winid = find_free_winid(wm); + win->parent = (parent && parent->parent) ? parent->parent : parent; win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo 3D Format (window)"); win->workspace_hook = BKE_workspace_instance_hook_create(bmain); @@ -272,10 +273,11 @@ wmWindow *wm_window_new(bContext *C) } /* part of wm_window.c api */ -wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_layout) +wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child) { Main *bmain = CTX_data_main(C); - wmWindow *win_dst = wm_window_new(C); + wmWindow *win_parent = (child) ? win_src : win_src->parent; + wmWindow *win_dst = wm_window_new(C, win_parent); WorkSpace *workspace = WM_window_get_active_workspace(win_src); WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src); Scene *scene = WM_window_get_active_scene(win_src); @@ -287,9 +289,9 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la win_dst->sizey = win_src->sizey; win_dst->scene = scene; - WM_window_set_active_workspace(win_dst, workspace); + BKE_workspace_active_set(win_dst->workspace_hook, workspace); layout_new = duplicate_layout ? ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) : layout_old; - WM_window_set_active_layout(win_dst, workspace, layout_new); + BKE_workspace_hook_layout_for_workspace_set(win_dst->workspace_hook, workspace, layout_new); *win_dst->stereo3d_format = *win_src->stereo3d_format; @@ -300,12 +302,12 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la * A higher level version of copy that tests the new window can be added. * (called from the operator directly) */ -wmWindow *wm_window_copy_test(bContext *C, wmWindow *win_src, const bool duplicate_layout) +wmWindow *wm_window_copy_test(bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win_dst; - win_dst = wm_window_copy(C, win_src, duplicate_layout); + win_dst = wm_window_copy(C, win_src, duplicate_layout, child); WM_check(C); @@ -473,56 +475,67 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) { wmWindow *tmpwin; - /* first check if we have to quit (there are non-temp remaining windows) */ - for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) { - if (tmpwin == win) - continue; - if (WM_window_is_temp_screen(tmpwin) == false) - break; + /* first check if we have to quit (there are non-temp and non-child windows remaining) */ + if (win->parent == NULL) { + for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) { + if (tmpwin == win) + continue; + if (tmpwin->parent == NULL) + break; + if (WM_window_is_temp_screen(tmpwin) == false) + break; + } + + if (tmpwin == NULL) { + wm_quit_with_optional_confirmation_prompt(C, win); + return; + } } - if (tmpwin == NULL) { - wm_quit_with_optional_confirmation_prompt(C, win); + /* close child windows */ + for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) { + if (tmpwin->parent == win) { + wm_window_close(C, wm, tmpwin); + } } - else { - bScreen *screen = WM_window_get_active_screen(win); - WorkSpace *workspace = WM_window_get_active_workspace(win); - WorkSpaceLayout *layout = BKE_workspace_active_layout_get(win->workspace_hook); - BLI_remlink(&wm->windows, win); + bScreen *screen = WM_window_get_active_screen(win); + WorkSpace *workspace = WM_window_get_active_workspace(win); + WorkSpaceLayout *layout = BKE_workspace_active_layout_get(win->workspace_hook); - CTX_wm_window_set(C, win); /* needed by handlers */ - WM_event_remove_handlers(C, &win->handlers); - WM_event_remove_handlers(C, &win->modalhandlers); + BLI_remlink(&wm->windows, win); - /* for regular use this will _never_ be NULL, - * however we may be freeing an improperly initialized window. */ - if (screen) { - ED_screen_exit(C, win, screen); - } + CTX_wm_window_set(C, win); /* needed by handlers */ + WM_event_remove_handlers(C, &win->handlers); + WM_event_remove_handlers(C, &win->modalhandlers); - if (tmpwin) { - BLF_batch_reset(); - gpu_batch_presets_reset(); - immDeactivate(); - } + /* for regular use this will _never_ be NULL, + * however we may be freeing an improperly initialized window. */ + if (screen) { + ED_screen_exit(C, win, screen); + } - wm_window_free(C, wm, win); + if (tmpwin) { + BLF_batch_reset(); + gpu_batch_presets_reset(); + immDeactivate(); + } - /* keep imediatemode active before the next `wm_window_make_drawable` call */ - if (tmpwin) { - GHOST_ActivateWindowDrawingContext(tmpwin->ghostwin); - GWN_context_active_set(tmpwin->gwnctx); - immActivate(); - } + wm_window_free(C, wm, win); + + /* keep imediatemode active before the next `wm_window_make_drawable` call */ + if (tmpwin) { + GHOST_ActivateWindowDrawingContext(tmpwin->ghostwin); + GWN_context_active_set(tmpwin->gwnctx); + immActivate(); + } - /* if temp screen, delete it after window free (it stops jobs that can access it) */ - if (screen && screen->temp) { - Main *bmain = CTX_data_main(C); + /* if temp screen, delete it after window free (it stops jobs that can access it) */ + if (screen && screen->temp) { + Main *bmain = CTX_data_main(C); - BLI_assert(BKE_workspace_layout_screen_get(layout) == screen); - BKE_workspace_layout_remove(bmain, workspace, layout); - } + BLI_assert(BKE_workspace_layout_screen_get(layout) == screen); + BKE_workspace_layout_remove(bmain, workspace, layout); } } @@ -809,7 +822,7 @@ void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm) wmWindow *WM_window_open(bContext *C, const rcti *rect) { wmWindow *win_prev = CTX_wm_window(C); - wmWindow *win = wm_window_new(C); + wmWindow *win = wm_window_new(C, win_prev); win->posx = rect->xmin; win->posy = rect->ymin; @@ -869,7 +882,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i /* add new window? */ if (win == NULL) { - win = wm_window_new(C); + win = wm_window_new(C, win_prev); win->posx = rect.xmin; win->posy = rect.ymin; @@ -887,7 +900,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i if (WM_window_get_active_workspace(win) == NULL) { WorkSpace *workspace = WM_window_get_active_workspace(win_prev); - WM_window_set_active_workspace(win, workspace); + BKE_workspace_active_set(win->workspace_hook, workspace); } if (screen == NULL) { @@ -904,7 +917,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i } /* In case we reuse an already existing temp window (see win lookup above). */ else if (WM_window_get_active_scene(win) != scene) { - WM_window_change_active_scene(bmain, C, win, scene); + WM_window_set_active_scene(bmain, C, win, scene); } screen->temp = 1; @@ -976,17 +989,25 @@ int wm_window_close_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -/* operator callback */ int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op)) { wmWindow *win_src = CTX_wm_window(C); bool ok; - ok = (wm_window_copy_test(C, win_src, true) != NULL); + ok = (wm_window_copy_test(C, win_src, true, true) != NULL); return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } +int wm_window_new_main_exec(bContext *C, wmOperator *UNUSED(op)) +{ + wmWindow *win_src = CTX_wm_window(C); + bool ok; + + ok = (wm_window_copy_test(C, win_src, true, false) != NULL); + + return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; +} /* fullscreen operator callback */ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) @@ -2103,21 +2124,45 @@ Scene *WM_window_get_active_scene(const wmWindow *win) /** * \warning Only call outside of area/region loops */ -void WM_window_change_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene_new) +void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene) { - const bScreen *screen = WM_window_get_active_screen(win); - Scene *scene_old = win->scene; + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win_parent = (win->parent) ? win->parent : win; - ED_scene_change_update(bmain, C, win, screen, scene_old, scene_new); + /* Set scene in parent and its child windows. */ + ED_screen_scene_change(C, win_parent, scene); + + for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { + if (win_child->parent == win_parent) { + ED_screen_scene_change(C, win_child, scene); + } + } + + /* Update depsgraph and renderers for scene change. */ + ViewLayer *view_layer = WM_window_get_active_view_layer(win_parent); + ED_scene_change_update(bmain, scene, view_layer); + + /* Complete redraw. */ + WM_event_add_notifier(C, NC_WINDOW, NULL); } WorkSpace *WM_window_get_active_workspace(const wmWindow *win) { return BKE_workspace_active_get(win->workspace_hook); } -void WM_window_set_active_workspace(wmWindow *win, WorkSpace *workspace) + +void WM_window_set_active_workspace(bContext *C, wmWindow *win, WorkSpace *workspace) { - BKE_workspace_active_set(win->workspace_hook, workspace); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win_parent = (win->parent) ? win->parent : win; + + ED_workspace_change(workspace, C, wm, win); + + for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { + if (win_child->parent == win_parent) { + ED_workspace_change(workspace, C, wm, win_child); + } + } } WorkSpaceLayout *WM_window_get_active_layout(const wmWindow *win) diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index 952ffe5c117..385d61217ad 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -45,9 +45,9 @@ void wm_ghost_exit(void); void wm_get_screensize(int *r_width, int *r_height); void wm_get_desktopsize(int *r_width, int *r_height); -wmWindow *wm_window_new (bContext *C); -wmWindow *wm_window_copy (bContext *C, wmWindow *win_src, const bool duplicate_layout); -wmWindow *wm_window_copy_test (bContext *C, wmWindow *win_src, const bool duplicate_layout); +wmWindow *wm_window_new (bContext *C, wmWindow *parent); +wmWindow *wm_window_copy (bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child); +wmWindow *wm_window_copy_test (bContext *C, wmWindow *win_src, const bool duplicate_layout, const bool child); void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win); void wm_window_close (bContext *C, wmWindowManager *wm, wmWindow *win); @@ -85,6 +85,7 @@ int wm_window_fullscreen_toggle_exec(bContext *C, struct wmOperator *op); void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win) ATTR_NONNULL(); int wm_window_new_exec(bContext *C, struct wmOperator *op); +int wm_window_new_main_exec(bContext *C, struct wmOperator *op); /* Initial (unmaximized) size to start with for * systems that can't find it for themselves (X11). -- cgit v1.2.3 From c43443d530bff67693dc2db4efdca6307703ce61 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Jul 2018 13:00:46 +0200 Subject: Workspaces: store view layer per main window, instead of per workspace. It was a bit odd that the scene was stored per window but not the view layer. The reasoning was that you would use different view layers for different tasks. This is still possible, but it's more predictable to switch them both explicitly, and with child window support manually syncing the view layers between multiple windows is no longer needed as often. --- source/blender/blenkernel/BKE_layer.h | 2 +- source/blender/blenkernel/BKE_workspace.h | 28 ------ source/blender/blenkernel/intern/context.c | 12 ++- source/blender/blenkernel/intern/layer.c | 30 ++++-- source/blender/blenkernel/intern/library_query.c | 4 - source/blender/blenkernel/intern/workspace.c | 101 --------------------- source/blender/blenloader/intern/readfile.c | 35 +------ source/blender/blenloader/intern/versioning_280.c | 19 ++-- source/blender/blenloader/intern/writefile.c | 6 +- source/blender/editors/include/ED_screen.h | 7 +- source/blender/editors/render/render_internal.c | 20 ++-- source/blender/editors/render/render_shading.c | 6 +- source/blender/editors/scene/scene_edit.c | 13 ++- source/blender/editors/screen/area.c | 4 +- source/blender/editors/screen/screen_context.c | 3 +- source/blender/editors/screen/screen_edit.c | 39 ++++---- source/blender/editors/screen/workspace_edit.c | 57 ++---------- .../editors/space_buttons/buttons_context.c | 22 +++-- .../editors/space_buttons/buttons_texture.c | 9 +- source/blender/editors/space_image/space_image.c | 1 + .../editors/space_outliner/outliner_select.c | 19 ++-- source/blender/makesdna/DNA_windowmanager_types.h | 3 +- source/blender/makesdna/DNA_workspace_types.h | 8 -- source/blender/makesrna/intern/rna_material.c | 3 +- source/blender/makesrna/intern/rna_wm.c | 9 +- source/blender/windowmanager/WM_api.h | 5 +- source/blender/windowmanager/WM_toolsystem.h | 8 +- source/blender/windowmanager/intern/wm.c | 1 + source/blender/windowmanager/intern/wm_draw.c | 3 +- .../blender/windowmanager/intern/wm_event_system.c | 17 +++- .../blender/windowmanager/intern/wm_toolsystem.c | 49 +++++----- source/blender/windowmanager/intern/wm_window.c | 100 +++++++++++++------- 32 files changed, 250 insertions(+), 393 deletions(-) diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index 9e89033894d..db0e5f21284 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -58,7 +58,7 @@ struct WorkSpace; struct ViewLayer *BKE_view_layer_default_view(const struct Scene *scene); struct ViewLayer *BKE_view_layer_default_render(const struct Scene *scene); -struct ViewLayer *BKE_view_layer_from_workspace_get(const struct Scene *scene, const struct WorkSpace *workspace); +struct ViewLayer *BKE_view_layer_find(const struct Scene *scene, const char *layer_name); struct ViewLayer *BKE_view_layer_add(struct Scene *scene, const char *name); /* DEPRECATED */ diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h index 03d24ac53d1..4f4ae9f375b 100644 --- a/source/blender/blenkernel/BKE_workspace.h +++ b/source/blender/blenkernel/BKE_workspace.h @@ -54,23 +54,11 @@ void BKE_workspace_layout_remove( void BKE_workspace_relations_free( ListBase *relation_list); -void BKE_workspace_scene_relations_free_invalid( - struct WorkSpace *workspace); /* -------------------------------------------------------------------- */ /* General Utils */ -void BKE_workspace_view_layer_rename( - const struct Main *bmain, - const struct Scene *scene, - const char *old_name, - const char *new_name) ATTR_NONNULL(); - -void BKE_workspace_view_layer_remove( - const struct Main *bmain, - const struct ViewLayer *view_layer) ATTR_NONNULL(); - struct WorkSpaceLayout *BKE_workspace_layout_find( const struct WorkSpace *workspace, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; struct WorkSpaceLayout *BKE_workspace_layout_find_global( @@ -97,17 +85,6 @@ struct bScreen *BKE_workspace_active_screen_get(const struct WorkSpaceInstanceHo void BKE_workspace_active_screen_set( struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct bScreen *screen) SETTER_ATTRS; -struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace, const struct Scene *scene); -struct ViewLayer *BKE_workspace_view_layer_get( - const struct WorkSpace *workspace, - const struct Scene *scene) GETTER_ATTRS; -struct ViewLayer *BKE_workspace_view_layer_exists( - const struct WorkSpace *workspace, - const struct Scene *scene) GETTER_ATTRS; -void BKE_workspace_view_layer_set( - struct WorkSpace *workspace, - struct ViewLayer *layer, - struct Scene *scene) SETTER_ATTRS; struct ListBase *BKE_workspace_layouts_get(struct WorkSpace *workspace) GETTER_ATTRS; const char *BKE_workspace_layout_name_get(const struct WorkSpaceLayout *layout) GETTER_ATTRS; @@ -121,11 +98,6 @@ struct WorkSpaceLayout *BKE_workspace_hook_layout_for_workspace_get( void BKE_workspace_hook_layout_for_workspace_set( struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL(); -/* Update / evaluate */ -void BKE_workspace_update_tagged(struct Main *bmain, - struct WorkSpace *workspace, - struct Scene *scene); - bool BKE_workspace_owner_id_check( const struct WorkSpace *workspace, const char *owner_id) ATTR_NONNULL(); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index ee907fa496f..1aaf5e4f485 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -926,9 +926,17 @@ ViewLayer *CTX_data_view_layer(const bContext *C) if (ctx_data_pointer_verify(C, "view_layer", (void *)&view_layer)) { return view_layer; } - else { - return BKE_view_layer_from_workspace_get(CTX_data_scene(C), CTX_wm_workspace(C)); + + wmWindow *win = CTX_wm_window(C); + Scene *scene = CTX_data_scene(C); + if (win) { + view_layer = BKE_view_layer_find(scene, win->view_layer_name); + if (view_layer) { + return view_layer; + } } + + return BKE_view_layer_default_view(scene); } RenderEngineType *CTX_data_engine_type(const bContext *C) diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 22188d25df5..80329a1d328 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -42,7 +42,6 @@ #include "BKE_layer.h" #include "BKE_main.h" #include "BKE_node.h" -#include "BKE_workspace.h" #include "BKE_object.h" #include "DNA_group_types.h" @@ -130,17 +129,22 @@ ViewLayer *BKE_view_layer_default_render(const Scene *scene) return scene->view_layers.first; } -/** - * Returns the ViewLayer to be used for drawing, outliner, and other context related areas. - */ -ViewLayer *BKE_view_layer_from_workspace_get(const struct Scene *scene, const struct WorkSpace *workspace) +/* Returns view layer with matching name, or NULL if not found. */ +ViewLayer *BKE_view_layer_find(const Scene *scene, const char *layer_name) { - return BKE_workspace_view_layer_get(workspace, scene); + for (ViewLayer *view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { + if (STREQ(view_layer->name, layer_name)) { + return view_layer; + } + } + + return NULL; } /** - * This is a placeholder to know which areas of the code need to be addressed for the Workspace changes. - * Never use this, you should either use BKE_view_layer_from_workspace_get or get ViewLayer explicitly. + * This is a placeholder to know which areas of the code need to be addressed + * for the Workspace changes. Never use this, you should typically get the + * active layer from the context or window. */ ViewLayer *BKE_view_layer_context_active_PLACEHOLDER(const Scene *scene) { @@ -418,9 +422,15 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con } } - /* fix all the animation data and workspace which may link to this */ + /* fix all the animation data and windows which may link to this */ BKE_animdata_fix_paths_rename_all(NULL, "view_layers", oldname, view_layer->name); - BKE_workspace_view_layer_rename(bmain, scene, oldname, view_layer->name); + + wmWindowManager *wm = bmain->wm.first; + for (wmWindow *win = wm->windows.first; win; win = win->next) { + if (win->scene == scene && STREQ(win->view_layer_name, oldname)) { + STRNCPY(win->view_layer_name, view_layer->name); + } + } /* Dependency graph uses view layer name based lookups. */ DEG_id_tag_update(&scene->id, 0); diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index 54b73dad982..93fdd3349bf 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -936,10 +936,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call /* allow callback to set a different screen */ BKE_workspace_layout_screen_set(layout, screen); } - - for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first; relation; relation = relation->next) { - CALLBACK_INVOKE(relation->scene, IDWALK_CB_NOP); - } break; } case ID_GD: diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c index f0f57e8e56c..783baebd525 100644 --- a/source/blender/blenkernel/intern/workspace.c +++ b/source/blender/blenkernel/intern/workspace.c @@ -157,7 +157,6 @@ WorkSpace *BKE_workspace_add(Main *bmain, const char *name) void BKE_workspace_free(WorkSpace *workspace) { BKE_workspace_relations_free(&workspace->hook_layout_relations); - BLI_freelistN(&workspace->scene_layer_relations); BLI_freelistN(&workspace->owner_ids); BLI_freelistN(&workspace->layouts); @@ -267,48 +266,9 @@ void BKE_workspace_relations_free( } } -void BKE_workspace_scene_relations_free_invalid( - WorkSpace *workspace) -{ - for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first, *relation_next; relation; relation = relation_next) { - relation_next = relation->next; - - if (relation->scene == NULL) { - BLI_freelinkN(&workspace->scene_layer_relations, relation); - } - else if (!BLI_findstring(&relation->scene->view_layers, relation->view_layer, offsetof(ViewLayer, name))) { - BLI_freelinkN(&workspace->scene_layer_relations, relation); - } - } -} - /* -------------------------------------------------------------------- */ /* General Utils */ -void BKE_workspace_view_layer_rename( - const Main *bmain, - const Scene *scene, - const char *old_name, - const char *new_name) -{ - for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { - for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first; relation; relation = relation->next) { - if (relation->scene == scene && STREQ(relation->view_layer, old_name)) { - STRNCPY(relation->view_layer, new_name); - } - } - } -} - -void BKE_workspace_view_layer_remove( - const Main *bmain, - const ViewLayer *UNUSED(view_layer)) -{ - for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { - BKE_workspace_scene_relations_free_invalid(workspace); - } -} - WorkSpaceLayout *BKE_workspace_layout_find( const WorkSpace *workspace, const bScreen *screen) { @@ -429,46 +389,6 @@ void BKE_workspace_active_screen_set(WorkSpaceInstanceHook *hook, WorkSpace *wor BKE_workspace_hook_layout_for_workspace_set(hook, workspace, layout); } -Base *BKE_workspace_active_base_get(const WorkSpace *workspace, const Scene *scene) -{ - ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); - return view_layer->basact; -} - -ViewLayer *BKE_workspace_view_layer_exists(const WorkSpace *workspace, const Scene *scene) -{ - WorkSpaceSceneRelation *relation = BLI_findptr(&workspace->scene_layer_relations, scene, offsetof(WorkSpaceSceneRelation, scene)); - return (relation) ? BLI_findstring(&scene->view_layers, relation->view_layer, offsetof(ViewLayer, name)) : NULL; -} - -ViewLayer *BKE_workspace_view_layer_get(const WorkSpace *workspace, const Scene *scene) -{ - ViewLayer *layer = BKE_workspace_view_layer_exists(workspace, scene); - - if (layer == NULL) { - BKE_workspace_view_layer_set((WorkSpace *)workspace, scene->view_layers.first, (Scene *)scene); - layer = scene->view_layers.first; - } - - return layer; -} - -void BKE_workspace_view_layer_set(WorkSpace *workspace, ViewLayer *layer, Scene *scene) -{ - WorkSpaceSceneRelation *relation = BLI_findptr(&workspace->scene_layer_relations, scene, offsetof(WorkSpaceSceneRelation, scene)); - if (relation == NULL) { - relation = MEM_callocN(sizeof(*relation), __func__); - } - else { - BLI_remlink(&workspace->scene_layer_relations, relation); - } - - /* (Re)insert at the head of the list, for faster lookups. */ - relation->scene = scene; - STRNCPY(relation->view_layer, layer->name); - BLI_addhead(&workspace->scene_layer_relations, relation); -} - ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) { return &workspace->layouts; @@ -504,27 +424,6 @@ void BKE_workspace_hook_layout_for_workspace_set( workspace_relation_ensure_updated(&workspace->hook_layout_relations, hook, layout); } -/* Update / evaluate */ - -void BKE_workspace_update_tagged(Main *bmain, - WorkSpace *workspace, - Scene *scene) -{ - ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); - struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, - view_layer, - true); - /* TODO(sergey): For now all dependency graphs which are evaluated from - * workspace are considered active. This will work all fine with "locked" - * view layer and time across windows. This is to be granted separately, - * and for until then we have to accept ambiguities when object is shared - * across visible view layers and has overrides on it. - */ - DEG_make_active(depsgraph); - BKE_scene_graph_update_tagged(depsgraph, bmain); -} - - bool BKE_workspace_owner_id_check( const WorkSpace *workspace, const char *owner_id) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 4fa897bb689..b3a2d2f0b0b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2866,19 +2866,6 @@ static void direct_link_cachefile(FileData *fd, CacheFile *cache_file) /* ************ READ WORKSPACES *************** */ -static void lib_link_workspace_scene_data(FileData *fd, WorkSpace *workspace) -{ - for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first; - relation != NULL; - relation = relation->next) - { - relation->scene = newlibadr(fd, workspace->id.lib, relation->scene); - } - - /* Free any relations that got lost due to missing datablocks. */ - BKE_workspace_scene_relations_free_invalid(workspace); -} - static void lib_link_workspaces(FileData *fd, Main *bmain) { for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { @@ -2891,8 +2878,6 @@ static void lib_link_workspaces(FileData *fd, Main *bmain) IDP_LibLinkProperty(id->properties, fd); id_us_ensure_real(id); - lib_link_workspace_scene_data(fd, workspace); - for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) { bScreen *screen = newlibadr(fd, id->lib, BKE_workspace_layout_screen_get(layout)); @@ -2918,7 +2903,6 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main { link_list(fd, BKE_workspace_layouts_get(workspace)); link_list(fd, &workspace->hook_layout_relations); - link_list(fd, &workspace->scene_layer_relations); link_list(fd, &workspace->owner_ids); link_list(fd, &workspace->tools); @@ -7140,19 +7124,6 @@ static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map) BKE_sequencer_base_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map); } -static void lib_link_workspace_scene_data_restore(struct IDNameLib_Map *id_map, WorkSpace *workspace) -{ - for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first; - relation != NULL; - relation = relation->next) - { - relation->scene = restore_pointer_by_name(id_map, &relation->scene->id, USER_IGNORE); - } - - /* Free any relations that got lost due to missing datablocks or view layers. */ - BKE_workspace_scene_relations_free_invalid(workspace); -} - static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene) { bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); @@ -7415,9 +7386,6 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene struct IDNameLib_Map *id_map = BKE_main_idmap_create(newmain); for (WorkSpace *workspace = newmain->workspaces.first; workspace; workspace = workspace->id.next) { - lib_link_workspace_scene_data_restore(id_map, workspace); - BKE_workspace_view_layer_set(workspace, cur_view_layer, curscene); - ListBase *layouts = BKE_workspace_layouts_get(workspace); for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { @@ -7436,6 +7404,9 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene if (win->scene == NULL) { win->scene = curscene; } + if (BKE_view_layer_find(win->scene, win->view_layer_name) == NULL) { + STRNCPY(win->view_layer_name, cur_view_layer->name); + } BKE_workspace_active_set(win->workspace_hook, workspace); /* keep cursor location through undo */ diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 757e17ce82b..3bdd4db3b94 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -97,15 +97,10 @@ static void do_version_workspaces_create_from_screens(Main *bmain) { for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { const bScreen *screen_parent = screen_parent_find(screen); - Scene *scene = screen->scene; WorkSpace *workspace; - ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay); if (screen->temp) { continue; } - if (!layer) { - layer = BKE_view_layer_default_view(scene); - } if (screen_parent) { /* fullscreen with "Back to Previous" option, don't create @@ -117,7 +112,6 @@ static void do_version_workspaces_create_from_screens(Main *bmain) workspace = BKE_workspace_add(bmain, screen->id.name + 2); } BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2); - BKE_workspace_view_layer_set(workspace, layer, scene); } } @@ -178,7 +172,16 @@ static void do_version_workspaces_after_lib_link(Main *bmain) BKE_workspace_active_set(win->workspace_hook, workspace); BKE_workspace_active_layout_set(win->workspace_hook, layouts->first); - win->scene = screen->scene; + /* Move scene and view layer to window. */ + Scene *scene = screen->scene; + ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay); + if (!layer) { + layer = BKE_view_layer_default_view(scene); + } + + win->scene = scene; + STRNCPY(win->view_layer_name, layer->name); + /* Deprecated from now on! */ win->screen = NULL; } @@ -594,7 +597,7 @@ void do_versions_after_linking_280(Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) { for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { /* same render-layer as do_version_workspaces_after_lib_link will activate, - * so same layer as BKE_view_layer_from_workspace_get would return */ + * so same layer as BKE_view_layer_default_view would return */ ViewLayer *layer = screen->scene->view_layers.first; for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 146494e6196..0a2d09d0c86 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -166,6 +166,7 @@ #include "BKE_constraint.h" #include "BKE_global.h" // for G #include "BKE_idcode.h" +#include "BKE_layer.h" #include "BKE_library.h" // for set_listbasepointers #include "BKE_library_override.h" #include "BKE_main.h" @@ -1147,7 +1148,6 @@ static void current_screen_compat( { wmWindowManager *wm; wmWindow *window = NULL; - WorkSpace *workspace; /* find a global current screen in the first open window, to have * a reasonable default for reading in older versions */ @@ -1171,11 +1171,10 @@ static void current_screen_compat( window = wm->windows.first; } } - workspace = (window) ? BKE_workspace_active_get(window->workspace_hook) : NULL; *r_screen = (window) ? BKE_workspace_active_screen_get(window->workspace_hook) : NULL; *r_scene = (window) ? window->scene : NULL; - *r_render_layer = (window) ? BKE_workspace_view_layer_get(workspace, *r_scene) : NULL; + *r_render_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) : NULL; } typedef struct RenderInfo { @@ -3646,7 +3645,6 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace) writestruct(wd, ID_WS, WorkSpace, 1, workspace); writelist(wd, DATA, WorkSpaceLayout, layouts); writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations); - writelist(wd, DATA, WorkSpaceSceneRelation, &workspace->scene_layer_relations); writelist(wd, DATA, wmOwnerID, &workspace->owner_ids); writelist(wd, DATA, bToolRef, &workspace->tools); for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index cc80108e20c..2b0729a8e13 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -204,9 +204,7 @@ void ED_screen_preview_render(const struct bScreen *screen, int size_x, int s /* workspaces */ struct WorkSpace *ED_workspace_add( struct Main *bmain, - const char *name, - Scene *scene, - ViewLayer *act_render_layer) ATTR_NONNULL(); + const char *name) ATTR_NONNULL(); bool ED_workspace_change( struct WorkSpace *workspace_new, struct bContext *C, @@ -220,9 +218,6 @@ bool ED_workspace_delete( struct wmWindowManager *wm) ATTR_NONNULL(); void ED_workspace_scene_data_sync( struct WorkSpaceInstanceHook *hook, Scene *scene) ATTR_NONNULL(); -void ED_workspace_view_layer_unset( - const struct Main *bmain, struct Scene *scene, - const ViewLayer *layer_unset, ViewLayer *layer_new) ATTR_NONNULL(1, 2); struct WorkSpaceLayout *ED_workspace_layout_add( struct Main *bmain, struct WorkSpace *workspace, diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 1385baa51ad..ae364828119 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -66,7 +66,6 @@ #include "BKE_screen.h" #include "BKE_scene.h" #include "BKE_undo_system.h" -#include "BKE_workspace.h" #include "DEG_depsgraph.h" @@ -263,7 +262,7 @@ static void image_buffer_rect_update(RenderJob *rj, RenderResult *rr, ImBuf *ibu /* set callbacks, exported to sequence render too. * Only call in foreground (UI) renders. */ -static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpace *workspace, Scene **scene, ViewLayer **single_layer) +static void screen_render_single_layer_set(wmOperator *op, Main *mainp, ViewLayer *active_layer, Scene **scene, ViewLayer **single_layer) { /* single layer re-render */ if (RNA_struct_property_is_set(op->ptr, "scene")) { @@ -292,8 +291,8 @@ static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpac if (rl) *single_layer = rl; } - else if (((*scene)->r.scemode & R_SINGLE_LAYER) && workspace) { - *single_layer = BKE_view_layer_from_workspace_get(*scene, workspace); + else if (((*scene)->r.scemode & R_SINGLE_LAYER) && active_layer) { + *single_layer = active_layer; } } @@ -302,12 +301,12 @@ static int screen_render_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); RenderEngineType *re_type = RE_engines_find(scene->r.engine); + ViewLayer *active_layer = CTX_data_view_layer(C); ViewLayer *single_layer = NULL; Render *re; Image *ima; View3D *v3d = CTX_wm_view3d(C); Main *mainp = CTX_data_main(C); - WorkSpace *workspace = CTX_wm_workspace(C); unsigned int lay_override; const bool is_animation = RNA_boolean_get(op->ptr, "animation"); const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); @@ -319,7 +318,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) } /* custom scene and single layer re-render */ - screen_render_single_layer_set(op, mainp, workspace, &scene, &single_layer); + screen_render_single_layer_set(op, mainp, active_layer, &scene, &single_layer); if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); @@ -846,8 +845,7 @@ static void clean_viewport_memory(Main *bmain, Scene *scene) /* Go over all the visible objects. */ for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { for (wmWindow *win = wm->windows.first; win; win = win->next) { - WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); for (base = view_layer->object_bases.first; base; base = base->next) { clean_viewport_memory_base(base); @@ -865,8 +863,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even { /* new render clears all callbacks */ Main *bmain = CTX_data_main(C); - ViewLayer *single_layer = NULL; Scene *scene = CTX_data_scene(C); + ViewLayer *active_layer = CTX_data_view_layer(C); + ViewLayer *single_layer = NULL; RenderEngineType *re_type = RE_engines_find(scene->r.engine); Render *re; wmJob *wm_job; @@ -877,7 +876,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); const bool use_viewport = RNA_boolean_get(op->ptr, "use_viewport"); View3D *v3d = use_viewport ? CTX_wm_view3d(C) : NULL; - WorkSpace *workspace = CTX_wm_workspace(C); struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; const char *name; ScrArea *sa; @@ -888,7 +886,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even } /* custom scene and single layer re-render */ - screen_render_single_layer_set(op, bmain, workspace, &scene, &single_layer); + screen_render_single_layer_set(op, bmain, active_layer, &scene, &single_layer); /* only one render job at a time */ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 31f25720f8d..07e0c124998 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -615,12 +615,12 @@ void WORLD_OT_new(wmOperatorType *ot) static int view_layer_add_exec(bContext *C, wmOperator *UNUSED(op)) { - WorkSpace *workspace = CTX_wm_workspace(C); + wmWindow *win = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = BKE_view_layer_add(scene, NULL); - if (workspace) { - BKE_workspace_view_layer_set(workspace, view_layer, scene); + if (win) { + WM_window_set_active_view_layer(win, view_layer); } DEG_id_tag_update(&scene->id, 0); diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c index 0ebbd770c9f..62933178266 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -23,9 +23,11 @@ */ #include +#include #include "BLI_compiler_attrs.h" #include "BLI_listbase.h" +#include "BLI_string.h" #include "BKE_context.h" #include "BKE_global.h" @@ -175,12 +177,17 @@ bool ED_scene_view_layer_delete( BLI_remlink(&scene->view_layers, layer); BLI_assert(BLI_listbase_is_empty(&scene->view_layers) == false); - ED_workspace_view_layer_unset(bmain, scene, layer, scene->view_layers.first); + /* Remove from windows. */ + wmWindowManager *wm = bmain->wm.first; + for (wmWindow *win = wm->windows.first; win; win = win->next) { + if (win->scene == scene && STREQ(win->view_layer_name, layer->name)) { + ViewLayer *first_layer = BKE_view_layer_default_view(scene); + STRNCPY(win->view_layer_name, first_layer->name); + } + } BKE_view_layer_free(layer); - BKE_workspace_view_layer_remove(bmain, layer); - DEG_id_tag_update(&scene->id, 0); DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_SCENE | ND_LAYER | NA_REMOVED, scene); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 5cb440d315b..77e178bf0b2 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1482,7 +1482,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) { WorkSpace *workspace = WM_window_get_active_workspace(win); const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); ARegion *ar; rcti rect, overlap_rect; rcti window_rect; @@ -1542,7 +1542,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV); } - WM_toolsystem_refresh_screen_area(workspace, scene, sa); + WM_toolsystem_refresh_screen_area(workspace, view_layer, sa); } static void region_update_rect(ARegion *ar) diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index fa18826005e..17b1af29010 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -91,8 +91,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bScreen *sc = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); Scene *scene = WM_window_get_active_scene(win); - WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obact = (view_layer && view_layer->basact) ? view_layer->basact->object : NULL; Object *obedit = view_layer ? OBEDIT_FROM_VIEW_LAYER(view_layer) : NULL; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 50609815168..8fbf74ed800 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -944,35 +944,36 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre } } -static ViewLayer *scene_change_get_new_view_layer(const WorkSpace *workspace, const Scene *scene_new) -{ - ViewLayer *layer_new = BKE_workspace_view_layer_exists(workspace, scene_new); - return layer_new ? layer_new : BKE_view_layer_default_view(scene_new); -} - void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene) { - const bScreen *screen = WM_window_get_active_screen(win); - WorkSpace *workspace = CTX_wm_workspace(C); - ViewLayer *view_layer = scene_change_get_new_view_layer(workspace, scene); - #if 0 - /* mode syncing */ - Object *obact_new = OBACT(view_layer); - UNUSED_VARS(obact_new); - eObjectMode object_mode_old = workspace->object_mode; - ViewLayer *layer_old = BKE_view_layer_from_workspace_get(scene_old, workspace); - Object *obact_old = OBACT(layer_old); - UNUSED_VARS(obact_old, object_mode_old); + ViewLayer *view_layer_old = WM_window_get_active_view_layer(win); #endif - BKE_workspace_view_layer_set(workspace, view_layer, scene); - + /* Switch scene. */ win->scene = scene; if (CTX_wm_window(C) == win) { CTX_data_scene_set(C, scene); } + /* Ensure the view layer name is updated. */ + WM_window_ensure_active_view_layer(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + +#if 0 + /* Mode Syncing. */ + if (view_layer_old) { + WorkSpace *workspace = CTX_wm_workspace(C); + Object *obact_new = OBACT(view_layer); + UNUSED_VARS(obact_new); + eObjectMode object_mode_old = workspace->object_mode; + Object *obact_old = OBACT(view_layer_old); + UNUSED_VARS(obact_old, object_mode_old); + } +#endif + + /* Update 3D view cameras. */ + const bScreen *screen = WM_window_get_active_screen(win); for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 9ba9b70a6e8..705d8992900 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -75,55 +75,33 @@ * \brief API for managing workspaces and their data. * \{ */ -WorkSpace *ED_workspace_add( - Main *bmain, const char *name, Scene *scene, - ViewLayer *act_view_layer) +WorkSpace *ED_workspace_add(Main *bmain, const char *name) { - WorkSpace *workspace = BKE_workspace_add(bmain, name); - - BKE_workspace_view_layer_set(workspace, act_view_layer, scene); - - return workspace; + return BKE_workspace_add(bmain, name); } /** * Changes the object mode (if needed) to the one set in \a workspace_new. * Object mode is still stored on object level. In future it should all be workspace level instead. */ -static void workspace_change_update_mode( - const WorkSpace *workspace_old, const WorkSpace *workspace_new, - bContext *C, Object *ob_act, ReportList *reports) +static void workspace_change_update( + WorkSpace *workspace_new, const WorkSpace *workspace_old, + bContext *C, wmWindowManager *wm) { - UNUSED_VARS(workspace_old, workspace_new, C, ob_act, reports); + /* needs to be done before changing mode! (to ensure right context) */ + UNUSED_VARS(workspace_old, workspace_new, C, wm); #if 0 + Object *ob_act = CTX_data_active_object(C) eObjectMode mode_old = workspace_old->object_mode; eObjectMode mode_new = workspace_new->object_mode; if (mode_old != mode_new) { - ED_object_mode_compat_set(C, ob_act, mode_new, reports); + ED_object_mode_compat_set(C, ob_act, mode_new, &wm->reports); ED_object_mode_toggle(C, mode_new); } #endif } -static void workspace_change_update_view_layer( - WorkSpace *workspace_new, const WorkSpace *workspace_old, - Scene *scene) -{ - if (!BKE_workspace_view_layer_exists(workspace_new, scene)) { - BKE_workspace_view_layer_set(workspace_new, BKE_workspace_view_layer_get(workspace_old, scene), scene); - } -} - -static void workspace_change_update( - WorkSpace *workspace_new, const WorkSpace *workspace_old, - bContext *C, wmWindowManager *wm) -{ - /* needs to be done before changing mode! (to ensure right context) */ - workspace_change_update_view_layer(workspace_new, workspace_old, CTX_data_scene(C)); - workspace_change_update_mode(workspace_old, workspace_new, C, CTX_data_active_object(C), &wm->reports); -} - static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, void *UNUSED(arg)) { /* return false to stop the iterator if we've found a layout that can be activated */ @@ -199,7 +177,6 @@ bool ED_workspace_change( screen_change_update(C, win, screen_new); workspace_change_update(workspace_new, workspace_old, C, wm); - BLI_assert(BKE_workspace_view_layer_exists(workspace_new, CTX_data_scene(C)) != NULL); BLI_assert(CTX_wm_workspace(C) == workspace_new); WM_toolsystem_unlink_all(C, workspace_old); @@ -220,10 +197,7 @@ WorkSpace *ED_workspace_duplicate( { WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook); ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old); - Scene *scene = WM_window_get_active_scene(win); - WorkSpace *workspace_new = ED_workspace_add( - bmain, workspace_old->id.name + 2, scene, - BKE_workspace_view_layer_get(workspace_old, scene)); + WorkSpace *workspace_new = ED_workspace_add(bmain, workspace_old->id.name + 2); /* TODO(campbell): tools */ @@ -271,17 +245,6 @@ void ED_workspace_scene_data_sync( BKE_screen_view3d_scene_sync(screen, scene); } -void ED_workspace_view_layer_unset( - const Main *bmain, Scene *scene, - const ViewLayer *layer_unset, ViewLayer *layer_new) -{ - for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { - if (BKE_workspace_view_layer_get(workspace, scene) == layer_unset) { - BKE_workspace_view_layer_set(workspace, layer_new, scene); - } - } -} - /** \} Workspace API */ diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index dd943e7988d..4ad62ec705d 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -47,6 +47,7 @@ #include "DNA_world_types.h" #include "DNA_brush_types.h" #include "DNA_linestyle_types.h" +#include "DNA_windowmanager_types.h" #include "BKE_context.h" #include "BKE_action.h" @@ -70,6 +71,8 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "WM_api.h" + #include "buttons_intern.h" // own include static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type) @@ -114,11 +117,13 @@ static int buttons_context_path_scene(ButsContextPath *path) return RNA_struct_is_a(ptr->type, &RNA_Scene); } -static int buttons_context_path_view_layer(ButsContextPath *path, WorkSpace *workspace) +static int buttons_context_path_view_layer(ButsContextPath *path, wmWindow *win) { if (buttons_context_path_scene(path)) { Scene *scene = path->ptr[path->len - 1].data; - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); + ViewLayer *view_layer = (win->scene == scene) ? + WM_window_get_active_view_layer(win) : + BKE_view_layer_default_view(scene); RNA_pointer_create(&scene->id, &RNA_ViewLayer, view_layer, &path->ptr[path->len]); path->len++; @@ -159,7 +164,7 @@ static int buttons_context_path_world(ButsContextPath *path) return 0; } -static int buttons_context_path_linestyle(ButsContextPath *path, WorkSpace *workspace) +static int buttons_context_path_linestyle(ButsContextPath *path, wmWindow *window) { FreestyleLineStyle *linestyle; PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -169,7 +174,7 @@ static int buttons_context_path_linestyle(ButsContextPath *path, WorkSpace *work return 1; } /* if we have a view layer, use the lineset's linestyle */ - else if (buttons_context_path_view_layer(path, workspace)) { + else if (buttons_context_path_view_layer(path, window)) { ViewLayer *view_layer = path->ptr[path->len - 1].data; linestyle = BKE_linestyle_active_from_view_layer(view_layer); if (linestyle) { @@ -432,7 +437,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path else if (GS(id->name) == ID_OB) buttons_context_path_object(path); else if (GS(id->name) == ID_LS) - buttons_context_path_linestyle(path, CTX_wm_workspace(C)); + buttons_context_path_linestyle(path, CTX_wm_window(C)); } if (ct->texture) { @@ -472,8 +477,9 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma { SpaceButs *sbuts = CTX_wm_space_buts(C); Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + wmWindow *window = CTX_wm_window(C); WorkSpace *workspace = CTX_wm_workspace(C); - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); ID *id; int found; @@ -514,13 +520,13 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma case BCONTEXT_VIEW_LAYER: #ifdef WITH_FREESTYLE if (buttons_context_linestyle_pinnable(C, view_layer)) { - found = buttons_context_path_linestyle(path, workspace); + found = buttons_context_path_linestyle(path, window); if (found) { break; } } #endif - found = buttons_context_path_view_layer(path, workspace); + found = buttons_context_path_view_layer(path, window); break; case BCONTEXT_WORLD: found = buttons_context_path_world(path); diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 5feb74edef7..66684de18ac 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -49,6 +49,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_linestyle_types.h" +#include "DNA_windowmanager_types.h" #include "BKE_context.h" #include "BKE_layer.h" @@ -72,6 +73,8 @@ #include "ED_node.h" #include "ED_screen.h" +#include "WM_api.h" + #include "../interface/interface_intern.h" #include "buttons_intern.h" // own include @@ -176,8 +179,10 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * const ID_Type id_type = pinid != NULL ? GS(pinid->name) : -1; if (!pinid || id_type == ID_SCE) { - WorkSpace *workspace = CTX_wm_workspace(C); - ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); + wmWindow *win = CTX_wm_window(C); + ViewLayer *view_layer = (win->scene == scene) ? + WM_window_get_active_view_layer(win) : + BKE_view_layer_default_view(scene); brush = BKE_paint_brush(BKE_paint_get_active_from_context(C)); linestyle = BKE_linestyle_active_from_view_layer(view_layer); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 5c95d5944d1..9d89e21289d 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -51,6 +51,7 @@ #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_material.h" +#include "BKE_workspace.h" #include "DEG_depsgraph.h" diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 8a5df196c7b..bc514914b81 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -173,24 +173,25 @@ void outliner_object_mode_toggle( /* Outliner Element Selection/Activation on Click */ static eOLDrawState active_viewlayer( - bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) + bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, const eOLSetState set) { - Scene *sce; - /* paranoia check */ if (te->idcode != ID_SCE) return OL_DRAWSEL_NONE; - sce = (Scene *)tselem->id; - WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = te->directdata; if (set != OL_SETSEL_NONE) { - BKE_workspace_view_layer_set(workspace, view_layer, sce); - WM_event_add_notifier(C, NC_SCREEN | ND_LAYER, NULL); + wmWindow *win = CTX_wm_window(C); + Scene *scene = WM_window_get_active_scene(win); + + if (BLI_findindex(&scene->view_layers, view_layer) != -1) { + WM_window_set_active_view_layer(win, view_layer); + WM_event_add_notifier(C, NC_SCREEN | ND_LAYER, NULL); + } } else { - return BKE_workspace_view_layer_get(workspace, sce) == view_layer; + return CTX_data_view_layer(C) == view_layer; } return OL_DRAWSEL_NONE; } @@ -895,7 +896,7 @@ eOLDrawState tree_element_type_active( case TSE_CONSTRAINT: return tree_element_active_constraint(C, scene, view_layer, te, tselem, set); case TSE_R_LAYER: - return active_viewlayer(C, scene, view_layer, te, tselem, set); + return active_viewlayer(C, scene, view_layer, te, set); case TSE_POSEGRP: return tree_element_active_posegroup(C, scene, view_layer, te, tselem, set); case TSE_SEQUENCE: diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 0ef9e9b134a..bd2811d3306 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -188,8 +188,9 @@ typedef struct wmWindow { struct wmWindow *parent; /* Parent window */ - struct Scene *scene; /* The scene displayed in this window. */ + struct Scene *scene; /* Active scene displayed in this window. */ struct Scene *new_scene; /* temporary when switching */ + char view_layer_name[64]; /* Active view layer displayed in this window. */ struct WorkSpaceInstanceHook *workspace_hook; diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h index f07dc195455..2b0f74a54ee 100644 --- a/source/blender/makesdna/DNA_workspace_types.h +++ b/source/blender/makesdna/DNA_workspace_types.h @@ -129,7 +129,6 @@ typedef struct WorkSpace { /* Store for each hook (so for each window) which layout has * been activated the last time this workspace was visible. */ ListBase hook_layout_relations DNA_PRIVATE_WORKSPACE_READ_WRITE; /* WorkSpaceDataRelation */ - ListBase scene_layer_relations; /* WorkSpaceSceneRelation */ /* Feature tagging (use for addons) */ ListBase owner_ids DNA_PRIVATE_WORKSPACE_READ_WRITE; /* wmOwnerID */ @@ -190,13 +189,6 @@ typedef struct WorkSpaceDataRelation { #endif /* DNA_PRIVATE_WORKSPACE_READ_WRITE */ -typedef struct WorkSpaceSceneRelation { - struct WorkSpaceSceneRelation *next, *prev; - - struct Scene *scene; - char view_layer[64]; /* MAX_NAME */ -} WorkSpaceSceneRelation; - /** * Little wrapper to store data that is going to be per window, but comming from the workspace. * It allows us to keep workspace and window data completely separate. diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 26c281ad9e1..0a8ea99b8fb 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -148,8 +148,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s Object *obedit = NULL; { - WorkSpace *workspace = WM_window_get_active_workspace(win); - ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); } diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 569bc20d435..7dc8ab54800 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -773,8 +773,8 @@ static void rna_workspace_screen_update(bContext *C, PointerRNA *ptr) static PointerRNA rna_Window_view_layer_get(PointerRNA *ptr) { wmWindow *win = ptr->data; - Scene *scene; - ViewLayer *view_layer = WM_window_get_active_view_layer_ex(win, &scene); + Scene *scene = WM_window_get_active_scene(win);; + ViewLayer *view_layer = WM_window_get_active_view_layer(win); PointerRNA scene_ptr; RNA_id_pointer_create(&scene->id, &scene_ptr); @@ -784,10 +784,9 @@ static PointerRNA rna_Window_view_layer_get(PointerRNA *ptr) static void rna_Window_view_layer_set(PointerRNA *ptr, PointerRNA value) { wmWindow *win = ptr->data; - Scene *scene = WM_window_get_active_scene(win); - WorkSpace *workspace = WM_window_get_active_workspace(win); + ViewLayer *view_layer = value.data; - BKE_workspace_view_layer_set(workspace, value.data, scene); + WM_window_set_active_view_layer(win, view_layer); } static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 0ed23a8fb20..e203a872d24 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -112,7 +112,7 @@ struct WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm struct Scene *WM_window_get_active_scene(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; void WM_window_set_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win, - struct Scene *scene_new) ATTR_NONNULL(); + struct Scene *scene_new) ATTR_NONNULL(); struct WorkSpace *WM_window_get_active_workspace(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; void WM_window_set_active_workspace(struct bContext *C, struct wmWindow *win, struct WorkSpace *workspace) ATTR_NONNULL(1); struct WorkSpaceLayout *WM_window_get_active_layout(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; @@ -121,8 +121,9 @@ void WM_window_set_active_layout( struct bScreen *WM_window_get_active_screen(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; void WM_window_set_active_screen(struct wmWindow *win, struct WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL(1); -struct ViewLayer *WM_window_get_active_view_layer_ex(const struct wmWindow *win, struct Scene **r_scene) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; struct ViewLayer *WM_window_get_active_view_layer(const struct wmWindow *win) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; +void WM_window_set_active_view_layer(struct wmWindow *win, struct ViewLayer *view_layer) ATTR_NONNULL(1); +void WM_window_ensure_active_view_layer(struct wmWindow *win) ATTR_NONNULL(1); bool WM_window_is_temp_screen(const struct wmWindow *win) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 30470e17ed4..f4505bef962 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -73,11 +73,9 @@ void WM_toolsystem_ref_set_from_runtime( void WM_toolsystem_init(struct bContext *C); int WM_toolsystem_mode_from_spacetype( - struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa, - int space_type); + struct ViewLayer *view_layer, struct ScrArea *sa, int space_type); bool WM_toolsystem_key_from_context( - struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa, - bToolKey *tkey); + struct ViewLayer *view_layer, struct ScrArea *sa, bToolKey *tkey); void WM_toolsystem_update_from_context( struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa); @@ -95,7 +93,7 @@ void WM_toolsystem_ref_properties_ensure(struct bToolRef *tref, struct wmOperato void WM_toolsystem_ref_properties_init_for_keymap( struct bToolRef *tref, struct PointerRNA *dst_ptr, struct PointerRNA *src_ptr, struct wmOperatorType *ot); -void WM_toolsystem_refresh_screen_area(struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa); +void WM_toolsystem_refresh_screen_area(struct WorkSpace *workspace, struct ViewLayer *view_layer, struct ScrArea *sa); void WM_toolsystem_refresh_screen_all(struct Main *bmain); #ifdef __cplusplus diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 9ef0883cbbf..9e7136dc81d 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -463,6 +463,7 @@ void wm_add_default(Main *bmain, bContext *C) CTX_wm_manager_set(C, wm); win = wm_window_new(C, NULL); win->scene = CTX_data_scene(C); + STRNCPY(win->view_layer_name, CTX_data_view_layer(C)->name); BKE_workspace_active_set(win->workspace_hook, workspace); BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace, layout); screen->winid = win->winid; diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5b88268f416..5314c434c4c 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -729,9 +729,8 @@ static void wm_draw_window(bContext *C, wmWindow *win) /* quick test to prevent changing window drawable */ static bool wm_draw_update_test_window(wmWindow *win) { - struct WorkSpace *workspace = WM_window_get_active_workspace(win); Scene *scene = WM_window_get_active_scene(win); - ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); bScreen *screen = WM_window_get_active_screen(win); ARegion *ar; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 3aee57d5801..91b924c1565 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -317,6 +317,7 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) for (wmWindow *win = wm->windows.first; win; win = win->next) { const bScreen *screen = WM_window_get_active_screen(win); Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); ScrArea *sa; CTX_wm_window_set(C, win); @@ -338,9 +339,15 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) /* XXX, hack so operators can enforce datamasks [#26482], gl render */ scene->customdata_mask |= scene->customdata_mask_modal; - WorkSpace *workspace = WM_window_get_active_workspace(win); - - BKE_workspace_update_tagged(bmain, workspace, scene); + /* TODO(sergey): For now all dependency graphs which are evaluated from + * workspace are considered active. This will work all fine with "locked" + * view layer and time across windows. This is to be granted separately, + * and for until then we have to accept ambiguities when object is shared + * across visible view layers and has overrides on it. + */ + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); + DEG_make_active(depsgraph); + BKE_scene_graph_update_tagged(depsgraph, bmain); } } @@ -4380,11 +4387,11 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win) { bToolRef *tref = NULL; if (ar->regiontype == RGN_TYPE_WINDOW) { - Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); WorkSpace *workspace = WM_window_get_active_workspace(win); const bToolKey tkey = { .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), }; tref = WM_toolsystem_ref_find(workspace, &tkey); } diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index cee5079a02f..d06cc21ec21 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -69,11 +69,11 @@ static void toolsystem_refresh_screen_from_active_tool( struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C) { WorkSpace *workspace = CTX_wm_workspace(C); - Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); ScrArea *sa = CTX_wm_area(C); const bToolKey tkey = { .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); /* We could return 'sa->runtime.tool' in this case. */ @@ -192,8 +192,8 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre wmWindowManager *wm = bmain->wm.first; for (wmWindow *win = wm->windows.first; win; win = win->next) { if (workspace == WM_window_get_active_workspace(win)) { - Scene *scene = win->scene; - ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); + Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); Paint *paint = BKE_paint_get_active(scene, view_layer); if (paint) { if (brush) { @@ -261,12 +261,12 @@ void WM_toolsystem_refresh_all(struct bContext *C, struct WorkSpace *workspace) void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); - Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { WorkSpace *workspace = WM_window_get_active_workspace(win); const bToolKey tkey = { .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); if (tref) { @@ -331,11 +331,11 @@ void WM_toolsystem_init(bContext *C) CTX_wm_window_set(C, win); WorkSpace *workspace = WM_window_get_active_workspace(win); bScreen *screen = WM_window_get_active_screen(win); - Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { const bToolKey tkey = { .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); if (tref) { @@ -351,15 +351,13 @@ void WM_toolsystem_init(bContext *C) } int WM_toolsystem_mode_from_spacetype( - WorkSpace *workspace, Scene *scene, ScrArea *sa, - int spacetype) + ViewLayer *view_layer, ScrArea *sa, int spacetype) { int mode = -1; switch (spacetype) { case SPACE_VIEW3D: { /* 'sa' may be NULL in this case. */ - ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); Object *obact = OBACT(view_layer); if (obact != NULL) { Object *obedit = OBEDIT_FROM_OBACT(obact); @@ -381,15 +379,14 @@ int WM_toolsystem_mode_from_spacetype( } bool WM_toolsystem_key_from_context( - WorkSpace *workspace, Scene *scene, ScrArea *sa, - bToolKey *tkey) + ViewLayer *view_layer, ScrArea *sa, bToolKey *tkey) { int space_type = SPACE_EMPTY; int mode = -1; if (sa != NULL) { space_type = sa->spacetype; - mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, space_type); + mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, space_type); } if (mode != -1) { @@ -400,11 +397,11 @@ bool WM_toolsystem_key_from_context( return false; } -void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, Scene *scene, ScrArea *sa) +void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_layer, ScrArea *sa) { sa->runtime.tool = NULL; sa->runtime.is_tool_set = true; - const int mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype); + const int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype); for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { if (tref->space_type == sa->spacetype) { if (tref->mode == mode) { @@ -426,12 +423,12 @@ void WM_toolsystem_refresh_screen_all(Main *bmain) space_type_has_tools[tref->space_type] = true; } bScreen *screen = WM_window_get_active_screen(win); - Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { sa->runtime.tool = NULL; sa->runtime.is_tool_set = true; if (space_type_has_tools[sa->spacetype]) { - WM_toolsystem_refresh_screen_area(workspace, scene, sa); + WM_toolsystem_refresh_screen_area(workspace, view_layer, sa); } } } @@ -446,10 +443,10 @@ static void toolsystem_refresh_screen_from_active_tool( for (wmWindow *win = wm->windows.first; win; win = win->next) { if (workspace == WM_window_get_active_workspace(win)) { bScreen *screen = WM_window_get_active_screen(win); - Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { if (sa->spacetype == tref->space_type) { - int mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype); + int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype); if (mode == tref->mode) { sa->runtime.tool = tref; sa->runtime.is_tool_set = true; @@ -477,9 +474,9 @@ bToolRef *WM_toolsystem_ref_set_by_name( /* Will get from context if not set. */ bToolKey tkey_from_context; if (tkey == NULL) { - Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); ScrArea *sa = CTX_wm_area(C); - WM_toolsystem_key_from_context(workspace, scene, sa, &tkey_from_context); + WM_toolsystem_key_from_context(view_layer, sa, &tkey_from_context); tkey = &tkey_from_context; } @@ -526,11 +523,11 @@ static void toolsystem_reinit_ensure_toolref( void WM_toolsystem_update_from_context_view3d(bContext *C) { WorkSpace *workspace = CTX_wm_workspace(C); - Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); int space_type = SPACE_VIEW3D; const bToolKey tkey = { .space_type = space_type, - .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, NULL, space_type), + .mode = WM_toolsystem_mode_from_spacetype(view_layer, NULL, space_type), }; toolsystem_reinit_ensure_toolref(C, workspace, &tkey, "Cursor"); } @@ -549,12 +546,12 @@ void WM_toolsystem_do_msg_notify_tag_refresh( bContext *C, wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) { WorkSpace *workspace = CTX_wm_workspace(C); - Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); ScrArea *sa = msg_val->user_data; int space_type = sa->spacetype; const bToolKey tkey = { .space_type = space_type, - .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), }; WM_toolsystem_refresh(C, workspace, &tkey); } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index d28d2c6b001..f902c4377cc 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -53,6 +53,7 @@ #include "BKE_blender.h" #include "BKE_context.h" #include "BKE_icons.h" +#include "BKE_layer.h" #include "BKE_library.h" #include "BKE_global.h" #include "BKE_main.h" @@ -280,7 +281,6 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la wmWindow *win_dst = wm_window_new(C, win_parent); WorkSpace *workspace = WM_window_get_active_workspace(win_src); WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src); - Scene *scene = WM_window_get_active_scene(win_src); WorkSpaceLayout *layout_new; win_dst->posx = win_src->posx + 10; @@ -288,7 +288,8 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la win_dst->sizex = win_src->sizex; win_dst->sizey = win_src->sizey; - win_dst->scene = scene; + win_dst->scene = win_src->scene; + STRNCPY(win_dst->view_layer_name, win_src->view_layer_name); BKE_workspace_active_set(win_dst->workspace_hook, workspace); layout_new = duplicate_layout ? ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) : layout_old; BKE_workspace_hook_layout_for_workspace_set(win_dst->workspace_hook, workspace, layout_new); @@ -856,6 +857,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i bScreen *screen; ScrArea *sa; Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); const char *title; /* convert to native OS window coordinates */ @@ -912,12 +914,10 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i WM_window_set_active_layout(win, workspace, layout); } - if (win->scene == NULL) { - win->scene = scene; - } - /* In case we reuse an already existing temp window (see win lookup above). */ - else if (WM_window_get_active_scene(win) != scene) { - WM_window_set_active_scene(bmain, C, win, scene); + /* Set scene and view layer to match original window. */ + STRNCPY(win->view_layer_name, view_layer->name); + if (WM_window_get_active_scene(win) != scene) { + ED_screen_scene_change(C, win, scene); } screen->temp = 1; @@ -2128,22 +2128,72 @@ void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene * { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win_parent = (win->parent) ? win->parent : win; + bool changed = false; /* Set scene in parent and its child windows. */ - ED_screen_scene_change(C, win_parent, scene); + if (win_parent->scene != scene) { + ED_screen_scene_change(C, win_parent, scene); + changed = true; + } for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { - if (win_child->parent == win_parent) { + if (win_child->parent == win_parent && win_child->scene != scene) { ED_screen_scene_change(C, win_child, scene); + changed = true; } } - /* Update depsgraph and renderers for scene change. */ - ViewLayer *view_layer = WM_window_get_active_view_layer(win_parent); - ED_scene_change_update(bmain, scene, view_layer); + if (changed) { + /* Update depsgraph and renderers for scene change. */ + ViewLayer *view_layer = WM_window_get_active_view_layer(win_parent); + ED_scene_change_update(bmain, scene, view_layer); + + /* Complete redraw. */ + WM_event_add_notifier(C, NC_WINDOW, NULL); + } +} + +ViewLayer *WM_window_get_active_view_layer(const wmWindow *win) +{ + Scene *scene = WM_window_get_active_scene(win); + if (scene == NULL) { + return NULL; + } + + ViewLayer *view_layer = BKE_view_layer_find(scene, win->view_layer_name); + if (view_layer) { + return view_layer; + } - /* Complete redraw. */ - WM_event_add_notifier(C, NC_WINDOW, NULL); + return BKE_view_layer_default_view(scene); +} + +void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer) +{ + BLI_assert(BKE_view_layer_find(WM_window_get_active_scene(win), view_layer->name) != NULL); + + wmWindowManager *wm = G_MAIN->wm.first; + wmWindow *win_parent = (win->parent) ? win->parent : win; + + /* Set view layer in parent and child windows. */ + STRNCPY(win->view_layer_name, view_layer->name); + + for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { + if (win_child->parent == win_parent) { + STRNCPY(win_child->view_layer_name, view_layer->name); + } + } +} + +void WM_window_ensure_active_view_layer(wmWindow *win) +{ + /* Update layer name is correct after scene changes, load without UI, etc. */ + Scene *scene = WM_window_get_active_scene(win); + + if (scene && BKE_view_layer_find(scene, win->view_layer_name) == NULL) { + ViewLayer *view_layer = BKE_view_layer_default_view(scene); + STRNCPY(win->view_layer_name, view_layer->name); + } } WorkSpace *WM_window_get_active_workspace(const wmWindow *win) @@ -2189,26 +2239,6 @@ void WM_window_set_active_screen(wmWindow *win, WorkSpace *workspace, bScreen *s BKE_workspace_active_screen_set(win->workspace_hook, workspace, screen); } -struct ViewLayer *WM_window_get_active_view_layer_ex(const wmWindow *win, Scene **r_scene) -{ - const WorkSpace *workspace = WM_window_get_active_workspace(win); - Scene *scene = WM_window_get_active_scene(win); - /* May be NULL in rare cases like closing Blender */ - bScreen *screen = (LIKELY(workspace != NULL) ? BKE_workspace_active_screen_get(win->workspace_hook) : NULL); - if (screen != NULL) { - if (r_scene) { - *r_scene = scene; - } - return BKE_workspace_view_layer_get(workspace, scene); - } - return NULL; -} - -struct ViewLayer *WM_window_get_active_view_layer(const wmWindow *win) -{ - return WM_window_get_active_view_layer_ex(win, NULL); -} - bool WM_window_is_temp_screen(const wmWindow *win) { const bScreen *screen = WM_window_get_active_screen(win); -- cgit v1.2.3 From 535fec06612799c2355525fa5332780e2472caac Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Jul 2018 18:22:29 +0200 Subject: Workspaces: change behavior when window layout for workspace is missing. When switching the workspace in a window that does not yet have a layout for the newly active workspace, we now duplicate the layout from the previously active workspace. Previously it duplicated the layout from the first window in the newly active workspace. --- source/blender/editors/screen/workspace_edit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 705d8992900..e54a764faa7 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -112,6 +112,7 @@ static WorkSpaceLayout *workspace_change_get_new_layout( Main *bmain, WorkSpace *workspace_new, wmWindow *win) { /* ED_workspace_duplicate may have stored a layout to activate once the workspace gets activated. */ + WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); WorkSpaceLayout *layout_new; bScreen *screen_new; @@ -132,8 +133,8 @@ static WorkSpaceLayout *workspace_change_get_new_layout( workspace_new, layout_new, workspace_change_find_new_layout_cb, NULL, false); if (!layout_temp) { - /* fallback solution: duplicate layout */ - layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_new, win); + /* fallback solution: duplicate layout from old workspace */ + layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_old, win); } layout_new = layout_temp; } -- cgit v1.2.3 From 53c63db2ee1bd544384840915c7f562819a7dbbc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Jul 2018 19:11:45 +0200 Subject: Fix issue with closing child windows in recent changes. --- source/blender/windowmanager/intern/wm_window.c | 41 ++++++++++++------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index f902c4377cc..e4ccf074bab 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -474,29 +474,26 @@ void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win) /* this is event from ghost, or exit-blender op */ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) { - wmWindow *tmpwin; - - /* first check if we have to quit (there are non-temp and non-child windows remaining) */ - if (win->parent == NULL) { - for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) { - if (tmpwin == win) - continue; - if (tmpwin->parent == NULL) - break; - if (WM_window_is_temp_screen(tmpwin) == false) - break; + /* First check if there is another main window remaining. */ + wmWindow *win_other; + for (win_other = wm->windows.first; win_other; win_other = win_other->next) { + if (win_other != win && + win_other->parent == NULL && + !WM_window_is_temp_screen(win_other)) + { + break; } + } - if (tmpwin == NULL) { - wm_quit_with_optional_confirmation_prompt(C, win); - return; - } + if (win->parent == NULL && win_other == NULL) { + wm_quit_with_optional_confirmation_prompt(C, win); + return; } /* close child windows */ - for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) { - if (tmpwin->parent == win) { - wm_window_close(C, wm, tmpwin); + for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { + if (win_child->parent == win) { + wm_window_close(C, wm, win_child); } } @@ -516,7 +513,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) ED_screen_exit(C, win, screen); } - if (tmpwin) { + if (win_other) { BLF_batch_reset(); gpu_batch_presets_reset(); immDeactivate(); @@ -525,9 +522,9 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) wm_window_free(C, wm, win); /* keep imediatemode active before the next `wm_window_make_drawable` call */ - if (tmpwin) { - GHOST_ActivateWindowDrawingContext(tmpwin->ghostwin); - GWN_context_active_set(tmpwin->gwnctx); + if (win_other) { + GHOST_ActivateWindowDrawingContext(win_other->ghostwin); + GWN_context_active_set(win_other->gwnctx); immActivate(); } -- cgit v1.2.3 From cd17b3258327522b8c6f56a3ee7239a91f2be149 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 07:53:21 +0200 Subject: Cleanup: pep8 --- doc/python_api/sphinx_doc_update.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/python_api/sphinx_doc_update.py b/doc/python_api/sphinx_doc_update.py index d43806d128a..af44137aca4 100755 --- a/doc/python_api/sphinx_doc_update.py +++ b/doc/python_api/sphinx_doc_update.py @@ -107,9 +107,11 @@ def main(): with tempfile.TemporaryDirectory() as tmp_dir: # II) Generate doc source in temp dir. - doc_gen_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1", - "--python", "%s/doc/python_api/sphinx_doc_gen.py" % args.source_dir, "--", - "--output", tmp_dir) + doc_gen_cmd = ( + args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1", + "--python", "%s/doc/python_api/sphinx_doc_gen.py" % args.source_dir, "--", + "--output", tmp_dir + ) subprocess.run(doc_gen_cmd) # III) Get Blender version info. -- cgit v1.2.3 From 30680b8d51caada48a4f773caee8b934f06e3f30 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 08:16:22 +0200 Subject: Keymap: use Shift-Space for auto-complete Resolve conflict w/ maximized area. --- source/blender/editors/space_console/space_console.c | 3 +-- source/blender/editors/space_text/space_text.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 23ef2e50b5f..18a83bc2100 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -333,8 +333,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "interactive", true); - //WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", TABKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */ - WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */ + WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_SHIFT, 0); /* python operator - space_text.py */ #endif WM_keymap_add_item(keymap, "CONSOLE_OT_copy_as_script", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index ac43d7de408..30f1f2a789f 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -391,7 +391,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "TEXT_MT_toolbox", RIGHTMOUSE, KM_PRESS, KM_ANY, 0); - WM_keymap_add_item(keymap, "TEXT_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_autocomplete", SPACEKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "TEXT_OT_line_number", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last! -- cgit v1.2.3 From edd59aa2be375170515fb8bd54ecafecbdbc068c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 08:27:42 +0200 Subject: Revert "Keymap: use Shift-Space for auto-complete" This reverts commit 30680b8d51caada48a4f773caee8b934f06e3f30. Conflicts with typing in capitals. --- source/blender/editors/space_console/space_console.c | 2 +- source/blender/editors/space_text/space_text.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 18a83bc2100..3a48d5ad7dd 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -333,7 +333,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "interactive", true); - WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_SHIFT, 0); /* python operator - space_text.py */ + WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */ #endif WM_keymap_add_item(keymap, "CONSOLE_OT_copy_as_script", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 30f1f2a789f..ac43d7de408 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -391,7 +391,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "TEXT_MT_toolbox", RIGHTMOUSE, KM_PRESS, KM_ANY, 0); - WM_keymap_add_item(keymap, "TEXT_OT_autocomplete", SPACEKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "TEXT_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_line_number", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last! -- cgit v1.2.3 From 99a6d616e85f8a06dfd3d825f8e3cd350e35f61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 5 Jul 2018 10:12:36 +0200 Subject: Ported CDDM_apply_vert_normals from DM to Mesh --- source/blender/blenkernel/BKE_mesh.h | 1 + source/blender/blenkernel/intern/mesh.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index c87c22953f1..ee6f1c326ed 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -204,6 +204,7 @@ int BKE_mesh_mselect_active_get(struct Mesh *me, int type); void BKE_mesh_mselect_active_set(struct Mesh *me, int index, int type); void BKE_mesh_apply_vert_coords(struct Mesh *mesh, float (*vertCoords)[3]); +void BKE_mesh_apply_vert_normals(struct Mesh *mesh, short (*vertNormals)[3]); /* *** mesh_evaluate.c *** */ diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index b13f45499f1..5c9736c2620 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1511,6 +1511,21 @@ void BKE_mesh_apply_vert_coords(Mesh *mesh, float (*vertCoords)[3]) mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL; } +void BKE_mesh_apply_vert_normals(Mesh *mesh, short (*vertNormals)[3]) +{ + MVert *vert; + int i; + + /* this will just return the pointer if it wasn't a referenced layer */ + vert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert); + mesh->mvert = vert; + + for (i = 0; i < mesh->totvert; ++i, ++vert) + copy_v3_v3_short(vert->no, vertNormals[i]); + + mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL; +} + /** * Compute 'split' (aka loop, or per face corner's) normals. * -- cgit v1.2.3 From f4ce6d02cde816c3c681702d97a75617b8e9a598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 5 Jul 2018 11:08:05 +0200 Subject: Fluidsim: ported from DerivedMesh to Mesh Also removed a bunch of unnecessary #include statements from fluidsim.c. --- source/blender/blenkernel/BKE_DerivedMesh.h | 4 -- source/blender/blenkernel/BKE_mesh_runtime.h | 9 +++ source/blender/blenkernel/intern/DerivedMesh.c | 15 +++++ source/blender/blenkernel/intern/fluidsim.c | 35 +++-------- source/blender/modifiers/intern/MOD_fluidsim.c | 19 +++--- .../blender/modifiers/intern/MOD_fluidsim_util.c | 71 +++++++++++----------- .../blender/modifiers/intern/MOD_fluidsim_util.h | 6 +- 7 files changed, 81 insertions(+), 78 deletions(-) diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 3099875c145..e497e84b7e0 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -530,10 +530,6 @@ DerivedMesh *getEditDerivedBMesh( struct BMEditMesh *em, struct Object *ob, CustomDataMask data_mask, float (*vertexCos)[3]); -DerivedMesh *mesh_create_derived_index_render( - struct Depsgraph *depsgraph, struct Scene *scene, - struct Object *ob, CustomDataMask dataMask, int index); - /* same as above but wont use render settings */ DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]); DerivedMesh *mesh_create_derived_view( diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h index f894f72e648..8ff097eb61b 100644 --- a/source/blender/blenkernel/BKE_mesh_runtime.h +++ b/source/blender/blenkernel/BKE_mesh_runtime.h @@ -85,6 +85,15 @@ struct Mesh *mesh_get_eval_deform( struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, CustomDataMask dataMask); +#ifdef USE_DERIVEDMESH +struct DerivedMesh *mesh_create_derived_index_render( + struct Depsgraph *depsgraph, struct Scene *scene, + struct Object *ob, CustomDataMask dataMask, int index); +#endif +struct Mesh *mesh_create_eval_final_index_render( + struct Depsgraph *depsgraph, struct Scene *scene, + struct Object *ob, CustomDataMask dataMask, int index); + void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb); /* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */ diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 4aee616580e..4fe689523e0 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -3156,6 +3156,8 @@ DerivedMesh *mesh_create_derived_render(struct Depsgraph *depsgraph, Scene *scen return final; } +#ifdef USE_DERIVEDMESH +/* Deprecated, use `mesh_create_eval_final_index_render` instead. */ DerivedMesh *mesh_create_derived_index_render(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask, int index) { DerivedMesh *final; @@ -3166,6 +3168,19 @@ DerivedMesh *mesh_create_derived_index_render(struct Depsgraph *depsgraph, Scene return final; } +#endif +struct Mesh *mesh_create_eval_final_index_render( + struct Depsgraph *depsgraph, struct Scene *scene, + struct Object *ob, CustomDataMask dataMask, int index) +{ + Mesh *final; + + mesh_calc_modifiers( + depsgraph, scene, ob, NULL, 1, false, dataMask, index, false, false, false, + NULL, &final); + + return final; +} DerivedMesh *mesh_create_derived_view( struct Depsgraph *depsgraph, Scene *scene, diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 87bc819c34f..bf1532bab42 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -30,36 +30,21 @@ */ -// headers for fluidsim bobj meshes -#include -#include -#include -#include - #include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "DNA_object_fluidsim_types.h" -#include "DNA_object_force_types.h" // for pointcache #include "DNA_object_types.h" -#include "DNA_particle_types.h" -#include "DNA_scene_types.h" #include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" #include "BKE_customdata.h" -#include "BKE_DerivedMesh.h" #include "BKE_fluidsim.h" -#include "BKE_modifier.h" -#include "BKE_mesh.h" +#include "BKE_library.h" +#include "BKE_mesh_runtime.h" /* ************************* fluidsim bobj file handling **************************** */ - //------------------------------------------------------------------------------- // file handling //------------------------------------------------------------------------------- @@ -69,7 +54,7 @@ void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Obj int *numTriangles, int **triangles, int useGlobalCoords, int modifierIndex) { - DerivedMesh *dm; + Mesh *mesh; const MVert *mvert; const MLoop *mloop; const MLoopTri *looptri, *lt; @@ -77,13 +62,13 @@ void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Obj float *verts; int *tris; - dm = mesh_create_derived_index_render(depsgraph, scene, ob, CD_MASK_BAREMESH, modifierIndex); + mesh = mesh_create_eval_final_index_render(depsgraph, scene, ob, CD_MASK_BAREMESH, modifierIndex); - mvert = dm->getVertArray(dm); - mloop = dm->getLoopArray(dm); - looptri = dm->getLoopTriArray(dm); - mvert_num = dm->getNumVerts(dm); - looptri_num = dm->getNumLoopTri(dm); + mvert = mesh->mvert; + mloop = mesh->mloop; + looptri = BKE_mesh_runtime_looptri_ensure(mesh); + mvert_num = mesh->totvert; + looptri_num = mesh->runtime.looptris.len; *numVertices = mvert_num; verts = MEM_mallocN(mvert_num * sizeof(float[3]), "elbeemmesh_vertices"); @@ -102,5 +87,5 @@ void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Obj } *triangles = tris; - dm->release(dm); + BKE_id_free(NULL, mesh); } diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index 6e322dc7016..bb87d0065fe 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -33,14 +33,13 @@ */ +#include "DNA_mesh_types.h" #include "DNA_scene_types.h" #include "DNA_object_fluidsim_types.h" #include "DNA_object_types.h" #include "BLI_utildefines.h" - -#include "BKE_cdderivedmesh.h" #include "BKE_layer.h" #include "BKE_modifier.h" @@ -80,25 +79,25 @@ static void copyData(const ModifierData *md, ModifierData *target, const int UNU -static DerivedMesh *applyModifier( +static Mesh *applyModifier( ModifierData *md, const ModifierEvalContext *ctx, - DerivedMesh *dm) + Mesh *mesh) { FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; - DerivedMesh *result = NULL; + Mesh *result = NULL; /* check for alloc failing */ if (!fluidmd->fss) { initData(md); if (!fluidmd->fss) { - return dm; + return mesh; } } - result = fluidsimModifier_do(fluidmd, ctx, dm); + result = fluidsimModifier_do(fluidmd, ctx, mesh); - return result ? result : dm; + return result ? result : mesh; } static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) @@ -145,14 +144,14 @@ ModifierTypeInfo modifierType_Fluidsim = { /* deformMatrices_DM */ NULL, /* deformVertsEM_DM */ NULL, /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ applyModifier, + /* applyModifier_DM */ NULL, /* applyModifierEM_DM */NULL, /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, + /* applyModifier */ applyModifier, /* applyModifierEM */ NULL, /* initData */ initData, diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index ed5d08a95d4..963296f80f6 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -47,8 +47,8 @@ #include "BLI_utildefines.h" #include "BKE_fluidsim.h" /* ensure definitions here match */ -#include "BKE_cdderivedmesh.h" #include "BKE_main.h" +#include "BKE_mesh.h" #ifdef WITH_MOD_FLUID # include "BKE_global.h" #endif @@ -165,13 +165,13 @@ void fluidsim_free(FluidsimModifierData *fluidmd) #ifdef WITH_MOD_FLUID /* read .bobj.gz file into a fluidsimDerivedMesh struct */ -static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_example) +static Mesh *fluidsim_read_obj(const char *filename, const MPoly *mp_example) { int wri = 0, i; int gotBytes; gzFile gzf; int numverts = 0, numfaces = 0; - DerivedMesh *dm = NULL; + Mesh *mesh = NULL; MPoly *mp; MLoop *ml; MVert *mv; @@ -220,9 +220,9 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - dm = CDDM_new(numverts, 0, 0, numfaces * 3, numfaces); + mesh = BKE_mesh_new_nomain(numverts, 0, 0, numfaces * 3, numfaces); - if (!dm) { + if (!mesh) { gzclose(gzf); return NULL; } @@ -231,7 +231,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam gotBytes = gzread(gzf, &wri, sizeof(wri)); /* read vertex position from file */ - mv = CDDM_get_verts(dm); + mv = mesh->mvert; for (i = 0; i < numverts; i++, mv++) gotBytes = gzread(gzf, mv->co, sizeof(float) * 3); @@ -239,16 +239,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam /* should be the same as numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); if (wri != numverts) { - if (dm) - dm->release(dm); + if (mesh) + BKE_id_free(NULL, mesh); gzclose(gzf); return NULL; } normals = MEM_calloc_arrayN(numverts, 3 * sizeof(short), "fluid_tmp_normals"); if (!normals) { - if (dm) - dm->release(dm); + if (mesh) + BKE_id_free(NULL, mesh); gzclose(gzf); return NULL; } @@ -264,16 +264,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam if (wri != numfaces) { printf("Fluidsim: error in reading data from file.\n"); - if (dm) - dm->release(dm); + if (mesh) + BKE_id_free(NULL, mesh); gzclose(gzf); MEM_freeN(normals); return NULL; } /* read triangles from file */ - mp = CDDM_get_polys(dm); - ml = CDDM_get_loops(dm); + mp = mesh->mpoly; + ml = mesh->mloop; for (i = 0; i < numfaces; i++, mp++, ml += 3) { int face[3]; @@ -294,13 +294,12 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam gzclose(gzf); - CDDM_calc_edges(dm); - - CDDM_apply_vert_normals(dm, (short (*)[3])normals); + BKE_mesh_calc_edges(mesh, false, false); + BKE_mesh_apply_vert_normals(mesh, (short (*)[3])normals); MEM_freeN(normals); // CDDM_calc_normals(result); - return dm; + return mesh; } @@ -370,14 +369,14 @@ void fluid_estimate_memory(Object *ob, FluidsimSettings *fss, char *value) /* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */ -static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename) +static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, Mesh *mesh, char *filename) { int wri, i, j; float wrf; gzFile gzf; FluidsimSettings *fss = fluidmd->fss; int len = strlen(filename); - int totvert = dm->getNumVerts(dm); + int totvert = mesh->totvert; FluidVertexVelocity *velarray = NULL; /* mesh and vverts have to be valid from loading... */ @@ -391,7 +390,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * if (fss->domainNovecgen > 0) return; - fss->meshVelocities = MEM_calloc_arrayN(dm->getNumVerts(dm), sizeof(FluidVertexVelocity), "Fluidsim_velocities"); + fss->meshVelocities = MEM_calloc_arrayN(mesh->totvert, sizeof(FluidVertexVelocity), "Fluidsim_velocities"); fss->totvert = totvert; velarray = fss->meshVelocities; @@ -426,8 +425,8 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * gzclose(gzf); } -static DerivedMesh *fluidsim_read_cache( - Object *ob, DerivedMesh *orgdm, +static Mesh *fluidsim_read_cache( + Object *ob, Mesh *orgmesh, FluidsimModifierData *fluidmd, int framenr, int useRenderParams) { int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */ @@ -436,7 +435,7 @@ static DerivedMesh *fluidsim_read_cache( char targetFile[FILE_MAX]; FluidsimSettings *fss = fluidmd->fss; - DerivedMesh *dm = NULL; + Mesh *newmesh = NULL; MPoly *mpoly; MPoly mp_example = {0}; @@ -467,15 +466,15 @@ static DerivedMesh *fluidsim_read_cache( /* assign material + flags to new dm * if there's no faces in original dm, keep materials and flags unchanged */ - mpoly = orgdm->getPolyArray(orgdm); + mpoly = orgmesh->mpoly; if (mpoly) { mp_example = *mpoly; } /* else leave NULL'd */ - dm = fluidsim_read_obj(targetFile, &mp_example); + newmesh = fluidsim_read_obj(targetFile, &mp_example); - if (!dm) { + if (!newmesh) { /* switch, abort background rendering when fluidsim mesh is missing */ const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp @@ -498,7 +497,7 @@ static DerivedMesh *fluidsim_read_cache( * TODO? use generate flag as loading flag as well? * warning, needs original .bobj.gz mesh loading filename */ if (displaymode == OB_FSDOM_FINAL) { - fluidsim_read_vel_cache(fluidmd, dm, targetFile); + fluidsim_read_vel_cache(fluidmd, newmesh, targetFile); } else { if (fss->meshVelocities) @@ -507,21 +506,21 @@ static DerivedMesh *fluidsim_read_cache( fss->meshVelocities = NULL; } - return dm; + return newmesh; } #endif // WITH_MOD_FLUID -DerivedMesh *fluidsimModifier_do( +Mesh *fluidsimModifier_do( FluidsimModifierData *fluidmd, const ModifierEvalContext *ctx, - DerivedMesh *dm) + Mesh *mesh) { #ifdef WITH_MOD_FLUID Object *ob = ctx->object; Depsgraph *depsgraph = ctx->depsgraph; const bool useRenderParams = (ctx->flag & MOD_APPLY_RENDER) != 0; // const bool isFinalCalc = (ctx->flag & MOD_APPLY_USECACHE) != 0; - DerivedMesh *result = NULL; + Mesh *result = NULL; int framenr; FluidsimSettings *fss = NULL; @@ -529,11 +528,11 @@ DerivedMesh *fluidsimModifier_do( /* only handle fluidsim domains */ if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN)) - return dm; + return mesh; /* sanity check */ if (!fluidmd || !fluidmd->fss) - return dm; + return mesh; fss = fluidmd->fss; @@ -548,10 +547,10 @@ DerivedMesh *fluidsimModifier_do( /* try to read from cache */ /* if the frame is there, fine, otherwise don't do anything */ - if ((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams))) + if ((result = fluidsim_read_cache(ob, mesh, fluidmd, framenr, useRenderParams))) return result; - return dm; + return mesh; #else /* unused */ (void)fluidmd; diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.h b/source/blender/modifiers/intern/MOD_fluidsim_util.h index 0a0c8419a99..041a67eddbd 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.h +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.h @@ -36,16 +36,16 @@ struct Object; struct Scene; struct FluidsimModifierData; -struct DerivedMesh; +struct Mesh; struct ModifierEvalContext; /* new fluid-modifier interface */ void fluidsim_init(struct FluidsimModifierData *fluidmd); void fluidsim_free(struct FluidsimModifierData *fluidmd); -struct DerivedMesh *fluidsimModifier_do( +struct Mesh *fluidsimModifier_do( struct FluidsimModifierData *fluidmd, const struct ModifierEvalContext *ctx, - struct DerivedMesh *dm); + struct Mesh *dm); #endif -- cgit v1.2.3 From 03ef9f32148acb45c4940cf93d7d8afb850231d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 5 Jul 2018 12:21:33 +0200 Subject: Fluidsim: fixed memory leak --- source/blender/modifiers/intern/MOD_fluidsim.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index bb87d0065fe..ebea7250d18 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -69,11 +69,20 @@ static void copyData(const ModifierData *md, ModifierData *target, const int UNU const FluidsimModifierData *fluidmd = (const FluidsimModifierData *) md; FluidsimModifierData *tfluidmd = (FluidsimModifierData *) target; - if (fluidmd->fss) { - tfluidmd->fss = MEM_dupallocN(fluidmd->fss); - if (tfluidmd->fss && (tfluidmd->fss->meshVelocities != NULL)) { - tfluidmd->fss->meshVelocities = MEM_dupallocN(tfluidmd->fss->meshVelocities); - } + /* Free any FSS that was allocated in initData() */ + if (tfluidmd->fss) { + MEM_SAFE_FREE(tfluidmd->fss->meshVelocities); + MEM_freeN(tfluidmd->fss); + } + + if (fluidmd->fss == NULL) { + tfluidmd->fss = NULL; + return; + } + + tfluidmd->fss = MEM_dupallocN(fluidmd->fss); + if (tfluidmd->fss->meshVelocities != NULL) { + tfluidmd->fss->meshVelocities = MEM_dupallocN(tfluidmd->fss->meshVelocities); } } -- cgit v1.2.3 From 1517fa43097a3925b5fd1d4b8738fd56fde17bc8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 12:26:10 +0200 Subject: Fix build w/o fluidsim --- source/blender/modifiers/intern/MOD_fluidsim_util.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 963296f80f6..edd7a7a331c 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -464,8 +464,8 @@ static Mesh *fluidsim_read_cache( BLI_path_abs(targetFile, modifier_path_relbase_from_global(ob)); BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no - /* assign material + flags to new dm - * if there's no faces in original dm, keep materials and flags unchanged */ + /* assign material + flags to new mesh. + * if there's no faces in original mesh, keep materials and flags unchanged */ mpoly = orgmesh->mpoly; if (mpoly) { mp_example = *mpoly; @@ -489,7 +489,7 @@ static Mesh *fluidsim_read_cache( } } - /* display org. object upon failure which is in dm */ + /* display org. object upon failure which is in new mesh */ return NULL; } @@ -555,7 +555,6 @@ Mesh *fluidsimModifier_do( /* unused */ (void)fluidmd; (void)ctx; - (void)dm; return NULL; #endif } -- cgit v1.2.3 From 397d088611b857e536bea08003eeba1b50678ec2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 12:09:17 +0200 Subject: UI: show modal operator keymaps in the status bar This is work in progress, transform keymap especially needs some filtering on it's keymap. --- .../editors/interface/interface_templates.c | 4 ++ source/blender/windowmanager/WM_api.h | 5 ++ .../blender/windowmanager/intern/wm_event_system.c | 80 +++++++++++++++++++++- 3 files changed, 86 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index a14d12492ec..1c3ed3e3c75 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -4330,6 +4330,10 @@ void uiTemplateInputStatus(uiLayout *layout, struct bContext *C) return; } + if (WM_window_modal_keymap_status_draw(C, win, layout)) { + return; + } + /* Otherwise should cursor keymap status. */ for (int i = 0; i < 3; i++) { uiLayout *box = uiLayoutRow(layout, false); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index e203a872d24..1f5e3aa2461 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -608,6 +608,11 @@ bool WM_event_is_ime_switch(const struct wmEvent *event); const char *WM_window_cursor_keymap_status_get(const struct wmWindow *win, int button_index, int type_index); void WM_window_cursor_keymap_status_refresh(struct bContext *C, struct wmWindow *win); +struct ScrArea *WM_window_find_area_status(struct wmWindow *win, struct bScreen *sc); +bool WM_window_modal_keymap_status_draw( + struct bContext *C, struct wmWindow *win, + struct uiLayout *layout); + /* wm_tooltip.c */ typedef struct ARegion *(*wmTooltipInitFn)(struct bContext *, struct ARegion *, bool *); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 91b924c1565..204bd62cfbe 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1960,6 +1960,15 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { wm_operator_reports(C, op, retval, false); + + if (op->type->modalkeymap) { + wmWindow *win = CTX_wm_window(C); + bScreen *sc = WM_window_get_active_screen(win); + ScrArea *sa = WM_window_find_area_status(win, sc); + if (sa != NULL) { + ED_area_tag_redraw(sa); + } + } } else { /* not very common, but modal operators may report before finishing */ @@ -3191,6 +3200,14 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op) BLI_addhead(&win->modalhandlers, handler); + if (op->type->modalkeymap) { + bScreen *sc = WM_window_get_active_screen(win); + ScrArea *sa = WM_window_find_area_status(win, sc); + if (sa != NULL) { + ED_area_tag_redraw(sa); + } + } + return handler; } @@ -4321,11 +4338,14 @@ const char *WM_window_cursor_keymap_status_get(const wmWindow *win, int button_i return NULL; } -void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win) +/** + * Similar to #BKE_screen_area_map_find_area_xy and related functions, + * use here since the ara is stored in the window manager. + */ +ScrArea *WM_window_find_area_status(wmWindow *win, bScreen *screen) { - bScreen *screen = WM_window_get_active_screen(win); if (screen->state == SCREENFULL) { - return; + return NULL; } ScrArea *sa_statusbar = NULL; for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) { @@ -4334,6 +4354,13 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win) break; } } + return sa_statusbar; +} + +void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) +{ + bScreen *screen = WM_window_get_active_screen(win); + ScrArea *sa_statusbar = WM_window_find_area_status(win, screen); if (sa_statusbar == NULL) { return; } @@ -4476,3 +4503,50 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win) } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Modal Keymap Status + * + * \{ */ + +bool WM_window_modal_keymap_status_draw( + bContext *UNUSED(C), wmWindow *win, + uiLayout *layout) +{ + wmKeyMap *keymap = NULL; + wmOperatorType *ot = NULL; + for (wmEventHandler *handler = win->modalhandlers.first; handler; handler = handler->next) { + if (handler->op) { + /* 'handler->keymap' could be checked too, seems not to be used. */ + wmKeyMap *keymap_test = handler->op->type->modalkeymap; + if (keymap_test && keymap_test->modal_items) { + keymap = keymap_test; + ot = handler->op->type; + break; + } + } + } + if (keymap == NULL) { + return false; + } + const EnumPropertyItem *items = keymap->modal_items; + + uiLayout *row = uiLayoutRow(layout, true); + for (int i = 0; items[i].identifier; i++) { + if (!items[i].identifier[0]) { + continue; + } + char buf[UI_MAX_DRAW_STR]; + int available_len = sizeof(buf); + char *p = buf; + WM_modalkeymap_operator_items_to_string_buf(ot, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p); + p -= 1; + if (p > buf) { + BLI_snprintf(p, available_len, ": %s", items[i].name); + uiItemL(row, buf, 0); + } + } + return true; +} + +/** \} */ -- cgit v1.2.3 From d13fb7a7c4dafcc2a2f239c8a878c64c8c294dbf Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 5 Jul 2018 12:31:17 +0200 Subject: Sculpt: Fix disappearing object on undo Tagging object for copy on write will ruin its PBVH. Since sculpting is an "original" domain, we only need to update draw batches to update. --- source/blender/editors/sculpt_paint/sculpt_undo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 61f7c3bd0d9..b78d030407b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -493,7 +493,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) } } - DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); + DEG_id_tag_update(&ob->id, DEG_TAG_SHADING_UPDATE); BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask); -- cgit v1.2.3 From a4328a4b70f80bbb1c2e8df3b95b793dc5f6fb06 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 12:29:48 +0200 Subject: Cleanup: warning --- source/blender/modifiers/intern/MOD_fluidsim_util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index edd7a7a331c..44079163de5 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -553,8 +553,7 @@ Mesh *fluidsimModifier_do( return mesh; #else /* unused */ - (void)fluidmd; - (void)ctx; + UNUSED_VARS(fluidmd, ctx, mesh); return NULL; #endif } -- cgit v1.2.3 From 4d00e95ee3ed91f86262bb218f1c5df901da724c Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Thu, 5 Jul 2018 12:37:52 +0200 Subject: Cycles: Adding native support for UINT16 textures. Textures in 16 bit integer format are sometimes used for displacement, bump and normal maps and can be exported by tools like Substance Painter. Without this patch, Cycles would promote those textures to single precision floating point, causing them to take up twice as much memory as needed. Reviewers: #cycles, brecht, sergey Reviewed By: #cycles, brecht, sergey Subscribers: sergey, dingto, #cycles Tags: #cycles Differential Revision: https://developer.blender.org/D3523 --- intern/cycles/device/device_cuda.cpp | 1 + intern/cycles/device/device_memory.h | 12 ++++ intern/cycles/kernel/CMakeLists.txt | 1 + .../cycles/kernel/kernels/cpu/kernel_cpu_image.h | 32 +++++++-- .../cycles/kernel/kernels/cuda/kernel_cuda_image.h | 8 ++- .../kernel/kernels/opencl/kernel_opencl_image.h | 12 ++++ intern/cycles/render/image.cpp | 82 +++++++++++++++++++--- intern/cycles/util/CMakeLists.txt | 1 + intern/cycles/util/util_half.h | 11 ++- intern/cycles/util/util_image_impl.h | 16 +++++ intern/cycles/util/util_texture.h | 2 + intern/cycles/util/util_types.h | 2 + intern/cycles/util/util_types_ushort4.h | 36 ++++++++++ 13 files changed, 198 insertions(+), 18 deletions(-) create mode 100644 intern/cycles/util/util_types_ushort4.h diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 8294af340e8..73c9697223d 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1072,6 +1072,7 @@ public: CUarray_format_enum format; switch(mem.data_type) { case TYPE_UCHAR: format = CU_AD_FORMAT_UNSIGNED_INT8; break; + case TYPE_UINT16: format = CU_AD_FORMAT_UNSIGNED_INT16; break; case TYPE_UINT: format = CU_AD_FORMAT_UNSIGNED_INT32; break; case TYPE_INT: format = CU_AD_FORMAT_SIGNED_INT32; break; case TYPE_FLOAT: format = CU_AD_FORMAT_FLOAT; break; diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h index 1138964f18c..b6f3c2913a5 100644 --- a/intern/cycles/device/device_memory.h +++ b/intern/cycles/device/device_memory.h @@ -43,6 +43,7 @@ enum MemoryType { enum DataType { TYPE_UNKNOWN, TYPE_UCHAR, + TYPE_UINT16, TYPE_UINT, TYPE_INT, TYPE_FLOAT, @@ -57,6 +58,7 @@ static inline size_t datatype_size(DataType datatype) case TYPE_UCHAR: return sizeof(uchar); case TYPE_FLOAT: return sizeof(float); case TYPE_UINT: return sizeof(uint); + case TYPE_UINT16: return sizeof(uint16_t); case TYPE_INT: return sizeof(int); case TYPE_HALF: return sizeof(half); case TYPE_UINT64: return sizeof(uint64_t); @@ -156,6 +158,16 @@ template<> struct device_type_traits { static const int num_elements = 1; }; +template<> struct device_type_traits { + static const DataType data_type = TYPE_UINT16; + static const int num_elements = 4; +}; + +template<> struct device_type_traits { + static const DataType data_type = TYPE_UINT16; + static const int num_elements = 1; +}; + template<> struct device_type_traits { static const DataType data_type = TYPE_HALF; static const int num_elements = 4; diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 95cdefdd94b..092bec08a51 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -287,6 +287,7 @@ set(SRC_UTIL_HEADERS ../util/util_types_uint3_impl.h ../util/util_types_uint4.h ../util/util_types_uint4_impl.h + ../util/util_types_ushort4.h ../util/util_types_vector3.h ../util/util_types_vector3_impl.h ) diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h index 7bf833eadbc..b77b7350d86 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h +++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h @@ -35,13 +35,13 @@ template struct TextureInterpolator { static ccl_always_inline float4 read(uchar4 r) { - float f = 1.0f/255.0f; + float f = 1.0f / 255.0f; return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); } static ccl_always_inline float4 read(uchar r) { - float f = r*(1.0f/255.0f); + float f = r * (1.0f / 255.0f); return make_float4(f, f, f, 1.0f); } @@ -63,6 +63,18 @@ template struct TextureInterpolator { return make_float4(f, f, f, 1.0f); } + static ccl_always_inline float4 read(uint16_t r) + { + float f = r*(1.0f/65535.0f); + return make_float4(f, f, f, 1.0f); + } + + static ccl_always_inline float4 read(ushort4 r) + { + float f = 1.0f/65535.0f; + return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); + } + static ccl_always_inline float4 read(const T *data, int x, int y, int width, int height) @@ -481,15 +493,21 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl return TextureInterpolator::interp(info, x, y); case IMAGE_DATA_TYPE_BYTE: return TextureInterpolator::interp(info, x, y); + case IMAGE_DATA_TYPE_USHORT: + return TextureInterpolator::interp(info, x, y); case IMAGE_DATA_TYPE_FLOAT: return TextureInterpolator::interp(info, x, y); case IMAGE_DATA_TYPE_HALF4: return TextureInterpolator::interp(info, x, y); case IMAGE_DATA_TYPE_BYTE4: return TextureInterpolator::interp(info, x, y); + case IMAGE_DATA_TYPE_USHORT4: + return TextureInterpolator::interp(info, x, y); case IMAGE_DATA_TYPE_FLOAT4: - default: return TextureInterpolator::interp(info, x, y); + default: + assert(0); + return make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A); } } @@ -502,15 +520,21 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x, return TextureInterpolator::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_BYTE: return TextureInterpolator::interp_3d(info, x, y, z, interp); + case IMAGE_DATA_TYPE_USHORT: + return TextureInterpolator::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_FLOAT: return TextureInterpolator::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_HALF4: return TextureInterpolator::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_BYTE4: return TextureInterpolator::interp_3d(info, x, y, z, interp); + case IMAGE_DATA_TYPE_USHORT4: + return TextureInterpolator::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_FLOAT4: - default: return TextureInterpolator::interp_3d(info, x, y, z, interp); + default: + assert(0); + return make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A); } } diff --git a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h index 91ad289a858..a72fae5e1b1 100644 --- a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h +++ b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h @@ -127,11 +127,12 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl const TextureInfo& info = kernel_tex_fetch(__texture_info, id); CUtexObject tex = (CUtexObject)info.data; - /* float4, byte4 and half4 */ + /* float4, byte4, ushort4 and half4 */ const int texture_type = kernel_tex_type(id); if(texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 || - texture_type == IMAGE_DATA_TYPE_HALF4) + texture_type == IMAGE_DATA_TYPE_HALF4 || + texture_type == IMAGE_DATA_TYPE_USHORT4) { if(info.interpolation == INTERPOLATION_CUBIC) { return kernel_tex_image_interp_bicubic(info, tex, x, y); @@ -164,7 +165,8 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x, const int texture_type = kernel_tex_type(id); if(texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 || - texture_type == IMAGE_DATA_TYPE_HALF4) + texture_type == IMAGE_DATA_TYPE_HALF4 || + texture_type == IMAGE_DATA_TYPE_USHORT4) { if(interpolation == INTERPOLATION_CUBIC) { return kernel_tex_image_interp_bicubic_3d(info, tex, x, y, z); diff --git a/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h b/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h index faa9dd66d0e..011623130eb 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h +++ b/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h @@ -54,11 +54,23 @@ ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, const ccl_glo float f = 1.0f/255.0f; return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); } + /* Ushort4 */ + else if(texture_type == IMAGE_DATA_TYPE_USHORT4) { + ushort4 r = tex_fetch(ushort4, info, offset); + float f = 1.0f/65535.f; + return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); + } /* Float */ else if(texture_type == IMAGE_DATA_TYPE_FLOAT) { float f = tex_fetch(float, info, offset); return make_float4(f, f, f, 1.0f); } + /* UShort */ + else if(texture_type == IMAGE_DATA_TYPE_USHORT) { + ushort r = tex_fetch(ushort, info, offset); + float f = r * (1.0f / 65535.0f); + return make_float4(f, f, f, 1.0f); + } /* Byte */ else { uchar r = tex_fetch(uchar, info, offset); diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 9c6536edc4f..3c49d17aa82 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -39,6 +39,10 @@ static bool isfinite(half /*value*/) { return false; } +static bool isfinite(uint16_t /*value*/) +{ + return false; +} ImageManager::ImageManager(const DeviceInfo& info) { @@ -164,23 +168,27 @@ bool ImageManager::get_image_metadata(const string& filename, metadata.height = spec.height; metadata.depth = spec.depth; - /* check the main format, and channel formats; - * if any take up more than one byte, we'll need a float texture slot */ - if(spec.format.basesize() > 1) { + + /* Check the main format, and channel formats. */ + size_t channel_size = spec.format.basesize(); + + if(spec.format.is_floating_point()) { metadata.is_float = true; metadata.is_linear = true; } for(size_t channel = 0; channel < spec.channelformats.size(); channel++) { - if(spec.channelformats[channel].basesize() > 1) { + channel_size = max(channel_size, spec.channelformats[channel].basesize()); + if(spec.channelformats[channel].is_floating_point()) { metadata.is_float = true; metadata.is_linear = true; } } /* check if it's half float */ - if(spec.format == TypeDesc::HALF) + if(spec.format == TypeDesc::HALF) { metadata.is_half = true; + } /* basic color space detection, not great but better than nothing * before we do OpenColorIO integration */ @@ -208,6 +216,9 @@ bool ImageManager::get_image_metadata(const string& filename, else if(metadata.is_float) { metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_FLOAT4 : IMAGE_DATA_TYPE_FLOAT; } + else if(spec.format == TypeDesc::USHORT) { + metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_USHORT4 : IMAGE_DATA_TYPE_USHORT; + } else { metadata.type = (metadata.channels > 1) ? IMAGE_DATA_TYPE_BYTE4 : IMAGE_DATA_TYPE_BYTE; } @@ -254,6 +265,10 @@ string ImageManager::name_from_type(int type) return "half4"; else if(type == IMAGE_DATA_TYPE_HALF) return "half"; + else if(type == IMAGE_DATA_TYPE_USHORT) + return "ushort"; + else if(type == IMAGE_DATA_TYPE_USHORT4) + return "ushort4"; else return "byte4"; } @@ -583,7 +598,8 @@ bool ImageManager::file_load_image(Image *img, */ bool is_rgba = (type == IMAGE_DATA_TYPE_FLOAT4 || type == IMAGE_DATA_TYPE_HALF4 || - type == IMAGE_DATA_TYPE_BYTE4); + type == IMAGE_DATA_TYPE_BYTE4 || + type == IMAGE_DATA_TYPE_USHORT4); if(is_rgba) { if(cmyk) { /* CMYK */ @@ -843,14 +859,61 @@ void ImageManager::device_load_image(Device *device, thread_scoped_lock device_lock(device_mutex); tex_img->copy_to_device(); } + else if(type == IMAGE_DATA_TYPE_USHORT) { + device_vector *tex_img + = new device_vector(device, img->mem_name.c_str(), MEM_TEXTURE); + + if(!file_load_image(img, + type, + texture_limit, + *tex_img)) { + /* on failure to load, we set a 1x1 pixels pink image */ + thread_scoped_lock device_lock(device_mutex); + uint16_t *pixels = (uint16_t*)tex_img->alloc(1, 1); + + pixels[0] = TEX_IMAGE_MISSING_R; + } + + img->mem = tex_img; + img->mem->interpolation = img->interpolation; + img->mem->extension = img->extension; + + thread_scoped_lock device_lock(device_mutex); + tex_img->copy_to_device(); + } + else if(type == IMAGE_DATA_TYPE_USHORT4) { + device_vector *tex_img + = new device_vector(device, img->mem_name.c_str(), MEM_TEXTURE); + + if(!file_load_image(img, + type, + texture_limit, + *tex_img)) { + /* on failure to load, we set a 1x1 pixels pink image */ + thread_scoped_lock device_lock(device_mutex); + uint16_t *pixels = (uint16_t*)tex_img->alloc(1, 1); + + pixels[0] = TEX_IMAGE_MISSING_R; + pixels[1] = TEX_IMAGE_MISSING_G; + pixels[2] = TEX_IMAGE_MISSING_B; + pixels[3] = TEX_IMAGE_MISSING_A; + } + + img->mem = tex_img; + img->mem->interpolation = img->interpolation; + img->mem->extension = img->extension; + + thread_scoped_lock device_lock(device_mutex); + tex_img->copy_to_device(); + } else if(type == IMAGE_DATA_TYPE_HALF) { device_vector *tex_img = new device_vector(device, img->mem_name.c_str(), MEM_TEXTURE); if(!file_load_image(img, - type, - texture_limit, - *tex_img)) { + type, + texture_limit, + *tex_img)) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); half *pixels = (half*)tex_img->alloc(1, 1); @@ -865,7 +928,6 @@ void ImageManager::device_load_image(Device *device, thread_scoped_lock device_lock(device_mutex); tex_img->copy_to_device(); } - img->need_load = false; } diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index 3b690860d53..508f44e7c4d 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -116,6 +116,7 @@ set(SRC_HEADERS util_types_uint3_impl.h util_types_uint4.h util_types_uint4_impl.h + util_types_ushort4.h util_types_vector3.h util_types_vector3_impl.h util_vector.h diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h index 612228dd1c1..f6c507906f3 100644 --- a/intern/cycles/util/util_half.h +++ b/intern/cycles/util/util_half.h @@ -36,7 +36,16 @@ CCL_NAMESPACE_BEGIN /* CUDA has its own half data type, no need to define then */ #ifndef __KERNEL_CUDA__ -typedef unsigned short half; +/* Implementing this as a class rather than a typedef so that the compiler can tell it apart from unsigned shorts. */ +class half { +public: + half() : v(0) {} + half(const unsigned short& i) : v(i) {} + operator unsigned short() { return v; } + half & operator =(const unsigned short& i) { v = i; return *this; } +private: + unsigned short v; +}; #endif struct half4 { half x, y, z, w; }; diff --git a/intern/cycles/util/util_image_impl.h b/intern/cycles/util/util_image_impl.h index 751f52aaa86..fb953a43ab2 100644 --- a/intern/cycles/util/util_image_impl.h +++ b/intern/cycles/util/util_image_impl.h @@ -53,6 +53,11 @@ inline float cast_to_float(uchar value) return (float)value / 255.0f; } template<> +inline float cast_to_float(uint16_t value) +{ + return (float)value / 65535.0f; +} +template<> inline float cast_to_float(half value) { return half_to_float(value); @@ -79,6 +84,17 @@ inline uchar cast_from_float(float value) return (uchar)((255.0f * value) + 0.5f); } template<> +inline uint16_t cast_from_float(float value) +{ + if(value < 0.0f) { + return 0; + } + else if(value >(1.0f - 0.5f / 65535.0f)) { + return 65535; + } + return (uchar)((65535.0f * value) + 0.5f); +} +template<> inline half cast_from_float(float value) { return float_to_half(value); diff --git a/intern/cycles/util/util_texture.h b/intern/cycles/util/util_texture.h index 4b5f630427d..f752e81128d 100644 --- a/intern/cycles/util/util_texture.h +++ b/intern/cycles/util/util_texture.h @@ -53,6 +53,8 @@ typedef enum ImageDataType { IMAGE_DATA_TYPE_FLOAT = 3, IMAGE_DATA_TYPE_BYTE = 4, IMAGE_DATA_TYPE_HALF = 5, + IMAGE_DATA_TYPE_USHORT4 = 6, + IMAGE_DATA_TYPE_USHORT = 7, IMAGE_DATA_NUM_TYPES } ImageDataType; diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index 84206a7ba5a..4bbba649ff2 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -116,6 +116,8 @@ CCL_NAMESPACE_END #include "util/util_types_uint3.h" #include "util/util_types_uint4.h" +#include "util/util_types_ushort4.h" + #include "util/util_types_float2.h" #include "util/util_types_float3.h" #include "util/util_types_float4.h" diff --git a/intern/cycles/util/util_types_ushort4.h b/intern/cycles/util/util_types_ushort4.h new file mode 100644 index 00000000000..fc234b8abe8 --- /dev/null +++ b/intern/cycles/util/util_types_ushort4.h @@ -0,0 +1,36 @@ +/* + * Copyright 2011-2017 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __UTIL_TYPES_USHORT4_H__ +#define __UTIL_TYPES_USHORT4_H__ + +#ifndef __UTIL_TYPES_H__ +# error "Do not include this file directly, include util_types.h instead." +#endif + +CCL_NAMESPACE_BEGIN + +#ifndef __KERNEL_GPU__ + +struct ushort4 { + uint16_t x, y, z, w; +}; + +#endif + +CCL_NAMESPACE_END + +#endif /* __UTIL_TYPES_USHORT4_H__ */ -- cgit v1.2.3 From f7ec70895c78900db8e7db88d3713ebb9aa62730 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 5 Jul 2018 14:38:14 +0200 Subject: Overlay: enable/disable drawing of specific object types. Added a option to the overlay popover that controls the visibility of non-renderable objects like lamps, cameras, speakers, armatures, curves empties and force fields. After discussion we went for a single option with more detailed check in the object_mode draw engine. Differential Revision: https://developer.blender.org/D3524 --- release/scripts/startup/bl_ui/space_view3d.py | 9 ++++ source/blender/blenloader/intern/versioning_280.c | 13 ++++++ source/blender/draw/modes/object_mode.c | 52 +++++++++++++++------- source/blender/editors/space_view3d/space_view3d.c | 1 + source/blender/makesdna/DNA_view3d_types.h | 14 +++++- source/blender/makesrna/intern/rna_space.c | 48 ++++++++++++++++++++ 6 files changed, 119 insertions(+), 18 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 7b71d41e678..0c3219ae8e1 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3833,6 +3833,14 @@ class VIEW3D_PT_overlay(Panel): sub.prop(overlay, "show_all_objects_origin") sub = split.column() + row = sub.row(align=True) + row.prop(overlay, "show_empties", text="", toggle=True) + row.prop(overlay, "show_lamps", text="", toggle=True) + row.prop(overlay, "show_cameras", text="", toggle=True) + row.prop(overlay, "show_armatures", text="", toggle=True) + row.prop(overlay, "show_lightprobes", text="", toggle=True) + row.prop(overlay, "show_speakers", text="", toggle=True) + sub.prop(overlay, "show_relationship_lines") sub.prop(overlay, "show_motion_paths") #sub.prop(overlay, "show_onion_skins") @@ -3847,6 +3855,7 @@ class VIEW3D_PT_overlay(Panel): sub.active = overlay.show_wireframes sub.prop(overlay, "wireframe_threshold", text="") + col = layout.column() col.active = display_all split = col.split(percentage=0.55) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 3bdd4db3b94..8194648f369 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1530,6 +1530,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", "visible_object_types")) { + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK; + } + } + } + } + } + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->toolsettings->manipulator_flag == 0) { scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 736bde725ae..2beb453e069 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2217,34 +2217,52 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; } case OB_LAMP: - DRW_shgroup_lamp(stl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_LAMP) + { + DRW_shgroup_lamp(stl, ob, view_layer); + } break; case OB_CAMERA: - DRW_shgroup_camera(stl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_CAMERA) + { + DRW_shgroup_camera(stl, ob, view_layer); + } break; case OB_EMPTY: - DRW_shgroup_empty(stl, psl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_EMPTY) + { + DRW_shgroup_empty(stl, psl, ob, view_layer); + } break; case OB_SPEAKER: - DRW_shgroup_speaker(stl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_SPEAKER) + { + DRW_shgroup_speaker(stl, ob, view_layer); + } break; case OB_LIGHTPROBE: - DRW_shgroup_lightprobe(stl, psl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_LIGHTPROBE) + { + DRW_shgroup_lightprobe(stl, psl, ob, view_layer); + } break; case OB_ARMATURE: { - bArmature *arm = ob->data; - if (arm->edbo == NULL) { - if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { - DRWArmaturePasses passes = { - .bone_solid = psl->bone_solid, - .bone_outline = psl->bone_outline, - .bone_wire = psl->bone_wire, - .bone_envelope = psl->bone_envelope, - .bone_axes = psl->bone_axes, - .relationship_lines = NULL, /* Don't draw relationship lines */ - }; - DRW_shgroup_armature_object(ob, view_layer, passes); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_ARMATURE) + { + bArmature *arm = ob->data; + if (arm->edbo == NULL) { + if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { + DRWArmaturePasses passes = { + .bone_solid = psl->bone_solid, + .bone_outline = psl->bone_outline, + .bone_wire = psl->bone_wire, + .bone_envelope = psl->bone_envelope, + .bone_axes = psl->bone_axes, + .relationship_lines = NULL, /* Don't draw relationship lines */ + }; + DRW_shgroup_armature_object(ob, view_layer, passes); + } } } break; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 77beadccd5d..5383e3d9e01 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -338,6 +338,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->overlay.texture_paint_mode_opacity = 0.8; v3d->overlay.weight_paint_mode_opacity = 0.8; v3d->overlay.vertex_paint_mode_opacity = 0.8; + v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK; v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 70f06b2eda0..f7fd4a52a5f 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -49,6 +49,7 @@ struct GPUViewport; #include "DNA_defs.h" #include "DNA_listBase.h" #include "DNA_image_types.h" +#include "DNA_object_types.h" #include "DNA_movieclip_types.h" #include "DNA_gpu_types.h" @@ -178,8 +179,8 @@ typedef struct View3DOverlay { /* Other settings */ float wireframe_threshold; + int visible_object_types; - int pad; } View3DOverlay; /* 3D ViewPort Struct */ @@ -383,6 +384,17 @@ enum { V3D_OVERLAY_ONION_SKINS = (1 << 7), }; +/* View3DOverlay->visible_object_types */ +enum { + V3D_OVERLAY_SHOW_EMPTY = (1 << OB_EMPTY), + V3D_OVERLAY_SHOW_LAMP = (1 << OB_LAMP), + V3D_OVERLAY_SHOW_CAMERA = (1 << OB_CAMERA), + V3D_OVERLAY_SHOW_SPEAKER = (1 << OB_SPEAKER), + V3D_OVERLAY_SHOW_LIGHTPROBE = (1 << OB_LIGHTPROBE), + V3D_OVERLAY_SHOW_ARMATURE = (1 << OB_ARMATURE), +}; +#define V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK (V3D_OVERLAY_SHOW_EMPTY | V3D_OVERLAY_SHOW_LAMP | V3D_OVERLAY_SHOW_CAMERA | V3D_OVERLAY_SHOW_SPEAKER | V3D_OVERLAY_SHOW_LIGHTPROBE | V3D_OVERLAY_SHOW_ARMATURE) + /* View3DOverlay->edit_flag */ enum { V3D_OVERLAY_EDIT_VERT_NORMALS = (1 << 0), diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index dfad4c07cb3..00baf948a84 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2608,6 +2608,54 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_empties", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_EMPTY); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Empties", "Draw empties in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_EMPTY, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_CAMERA); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Cameras", "Draw cameras in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CAMERA, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_SPEAKER); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Speakers", "Draw speakers in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_SPEAKER, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_lightprobes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_LIGHTPROBE); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Lightprobes", "Draw lightprobes in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LIGHTPROBE, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_ARMATURE); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Armatures", "Draw armatures in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_ARMATURE, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_LAMP); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Lamps", "Draw lamps in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LAMP, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_text", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_TEXT); RNA_def_property_ui_text(prop, "Show Text", "Display overlay text"); -- cgit v1.2.3 From c1678a3723471fe2345c23afb439f6aa8d1a6ef5 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 5 Jul 2018 16:51:49 +0200 Subject: Revert "Overlay: enable/disable drawing of specific object types." This reverts commit f7ec70895c78900db8e7db88d3713ebb9aa62730. --- release/scripts/startup/bl_ui/space_view3d.py | 9 ---- source/blender/blenloader/intern/versioning_280.c | 13 ------ source/blender/draw/modes/object_mode.c | 52 +++++++--------------- source/blender/editors/space_view3d/space_view3d.c | 1 - source/blender/makesdna/DNA_view3d_types.h | 14 +----- source/blender/makesrna/intern/rna_space.c | 48 -------------------- 6 files changed, 18 insertions(+), 119 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 0c3219ae8e1..7b71d41e678 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3833,14 +3833,6 @@ class VIEW3D_PT_overlay(Panel): sub.prop(overlay, "show_all_objects_origin") sub = split.column() - row = sub.row(align=True) - row.prop(overlay, "show_empties", text="", toggle=True) - row.prop(overlay, "show_lamps", text="", toggle=True) - row.prop(overlay, "show_cameras", text="", toggle=True) - row.prop(overlay, "show_armatures", text="", toggle=True) - row.prop(overlay, "show_lightprobes", text="", toggle=True) - row.prop(overlay, "show_speakers", text="", toggle=True) - sub.prop(overlay, "show_relationship_lines") sub.prop(overlay, "show_motion_paths") #sub.prop(overlay, "show_onion_skins") @@ -3855,7 +3847,6 @@ class VIEW3D_PT_overlay(Panel): sub.active = overlay.show_wireframes sub.prop(overlay, "wireframe_threshold", text="") - col = layout.column() col.active = display_all split = col.split(percentage=0.55) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 8194648f369..3bdd4db3b94 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1530,19 +1530,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", "visible_object_types")) { - for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK; - } - } - } - } - } - for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->toolsettings->manipulator_flag == 0) { scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 2beb453e069..736bde725ae 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2217,52 +2217,34 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; } case OB_LAMP: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_LAMP) - { - DRW_shgroup_lamp(stl, ob, view_layer); - } + DRW_shgroup_lamp(stl, ob, view_layer); break; case OB_CAMERA: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_CAMERA) - { - DRW_shgroup_camera(stl, ob, view_layer); - } + DRW_shgroup_camera(stl, ob, view_layer); break; case OB_EMPTY: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_EMPTY) - { - DRW_shgroup_empty(stl, psl, ob, view_layer); - } + DRW_shgroup_empty(stl, psl, ob, view_layer); break; case OB_SPEAKER: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_SPEAKER) - { - DRW_shgroup_speaker(stl, ob, view_layer); - } + DRW_shgroup_speaker(stl, ob, view_layer); break; case OB_LIGHTPROBE: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_LIGHTPROBE) - { - DRW_shgroup_lightprobe(stl, psl, ob, view_layer); - } + DRW_shgroup_lightprobe(stl, psl, ob, view_layer); break; case OB_ARMATURE: { - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_ARMATURE) - { - bArmature *arm = ob->data; - if (arm->edbo == NULL) { - if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { - DRWArmaturePasses passes = { - .bone_solid = psl->bone_solid, - .bone_outline = psl->bone_outline, - .bone_wire = psl->bone_wire, - .bone_envelope = psl->bone_envelope, - .bone_axes = psl->bone_axes, - .relationship_lines = NULL, /* Don't draw relationship lines */ - }; - DRW_shgroup_armature_object(ob, view_layer, passes); - } + bArmature *arm = ob->data; + if (arm->edbo == NULL) { + if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { + DRWArmaturePasses passes = { + .bone_solid = psl->bone_solid, + .bone_outline = psl->bone_outline, + .bone_wire = psl->bone_wire, + .bone_envelope = psl->bone_envelope, + .bone_axes = psl->bone_axes, + .relationship_lines = NULL, /* Don't draw relationship lines */ + }; + DRW_shgroup_armature_object(ob, view_layer, passes); } } break; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 5383e3d9e01..77beadccd5d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -338,7 +338,6 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->overlay.texture_paint_mode_opacity = 0.8; v3d->overlay.weight_paint_mode_opacity = 0.8; v3d->overlay.vertex_paint_mode_opacity = 0.8; - v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK; v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index f7fd4a52a5f..70f06b2eda0 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -49,7 +49,6 @@ struct GPUViewport; #include "DNA_defs.h" #include "DNA_listBase.h" #include "DNA_image_types.h" -#include "DNA_object_types.h" #include "DNA_movieclip_types.h" #include "DNA_gpu_types.h" @@ -179,8 +178,8 @@ typedef struct View3DOverlay { /* Other settings */ float wireframe_threshold; - int visible_object_types; + int pad; } View3DOverlay; /* 3D ViewPort Struct */ @@ -384,17 +383,6 @@ enum { V3D_OVERLAY_ONION_SKINS = (1 << 7), }; -/* View3DOverlay->visible_object_types */ -enum { - V3D_OVERLAY_SHOW_EMPTY = (1 << OB_EMPTY), - V3D_OVERLAY_SHOW_LAMP = (1 << OB_LAMP), - V3D_OVERLAY_SHOW_CAMERA = (1 << OB_CAMERA), - V3D_OVERLAY_SHOW_SPEAKER = (1 << OB_SPEAKER), - V3D_OVERLAY_SHOW_LIGHTPROBE = (1 << OB_LIGHTPROBE), - V3D_OVERLAY_SHOW_ARMATURE = (1 << OB_ARMATURE), -}; -#define V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK (V3D_OVERLAY_SHOW_EMPTY | V3D_OVERLAY_SHOW_LAMP | V3D_OVERLAY_SHOW_CAMERA | V3D_OVERLAY_SHOW_SPEAKER | V3D_OVERLAY_SHOW_LIGHTPROBE | V3D_OVERLAY_SHOW_ARMATURE) - /* View3DOverlay->edit_flag */ enum { V3D_OVERLAY_EDIT_VERT_NORMALS = (1 << 0), diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 00baf948a84..dfad4c07cb3 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2608,54 +2608,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_empties", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_EMPTY); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Empties", "Draw empties in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_EMPTY, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_CAMERA); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Cameras", "Draw cameras in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CAMERA, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_SPEAKER); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Speakers", "Draw speakers in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_SPEAKER, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_lightprobes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_LIGHTPROBE); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Lightprobes", "Draw lightprobes in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LIGHTPROBE, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_ARMATURE); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Armatures", "Draw armatures in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_ARMATURE, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_LAMP); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Lamps", "Draw lamps in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LAMP, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_text", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_TEXT); RNA_def_property_ui_text(prop, "Show Text", "Display overlay text"); -- cgit v1.2.3 From d192d723123add1dde3e9f7e9458aefcafb7e7d2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 5 Jul 2018 15:30:56 +0200 Subject: Ensure dependency graph exists before initializing editors Will help entering sculpt mode on file load by making it possible to fully initialize sculpt session. The goal is to make sure PBVH exists since the very beginning of file open (missing PBVH is a reason why object is not visible before first stroke). This is not enough yet to fully solve the issue, since entering sculpt mode tags object for Copy-on-Write update, which frees PBVH. --- source/blender/blenkernel/intern/paint.c | 9 ----- .../blender/windowmanager/intern/wm_event_system.c | 40 ++++++++++++++-------- source/blender/windowmanager/intern/wm_files.c | 5 +-- source/blender/windowmanager/wm_event_system.h | 1 + 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 4d3a0587a0b..07aa21f44ff 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -864,15 +864,6 @@ void BKE_sculpt_update_mesh_elements( Depsgraph *depsgraph, Scene *scene, Sculpt *sd, Object *ob, bool need_pmap, bool need_mask) { - if (depsgraph == NULL) { - /* Happens on file load. - * - * We do nothing in this case, it will be taken care about on depsgraph - * evaluation. - */ - return; - } - SculptSession *ss = ob->sculpt; Mesh *me = BKE_object_get_original_mesh(ob); MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 204bd62cfbe..19889f57261 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -296,11 +296,7 @@ static void wm_notifier_clear(wmNotifier *note) memset(((char *)note) + sizeof(Link), 0, sizeof(*note) - sizeof(Link)); } -/** - * Was part of #wm_event_do_notifiers, split out so it can be called once before entering the #WM_main loop. - * This ensures operators don't run before the UI and depsgraph are initialized. - */ -void wm_event_do_refresh_wm_and_depsgraph(bContext *C) +void wm_event_do_depsgraph(bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); uint64_t win_combine_v3d_datamask = 0; @@ -315,18 +311,8 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) /* cached: editor refresh callbacks now, they get context */ for (wmWindow *win = wm->windows.first; win; win = win->next) { - const bScreen *screen = WM_window_get_active_screen(win); Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - ScrArea *sa; - - CTX_wm_window_set(C, win); - for (sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->do_refresh) { - CTX_wm_area_set(C, sa); - ED_area_do_refresh(C, sa); - } - } /* XXX make lock in future, or separated derivedmesh users in scene */ if (G.is_rendering == false) { @@ -350,6 +336,30 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) BKE_scene_graph_update_tagged(depsgraph, bmain); } } +} + +/** + * Was part of #wm_event_do_notifiers, split out so it can be called once before entering the #WM_main loop. + * This ensures operators don't run before the UI and depsgraph are initialized. + */ +void wm_event_do_refresh_wm_and_depsgraph(bContext *C) +{ + wmWindowManager *wm = CTX_wm_manager(C); + /* cached: editor refresh callbacks now, they get context */ + for (wmWindow *win = wm->windows.first; win; win = win->next) { + const bScreen *screen = WM_window_get_active_screen(win); + ScrArea *sa; + + CTX_wm_window_set(C, win); + for (sa = screen->areabase.first; sa; sa = sa->next) { + if (sa->do_refresh) { + CTX_wm_area_set(C, sa); + ED_area_do_refresh(C, sa); + } + } + } + + wm_event_do_depsgraph(C); CTX_wm_window_set(C, NULL); } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index f00ec500bc0..240f1e48e4b 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -482,10 +482,11 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo CTX_wm_window_set(C, wm->windows.first); - ED_editors_init(C); - Main *bmain = CTX_data_main(C); DEG_on_visible_update(bmain, true); + wm_event_do_depsgraph(C); + + ED_editors_init(C); #ifdef WITH_PYTHON if (is_startup_file) { diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index b9b41b0b685..d191fe4a9c2 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -97,6 +97,7 @@ void wm_event_do_handlers (bContext *C); void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata); +void wm_event_do_depsgraph(bContext *C); void wm_event_do_refresh_wm_and_depsgraph(bContext *C); void wm_event_do_notifiers(bContext *C); -- cgit v1.2.3 From ec98d8cc9e34b3b4c8b5e73997e708276775c20a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 5 Jul 2018 16:55:25 +0200 Subject: Cleanup: Undefined function declarations --- source/blender/editors/include/ED_screen.h | 5 ----- source/blender/editors/physics/particle_edit.c | 2 -- source/blender/editors/sculpt_paint/sculpt.c | 4 ---- 3 files changed, 11 deletions(-) diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 2b0729a8e13..914641c1add 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -234,11 +234,6 @@ bool ED_workspace_layout_cycle( struct WorkSpace *workspace, const short direction, struct bContext *C) ATTR_NONNULL(); -void ED_workspace_object_mode_sync_from_object( - struct wmWindowManager *wm, WorkSpace *workspace, struct Object *obact); -void ED_workspace_object_mode_sync_from_scene( - struct wmWindowManager *wm, WorkSpace *workspace, struct Scene *scene); - void ED_workspace_status_text(struct bContext *C, const char *str); /* anim */ diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index e637a58e8c6..a08e35d08a7 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4809,8 +4809,6 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); } - // ED_workspace_object_mode_sync_from_object(wm, workspace, ob); - DEG_id_tag_update(&ob->id, OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE); WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 946757d5d20..baaa2d638a3 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5738,8 +5738,6 @@ void ED_object_sculptmode_enter_ex( } } - // ED_workspace_object_mode_sync_from_object(bmain->wm.first, workspace, ob); - /* Flush object mode. */ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); } @@ -5790,8 +5788,6 @@ void ED_object_sculptmode_exit_ex( /* Leave sculptmode */ ob->mode &= ~mode_flag; - // ED_workspace_object_mode_sync_from_object(G_MAIN->wm.first, workspace, ob); - BKE_sculptsession_free(ob); paint_cursor_delete_textures(); -- cgit v1.2.3 From 5db711fdd9d23ef2e54f19545398a6520fa02b56 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 5 Jul 2018 16:55:46 +0200 Subject: Depsgraph: Preserve engine data when doing object copy on write update --- source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 0f49d57a826..447a8af6235 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -713,6 +713,7 @@ typedef struct ObjectRuntimeBackup { CurveCache *curve_cache; Object_Runtime runtime; short base_flag; + ListBase drawdata; } ObjectRuntimeBackup; /* Make a backup of object's evaluation runtime data, additionally @@ -739,6 +740,9 @@ static void deg_backup_object_runtime( object->curve_cache = NULL; /* Make a backup of base flags. */ object_runtime_backup->base_flag = object->base_flag; + /* Make backup of object draw data.*/ + object_runtime_backup->drawdata = object->drawdata; + BLI_listbase_clear(&object->drawdata); } static void deg_restore_object_runtime( @@ -778,6 +782,8 @@ static void deg_restore_object_runtime( object->curve_cache = object_runtime_backup->curve_cache; } object->base_flag = object_runtime_backup->base_flag; + /* Restore draw data. */ + object->drawdata = object_runtime_backup->drawdata; } ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, -- cgit v1.2.3 From 4dfcc6c25a6e058e107b996d08403b803cc52915 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 5 Jul 2018 15:01:04 +0200 Subject: Overlay: enable/disable drawing of specific object types. This patch will allow users to customize what object types will be drawn by the object mode overlay. It supports: Empties, Lamps, Cameras, Speakers, Armatures and Lightprobes. It currently does not support Physics objects due to the overlap it has with other objects types. Also be aware that in pose mode the armature is drawn, but not by the object mode overlay Reviewers: campbellbarton Tags: #bf_blender_2.8 Differential Revision: https://developer.blender.org/D3524 --- release/scripts/startup/bl_ui/space_view3d.py | 9 ++++ source/blender/blenloader/intern/versioning_280.c | 13 ++++++ source/blender/draw/modes/object_mode.c | 52 +++++++++++++++------- source/blender/editors/space_view3d/space_view3d.c | 1 + source/blender/makesdna/DNA_view3d_types.h | 14 +++++- source/blender/makesrna/intern/rna_space.c | 48 ++++++++++++++++++++ 6 files changed, 119 insertions(+), 18 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 7b71d41e678..0c3219ae8e1 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3833,6 +3833,14 @@ class VIEW3D_PT_overlay(Panel): sub.prop(overlay, "show_all_objects_origin") sub = split.column() + row = sub.row(align=True) + row.prop(overlay, "show_empties", text="", toggle=True) + row.prop(overlay, "show_lamps", text="", toggle=True) + row.prop(overlay, "show_cameras", text="", toggle=True) + row.prop(overlay, "show_armatures", text="", toggle=True) + row.prop(overlay, "show_lightprobes", text="", toggle=True) + row.prop(overlay, "show_speakers", text="", toggle=True) + sub.prop(overlay, "show_relationship_lines") sub.prop(overlay, "show_motion_paths") #sub.prop(overlay, "show_onion_skins") @@ -3847,6 +3855,7 @@ class VIEW3D_PT_overlay(Panel): sub.active = overlay.show_wireframes sub.prop(overlay, "wireframe_threshold", text="") + col = layout.column() col.active = display_all split = col.split(percentage=0.55) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 3bdd4db3b94..8194648f369 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1530,6 +1530,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", "visible_object_types")) { + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK; + } + } + } + } + } + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->toolsettings->manipulator_flag == 0) { scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 736bde725ae..2beb453e069 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2217,34 +2217,52 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; } case OB_LAMP: - DRW_shgroup_lamp(stl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_LAMP) + { + DRW_shgroup_lamp(stl, ob, view_layer); + } break; case OB_CAMERA: - DRW_shgroup_camera(stl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_CAMERA) + { + DRW_shgroup_camera(stl, ob, view_layer); + } break; case OB_EMPTY: - DRW_shgroup_empty(stl, psl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_EMPTY) + { + DRW_shgroup_empty(stl, psl, ob, view_layer); + } break; case OB_SPEAKER: - DRW_shgroup_speaker(stl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_SPEAKER) + { + DRW_shgroup_speaker(stl, ob, view_layer); + } break; case OB_LIGHTPROBE: - DRW_shgroup_lightprobe(stl, psl, ob, view_layer); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_LIGHTPROBE) + { + DRW_shgroup_lightprobe(stl, psl, ob, view_layer); + } break; case OB_ARMATURE: { - bArmature *arm = ob->data; - if (arm->edbo == NULL) { - if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { - DRWArmaturePasses passes = { - .bone_solid = psl->bone_solid, - .bone_outline = psl->bone_outline, - .bone_wire = psl->bone_wire, - .bone_envelope = psl->bone_envelope, - .bone_axes = psl->bone_axes, - .relationship_lines = NULL, /* Don't draw relationship lines */ - }; - DRW_shgroup_armature_object(ob, view_layer, passes); + if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_ARMATURE) + { + bArmature *arm = ob->data; + if (arm->edbo == NULL) { + if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { + DRWArmaturePasses passes = { + .bone_solid = psl->bone_solid, + .bone_outline = psl->bone_outline, + .bone_wire = psl->bone_wire, + .bone_envelope = psl->bone_envelope, + .bone_axes = psl->bone_axes, + .relationship_lines = NULL, /* Don't draw relationship lines */ + }; + DRW_shgroup_armature_object(ob, view_layer, passes); + } } } break; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 77beadccd5d..5383e3d9e01 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -338,6 +338,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->overlay.texture_paint_mode_opacity = 0.8; v3d->overlay.weight_paint_mode_opacity = 0.8; v3d->overlay.vertex_paint_mode_opacity = 0.8; + v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK; v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 70f06b2eda0..f7fd4a52a5f 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -49,6 +49,7 @@ struct GPUViewport; #include "DNA_defs.h" #include "DNA_listBase.h" #include "DNA_image_types.h" +#include "DNA_object_types.h" #include "DNA_movieclip_types.h" #include "DNA_gpu_types.h" @@ -178,8 +179,8 @@ typedef struct View3DOverlay { /* Other settings */ float wireframe_threshold; + int visible_object_types; - int pad; } View3DOverlay; /* 3D ViewPort Struct */ @@ -383,6 +384,17 @@ enum { V3D_OVERLAY_ONION_SKINS = (1 << 7), }; +/* View3DOverlay->visible_object_types */ +enum { + V3D_OVERLAY_SHOW_EMPTY = (1 << OB_EMPTY), + V3D_OVERLAY_SHOW_LAMP = (1 << OB_LAMP), + V3D_OVERLAY_SHOW_CAMERA = (1 << OB_CAMERA), + V3D_OVERLAY_SHOW_SPEAKER = (1 << OB_SPEAKER), + V3D_OVERLAY_SHOW_LIGHTPROBE = (1 << OB_LIGHTPROBE), + V3D_OVERLAY_SHOW_ARMATURE = (1 << OB_ARMATURE), +}; +#define V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK (V3D_OVERLAY_SHOW_EMPTY | V3D_OVERLAY_SHOW_LAMP | V3D_OVERLAY_SHOW_CAMERA | V3D_OVERLAY_SHOW_SPEAKER | V3D_OVERLAY_SHOW_LIGHTPROBE | V3D_OVERLAY_SHOW_ARMATURE) + /* View3DOverlay->edit_flag */ enum { V3D_OVERLAY_EDIT_VERT_NORMALS = (1 << 0), diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index dfad4c07cb3..00baf948a84 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2608,6 +2608,54 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_empties", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_EMPTY); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Empties", "Draw empties in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_EMPTY, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_CAMERA); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Cameras", "Draw cameras in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CAMERA, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_SPEAKER); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Speakers", "Draw speakers in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_SPEAKER, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_lightprobes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_LIGHTPROBE); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Lightprobes", "Draw lightprobes in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LIGHTPROBE, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_ARMATURE); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Armatures", "Draw armatures in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_ARMATURE, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_LAMP); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show Lamps", "Draw lamps in the overlay"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LAMP, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_text", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_TEXT); RNA_def_property_ui_text(prop, "Show Text", "Display overlay text"); -- cgit v1.2.3 From 35f8198c9de254ff0ef2595719275413f1b798a5 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 5 Jul 2018 15:13:15 +0200 Subject: Refactor: SHOW->HIDE HIDE needs less code also in the future, RNA still uses SHOW. --- source/blender/blenloader/intern/versioning_280.c | 13 ------------- source/blender/draw/modes/object_mode.c | 12 ++++++------ source/blender/editors/space_view3d/space_view3d.c | 1 - source/blender/makesdna/DNA_view3d_types.h | 17 ++++++++--------- source/blender/makesrna/intern/rna_space.c | 12 ++++++------ 5 files changed, 20 insertions(+), 35 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 8194648f369..3bdd4db3b94 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1530,19 +1530,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", "visible_object_types")) { - for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK; - } - } - } - } - } - for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->toolsettings->manipulator_flag == 0) { scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 2beb453e069..b8387a53f22 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2217,38 +2217,38 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; } case OB_LAMP: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_LAMP) + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_LAMP) == 0) { DRW_shgroup_lamp(stl, ob, view_layer); } break; case OB_CAMERA: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_CAMERA) + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_CAMERA) == 0) { DRW_shgroup_camera(stl, ob, view_layer); } break; case OB_EMPTY: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_EMPTY) + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_EMPTY) == 0) { DRW_shgroup_empty(stl, psl, ob, view_layer); } break; case OB_SPEAKER: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_SPEAKER) + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_SPEAKER) == 0) { DRW_shgroup_speaker(stl, ob, view_layer); } break; case OB_LIGHTPROBE: - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_LIGHTPROBE) + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_LIGHTPROBE) == 0) { DRW_shgroup_lightprobe(stl, psl, ob, view_layer); } break; case OB_ARMATURE: { - if (v3d->overlay.visible_object_types & V3D_OVERLAY_SHOW_ARMATURE) + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_ARMATURE) == 0) { bArmature *arm = ob->data; if (arm->edbo == NULL) { diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 5383e3d9e01..77beadccd5d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -338,7 +338,6 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->overlay.texture_paint_mode_opacity = 0.8; v3d->overlay.weight_paint_mode_opacity = 0.8; v3d->overlay.vertex_paint_mode_opacity = 0.8; - v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK; v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index f7fd4a52a5f..04edb202ded 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -179,7 +179,7 @@ typedef struct View3DOverlay { /* Other settings */ float wireframe_threshold; - int visible_object_types; + int hidden_object_types; } View3DOverlay; @@ -384,16 +384,15 @@ enum { V3D_OVERLAY_ONION_SKINS = (1 << 7), }; -/* View3DOverlay->visible_object_types */ +/* View3DOverlay->hidden_object_types */ enum { - V3D_OVERLAY_SHOW_EMPTY = (1 << OB_EMPTY), - V3D_OVERLAY_SHOW_LAMP = (1 << OB_LAMP), - V3D_OVERLAY_SHOW_CAMERA = (1 << OB_CAMERA), - V3D_OVERLAY_SHOW_SPEAKER = (1 << OB_SPEAKER), - V3D_OVERLAY_SHOW_LIGHTPROBE = (1 << OB_LIGHTPROBE), - V3D_OVERLAY_SHOW_ARMATURE = (1 << OB_ARMATURE), + V3D_OVERLAY_HIDE_EMPTY = (1 << OB_EMPTY), + V3D_OVERLAY_HIDE_LAMP = (1 << OB_LAMP), + V3D_OVERLAY_HIDE_CAMERA = (1 << OB_CAMERA), + V3D_OVERLAY_HIDE_SPEAKER = (1 << OB_SPEAKER), + V3D_OVERLAY_HIDE_LIGHTPROBE = (1 << OB_LIGHTPROBE), + V3D_OVERLAY_HIDE_ARMATURE = (1 << OB_ARMATURE), }; -#define V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK (V3D_OVERLAY_SHOW_EMPTY | V3D_OVERLAY_SHOW_LAMP | V3D_OVERLAY_SHOW_CAMERA | V3D_OVERLAY_SHOW_SPEAKER | V3D_OVERLAY_SHOW_LIGHTPROBE | V3D_OVERLAY_SHOW_ARMATURE) /* View3DOverlay->edit_flag */ enum { diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 00baf948a84..346ca6c8774 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2609,7 +2609,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_empties", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_EMPTY); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_EMPTY); RNA_def_property_boolean_default(prop, true); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Show Empties", "Draw empties in the overlay"); @@ -2617,7 +2617,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_CAMERA); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_CAMERA); RNA_def_property_boolean_default(prop, true); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Show Cameras", "Draw cameras in the overlay"); @@ -2625,7 +2625,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_SPEAKER); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_SPEAKER); RNA_def_property_boolean_default(prop, true); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Show Speakers", "Draw speakers in the overlay"); @@ -2633,7 +2633,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_lightprobes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_LIGHTPROBE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_LIGHTPROBE); RNA_def_property_boolean_default(prop, true); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Show Lightprobes", "Draw lightprobes in the overlay"); @@ -2641,7 +2641,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_ARMATURE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_ARMATURE); RNA_def_property_boolean_default(prop, true); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Show Armatures", "Draw armatures in the overlay"); @@ -2649,7 +2649,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.visible_object_types", V3D_OVERLAY_SHOW_LAMP); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_LAMP); RNA_def_property_boolean_default(prop, true); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Show Lamps", "Draw lamps in the overlay"); -- cgit v1.2.3 From 404bacc63980e33957c1ee98f2bd758dac90e951 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 5 Jul 2018 15:39:20 +0200 Subject: Refactored into a single option Technical all options are still there for finetuning. --- release/scripts/startup/bl_ui/space_view3d.py | 9 +---- source/blender/draw/modes/object_mode.c | 36 +++++++++++--------- source/blender/makesdna/DNA_view3d_types.h | 2 ++ source/blender/makesrna/intern/rna_space.c | 47 ++------------------------- 4 files changed, 27 insertions(+), 67 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 0c3219ae8e1..1ed33b78706 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3833,14 +3833,7 @@ class VIEW3D_PT_overlay(Panel): sub.prop(overlay, "show_all_objects_origin") sub = split.column() - row = sub.row(align=True) - row.prop(overlay, "show_empties", text="", toggle=True) - row.prop(overlay, "show_lamps", text="", toggle=True) - row.prop(overlay, "show_cameras", text="", toggle=True) - row.prop(overlay, "show_armatures", text="", toggle=True) - row.prop(overlay, "show_lightprobes", text="", toggle=True) - row.prop(overlay, "show_speakers", text="", toggle=True) - + sub.prop(overlay, "show_non_renderable_objects") sub.prop(overlay, "show_relationship_lines") sub.prop(overlay, "show_motion_paths") #sub.prop(overlay, "show_onion_skins") diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index b8387a53f22..0a45dd7f123 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2185,27 +2185,31 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; case OB_LATTICE: { - if (ob != draw_ctx->object_edit) { - struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false); - if (theme_id == TH_UNDEFINED) { - theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); - } + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_OTHER) == 0) { + if (ob != draw_ctx->object_edit) { + struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false); + if (theme_id == TH_UNDEFINED) { + theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); + } - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); - DRW_shgroup_call_object_add(shgroup, geom, ob); + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); + DRW_shgroup_call_object_add(shgroup, geom, ob); + } } break; } case OB_CURVE: { - if (ob != draw_ctx->object_edit) { - struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob); - if (theme_id == TH_UNDEFINED) { - theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_OTHER) == 0) { + if (ob != draw_ctx->object_edit) { + struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob); + if (theme_id == TH_UNDEFINED) { + theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); + } + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); + DRW_shgroup_call_object_add(shgroup, geom, ob); } - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); - DRW_shgroup_call_object_add(shgroup, geom, ob); } break; } @@ -2271,8 +2275,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; } - if (ob->pd && ob->pd->forcefield) { - DRW_shgroup_forcefield(stl, ob, view_layer); + if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_OTHER) == 0) { + if (ob->pd && ob->pd->forcefield) { + DRW_shgroup_forcefield(stl, ob, view_layer); + } } /* don't show object extras in set's */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 04edb202ded..c1244e9a0c7 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -392,7 +392,9 @@ enum { V3D_OVERLAY_HIDE_SPEAKER = (1 << OB_SPEAKER), V3D_OVERLAY_HIDE_LIGHTPROBE = (1 << OB_LIGHTPROBE), V3D_OVERLAY_HIDE_ARMATURE = (1 << OB_ARMATURE), + V3D_OVERLAY_HIDE_OTHER = (1 << 14), }; +#define V3D_OVERLAY_HIDE_NON_RENDERABLE (V3D_OVERLAY_HIDE_EMPTY | V3D_OVERLAY_HIDE_LAMP | V3D_OVERLAY_HIDE_CAMERA | V3D_OVERLAY_HIDE_SPEAKER | V3D_OVERLAY_HIDE_LIGHTPROBE | V3D_OVERLAY_HIDE_ARMATURE | V3D_OVERLAY_HIDE_OTHER) /* View3DOverlay->edit_flag */ enum { diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 346ca6c8774..249f6b29143 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2608,52 +2608,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_empties", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_EMPTY); + prop = RNA_def_property(srna, "show_non_renderable_objects", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_NON_RENDERABLE); RNA_def_property_boolean_default(prop, true); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Empties", "Draw empties in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_EMPTY, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_CAMERA); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Cameras", "Draw cameras in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CAMERA, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_SPEAKER); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Speakers", "Draw speakers in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_SPEAKER, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_lightprobes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_LIGHTPROBE); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Lightprobes", "Draw lightprobes in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LIGHTPROBE, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_ARMATURE); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Armatures", "Draw armatures in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_ARMATURE, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_LAMP); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Lamps", "Draw lamps in the overlay"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LAMP, 0); + RNA_def_property_ui_text(prop, "Show Non Renderable", "Draw not renderable objects in the overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_text", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3 From 997b73c1dbac2bad7af6ac57e2a44cf67a505d75 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 16:54:30 +0200 Subject: 3D View: split view-numpad into two operators Naming operator based on keys it used was strange, split into view-axis and view-camera. --- release/scripts/presets/keyconfig/blender_27x.py | 45 ++++++------- release/scripts/startup/bl_ui/space_view3d.py | 28 ++++---- source/blender/editors/space_view3d/view3d_edit.c | 78 ++++++++++++++++------ .../blender/editors/space_view3d/view3d_intern.h | 3 +- .../space_view3d/view3d_manipulator_navigate.c | 10 +-- source/blender/editors/space_view3d/view3d_ops.c | 47 ++++++------- 6 files changed, 124 insertions(+), 87 deletions(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index e047364a9e3..e2a4c37cdad 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -2208,28 +2208,27 @@ kmi_props_setattr(kmi.properties, 'use_all_regions', True) kmi_props_setattr(kmi.properties, 'center', False) kmi = km.keymap_items.new('view3d.view_all', 'C', 'PRESS', shift=True) kmi_props_setattr(kmi.properties, 'center', True) -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_0', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'CAMERA') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS') +kmi = km.keymap_items.new('view3d.view_camera', 'NUMPAD_0', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_1', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'FRONT') kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_2', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'ORBITDOWN') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_3', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'RIGHT') kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_4', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'ORBITLEFT') kmi = km.keymap_items.new('view3d.view_persportho', 'NUMPAD_5', 'PRESS') kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_6', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'ORBITRIGHT') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_7', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'TOP') kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_8', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'ORBITUP') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_1', 'PRESS', ctrl=True) kmi_props_setattr(kmi.properties, 'type', 'BACK') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_3', 'PRESS', ctrl=True) kmi_props_setattr(kmi.properties, 'type', 'LEFT') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_7', 'PRESS', ctrl=True) kmi_props_setattr(kmi.properties, 'type', 'BOTTOM') kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_2', 'PRESS', ctrl=True) kmi_props_setattr(kmi.properties, 'type', 'PANDOWN') @@ -2266,22 +2265,22 @@ kmi = km.keymap_items.new('view3d.view_roll', 'WHEELUPMOUSE', 'PRESS', shift=Tru kmi_props_setattr(kmi.properties, 'type', 'LEFT') kmi = km.keymap_items.new('view3d.view_roll', 'WHEELDOWNMOUSE', 'PRESS', shift=True, ctrl=True) kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_1', 'PRESS', shift=True) kmi_props_setattr(kmi.properties, 'type', 'FRONT') kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_3', 'PRESS', shift=True) kmi_props_setattr(kmi.properties, 'type', 'RIGHT') kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_7', 'PRESS', shift=True) kmi_props_setattr(kmi.properties, 'type', 'TOP') kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_1', 'PRESS', shift=True, ctrl=True) kmi_props_setattr(kmi.properties, 'type', 'BACK') kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_3', 'PRESS', shift=True, ctrl=True) kmi_props_setattr(kmi.properties, 'type', 'LEFT') kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_7', 'PRESS', shift=True, ctrl=True) kmi_props_setattr(kmi.properties, 'type', 'BOTTOM') kmi_props_setattr(kmi.properties, 'align_active', True) kmi = km.keymap_items.new('view3d.ndof_orbit_zoom', 'NDOF_MOTION', 'ANY') @@ -2294,25 +2293,25 @@ kmi = km.keymap_items.new('view3d.view_roll', 'NDOF_BUTTON_ROLL_CCW', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'LEFT') kmi = km.keymap_items.new('view3d.view_roll', 'NDOF_BUTTON_ROLL_CCW', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_FRONT', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_FRONT', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'FRONT') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_BACK', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_BACK', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'BACK') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_LEFT', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_LEFT', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'LEFT') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_RIGHT', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_RIGHT', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_TOP', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_TOP', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'TOP') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_BOTTOM', 'PRESS') +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_BOTTOM', 'PRESS') kmi_props_setattr(kmi.properties, 'type', 'BOTTOM') -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_FRONT', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_FRONT', 'PRESS', shift=True) kmi_props_setattr(kmi.properties, 'type', 'FRONT') kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_RIGHT', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_RIGHT', 'PRESS', shift=True) kmi_props_setattr(kmi.properties, 'type', 'RIGHT') kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.viewnumpad', 'NDOF_BUTTON_TOP', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_TOP', 'PRESS', shift=True) kmi_props_setattr(kmi.properties, 'type', 'TOP') kmi_props_setattr(kmi.properties, 'align_active', True) kmi = km.keymap_items.new('view3d.layers', 'ACCENT_GRAVE', 'PRESS') diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 1ed33b78706..4614a4bd84a 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -573,7 +573,7 @@ class VIEW3D_MT_view_cameras(Menu): layout = self.layout layout.operator("view3d.object_as_camera") - layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA' + layout.operator("view3d.view_camera", text="Active Camera") class VIEW3D_MT_view_viewpoint(Menu): @@ -582,22 +582,22 @@ class VIEW3D_MT_view_viewpoint(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA' + layout.operator("view3d.view_camera", text="Camera") layout.separator() - layout.operator("view3d.viewnumpad", text="Top").type = 'TOP' - layout.operator("view3d.viewnumpad", text="Bottom").type = 'BOTTOM' + layout.operator("view3d.view_axis", text="Top").type = 'TOP' + layout.operator("view3d.view_axis", text="Bottom").type = 'BOTTOM' layout.separator() - layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT' - layout.operator("view3d.viewnumpad", text="Back").type = 'BACK' + layout.operator("view3d.view_axis", text="Front").type = 'FRONT' + layout.operator("view3d.view_axis", text="Back").type = 'BACK' layout.separator() - layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT' - layout.operator("view3d.viewnumpad", text="Left").type = 'LEFT' + layout.operator("view3d.view_axis", text="Right").type = 'RIGHT' + layout.operator("view3d.view_axis", text="Left").type = 'LEFT' class VIEW3D_MT_view_navigation(Menu): @@ -661,27 +661,27 @@ class VIEW3D_MT_view_align_selected(Menu): def draw(self, context): layout = self.layout - props = layout.operator("view3d.viewnumpad", text="Top") + props = layout.operator("view3d.view_axis", text="Top") props.align_active = True props.type = 'TOP' - props = layout.operator("view3d.viewnumpad", text="Bottom") + props = layout.operator("view3d.view_axis", text="Bottom") props.align_active = True props.type = 'BOTTOM' - props = layout.operator("view3d.viewnumpad", text="Front") + props = layout.operator("view3d.view_axis", text="Front") props.align_active = True props.type = 'FRONT' - props = layout.operator("view3d.viewnumpad", text="Back") + props = layout.operator("view3d.view_axis", text="Back") props.align_active = True props.type = 'BACK' - props = layout.operator("view3d.viewnumpad", text="Right") + props = layout.operator("view3d.view_axis", text="Right") props.align_active = True props.type = 'RIGHT' - props = layout.operator("view3d.viewnumpad", text="Left") + props = layout.operator("view3d.view_axis", text="Left") props.align_active = True props.type = 'LEFT' diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index cc30375255d..24cd6da314c 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3602,7 +3602,7 @@ void VIEW3D_OT_zoom_camera_1_to_1(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/** \name View Axis/Type Operator +/** \name View Axis Operator * \{ */ static const EnumPropertyItem prop_view_items[] = { @@ -3612,7 +3612,6 @@ static const EnumPropertyItem prop_view_items[] = { {RV3D_VIEW_TOP, "TOP", ICON_TRIA_UP, "Top", "View From the Top"}, {RV3D_VIEW_FRONT, "FRONT", 0, "Front", "View From the Front"}, {RV3D_VIEW_BACK, "BACK", 0, "Back", "View From the Back"}, - {RV3D_VIEW_CAMERA, "CAMERA", ICON_CAMERA_DATA, "Camera", "View From the Active Camera"}, {0, NULL, 0, NULL, NULL} }; @@ -3710,7 +3709,7 @@ static void axis_set_view( } } -static int viewnumpad_exec(bContext *C, wmOperator *op) +static int view_axis_exec(bContext *C, wmOperator *op) { View3D *v3d; ARegion *ar; @@ -3738,13 +3737,60 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) nextperspo = perspo; } - if (RV3D_VIEW_IS_AXIS(viewnum)) { + { float quat[4]; - ED_view3d_quat_from_axis_view(viewnum, quat); axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_active, smooth_viewtx); } - else if (viewnum == RV3D_VIEW_CAMERA) { + + perspo = rv3d->persp; + + return OPERATOR_FINISHED; +} + + +void VIEW3D_OT_view_axis(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "View Axis"; + ot->description = "Use a preset viewpoint"; + ot->idname = "VIEW3D_OT_view_axis"; + + /* api callbacks */ + ot->exec = view_axis_exec; + ot->poll = ED_operator_rv3d_user_region_poll; + + /* flags */ + ot->flag = 0; + + ot->prop = RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "Preset viewpoint to use"); + RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "align_active", 0, "Align Active", "Align to the active object's axis"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name View Camera Operator + * \{ */ + +static int view_camera_exec(bContext *C, wmOperator *op) +{ + View3D *v3d; + ARegion *ar; + RegionView3D *rv3d; + const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); + + /* no NULL check is needed, poll checks */ + ED_view3d_context_user_region(C, &v3d, &ar); + rv3d = ar->regiondata; + + ED_view3d_smooth_view_force_finish(C, v3d, ar); + + { if ((rv3d->viewlock & RV3D_LOCKED) == 0) { /* lastview - */ @@ -3816,32 +3862,22 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) } } - if (rv3d->persp != RV3D_CAMOB) perspo = rv3d->persp; - return OPERATOR_FINISHED; } - -void VIEW3D_OT_viewnumpad(wmOperatorType *ot) +void VIEW3D_OT_view_camera(wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ - ot->name = "View Numpad"; - ot->description = "Use a preset viewpoint"; - ot->idname = "VIEW3D_OT_viewnumpad"; + ot->name = "View Camera"; + ot->description = "Toggle the camera view"; + ot->idname = "VIEW3D_OT_view_camera"; /* api callbacks */ - ot->exec = viewnumpad_exec; + ot->exec = view_camera_exec; ot->poll = ED_operator_rv3d_user_region_poll; /* flags */ ot->flag = 0; - - ot->prop = RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "Preset viewpoint to use"); - RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "align_active", 0, "Align Active", "Align to the active object's axis"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 8263d1d892c..9cc27a2854f 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -83,7 +83,8 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot); void VIEW3D_OT_ndof_all(struct wmOperatorType *ot); #endif /* WITH_INPUT_NDOF */ void VIEW3D_OT_view_all(struct wmOperatorType *ot); -void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); +void VIEW3D_OT_view_axis(struct wmOperatorType *ot); +void VIEW3D_OT_view_camera(struct wmOperatorType *ot); void VIEW3D_OT_view_selected(struct wmOperatorType *ot); void VIEW3D_OT_view_lock_clear(struct wmOperatorType *ot); void VIEW3D_OT_view_lock_to_active(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c index 22b7af48de6..9eb3ca89c55 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c @@ -154,7 +154,7 @@ struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = { .manipulator = "MANIPULATOR_WT_button_2d", .SHAPE_VARS(shape_ortho), }, { - .opname = "VIEW3D_OT_viewnumpad", + .opname = "VIEW3D_OT_view_camera", .manipulator = "MANIPULATOR_WT_button_2d", .SHAPE_VARS(shape_camera), }, @@ -197,7 +197,8 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG navgroup->region_size[0] = -1; navgroup->region_size[1] = -1; - wmOperatorType *ot_viewnumpad = WM_operatortype_find("VIEW3D_OT_viewnumpad", true); + wmOperatorType *ot_view_axis = WM_operatortype_find("VIEW3D_OT_view_axis", true); + wmOperatorType *ot_view_camera = WM_operatortype_find("VIEW3D_OT_view_camera", true); for (int i = 0; i < MPR_TOTAL; i++) { const struct NavigateManipulatorInfo *info = &g_navigate_params[i]; @@ -223,8 +224,7 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG { wmManipulator *mpr = navgroup->mpr_array[MPR_CAMERA]; - PointerRNA *ptr = WM_manipulator_operator_set(mpr, 0, ot_viewnumpad, NULL); - RNA_enum_set(ptr, "type", RV3D_VIEW_CAMERA); + WM_manipulator_operator_set(mpr, 0, ot_view_camera, NULL); } /* Click only buttons (not modal). */ @@ -259,7 +259,7 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG }; for (int part_index = 0; part_index < 6; part_index += 1) { - PointerRNA *ptr = WM_manipulator_operator_set(mpr, part_index + 1, ot_viewnumpad, NULL); + PointerRNA *ptr = WM_manipulator_operator_set(mpr, part_index + 1, ot_view_axis, NULL); RNA_enum_set(ptr, "type", mapping[part_index]); } diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index f93ea7bf618..b4fa092bede 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -174,7 +174,8 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_ndof_all); #endif /* WITH_INPUT_NDOF */ WM_operatortype_append(VIEW3D_OT_view_all); - WM_operatortype_append(VIEW3D_OT_viewnumpad); + WM_operatortype_append(VIEW3D_OT_view_axis); + WM_operatortype_append(VIEW3D_OT_view_camera); WM_operatortype_append(VIEW3D_OT_view_orbit); WM_operatortype_append(VIEW3D_OT_view_roll); WM_operatortype_append(VIEW3D_OT_view_pan); @@ -313,19 +314,19 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_view_pie", ACCENTGRAVEKEY, KM_CLICK_DRAG, 0, 0); /* numpad view hotkeys*/ - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_CAMERA); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT); + WM_keymap_add_item(keymap, "VIEW3D_OT_view_camera", PAD0, KM_PRESS, 0, 0); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD2, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPDOWN); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD4, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT); WM_keymap_add_item(keymap, "VIEW3D_OT_view_persportho", PAD5, KM_PRESS, 0, 0); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD6, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD8, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPUP); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BACK); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_LEFT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BOTTOM); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BACK); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_LEFT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BOTTOM); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD2, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANDOWN); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD4, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT); @@ -352,22 +353,22 @@ void view3d_keymap(wmKeyConfig *keyconf) #endif /* active aligned, replaces '*' key in 2.4x */ - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD1, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT); RNA_boolean_set(kmi->ptr, "align_active", true); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD3, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT); RNA_boolean_set(kmi->ptr, "align_active", true); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD7, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP); RNA_boolean_set(kmi->ptr, "align_active", true); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD1, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BACK); RNA_boolean_set(kmi->ptr, "align_active", true); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD3, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT); RNA_boolean_set(kmi->ptr, "align_active", true); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", PAD7, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM); RNA_boolean_set(kmi->ptr, "align_active", true); @@ -383,21 +384,21 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", NDOF_BUTTON_ROLL_CCW, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", NDOF_BUTTON_ROLL_CCW, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_LEFT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_LEFT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BOTTOM, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BOTTOM); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_LEFT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_LEFT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_RIGHT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_TOP, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_BOTTOM, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BOTTOM); /* 3D mouse align */ - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_FRONT, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT); RNA_boolean_set(kmi->ptr, "align_active", true); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_RIGHT, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT); RNA_boolean_set(kmi->ptr, "align_active", true); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", NDOF_BUTTON_TOP, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP); RNA_boolean_set(kmi->ptr, "align_active", true); #endif /* WITH_INPUT_NDOF */ -- cgit v1.2.3 From c974a359531733e02adcd7366d684291b257affa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 16:59:52 +0200 Subject: Cleanup: indentation --- source/blender/editors/space_view3d/view3d_edit.c | 120 ++++++++++------------ 1 file changed, 53 insertions(+), 67 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 24cd6da314c..88edf32d154 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3715,7 +3715,7 @@ static int view_axis_exec(bContext *C, wmOperator *op) ARegion *ar; RegionView3D *rv3d; static int perspo = RV3D_PERSP; - int viewnum, nextperspo; + int viewnum; bool align_active; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); @@ -3729,19 +3729,10 @@ static int view_axis_exec(bContext *C, wmOperator *op) align_active = RNA_boolean_get(op->ptr, "align_active"); /* Use this to test if we started out with a camera */ - - if (rv3d->persp == RV3D_CAMOB) { - nextperspo = rv3d->lpersp; - } - else { - nextperspo = perspo; - } - - { - float quat[4]; - ED_view3d_quat_from_axis_view(viewnum, quat); - axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_active, smooth_viewtx); - } + const int nextperspo = (rv3d->persp == RV3D_CAMOB) ? rv3d->lpersp : perspo; + float quat[4]; + ED_view3d_quat_from_axis_view(viewnum, quat); + axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_active, smooth_viewtx); perspo = rv3d->persp; @@ -3790,75 +3781,70 @@ static int view_camera_exec(bContext *C, wmOperator *op) ED_view3d_smooth_view_force_finish(C, v3d, ar); - { - if ((rv3d->viewlock & RV3D_LOCKED) == 0) { - /* lastview - */ + if ((rv3d->viewlock & RV3D_LOCKED) == 0) { + /* lastview - */ - ViewLayer *view_layer = CTX_data_view_layer(C); - Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Scene *scene = CTX_data_scene(C); - if (rv3d->persp != RV3D_CAMOB) { - Object *ob = OBACT(view_layer); + if (rv3d->persp != RV3D_CAMOB) { + Object *ob = OBACT(view_layer); - if (!rv3d->smooth_timer) { - /* store settings of current view before allowing overwriting with camera view - * only if we're not currently in a view transition */ + if (!rv3d->smooth_timer) { + /* store settings of current view before allowing overwriting with camera view + * only if we're not currently in a view transition */ - ED_view3d_lastview_store(rv3d); - } + ED_view3d_lastview_store(rv3d); + } #if 0 - if (G.qual == LR_ALTKEY) { - if (oldcamera && is_an_active_object(oldcamera)) { - v3d->camera = oldcamera; - } - handle_view3d_lock(); + if (G.qual == LR_ALTKEY) { + if (oldcamera && is_an_active_object(oldcamera)) { + v3d->camera = oldcamera; } + handle_view3d_lock(); + } #endif - /* first get the default camera for the view lock type */ - if (v3d->scenelock) { - /* sets the camera view if available */ + /* first get the default camera for the view lock type */ + if (v3d->scenelock) { + /* sets the camera view if available */ + v3d->camera = scene->camera; + } + else { + /* use scene camera if one is not set (even though we're unlocked) */ + if (v3d->camera == NULL) { v3d->camera = scene->camera; } - else { - /* use scene camera if one is not set (even though we're unlocked) */ - if (v3d->camera == NULL) { - v3d->camera = scene->camera; - } - } + } - /* if the camera isn't found, check a number of options */ - if (v3d->camera == NULL && ob && ob->type == OB_CAMERA) - v3d->camera = ob; + /* if the camera isn't found, check a number of options */ + if (v3d->camera == NULL && ob && ob->type == OB_CAMERA) + v3d->camera = ob; - if (v3d->camera == NULL) - v3d->camera = BKE_view_layer_camera_find(view_layer); + if (v3d->camera == NULL) + v3d->camera = BKE_view_layer_camera_find(view_layer); - /* couldnt find any useful camera, bail out */ - if (v3d->camera == NULL) - return OPERATOR_CANCELLED; + /* couldnt find any useful camera, bail out */ + if (v3d->camera == NULL) + return OPERATOR_CANCELLED; - /* important these don't get out of sync for locked scenes */ - if (v3d->scenelock) - scene->camera = v3d->camera; + /* important these don't get out of sync for locked scenes */ + if (v3d->scenelock) + scene->camera = v3d->camera; - /* finally do snazzy view zooming */ - rv3d->persp = RV3D_CAMOB; - ED_view3d_smooth_view( - C, v3d, ar, smooth_viewtx, - &(const V3D_SmoothParams) { - .camera = v3d->camera, .ofs = rv3d->ofs, .quat = rv3d->viewquat, - .dist = &rv3d->dist, .lens = &v3d->lens}); - } - else { - /* return to settings of last view */ - /* does view3d_smooth_view too */ - axis_set_view(C, v3d, ar, - rv3d->lviewquat, - rv3d->lview, rv3d->lpersp, 0, - smooth_viewtx); - } + /* finally do snazzy view zooming */ + rv3d->persp = RV3D_CAMOB; + ED_view3d_smooth_view( + C, v3d, ar, smooth_viewtx, + &(const V3D_SmoothParams) { + .camera = v3d->camera, .ofs = rv3d->ofs, .quat = rv3d->viewquat, + .dist = &rv3d->dist, .lens = &v3d->lens}); + } + else { + /* return to settings of last view */ + /* does view3d_smooth_view too */ + axis_set_view(C, v3d, ar, rv3d->lviewquat, rv3d->lview, rv3d->lpersp, 0, smooth_viewtx); } } -- cgit v1.2.3 From d8223468fe445797a300dd5cd97fe49f74ca6128 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 5 Jul 2018 17:20:44 +0200 Subject: GPU: avoid unnecessary multiple nodetree localize and output finding. --- source/blender/blenkernel/BKE_node.h | 5 +- source/blender/gpu/intern/gpu_material.c | 3 +- source/blender/nodes/shader/node_shader_tree.c | 67 +++++++--------------- source/blender/nodes/shader/node_shader_util.c | 4 +- source/blender/nodes/shader/node_shader_util.h | 2 +- .../nodes/shader/nodes/node_shader_common.c | 6 +- 6 files changed, 27 insertions(+), 60 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 1578176d465..a400337e2cf 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -254,7 +254,6 @@ typedef struct bNodeType { /* nodetype->compatibility */ #define NODE_OLD_SHADING (1 << 0) #define NODE_NEW_SHADING (1 << 1) -#define NODE_NEWER_SHADING (1 << 2) /* node resize directions */ #define NODE_RESIZE_TOP 1 @@ -814,8 +813,8 @@ struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree); void ntreeShaderEndExecTree(struct bNodeTreeExec *exec); bool ntreeShaderExecTree(struct bNodeTree *ntree, int thread); -void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat, short compatibility); -void ntreeGPUMaterialDomain(struct bNodeTree *ntree, bool *has_surface_output, bool *has_volume_output); +void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat, + bool *has_surface_output, bool *has_volume_output); /** \} */ diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 9c776e64ba0..c224e3e0e32 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -644,8 +644,7 @@ GPUMaterial *GPU_material_from_nodetree( mat->engine_type = engine_type; mat->options = options; - ntreeGPUMaterialNodes(ntree, mat, NODE_NEW_SHADING | NODE_NEWER_SHADING); - ntreeGPUMaterialDomain(ntree, &has_surface_output, &has_volume_output); + ntreeGPUMaterialNodes(ntree, mat, &has_surface_output, &has_volume_output); if (has_surface_output) { mat->domain |= GPU_DOMAIN_SURFACE; diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 301fd3c35a8..329e850d19e 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -258,11 +258,11 @@ static bNodeSocket *ntree_shader_node_find_output(bNode *node, * also returned. */ static bool ntree_shader_has_displacement(bNodeTree *ntree, + bNode *output_node, bNode **r_node, bNodeSocket **r_socket, bNodeLink **r_link) { - bNode *output_node = ntree_shader_output_node(ntree); if (output_node == NULL) { /* We can't have displacement without output node, apparently. */ return false; @@ -426,17 +426,13 @@ static void ntree_shader_link_builtin_normal(bNodeTree *ntree, /* Re-link displacement output to unconnected normal sockets via bump node. * This way material with have proper displacement in the viewport. */ -static void ntree_shader_relink_displacement(bNodeTree *ntree, - short compatibility) +static void ntree_shader_relink_displacement(bNodeTree *ntree, bNode *output_node) { - if ((compatibility & NODE_NEW_SHADING) == 0) { - /* We can only deal with new shading system here. */ - return; - } bNode *displacement_node; bNodeSocket *displacement_socket; bNodeLink *displacement_link; if (!ntree_shader_has_displacement(ntree, + output_node, &displacement_node, &displacement_socket, &displacement_link)) @@ -514,14 +510,8 @@ static bool ntree_tag_ssr_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void * /* EEVEE: Scan the ntree to set the Screen Space Reflection * layer id of every specular node. */ -static void ntree_shader_tag_ssr_node(bNodeTree *ntree, short compatibility) +static void ntree_shader_tag_ssr_node(bNodeTree *ntree, bNode *output_node) { - if ((compatibility & NODE_NEWER_SHADING) == 0) { - /* We can only deal with new shading system here. */ - return; - } - - bNode *output_node = ntree_shader_output_node(ntree); if (output_node == NULL) { return; } @@ -549,14 +539,8 @@ static bool ntree_tag_sss_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void * /* EEVEE: Scan the ntree to set the Subsurface Scattering id of every SSS node. */ -static void ntree_shader_tag_sss_node(bNodeTree *ntree, short compatibility) +static void ntree_shader_tag_sss_node(bNodeTree *ntree, bNode *output_node) { - if ((compatibility & NODE_NEWER_SHADING) == 0) { - /* We can only deal with new shading system here. */ - return; - } - - bNode *output_node = ntree_shader_output_node(ntree); if (output_node == NULL) { return; } @@ -567,15 +551,26 @@ static void ntree_shader_tag_sss_node(bNodeTree *ntree, short compatibility) nodeChainIter(ntree, output_node, ntree_tag_sss_bsdf_cb, &sss_id, true); } -/* EEVEE: Find which material domain are used (volume, surface ...). - */ -void ntreeGPUMaterialDomain(bNodeTree *ntree, bool *has_surface_output, bool *has_volume_output) +void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, bool *has_surface_output, bool *has_volume_output) { /* localize tree to create links for reroute and mute */ bNodeTree *localtree = ntreeLocalize(ntree); + bNode *output = ntree_shader_output_node(localtree); + bNodeTreeExec *exec; + + /* Perform all needed modifications on the tree in order to support + * displacement/bump mapping. + */ + ntree_shader_relink_displacement(localtree, output); + + ntree_shader_tag_ssr_node(localtree, output); + ntree_shader_tag_sss_node(localtree, output); - struct bNode *output = ntree_shader_output_node(localtree); + exec = ntreeShaderBeginExecTree(localtree); + ntreeExecGPUNodes(exec, mat, 1); + ntreeShaderEndExecTree(exec); + /* EEVEE: Find which material domain was used (volume, surface ...). */ *has_surface_output = false; *has_volume_output = false; @@ -596,28 +591,6 @@ void ntreeGPUMaterialDomain(bNodeTree *ntree, bool *has_surface_output, bool *ha MEM_freeN(localtree); } -void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, short compatibility) -{ - /* localize tree to create links for reroute and mute */ - bNodeTree *localtree = ntreeLocalize(ntree); - bNodeTreeExec *exec; - - /* Perform all needed modifications on the tree in order to support - * displacement/bump mapping. - */ - ntree_shader_relink_displacement(localtree, compatibility); - - ntree_shader_tag_ssr_node(localtree, compatibility); - ntree_shader_tag_sss_node(localtree, compatibility); - - exec = ntreeShaderBeginExecTree(localtree); - ntreeExecGPUNodes(exec, mat, 1, compatibility); - ntreeShaderEndExecTree(exec); - - ntreeFreeTree(localtree); - MEM_freeN(localtree); -} - bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key) { bNodeTreeExec *exec; diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 5cc7d14bc8b..1ae50dab358 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -207,7 +207,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree) return inactivenode; } -void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, short compatibility) +void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs) { bNodeExec *nodeexec; bNode *node; @@ -226,7 +226,7 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, sh do_it = false; /* for groups, only execute outputs for edited group */ if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { - if (node->typeinfo->compatibility & compatibility) + if (node->typeinfo->compatibility & NODE_NEW_SHADING) if (do_outputs && (node->flag & NODE_DO_OUTPUT)) do_it = true; } diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h index 4fb18b1a9d8..7fce5ed9927 100644 --- a/source/blender/nodes/shader/node_shader_util.h +++ b/source/blender/nodes/shader/node_shader_util.h @@ -98,6 +98,6 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeSta void node_data_from_gpu_stack(struct bNodeStack *ns, struct GPUNodeStack *gs); void node_shader_gpu_tex_mapping(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out); -void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs, short compatibility); +void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs); #endif diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index 24de03dbda4..09fc10a4c71 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -215,11 +215,7 @@ static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execd return 0; group_gpu_copy_inputs(node, in, exec->stack); -#if 0 /* XXX NODE_GROUP_EDIT is deprecated, depends on node space */ - ntreeExecGPUNodes(exec, mat, (node->flag & NODE_GROUP_EDIT)); -#else - ntreeExecGPUNodes(exec, mat, 0, NODE_NEW_SHADING | NODE_OLD_SHADING); -#endif + ntreeExecGPUNodes(exec, mat, 0); group_gpu_move_outputs(node, out, exec->stack); return 1; -- cgit v1.2.3 From 5bd57aaa052d9578d089a92338d6f0977b5d6c5c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 5 Jul 2018 12:28:03 +0200 Subject: Viewport: tweak Z key shading toggle. * Z now goes to solid mode when in lookdev or rendered mode. * Alt-Z was broken after removal of texture mode, now toggles lookdev mode. * Simplify code by turning it into a single operator. --- source/blender/editors/space_view3d/view3d_edit.c | 69 ++++++++++++++++++---- .../blender/editors/space_view3d/view3d_header.c | 39 +----------- .../blender/editors/space_view3d/view3d_intern.h | 3 +- source/blender/editors/space_view3d/view3d_ops.c | 19 +++--- 4 files changed, 65 insertions(+), 65 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 88edf32d154..cfc73367435 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4805,34 +4805,77 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Toggle Render Shading Operator +/** \name Toggle Shading Operator * \{ */ -static int toggle_render_exec(bContext *C, wmOperator *UNUSED(op)) +static const EnumPropertyItem prop_shading_type_items[] = { + {OB_SOLID, "SOLID", 0, "Solid and X-Ray", "Toggle solid and X-ray shading"}, + {OB_MATERIAL, "MATERIAL", 0, "LookDev", "Toggle lookdev shading"}, + {OB_RENDER, "RENDERED", 0, "Rendered", "Toggle rendered shading"}, + {0, NULL, 0, NULL, NULL} +}; + +static int toggle_shading_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); View3D *v3d = CTX_wm_view3d(C); - if (v3d->drawtype == OB_RENDER) { - v3d->drawtype = v3d->prev_drawtype; + ScrArea *sa = CTX_wm_area(C); + int type = RNA_enum_get(op->ptr, "type"); + + if (type == OB_SOLID) { + if (v3d->drawtype == OB_SOLID) { + /* Toggle X-Ray if already in solid mode. */ + if (ED_operator_posemode(C) || ED_operator_editmesh(C)) { + v3d->flag ^= V3D_ZBUF_SELECT; + } + else { + v3d->shading.flag ^= V3D_SHADING_XRAY; + } + } + else { + /* Go to solid mode. */ + v3d->drawtype = OB_SOLID; + } } - else { - v3d->prev_drawtype = v3d->drawtype; - v3d->drawtype = OB_RENDER; + else if (type == OB_MATERIAL) { + if (v3d->drawtype == OB_MATERIAL) { + v3d->drawtype = OB_SOLID; + } + else { + v3d->drawtype = OB_MATERIAL; + } + } + else if (type == OB_RENDER) { + if (v3d->drawtype == OB_RENDER) { + v3d->drawtype = v3d->prev_drawtype; + } + else { + v3d->prev_drawtype = v3d->drawtype; + v3d->drawtype = OB_RENDER; + } } - ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C)); + + ED_view3d_shade_update(bmain, v3d, sa); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + return OPERATOR_FINISHED; } -void VIEW3D_OT_toggle_render(wmOperatorType *ot) +void VIEW3D_OT_toggle_shading(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ - ot->name = "Toggle Rendered Shading"; - ot->description = "Toggle rendered shading mode of the viewport"; - ot->idname = "VIEW3D_OT_toggle_render"; + ot->name = "Toggle Shading Type"; + ot->description = "Toggle shading type in 3D viewport"; + ot->idname = "VIEW3D_OT_toggle_shading"; /* api callbacks */ - ot->exec = toggle_render_exec; + ot->exec = toggle_shading_exec; ot->poll = ED_operator_view3d_active; + + prop = RNA_def_enum(ot->srna, "type", prop_shading_type_items, 0, "Type", "Shading type to toggle"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index eeddacee808..a2dda8d6403 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -221,46 +221,10 @@ void VIEW3D_OT_layers(wmOperatorType *ot) RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer"); } -/* -------------------------------------------------------------------- */ -/** \name Toggle Bone selection Overlay Operator - * \{ */ - -static int toggle_show_xray(bContext *C, wmOperator *UNUSED(op)) -{ - View3D *v3d = CTX_wm_view3d(C); - v3d->shading.flag ^= V3D_SHADING_XRAY; - ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C)); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); - return OPERATOR_FINISHED; -} - -static bool toggle_show_xray_poll(bContext *C) -{ - bool result = (ED_operator_view3d_active(C) && !ED_operator_posemode(C) && !ED_operator_editmesh(C)); - if (result) { - // Additional test for SOLID or TEXTURE mode - View3D *v3d = CTX_wm_view3d(C); - result = (v3d->drawtype & (OB_SOLID | OB_TEXTURE)) > 0; - } - return result; -} - -void VIEW3D_OT_toggle_xray_draw_option(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Toggle Show X-Ray"; - ot->description = "Toggle show X-Ray"; - ot->idname = "VIEW3D_OT_toggle_xray_draw_option"; - - /* api callbacks */ - ot->exec = toggle_show_xray; - ot->poll = toggle_show_xray_poll; -} - /** \} */ /* -------------------------------------------------------------------- */ -/** \name Toggle Bone selection Overlay Operator +/** \name Toggle Matcap Flip Operator * \{ */ static int toggle_matcap_flip(bContext *C, wmOperator *UNUSED(op)) @@ -281,7 +245,6 @@ void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot) /* api callbacks */ ot->exec = toggle_matcap_flip; - // ot->poll = toggle_show_xray_poll; } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 9cc27a2854f..1b6e4213513 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -64,7 +64,6 @@ enum { /* view3d_header.c */ void VIEW3D_OT_layers(struct wmOperatorType *ot); -void VIEW3D_OT_toggle_xray_draw_option(struct wmOperatorType *ot); void VIEW3D_OT_toggle_matcap_flip(struct wmOperatorType *ot); /* view3d_ops.c */ @@ -104,7 +103,7 @@ void VIEW3D_OT_cursor3d(struct wmOperatorType *ot); void VIEW3D_OT_render_border(struct wmOperatorType *ot); void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot); void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); -void VIEW3D_OT_toggle_render(struct wmOperatorType *ot); +void VIEW3D_OT_toggle_shading(struct wmOperatorType *ot); void view3d_boxview_copy(ScrArea *sa, ARegion *ar); void view3d_boxview_sync(ScrArea *sa, ARegion *ar); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index b4fa092bede..2740b9a9042 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -222,8 +222,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active); - WM_operatortype_append(VIEW3D_OT_toggle_render); - WM_operatortype_append(VIEW3D_OT_toggle_xray_draw_option); + WM_operatortype_append(VIEW3D_OT_toggle_shading); WM_operatortype_append(VIEW3D_OT_toggle_matcap_flip); WM_operatortype_append(VIEW3D_OT_ruler_add); @@ -404,16 +403,12 @@ void view3d_keymap(wmKeyConfig *keyconf) #endif /* WITH_INPUT_NDOF */ /* drawtype */ - kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0); - RNA_string_set(kmi->ptr, "data_path", "space_data.shading.type"); - RNA_string_set(kmi->ptr, "value_1", "SOLID"); - RNA_string_set(kmi->ptr, "value_2", "TEXTURED"); - - WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_render", ZKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_xray_draw_option", ZKEY, KM_PRESS, 0, 0); - - kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ZKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "space_data.use_occlude_geometry"); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "type", OB_SOLID); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "type", OB_MATERIAL); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(kmi->ptr, "type", OB_RENDER); /* selection*/ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); -- cgit v1.2.3 From dbdafe1209a4787d6f8dcafa034bc9ced3c7f365 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 5 Jul 2018 12:44:15 +0200 Subject: Shaders: add target setting to material output node. This makes it possible to have a single shading nodetree that contains separate Cycles and Eevee shaders. By default the target is set to All so shaders are shared. --- intern/cycles/blender/addon/ui.py | 18 ++++---- intern/cycles/blender/blender_shader.cpp | 27 +----------- release/scripts/modules/bpy_extras/node_utils.py | 20 --------- .../scripts/startup/bl_ui/properties_material.py | 6 +-- release/scripts/startup/bl_ui/properties_world.py | 4 +- source/blender/blenkernel/BKE_node.h | 1 + source/blender/editors/space_node/drawnode.c | 10 +++++ source/blender/makesdna/DNA_node_types.h | 41 ++++-------------- source/blender/makesrna/intern/rna_nodetree.c | 23 ++++++++++ source/blender/nodes/shader/node_shader_tree.c | 50 ++++++++++++++++++---- 10 files changed, 98 insertions(+), 102 deletions(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index f8bc9ca8512..7a4ed4fbdaf 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -17,7 +17,7 @@ # import bpy -from bpy_extras.node_utils import find_node_input, find_output_node +from bpy_extras.node_utils import find_node_input from bl_operators.presets import PresetMenu from bpy.types import ( @@ -1069,14 +1069,14 @@ class CYCLES_OT_use_shading_nodes(Operator): return {'FINISHED'} -def panel_node_draw(layout, id_data, output_types, input_name): +def panel_node_draw(layout, id_data, output_type, input_name): if not id_data.use_nodes: layout.operator("cycles.use_shading_nodes", icon='NODETREE') return False ntree = id_data.node_tree - node = find_output_node(ntree, output_types) + node = ntree.get_output_node('CYCLES') if node: input = find_node_input(node, input_name) if input: @@ -1176,7 +1176,7 @@ class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel): layout = self.layout lamp = context.lamp - if not panel_node_draw(layout, lamp, ('OUTPUT_LAMP',), 'Surface'): + if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'): layout.prop(lamp, "color") @@ -1226,7 +1226,7 @@ class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel): world = context.world - if not panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Surface'): + if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'): layout.prop(world, "horizon_color", text="Color") @@ -1244,7 +1244,7 @@ class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel): layout = self.layout world = context.world - panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Volume') + panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume') class CYCLES_WORLD_PT_ambient_occlusion(CyclesButtonsPanel, Panel): @@ -1425,7 +1425,7 @@ class CYCLES_MATERIAL_PT_surface(CyclesButtonsPanel, Panel): layout = self.layout mat = context.material - if not panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Surface'): + if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'): layout.prop(mat, "diffuse_color") @@ -1445,7 +1445,7 @@ class CYCLES_MATERIAL_PT_volume(CyclesButtonsPanel, Panel): mat = context.material # cmat = mat.cycles - panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Volume') + panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume') class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel): @@ -1461,7 +1461,7 @@ class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel): layout = self.layout mat = context.material - panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Displacement') + panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement') class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel): diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 66034919145..ed92cb71f04 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -1001,31 +1001,6 @@ static ShaderOutput *node_find_output_by_name(ShaderNode *node, return node->output(name.c_str()); } -static BL::ShaderNode find_output_node(BL::ShaderNodeTree& b_ntree) -{ - BL::ShaderNodeTree::nodes_iterator b_node; - BL::ShaderNode output_node(PointerRNA_NULL); - - for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) { - BL::ShaderNodeOutputMaterial b_output_node(*b_node); - - if (b_output_node.is_a(&RNA_ShaderNodeOutputMaterial) || - b_output_node.is_a(&RNA_ShaderNodeOutputWorld) || - b_output_node.is_a(&RNA_ShaderNodeOutputLamp)) { - /* regular Cycles output node */ - if(b_output_node.is_active_output()) { - output_node = b_output_node; - break; - } - else if(!output_node.ptr.data) { - output_node = b_output_node; - } - } - } - - return output_node; -} - static void add_nodes(Scene *scene, BL::RenderEngine& b_engine, BL::BlendData& b_data, @@ -1045,7 +1020,7 @@ static void add_nodes(Scene *scene, BL::Node::outputs_iterator b_output; /* find the node to use for output if there are multiple */ - BL::ShaderNode output_node = find_output_node(b_ntree); + BL::ShaderNode output_node = b_ntree.get_output_node(BL::ShaderNodeOutputMaterial::target_CYCLES); /* add nodes */ for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) { diff --git a/release/scripts/modules/bpy_extras/node_utils.py b/release/scripts/modules/bpy_extras/node_utils.py index d459b99ddd0..d4c6d5cd45a 100644 --- a/release/scripts/modules/bpy_extras/node_utils.py +++ b/release/scripts/modules/bpy_extras/node_utils.py @@ -20,7 +20,6 @@ __all__ = ( "find_node_input", - "find_output_node", ) @@ -31,22 +30,3 @@ def find_node_input(node, name): return input return None - -# Return the output node to display in the UI. In case multiple node types are -# specified, node types earlier in the list get priority. - - -def find_output_node(ntree, nodetypes): - if ntree: - output_node = None - for nodetype in nodetypes: - for node in ntree.nodes: - if getattr(node, "type", None) == nodetype: - if getattr(node, "is_active_output", True): - return node - if not output_node: - output_node = node - if output_node: - return output_node - - return None diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index fdbf0b240c4..3761cbba372 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -21,7 +21,7 @@ import bpy from bpy.types import Menu, Panel, UIList from rna_prop_ui import PropertyPanel from bpy.app.translations import pgettext_iface as iface_ -from bpy_extras.node_utils import find_node_input, find_output_node +from bpy_extras.node_utils import find_node_input class MATERIAL_MT_specials(Menu): @@ -140,7 +140,7 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): def panel_node_draw(layout, ntree, output_type): - node = find_output_node(ntree, output_type) + node = ntree.get_output_node('EEVEE') if node: input = find_node_input(node, 'Surface') @@ -171,7 +171,7 @@ class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel): layout.separator() if mat.use_nodes: - panel_node_draw(layout, mat.node_tree, ('OUTPUT_EEVEE_MATERIAL', 'OUTPUT_MATERIAL')) + panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL') else: layout.use_property_split = True layout.prop(mat, "diffuse_color", text="Base Color") diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py index bba7f9e132a..52a769fd223 100644 --- a/release/scripts/startup/bl_ui/properties_world.py +++ b/release/scripts/startup/bl_ui/properties_world.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Panel from rna_prop_ui import PropertyPanel -from bpy_extras.node_utils import find_node_input, find_output_node +from bpy_extras.node_utils import find_node_input class WorldButtonsPanel: @@ -109,7 +109,7 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel): if world.use_nodes: ntree = world.node_tree - node = find_output_node(ntree, ('OUTPUT_WORLD',)) + node = ntree.get_output_node('EEVEE') if node: input = find_node_input(node, 'Surface') diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index a400337e2cf..9eb026b1c4f 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -812,6 +812,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, c struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree); void ntreeShaderEndExecTree(struct bNodeTreeExec *exec); bool ntreeShaderExecTree(struct bNodeTree *ntree, int thread); +struct bNode *ntreeShaderOutputNode(struct bNodeTree *ntree, int target); void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat, bool *has_surface_output, bool *has_volume_output); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index da49a772688..d7015ed5e53 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1066,6 +1066,11 @@ static void node_shader_buts_script_ex(uiLayout *layout, bContext *C, PointerRNA #endif } +static void node_buts_output_shader(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "target", 0, "", ICON_NONE); +} + static void node_buts_output_linestyle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row, *col; @@ -1209,6 +1214,11 @@ static void node_shader_set_butfunc(bNodeType *ntype) case SH_NODE_UVALONGSTROKE: ntype->draw_buttons = node_shader_buts_uvalongstroke; break; + case SH_NODE_OUTPUT_MATERIAL: + case SH_NODE_OUTPUT_LAMP: + case SH_NODE_OUTPUT_WORLD: + ntype->draw_buttons = node_buts_output_shader; + break; case SH_NODE_OUTPUT_LINESTYLE: ntype->draw_buttons = node_buts_output_linestyle; break; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index f38ae61421b..90c9d81e996 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -1101,39 +1101,6 @@ enum { #define CMP_NODE_MASK_MBLUR_SAMPLES_MAX 64 -/* geometry output socket defines */ -#define GEOM_OUT_GLOB 0 -#define GEOM_OUT_LOCAL 1 -#define GEOM_OUT_VIEW 2 -#define GEOM_OUT_ORCO 3 -#define GEOM_OUT_UV 4 -#define GEOM_OUT_NORMAL 5 -#define GEOM_OUT_VCOL 6 -#define GEOM_OUT_VCOL_ALPHA 7 -#define GEOM_OUT_FRONTBACK 8 - -/* material input socket defines */ -#define MAT_IN_COLOR 0 -#define MAT_IN_SPEC 1 -#define MAT_IN_REFL 2 -#define MAT_IN_NORMAL 3 -#define MAT_IN_MIR 4 -#define MAT_IN_AMB 5 -#define MAT_IN_EMIT 6 -#define MAT_IN_SPECTRA 7 -#define MAT_IN_RAY_MIRROR 8 -#define MAT_IN_ALPHA 9 -#define MAT_IN_TRANSLUCENCY 10 -#define NUM_MAT_IN 11 /* for array size */ - -/* material output socket defines */ -#define MAT_OUT_COLOR 0 -#define MAT_OUT_ALPHA 1 -#define MAT_OUT_NORMAL 2 -#define MAT_OUT_DIFFUSE 3 -#define MAT_OUT_SPEC 4 -#define MAT_OUT_AO 5 - /* image */ #define CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT 1 @@ -1176,4 +1143,12 @@ enum { SHD_POINTDENSITY_COLOR_VERTNOR = 2, }; +/* Output shader node */ + +typedef enum NodeShaderOutputTarget { + SHD_OUTPUT_ALL = 0, + SHD_OUTPUT_EEVEE = 1, + SHD_OUTPUT_CYCLES = 2, +} NodeShaderOutputTarget; + #endif diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 492335d4d25..9e800d3b875 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -175,6 +175,14 @@ static const EnumPropertyItem node_sampler_type_items[] = { {2, "BICUBIC", 0, "Bicubic", ""}, {0, NULL, 0, NULL, NULL} }; + + +static const EnumPropertyItem prop_shader_output_target_items[] = { + {SHD_OUTPUT_ALL, "ALL", 0, "All", "Use shaders for all renderers and viewports, unless there exists a more specific output"}, + {SHD_OUTPUT_EEVEE, "EEVEE", 0, "Eevee", "Use shaders for Eevee renderer"}, + {SHD_OUTPUT_CYCLES, "CYCLES", 0, "Cycles", "Use shaders for Cycles renderer"}, + {0, NULL, 0, NULL, NULL} +}; #endif #ifdef RNA_RUNTIME @@ -3536,6 +3544,12 @@ static void def_sh_output(StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_DO_OUTPUT); RNA_def_property_ui_text(prop, "Active Output", "True if this node is used as the active output"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "target", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, prop_shader_output_target_items); + RNA_def_property_ui_text(prop, "Target", "Which renderer and viewport shading types to use the shaders for"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_sh_output_linestyle(StructRNA *srna) @@ -8377,12 +8391,21 @@ static void rna_def_composite_nodetree(BlenderRNA *brna) static void rna_def_shader_nodetree(BlenderRNA *brna) { StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; srna = RNA_def_struct(brna, "ShaderNodeTree", "NodeTree"); RNA_def_struct_ui_text(srna, "Shader Node Tree", "Node tree consisting of linked nodes used for materials (and other shading data-blocks)"); RNA_def_struct_sdna(srna, "bNodeTree"); RNA_def_struct_ui_icon(srna, ICON_MATERIAL); + + func = RNA_def_function(srna, "get_output_node", "ntreeShaderOutputNode"); + RNA_def_function_ui_description(func, "Return active shader output node for the specified target"); + parm = RNA_def_enum(func, "target", prop_shader_output_target_items, SHD_OUTPUT_ALL, "Target", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "node", "ShaderNode", "Node", ""); + RNA_def_function_return(func, parm); } static void rna_def_texture_nodetree(BlenderRNA *brna) diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 329e850d19e..8db88f13ea6 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -209,20 +209,52 @@ static void ntree_shader_link_builtin_normal(bNodeTree *ntree, * render engines works but it's how the GPU shader compilation works. This we * can change in the future and make it a generic function, but for now it stays * private here. - * - * It also does not yet take into account render engine specific output nodes, - * it should give priority to e.g. the Eevee material output node for Eevee. */ -static bNode *ntree_shader_output_node(bNodeTree *ntree) +bNode *ntreeShaderOutputNode(bNodeTree *ntree, int target) { /* Make sure we only have single node tagged as output. */ ntreeSetOutput(ntree); - for (bNode *node = ntree->nodes.first; node != NULL; node = node->next) { - if (node->flag & NODE_DO_OUTPUT) { - return node; + + /* Find output node that matches type and target. If there are + * multiple, we prefer exact target match and active nodes. */ + bNode *output_node = NULL; + + for (bNode *node = ntree->nodes.first; node; node = node->next) { + if (!ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, + SH_NODE_OUTPUT_WORLD, + SH_NODE_OUTPUT_LAMP)) + { + continue; + } + + if (node->custom1 == SHD_OUTPUT_ALL) { + if (output_node == NULL) { + output_node = node; + } + else if (output_node->custom1 == SHD_OUTPUT_ALL) { + if ((node->flag & NODE_DO_OUTPUT) && + !(output_node->flag & NODE_DO_OUTPUT)) + { + output_node = node; + } + } + } + else if (node->custom1 == target) { + if (output_node == NULL) { + output_node = node; + } + else if(output_node->custom1 == SHD_OUTPUT_ALL) { + output_node = node; + } + else if ((node->flag & NODE_DO_OUTPUT) && + !(output_node->flag & NODE_DO_OUTPUT)) + { + output_node = node; + } } } - return NULL; + + return output_node; } /* Find socket with a specified identifier. */ @@ -555,7 +587,7 @@ void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, bool *has_surface { /* localize tree to create links for reroute and mute */ bNodeTree *localtree = ntreeLocalize(ntree); - bNode *output = ntree_shader_output_node(localtree); + bNode *output = ntreeShaderOutputNode(localtree, SHD_OUTPUT_EEVEE); bNodeTreeExec *exec; /* Perform all needed modifications on the tree in order to support -- cgit v1.2.3 From a883f0fd54df89c18ac32e2a1f2d04c56081b8a6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 5 Jul 2018 19:19:43 +0200 Subject: UI: add separators in properties editor header tabs. --- source/blender/editors/interface/interface_layout.c | 5 ++++- source/blender/editors/space_buttons/buttons_context.c | 4 ++-- source/blender/makesrna/intern/rna_space.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 9b9199538d6..358131fcb87 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -680,10 +680,13 @@ static void ui_item_enum_expand( } for (item = item_array; item->identifier; item++) { - if (!item->identifier[0]) { + if (!item->identifier[0] && (item+1)->identifier) { if (radial && layout_radial) { uiItemS(layout_radial); } + else { + uiItemS(block->curlayout); + } continue; } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 4ad62ec705d..19a55c2e3cd 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -1009,10 +1009,10 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); if (name) { - if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER) && ptr->type == &RNA_Scene)) { + if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD) && ptr->type == &RNA_Scene)) { uiItemLDrag(row, ptr, "", icon); /* save some space */ } - else if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER) && ptr->type == &RNA_ViewLayer)) { + else if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD) && ptr->type == &RNA_ViewLayer)) { uiItemLDrag(row, ptr, "", icon); /* save some space */ } else { diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 249f6b29143..df7cc228fc4 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1241,6 +1241,14 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf( RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_TOOL); } + if (sbuts->pathflag & (1 << BCONTEXT_WORKSPACE)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORKSPACE); + } + + if (totitem) { + RNA_enum_item_add_separator(&item, &totitem); + } + if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_RENDER); } @@ -1257,8 +1265,8 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf( RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD); } - if (sbuts->pathflag & (1 << BCONTEXT_WORKSPACE)) { - RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORKSPACE); + if (totitem) { + RNA_enum_item_add_separator(&item, &totitem); } if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) { -- cgit v1.2.3 From f2de8a190fea052a33a2fbcc61d56e8ebe5a9017 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 19:27:57 +0200 Subject: 3D View: support setting the relative axis This sets the closest view axis, as if the current view is 'front'. Useful to switch to the nearest left/right/top/bottom. --- source/blender/editors/space_view3d/view3d_edit.c | 100 ++++++++++++++++------ 1 file changed, 74 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index cfc73367435..20241b93471 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3618,10 +3618,14 @@ static const EnumPropertyItem prop_view_items[] = { /* would like to make this a generic function - outside of transform */ +/** + * \param align_to_quat: When not NULL, set the axis relative to this rotation. + */ static void axis_set_view( bContext *C, View3D *v3d, ARegion *ar, const float quat_[4], - short view, int perspo, bool align_active, + short view, int perspo, + const float *align_to_quat, const int smooth_viewtx) { RegionView3D *rv3d = ar->regiondata; /* no NULL check is needed, poll checks */ @@ -3631,29 +3635,12 @@ static void axis_set_view( normalize_qt_qt(quat, quat_); - if (align_active) { - /* align to active object */ - Object *obact = CTX_data_active_object(C); - if (obact == NULL) { - /* no active object, ignore this option */ - align_active = false; - } - else { - float obact_quat[4]; - float twmat[3][3]; - - /* same as transform manipulator when normal is set */ - ED_getTransformOrientationMatrix(C, twmat, V3D_AROUND_ACTIVE); - - mat3_to_quat(obact_quat, twmat); - invert_qt_normalized(obact_quat); - mul_qt_qtqt(quat, quat, obact_quat); - - rv3d->view = view = RV3D_VIEW_USER; - } + if (align_to_quat) { + mul_qt_qtqt(quat, quat, align_to_quat); + rv3d->view = view = RV3D_VIEW_USER; } - if (align_active == false) { + if (align_to_quat == NULL) { rv3d->view = view; } @@ -3716,7 +3703,6 @@ static int view_axis_exec(bContext *C, wmOperator *op) RegionView3D *rv3d; static int perspo = RV3D_PERSP; int viewnum; - bool align_active; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); /* no NULL check is needed, poll checks */ @@ -3726,13 +3712,73 @@ static int view_axis_exec(bContext *C, wmOperator *op) ED_view3d_smooth_view_force_finish(C, v3d, ar); viewnum = RNA_enum_get(op->ptr, "type"); - align_active = RNA_boolean_get(op->ptr, "align_active"); + + float align_quat_buf[4]; + float *align_quat = NULL; + + if (RNA_boolean_get(op->ptr, "align_active")) { + /* align to active object */ + Object *obact = CTX_data_active_object(C); + if (obact != NULL) { + float twmat[3][3]; + /* same as transform manipulator when normal is set */ + ED_getTransformOrientationMatrix(C, twmat, V3D_AROUND_ACTIVE); + align_quat = align_quat_buf; + mat3_to_quat(align_quat, twmat); + invert_qt_normalized(align_quat); + } + } + + if (RNA_boolean_get(op->ptr, "relative")) { + float angle_max = FLT_MAX; + int view_closest = -1; + float z_rel[3] = {0.0f, 0.0f, 1.0f}; + + if (viewnum == RV3D_VIEW_TOP) { + negate_v3_v3(z_rel, rv3d->viewinv[1]); + } + else if (viewnum == RV3D_VIEW_BOTTOM) { + copy_v3_v3(z_rel, rv3d->viewinv[1]); + } + else if (viewnum == RV3D_VIEW_RIGHT) { + negate_v3_v3(z_rel, rv3d->viewinv[0]); + } + else if (viewnum == RV3D_VIEW_LEFT) { + copy_v3_v3(z_rel, rv3d->viewinv[0]); + } + else if (viewnum == RV3D_VIEW_FRONT) { + negate_v3_v3(z_rel, rv3d->viewinv[2]); + } + else if (viewnum == RV3D_VIEW_BACK) { + copy_v3_v3(z_rel, rv3d->viewinv[2]); + } + + for (int i = RV3D_VIEW_FRONT; i <= RV3D_VIEW_BOTTOM; i++) { + float quat[4]; + float mat[3][3]; + ED_view3d_quat_from_axis_view(i, quat); + quat[0] *= -1.0f; + quat_to_mat3(mat, quat); + if (align_quat) { + mul_qt_qtqt(quat, quat, align_quat); + } + const float angle_test = angle_normalized_v3v3(z_rel, mat[2]); + if (angle_max > angle_test) { + angle_max = angle_test; + view_closest = i; + } + } + if (view_closest == -1) { + view_closest = RV3D_VIEW_FRONT; + } + viewnum = view_closest; + } /* Use this to test if we started out with a camera */ const int nextperspo = (rv3d->persp == RV3D_CAMOB) ? rv3d->lpersp : perspo; float quat[4]; ED_view3d_quat_from_axis_view(viewnum, quat); - axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_active, smooth_viewtx); + axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_quat, smooth_viewtx); perspo = rv3d->persp; @@ -3760,6 +3806,8 @@ void VIEW3D_OT_view_axis(wmOperatorType *ot) RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "align_active", 0, "Align Active", "Align to the active object's axis"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "relative", 0, "Relative", "Rotate relative to the current orientation"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ @@ -3844,7 +3892,7 @@ static int view_camera_exec(bContext *C, wmOperator *op) else { /* return to settings of last view */ /* does view3d_smooth_view too */ - axis_set_view(C, v3d, ar, rv3d->lviewquat, rv3d->lview, rv3d->lpersp, 0, smooth_viewtx); + axis_set_view(C, v3d, ar, rv3d->lviewquat, rv3d->lview, rv3d->lpersp, NULL, smooth_viewtx); } } -- cgit v1.2.3 From 1bf5cc57bd15cfaf8c26b50a91a8c5fbab26cb68 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 19:29:56 +0200 Subject: Keymap: convenience Alt-MMB view switching Allows to quickly set the view axis for advanced users, Requested by @hjalti --- source/blender/editors/space_view3d/view3d_ops.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 2740b9a9042..4d5e6661bd0 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -371,6 +371,19 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM); RNA_boolean_set(kmi->ptr, "align_active", true); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", EVT_TWEAK_M, EVT_GESTURE_N, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP); + RNA_boolean_set(kmi->ptr, "relative", true); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", EVT_TWEAK_M, EVT_GESTURE_S, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM); + RNA_boolean_set(kmi->ptr, "relative", true); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", EVT_TWEAK_M, EVT_GESTURE_E, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT); + RNA_boolean_set(kmi->ptr, "relative", true); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_axis", EVT_TWEAK_M, EVT_GESTURE_W, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT); + RNA_boolean_set(kmi->ptr, "relative", true); + #ifdef WITH_INPUT_NDOF /* note: positioned here so keymaps show keyboard keys if assigned */ /* 3D mouse */ -- cgit v1.2.3 From 7112e96e0f8854491417d6556b9308a432c9ef32 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 19:41:38 +0200 Subject: Cleanup: minor changes to last commit --- source/blender/editors/space_view3d/view3d_edit.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 20241b93471..f49d098d1f0 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3730,11 +3730,15 @@ static int view_axis_exec(bContext *C, wmOperator *op) } if (RNA_boolean_get(op->ptr, "relative")) { - float angle_max = FLT_MAX; - int view_closest = -1; - float z_rel[3] = {0.0f, 0.0f, 1.0f}; + float z_rel[3]; - if (viewnum == RV3D_VIEW_TOP) { + if (viewnum == RV3D_VIEW_RIGHT) { + negate_v3_v3(z_rel, rv3d->viewinv[0]); + } + else if (viewnum == RV3D_VIEW_LEFT) { + copy_v3_v3(z_rel, rv3d->viewinv[0]); + } + else if (viewnum == RV3D_VIEW_TOP) { negate_v3_v3(z_rel, rv3d->viewinv[1]); } else if (viewnum == RV3D_VIEW_BOTTOM) { @@ -3752,7 +3756,12 @@ static int view_axis_exec(bContext *C, wmOperator *op) else if (viewnum == RV3D_VIEW_BACK) { copy_v3_v3(z_rel, rv3d->viewinv[2]); } + else { + BLI_assert(0); + } + float angle_max = FLT_MAX; + int view_closest = -1; for (int i = RV3D_VIEW_FRONT; i <= RV3D_VIEW_BOTTOM; i++) { float quat[4]; float mat[3][3]; -- cgit v1.2.3 From e5ca319f9db4de752fe7628807d7a1edad2389c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 19:49:05 +0200 Subject: Cleanup: minor changes to last commit, #2 --- source/blender/editors/space_view3d/view3d_edit.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index f49d098d1f0..0078988e1b0 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3744,12 +3744,6 @@ static int view_axis_exec(bContext *C, wmOperator *op) else if (viewnum == RV3D_VIEW_BOTTOM) { copy_v3_v3(z_rel, rv3d->viewinv[1]); } - else if (viewnum == RV3D_VIEW_RIGHT) { - negate_v3_v3(z_rel, rv3d->viewinv[0]); - } - else if (viewnum == RV3D_VIEW_LEFT) { - copy_v3_v3(z_rel, rv3d->viewinv[0]); - } else if (viewnum == RV3D_VIEW_FRONT) { negate_v3_v3(z_rel, rv3d->viewinv[2]); } -- cgit v1.2.3 From 72e04f98909c0970c82c3e708b0c651553487693 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 20:27:04 +0200 Subject: Draw Manager: simplify object mask usage Remove flag defines, use object types directly. --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/draw/modes/object_mode.c | 93 +++++++++++---------------- source/blender/makesdna/DNA_view3d_types.h | 14 +--- source/blender/makesrna/intern/rna_space.c | 7 +- 4 files changed, 43 insertions(+), 73 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 4614a4bd84a..3c367236cb1 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3833,7 +3833,7 @@ class VIEW3D_PT_overlay(Panel): sub.prop(overlay, "show_all_objects_origin") sub = split.column() - sub.prop(overlay, "show_non_renderable_objects") + sub.prop(overlay, "show_non_geometry") sub.prop(overlay, "show_relationship_lines") sub.prop(overlay, "show_motion_paths") #sub.prop(overlay, "show_onion_skins") diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 0a45dd7f123..1e77631fbf0 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2127,6 +2127,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) return; } + if (v3d->overlay.object_type_exclude & (1 << ob->type)) { + return; + } + bool do_outlines = (draw_ctx->v3d->flag & V3D_SELECT_OUTLINE) && ((ob->base_flag & BASE_SELECTED) != 0); bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0); @@ -2185,31 +2189,26 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; case OB_LATTICE: { - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_OTHER) == 0) { - if (ob != draw_ctx->object_edit) { - struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false); - if (theme_id == TH_UNDEFINED) { - theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); - } - - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); - DRW_shgroup_call_object_add(shgroup, geom, ob); + if (ob != draw_ctx->object_edit) { + struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false); + if (theme_id == TH_UNDEFINED) { + theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } + + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); + DRW_shgroup_call_object_add(shgroup, geom, ob); } break; } - case OB_CURVE: { - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_OTHER) == 0) { - if (ob != draw_ctx->object_edit) { - struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob); - if (theme_id == TH_UNDEFINED) { - theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); - } - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); - DRW_shgroup_call_object_add(shgroup, geom, ob); + if (ob != draw_ctx->object_edit) { + struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob); + if (theme_id == TH_UNDEFINED) { + theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire); + DRW_shgroup_call_object_add(shgroup, geom, ob); } break; } @@ -2221,52 +2220,34 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; } case OB_LAMP: - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_LAMP) == 0) - { - DRW_shgroup_lamp(stl, ob, view_layer); - } + DRW_shgroup_lamp(stl, ob, view_layer); break; case OB_CAMERA: - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_CAMERA) == 0) - { - DRW_shgroup_camera(stl, ob, view_layer); - } + DRW_shgroup_camera(stl, ob, view_layer); break; case OB_EMPTY: - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_EMPTY) == 0) - { - DRW_shgroup_empty(stl, psl, ob, view_layer); - } + DRW_shgroup_empty(stl, psl, ob, view_layer); break; case OB_SPEAKER: - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_SPEAKER) == 0) - { - DRW_shgroup_speaker(stl, ob, view_layer); - } + DRW_shgroup_speaker(stl, ob, view_layer); break; case OB_LIGHTPROBE: - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_LIGHTPROBE) == 0) - { - DRW_shgroup_lightprobe(stl, psl, ob, view_layer); - } + DRW_shgroup_lightprobe(stl, psl, ob, view_layer); break; case OB_ARMATURE: { - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_ARMATURE) == 0) - { - bArmature *arm = ob->data; - if (arm->edbo == NULL) { - if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { - DRWArmaturePasses passes = { - .bone_solid = psl->bone_solid, - .bone_outline = psl->bone_outline, - .bone_wire = psl->bone_wire, - .bone_envelope = psl->bone_envelope, - .bone_axes = psl->bone_axes, - .relationship_lines = NULL, /* Don't draw relationship lines */ - }; - DRW_shgroup_armature_object(ob, view_layer, passes); - } + bArmature *arm = ob->data; + if (arm->edbo == NULL) { + if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { + DRWArmaturePasses passes = { + .bone_solid = psl->bone_solid, + .bone_outline = psl->bone_outline, + .bone_wire = psl->bone_wire, + .bone_envelope = psl->bone_envelope, + .bone_axes = psl->bone_axes, + .relationship_lines = NULL, /* Don't draw relationship lines */ + }; + DRW_shgroup_armature_object(ob, view_layer, passes); } } break; @@ -2275,10 +2256,8 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; } - if ((v3d->overlay.hidden_object_types & V3D_OVERLAY_HIDE_OTHER) == 0) { - if (ob->pd && ob->pd->forcefield) { - DRW_shgroup_forcefield(stl, ob, view_layer); - } + if (ob->pd && ob->pd->forcefield) { + DRW_shgroup_forcefield(stl, ob, view_layer); } /* don't show object extras in set's */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index c1244e9a0c7..5668cf24fe6 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -179,7 +179,7 @@ typedef struct View3DOverlay { /* Other settings */ float wireframe_threshold; - int hidden_object_types; + int object_type_exclude; } View3DOverlay; @@ -384,18 +384,6 @@ enum { V3D_OVERLAY_ONION_SKINS = (1 << 7), }; -/* View3DOverlay->hidden_object_types */ -enum { - V3D_OVERLAY_HIDE_EMPTY = (1 << OB_EMPTY), - V3D_OVERLAY_HIDE_LAMP = (1 << OB_LAMP), - V3D_OVERLAY_HIDE_CAMERA = (1 << OB_CAMERA), - V3D_OVERLAY_HIDE_SPEAKER = (1 << OB_SPEAKER), - V3D_OVERLAY_HIDE_LIGHTPROBE = (1 << OB_LIGHTPROBE), - V3D_OVERLAY_HIDE_ARMATURE = (1 << OB_ARMATURE), - V3D_OVERLAY_HIDE_OTHER = (1 << 14), -}; -#define V3D_OVERLAY_HIDE_NON_RENDERABLE (V3D_OVERLAY_HIDE_EMPTY | V3D_OVERLAY_HIDE_LAMP | V3D_OVERLAY_HIDE_CAMERA | V3D_OVERLAY_HIDE_SPEAKER | V3D_OVERLAY_HIDE_LIGHTPROBE | V3D_OVERLAY_HIDE_ARMATURE | V3D_OVERLAY_HIDE_OTHER) - /* View3DOverlay->edit_flag */ enum { V3D_OVERLAY_EDIT_VERT_NORMALS = (1 << 0), diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index df7cc228fc4..239203bd384 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2616,8 +2616,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_non_renderable_objects", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.hidden_object_types", V3D_OVERLAY_HIDE_NON_RENDERABLE); + prop = RNA_def_property(srna, "show_non_geometry", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna( + prop, NULL, "overlay.object_type_exclude", + ((1 << OB_TYPE_MAX) - 1) & + ~((1 << OB_MESH) | (1 << OB_CURVE) | (1 << OB_SURF) | (1 << OB_FONT) | (1 << OB_MBALL))); RNA_def_property_boolean_default(prop, true); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Show Non Renderable", "Draw not renderable objects in the overlay"); -- cgit v1.2.3 From a3f5d4cb147d7f1186e9614c1f253efcd7b562ec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 21:28:25 +0200 Subject: Keymap: Make Ctrl-Tab toggles pose mode Showing a pie menu is redundant since tab is already mapped to edit mode. Bypass the menu for pose mode toggle. --- source/blender/editors/object/object_ops.c | 6 ++++- .../blender/editors/space_view3d/view3d_buttons.c | 26 ++++++++++++++++++++++ .../blender/editors/space_view3d/view3d_intern.h | 1 + source/blender/editors/space_view3d/view3d_ops.c | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index cae8005c86c..43d993531bc 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -297,7 +297,11 @@ void ED_keymap_object(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT); RNA_boolean_set(kmi->ptr, "toggle", true); - kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_object_mode_pie", TABKEY, KM_PRESS, KM_CTRL, 0); +#if 0 + WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_object_mode_pie", TABKEY, KM_PRESS, KM_CTRL, 0); +#else + WM_keymap_add_item(keymap, "VIEW3D_OT_object_mode_pie_or_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); +#endif #ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index f5e8bf10817..bcf9a7c4ad1 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1222,3 +1222,29 @@ void VIEW3D_OT_properties(wmOperatorType *ot) /* flags */ ot->flag = 0; } + +static int view3d_object_mode_menu(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob = CTX_data_active_object(C); + if (ob->type == OB_ARMATURE) { + ED_object_mode_toggle(C, OB_MODE_POSE); + return OPERATOR_CANCELLED; + } + else { + UI_pie_menu_invoke(C, "VIEW3D_MT_object_mode_pie", CTX_wm_window(C)->eventstate); + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_object_mode_pie_or_toggle(wmOperatorType *ot) +{ + ot->name = "Object Mode Menu"; + ot->description = ""; + ot->idname = "VIEW3D_OT_object_mode_pie_or_toggle"; + + ot->exec = view3d_object_mode_menu; + ot->poll = ED_operator_view3d_active; + + /* flags */ + ot->flag = 0; +} diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 1b6e4213513..b74a40969a1 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -216,6 +216,7 @@ void viewdolly_modal_keymap(struct wmKeyConfig *keyconf); /* view3d_buttons.c */ void VIEW3D_OT_properties(struct wmOperatorType *ot); +void VIEW3D_OT_object_mode_pie_or_toggle(struct wmOperatorType *ot); void view3d_buttons_register(struct ARegionType *art); /* view3d_camera_control.c */ diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 4d5e6661bd0..00f0dea8fe2 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -212,6 +212,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_pastebuffer); WM_operatortype_append(VIEW3D_OT_properties); + WM_operatortype_append(VIEW3D_OT_object_mode_pie_or_toggle); WM_operatortype_append(VIEW3D_OT_toolshelf); WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid); -- cgit v1.2.3 From 45fdf41be87fb0b2fbf85778a714537ed1f5eca3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 21:48:46 +0200 Subject: RNA: use is_dirty prefix for checking updates Common convention for read-only update checks --- source/blender/makesrna/intern/rna_depsgraph.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index eb069b5e069..f1ff038ddd7 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -143,27 +143,27 @@ static PointerRNA rna_DepsgraphUpdate_id_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_ID, ptr->data); } -static int rna_DepsgraphUpdate_updated_transform_get(PointerRNA *ptr) +static int rna_DepsgraphUpdate_is_dirty_transform_get(PointerRNA *ptr) { ID *id = ptr->data; - return ((id->recalc & ID_RECALC_TRANSFORM) != 0); + return ((id->recalc & ID_RECALC_TRANSFORM) == 0); } -static int rna_DepsgraphUpdate_updated_geometry_get(PointerRNA *ptr) +static int rna_DepsgraphUpdate_is_dirty_geometry_get(PointerRNA *ptr) { ID *id = ptr->data; if (id->recalc & ID_RECALC_GEOMETRY) { - return true; + return false; } if (GS(id->name) != ID_OB) { - return false; + return true; } Object *object = (Object *)id; ID *data = object->data; if (data == NULL) { - return 0; + return true; } - return ((data->recalc & ID_RECALC_ALL) != 0); + return ((data->recalc & ID_RECALC_ALL) == 0); } /* **************** Depsgraph **************** */ @@ -454,15 +454,15 @@ static void rna_def_depsgraph_update(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, "rna_DepsgraphUpdate_id_get", NULL, NULL, NULL); - prop = RNA_def_property(srna, "updated_transform", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "is_dirty_transform", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Transform", "Object transformation was updated"); - RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_updated_transform_get", NULL); + RNA_def_property_ui_text(prop, "Transform", "Object transformation is not updated"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_dirty_transform_get", NULL); - prop = RNA_def_property(srna, "updated_geometry", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "is_dirty_geometry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Geometry", "Object geometry was updated"); - RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_updated_geometry_get", NULL); + RNA_def_property_ui_text(prop, "Geometry", "Object geometry is not updated"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_dirty_geometry_get", NULL); } static void rna_def_depsgraph(BlenderRNA *brna) -- cgit v1.2.3 From 0e2915b2929aa312a03bc4d3a606bb8073fcead0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 22:25:34 +0200 Subject: RNA: correct callback type Missed when changing callbacks from int to bool type. --- source/blender/makesrna/intern/rna_ID.c | 6 +-- source/blender/makesrna/intern/rna_actuator.c | 10 ++--- source/blender/makesrna/intern/rna_animation.c | 2 +- source/blender/makesrna/intern/rna_armature.c | 4 +- source/blender/makesrna/intern/rna_brush.c | 54 +++++++++++------------ source/blender/makesrna/intern/rna_color.c | 4 +- source/blender/makesrna/intern/rna_controller.c | 2 +- source/blender/makesrna/intern/rna_curve.c | 2 +- source/blender/makesrna/intern/rna_dynamicpaint.c | 4 +- source/blender/makesrna/intern/rna_fcurve.c | 2 +- source/blender/makesrna/intern/rna_gpencil.c | 12 ++--- source/blender/makesrna/intern/rna_image.c | 10 ++--- source/blender/makesrna/intern/rna_internal.h | 4 +- source/blender/makesrna/intern/rna_lamp.c | 4 +- source/blender/makesrna/intern/rna_lattice.c | 4 +- source/blender/makesrna/intern/rna_main.c | 8 ++-- source/blender/makesrna/intern/rna_material.c | 8 ++-- source/blender/makesrna/intern/rna_mesh.c | 44 +++++++++--------- source/blender/makesrna/intern/rna_meta.c | 2 +- source/blender/makesrna/intern/rna_modifier.c | 10 ++--- source/blender/makesrna/intern/rna_nla.c | 8 ++-- source/blender/makesrna/intern/rna_nodetree.c | 12 ++--- source/blender/makesrna/intern/rna_object.c | 2 +- source/blender/makesrna/intern/rna_object_force.c | 24 +++++----- source/blender/makesrna/intern/rna_particle.c | 8 ++-- source/blender/makesrna/intern/rna_pose.c | 4 +- source/blender/makesrna/intern/rna_rigidbody.c | 20 ++++----- source/blender/makesrna/intern/rna_rna.c | 36 +++++++-------- source/blender/makesrna/intern/rna_scene.c | 26 +++++------ source/blender/makesrna/intern/rna_screen.c | 4 +- source/blender/makesrna/intern/rna_sculpt_paint.c | 4 +- source/blender/makesrna/intern/rna_sensor.c | 4 +- source/blender/makesrna/intern/rna_sequencer.c | 8 ++-- source/blender/makesrna/intern/rna_smoke.c | 2 +- source/blender/makesrna/intern/rna_sound.c | 4 +- source/blender/makesrna/intern/rna_space.c | 22 ++++----- source/blender/makesrna/intern/rna_text.c | 2 +- source/blender/makesrna/intern/rna_texture.c | 4 +- source/blender/makesrna/intern/rna_tracking.c | 4 +- source/blender/makesrna/intern/rna_ui.c | 16 +++---- source/blender/makesrna/intern/rna_wm.c | 18 ++++---- 41 files changed, 214 insertions(+), 214 deletions(-) diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 142e84bd661..6335869ca43 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -239,7 +239,7 @@ IDProperty *rna_ID_idprops(PointerRNA *ptr, bool create) return IDP_GetProperties(ptr->data, create); } -void rna_ID_fake_user_set(PointerRNA *ptr, int value) +void rna_ID_fake_user_set(PointerRNA *ptr, bool value) { ID *id = (ID *)ptr->data; @@ -647,7 +647,7 @@ static void rna_ImagePreview_pixels_float_set(PointerRNA *ptr, const float *valu } -static void rna_ImagePreview_is_image_custom_set(PointerRNA *ptr, int value) +static void rna_ImagePreview_is_image_custom_set(PointerRNA *ptr, bool value) { rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_PREVIEW); } @@ -693,7 +693,7 @@ static void rna_ImagePreview_image_pixels_float_set(PointerRNA *ptr, const float } -static void rna_ImagePreview_is_icon_custom_set(PointerRNA *ptr, int value) +static void rna_ImagePreview_is_icon_custom_set(PointerRNA *ptr, bool value) { rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_ICON); } diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 562e225303d..6f0ff9aa556 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -329,7 +329,7 @@ static void rna_ConstraintActuator_spring_set(struct PointerRNA *ptr, float valu } /* ConstraintActuator uses the same property for Material and Property. * Therefore we need to clear the property when "use_material_detect" mode changes */ -static void rna_Actuator_constraint_detect_material_set(struct PointerRNA *ptr, int value) +static void rna_Actuator_constraint_detect_material_set(struct PointerRNA *ptr, bool value) { bActuator *act = (bActuator *)ptr->data; bConstraintActuator *ca = act->data; @@ -342,12 +342,12 @@ static void rna_Actuator_constraint_detect_material_set(struct PointerRNA *ptr, } } -static void rna_ActionActuator_add_set(struct PointerRNA *ptr, int value) +static void rna_ActionActuator_add_set(struct PointerRNA *ptr, bool value) { bActuator *act = (bActuator *)ptr->data; bActionActuator *aa = act->data; - if (value == 1) { + if (value) { aa->flag &= ~ACT_IPOFORCE; aa->flag |= ACT_IPOADD; } @@ -356,12 +356,12 @@ static void rna_ActionActuator_add_set(struct PointerRNA *ptr, int value) } } -static void rna_ActionActuator_force_set(struct PointerRNA *ptr, int value) +static void rna_ActionActuator_force_set(struct PointerRNA *ptr, bool value) { bActuator *act = (bActuator *)ptr->data; bActionActuator *aa = act->data; - if (value == 1) { + if (value) { aa->flag &= ~ACT_IPOADD; aa->flag |= ACT_IPOFORCE; } diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 623eccc9ee5..6f1445d31ef 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -118,7 +118,7 @@ static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value) } } -static void rna_AnimData_tweakmode_set(PointerRNA *ptr, const int value) +static void rna_AnimData_tweakmode_set(PointerRNA *ptr, const bool value) { AnimData *adt = (AnimData *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index b6eb0aed709..7af3746b855 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -355,7 +355,7 @@ static void rna_EditBone_connected_check(EditBone *ebone) } } -static void rna_EditBone_connected_set(PointerRNA *ptr, int value) +static void rna_EditBone_connected_set(PointerRNA *ptr, bool value) { EditBone *ebone = (EditBone *)(ptr->data); @@ -475,7 +475,7 @@ static void rna_Armature_bones_next(CollectionPropertyIterator *iter) iter->valid = (internal->link != NULL); } -static int rna_Armature_is_editmode_get(PointerRNA *ptr) +static bool rna_Armature_is_editmode_get(PointerRNA *ptr) { bArmature *arm = (bArmature *)ptr->id.data; return (arm->edbo != NULL); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 71cdb24ffdc..bb204bf8c81 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -135,25 +135,25 @@ const EnumPropertyItem rna_enum_brush_image_tool_items[] = { #include "WM_api.h" -static int rna_SculptToolCapabilities_has_accumulate_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_accumulate_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return SCULPT_TOOL_HAS_ACCUMULATE(br->sculpt_tool); } -static int rna_SculptToolCapabilities_has_auto_smooth_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_auto_smooth_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH); } -static int rna_SculptToolCapabilities_has_height_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_height_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return br->sculpt_tool == SCULPT_TOOL_LAYER; } -static int rna_SculptToolCapabilities_has_jitter_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_jitter_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED) && @@ -163,19 +163,19 @@ static int rna_SculptToolCapabilities_has_jitter_get(PointerRNA *ptr) SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } -static int rna_SculptToolCapabilities_has_normal_weight_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_normal_weight_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return SCULPT_TOOL_HAS_NORMAL_WEIGHT(br->sculpt_tool); } -static int rna_SculptToolCapabilities_has_rake_factor_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_rake_factor_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return SCULPT_TOOL_HAS_RAKE(br->sculpt_tool); } -static int rna_BrushCapabilities_has_overlay_get(PointerRNA *ptr) +static bool rna_BrushCapabilities_has_overlay_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return ELEM(br->mtex.brush_map_mode, @@ -184,26 +184,26 @@ static int rna_BrushCapabilities_has_overlay_get(PointerRNA *ptr) MTEX_MAP_MODE_STENCIL); } -static int rna_SculptToolCapabilities_has_persistence_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_persistence_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return br->sculpt_tool == SCULPT_TOOL_LAYER; } -static int rna_SculptToolCapabilities_has_pinch_factor_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_pinch_factor_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return ELEM(br->sculpt_tool, SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE, SCULPT_TOOL_SNAKE_HOOK); } -static int rna_SculptToolCapabilities_has_plane_offset_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_plane_offset_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return ELEM(br->sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_SCRAPE); } -static int rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return (!ELEM(br->sculpt_tool, @@ -211,7 +211,7 @@ static int rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *p SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } -static int rna_TextureCapabilities_has_random_texture_angle_get(PointerRNA *ptr) +static bool rna_TextureCapabilities_has_random_texture_angle_get(PointerRNA *ptr) { MTex *mtex = (MTex *)ptr->data; return ELEM(mtex->brush_map_mode, @@ -221,13 +221,13 @@ static int rna_TextureCapabilities_has_random_texture_angle_get(PointerRNA *ptr) } -static int rna_BrushCapabilities_has_random_texture_angle_get(PointerRNA *ptr) +static bool rna_BrushCapabilities_has_random_texture_angle_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return !(br->flag & BRUSH_ANCHORED); } -static int rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return !ELEM(br->sculpt_tool, SCULPT_TOOL_INFLATE, @@ -235,13 +235,13 @@ static int rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr) SCULPT_TOOL_SMOOTH); } -static int rna_SculptToolCapabilities_has_secondary_color_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_secondary_color_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return BKE_brush_sculpt_has_secondary_color(br); } -static int rna_SculptToolCapabilities_has_smooth_stroke_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_smooth_stroke_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED) && @@ -253,7 +253,7 @@ static int rna_SculptToolCapabilities_has_smooth_stroke_get(PointerRNA *ptr) SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } -static int rna_BrushCapabilities_has_smooth_stroke_get(PointerRNA *ptr) +static bool rna_BrushCapabilities_has_smooth_stroke_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED) && @@ -262,7 +262,7 @@ static int rna_BrushCapabilities_has_smooth_stroke_get(PointerRNA *ptr) !(br->flag & BRUSH_CURVE)); } -static int rna_SculptToolCapabilities_has_space_attenuation_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_space_attenuation_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return ((br->flag & (BRUSH_SPACE | BRUSH_LINE | BRUSH_CURVE)) && @@ -270,38 +270,38 @@ static int rna_SculptToolCapabilities_has_space_attenuation_get(PointerRNA *ptr) SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK)); } -static int rna_ImapaintToolCapabilities_has_space_attenuation_get(PointerRNA *ptr) +static bool rna_ImapaintToolCapabilities_has_space_attenuation_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return (br->flag & (BRUSH_SPACE | BRUSH_LINE | BRUSH_CURVE)) && br->imagepaint_tool != PAINT_TOOL_FILL; } -static int rna_BrushCapabilities_has_spacing_get(PointerRNA *ptr) +static bool rna_BrushCapabilities_has_spacing_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED)); } -static int rna_SculptToolCapabilities_has_strength_pressure_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_strength_pressure_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); } -static int rna_TextureCapabilities_has_texture_angle_get(PointerRNA *ptr) +static bool rna_TextureCapabilities_has_texture_angle_get(PointerRNA *ptr) { MTex *mtex = (MTex *)ptr->data; return mtex->brush_map_mode != MTEX_MAP_MODE_3D; } -static int rna_SculptToolCapabilities_has_gravity_get(PointerRNA *ptr) +static bool rna_SculptToolCapabilities_has_gravity_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH); } -static int rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr) +static bool rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr) { MTex *mtex = (MTex *)ptr->data; return ELEM(mtex->brush_map_mode, @@ -310,7 +310,7 @@ static int rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr) MTEX_MAP_MODE_RANDOM); } -static int rna_ImapaintToolCapabilities_has_accumulate_get(PointerRNA *ptr) +static bool rna_ImapaintToolCapabilities_has_accumulate_get(PointerRNA *ptr) { /* only support for draw tool */ Brush *br = (Brush *)ptr->data; @@ -325,7 +325,7 @@ static int rna_ImapaintToolCapabilities_has_accumulate_get(PointerRNA *ptr) ) ? false : true; } -static int rna_ImapaintToolCapabilities_has_radius_get(PointerRNA *ptr) +static bool rna_ImapaintToolCapabilities_has_radius_get(PointerRNA *ptr) { /* only support for draw tool */ Brush *br = (Brush *)ptr->data; @@ -456,7 +456,7 @@ static void rna_Brush_set_size(PointerRNA *ptr, int value) brush->size = value; } -static void rna_Brush_use_gradient_set(PointerRNA *ptr, int value) +static void rna_Brush_use_gradient_set(PointerRNA *ptr, bool value) { Brush *br = (Brush *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 1d85ba43995..080916bfbf8 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -85,7 +85,7 @@ static void rna_CurveMapping_curves_begin(CollectionPropertyIterator *iter, Poin rna_iterator_array_begin(iter, cumap->cm, sizeof(CurveMap), rna_CurveMapping_curves_length(ptr), 0, NULL); } -static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value) +static void rna_CurveMapping_clip_set(PointerRNA *ptr, bool value) { CurveMapping *cumap = (CurveMapping *)ptr->data; @@ -521,7 +521,7 @@ static const EnumPropertyItem *rna_ColorManagedViewSettings_look_itemf( return items; } -static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, int value) +static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, bool value) { ColorManagedViewSettings *view_settings = (ColorManagedViewSettings *) ptr->data; diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index 96e8878b938..606f482c92e 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -159,7 +159,7 @@ static void rna_Controller_state_get(PointerRNA *ptr, int *values) values[i] = (cont->state_mask & (1 << i)); } -static void rna_Controller_state_set(PointerRNA *ptr, const int *values) +static void rna_Controller_state_set(PointerRNA *ptr, const bool *values) { bController *cont = (bController *)ptr->data; int i, tot = 0; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 3c4baa70c5f..59fbde13ee3 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -735,7 +735,7 @@ static void rna_Curve_splines_begin(CollectionPropertyIterator *iter, PointerRNA rna_iterator_listbase_begin(iter, BKE_curve_nurbs_get(cu), NULL); } -static int rna_Curve_is_editmode_get(PointerRNA *ptr) +static bool rna_Curve_is_editmode_get(PointerRNA *ptr) { Curve *cu = (Curve *)ptr->id.data; const short type = BKE_curve_type_get(cu); diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c index 325deff0a7a..d16ef3db296 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.c +++ b/source/blender/makesrna/intern/rna_dynamicpaint.c @@ -223,7 +223,7 @@ static void rna_DynamicPaint_uvlayer_set(PointerRNA *ptr, const char *value) } /* is point cache used */ -static int rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr) +static bool rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr) { DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data; @@ -231,7 +231,7 @@ static int rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr) } /* is some 3D view preview available */ -static int rna_DynamicPaint_use_color_preview_get(PointerRNA *ptr) +static bool rna_DynamicPaint_use_color_preview_get(PointerRNA *ptr) { DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index c225045e187..9dbc9a62aa4 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -510,7 +510,7 @@ static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, Pointe RNA_POINTER_INVALIDATE(fcm_ptr); } -static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value)) +static void rna_FModifier_active_set(PointerRNA *ptr, bool UNUSED(value)) { FModifier *fcm = (FModifier *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index fb06e2e17d3..90af65497a4 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -275,7 +275,7 @@ static const EnumPropertyItem *rna_Object_parent_type_itemf( return item; } -static int rna_GPencilLayer_is_parented_get(PointerRNA *ptr) +static bool rna_GPencilLayer_is_parented_get(PointerRNA *ptr) { bGPDlayer *gpl = (bGPDlayer *)ptr->data; return (gpl->parent != NULL); @@ -366,7 +366,7 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info); } -static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value) +static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const bool value) { bGPdata *gpd = ptr->id.data; bGPDlayer *gpl; @@ -423,7 +423,7 @@ static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd, cons return NULL; } -static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const int value) +static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const bool value) { bGPdata *gpd = ptr->id.data; bGPDspoint *pt = ptr->data; @@ -525,7 +525,7 @@ static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, Poi WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } -static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const int value) +static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const bool value) { bGPDstroke *gps = ptr->data; bGPDspoint *pt; @@ -851,13 +851,13 @@ static void rna_GPencilStrokeColor_info_set(PointerRNA *ptr, const char *value) } -static int rna_GPencilPaletteColor_is_stroke_visible_get(PointerRNA *ptr) +static bool rna_GPencilPaletteColor_is_stroke_visible_get(PointerRNA *ptr) { bGPDpalettecolor *pcolor = (bGPDpalettecolor *)ptr->data; return (pcolor->color[3] > GPENCIL_ALPHA_OPACITY_THRESH); } -static int rna_GPencilPaletteColor_is_fill_visible_get(PointerRNA *ptr) +static bool rna_GPencilPaletteColor_is_fill_visible_get(PointerRNA *ptr) { bGPDpalettecolor *pcolor = (bGPDpalettecolor *)ptr->data; return (pcolor->fill[3] > GPENCIL_ALPHA_OPACITY_THRESH); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 9549eb1de08..018a4765cd0 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -83,17 +83,17 @@ static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), } } -static int rna_Image_is_stereo_3d_get(PointerRNA *ptr) +static bool rna_Image_is_stereo_3d_get(PointerRNA *ptr) { return BKE_image_is_stereo((Image *)ptr->data); } -static int rna_Image_is_multiview_get(PointerRNA *ptr) +static bool rna_Image_is_multiview_get(PointerRNA *ptr) { return BKE_image_is_multiview((Image *)ptr->data); } -static int rna_Image_dirty_get(PointerRNA *ptr) +static bool rna_Image_dirty_get(PointerRNA *ptr) { return BKE_image_is_dirty((Image *)ptr->data); } @@ -251,7 +251,7 @@ static void rna_Image_file_format_set(PointerRNA *ptr, int value) } } -static int rna_Image_has_data_get(PointerRNA *ptr) +static bool rna_Image_has_data_get(PointerRNA *ptr) { Image *image = (Image *)ptr->data; @@ -438,7 +438,7 @@ static int rna_Image_channels_get(PointerRNA *ptr) return channels; } -static int rna_Image_is_float_get(PointerRNA *ptr) +static bool rna_Image_is_float_get(PointerRNA *ptr) { Image *im = (Image *)ptr->data; ImBuf *ibuf; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index fac0f39b11c..67fbee8d0ef 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -209,14 +209,14 @@ void rna_def_render_layer_common(struct StructRNA *srna, int scene); void rna_def_actionbone_group_common(struct StructRNA *srna, int update_flag, const char *update_cb); void rna_ActionGroup_colorset_set(struct PointerRNA *ptr, int value); -int rna_ActionGroup_is_custom_colorset_get(struct PointerRNA *ptr); +bool rna_ActionGroup_is_custom_colorset_get(struct PointerRNA *ptr); void rna_ID_name_get(struct PointerRNA *ptr, char *value); int rna_ID_name_length(struct PointerRNA *ptr); void rna_ID_name_set(struct PointerRNA *ptr, const char *value); struct StructRNA *rna_ID_refine(struct PointerRNA *ptr); struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, bool create); -void rna_ID_fake_user_set(struct PointerRNA *ptr, int value); +void rna_ID_fake_user_set(struct PointerRNA *ptr, bool value); void **rna_ID_instance(PointerRNA *ptr); struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, bool create); void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 60b64b0795d..1e1ae2e8183 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -89,7 +89,7 @@ static void rna_Lamp_active_texture_set(PointerRNA *ptr, PointerRNA value) set_current_lamp_texture(la, value.data); } -static int rna_use_shadow_get(PointerRNA *ptr) +static bool rna_use_shadow_get(PointerRNA *ptr) { Lamp *la = (Lamp *)ptr->data; @@ -101,7 +101,7 @@ static int rna_use_shadow_get(PointerRNA *ptr) } } -static void rna_use_shadow_set(PointerRNA *ptr, int value) +static void rna_use_shadow_set(PointerRNA *ptr, bool value) { Lamp *la = (Lamp *)ptr->data; la->mode &= ~(LA_SHAD_BUF | LA_SHAD_RAY); diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 424c6f93f75..bbc0c251897 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -154,7 +154,7 @@ static void rna_Lattice_update_size(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Lattice_update_data(bmain, scene, ptr); } -static void rna_Lattice_use_outside_set(PointerRNA *ptr, int value) +static void rna_Lattice_use_outside_set(PointerRNA *ptr, bool value) { Lattice *lt = ptr->data; @@ -235,7 +235,7 @@ static char *rna_LatticePoint_path(PointerRNA *ptr) return BLI_strdup(""); } -static int rna_Lattice_is_editmode_get(PointerRNA *ptr) +static bool rna_Lattice_is_editmode_get(PointerRNA *ptr) { Lattice *lt = (Lattice *)ptr->id.data; return (lt->editlatt != NULL); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 89e1ee47475..5d7088c952b 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -42,7 +42,7 @@ /* all the list begin functions are added manually here, Main is not in SDNA */ -static int rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr)) +static bool rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr)) { if (G.fileflags & G_AUTOPACK) return 1; @@ -50,7 +50,7 @@ static int rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr)) return 0; } -static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), int value) +static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), bool value) { if (value) G.fileflags |= G_AUTOPACK; @@ -58,12 +58,12 @@ static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), int value) G.fileflags &= ~G_AUTOPACK; } -static int rna_Main_is_saved_get(PointerRNA *UNUSED(ptr)) +static bool rna_Main_is_saved_get(PointerRNA *UNUSED(ptr)) { return G.relbase_valid; } -static int rna_Main_is_dirty_get(PointerRNA *ptr) +static bool rna_Main_is_dirty_get(PointerRNA *ptr) { /* XXX, not totally nice to do it this way, should store in main ? */ Main *bmain = (Main *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index a4b9f52464d..4947557af10 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -285,7 +285,7 @@ static void rna_MaterialStrand_end_size_range(PointerRNA *ptr, float *min, float } } -static int rna_MaterialTextureSlot_use_get(PointerRNA *ptr) +static bool rna_MaterialTextureSlot_use_get(PointerRNA *ptr) { Material *ma = (Material *)ptr->id.data; MTex *mtex = (MTex *)ptr->data; @@ -298,7 +298,7 @@ static int rna_MaterialTextureSlot_use_get(PointerRNA *ptr) return 0; } -static void rna_MaterialTextureSlot_use_set(PointerRNA *ptr, int value) +static void rna_MaterialTextureSlot_use_set(PointerRNA *ptr, bool value) { Material *ma = (Material *)ptr->id.data; MTex *mtex = (MTex *)ptr->data; @@ -314,7 +314,7 @@ static void rna_MaterialTextureSlot_use_set(PointerRNA *ptr, int value) } } -static void rna_Material_use_diffuse_ramp_set(PointerRNA *ptr, int value) +static void rna_Material_use_diffuse_ramp_set(PointerRNA *ptr, bool value) { Material *ma = (Material *)ptr->data; @@ -325,7 +325,7 @@ static void rna_Material_use_diffuse_ramp_set(PointerRNA *ptr, int value) ma->ramp_col = BKE_colorband_add(false); } -static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value) +static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, bool value) { Material *ma = (Material *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index f09fd29889a..0b8f90e1c68 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -209,10 +209,10 @@ static void rna_MeshAnyLayer_name_set(PointerRNA *ptr, const char *value) rna_cd_layer_name_set(cd, (CustomDataLayer *)ptr->data, value); } -static int rna_Mesh_has_custom_normals_get(PointerRNA *ptr) +static bool rna_Mesh_has_custom_normals_get(PointerRNA *ptr) { Mesh *me = ptr->data; - return (int)BKE_mesh_has_custom_loop_normals(me); + return BKE_mesh_has_custom_loop_normals(me); } /* -------------------------------------------------------------------- */ @@ -778,7 +778,7 @@ static void rna_CustomDataLayer_clone_set(PointerRNA *ptr, CustomData *data, int CustomData_set_layer_clone_index(data, type, n); } -static int rna_MEdge_freestyle_edge_mark_get(PointerRNA *ptr) +static bool rna_MEdge_freestyle_edge_mark_get(PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); MEdge *medge = (MEdge *)ptr->data; @@ -787,7 +787,7 @@ static int rna_MEdge_freestyle_edge_mark_get(PointerRNA *ptr) return fed && (fed->flag & FREESTYLE_EDGE_MARK) != 0; } -static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, int value) +static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, bool value) { Mesh *me = rna_mesh(ptr); MEdge *medge = (MEdge *)ptr->data; @@ -804,7 +804,7 @@ static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, int value) } } -static int rna_MPoly_freestyle_face_mark_get(PointerRNA *ptr) +static bool rna_MPoly_freestyle_face_mark_get(PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); MPoly *mpoly = (MPoly *)ptr->data; @@ -890,22 +890,22 @@ static int rna_MeshTextureFaceLayer_data_length(PointerRNA *ptr) return (me->edit_btmesh) ? 0 : me->totface; } -static int rna_MeshTextureFaceLayer_active_render_get(PointerRNA *ptr) +static bool rna_MeshTextureFaceLayer_active_render_get(PointerRNA *ptr) { return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE, 1); } -static int rna_MeshTextureFaceLayer_active_get(PointerRNA *ptr) +static bool rna_MeshTextureFaceLayer_active_get(PointerRNA *ptr) { return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE, 0); } -static int rna_MeshTextureFaceLayer_clone_get(PointerRNA *ptr) +static bool rna_MeshTextureFaceLayer_clone_get(PointerRNA *ptr) { return rna_CustomDataLayer_clone_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE); } -static void rna_MeshTextureFaceLayer_active_render_set(PointerRNA *ptr, int value) +static void rna_MeshTextureFaceLayer_active_render_set(PointerRNA *ptr, bool value) { rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MTFACE, 1); } @@ -941,22 +941,22 @@ static int rna_MeshTexturePolyLayer_data_length(PointerRNA *ptr) return (me->edit_btmesh) ? 0 : me->totpoly; } -static int rna_MeshTexturePolyLayer_active_render_get(PointerRNA *ptr) +static bool rna_MeshTexturePolyLayer_active_render_get(PointerRNA *ptr) { return rna_CustomDataLayer_active_get(ptr, rna_mesh_pdata(ptr), CD_MTEXPOLY, 1); } -static int rna_MeshTexturePolyLayer_active_get(PointerRNA *ptr) +static bool rna_MeshTexturePolyLayer_active_get(PointerRNA *ptr) { return rna_CustomDataLayer_active_get(ptr, rna_mesh_pdata(ptr), CD_MTEXPOLY, 0); } -static int rna_MeshTexturePolyLayer_clone_get(PointerRNA *ptr) +static bool rna_MeshTexturePolyLayer_clone_get(PointerRNA *ptr) { return rna_CustomDataLayer_clone_get(ptr, rna_mesh_pdata(ptr), CD_MTEXPOLY); } -static void rna_MeshTexturePolyLayer_active_render_set(PointerRNA *ptr, int value) +static void rna_MeshTexturePolyLayer_active_render_set(PointerRNA *ptr, bool value) { rna_CustomDataLayer_active_set(ptr, rna_mesh_pdata(ptr), value, CD_MTEXPOLY, 1); } @@ -966,7 +966,7 @@ static void rna_MeshTexturePolyLayer_active_set(PointerRNA *ptr, int value) rna_CustomDataLayer_active_set(ptr, rna_mesh_pdata(ptr), value, CD_MTEXPOLY, 0); } -static void rna_MeshTexturePolyLayer_clone_set(PointerRNA *ptr, int value) +static void rna_MeshTexturePolyLayer_clone_set(PointerRNA *ptr, bool value) { rna_CustomDataLayer_clone_set(ptr, rna_mesh_pdata(ptr), value, CD_MTEXPOLY); } @@ -990,17 +990,17 @@ static int rna_MeshColorLayer_data_length(PointerRNA *ptr) return me->totface; } -static int rna_MeshColorLayer_active_render_get(PointerRNA *ptr) +static bool rna_MeshColorLayer_active_render_get(PointerRNA *ptr) { return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MCOL, 1); } -static int rna_MeshColorLayer_active_get(PointerRNA *ptr) +static bool rna_MeshColorLayer_active_get(PointerRNA *ptr) { return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MCOL, 0); } -static void rna_MeshColorLayer_active_render_set(PointerRNA *ptr, int value) +static void rna_MeshColorLayer_active_render_set(PointerRNA *ptr, bool value) { rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MCOL, 1); } @@ -1027,22 +1027,22 @@ static int rna_MeshLoopColorLayer_data_length(PointerRNA *ptr) return (me->edit_btmesh) ? 0 : me->totloop; } -static int rna_MeshLoopColorLayer_active_render_get(PointerRNA *ptr) +static bool rna_MeshLoopColorLayer_active_render_get(PointerRNA *ptr) { return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPCOL, 1); } -static int rna_MeshLoopColorLayer_active_get(PointerRNA *ptr) +static bool rna_MeshLoopColorLayer_active_get(PointerRNA *ptr) { return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPCOL, 0); } -static void rna_MeshLoopColorLayer_active_render_set(PointerRNA *ptr, int value) +static void rna_MeshLoopColorLayer_active_render_set(PointerRNA *ptr, bool value) { rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPCOL, 1); } -static void rna_MeshLoopColorLayer_active_set(PointerRNA *ptr, int value) +static void rna_MeshLoopColorLayer_active_set(PointerRNA *ptr, bool value) { rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPCOL, 0); } @@ -1823,7 +1823,7 @@ static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, ReportList * } -static int rna_Mesh_is_editmode_get(PointerRNA *ptr) +static bool rna_Mesh_is_editmode_get(PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); return (me->edit_btmesh != NULL); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 07f36b3efff..7025e05d56c 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -158,7 +158,7 @@ static void rna_MetaBall_elements_clear(MetaBall *mb) } } -static int rna_Meta_is_editmode_get(PointerRNA *ptr) +static bool rna_Meta_is_editmode_get(PointerRNA *ptr) { MetaBall *mb = ptr->id.data; return (mb->editelems != NULL); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 27fd02c9be7..902074d8628 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -651,7 +651,7 @@ static void rna_MultiresModifier_level_range(PointerRNA *ptr, int *min, int *max *max = max_ii(0, mmd->totlvl); /* intentionally _not_ -1 */ } -static int rna_MultiresModifier_external_get(PointerRNA *ptr) +static bool rna_MultiresModifier_external_get(PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; Mesh *me = ob->data; @@ -700,7 +700,7 @@ static void rna_ShrinkwrapModifier_face_cull_set(struct PointerRNA *ptr, int val (swm->shrinkOpts & ~(MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) | value; } -static int rna_MeshDeformModifier_is_bound_get(PointerRNA *ptr) +static bool rna_MeshDeformModifier_is_bound_get(PointerRNA *ptr) { return (((MeshDeformModifierData *)ptr->data)->bindcagecos != NULL); } @@ -775,7 +775,7 @@ static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value) } } -static int rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr) +static bool rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr) { LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)ptr->data; return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->cache_system != NULL)); @@ -1129,13 +1129,13 @@ static void rna_CorrectiveSmoothModifier_rest_source_update(Main *bmain, Scene * rna_CorrectiveSmoothModifier_update(bmain, scene, ptr); } -static int rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA *ptr) +static bool rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA *ptr) { CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)ptr->data; return (csmd->bind_coords != NULL); } -static int rna_SurfaceDeformModifier_is_bound_get(PointerRNA *ptr) +static bool rna_SurfaceDeformModifier_is_bound_get(PointerRNA *ptr) { return (((SurfaceDeformModifierData *)ptr->data)->verts != NULL); } diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index d76f2ccf443..09b194d0e1b 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -254,7 +254,7 @@ static void rna_NlaStrip_blend_out_set(PointerRNA *ptr, float value) data->blendout = value; } -static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, int value) +static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, bool value) { NlaStrip *data = (NlaStrip *)ptr->data; @@ -330,7 +330,7 @@ static void rna_NlaStrip_action_end_frame_set(PointerRNA *ptr, float value) BKE_nlastrip_recalculate_bounds(data); } -static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, int value) +static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, bool value) { NlaStrip *data = (NlaStrip *)ptr->data; @@ -343,7 +343,7 @@ static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, int value) data->flag &= ~NLASTRIP_FLAG_USR_INFLUENCE; } -static void rna_NlaStrip_animated_time_set(PointerRNA *ptr, int value) +static void rna_NlaStrip_animated_time_set(PointerRNA *ptr, bool value) { NlaStrip *data = (NlaStrip *)ptr->data; @@ -434,7 +434,7 @@ static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *report /* Set the 'solo' setting for the given NLA-track, making sure that it is the only one * that has this status in its AnimData block. */ -static void rna_NlaTrack_solo_set(PointerRNA *ptr, int value) +static void rna_NlaTrack_solo_set(PointerRNA *ptr, bool value) { NlaTrack *data = (NlaTrack *)ptr->data; AnimData *adt = BKE_animdata_from_id(ptr->id.data); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 38e969fedb5..a2ab00a482b 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1086,7 +1086,7 @@ static void rna_NodeTree_interface_update(bNodeTree *ntree, bContext *C) /* ******** NodeLink ******** */ -static int rna_NodeLink_is_hidden_get(PointerRNA *ptr) +static bool rna_NodeLink_is_hidden_get(PointerRNA *ptr) { bNodeLink *link = ptr->data; return nodeLinkIsHidden(link); @@ -1587,7 +1587,7 @@ static void rna_Node_socket_value_update(ID *id, bNode *node, bContext *C) ED_node_tag_update_nodetree(CTX_data_main(C), (bNodeTree *)id, node); } -static void rna_Node_select_set(PointerRNA *ptr, int value) +static void rna_Node_select_set(PointerRNA *ptr, bool value) { bNode *node = (bNode *)ptr->data; nodeSetSelected(node, value); @@ -1957,7 +1957,7 @@ static void rna_NodeSocket_update(Main *bmain, Scene *UNUSED(scene), PointerRNA } } -static int rna_NodeSocket_is_output_get(PointerRNA *ptr) +static bool rna_NodeSocket_is_output_get(PointerRNA *ptr) { bNodeSocket *sock = ptr->data; return sock->in_out == SOCK_OUT; @@ -1969,7 +1969,7 @@ static void rna_NodeSocket_link_limit_set(PointerRNA *ptr, int value) sock->limit = (value == 0 ? 0xFFF : value); } -static void rna_NodeSocket_hide_set(PointerRNA *ptr, int value) +static void rna_NodeSocket_hide_set(PointerRNA *ptr, bool value) { bNodeSocket *sock = (bNodeSocket *)ptr->data; @@ -2687,7 +2687,7 @@ static const EnumPropertyItem *rna_Node_image_layer_itemf(bContext *UNUSED(C), P return item; } -static int rna_Node_image_has_layers_get(PointerRNA *ptr) +static bool rna_Node_image_has_layers_get(PointerRNA *ptr) { bNode *node = (bNode *)ptr->data; Image *ima = (Image *)node->id; @@ -2697,7 +2697,7 @@ static int rna_Node_image_has_layers_get(PointerRNA *ptr) return RE_layers_have_name(ima->rr); } -static int rna_Node_image_has_views_get(PointerRNA *ptr) +static bool rna_Node_image_has_views_get(PointerRNA *ptr) { bNode *node = (bNode *)ptr->data; Image *ima = (Image *)node->id; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 9b741cf044a..1d62f438047 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1513,7 +1513,7 @@ int rna_DupliObject_index_get(PointerRNA *ptr) return dob->persistent_id[0]; } -int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr) +bool rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr) { SculptSession *ss = ((Object *)ptr->id.data)->sculpt; return (ss && ss->bm); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 4e51f81fd89..7da859c000c 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -346,52 +346,52 @@ static char *rna_CollisionSettings_path(PointerRNA *UNUSED(ptr)) #endif } -static int rna_SoftBodySettings_use_edges_get(PointerRNA *ptr) +static bool rna_SoftBodySettings_use_edges_get(PointerRNA *ptr) { Object *data = (Object *)(ptr->id.data); return (((data->softflag) & OB_SB_EDGES) != 0); } -static void rna_SoftBodySettings_use_edges_set(PointerRNA *ptr, int value) +static void rna_SoftBodySettings_use_edges_set(PointerRNA *ptr, bool value) { Object *data = (Object *)(ptr->id.data); if (value) data->softflag |= OB_SB_EDGES; else data->softflag &= ~OB_SB_EDGES; } -static int rna_SoftBodySettings_use_goal_get(PointerRNA *ptr) +static bool rna_SoftBodySettings_use_goal_get(PointerRNA *ptr) { Object *data = (Object *)(ptr->id.data); return (((data->softflag) & OB_SB_GOAL) != 0); } -static void rna_SoftBodySettings_use_goal_set(PointerRNA *ptr, int value) +static void rna_SoftBodySettings_use_goal_set(PointerRNA *ptr, bool value) { Object *data = (Object *)(ptr->id.data); if (value) data->softflag |= OB_SB_GOAL; else data->softflag &= ~OB_SB_GOAL; } -static int rna_SoftBodySettings_stiff_quads_get(PointerRNA *ptr) +static bool rna_SoftBodySettings_stiff_quads_get(PointerRNA *ptr) { Object *data = (Object *)(ptr->id.data); return (((data->softflag) & OB_SB_QUADS) != 0); } -static void rna_SoftBodySettings_stiff_quads_set(PointerRNA *ptr, int value) +static void rna_SoftBodySettings_stiff_quads_set(PointerRNA *ptr, bool value) { Object *data = (Object *)(ptr->id.data); if (value) data->softflag |= OB_SB_QUADS; else data->softflag &= ~OB_SB_QUADS; } -static int rna_SoftBodySettings_self_collision_get(PointerRNA *ptr) +static bool rna_SoftBodySettings_self_collision_get(PointerRNA *ptr) { Object *data = (Object *)(ptr->id.data); return (((data->softflag) & OB_SB_SELF) != 0); } -static void rna_SoftBodySettings_self_collision_set(PointerRNA *ptr, int value) +static void rna_SoftBodySettings_self_collision_set(PointerRNA *ptr, bool value) { Object *data = (Object *)(ptr->id.data); if (value) data->softflag |= OB_SB_SELF; @@ -416,26 +416,26 @@ static void rna_SoftBodySettings_new_aero_set(PointerRNA *ptr, int value) data->softflag &= ~OB_SB_AERO_ANGLE; } -static int rna_SoftBodySettings_face_collision_get(PointerRNA *ptr) +static bool rna_SoftBodySettings_face_collision_get(PointerRNA *ptr) { Object *data = (Object *)(ptr->id.data); return (((data->softflag) & OB_SB_FACECOLL) != 0); } -static void rna_SoftBodySettings_face_collision_set(PointerRNA *ptr, int value) +static void rna_SoftBodySettings_face_collision_set(PointerRNA *ptr, bool value) { Object *data = (Object *)(ptr->id.data); if (value) data->softflag |= OB_SB_FACECOLL; else data->softflag &= ~OB_SB_FACECOLL; } -static int rna_SoftBodySettings_edge_collision_get(PointerRNA *ptr) +static bool rna_SoftBodySettings_edge_collision_get(PointerRNA *ptr) { Object *data = (Object *)(ptr->id.data); return (((data->softflag) & OB_SB_EDGECOLL) != 0); } -static void rna_SoftBodySettings_edge_collision_set(PointerRNA *ptr, int value) +static void rna_SoftBodySettings_edge_collision_set(PointerRNA *ptr, bool value) { Object *data = (Object *)(ptr->id.data); if (value) data->softflag |= OB_SB_EDGECOLL; diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index fc8f28f4f2c..a2286f0b92a 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -935,7 +935,7 @@ static float rna_PartSetting_linelenhead_get(struct PointerRNA *ptr) } -static int rna_PartSettings_is_fluid_get(PointerRNA *ptr) +static bool rna_PartSettings_is_fluid_get(PointerRNA *ptr) { ParticleSettings *part = (ParticleSettings *)ptr->data; @@ -1095,19 +1095,19 @@ static char *rna_SPHFluidSettings_path(PointerRNA *ptr) return NULL; } -static int rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr) +static bool rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr) { ParticleSystem *psys = (ParticleSystem *)ptr->data; return (psys->ptcaches.first != psys->ptcaches.last); } -static int rna_ParticleSystem_editable_get(PointerRNA *ptr) +static bool rna_ParticleSystem_editable_get(PointerRNA *ptr) { ParticleSystem *psys = (ParticleSystem *)ptr->data; return psys_check_edited(psys); } -static int rna_ParticleSystem_edited_get(PointerRNA *ptr) +static bool rna_ParticleSystem_edited_get(PointerRNA *ptr) { ParticleSystem *psys = (ParticleSystem *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index a1a026536cf..e06aab8c4cc 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -181,7 +181,7 @@ void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value) } } -int rna_ActionGroup_is_custom_colorset_get(PointerRNA *ptr) +bool rna_ActionGroup_is_custom_colorset_get(PointerRNA *ptr) { bActionGroup *grp = ptr->data; @@ -292,7 +292,7 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value) ED_armature_bone_rename(G_MAIN, ob->data, oldname, newname); } -static int rna_PoseChannel_has_ik_get(PointerRNA *ptr) +static bool rna_PoseChannel_has_ik_get(PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; bPoseChannel *pchan = (bPoseChannel *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c index df52515934a..e1e9bb30335 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.c +++ b/source/blender/makesrna/intern/rna_rigidbody.c @@ -131,7 +131,7 @@ static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int va #endif } -static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, int value) +static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, bool value) { RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data; @@ -194,7 +194,7 @@ static void rna_RigidBodyOb_shape_set(PointerRNA *ptr, int value) rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; } -static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value) +static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, bool value) { RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; @@ -276,7 +276,7 @@ static void rna_RigidBodyOb_collision_groups_set(PointerRNA *ptr, const bool *va rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; } -static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value) +static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, bool value) { RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; @@ -292,7 +292,7 @@ static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value) #endif } -static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, int value) +static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, bool value) { RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; @@ -376,7 +376,7 @@ static void rna_RigidBodyCon_type_set(PointerRNA *ptr, int value) rbc->flag |= RBC_FLAG_NEEDS_VALIDATE; } -static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, int value) +static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, bool value) { RigidBodyCon *rbc = (RigidBodyCon *)ptr->data; @@ -389,7 +389,7 @@ static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, int value) #endif } -static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, int value) +static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, bool value) { RigidBodyCon *rbc = (RigidBodyCon *)ptr->data; @@ -398,7 +398,7 @@ static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, int value) rbc->flag |= RBC_FLAG_NEEDS_VALIDATE; } -static void rna_RigidBodyCon_use_breaking_set(PointerRNA *ptr, int value) +static void rna_RigidBodyCon_use_breaking_set(PointerRNA *ptr, bool value) { RigidBodyCon *rbc = (RigidBodyCon *)ptr->data; @@ -433,7 +433,7 @@ static void rna_RigidBodyCon_breaking_threshold_set(PointerRNA *ptr, float value #endif } -static void rna_RigidBodyCon_override_solver_iterations_set(PointerRNA *ptr, int value) +static void rna_RigidBodyCon_override_solver_iterations_set(PointerRNA *ptr, bool value) { RigidBodyCon *rbc = (RigidBodyCon *)ptr->data; @@ -633,7 +633,7 @@ static void rna_RigidBodyCon_motor_lin_max_impulse_set(PointerRNA *ptr, float va #endif } -static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, int value) +static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, bool value) { RigidBodyCon *rbc = (RigidBodyCon *)ptr->data; @@ -646,7 +646,7 @@ static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, int value) #endif } -static void rna_RigidBodyCon_use_motor_ang_set(PointerRNA *ptr, int value) +static void rna_RigidBodyCon_use_motor_ang_set(PointerRNA *ptr, bool value) { RigidBodyCon *rbc = (RigidBodyCon *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index f158cfaa54c..7eb48272c56 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -570,7 +570,7 @@ static int rna_Property_icon_get(PointerRNA *ptr) return prop->icon; } -static int rna_Property_readonly_get(PointerRNA *ptr) +static bool rna_Property_readonly_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; @@ -581,57 +581,57 @@ static int rna_Property_readonly_get(PointerRNA *ptr) return (prop->flag & PROP_EDITABLE) == 0; } -static int rna_Property_animatable_get(PointerRNA *ptr) +static bool rna_Property_animatable_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag & PROP_ANIMATABLE) != 0; } -static int rna_Property_use_output_get(PointerRNA *ptr) +static bool rna_Property_use_output_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag_parameter & PARM_OUTPUT) != 0; } -static int rna_Property_is_required_get(PointerRNA *ptr) +static bool rna_Property_is_required_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag_parameter & PARM_REQUIRED) != 0; } -static int rna_Property_is_argument_optional_get(PointerRNA *ptr) +static bool rna_Property_is_argument_optional_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag_parameter & PARM_PYFUNC_OPTIONAL) != 0; } -static int rna_Property_is_never_none_get(PointerRNA *ptr) +static bool rna_Property_is_never_none_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag & PROP_NEVER_NULL) != 0; } -static int rna_Property_is_hidden_get(PointerRNA *ptr) +static bool rna_Property_is_hidden_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag & PROP_HIDDEN) != 0; } -static int rna_Property_is_skip_save_get(PointerRNA *ptr) +static bool rna_Property_is_skip_save_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag & PROP_SKIP_SAVE) != 0; } -static int rna_Property_is_enum_flag_get(PointerRNA *ptr) +static bool rna_Property_is_enum_flag_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag & PROP_ENUM_FLAG) != 0; } -static int rna_Property_is_library_editable_flag_get(PointerRNA *ptr) +static bool rna_Property_is_library_editable_flag_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag & PROP_LIB_EXCEPTION) != 0; @@ -688,26 +688,26 @@ static void rna_Property_array_dimensions_get(PointerRNA *ptr, int dimensions[RN } } -static int rna_Property_is_registered_get(PointerRNA *ptr) +static bool rna_Property_is_registered_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag & PROP_REGISTER) != 0; } -static int rna_Property_is_registered_optional_get(PointerRNA *ptr) +static bool rna_Property_is_registered_optional_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag & PROP_REGISTER_OPTIONAL) != 0; } -static int rna_Property_is_runtime_get(PointerRNA *ptr) +static bool rna_Property_is_runtime_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; return (prop->flag_internal & PROP_INTERN_RUNTIME) != 0; } -static int rna_BoolProperty_default_get(PointerRNA *ptr) +static bool rna_BoolProperty_default_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; rna_idproperty_check(&prop, ptr); @@ -730,7 +730,7 @@ static int rna_NumberProperty_default_array_get_length(PointerRNA *ptr, int leng return length[0]; } -static int rna_NumberProperty_is_array_get(PointerRNA *ptr) +static bool rna_NumberProperty_is_array_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; @@ -1035,19 +1035,19 @@ static void rna_Function_parameters_begin(CollectionPropertyIterator *iter, Poin rna_iterator_listbase_begin(iter, &((FunctionRNA *)ptr->data)->cont.properties, rna_property_builtin); } -static int rna_Function_registered_get(PointerRNA *ptr) +static bool rna_Function_registered_get(PointerRNA *ptr) { FunctionRNA *func = (FunctionRNA *)ptr->data; return 0 != (func->flag & FUNC_REGISTER); } -static int rna_Function_registered_optional_get(PointerRNA *ptr) +static bool rna_Function_registered_optional_get(PointerRNA *ptr) { FunctionRNA *func = (FunctionRNA *)ptr->data; return 0 != (func->flag & (FUNC_REGISTER_OPTIONAL & ~FUNC_REGISTER)); } -static int rna_Function_no_self_get(PointerRNA *ptr) +static bool rna_Function_no_self_get(PointerRNA *ptr) { FunctionRNA *func = (FunctionRNA *)ptr->data; return !(func->flag & FUNC_NO_SELF); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 894742fe8fe..3c8cc9ee2be 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -839,7 +839,7 @@ static void rna_Scene_end_frame_set(PointerRNA *ptr, int value) } } -static void rna_Scene_use_preview_range_set(PointerRNA *ptr, int value) +static void rna_Scene_use_preview_range_set(PointerRNA *ptr, bool value) { Scene *data = (Scene *)ptr->data; @@ -1059,13 +1059,13 @@ static int rna_RenderSettings_threads_mode_get(PointerRNA *ptr) return (rd->mode & R_FIXED_THREADS); } -static int rna_RenderSettings_is_movie_format_get(PointerRNA *ptr) +static bool rna_RenderSettings_is_movie_format_get(PointerRNA *ptr) { RenderData *rd = (RenderData *)ptr->data; return BKE_imtype_is_movie(rd->im_format.imtype); } -static int rna_RenderSettings_save_buffers_get(PointerRNA *ptr) +static bool rna_RenderSettings_save_buffers_get(PointerRNA *ptr) { RenderData *rd = (RenderData *)ptr->data; Scene *scene = (Scene *)ptr->id.data; @@ -1312,7 +1312,7 @@ static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str) } #ifdef WITH_FFMPEG -static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, int value) +static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, bool value) { Scene *scene = (Scene *) ptr->id.data; RenderData *rd = &scene->r; @@ -1610,24 +1610,24 @@ static void rna_RenderSettings_views_format_set(PointerRNA *ptr, int value) rd->views_format = value; } -static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) +static bool rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) { return (BLI_listbase_count(&R_engines) > 1); } -static int rna_RenderSettings_use_shading_nodes_get(PointerRNA *ptr) +static bool rna_RenderSettings_use_shading_nodes_get(PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; return BKE_scene_use_new_shading_nodes(scene); } -static int rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr) +static bool rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; return BKE_scene_use_spherical_stereo(scene); } -static int rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) +static bool rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) { RenderData *rd = (RenderData *)ptr->data; RenderEngineType *type; @@ -1777,13 +1777,13 @@ static void rna_Scene_use_persistent_data_update(Main *UNUSED(bmain), Scene *UNU RE_FreePersistentData(); } -static int rna_Scene_use_audio_get(PointerRNA *ptr) +static bool rna_Scene_use_audio_get(PointerRNA *ptr) { Scene *scene = (Scene *)ptr->data; return (scene->audio.flag & AUDIO_MUTE) != 0; } -static void rna_Scene_use_audio_set(PointerRNA *ptr, int value) +static void rna_Scene_use_audio_set(PointerRNA *ptr, bool value) { Scene *scene = (Scene *)ptr->data; @@ -1820,12 +1820,12 @@ static void rna_Scene_sync_mode_set(PointerRNA *ptr, int value) } } -static int rna_GameSettings_auto_start_get(PointerRNA *UNUSED(ptr)) +static bool rna_GameSettings_auto_start_get(PointerRNA *UNUSED(ptr)) { return (G.fileflags & G_FILE_AUTOPLAY) != 0; } -static void rna_GameSettings_auto_start_set(PointerRNA *UNUSED(ptr), int value) +static void rna_GameSettings_auto_start_set(PointerRNA *UNUSED(ptr), bool value) { if (value) G.fileflags |= G_FILE_AUTOPLAY; @@ -2162,7 +2162,7 @@ static void rna_Stereo3dFormat_update(Main *bmain, Scene *UNUSED(scene), Pointer } } -static int rna_gpu_is_hq_supported_get(PointerRNA *UNUSED(ptr)) +static bool rna_gpu_is_hq_supported_get(PointerRNA *UNUSED(ptr)) { return GPU_instanced_drawing_support() && GPU_geometry_shader_support(); } diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 0b2034b6369..7ca26ab1c9f 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -108,14 +108,14 @@ static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), } -static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) +static bool rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) { /* can be NULL on file load, T42619 */ wmWindowManager *wm = G_MAIN->wm.first; return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; } -static int rna_Screen_fullscreen_get(PointerRNA *ptr) +static bool rna_Screen_fullscreen_get(PointerRNA *ptr) { bScreen *sc = (bScreen *)ptr->data; return (sc->state == SCREENMAXIMIZED); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 890aa532943..c111263cb7d 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -214,7 +214,7 @@ static const EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerR return particle_edit_cache_brush_items; } -static int rna_ParticleEdit_editable_get(PointerRNA *ptr) +static bool rna_ParticleEdit_editable_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; @@ -224,7 +224,7 @@ static int rna_ParticleEdit_editable_get(PointerRNA *ptr) } return (pset->object && pset->scene && PE_get_current(G_MAIN, pset->scene, pset->object)); } -static int rna_ParticleEdit_hair_get(PointerRNA *ptr) +static bool rna_ParticleEdit_hair_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index c992f4dd57d..e04e78f3ac7 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -211,7 +211,7 @@ static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value) ks->qual2 = 0; } -static void rna_Sensor_tap_set(struct PointerRNA *ptr, int value) +static void rna_Sensor_tap_set(struct PointerRNA *ptr, bool value) { bSensor *sens = (bSensor *)ptr->data; @@ -220,7 +220,7 @@ static void rna_Sensor_tap_set(struct PointerRNA *ptr, int value) sens->level = 0; } -static void rna_Sensor_level_set(struct PointerRNA *ptr, int value) +static void rna_Sensor_level_set(struct PointerRNA *ptr, bool value) { bSensor *sens = (bSensor *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index aa3ab1742aa..e78bce9170d 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -327,13 +327,13 @@ static void rna_Sequence_frame_offset_range(PointerRNA *ptr, int *min, int *max, *max = INT_MAX; } -static void rna_Sequence_use_proxy_set(PointerRNA *ptr, int value) +static void rna_Sequence_use_proxy_set(PointerRNA *ptr, bool value) { Sequence *seq = (Sequence *)ptr->data; BKE_sequencer_proxy_set(seq, value != 0); } -static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value) +static void rna_Sequence_use_translation_set(PointerRNA *ptr, bool value) { Sequence *seq = (Sequence *)ptr->data; if (value) { @@ -347,7 +347,7 @@ static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value) } } -static void rna_Sequence_use_crop_set(PointerRNA *ptr, int value) +static void rna_Sequence_use_crop_set(PointerRNA *ptr, bool value) { Sequence *seq = (Sequence *)ptr->data; if (value) { @@ -891,7 +891,7 @@ static void rna_SequenceColorBalance_update(Main *UNUSED(bmain), Scene *UNUSED(s BKE_sequence_invalidate_cache_for_modifier(scene, seq); } -static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, int value) +static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, bool value) { Scene *scene = ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, false); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 52550a9b8cc..65e56ddb487 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -429,7 +429,7 @@ static void rna_SmokeFlow_uvlayer_set(PointerRNA *ptr, const char *value) rna_object_uvlayer_name_set(ptr, value, flow->uvlayer_name, sizeof(flow->uvlayer_name)); } -static void rna_Smoke_use_color_ramp_set(PointerRNA *ptr, int value) +static void rna_Smoke_use_color_ramp_set(PointerRNA *ptr, bool value) { SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 6aacede5816..3339c5ec405 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -45,13 +45,13 @@ static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) BKE_sound_load(bmain, (bSound *)ptr->data); } -static int rna_Sound_caching_get(PointerRNA *ptr) +static bool rna_Sound_caching_get(PointerRNA *ptr) { bSound *sound = (bSound *)(ptr->data); return (sound->flags & SOUND_FLAGS_CACHING) != 0; } -static void rna_Sound_caching_set(PointerRNA *ptr, const int value) +static void rna_Sound_caching_set(PointerRNA *ptr, const bool value) { bSound *sound = (bSound *)(ptr->data); if (value) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 23ed021b190..813e847aae6 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -367,7 +367,7 @@ static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **r_sa, ARe area_region_from_regiondata(sc, regiondata, r_sa, r_ar); } -static int rna_Space_view2d_sync_get(PointerRNA *ptr) +static bool rna_Space_view2d_sync_get(PointerRNA *ptr) { ScrArea *sa; ARegion *ar; @@ -382,7 +382,7 @@ static int rna_Space_view2d_sync_get(PointerRNA *ptr) return false; } -static void rna_Space_view2d_sync_set(PointerRNA *ptr, int value) +static void rna_Space_view2d_sync_set(PointerRNA *ptr, bool value) { ScrArea *sa; ARegion *ar; @@ -477,7 +477,7 @@ static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA } } -static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int value) +static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, bool value) { View3D *v3d = (View3D *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; @@ -786,7 +786,7 @@ static void rna_SpaceImageEditor_show_stereo_set(PointerRNA *ptr, int value) sima->iuser.flag &= ~IMA_SHOW_STEREO; } -static int rna_SpaceImageEditor_show_stereo_get(PointerRNA *ptr) +static bool rna_SpaceImageEditor_show_stereo_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); return (sima->iuser.flag & IMA_SHOW_STEREO) != 0; @@ -807,26 +807,26 @@ static void rna_SpaceImageEditor_show_stereo_update(Main *UNUSED(bmain), Scene * } } -static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr) +static bool rna_SpaceImageEditor_show_render_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); return ED_space_image_show_render(sima); } -static int rna_SpaceImageEditor_show_paint_get(PointerRNA *ptr) +static bool rna_SpaceImageEditor_show_paint_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); return ED_space_image_show_paint(sima); } -static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) +static bool rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; return ED_space_image_show_uvedit(sima, sc->scene->obedit); } -static int rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) +static bool rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; @@ -993,7 +993,7 @@ static const EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf(bContext *UNUSED /* Space Text Editor */ -static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value) +static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, bool value) { SpaceText *st = (SpaceText *)(ptr->data); @@ -1400,7 +1400,7 @@ static void rna_SpaceGraphEditor_display_mode_update(Main *UNUSED(bmain), Scene ED_area_tag_refresh(sa); } -static int rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr) +static bool rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr) { SpaceIpo *sipo = (SpaceIpo *)(ptr->data); return (BLI_listbase_is_empty(&sipo->ghostCurves) == false); @@ -1606,7 +1606,7 @@ static void rna_SpaceClipEditor_view_type_update(Main *UNUSED(bmain), Scene *UNU /* File browser. */ -static int rna_FileSelectParams_use_lib_get(PointerRNA *ptr) +static bool rna_FileSelectParams_use_lib_get(PointerRNA *ptr) { FileSelectParams *params = ptr->data; diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c index 1035a3f7f55..191c3355176 100644 --- a/source/blender/makesrna/intern/rna_text.c +++ b/source/blender/makesrna/intern/rna_text.c @@ -73,7 +73,7 @@ static void rna_Text_filename_set(PointerRNA *ptr, const char *value) text->name = NULL; } -static int rna_Text_modified_get(PointerRNA *ptr) +static bool rna_Text_modified_get(PointerRNA *ptr) { Text *text = (Text *)ptr->data; return BKE_text_file_modified_check(text) != 0; diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index b20f489af55..b2271c3903d 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -397,7 +397,7 @@ static const EnumPropertyItem *rna_TextureSlot_output_node_itemf( return item; } -static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) +static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, bool value) { Tex *tex = (Tex *)ptr->data; @@ -422,7 +422,7 @@ static void rna_Texture_use_nodes_update(bContext *C, PointerRNA *ptr) rna_Texture_nodes_update(CTX_data_main(C), CTX_data_scene(C), ptr); } -static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, int value) +static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, bool value) { Tex *tex = (Tex *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 0f7ebcc544f..deb40070fe9 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -208,14 +208,14 @@ static void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value) } } -static int rna_trackingTrack_select_get(PointerRNA *ptr) +static bool rna_trackingTrack_select_get(PointerRNA *ptr) { MovieTrackingTrack *track = (MovieTrackingTrack *)ptr->data; return TRACK_SELECTED(track); } -static void rna_trackingTrack_select_set(PointerRNA *ptr, int value) +static void rna_trackingTrack_select_set(PointerRNA *ptr, bool value) { MovieTrackingTrack *track = (MovieTrackingTrack *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 840fe86ea04..782d39bcb7e 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -797,22 +797,22 @@ static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value) /* UILayout */ -static int rna_UILayout_active_get(PointerRNA *ptr) +static bool rna_UILayout_active_get(PointerRNA *ptr) { return uiLayoutGetActive(ptr->data); } -static void rna_UILayout_active_set(PointerRNA *ptr, int value) +static void rna_UILayout_active_set(PointerRNA *ptr, bool value) { uiLayoutSetActive(ptr->data, value); } -static int rna_UILayout_alert_get(PointerRNA *ptr) +static bool rna_UILayout_alert_get(PointerRNA *ptr) { return uiLayoutGetRedAlert(ptr->data); } -static void rna_UILayout_alert_set(PointerRNA *ptr, int value) +static void rna_UILayout_alert_set(PointerRNA *ptr, bool value) { uiLayoutSetRedAlert(ptr->data, value); } @@ -827,12 +827,12 @@ static int rna_UILayout_op_context_get(PointerRNA *ptr) return uiLayoutGetOperatorContext(ptr->data); } -static int rna_UILayout_enabled_get(PointerRNA *ptr) +static bool rna_UILayout_enabled_get(PointerRNA *ptr) { return uiLayoutGetEnabled(ptr->data); } -static void rna_UILayout_enabled_set(PointerRNA *ptr, int value) +static void rna_UILayout_enabled_set(PointerRNA *ptr, bool value) { uiLayoutSetEnabled(ptr->data, value); } @@ -843,12 +843,12 @@ static int rna_UILayout_red_alert_get(PointerRNA *ptr) return uiLayoutGetRedAlert(ptr->data); } -static void rna_UILayout_red_alert_set(PointerRNA *ptr, int value) +static void rna_UILayout_red_alert_set(PointerRNA *ptr, bool value) { uiLayoutSetRedAlert(ptr->data, value); } -static int rna_UILayout_keep_aspect_get(PointerRNA *ptr) +static bool rna_UILayout_keep_aspect_get(PointerRNA *ptr) { return uiLayoutGetKeepAspect(ptr->data); } diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 44e01cf8d44..8930c144f17 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -518,7 +518,7 @@ static int rna_Operator_name_length(PointerRNA *ptr) return strlen(op->type->name); } -static int rna_Operator_has_reports_get(PointerRNA *ptr) +static bool rna_Operator_has_reports_get(PointerRNA *ptr) { wmOperator *op = (wmOperator *)ptr->data; return (op->reports && op->reports->list.first); @@ -590,7 +590,7 @@ static float rna_Event_pressure_get(PointerRNA *ptr) return WM_event_tablet_data(event, NULL, NULL); } -static int rna_Event_is_tablet_get(PointerRNA *ptr) +static bool rna_Event_is_tablet_get(PointerRNA *ptr) { const wmEvent *event = ptr->data; return WM_event_is_tablet(event); @@ -785,7 +785,7 @@ static const EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, Point return rna_enum_keymap_propvalue_items; /* ERROR */ } -static int rna_KeyMapItem_any_get(PointerRNA *ptr) +static bool rna_KeyMapItem_any_get(PointerRNA *ptr) { wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; @@ -801,7 +801,7 @@ static int rna_KeyMapItem_any_get(PointerRNA *ptr) } } -static void rna_KeyMapItem_any_set(PointerRNA *ptr, int value) +static void rna_KeyMapItem_any_set(PointerRNA *ptr, bool value) { wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; @@ -813,25 +813,25 @@ static void rna_KeyMapItem_any_set(PointerRNA *ptr, int value) } } -static int rna_KeyMapItem_shift_get(PointerRNA *ptr) +static bool rna_KeyMapItem_shift_get(PointerRNA *ptr) { wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; return kmi->shift != 0; } -static int rna_KeyMapItem_ctrl_get(PointerRNA *ptr) +static bool rna_KeyMapItem_ctrl_get(PointerRNA *ptr) { wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; return kmi->ctrl != 0; } -static int rna_KeyMapItem_alt_get(PointerRNA *ptr) +static bool rna_KeyMapItem_alt_get(PointerRNA *ptr) { wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; return kmi->alt != 0; } -static int rna_KeyMapItem_oskey_get(PointerRNA *ptr) +static bool rna_KeyMapItem_oskey_get(PointerRNA *ptr) { wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; return kmi->oskey != 0; @@ -902,7 +902,7 @@ static int rna_wmKeyMapItem_name_length(PointerRNA *ptr) return strlen(ot ? RNA_struct_ui_name(ot->srna) : kmi->idname); } -static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr) +static bool rna_KeyMapItem_userdefined_get(PointerRNA *ptr) { wmKeyMapItem *kmi = ptr->data; return kmi->id < 0; -- cgit v1.2.3 From 52655f51619d0ab06bbde6966c31d15f6ab4ab19 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 22:49:42 +0200 Subject: Cleanup: flag checks --- source/blender/compositor/intern/COM_compositor.cpp | 2 +- source/blender/editors/physics/physics_fluid.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index 4599832b433..ae9defa786e 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -88,7 +88,7 @@ void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rende editingtree->progress(editingtree->prh, 0.0); editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing")); - bool twopass = (editingtree->flag & NTREE_TWO_PASS) > 0 && !rendering; + bool twopass = (editingtree->flag & NTREE_TWO_PASS) && !rendering; /* initialize execution system */ if (twopass) { ExecutionSystem *system = new ExecutionSystem(rd, scene, editingtree, rendering, twopass, viewSettings, displaySettings, viewName); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index c76c04c1e99..1cd2528b3ca 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -430,7 +430,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid for (fobj=fobjects->first; fobj; fobj=fobj->next) { Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - float active= (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) > 0 ? 1 : 0); + float active = (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) ? 1 : 0); float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f}; if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) -- cgit v1.2.3 From 08ae597d63d2e89888ae937c35357b2de62d7a8e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2018 22:56:18 +0200 Subject: Cleanup: flag checks --- source/blender/draw/engines/eevee/eevee_private.h | 2 +- .../eevee/shaders/ambient_occlusion_lib.glsl | 2 +- .../draw/engines/workbench/workbench_data.c | 2 +- .../draw/engines/workbench/workbench_deferred.c | 2 +- .../draw/modes/shaders/object_grid_frag.glsl | 33 ++++++++++++---------- .../draw/modes/shaders/object_grid_vert.glsl | 8 +++--- source/blender/makesrna/intern/rna_space.c | 5 ++-- source/blender/makesrna/intern/rna_userdef.c | 2 +- 8 files changed, 30 insertions(+), 26 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index d077668197d..c2f9d16361d 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -94,7 +94,7 @@ extern struct DrawEngineType draw_engine_eevee_type; #define OVERLAY_ENABLED(v3d) ((v3d) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) #define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->drawtype == OB_MATERIAL)) -#define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && ((v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV) > 0)) +#define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && (v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV)) #define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHT)))) /* World shader variations */ diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl index 9d27224b5c9..fae310be90b 100644 --- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl @@ -246,7 +246,7 @@ float gtao_multibounce(float visibility, vec3 albedo) float occlusion_compute(vec3 N, vec3 vpos, float user_occlusion, vec4 rand, out vec3 bent_normal) { #ifndef USE_REFRACTION - if ((int(aoSettings) & USE_AO) > 0) { + if ((int(aoSettings) & USE_AO) != 0) { float visibility; vec3 vnor = mat3(ViewMatrix) * N; diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index 4c68e41d010..1f5a1e17277 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -40,7 +40,7 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity; WORKBENCH_UBO_World *wd = &wpd->world_data; - wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) > 0; + wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0; wd->background_alpha = 1.0f; if ((v3d->flag3 & V3D_SHOW_WORLD) && diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 1307f1c4446..d153728a000 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -720,7 +720,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) } } - if (SHADOW_ENABLED(wpd) && (ob->display.flag & OB_SHOW_SHADOW) > 0) { + if (SHADOW_ENABLED(wpd) && (ob->display.flag & OB_SHOW_SHADOW)) { bool is_manifold; struct Gwn_Batch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold); if (geom_shadow) { diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl index 2b04bb0d855..82780e0cddc 100644 --- a/source/blender/draw/modes/shaders/object_grid_frag.glsl +++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl @@ -113,12 +113,15 @@ void main() viewvec /= dist; float angle; - if ((gridFlag & PLANE_XZ) > 0) + if ((gridFlag & PLANE_XZ) != 0) { angle = viewvec.y; - else if ((gridFlag & PLANE_YZ) > 0) + } + else if ((gridFlag & PLANE_YZ) != 0) { angle = viewvec.x; - else + } + else { angle = viewvec.z; + } angle = 1.0 - abs(angle); angle *= angle; @@ -130,7 +133,7 @@ void main() fade = 1.0 - smoothstep(0.0, 0.5, dist - 0.5); dist = 1.0; /* avoid branch after */ - if ((gridFlag & PLANE_XY) > 0) { + if ((gridFlag & PLANE_XY) != 0) { float angle = 1.0 - abs(eye.z); dist = 1.0 + angle * 2.0; angle *= angle; @@ -138,7 +141,7 @@ void main() } } - if ((gridFlag & GRID) > 0) { + if ((gridFlag & GRID) != 0) { float grid_res = log(dist * gridResolution) * gridOneOverLogSubdiv; float blend = fract(-max(grid_res, 0.0)); @@ -150,11 +153,11 @@ void main() float scaleC = gridScale * pow(gridSubdiv, max(lvl + 1.0, 1.0)); vec2 grid_pos, grid_fwidth; - if ((gridFlag & PLANE_XZ) > 0) { + if ((gridFlag & PLANE_XZ) != 0) { grid_pos = wPos.xz; grid_fwidth = fwidthPos.xz; } - else if ((gridFlag & PLANE_YZ) > 0) { + else if ((gridFlag & PLANE_YZ) != 0) { grid_pos = wPos.yz; grid_fwidth = fwidthPos.yz; } @@ -175,19 +178,19 @@ void main() FragColor = vec4(colorGrid.rgb, 0.0); } - if ((gridFlag & (AXIS_X | AXIS_Y | AXIS_Z)) > 0) { + if ((gridFlag & (AXIS_X | AXIS_Y | AXIS_Z)) != 0) { /* Setup axes 'domains' */ vec3 axes_dist, axes_fwidth; - if ((gridFlag & AXIS_X) > 0) { + if ((gridFlag & AXIS_X) != 0) { axes_dist.x = dot(wPos.yz, planeAxes.yz); axes_fwidth.x = dot(fwidthPos.yz, planeAxes.yz); } - if ((gridFlag & AXIS_Y) > 0) { + if ((gridFlag & AXIS_Y) != 0) { axes_dist.y = dot(wPos.xz, planeAxes.xz); axes_fwidth.y = dot(fwidthPos.xz, planeAxes.xz); } - if ((gridFlag & AXIS_Z) > 0) { + if ((gridFlag & AXIS_Z) != 0) { axes_dist.z = dot(wPos.xy, planeAxes.xy); axes_fwidth.z = dot(fwidthPos.xy, planeAxes.xy); } @@ -195,19 +198,19 @@ void main() /* Computing all axes at once using vec3 */ vec3 axes = get_axes(axes_dist, axes_fwidth, 0.1); - if ((gridFlag & AXIS_X) > 0) { + if ((gridFlag & AXIS_X) != 0) { FragColor = mix(FragColor, colorGridAxisX, axes.x); } - if ((gridFlag & AXIS_Y) > 0) { + if ((gridFlag & AXIS_Y) != 0) { FragColor = mix(FragColor, colorGridAxisY, axes.y); } - if ((gridFlag & AXIS_Z) > 0) { + if ((gridFlag & AXIS_Z) != 0) { FragColor = mix(FragColor, colorGridAxisZ, axes.z); } } float scene_depth = texture(depthBuffer, sPos).r; - if ((gridFlag & GRID_BACK) > 0) { + if ((gridFlag & GRID_BACK) != 0) { fade *= (scene_depth == 1.0) ? 1.0 : 0.0; } else { diff --git a/source/blender/draw/modes/shaders/object_grid_vert.glsl b/source/blender/draw/modes/shaders/object_grid_vert.glsl index 3f99d8b5d0a..a346973a597 100644 --- a/source/blender/draw/modes/shaders/object_grid_vert.glsl +++ b/source/blender/draw/modes/shaders/object_grid_vert.glsl @@ -27,11 +27,11 @@ void main() vec3 vert_pos, proj_camera_pos; /* Project camera pos to the needed plane */ - if ((gridFlag & PLANE_XY) > 0) { + if ((gridFlag & PLANE_XY) != 0) { vert_pos = vec3(pos.x, pos.y, 0.0); proj_camera_pos = vec3(cameraPos.x, cameraPos.y, 0.0); } - else if ((gridFlag & PLANE_XZ) > 0) { + else if ((gridFlag & PLANE_XZ) != 0) { vert_pos = vec3(pos.x, 0.0, pos.y); proj_camera_pos = vec3(cameraPos.x, 0.0, cameraPos.z); } @@ -52,10 +52,10 @@ void main() vec3 realPos = proj_camera_pos + vert_pos; /* Used for additional Z axis */ - if ((gridFlag & CLIP_Z_POS) > 0) { + if ((gridFlag & CLIP_Z_POS) != 0) { realPos.z = max(realPos.z, 0.0); } - if ((gridFlag & CLIP_Z_NEG) > 0) { + if ((gridFlag & CLIP_Z_NEG) != 0) { realPos.z = min(-realPos.z, 0.0); } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 6a368fa4b41..92913e29f69 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -853,11 +853,12 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf( switch (v3d->drawtype) { case OB_SOLID: case OB_TEXTURE: - show_studiolight = (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) > 0; + show_studiolight = ( + (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) != 0); break; case OB_MATERIAL: - show_studiolight = (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) > 0; + show_studiolight = ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) != 0); icon_id = sl->icon_id_radiance; break; } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 364a5694a07..9cde04c560e 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -761,7 +761,7 @@ static int rna_UserDef_studiolight_index_get(PointerRNA *ptr) static bool rna_UserDef_studiolight_is_user_defined_get(PointerRNA *ptr) { StudioLight *sl = (StudioLight *)ptr->data; - return (sl->flag & STUDIOLIGHT_USER_DEFINED) > 0; + return (sl->flag & STUDIOLIGHT_USER_DEFINED) != 0; } /* StudioLight.orientation */ -- cgit v1.2.3 From 88a6aab8bbce423e042419fe26891bf8c5fbf84e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 6 Jul 2018 15:01:28 +1200 Subject: Fix T55775: Crash when select keyframe on object channels in Timeline editor --- source/blender/editors/space_action/action_select.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index b6431596323..c46d0fdb035 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -1369,7 +1369,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ rctf rectf; /* get dopesheet info */ - if (ac->datatype == ANIMCONT_DOPESHEET) + if (ELEM(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) ads = ac->data; /* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */ @@ -1490,7 +1490,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ deselect_action_keys(ac, 0, SELECT_SUBTRACT); /* highlight channel clicked on */ - if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) { + if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) { /* deselect all other channels first */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); -- cgit v1.2.3 From a71c2deac5d1a80d802fb646474da2256d73d79f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 6 Jul 2018 15:15:45 +1200 Subject: Fix T55777: Non-selected keys in Graph Editor are invisible Restore theem setting default for Graph Editor's vertex, with default alpha set to 1.0. The alpha value here needs to be non-zero, as the alpha values currently get used when drawing verts. --- release/datafiles/userdef/userdef_default_theme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 04a34cfd1ae..f7a4bd157e0 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -424,6 +424,7 @@ const bTheme U_theme_default = { .grid = RGBA(0x1a1a1aff), .group = RGBA(0x44992eff), .group_active = RGBA(0x5ccd3eff), + .vertex = RGBA(0x000000ff), .vertex_select = RGBA(0xff8500ff), .cframe = RGBA(0x308837ff), .lastsel_point = RGBA(0xffffffff), -- cgit v1.2.3 From 288bcb2593f52c47225da9ea8efe13d288d35892 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 6 Jul 2018 15:38:25 +1200 Subject: Further tweaks to drawing of non-selected graph editor keyframes The previous commit only solves the problem when using the default theme using factory settings. For previously saved themes, there could still be problems, as the alpha values were still 0. This commit improves the logic here so that while keyframe points on unselected F-Curves will still get faded out (to not stick out too much from the curves they live on), but the effect will not be as pronounced (i.e. the points will stay visible all the time). --- source/blender/editors/space_graph/graph_draw.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index b08ff8dcfa1..4e9f8cd3733 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -148,21 +148,27 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) /* helper func - set color to draw F-Curve data with */ static void set_fcurve_vertex_color(FCurve *fcu, bool sel) { - /* Fade the 'intensity' of the vertices based on the selection of the curves too */ - int alphaOffset = (int)((fcurve_display_alpha(fcu) - 1.0f) * 255); - float color[4]; + float diff; /* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */ if ((fcu->flag & FCURVE_PROTECTED) == 0) { /* Curve's points ARE BEING edited */ - UI_GetThemeColorShadeAlpha4fv(sel ? TH_VERTEX_SELECT : TH_VERTEX, 0, alphaOffset, color); + UI_GetThemeColor3fv(sel ? TH_VERTEX_SELECT : TH_VERTEX, color); } else { /* Curve's points CANNOT BE edited */ - UI_GetThemeColorShadeAlpha4fv(sel ? TH_TEXT_HI : TH_TEXT, 0, alphaOffset, color); + UI_GetThemeColor3fv(sel ? TH_TEXT_HI : TH_TEXT, color); } + /* Fade the 'intensity' of the vertices based on the selection of the curves too + * - Only fade by 50% the amount the curves were faded by, so that the points + * still stand out for easier selection + */ + diff = 1.0f - fcurve_display_alpha(fcu); + color[3] = 1.0f - (diff * 0.5f); + CLAMP(color[3], 0.2f, 1.0f); + immUniformColor4fv(color); } -- cgit v1.2.3 From d56b90705e81768ca1a586b622ef4bbe3b216d5c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 07:55:29 +0200 Subject: BKE_addons: utility to remove by name --- source/blender/blenkernel/BKE_addon.h | 1 + source/blender/blenkernel/intern/addon.c | 11 +++++++++++ source/blender/editors/interface/resources.c | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/BKE_addon.h b/source/blender/blenkernel/BKE_addon.h index 3af6d3b61bf..a463525d644 100644 --- a/source/blender/blenkernel/BKE_addon.h +++ b/source/blender/blenkernel/BKE_addon.h @@ -53,6 +53,7 @@ void BKE_addon_pref_type_free(void); struct bAddon *BKE_addon_new(void); struct bAddon *BKE_addon_find(struct ListBase *addon_list, const char *module); struct bAddon *BKE_addon_ensure(struct ListBase *addon_list, const char *module); +bool BKE_addon_remove_safe(struct ListBase *addon_list, const char *module); void BKE_addon_free(struct bAddon *addon); #endif /* __BKE_ADDON_H__ */ diff --git a/source/blender/blenkernel/intern/addon.c b/source/blender/blenkernel/intern/addon.c index a9bb193a7a1..854bf62c061 100644 --- a/source/blender/blenkernel/intern/addon.c +++ b/source/blender/blenkernel/intern/addon.c @@ -69,6 +69,17 @@ bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module) return addon; } +bool BKE_addon_remove_safe(ListBase *addon_list, const char *module) +{ + bAddon *addon = BLI_findstring(addon_list, module, offsetof(bAddon, module)); + if (addon) { + BLI_remlink(addon_list, addon); + BKE_addon_free(addon); + return true; + } + return false; +} + void BKE_addon_free(bAddon *addon) { if (addon->prop) { diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index b9da0923e07..77c36bf47f3 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -2788,11 +2788,7 @@ void init_userdef_do_versions(Main *bmain) /* Not versioning, just avoid errors. */ #ifndef WITH_CYCLES - bAddon *addon = BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module)); - if (addon) { - BLI_remlink(&U.addons, addon); - BKE_addon_free(addon); - } + BKE_addon_remove_safe(&U.addons, "cycles"); #endif /* funny name, but it is GE stuff, moves userdef stuff to engine */ -- cgit v1.2.3 From 3314d0bcb65d8c74cd0caccc4e10fb425da2154b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 08:02:20 +0200 Subject: Disable addons which haven't been updated Gave noisy warnings on startup. --- .../blender/blenloader/intern/versioning_defaults.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 860d1432370..e4b1ccd1d2b 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -44,6 +44,7 @@ #include "DNA_object_types.h" #include "DNA_workspace_types.h" +#include "BKE_addon.h" #include "BKE_brush.h" #include "BKE_library.h" #include "BKE_main.h" @@ -95,6 +96,24 @@ void BLO_update_defaults_userpref_blend(void) U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE; #endif + /* XXX, until these are working w/ 2.8x. */ + { + const char *addon_id_remove[] = { + "io_anim_bvh", + "io_curve_svg", + "io_mesh_ply", + "io_mesh_stl", + "io_mesh_uv_layout", + "io_scene_3ds", + "io_scene_fbx", + "io_scene_obj", + "io_scene_x3d", + }; + for (int i = 0; i < ARRAY_SIZE(addon_id_remove); i++) { + BKE_addon_remove_safe(&U.addons, addon_id_remove[i]); + } + } + /* Ignore the theme saved in the blend file, * instead use the theme from 'userdef_default_theme.c' */ { -- cgit v1.2.3 From 27e0d6cbd03db5d6eeead80953842968b1343e25 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 09:10:07 +0200 Subject: Fix image drag and drop - Dropping now creates empty images w/o holding Ctrl. - Dropping background images works when cursor over camera. --- source/blender/editors/space_view3d/space_view3d.c | 23 ++++++++++++-- source/blender/editors/space_view3d/view3d_edit.c | 35 +++++++++++++++------- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 77beadccd5d..15d241a88cc 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -596,10 +596,23 @@ static bool view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEven return 0; } +static bool view3d_ima_bg_is_camera_view(bContext *C) +{ + RegionView3D *rv3d = CTX_wm_region_view3d(C); + if ((rv3d && (rv3d->persp == RV3D_CAMOB))) { + View3D *v3d = CTX_wm_view3d(C); + if (v3d && v3d->camera && v3d->camera->type == OB_CAMERA) { + return true; + } + } + return false; +} + static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { - if (event->ctrl) - return false; + if (view3d_ima_bg_is_camera_view(C)) { + return true; + } if (!ED_view3d_give_base_under_cursor(C, event->mval)) { return view3d_ima_drop_poll(C, drag, event); @@ -609,10 +622,14 @@ static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *ev static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { + if (!view3d_ima_bg_is_camera_view(C)) { + return true; + } + Base *base = ED_view3d_give_base_under_cursor(C, event->mval); /* either holding and ctrl and no object, or dropping to empty */ - if (((base == NULL) && event->ctrl) || + if ((base == NULL) || ((base != NULL) && base->object->type == OB_EMPTY)) { return view3d_ima_drop_poll(C, drag, event); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 0078988e1b0..d4c2f5babb1 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4427,30 +4427,40 @@ void VIEW3D_OT_navigate(wmOperatorType *ot) /** \name Background Image Add Operator * \{ */ -static CameraBGImage *background_image_add(bContext *C) -{ - Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data; - return BKE_camera_background_image_new(cam); +static Camera *background_image_camera_from_context(bContext *C) +{ + /* Needed to support drag-and-drop & camera buttons context. */ + View3D *v3d = CTX_wm_view3d(C); + if (v3d != NULL) { + if (v3d->camera && v3d->camera->data && v3d->camera->type == OB_CAMERA) { + return v3d->camera->data; + } + return NULL; + } + else { + return CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data; + } } static int background_image_add_exec(bContext *C, wmOperator *UNUSED(op)) { - background_image_add(C); + Camera *cam = background_image_camera_from_context(C); + BKE_camera_background_image_new(cam); return OPERATOR_FINISHED; } static int background_image_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data; + Camera *cam = background_image_camera_from_context(C); Image *ima; CameraBGImage *bgpic; ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM); /* may be NULL, continue anyway */ - bgpic = background_image_add(C); + bgpic = BKE_camera_background_image_new(cam); bgpic->ima = ima; cam->flag |= CAM_SHOW_BG_IMAGE; @@ -4460,19 +4470,24 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, const wmEven return OPERATOR_FINISHED; } +static bool background_image_add_poll(bContext *C) +{ + return background_image_camera_from_context(C) != NULL; +} + void VIEW3D_OT_background_image_add(wmOperatorType *ot) { /* identifiers */ /* note: having key shortcut here is bad practice, * but for now keep because this displays when dragging an image over the 3D viewport */ - ot->name = "Add Background Image (Ctrl for Empty Object)"; - ot->description = "Add a new background image (Ctrl for Empty Object)"; + ot->name = "Add Background Image"; + ot->description = "Add a new background image"; ot->idname = "VIEW3D_OT_background_image_add"; /* api callbacks */ ot->invoke = background_image_add_invoke; ot->exec = background_image_add_exec; - ot->poll = ED_operator_camera; + ot->poll = background_image_add_poll; /* flags */ ot->flag = OPTYPE_UNDO; -- cgit v1.2.3 From ed2204933ad2a8f5b012ebc457c2e2576b006cac Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 10:01:05 +0200 Subject: Fix typo in empty image drawing --- release/scripts/startup/bl_ui/properties_data_empty.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_data_empty.py b/release/scripts/startup/bl_ui/properties_data_empty.py index 1da3d9621aa..ab12d0f5c5f 100644 --- a/release/scripts/startup/bl_ui/properties_data_empty.py +++ b/release/scripts/startup/bl_ui/properties_data_empty.py @@ -50,7 +50,7 @@ class DATA_PT_empty(DataButtonsPanel, Panel): row = layout.row(align=True) layout.prop(ob, "color", text="Transparency", index=3, slider=True) - col = layout.col(align=True) + col = layout.column(align=True) col.prop(ob, "empty_image_offset", text="Offset X", index=0) col.prop(ob, "empty_image_offset", text="Y", index=1) -- cgit v1.2.3 From 62fbb7d4a10bea1ce88a486657a87743b93c9fd1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 10:05:14 +0200 Subject: Empty Object: Center images by default --- source/blender/blenkernel/intern/object.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index eeb0ab22bd6..86326655cfe 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -619,6 +619,9 @@ void BKE_object_init(Object *ob) ob->dt = OB_TEXTURE; ob->empty_drawtype = OB_PLAINAXES; ob->empty_drawsize = 1.0; + if (ob->type == OB_EMPTY) { + copy_v2_fl(ob->ima_ofs, -0.5f); + } if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { ob->trackflag = OB_NEGZ; -- cgit v1.2.3 From 6d38d824377c55aaaed7e8283e81a7128bf6f728 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 10:16:28 +0200 Subject: Cycles: missed when renaming updated RNA --- intern/cycles/blender/blender_sync.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 80aa68d9756..b449302241d 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -121,9 +121,9 @@ void BlenderSync::sync_recalc(BL::Depsgraph& b_depsgraph) /* Object */ else if (b_id.is_a(&RNA_Object)) { BL::Object b_ob(b_id); - const bool updated_geometry = b_update->updated_geometry(); + const bool updated_geometry = !b_update->is_dirty_geometry(); - if (b_update->updated_transform()) { + if (!b_update->is_dirty_transform()) { object_map.set_recalc(b_ob); light_map.set_recalc(b_ob); } -- cgit v1.2.3 From 1daa20ad9f6f0c433a4e0a97a74e5beb9ea4e2c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 10:17:58 +0200 Subject: Cleanup: strip trailing space for cycles --- intern/cycles/app/cycles_cubin_cc.cpp | 2 +- intern/cycles/app/cycles_server.cpp | 1 - intern/cycles/app/cycles_standalone.cpp | 1 - intern/cycles/app/cycles_xml.cpp | 3 +- intern/cycles/app/io_export_cycles_xml.py | 22 +++---- intern/cycles/blender/blender_camera.cpp | 5 +- intern/cycles/blender/blender_object.cpp | 13 ++-- intern/cycles/blender/blender_object_cull.cpp | 1 - intern/cycles/blender/blender_particles.cpp | 2 +- intern/cycles/blender/blender_python.cpp | 4 +- intern/cycles/blender/blender_shader.cpp | 11 ++-- intern/cycles/blender/blender_sync.cpp | 15 ++--- intern/cycles/blender/blender_sync.h | 1 - intern/cycles/bvh/bvh_binning.cpp | 1 - intern/cycles/bvh/bvh_node.cpp | 5 +- intern/cycles/bvh/bvh_sort.cpp | 1 - intern/cycles/device/device.h | 7 +- intern/cycles/device/device_intern.h | 1 - intern/cycles/device/device_memory.cpp | 1 - intern/cycles/device/device_memory.h | 3 +- intern/cycles/device/device_multi.cpp | 1 - intern/cycles/device/device_network.cpp | 2 - intern/cycles/device/device_network.h | 7 +- intern/cycles/device/device_split_kernel.cpp | 4 +- intern/cycles/device/device_split_kernel.h | 3 - intern/cycles/device/device_task.cpp | 1 - intern/cycles/device/device_task.h | 1 - intern/cycles/device/opencl/memory_manager.cpp | 1 - intern/cycles/device/opencl/memory_manager.h | 1 - intern/cycles/doc/license/Apache_2.0.txt | 1 - intern/cycles/doc/license/ILM.txt | 3 +- intern/cycles/doc/license/NVidia.txt | 1 - intern/cycles/doc/license/OSL.txt | 1 - intern/cycles/doc/license/Sobol.txt | 1 - intern/cycles/doc/license/readme.txt | 1 - intern/cycles/graph/node.cpp | 1 - intern/cycles/graph/node.h | 1 - intern/cycles/graph/node_enum.h | 1 - intern/cycles/graph/node_type.cpp | 1 - intern/cycles/graph/node_type.h | 1 - intern/cycles/graph/node_xml.cpp | 1 - intern/cycles/graph/node_xml.h | 1 - intern/cycles/kernel/closure/bsdf.h | 1 - .../cycles/kernel/closure/bsdf_ashikhmin_shirley.h | 2 +- .../cycles/kernel/closure/bsdf_ashikhmin_velvet.h | 5 +- intern/cycles/kernel/closure/bsdf_diffuse.h | 3 +- intern/cycles/kernel/closure/bsdf_diffuse_ramp.h | 4 +- intern/cycles/kernel/closure/bsdf_hair.h | 1 - intern/cycles/kernel/closure/bsdf_microfacet.h | 11 ++-- intern/cycles/kernel/closure/bsdf_phong_ramp.h | 10 +-- .../kernel/closure/bsdf_principled_diffuse.h | 2 - .../cycles/kernel/closure/bsdf_principled_sheen.h | 2 - intern/cycles/kernel/closure/bsdf_reflection.h | 1 - intern/cycles/kernel/closure/bsdf_refraction.h | 1 - intern/cycles/kernel/closure/bsdf_toon.h | 11 ++-- intern/cycles/kernel/closure/bsdf_transparent.h | 1 - intern/cycles/kernel/closure/bsdf_util.h | 5 +- intern/cycles/kernel/closure/bssrdf.h | 1 - intern/cycles/kernel/closure/emissive.h | 3 +- intern/cycles/kernel/closure/volume.h | 2 +- intern/cycles/kernel/geom/geom.h | 1 - intern/cycles/kernel/geom/geom_attribute.h | 5 +- intern/cycles/kernel/geom/geom_motion_curve.h | 1 - intern/cycles/kernel/geom/geom_motion_triangle.h | 4 +- .../kernel/geom/geom_motion_triangle_shader.h | 1 - intern/cycles/kernel/geom/geom_object.h | 1 - intern/cycles/kernel/geom/geom_patch.h | 1 - intern/cycles/kernel/geom/geom_primitive.h | 3 +- intern/cycles/kernel/geom/geom_subd_triangle.h | 1 - intern/cycles/kernel/geom/geom_volume.h | 1 - intern/cycles/kernel/kernel.h | 1 - intern/cycles/kernel/kernel_accumulate.h | 2 +- intern/cycles/kernel/kernel_bake.h | 1 - intern/cycles/kernel/kernel_compat_cpu.h | 1 - intern/cycles/kernel/kernel_compat_opencl.h | 1 - intern/cycles/kernel/kernel_differential.h | 1 - intern/cycles/kernel/kernel_emission.h | 3 +- intern/cycles/kernel/kernel_film.h | 1 - intern/cycles/kernel/kernel_jitter.h | 1 - intern/cycles/kernel/kernel_light.h | 2 +- intern/cycles/kernel/kernel_montecarlo.h | 2 +- intern/cycles/kernel/kernel_passes.h | 5 +- intern/cycles/kernel/kernel_path.h | 1 - intern/cycles/kernel/kernel_path_state.h | 1 - intern/cycles/kernel/kernel_path_subsurface.h | 1 - intern/cycles/kernel/kernel_path_surface.h | 1 - intern/cycles/kernel/kernel_path_volume.h | 7 +- intern/cycles/kernel/kernel_projection.h | 2 +- intern/cycles/kernel/kernel_random.h | 1 - intern/cycles/kernel/kernel_subsurface.h | 3 +- intern/cycles/kernel/kernel_textures.h | 1 - intern/cycles/kernel/kernel_types.h | 7 +- intern/cycles/kernel/kernel_volume.h | 12 ++-- intern/cycles/kernel/kernels/cpu/kernel_split.cpp | 1 - intern/cycles/kernel/kernels/cuda/kernel_config.h | 1 - .../cycles/kernel/kernels/cuda/kernel_cuda_image.h | 1 - .../kernel/kernels/opencl/kernel_split_function.h | 1 - intern/cycles/kernel/osl/background.cpp | 3 +- intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp | 3 +- intern/cycles/kernel/osl/bsdf_phong_ramp.cpp | 3 +- intern/cycles/kernel/osl/emissive.cpp | 3 +- intern/cycles/kernel/osl/osl_bssrdf.cpp | 3 +- intern/cycles/kernel/osl/osl_closures.cpp | 3 +- intern/cycles/kernel/osl/osl_closures.h | 3 +- intern/cycles/kernel/osl/osl_globals.h | 1 - intern/cycles/kernel/osl/osl_services.cpp | 10 +-- intern/cycles/kernel/osl/osl_services.h | 9 ++- intern/cycles/kernel/osl/osl_shader.cpp | 5 +- intern/cycles/kernel/osl/osl_shader.h | 1 - intern/cycles/kernel/shaders/node_color.h | 3 +- intern/cycles/kernel/shaders/node_fresnel.h | 3 +- intern/cycles/kernel/shaders/node_ramp_util.h | 2 +- intern/cycles/kernel/shaders/node_texture.h | 13 ++-- intern/cycles/kernel/shaders/stdosl.h | 4 +- intern/cycles/kernel/split/kernel_branched.h | 1 - intern/cycles/kernel/split/kernel_lamp_emission.h | 1 - .../cycles/kernel/split/kernel_shadow_blocked_ao.h | 1 - intern/cycles/kernel/svm/svm.h | 1 - intern/cycles/kernel/svm/svm_attribute.h | 1 - intern/cycles/kernel/svm/svm_bevel.h | 1 - intern/cycles/kernel/svm/svm_brick.h | 21 +++--- intern/cycles/kernel/svm/svm_bump.h | 1 - intern/cycles/kernel/svm/svm_camera.h | 1 - intern/cycles/kernel/svm/svm_checker.h | 5 +- intern/cycles/kernel/svm/svm_closure.h | 7 +- intern/cycles/kernel/svm/svm_color_util.h | 9 ++- intern/cycles/kernel/svm/svm_convert.h | 1 - intern/cycles/kernel/svm/svm_displace.h | 1 - intern/cycles/kernel/svm/svm_fresnel.h | 3 +- intern/cycles/kernel/svm/svm_geometry.h | 1 - intern/cycles/kernel/svm/svm_gradient.h | 3 +- intern/cycles/kernel/svm/svm_hsv.h | 1 - intern/cycles/kernel/svm/svm_image.h | 1 - intern/cycles/kernel/svm/svm_invert.h | 1 - intern/cycles/kernel/svm/svm_light_path.h | 1 - intern/cycles/kernel/svm/svm_magic.h | 1 - intern/cycles/kernel/svm/svm_mapping.h | 1 - intern/cycles/kernel/svm/svm_math.h | 1 - intern/cycles/kernel/svm/svm_math_util.h | 3 +- intern/cycles/kernel/svm/svm_mix.h | 1 - intern/cycles/kernel/svm/svm_musgrave.h | 3 +- intern/cycles/kernel/svm/svm_noise.h | 5 +- intern/cycles/kernel/svm/svm_noisetex.h | 1 - intern/cycles/kernel/svm/svm_normal.h | 1 - intern/cycles/kernel/svm/svm_ramp.h | 1 - intern/cycles/kernel/svm/svm_ramp_util.h | 1 - intern/cycles/kernel/svm/svm_sepcomb_hsv.h | 9 ++- intern/cycles/kernel/svm/svm_sepcomb_vector.h | 1 - intern/cycles/kernel/svm/svm_sky.h | 19 +++--- intern/cycles/kernel/svm/svm_tex_coord.h | 3 +- intern/cycles/kernel/svm/svm_texture.h | 1 - intern/cycles/kernel/svm/svm_types.h | 3 +- intern/cycles/kernel/svm/svm_value.h | 1 - intern/cycles/kernel/svm/svm_vector_transform.h | 19 +++--- intern/cycles/kernel/svm/svm_voronoi.h | 1 - intern/cycles/kernel/svm/svm_wave.h | 1 - intern/cycles/kernel/svm/svm_wavelength.h | 11 ++-- intern/cycles/kernel/svm/svm_wireframe.h | 3 +- intern/cycles/render/attribute.cpp | 9 ++- intern/cycles/render/attribute.h | 1 - intern/cycles/render/background.cpp | 3 +- intern/cycles/render/background.h | 1 - intern/cycles/render/bake.h | 1 - intern/cycles/render/buffers.cpp | 1 - intern/cycles/render/buffers.h | 1 - intern/cycles/render/camera.cpp | 2 +- intern/cycles/render/camera.h | 3 +- intern/cycles/render/constant_fold.h | 1 - intern/cycles/render/curves.cpp | 1 - intern/cycles/render/curves.h | 1 - intern/cycles/render/film.cpp | 9 ++- intern/cycles/render/film.h | 1 - intern/cycles/render/graph.cpp | 19 +++--- intern/cycles/render/graph.h | 3 +- intern/cycles/render/image.cpp | 1 - intern/cycles/render/image.h | 1 - intern/cycles/render/integrator.cpp | 5 +- intern/cycles/render/integrator.h | 3 +- intern/cycles/render/light.cpp | 5 +- intern/cycles/render/light.h | 1 - intern/cycles/render/mesh.h | 1 - intern/cycles/render/mesh_displace.cpp | 5 +- intern/cycles/render/mesh_subdivision.cpp | 1 - intern/cycles/render/nodes.cpp | 74 +++++++++++----------- intern/cycles/render/nodes.h | 1 - intern/cycles/render/object.cpp | 5 +- intern/cycles/render/object.h | 1 - intern/cycles/render/osl.cpp | 15 ++--- intern/cycles/render/osl.h | 1 - intern/cycles/render/particles.cpp | 19 +++--- intern/cycles/render/particles.h | 1 - intern/cycles/render/scene.cpp | 3 +- intern/cycles/render/scene.h | 1 - intern/cycles/render/session.cpp | 6 +- intern/cycles/render/session.h | 1 - intern/cycles/render/shader.cpp | 11 ++-- intern/cycles/render/shader.h | 3 +- intern/cycles/render/sobol.cpp | 23 ++++--- intern/cycles/render/sobol.h | 1 - intern/cycles/render/svm.cpp | 21 +++--- intern/cycles/render/svm.h | 1 - intern/cycles/render/tables.cpp | 1 - intern/cycles/render/tables.h | 1 - intern/cycles/render/tile.cpp | 1 - intern/cycles/render/tile.h | 1 - intern/cycles/subd/subd_dice.cpp | 1 - intern/cycles/subd/subd_dice.h | 3 +- intern/cycles/subd/subd_patch.cpp | 5 +- intern/cycles/subd/subd_patch.h | 1 - intern/cycles/subd/subd_patch_table.cpp | 1 - intern/cycles/subd/subd_patch_table.h | 1 - intern/cycles/subd/subd_split.cpp | 3 +- intern/cycles/subd/subd_split.h | 1 - intern/cycles/util/util_algorithm.h | 1 - intern/cycles/util/util_args.h | 1 - intern/cycles/util/util_boundbox.h | 11 ++-- intern/cycles/util/util_color.h | 1 - intern/cycles/util/util_defines.h | 1 - intern/cycles/util/util_foreach.h | 1 - intern/cycles/util/util_function.h | 1 - intern/cycles/util/util_half.h | 1 - intern/cycles/util/util_hash.h | 1 - intern/cycles/util/util_list.h | 1 - intern/cycles/util/util_map.h | 1 - intern/cycles/util/util_md5.cpp | 5 +- intern/cycles/util/util_md5.h | 1 - intern/cycles/util/util_optimization.h | 1 - intern/cycles/util/util_param.h | 1 - intern/cycles/util/util_path.cpp | 1 - intern/cycles/util/util_path.h | 1 - intern/cycles/util/util_progress.h | 1 - intern/cycles/util/util_projection.h | 1 - intern/cycles/util/util_queue.h | 1 - intern/cycles/util/util_rect.h | 1 - intern/cycles/util/util_set.h | 1 - intern/cycles/util/util_simd.h | 39 ++++++------ intern/cycles/util/util_sky_model.cpp | 1 - intern/cycles/util/util_sseb.h | 13 ++-- intern/cycles/util/util_ssef.h | 37 ++++++----- intern/cycles/util/util_ssei.h | 27 ++++---- intern/cycles/util/util_string.cpp | 1 - intern/cycles/util/util_string.h | 1 - intern/cycles/util/util_system.cpp | 1 - intern/cycles/util/util_system.h | 1 - intern/cycles/util/util_task.cpp | 9 ++- intern/cycles/util/util_task.h | 3 +- intern/cycles/util/util_thread.h | 1 - intern/cycles/util/util_time.cpp | 1 - intern/cycles/util/util_time.h | 1 - intern/cycles/util/util_transform.cpp | 10 +-- intern/cycles/util/util_transform.h | 3 +- intern/cycles/util/util_types.h | 1 - intern/cycles/util/util_types_float4_impl.h | 2 +- intern/cycles/util/util_vector.h | 1 - intern/cycles/util/util_view.cpp | 1 - intern/cycles/util/util_view.h | 1 - intern/cycles/util/util_windows.h | 1 - 257 files changed, 373 insertions(+), 616 deletions(-) diff --git a/intern/cycles/app/cycles_cubin_cc.cpp b/intern/cycles/app/cycles_cubin_cc.cpp index 3c83bf2dae3..01a1234531b 100644 --- a/intern/cycles/app/cycles_cubin_cc.cpp +++ b/intern/cycles/app/cycles_cubin_cc.cpp @@ -164,7 +164,7 @@ bool link_ptxas(CompilationSettings &settings) ptx += " --verbose"; printf("%s\n", ptx.c_str()); } - + int pxresult = system(ptx.c_str()); if(pxresult) { fprintf(stderr, "Error: ptxas failed (%x)\n\n", pxresult); diff --git a/intern/cycles/app/cycles_server.cpp b/intern/cycles/app/cycles_server.cpp index e65b9d769e4..e2166473aa3 100644 --- a/intern/cycles/app/cycles_server.cpp +++ b/intern/cycles/app/cycles_server.cpp @@ -112,4 +112,3 @@ int main(int argc, const char **argv) return 0; } - diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index c682744f5fa..1ec8d18f410 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -524,4 +524,3 @@ int main(int argc, const char **argv) return 0; } - diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index a46955322e3..895a83818df 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -184,7 +184,7 @@ static bool xml_equal_string(xml_node node, const char *name, const char *value) if(attr) return string_iequals(attr.value(), value); - + return false; } @@ -697,4 +697,3 @@ void xml_read_file(Scene *scene, const char *filepath) } CCL_NAMESPACE_END - diff --git a/intern/cycles/app/io_export_cycles_xml.py b/intern/cycles/app/io_export_cycles_xml.py index 7d6d85f88af..816536c0071 100644 --- a/intern/cycles/app/io_export_cycles_xml.py +++ b/intern/cycles/app/io_export_cycles_xml.py @@ -39,7 +39,7 @@ def write(node, fname): f = open(fname, "w") f.write(s) - + class CyclesXMLSettings(bpy.types.PropertyGroup): @classmethod def register(cls): @@ -53,11 +53,11 @@ class CyclesXMLSettings(bpy.types.PropertyGroup): maxlen=256, default='', subtype='FILE_PATH') - + @classmethod def unregister(cls): del bpy.types.Scene.cycles_xml - + # User Interface Drawing Code class RenderButtonsPanel(): bl_space_type = 'PROPERTIES' @@ -75,13 +75,13 @@ class PHYSICS_PT_fluid_export(RenderButtonsPanel, bpy.types.Panel): def draw(self, context): layout = self.layout - + cycles = context.scene.cycles_xml - + #layout.prop(cycles, "filepath") layout.operator("export_mesh.cycles_xml") - + # Export Operator class ExportCyclesXML(bpy.types.Operator, ExportHelper): bl_idname = "export_mesh.cycles_xml" @@ -118,23 +118,23 @@ class ExportCyclesXML(bpy.types.Operator, ExportHelper): P += "%f %f %f " % (v.co[0], v.co[1], v.co[2]) verts_and_uvs = zip(mesh.tessfaces, mesh.tessface_uv_textures.active.data) - + for f, uvf in verts_and_uvs: vcount = len(f.vertices) nverts += str(vcount) + " " for v in f.vertices: verts += str(v) + " " - + uvs += str(uvf.uv1[0]) + " " + str(uvf.uv1[1]) + " " uvs += str(uvf.uv2[0]) + " " + str(uvf.uv2[1]) + " " uvs += str(uvf.uv3[0]) + " " + str(uvf.uv3[1]) + " " if vcount==4: uvs += " " + str(uvf.uv4[0]) + " " + str(uvf.uv4[1]) + " " - + node = etree.Element('mesh', attrib={'nverts': nverts.strip(), 'verts': verts.strip(), 'P': P, 'UV' : uvs.strip()}) - + # write to file write(node, filepath) @@ -148,5 +148,3 @@ def unregister(): if __name__ == "__main__": register() - - diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index 1b798bcb42c..5a447a347a3 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -124,7 +124,7 @@ static float blender_camera_focal_distance(BL::RenderEngine& b_engine, if(!b_dof_object) return b_camera.dof_distance(); - + /* for dof object, return distance along camera Z direction */ BL::Array b_ob_matrix; b_engine.camera_model_matrix(b_ob, bcam->use_spherical_stereo, b_ob_matrix); @@ -726,7 +726,7 @@ static void blender_camera_view_subset(BL::RenderEngine& b_engine, blender_camera_viewplane(&cam_bcam, cam_bcam.full_width, cam_bcam.full_height, &cam, &cam_aspect, &sensor_size); - + /* return */ *view_box = view * (1.0f/view_aspect); *cam_box = cam * (1.0f/cam_aspect); @@ -895,4 +895,3 @@ BufferParams BlenderSync::get_buffer_params(BL::RenderSettings& b_render, } CCL_NAMESPACE_END - diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 7f9018964c7..35bf7beda41 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -125,7 +125,7 @@ void BlenderSync::sync_light(BL::Object& b_parent, *use_portal = true; return; } - + BL::Lamp b_lamp(b_ob.data()); /* type */ @@ -185,7 +185,7 @@ void BlenderSync::sync_light(BL::Object& b_parent, PointerRNA clamp = RNA_pointer_get(&b_lamp.ptr, "cycles"); light->cast_shadow = get_boolean(clamp, "cast_shadow"); light->use_mis = get_boolean(clamp, "use_multiple_importance_sampling"); - + int samples = get_int(clamp, "samples"); if(get_boolean(cscene, "use_square_samples")) light->samples = samples * samples; @@ -287,7 +287,7 @@ Object *BlenderSync::sync_object(BL::Object& b_parent, { BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent); bool motion = motion_time != 0.0f; - + /* light is handled separately */ if(object_is_light(b_ob)) { /* don't use lamps for excluded layers used as mask layer */ @@ -360,7 +360,7 @@ Object *BlenderSync::sync_object(BL::Object& b_parent, if(object_map.sync(&object, b_ob, b_parent, key)) object_updated = true; - + /* mesh sync */ object->mesh = sync_mesh(b_ob, object_updated, hide_tris); @@ -502,7 +502,7 @@ static bool object_render_hide(BL::Object& b_ob, } parent = parent.parent(); } - + hide_triangles = hide_emitter; if(show_emitter) { @@ -530,7 +530,7 @@ void BlenderSync::sync_objects(float motion_time) /* layer data */ uint scene_layer = render_layer.scene_layer; bool motion = motion_time != 0.0f; - + if(!motion) { /* prepare for sync */ light_map.pre_sync(); @@ -755,4 +755,3 @@ void BlenderSync::sync_motion(BL::RenderSettings& b_render, } CCL_NAMESPACE_END - diff --git a/intern/cycles/blender/blender_object_cull.cpp b/intern/cycles/blender/blender_object_cull.cpp index bdf7dc469b2..680d9d7b1ff 100644 --- a/intern/cycles/blender/blender_object_cull.cpp +++ b/intern/cycles/blender/blender_object_cull.cpp @@ -146,4 +146,3 @@ bool BlenderObjectCulling::test_distance(Scene *scene, float3 bb[8]) } CCL_NAMESPACE_END - diff --git a/intern/cycles/blender/blender_particles.cpp b/intern/cycles/blender/blender_particles.cpp index 00f8cb3cf1b..727d9acf729 100644 --- a/intern/cycles/blender/blender_particles.cpp +++ b/intern/cycles/blender/blender_particles.cpp @@ -68,7 +68,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object& b_ob, /* add particle */ BL::Particle b_pa = b_psys.particles[persistent_id[0]]; Particle pa; - + pa.index = persistent_id[0]; pa.age = b_scene.frame_current() - b_pa.birth_time(); pa.lifetime = b_pa.lifetime(); diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 76cc18dd9a1..3eccecb8850 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -331,7 +331,7 @@ static PyObject *draw_func(PyObject * /*self*/, PyObject *args) if(!PyArg_ParseTuple(args, "OOO", &pysession, &pyv3d, &pyrv3d)) return NULL; - + BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession); if(PyLong_AsVoidPtr(pyrv3d)) { @@ -590,7 +590,7 @@ static PyObject *osl_compile_func(PyObject * /*self*/, PyObject *args) if(!PyArg_ParseTuple(args, "ss", &inputfile, &outputfile)) return NULL; - + /* return */ if(!OSLShaderManager::osl_compile(inputfile, outputfile)) Py_RETURN_FALSE; diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 89612b74c39..8afcb0ce885 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -154,7 +154,7 @@ static SocketType::Type convert_socket_type(BL::NodeSocket& b_socket) return SocketType::STRING; case BL::NodeSocket::type_SHADER: return SocketType::CLOSURE; - + default: return SocketType::UNDEFINED; } @@ -443,7 +443,7 @@ static ShaderNode *add_node(Scene *scene, else if(b_node.is_a(&RNA_ShaderNodeBsdfGlossy)) { BL::ShaderNodeBsdfGlossy b_glossy_node(b_node); GlossyBsdfNode *glossy = new GlossyBsdfNode(); - + switch(b_glossy_node.distribution()) { case BL::ShaderNodeBsdfGlossy::distribution_SHARP: glossy->distribution = CLOSURE_BSDF_REFLECTION_ID; @@ -943,7 +943,7 @@ static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::NodeSocket& b_socket) { string name = b_socket.name(); - + if(node_use_modified_socket_name(node)) { BL::Node::inputs_iterator b_input; bool found = false; @@ -1062,7 +1062,7 @@ static void add_nodes(Scene *scene, } } else if(b_node->is_a(&RNA_ShaderNodeGroup) || b_node->is_a(&RNA_NodeCustomGroup)) { - + BL::ShaderNodeTree b_group_ntree(PointerRNA_NULL); if(b_node->is_a(&RNA_ShaderNodeGroup)) b_group_ntree = BL::ShaderNodeTree(((BL::NodeGroup)(*b_node)).node_tree()); @@ -1104,7 +1104,7 @@ static void add_nodes(Scene *scene, output_map[b_output->ptr.data] = proxy->outputs[0]; } - + if(b_group_ntree) { add_nodes(scene, b_engine, @@ -1481,4 +1481,3 @@ void BlenderSync::sync_shaders() } CCL_NAMESPACE_END - diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 283aa5600fd..a08089118d5 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -142,7 +142,7 @@ bool BlenderSync::sync_recalc() if(b_ob->is_updated_data() || b_ob->data().is_updated()) light_map.set_recalc(*b_ob); } - + if(b_ob->is_updated_data()) { BL::Object::particle_systems_iterator b_psys; for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys) @@ -301,7 +301,7 @@ void BlenderSync::sync_integrator() integrator->mesh_light_samples = mesh_light_samples * mesh_light_samples; integrator->subsurface_samples = subsurface_samples * subsurface_samples; integrator->volume_samples = volume_samples * volume_samples; - } + } else { integrator->diffuse_samples = diffuse_samples; integrator->glossy_samples = glossy_samples; @@ -336,7 +336,7 @@ void BlenderSync::sync_film() Film *film = scene->film; Film prevfilm = *film; - + film->exposure = get_float(cscene, "film_exposure"); film->filter_type = (FilterType)get_enum(cscene, "pixel_filter_type", @@ -633,7 +633,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene, params.shadingsystem = SHADINGSYSTEM_SVM; else if(shadingsystem == 1) params.shadingsystem = SHADINGSYSTEM_OSL; - + if(background || DebugFlags().viewport_static_bvh) params.bvh_type = SceneParams::BVH_STATIC; else @@ -698,7 +698,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine, /* device type */ vector& devices = Device::available_devices(); - + /* device default CPU */ foreach(DeviceInfo& device, devices) { if(device.type == DEVICE_CPU) { @@ -773,7 +773,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine, int aa_samples = get_int(cscene, "aa_samples"); int preview_samples = get_int(cscene, "preview_samples"); int preview_aa_samples = get_int(cscene, "preview_aa_samples"); - + if(get_boolean(cscene, "use_square_samples")) { aa_samples = aa_samples * aa_samples; preview_aa_samples = preview_aa_samples * preview_aa_samples; @@ -869,7 +869,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine, params.shadingsystem = SHADINGSYSTEM_SVM; else if(shadingsystem == 1) params.shadingsystem = SHADINGSYSTEM_OSL; - + /* color managagement */ #ifdef GLEW_MX /* When using GLEW MX we need to check whether we've got an OpenGL @@ -894,4 +894,3 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine, } CCL_NAMESPACE_END - diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 1e7b0b32518..5e63f76033d 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -214,4 +214,3 @@ private: CCL_NAMESPACE_END #endif /* __BLENDER_SYNC_H__ */ - diff --git a/intern/cycles/bvh/bvh_binning.cpp b/intern/cycles/bvh/bvh_binning.cpp index 63a7fc11668..f574f31b358 100644 --- a/intern/cycles/bvh/bvh_binning.cpp +++ b/intern/cycles/bvh/bvh_binning.cpp @@ -251,4 +251,3 @@ void BVHObjectBinning::split(BVHReference* prims, } CCL_NAMESPACE_END - diff --git a/intern/cycles/bvh/bvh_node.cpp b/intern/cycles/bvh/bvh_node.cpp index 24af919ff46..879d07b9625 100644 --- a/intern/cycles/bvh/bvh_node.cpp +++ b/intern/cycles/bvh/bvh_node.cpp @@ -206,7 +206,7 @@ void InnerNode::print(int depth) const { for(int i = 0; i < depth; i++) printf(" "); - + printf("inner node %p\n", (void*)this); if(children[0]) @@ -219,9 +219,8 @@ void LeafNode::print(int depth) const { for(int i = 0; i < depth; i++) printf(" "); - + printf("leaf node %d to %d\n", lo, hi); } CCL_NAMESPACE_END - diff --git a/intern/cycles/bvh/bvh_sort.cpp b/intern/cycles/bvh/bvh_sort.cpp index b40bf5bb21b..f4f73ab2f2f 100644 --- a/intern/cycles/bvh/bvh_sort.cpp +++ b/intern/cycles/bvh/bvh_sort.cpp @@ -201,4 +201,3 @@ void bvh_reference_sort(int start, } CCL_NAMESPACE_END - diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index b856bdd9d01..2400788c833 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -123,7 +123,7 @@ public: /* Use OpenSubdiv patch evaluation */ bool use_patch_evaluation; - + /* Use Transparent shadows */ bool use_transparent; @@ -294,7 +294,7 @@ public: /* open shading language, only for CPU device */ virtual void *osl_memory() { return NULL; } - /* load/compile kernels, must be called before adding tasks */ + /* load/compile kernels, must be called before adding tasks */ virtual bool load_kernels( const DeviceRequestedFeatures& /*requested_features*/) { return true; } @@ -304,7 +304,7 @@ public: virtual void task_add(DeviceTask& task) = 0; virtual void task_wait() = 0; virtual void task_cancel() = 0; - + /* opengl drawing */ virtual void draw_pixels(device_memory& mem, int y, int w, int h, int dx, int dy, int width, int height, bool transparent, @@ -362,4 +362,3 @@ private: CCL_NAMESPACE_END #endif /* __DEVICE_H__ */ - diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h index de487649045..941be448101 100644 --- a/intern/cycles/device/device_intern.h +++ b/intern/cycles/device/device_intern.h @@ -41,4 +41,3 @@ string device_cuda_capabilities(void); CCL_NAMESPACE_END #endif /* __DEVICE_INTERN_H__ */ - diff --git a/intern/cycles/device/device_memory.cpp b/intern/cycles/device/device_memory.cpp index 482af685011..a8d29896553 100644 --- a/intern/cycles/device/device_memory.cpp +++ b/intern/cycles/device/device_memory.cpp @@ -138,4 +138,3 @@ device_sub_ptr::~device_sub_ptr() } CCL_NAMESPACE_END - diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h index b6f3c2913a5..2b4835c9c65 100644 --- a/intern/cycles/device/device_memory.h +++ b/intern/cycles/device/device_memory.h @@ -51,7 +51,7 @@ enum DataType { TYPE_UINT64, }; -static inline size_t datatype_size(DataType datatype) +static inline size_t datatype_size(DataType datatype) { switch(datatype) { case TYPE_UNKNOWN: return 1; @@ -497,4 +497,3 @@ protected: CCL_NAMESPACE_END #endif /* __DEVICE_MEMORY_H__ */ - diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index 1353797edb4..f1bd3fd13e1 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -376,4 +376,3 @@ Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background) } CCL_NAMESPACE_END - diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp index 5ad4405366e..204e405421d 100644 --- a/intern/cycles/device/device_network.cpp +++ b/intern/cycles/device/device_network.cpp @@ -797,5 +797,3 @@ void Device::server_run() CCL_NAMESPACE_END #endif - - diff --git a/intern/cycles/device/device_network.h b/intern/cycles/device/device_network.h index b734ba2bda9..96e0de742db 100644 --- a/intern/cycles/device/device_network.h +++ b/intern/cycles/device/device_network.h @@ -179,7 +179,7 @@ public: boost::asio::write(socket, boost::asio::buffer(archive_str), boost::asio::transfer_all(), error); - + if(error.value()) error_func->network_error(error.message()); @@ -193,7 +193,7 @@ public: boost::asio::write(socket, boost::asio::buffer(buffer, size), boost::asio::transfer_all(), error); - + if(error.value()) error_func->network_error(error.message()); } @@ -467,7 +467,7 @@ private: /* buffer and endpoint for receiving messages */ char receive_buffer[256]; boost::asio::ip::udp::endpoint receive_endpoint; - + // os, version, devices, status, host name, group name, ip as far as fields go struct ServerInfo { string cycles_version; @@ -489,4 +489,3 @@ CCL_NAMESPACE_END #endif #endif /* __DEVICE_NETWORK_H__ */ - diff --git a/intern/cycles/device/device_split_kernel.cpp b/intern/cycles/device/device_split_kernel.cpp index 74135a1f3c8..efaae8c84f4 100644 --- a/intern/cycles/device/device_split_kernel.cpp +++ b/intern/cycles/device/device_split_kernel.cpp @@ -261,7 +261,7 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task, ENQUEUE_SPLIT_KERNEL(buffer_update, global_size, local_size); if(task->get_cancel() && cancel_time == DBL_MAX) { - /* Wait up to twice as many seconds for current samples to finish + /* Wait up to twice as many seconds for current samples to finish * to avoid artifacts in render result from ending too soon. */ cancel_time = time_dt() + 2.0 * time_multiplier; @@ -322,5 +322,3 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task, } CCL_NAMESPACE_END - - diff --git a/intern/cycles/device/device_split_kernel.h b/intern/cycles/device/device_split_kernel.h index 2ec0261e847..26ddce5bb22 100644 --- a/intern/cycles/device/device_split_kernel.h +++ b/intern/cycles/device/device_split_kernel.h @@ -131,6 +131,3 @@ public: CCL_NAMESPACE_END #endif /* __DEVICE_SPLIT_KERNEL_H__ */ - - - diff --git a/intern/cycles/device/device_task.cpp b/intern/cycles/device/device_task.cpp index 3c7d24fb5b7..8310863886c 100644 --- a/intern/cycles/device/device_task.cpp +++ b/intern/cycles/device/device_task.cpp @@ -126,4 +126,3 @@ void DeviceTask::update_progress(RenderTile *rtile, int pixel_samples) } CCL_NAMESPACE_END - diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h index b9658eb978f..ec87aa8c560 100644 --- a/intern/cycles/device/device_task.h +++ b/intern/cycles/device/device_task.h @@ -86,4 +86,3 @@ protected: CCL_NAMESPACE_END #endif /* __DEVICE_TASK_H__ */ - diff --git a/intern/cycles/device/opencl/memory_manager.cpp b/intern/cycles/device/opencl/memory_manager.cpp index 75c9de65035..485a656cb83 100644 --- a/intern/cycles/device/opencl/memory_manager.cpp +++ b/intern/cycles/device/opencl/memory_manager.cpp @@ -254,4 +254,3 @@ void MemoryManager::set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg) CCL_NAMESPACE_END #endif /* WITH_OPENCL */ - diff --git a/intern/cycles/device/opencl/memory_manager.h b/intern/cycles/device/opencl/memory_manager.h index b3d861275f0..b49bd32dab6 100644 --- a/intern/cycles/device/opencl/memory_manager.h +++ b/intern/cycles/device/opencl/memory_manager.h @@ -104,4 +104,3 @@ public: }; CCL_NAMESPACE_END - diff --git a/intern/cycles/doc/license/Apache_2.0.txt b/intern/cycles/doc/license/Apache_2.0.txt index 6b0b1270ff0..d6456956733 100644 --- a/intern/cycles/doc/license/Apache_2.0.txt +++ b/intern/cycles/doc/license/Apache_2.0.txt @@ -200,4 +200,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - diff --git a/intern/cycles/doc/license/ILM.txt b/intern/cycles/doc/license/ILM.txt index 0e24aa56203..8b68abc954d 100644 --- a/intern/cycles/doc/license/ILM.txt +++ b/intern/cycles/doc/license/ILM.txt @@ -13,7 +13,7 @@ met: distribution. * Neither the name of Industrial Light & Magic nor the names of its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. + from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -26,4 +26,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/intern/cycles/doc/license/NVidia.txt b/intern/cycles/doc/license/NVidia.txt index 4fa55d3d2bc..42c165e11d2 100644 --- a/intern/cycles/doc/license/NVidia.txt +++ b/intern/cycles/doc/license/NVidia.txt @@ -33,4 +33,3 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - diff --git a/intern/cycles/doc/license/OSL.txt b/intern/cycles/doc/license/OSL.txt index 1ffeb58291e..e716b5c5e10 100644 --- a/intern/cycles/doc/license/OSL.txt +++ b/intern/cycles/doc/license/OSL.txt @@ -25,4 +25,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/intern/cycles/doc/license/Sobol.txt b/intern/cycles/doc/license/Sobol.txt index 4ad42d22fb1..0bce8349fe5 100644 --- a/intern/cycles/doc/license/Sobol.txt +++ b/intern/cycles/doc/license/Sobol.txt @@ -26,4 +26,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/intern/cycles/doc/license/readme.txt b/intern/cycles/doc/license/readme.txt index 4c56c90a0f1..cc5476e3511 100644 --- a/intern/cycles/doc/license/readme.txt +++ b/intern/cycles/doc/license/readme.txt @@ -13,4 +13,3 @@ MIT license Boost License * Boost and OpenCL dynamic loading - diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp index b16c6af5d0e..45ffc8d7d6b 100644 --- a/intern/cycles/graph/node.cpp +++ b/intern/cycles/graph/node.cpp @@ -496,4 +496,3 @@ void Node::hash(MD5Hash& md5) } CCL_NAMESPACE_END - diff --git a/intern/cycles/graph/node.h b/intern/cycles/graph/node.h index d198c38be32..a738bfe197e 100644 --- a/intern/cycles/graph/node.h +++ b/intern/cycles/graph/node.h @@ -97,4 +97,3 @@ struct Node }; CCL_NAMESPACE_END - diff --git a/intern/cycles/graph/node_enum.h b/intern/cycles/graph/node_enum.h index 4e40c294f4f..9de776ddb55 100644 --- a/intern/cycles/graph/node_enum.h +++ b/intern/cycles/graph/node_enum.h @@ -45,4 +45,3 @@ private: }; CCL_NAMESPACE_END - diff --git a/intern/cycles/graph/node_type.cpp b/intern/cycles/graph/node_type.cpp index 37aae211e93..671ae2d815a 100644 --- a/intern/cycles/graph/node_type.cpp +++ b/intern/cycles/graph/node_type.cpp @@ -217,4 +217,3 @@ const NodeType *NodeType::find(ustring name) } CCL_NAMESPACE_END - diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h index 15d34a79bb8..d4e2dbceff6 100644 --- a/intern/cycles/graph/node_type.h +++ b/intern/cycles/graph/node_type.h @@ -263,4 +263,3 @@ const NodeType *structname::register_type() { type->register_output(ustring(#name), ustring(ui_name), SocketType::ENUM); } CCL_NAMESPACE_END - diff --git a/intern/cycles/graph/node_xml.cpp b/intern/cycles/graph/node_xml.cpp index f4599e22d40..b7a28b427e5 100644 --- a/intern/cycles/graph/node_xml.cpp +++ b/intern/cycles/graph/node_xml.cpp @@ -458,4 +458,3 @@ xml_node xml_write_node(Node *node, xml_node xml_root) } CCL_NAMESPACE_END - diff --git a/intern/cycles/graph/node_xml.h b/intern/cycles/graph/node_xml.h index b648c9666c1..5fecf40f96c 100644 --- a/intern/cycles/graph/node_xml.h +++ b/intern/cycles/graph/node_xml.h @@ -32,4 +32,3 @@ void xml_read_node(XMLReader& reader, Node *node, xml_node xml_node); xml_node xml_write_node(Node *node, xml_node xml_root); CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h index c1b02cd4be1..f191b812f11 100644 --- a/intern/cycles/kernel/closure/bsdf.h +++ b/intern/cycles/kernel/closure/bsdf.h @@ -486,4 +486,3 @@ ccl_device bool bsdf_merge(ShaderClosure *a, ShaderClosure *b) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h index b6c896c754b..ff238b7a834 100644 --- a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h +++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h @@ -117,7 +117,7 @@ ccl_device_forceinline float3 bsdf_ashikhmin_shirley_eval_reflect( lobe = 1.0f; } float norm = sqrtf((n_x + 1.0f)*(n_y + 1.0f)) / (8.0f * M_PI_F); - + out = NdotO * norm * lobe * pump; *pdf = norm * lobe / HdotI; } diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h index a5ba2cb2972..b0bdea723b9 100644 --- a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h +++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -46,7 +46,7 @@ ccl_device int bsdf_ashikhmin_velvet_setup(VelvetBsdf *bsdf) { float sigma = fmaxf(bsdf->sigma, 0.01f); bsdf->invsigma2 = 1.0f/(sigma * sigma); - + bsdf->type = CLOSURE_BSDF_ASHIKHMIN_VELVET_ID; return SD_BSDF|SD_BSDF_HAS_EVAL; @@ -159,4 +159,3 @@ ccl_device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc, float3 Ng, CCL_NAMESPACE_END #endif /* __BSDF_ASHIKHMIN_VELVET_H__ */ - diff --git a/intern/cycles/kernel/closure/bsdf_diffuse.h b/intern/cycles/kernel/closure/bsdf_diffuse.h index ec6f1f20996..ee6d4cdf2df 100644 --- a/intern/cycles/kernel/closure/bsdf_diffuse.h +++ b/intern/cycles/kernel/closure/bsdf_diffuse.h @@ -88,7 +88,7 @@ ccl_device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, } else *pdf = 0.0f; - + return LABEL_REFLECT|LABEL_DIFFUSE; } @@ -140,4 +140,3 @@ ccl_device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float CCL_NAMESPACE_END #endif /* __BSDF_DIFFUSE_H__ */ - diff --git a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h index 24f40af46a3..35bb2fdf0e8 100644 --- a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h +++ b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h @@ -46,7 +46,7 @@ typedef ccl_addr_space struct DiffuseRampBsdf { ccl_device float3 bsdf_diffuse_ramp_get_color(const float3 colors[8], float pos) { int MAXCOLORS = 8; - + float npos = pos * (float)(MAXCOLORS - 1); int ipos = float_to_int(npos); if(ipos < 0) @@ -99,7 +99,7 @@ ccl_device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc, float3 Ng, floa } else *pdf = 0.0f; - + return LABEL_REFLECT|LABEL_DIFFUSE; } diff --git a/intern/cycles/kernel/closure/bsdf_hair.h b/intern/cycles/kernel/closure/bsdf_hair.h index daaa26dc6ad..7b44a23f05b 100644 --- a/intern/cycles/kernel/closure/bsdf_hair.h +++ b/intern/cycles/kernel/closure/bsdf_hair.h @@ -278,4 +278,3 @@ ccl_device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng, CCL_NAMESPACE_END #endif /* __BSDF_HAIR_H__ */ - diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h index 2dd59354058..e74d5ebaa42 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet.h @@ -231,7 +231,7 @@ ccl_device_forceinline float3 microfacet_sample_stretched( /* 5. compute normal */ return normalize(make_float3(-slope_x, -slope_y, 1.0f)); -} +} /* Calculate the reflection color * @@ -434,7 +434,7 @@ ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, cons /* eq. 34: now calculate G1(i,m) and G1(o,m) */ G1o = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNO * cosNO) / (cosNO * cosNO))); - G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI))); + G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI))); } else { /* anisotropic */ @@ -535,7 +535,7 @@ ccl_device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, con /* eq. 34: now calculate G1(i,m) and G1(o,m) */ G1o = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNO * cosNO) / (cosNO * cosNO))); - G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI))); + G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI))); float G = G1o * G1i; @@ -706,7 +706,7 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure dIdx, dIdy, &dRdx, &dRdy, &dTdx, &dTdy, #endif &inside); - + if(!inside && fresnel != 1.0f) { *omega_in = T; @@ -733,7 +733,7 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure float cosNI = dot(N, *omega_in); /* eq. 34: now calculate G1(i,m) */ - float G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI))); + float G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI))); /* eq. 21 */ float cosHI = dot(m, *omega_in); @@ -1125,4 +1125,3 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg, const ShaderCl CCL_NAMESPACE_END #endif /* __BSDF_MICROFACET_H__ */ - diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h index 420f94755ee..91c7803346d 100644 --- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h +++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h @@ -47,7 +47,7 @@ typedef ccl_addr_space struct PhongRampBsdf { ccl_device float3 bsdf_phong_ramp_get_color(const float3 colors[8], float pos) { int MAXCOLORS = 8; - + float npos = pos * (float)(MAXCOLORS - 1); int ipos = float_to_int(npos); if(ipos < 0) @@ -71,7 +71,7 @@ ccl_device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const fl float m_exponent = bsdf->exponent; float cosNI = dot(bsdf->N, omega_in); float cosNO = dot(bsdf->N, I); - + if(cosNI > 0 && cosNO > 0) { // reflect the view vector float3 R = (2 * cosNO) * bsdf->N - I; @@ -84,7 +84,7 @@ ccl_device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const fl return bsdf_phong_ramp_get_color(bsdf->colors, cosp) * out; } } - + return make_float3(0.0f, 0.0f, 0.0f); } @@ -98,7 +98,7 @@ ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, float3 Ng, float3 const PhongRampBsdf *bsdf = (const PhongRampBsdf*)sc; float cosNO = dot(bsdf->N, I); float m_exponent = bsdf->exponent; - + if(cosNO > 0) { // reflect the view vector float3 R = (2 * cosNO) * bsdf->N - I; @@ -107,7 +107,7 @@ ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, float3 Ng, float3 *domega_in_dx = (2 * dot(bsdf->N, dIdx)) * bsdf->N - dIdx; *domega_in_dy = (2 * dot(bsdf->N, dIdy)) * bsdf->N - dIdy; #endif - + float3 T, B; make_orthonormals (R, &T, &B); float phi = M_2PI_F * randu; diff --git a/intern/cycles/kernel/closure/bsdf_principled_diffuse.h b/intern/cycles/kernel/closure/bsdf_principled_diffuse.h index f8ca64293b0..83be2b35a00 100644 --- a/intern/cycles/kernel/closure/bsdf_principled_diffuse.h +++ b/intern/cycles/kernel/closure/bsdf_principled_diffuse.h @@ -123,5 +123,3 @@ ccl_device int bsdf_principled_diffuse_sample(const ShaderClosure *sc, CCL_NAMESPACE_END #endif /* __BSDF_PRINCIPLED_DIFFUSE_H__ */ - - diff --git a/intern/cycles/kernel/closure/bsdf_principled_sheen.h b/intern/cycles/kernel/closure/bsdf_principled_sheen.h index f4476bfecd0..8b7c4399516 100644 --- a/intern/cycles/kernel/closure/bsdf_principled_sheen.h +++ b/intern/cycles/kernel/closure/bsdf_principled_sheen.h @@ -109,5 +109,3 @@ ccl_device int bsdf_principled_sheen_sample(const ShaderClosure *sc, CCL_NAMESPACE_END #endif /* __BSDF_PRINCIPLED_SHEEN_H__ */ - - diff --git a/intern/cycles/kernel/closure/bsdf_reflection.h b/intern/cycles/kernel/closure/bsdf_reflection.h index 1d21614ecee..b33b6e3597b 100644 --- a/intern/cycles/kernel/closure/bsdf_reflection.h +++ b/intern/cycles/kernel/closure/bsdf_reflection.h @@ -78,4 +78,3 @@ ccl_device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 CCL_NAMESPACE_END #endif /* __BSDF_REFLECTION_H__ */ - diff --git a/intern/cycles/kernel/closure/bsdf_refraction.h b/intern/cycles/kernel/closure/bsdf_refraction.h index 050a4e76fa9..b181650e928 100644 --- a/intern/cycles/kernel/closure/bsdf_refraction.h +++ b/intern/cycles/kernel/closure/bsdf_refraction.h @@ -87,4 +87,3 @@ ccl_device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 CCL_NAMESPACE_END #endif /* __BSDF_REFRACTION_H__ */ - diff --git a/intern/cycles/kernel/closure/bsdf_toon.h b/intern/cycles/kernel/closure/bsdf_toon.h index d8b6d8ddead..6d8074b7130 100644 --- a/intern/cycles/kernel/closure/bsdf_toon.h +++ b/intern/cycles/kernel/closure/bsdf_toon.h @@ -73,7 +73,7 @@ ccl_device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float a is = (1.0f - (angle - max_angle)/smooth); else is = 0.0f; - + return make_float3(is, is, is); } @@ -90,7 +90,7 @@ ccl_device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const float angle = safe_acosf(fmaxf(dot(bsdf->N, omega_in), 0.0f)); float3 eval = bsdf_toon_get_intensity(max_angle, smooth, angle); - + if(eval.x > 0.0f) { float sample_angle = bsdf_toon_get_sample_angle(max_angle, smooth); @@ -152,7 +152,7 @@ ccl_device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const f float smooth = bsdf->smooth*M_PI_2_F; float cosNI = dot(bsdf->N, omega_in); float cosNO = dot(bsdf->N, I); - + if(cosNI > 0 && cosNO > 0) { /* reflect the view vector */ float3 R = (2 * cosNO) * bsdf->N - I; @@ -166,7 +166,7 @@ ccl_device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const f *pdf = 0.5f * M_1_PI_F / (1.0f - cosf(sample_angle)); return *pdf * eval; } - + return make_float3(0.0f, 0.0f, 0.0f); } @@ -181,7 +181,7 @@ ccl_device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float float max_angle = bsdf->size*M_PI_2_F; float smooth = bsdf->smooth*M_PI_2_F; float cosNO = dot(bsdf->N, I); - + if(cosNO > 0) { /* reflect the view vector */ float3 R = (2 * cosNO) * bsdf->N - I; @@ -216,4 +216,3 @@ ccl_device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float CCL_NAMESPACE_END #endif /* __BSDF_TOON_H__ */ - diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h index 8fc7ef4dd4f..f788dbcd0ff 100644 --- a/intern/cycles/kernel/closure/bsdf_transparent.h +++ b/intern/cycles/kernel/closure/bsdf_transparent.h @@ -107,4 +107,3 @@ ccl_device int bsdf_transparent_sample(const ShaderClosure *sc, float3 Ng, float CCL_NAMESPACE_END #endif /* __BSDF_TRANSPARENT_H__ */ - diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h index 3dc15d5791c..b080e025d16 100644 --- a/intern/cycles/kernel/closure/bsdf_util.h +++ b/intern/cycles/kernel/closure/bsdf_util.h @@ -62,14 +62,14 @@ ccl_device float fresnel_dielectric( Nn = -N; *is_inside = true; } - + // compute reflection *R = (2 * cos)* Nn - I; #ifdef __RAY_DIFFERENTIALS__ *dRdx = (2 * dot(Nn, dIdx)) * Nn - dIdx; *dRdy = (2 * dot(Nn, dIdy)) * Nn - dIdy; #endif - + float arg = 1 -(neta * neta *(1 -(cos * cos))); if(arg < 0) { *T = make_float3(0.0f, 0.0f, 0.0f); @@ -159,4 +159,3 @@ ccl_device_forceinline float3 interpolate_fresnel_color(float3 L, float3 H, floa CCL_NAMESPACE_END #endif /* __BSDF_UTIL_H__ */ - diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h index 8578767b07e..ba0c6ae8c61 100644 --- a/intern/cycles/kernel/closure/bssrdf.h +++ b/intern/cycles/kernel/closure/bssrdf.h @@ -500,4 +500,3 @@ ccl_device_forceinline float bssrdf_pdf(const ShaderClosure *sc, float r) CCL_NAMESPACE_END #endif /* __KERNEL_BSSRDF_H__ */ - diff --git a/intern/cycles/kernel/closure/emissive.h b/intern/cycles/kernel/closure/emissive.h index e709ca9a372..a7f4a2a7327 100644 --- a/intern/cycles/kernel/closure/emissive.h +++ b/intern/cycles/kernel/closure/emissive.h @@ -76,9 +76,8 @@ ccl_device void emissive_sample(const float3 Ng, float randu, float randv, ccl_device float3 emissive_simple_eval(const float3 Ng, const float3 I) { float res = emissive_pdf(Ng, I); - + return make_float3(res, res, res); } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/closure/volume.h b/intern/cycles/kernel/closure/volume.h index da791e9aa73..872d06c936a 100644 --- a/intern/cycles/kernel/closure/volume.h +++ b/intern/cycles/kernel/closure/volume.h @@ -51,7 +51,7 @@ ccl_device float single_peaked_henyey_greenstein(float cos_theta, float g) ccl_device int volume_henyey_greenstein_setup(HenyeyGreensteinVolume *volume) { volume->type = CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID; - + /* clamp anisotropy to avoid delta function */ volume->g = signf(volume->g) * min(fabsf(volume->g), 1.0f - 1e-3f); diff --git a/intern/cycles/kernel/geom/geom.h b/intern/cycles/kernel/geom/geom.h index f34b77ebc07..e81c1b781c8 100644 --- a/intern/cycles/kernel/geom/geom.h +++ b/intern/cycles/kernel/geom/geom.h @@ -30,4 +30,3 @@ #include "kernel/geom/geom_curve_intersect.h" #include "kernel/geom/geom_volume.h" #include "kernel/geom/geom_primitive.h" - diff --git a/intern/cycles/kernel/geom/geom_attribute.h b/intern/cycles/kernel/geom/geom_attribute.h index 42c053704d5..e991f3d685a 100644 --- a/intern/cycles/kernel/geom/geom_attribute.h +++ b/intern/cycles/kernel/geom/geom_attribute.h @@ -66,7 +66,7 @@ ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const Sh uint attr_offset = object_attribute_map_offset(kg, sd->object); attr_offset += attribute_primitive_type(kg, sd); uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset); - + while(attr_map.x != id) { if(UNLIKELY(attr_map.x == ATTR_STD_NONE)) { return attribute_not_found(); @@ -77,7 +77,7 @@ ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const Sh AttributeDescriptor desc; desc.element = (AttributeElement)attr_map.y; - + if(sd->prim == PRIM_NONE && desc.element != ATTR_ELEMENT_MESH && desc.element != ATTR_ELEMENT_VOXEL && @@ -108,4 +108,3 @@ ccl_device Transform primitive_attribute_matrix(KernelGlobals *kg, const ShaderD } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/geom/geom_motion_curve.h b/intern/cycles/kernel/geom/geom_motion_curve.h index fad29e431ec..5cc22ae2155 100644 --- a/intern/cycles/kernel/geom/geom_motion_curve.h +++ b/intern/cycles/kernel/geom/geom_motion_curve.h @@ -214,4 +214,3 @@ ccl_device_inline void motion_cardinal_curve_keys_avx(KernelGlobals *kg, #endif CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/geom/geom_motion_triangle.h b/intern/cycles/kernel/geom/geom_motion_triangle.h index 7ac6807e749..64f6d027b99 100644 --- a/intern/cycles/kernel/geom/geom_motion_triangle.h +++ b/intern/cycles/kernel/geom/geom_motion_triangle.h @@ -34,14 +34,14 @@ ccl_device_inline int find_attribute_motion(KernelGlobals *kg, int object, uint /* todo: find a better (faster) solution for this, maybe store offset per object */ uint attr_offset = object_attribute_map_offset(kg, object); uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset); - + while(attr_map.x != id) { attr_offset += ATTR_PRIM_TYPES; attr_map = kernel_tex_fetch(__attributes_map, attr_offset); } *elem = (AttributeElement)attr_map.y; - + /* return result */ return (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : (int)attr_map.z; } diff --git a/intern/cycles/kernel/geom/geom_motion_triangle_shader.h b/intern/cycles/kernel/geom/geom_motion_triangle_shader.h index 4789137d5b0..e91a4be96ba 100644 --- a/intern/cycles/kernel/geom/geom_motion_triangle_shader.h +++ b/intern/cycles/kernel/geom/geom_motion_triangle_shader.h @@ -120,4 +120,3 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals *kg, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h index 800649abf38..cfe17e63627 100644 --- a/intern/cycles/kernel/geom/geom_object.h +++ b/intern/cycles/kernel/geom/geom_object.h @@ -613,4 +613,3 @@ ccl_device_inline void object_normal_transform_addrspace(KernelGlobals *kg, #endif CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/geom/geom_patch.h b/intern/cycles/kernel/geom/geom_patch.h index 5663b598508..343649ad934 100644 --- a/intern/cycles/kernel/geom/geom_patch.h +++ b/intern/cycles/kernel/geom/geom_patch.h @@ -340,4 +340,3 @@ ccl_device float3 patch_eval_uchar4(KernelGlobals *kg, const ShaderData *sd, int } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/geom/geom_primitive.h b/intern/cycles/kernel/geom/geom_primitive.h index c159be92885..6db8475d196 100644 --- a/intern/cycles/kernel/geom/geom_primitive.h +++ b/intern/cycles/kernel/geom/geom_primitive.h @@ -192,7 +192,7 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals *kg, ShaderData * /* object motion. note that depending on the mesh having motion vectors, this * transformation was set match the world/object space of motion_pre/post */ Transform tfm; - + tfm = object_fetch_motion_pass_transform(kg, sd->object, OBJECT_PASS_MOTION_PRE); motion_pre = transform_point(&tfm, motion_pre); @@ -240,4 +240,3 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals *kg, ShaderData * } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/geom/geom_subd_triangle.h b/intern/cycles/kernel/geom/geom_subd_triangle.h index 044e82f03d4..00ce89ae567 100644 --- a/intern/cycles/kernel/geom/geom_subd_triangle.h +++ b/intern/cycles/kernel/geom/geom_subd_triangle.h @@ -352,4 +352,3 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h index 346f228e961..688413b74a1 100644 --- a/intern/cycles/kernel/geom/geom_volume.h +++ b/intern/cycles/kernel/geom/geom_volume.h @@ -80,4 +80,3 @@ ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *s #endif CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h index cfb35dd33f5..373324afb01 100644 --- a/intern/cycles/kernel/kernel.h +++ b/intern/cycles/kernel/kernel.h @@ -64,4 +64,3 @@ void kernel_tex_copy(KernelGlobals *kg, CCL_NAMESPACE_END #endif /* __KERNEL_H__ */ - diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h index c0f281cae97..6b3cec9fda6 100644 --- a/intern/cycles/kernel/kernel_accumulate.h +++ b/intern/cycles/kernel/kernel_accumulate.h @@ -270,7 +270,7 @@ ccl_device_inline void path_radiance_bsdf_bounce( L_state->transmission + L_state->subsurface + L_state->scatter; - + L_state->direct = *throughput; } else { diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h index 79e6d1b4862..afb63152830 100644 --- a/intern/cycles/kernel/kernel_bake.h +++ b/intern/cycles/kernel/kernel_bake.h @@ -563,4 +563,3 @@ ccl_device void kernel_background_evaluate(KernelGlobals *kg, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h index d26b668cb11..2f955741797 100644 --- a/intern/cycles/kernel/kernel_compat_cpu.h +++ b/intern/cycles/kernel/kernel_compat_cpu.h @@ -153,4 +153,3 @@ ccl_device_inline void print_sse3i(const char *label, sse3i& a) CCL_NAMESPACE_END #endif /* __KERNEL_COMPAT_CPU_H__ */ - diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h index 671c47e2225..438c819eec6 100644 --- a/intern/cycles/kernel/kernel_compat_opencl.h +++ b/intern/cycles/kernel/kernel_compat_opencl.h @@ -154,4 +154,3 @@ #include "util/util_types.h" #endif /* __KERNEL_COMPAT_OPENCL_H__ */ - diff --git a/intern/cycles/kernel/kernel_differential.h b/intern/cycles/kernel/kernel_differential.h index ae1e70f0167..924d96c72e5 100644 --- a/intern/cycles/kernel/kernel_differential.h +++ b/intern/cycles/kernel/kernel_differential.h @@ -103,4 +103,3 @@ ccl_device differential3 differential3_zero() } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 524e2467ebc..302bb047647 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -76,7 +76,7 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, /* Evaluate emissive closure. */ eval = shader_emissive_eval(kg, emission_sd); } - + eval *= ls->eval_fac; return eval; @@ -338,4 +338,3 @@ ccl_device_noinline float3 indirect_background(KernelGlobals *kg, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h index 94815601179..b5f151d8663 100644 --- a/intern/cycles/kernel/kernel_film.h +++ b/intern/cycles/kernel/kernel_film.h @@ -87,4 +87,3 @@ ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_jitter.h b/intern/cycles/kernel/kernel_jitter.h index f5855757d3f..3bde96b078c 100644 --- a/intern/cycles/kernel/kernel_jitter.h +++ b/intern/cycles/kernel/kernel_jitter.h @@ -226,4 +226,3 @@ ccl_device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy) #endif CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h index bb182ef1f25..a25a7e3842b 100644 --- a/intern/cycles/kernel/kernel_light.h +++ b/intern/cycles/kernel/kernel_light.h @@ -506,7 +506,7 @@ ccl_device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 if(cos_pi <= 0.0f) return 0.0f; - + return t*t/cos_pi; } diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index 9995490505f..49dc1f08cc1 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index a42a8e9812f..458aa6c2a97 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -203,7 +203,7 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl if(!((flag | light_flag) & PASS_ANY)) return; - + if(!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) { if(!(sd->flag & SD_TRANSPARENT) || kernel_data.film.pass_alpha_threshold == 0.0f || @@ -285,7 +285,7 @@ ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global f if(!kernel_data.film.use_light_pass) return; - + if(light_flag & PASSMASK(DIFFUSE_INDIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, L->indirect_diffuse); if(light_flag & PASSMASK(GLOSSY_INDIRECT)) @@ -392,4 +392,3 @@ ccl_device_inline void kernel_write_result(KernelGlobals *kg, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index d79b556c2ce..5745762e183 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -762,4 +762,3 @@ ccl_device void kernel_path_trace(KernelGlobals *kg, #endif /* __SPLIT_KERNEL__ */ CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h index 8a358e51f94..b13fabde268 100644 --- a/intern/cycles/kernel/kernel_path_state.h +++ b/intern/cycles/kernel/kernel_path_state.h @@ -269,4 +269,3 @@ ccl_device_inline void path_state_branch(ccl_addr_space PathState *state, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_path_subsurface.h b/intern/cycles/kernel/kernel_path_subsurface.h index 71aea9e3b27..ff4a8a9d580 100644 --- a/intern/cycles/kernel/kernel_path_subsurface.h +++ b/intern/cycles/kernel/kernel_path_subsurface.h @@ -152,4 +152,3 @@ ccl_device void kernel_path_subsurface_setup_indirect( #endif /* __SUBSURFACE__ */ CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h index 27be90d5059..c9202ccb16d 100644 --- a/intern/cycles/kernel/kernel_path_surface.h +++ b/intern/cycles/kernel/kernel_path_surface.h @@ -356,4 +356,3 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_path_volume.h b/intern/cycles/kernel/kernel_path_volume.h index 6275d0d6562..feaea15d3c4 100644 --- a/intern/cycles/kernel/kernel_path_volume.h +++ b/intern/cycles/kernel/kernel_path_volume.h @@ -85,7 +85,7 @@ bool kernel_path_volume_bounce( if(phase_pdf == 0.0f || bsdf_eval_is_zero(&phase_eval)) return false; - + /* modify throughput */ path_radiance_bsdf_bounce(kg, L_state, throughput, &phase_eval, phase_pdf, state->bounce, label); @@ -223,7 +223,7 @@ ccl_device void kernel_branched_path_volume_connect_light( VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg, state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false); - + /* todo: split up light_sample so we don't have to call it again with new position */ if(result == VOLUME_PATH_SCATTERED && light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) { @@ -260,7 +260,7 @@ ccl_device void kernel_branched_path_volume_connect_light( VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg, state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false); - + /* todo: split up light_sample so we don't have to call it again with new position */ if(result == VOLUME_PATH_SCATTERED && light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) { @@ -284,4 +284,3 @@ ccl_device void kernel_branched_path_volume_connect_light( #endif /* __VOLUME_SCATTER__ */ CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h index 4540d733af4..7bad89c831c 100644 --- a/intern/cycles/kernel/kernel_projection.h +++ b/intern/cycles/kernel/kernel_projection.h @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h index 93152e9ff1c..b33e4eba8a4 100644 --- a/intern/cycles/kernel/kernel_random.h +++ b/intern/cycles/kernel/kernel_random.h @@ -296,4 +296,3 @@ ccl_device float lcg_step_float_addrspace(ccl_addr_space uint *rng) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h index e8553d84547..a06fbe72ffa 100644 --- a/intern/cycles/kernel/kernel_subsurface.h +++ b/intern/cycles/kernel/kernel_subsurface.h @@ -50,7 +50,7 @@ ccl_device_inline float3 subsurface_scatter_eval(ShaderData *sd, for(int i = 0; i < sd->num_closure; i++) { sc = &sd->closure[i]; - + if(CLOSURE_IS_DISK_BSSRDF(sc->type)) { /* in case of branched path integrate we sample all bssrdf's once, * for path trace we pick one, so adjust pdf for that */ @@ -533,4 +533,3 @@ ccl_device_inline int subsurface_scatter_multi_intersect( } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h index a7b8c492ee9..e83727ec64e 100644 --- a/intern/cycles/kernel/kernel_textures.h +++ b/intern/cycles/kernel/kernel_textures.h @@ -85,4 +85,3 @@ KERNEL_TEX(TextureInfo, __texture_info) KERNEL_TEX(float, __ies) #undef KERNEL_TEX - diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index c2a65dc9999..69ee66b3dd5 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -1238,19 +1238,19 @@ typedef struct KernelFilm { int pass_glossy_color; int pass_transmission_color; int pass_subsurface_color; - + int pass_diffuse_indirect; int pass_glossy_indirect; int pass_transmission_indirect; int pass_subsurface_indirect; int pass_volume_indirect; - + int pass_diffuse_direct; int pass_glossy_direct; int pass_transmission_direct; int pass_subsurface_direct; int pass_volume_direct; - + int pass_emission; int pass_background; int pass_ao; @@ -1671,4 +1671,3 @@ typedef struct WorkTile { CCL_NAMESPACE_END #endif /* __KERNEL_TYPES_H__ */ - diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h index 58032545338..a7072c3ad03 100644 --- a/intern/cycles/kernel/kernel_volume.h +++ b/intern/cycles/kernel/kernel_volume.h @@ -68,7 +68,7 @@ ccl_device_inline bool volume_shader_sample(KernelGlobals *kg, if(!(sd->flag & (SD_EXTINCTION|SD_SCATTER|SD_EMISSION))) return false; - + coeff->sigma_s = make_float3(0.0f, 0.0f, 0.0f); coeff->sigma_t = (sd->flag & SD_EXTINCTION)? sd->closure_transparent_extinction: make_float3(0.0f, 0.0f, 0.0f); @@ -368,7 +368,7 @@ ccl_device float3 kernel_volume_emission_integrate(VolumeShaderCoefficients *coe } else emission *= t; - + return emission; } @@ -475,7 +475,7 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_homogeneous( new_tp = *throughput * transmittance / pdf; } } - else + else #endif if(closure_flag & SD_EXTINCTION) { /* absorption only, no sampling needed */ @@ -596,7 +596,7 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_heterogeneous_distance( xi = 1.0f - (1.0f - xi)/sample_transmittance; } } - else + else #endif if(closure_flag & SD_EXTINCTION) { /* absorption only, no sampling needed */ @@ -751,7 +751,7 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg, PathState *sta step_offset = 0.0f; segment->steps = &segment->stack_step; } - + /* init accumulation variables */ float3 accum_emission = make_float3(0.0f, 0.0f, 0.0f); float3 accum_transmittance = make_float3(1.0f, 1.0f, 1.0f); @@ -1263,7 +1263,7 @@ ccl_device void kernel_volume_stack_enter_exit(KernelGlobals *kg, ShaderData *sd if(!(sd->flag & SD_HAS_VOLUME)) return; - + if(sd->flag & SD_BACKFACING) { /* exit volume object: remove from stack */ for(int i = 0; stack[i].shader != SHADER_NONE; i++) { diff --git a/intern/cycles/kernel/kernels/cpu/kernel_split.cpp b/intern/cycles/kernel/kernels/cpu/kernel_split.cpp index ca750e5a00d..c5e199b0a69 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_split.cpp +++ b/intern/cycles/kernel/kernels/cpu/kernel_split.cpp @@ -60,4 +60,3 @@ #include "kernel/kernel.h" #define KERNEL_ARCH cpu #include "kernel/kernels/cpu/kernel_cpu_impl.h" - diff --git a/intern/cycles/kernel/kernels/cuda/kernel_config.h b/intern/cycles/kernel/kernels/cuda/kernel_config.h index f3d0d721c5c..3808898c5ca 100644 --- a/intern/cycles/kernel/kernels/cuda/kernel_config.h +++ b/intern/cycles/kernel/kernels/cuda/kernel_config.h @@ -106,4 +106,3 @@ #if CUDA_KERNEL_BRANCHED_MAX_REGISTERS > CUDA_THREAD_MAX_REGISTERS # error "Maximum number of registers per thread exceeded" #endif - diff --git a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h index a72fae5e1b1..37cfbbcb235 100644 --- a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h +++ b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h @@ -188,4 +188,3 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x, return make_float4(f, f, f, 1.0f); } } - diff --git a/intern/cycles/kernel/kernels/opencl/kernel_split_function.h b/intern/cycles/kernel/kernels/opencl/kernel_split_function.h index 6aa7681cbed..05e1ddf6da2 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_split_function.h +++ b/intern/cycles/kernel/kernels/opencl/kernel_split_function.h @@ -62,4 +62,3 @@ __kernel void KERNEL_NAME_EVAL(kernel_ocl_path_trace, KERNEL_NAME)( #undef KERNEL_NAME_JOIN #undef KERNEL_NAME_EVAL - diff --git a/intern/cycles/kernel/osl/background.cpp b/intern/cycles/kernel/osl/background.cpp index 30a9e84c399..6924a4144c5 100644 --- a/intern/cycles/kernel/osl/background.cpp +++ b/intern/cycles/kernel/osl/background.cpp @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -96,4 +96,3 @@ ClosureParam *closure_holdout_params() CCLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure) CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp b/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp index ea18f2c8c86..ed5d5235a34 100644 --- a/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp +++ b/intern/cycles/kernel/osl/bsdf_diffuse_ramp.cpp @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -82,4 +82,3 @@ ClosureParam *closure_bsdf_diffuse_ramp_params() CCLOSURE_PREPARE(closure_bsdf_diffuse_ramp_prepare, DiffuseRampClosure) CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp index a26671eb09e..a8acdb8e342 100644 --- a/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp +++ b/intern/cycles/kernel/osl/bsdf_phong_ramp.cpp @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -82,4 +82,3 @@ ClosureParam *closure_bsdf_phong_ramp_params() CCLOSURE_PREPARE(closure_bsdf_phong_ramp_prepare, PhongRampClosure) CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/osl/emissive.cpp b/intern/cycles/kernel/osl/emissive.cpp index 6162786b527..c2a848231f2 100644 --- a/intern/cycles/kernel/osl/emissive.cpp +++ b/intern/cycles/kernel/osl/emissive.cpp @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -72,4 +72,3 @@ ClosureParam *closure_emission_params() CCLOSURE_PREPARE(closure_emission_prepare, GenericEmissiveClosure) CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/osl/osl_bssrdf.cpp b/intern/cycles/kernel/osl/osl_bssrdf.cpp index da7368bbc61..2ebfd5f0c2f 100644 --- a/intern/cycles/kernel/osl/osl_bssrdf.cpp +++ b/intern/cycles/kernel/osl/osl_bssrdf.cpp @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -132,4 +132,3 @@ ClosureParam *closure_bssrdf_params() CCLOSURE_PREPARE(closure_bssrdf_prepare, CBSSRDFClosure) CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp index 6a1e52d7d16..581b38e65c0 100644 --- a/intern/cycles/kernel/osl/osl_closures.cpp +++ b/intern/cycles/kernel/osl/osl_closures.cpp @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -770,4 +770,3 @@ CCLOSURE_PREPARE(closure_henyey_greenstein_prepare, VolumeHenyeyGreensteinClosur CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/osl/osl_closures.h b/intern/cycles/kernel/osl/osl_closures.h index 68dfa9a4650..857cc84afd2 100644 --- a/intern/cycles/kernel/osl/osl_closures.h +++ b/intern/cycles/kernel/osl/osl_closures.h @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -146,4 +146,3 @@ CCLOSURE_PREPARE_STATIC(bsdf_##lower##_prepare, Upper##Closure) CCL_NAMESPACE_END #endif /* __OSL_CLOSURES_H__ */ - diff --git a/intern/cycles/kernel/osl/osl_globals.h b/intern/cycles/kernel/osl/osl_globals.h index 9585d9f4825..30b29793e2d 100644 --- a/intern/cycles/kernel/osl/osl_globals.h +++ b/intern/cycles/kernel/osl/osl_globals.h @@ -95,4 +95,3 @@ CCL_NAMESPACE_END #endif #endif /* __OSL_GLOBALS_H__ */ - diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp index 4b7a4cb34b7..7902381440b 100644 --- a/intern/cycles/kernel/osl/osl_services.cpp +++ b/intern/cycles/kernel/osl/osl_services.cpp @@ -364,7 +364,7 @@ bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring to) { KernelGlobals *kg = kernel_globals; - + if(to == u_ndc) { copy_matrix(result, kernel_data.cam.worldtondc); return true; @@ -381,11 +381,11 @@ bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 copy_matrix(result, kernel_data.cam.worldtocamera); return true; } - + return false; } -bool OSLRenderServices::get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives, +bool OSLRenderServices::get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives, ustring object, TypeDesc type, ustring name, int index, void *val) { @@ -684,7 +684,7 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD float3 f = particle_angular_velocity(kg, particle_id); return set_attribute_float3(f, type, derivatives, val); } - + /* Geometry Attributes */ else if(name == u_geom_numpolyvertices) { return set_attribute_int(3, type, derivatives, val); @@ -873,7 +873,7 @@ bool OSLRenderServices::get_attribute(ShaderData *sd, bool derivatives, ustring return false; } -bool OSLRenderServices::get_userdata(bool derivatives, ustring name, TypeDesc type, +bool OSLRenderServices::get_userdata(bool derivatives, ustring name, TypeDesc type, OSL::ShaderGlobals *sg, void *val) { return false; /* disabled by lockgeom */ diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h index 1a40e2ece2b..50044746fd1 100644 --- a/intern/cycles/kernel/osl/osl_services.h +++ b/intern/cycles/kernel/osl/osl_services.h @@ -45,18 +45,18 @@ class OSLRenderServices : public OSL::RendererServices public: OSLRenderServices(); ~OSLRenderServices(); - + void thread_init(KernelGlobals *kernel_globals, OSL::TextureSystem *ts); bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time); bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time); - + bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from, float time); bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring to, float time); - + bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform); bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform); - + bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from); bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from); @@ -195,4 +195,3 @@ private: CCL_NAMESPACE_END #endif /* __OSL_SERVICES_H__ */ - diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp index b7d1c629291..6a690e880ad 100644 --- a/intern/cycles/kernel/osl/osl_shader.cpp +++ b/intern/cycles/kernel/osl/osl_shader.cpp @@ -115,7 +115,7 @@ static void shaderdata_to_shaderglobals(KernelGlobals *kg, ShaderData *sd, PathS globals->backfacing = (sd->flag & SD_BACKFACING); /* shader data to be used in services callbacks */ - globals->renderstate = sd; + globals->renderstate = sd; /* hacky, we leave it to services to fetch actual object matrix */ globals->shader2common = sd; @@ -340,7 +340,7 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state, if(kg->osl->volume_state[shader]) { ss->execute(octx, *(kg->osl->volume_state[shader]), *globals); } - + /* flatten closure tree */ if(globals->Ci) flatten_volume_closure_tree(sd, globals->Ci); @@ -405,4 +405,3 @@ int OSLShader::find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/osl/osl_shader.h b/intern/cycles/kernel/osl/osl_shader.h index 6b392b25cf7..571a3f502be 100644 --- a/intern/cycles/kernel/osl/osl_shader.h +++ b/intern/cycles/kernel/osl/osl_shader.h @@ -67,4 +67,3 @@ CCL_NAMESPACE_END #endif #endif /* __OSL_SHADER_H__ */ - diff --git a/intern/cycles/kernel/shaders/node_color.h b/intern/cycles/kernel/shaders/node_color.h index 2c3a810cb18..fc758bef1fa 100644 --- a/intern/cycles/kernel/shaders/node_color.h +++ b/intern/cycles/kernel/shaders/node_color.h @@ -131,7 +131,7 @@ color hsv_to_rgb(color hsv) else { if (h == 1.0) h = 0.0; - + h *= 6.0; i = floor(h); f = h - i; @@ -150,4 +150,3 @@ color hsv_to_rgb(color hsv) return rgb; } - diff --git a/intern/cycles/kernel/shaders/node_fresnel.h b/intern/cycles/kernel/shaders/node_fresnel.h index de2d40a849c..fcb0efa8445 100644 --- a/intern/cycles/kernel/shaders/node_fresnel.h +++ b/intern/cycles/kernel/shaders/node_fresnel.h @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + float fresnel_dielectric_cos(float cosi, float eta) { /* compute fresnel reflectance without explicitly computing @@ -46,4 +46,3 @@ color fresnel_conductor(float cosi, color eta, color k) (tmp_f + (2.0 * eta * cosi) + cosi2); return (Rparl2 + Rperp2) * 0.5; } - diff --git a/intern/cycles/kernel/shaders/node_ramp_util.h b/intern/cycles/kernel/shaders/node_ramp_util.h index 917fb65c6df..d07d5a98316 100644 --- a/intern/cycles/kernel/shaders/node_ramp_util.h +++ b/intern/cycles/kernel/shaders/node_ramp_util.h @@ -84,6 +84,6 @@ float rgb_ramp_lookup(float ramp[], float at, int interpolate, int extrapolate) if (interpolate && t > 0.0) result = (1.0 - t) * result + t * ramp[i + 1]; - + return result; } diff --git a/intern/cycles/kernel/shaders/node_texture.h b/intern/cycles/kernel/shaders/node_texture.h index fc2cfdcd55c..88305fb320f 100644 --- a/intern/cycles/kernel/shaders/node_texture.h +++ b/intern/cycles/kernel/shaders/node_texture.h @@ -90,11 +90,11 @@ void voronoi(point p, float e, float da[4], point pa[4]) float safe_noise(point p, string type) { float f = 0.0; - + /* Perlin noise in range -1..1 */ if (type == "signed") f = noise("perlin", p); - + /* Perlin noise in range 0..1 */ else f = noise(p); @@ -102,7 +102,7 @@ float safe_noise(point p, string type) /* can happen for big coordinates, things even out to 0.5 then anyway */ if (!isfinite(f)) return 0.5; - + return f; } @@ -114,7 +114,7 @@ float noise_turbulence(point p, float details, int hard) float amp = 1.0; float sum = 0.0; int i, n; - + float octaves = clamp(details, 0.0, 16.0); n = (int)octaves; @@ -128,7 +128,7 @@ float noise_turbulence(point p, float details, int hard) amp *= 0.5; fscale *= 2.0; } - + float rmd = octaves - floor(octaves); if (rmd != 0.0) { @@ -160,7 +160,6 @@ float nonzero(float f, float eps) r = sign(f) * eps; else r = f; - + return r; } - diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h index 091ade4a60d..82223ca0219 100644 --- a/intern/cycles/kernel/shaders/stdosl.h +++ b/intern/cycles/kernel/shaders/stdosl.h @@ -213,7 +213,7 @@ void fresnel (vector I, normal N, float eta, F *= sqr (beta / (g+c)); Kr = F; Kt = (1.0 - Kr) * eta*eta; - // OPT: the following recomputes some of the above values, but it + // OPT: the following recomputes some of the above values, but it // gives us the same result as if the shader-writer called refract() T = refract(I, N, eta); } else { @@ -415,7 +415,7 @@ color transformc (string from, string to, color x) return transformc (to, r); } - + // Matrix functions diff --git a/intern/cycles/kernel/split/kernel_branched.h b/intern/cycles/kernel/split/kernel_branched.h index 368a4395760..ed0a82067f1 100644 --- a/intern/cycles/kernel/split/kernel_branched.h +++ b/intern/cycles/kernel/split/kernel_branched.h @@ -231,4 +231,3 @@ ccl_device_noinline bool kernel_split_branched_path_surface_indirect_light_iter( #endif /* __BRANCHED_PATH__ */ CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/split/kernel_lamp_emission.h b/intern/cycles/kernel/split/kernel_lamp_emission.h index c14f66f664f..5b2c554b922 100644 --- a/intern/cycles/kernel/split/kernel_lamp_emission.h +++ b/intern/cycles/kernel/split/kernel_lamp_emission.h @@ -65,4 +65,3 @@ ccl_device void kernel_lamp_emission(KernelGlobals *kg) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h b/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h index a4cffd77eff..fb08112503a 100644 --- a/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h +++ b/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h @@ -52,4 +52,3 @@ ccl_device void kernel_shadow_blocked_ao(KernelGlobals *kg) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index 2bee4bc7b69..ab69afa051e 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -498,4 +498,3 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a CCL_NAMESPACE_END #endif /* __SVM_H__ */ - diff --git a/intern/cycles/kernel/svm/svm_attribute.h b/intern/cycles/kernel/svm/svm_attribute.h index 229a3f20421..d98f538d089 100644 --- a/intern/cycles/kernel/svm/svm_attribute.h +++ b/intern/cycles/kernel/svm/svm_attribute.h @@ -154,4 +154,3 @@ void svm_node_attr_bump_dy(KernelGlobals *kg, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_bevel.h b/intern/cycles/kernel/svm/svm_bevel.h index 89f4a98e846..19cdb71c20f 100644 --- a/intern/cycles/kernel/svm/svm_bevel.h +++ b/intern/cycles/kernel/svm/svm_bevel.h @@ -223,4 +223,3 @@ ccl_device void svm_node_bevel( } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_brick.h b/intern/cycles/kernel/svm/svm_brick.h index 90fa2a99b67..744d9ff16c5 100644 --- a/intern/cycles/kernel/svm/svm_brick.h +++ b/intern/cycles/kernel/svm/svm_brick.h @@ -36,7 +36,7 @@ ccl_device_noinline float2 svm_brick(float3 p, float mortar_size, float mortar_s float x, y; rownum = floor_to_int(p.y / row_height); - + if(offset_frequency && squash_frequency) { brick_width *= (rownum % squash_frequency) ? 1.0f : squash_amount; /* squash */ offset = (rownum % offset_frequency) ? 0.0f : (brick_width*offset_amount); /* offset */ @@ -66,31 +66,31 @@ ccl_device_noinline float2 svm_brick(float3 p, float mortar_size, float mortar_s } ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) -{ +{ uint4 node2 = read_node(kg, offset); uint4 node3 = read_node(kg, offset); uint4 node4 = read_node(kg, offset); - + /* Input and Output Sockets */ uint co_offset, color1_offset, color2_offset, mortar_offset, scale_offset; uint mortar_size_offset, bias_offset, brick_width_offset, row_height_offset; uint color_offset, fac_offset, mortar_smooth_offset; - + /* RNA properties */ uint offset_frequency, squash_frequency; - + decode_node_uchar4(node.y, &co_offset, &color1_offset, &color2_offset, &mortar_offset); decode_node_uchar4(node.z, &scale_offset, &mortar_size_offset, &bias_offset, &brick_width_offset); decode_node_uchar4(node.w, &row_height_offset, &color_offset, &fac_offset, &mortar_smooth_offset); - + decode_node_uchar4(node2.x, &offset_frequency, &squash_frequency, NULL, NULL); float3 co = stack_load_float3(stack, co_offset); - + float3 color1 = stack_load_float3(stack, color1_offset); float3 color2 = stack_load_float3(stack, color2_offset); float3 mortar = stack_load_float3(stack, mortar_offset); - + float scale = stack_load_float_default(stack, scale_offset, node2.y); float mortar_size = stack_load_float_default(stack, mortar_size_offset, node2.z); float mortar_smooth = stack_load_float_default(stack, mortar_smooth_offset, node4.x); @@ -99,13 +99,13 @@ ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *sta float row_height = stack_load_float_default(stack, row_height_offset, node3.y); float offset_amount = __int_as_float(node3.z); float squash_amount = __int_as_float(node3.w); - + float2 f2 = svm_brick(co*scale, mortar_size, mortar_smooth, bias, brick_width, row_height, offset_amount, offset_frequency, squash_amount, squash_frequency); float tint = f2.x; float f = f2.y; - + if(f != 1.0f) { float facm = 1.0f - tint; color1 = facm * color1 + tint * color2; @@ -118,4 +118,3 @@ ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *sta } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_bump.h b/intern/cycles/kernel/svm/svm_bump.h index 610d9af9e1f..1c1fe155538 100644 --- a/intern/cycles/kernel/svm/svm_bump.h +++ b/intern/cycles/kernel/svm/svm_bump.h @@ -51,4 +51,3 @@ ccl_device void svm_node_leave_bump_eval(KernelGlobals *kg, ShaderData *sd, floa } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_camera.h b/intern/cycles/kernel/svm/svm_camera.h index 90249dfd978..cf90229b53b 100644 --- a/intern/cycles/kernel/svm/svm_camera.h +++ b/intern/cycles/kernel/svm/svm_camera.h @@ -38,4 +38,3 @@ ccl_device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_checker.h b/intern/cycles/kernel/svm/svm_checker.h index cea245991de..45e6c181e9e 100644 --- a/intern/cycles/kernel/svm/svm_checker.h +++ b/intern/cycles/kernel/svm/svm_checker.h @@ -33,7 +33,7 @@ ccl_device_noinline float svm_checker(float3 p) } ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) -{ +{ uint co_offset, color1_offset, color2_offset, scale_offset; uint color_offset, fac_offset; @@ -44,7 +44,7 @@ ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *s float3 color1 = stack_load_float3(stack, color1_offset); float3 color2 = stack_load_float3(stack, color2_offset); float scale = stack_load_float_default(stack, scale_offset, node.w); - + float f = svm_checker(co*scale); if(stack_valid(color_offset)) @@ -54,4 +54,3 @@ ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *s } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index f5b316c67da..4de9cfb88db 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -130,7 +130,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * // calculate weights of the diffuse and specular part float diffuse_weight = (1.0f - saturate(metallic)) * (1.0f - saturate(transmission)); - + float final_transmission = saturate(transmission) * (1.0f - saturate(metallic)); float specular_weight = (1.0f - final_transmission); @@ -713,7 +713,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * bsdf->N = N; bsdf->size = param1; bsdf->smooth = param2; - + if(type == CLOSURE_BSDF_DIFFUSE_TOON_ID) sd->flag |= bsdf_diffuse_toon_setup(bsdf); else @@ -725,7 +725,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * case CLOSURE_BSDF_HAIR_REFLECTION_ID: case CLOSURE_BSDF_HAIR_TRANSMISSION_ID: { float3 weight = sd->svm_closure_weight * mix_weight; - + if(sd->flag & SD_BACKFACING && sd->type & PRIMITIVE_ALL_CURVE) { /* todo: giving a fixed weight here will cause issues when * mixing multiple BSDFS. energy will not be conserved and @@ -1055,4 +1055,3 @@ ccl_device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *st } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_color_util.h b/intern/cycles/kernel/svm/svm_color_util.h index 258cdeb630e..d5945f915c6 100644 --- a/intern/cycles/kernel/svm/svm_color_util.h +++ b/intern/cycles/kernel/svm/svm_color_util.h @@ -60,7 +60,7 @@ ccl_device float3 svm_mix_overlay(float t, float3 col1, float3 col2) outcol.z *= tm + 2.0f*t*col2.z; else outcol.z = 1.0f - (tm + 2.0f*t*(1.0f - col2.z))*(1.0f - outcol.z); - + return outcol; } @@ -167,7 +167,7 @@ ccl_device float3 svm_mix_burn(float t, float3 col1, float3 col2) outcol.z = 1.0f; else outcol.z = tmp; - + return outcol; } @@ -180,7 +180,7 @@ ccl_device float3 svm_mix_hue(float t, float3 col1, float3 col2) if(hsv2.y != 0.0f) { float3 hsv = rgb_to_hsv(outcol); hsv.x = hsv2.x; - float3 tmp = hsv_to_rgb(hsv); + float3 tmp = hsv_to_rgb(hsv); outcol = interp(outcol, tmp, t); } @@ -227,7 +227,7 @@ ccl_device float3 svm_mix_color(float t, float3 col1, float3 col2) float3 hsv = rgb_to_hsv(outcol); hsv.x = hsv2.x; hsv.y = hsv2.y; - float3 tmp = hsv_to_rgb(hsv); + float3 tmp = hsv_to_rgb(hsv); outcol = interp(outcol, tmp, t); } @@ -303,4 +303,3 @@ ccl_device_inline float3 svm_brightness_contrast(float3 color, float brightness, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_convert.h b/intern/cycles/kernel/svm/svm_convert.h index c88ac57e20d..63b1dc6865e 100644 --- a/intern/cycles/kernel/svm/svm_convert.h +++ b/intern/cycles/kernel/svm/svm_convert.h @@ -69,4 +69,3 @@ ccl_device void svm_node_convert(KernelGlobals *kg, ShaderData *sd, float *stack } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h index 533b7f065e6..b85eb9c0458 100644 --- a/intern/cycles/kernel/svm/svm_displace.h +++ b/intern/cycles/kernel/svm/svm_displace.h @@ -160,4 +160,3 @@ ccl_device void svm_node_vector_displacement(KernelGlobals *kg, ShaderData *sd, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h index 3703ec55015..99dda5fb170 100644 --- a/intern/cycles/kernel/svm/svm_fresnel.h +++ b/intern/cycles/kernel/svm/svm_fresnel.h @@ -24,7 +24,7 @@ ccl_device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, decode_node_uchar4(node, &normal_offset, &out_offset, NULL, NULL); float eta = (stack_valid(ior_offset))? stack_load_float(stack, ior_offset): __uint_as_float(ior_value); float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N; - + eta = fmaxf(eta, 1e-5f); eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta; @@ -71,4 +71,3 @@ ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h index 81308d6f12b..05443772505 100644 --- a/intern/cycles/kernel/svm/svm_geometry.h +++ b/intern/cycles/kernel/svm/svm_geometry.h @@ -208,4 +208,3 @@ ccl_device void svm_node_hair_info(KernelGlobals *kg, #endif CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_gradient.h b/intern/cycles/kernel/svm/svm_gradient.h index 74e36e70427..177e0506dee 100644 --- a/intern/cycles/kernel/svm/svm_gradient.h +++ b/intern/cycles/kernel/svm/svm_gradient.h @@ -36,7 +36,7 @@ ccl_device float svm_gradient(float3 p, NodeGradientType type) else if(type == NODE_BLEND_EASING) { float r = fminf(fmaxf(x, 0.0f), 1.0f); float t = r*r; - + return (3.0f*t - 2.0f*t*r); } else if(type == NODE_BLEND_DIAGONAL) { @@ -78,4 +78,3 @@ ccl_device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_hsv.h b/intern/cycles/kernel/svm/svm_hsv.h index 3a1840c12e2..27127b85323 100644 --- a/intern/cycles/kernel/svm/svm_hsv.h +++ b/intern/cycles/kernel/svm/svm_hsv.h @@ -60,4 +60,3 @@ ccl_device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, ui CCL_NAMESPACE_END #endif /* __SVM_HSV_H__ */ - diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index 28565308867..81ee79c984e 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -203,4 +203,3 @@ ccl_device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, floa } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_invert.h b/intern/cycles/kernel/svm/svm_invert.h index 5ce858e2e5d..57cc4281101 100644 --- a/intern/cycles/kernel/svm/svm_invert.h +++ b/intern/cycles/kernel/svm/svm_invert.h @@ -35,4 +35,3 @@ ccl_device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h index 1492e358608..dd4390057cf 100644 --- a/intern/cycles/kernel/svm/svm_light_path.h +++ b/intern/cycles/kernel/svm/svm_light_path.h @@ -74,4 +74,3 @@ ccl_device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_magic.h b/intern/cycles/kernel/svm/svm_magic.h index ac87c77d719..6afaff37acd 100644 --- a/intern/cycles/kernel/svm/svm_magic.h +++ b/intern/cycles/kernel/svm/svm_magic.h @@ -109,4 +109,3 @@ ccl_device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *sta } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_mapping.h b/intern/cycles/kernel/svm/svm_mapping.h index 42a7ae9946f..86181283821 100644 --- a/intern/cycles/kernel/svm/svm_mapping.h +++ b/intern/cycles/kernel/svm/svm_mapping.h @@ -43,4 +43,3 @@ ccl_device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h index d633e54ed8d..c9a838361cd 100644 --- a/intern/cycles/kernel/svm/svm_math.h +++ b/intern/cycles/kernel/svm/svm_math.h @@ -47,4 +47,3 @@ ccl_device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *s } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h index caf0addbf35..04864bd610a 100644 --- a/intern/cycles/kernel/svm/svm_math_util.h +++ b/intern/cycles/kernel/svm/svm_math_util.h @@ -98,7 +98,7 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2) Fac = saturate(Fac1); else Fac = 0.0f; - + return Fac; } @@ -180,4 +180,3 @@ ccl_device_inline float3 svm_math_gamma_color(float3 color, float gamma) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_mix.h b/intern/cycles/kernel/svm/svm_mix.h index 022a68d1928..903a4dacebf 100644 --- a/intern/cycles/kernel/svm/svm_mix.h +++ b/intern/cycles/kernel/svm/svm_mix.h @@ -32,4 +32,3 @@ ccl_device void svm_node_mix(KernelGlobals *kg, ShaderData *sd, float *stack, ui } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_musgrave.h b/intern/cycles/kernel/svm/svm_musgrave.h index 09eba31945e..5d9e12628ca 100644 --- a/intern/cycles/kernel/svm/svm_musgrave.h +++ b/intern/cycles/kernel/svm/svm_musgrave.h @@ -193,7 +193,7 @@ ccl_device float svm_musgrave(NodeMusgraveType type, float dimension, float lacu return intensity*noise_musgrave_ridged_multi_fractal(p, dimension, lacunarity, octaves, offset, gain); else if(type == NODE_MUSGRAVE_HETERO_TERRAIN) return intensity*noise_musgrave_hetero_terrain(p, dimension, lacunarity, octaves, offset); - + return 0.0f; } @@ -232,4 +232,3 @@ ccl_device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float * } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_noise.h b/intern/cycles/kernel/svm/svm_noise.h index 3f75ae5c04e..38074f0faff 100644 --- a/intern/cycles/kernel/svm/svm_noise.h +++ b/intern/cycles/kernel/svm/svm_noise.h @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2011, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -120,7 +120,7 @@ ccl_device int imod(int a, int b) return a < 0 ? a + b : a; } -ccl_device uint phash(int kx, int ky, int kz, int3 p) +ccl_device uint phash(int kx, int ky, int kz, int3 p) { return hash(imod(kx, p.x), imod(ky, p.y), imod(kz, p.z)); } @@ -334,4 +334,3 @@ ccl_device ssef cellnoise_color(const ssef& p) #endif CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_noisetex.h b/intern/cycles/kernel/svm/svm_noisetex.h index 0347ab7b193..c02940f96d6 100644 --- a/intern/cycles/kernel/svm/svm_noisetex.h +++ b/intern/cycles/kernel/svm/svm_noisetex.h @@ -57,4 +57,3 @@ ccl_device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *sta } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_normal.h b/intern/cycles/kernel/svm/svm_normal.h index 53abef71012..fe46d79fe15 100644 --- a/intern/cycles/kernel/svm/svm_normal.h +++ b/intern/cycles/kernel/svm/svm_normal.h @@ -36,4 +36,3 @@ ccl_device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_ramp.h b/intern/cycles/kernel/svm/svm_ramp.h index 368740f64c7..a3e4b6e87cd 100644 --- a/intern/cycles/kernel/svm/svm_ramp.h +++ b/intern/cycles/kernel/svm/svm_ramp.h @@ -109,4 +109,3 @@ ccl_device void svm_node_curves(KernelGlobals *kg, ShaderData *sd, float *stack, CCL_NAMESPACE_END #endif /* __SVM_RAMP_H__ */ - diff --git a/intern/cycles/kernel/svm/svm_ramp_util.h b/intern/cycles/kernel/svm/svm_ramp_util.h index b0adadae9b7..a67689ff9d1 100644 --- a/intern/cycles/kernel/svm/svm_ramp_util.h +++ b/intern/cycles/kernel/svm/svm_ramp_util.h @@ -96,4 +96,3 @@ ccl_device float float_ramp_lookup(const float *ramp, CCL_NAMESPACE_END #endif /* __SVM_RAMP_UTIL_H__ */ - diff --git a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h index 6f51b163756..1096aed2d97 100644 --- a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h +++ b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h @@ -20,11 +20,11 @@ ccl_device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *s { uint4 node1 = read_node(kg, offset); uint color_out = node1.y; - + float hue = stack_load_float(stack, hue_in); float saturation = stack_load_float(stack, saturation_in); float value = stack_load_float(stack, value_in); - + /* Combine, and convert back to RGB */ float3 color = hsv_to_rgb(make_float3(hue, saturation, value)); @@ -36,9 +36,9 @@ ccl_device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float * { uint4 node1 = read_node(kg, offset); uint value_out = node1.y; - + float3 color = stack_load_float3(stack, color_in); - + /* Convert to HSV */ color = rgb_to_hsv(color); @@ -51,4 +51,3 @@ ccl_device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float * } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_sepcomb_vector.h b/intern/cycles/kernel/svm/svm_sepcomb_vector.h index 63570dd6942..0d85c0d6f1d 100644 --- a/intern/cycles/kernel/svm/svm_sepcomb_vector.h +++ b/intern/cycles/kernel/svm/svm_sepcomb_vector.h @@ -41,4 +41,3 @@ ccl_device void svm_node_separate_vector(ShaderData *sd, float *stack, uint ivec } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h index b83a7168541..092f6e045d6 100644 --- a/intern/cycles/kernel/svm/svm_sky.h +++ b/intern/cycles/kernel/svm/svm_sky.h @@ -110,7 +110,7 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack /* Define variables */ float sunphi, suntheta, radiance_x, radiance_y, radiance_z; float config_x[9], config_y[9], config_z[9]; - + /* Load data */ uint dir_offset = node.y; uint out_offset = node.z; @@ -121,49 +121,49 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack suntheta = data.y; radiance_x = data.z; radiance_y = data.w; - + data = read_node_float(kg, offset); radiance_z = data.x; config_x[0] = data.y; config_x[1] = data.z; config_x[2] = data.w; - + data = read_node_float(kg, offset); config_x[3] = data.x; config_x[4] = data.y; config_x[5] = data.z; config_x[6] = data.w; - + data = read_node_float(kg, offset); config_x[7] = data.x; config_x[8] = data.y; config_y[0] = data.z; config_y[1] = data.w; - + data = read_node_float(kg, offset); config_y[2] = data.x; config_y[3] = data.y; config_y[4] = data.z; config_y[5] = data.w; - + data = read_node_float(kg, offset); config_y[6] = data.x; config_y[7] = data.y; config_y[8] = data.z; config_z[0] = data.w; - + data = read_node_float(kg, offset); config_z[1] = data.x; config_z[2] = data.y; config_z[3] = data.z; config_z[4] = data.w; - + data = read_node_float(kg, offset); config_z[5] = data.x; config_z[6] = data.y; config_z[7] = data.z; config_z[8] = data.w; - + float3 dir = stack_load_float3(stack, dir_offset); float3 f; @@ -183,4 +183,3 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h index 6ff39e5f587..7c207083929 100644 --- a/intern/cycles/kernel/svm/svm_tex_coord.h +++ b/intern/cycles/kernel/svm/svm_tex_coord.h @@ -323,7 +323,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st color.y = -color.y; color.z = -color.z; } - + /* object, world space */ N = color; @@ -392,4 +392,3 @@ ccl_device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_texture.h b/intern/cycles/kernel/svm/svm_texture.h index dcb00f7dd55..57729817bdc 100644 --- a/intern/cycles/kernel/svm/svm_texture.h +++ b/intern/cycles/kernel/svm/svm_texture.h @@ -61,4 +61,3 @@ ccl_device_noinline float noise_turbulence(float3 p, float octaves, int hard) } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index 54db18cd7bb..b94a83b6712 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -24,7 +24,7 @@ CCL_NAMESPACE_BEGIN /* SVM stack has a fixed size */ #define SVM_STACK_SIZE 255 /* SVM stack offsets with this value indicate that it's not on the stack */ -#define SVM_STACK_INVALID 255 +#define SVM_STACK_INVALID 255 #define SVM_BUMP_EVAL_STATE_SIZE 9 @@ -505,4 +505,3 @@ typedef enum ClosureType { CCL_NAMESPACE_END #endif /* __SVM_TYPES_H__ */ - diff --git a/intern/cycles/kernel/svm/svm_value.h b/intern/cycles/kernel/svm/svm_value.h index c1c2b539df3..062aee2956e 100644 --- a/intern/cycles/kernel/svm/svm_value.h +++ b/intern/cycles/kernel/svm/svm_value.h @@ -33,4 +33,3 @@ ccl_device void svm_node_value_v(KernelGlobals *kg, ShaderData *sd, float *stack } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_vector_transform.h b/intern/cycles/kernel/svm/svm_vector_transform.h index 4e92f27acdb..f6ec36ba41f 100644 --- a/intern/cycles/kernel/svm/svm_vector_transform.h +++ b/intern/cycles/kernel/svm/svm_vector_transform.h @@ -22,20 +22,20 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo { uint itype, ifrom, ito; uint vector_in, vector_out; - + decode_node_uchar4(node.y, &itype, &ifrom, &ito, NULL); decode_node_uchar4(node.z, &vector_in, &vector_out, NULL, NULL); - + float3 in = stack_load_float3(stack, vector_in); - + NodeVectorTransformType type = (NodeVectorTransformType)itype; NodeVectorTransformConvertSpace from = (NodeVectorTransformConvertSpace)ifrom; NodeVectorTransformConvertSpace to = (NodeVectorTransformConvertSpace)ito; - + Transform tfm; bool is_object = (sd->object != OBJECT_NONE); bool is_direction = (type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR || type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL); - + /* From world */ if(from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD) { if(to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) { @@ -52,7 +52,7 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo object_inverse_position_transform(kg, sd, &in); } } - + /* From camera */ else if(from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) { if(to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) { @@ -69,7 +69,7 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo object_inverse_position_transform(kg, sd, &in); } } - + /* From object */ else if(from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) { if((to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) && is_object) { @@ -86,11 +86,11 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo in = transform_point(&tfm, in); } } - + /* Normalize Normal */ if(type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL) in = normalize(in); - + /* Output */ if(stack_valid(vector_out)) { stack_store_float3(stack, vector_out, in); @@ -98,4 +98,3 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h index d612d7e973f..9bfb182544b 100644 --- a/intern/cycles/kernel/svm/svm_voronoi.h +++ b/intern/cycles/kernel/svm/svm_voronoi.h @@ -137,4 +137,3 @@ ccl_device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *s } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_wave.h b/intern/cycles/kernel/svm/svm_wave.h index 6ce69458a03..7b60ab6e6ae 100644 --- a/intern/cycles/kernel/svm/svm_wave.h +++ b/intern/cycles/kernel/svm/svm_wave.h @@ -63,4 +63,3 @@ ccl_device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stac } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_wavelength.h b/intern/cycles/kernel/svm/svm_wavelength.h index 62e026278ac..e935fd20690 100644 --- a/intern/cycles/kernel/svm/svm_wavelength.h +++ b/intern/cycles/kernel/svm/svm_wavelength.h @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2013, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -71,12 +71,12 @@ ccl_static_constant float cie_colour_match[81][3] = { }; ccl_device void svm_node_wavelength(KernelGlobals *kg, ShaderData *sd, float *stack, uint wavelength, uint color_out) -{ +{ float lambda_nm = stack_load_float(stack, wavelength); float ii = (lambda_nm-380.0f) * (1.0f/5.0f); // scaled 0..80 int i = float_to_int(ii); float3 color; - + if(i < 0 || i >= 80) { color = make_float3(0.0f, 0.0f, 0.0f); } @@ -85,10 +85,10 @@ ccl_device void svm_node_wavelength(KernelGlobals *kg, ShaderData *sd, float *st ccl_constant float *c = cie_colour_match[i]; color = interp(make_float3(c[0], c[1], c[2]), make_float3(c[3], c[4], c[5]), ii); } - + color = xyz_to_rgb(kg, color); color *= 1.0f/2.52f; // Empirical scale from lg to make all comps <= 1 - + /* Clamp to zero if values are smaller */ color = max(color, make_float3(0.0f, 0.0f, 0.0f)); @@ -96,4 +96,3 @@ ccl_device void svm_node_wavelength(KernelGlobals *kg, ShaderData *sd, float *st } CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/svm/svm_wireframe.h b/intern/cycles/kernel/svm/svm_wireframe.h index 3c6353c8001..35df9e8a0e7 100644 --- a/intern/cycles/kernel/svm/svm_wireframe.h +++ b/intern/cycles/kernel/svm/svm_wireframe.h @@ -5,7 +5,7 @@ * All Rights Reserved. * * Modifications Copyright 2013, Blender Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -134,4 +134,3 @@ ccl_device void svm_node_wireframe(KernelGlobals *kg, } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp index 8c77687d9cc..a7450849195 100644 --- a/intern/cycles/render/attribute.cpp +++ b/intern/cycles/render/attribute.cpp @@ -202,7 +202,7 @@ bool Attribute::same_storage(TypeDesc a, TypeDesc b) { if(a == b) return true; - + if(a == TypeDesc::TypeColor || a == TypeDesc::TypePoint || a == TypeDesc::TypeVector || a == TypeDesc::TypeNormal) { @@ -292,7 +292,7 @@ const char *Attribute::standard_name(AttributeStandard std) case ATTR_STD_NUM: return ""; } - + return ""; } @@ -476,7 +476,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name) } attr->std = std; - + return attr; } @@ -682,7 +682,7 @@ bool AttributeRequestSet::find(ustring name) foreach(AttributeRequest& req, requests) if(req.name == name) return true; - + return false; } @@ -706,4 +706,3 @@ void AttributeRequestSet::clear() } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/attribute.h b/intern/cycles/render/attribute.h index 5cb6c75aab2..40e5be2e1b2 100644 --- a/intern/cycles/render/attribute.h +++ b/intern/cycles/render/attribute.h @@ -173,4 +173,3 @@ public: CCL_NAMESPACE_END #endif /* __ATTRIBUTE_H__ */ - diff --git a/intern/cycles/render/background.cpp b/intern/cycles/render/background.cpp index df3b65be110..d8a49bf6a5e 100644 --- a/intern/cycles/render/background.cpp +++ b/intern/cycles/render/background.cpp @@ -62,7 +62,7 @@ void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene { if(!need_update) return; - + device_free(device, dscene); Shader *bg_shader = shader; @@ -135,4 +135,3 @@ void Background::tag_update(Scene *scene) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/background.h b/intern/cycles/render/background.h index 145c05f1c18..3f56dedb2c8 100644 --- a/intern/cycles/render/background.h +++ b/intern/cycles/render/background.h @@ -60,4 +60,3 @@ public: CCL_NAMESPACE_END #endif /* __BACKGROUND_H__ */ - diff --git a/intern/cycles/render/bake.h b/intern/cycles/render/bake.h index fbb8686b8f6..a811eac3327 100644 --- a/intern/cycles/render/bake.h +++ b/intern/cycles/render/bake.h @@ -84,4 +84,3 @@ private: CCL_NAMESPACE_END #endif /* __BAKE_H__ */ - diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 6f560380b40..1724e254819 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -448,4 +448,3 @@ bool DisplayBuffer::draw_ready() } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h index ee7c0490dfd..1b06ffe33a6 100644 --- a/intern/cycles/render/buffers.h +++ b/intern/cycles/render/buffers.h @@ -147,4 +147,3 @@ public: CCL_NAMESPACE_END #endif /* __BUFFERS_H__ */ - diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index 734cdffd5c5..cc3dd1c923b 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -246,7 +246,7 @@ void Camera::update(Scene *scene) cameratoscreen = projection_orthographic(nearclip, farclip); else cameratoscreen = projection_identity(); - + ProjectionTransform screentocamera = projection_inverse(cameratoscreen); rastertocamera = screentocamera * rastertoscreen; diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h index 37d05c01bd9..323f2c61ca4 100644 --- a/intern/cycles/render/camera.h +++ b/intern/cycles/render/camera.h @@ -181,7 +181,7 @@ public: /* functions */ Camera(); ~Camera(); - + void compute_auto_viewplane(); void update(Scene *scene); @@ -213,4 +213,3 @@ private: CCL_NAMESPACE_END #endif /* __CAMERA_H__ */ - diff --git a/intern/cycles/render/constant_fold.h b/intern/cycles/render/constant_fold.h index cc24d614206..26fa4e8b1c8 100644 --- a/intern/cycles/render/constant_fold.h +++ b/intern/cycles/render/constant_fold.h @@ -71,4 +71,3 @@ public: CCL_NAMESPACE_END #endif /* __CONSTANT_FOLD_H__ */ - diff --git a/intern/cycles/render/curves.cpp b/intern/cycles/render/curves.cpp index 4c085b928fb..58b71d3e122 100644 --- a/intern/cycles/render/curves.cpp +++ b/intern/cycles/render/curves.cpp @@ -188,4 +188,3 @@ void CurveSystemManager::tag_update_mesh() need_mesh_update = true; } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/curves.h b/intern/cycles/render/curves.h index 8834764bd63..62066d8a809 100644 --- a/intern/cycles/render/curves.h +++ b/intern/cycles/render/curves.h @@ -120,4 +120,3 @@ public: CCL_NAMESPACE_END #endif /* __CURVES_H__ */ - diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index 69828cc78da..8f3596ade58 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -175,11 +175,11 @@ bool Pass::equals(const array& A, const array& B) { if(A.size() != B.size()) return false; - + for(int i = 0; i < A.size(); i++) if(A[i].type != B[i].type) return false; - + return true; } @@ -188,7 +188,7 @@ bool Pass::contains(const array& passes, PassType type) for(size_t i = 0; i < passes.size(); i++) if(passes[i].type == type) return true; - + return false; } @@ -302,7 +302,7 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) { if(!need_update) return; - + device_free(device, dscene, scene); KernelFilm *kfilm = &dscene->data.film; @@ -510,4 +510,3 @@ void Film::tag_update(Scene * /*scene*/) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h index 29b1e7e9157..6ab2eea79b8 100644 --- a/intern/cycles/render/film.h +++ b/intern/cycles/render/film.h @@ -93,4 +93,3 @@ public: CCL_NAMESPACE_END #endif /* __FILM_H__ */ - diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 8b179f742c4..78a2039c423 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -745,7 +745,7 @@ void ShaderGraph::clean(Scene *scene) vector visited(num_node_ids, false); vector on_stack(num_node_ids, false); - + /* break cycles */ break_cycles(output(), visited, on_stack); @@ -860,7 +860,7 @@ void ShaderGraph::refine_bump_nodes() copy_nodes(nodes_bump, nodes_dx); copy_nodes(nodes_bump, nodes_dy); - + /* mark nodes to indicate they are use for bump computation, so that any texture coordinates are shifted by dx/dy when sampling */ foreach(ShaderNode *node, nodes_bump) @@ -876,13 +876,13 @@ void ShaderGraph::refine_bump_nodes() connect(out_dx, node->input("SampleX")); connect(out_dy, node->input("SampleY")); - + /* add generated nodes */ foreach(NodePair& pair, nodes_dx) add(pair.second); foreach(NodePair& pair, nodes_dy) add(pair.second); - + /* connect what is connected is bump to samplecenter input*/ connect(out , node->input("SampleCenter")); @@ -941,7 +941,7 @@ void ShaderGraph::bump_from_displacement(bool use_object_space) * this for bump from displacement, this will be the only bump allowed to * overwrite the shader normal */ ShaderNode *set_normal = add(new SetNormalNode()); - + /* add bump node and connect copied graphs to it */ BumpNode *bump = (BumpNode*)add(new BumpNode()); bump->use_object_space = use_object_space; @@ -973,7 +973,7 @@ void ShaderGraph::bump_from_displacement(bool use_object_space) connect(dot_center->output("Value"), bump->input("SampleCenter")); connect(dot_dx->output("Value"), bump->input("SampleX")); connect(dot_dy->output("Value"), bump->input("SampleY")); - + /* connect the bump out to the set normal in: */ connect(bump->output("Normal"), set_normal->input("Direction")); @@ -996,7 +996,7 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight * the graph into nodes that feed weights into closure nodes. this is too * avoid building a closure tree and then flattening it, and instead write it * directly to an array */ - + if(node->special_type == SHADER_SPECIAL_TYPE_COMBINE_CLOSURE) { ShaderInput *fin = node->input("Fac"); ShaderInput *cl1in = node->input("Closure1"); @@ -1007,8 +1007,8 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight /* mix closure: add node to mix closure weights */ MixClosureWeightNode *mix_node = new MixClosureWeightNode(); add(mix_node); - ShaderInput *fac_in = mix_node->input("Fac"); - ShaderInput *weight_in = mix_node->input("Weight"); + ShaderInput *fac_in = mix_node->input("Fac"); + ShaderInput *weight_in = mix_node->input("Weight"); if(fin->link) connect(fin->link, fac_in); @@ -1171,4 +1171,3 @@ void ShaderGraph::dump_graph(const char *filename) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h index 5d986ae4827..426522066b3 100644 --- a/intern/cycles/render/graph.h +++ b/intern/cycles/render/graph.h @@ -165,7 +165,7 @@ public: int id; /* index in graph node array */ ShaderBump bump; /* for bump mapping utility */ - + ShaderNodeSpecialType special_type; /* special node type */ /* ** Selective nodes compilation ** */ @@ -294,4 +294,3 @@ protected: CCL_NAMESPACE_END #endif /* __GRAPH_H__ */ - diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 3c49d17aa82..7f0660cee07 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -1034,4 +1034,3 @@ void ImageManager::device_free(Device *device) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index 4fd09adaa64..5932c24cb74 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -167,4 +167,3 @@ private: CCL_NAMESPACE_END #endif /* __IMAGE_H__ */ - diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index 9c276bcab31..d86eb8fc5d3 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -118,7 +118,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene } /* Transparent Shadows - * We only need to enable transparent shadows, if we actually have + * We only need to enable transparent shadows, if we actually have * transparent shaders in the scene. Otherwise we can disable it * to improve performance a bit. */ kintegrator->transparent_shadows = false; @@ -141,7 +141,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene kintegrator->use_ambient_occlusion = ((Pass::contains(scene->film->passes, PASS_AO)) || dscene->data.background.ao_factor != 0.0f); - + kintegrator->sample_clamp_direct = (sample_clamp_direct == 0.0f)? FLT_MAX: sample_clamp_direct*3.0f; kintegrator->sample_clamp_indirect = (sample_clamp_indirect == 0.0f)? FLT_MAX: sample_clamp_indirect*3.0f; @@ -236,4 +236,3 @@ void Integrator::tag_update(Scene *scene) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h index 3cb430d72b4..f68400ac416 100644 --- a/intern/cycles/render/integrator.h +++ b/intern/cycles/render/integrator.h @@ -75,7 +75,7 @@ public: NUM_METHODS, }; - + Method method; SamplingPattern sampling_pattern; @@ -95,4 +95,3 @@ public: CCL_NAMESPACE_END #endif /* __INTEGRATOR_H__ */ - diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 122c5dfb07a..da29e1a255a 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -759,7 +759,7 @@ void LightManager::device_update_points(Device *, float area = len(axisu)*len(axisv); float invarea = (area > 0.0f)? 1.0f/area: 1.0f; float3 dir = light->dir; - + dir = safe_normalize(dir); if(light->use_mis && area > 0.0f) @@ -788,7 +788,7 @@ void LightManager::device_update_points(Device *, float spot_angle = cosf(light->spot_angle*0.5f); float spot_smooth = (1.0f - spot_angle)*light->spot_smooth; float3 dir = light->dir; - + dir = safe_normalize(dir); if(light->use_mis && radius > 0.0f) @@ -1027,4 +1027,3 @@ void LightManager::device_update_ies(DeviceScene *dscene) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h index 5f8677ee2f2..32a911dc256 100644 --- a/intern/cycles/render/light.h +++ b/intern/cycles/render/light.h @@ -140,4 +140,3 @@ protected: CCL_NAMESPACE_END #endif /* __LIGHT_H__ */ - diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h index e370f8a2021..e7dc1c8e5cf 100644 --- a/intern/cycles/render/mesh.h +++ b/intern/cycles/render/mesh.h @@ -388,4 +388,3 @@ protected: CCL_NAMESPACE_END #endif /* __MESH_H__ */ - diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp index ad2a5713bcb..53b9bfa3451 100644 --- a/intern/cycles/render/mesh_displace.cpp +++ b/intern/cycles/render/mesh_displace.cpp @@ -89,7 +89,7 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me int object = object_index; int prim = mesh->tri_offset + i; float u, v; - + switch(j) { case 0: u = 1.0f; @@ -113,7 +113,7 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me if(d_input_size == 0) return false; - + /* run device task */ device_vector d_output(device, "displace_output", MEM_READ_WRITE); d_output.alloc(d_input_size); @@ -319,4 +319,3 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/mesh_subdivision.cpp b/intern/cycles/render/mesh_subdivision.cpp index 9dd81eb6700..13fda99e9cc 100644 --- a/intern/cycles/render/mesh_subdivision.cpp +++ b/intern/cycles/render/mesh_subdivision.cpp @@ -613,4 +613,3 @@ void Mesh::tessellate(DiagSplit *split) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 601d72c4b1b..beff7f91348 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -82,7 +82,7 @@ Transform TextureMapping::compute_transform() mmat[1][y_mapping-1] = 1.0f; if(z_mapping != NONE) mmat[2][z_mapping-1] = 1.0f; - + float3 scale_clamped = scale; if(type == TEXTURE || type == NORMAL) { @@ -94,7 +94,7 @@ Transform TextureMapping::compute_transform() if(fabsf(scale.z) < 1e-5f) scale_clamped.z = signf(scale.z)*1e-5f; } - + Transform smat = transform_scale(scale_clamped); Transform rmat = transform_euler(rotation); Transform tmat = transform_translate(translation); @@ -137,12 +137,12 @@ bool TextureMapping::skip() return false; if(scale != make_float3(1.0f, 1.0f, 1.0f)) return false; - + if(x_mapping != X || y_mapping != Y || z_mapping != Z) return false; if(use_minmax) return false; - + return true; } @@ -520,7 +520,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler) compiler.stack_assign_if_linked(alpha_out), srgb), projection); - + tex_mapping.compile_end(compiler, vector_in, vector_offset); } else { @@ -612,7 +612,7 @@ static void sky_texture_precompute_old(SunSky *sunsky, float3 dir, float turbidi * zenith_Y/x/y is now radiance_x/y/z * perez_Y/x/y is now config_x/y/z */ - + float2 spherical = sky_spherical_coordinates(dir); float theta = spherical.x; float phi = spherical.y; @@ -676,12 +676,12 @@ static void sky_texture_precompute_new(SunSky *sunsky, float3 dir, float turbidi float2 spherical = sky_spherical_coordinates(dir); float theta = spherical.x; float phi = spherical.y; - + /* Clamp Turbidity */ - turbidity = clamp(turbidity, 0.0f, 10.0f); - + turbidity = clamp(turbidity, 0.0f, 10.0f); + /* Clamp to Horizon */ - theta = clamp(theta, 0.0f, M_PI_2_F); + theta = clamp(theta, 0.0f, M_PI_2_F); sunsky->theta = theta; sunsky->phi = phi; @@ -773,7 +773,7 @@ void SkyTextureNode::compile(OSLCompiler& compiler) sky_texture_precompute_new(&sunsky, sun_direction, turbidity, ground_albedo); else assert(false); - + compiler.parameter(this, "type"); compiler.parameter("theta", sunsky.theta); compiler.parameter("phi", sunsky.phi); @@ -1296,7 +1296,7 @@ void CheckerTextureNode::compile(SVMCompiler& compiler) ShaderInput *color1_in = input("Color1"); ShaderInput *color2_in = input("Color2"); ShaderInput *scale_in = input("Scale"); - + ShaderOutput *color_out = output("Color"); ShaderOutput *fac_out = output("Fac"); @@ -1371,7 +1371,7 @@ void BrickTextureNode::compile(SVMCompiler& compiler) ShaderInput *bias_in = input("Bias"); ShaderInput *brick_width_in = input("Brick Width"); ShaderInput *row_height_in = input("Row Height"); - + ShaderOutput *color_out = output("Color"); ShaderOutput *fac_out = output("Fac"); @@ -1393,7 +1393,7 @@ void BrickTextureNode::compile(SVMCompiler& compiler) compiler.stack_assign_if_linked(color_out), compiler.stack_assign_if_linked(fac_out), compiler.stack_assign_if_linked(mortar_smooth_in))); - + compiler.add_node(compiler.encode_uchar4(offset_frequency, squash_frequency), __float_as_int(scale), __float_as_int(mortar_size), @@ -2310,7 +2310,7 @@ ToonBsdfNode::ToonBsdfNode() void ToonBsdfNode::compile(SVMCompiler& compiler) { closure = component; - + BsdfNode::compile(compiler, input("Size"), input("Smooth")); } @@ -2864,7 +2864,7 @@ void VolumeNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(color_in)); else compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color); - + compiler.add_node(NODE_CLOSURE_VOLUME, compiler.encode_uchar4(closure, (param1)? compiler.stack_assign(param1): SVM_STACK_INVALID, @@ -3158,7 +3158,7 @@ void GeometryNode::compile(SVMCompiler& compiler) geom_node = NODE_GEOMETRY_BUMP_DY; attr_node = NODE_ATTR_BUMP_DY; } - + out = output("Position"); if(!out->links.empty()) { compiler.add_node(geom_node, NODE_GEOM_P, compiler.stack_assign(out)); @@ -3287,7 +3287,7 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler) attr_node = NODE_ATTR_BUMP_DY; geom_node = NODE_GEOMETRY_BUMP_DY; } - + out = output("Generated"); if(!out->links.empty()) { if(compiler.background) { @@ -3363,7 +3363,7 @@ void TextureCoordinateNode::compile(OSLCompiler& compiler) compiler.parameter("bump_offset", "dy"); else compiler.parameter("bump_offset", "center"); - + if(compiler.background) compiler.parameter("is_background", true); if(compiler.output_type() == SHADER_TYPE_VOLUME) @@ -3525,7 +3525,7 @@ void LightPathNode::compile(SVMCompiler& compiler) if(!out->links.empty()) { compiler.add_node(NODE_LIGHT_PATH, NODE_LP_transmission, compiler.stack_assign(out)); } - + out = output("Is Volume Scatter Ray"); if(!out->links.empty()) { compiler.add_node(NODE_LIGHT_PATH, NODE_LP_volume_scatter, compiler.stack_assign(out)); @@ -3535,7 +3535,7 @@ void LightPathNode::compile(SVMCompiler& compiler) if(!out->links.empty()) { compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_length, compiler.stack_assign(out)); } - + out = output("Ray Depth"); if(!out->links.empty()) { compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_depth, compiler.stack_assign(out)); @@ -3728,7 +3728,7 @@ void ParticleInfoNode::attributes(Shader *shader, AttributeRequestSet *attribute void ParticleInfoNode::compile(SVMCompiler& compiler) { ShaderOutput *out; - + out = output("Index"); if(!out->links.empty()) { compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_INDEX, compiler.stack_assign(out)); @@ -3738,22 +3738,22 @@ void ParticleInfoNode::compile(SVMCompiler& compiler) if(!out->links.empty()) { compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_RANDOM, compiler.stack_assign(out)); } - + out = output("Age"); if(!out->links.empty()) { compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_AGE, compiler.stack_assign(out)); } - + out = output("Lifetime"); if(!out->links.empty()) { compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_LIFETIME, compiler.stack_assign(out)); } - + out = output("Location"); if(!out->links.empty()) { compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_LOCATION, compiler.stack_assign(out)); } - + /* quaternion data is not yet supported by Cycles */ #if 0 out = output("Rotation"); @@ -3761,17 +3761,17 @@ void ParticleInfoNode::compile(SVMCompiler& compiler) compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_ROTATION, compiler.stack_assign(out)); } #endif - + out = output("Size"); if(!out->links.empty()) { compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_SIZE, compiler.stack_assign(out)); } - + out = output("Velocity"); if(!out->links.empty()) { compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_VELOCITY, compiler.stack_assign(out)); } - + out = output("Angular Velocity"); if(!out->links.empty()) { compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_ANGULAR_VELOCITY, compiler.stack_assign(out)); @@ -3824,7 +3824,7 @@ void HairInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes) void HairInfoNode::compile(SVMCompiler& compiler) { ShaderOutput *out; - + out = output("Is Strand"); if(!out->links.empty()) { compiler.add_node(NODE_HAIR_INFO, NODE_INFO_CURVE_IS_STRAND, compiler.stack_assign(out)); @@ -4747,7 +4747,7 @@ void AttributeNode::compile(OSLCompiler& compiler) compiler.parameter("bump_offset", "dy"); else compiler.parameter("bump_offset", "center"); - + if(Attribute::name_standard(attribute.c_str()) != ATTR_STD_NONE) compiler.parameter("name", (string("geom:") + attribute.c_str()).c_str()); else @@ -5553,7 +5553,7 @@ void RGBRampNode::compile(OSLCompiler& compiler) compiler.parameter_color_array("ramp_color", ramp); compiler.parameter_array("ramp_alpha", ramp_alpha.data(), ramp_alpha.size()); compiler.parameter(this, "interpolate"); - + compiler.add(this, "node_rgb_ramp"); } @@ -5586,7 +5586,7 @@ void SetNormalNode::compile(SVMCompiler& compiler) void SetNormalNode::compile(OSLCompiler& compiler) { - compiler.add(this, "node_set_normal"); + compiler.add(this, "node_set_normal"); } /* OSLNode */ @@ -5707,7 +5707,7 @@ void NormalMapNode::attributes(Shader *shader, AttributeRequestSet *attributes) attributes->add(ATTR_STD_VERTEX_NORMAL); } - + ShaderNode::attributes(shader, attributes); } @@ -5752,7 +5752,7 @@ void NormalMapNode::compile(OSLCompiler& compiler) } compiler.parameter(this, "space"); - compiler.add(this, "node_normal_map"); + compiler.add(this, "node_normal_map"); } /* Tangent */ @@ -5797,7 +5797,7 @@ void TangentNode::attributes(Shader *shader, AttributeRequestSet *attributes) else attributes->add(ATTR_STD_GENERATED); } - + ShaderNode::attributes(shader, attributes); } @@ -5833,7 +5833,7 @@ void TangentNode::compile(OSLCompiler& compiler) compiler.parameter(this, "direction_type"); compiler.parameter(this, "axis"); - compiler.add(this, "node_tangent"); + compiler.add(this, "node_tangent"); } /* Bevel */ diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index be52cf40a17..f24445ea2e9 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -1121,4 +1121,3 @@ public: CCL_NAMESPACE_END #endif /* __NODES_H__ */ - diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 4d64d841206..e3f35c366d6 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -183,7 +183,7 @@ void Object::apply_transform(bool apply_to_motion) { if(!mesh || tfm == transform_identity()) return; - + /* triangles */ if(mesh->verts.size()) { /* store matrix to transform later. when accessing these as attributes we @@ -194,7 +194,7 @@ void Object::apply_transform(bool apply_to_motion) /* apply to mesh vertices */ for(size_t i = 0; i < mesh->verts.size(); i++) mesh->verts[i] = transform_point(&tfm, mesh->verts[i]); - + if(apply_to_motion) { Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); @@ -840,4 +840,3 @@ void ObjectManager::tag_update(Scene *scene) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h index c7212ae25f9..b80c4aef70b 100644 --- a/intern/cycles/render/object.h +++ b/intern/cycles/render/object.h @@ -129,4 +129,3 @@ protected: CCL_NAMESPACE_END #endif /* __OBJECT_H__ */ - diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index dde622bff8a..fdd872f62b9 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -122,7 +122,7 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene shader->need_update = false; need_update = false; - + /* set texture system */ scene->image_manager->set_osl_texture_system((void*)ts); @@ -578,7 +578,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderInput *input) /* strip whitespace */ while((i = sname.find(" ")) != string::npos) sname.replace(i, 1, ""); - + /* if output exists with the same name, add "In" suffix */ foreach(ShaderOutput *output, node->outputs) { if(input->name() == output->name()) { @@ -586,7 +586,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderInput *input) break; } } - + return sname; } @@ -598,7 +598,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderOutput *output) /* strip whitespace */ while((i = sname.find(" ")) != string::npos) sname.replace(i, 1, ""); - + /* if input exists with the same name, add "Out" suffix */ foreach(ShaderInput *input, node->inputs) { if(input->name() == output->name()) { @@ -606,7 +606,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderOutput *output) break; } } - + return sname; } @@ -614,7 +614,7 @@ bool OSLCompiler::node_skip_input(ShaderNode *node, ShaderInput *input) { /* exception for output node, only one input is actually used * depending on the current shader type */ - + if(input->flags() & SocketType::SVM_INTERNAL) return true; @@ -704,7 +704,7 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath) ss->Shader("displacement", name, id(node).c_str()); else assert(0); - + /* link inputs to other nodes */ foreach(ShaderInput *input, node->inputs) { if(input->link) { @@ -1250,4 +1250,3 @@ void OSLCompiler::parameter_color_array(const char * /*name*/, const arrayparticle_systems.size(); j++) num_particles += scene->particle_systems[j]->particles.size(); - + KernelParticle *kparticles = dscene->particles.alloc(num_particles); - + /* dummy particle */ memset(kparticles, 0, sizeof(KernelParticle)); - + int i = 1; for(size_t j = 0; j < scene->particle_systems.size(); j++) { ParticleSystem *psys = scene->particle_systems[j]; @@ -74,7 +74,7 @@ void ParticleSystemManager::device_update_particles(Device *, DeviceScene *dscen for(size_t k = 0; k < psys->particles.size(); k++) { /* pack in texture */ Particle& pa = psys->particles[k]; - + kparticles[i].index = pa.index; kparticles[i].age = pa.age; kparticles[i].lifetime = pa.lifetime; @@ -83,13 +83,13 @@ void ParticleSystemManager::device_update_particles(Device *, DeviceScene *dscen kparticles[i].location = float3_to_float4(pa.location); kparticles[i].velocity = float3_to_float4(pa.velocity); kparticles[i].angular_velocity = float3_to_float4(pa.angular_velocity); - + i++; - + if(progress.get_cancel()) return; } } - + dscene->particles.copy_to_device(); } @@ -105,9 +105,9 @@ void ParticleSystemManager::device_update(Device *device, DeviceScene *dscene, S progress.set_status("Updating Particle Systems", "Copying Particles to device"); device_update_particles(device, dscene, scene, progress); - + if(progress.get_cancel()) return; - + need_update = false; } @@ -122,4 +122,3 @@ void ParticleSystemManager::tag_update(Scene * /*scene*/) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/particles.h b/intern/cycles/render/particles.h index 66d46114b3e..7e7afd5d054 100644 --- a/intern/cycles/render/particles.h +++ b/intern/cycles/render/particles.h @@ -69,4 +69,3 @@ public: CCL_NAMESPACE_END #endif /* __PARTICLES_H__ */ - diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index c0f1ae0445e..1d65ef65980 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -319,7 +319,7 @@ bool Scene::need_global_attribute(AttributeStandard std) return need_motion() != MOTION_NONE; else if(std == ATTR_STD_MOTION_VERTEX_NORMAL) return need_motion() == MOTION_BLUR; - + return false; } @@ -380,4 +380,3 @@ void Scene::device_free() } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h index 6c67433c9fc..713eba623b1 100644 --- a/intern/cycles/render/scene.h +++ b/intern/cycles/render/scene.h @@ -267,4 +267,3 @@ protected: CCL_NAMESPACE_END #endif /* __SCENE_H__ */ - diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 3106ee53832..d0aa985b035 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -364,7 +364,7 @@ bool Session::acquire_tile(Device *tile_device, RenderTile& rtile) if(!tile_manager.next_tile(tile, device_num)) return false; - + /* fill render tile */ rtile.x = tile_manager.state.buffer.full_x + tile->x; rtile.y = tile_manager.state.buffer.full_y + tile->y; @@ -916,7 +916,7 @@ void Session::update_status_time(bool show_pause, bool show_done) substatus = string_printf("Path Tracing Sample %d/%d", progressive_sample+1, num_samples); - + if(show_pause) { status = "Paused"; } @@ -941,7 +941,7 @@ void Session::render() /* Add path trace task. */ DeviceTask task(DeviceTask::RENDER); - + task.acquire_tile = function_bind(&Session::acquire_tile, this, _1, _2); task.release_tile = function_bind(&Session::release_tile, this, _1); task.map_neighbor_tiles = function_bind(&Session::map_neighbor_tiles, this, _1, _2); diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h index e63cad0d977..61f62f8e712 100644 --- a/intern/cycles/render/session.h +++ b/intern/cycles/render/session.h @@ -237,4 +237,3 @@ protected: CCL_NAMESPACE_END #endif /* __SESSION_H__ */ - diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 46e7d1b1d7b..ac605305b94 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -313,7 +313,7 @@ void Shader::tag_update(Scene *scene) if(has_displacement && displacement_method == DISPLACE_BOTH) { attributes.add(ATTR_STD_POSITION_UNDISPLACED); } - + /* compare if the attributes changed, mesh manager will check * need_update_mesh, update the relevant meshes and clear it. */ if(attributes.modified(prev_attributes)) { @@ -398,7 +398,7 @@ ShaderManager *ShaderManager::create(Scene *scene, int shadingsystem) { manager = new SVMShaderManager(); } - + add_default(scene); return manager; @@ -413,7 +413,7 @@ uint ShaderManager::get_attribute_id(ustring name) if(it != unique_attribute_id.end()) return it->second; - + uint id = (uint)ATTR_STD_NUM + unique_attribute_id.size(); unique_attribute_id[name] = id; return id; @@ -432,10 +432,10 @@ int ShaderManager::get_shader_id(Shader *shader, bool smooth) /* smooth flag */ if(smooth) id |= SHADER_SMOOTH_NORMAL; - + /* default flags */ id |= SHADER_CAST_SHADOW|SHADER_AREA_LIGHT; - + return id; } @@ -696,4 +696,3 @@ float ShaderManager::linear_rgb_to_gray(float3 c) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index 0353da90013..58314a1e310 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -155,7 +155,7 @@ public: }; /* Shader Manager virtual base class - * + * * From this the SVM and OSL shader managers are derived, that do the actual * shader compiling and device updating. */ @@ -223,4 +223,3 @@ protected: CCL_NAMESPACE_END #endif /* __SHADER_H__ */ - diff --git a/intern/cycles/render/sobol.cpp b/intern/cycles/render/sobol.cpp index 6906667ac19..01dfafa2ed9 100644 --- a/intern/cycles/render/sobol.cpp +++ b/intern/cycles/render/sobol.cpp @@ -7,7 +7,7 @@ * http://web.maths.unsw.edu.au/~fkuo/sobol/ * * From these papers: - * + * * S. Joe and F. Y. Kuo, Remark on Algorithm 659: Implementing Sobol's quasirandom * sequence generator, ACM Trans. Math. Softw. 29, 49-57 (2003) * @@ -18,22 +18,22 @@ /* Copyright (c) 2008, Frances Y. Kuo and Stephen Joe * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * * Neither the names of the copyright holders nor the names of the * University of New South Wales and the University of Waikato * and its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -21284,21 +21284,20 @@ void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions if(L <= s) { for(uint i = 0; i < L; i++) - v[i] = m[i] << (31-i); + v[i] = m[i] << (31-i); } else { for(uint i = 0; i < s; i++) - v[i] = m[i] << (31-i); + v[i] = m[i] << (31-i); for(uint i = s; i < L; i++) { - v[i] = v[i-s] ^ (v[i-s] >> s); + v[i] = v[i-s] ^ (v[i-s] >> s); - for(uint k = 1; k < s; k++) - v[i] ^= (((a >> (s-1-k)) & 1) * v[i-k]); + for(uint k = 1; k < s; k++) + v[i] ^= (((a >> (s-1-k)) & 1) * v[i-k]); } } } } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/sobol.h b/intern/cycles/render/sobol.h index 9fbce4e14a5..d38857d2b35 100644 --- a/intern/cycles/render/sobol.h +++ b/intern/cycles/render/sobol.h @@ -29,4 +29,3 @@ void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions CCL_NAMESPACE_END #endif /* __SOBOL_H__ */ - diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index 626f160786f..44b7eeec6db 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -71,12 +71,12 @@ void SVMShaderManager::device_update_shader(Scene *scene, scene->light_manager->need_update = true; } - /* The copy needs to be done inside the lock, if another thread resizes the array - * while memcpy is running, it'll be copying into possibly invalid/freed ram. + /* The copy needs to be done inside the lock, if another thread resizes the array + * while memcpy is running, it'll be copying into possibly invalid/freed ram. */ size_t global_nodes_size = global_svm_nodes->size(); global_svm_nodes->resize(global_nodes_size + svm_nodes.size()); - + /* Offset local SVM nodes to a global address space. */ int4& jump_node = (*global_svm_nodes)[shader->id]; jump_node.y = svm_nodes[0].y + global_nodes_size - 1; @@ -173,7 +173,7 @@ SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, int SVMCompiler::stack_size(SocketType::Type type) { int size = 0; - + switch(type) { case SocketType::FLOAT: case SocketType::INT: @@ -192,14 +192,14 @@ int SVMCompiler::stack_size(SocketType::Type type) assert(0); break; } - + return size; } int SVMCompiler::stack_find_offset(int size) { int offset = -1; - + /* find free space in stack & mark as used */ for(int i = 0, num_unused = 0; i < SVM_STACK_SIZE; i++) { if(active_stack.users[i]) num_unused = 0; @@ -413,7 +413,7 @@ bool SVMCompiler::node_skip_input(ShaderNode * /*node*/, ShaderInput *input) /* nasty exception .. */ if(current_type == SHADER_TYPE_DISPLACEMENT && input->link && input->link->parent->special_type == SHADER_SPECIAL_TYPE_BUMP) return true; - + return false; } @@ -715,7 +715,7 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty /* get input in output node */ ShaderNode *node = graph->output(); ShaderInput *clin = NULL; - + switch(type) { case SHADER_TYPE_SURFACE: clin = node->input("Surface"); @@ -756,9 +756,9 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty if(shader->used) { if(clin->link) { bool generate = false; - + switch(type) { - case SHADER_TYPE_SURFACE: /* generate surface shader */ + case SHADER_TYPE_SURFACE: /* generate surface shader */ generate = true; shader->has_surface = true; break; @@ -936,4 +936,3 @@ SVMCompiler::CompilerState::CompilerState(ShaderGraph *graph) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/svm.h b/intern/cycles/render/svm.h index 7cf1e4ad791..1d0613bbfdc 100644 --- a/intern/cycles/render/svm.h +++ b/intern/cycles/render/svm.h @@ -224,4 +224,3 @@ protected: CCL_NAMESPACE_END #endif /* __SVM_H__ */ - diff --git a/intern/cycles/render/tables.cpp b/intern/cycles/render/tables.cpp index 536fdd0775e..ddbb138f059 100644 --- a/intern/cycles/render/tables.cpp +++ b/intern/cycles/render/tables.cpp @@ -115,4 +115,3 @@ void LookupTables::remove_table(size_t *offset) } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/tables.h b/intern/cycles/render/tables.h index bc261c2a74d..09d961a9c3c 100644 --- a/intern/cycles/render/tables.h +++ b/intern/cycles/render/tables.h @@ -51,4 +51,3 @@ public: CCL_NAMESPACE_END #endif /* __TABLES_H__ */ - diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp index a388f5dfc8b..dc863b067b0 100644 --- a/intern/cycles/render/tile.cpp +++ b/intern/cycles/render/tile.cpp @@ -535,4 +535,3 @@ int TileManager::get_num_effective_samples() } CCL_NAMESPACE_END - diff --git a/intern/cycles/render/tile.h b/intern/cycles/render/tile.h index 2692c7cf9f0..f72f653f4c2 100644 --- a/intern/cycles/render/tile.h +++ b/intern/cycles/render/tile.h @@ -155,4 +155,3 @@ protected: CCL_NAMESPACE_END #endif /* __TILE_H__ */ - diff --git a/intern/cycles/subd/subd_dice.cpp b/intern/cycles/subd/subd_dice.cpp index 8c426da4acf..c5ac54cfcc8 100644 --- a/intern/cycles/subd/subd_dice.cpp +++ b/intern/cycles/subd/subd_dice.cpp @@ -348,4 +348,3 @@ void QuadDice::dice(SubPatch& sub, EdgeFactors& ef) } CCL_NAMESPACE_END - diff --git a/intern/cycles/subd/subd_dice.h b/intern/cycles/subd/subd_dice.h index c0e32be18c4..4617c782b3a 100644 --- a/intern/cycles/subd/subd_dice.h +++ b/intern/cycles/subd/subd_dice.h @@ -81,7 +81,7 @@ public: * Edge tessellation factors and subpatch coordinates are as follows: * * tu1 - * P01 --------- P11 + * P01 --------- P11 * | | * tv0 | | tv1 * | | @@ -135,4 +135,3 @@ public: CCL_NAMESPACE_END #endif /* __SUBD_DICE_H__ */ - diff --git a/intern/cycles/subd/subd_patch.cpp b/intern/cycles/subd/subd_patch.cpp index fa2fe2bf113..f8f5aa25d19 100644 --- a/intern/cycles/subd/subd_patch.cpp +++ b/intern/cycles/subd/subd_patch.cpp @@ -80,7 +80,7 @@ BoundBox LinearQuadPatch::bound() for(int i = 0; i < 4; i++) bbox.grow(hull[i]); - + return bbox; } @@ -110,9 +110,8 @@ BoundBox BicubicPatch::bound() for(int i = 0; i < 16; i++) bbox.grow(hull[i]); - + return bbox; } CCL_NAMESPACE_END - diff --git a/intern/cycles/subd/subd_patch.h b/intern/cycles/subd/subd_patch.h index 1bb81588835..64ec8f70951 100644 --- a/intern/cycles/subd/subd_patch.h +++ b/intern/cycles/subd/subd_patch.h @@ -57,4 +57,3 @@ public: CCL_NAMESPACE_END #endif /* __SUBD_PATCH_H__ */ - diff --git a/intern/cycles/subd/subd_patch_table.cpp b/intern/cycles/subd/subd_patch_table.cpp index 63bf673a90b..13a6f284542 100644 --- a/intern/cycles/subd/subd_patch_table.cpp +++ b/intern/cycles/subd/subd_patch_table.cpp @@ -294,4 +294,3 @@ void PackedPatchTable::copy_adjusting_offsets(uint* dest, int doffset) } CCL_NAMESPACE_END - diff --git a/intern/cycles/subd/subd_patch_table.h b/intern/cycles/subd/subd_patch_table.h index 907f2dd6c28..45be7051992 100644 --- a/intern/cycles/subd/subd_patch_table.h +++ b/intern/cycles/subd/subd_patch_table.h @@ -60,4 +60,3 @@ struct PackedPatchTable { CCL_NAMESPACE_END #endif /* __SUBD_PATCH_TABLE_H__ */ - diff --git a/intern/cycles/subd/subd_split.cpp b/intern/cycles/subd/subd_split.cpp index d3bed6a5c53..76261243359 100644 --- a/intern/cycles/subd/subd_split.cpp +++ b/intern/cycles/subd/subd_split.cpp @@ -86,7 +86,7 @@ int DiagSplit::T(Patch *patch, float2 Pstart, float2 Pend) if(tmax - tmin > params.split_threshold) return DSPLIT_NON_UNIFORM; - + return tmax; } @@ -258,4 +258,3 @@ void DiagSplit::split_quad(Patch *patch, QuadDice::SubPatch *subpatch) } CCL_NAMESPACE_END - diff --git a/intern/cycles/subd/subd_split.h b/intern/cycles/subd/subd_split.h index f869cc6a48e..7a276b35382 100644 --- a/intern/cycles/subd/subd_split.h +++ b/intern/cycles/subd/subd_split.h @@ -57,4 +57,3 @@ public: CCL_NAMESPACE_END #endif /* __SUBD_SPLIT_H__ */ - diff --git a/intern/cycles/util/util_algorithm.h b/intern/cycles/util/util_algorithm.h index 5c79c00cc98..eb874713d43 100644 --- a/intern/cycles/util/util_algorithm.h +++ b/intern/cycles/util/util_algorithm.h @@ -30,4 +30,3 @@ using std::remove; CCL_NAMESPACE_END #endif /* __UTIL_ALGORITHM_H__ */ - diff --git a/intern/cycles/util/util_args.h b/intern/cycles/util/util_args.h index a53fc061758..be6f2c2b9f1 100644 --- a/intern/cycles/util/util_args.h +++ b/intern/cycles/util/util_args.h @@ -29,4 +29,3 @@ OIIO_NAMESPACE_USING CCL_NAMESPACE_END #endif /* __UTIL_ARGS_H__ */ - diff --git a/intern/cycles/util/util_boundbox.h b/intern/cycles/util/util_boundbox.h index ed94ca20211..b1bd5be0df3 100644 --- a/intern/cycles/util/util_boundbox.h +++ b/intern/cycles/util/util_boundbox.h @@ -55,7 +55,7 @@ public: { } - __forceinline void grow(const float3& pt) + __forceinline void grow(const float3& pt) { /* the order of arguments to min is such that if pt is nan, it will not * influence the resulting bounding box */ @@ -63,7 +63,7 @@ public: max = ccl::max(pt, max); } - __forceinline void grow(const float3& pt, float border) + __forceinline void grow(const float3& pt, float border) { float3 shift = make_float3(border, border, border); min = ccl::min(pt - shift, min); @@ -76,7 +76,7 @@ public: grow(bbox.max); } - __forceinline void grow_safe(const float3& pt) + __forceinline void grow_safe(const float3& pt) { /* the order of arguments to min is such that if pt is nan, it will not * influence the resulting bounding box */ @@ -86,7 +86,7 @@ public: } } - __forceinline void grow_safe(const float3& pt, float border) + __forceinline void grow_safe(const float3& pt, float border) { if(isfinite(pt.x) && isfinite(pt.y) && isfinite(pt.z) && isfinite(border)) { float3 shift = make_float3(border, border, border); @@ -101,7 +101,7 @@ public: grow_safe(bbox.max); } - __forceinline void intersect(const BoundBox& bbox) + __forceinline void intersect(const BoundBox& bbox) { min = ccl::max(min, bbox.min); max = ccl::min(max, bbox.max); @@ -283,4 +283,3 @@ public: CCL_NAMESPACE_END #endif /* __UTIL_BOUNDBOX_H__ */ - diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h index 62a9bf8e47d..826db469d25 100644 --- a/intern/cycles/util/util_color.h +++ b/intern/cycles/util/util_color.h @@ -241,4 +241,3 @@ ccl_device float4 color_srgb_to_linear_v4(float4 c) CCL_NAMESPACE_END #endif /* __UTIL_COLOR_H__ */ - diff --git a/intern/cycles/util/util_defines.h b/intern/cycles/util/util_defines.h index 98944a19022..d994d4e08f4 100644 --- a/intern/cycles/util/util_defines.h +++ b/intern/cycles/util/util_defines.h @@ -133,4 +133,3 @@ template static inline T decltype_helper(T x) { return x; } #endif #endif /* __UTIL_DEFINES_H__ */ - diff --git a/intern/cycles/util/util_foreach.h b/intern/cycles/util/util_foreach.h index 4f7337107b3..03fcefc67b9 100644 --- a/intern/cycles/util/util_foreach.h +++ b/intern/cycles/util/util_foreach.h @@ -27,4 +27,3 @@ #endif #endif /* __UTIL_FOREACH_H__ */ - diff --git a/intern/cycles/util/util_function.h b/intern/cycles/util/util_function.h index 6d0f0b444a9..958f8b4008c 100644 --- a/intern/cycles/util/util_function.h +++ b/intern/cycles/util/util_function.h @@ -47,4 +47,3 @@ using boost::function; CCL_NAMESPACE_END #endif /* __UTIL_FUNCTION_H__ */ - diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h index f6c507906f3..58f3f903619 100644 --- a/intern/cycles/util/util_half.h +++ b/intern/cycles/util/util_half.h @@ -149,4 +149,3 @@ ccl_device_inline half float_to_half(float f) CCL_NAMESPACE_END #endif /* __UTIL_HALF_H__ */ - diff --git a/intern/cycles/util/util_hash.h b/intern/cycles/util/util_hash.h index 2307ca158f0..a8a5076fbb3 100644 --- a/intern/cycles/util/util_hash.h +++ b/intern/cycles/util/util_hash.h @@ -69,4 +69,3 @@ ccl_device_inline float hash_int_01(uint k) CCL_NAMESPACE_END #endif /* __UTIL_HASH_H__ */ - diff --git a/intern/cycles/util/util_list.h b/intern/cycles/util/util_list.h index 6cb27e6defe..f555b001186 100644 --- a/intern/cycles/util/util_list.h +++ b/intern/cycles/util/util_list.h @@ -26,4 +26,3 @@ using std::list; CCL_NAMESPACE_END #endif /* __UTIL_LIST_H__ */ - diff --git a/intern/cycles/util/util_map.h b/intern/cycles/util/util_map.h index 46c2885f8b0..b3d887f093c 100644 --- a/intern/cycles/util/util_map.h +++ b/intern/cycles/util/util_map.h @@ -54,4 +54,3 @@ using std::unordered_map; CCL_NAMESPACE_END #endif /* __UTIL_MAP_H__ */ - diff --git a/intern/cycles/util/util_md5.cpp b/intern/cycles/util/util_md5.cpp index 749760d84f0..7cdd28a4793 100644 --- a/intern/cycles/util/util_md5.cpp +++ b/intern/cycles/util/util_md5.cpp @@ -338,7 +338,7 @@ bool MD5Hash::append_file(const string& filepath) bool success = (ferror(f) == 0); fclose(f); - + return success; } @@ -376,7 +376,7 @@ string MD5Hash::get_hex() for(int i = 0; i < 16; i++) sprintf(buf + i*2, "%02X", (unsigned int)digest[i]); buf[sizeof(buf)-1] = '\0'; - + return string(buf); } @@ -388,4 +388,3 @@ string util_md5_string(const string& str) } CCL_NAMESPACE_END - diff --git a/intern/cycles/util/util_md5.h b/intern/cycles/util/util_md5.h index b043b591e67..9023ccee4c2 100644 --- a/intern/cycles/util/util_md5.h +++ b/intern/cycles/util/util_md5.h @@ -59,4 +59,3 @@ string util_md5_string(const string& str); CCL_NAMESPACE_END #endif /* __UTIL_MD5_H__ */ - diff --git a/intern/cycles/util/util_optimization.h b/intern/cycles/util/util_optimization.h index 3c5785c4807..3b3627242d5 100644 --- a/intern/cycles/util/util_optimization.h +++ b/intern/cycles/util/util_optimization.h @@ -69,4 +69,3 @@ #endif #endif /* __UTIL_OPTIMIZATION_H__ */ - diff --git a/intern/cycles/util/util_param.h b/intern/cycles/util/util_param.h index 69bcbf80a78..246b5cb7d63 100644 --- a/intern/cycles/util/util_param.h +++ b/intern/cycles/util/util_param.h @@ -31,4 +31,3 @@ OIIO_NAMESPACE_USING CCL_NAMESPACE_END #endif /* __UTIL_PARAM_H__ */ - diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp index 0e0371928ab..51b7944705e 100644 --- a/intern/cycles/util/util_path.cpp +++ b/intern/cycles/util/util_path.cpp @@ -987,4 +987,3 @@ void path_cache_clear_except(const string& name, const set& except) } CCL_NAMESPACE_END - diff --git a/intern/cycles/util/util_path.h b/intern/cycles/util/util_path.h index 0e5e2d2c837..738dba94647 100644 --- a/intern/cycles/util/util_path.h +++ b/intern/cycles/util/util_path.h @@ -76,4 +76,3 @@ void path_cache_clear_except(const string& name, const set& except); CCL_NAMESPACE_END #endif - diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h index 134383e88db..3ef15c5c09a 100644 --- a/intern/cycles/util/util_progress.h +++ b/intern/cycles/util/util_progress.h @@ -366,4 +366,3 @@ protected: CCL_NAMESPACE_END #endif /* __UTIL_PROGRESS_H__ */ - diff --git a/intern/cycles/util/util_projection.h b/intern/cycles/util/util_projection.h index dbcb9877a48..26b4843928c 100644 --- a/intern/cycles/util/util_projection.h +++ b/intern/cycles/util/util_projection.h @@ -174,4 +174,3 @@ ccl_device_inline ProjectionTransform projection_orthographic(float znear, float CCL_NAMESPACE_END #endif /* __UTIL_PROJECTION_H__ */ - diff --git a/intern/cycles/util/util_queue.h b/intern/cycles/util/util_queue.h index f4c802785f9..622f4fe3e47 100644 --- a/intern/cycles/util/util_queue.h +++ b/intern/cycles/util/util_queue.h @@ -26,4 +26,3 @@ using std::queue; CCL_NAMESPACE_END #endif /* __UTIL_LIST_H__ */ - diff --git a/intern/cycles/util/util_rect.h b/intern/cycles/util/util_rect.h index 17a55a14d0b..d13baefe85e 100644 --- a/intern/cycles/util/util_rect.h +++ b/intern/cycles/util/util_rect.h @@ -70,4 +70,3 @@ ccl_device_inline int rect_size(int4 rect) CCL_NAMESPACE_END #endif /* __UTIL_RECT_H__ */ - diff --git a/intern/cycles/util/util_set.h b/intern/cycles/util/util_set.h index c19fa071b37..1d010e19996 100644 --- a/intern/cycles/util/util_set.h +++ b/intern/cycles/util/util_set.h @@ -60,4 +60,3 @@ using std::unordered_set; CCL_NAMESPACE_END #endif /* __UTIL_SET_H__ */ - diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h index 04341451afb..cc7f436c8fe 100644 --- a/intern/cycles/util/util_simd.h +++ b/intern/cycles/util/util_simd.h @@ -111,7 +111,7 @@ __forceinline size_t __popcnt(size_t in) { #endif __forceinline int __bsf(int v) { -#if defined(__KERNEL_AVX2__) +#if defined(__KERNEL_AVX2__) return _tzcnt_u32(v); #else unsigned long r = 0; _BitScanForward(&r,v); return r; @@ -119,7 +119,7 @@ __forceinline int __bsf(int v) { } __forceinline unsigned int __bsf(unsigned int v) { -#if defined(__KERNEL_AVX2__) +#if defined(__KERNEL_AVX2__) return _tzcnt_u32(v); #else unsigned long r = 0; _BitScanForward(&r,v); return r; @@ -143,7 +143,7 @@ __forceinline int __btr(int v, int i) { } __forceinline int bitscan(int v) { -#if defined(__KERNEL_AVX2__) +#if defined(__KERNEL_AVX2__) return _tzcnt_u32(v); #else return __bsf(v); @@ -156,18 +156,18 @@ __forceinline int clz(const int x) return _lzcnt_u32(x); #else if(UNLIKELY(x == 0)) return 32; - return 31 - __bsr(x); + return 31 - __bsr(x); #endif } -__forceinline int __bscf(int& v) +__forceinline int __bscf(int& v) { int i = __bsf(v); v &= v-1; return i; } -__forceinline unsigned int __bscf(unsigned int& v) +__forceinline unsigned int __bscf(unsigned int& v) { unsigned int i = __bsf(v); v &= v-1; @@ -177,7 +177,7 @@ __forceinline unsigned int __bscf(unsigned int& v) #if defined(__KERNEL_64_BIT__) __forceinline size_t __bsf(size_t v) { -#if defined(__KERNEL_AVX2__) +#if defined(__KERNEL_AVX2__) return _tzcnt_u64(v); #else unsigned long r = 0; _BitScanForward64(&r,v); return r; @@ -212,7 +212,7 @@ __forceinline size_t bitscan(size_t v) { #endif } -__forceinline size_t __bscf(size_t& v) +__forceinline size_t __bscf(size_t& v) { size_t i = __bsf(v); v &= v-1; @@ -274,7 +274,7 @@ __forceinline size_t __btr(size_t v, size_t i) { } __forceinline int bitscan(int v) { -#if defined(__KERNEL_AVX2__) +#if defined(__KERNEL_AVX2__) return _tzcnt_u32(v); #else return __bsf(v); @@ -282,7 +282,7 @@ __forceinline int bitscan(int v) { } __forceinline unsigned int bitscan(unsigned int v) { -#if defined(__KERNEL_AVX2__) +#if defined(__KERNEL_AVX2__) return _tzcnt_u32(v); #else return __bsf(v); @@ -309,11 +309,11 @@ __forceinline int clz(const int x) return _lzcnt_u32(x); #else if(UNLIKELY(x == 0)) return 32; - return 31 - __bsr(x); + return 31 - __bsr(x); #endif } -__forceinline int __bscf(int& v) +__forceinline int __bscf(int& v) { int i = bitscan(v); #if defined(__KERNEL_AVX2__) @@ -324,7 +324,7 @@ __forceinline int __bscf(int& v) return i; } -__forceinline unsigned int __bscf(unsigned int& v) +__forceinline unsigned int __bscf(unsigned int& v) { unsigned int i = bitscan(v); v &= v-1; @@ -332,7 +332,7 @@ __forceinline unsigned int __bscf(unsigned int& v) } #if (defined(__KERNEL_64_BIT__) || defined(__APPLE__)) && !(defined(__ILP32__) && defined(__x86_64__)) -__forceinline size_t __bscf(size_t& v) +__forceinline size_t __bscf(size_t& v) { size_t i = bitscan(v); #if defined(__KERNEL_AVX2__) @@ -375,28 +375,28 @@ __forceinline __m128 _mm_blendv_ps_emu( __m128 value, __m128 input, __m128 mask) #define _mm_blend_ps _mm_blend_ps_emu __forceinline __m128 _mm_blend_ps_emu( __m128 value, __m128 input, const int mask) { - assert(mask < 0x10); return _mm_blendv_ps(value, input, _mm_lookupmask_ps[mask]); + assert(mask < 0x10); return _mm_blendv_ps(value, input, _mm_lookupmask_ps[mask]); } #undef _mm_blendv_epi8 #define _mm_blendv_epi8 _mm_blendv_epi8_emu __forceinline __m128i _mm_blendv_epi8_emu( __m128i value, __m128i input, __m128i mask) { - return _mm_or_si128(_mm_and_si128(mask, input), _mm_andnot_si128(mask, value)); + return _mm_or_si128(_mm_and_si128(mask, input), _mm_andnot_si128(mask, value)); } #undef _mm_min_epi32 #define _mm_min_epi32 _mm_min_epi32_emu __forceinline __m128i _mm_min_epi32_emu( __m128i value, __m128i input) { - return _mm_blendv_epi8(input, value, _mm_cmplt_epi32(value, input)); + return _mm_blendv_epi8(input, value, _mm_cmplt_epi32(value, input)); } #undef _mm_max_epi32 #define _mm_max_epi32 _mm_max_epi32_emu __forceinline __m128i _mm_max_epi32_emu( __m128i value, __m128i input) { - return _mm_blendv_epi8(value, input, _mm_cmplt_epi32(value, input)); + return _mm_blendv_epi8(value, input, _mm_cmplt_epi32(value, input)); } #undef _mm_extract_epi32 @@ -416,7 +416,7 @@ __forceinline int _mm_extract_epi32_emu( __m128i input, const int index) #define _mm_insert_epi32 _mm_insert_epi32_emu __forceinline __m128i _mm_insert_epi32_emu( __m128i value, int input, const int index) { - assert(index >= 0 && index < 4); ((int*)&value)[index] = input; return value; + assert(index >= 0 && index < 4); ((int*)&value)[index] = input; return value; } #undef _mm_insert_ps @@ -487,4 +487,3 @@ CCL_NAMESPACE_END #endif /* __KERNEL_GPU__ */ #endif /* __UTIL_SIMD_TYPES_H__ */ - diff --git a/intern/cycles/util/util_sky_model.cpp b/intern/cycles/util/util_sky_model.cpp index 6dda8469907..526bce4ff88 100644 --- a/intern/cycles/util/util_sky_model.cpp +++ b/intern/cycles/util/util_sky_model.cpp @@ -367,4 +367,3 @@ ArHosekSkyModelState * arhosek_xyz_skymodelstate_alloc_init( } CCL_NAMESPACE_END - diff --git a/intern/cycles/util/util_sseb.h b/intern/cycles/util/util_sseb.h index 977976c3fc0..115b133c662 100644 --- a/intern/cycles/util/util_sseb.h +++ b/intern/cycles/util/util_sseb.h @@ -38,7 +38,7 @@ struct sseb //////////////////////////////////////////////////////////////////////////////// /// Constructors, Assignment & Cast Operators //////////////////////////////////////////////////////////////////////////////// - + __forceinline sseb ( ) {} __forceinline sseb ( const sseb& other ) { m128 = other.m128; } __forceinline sseb& operator=( const sseb& other ) { m128 = other.m128; return *this; } @@ -47,10 +47,10 @@ struct sseb __forceinline operator const __m128&( void ) const { return m128; } __forceinline operator const __m128i( void ) const { return _mm_castps_si128(m128); } __forceinline operator const __m128d( void ) const { return _mm_castps_pd(m128); } - + __forceinline sseb ( bool a ) : m128(_mm_lookupmask_ps[(size_t(a) << 3) | (size_t(a) << 2) | (size_t(a) << 1) | size_t(a)]) {} - __forceinline sseb ( bool a, bool b) + __forceinline sseb ( bool a, bool b) : m128(_mm_lookupmask_ps[(size_t(b) << 3) | (size_t(a) << 2) | (size_t(b) << 1) | size_t(a)]) {} __forceinline sseb ( bool a, bool b, bool c, bool d) : m128(_mm_lookupmask_ps[(size_t(d) << 3) | (size_t(c) << 2) | (size_t(b) << 1) | size_t(a)]) {} @@ -103,11 +103,11 @@ __forceinline const sseb operator ^=( sseb& a, const sseb& b ) { return a = a ^ __forceinline const sseb operator !=( const sseb& a, const sseb& b ) { return _mm_xor_ps(a, b); } __forceinline const sseb operator ==( const sseb& a, const sseb& b ) { return _mm_castsi128_ps(_mm_cmpeq_epi32(a, b)); } -__forceinline const sseb select( const sseb& m, const sseb& t, const sseb& f ) { +__forceinline const sseb select( const sseb& m, const sseb& t, const sseb& f ) { #if defined(__KERNEL_SSE41__) - return _mm_blendv_ps(f, t, m); + return _mm_blendv_ps(f, t, m); #else - return _mm_or_ps(_mm_and_ps(m, t), _mm_andnot_ps(m, f)); + return _mm_or_ps(_mm_and_ps(m, t), _mm_andnot_ps(m, f)); #endif } @@ -186,4 +186,3 @@ ccl_device_inline void print_sseb(const char *label, const sseb &a) CCL_NAMESPACE_END #endif - diff --git a/intern/cycles/util/util_ssef.h b/intern/cycles/util/util_ssef.h index e9a617bb2cc..b5623860e33 100644 --- a/intern/cycles/util/util_ssef.h +++ b/intern/cycles/util/util_ssef.h @@ -31,14 +31,14 @@ struct ssef typedef sseb Mask; // mask type typedef ssei Int; // int type typedef ssef Float; // float type - + enum { size = 4 }; // number of SIMD elements union { __m128 m128; float f[4]; int i[4]; }; // data //////////////////////////////////////////////////////////////////////////////// /// Constructors, Assignment & Cast Operators //////////////////////////////////////////////////////////////////////////////// - + __forceinline ssef () {} __forceinline ssef (const ssef& other) { m128 = other.m128; } __forceinline ssef& operator=(const ssef& other) { m128 = other.m128; return *this; } @@ -143,7 +143,7 @@ __forceinline ssef mini(const ssef& a, const ssef& b) { return _mm_castsi128_ps(ci); } #endif - + #if defined(__KERNEL_SSE41__) __forceinline ssef maxi(const ssef& a, const ssef& b) { const ssei ai = _mm_castps_si128(a); @@ -229,7 +229,7 @@ __forceinline const ssef select(const ssef& m, const ssef& t, const ssef& f) { #endif } -__forceinline const ssef select(const int mask, const ssef& t, const ssef& f) { +__forceinline const ssef select(const int mask, const ssef& t, const ssef& f) { #if defined(__KERNEL_SSE41__) && ((!defined(__clang__) && !defined(_MSC_VER)) || defined(__INTEL_COMPILER)) return _mm_blend_ps(f, t, mask); #else @@ -298,8 +298,8 @@ template<> __forceinline const ssef shuffle<2, 3, 2, 3>(const ssef& a, const sse } #if defined(__KERNEL_SSSE3__) -__forceinline const ssef shuffle8(const ssef& a, const ssei& shuf) { - return _mm_castsi128_ps(_mm_shuffle_epi8(_mm_castps_si128(a), shuf)); +__forceinline const ssef shuffle8(const ssef& a, const ssei& shuf) { + return _mm_castsi128_ps(_mm_shuffle_epi8(_mm_castps_si128(a), shuf)); } #endif @@ -333,7 +333,7 @@ template __forceinline const ssef insert(const ssef& a, /// Transpose //////////////////////////////////////////////////////////////////////////////// -__forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, const ssef& r3, ssef& c0, ssef& c1, ssef& c2, ssef& c3) +__forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, const ssef& r3, ssef& c0, ssef& c1, ssef& c2, ssef& c3) { ssef l02 = unpacklo(r0,r2); ssef h02 = unpackhi(r0,r2); @@ -345,7 +345,7 @@ __forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, con c3 = unpackhi(h02,h13); } -__forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, const ssef& r3, ssef& c0, ssef& c1, ssef& c2) +__forceinline void transpose(const ssef& r0, const ssef& r1, const ssef& r2, const ssef& r3, ssef& c0, ssef& c1, ssef& c2) { ssef l02 = unpacklo(r0,r2); ssef h02 = unpackhi(r0,r2); @@ -382,22 +382,22 @@ __forceinline size_t movemask( const ssef& a ) { return _mm_movemask_ps(a); } __forceinline ssef load4f(const float4& a) { #ifdef __KERNEL_WITH_SSE_ALIGN__ - return _mm_load_ps(&a.x); + return _mm_load_ps(&a.x); #else - return _mm_loadu_ps(&a.x); + return _mm_loadu_ps(&a.x); #endif } __forceinline ssef load4f(const float3& a) { #ifdef __KERNEL_WITH_SSE_ALIGN__ - return _mm_load_ps(&a.x); + return _mm_load_ps(&a.x); #else - return _mm_loadu_ps(&a.x); + return _mm_loadu_ps(&a.x); #endif } __forceinline ssef load4f(const void* const a) { - return _mm_load_ps((float*)a); + return _mm_load_ps((float*)a); } __forceinline ssef load1f_first(const float a) { @@ -409,14 +409,14 @@ __forceinline void store4f(void* ptr, const ssef& v) { } __forceinline ssef loadu4f(const void* const a) { - return _mm_loadu_ps((float*)a); + return _mm_loadu_ps((float*)a); } __forceinline void storeu4f(void* ptr, const ssef& v) { _mm_storeu_ps((float*)ptr,v); } -__forceinline void store4f(const sseb& mask, void* ptr, const ssef& f) { +__forceinline void store4f(const sseb& mask, void* ptr, const ssef& f) { #if defined(__KERNEL_AVX__) _mm_maskstore_ps((float*)ptr,(__m128i)mask,f); #else @@ -428,7 +428,7 @@ __forceinline ssef load4f_nt(void* ptr) { #if defined(__KERNEL_SSE41__) return _mm_castsi128_ps(_mm_stream_load_si128((__m128i*)ptr)); #else - return _mm_load_ps((float*)ptr); + return _mm_load_ps((float*)ptr); #endif } @@ -449,7 +449,7 @@ __forceinline float dot(const ssef& a, const ssef& b) { } /* calculate shuffled cross product, useful when order of components does not matter */ -__forceinline ssef cross_zxy(const ssef& a, const ssef& b) +__forceinline ssef cross_zxy(const ssef& a, const ssef& b) { const ssef a0 = a; const ssef b0 = shuffle<1,2,0,3>(b); @@ -458,7 +458,7 @@ __forceinline ssef cross_zxy(const ssef& a, const ssef& b) return msub(a0,b0,a1*b1); } -__forceinline ssef cross(const ssef& a, const ssef& b) +__forceinline ssef cross(const ssef& a, const ssef& b) { return shuffle<1,2,0,3>(cross_zxy(a, b)); } @@ -628,4 +628,3 @@ ccl_device_inline void print_ssef(const char *label, const ssef &a) CCL_NAMESPACE_END #endif - diff --git a/intern/cycles/util/util_ssei.h b/intern/cycles/util/util_ssei.h index ef2a9e68b7d..ba0389cd114 100644 --- a/intern/cycles/util/util_ssei.h +++ b/intern/cycles/util/util_ssei.h @@ -38,7 +38,7 @@ struct ssei //////////////////////////////////////////////////////////////////////////////// /// Constructors, Assignment & Cast Operators //////////////////////////////////////////////////////////////////////////////// - + __forceinline ssei ( ) {} __forceinline ssei ( const ssei& a ) { m128 = a.m128; } __forceinline ssei& operator=( const ssei& a ) { m128 = a.m128; return *this; } @@ -173,15 +173,15 @@ __forceinline const sseb operator <=( const ssei& a, const ssei& b ) { return !( __forceinline const sseb operator <=( const ssei& a, const int32_t& b ) { return a <= ssei(b); } __forceinline const sseb operator <=( const int32_t& a, const ssei& b ) { return ssei(a) <= b; } -__forceinline const ssei select( const sseb& m, const ssei& t, const ssei& f ) { +__forceinline const ssei select( const sseb& m, const ssei& t, const ssei& f ) { #ifdef __KERNEL_SSE41__ - return _mm_castps_si128(_mm_blendv_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), m)); + return _mm_castps_si128(_mm_blendv_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), m)); #else - return _mm_or_si128(_mm_and_si128(m, t), _mm_andnot_si128(m, f)); + return _mm_or_si128(_mm_and_si128(m, t), _mm_andnot_si128(m, f)); #endif } -__forceinline const ssei select( const int mask, const ssei& t, const ssei& f ) { +__forceinline const ssei select( const int mask, const ssei& t, const ssei& f ) { #if defined(__KERNEL_SSE41__) && ((!defined(__clang__) && !defined(_MSC_VER)) || defined(__INTEL_COMPILER)) return _mm_castps_si128(_mm_blend_ps(_mm_castsi128_ps(f), _mm_castsi128_ps(t), mask)); #else @@ -249,8 +249,8 @@ __forceinline int reduce_add(const ssei& v) { return v[0]+v[1]+v[2]+v[3]; } /// Memory load and store operations //////////////////////////////////////////////////////////////////////////////// -__forceinline ssei load4i( const void* const a ) { - return _mm_load_si128((__m128i*)a); +__forceinline ssei load4i( const void* const a ) { + return _mm_load_si128((__m128i*)a); } __forceinline void store4i(void* ptr, const ssei& v) { @@ -261,7 +261,7 @@ __forceinline void storeu4i(void* ptr, const ssei& v) { _mm_storeu_si128((__m128i*)ptr,v); } -__forceinline void store4i( const sseb& mask, void* ptr, const ssei& i ) { +__forceinline void store4i( const sseb& mask, void* ptr, const ssei& i ) { #if defined (__KERNEL_AVX__) _mm_maskstore_ps((float*)ptr,(__m128i)mask,_mm_castsi128_ps(i)); #else @@ -269,17 +269,17 @@ __forceinline void store4i( const sseb& mask, void* ptr, const ssei& i ) { #endif } -__forceinline ssei load4i_nt (void* ptr) { +__forceinline ssei load4i_nt (void* ptr) { #if defined(__KERNEL_SSE41__) - return _mm_stream_load_si128((__m128i*)ptr); + return _mm_stream_load_si128((__m128i*)ptr); #else - return _mm_load_si128((__m128i*)ptr); + return _mm_load_si128((__m128i*)ptr); #endif } -__forceinline void store4i_nt(void* ptr, const ssei& v) { +__forceinline void store4i_nt(void* ptr, const ssei& v) { #if defined(__KERNEL_SSE41__) - _mm_stream_ps((float*)ptr,_mm_castsi128_ps(v)); + _mm_stream_ps((float*)ptr,_mm_castsi128_ps(v)); #else _mm_store_si128((__m128i*)ptr,v); #endif @@ -300,4 +300,3 @@ ccl_device_inline void print_ssei(const char *label, const ssei &a) CCL_NAMESPACE_END #endif - diff --git a/intern/cycles/util/util_string.cpp b/intern/cycles/util/util_string.cpp index 94ad512982c..995f5d3df27 100644 --- a/intern/cycles/util/util_string.cpp +++ b/intern/cycles/util/util_string.cpp @@ -293,4 +293,3 @@ string string_human_readable_number(size_t num) } CCL_NAMESPACE_END - diff --git a/intern/cycles/util/util_string.h b/intern/cycles/util/util_string.h index e2c105db9c1..7dfa97335a9 100644 --- a/intern/cycles/util/util_string.h +++ b/intern/cycles/util/util_string.h @@ -73,4 +73,3 @@ string string_human_readable_number(size_t num); CCL_NAMESPACE_END #endif /* __UTIL_STRING_H__ */ - diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index 5f5211228c5..8ae5b63b2f9 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -312,4 +312,3 @@ size_t system_physical_ram() } CCL_NAMESPACE_END - diff --git a/intern/cycles/util/util_system.h b/intern/cycles/util/util_system.h index e55dd6dd136..42ad72356b9 100644 --- a/intern/cycles/util/util_system.h +++ b/intern/cycles/util/util_system.h @@ -47,4 +47,3 @@ size_t system_physical_ram(); CCL_NAMESPACE_END #endif /* __UTIL_SYSTEM_H__ */ - diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp index 9df1096de8a..2d21d6b5a18 100644 --- a/intern/cycles/util/util_task.cpp +++ b/intern/cycles/util/util_task.cpp @@ -122,7 +122,7 @@ void TaskPool::cancel() do_cancel = true; TaskScheduler::clear(this); - + { thread_scoped_lock num_lock(num_mutex); @@ -210,7 +210,7 @@ void TaskScheduler::init(int num_threads) int current_group_threads = 0; if(num_groups > 1) { process_groups.resize(num_groups); - num_process_groups = system_cpu_process_groups(num_groups, + num_process_groups = system_cpu_process_groups(num_groups, &process_groups[0]); if(num_process_groups == 1) { current_group_threads = system_cpu_group_thread_count(process_groups[0]); @@ -251,7 +251,7 @@ void TaskScheduler::init(int num_threads) } } } - + users++; } @@ -295,7 +295,7 @@ bool TaskScheduler::thread_wait_pop(Entry& entry) assert(do_exit); return false; } - + entry = queue.front(); queue.pop_front(); @@ -518,4 +518,3 @@ string TaskPool::Summary::full_report() const } CCL_NAMESPACE_END - diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h index 3ebfb007e40..15f0d341be7 100644 --- a/intern/cycles/util/util_task.h +++ b/intern/cycles/util/util_task.h @@ -118,7 +118,7 @@ protected: }; /* Task Scheduler - * + * * Central scheduler that holds running threads ready to execute tasks. A singe * queue holds the task from all pools. */ @@ -207,4 +207,3 @@ protected: CCL_NAMESPACE_END #endif - diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h index 4d8f464359c..77b51d37ea0 100644 --- a/intern/cycles/util/util_thread.h +++ b/intern/cycles/util/util_thread.h @@ -155,4 +155,3 @@ protected: CCL_NAMESPACE_END #endif /* __UTIL_THREAD_H__ */ - diff --git a/intern/cycles/util/util_time.cpp b/intern/cycles/util/util_time.cpp index 7c39aa294bf..bc6ac4e2099 100644 --- a/intern/cycles/util/util_time.cpp +++ b/intern/cycles/util/util_time.cpp @@ -77,4 +77,3 @@ void time_sleep(double t) CCL_NAMESPACE_END #endif - diff --git a/intern/cycles/util/util_time.h b/intern/cycles/util/util_time.h index f03aa590e9b..13281bf188b 100644 --- a/intern/cycles/util/util_time.h +++ b/intern/cycles/util/util_time.h @@ -59,4 +59,3 @@ protected: CCL_NAMESPACE_END #endif - diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp index 206c3da23eb..c72e729a2e5 100644 --- a/intern/cycles/util/util_transform.cpp +++ b/intern/cycles/util/util_transform.cpp @@ -16,10 +16,10 @@ /* * Adapted from code with license: - * + * * Copyright (c) 2002, Industrial Light & Magic, a division of Lucas * Digital Ltd. LLC. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -31,8 +31,8 @@ * distribution. * * Neither the name of Industrial Light & Magic nor the names of its * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * + * from this software without specific prior written permission. + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -236,7 +236,7 @@ static void transform_decompose(DecomposedTransform *decomp, const Transform *tf for(int i = 0; i < 3; i++) for(int j = 0; j < 4; j++) Rnext[i][j] = 0.5f * (R[i][j] + Rit[i][j]); - + norm = 0.0f; for(int i = 0; i < 3; i++) { norm = max(norm, diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h index 987f4dac777..e781f85dded 100644 --- a/intern/cycles/util/util_transform.h +++ b/intern/cycles/util/util_transform.h @@ -258,7 +258,7 @@ ccl_device_inline bool transform_uniform_scale(const Transform& tfm, float& scal /* the epsilon here is quite arbitrary, but this function is only used for * surface area and bump, where we expect it to not be so sensitive */ float eps = 1e-6f; - + float sx = len_squared(float4_to_float3(tfm.x)); float sy = len_squared(float4_to_float3(tfm.y)); float sz = len_squared(float4_to_float3(tfm.z)); @@ -471,4 +471,3 @@ OPENCL_TRANSFORM_ADDRSPACE_DECLARE(transform_direction_transposed) CCL_NAMESPACE_END #endif /* __UTIL_TRANSFORM_H__ */ - diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index 4bbba649ff2..dfe755a8789 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -152,4 +152,3 @@ CCL_NAMESPACE_END #endif #endif /* __UTIL_TYPES_H__ */ - diff --git a/intern/cycles/util/util_types_float4_impl.h b/intern/cycles/util/util_types_float4_impl.h index 09f45f47d38..a49fac65b10 100644 --- a/intern/cycles/util/util_types_float4_impl.h +++ b/intern/cycles/util/util_types_float4_impl.h @@ -102,7 +102,7 @@ ccl_device_inline float4 make_float4(const int4& i) ccl_device_inline void print_float4(const char *label, const float4& a) { printf("%s: %.8f %.8f %.8f %.8f\n", - label, + label, (double)a.x, (double)a.y, (double)a.z, (double)a.w); } #endif /* __KERNEL_GPU__ */ diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h index 8d91d3936a4..569f503b66e 100644 --- a/intern/cycles/util/util_vector.h +++ b/intern/cycles/util/util_vector.h @@ -341,4 +341,3 @@ protected: CCL_NAMESPACE_END #endif /* __UTIL_VECTOR_H__ */ - diff --git a/intern/cycles/util/util_view.cpp b/intern/cycles/util/util_view.cpp index 10d86167921..3836cc86ee0 100644 --- a/intern/cycles/util/util_view.cpp +++ b/intern/cycles/util/util_view.cpp @@ -272,4 +272,3 @@ void view_redraw() } CCL_NAMESPACE_END - diff --git a/intern/cycles/util/util_view.h b/intern/cycles/util/util_view.h index 5def0564175..e603e605776 100644 --- a/intern/cycles/util/util_view.h +++ b/intern/cycles/util/util_view.h @@ -41,4 +41,3 @@ void view_redraw(); CCL_NAMESPACE_END #endif /*__UTIL_VIEW_H__*/ - diff --git a/intern/cycles/util/util_windows.h b/intern/cycles/util/util_windows.h index 7ea3e65c2c5..3b23ce8a3cb 100644 --- a/intern/cycles/util/util_windows.h +++ b/intern/cycles/util/util_windows.h @@ -57,4 +57,3 @@ CCL_NAMESPACE_END #endif /* WIN32 */ #endif /* __UTIL_WINDOWS_H__ */ - -- cgit v1.2.3 From d20d2bcb7fe76a5a8241eefb2f2f3374e4d101bd Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Fri, 6 Jul 2018 10:21:02 +0200 Subject: Cycles: Fixed OpenCL kernel build, it threw a compiler error. --- intern/cycles/kernel/filter/filter_defines.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/intern/cycles/kernel/filter/filter_defines.h b/intern/cycles/kernel/filter/filter_defines.h index d48ea3ac1d6..1a2f22a6987 100644 --- a/intern/cycles/kernel/filter/filter_defines.h +++ b/intern/cycles/kernel/filter/filter_defines.h @@ -50,7 +50,15 @@ typedef struct TileInfo { tile_buffer_1, tile_buffer_2, tile_buffer_3, \ tile_buffer_4, tile_buffer_5, tile_buffer_6, \ tile_buffer_7, tile_buffer_8, tile_buffer_9 -# define ccl_get_tile_buffer(id) (tile_buffer_ ## id) +# define ccl_get_tile_buffer(id) (id == 0 ? tile_buffer_1 \ + : id == 1 ? tile_buffer_2 \ + : id == 2 ? tile_buffer_3 \ + : id == 3 ? tile_buffer_4 \ + : id == 4 ? tile_buffer_5 \ + : id == 5 ? tile_buffer_6 \ + : id == 6 ? tile_buffer_7 \ + : id == 7 ? tile_buffer_8 \ + : tile_buffer_9) #else # ifdef __KERNEL_CUDA__ # define CCL_FILTER_TILE_INFO ccl_global TileInfo* tile_info -- cgit v1.2.3 From 174a3348ab78796b671c25d2f09105a2470102d6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 10:23:08 +0200 Subject: Addons: svg has been updated --- source/blender/blenloader/intern/versioning_defaults.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index e4b1ccd1d2b..0f219526642 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -100,7 +100,6 @@ void BLO_update_defaults_userpref_blend(void) { const char *addon_id_remove[] = { "io_anim_bvh", - "io_curve_svg", "io_mesh_ply", "io_mesh_stl", "io_mesh_uv_layout", -- cgit v1.2.3 From 6379c7bd4743cead9121493a41fade42ec465a69 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 10:59:29 +0200 Subject: Addons: silence warnings instead of disabling --- release/scripts/modules/addon_utils.py | 14 ++++++++++++++ .../blender/blenloader/intern/versioning_defaults.c | 19 ------------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index c96acb002af..90f6dc665de 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -353,6 +353,20 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non # 1.1) fail when add-on is too old # This is a temporary 2.8x migration check, so we can manage addons that are supported. + + # Silent default, we know these need updating. + if module_name in { + "io_anim_bvh", + "io_mesh_ply", + "io_mesh_stl", + "io_mesh_uv_layout", + "io_scene_3ds", + "io_scene_fbx", + "io_scene_obj", + "io_scene_x3d", + }: + return None + try: print(mod.bl_info.get("blender", (0, 0, 0))) if mod.bl_info.get("blender", (0, 0, 0)) < (2, 80, 0): diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 0f219526642..d43000e859e 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -44,7 +44,6 @@ #include "DNA_object_types.h" #include "DNA_workspace_types.h" -#include "BKE_addon.h" #include "BKE_brush.h" #include "BKE_library.h" #include "BKE_main.h" @@ -53,7 +52,6 @@ #include "BLO_readfile.h" - /** * Override values in in-memory startup.blend, avoids resaving for small changes. */ @@ -96,23 +94,6 @@ void BLO_update_defaults_userpref_blend(void) U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE; #endif - /* XXX, until these are working w/ 2.8x. */ - { - const char *addon_id_remove[] = { - "io_anim_bvh", - "io_mesh_ply", - "io_mesh_stl", - "io_mesh_uv_layout", - "io_scene_3ds", - "io_scene_fbx", - "io_scene_obj", - "io_scene_x3d", - }; - for (int i = 0; i < ARRAY_SIZE(addon_id_remove); i++) { - BKE_addon_remove_safe(&U.addons, addon_id_remove[i]); - } - } - /* Ignore the theme saved in the blend file, * instead use the theme from 'userdef_default_theme.c' */ { -- cgit v1.2.3 From 3e0920c61acda3d5fd685a192ed09b0ead6332ab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 11:17:50 +0200 Subject: Fix view pie menu --- release/scripts/startup/bl_ui/space_view3d.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 3c367236cb1..611deb1889b 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3582,7 +3582,8 @@ class VIEW3D_MT_view_pie(Menu): layout = self.layout pie = layout.menu_pie() - pie.operator_enum("VIEW3D_OT_viewnumpad", "type") + pie.operator_enum("VIEW3D_OT_view_axis", "type") + pie.operator("view3d.view_camera", text="View Camera", icon='CAMERA_DATA') pie.operator("view3d.view_selected", text="View Selected", icon='ZOOM_SELECTED') -- cgit v1.2.3 From df30b50f2f5ee66e055fc795fea91c0f7f4954d5 Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Fri, 6 Jul 2018 11:42:34 +0200 Subject: Cycles: Enabled half precision textures for OpenCL devices that support the cl_khr_fp16 extension. --- intern/cycles/device/device_opencl.cpp | 4 +++ intern/cycles/device/opencl/opencl.h | 13 ++++++-- intern/cycles/device/opencl/opencl_util.cpp | 38 +++++++++++++++++++++- intern/cycles/kernel/kernel_compat_opencl.h | 5 +++ .../kernel/kernels/opencl/kernel_opencl_image.h | 11 +++++++ 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 9d61bbdae5d..95eef8263d4 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -137,6 +137,10 @@ void device_opencl_info(vector& devices) info.has_volume_decoupled = false; info.bvh_layout_mask = BVH_LAYOUT_BVH2; info.id = id; + + /* Check OpenCL extensions */ + info.has_half_images = platform_device.device_extensions.find("cl_khr_fp16") != string::npos; + devices.push_back(info); num_devices++; } diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index 22e0503365c..d0571fc3c14 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -59,19 +59,22 @@ struct OpenCLPlatformDevice { cl_device_id device_id, cl_device_type device_type, const string& device_name, - const string& hardware_id) + const string& hardware_id, + const string& device_extensions) : platform_id(platform_id), platform_name(platform_name), device_id(device_id), device_type(device_type), device_name(device_name), - hardware_id(hardware_id) {} + hardware_id(hardware_id), + device_extensions(device_extensions) {} cl_platform_id platform_id; string platform_name; cl_device_id device_id; cl_device_type device_type; string device_name; string hardware_id; + string device_extensions; }; /* Contains all static OpenCL helper functions. */ @@ -130,6 +133,12 @@ public: static string get_device_name(cl_device_id device_id); + static bool get_device_extensions(cl_device_id device_id, + string *device_extensions, + cl_int* error = NULL); + + static string get_device_extensions(cl_device_id device_id); + static bool get_device_type(cl_device_id device_id, cl_device_type *device_type, cl_int* error = NULL); diff --git a/intern/cycles/device/opencl/opencl_util.cpp b/intern/cycles/device/opencl/opencl_util.cpp index 78ed401bff5..9104f64bedd 100644 --- a/intern/cycles/device/opencl/opencl_util.cpp +++ b/intern/cycles/device/opencl/opencl_util.cpp @@ -831,13 +831,15 @@ void OpenCLInfo::get_usable_devices(vector *usable_devices FIRST_VLOG(2) << "Adding new device " << readable_device_name << "."; string hardware_id = get_hardware_id(platform_name, device_id); + string device_extensions = get_device_extensions(device_id); usable_devices->push_back(OpenCLPlatformDevice( platform_id, platform_name, device_id, device_type, readable_device_name, - hardware_id)); + hardware_id, + device_extensions)); } else { FIRST_VLOG(2) << "Ignoring device " << device_name @@ -1047,6 +1049,40 @@ string OpenCLInfo::get_device_name(cl_device_id device_id) return device_name; } +bool OpenCLInfo::get_device_extensions(cl_device_id device_id, + string *device_extensions, + cl_int* error) +{ + char buffer[1024]; + cl_int err; + if((err = clGetDeviceInfo(device_id, + CL_DEVICE_EXTENSIONS, + sizeof(buffer), + &buffer, + NULL)) != CL_SUCCESS) + { + if(error != NULL) { + *error = err; + } + *device_extensions = ""; + return false; + } + if(error != NULL) { + *error = CL_SUCCESS; + } + *device_extensions = buffer; + return true; +} + +string OpenCLInfo::get_device_extensions(cl_device_id device_id) +{ + string device_extensions; + if(!get_device_extensions(device_id, &device_extensions)) { + return ""; + } + return device_extensions; +} + bool OpenCLInfo::get_device_type(cl_device_id device_id, cl_device_type *device_type, cl_int* error) diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h index 438c819eec6..d1ae10a0384 100644 --- a/intern/cycles/kernel/kernel_compat_opencl.h +++ b/intern/cycles/kernel/kernel_compat_opencl.h @@ -150,6 +150,11 @@ /* define NULL */ #define NULL 0 +/* enable extensions */ +#ifdef __KERNEL_CL_KHR_FP16__ +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif + #include "util/util_half.h" #include "util/util_types.h" diff --git a/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h b/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h index 011623130eb..dd9d683e030 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h +++ b/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h @@ -72,6 +72,17 @@ ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, const ccl_glo return make_float4(f, f, f, 1.0f); } /* Byte */ +#ifdef cl_khr_fp16 + /* half and half4 are optional in OpenCL */ + else if(texture_type == IMAGE_DATA_TYPE_HALF) { + float f = tex_fetch(half, info, offset); + return make_float4(f, f, f, 1.0f); + } + else if(texture_type == IMAGE_DATA_TYPE_HALF4) { + half4 r = tex_fetch(half4, info, offset); + return make_float4(r.x, r.y, r.z, r.w); + } +#endif else { uchar r = tex_fetch(uchar, info, offset); float f = r * (1.0f/255.0f); -- cgit v1.2.3 From 3cc2a9b934d072fdd817863aa8e93e2416f5c804 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 22 Jun 2018 13:44:12 +0200 Subject: Fix T55581: kill running (render) jobs when deleting a scene also fixed passing WM_JOB_TYPE_ANY to WM_jobs_kill_type() Reviewed By: brecht Differential Revision: https://developer.blender.org/D3498 --- source/blender/editors/screen/screen_edit.c | 4 ++++ source/blender/windowmanager/intern/wm_jobs.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 82552c35786..131b509df5a 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1447,6 +1447,10 @@ bool ED_screen_delete_scene(bContext *C, Scene *scene) Main *bmain = CTX_data_main(C); Scene *newscene; + // kill running jobs + wmWindowManager *wm = CTX_wm_manager(C); + WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_ANY); + if (scene->id.prev) newscene = scene->id.prev; else if (scene->id.next) diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 3a4195ae1ae..dd9e7edf413 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -500,7 +500,7 @@ void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type) next_job = wm_job->next; if (!owner || wm_job->owner == owner) - if (wm_job->job_type == job_type) + if (job_type == WM_JOB_TYPE_ANY || wm_job->job_type == job_type) wm_jobs_kill_job(wm, wm_job); } } -- cgit v1.2.3 From dd5c25fab205daea5afa7e62d80d56ac17f297fa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 12:10:30 +0200 Subject: Remove print left in by accident --- release/scripts/modules/addon_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 90f6dc665de..1814c87deda 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -368,7 +368,6 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non return None try: - print(mod.bl_info.get("blender", (0, 0, 0))) if mod.bl_info.get("blender", (0, 0, 0)) < (2, 80, 0): raise Exception(f"Add-on '{module_name:s}' has not been upgraded to 2.8, ignoring") except Exception as ex: -- cgit v1.2.3 From 769104016636b26be1b01726a1ea45c95b184a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 6 Jul 2018 12:40:09 +0200 Subject: Ocean Modifier: removed the MOD_OCEAN_REFRESH_ADD flag The flag was only used in readfile.c, and resulted in a delayed call to BKE_ocean_add(); this call is now immediately made instead as it's not very expensive. --- source/blender/blenloader/intern/readfile.c | 5 +++-- source/blender/makesdna/DNA_modifier_types.h | 2 +- source/blender/modifiers/intern/MOD_ocean.c | 3 --- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c57817c275a..a03016c2536 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -138,6 +138,7 @@ #include "BKE_multires.h" #include "BKE_node.h" // for tree type defines #include "BKE_object.h" +#include "BKE_ocean.h" #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pointcache.h" @@ -5362,8 +5363,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) else if (md->type == eModifierType_Ocean) { OceanModifierData *omd = (OceanModifierData *)md; omd->oceancache = NULL; - omd->ocean = NULL; - omd->refresh = (MOD_OCEAN_REFRESH_ADD|MOD_OCEAN_REFRESH_RESET|MOD_OCEAN_REFRESH_SIM); + omd->ocean = BKE_ocean_add(); + omd->refresh = MOD_OCEAN_REFRESH_RESET | MOD_OCEAN_REFRESH_SIM; } else if (md->type == eModifierType_Warp) { WarpModifierData *tmd = (WarpModifierData *)md; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index a023237d847..f7fb3e0e376 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1010,7 +1010,7 @@ enum { enum { MOD_OCEAN_REFRESH_RESET = (1 << 0), MOD_OCEAN_REFRESH_SIM = (1 << 1), - MOD_OCEAN_REFRESH_ADD = (1 << 2), + /* MOD_OCEAN_REFRESH_ADD = (1 << 2), */ MOD_OCEAN_REFRESH_CLEAR_CACHE = (1 << 3), MOD_OCEAN_REFRESH_TOPOLOGY = (1 << 4), }; diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index c29e835797b..b845e62c530 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -435,9 +435,6 @@ static DerivedMesh *doOcean( } /* update modifier */ - if (omd->refresh & MOD_OCEAN_REFRESH_ADD) { - omd->ocean = BKE_ocean_add(); - } if (omd->refresh & MOD_OCEAN_REFRESH_RESET) { init_ocean_modifier(omd); } -- cgit v1.2.3 From 12ce0cfb21d83b70183a64de47ad05b5775b4937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 6 Jul 2018 12:42:58 +0200 Subject: Ocean Modifier: removed unused refresh flags The flags were set and cleared correctly, but nothing was actually reading them. --- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/makesdna/DNA_modifier_types.h | 4 ++-- source/blender/makesrna/intern/rna_modifier.c | 32 ++++++--------------------- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a03016c2536..4e845b9a60d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5364,7 +5364,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) OceanModifierData *omd = (OceanModifierData *)md; omd->oceancache = NULL; omd->ocean = BKE_ocean_add(); - omd->refresh = MOD_OCEAN_REFRESH_RESET | MOD_OCEAN_REFRESH_SIM; + omd->refresh = MOD_OCEAN_REFRESH_RESET; } else if (md->type == eModifierType_Warp) { WarpModifierData *tmd = (WarpModifierData *)md; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index f7fb3e0e376..00ae9ff8b60 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1009,10 +1009,10 @@ enum { enum { MOD_OCEAN_REFRESH_RESET = (1 << 0), - MOD_OCEAN_REFRESH_SIM = (1 << 1), + /* MOD_OCEAN_REFRESH_SIM = (1 << 1), */ /* MOD_OCEAN_REFRESH_ADD = (1 << 2), */ MOD_OCEAN_REFRESH_CLEAR_CACHE = (1 << 3), - MOD_OCEAN_REFRESH_TOPOLOGY = (1 << 4), + /* MOD_OCEAN_REFRESH_TOPOLOGY = (1 << 4), */ }; enum { diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 902074d8628..1a05b6e5e00 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -737,25 +737,7 @@ static void rna_OceanModifier_init_update(Main *bmain, Scene *scene, PointerRNA { OceanModifierData *omd = (OceanModifierData *)ptr->data; - omd->refresh |= (MOD_OCEAN_REFRESH_RESET | MOD_OCEAN_REFRESH_SIM | MOD_OCEAN_REFRESH_CLEAR_CACHE); - - rna_Modifier_update(bmain, scene, ptr); -} - -static void rna_OceanModifier_sim_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - OceanModifierData *omd = (OceanModifierData *)ptr->data; - - omd->refresh |= MOD_OCEAN_REFRESH_SIM; - - rna_Modifier_update(bmain, scene, ptr); -} - -static void rna_OceanModifier_topology_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - OceanModifierData *omd = (OceanModifierData *)ptr->data; - - omd->refresh |= MOD_OCEAN_REFRESH_TOPOLOGY; + omd->refresh |= MOD_OCEAN_REFRESH_RESET | MOD_OCEAN_REFRESH_CLEAR_CACHE; rna_Modifier_update(bmain, scene, ptr); } @@ -4070,7 +4052,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Size", "Surface scale factor (does not affect the height of the waves)"); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, -1); - RNA_def_property_update(prop, 0, "rna_OceanModifier_topology_update"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "repeat_x", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "repeat_x"); @@ -4078,7 +4060,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna) RNA_def_property_range(prop, 1, 1024); RNA_def_property_ui_range(prop, 1, 100, 1, -1); RNA_def_property_ui_text(prop, "Repeat X", "Repetitions of the generated surface in X"); - RNA_def_property_update(prop, 0, "rna_OceanModifier_topology_update"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "repeat_y", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "repeat_y"); @@ -4086,7 +4068,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna) RNA_def_property_range(prop, 1, 1024); RNA_def_property_ui_range(prop, 1, 100, 1, -1); RNA_def_property_ui_text(prop, "Repeat Y", "Repetitions of the generated surface in Y"); - RNA_def_property_update(prop, 0, "rna_OceanModifier_topology_update"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_normals", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_OCEAN_GENERATE_NORMALS); @@ -4150,7 +4132,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna) prop = RNA_def_property(srna, "wave_scale", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "wave_scale"); RNA_def_property_ui_text(prop, "Wave Scale", "Scale of the displacement effect"); - RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "depth", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "depth"); @@ -4182,13 +4164,13 @@ static void rna_def_modifier_ocean(BlenderRNA *brna) "Choppiness of the wave's crest (adds some horizontal component to the displacement)"); RNA_def_property_ui_range(prop, 0.0, 4.0, 3, -1); RNA_def_property_float_funcs(prop, NULL, "rna_OceanModifier_ocean_chop_set", NULL); - RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "time"); RNA_def_property_ui_text(prop, "Time", "Current time of the simulation"); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, -1); - RNA_def_property_update(prop, 0, "rna_OceanModifier_sim_update"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "random_seed", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "seed"); -- cgit v1.2.3 From 0987c11c768367f2d236683c6ae0c39c55891bbd Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 6 Jul 2018 12:58:07 +0200 Subject: fix c++ comment style in 3cc2a9b934d0 --- source/blender/editors/screen/screen_edit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 131b509df5a..e4d748afecf 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1447,7 +1447,7 @@ bool ED_screen_delete_scene(bContext *C, Scene *scene) Main *bmain = CTX_data_main(C); Scene *newscene; - // kill running jobs + /* kill running jobs */ wmWindowManager *wm = CTX_wm_manager(C); WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_ANY); -- cgit v1.2.3 From 81a93df6d22c2f148667b9a6e8308e083a4cec39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 6 Jul 2018 13:52:35 +0200 Subject: Fix crash when startup file has an image in it This fixes an issue introduced in d192d723123add1dde3e9f7e9458aefcafb7e7d2. When starting up, the UI hasn't been fully initialised yet, and calling wm_event_do_depsgraph() can trigger icon updates when the startup file contains an image, causing a segfault due to a not-yet-initialised ghash for the icons. --- source/blender/windowmanager/intern/wm_files.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 240f1e48e4b..6b727a57370 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -484,7 +484,13 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo Main *bmain = CTX_data_main(C); DEG_on_visible_update(bmain, true); - wm_event_do_depsgraph(C); + + if (!is_startup_file) { + /* When starting up, the UI hasn't been fully initialised yet, and + * this call can trigger icon updates, causing a segfault due to a + * not-yet-initialised ghash for the icons. */ + wm_event_do_depsgraph(C); + } ED_editors_init(C); -- cgit v1.2.3 From 02f903d0996a785b5e167b26907ff53e967037d7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 6 Jul 2018 11:28:00 +0200 Subject: Fix layout issue with enum property separators. --- source/blender/editors/interface/interface_layout.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 358131fcb87..16016a799ef 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -680,12 +680,15 @@ static void ui_item_enum_expand( } for (item = item_array; item->identifier; item++) { - if (!item->identifier[0] && (item+1)->identifier) { - if (radial && layout_radial) { - uiItemS(layout_radial); - } - else { - uiItemS(block->curlayout); + if (!item->identifier[0]) { + const EnumPropertyItem *next_item = item + 1; + if (next_item->identifier) { + if (radial && layout_radial) { + uiItemS(layout_radial); + } + else { + uiItemS(block->curlayout); + } } continue; } -- cgit v1.2.3 From a364150c14dbe8676b65cd45b54f43a581c3b765 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 6 Jul 2018 11:37:17 +0200 Subject: Fix crash with properties editor pinning. --- source/blender/editors/space_buttons/buttons_context.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 19a55c2e3cd..4c6de3ec012 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -204,6 +204,9 @@ static int buttons_context_path_object(ButsContextPath *path) if (RNA_struct_is_a(ptr->type, &RNA_Object)) { return 1; } + if (!RNA_struct_is_a(ptr->type, &RNA_ViewLayer)) { + return 0; + } ViewLayer *view_layer = ptr->data; Object *ob = (view_layer->basact) ? view_layer->basact->object : NULL; -- cgit v1.2.3 From 3da1207b485ee03cacbb30204229ea76f7265b11 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 6 Jul 2018 13:02:15 +0200 Subject: UI: draw search popups with menu background, instead of box. Otherwise these are not visible well with the new dark theme. --- source/blender/editors/interface/interface_region_search.c | 4 ++-- source/blender/editors/interface/interface_widgets.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c index 9ca79a3dc63..d262cbc38bd 100644 --- a/source/blender/editors/interface/interface_region_search.c +++ b/source/blender/editors/interface/interface_region_search.c @@ -406,7 +406,7 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *ar) wmOrtho2_region_pixelspace(ar); if (data->noback == false) { - ui_draw_widget_back(UI_WTYPE_BOX, true, &data->bbox); + ui_draw_widget_back(UI_WTYPE_MENU_BACK, true, &data->bbox); } /* draw text */ @@ -686,7 +686,7 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe wmOrtho2_region_pixelspace(ar); if (data->noback == false) { - ui_draw_widget_back(UI_WTYPE_BOX, true, &data->bbox); + ui_draw_widget_back(UI_WTYPE_MENU_BACK, true, &data->bbox); } /* draw text */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 19aff48e2c1..c390c3fdda8 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -4564,6 +4564,7 @@ void ui_draw_widget_back_color( if (use_shadow) { GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit); GPU_blend(false); } -- cgit v1.2.3 From 9fc79a403374d06a23080df6249c207357009716 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 6 Jul 2018 13:46:26 +0200 Subject: UI: disable broken horizontal properties editor alignment. --- .../blender/blenloader/intern/versioning_legacy.c | 1 - source/blender/editors/interface/interface_panel.c | 19 +++++++++++-------- .../blender/editors/space_buttons/space_buttons.c | 22 +++++----------------- source/blender/makesdna/DNA_space_types.h | 10 +--------- source/blender/makesrna/intern/rna_space.c | 21 --------------------- 5 files changed, 17 insertions(+), 56 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index bc69b1d99fc..8dae3b235c2 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1033,7 +1033,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) SpaceButs *sbuts = (SpaceButs *) sl; sbuts->v2d.maxzoom = 1.2f; - sbuts->align = 1; /* horizontal default */ if (sbuts->mainb == BUTS_LAMP) { sbuts->mainb = CONTEXT_SHADING; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 8107254f30b..a99a6610e88 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -117,12 +117,17 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat /*********************** space specific code ************************/ /* temporary code to remove all sbuts stuff from panel code */ +/* SpaceButs.align */ +typedef enum eSpaceButtons_Align { + BUT_HORIZONTAL = 0, + BUT_VERTICAL = 1, + BUT_AUTO = 2, +} eSpaceButtons_Align; + static int panel_aligned(ScrArea *sa, ARegion *ar) { - if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) { - SpaceButs *sbuts = sa->spacedata.first; - return sbuts->align; - } + if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) + return BUT_VERTICAL; else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) return BUT_VERTICAL; else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) @@ -180,10 +185,8 @@ static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **pa_animate) if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) { SpaceButs *sbuts = sa->spacedata.first; - if (sbuts->align) { - if (sbuts->re_align || sbuts->mainbo != sbuts->mainb) { - return true; - } + if (sbuts->mainbo != sbuts->mainb) { + return true; } } else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) { diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 55ca3524a61..6f7a4ca971a 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -65,7 +65,6 @@ static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s sbuts = MEM_callocN(sizeof(SpaceButs), "initbuts"); sbuts->spacetype = SPACE_BUTS; - sbuts->align = BUT_VERTICAL; sbuts->mainb = sbuts->mainbuser = BCONTEXT_OBJECT; @@ -109,17 +108,8 @@ static void buttons_free(SpaceLink *sl) } /* spacetype; init callback */ -static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) +static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) { - SpaceButs *sbuts = sa->spacedata.first; - - /* auto-align based on size */ - if (sbuts->align == BUT_AUTO || !sbuts->align) { - if (sa->winx > sa->winy) - sbuts->align = BUT_HORIZONTAL; - else - sbuts->align = BUT_VERTICAL; - } } static SpaceLink *buttons_duplicate(SpaceLink *sl) @@ -146,8 +136,6 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *ar) static void buttons_main_region_layout_properties(const bContext *C, SpaceButs *sbuts, ARegion *ar) { - const bool vertical = (sbuts->align == BUT_VERTICAL); - buttons_context_compute(C, sbuts); const char *contexts[2] = {NULL, NULL}; @@ -203,12 +191,12 @@ static void buttons_main_region_layout_properties(const bContext *C, SpaceButs * break; } + const bool vertical = true; ED_region_panels_layout_ex(C, ar, contexts, sbuts->mainb, vertical); } -static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts, ARegion *ar) +static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar) { - const bool vertical = (sbuts->align == BUT_VERTICAL); const char *contexts[3] = {NULL}; const WorkSpace *workspace = CTX_wm_workspace(C); @@ -263,6 +251,7 @@ static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts, /* TODO */ } + const bool vertical = true; ED_region_panels_layout_ex(C, ar, contexts, -1, vertical); } @@ -272,13 +261,12 @@ static void buttons_main_region_layout(const bContext *C, ARegion *ar) SpaceButs *sbuts = CTX_wm_space_buts(C); if (sbuts->mainb == BCONTEXT_TOOL) { - buttons_main_region_layout_tool(C, sbuts, ar); + buttons_main_region_layout_tool(C, ar); } else { buttons_main_region_layout_properties(C, sbuts, ar); } - sbuts->re_align = 0; sbuts->mainbo = sbuts->mainb; } diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index bbfbf660774..d6d043b03ae 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -138,8 +138,8 @@ typedef struct SpaceButs { short space_subtype; short mainb, mainbo, mainbuser; /* context tabs */ - short re_align, align; /* align for panels */ short preview; /* preview is signal to refresh */ + short pad[2]; char flag; char collection_context; @@ -213,14 +213,6 @@ typedef enum eSpaceButtons_Flag { SB_SHADING_CONTEXT = (1 << 4), } eSpaceButtons_Flag; -/* SpaceButs.align */ -typedef enum eSpaceButtons_Align { - BUT_FREE = 0, - BUT_HORIZONTAL = 1, - BUT_VERTICAL = 2, - BUT_AUTO = 3, -} eSpaceButtons_Align; - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 92913e29f69..2a7bb5994c3 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1326,14 +1326,6 @@ static void rna_SpaceProperties_context_update(Main *UNUSED(bmain), Scene *UNUSE } } -static void rna_SpaceProperties_align_set(PointerRNA *ptr, int value) -{ - SpaceButs *sbuts = (SpaceButs *)(ptr->data); - - sbuts->align = value; - sbuts->re_align = 1; -} - /* Space Console */ static void rna_ConsoleLine_body_get(PointerRNA *ptr, char *value) { @@ -3161,12 +3153,6 @@ static void rna_def_space_buttons(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem align_items[] = { - {BUT_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""}, - {BUT_VERTICAL, "VERTICAL", 0, "Vertical", ""}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "SpaceProperties", "Space"); RNA_def_struct_sdna(srna, "SpaceButs"); RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data"); @@ -3178,13 +3164,6 @@ static void rna_def_space_buttons(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Context", "Type of active data to display and edit"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_SpaceProperties_context_update"); - prop = RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "align"); - RNA_def_property_enum_items(prop, align_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_align_set", NULL); - RNA_def_property_ui_text(prop, "Align", "Arrangement of the panels"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, NULL); - /* pinned data */ prop = RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pinid"); -- cgit v1.2.3 From b0c32818ba401a81c18f89f931d4336d8e859bc2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 6 Jul 2018 13:37:39 +0200 Subject: UI: small layout fixes for RMB context menus. --- release/scripts/startup/bl_ui/space_topbar.py | 1 + source/blender/editors/screen/screen_ops.c | 20 ++++++++++++++++---- source/blender/editors/space_buttons/buttons_ops.c | 16 ++++------------ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 5cf28578217..5129b5648ce 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -557,6 +557,7 @@ class TOPBAR_MT_window_specials(Menu): layout.operator_context = 'EXEC_AREA' layout.operator("wm.window_new") + layout.operator("wm.window_new_main") layout.operator_context = 'INVOKE_AREA' diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index ab0fbfacf93..4a8ab724c9a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3659,27 +3659,38 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot) /** \name Header Tools Operator * \{ */ +static bool header_context_menu_poll(bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + return (sa && sa->spacetype != SPACE_STATUSBAR); +} + void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : IFACE_("Flip to Top"); - uiItemO(layout, IFACE_("Toggle Header"), ICON_NONE, "SCREEN_OT_header"); + if (!ELEM(sa->spacetype, SPACE_TOPBAR)) { + uiItemO(layout, IFACE_("Toggle Header"), ICON_NONE, "SCREEN_OT_header"); + } /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); - uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); + if (!ELEM(sa->spacetype, SPACE_TOPBAR)) { + uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); + } + uiItemO(layout, IFACE_("Collapse Menus"), (sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT, "SCREEN_OT_header_toggle_menus"); - uiItemS(layout); - /* file browser should be fullscreen all the time, topbar should * never be. But other regions can be maximized/restored... */ if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) { + uiItemS(layout); + const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area"); uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area"); } @@ -3708,6 +3719,7 @@ static void SCREEN_OT_header_context_menu(wmOperatorType *ot) ot->idname = "SCREEN_OT_header_context_menu"; /* api callbacks */ + ot->poll = header_context_menu_poll; ot->invoke = header_context_menu_invoke; } diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 93670919d4c..fb2907983c8 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -64,17 +64,9 @@ static int context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { - bScreen *sc = CTX_wm_screen(C); - SpaceButs *sbuts = CTX_wm_space_buts(C); - PointerRNA ptr; - uiPopupMenu *pup; - uiLayout *layout; - - RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); - - pup = UI_popup_menu_begin(C, IFACE_("Align"), ICON_NONE); - layout = UI_popup_menu_layout(pup); - uiItemsEnumR(layout, &ptr, "align"); + uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Context Menu"), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); + uiItemM(layout, "INFO_MT_area", NULL, ICON_NONE); UI_popup_menu_end(C, pup); return OPERATOR_INTERFACE; @@ -84,7 +76,7 @@ void BUTTONS_OT_context_menu(wmOperatorType *ot) { /* identifiers */ ot->name = "Context Menu"; - ot->description = "Display button panel context_menu"; + ot->description = "Display properties editor context_menu"; ot->idname = "BUTTONS_OT_context_menu"; /* api callbacks */ -- cgit v1.2.3 From 3527857cdca1f5d07037f20fed9840efe1954a57 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 14:40:13 +0200 Subject: Cleanup: use outliner_flag_* name prefix --- .../blender/editors/space_outliner/outliner_edit.c | 26 +++++++++++----------- .../editors/space_outliner/outliner_intern.h | 4 ++-- .../editors/space_outliner/outliner_select.c | 2 +- .../editors/space_outliner/outliner_tools.c | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 6eda2283b6a..3708b653ec4 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -161,7 +161,7 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement /* all below close/open? */ if (all) { tselem->flag &= ~TSE_CLOSED; - outliner_set_flag(&te->subtree, TSE_CLOSED, !outliner_has_one_flag(&te->subtree, TSE_CLOSED, 1)); + outliner_flag_set(&te->subtree, TSE_CLOSED, !outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1)); } else { if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; @@ -727,7 +727,7 @@ static int outliner_count_levels(ListBase *lb, const int curlevel) return level; } -int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel) +int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel) { TreeElement *te; TreeStoreElem *tselem; @@ -737,13 +737,13 @@ int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel) tselem = TREESTORE(te); if (tselem->flag & flag) return curlevel; - level = outliner_has_one_flag(&te->subtree, flag, curlevel + 1); + level = outliner_flag_is_any_test(&te->subtree, flag, curlevel + 1); if (level) return level; } return 0; } -void outliner_set_flag(ListBase *lb, short flag, short set) +void outliner_flag_set(ListBase *lb, short flag, short set) { TreeElement *te; TreeStoreElem *tselem; @@ -752,7 +752,7 @@ void outliner_set_flag(ListBase *lb, short flag, short set) tselem = TREESTORE(te); if (set == 0) tselem->flag &= ~flag; else tselem->flag |= flag; - outliner_set_flag(&te->subtree, flag, set); + outliner_flag_set(&te->subtree, flag, set); } } @@ -965,10 +965,10 @@ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) SpaceOops *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); - if (outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1)) - outliner_set_flag(&soops->tree, TSE_CLOSED, 0); + if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1)) + outliner_flag_set(&soops->tree, TSE_CLOSED, 0); else - outliner_set_flag(&soops->tree, TSE_CLOSED, 1); + outliner_flag_set(&soops->tree, TSE_CLOSED, 1); ED_region_tag_redraw(ar); @@ -997,10 +997,10 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); - if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1)) - outliner_set_flag(&soops->tree, TSE_SELECTED, 0); + if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) + outliner_flag_set(&soops->tree, TSE_SELECTED, 0); else - outliner_set_flag(&soops->tree, TSE_SELECTED, 1); + outliner_flag_set(&soops->tree, TSE_SELECTED, 1); soops->storeflag |= SO_TREESTORE_REDRAW; @@ -1265,7 +1265,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so outliner_set_coordinates(ar, soops); /* deselect all visible, and select found element */ - outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); + outliner_flag_set(soops, &soops->tree, TSE_SELECTED, 0); tselem->flag |= TSE_SELECTED; /* make te->ys center of view */ @@ -1325,7 +1325,7 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op) const bool add = RNA_boolean_get(op->ptr, "open"); int level; - level = outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1); + level = outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1); if (add == 1) { if (level) outliner_openclose_level(&soops->tree, 1, level, 1); } diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 9bf2231b313..49647a0d838 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -172,8 +172,8 @@ void outliner_do_object_operation( int common_restrict_check(struct bContext *C, struct Object *ob); -int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel); -void outliner_set_flag(ListBase *lb, short flag, short set); +int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel); +void outliner_flag_set(ListBase *lb, short flag, short set); void object_toggle_visibility_cb( struct bContext *C, struct ReportList *reports, struct Scene *scene, diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 5149715740f..e40ba867049 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -988,7 +988,7 @@ static bool do_outliner_item_activate_from_cursor( /* all below close/open? */ if (extend) { tselem->flag &= ~TSE_CLOSED; - outliner_set_flag(&te->subtree, TSE_CLOSED, !outliner_has_one_flag(&te->subtree, TSE_CLOSED, 1)); + outliner_flag_set(&te->subtree, TSE_CLOSED, !outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1)); } else { if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 75151325bdf..2707e130598 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -1860,8 +1860,8 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop /* select object that's clicked on and popup context menu */ if (!(tselem->flag & TSE_SELECTED)) { - if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1)) - outliner_set_flag(&soops->tree, TSE_SELECTED, 0); + if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) + outliner_flag_set(&soops->tree, TSE_SELECTED, 0); tselem->flag |= TSE_SELECTED; /* redraw, same as outliner_select function */ -- cgit v1.2.3 From 571e773fbe38b2cc1a6af43e8ed55574d2caadb4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 14:45:30 +0200 Subject: Keymap: outliner now uses A/Alt-A for selection --- .../blender/editors/space_outliner/outliner_edit.c | 47 +++++++++++++++++----- .../editors/space_outliner/outliner_intern.h | 3 +- .../blender/editors/space_outliner/outliner_ops.c | 10 ++++- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index d8a5ba533c4..d9bcf05fa29 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -880,6 +880,21 @@ bool outliner_flag_set(ListBase *lb, short flag, short set) return changed; } +bool outliner_flag_flip(ListBase *lb, short flag) +{ + TreeElement *te; + TreeStoreElem *tselem; + bool changed = false; + + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + tselem->flag ^= flag; + changed |= outliner_flag_flip(&te->subtree, flag); + } + + return changed; +} + /* Restriction Columns ------------------------------- */ /* same check needed for both object operation and restrict column button func @@ -940,16 +955,27 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) /* Toggle Selected (Outliner) ---------------------------------------- */ -static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) +static int outliner_select_all_exec(bContext *C, wmOperator *op) { SpaceOops *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); + int action = RNA_enum_get(op->ptr, "action"); + if (action == SEL_TOGGLE) { + action = outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1) ? SEL_DESELECT : SEL_SELECT; + } - if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) - outliner_flag_set(&soops->tree, TSE_SELECTED, 0); - else - outliner_flag_set(&soops->tree, TSE_SELECTED, 1); + switch (action) { + case SEL_SELECT: + outliner_flag_set(&soops->tree, TSE_SELECTED, 1); + break; + case SEL_DESELECT: + outliner_flag_set(&soops->tree, TSE_SELECTED, 0); + break; + case SEL_INVERT: + outliner_flag_flip(&soops->tree, TSE_SELECTED); + break; + } DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -958,18 +984,21 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void OUTLINER_OT_selected_toggle(wmOperatorType *ot) +void OUTLINER_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "Toggle Selected"; - ot->idname = "OUTLINER_OT_selected_toggle"; + ot->idname = "OUTLINER_OT_select_all"; ot->description = "Toggle the Outliner selection of items"; /* callbacks */ - ot->exec = outliner_toggle_selected_exec; + ot->exec = outliner_select_all_exec; ot->poll = ED_operator_outliner_active; - /* no undo or registry, UI option */ + /* no undo or registry */ + + /* rna */ + WM_operator_properties_select_all(ot); } /* ************************************************************** */ diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 0763933b102..093ad9361c2 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -247,6 +247,7 @@ int common_restrict_check(struct bContext *C, struct Object *ob); int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel); bool outliner_flag_set(ListBase *lb, short flag, short set); +bool outliner_flag_flip(ListBase *lb, short flag); void object_toggle_visibility_cb( struct bContext *C, struct ReportList *reports, struct Scene *scene, @@ -305,7 +306,7 @@ void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot); void OUTLINER_OT_select_border(struct wmOperatorType *ot); -void OUTLINER_OT_selected_toggle(struct wmOperatorType *ot); +void OUTLINER_OT_select_all(struct wmOperatorType *ot); void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot); void OUTLINER_OT_scroll_page(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 760e2853038..0dd492839c9 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -431,7 +431,7 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_show_hierarchy); WM_operatortype_append(OUTLINER_OT_scroll_page); - WM_operatortype_append(OUTLINER_OT_selected_toggle); + WM_operatortype_append(OUTLINER_OT_select_all); WM_operatortype_append(OUTLINER_OT_expanded_toggle); WM_operatortype_append(OUTLINER_OT_keyingset_add_selected); @@ -542,7 +542,13 @@ void outliner_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "open", false); /* close */ - WM_keymap_add_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + WM_keymap_add_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0); /* keying sets - only for databrowse */ -- cgit v1.2.3 From 15f4aa182f82bc0642d19eab58ee8b4a5182ac46 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 6 Jul 2018 14:45:14 +0200 Subject: Depsgraph: Relations builder should not tag ID in all depsgraphs --- source/blender/depsgraph/intern/builder/deg_builder.cc | 5 ++++- source/blender/depsgraph/intern/depsgraph_tag.cc | 13 +++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index b6256e9ceb0..34da29652a4 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -69,7 +69,10 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) flag |= DEG_TAG_COPY_ON_WRITE; } if (flag != 0) { - DEG_id_tag_update_ex(bmain, id_node->id_orig, flag); + DEG_graph_id_tag_update(bmain, + (::Depsgraph*)graph, + id_node->id_orig, + flag); } } } diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 9128571155f..4229f8bf9a2 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -299,6 +299,7 @@ void depsgraph_tag_component(Depsgraph *graph, * explicitly, but not all areas are aware of this yet. */ void deg_graph_id_tag_legacy_compat(Main *bmain, + Depsgraph *depsgraph, ID *id, eDepsgraph_Tag tag) { @@ -309,7 +310,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain, Object *object = (Object *)id; ID *data_id = (ID *)object->data; if (data_id != NULL) { - DEG_id_tag_update_ex(bmain, data_id, 0); + deg_graph_id_tag_update(bmain, depsgraph, data_id, 0); } break; } @@ -322,7 +323,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain, Mesh *mesh = (Mesh *)id; ID *key_id = &mesh->key->id; if (key_id != NULL) { - DEG_id_tag_update_ex(bmain, key_id, 0); + deg_graph_id_tag_update(bmain, depsgraph, key_id, 0); } break; } @@ -331,7 +332,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain, Lattice *lattice = (Lattice *)id; ID *key_id = &lattice->key->id; if (key_id != NULL) { - DEG_id_tag_update_ex(bmain, key_id, 0); + deg_graph_id_tag_update(bmain, depsgraph, key_id, 0); } break; } @@ -340,7 +341,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain, Curve *curve = (Curve *)id; ID *key_id = &curve->key->id; if (key_id != NULL) { - DEG_id_tag_update_ex(bmain, key_id, 0); + deg_graph_id_tag_update(bmain, depsgraph, key_id, 0); } break; } @@ -396,7 +397,7 @@ static void deg_graph_id_tag_update_single_flag(Main *bmain, /* TODO(sergey): Get rid of this once all areas are using proper data ID * for tagging. */ - deg_graph_id_tag_legacy_compat(bmain, id, tag); + deg_graph_id_tag_legacy_compat(bmain, graph, id, tag); } @@ -454,7 +455,7 @@ void deg_graph_node_tag_zero(Main *bmain, Depsgraph *graph, IDDepsNode *id_node) comp_node->tag_update(graph); } GHASH_FOREACH_END(); - deg_graph_id_tag_legacy_compat(bmain, id, (eDepsgraph_Tag)0); + deg_graph_id_tag_legacy_compat(bmain, graph, id, (eDepsgraph_Tag)0); } void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag) -- cgit v1.2.3 From 7ea26cc9c53dc3d7f59012da4d7a6fad6216f904 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 14:49:51 +0200 Subject: Keymap: update 2.7x --- release/scripts/presets/keyconfig/blender_27x.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index e2a4c37cdad..5c821bea018 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -706,7 +706,8 @@ kmi_props_setattr(kmi.properties, 'up', True) kmi = km.keymap_items.new('outliner.show_one_level', 'NUMPAD_PLUS', 'PRESS') kmi = km.keymap_items.new('outliner.show_one_level', 'NUMPAD_MINUS', 'PRESS') kmi_props_setattr(kmi.properties, 'open', False) -kmi = km.keymap_items.new('outliner.selected_toggle', 'A', 'PRESS') +kmi = km.keymap_items.new('outliner.select_all', 'A', 'PRESS') +kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') kmi = km.keymap_items.new('outliner.expanded_toggle', 'A', 'PRESS', shift=True) kmi = km.keymap_items.new('outliner.keyingset_add_selected', 'K', 'PRESS') kmi = km.keymap_items.new('outliner.keyingset_remove_selected', 'K', 'PRESS', alt=True) -- cgit v1.2.3 From 4e4e88f02b521752dea7783037c4d02e5d63f1a9 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Fri, 6 Jul 2018 16:15:34 +0200 Subject: UI: Default theme unification More unification of colors and roundness. Also use accent color as current_frame indicator. --- release/datafiles/userdef/userdef_default_theme.c | 48 +++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index f7a4bd157e0..55827f7b222 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -46,7 +46,7 @@ const bTheme U_theme_default = { .item = RGBA(0xffffff8f), .text = RGBA(0xffffffff), .text_sel = RGBA(0xffffffff), - .roundness = 0.25f, + .roundness = 0.2f, }, .wcol_text = { .outline = RGBA(0x444444ff), @@ -57,12 +57,12 @@ const bTheme U_theme_default = { .text_sel = RGBA(0xffffffff), .shaded = 1, .shadetop = -3, - .roundness = 0.1f, + .roundness = 0.2f, }, .wcol_radio = { .outline = RGBA(0x373737ff), .inner = RGBA(0x595959ff), - .inner_sel = RGBA(0x5680c2e6), + .inner_sel = RGBA(0x597cb3e6), .item = RGBA(0xffffffff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), @@ -78,7 +78,7 @@ const bTheme U_theme_default = { .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shadedown = -15, - .roundness = 0.25f, + .roundness = 0.2f, }, .wcol_toggle = { .outline = RGBA(0x373737ff), @@ -87,7 +87,7 @@ const bTheme U_theme_default = { .item = RGBA(0x191919ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), - .roundness = 0.25f, + .roundness = 0.4f, }, .wcol_num = { .outline = RGBA(0x444444ff), @@ -96,7 +96,7 @@ const bTheme U_theme_default = { .item = RGBA(0x333333ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), - .roundness = 0.3f, + .roundness = 0.2f, }, .wcol_numslider = { .outline = RGBA(0x444444ff), @@ -116,7 +116,7 @@ const bTheme U_theme_default = { .item = RGBA(0x2d2d2dff), .text = RGBA(0xa4a4a4ff), .text_sel = RGBA(0xffffffff), - .roundness = 0.15f, + .roundness = 0.2f, }, .wcol_menu = { .outline = RGBA(0x444444ff), @@ -149,15 +149,15 @@ const bTheme U_theme_default = { .text_sel = RGBA(0xffffffff), .shadetop = 25, .shadedown = -20, - .roundness = 0.25f, + .roundness = 0.2f, }, .wcol_menu_item = { - .inner_sel = RGBA(0x5680c2ff), + .inner_sel = RGBA(0x597cb3e6), .item = RGBA(0xffffff8f), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shadetop = 38, - .roundness = 0.25f, + .roundness = 0.2f, }, .wcol_tooltip = { .outline = RGBA(0x19191aff), @@ -168,7 +168,7 @@ const bTheme U_theme_default = { .text_sel = RGBA(0xffffffff), .shadetop = 25, .shadedown = -20, - .roundness = 0.4f, + .roundness = 0.2f, }, .wcol_box = { .outline = RGBA(0x444444ff), @@ -197,7 +197,7 @@ const bTheme U_theme_default = { .item = RGBA(0x5680c2ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), - .roundness = 0.25f, + .roundness = 0.2f, }, .wcol_list_item = { .outline = RGBA(0x2d2d2dff), @@ -209,15 +209,15 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_pie_menu = { - .outline = RGBA(0x2e2e2eff), - .inner = RGBA(0x212121ff), + .outline = RGBA(0x212121ff), + .inner = RGBA(0x212121ef), .inner_sel = RGBA(0x585858ff), - .item = RGBA(0x5680c2ff), + .item = RGBA(0x597cb3ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), .shadetop = 10, .shadedown = -10, - .roundness = 0.5f, + .roundness = 0.2f, }, .wcol_state = { .inner_anim = RGBA(0x73be4cff), @@ -387,13 +387,13 @@ const bTheme U_theme_default = { .show_header = 1, .show_back = 1, }, - .hilite = RGBA(0x5b8199ff), + .hilite = RGBA(0x4f76b3ff), .vertex_size = 3, .outline_width = 1, .facedot_size = 4, }, .tipo = { - .back = RGBA(0x35353500), + .back = RGBA(0x42424200), .title = RGBA(0xffffffff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), @@ -421,12 +421,12 @@ const bTheme U_theme_default = { }, .shade1 = RGBA(0x96969600), .shade2 = RGBA(0x2e2e2e64), - .grid = RGBA(0x1a1a1aff), + .grid = RGBA(0x2a2a2aff), .group = RGBA(0x44992eff), .group_active = RGBA(0x5ccd3eff), .vertex = RGBA(0x000000ff), .vertex_select = RGBA(0xff8500ff), - .cframe = RGBA(0x308837ff), + .cframe = RGBA(0x5680c2ff), .lastsel_point = RGBA(0xffffffff), .handle_auto = RGBA(0x909000ff), .handle_vect = RGBA(0x409030ff), @@ -510,12 +510,12 @@ const bTheme U_theme_default = { .shade1 = RGBA(0xc0c0c000), .shade2 = RGBA(0x70707064), .hilite = RGBA(0x60c040ff), - .grid = RGBA(0x272727ff), + .grid = RGBA(0x2a2a2aff), .group = RGBA(0x44992eff), .group_active = RGBA(0x5ccd3eff), .strip = RGBA(0x1a151580), .strip_select = RGBA(0xff8c00ff), - .cframe = RGBA(0x308837ff), + .cframe = RGBA(0x5680c2ff), .ds_channel = RGBA(0x5a85b2ff), .ds_subchannel = RGBA(0x7d98b3ff), .keytype_keyframe = RGBA(0xe8e8e8ff), @@ -566,7 +566,7 @@ const bTheme U_theme_default = { .grid = RGBA(0x5e5e5eff), .strip = RGBA(0x0c0a0a80), .strip_select = RGBA(0xff8c00ff), - .cframe = RGBA(0x308837ff), + .cframe = RGBA(0x5680c2ff), .keyborder = RGBA(0x000000ff), .keyborder_select = RGBA(0x000000ff), .vertex_size = 3, @@ -611,7 +611,7 @@ const bTheme U_theme_default = { .grid = RGBA(0x404040ff), .vertex_select = RGBA(0xff8500ff), .bone_pose = RGBA(0x50c8ff50), - .cframe = RGBA(0x308837ff), + .cframe = RGBA(0x5680c2ff), .vertex_size = 3, .outline_width = 1, .facedot_size = 4, -- cgit v1.2.3 From 49af17beb8d2aca856ff8e23bac99841d1b45f5b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 7 Jul 2018 02:52:11 +1200 Subject: Fix T55796: Motion Paths are not being drawn as overlay Remove depth testing flags from motion path pass drawing, so that they always appear to draw in "x-ray" style on top of everything, making it easier for animators to see what they're doing. --- source/blender/draw/intern/draw_anim_viz.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c index 42c36ab3662..d19bd54ff5f 100644 --- a/source/blender/draw/intern/draw_anim_viz.c +++ b/source/blender/draw/intern/draw_anim_viz.c @@ -149,12 +149,12 @@ static void MPATH_cache_init(void *vedata) MPATH_PassList *psl = ((MPATH_Data *)vedata)->psl; { - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; + DRWState state = DRW_STATE_WRITE_COLOR; psl->lines = DRW_pass_create("Motionpath Line Pass", state); } { - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_POINT; + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_POINT; psl->points = DRW_pass_create("Motionpath Point Pass", state); } } -- cgit v1.2.3 From 22150eb4094ca4caf8c231ab137dcee9dc445bca Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 6 Jul 2018 17:14:16 +0200 Subject: Animation player: Ensure new frames are displayed while dragging mouse Thanks Campbell for review! --- source/blender/windowmanager/intern/wm_playanim.c | 52 ++++++++++++++--------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index d9d5bf901ca..b4f2435ee2d 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -132,6 +132,9 @@ typedef struct PlayState { /* restarts player for file drop */ char dropped_file[FILE_MAX]; + + bool need_frame_update; + int frame_cursor_x; } PlayState; /* for debugging */ @@ -548,8 +551,18 @@ static void update_sound_fps(void) #endif } -static void change_frame(PlayState *ps, int cx) +static void tag_change_frame(PlayState *ps, int cx) +{ + ps->need_frame_update = true; + ps->frame_cursor_x = cx; +} + +static void change_frame(PlayState *ps) { + if (!ps->need_frame_update) { + return; + } + int sizex, sizey; int i, i_last; @@ -559,7 +572,7 @@ static void change_frame(PlayState *ps, int cx) playanim_window_get_size(&sizex, &sizey); i_last = ((struct PlayAnimPict *)picsbase.last)->frame; - i = (i_last * cx) / sizex; + i = (i_last * ps->frame_cursor_x) / sizex; CLAMP(i, 0, i_last); #ifdef WITH_AUDASPACE @@ -600,6 +613,8 @@ static void change_frame(PlayState *ps, int cx) ps->sstep = true; ps->wait2 = false; ps->next_frame = 0; + + ps->need_frame_update = false; } static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) @@ -951,7 +966,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) if (type == GHOST_kEventButtonDown) { if (inside_window) { g_WS.qual |= WS_QUAL_LMOUSE; - change_frame(ps, cx); + tag_change_frame(ps, cx); } } else @@ -996,7 +1011,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &cx, &cy); - change_frame(ps, cx); + tag_change_frame(ps, cx); } break; } @@ -1428,23 +1443,18 @@ static char *wm_main_playanim_intern(int argc, const char **argv) ps.next_frame = ps.direction; - while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, ps.wait2))) { - if (hasevent) { - GHOST_DispatchEvents(g_WS.ghost_system); - } - /* Note, this still draws for mousemoves on pause */ - if (ps.wait2) { - if (hasevent) { - if (ibuf) { - while (pupdate_time()) PIL_sleep_ms(1); - ptottime -= swaptime; - playanim_toscreen(&ps, ps.picture, ibuf, ps.fontid, ps.fstep); - } - } - } - if (ps.go == false) { - break; - } + while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) { + GHOST_DispatchEvents(g_WS.ghost_system); + } + if (ps.go == false) { + break; + } + change_frame(&ps); + if (!hasevent) { + PIL_sleep_ms(1); + } + if (ps.wait2) { + continue; } ps.wait2 = ps.sstep; -- cgit v1.2.3 From a48b52d5466939044589bc332918463eef186ba8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 17:43:53 +0200 Subject: 3D View: support object type visibility/selection Trying to have a single option for this is too likely to be insufficient in some cases. Instead, support object type visibility & selectability per view-port. --- release/scripts/startup/bl_ui/space_view3d.py | 55 ++++++++++++++++++++++++- source/blender/draw/intern/draw_manager.c | 27 ++++++++++--- source/blender/draw/modes/object_mode.c | 4 -- source/blender/makesdna/DNA_view3d_types.h | 5 ++- source/blender/makesrna/intern/rna_space.c | 58 ++++++++++++++++++++++----- 5 files changed, 127 insertions(+), 22 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 611deb1889b..2a358b3fc9f 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -112,6 +112,14 @@ class VIEW3D_HT_header(Header): sub.active = overlay.show_overlays sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay") + layout.popover( + text="", + icon='HIDE_OFF', + space_type='VIEW_3D', + region_type='HEADER', + panel_type="VIEW3D_PT_object_type_visibility", + ) + layout.separator_spacer() # Mode & Transform Settings @@ -3834,7 +3842,6 @@ class VIEW3D_PT_overlay(Panel): sub.prop(overlay, "show_all_objects_origin") sub = split.column() - sub.prop(overlay, "show_non_geometry") sub.prop(overlay, "show_relationship_lines") sub.prop(overlay, "show_motion_paths") #sub.prop(overlay, "show_onion_skins") @@ -4110,6 +4117,51 @@ class VIEW3D_PT_overlay_paint(Panel): col.prop(overlay, "show_paint_wire") +class VIEW3D_PT_object_type_visibility(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_label = "Object Visibility" + + def draw(self, context): + layout = self.layout + view = context.space_data + + col = layout.column() + + split = col.split() + + heading_pair = ("Visible", "Selectable") + attr_object_types = ( + "mesh", + "curve", + "surf", + "meta", + "font", + "armature", + "lattice", + "empty", + "camera", + "lamp", + "light_probe", + "speaker", + ) + + attr_vis = [f"show_object_viewport_{attr}" for attr in attr_object_types] + attr_sel = [f"show_object_select_{attr}" for attr in attr_object_types] + + sub = split.column() + sub.label("Visible") + for attr_v in attr_vis: + sub.prop(view, attr_v) + + sub = split.column() + sub.label("Selectable") + for attr_v, attr_s in zip(attr_vis, attr_sel): + row = sub.row(align=True) + row.active = getattr(view, attr_v) + row.prop(view, attr_s) + + class VIEW3D_PT_pivot_point(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' @@ -4458,6 +4510,7 @@ classes = ( VIEW3D_PT_overlay_pose, VIEW3D_PT_overlay_paint, VIEW3D_PT_overlay_sculpt, + VIEW3D_PT_object_type_visibility, VIEW3D_PT_pivot_point, VIEW3D_PT_snapping, VIEW3D_PT_transform_orientations, diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index ea25739e52d..7e40966f9c8 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1274,9 +1274,12 @@ void DRW_draw_render_loop_ex( PROFILE_START(stime); drw_engines_cache_init(); + const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) { - drw_engines_cache_populate(ob); + if ((object_type_exclude_viewport & (1 << ob->type)) == 0) { + drw_engines_cache_populate(ob); + } } DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END; @@ -1557,12 +1560,17 @@ void DRW_render_object_iter( void *vedata, RenderEngine *engine, struct Depsgraph *depsgraph, void (*callback)(void *vedata, Object *ob, RenderEngine *engine, struct Depsgraph *depsgraph)) { + const DRWContextState *draw_ctx = DRW_context_state_get(); + DRW_hair_init(); + const int object_type_exclude_viewport = draw_ctx->v3d->object_type_exclude_viewport; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) { - DST.ob_state = NULL; - callback(vedata, ob, engine, depsgraph); + if ((object_type_exclude_viewport & (1 << ob->type)) == 0) { + DST.ob_state = NULL; + callback(vedata, ob, engine, depsgraph); + } } DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END } @@ -1701,6 +1709,9 @@ void DRW_draw_select_loop( #endif } else { + const int object_type_exclude_select = ( + v3d->object_type_exclude_viewport | v3d->object_type_exclude_select + ); bool filter_exclude = false; DEG_OBJECT_ITER_BEGIN( depsgraph, ob, @@ -1708,8 +1719,9 @@ void DRW_draw_select_loop( DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI) { - if ((ob->base_flag & BASE_SELECTABLE) != 0) { - + if ((ob->base_flag & BASE_SELECTABLE) && + (object_type_exclude_select & (1 << ob->type)) == 0) + { if (object_filter_fn != NULL) { if (ob->base_flag & BASE_FROMDUPLI) { /* pass (use previous filter_exclude value) */ @@ -1880,9 +1892,12 @@ void DRW_draw_depth_loop( { drw_engines_cache_init(); + const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) { - drw_engines_cache_populate(ob); + if ((object_type_exclude_viewport & (1 << ob->type)) == 0) { + drw_engines_cache_populate(ob); + } } DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 1e77631fbf0..17e4a7b15ce 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2127,10 +2127,6 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) return; } - if (v3d->overlay.object_type_exclude & (1 << ob->type)) { - return; - } - bool do_outlines = (draw_ctx->v3d->flag & V3D_SELECT_OUTLINE) && ((ob->base_flag & BASE_SELECTED) != 0); bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0); diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 5668cf24fe6..806d6f925ba 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -179,7 +179,7 @@ typedef struct View3DOverlay { /* Other settings */ float wireframe_threshold; - int object_type_exclude; + char _pad0[4]; } View3DOverlay; @@ -202,6 +202,9 @@ typedef struct View3D { unsigned int lay_prev; /* for active layer toggle */ unsigned int lay_used; /* used while drawing */ + int object_type_exclude_viewport; + int object_type_exclude_select; + short persp DNA_DEPRECATED; short view DNA_DEPRECATED; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 2a7bb5994c3..13978f3f5ee 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2609,16 +2609,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_non_geometry", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna( - prop, NULL, "overlay.object_type_exclude", - ((1 << OB_TYPE_MAX) - 1) & - ~((1 << OB_MESH) | (1 << OB_CURVE) | (1 << OB_SURF) | (1 << OB_FONT) | (1 << OB_MBALL))); - RNA_def_property_boolean_default(prop, true); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Show Non Renderable", "Draw not renderable objects in the overlay"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_text", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_TEXT); RNA_def_property_ui_text(prop, "Show Text", "Display overlay text"); @@ -3024,6 +3014,54 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Volume Alpha", "Opacity (alpha) of the cameras' frustum volume"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + { + struct { + const char *name; + int type_mask; + const char *identifier[2]; + } info[] = { + {"Mesh", (1 << OB_MESH), + {"show_object_viewport_mesh", "show_object_select_mesh"}}, + {"Curve", (1 << OB_CURVE), + {"show_object_viewport_curve", "show_object_select_curve"}}, + {"Surface", (1 << OB_SURF), + {"show_object_viewport_surf", "show_object_select_surf"}}, + {"Meta", (1 << OB_MBALL), + {"show_object_viewport_meta", "show_object_select_meta"}}, + {"Font", (1 << OB_FONT), + {"show_object_viewport_font", "show_object_select_font"}}, + {"Armature", (1 << OB_ARMATURE), + {"show_object_viewport_armature", "show_object_select_armature"}}, + {"Lattice", (1 << OB_LATTICE), + {"show_object_viewport_lattice", "show_object_select_lattice"}}, + {"Empty", (1 << OB_EMPTY), + {"show_object_viewport_empty", "show_object_select_empty"}}, + {"Camera", (1 << OB_CAMERA), + {"show_object_viewport_camera", "show_object_select_camera"}}, + {"Lamp", (1 << OB_LAMP), + {"show_object_viewport_lamp", "show_object_select_lamp"}}, + {"Speaker", (1 << OB_SPEAKER), + {"show_object_viewport_speaker", "show_object_select_speaker"}}, + {"Light Probe", (1 << OB_LIGHTPROBE), + {"show_object_viewport_light_probe", "show_object_select_light_probe"}}, + }; + + const char *view_mask_member[2] = { + "object_type_exclude_viewport", + "object_type_exclude_select", + }; + for (int mask_index = 0; mask_index < 2; mask_index++) { + for (int type_index = 0; type_index < ARRAY_SIZE(info); type_index++) { + prop = RNA_def_property(srna, info[type_index].identifier[mask_index], PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna( + prop, NULL, view_mask_member[mask_index], info[type_index].type_mask); + RNA_def_property_ui_text(prop, info[type_index].name, ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + + } + } + } + /* Nested Structs */ prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); -- cgit v1.2.3 From 4674cffe290e442d755bfe0036e980fc89524796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuk=20Garda=C5=A1evi=C4=87?= Date: Fri, 6 Jul 2018 18:22:55 +0200 Subject: UI: 3D View, View panel: single-column, flow and subpanel See D3525 --- release/scripts/startup/bl_ui/space_view3d.py | 77 ++++++++++++++++++--------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 2a358b3fc9f..2fd8c08743d 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3627,37 +3627,65 @@ class VIEW3D_PT_view3d_properties(Panel): view = context.space_data - col = layout.column() - col.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews) - col.prop(view, "lens") - col.label(text="Lock to Object:") - col.prop(view, "lock_object", text="") - lock_object = view.lock_object - if lock_object: - if lock_object.type == 'ARMATURE': - col.prop_search(view, "lock_bone", lock_object.data, - "edit_bones" if lock_object.mode == 'EDIT' - else "bones", - text="") - else: - col.prop(view, "lock_cursor", text="Lock to Cursor") + layout.use_property_split = True + layout.use_property_decorate = False # No animation. - col = layout.column() - col.prop(view, "lock_camera") + flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) + col = flow.column() - col = layout.column(align=True) - col.label(text="Clip:") - col.prop(view, "clip_start", text="Start") - col.prop(view, "clip_end", text="End") + subcol = col.column() + subcol.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews) + subcol.prop(view, "lens", text="Focal Length") subcol = col.column(align=True) + subcol.prop(view, "clip_start", text="Clip Start") + subcol.prop(view, "clip_end", text="End") + + subcol.separator() + + col = flow.column() + + subcol = col.column() subcol.enabled = not view.lock_camera_and_layers - subcol.label(text="Local Camera:") - subcol.prop(view, "camera", text="") + subcol.prop(view, "camera", text="Local Camera") + + subcol = col.column(align=True) + subcol.prop(view, "use_render_border") + subcol.active = view.region_3d.view_perspective != 'CAMERA' + + +class VIEW3D_PT_view3d_camera_lock(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'UI' + bl_label = "Camera Lock" + bl_parent_id = "VIEW3D_PT_view3d_properties" + + def draw(self, context): + layout = self.layout + + layout.use_property_split = True + layout.use_property_decorate = False # No animation. + + view = context.space_data col = layout.column(align=True) - col.prop(view, "use_render_border") - col.active = view.region_3d.view_perspective != 'CAMERA' + subcol = col.column() + subcol.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews) + + subcol.prop(view, "lock_object") + lock_object = view.lock_object + if lock_object: + if lock_object.type == 'ARMATURE': + subcol.prop_search( + view, "lock_bone", lock_object.data, + "edit_bones" if lock_object.mode == 'EDIT' + else "bones", + text="" + ) + else: + subcol.prop(view, "lock_cursor", text="Lock to 3D Cursor") + + col.prop(view, "lock_camera") class VIEW3D_PT_view3d_cursor(Panel): @@ -4496,6 +4524,7 @@ classes = ( VIEW3D_PT_grease_pencil, VIEW3D_PT_grease_pencil_palettecolor, VIEW3D_PT_view3d_properties, + VIEW3D_PT_view3d_camera_lock, VIEW3D_PT_view3d_cursor, VIEW3D_PT_quad_view, VIEW3D_PT_view3d_stereo, -- cgit v1.2.3 From d360eced65ba0919e0f2d6e24aaa766c07866846 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Fri, 6 Jul 2018 18:29:57 +0200 Subject: UI: Single-column for 3D Cursor panel in 3D View --- release/scripts/startup/bl_ui/space_view3d.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 2fd8c08743d..4dfc9a9129b 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3700,8 +3700,10 @@ class VIEW3D_PT_view3d_cursor(Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True view = context.space_data + layout.column().prop(view, "cursor_location", text="Location") -- cgit v1.2.3 From b94222b0903cee2c453e46b7bdb4c9862bbc771c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 19:31:00 +0200 Subject: PyDrivers: update bytecode check for Python3.6 --- source/blender/python/intern/bpy_driver.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index bc81eb8ee24..f6ff1b3f36b 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -253,7 +253,6 @@ static void pydriver_error(ChannelDriver *driver) #define OK_OP(op) [op] = 1 const char secure_opcodes[255] = { - OK_OP(0), OK_OP(POP_TOP), OK_OP(ROT_TWO), OK_OP(ROT_THREE), @@ -347,15 +346,14 @@ static bool bpy_driver_secure_bytecode_validate(PyObject *expr_code, PyObject *d /* Check opcodes. */ { - const char *codestr; + const _Py_CODEUNIT *codestr; Py_ssize_t code_len; PyBytes_AsStringAndSize(py_code->co_code, (char **)&codestr, &code_len); + code_len /= sizeof(*codestr); -#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1) - - for (Py_ssize_t i = 0; i < code_len; i += CODESIZE(codestr[i])) { - const int opcode = codestr[i]; + for (Py_ssize_t i = 0; i < code_len; i++) { + const int opcode = _Py_OPCODE(codestr[i]); if (secure_opcodes[opcode] == 0) { fprintf(stderr, "\tBPY_driver_eval() - restructed access disallows opcode '%d', " "enable auto-execution to support\n", opcode); -- cgit v1.2.3 From 2a199f5093cf6dc537047f9456adffa52b6aa005 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 5 Jul 2018 23:30:53 +0200 Subject: UI: Use flat triangle drawing for indicating submenus Left the RIGHTARROW_THIN icon in, even though it's not used in C code anymore. However add-ons may do (e.g. Amaranth does). --- .../blender/editors/interface/interface_intern.h | 3 +- source/blender/editors/interface/interface_panel.c | 35 +++++------- .../blender/editors/interface/interface_widgets.c | 62 ++++++++++++++++------ 3 files changed, 60 insertions(+), 40 deletions(-) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 04e9e2b18b4..10b4ff58224 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -744,8 +744,7 @@ struct Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased); struct Gwn_Batch *ui_batch_roundbox_widget_get(int tria); struct Gwn_Batch *ui_batch_roundbox_shadow_get(void); -void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, - float rad, bool use_alpha, const float color[4]); +void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4]); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_popover_back(ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_pie_center(uiBlock *block); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index a99a6610e88..b930b39ba02 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -469,23 +469,6 @@ void UI_draw_icon_tri(float x, float y, char dir, const float color[4]) } } -/* triangle 'icon' inside rect */ -static void ui_draw_tria_rect(const rctf *rect, char dir) -{ - float color[4]; - UI_GetThemeColor3fv(TH_TITLE, color); - color[3] = 1.0f; - - if (dir == 'h') { - float half = 0.5f * BLI_rctf_size_y(rect); - UI_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half, color); - } - else { - float half = 0.5f * BLI_rctf_size_x(rect); - UI_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin, color); - } -} - static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float y2) { @@ -853,12 +836,18 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con BLI_rctf_scale(&itemrect, 0.25f); - if (is_closed_y) - ui_draw_tria_rect(&itemrect, 'h'); - else if (is_closed_x) - ui_draw_tria_rect(&itemrect, 'h'); - else - ui_draw_tria_rect(&itemrect, 'v'); + { + float tria_color[4]; + UI_GetThemeColor3fv(TH_TITLE, tria_color); + tria_color[3] = 1.0f; + + if (is_closed_y) + ui_draw_anti_tria_rect(&itemrect, 'h', tria_color); + else if (is_closed_x) + ui_draw_anti_tria_rect(&itemrect, 'h', tria_color); + else + ui_draw_anti_tria_rect(&itemrect, 'v', tria_color); + } } /************************** panel alignment *************************/ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c390c3fdda8..c70b9b72a07 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -532,6 +532,20 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y GPU_blend(false); } +/* triangle 'icon' inside rect */ +void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4]) +{ + if (dir == 'h') { + float half = 0.5f * BLI_rctf_size_y(rect); + UI_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half, color); + } + else { + float half = 0.5f * BLI_rctf_size_x(rect); + UI_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin, color); + } +} + + void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float color[4]) { float draw_color[4]; @@ -1255,8 +1269,8 @@ static int ui_but_draw_menu_icon(const uiBut *but) /* icons have been standardized... and this call draws in untransformed coordinates */ static void widget_draw_icon_ex( - const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const bool show_menu_icon, - const int icon_size) + const uiBut *but, BIFIconID icon, float alpha, + const rcti *rect, const int icon_size) { float xs = 0.0f, ys = 0.0f; float aspect, height; @@ -1331,20 +1345,35 @@ static void widget_draw_icon_ex( } } - if (show_menu_icon) { - xs = rect->xmax - UI_DPI_ICON_SIZE - aspect; - ys = (rect->ymin + rect->ymax - height) / 2.0f; - - UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha); - } - GPU_blend(false); } static void widget_draw_icon( - const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const bool show_menu_icon) + const uiBut *but, BIFIconID icon, float alpha, const rcti *rect) { - widget_draw_icon_ex(but, icon, alpha, rect, show_menu_icon, ICON_DEFAULT_HEIGHT); + widget_draw_icon_ex(but, icon, alpha, rect, ICON_DEFAULT_HEIGHT); +} + +static void widget_draw_submenu_tria(const uiBut *but, const rcti *rect, const uiWidgetColors *wcol) +{ + const float aspect = but->block->aspect / UI_DPI_FAC; + const int tria_height = (int)(ICON_DEFAULT_HEIGHT / aspect); + const int tria_width = (int)(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize; + const int xs = rect->xmax - UI_DPI_ICON_SIZE - aspect; + const int ys = (rect->ymin + rect->ymax - tria_height) / 2.0f; + float col[4]; + rctf tria_rect; + + rgba_uchar_to_float(col, (const uchar *)wcol->text); + col[3] *= 0.8f; + + BLI_rctf_init(&tria_rect, xs, xs + tria_width, ys, ys + tria_height); + BLI_rctf_scale(&tria_rect, 0.4f); + + GPU_blend(true); + UI_widgetbase_draw_cache_flush(); + GPU_blend(false); + ui_draw_anti_tria_rect(&tria_rect, 'h', col); } static void ui_text_clip_give_prev_off(uiBut *but, const char *str) @@ -1987,7 +2016,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && (but->flag & UI_BUT_NODE_LINK)) { rcti temp = *rect; temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1; - widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, false); + widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp); rect->xmax = temp.xmin; } @@ -2057,7 +2086,10 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB else if (ui_block_is_menu(but->block)) rect->xmin += 0.3f * U.widget_unit; - widget_draw_icon(but, icon, alpha, rect, show_menu_icon); + widget_draw_icon(but, icon, alpha, rect); + if (show_menu_icon) { + widget_draw_submenu_tria(but, rect, wcol); + } #ifdef USE_UI_TOOLBAR_HACK but->block->aspect = aspect_orig; @@ -2084,10 +2116,10 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f); if (extra_icon_type == UI_BUT_ICONEXTRA_CLEAR) { - widget_draw_icon(but, ICON_PANEL_CLOSE, alpha, &temp, false); + widget_draw_icon(but, ICON_PANEL_CLOSE, alpha, &temp); } else if (extra_icon_type == UI_BUT_ICONEXTRA_EYEDROPPER) { - widget_draw_icon(but, ICON_EYEDROPPER, alpha, &temp, false); + widget_draw_icon(but, ICON_EYEDROPPER, alpha, &temp); } else { BLI_assert(0); -- cgit v1.2.3 From 29b8adec61b2c88a07d29b78b26aeca26658a166 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 6 Jul 2018 19:26:12 +0200 Subject: UI: Add extra padding to menus to draw sub-menu triangles in Shortcut strings would be offset to the left to make space for the triangles, breaking the alignment with other shortcut strings. Now this alignment is kept by making menus slightly wider if there's a sub-menu triangle visible, making room for the triangle. --- source/blender/editors/interface/interface.c | 12 +++++++++--- source/blender/editors/interface/interface_intern.h | 16 ++++++++++++++-- .../blender/editors/interface/interface_region_popup.c | 3 +++ source/blender/editors/interface/interface_widgets.c | 13 ++++++++----- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 427f5621177..20361bde16f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3454,6 +3454,12 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu block->flag |= UI_BLOCK_IS_FLIP; } +static void ui_but_submenu_enable(uiBlock *block, uiBut *but) +{ + but->flag |= UI_BUT_ICON_SUBMENU; + block->content_hints |= BLOCK_CONTAINS_SUBMENU_BUT; +} + /** * ui_def_but_rna_propname and ui_def_but_rna * both take the same args except for propname vs prop, this is done so we can @@ -3589,7 +3595,7 @@ static uiBut *ui_def_but_rna( } if ((type == UI_BTYPE_MENU) && (but->dt == UI_EMBOSS_PULLDOWN)) { - but->flag |= UI_BUT_ICON_SUBMENU; + ui_but_submenu_enable(block, but); } const char *info; @@ -4328,7 +4334,7 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in ui_def_but_icon(but, icon, UI_HAS_ICON); but->drawflag |= UI_BUT_ICON_LEFT; - but->flag |= UI_BUT_ICON_SUBMENU; + ui_but_submenu_enable(block, but); but->menu_create_func = func; ui_but_update(but); @@ -4360,7 +4366,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, but->drawflag |= UI_BUT_ICON_LEFT; } but->flag |= UI_HAS_ICON; - but->flag |= UI_BUT_ICON_SUBMENU; + ui_but_submenu_enable(block, but); but->block_create_func = func; ui_but_update(but); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 10b4ff58224..0b76e311cc7 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -105,7 +105,8 @@ typedef enum { UI_WTYPE_PROGRESSBAR, } uiWidgetTypeEnum; -#define UI_MENU_WIDTH_MIN (UI_UNIT_Y * 9) +#define UI_MENU_WIDTH_MIN (UI_UNIT_Y * 9) +#define UI_MENU_SUBMENU_PADDING (6 * UI_DPI_FAC) /* some extra padding added to menus containing submenu icons */ /* menu scrolling */ #define UI_MENU_SCROLL_ARROW 12 @@ -349,6 +350,13 @@ struct PieMenuData { float alphafac; }; +/* uiBlock.content_hints */ +enum eBlockContentHints { + /* In a menu block, if there is a single sub-menu button, we add some + * padding to the right to put nicely aligned triangle icons there. */ + BLOCK_CONTAINS_SUBMENU_BUT = (1 << 0), +}; + struct uiBlock { uiBlock *next, *prev; @@ -395,11 +403,15 @@ struct uiBlock { int flag; short alignnr; + /* Hints about the buttons of this block. Used to avoid iterating over + * buttons to find out if some criteria is met by any. Instead, check this + * criteria when adding the button and set a flag here if it's met. */ + short content_hints; /* eBlockContentHints */ char direction; char dt; /* drawtype: UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied to buttons */ bool auto_open; - char _pad[7]; + char _pad[5]; double auto_open_last; const char *lockstr; diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 320ee1f4616..1bbf2242c5d 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -116,6 +116,9 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut BLI_rctf_init_minmax(&block->rect); for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + if (block->content_hints & BLOCK_CONTAINS_SUBMENU_BUT) { + bt->rect.xmax += UI_MENU_SUBMENU_PADDING; + } BLI_rctf_union(&block->rect, &bt->rect); } } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c70b9b72a07..4e15737c3e5 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1359,7 +1359,7 @@ static void widget_draw_submenu_tria(const uiBut *but, const rcti *rect, const u const float aspect = but->block->aspect / UI_DPI_FAC; const int tria_height = (int)(ICON_DEFAULT_HEIGHT / aspect); const int tria_width = (int)(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize; - const int xs = rect->xmax - UI_DPI_ICON_SIZE - aspect; + const int xs = rect->xmax - tria_width; const int ys = (rect->ymin + rect->ymax - tria_height) / 2.0f; float col[4]; rctf tria_rect; @@ -2088,6 +2088,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB widget_draw_icon(but, icon, alpha, rect); if (show_menu_icon) { + BLI_assert(but->block->content_hints & BLOCK_CONTAINS_SUBMENU_BUT); widget_draw_submenu_tria(but, rect, wcol); } @@ -2096,10 +2097,6 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB #endif rect->xmin += icon_size; - /* without this menu keybindings will overlap the arrow icon [#38083] */ - if (show_menu_icon) { - rect->xmax -= icon_size / 2.0f; - } } if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) { @@ -2109,6 +2106,12 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } + /* Menu contains sub-menu items with triangle icon on their right. Shortcut + * strings should be drawn with some padding to the right then. */ + if (ui_block_is_menu(but->block) && (but->block->content_hints & BLOCK_CONTAINS_SUBMENU_BUT)) { + rect->xmax -= UI_MENU_SUBMENU_PADDING; + } + /* extra icons, e.g. 'x' icon to clear text or icon for eyedropper */ if (extra_icon_type != UI_BUT_ICONEXTRA_NONE) { rcti temp = *rect; -- cgit v1.2.3 From 74fd17e9d788394fa5bf781bb3e60bca7617b22c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 27 Jun 2018 14:41:53 +0200 Subject: UI/Python: rename Lamps to Lights, to follow more standard terminology. Internally it's still mostly named lamps, though some modules like Cycles were already calling them lights. --- intern/cycles/blender/addon/properties.py | 24 +- intern/cycles/blender/addon/ui.py | 96 +++--- intern/cycles/blender/addon/version_update.py | 20 +- intern/cycles/blender/blender_camera.cpp | 2 +- intern/cycles/blender/blender_object.cpp | 66 ++-- intern/cycles/blender/blender_shader.cpp | 26 +- intern/cycles/blender/blender_sync.cpp | 8 +- intern/cycles/blender/blender_sync.h | 2 +- .../modules/bl_i18n_utils/bl_extract_messages.py | 2 +- .../bl_previews_utils/bl_previews_render.py | 66 ++-- release/scripts/modules/bpy_types.py | 2 +- .../scripts/presets/interface_theme/24x_blues.xml | 2 +- .../presets/interface_theme/back_to_black.xml | 2 +- .../presets/interface_theme/blender_24x.xml | 2 +- .../presets/interface_theme/blender_27x.xml | 2 +- .../presets/interface_theme/dark_blue_gradient.xml | 2 +- .../scripts/presets/interface_theme/default++.xml | 2 +- .../scripts/presets/interface_theme/elsyiun.xml | 2 +- .../presets/interface_theme/flatty_light.xml | 2 +- release/scripts/presets/interface_theme/graph.xml | 2 +- .../scripts/presets/interface_theme/hexagon.xml | 2 +- .../presets/interface_theme/modern_minimalist.xml | 2 +- release/scripts/presets/interface_theme/north.xml | 2 +- release/scripts/presets/interface_theme/rtheme.xml | 2 +- .../scripts/presets/interface_theme/sandyslate.xml | 2 +- .../presets/interface_theme/science_lab.xml | 2 +- .../scripts/presets/interface_theme/softblend.xml | 2 +- .../presets/interface_theme/true_blue_menu.xml | 2 +- release/scripts/presets/sunsky/classic.py | 14 - release/scripts/presets/sunsky/desert.py | 14 - release/scripts/presets/sunsky/mountain.py | 14 - release/scripts/startup/bl_operators/anim.py | 10 +- release/scripts/startup/bl_operators/clip.py | 32 +- release/scripts/startup/bl_ui/__init__.py | 2 +- .../scripts/startup/bl_ui/properties_data_lamp.py | 363 --------------------- .../scripts/startup/bl_ui/properties_data_light.py | 363 +++++++++++++++++++++ release/scripts/startup/bl_ui/space_dopesheet.py | 4 +- release/scripts/startup/bl_ui/space_node.py | 7 +- release/scripts/startup/bl_ui/space_outliner.py | 4 +- release/scripts/startup/bl_ui/space_userpref.py | 28 +- release/scripts/startup/bl_ui/space_view3d.py | 36 +- release/scripts/startup/nodeitems_builtins.py | 2 +- release/scripts/templates_py/background_job.py | 10 +- .../templates_py/manipulator_custom_geometry.py | 12 +- release/scripts/templates_py/manipulator_simple.py | 14 +- source/blender/blenkernel/BKE_node.h | 2 +- source/blender/blenkernel/intern/idcode.c | 2 +- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/object.c | 2 +- source/blender/collada/DocumentImporter.cpp | 6 +- .../intern/builder/deg_builder_relations.cc | 4 +- source/blender/draw/engines/eevee/eevee_lights.c | 2 +- .../editors/animation/anim_channels_defines.c | 26 +- source/blender/editors/include/UI_icons.h | 18 +- source/blender/editors/interface/interface_icons.c | 2 +- .../editors/interface/interface_templates.c | 6 +- source/blender/editors/object/object_add.c | 36 +- source/blender/editors/object/object_intern.h | 2 +- source/blender/editors/object/object_ops.c | 2 +- source/blender/editors/object/object_select.c | 8 +- source/blender/editors/object/object_transform.c | 6 +- source/blender/editors/render/render_internal.c | 2 +- source/blender/editors/render/render_shading.c | 2 +- .../editors/space_buttons/buttons_context.c | 8 +- source/blender/editors/space_file/filelist.c | 2 +- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/editors/space_node/node_edit.c | 4 +- .../blender/editors/space_outliner/outliner_draw.c | 16 +- source/blender/editors/space_view3d/space_view3d.c | 6 +- .../space_view3d/view3d_manipulator_empty.c | 2 +- .../editors/space_view3d/view3d_manipulator_lamp.c | 8 +- source/blender/makesrna/RNA_access.h | 18 +- source/blender/makesrna/RNA_enum_types.h | 2 +- source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/makesrna/intern/rna_ID.c | 6 +- source/blender/makesrna/intern/rna_access.c | 2 +- source/blender/makesrna/intern/rna_action.c | 6 +- source/blender/makesrna/intern/rna_internal.h | 6 +- source/blender/makesrna/intern/rna_lamp.c | 215 ++++++------ source/blender/makesrna/intern/rna_main.c | 4 +- source/blender/makesrna/intern/rna_main_api.c | 37 ++- source/blender/makesrna/intern/rna_modifier.c | 4 +- source/blender/makesrna/intern/rna_object.c | 6 +- source/blender/makesrna/intern/rna_object_api.c | 2 +- source/blender/makesrna/intern/rna_scene.c | 6 +- source/blender/makesrna/intern/rna_space.c | 12 +- source/blender/makesrna/intern/rna_texture.c | 2 +- source/blender/makesrna/intern/rna_ui_api.c | 4 +- source/blender/makesrna/intern/rna_userdef.c | 11 +- source/blender/nodes/NOD_static_types.h | 4 +- source/blender/nodes/shader/node_shader_tree.c | 2 +- .../nodes/shader/nodes/node_shader_output_lamp.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 2 +- tests/python/bl_mesh_modifiers.py | 2 +- tests/python/bl_pyapi_idprop_datablock.py | 22 +- tests/python/bl_rna_defaults.py | 4 +- 96 files changed, 899 insertions(+), 939 deletions(-) delete mode 100644 release/scripts/presets/sunsky/classic.py delete mode 100644 release/scripts/presets/sunsky/desert.py delete mode 100644 release/scripts/presets/sunsky/mountain.py delete mode 100644 release/scripts/startup/bl_ui/properties_data_lamp.py create mode 100644 release/scripts/startup/bl_ui/properties_data_light.py diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index df6949f2095..85947b4bd28 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -887,17 +887,17 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup): del bpy.types.Material.cycles -class CyclesLampSettings(bpy.types.PropertyGroup): +class CyclesLightSettings(bpy.types.PropertyGroup): @classmethod def register(cls): - bpy.types.Lamp.cycles = PointerProperty( - name="Cycles Lamp Settings", - description="Cycles lamp settings", + bpy.types.Light.cycles = PointerProperty( + name="Cycles Light Settings", + description="Cycles light settings", type=cls, ) cls.cast_shadow = BoolProperty( name="Cast Shadow", - description="Lamp casts shadows", + description="Light casts shadows", default=True, ) cls.samples = IntProperty( @@ -914,20 +914,20 @@ class CyclesLampSettings(bpy.types.PropertyGroup): ) cls.use_multiple_importance_sampling = BoolProperty( name="Multiple Importance Sample", - description="Use multiple importance sampling for the lamp, " - "reduces noise for area lamps and sharp glossy materials", + description="Use multiple importance sampling for the light, " + "reduces noise for area lights and sharp glossy materials", default=True, ) cls.is_portal = BoolProperty( name="Is Portal", - description="Use this area lamp to guide sampling of the background, " - "note that this will make the lamp invisible", + description="Use this area light to guide sampling of the background, " + "note that this will make the light invisible", default=False, ) @classmethod def unregister(cls): - del bpy.types.Lamp.cycles + del bpy.types.Light.cycles class CyclesWorldSettings(bpy.types.PropertyGroup): @@ -1460,7 +1460,7 @@ def register(): bpy.utils.register_class(CyclesRenderSettings) bpy.utils.register_class(CyclesCameraSettings) bpy.utils.register_class(CyclesMaterialSettings) - bpy.utils.register_class(CyclesLampSettings) + bpy.utils.register_class(CyclesLightSettings) bpy.utils.register_class(CyclesWorldSettings) bpy.utils.register_class(CyclesVisibilitySettings) bpy.utils.register_class(CyclesMeshSettings) @@ -1475,7 +1475,7 @@ def unregister(): bpy.utils.unregister_class(CyclesRenderSettings) bpy.utils.unregister_class(CyclesCameraSettings) bpy.utils.unregister_class(CyclesMaterialSettings) - bpy.utils.unregister_class(CyclesLampSettings) + bpy.utils.unregister_class(CyclesLightSettings) bpy.utils.unregister_class(CyclesWorldSettings) bpy.utils.unregister_class(CyclesMeshSettings) bpy.utils.unregister_class(CyclesObjectSettings) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 7a4ed4fbdaf..6688874de49 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1008,7 +1008,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel): def poll(cls, context): ob = context.object return (CyclesButtonsPanel.poll(context) and - ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'}) or + ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT'}) or (ob.dupli_type == 'COLLECTION' and ob.dupli_group))) def draw(self, context): @@ -1029,7 +1029,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel): flow.prop(visibility, "transmission") flow.prop(visibility, "scatter") - if ob.type != 'LAMP': + if ob.type != 'LIGHT': flow.prop(visibility, "shadow") row = layout.row() @@ -1049,7 +1049,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel): class CYCLES_OT_use_shading_nodes(Operator): - """Enable nodes on a material, world or lamp""" + """Enable nodes on a material, world or light""" bl_idname = "cycles.use_shading_nodes" bl_label = "Use Nodes" @@ -1063,8 +1063,8 @@ class CYCLES_OT_use_shading_nodes(Operator): context.material.use_nodes = True elif context.world: context.world.use_nodes = True - elif context.lamp: - context.lamp.use_nodes = True + elif context.light: + context.light.use_nodes = True return {'FINISHED'} @@ -1089,7 +1089,7 @@ def panel_node_draw(layout, id_data, output_type, input_name): return True -class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel): +class CYCLES_LIGHT_PT_preview(CyclesButtonsPanel, Panel): bl_label = "Preview" bl_context = "data" bl_options = {'DEFAULT_CLOSED'} @@ -1097,52 +1097,52 @@ class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): return ( - context.lamp and + context.light and not ( - context.lamp.type == 'AREA' and - context.lamp.cycles.is_portal + context.light.type == 'AREA' and + context.light.cycles.is_portal ) and CyclesButtonsPanel.poll(context) ) def draw(self, context): - self.layout.template_preview(context.lamp) + self.layout.template_preview(context.light) -class CYCLES_LAMP_PT_lamp(CyclesButtonsPanel, Panel): - bl_label = "Lamp" +class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel): + bl_label = "Light" bl_context = "data" @classmethod def poll(cls, context): - return context.lamp and CyclesButtonsPanel.poll(context) + return context.light and CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout - lamp = context.lamp - clamp = lamp.cycles + light = context.light + clamp = light.cycles # cscene = context.scene.cycles - layout.prop(lamp, "type", expand=True) + layout.prop(light, "type", expand=True) layout.use_property_split = True col = layout.column() - if lamp.type in {'POINT', 'SUN', 'SPOT'}: - col.prop(lamp, "shadow_soft_size", text="Size") - elif lamp.type == 'AREA': - col.prop(lamp, "shape", text="Shape") + if light.type in {'POINT', 'SUN', 'SPOT'}: + col.prop(light, "shadow_soft_size", text="Size") + elif light.type == 'AREA': + col.prop(light, "shape", text="Shape") sub = col.column(align=True) - if lamp.shape in {'SQUARE', 'DISK'}: - sub.prop(lamp, "size") - elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}: - sub.prop(lamp, "size", text="Size X") - sub.prop(lamp, "size_y", text="Y") + if light.shape in {'SQUARE', 'DISK'}: + sub.prop(light, "size") + elif light.shape in {'RECTANGLE', 'ELLIPSE'}: + sub.prop(light, "size", text="Size X") + sub.prop(light, "size_y", text="Y") - if not (lamp.type == 'AREA' and clamp.is_portal): + if not (light.type == 'AREA' and clamp.is_portal): sub = col.column() if use_branched_path(context): subsub = sub.row(align=True) @@ -1151,53 +1151,53 @@ class CYCLES_LAMP_PT_lamp(CyclesButtonsPanel, Panel): sub.prop(clamp, "max_bounces") sub = col.column(align=True) - sub.active = not (lamp.type == 'AREA' and clamp.is_portal) + sub.active = not (light.type == 'AREA' and clamp.is_portal) sub.prop(clamp, "cast_shadow") sub.prop(clamp, "use_multiple_importance_sampling", text="Multiple Importance") - if lamp.type == 'AREA': + if light.type == 'AREA': col.prop(clamp, "is_portal", text="Portal") - if lamp.type == 'HEMI': - layout.label(text="Not supported, interpreted as sun lamp") + if light.type == 'HEMI': + layout.label(text="Not supported, interpreted as sun light") -class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel): +class CYCLES_LIGHT_PT_nodes(CyclesButtonsPanel, Panel): bl_label = "Nodes" bl_context = "data" @classmethod def poll(cls, context): - return context.lamp and not (context.lamp.type == 'AREA' and - context.lamp.cycles.is_portal) and \ + return context.light and not (context.light.type == 'AREA' and + context.light.cycles.is_portal) and \ CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout - lamp = context.lamp - if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'): - layout.prop(lamp, "color") + light = context.light + if not panel_node_draw(layout, light, 'OUTPUT_LIGHT', 'Surface'): + layout.prop(light, "color") -class CYCLES_LAMP_PT_spot(CyclesButtonsPanel, Panel): +class CYCLES_LIGHT_PT_spot(CyclesButtonsPanel, Panel): bl_label = "Spot Shape" bl_context = "data" @classmethod def poll(cls, context): - lamp = context.lamp - return (lamp and lamp.type == 'SPOT') and CyclesButtonsPanel.poll(context) + light = context.light + return (light and light.type == 'SPOT') and CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout - lamp = context.lamp + light = context.light layout.use_property_split = True col = layout.column() - col.prop(lamp, "spot_size", text="Size") - col.prop(lamp, "spot_blend", text="Blend", slider=True) - col.prop(lamp, "show_cone") + col.prop(light, "spot_size", text="Size") + col.prop(light, "spot_blend", text="Blend", slider=True) + col.prop(light, "show_cone") class CYCLES_WORLD_PT_preview(CyclesButtonsPanel, Panel): @@ -1789,7 +1789,7 @@ def get_panels(): 'DATA_PT_area', 'DATA_PT_camera_dof', 'DATA_PT_falloff_curve', - 'DATA_PT_lamp', + 'DATA_PT_light', 'DATA_PT_preview', 'DATA_PT_spot', 'MATERIAL_PT_context_material', @@ -1843,10 +1843,10 @@ classes = ( CYCLES_OBJECT_PT_motion_blur, CYCLES_OBJECT_PT_cycles_settings, CYCLES_OT_use_shading_nodes, - CYCLES_LAMP_PT_preview, - CYCLES_LAMP_PT_lamp, - CYCLES_LAMP_PT_nodes, - CYCLES_LAMP_PT_spot, + CYCLES_LIGHT_PT_preview, + CYCLES_LIGHT_PT_light, + CYCLES_LIGHT_PT_nodes, + CYCLES_LIGHT_PT_spot, CYCLES_WORLD_PT_preview, CYCLES_WORLD_PT_surface, CYCLES_WORLD_PT_volume, diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py index 3334ccd65fd..b6ace0e6b57 100644 --- a/intern/cycles/blender/addon/version_update.py +++ b/intern/cycles/blender/addon/version_update.py @@ -55,10 +55,10 @@ def check_is_new_shading_world(world): return check_is_new_shading_ntree(world.node_tree) -def check_is_new_shading_lamp(lamp): - if not lamp.node_tree: +def check_is_new_shading_light(light): + if not light.node_tree: return False - return check_is_new_shading_ntree(lamp.node_tree) + return check_is_new_shading_ntree(light.node_tree) def foreach_notree_node(nodetree, callback, traversed): @@ -83,9 +83,9 @@ def foreach_cycles_node(callback): foreach_notree_node(world.node_tree, callback, traversed) - for lamp in bpy.data.lamps: - if check_is_new_shading_world(lamp): - foreach_notree_node(lamp.node_tree, + for light in bpy.data.lights: + if check_is_new_shading_world(light): + foreach_notree_node(light.node_tree, callback, traversed) @@ -393,12 +393,12 @@ def do_versions(self): if not cscene.is_property_set("tile_order"): cscene.tile_order = 'CENTER' - for lamp in bpy.data.lamps: - clamp = lamp.cycles + for light in bpy.data.lights: + clight = light.cycles # MIS - if not clamp.is_property_set("use_multiple_importance_sampling"): - clamp.use_multiple_importance_sampling = False + if not clight.is_property_set("use_multiple_importance_sampling"): + clight.use_multiple_importance_sampling = False for mat in bpy.data.materials: cmat = mat.cycles diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index 228f0645f94..fc86094949f 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -232,7 +232,7 @@ static void blender_camera_from_object(BlenderCamera *bcam, bcam->motion_steps = object_motion_steps(b_ob, b_ob); } else { - /* from lamp not implemented yet */ + /* from light not implemented yet */ } } diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 70d6092622a..ed01d728931 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -89,7 +89,7 @@ bool BlenderSync::object_is_light(BL::Object& b_ob) { BL::ID b_ob_data = b_ob.data(); - return (b_ob_data && b_ob_data.is_a(&RNA_Lamp)); + return (b_ob_data && b_ob_data.is_a(&RNA_Light)); } static uint object_ray_visibility(BL::Object& b_ob) @@ -127,56 +127,56 @@ void BlenderSync::sync_light(BL::Object& b_parent, return; } - BL::Lamp b_lamp(b_ob.data()); + BL::Light b_light(b_ob.data()); /* type */ - switch(b_lamp.type()) { - case BL::Lamp::type_POINT: { - BL::PointLamp b_point_lamp(b_lamp); - light->size = b_point_lamp.shadow_soft_size(); + switch(b_light.type()) { + case BL::Light::type_POINT: { + BL::PointLight b_point_light(b_light); + light->size = b_point_light.shadow_soft_size(); light->type = LIGHT_POINT; break; } - case BL::Lamp::type_SPOT: { - BL::SpotLamp b_spot_lamp(b_lamp); - light->size = b_spot_lamp.shadow_soft_size(); + case BL::Light::type_SPOT: { + BL::SpotLight b_spot_light(b_light); + light->size = b_spot_light.shadow_soft_size(); light->type = LIGHT_SPOT; - light->spot_angle = b_spot_lamp.spot_size(); - light->spot_smooth = b_spot_lamp.spot_blend(); + light->spot_angle = b_spot_light.spot_size(); + light->spot_smooth = b_spot_light.spot_blend(); break; } - case BL::Lamp::type_HEMI: { + case BL::Light::type_HEMI: { light->type = LIGHT_DISTANT; light->size = 0.0f; break; } - case BL::Lamp::type_SUN: { - BL::SunLamp b_sun_lamp(b_lamp); - light->size = b_sun_lamp.shadow_soft_size(); + case BL::Light::type_SUN: { + BL::SunLight b_sun_light(b_light); + light->size = b_sun_light.shadow_soft_size(); light->type = LIGHT_DISTANT; break; } - case BL::Lamp::type_AREA: { - BL::AreaLamp b_area_lamp(b_lamp); + case BL::Light::type_AREA: { + BL::AreaLight b_area_light(b_light); light->size = 1.0f; light->axisu = transform_get_column(&tfm, 0); light->axisv = transform_get_column(&tfm, 1); - light->sizeu = b_area_lamp.size(); - switch(b_area_lamp.shape()) { - case BL::AreaLamp::shape_SQUARE: + light->sizeu = b_area_light.size(); + switch(b_area_light.shape()) { + case BL::AreaLight::shape_SQUARE: light->sizev = light->sizeu; light->round = false; break; - case BL::AreaLamp::shape_RECTANGLE: - light->sizev = b_area_lamp.size_y(); + case BL::AreaLight::shape_RECTANGLE: + light->sizev = b_area_light.size_y(); light->round = false; break; - case BL::AreaLamp::shape_DISK: + case BL::AreaLight::shape_DISK: light->sizev = light->sizeu; light->round = true; break; - case BL::AreaLamp::shape_ELLIPSE: - light->sizev = b_area_lamp.size_y(); + case BL::AreaLight::shape_ELLIPSE: + light->sizev = b_area_light.size_y(); light->round = true; break; } @@ -192,22 +192,22 @@ void BlenderSync::sync_light(BL::Object& b_parent, /* shader */ vector used_shaders; - find_shader(b_lamp, used_shaders, scene->default_light); + find_shader(b_light, used_shaders, scene->default_light); light->shader = used_shaders[0]; /* shadow */ PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); - PointerRNA clamp = RNA_pointer_get(&b_lamp.ptr, "cycles"); - light->cast_shadow = get_boolean(clamp, "cast_shadow"); - light->use_mis = get_boolean(clamp, "use_multiple_importance_sampling"); + PointerRNA clight = RNA_pointer_get(&b_light.ptr, "cycles"); + light->cast_shadow = get_boolean(clight, "cast_shadow"); + light->use_mis = get_boolean(clight, "use_multiple_importance_sampling"); - int samples = get_int(clamp, "samples"); + int samples = get_int(clight, "samples"); if(get_boolean(cscene, "use_square_samples")) light->samples = samples * samples; else light->samples = samples; - light->max_bounces = get_int(clamp, "max_bounces"); + light->max_bounces = get_int(clight, "max_bounces"); if(b_ob != b_ob_instance) { light->random_id = random_id; @@ -217,7 +217,7 @@ void BlenderSync::sync_light(BL::Object& b_parent, } if(light->type == LIGHT_AREA) - light->is_portal = get_boolean(clamp, "is_portal"); + light->is_portal = get_boolean(clight, "is_portal"); else light->is_portal = false; @@ -315,7 +315,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph, /* light is handled separately */ if(object_is_light(b_ob)) { - /* don't use lamps for excluded layers used as mask layer */ + /* don't use lights for excluded layers used as mask layer */ if(!motion && !((layer_flag & view_layer.holdout_layer) && (layer_flag & view_layer.exclude_layer))) { diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index e2463200001..e254ee6f68d 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -1393,45 +1393,45 @@ void BlenderSync::sync_world(BL::Depsgraph& b_depsgraph, bool update_all) background->tag_update(scene); } -/* Sync Lamps */ +/* Sync Lights */ -void BlenderSync::sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all) +void BlenderSync::sync_lights(BL::Depsgraph& b_depsgraph, bool update_all) { shader_map.set_default(scene->default_light); BL::Depsgraph::ids_iterator b_id; for(b_depsgraph.ids.begin(b_id); b_id != b_depsgraph.ids.end(); ++b_id) { - if (!b_id->is_a(&RNA_Lamp)) { + if (!b_id->is_a(&RNA_Light)) { continue; } - BL::Lamp b_lamp(*b_id); + BL::Light b_light(*b_id); Shader *shader; /* test if we need to sync */ - if(shader_map.sync(&shader, b_lamp) || update_all) { + if(shader_map.sync(&shader, b_light) || update_all) { ShaderGraph *graph = new ShaderGraph(); /* create nodes */ - if(b_lamp.use_nodes() && b_lamp.node_tree()) { - shader->name = b_lamp.name().c_str(); + if(b_light.use_nodes() && b_light.node_tree()) { + shader->name = b_light.name().c_str(); - BL::ShaderNodeTree b_ntree(b_lamp.node_tree()); + BL::ShaderNodeTree b_ntree(b_light.node_tree()); add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, graph, b_ntree); } else { float strength = 1.0f; - if(b_lamp.type() == BL::Lamp::type_POINT || - b_lamp.type() == BL::Lamp::type_SPOT || - b_lamp.type() == BL::Lamp::type_AREA) + if(b_light.type() == BL::Light::type_POINT || + b_light.type() == BL::Light::type_SPOT || + b_light.type() == BL::Light::type_AREA) { strength = 100.0f; } EmissionNode *emission = new EmissionNode(); - emission->color = get_float3(b_lamp.color()); + emission->color = get_float3(b_light.color()); emission->strength = strength; graph->add(emission); @@ -1459,7 +1459,7 @@ void BlenderSync::sync_shaders(BL::Depsgraph& b_depsgraph) shader_map.pre_sync(); sync_world(b_depsgraph, auto_refresh_update); - sync_lamps(b_depsgraph, auto_refresh_update); + sync_lights(b_depsgraph, auto_refresh_update); sync_materials(b_depsgraph, auto_refresh_update); /* false = don't delete unused shaders, not supported */ diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index f9e04bdef7c..cbca623ece7 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -113,10 +113,10 @@ void BlenderSync::sync_recalc(BL::Depsgraph& b_depsgraph) BL::Material b_mat(b_id); shader_map.set_recalc(b_mat); } - /* Lamp */ - else if (b_id.is_a(&RNA_Lamp)) { - BL::Lamp b_lamp(b_id); - shader_map.set_recalc(b_lamp); + /* Light */ + else if (b_id.is_a(&RNA_Light)) { + BL::Light b_light(b_id); + shader_map.set_recalc(b_light); } /* Object */ else if (b_id.is_a(&RNA_Object)) { diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 1dce7ec99ef..cd1a37d3f13 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -100,7 +100,7 @@ public: private: /* sync */ - void sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all); + void sync_lights(BL::Depsgraph& b_depsgraph, bool update_all); void sync_materials(BL::Depsgraph& b_depsgraph, bool update_all); void sync_objects(BL::Depsgraph& b_depsgraph, float motion_time = 0.0f); void sync_motion(BL::RenderSettings& b_render, diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py index bbeb1780355..1d3a0a23267 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -385,7 +385,7 @@ def dump_rna_messages(msgs, reports, settings, verbose=False): return def full_class_id(cls): - """Gives us 'ID.Lamp.AreaLamp' which is best for sorting.""" + """Gives us 'ID.Light.AreaLight' which is best for sorting.""" # Always the same issue, some classes listed in blacklist should actually no more exist (they have been # unregistered), but are still listed by __subclasses__() calls... :/ if cls in blacklist_rna_class: diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py index 2efd6349d73..f2c766b2b2d 100644 --- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py +++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py @@ -31,7 +31,7 @@ from mathutils import ( ) -INTERN_PREVIEW_TYPES = {'MATERIAL', 'LAMP', 'WORLD', 'TEXTURE', 'IMAGE'} +INTERN_PREVIEW_TYPES = {'MATERIAL', 'LIGHT', 'WORLD', 'TEXTURE', 'IMAGE'} OBJECT_TYPES_RENDER = {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'} @@ -73,15 +73,15 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): # Helpers. RenderContext = collections.namedtuple("RenderContext", ( - "scene", "world", "camera", "lamp", "camera_data", "lamp_data", "image", # All those are names! - "backup_scene", "backup_world", "backup_camera", "backup_lamp", "backup_camera_data", "backup_lamp_data", + "scene", "world", "camera", "light", "camera_data", "light_data", "image", # All those are names! + "backup_scene", "backup_world", "backup_camera", "backup_light", "backup_camera_data", "backup_light_data", )) RENDER_PREVIEW_SIZE = bpy.app.render_preview_size def render_context_create(engine, objects_ignored): if engine == '__SCENE': - backup_scene, backup_world, backup_camera, backup_lamp, backup_camera_data, backup_lamp_data = [()] * 6 + backup_scene, backup_world, backup_camera, backup_light, backup_camera_data, backup_light_data = [()] * 6 scene = bpy.context.screen.scene exclude_props = {('world',), ('camera',), ('tool_settings',), ('preview',)} backup_scene = tuple(rna_backup_gen(scene, exclude_props=exclude_props)) @@ -96,20 +96,20 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): camera.rotation_euler = Euler((1.1635528802871704, 0.0, 0.7853981852531433), 'XYZ') # (66.67, 0.0, 45.0) scene.camera = camera scene.objects.link(camera) - # TODO: add lamp if none found in scene? - lamp = None - lamp_data = None + # TODO: add light if none found in scene? + light = None + light_data = None else: - backup_scene, backup_world, backup_camera, backup_lamp, backup_camera_data, backup_lamp_data = [None] * 6 + backup_scene, backup_world, backup_camera, backup_light, backup_camera_data, backup_light_data = [None] * 6 scene = bpy.data.scenes.new("TEMP_preview_render_scene") world = bpy.data.worlds.new("TEMP_preview_render_world") camera_data = bpy.data.cameras.new("TEMP_preview_render_camera") camera = bpy.data.objects.new("TEMP_preview_render_camera", camera_data) - lamp_data = bpy.data.lamps.new("TEMP_preview_render_lamp", 'SPOT') - lamp = bpy.data.objects.new("TEMP_preview_render_lamp", lamp_data) + light_data = bpy.data.lights.new("TEMP_preview_render_light", 'SPOT') + light = bpy.data.objects.new("TEMP_preview_render_light", light_data) - objects_ignored.add((camera.name, lamp.name)) + objects_ignored.add((camera.name, light.name)) scene.world = world @@ -117,10 +117,10 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): scene.camera = camera scene.objects.link(camera) - lamp.rotation_euler = Euler((0.7853981852531433, 0.0, 1.7453292608261108), 'XYZ') # (45.0, 0.0, 100.0) - lamp_data.falloff_type = 'CONSTANT' - lamp_data.spot_size = 1.0471975803375244 # 60 - scene.objects.link(lamp) + light.rotation_euler = Euler((0.7853981852531433, 0.0, 1.7453292608261108), 'XYZ') # (45.0, 0.0, 100.0) + light_data.falloff_type = 'CONSTANT' + light_data.spot_size = 1.0471975803375244 # 60 + scene.objects.link(light) if engine == 'BLENDER_RENDER': scene.render.engine = 'BLENDER_RENDER' @@ -154,9 +154,9 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): image.filepath = scene.render.filepath return RenderContext( - scene.name, world.name if world else None, camera.name, lamp.name if lamp else None, - camera_data.name, lamp_data.name if lamp_data else None, image.name, - backup_scene, backup_world, backup_camera, backup_lamp, backup_camera_data, backup_lamp_data, + scene.name, world.name if world else None, camera.name, light.name if light else None, + camera_data.name, light_data.name if light_data else None, image.name, + backup_scene, backup_world, backup_camera, backup_light, backup_camera_data, backup_light_data, ) def render_context_delete(render_context): @@ -171,8 +171,8 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): scene.camera = None if render_context.camera: scene.objects.unlink(bpy.data.objects[render_context.camera, None]) - if render_context.lamp: - scene.objects.unlink(bpy.data.objects[render_context.lamp, None]) + if render_context.light: + scene.objects.unlink(bpy.data.objects[render_context.light, None]) bpy.data.scenes.remove(scene, do_unlink=True) scene = None else: @@ -213,18 +213,18 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): print("ERROR:", e) success = False - if render_context.lamp: + if render_context.light: try: - lamp = bpy.data.objects[render_context.lamp, None] - if render_context.backup_lamp is None: + light = bpy.data.objects[render_context.light, None] + if render_context.backup_light is None: if scene is not None: - scene.objects.unlink(lamp) - lamp.user_clear() - bpy.data.objects.remove(lamp) - bpy.data.lamps.remove(bpy.data.lamps[render_context.lamp_data, None]) + scene.objects.unlink(light) + light.user_clear() + bpy.data.objects.remove(light) + bpy.data.lights.remove(bpy.data.lights[render_context.light_data, None]) else: - rna_backup_restore(lamp, render_context.backup_lamp) - rna_backup_restore(bpy.data.lamps[render_context.lamp_data, None], render_context.backup_lamp_data) + rna_backup_restore(light, render_context.backup_light) + rna_backup_restore(bpy.data.lights[render_context.light_data, None], render_context.backup_light_data) except Exception as e: print("ERROR:", e) success = False @@ -305,7 +305,7 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): scene = bpy.data.scenes[render_context.scene, None] if objects is not None: camera = bpy.data.objects[render_context.camera, None] - lamp = bpy.data.objects[render_context.lamp, None] if render_context.lamp is not None else None + light = bpy.data.objects[render_context.light, None] if render_context.light is not None else None cos = objects_bbox_calc(camera, objects, offset_matrix) loc, ortho_scale = camera.camera_fit_coords(scene, cos) camera.location = loc @@ -320,9 +320,9 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): max_dist = dist camera.data.clip_start = min_dist / 2 camera.data.clip_end = max_dist * 2 - if lamp: - loc, ortho_scale = lamp.camera_fit_coords(scene, cos) - lamp.location = loc + if light: + loc, ortho_scale = light.camera_fit_coords(scene, cos) + light.location = loc scene.update() bpy.ops.render.render(write_still=True) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index b14565e2a9a..c4bf8422d3f 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -61,7 +61,7 @@ class Library(bpy_types.ID): # we could make this an attribute in rna. attr_links = ("actions", "armatures", "brushes", "cameras", "curves", "grease_pencil", "collections", "images", - "lamps", "lattices", "materials", "metaballs", + "lights", "lattices", "materials", "metaballs", "meshes", "node_groups", "objects", "scenes", "sounds", "speakers", "textures", "texts", "fonts", "worlds") diff --git a/release/scripts/presets/interface_theme/24x_blues.xml b/release/scripts/presets/interface_theme/24x_blues.xml index 36cfeeb5980..18b866eeb0f 100644 --- a/release/scripts/presets/interface_theme/24x_blues.xml +++ b/release/scripts/presets/interface_theme/24x_blues.xml @@ -253,7 +253,7 @@ text_keyframe="#ddd700" camera="#000000" empty="#000000" - lamp="#00000028" + light="#00000028" speaker="#000000" vertex="#000000" vertex_select="#ff8500" diff --git a/release/scripts/presets/interface_theme/back_to_black.xml b/release/scripts/presets/interface_theme/back_to_black.xml index 1636f5b5cf6..464625d0ba5 100644 --- a/release/scripts/presets/interface_theme/back_to_black.xml +++ b/release/scripts/presets/interface_theme/back_to_black.xml @@ -253,7 +253,7 @@ text_keyframe="#ddd700" camera="#535353" empty="#535353" - lamp="#fff0d328" + light="#fff0d328" speaker="#535353" vertex="#72cfdd" vertex_select="#ff8500" diff --git a/release/scripts/presets/interface_theme/blender_24x.xml b/release/scripts/presets/interface_theme/blender_24x.xml index 818e557adf0..d0459e02115 100644 --- a/release/scripts/presets/interface_theme/blender_24x.xml +++ b/release/scripts/presets/interface_theme/blender_24x.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#00000028" + light="#00000028" speaker="#000000" camera="#000000" view_overlay="#000000" diff --git a/release/scripts/presets/interface_theme/blender_27x.xml b/release/scripts/presets/interface_theme/blender_27x.xml index 6a78dd5fc8f..db9d042ae55 100644 --- a/release/scripts/presets/interface_theme/blender_27x.xml +++ b/release/scripts/presets/interface_theme/blender_27x.xml @@ -304,7 +304,7 @@ text_keyframe="#ddd700" camera="#000000" empty="#000000" - lamp="#00000028" + light="#00000028" speaker="#000000" vertex="#000000" vertex_select="#ff8500" diff --git a/release/scripts/presets/interface_theme/dark_blue_gradient.xml b/release/scripts/presets/interface_theme/dark_blue_gradient.xml index d226f8531b2..589aeab3a50 100644 --- a/release/scripts/presets/interface_theme/dark_blue_gradient.xml +++ b/release/scripts/presets/interface_theme/dark_blue_gradient.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#00000028" + light="#00000028" speaker="#000000" camera="#000000" view_overlay="#000000" diff --git a/release/scripts/presets/interface_theme/default++.xml b/release/scripts/presets/interface_theme/default++.xml index 413fbc1aa71..3599a094381 100644 --- a/release/scripts/presets/interface_theme/default++.xml +++ b/release/scripts/presets/interface_theme/default++.xml @@ -253,7 +253,7 @@ text_keyframe="#ddd700" camera="#000000" empty="#000000" - lamp="#00000028" + light="#00000028" speaker="#000000" vertex="#000000" vertex_select="#ff8500" diff --git a/release/scripts/presets/interface_theme/elsyiun.xml b/release/scripts/presets/interface_theme/elsyiun.xml index b9292856fe9..51af13a6009 100644 --- a/release/scripts/presets/interface_theme/elsyiun.xml +++ b/release/scripts/presets/interface_theme/elsyiun.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#00000028" + light="#00000028" speaker="#000000" camera="#000000" view_overlay="#000000" diff --git a/release/scripts/presets/interface_theme/flatty_light.xml b/release/scripts/presets/interface_theme/flatty_light.xml index bdcf381f8f9..497b6575731 100644 --- a/release/scripts/presets/interface_theme/flatty_light.xml +++ b/release/scripts/presets/interface_theme/flatty_light.xml @@ -304,7 +304,7 @@ text_keyframe="#ddd700" camera="#b3b3b3" empty="#b3b3b3" - lamp="#cccccc33" + light="#cccccc33" speaker="#b3b3b3" vertex="#000000" vertex_select="#ff8500" diff --git a/release/scripts/presets/interface_theme/graph.xml b/release/scripts/presets/interface_theme/graph.xml index a032d8bd3b2..904fcdf41ec 100644 --- a/release/scripts/presets/interface_theme/graph.xml +++ b/release/scripts/presets/interface_theme/graph.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#00000028" + light="#00000028" speaker="#000000" camera="#8d8c8d" view_overlay="#000000" diff --git a/release/scripts/presets/interface_theme/hexagon.xml b/release/scripts/presets/interface_theme/hexagon.xml index 4b24abc5fa7..1ca52b76253 100644 --- a/release/scripts/presets/interface_theme/hexagon.xml +++ b/release/scripts/presets/interface_theme/hexagon.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#00000028" + light="#00000028" speaker="#000000" camera="#000000" view_overlay="#000000" diff --git a/release/scripts/presets/interface_theme/modern_minimalist.xml b/release/scripts/presets/interface_theme/modern_minimalist.xml index 8ba9402ecdb..3b982514f4f 100644 --- a/release/scripts/presets/interface_theme/modern_minimalist.xml +++ b/release/scripts/presets/interface_theme/modern_minimalist.xml @@ -253,7 +253,7 @@ text_keyframe="#ddd700" camera="#8d8c8d" empty="#8d8c8d" - lamp="#8d8c8d40" + light="#8d8c8d40" speaker="#8d8c8d" vertex="#bfbfbf" vertex_select="#00bdff" diff --git a/release/scripts/presets/interface_theme/north.xml b/release/scripts/presets/interface_theme/north.xml index 69cb90a64ce..8ab51261994 100644 --- a/release/scripts/presets/interface_theme/north.xml +++ b/release/scripts/presets/interface_theme/north.xml @@ -253,7 +253,7 @@ text_keyframe="#ddd700" camera="#000000" empty="#000000" - lamp="#00000028" + light="#00000028" speaker="#000000" vertex="#000000" vertex_select="#f2b252" diff --git a/release/scripts/presets/interface_theme/rtheme.xml b/release/scripts/presets/interface_theme/rtheme.xml index 27f33aa2fe5..34d4f6bd0db 100644 --- a/release/scripts/presets/interface_theme/rtheme.xml +++ b/release/scripts/presets/interface_theme/rtheme.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#00000028" + light="#00000028" speaker="#000000" camera="#000000" view_overlay="#000000" diff --git a/release/scripts/presets/interface_theme/sandyslate.xml b/release/scripts/presets/interface_theme/sandyslate.xml index c5bae419bca..0b4756a40e8 100644 --- a/release/scripts/presets/interface_theme/sandyslate.xml +++ b/release/scripts/presets/interface_theme/sandyslate.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#ff000080" + light="#ff000080" speaker="#979797" camera="#ff0000" view_overlay="#000000" diff --git a/release/scripts/presets/interface_theme/science_lab.xml b/release/scripts/presets/interface_theme/science_lab.xml index 2fe4cf99e41..e8a32f6ac29 100644 --- a/release/scripts/presets/interface_theme/science_lab.xml +++ b/release/scripts/presets/interface_theme/science_lab.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#dbac00b9" + light="#dbac00b9" speaker="#229cd8" camera="#e28400" view_overlay="#666666" diff --git a/release/scripts/presets/interface_theme/softblend.xml b/release/scripts/presets/interface_theme/softblend.xml index ab0a5994838..ce20f7d4085 100644 --- a/release/scripts/presets/interface_theme/softblend.xml +++ b/release/scripts/presets/interface_theme/softblend.xml @@ -244,7 +244,7 @@ gp_vertex="#000000" gp_vertex_select="#ff8500" gp_vertex_size="3" - lamp="#ffe56666" + light="#ffe56666" speaker="#c2e787" camera="#000000" view_overlay="#000000" diff --git a/release/scripts/presets/interface_theme/true_blue_menu.xml b/release/scripts/presets/interface_theme/true_blue_menu.xml index 2b464ae120e..26e39f3bcdf 100644 --- a/release/scripts/presets/interface_theme/true_blue_menu.xml +++ b/release/scripts/presets/interface_theme/true_blue_menu.xml @@ -253,7 +253,7 @@ text_keyframe="#ddd700" camera="#000000" empty="#a78721" - lamp="#d6df1628" + light="#d6df1628" speaker="#a83f2d" vertex="#657780" vertex_select="#00cccb" diff --git a/release/scripts/presets/sunsky/classic.py b/release/scripts/presets/sunsky/classic.py deleted file mode 100644 index edb065d553c..00000000000 --- a/release/scripts/presets/sunsky/classic.py +++ /dev/null @@ -1,14 +0,0 @@ -import bpy -bpy.context.lamp.sky.atmosphere_turbidity = 4.0 -bpy.context.lamp.sky.sky_blend_type = 'ADD' -bpy.context.lamp.sky.sky_blend = 1.0 -bpy.context.lamp.sky.horizon_brightness = 10.0 -bpy.context.lamp.sky.spread = 1.49011614159e-09 -bpy.context.lamp.sky.sky_color_space = 'SMPTE' -bpy.context.lamp.sky.sky_exposure = 1.0 -bpy.context.lamp.sky.sun_brightness = 1.00000011921 -bpy.context.lamp.sky.sun_size = 1.00000166893 -bpy.context.lamp.sky.backscattered_light = 0.0 -bpy.context.lamp.sky.sun_intensity = 4.0 -bpy.context.lamp.sky.atmosphere_inscattering = 1.0 -bpy.context.lamp.sky.atmosphere_extinction = 1.0 diff --git a/release/scripts/presets/sunsky/desert.py b/release/scripts/presets/sunsky/desert.py deleted file mode 100644 index 8dd587a6eaf..00000000000 --- a/release/scripts/presets/sunsky/desert.py +++ /dev/null @@ -1,14 +0,0 @@ -import bpy -bpy.context.lamp.sky.atmosphere_turbidity = 6.0 -bpy.context.lamp.sky.sky_blend_type = 'ADD' -bpy.context.lamp.sky.sky_blend = 1.0 -bpy.context.lamp.sky.horizon_brightness = 4.99999761581 -bpy.context.lamp.sky.spread = 1.49011614159e-09 -bpy.context.lamp.sky.sky_color_space = 'SMPTE' -bpy.context.lamp.sky.sky_exposure = 1.0 -bpy.context.lamp.sky.sun_brightness = 1.00000011921 -bpy.context.lamp.sky.sun_size = 4.0 -bpy.context.lamp.sky.backscattered_light = 1.0 -bpy.context.lamp.sky.sun_intensity = 1.0 -bpy.context.lamp.sky.atmosphere_inscattering = 1.0 -bpy.context.lamp.sky.atmosphere_extinction = 1.0 diff --git a/release/scripts/presets/sunsky/mountain.py b/release/scripts/presets/sunsky/mountain.py deleted file mode 100644 index f0540af8100..00000000000 --- a/release/scripts/presets/sunsky/mountain.py +++ /dev/null @@ -1,14 +0,0 @@ -import bpy -bpy.context.lamp.sky.atmosphere_turbidity = 2.00000023842 -bpy.context.lamp.sky.sky_blend_type = 'ADD' -bpy.context.lamp.sky.sky_blend = 1.0 -bpy.context.lamp.sky.horizon_brightness = 0.100000016391 -bpy.context.lamp.sky.spread = 1.0 -bpy.context.lamp.sky.sky_color_space = 'SMPTE' -bpy.context.lamp.sky.sky_exposure = 1.0 -bpy.context.lamp.sky.sun_brightness = 1.99999988079 -bpy.context.lamp.sky.sun_size = 4.0 -bpy.context.lamp.sky.backscattered_light = -1.0 -bpy.context.lamp.sky.sun_intensity = 10.0 -bpy.context.lamp.sky.atmosphere_inscattering = 1.0 -bpy.context.lamp.sky.atmosphere_extinction = 1.0 diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index 250c88b9009..d898239d7a9 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -110,7 +110,7 @@ class ANIM_OT_keying_set_export(Operator): # - special handling is needed for "nested" ID-blocks # (e.g. nodetree in Material) if ksp.id.bl_rna.identifier.startswith("ShaderNodeTree"): - # Find material or lamp using this node tree... + # Find material or light using this node tree... id_bpy_path = "bpy.data.nodes[\"%s\"]" found = False @@ -121,14 +121,14 @@ class ANIM_OT_keying_set_export(Operator): break if not found: - for lamp in bpy.data.lamps: - if lamp.node_tree == ksp.id: - id_bpy_path = "bpy.data.lamps[\"%s\"].node_tree" % (lamp.name) + for light in bpy.data.lights: + if light.node_tree == ksp.id: + id_bpy_path = "bpy.data.lights[\"%s\"].node_tree" % (light.name) found = True break if not found: - self.report({'WARN'}, "Could not find material or lamp using Shader Node Tree - %s" % (ksp.id)) + self.report({'WARN'}, "Could not find material or light using Shader Node Tree - %s" % (ksp.id)) elif ksp.id.bl_rna.identifier.startswith("CompositorNodeTree"): # Find compositor nodetree using this node tree... for scene in bpy.data.scenes: diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index 5f3075b403f..95c4bbbfba9 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -915,17 +915,17 @@ class CLIP_OT_setup_tracking_scene(Operator): return [(layers_a[i] | layers_b[i]) for i in range(len(layers_a))] @staticmethod - def _createLamp(scene): - lamp = bpy.data.lamps.new(name="Lamp", type='POINT') - lampob = bpy.data.objects.new(name="Lamp", object_data=lamp) - scene.objects.link(lampob) + def _createLight(scene): + light = bpy.data.lights.new(name="Light", type='POINT') + lightob = bpy.data.objects.new(name="Light", object_data=light) + scene.objects.link(lightob) - lampob.matrix_local = Matrix.Translation((4.076, 1.005, 5.904)) + lightob.matrix_local = Matrix.Translation((4.076, 1.005, 5.904)) - lamp.distance = 30 - lamp.shadow_method = 'RAY_SHADOW' + light.distance = 30 + light.shadow_method = 'RAY_SHADOW' - return lampob + return lightob def _createSampleObject(self, scene): vertices = self._getPlaneVertices(1.0, -1.0) + \ @@ -947,20 +947,20 @@ class CLIP_OT_setup_tracking_scene(Operator): all_layers = self._mergeLayers(fg.layers, bg.layers) - # ensure all lamps are active on foreground and background - has_lamp = False + # ensure all lights are active on foreground and background + has_light = False has_mesh = False for ob in scene.objects: - if ob.type == 'LAMP': + if ob.type == 'LIGHT': ob.layers = all_layers - has_lamp = True + has_light = True elif ob.type == 'MESH' and "is_ground" not in ob: has_mesh = True - # create sample lamp if there's no lamps in the scene - if not has_lamp: - lamp = self._createLamp(scene) - lamp.layers = all_layers + # create sample light if there's no lights in the scene + if not has_light: + light = self._createLight(scene) + light.layers = all_layers # create sample object if there's no meshes in the scene if not has_mesh: diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index da9054fb681..51ba45cdcd7 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -34,7 +34,7 @@ _modules = [ "properties_data_camera", "properties_data_curve", "properties_data_empty", - "properties_data_lamp", + "properties_data_light", "properties_data_lattice", "properties_data_mesh", "properties_data_metaball", diff --git a/release/scripts/startup/bl_ui/properties_data_lamp.py b/release/scripts/startup/bl_ui/properties_data_lamp.py deleted file mode 100644 index d613967584c..00000000000 --- a/release/scripts/startup/bl_ui/properties_data_lamp.py +++ /dev/null @@ -1,363 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# -import bpy -from bpy.types import Menu, Panel -from rna_prop_ui import PropertyPanel - - -class DataButtonsPanel: - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" - - @classmethod - def poll(cls, context): - engine = context.engine - return context.lamp and (engine in cls.COMPAT_ENGINES) - - -class DATA_PT_context_lamp(DataButtonsPanel, Panel): - bl_label = "" - bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} - - def draw(self, context): - layout = self.layout - - ob = context.object - lamp = context.lamp - space = context.space_data - - split = layout.split(percentage=0.65) - - if ob: - split.template_ID(ob, "data") - elif lamp: - split.template_ID(space, "pin_id") - - -class DATA_PT_preview(DataButtonsPanel, Panel): - bl_label = "Preview" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} - - def draw(self, context): - self.layout.template_preview(context.lamp) - - -class DATA_PT_lamp(DataButtonsPanel, Panel): - bl_label = "Lamp" - COMPAT_ENGINES = {'BLENDER_RENDER'} - - def draw(self, context): - layout = self.layout - - lamp = context.lamp - - layout.row().prop(lamp, "type", expand=True) - - layout.use_property_split = True - - col = col.column() - col.prop(lamp, "color") - col.prop(lamp, "energy") - - if lamp.type in {'POINT', 'SPOT'}: - - col = col.column() - col.label(text="Falloff") - col.prop(lamp, "falloff_type") - col.prop(lamp, "distance") - col.prop(lamp, "shadow_soft_size") - - if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED': - sub = col.column(align=True) - sub.prop(lamp, "linear_attenuation", slider=True, text="Linear") - sub.prop(lamp, "quadratic_attenuation", slider=True, text="Quadratic") - - elif lamp.falloff_type == 'INVERSE_COEFFICIENTS': - col.label(text="Inverse Coefficients") - sub = col.column(align=True) - sub.prop(lamp, "constant_coefficient", text="Constant") - sub.prop(lamp, "linear_coefficient", text="Linear") - sub.prop(lamp, "quadratic_coefficient", text="Quadratic") - - if lamp.type == 'AREA': - col.prop(lamp, "distance") - - col = split.column() - col.label() - - -class DATA_PT_EEVEE_lamp(DataButtonsPanel, Panel): - bl_label = "Lamp" - COMPAT_ENGINES = {'BLENDER_EEVEE'} - - def draw(self, context): - layout = self.layout - lamp = context.lamp - - layout.row().prop(lamp, "type", expand=True) - - layout.use_property_split = True - - col = layout.column() - col.prop(lamp, "color") - col.prop(lamp, "energy") - col.prop(lamp, "specular_factor", text="Specular") - - col.separator() - - if lamp.type in {'POINT', 'SPOT', 'SUN'}: - col.prop(lamp, "shadow_soft_size", text="Radius") - elif lamp.type == 'AREA': - col.prop(lamp, "shape") - - sub = col.column(align=True) - - if lamp.shape in {'SQUARE', 'DISK'}: - sub.prop(lamp, "size") - elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}: - sub.prop(lamp, "size", text="Size X") - sub.prop(lamp, "size_y", text="Y") - - -class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel): - bl_label = "Shadow" - COMPAT_ENGINES = {'BLENDER_EEVEE'} - - @classmethod - def poll(cls, context): - lamp = context.lamp - engine = context.engine - return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES) - - def draw_header(self, context): - lamp = context.lamp - self.layout.prop(lamp, "use_shadow", text="") - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - - lamp = context.lamp - - layout.active = lamp.use_shadow - - col = layout.column() - sub = col.column(align=True) - sub.prop(lamp, "shadow_buffer_clip_start", text="Clip Start") - sub.prop(lamp, "shadow_buffer_clip_end", text="End") - - col.prop(lamp, "shadow_buffer_soft", text="Softness") - - col.separator() - - col.prop(lamp, "shadow_buffer_bias", text="Bias") - col.prop(lamp, "shadow_buffer_exp", text="Exponent") - col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias") - - -class DATA_PT_EEVEE_shadow_cascaded_shadow_map(DataButtonsPanel, Panel): - bl_label = "Cascaded Shadow Map" - bl_parent_id = "DATA_PT_EEVEE_shadow" - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_EEVEE'} - - @classmethod - def poll(cls, context): - lamp = context.lamp - engine = context.engine - - return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES) - - def draw(self, context): - layout = self.layout - lamp = context.lamp - layout.use_property_split = True - - col = layout.column() - - col.prop(lamp, "shadow_cascade_count", text="Count") - col.prop(lamp, "shadow_cascade_fade", text="Fade") - - col.prop(lamp, "shadow_cascade_max_distance", text="Max Distance") - col.prop(lamp, "shadow_cascade_exponent", text="Distribution") - - -class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel): - bl_label = "Contact Shadows" - bl_parent_id = "DATA_PT_EEVEE_shadow" - COMPAT_ENGINES = {'BLENDER_EEVEE'} - - @classmethod - def poll(cls, context): - lamp = context.lamp - engine = context.engine - return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES) - - def draw_header(self, context): - lamp = context.lamp - - layout = self.layout - layout.active = lamp.use_shadow - layout.prop(lamp, "use_contact_shadow", text="") - - def draw(self, context): - layout = self.layout - lamp = context.lamp - layout.use_property_split = True - - col = layout.column() - col.active = lamp.use_shadow and lamp.use_contact_shadow - - col.prop(lamp, "contact_shadow_distance", text="Distance") - col.prop(lamp, "contact_shadow_soft_size", text="Softness") - col.prop(lamp, "contact_shadow_bias", text="Bias") - col.prop(lamp, "contact_shadow_thickness", text="Thickness") - - -class DATA_PT_area(DataButtonsPanel, Panel): - bl_label = "Area Shape" - COMPAT_ENGINES = {'BLENDER_RENDER'} - - @classmethod - def poll(cls, context): - lamp = context.lamp - engine = context.engine - return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES) - - def draw(self, context): - layout = self.layout - - lamp = context.lamp - - col = layout.column() - col.row().prop(lamp, "shape", expand=True) - sub = col.row(align=True) - - if lamp.shape in {'SQUARE', 'DISK'}: - sub.prop(lamp, "size") - elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}: - sub.prop(lamp, "size", text="Size X") - sub.prop(lamp, "size_y", text="Size Y") - - -class DATA_PT_spot(DataButtonsPanel, Panel): - bl_label = "Spot Shape" - COMPAT_ENGINES = {'BLENDER_RENDER'} - - @classmethod - def poll(cls, context): - lamp = context.lamp - engine = context.engine - return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES) - - def draw(self, context): - layout = self.layout - - lamp = context.lamp - - split = layout.split() - - col = split.column() - sub = col.column() - sub.prop(lamp, "spot_size", text="Size") - sub.prop(lamp, "spot_blend", text="Blend", slider=True) - col.prop(lamp, "use_square") - col.prop(lamp, "show_cone") - - col = split.column() - - col.active = (lamp.shadow_method != 'BUFFER_SHADOW' or lamp.shadow_buffer_type != 'DEEP') - col.prop(lamp, "use_halo") - sub = col.column(align=True) - sub.active = lamp.use_halo - sub.prop(lamp, "halo_intensity", text="Intensity") - if lamp.shadow_method == 'BUFFER_SHADOW': - sub.prop(lamp, "halo_step", text="Step") - - -class DATA_PT_spot(DataButtonsPanel, Panel): - bl_label = "Spot Shape" - bl_parent_id = "DATA_PT_EEVEE_lamp" - COMPAT_ENGINES = {'BLENDER_EEVEE'} - - @classmethod - def poll(cls, context): - lamp = context.lamp - engine = context.engine - return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES) - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - - lamp = context.lamp - - col = layout.column() - - col.prop(lamp, "spot_size", text="Size") - col.prop(lamp, "spot_blend", text="Blend", slider=True) - - col.prop(lamp, "show_cone") - - -class DATA_PT_falloff_curve(DataButtonsPanel, Panel): - bl_label = "Falloff Curve" - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} - - @classmethod - def poll(cls, context): - lamp = context.lamp - engine = context.engine - - return (lamp and lamp.type in {'POINT', 'SPOT'} and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES) - - def draw(self, context): - lamp = context.lamp - - self.layout.template_curve_mapping(lamp, "falloff_curve", use_negative_slope=True) - - -class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} - _context_path = "object.data" - _property_type = bpy.types.Lamp - - -classes = ( - DATA_PT_context_lamp, - DATA_PT_preview, - DATA_PT_lamp, - DATA_PT_EEVEE_lamp, - DATA_PT_EEVEE_shadow, - DATA_PT_EEVEE_shadow_contact, - DATA_PT_EEVEE_shadow_cascaded_shadow_map, - DATA_PT_area, - DATA_PT_spot, - DATA_PT_falloff_curve, - DATA_PT_custom_props_lamp, -) - -if __name__ == "__main__": # only for live edit. - from bpy.utils import register_class - for cls in classes: - register_class(cls) diff --git a/release/scripts/startup/bl_ui/properties_data_light.py b/release/scripts/startup/bl_ui/properties_data_light.py new file mode 100644 index 00000000000..057f7dffce0 --- /dev/null +++ b/release/scripts/startup/bl_ui/properties_data_light.py @@ -0,0 +1,363 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# +import bpy +from bpy.types import Menu, Panel +from rna_prop_ui import PropertyPanel + + +class DataButtonsPanel: + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "data" + + @classmethod + def poll(cls, context): + engine = context.engine + return context.light and (engine in cls.COMPAT_ENGINES) + + +class DATA_PT_context_light(DataButtonsPanel, Panel): + bl_label = "" + bl_options = {'HIDE_HEADER'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + def draw(self, context): + layout = self.layout + + ob = context.object + light = context.light + space = context.space_data + + split = layout.split(percentage=0.65) + + if ob: + split.template_ID(ob, "data") + elif light: + split.template_ID(space, "pin_id") + + +class DATA_PT_preview(DataButtonsPanel, Panel): + bl_label = "Preview" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + def draw(self, context): + self.layout.template_preview(context.light) + + +class DATA_PT_light(DataButtonsPanel, Panel): + bl_label = "Light" + COMPAT_ENGINES = {'BLENDER_RENDER'} + + def draw(self, context): + layout = self.layout + + light = context.light + + layout.row().prop(light, "type", expand=True) + + layout.use_property_split = True + + col = col.column() + col.prop(light, "color") + col.prop(light, "energy") + + if light.type in {'POINT', 'SPOT'}: + + col = col.column() + col.label(text="Falloff") + col.prop(light, "falloff_type") + col.prop(light, "distance") + col.prop(light, "shadow_soft_size") + + if light.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED': + sub = col.column(align=True) + sub.prop(light, "linear_attenuation", slider=True, text="Linear") + sub.prop(light, "quadratic_attenuation", slider=True, text="Quadratic") + + elif light.falloff_type == 'INVERSE_COEFFICIENTS': + col.label(text="Inverse Coefficients") + sub = col.column(align=True) + sub.prop(light, "constant_coefficient", text="Constant") + sub.prop(light, "linear_coefficient", text="Linear") + sub.prop(light, "quadratic_coefficient", text="Quadratic") + + if light.type == 'AREA': + col.prop(light, "distance") + + col = split.column() + col.label() + + +class DATA_PT_EEVEE_light(DataButtonsPanel, Panel): + bl_label = "Light" + COMPAT_ENGINES = {'BLENDER_EEVEE'} + + def draw(self, context): + layout = self.layout + light = context.light + + layout.row().prop(light, "type", expand=True) + + layout.use_property_split = True + + col = layout.column() + col.prop(light, "color") + col.prop(light, "energy") + col.prop(light, "specular_factor", text="Specular") + + col.separator() + + if light.type in {'POINT', 'SPOT', 'SUN'}: + col.prop(light, "shadow_soft_size", text="Radius") + elif light.type == 'AREA': + col.prop(light, "shape") + + sub = col.column(align=True) + + if light.shape in {'SQUARE', 'DISK'}: + sub.prop(light, "size") + elif light.shape in {'RECTANGLE', 'ELLIPSE'}: + sub.prop(light, "size", text="Size X") + sub.prop(light, "size_y", text="Y") + + +class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel): + bl_label = "Shadow" + COMPAT_ENGINES = {'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + light = context.light + engine = context.engine + return (light and light.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES) + + def draw_header(self, context): + light = context.light + self.layout.prop(light, "use_shadow", text="") + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + light = context.light + + layout.active = light.use_shadow + + col = layout.column() + sub = col.column(align=True) + sub.prop(light, "shadow_buffer_clip_start", text="Clip Start") + sub.prop(light, "shadow_buffer_clip_end", text="End") + + col.prop(light, "shadow_buffer_soft", text="Softness") + + col.separator() + + col.prop(light, "shadow_buffer_bias", text="Bias") + col.prop(light, "shadow_buffer_exp", text="Exponent") + col.prop(light, "shadow_buffer_bleed_bias", text="Bleed Bias") + + +class DATA_PT_EEVEE_shadow_cascaded_shadow_map(DataButtonsPanel, Panel): + bl_label = "Cascaded Shadow Map" + bl_parent_id = "DATA_PT_EEVEE_shadow" + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + light = context.light + engine = context.engine + + return (light and light.type == 'SUN') and (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + light = context.light + layout.use_property_split = True + + col = layout.column() + + col.prop(light, "shadow_cascade_count", text="Count") + col.prop(light, "shadow_cascade_fade", text="Fade") + + col.prop(light, "shadow_cascade_max_distance", text="Max Distance") + col.prop(light, "shadow_cascade_exponent", text="Distribution") + + +class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel): + bl_label = "Contact Shadows" + bl_parent_id = "DATA_PT_EEVEE_shadow" + COMPAT_ENGINES = {'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + light = context.light + engine = context.engine + return (light and light.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES) + + def draw_header(self, context): + light = context.light + + layout = self.layout + layout.active = light.use_shadow + layout.prop(light, "use_contact_shadow", text="") + + def draw(self, context): + layout = self.layout + light = context.light + layout.use_property_split = True + + col = layout.column() + col.active = light.use_shadow and light.use_contact_shadow + + col.prop(light, "contact_shadow_distance", text="Distance") + col.prop(light, "contact_shadow_soft_size", text="Softness") + col.prop(light, "contact_shadow_bias", text="Bias") + col.prop(light, "contact_shadow_thickness", text="Thickness") + + +class DATA_PT_area(DataButtonsPanel, Panel): + bl_label = "Area Shape" + COMPAT_ENGINES = {'BLENDER_RENDER'} + + @classmethod + def poll(cls, context): + light = context.light + engine = context.engine + return (light and light.type == 'AREA') and (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + + light = context.light + + col = layout.column() + col.row().prop(light, "shape", expand=True) + sub = col.row(align=True) + + if light.shape in {'SQUARE', 'DISK'}: + sub.prop(light, "size") + elif light.shape in {'RECTANGLE', 'ELLIPSE'}: + sub.prop(light, "size", text="Size X") + sub.prop(light, "size_y", text="Size Y") + + +class DATA_PT_spot(DataButtonsPanel, Panel): + bl_label = "Spot Shape" + COMPAT_ENGINES = {'BLENDER_RENDER'} + + @classmethod + def poll(cls, context): + light = context.light + engine = context.engine + return (light and light.type == 'SPOT') and (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + + light = context.light + + split = layout.split() + + col = split.column() + sub = col.column() + sub.prop(light, "spot_size", text="Size") + sub.prop(light, "spot_blend", text="Blend", slider=True) + col.prop(light, "use_square") + col.prop(light, "show_cone") + + col = split.column() + + col.active = (light.shadow_method != 'BUFFER_SHADOW' or light.shadow_buffer_type != 'DEEP') + col.prop(light, "use_halo") + sub = col.column(align=True) + sub.active = light.use_halo + sub.prop(light, "halo_intensity", text="Intensity") + if light.shadow_method == 'BUFFER_SHADOW': + sub.prop(light, "halo_step", text="Step") + + +class DATA_PT_spot(DataButtonsPanel, Panel): + bl_label = "Spot Shape" + bl_parent_id = "DATA_PT_EEVEE_light" + COMPAT_ENGINES = {'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + light = context.light + engine = context.engine + return (light and light.type == 'SPOT') and (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + light = context.light + + col = layout.column() + + col.prop(light, "spot_size", text="Size") + col.prop(light, "spot_blend", text="Blend", slider=True) + + col.prop(light, "show_cone") + + +class DATA_PT_falloff_curve(DataButtonsPanel, Panel): + bl_label = "Falloff Curve" + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + light = context.light + engine = context.engine + + return (light and light.type in {'POINT', 'SPOT'} and light.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + light = context.light + + self.layout.template_curve_mapping(light, "falloff_curve", use_negative_slope=True) + + +class DATA_PT_custom_props_light(DataButtonsPanel, PropertyPanel, Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + _context_path = "object.data" + _property_type = bpy.types.Light + + +classes = ( + DATA_PT_context_light, + DATA_PT_preview, + DATA_PT_light, + DATA_PT_EEVEE_light, + DATA_PT_EEVEE_shadow, + DATA_PT_EEVEE_shadow_contact, + DATA_PT_EEVEE_shadow_cascaded_shadow_map, + DATA_PT_area, + DATA_PT_spot, + DATA_PT_falloff_curve, + DATA_PT_custom_props_light, +) + +if __name__ == "__main__": # only for live edit. + from bpy.utils import register_class + for cls in classes: + register_class(cls) diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index 93fbc7799bf..92022e019cc 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -132,8 +132,8 @@ class DopesheetFilterPopoverBase: flow.prop(dopesheet, "show_cameras", text="Cameras") if bpy.data.grease_pencil: flow.prop(dopesheet, "show_gpencil", text="Grease Pencil Objects") - if bpy.data.lamps: - flow.prop(dopesheet, "show_lamps", text="Lamps") + if bpy.data.lights: + flow.prop(dopesheet, "show_lights", text="Lights") if bpy.data.materials: flow.prop(dopesheet, "show_materials", text="Materials") if bpy.data.textures: diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 3960f336cd0..9d8c14ba9c3 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -61,7 +61,7 @@ class NODE_HT_header(Header): NODE_MT_editor_menus.draw_collapsible(context, layout) # No shader nodes for Eevee lamps - if snode_id and not (context.engine == 'BLENDER_EEVEE' and ob.type == 'LAMP'): + if snode_id and not (context.engine == 'BLENDER_EEVEE' and ob.type == 'LIGHT'): row = layout.row() row.prop(snode_id, "use_nodes") @@ -73,12 +73,11 @@ class NODE_HT_header(Header): # Show material.new when no active ID/slot exists if not id_from and ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'METABALL'}: row.template_ID(ob, "active_material", new="material.new") - # Material ID, but not for Lamps - if id_from and ob.type != 'LAMP': + # Material ID, but not for Lights + if id_from and ob.type != 'LIGHT': row.template_ID(id_from, "active_material", new="material.new") if snode.shader_type == 'WORLD': - NODE_MT_editor_menus.draw_collapsible(context, layout) if snode_id: diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index f19b0304afa..37a5804f12c 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -270,8 +270,8 @@ class OUTLINER_PT_filter(Panel): sub.prop(space, "use_filter_object_mesh", text="Meshes", icon="MESH_DATA") if bpy.data.armatures: sub.prop(space, "use_filter_object_armature", text="Armatures", icon="ARMATURE_DATA") - if bpy.data.lamps: - sub.prop(space, "use_filter_object_lamp", text="Lamps", icon="LAMP_DATA") + if bpy.data.lights: + sub.prop(space, "use_filter_object_light", text="Lights", icon="LIGHT_DATA") if bpy.data.cameras: sub.prop(space, "use_filter_object_camera", text="Cameras", icon="CAMERA_DATA") diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 1f00f8af1ff..8d560ff8815 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -28,23 +28,23 @@ from bpy.app.translations import pgettext_iface as iface_ from bpy.app.translations import contexts as i18n_contexts -def opengl_lamp_buttons(column, lamp): +def opengl_light_buttons(column, light): split = column.row() - split.prop(lamp, "use", text="", icon='OUTLINER_OB_LAMP' if lamp.use else 'LAMP_DATA') + split.prop(light, "use", text="", icon='OUTLINER_OB_LIGHT' if light.use else 'LIGHT_DATA') col = split.column() - col.active = lamp.use + col.active = light.use row = col.row() row.label(text="Diffuse:") - row.prop(lamp, "diffuse_color", text="") + row.prop(light, "diffuse_color", text="") row = col.row() row.label(text="Specular:") - row.prop(lamp, "specular_color", text="") + row.prop(light, "specular_color", text="") col = split.column() - col.active = lamp.use - col.prop(lamp, "direction", text="") + col.active = light.use + col.prop(light, "direction", text="") class USERPREF_HT_header(Header): @@ -454,7 +454,7 @@ class USERPREF_PT_edit(Panel): col.prop(edit, "use_duplicate_text", text="Text") col.prop(edit, "use_duplicate_metaball", text="Metaball") col.prop(edit, "use_duplicate_armature", text="Armature") - col.prop(edit, "use_duplicate_lamp", text="Lamp") + col.prop(edit, "use_duplicate_light", text="Light") col.prop(edit, "use_duplicate_material", text="Material") col.prop(edit, "use_duplicate_texture", text="Texture") #col.prop(edit, "use_duplicate_fcurve", text="F-Curve") @@ -580,14 +580,14 @@ class USERPREF_PT_system(Panel): split.label(text="Colors:") split.label(text="Direction:") - lamp = system.solid_lights[0] - opengl_lamp_buttons(column, lamp) + light = system.solid_lights[0] + opengl_light_buttons(column, light) - lamp = system.solid_lights[1] - opengl_lamp_buttons(column, lamp) + light = system.solid_lights[1] + opengl_light_buttons(column, light) - lamp = system.solid_lights[2] - opengl_lamp_buttons(column, lamp) + light = system.solid_lights[2] + opengl_light_buttons(column, light) column.separator() diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 4dfc9a9129b..ce764ef98c7 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1399,15 +1399,15 @@ class INFO_MT_armature_add(Menu): layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA') -class INFO_MT_lamp_add(Menu): - bl_idname = "INFO_MT_lamp_add" - bl_label = "Lamp" +class INFO_MT_light_add(Menu): + bl_idname = "INFO_MT_light_add" + bl_label = "Light" def draw(self, context): layout = self.layout layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator_enum("object.lamp_add", "type") + layout.operator_enum("object.light_add", "type") class INFO_MT_lightprobe_add(Menu): @@ -1467,7 +1467,7 @@ class INFO_MT_add(Menu): else: INFO_MT_camera_add.draw(self, context) - layout.menu("INFO_MT_lamp_add", icon='OUTLINER_OB_LAMP') + layout.menu("INFO_MT_light_add", icon='OUTLINER_OB_LIGHT') layout.separator() layout.menu("INFO_MT_lightprobe_add", icon='OUTLINER_OB_LIGHTPROBE') layout.separator() @@ -1739,14 +1739,14 @@ class VIEW3D_MT_object_specials(Menu): props.input_scale = 0.01 props.header_text = "Empty Draw Size: %.3f" - if obj.type == 'LAMP': - lamp = obj.data + if obj.type == 'LIGHT': + light = obj.data layout.operator_context = 'INVOKE_REGION_WIN' emission_node = None - if lamp.node_tree: - for node in lamp.node_tree.nodes: + if light.node_tree: + for node in light.node_tree.nodes: if getattr(node, "type", None) == 'EMISSION': emission_node = node break @@ -1757,28 +1757,28 @@ class VIEW3D_MT_object_specials(Menu): props.data_path_item = "data.node_tree" \ ".nodes[\"" + emission_node.name + "\"]" \ ".inputs[\"Strength\"].default_value" - props.header_text = "Lamp Strength: %.3f" + props.header_text = "Light Strength: %.3f" props.input_scale = 0.1 - if lamp.type == 'AREA': + if light.type == 'AREA': props = layout.operator("wm.context_modal_mouse", text="Size X") props.data_path_iter = "selected_editable_objects" props.data_path_item = "data.size" - props.header_text = "Lamp Size X: %.3f" + props.header_text = "Light Size X: %.3f" - if lamp.shape in {'RECTANGLE', 'ELLIPSE'}: + if light.shape in {'RECTANGLE', 'ELLIPSE'}: props = layout.operator("wm.context_modal_mouse", text="Size Y") props.data_path_iter = "selected_editable_objects" props.data_path_item = "data.size_y" - props.header_text = "Lamp Size Y: %.3f" + props.header_text = "Light Size Y: %.3f" - elif lamp.type in {'SPOT', 'POINT', 'SUN'}: + elif light.type in {'SPOT', 'POINT', 'SUN'}: props = layout.operator("wm.context_modal_mouse", text="Size") props.data_path_iter = "selected_editable_objects" props.data_path_item = "data.shadow_soft_size" - props.header_text = "Lamp Size: %.3f" + props.header_text = "Light Size: %.3f" - if lamp.type == 'SPOT': + if light.type == 'SPOT': layout.separator() props = layout.operator("wm.context_modal_mouse", text="Spot Size") props.data_path_iter = "selected_editable_objects" @@ -4437,7 +4437,7 @@ classes = ( INFO_MT_edit_curve_add, INFO_MT_edit_armature_add, INFO_MT_armature_add, - INFO_MT_lamp_add, + INFO_MT_light_add, INFO_MT_lightprobe_add, INFO_MT_camera_add, INFO_MT_add, diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 888045487f0..e6500b7c2c0 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -189,7 +189,7 @@ shader_node_categories = [ ]), ShaderNodeCategory("SH_NEW_OUTPUT", "Output", items=[ NodeItem("ShaderNodeOutputMaterial", poll=object_eevee_cycles_shader_nodes_poll), - NodeItem("ShaderNodeOutputLamp", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeOutputLight", poll=object_cycles_shader_nodes_poll), NodeItem("ShaderNodeOutputWorld", poll=world_shader_nodes_poll), NodeItem("ShaderNodeOutputLineStyle", poll=line_style_shader_nodes_poll), NodeItem("NodeGroupOutput", poll=group_input_output_item_poll), diff --git a/release/scripts/templates_py/background_job.py b/release/scripts/templates_py/background_job.py index 2f444641a51..020dabeb258 100644 --- a/release/scripts/templates_py/background_job.py +++ b/release/scripts/templates_py/background_job.py @@ -42,11 +42,11 @@ def example_function(text, save_path, render_path): scene.camera = cam_ob # set the active camera cam_ob.location = 0.0, 0.0, 10.0 - # Lamp - lamp_data = bpy.data.lamps.new("MyLamp", 'POINT') - lamp_ob = bpy.data.objects.new(name="MyCam", object_data=lamp_data) - scene.objects.link(lamp_ob) - lamp_ob.location = 2.0, 2.0, 5.0 + # Light + light_data = bpy.data.lights.new("MyLight", 'POINT') + light_ob = bpy.data.objects.new(name="MyCam", object_data=light_data) + scene.objects.link(light_ob) + light_ob.location = 2.0, 2.0, 5.0 if save_path: bpy.ops.wm.save_as_mainfile(filepath=save_path) diff --git a/release/scripts/templates_py/manipulator_custom_geometry.py b/release/scripts/templates_py/manipulator_custom_geometry.py index 48bb6956f85..de324a909db 100644 --- a/release/scripts/templates_py/manipulator_custom_geometry.py +++ b/release/scripts/templates_py/manipulator_custom_geometry.py @@ -1,6 +1,6 @@ # Example of a custom widget that defines it's own geometry. # -# Usage: Select a lamp in the 3D view and drag the arrow at it's rear +# Usage: Select a light in the 3D view and drag the arrow at it's rear # to change it's energy value. # import bpy @@ -75,7 +75,7 @@ class MyCustomShapeWidget(Manipulator): ) def _update_offset_matrix(self): - # offset behind the lamp + # offset behind the light self.matrix_offset.col[3][2] = self.target_get_value("offset") / -10.0 def draw(self, context): @@ -113,8 +113,8 @@ class MyCustomShapeWidget(Manipulator): class MyCustomShapeWidgetGroup(ManipulatorGroup): - bl_idname = "OBJECT_WGT_lamp_test" - bl_label = "Test Lamp Widget" + bl_idname = "OBJECT_WGT_light_test" + bl_label = "Test Light Widget" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' bl_options = {'3D', 'PERSISTENT'} @@ -122,10 +122,10 @@ class MyCustomShapeWidgetGroup(ManipulatorGroup): @classmethod def poll(cls, context): ob = context.object - return (ob and ob.type == 'LAMP') + return (ob and ob.type == 'LIGHT') def setup(self, context): - # Assign the 'offset' target property to the lamp energy. + # Assign the 'offset' target property to the light energy. ob = context.object mpr = self.manipulators.new(MyCustomShapeWidget.bl_idname) mpr.target_set_prop("offset", ob.data, "energy") diff --git a/release/scripts/templates_py/manipulator_simple.py b/release/scripts/templates_py/manipulator_simple.py index 8ddb870cd13..cb10a8b94bb 100644 --- a/release/scripts/templates_py/manipulator_simple.py +++ b/release/scripts/templates_py/manipulator_simple.py @@ -1,7 +1,7 @@ # Example of a group that edits a single property # using the predefined manipulator arrow. # -# Usage: Select a lamp in the 3D view and drag the arrow at it's rear +# Usage: Select a light in the 3D view and drag the arrow at it's rear # to change it's energy value. # import bpy @@ -10,9 +10,9 @@ from bpy.types import ( ) -class MyLampWidgetGroup(ManipulatorGroup): - bl_idname = "OBJECT_WGT_lamp_test" - bl_label = "Test Lamp Widget" +class MyLightWidgetGroup(ManipulatorGroup): + bl_idname = "OBJECT_WGT_light_test" + bl_label = "Test Light Widget" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' bl_options = {'3D', 'PERSISTENT'} @@ -20,10 +20,10 @@ class MyLampWidgetGroup(ManipulatorGroup): @classmethod def poll(cls, context): ob = context.object - return (ob and ob.type == 'LAMP') + return (ob and ob.type == 'LIGHT') def setup(self, context): - # Arrow manipulator has one 'offset' property we can assign to the lamp energy. + # Arrow manipulator has one 'offset' property we can assign to the light energy. ob = context.object mpr = self.manipulators.new("MANIPULATOR_WT_arrow_3d") mpr.target_set_prop("offset", ob.data, "energy") @@ -44,4 +44,4 @@ class MyLampWidgetGroup(ManipulatorGroup): mpr.matrix_basis = ob.matrix_world.normalized() -bpy.utils.register_class(MyLampWidgetGroup) +bpy.utils.register_class(MyLightWidgetGroup) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 9eb026b1c4f..13d6fd10eaa 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -733,7 +733,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, c #define SH_NODE_OUTPUT_MATERIAL 124 #define SH_NODE_OUTPUT_WORLD 125 -#define SH_NODE_OUTPUT_LAMP 126 +#define SH_NODE_OUTPUT_LIGHT 126 #define SH_NODE_FRESNEL 127 #define SH_NODE_MIX_SHADER 128 #define SH_NODE_ATTRIBUTE 129 diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 0edeaab8900..8328d71128a 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -67,7 +67,7 @@ static IDType idtypes[] = { { ID_IM, "Image", "images", BLT_I18NCONTEXT_ID_IMAGE, IDTYPE_FLAGS_ISLINKABLE }, { ID_IP, "Ipo", "ipos", "", IDTYPE_FLAGS_ISLINKABLE }, /* deprecated */ { ID_KE, "Key", "shape_keys", BLT_I18NCONTEXT_ID_SHAPEKEY, 0 }, - { ID_LA, "Lamp", "lamps", BLT_I18NCONTEXT_ID_LAMP, IDTYPE_FLAGS_ISLINKABLE }, + { ID_LA, "Light", "lights", BLT_I18NCONTEXT_ID_LAMP, IDTYPE_FLAGS_ISLINKABLE }, { ID_LI, "Library", "libraries", BLT_I18NCONTEXT_ID_LIBRARY, 0 }, { ID_LS, "FreestyleLineStyle", "linestyles", BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, IDTYPE_FLAGS_ISLINKABLE }, { ID_LT, "Lattice", "lattices", BLT_I18NCONTEXT_ID_LATTICE, IDTYPE_FLAGS_ISLINKABLE }, diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index f8040f0cf24..b7ca73e9f4a 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1999,7 +1999,7 @@ void do_versions_ipos_to_animato(Main *bmain) for (id = bmain->lamp.first; id; id = id->next) { Lamp *la = (Lamp *)id; - if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name + 2); + if (G.debug & G_DEBUG) printf("\tconverting light %s\n", id->name + 2); /* we're only interested in the IPO */ if (la->ipo) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0418634c704..a7c13ab2a81 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -653,7 +653,7 @@ static const char *get_obdata_defname(int type) case OB_FONT: return DATA_("Text"); case OB_MBALL: return DATA_("Mball"); case OB_CAMERA: return DATA_("Camera"); - case OB_LAMP: return DATA_("Lamp"); + case OB_LAMP: return DATA_("Light"); case OB_LATTICE: return DATA_("Lattice"); case OB_ARMATURE: return DATA_("Armature"); case OB_SPEAKER: return DATA_("Speaker"); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index a382b7cca9c..ced6e967acf 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -389,7 +389,7 @@ Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce { const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId(); if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) { - fprintf(stderr, "Couldn't find lamp by UID.\n"); + fprintf(stderr, "Couldn't find light by UID.\n"); return NULL; } @@ -1122,7 +1122,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) else lamp = (Lamp *)BKE_lamp_add(bmain, (char *)la_id.c_str()); if (!lamp) { - fprintf(stderr, "Cannot create lamp.\n"); + fprintf(stderr, "Cannot create light.\n"); return true; } @@ -1234,7 +1234,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) break; case COLLADAFW::Light::UNDEFINED: { - fprintf(stderr, "Current lamp type is not supported.\n"); + fprintf(stderr, "Current light type is not supported.\n"); lamp->type = LA_LOCAL; } break; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index f64c4f5aff0..1e0420ef6bc 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -679,7 +679,7 @@ void DepsgraphRelationBuilder::build_object_data_lamp(Object *object) build_lamp(lamp); ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS); ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS); - add_relation(lamp_parameters_key, object_parameters_key, "Lamp -> Object"); + add_relation(lamp_parameters_key, object_parameters_key, "Light -> Object"); } void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object) @@ -1968,7 +1968,7 @@ void DepsgraphRelationBuilder::build_lamp(Lamp *lamp) build_nodetree(lamp->nodetree); ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS); ComponentKey nodetree_key(&lamp->nodetree->id, DEG_NODE_TYPE_SHADING); - add_relation(nodetree_key, lamp_parameters_key, "NTree->Lamp Parameters"); + add_relation(nodetree_key, lamp_parameters_key, "NTree->Light Parameters"); build_nested_nodetree(&lamp->id, lamp->nodetree); } } diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index 880519911ed..2b1bd9fbce3 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -334,7 +334,7 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob) /* Step 1 find all lamps in the scene and setup them */ if (linfo->num_light >= MAX_LIGHT) { - printf("Too many lamps in the scene !!!\n"); + printf("Too many lights in the scene !!!\n"); } else { Lamp *la = (Lamp *)ob->data; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 6bd333294c5..5bbaabcc6bc 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -638,7 +638,7 @@ static int acf_object_icon(bAnimListElem *ale) /* icon depends on object-type */ switch (ob->type) { case OB_LAMP: - return ICON_OUTLINER_OB_LAMP; + return ICON_OUTLINER_OB_LIGHT; case OB_MESH: return ICON_OUTLINER_OB_MESH; case OB_CAMERA: @@ -1452,16 +1452,16 @@ static bAnimChannelType ACF_DSMAT = acf_dsmat_setting_ptr /* pointer for setting */ }; -/* Lamp Expander ------------------------------------------- */ +/* Light Expander ------------------------------------------- */ // TODO: just get this from RNA? -static int acf_dslam_icon(bAnimListElem *UNUSED(ale)) +static int acf_dslight_icon(bAnimListElem *UNUSED(ale)) { - return ICON_LAMP_DATA; + return ICON_LIGHT_DATA; } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg) +static int acf_dslight_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg) { /* clear extra return data first */ *neg = false; @@ -1486,7 +1486,7 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting } /* get pointer to the setting */ -static void *acf_dslam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) +static void *acf_dslight_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Lamp *la = (Lamp *)ale->data; @@ -1510,9 +1510,9 @@ static void *acf_dslam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set } /* lamp expander type define */ -static bAnimChannelType ACF_DSLAM = +static bAnimChannelType ACF_DSLIGHT = { - "Lamp Expander", /* type name */ + "Light Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ acf_generic_dataexpand_color, /* backdrop color */ @@ -1521,12 +1521,12 @@ static bAnimChannelType ACF_DSLAM = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_name_prop, /* name prop */ - acf_dslam_icon, /* icon */ + acf_generic_idblock_name_prop, /* name prop */ + acf_dslight_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dslam_setting_flag, /* flag for setting */ - acf_dslam_setting_ptr /* pointer for setting */ + acf_dslight_setting_flag, /* flag for setting */ + acf_dslight_setting_ptr /* pointer for setting */ }; /* Texture Expander ------------------------------------------- */ @@ -3580,7 +3580,7 @@ static void ANIM_init_channel_typeinfo_data(void) animchannelTypeInfo[type++] = &ACF_FILLDRIVERS; /* Drivers Expander */ animchannelTypeInfo[type++] = &ACF_DSMAT; /* Material Channel */ - animchannelTypeInfo[type++] = &ACF_DSLAM; /* Lamp Channel */ + animchannelTypeInfo[type++] = &ACF_DSLIGHT; /* Light Channel */ animchannelTypeInfo[type++] = &ACF_DSCAM; /* Camera Channel */ animchannelTypeInfo[type++] = &ACF_DSCACHEFILE; /* CacheFile Channel */ animchannelTypeInfo[type++] = &ACF_DSCUR; /* Curve Channel */ diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 4c67a306e75..68318835a00 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -119,7 +119,7 @@ DEF_ICON(FULLSCREEN_EXIT) DEF_ICON(BLANK1) // Not actually blank - this is used all over the place /* BUTTONS */ -DEF_ICON(LAMP) +DEF_ICON(LIGHT) DEF_ICON(MATERIAL) DEF_ICON(TEXTURE) DEF_ICON(ANIM) @@ -216,7 +216,7 @@ DEF_ICON(MESH_DATA) DEF_ICON(CURVE_DATA) DEF_ICON(META_DATA) DEF_ICON(LATTICE_DATA) -DEF_ICON(LAMP_DATA) +DEF_ICON(LIGHT_DATA) DEF_ICON(MATERIAL_DATA) DEF_ICON(TEXTURE_DATA) DEF_ICON(ANIM_DATA) @@ -304,7 +304,7 @@ DEF_ICON(OUTLINER_OB_MESH) DEF_ICON(OUTLINER_OB_CURVE) DEF_ICON(OUTLINER_OB_LATTICE) DEF_ICON(OUTLINER_OB_META) -DEF_ICON(OUTLINER_OB_LAMP) +DEF_ICON(OUTLINER_OB_LIGHT) DEF_ICON(OUTLINER_OB_CAMERA) DEF_ICON(OUTLINER_OB_ARMATURE) DEF_ICON(OUTLINER_OB_FONT) @@ -336,7 +336,7 @@ DEF_ICON(OUTLINER_DATA_MESH) DEF_ICON(OUTLINER_DATA_CURVE) DEF_ICON(OUTLINER_DATA_LATTICE) DEF_ICON(OUTLINER_DATA_META) -DEF_ICON(OUTLINER_DATA_LAMP) +DEF_ICON(OUTLINER_DATA_LIGHT) DEF_ICON(OUTLINER_DATA_CAMERA) DEF_ICON(OUTLINER_DATA_ARMATURE) DEF_ICON(OUTLINER_DATA_FONT) @@ -377,11 +377,11 @@ DEF_ICON(MESH_CAPSULE) #ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK611) #endif -DEF_ICON(LAMP_POINT) -DEF_ICON(LAMP_SUN) -DEF_ICON(LAMP_SPOT) -DEF_ICON(LAMP_HEMI) -DEF_ICON(LAMP_AREA) +DEF_ICON(LIGHT_POINT) +DEF_ICON(LIGHT_SUN) +DEF_ICON(LIGHT_SPOT) +DEF_ICON(LIGHT_HEMI) +DEF_ICON(LIGHT_AREA) #ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK617) DEF_ICON(BLANK618) diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index c3246213d4e..4748ff3310a 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1554,7 +1554,7 @@ int UI_idcode_icon_get(const int idcode) case ID_IM: return ICON_IMAGE_DATA; case ID_LA: - return ICON_LAMP_DATA; + return ICON_LIGHT_DATA; case ID_LS: return ICON_LINE_DATA; case ID_LT: diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1c3ed3e3c75..f80e4e486d6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -518,7 +518,7 @@ static const char *template_id_browse_tip(const StructRNA *type) case ID_IM: return N_("Browse Image to be linked"); case ID_LS: return N_("Browse Line Style Data to be linked"); case ID_LT: return N_("Browse Lattice Data to be linked"); - case ID_LA: return N_("Browse Lamp Data to be linked"); + case ID_LA: return N_("Browse Light Data to be linked"); case ID_CA: return N_("Browse Camera Data to be linked"); case ID_WO: return N_("Browse World Settings to be linked"); case ID_SCR: return N_("Choose Screen layout"); @@ -1863,7 +1863,7 @@ void uiTemplatePreview( char _preview_id[UI_MAX_NAME_STR]; if (id && !ELEM(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA, ID_LS)) { - RNA_warning("Expected ID of type material, texture, lamp, world or line style"); + RNA_warning("Expected ID of type material, texture, light, world or line style"); return; } @@ -1954,7 +1954,7 @@ void uiTemplatePreview( pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); } else if (GS(parent->name) == ID_LA) { - uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Lamp"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, + uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Light"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); } else if (GS(parent->name) == ID_WO) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index a8c3c905dd4..a8917f4c4aa 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -120,12 +120,12 @@ /* this is an exact copy of the define in rna_lamp.c * kept here because of linking order. * Icons are only defined here */ -const EnumPropertyItem rna_enum_lamp_type_items[] = { - {LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source"}, - {LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source"}, - {LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source"}, - {LA_HEMI, "HEMI", ICON_LAMP_HEMI, "Hemi", "180 degree constant light source"}, - {LA_AREA, "AREA", ICON_LAMP_AREA, "Area", "Directional area light source"}, +const EnumPropertyItem rna_enum_light_type_items[] = { + {LA_LOCAL, "POINT", ICON_LIGHT_POINT, "Point", "Omnidirectional point light source"}, + {LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"}, + {LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"}, + {LA_HEMI, "HEMI", ICON_LIGHT_HEMI, "Hemi", "180 degree constant light source"}, + {LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"}, {0, NULL, 0, NULL, NULL} }; @@ -985,9 +985,9 @@ void OBJECT_OT_drop_named_image(wmOperatorType *ot) ED_object_add_generic_props(ot, false); } -/********************* Add Lamp Operator ********************/ +/********************* Add Light Operator ********************/ -static const char *get_lamp_defname(int type) +static const char *get_light_defname(int type) { switch (type) { case LA_LOCAL: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Point"); @@ -996,11 +996,11 @@ static const char *get_lamp_defname(int type) case LA_HEMI: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Hemi"); case LA_AREA: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Area"); default: - return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Lamp"); + return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Light"); } } -static int object_lamp_add_exec(bContext *C, wmOperator *op) +static int object_light_add_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Object *ob; @@ -1013,10 +1013,10 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &layer, NULL)) return OPERATOR_CANCELLED; - ob = ED_object_add_type(C, OB_LAMP, get_lamp_defname(type), loc, rot, false, layer); + ob = ED_object_add_type(C, OB_LAMP, get_light_defname(type), loc, rot, false, layer); float size = RNA_float_get(op->ptr, "radius"); - /* Better defaults for lamp size. */ + /* Better defaults for light size. */ switch (type) { case LA_LOCAL: case LA_SPOT: @@ -1041,23 +1041,23 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void OBJECT_OT_lamp_add(wmOperatorType *ot) +void OBJECT_OT_light_add(wmOperatorType *ot) { /* identifiers */ - ot->name = "Add Lamp"; - ot->description = "Add a lamp object to the scene"; - ot->idname = "OBJECT_OT_lamp_add"; + ot->name = "Add Light"; + ot->description = "Add a light object to the scene"; + ot->idname = "OBJECT_OT_light_add"; /* api callbacks */ ot->invoke = WM_menu_invoke; - ot->exec = object_lamp_add_exec; + ot->exec = object_light_add_exec; ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_lamp_type_items, 0, "Type", ""); + ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_light_type_items, 0, "Type", ""); RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_LAMP); ED_object_add_unit_props(ot); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index b1ea6d72346..1b5c6df2632 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -115,7 +115,7 @@ void OBJECT_OT_armature_add(struct wmOperatorType *ot); void OBJECT_OT_empty_add(struct wmOperatorType *ot); void OBJECT_OT_lightprobe_add(struct wmOperatorType *ot); void OBJECT_OT_drop_named_image(struct wmOperatorType *ot); -void OBJECT_OT_lamp_add(struct wmOperatorType *ot); +void OBJECT_OT_light_add(struct wmOperatorType *ot); void OBJECT_OT_effector_add(struct wmOperatorType *ot); void OBJECT_OT_camera_add(struct wmOperatorType *ot); void OBJECT_OT_speaker_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 43d993531bc..5a83d085aee 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -114,7 +114,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_empty_add); WM_operatortype_append(OBJECT_OT_lightprobe_add); WM_operatortype_append(OBJECT_OT_drop_named_image); - WM_operatortype_append(OBJECT_OT_lamp_add); + WM_operatortype_append(OBJECT_OT_light_add); WM_operatortype_append(OBJECT_OT_camera_add); WM_operatortype_append(OBJECT_OT_speaker_add); WM_operatortype_append(OBJECT_OT_add); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index b1dee812f45..d5f7a93cc6e 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -485,7 +485,7 @@ enum { OBJECT_GRPSEL_PASS = 8, OBJECT_GRPSEL_COLOR = 9, OBJECT_GRPSEL_KEYINGSET = 10, - OBJECT_GRPSEL_LAMP_TYPE = 11, + OBJECT_GRPSEL_LIGHT_TYPE = 11, }; static const EnumPropertyItem prop_select_grouped_types[] = { @@ -499,7 +499,7 @@ static const EnumPropertyItem prop_select_grouped_types[] = { {OBJECT_GRPSEL_PASS, "PASS", 0, "Pass", "Render pass Index"}, {OBJECT_GRPSEL_COLOR, "COLOR", 0, "Color", "Object Color"}, {OBJECT_GRPSEL_KEYINGSET, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"}, - {OBJECT_GRPSEL_LAMP_TYPE, "LAMP_TYPE", 0, "Lamp Type", "Matching lamp types"}, + {OBJECT_GRPSEL_LIGHT_TYPE, "LIGHT_TYPE", 0, "Light Type", "Matching light types"}, {0, NULL, 0, NULL, NULL} }; @@ -803,9 +803,9 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) case OBJECT_GRPSEL_KEYINGSET: changed |= select_grouped_keyingset(C, ob, op->reports); break; - case OBJECT_GRPSEL_LAMP_TYPE: + case OBJECT_GRPSEL_LIGHT_TYPE: if (ob->type != OB_LAMP) { - BKE_report(op->reports, RPT_ERROR, "Active object must be a lamp"); + BKE_report(op->reports, RPT_ERROR, "Active object must be a light"); break; } changed |= select_grouped_lamptype(C, ob); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 721d248ae4c..d2a0879464b 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -485,7 +485,7 @@ static int apply_objects_internal( if (la->type == LA_AREA) { if (apply_rot || apply_loc) { BKE_reportf(reports, RPT_ERROR, - "Area Lamps can only have scale applied: \"%s\"", + "Area Lights can only have scale applied: \"%s\"", ob->id.name + 2); changed = false; } @@ -1540,8 +1540,8 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const void OBJECT_OT_transform_axis_target(wmOperatorType *ot) { /* identifiers */ - ot->name = "Interactive Lamp Track to Cursor"; - ot->description = "Interactively point cameras and lamps to a location (Ctrl translates)"; + ot->name = "Interactive Light Track to Cursor"; + ot->description = "Interactively point cameras and lights to a location (Ctrl translates)"; ot->idname = "OBJECT_OT_transform_axis_target"; /* api callbacks */ diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index ae364828119..d6a968d993c 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -427,7 +427,7 @@ static void make_renderinfo_string(const RenderStats *rs, if (rs->totface) spos += sprintf(spos, IFACE_("Fa:%d "), rs->totface); if (rs->tothalo) spos += sprintf(spos, IFACE_("Ha:%d "), rs->tothalo); if (rs->totstrand) spos += sprintf(spos, IFACE_("St:%d "), rs->totstrand); - if (rs->totlamp) spos += sprintf(spos, IFACE_("La:%d "), rs->totlamp); + if (rs->totlamp) spos += sprintf(spos, IFACE_("Li:%d "), rs->totlamp); if (rs->mem_peak == 0.0f) spos += sprintf(spos, IFACE_("| Mem:%.2fM (%.2fM, Peak %.2fM) "), diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 07e0c124998..1673e0d7ca0 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -1654,7 +1654,7 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op)) if (id == NULL) { Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data; - Lamp *la = CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data; + Lamp *la = CTX_data_pointer_get_type(C, "light", &RNA_Light).data; World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data; ParticleSystem *psys = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data; FreestyleLineStyle *linestyle = CTX_data_pointer_get_type(C, "line_style", &RNA_FreestyleLineStyle).data; diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 4c6de3ec012..faee9c2b7ac 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -234,7 +234,7 @@ static int buttons_context_path_data(ButsContextPath *path, int type) else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1; else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1; else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Lamp) && (type == -1 || type == OB_LAMP)) return 1; + else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) return 1; else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1; else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) return 1; /* try to get an object in the path, no pinning supported here */ @@ -679,7 +679,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) const char *buttons_context_dir[] = { "texture_slot", "scene", "world", "object", "mesh", "armature", "lattice", "curve", - "meta_ball", "lamp", "speaker", "lightprobe", "camera", "material", "material_slot", + "meta_ball", "light", "speaker", "lightprobe", "camera", "material", "material_slot", "texture", "texture_user", "texture_user_property", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable", "particle_settings", "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", @@ -736,8 +736,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r set_pointer_type(path, result, &RNA_MetaBall); return 1; } - else if (CTX_data_equals(member, "lamp")) { - set_pointer_type(path, result, &RNA_Lamp); + else if (CTX_data_equals(member, "light")) { + set_pointer_type(path, result, &RNA_Light); return 1; } else if (CTX_data_equals(member, "camera")) { diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 09e2660a762..968757bc637 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -2357,7 +2357,7 @@ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist) filelist->filelist.entries[9].entry->relpath = BLI_strdup("Ika"); filelist->filelist.entries[10].entry->relpath = BLI_strdup("Wave"); filelist->filelist.entries[11].entry->relpath = BLI_strdup("Lattice"); - filelist->filelist.entries[12].entry->relpath = BLI_strdup("Lamp"); + filelist->filelist.entries[12].entry->relpath = BLI_strdup("Light"); filelist->filelist.entries[13].entry->relpath = BLI_strdup("Camera"); filelist->filelist.entries[14].entry->relpath = BLI_strdup("Ipo"); filelist->filelist.entries[15].entry->relpath = BLI_strdup("World"); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index d7015ed5e53..118a14c887d 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1215,7 +1215,7 @@ static void node_shader_set_butfunc(bNodeType *ntype) ntype->draw_buttons = node_shader_buts_uvalongstroke; break; case SH_NODE_OUTPUT_MATERIAL: - case SH_NODE_OUTPUT_LAMP: + case SH_NODE_OUTPUT_LIGHT: case SH_NODE_OUTPUT_WORLD: ntype->draw_buttons = node_buts_output_shader; break; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index cc32e5ef499..1a6710035c2 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -424,7 +424,7 @@ void ED_node_shader_default(const bContext *C, ID *id) Lamp *la = (Lamp *)id; la->nodetree = ntree; - output_type = SH_NODE_OUTPUT_LAMP; + output_type = SH_NODE_OUTPUT_LIGHT; shader_type = SH_NODE_EMISSION; copy_v3_v3(color, &la->r); @@ -628,7 +628,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) nodeClearActiveID(ntree, ID_TE); if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, - SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LAMP, SH_NODE_OUTPUT_LINESTYLE)) + SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT, SH_NODE_OUTPUT_LINESTYLE)) { bNode *tnode; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index ed4853f5ede..c829b808348 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1141,7 +1141,7 @@ static void tselem_draw_icon( ICON_DRAW(ICON_RENDER_RESULT); break; case TSE_LINKED_LAMP: - ICON_DRAW(ICON_LAMP_DATA); + ICON_DRAW(ICON_LIGHT_DATA); break; case TSE_LINKED_MAT: ICON_DRAW(ICON_MATERIAL_DATA); @@ -1200,7 +1200,7 @@ static void tselem_draw_icon( Object *ob = (Object *)tselem->id; switch (ob->type) { case OB_LAMP: - ICON_CLICK_DRAW(ICON_OUTLINER_OB_LAMP); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_LIGHT); break; case OB_MESH: ICON_CLICK_DRAW(ICON_OUTLINER_OB_MESH); break; case OB_CAMERA: @@ -1251,17 +1251,17 @@ static void tselem_draw_icon( Lamp *la = (Lamp *)tselem->id; switch (la->type) { case LA_LOCAL: - tselem_draw_icon_uibut(&arg, ICON_LAMP_POINT); break; + tselem_draw_icon_uibut(&arg, ICON_LIGHT_POINT); break; case LA_SUN: - tselem_draw_icon_uibut(&arg, ICON_LAMP_SUN); break; + tselem_draw_icon_uibut(&arg, ICON_LIGHT_SUN); break; case LA_SPOT: - tselem_draw_icon_uibut(&arg, ICON_LAMP_SPOT); break; + tselem_draw_icon_uibut(&arg, ICON_LIGHT_SPOT); break; case LA_HEMI: - tselem_draw_icon_uibut(&arg, ICON_LAMP_HEMI); break; + tselem_draw_icon_uibut(&arg, ICON_LIGHT_HEMI); break; case LA_AREA: - tselem_draw_icon_uibut(&arg, ICON_LAMP_AREA); break; + tselem_draw_icon_uibut(&arg, ICON_LIGHT_AREA); break; default: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LAMP); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LIGHT); break; } break; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 15d241a88cc..83189159086 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1050,11 +1050,11 @@ static void view3d_main_region_message_subscribe( &RNA_Window, /* These object have properties that impact drawing. */ - &RNA_AreaLamp, + &RNA_AreaLight, &RNA_Camera, - &RNA_Lamp, + &RNA_Light, &RNA_Speaker, - &RNA_SunLamp, + &RNA_SunLight, /* General types the 3D view depends on. */ &RNA_Object, diff --git a/source/blender/editors/space_view3d/view3d_manipulator_empty.c b/source/blender/editors/space_view3d/view3d_manipulator_empty.c index 75e4a9e3314..fc15ec593f5 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_empty.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_empty.c @@ -186,7 +186,7 @@ static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGrou void VIEW3D_WGT_empty_image(wmManipulatorGroupType *wgt) { - wgt->name = "Area Lamp Widgets"; + wgt->name = "Area Light Widgets"; wgt->idname = "VIEW3D_WGT_empty_image"; wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c index f98a2f336bc..0e1015a66f1 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c @@ -99,13 +99,13 @@ static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup /* need to set property here for undo. TODO would prefer to do this in _init */ PointerRNA lamp_ptr; const char *propname = "spot_size"; - RNA_pointer_create(&la->id, &RNA_Lamp, la, &lamp_ptr); + RNA_pointer_create(&la->id, &RNA_Light, la, &lamp_ptr); WM_manipulator_target_property_def_rna(mpr, "offset", &lamp_ptr, propname, -1); } void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt) { - wgt->name = "Spot Lamp Widgets"; + wgt->name = "Spot Light Widgets"; wgt->idname = "VIEW3D_WGT_lamp_spot"; wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | @@ -213,7 +213,7 @@ static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt) { - wgt->name = "Area Lamp Widgets"; + wgt->name = "Area Light Widgets"; wgt->idname = "VIEW3D_WGT_lamp_area"; wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | @@ -291,7 +291,7 @@ static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulato void VIEW3D_WGT_lamp_target(wmManipulatorGroupType *wgt) { - wgt->name = "Target Lamp Widgets"; + wgt->name = "Target Light Widgets"; wgt->idname = "VIEW3D_WGT_lamp_target"; wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 06bbde0497c..fe8868235c4 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -69,7 +69,7 @@ extern StructRNA RNA_AnimVizMotionPaths; extern StructRNA RNA_AnimVizOnionSkinning; extern StructRNA RNA_AnyType; extern StructRNA RNA_Area; -extern StructRNA RNA_AreaLamp; +extern StructRNA RNA_AreaLight; extern StructRNA RNA_Armature; extern StructRNA RNA_ArmatureModifier; extern StructRNA RNA_ArmatureSensor; @@ -281,7 +281,7 @@ extern StructRNA RNA_GaussianBlurSequence; extern StructRNA RNA_GlowSequence; extern StructRNA RNA_GreasePencil; extern StructRNA RNA_Header; -extern StructRNA RNA_HemiLamp; +extern StructRNA RNA_HemiLight; extern StructRNA RNA_Histogram; extern StructRNA RNA_HookModifier; extern StructRNA RNA_ID; @@ -312,9 +312,9 @@ extern StructRNA RNA_KeyingSetInfo; extern StructRNA RNA_KeyingSetPath; extern StructRNA RNA_KeyingSetsAll; extern StructRNA RNA_KinematicConstraint; -extern StructRNA RNA_Lamp; -extern StructRNA RNA_LampSkySettings; -extern StructRNA RNA_LampTextureSlot; +extern StructRNA RNA_Light; +extern StructRNA RNA_LightSkySettings; +extern StructRNA RNA_LightTextureSlot; extern StructRNA RNA_LaplacianDeformModifier; extern StructRNA RNA_LaplacianSmoothModifier; extern StructRNA RNA_Lattice; @@ -476,7 +476,7 @@ extern StructRNA RNA_ParticleSystemModifier; extern StructRNA RNA_ParticleTarget; extern StructRNA RNA_PivotConstraint; extern StructRNA RNA_PointCache; -extern StructRNA RNA_PointLamp; +extern StructRNA RNA_PointLight; extern StructRNA RNA_PointerProperty; extern StructRNA RNA_Pose; extern StructRNA RNA_PoseBone; @@ -529,7 +529,7 @@ extern StructRNA RNA_ShaderNodeGeometry; extern StructRNA RNA_ShaderNodeHueSaturation; extern StructRNA RNA_ShaderNodeIESLight; extern StructRNA RNA_ShaderNodeInvert; -extern StructRNA RNA_ShaderNodeLampData; +extern StructRNA RNA_ShaderNodeLightData; extern StructRNA RNA_ShaderNodeMapping; extern StructRNA RNA_ShaderNodeMaterial; extern StructRNA RNA_ShaderNodeMath; @@ -588,7 +588,7 @@ extern StructRNA RNA_Speaker; extern StructRNA RNA_SpeedControlSequence; extern StructRNA RNA_Spline; extern StructRNA RNA_SplineIKConstraint; -extern StructRNA RNA_SpotLamp; +extern StructRNA RNA_SpotLight; extern StructRNA RNA_Stereo3dDisplay; extern StructRNA RNA_StretchToConstraint; extern StructRNA RNA_StringProperty; @@ -596,7 +596,7 @@ extern StructRNA RNA_Struct; extern StructRNA RNA_StucciTexture; extern StructRNA RNA_StudioLight; extern StructRNA RNA_SubsurfModifier; -extern StructRNA RNA_SunLamp; +extern StructRNA RNA_SunLight; extern StructRNA RNA_SurfaceCurve; extern StructRNA RNA_SurfaceDeformModifier; extern StructRNA RNA_SurfaceModifier; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index ce1edba75fd..bafb2bf5753 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -129,7 +129,7 @@ extern const EnumPropertyItem rna_enum_symmetrize_direction_items[]; extern const EnumPropertyItem rna_enum_texture_type_items[]; -extern const EnumPropertyItem rna_enum_lamp_type_items[]; +extern const EnumPropertyItem rna_enum_light_type_items[]; extern const EnumPropertyItem rna_enum_unpack_method_items[]; diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 1dd4535610c..4b06d917ab7 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3407,7 +3407,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_group.c", NULL, RNA_def_collections}, {"rna_image.c", "rna_image_api.c", RNA_def_image}, {"rna_key.c", NULL, RNA_def_key}, - {"rna_lamp.c", NULL, RNA_def_lamp}, + {"rna_lamp.c", NULL, RNA_def_light}, {"rna_lattice.c", "rna_lattice_api.c", RNA_def_lattice}, {"rna_layer.c", NULL, RNA_def_view_layer}, {"rna_linestyle.c", NULL, RNA_def_linestyle}, diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index a2648d7db02..0a294bfaab9 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -61,7 +61,7 @@ const EnumPropertyItem rna_enum_id_type_items[] = { {ID_GR, "COLLECTION", ICON_GROUP, "Collection", ""}, {ID_IM, "IMAGE", ICON_IMAGE_DATA, "Image", ""}, {ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""}, - {ID_LA, "LAMP", ICON_LAMP_DATA, "Lamp", ""}, + {ID_LA, "LIGHT", ICON_LIGHT_DATA, "Light", ""}, {ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""}, {ID_LS, "LINESTYLE", ICON_LINE_DATA, "Line Style", ""}, {ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""}, @@ -183,7 +183,7 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_Collection) return ID_GR; if (base_type == &RNA_Image) return ID_IM; if (base_type == &RNA_Key) return ID_KE; - if (base_type == &RNA_Lamp) return ID_LA; + if (base_type == &RNA_Light) return ID_LA; if (base_type == &RNA_Library) return ID_LI; if (base_type == &RNA_FreestyleLineStyle) return ID_LS; if (base_type == &RNA_Lattice) return ID_LT; @@ -227,7 +227,7 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_GR: return &RNA_Collection; case ID_IM: return &RNA_Image; case ID_KE: return &RNA_Key; - case ID_LA: return &RNA_Lamp; + case ID_LA: return &RNA_Light; case ID_LI: return &RNA_Library; case ID_LS: return &RNA_FreestyleLineStyle; case ID_LT: return &RNA_Lattice; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 638589c104a..7228f4a4683 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -620,7 +620,7 @@ StructRNA *RNA_struct_base(StructRNA *type) /** * Use to find the subtype directly below a base-type. * - * So if type were `RNA_SpotLamp`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Lamp`. + * So if type were `RNA_SpotLIght`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Light`. */ const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type) { diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 97c9d5a9866..12e28d457fb 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -423,10 +423,10 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_lights", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM); - RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of lamp related animation data"); - RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0); + RNA_def_property_ui_text(prop, "Display Light", "Include visualization of light related animation data"); + RNA_def_property_ui_icon(prop, ICON_LIGHT_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_linestyles", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 8b59d46aaf8..a57777f0630 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -155,7 +155,7 @@ void RNA_def_fcurve(struct BlenderRNA *brna); void RNA_def_gpencil(struct BlenderRNA *brna); void RNA_def_image(struct BlenderRNA *brna); void RNA_def_key(struct BlenderRNA *brna); -void RNA_def_lamp(struct BlenderRNA *brna); +void RNA_def_light(struct BlenderRNA *brna); void RNA_def_lattice(struct BlenderRNA *brna); void RNA_def_linestyle(struct BlenderRNA *brna); void RNA_def_main(struct BlenderRNA *brna); @@ -283,7 +283,7 @@ void rna_TextureSlot_update(struct bContext *C, struct PointerRNA *ptr); bool rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Camera_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Curve_object_poll(struct PointerRNA *ptr, struct PointerRNA value); -bool rna_Lamp_object_poll(struct PointerRNA *ptr, struct PointerRNA value); +bool rna_Light_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Lattice_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Mesh_object_poll(struct PointerRNA *ptr, struct PointerRNA value); @@ -354,7 +354,7 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop); -void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_lights(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index dff27e1c625..1fb76a93e27 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -20,7 +20,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/makesrna/intern/rna_lamp.c +/** \file blender/makesrna/intern/rna_light.c * \ingroup RNA */ @@ -54,7 +54,7 @@ #include "WM_api.h" #include "WM_types.h" -static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value) +static void rna_Light_buffer_size_set(PointerRNA *ptr, int value) { Lamp *la = (Lamp *)ptr->data; @@ -63,27 +63,27 @@ static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value) la->bufsize &= (~15); /* round to multiple of 16 */ } -static StructRNA *rna_Lamp_refine(struct PointerRNA *ptr) +static StructRNA *rna_Light_refine(struct PointerRNA *ptr) { Lamp *la = (Lamp *)ptr->data; switch (la->type) { case LA_LOCAL: - return &RNA_PointLamp; + return &RNA_PointLight; case LA_SUN: - return &RNA_SunLamp; + return &RNA_SunLight; case LA_SPOT: - return &RNA_SpotLamp; + return &RNA_SpotLight; case LA_HEMI: - return &RNA_HemiLamp; + return &RNA_HemiLight; case LA_AREA: - return &RNA_AreaLamp; + return &RNA_AreaLight; default: - return &RNA_Lamp; + return &RNA_Light; } } -static void rna_Lamp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Light_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Lamp *la = ptr->id.data; @@ -91,7 +91,7 @@ static void rna_Lamp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN WM_main_add_notifier(NC_LAMP | ND_LIGHTING, la); } -static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Light_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Lamp *la = ptr->id.data; @@ -99,19 +99,19 @@ static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, la); } -static void rna_Lamp_use_nodes_update(bContext *C, PointerRNA *ptr) +static void rna_Light_use_nodes_update(bContext *C, PointerRNA *ptr) { Lamp *la = (Lamp *)ptr->data; if (la->use_nodes && la->nodetree == NULL) ED_node_shader_default(C, &la->id); - rna_Lamp_update(CTX_data_main(C), CTX_data_scene(C), ptr); + rna_Light_update(CTX_data_main(C), CTX_data_scene(C), ptr); } #else -/* Don't define icons here, so they don't show up in the Lamp UI (properties Editor) - DingTo */ -const EnumPropertyItem rna_enum_lamp_type_items[] = { +/* Don't define icons here, so they don't show up in the Light UI (properties Editor) - DingTo */ +const EnumPropertyItem rna_enum_light_type_items[] = { {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"}, {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"}, {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"}, @@ -120,21 +120,22 @@ const EnumPropertyItem rna_enum_lamp_type_items[] = { {0, NULL, 0, NULL, NULL} }; -static void rna_def_lamp(BlenderRNA *brna) +static void rna_def_light(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "Lamp", "ID"); - RNA_def_struct_refine_func(srna, "rna_Lamp_refine"); - RNA_def_struct_ui_text(srna, "Lamp", "Lamp data-block for lighting a scene"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_DATA); + srna = RNA_def_struct(brna, "Light", "ID"); + RNA_def_struct_sdna(srna, "Lamp"); + RNA_def_struct_refine_func(srna, "rna_Light_refine"); + RNA_def_struct_ui_text(srna, "Light", "Light data-block for lighting a scene"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_DATA); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, rna_enum_lamp_type_items); - RNA_def_property_ui_text(prop, "Type", "Type of Lamp"); + RNA_def_property_enum_items(prop, rna_enum_light_type_items); + RNA_def_property_ui_text(prop, "Type", "Type of Light"); RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_LAMP); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); @@ -142,43 +143,43 @@ static void rna_def_lamp(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0, 1000, 1, 3); RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_range(prop, 0, 10, 1, 3); - RNA_def_property_ui_text(prop, "Energy", "Amount of light that the lamp emits"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_ui_text(prop, "Energy", "Amount of light emitted"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Color", "Light color"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "spec_fac"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2); RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); /* nodes */ prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); - RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lamps"); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lights"); prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); - RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the lamp"); - RNA_def_property_update(prop, 0, "rna_Lamp_use_nodes_update"); + RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the light"); + RNA_def_property_update(prop, 0, "rna_Light_use_nodes_update"); /* common */ rna_def_animdata_common(srna); } -static void rna_def_lamp_falloff(StructRNA *srna) +static void rna_def_light_falloff(StructRNA *srna) { PropertyRNA *prop; @@ -195,54 +196,54 @@ static void rna_def_lamp_falloff(StructRNA *srna) prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_fallofftype_items); RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curfalloff"); - RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_ui_text(prop, "Falloff Curve", "Custom light falloff curve"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "att1"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Linear Attenuation", "Linear distance attenuation"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "quadratic_attenuation", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "att2"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Quadratic Attenuation", "Quadratic distance attenuation"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "constant_coefficient", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "coeff_const"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Constant Coefficient", "Constant distance attenuation coefficient"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "linear_coefficient", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "coeff_lin"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Linear Coefficient", "Linear distance attenuation coefficient"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "quadratic_coefficient", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "coeff_quad"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Quadratic Coefficient", "Quadratic distance attenuation coefficient"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); } -static void rna_def_lamp_shadow(StructRNA *srna, int sun) +static void rna_def_light_shadow(StructRNA *srna, int sun) { PropertyRNA *prop; prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHADOW); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "bufsize"); @@ -250,66 +251,66 @@ static void rna_def_lamp_shadow(StructRNA *srna, int sun) RNA_def_property_ui_text(prop, "Shadow Buffer Size", "Resolution of the shadow buffer, higher values give crisper shadows " "but use more memory"); - RNA_def_property_int_funcs(prop, NULL, "rna_Lamp_buffer_size_set", NULL); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_int_funcs(prop, NULL, "rna_Light_buffer_size_set", NULL); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start", "Shadow map clip start, below which objects will not generate shadows"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipend"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip End", "Shadow map clip end, beyond which objects will not generate shadows"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bias"); RNA_def_property_range(prop, 0.001f, 9999.0f); RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3); RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Bias for reducing self shadowing"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_bleed_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bleedbias"); RNA_def_property_range(prop, 0.f, 1.f); RNA_def_property_ui_text(prop, "Shadow Buffer Bleed Bias", "Bias for reducing light-bleed on variance shadow maps"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_exp", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bleedexp"); RNA_def_property_range(prop, 1.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Exponent", "Bias for reducing light-bleed on exponential shadow maps"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_soft", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "soft"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Soft", "Size of shadow buffer sampling area"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_samples", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "samp"); RNA_def_property_range(prop, 1, 16); RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "shdwr"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the lamp"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the light"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_size"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); /* Eevee */ prop = RNA_def_property(srna, "use_contact_shadow", PROP_BOOLEAN, PROP_NONE); @@ -317,76 +318,76 @@ static void rna_def_lamp_shadow(StructRNA *srna, int sun) RNA_def_property_ui_text(prop, "Contact Shadow", "Use screen space raytracing to have correct shadowing " "near occluder, or for small features that does not appear " "in shadow maps"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "contact_shadow_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "contact_dist"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Contact Shadow Distance", "World space distance in which to search for " "screen space occluder"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "contact_shadow_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "contact_bias"); RNA_def_property_range(prop, 0.001f, 9999.0f); RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3); RNA_def_property_ui_text(prop, "Contact Shadow Bias", "Bias to avoid self shadowing"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "contact_shadow_soft_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "contact_spread"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Contact Shadow Soft", "Control how soft the contact shadows will be"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "contact_shadow_thickness", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "contact_thickness"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Contact Shadow Thickness", "Pixel thickness used to detect occlusion"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); if (sun) { prop = RNA_def_property(srna, "shadow_cascade_max_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "cascade_max_dist"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Cascade Max Distance", "End distance of the cascaded shadow map (only in perspective view)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_cascade_count", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "cascade_count"); RNA_def_property_range(prop, 1, 4); RNA_def_property_ui_text(prop, "Cascade Count", "Number of texture used by the cascaded shadow map"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_cascade_exponent", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "cascade_exponent"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Exponential Distribution", "Higher value increase resolution towards the viewpoint"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_cascade_fade", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "cascade_fade"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Cascade Fade", "How smooth is the transition between each cascade"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); } } -static void rna_def_point_lamp(BlenderRNA *brna) +static void rna_def_point_light(BlenderRNA *brna) { StructRNA *srna; - srna = RNA_def_struct(brna, "PointLamp", "Lamp"); + srna = RNA_def_struct(brna, "PointLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Point Lamp", "Omnidirectional point lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_POINT); + RNA_def_struct_ui_text(srna, "Point Light", "Omnidirectional point Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_POINT); - rna_def_lamp_falloff(srna); - rna_def_lamp_shadow(srna, 0); + rna_def_light_falloff(srna); + rna_def_light_shadow(srna, 0); } -static void rna_def_area_lamp(BlenderRNA *brna) +static void rna_def_area_light(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -399,103 +400,103 @@ static void rna_def_area_lamp(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - srna = RNA_def_struct(brna, "AreaLamp", "Lamp"); + srna = RNA_def_struct(brna, "AreaLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Area Lamp", "Directional area lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_AREA); + RNA_def_struct_ui_text(srna, "Area Light", "Directional area Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_AREA); - rna_def_lamp_shadow(srna, 0); - rna_def_lamp_falloff(srna); + rna_def_light_shadow(srna, 0); + rna_def_light_falloff(srna); prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "area_shape"); RNA_def_property_enum_items(prop, prop_areashape_items); - RNA_def_property_ui_text(prop, "Shape", "Shape of the area lamp"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_ui_text(prop, "Shape", "Shape of the area Light"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_size"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); - RNA_def_property_ui_text(prop, "Size", "Size of the area of the area Lamp, X direction size for Rectangle shapes"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_ui_text(prop, "Size", "Size of the area of the area light, X direction size for rectangle shapes"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_float_sdna(prop, NULL, "area_sizey"); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Size Y", - "Size of the area of the area Lamp in the Y direction for Rectangle shapes"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + "Size of the area of the area light in the Y direction for rectangle shapes"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); } -static void rna_def_spot_lamp(BlenderRNA *brna) +static void rna_def_spot_light(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "SpotLamp", "Lamp"); + srna = RNA_def_struct(brna, "SpotLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Spot Lamp", "Directional cone lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_SPOT); + RNA_def_struct_ui_text(srna, "Spot Light", "Directional cone Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_SPOT); - rna_def_lamp_falloff(srna); - rna_def_lamp_shadow(srna, 0); + rna_def_light_falloff(srna); + rna_def_light_shadow(srna, 0); prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE); RNA_def_property_ui_text(prop, "Square", "Cast a square spot light shape"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "spotblend"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "spotsize"); RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f)); RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "show_cone", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHOW_CONE); RNA_def_property_ui_text(prop, "Show Cone", "Draw transparent cone in 3D view to visualize which objects are contained in it"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); } -static void rna_def_sun_lamp(BlenderRNA *brna) +static void rna_def_sun_light(BlenderRNA *brna) { StructRNA *srna; - srna = RNA_def_struct(brna, "SunLamp", "Lamp"); + srna = RNA_def_struct(brna, "SunLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Sun Lamp", "Constant direction parallel ray lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_SUN); + RNA_def_struct_ui_text(srna, "Sun Light", "Constant direction parallel ray Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_SUN); - rna_def_lamp_shadow(srna, 1); + rna_def_light_shadow(srna, 1); } -static void rna_def_hemi_lamp(BlenderRNA *brna) +static void rna_def_hemi_light(BlenderRNA *brna) { StructRNA *srna; - srna = RNA_def_struct(brna, "HemiLamp", "Lamp"); + srna = RNA_def_struct(brna, "HemiLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Hemi Lamp", "180 degree constant lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_HEMI); + RNA_def_struct_ui_text(srna, "Hemi Light", "180 degree constant Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_HEMI); } -void RNA_def_lamp(BlenderRNA *brna) +void RNA_def_light(BlenderRNA *brna) { - rna_def_lamp(brna); - rna_def_point_lamp(brna); - rna_def_area_lamp(brna); - rna_def_spot_lamp(brna); - rna_def_sun_lamp(brna); - rna_def_hemi_lamp(brna); + rna_def_light(brna); + rna_def_point_light(brna); + rna_def_area_light(brna); + rna_def_spot_light(brna); + rna_def_sun_light(brna); + rna_def_hemi_light(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index f3921545ac5..5e05d37dc8c 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -107,7 +107,7 @@ static void rna_Main_object_begin(CollectionPropertyIterator *iter, PointerRNA * rna_iterator_listbase_begin(iter, &bmain->object, NULL); } -static void rna_Main_lamp_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Main_light_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Main *bmain = (Main *)ptr->data; rna_iterator_listbase_begin(iter, &bmain->lamp, NULL); @@ -353,7 +353,7 @@ void RNA_def_main(BlenderRNA *brna) {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material data-blocks", RNA_def_main_materials}, {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group data-blocks", RNA_def_main_node_groups}, {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh data-blocks", RNA_def_main_meshes}, - {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp data-blocks", RNA_def_main_lamps}, + {"lights", "Light", "rna_Main_light_begin", "Lights", "Light data-blocks", RNA_def_main_lights}, {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library data-blocks", RNA_def_main_libraries}, {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen data-blocks", RNA_def_main_screens}, {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager data-blocks", RNA_def_main_window_managers}, diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 5fca91064b6..febe74f63c9 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -319,7 +319,7 @@ Mesh *rna_Main_meshes_new_from_object( return BKE_mesh_new_from_object(depsgraph, bmain, sce, ob, apply_modifiers, calc_tessface, calc_undeformed); } -static Lamp *rna_Main_lamps_new(Main *bmain, const char *name, int type) +static Lamp *rna_Main_lights_new(Main *bmain, const char *name, int type) { char safe_name[MAX_ID_NAME - 2]; rna_idname_validate(name, safe_name); @@ -603,7 +603,7 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(objects, object, ID_OB) RNA_MAIN_ID_TAG_FUNCS_DEF(materials, mat, ID_MA) RNA_MAIN_ID_TAG_FUNCS_DEF(node_groups, nodetree, ID_NT) RNA_MAIN_ID_TAG_FUNCS_DEF(meshes, mesh, ID_ME) -RNA_MAIN_ID_TAG_FUNCS_DEF(lamps, lamp, ID_LA) +RNA_MAIN_ID_TAG_FUNCS_DEF(lights, lamp, ID_LA) RNA_MAIN_ID_TAG_FUNCS_DEF(libraries, library, ID_LI) RNA_MAIN_ID_TAG_FUNCS_DEF(screens, screen, ID_SCR) RNA_MAIN_ID_TAG_FUNCS_DEF(window_managers, wm, ID_WM) @@ -894,42 +894,43 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } -void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) + +void RNA_def_main_lights(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - RNA_def_property_srna(cprop, "BlendDataLamps"); - srna = RNA_def_struct(brna, "BlendDataLamps", NULL); + RNA_def_property_srna(cprop, "BlendDataLights"); + srna = RNA_def_struct(brna, "BlendDataLights", NULL); RNA_def_struct_sdna(srna, "Main"); - RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps"); + RNA_def_struct_ui_text(srna, "Main Lights", "Collection of lights"); - func = RNA_def_function(srna, "new", "rna_Main_lamps_new"); - RNA_def_function_ui_description(func, "Add a new lamp to the main database"); - parm = RNA_def_string(func, "name", "Lamp", 0, "", "New name for the data-block"); + func = RNA_def_function(srna, "new", "rna_Main_lights_new"); + RNA_def_function_ui_description(func, "Add a new light to the main database"); + parm = RNA_def_string(func, "name", "Light", 0, "", "New name for the data-block"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum(func, "type", rna_enum_lamp_type_items, 0, "Type", "The type of texture to add"); + parm = RNA_def_enum(func, "type", rna_enum_light_type_items, 0, "Type", "The type of texture to add"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "lamp", "Lamp", "", "New lamp data-block"); + parm = RNA_def_pointer(func, "light", "Light", "", "New light data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile"); - parm = RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove"); + RNA_def_function_ui_description(func, "Remove a light from the current blendfile"); + parm = RNA_def_pointer(func, "light", "Light", "", "Light to remove"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); RNA_def_boolean(func, "do_unlink", true, "", - "Unlink all usages of this lamp before deleting it " - "(WARNING: will also delete objects instancing that lamp data)"); + "Unlink all usages of this Light before deleting it " + "(WARNING: will also delete objects instancing that light data)"); RNA_def_boolean(func, "do_id_user", true, "", - "Decrement user counter of all datablocks used by this lamp data"); + "Decrement user counter of all datablocks used by this light data"); RNA_def_boolean(func, "do_ui_user", true, "", - "Make sure interface does not reference this lamp data"); + "Make sure interface does not reference this light data"); - func = RNA_def_function(srna, "tag", "rna_Main_lamps_tag"); + func = RNA_def_function(srna, "tag", "rna_Main_lights_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 46022511f8e..50246c3f9ac 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1309,7 +1309,7 @@ static void rna_def_modifier_warp(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curfalloff"); - RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve"); + RNA_def_property_ui_text(prop, "Falloff Curve", "Custom falloff curve"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE); @@ -1900,7 +1900,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curfalloff"); - RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve"); + RNA_def_property_ui_text(prop, "Falloff Curve", "Custom falloff curve"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "center", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 04f4c41659d..2bdfbade53a 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -146,7 +146,7 @@ const EnumPropertyItem rna_enum_object_type_items[] = { {OB_EMPTY, "EMPTY", 0, "Empty", ""}, {0, "", 0, NULL, NULL}, {OB_CAMERA, "CAMERA", 0, "Camera", ""}, - {OB_LAMP, "LAMP", 0, "Lamp", ""}, + {OB_LAMP, "LIGHT", 0, "Light", ""}, {OB_SPEAKER, "SPEAKER", 0, "Speaker", ""}, {OB_LIGHTPROBE, "LIGHT_PROBE", 0, "Probe", ""}, {0, NULL, 0, NULL, NULL} @@ -375,7 +375,7 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) case OB_SURF: return &RNA_Curve; case OB_FONT: return &RNA_Curve; case OB_MBALL: return &RNA_MetaBall; - case OB_LAMP: return &RNA_Lamp; + case OB_LAMP: return &RNA_Light; case OB_CAMERA: return &RNA_Camera; case OB_LATTICE: return &RNA_Lattice; case OB_ARMATURE: return &RNA_Armature; @@ -1446,7 +1446,7 @@ bool rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) return ((Object *)value.id.data)->type == OB_CAMERA; } -bool rna_Lamp_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) +bool rna_Light_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) { return ((Object *)value.id.data)->type == OB_LAMP; } diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index b902fa73334..1a2b3854668 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -517,7 +517,7 @@ void RNA_api_object(StructRNA *srna) /* Camera-related operations */ func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera"); RNA_def_function_ui_description(func, "Generate the camera projection matrix of this object " - "(mostly useful for Camera and Lamp types)"); + "(mostly useful for Camera and Light types)"); parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", "Depsgraph to get evaluated data from"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 72245e8feb9..5b7377eed17 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -5952,7 +5952,7 @@ static void rna_def_scene_eevee(BlenderRNA *brna) prop = RNA_def_property(srna, "use_volumetric_lights", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_LIGHTS); RNA_def_property_boolean_default(prop, 1); - RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene lamps interactions with volumetrics"); + RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene light interactions with volumetrics"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE); @@ -6116,13 +6116,13 @@ static void rna_def_scene_eevee(BlenderRNA *brna) prop = RNA_def_property(srna, "shadow_cube_size", PROP_ENUM, PROP_NONE); RNA_def_property_enum_default(prop, 512); RNA_def_property_enum_items(prop, eevee_shadow_size_items); - RNA_def_property_ui_text(prop, "Cube Shadows Resolution", "Size of point and area lamps shadow maps"); + RNA_def_property_ui_text(prop, "Cube Shadows Resolution", "Size of point and area light shadow maps"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); prop = RNA_def_property(srna, "shadow_cascade_size", PROP_ENUM, PROP_NONE); RNA_def_property_enum_default(prop, 1024); RNA_def_property_enum_items(prop, eevee_shadow_size_items); - RNA_def_property_ui_text(prop, "Directional Shadows Resolution", "Size of sun lamps shadow maps"); + RNA_def_property_ui_text(prop, "Directional Shadows Resolution", "Size of sun light shadow maps"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); prop = RNA_def_property(srna, "use_shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 13978f3f5ee..4d85d845081 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1320,7 +1320,7 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf( static void rna_SpaceProperties_context_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { SpaceButs *sbuts = (SpaceButs *)(ptr->data); - /* XXX BCONTEXT_DATA is ugly, but required for lamps... See T51318. */ + /* XXX BCONTEXT_DATA is ugly, but required for lights... See T51318. */ if (ELEM(sbuts->mainb, BCONTEXT_WORLD, BCONTEXT_MATERIAL, BCONTEXT_TEXTURE, BCONTEXT_DATA)) { sbuts->preview = 1; } @@ -2339,9 +2339,9 @@ static void rna_def_space_outliner(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Empties", "Show empty objects"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); - prop = RNA_def_property(srna, "use_filter_object_lamp", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_filter_object_light", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_LAMP); - RNA_def_property_ui_text(prop, "Show Lamps", "Show lamps objects"); + RNA_def_property_ui_text(prop, "Show Lights", "Show light objects"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); prop = RNA_def_property(srna, "use_filter_object_camera", PROP_BOOLEAN, PROP_NONE); @@ -2482,7 +2482,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) prop = RNA_def_property(srna, "use_scene_light", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SCENE_LIGHT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Scene Light", "Render lamps and light probes of the scene"); + RNA_def_property_ui_text(prop, "Scene Light", "Render lights and light probes of the scene"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_specular_highlight", PROP_BOOLEAN, PROP_NONE); @@ -4085,7 +4085,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) {FILTER_ID_GD, "GREASE_PENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Show/hide Grease pencil data-blocks"}, {FILTER_ID_GR, "GROUP", ICON_GROUP, "Groups", "Show/hide Group data-blocks"}, {FILTER_ID_IM, "IMAGE", ICON_IMAGE_DATA, "Images", "Show/hide Image data-blocks"}, - {FILTER_ID_LA, "LAMP", ICON_LAMP_DATA, "Lamps", "Show/hide Lamp data-blocks"}, + {FILTER_ID_LA, "LIGHT", ICON_LIGHT_DATA, "Lights", "Show/hide Light data-blocks"}, {FILTER_ID_LS, "LINESTYLE", ICON_LINE_DATA, "Freestyle Linestyles", "Show/hide Freestyle's Line Style data-blocks"}, {FILTER_ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattices", "Show/hide Lattice data-blocks"}, @@ -4127,7 +4127,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) {FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO, "IMAGE", ICON_IMAGE_DATA, "Images & Sounds", "Show/hide images, movie clips, sounds and masks"}, {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS, - "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lamps, cameras and speakers"}, + "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lights, cameras and speakers"}, {FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_CF, "MISC", ICON_GREASEPENCIL, "Miscellaneous", "Show/hide other data types"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 0026344e460..07fd20c6fc5 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1435,7 +1435,7 @@ static void rna_def_texture(BlenderRNA *brna) srna = RNA_def_struct(brna, "Texture", "ID"); RNA_def_struct_sdna(srna, "Tex"); - RNA_def_struct_ui_text(srna, "Texture", "Texture data-block used by materials, lamps, worlds and brushes"); + RNA_def_struct_ui_text(srna, "Texture", "Texture data-block used by materials, lights, worlds and brushes"); RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA); RNA_def_struct_refine_func(srna, "rna_Texture_refine"); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index be8bce61910..74117b43d91 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -844,7 +844,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "template_preview", "uiTemplatePreview"); - RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lamps or worlds"); + RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lights or worlds"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "id", "ID", "", "ID data-block"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -856,7 +856,7 @@ void RNA_api_ui_layout(StructRNA *srna) "(i.e. all previews of materials without explicit ID will have the same size...)"); func = RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping"); - RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lamps"); + RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lights"); api_ui_item_rna_common(func); RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display"); RNA_def_boolean(func, "levels", false, "", "Show black/white levels"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9cde04c560e..9ac93efe347 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1805,9 +1805,10 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Empty", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "lamp", PROP_FLOAT, PROP_COLOR_GAMMA); + prop = RNA_def_property(srna, "light", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "lamp"); RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Lamp", ""); + RNA_def_property_ui_text(prop, "Light", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "speaker", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -3803,7 +3804,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "obcenter_dia"); RNA_def_property_range(prop, 4, 10); - RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Lamp origin display"); + RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Light origin display"); RNA_def_property_update(prop, 0, "rna_userdef_update"); /* View2D Grid Displays */ @@ -4038,9 +4039,9 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_ARM); RNA_def_property_ui_text(prop, "Duplicate Armature", "Causes armature data to be duplicated with the object"); - prop = RNA_def_property(srna, "use_duplicate_lamp", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_duplicate_light", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_LAMP); - RNA_def_property_ui_text(prop, "Duplicate Lamp", "Causes lamp data to be duplicated with the object"); + RNA_def_property_ui_text(prop, "Duplicate Light", "Causes light data to be duplicated with the object"); prop = RNA_def_property(srna, "use_duplicate_material", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_MAT); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index ec4e88768de..cf974132961 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -62,8 +62,8 @@ DefNode( ShaderNode, SH_NODE_COMBRGB, 0, "COMBR DefNode( ShaderNode, SH_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" ) DefNode( ShaderNode, SH_NODE_OUTPUT_MATERIAL, def_sh_output, "OUTPUT_MATERIAL", OutputMaterial, "Material Output", "" ) -DefNode( ShaderNode, SH_NODE_EEVEE_SPECULAR, 0, "EEVEE_SPECULAR", EeveeSpecular, "Specular", "") -DefNode( ShaderNode, SH_NODE_OUTPUT_LAMP, def_sh_output, "OUTPUT_LAMP", OutputLamp, "Lamp Output", "" ) +DefNode( ShaderNode, SH_NODE_EEVEE_SPECULAR, 0, "EEVEE_SPECULAR", EeveeSpecular, "Specular", "" ) +DefNode( ShaderNode, SH_NODE_OUTPUT_LIGHT, def_sh_output, "OUTPUT_LIGHT", OutputLight, "Light Output", "" ) DefNode( ShaderNode, SH_NODE_OUTPUT_WORLD, def_sh_output, "OUTPUT_WORLD", OutputWorld, "World Output", "" ) DefNode( ShaderNode, SH_NODE_OUTPUT_LINESTYLE, def_sh_output_linestyle,"OUTPUT_LINESTYLE", OutputLineStyle, "Line Style Output", "" ) DefNode( ShaderNode, SH_NODE_FRESNEL, 0, "FRESNEL", Fresnel, "Fresnel", "" ) diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 8db88f13ea6..32c9244735d 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -222,7 +222,7 @@ bNode *ntreeShaderOutputNode(bNodeTree *ntree, int target) for (bNode *node = ntree->nodes.first; node; node = node->next) { if (!ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, - SH_NODE_OUTPUT_LAMP)) + SH_NODE_OUTPUT_LIGHT)) { continue; } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c index b08a4b4ff57..4eb81f4cb5e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c @@ -39,7 +39,7 @@ void register_node_type_sh_output_lamp(void) { static bNodeType ntype; - sh_node_type_base(&ntype, SH_NODE_OUTPUT_LAMP, "Lamp Output", NODE_CLASS_OUTPUT, 0); + sh_node_type_base(&ntype, SH_NODE_OUTPUT_LAMP, "Light Output", NODE_CLASS_OUTPUT, 0); node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_output_lamp_in, NULL); node_type_init(&ntype, NULL); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1983c0e6b84..d7210c4ee29 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3558,7 +3558,7 @@ static const EnumPropertyItem preview_id_type_items[] = { {FILTER_ID_GR, "GROUP", 0, "Groups", ""}, {FILTER_ID_OB, "OBJECT", 0, "Objects", ""}, {FILTER_ID_MA, "MATERIAL", 0, "Materials", ""}, - {FILTER_ID_LA, "LAMP", 0, "Lamps", ""}, + {FILTER_ID_LA, "LIGHT", 0, "Lights", ""}, {FILTER_ID_WO, "WORLD", 0, "Worlds", ""}, {FILTER_ID_TE, "TEXTURE", 0, "Textures", ""}, {FILTER_ID_IM, "IMAGE", 0, "Images", ""}, diff --git a/tests/python/bl_mesh_modifiers.py b/tests/python/bl_mesh_modifiers.py index d553a2e2c27..f2ab6b406bd 100644 --- a/tests/python/bl_mesh_modifiers.py +++ b/tests/python/bl_mesh_modifiers.py @@ -127,7 +127,7 @@ def ctx_clear_scene(): # copied from batch_import.py # remove obdata, for now only worry about the startup scene for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, - bpy.data.lamps, + bpy.data.lights, bpy.data.cameras, ): diff --git a/tests/python/bl_pyapi_idprop_datablock.py b/tests/python/bl_pyapi_idprop_datablock.py index 4b46bea7c00..8ff597dda31 100644 --- a/tests/python/bl_pyapi_idprop_datablock.py +++ b/tests/python/bl_pyapi_idprop_datablock.py @@ -90,10 +90,10 @@ def make_lib(): # datablock pointer to the Camera object bpy.data.objects["Cube"].prop = bpy.data.objects['Camera'] - # array of datablock pointers to the Lamp object + # array of datablock pointers to the Light object for i in range(0, arr_len): a = bpy.data.objects["Cube"].prop_array.add() - a.test_prop = bpy.data.objects['Lamp'] + a.test_prop = bpy.data.objects['Light'] a.name = a.test_prop.name # make unique named copy of the cube @@ -124,7 +124,7 @@ def check_lib(): # check array of pointers in duplicated object for i in range(0, arr_len): abort_if_false(bpy.data.objects["Cube.001"].prop_array[i].test_prop == - bpy.data.objects['Lamp']) + bpy.data.objects['Light']) def check_lib_linking(): @@ -137,7 +137,7 @@ def check_lib_linking(): o = bpy.data.scenes["Scene_lib"].objects['Unique_Cube'] - abort_if_false(o.prop_array[0].test_prop == bpy.data.scenes["Scene_lib"].objects['Lamp']) + abort_if_false(o.prop_array[0].test_prop == bpy.data.scenes["Scene_lib"].objects['Light']) abort_if_false(o.prop == bpy.data.scenes["Scene_lib"].objects['Camera']) abort_if_false(o.prop.library == o.library) @@ -187,15 +187,15 @@ def check_scene_copying(): # count users def test_users_counting(): bpy.ops.wm.read_factory_settings() - lamp_us = bpy.data.objects["Lamp"].data.users + Light_us = bpy.data.objects["Light"].data.users n = 1000 for i in range(0, n): - bpy.data.objects["Cube"]["a%s" % i] = bpy.data.objects["Lamp"].data - abort_if_false(bpy.data.objects["Lamp"].data.users == lamp_us + n) + bpy.data.objects["Cube"]["a%s" % i] = bpy.data.objects["Light"].data + abort_if_false(bpy.data.objects["Light"].data.users == Light_us + n) for i in range(0, int(n / 2)): bpy.data.objects["Cube"]["a%s" % i] = 1 - abort_if_false(bpy.data.objects["Lamp"].data.users == lamp_us + int(n / 2)) + abort_if_false(bpy.data.objects["Light"].data.users == Light_us + int(n / 2)) # linking @@ -259,13 +259,13 @@ def test_restrictions1(): bpy.types.Scene.prop2 = bpy.props.PointerProperty(type=bpy.types.NodeTree, poll=poll1) # check poll effect on UI (poll returns false => red alert) - bpy.context.scene.prop = bpy.data.objects["Lamp.001"] - bpy.context.scene.prop1 = bpy.data.objects["Lamp.001"] + bpy.context.scene.prop = bpy.data.objects["Light.001"] + bpy.context.scene.prop1 = bpy.data.objects["Light.001"] # check incorrect type assignment def sub_test(): # NodeTree id_prop - bpy.context.scene.prop2 = bpy.data.objects["Lamp.001"] + bpy.context.scene.prop2 = bpy.data.objects["Light.001"] check_crash(sub_test) diff --git a/tests/python/bl_rna_defaults.py b/tests/python/bl_rna_defaults.py index 6038ef34d78..fc895dbddfc 100644 --- a/tests/python/bl_rna_defaults.py +++ b/tests/python/bl_rna_defaults.py @@ -125,8 +125,8 @@ test_World = _test_id_gen("worlds") ns = globals() for t in bpy.data.curves.bl_rna.functions["new"].parameters["type"].enum_items.keys(): ns["test_Curve_%s" % t] = _test_id_gen("curves", args_create=(DUMMY_NAME, t)) -for t in bpy.data.lamps.bl_rna.functions["new"].parameters["type"].enum_items.keys(): - ns["test_Lamp_%s" % t] = _test_id_gen("lamps", args_create=(DUMMY_NAME, t)) +for t in bpy.data.lights.bl_rna.functions["new"].parameters["type"].enum_items.keys(): + ns["test_Light_%s" % t] = _test_id_gen("lights", args_create=(DUMMY_NAME, t)) # types are a dynamic enum, have to hard-code. for t in "ShaderNodeTree", "CompositorNodeTree", "TextureNodeTree": ns["test_NodeGroup_%s" % t] = _test_id_gen("node_groups", args_create=(DUMMY_NAME, t)) -- cgit v1.2.3 From aed09d43295de3dcba3d318345a4fd1396a16ea1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 5 Jul 2018 19:18:43 +0200 Subject: Cleanup: remove unused shader node compatibility flag. No longer needed after Blender Internal removal and Eevee replacing the Cycles GLSL shading nodes. --- intern/cycles/blender/addon/version_update.py | 69 +++++----------------- .../bl_previews_utils/bl_previews_render.py | 43 +++----------- source/blender/blenkernel/BKE_node.h | 7 +-- source/blender/blenkernel/intern/node.c | 5 -- source/blender/editors/space_node/node_templates.c | 9 --- source/blender/makesrna/intern/rna_nodetree.c | 12 ---- source/blender/nodes/intern/node_common.c | 3 - source/blender/nodes/shader/node_shader_util.c | 5 +- .../nodes/shader/nodes/node_shader_add_shader.c | 1 - .../shader/nodes/node_shader_ambient_occlusion.c | 1 - .../nodes/shader/nodes/node_shader_attribute.c | 1 - .../nodes/shader/nodes/node_shader_background.c | 1 - .../blender/nodes/shader/nodes/node_shader_bevel.c | 1 - .../nodes/shader/nodes/node_shader_blackbody.c | 1 - .../nodes/shader/nodes/node_shader_brightness.c | 1 - .../shader/nodes/node_shader_bsdf_anisotropic.c | 1 - .../nodes/shader/nodes/node_shader_bsdf_diffuse.c | 1 - .../nodes/shader/nodes/node_shader_bsdf_glass.c | 1 - .../nodes/shader/nodes/node_shader_bsdf_glossy.c | 1 - .../nodes/shader/nodes/node_shader_bsdf_hair.c | 1 - .../shader/nodes/node_shader_bsdf_principled.c | 1 - .../shader/nodes/node_shader_bsdf_refraction.c | 1 - .../nodes/shader/nodes/node_shader_bsdf_toon.c | 1 - .../shader/nodes/node_shader_bsdf_translucent.c | 1 - .../shader/nodes/node_shader_bsdf_transparent.c | 1 - .../nodes/shader/nodes/node_shader_bsdf_velvet.c | 1 - .../blender/nodes/shader/nodes/node_shader_bump.c | 1 - .../nodes/shader/nodes/node_shader_camera.c | 1 - .../nodes/shader/nodes/node_shader_common.c | 1 - .../nodes/shader/nodes/node_shader_curves.c | 2 - .../nodes/shader/nodes/node_shader_displacement.c | 1 - .../shader/nodes/node_shader_eevee_specular.c | 1 - .../nodes/shader/nodes/node_shader_emission.c | 1 - .../nodes/shader/nodes/node_shader_fresnel.c | 1 - .../blender/nodes/shader/nodes/node_shader_gamma.c | 1 - .../nodes/shader/nodes/node_shader_geometry.c | 1 - .../nodes/shader/nodes/node_shader_hair_info.c | 1 - .../nodes/shader/nodes/node_shader_holdout.c | 1 - .../nodes/shader/nodes/node_shader_hueSatVal.c | 1 - .../nodes/shader/nodes/node_shader_ies_light.c | 1 - .../nodes/shader/nodes/node_shader_invert.c | 1 - .../nodes/shader/nodes/node_shader_layer_weight.c | 1 - .../nodes/shader/nodes/node_shader_light_falloff.c | 1 - .../nodes/shader/nodes/node_shader_light_path.c | 1 - .../nodes/shader/nodes/node_shader_mapping.c | 1 - .../blender/nodes/shader/nodes/node_shader_math.c | 1 - .../nodes/shader/nodes/node_shader_mixRgb.c | 1 - .../nodes/shader/nodes/node_shader_mix_shader.c | 1 - .../nodes/shader/nodes/node_shader_normal.c | 1 - .../nodes/shader/nodes/node_shader_normal_map.c | 1 - .../nodes/shader/nodes/node_shader_object_info.c | 1 - .../nodes/shader/nodes/node_shader_output_lamp.c | 3 +- .../shader/nodes/node_shader_output_linestyle.c | 1 - .../shader/nodes/node_shader_output_material.c | 1 - .../nodes/shader/nodes/node_shader_output_world.c | 1 - .../nodes/shader/nodes/node_shader_particle_info.c | 1 - .../blender/nodes/shader/nodes/node_shader_rgb.c | 1 - .../nodes/shader/nodes/node_shader_script.c | 1 - .../nodes/shader/nodes/node_shader_sepcombHSV.c | 2 - .../nodes/shader/nodes/node_shader_sepcombRGB.c | 2 - .../nodes/shader/nodes/node_shader_sepcombXYZ.c | 2 - .../nodes/shader/nodes/node_shader_shaderToRgb.c | 1 - .../nodes/shader/nodes/node_shader_squeeze.c | 1 - .../nodes/node_shader_subsurface_scattering.c | 1 - .../nodes/shader/nodes/node_shader_tangent.c | 1 - .../nodes/shader/nodes/node_shader_tex_brick.c | 1 - .../nodes/shader/nodes/node_shader_tex_checker.c | 1 - .../nodes/shader/nodes/node_shader_tex_coord.c | 1 - .../shader/nodes/node_shader_tex_environment.c | 1 - .../nodes/shader/nodes/node_shader_tex_gradient.c | 1 - .../nodes/shader/nodes/node_shader_tex_image.c | 1 - .../nodes/shader/nodes/node_shader_tex_magic.c | 1 - .../nodes/shader/nodes/node_shader_tex_musgrave.c | 1 - .../nodes/shader/nodes/node_shader_tex_noise.c | 1 - .../shader/nodes/node_shader_tex_pointdensity.c | 1 - .../nodes/shader/nodes/node_shader_tex_sky.c | 1 - .../nodes/shader/nodes/node_shader_tex_voronoi.c | 1 - .../nodes/shader/nodes/node_shader_tex_wave.c | 1 - .../nodes/shader/nodes/node_shader_uvAlongStroke.c | 1 - .../blender/nodes/shader/nodes/node_shader_uvmap.c | 1 - .../nodes/shader/nodes/node_shader_valToRgb.c | 2 - .../blender/nodes/shader/nodes/node_shader_value.c | 1 - .../nodes/shader/nodes/node_shader_vectMath.c | 1 - .../nodes/shader/nodes/node_shader_vectTransform.c | 1 - .../shader/nodes/node_shader_vector_displacement.c | 1 - .../shader/nodes/node_shader_volume_absorption.c | 1 - .../shader/nodes/node_shader_volume_principled.c | 1 - .../shader/nodes/node_shader_volume_scatter.c | 1 - .../nodes/shader/nodes/node_shader_wavelength.c | 1 - .../nodes/shader/nodes/node_shader_wireframe.c | 1 - 90 files changed, 28 insertions(+), 214 deletions(-) diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py index b6ace0e6b57..679c3e6a437 100644 --- a/intern/cycles/blender/addon/version_update.py +++ b/intern/cycles/blender/addon/version_update.py @@ -22,45 +22,6 @@ import math from bpy.app.handlers import persistent -def check_is_new_shading_ntree(node_tree): - for node in node_tree.nodes: - # If material has any node with ONLY new shading system - # compatibility then it's considered a Cycles material - # and versioning code would need to perform on it. - # - # We can not check for whether NEW_SHADING in compatibility - # because some nodes could have compatibility with both old - # and new shading system and they can't be used for any - # decision here. - if node.shading_compatibility == {'NEW_SHADING'}: - return True - - # If node is only compatible with old shading system - # then material can not be Cycles material and we - # can stopiterating nodes now. - if node.shading_compatibility == {'OLD_SHADING'}: - return False - return False - - -def check_is_new_shading_material(material): - if not material.node_tree: - return False - return check_is_new_shading_ntree(material.node_tree) - - -def check_is_new_shading_world(world): - if not world.node_tree: - return False - return check_is_new_shading_ntree(world.node_tree) - - -def check_is_new_shading_light(light): - if not light.node_tree: - return False - return check_is_new_shading_ntree(light.node_tree) - - def foreach_notree_node(nodetree, callback, traversed): if nodetree in traversed: return @@ -74,20 +35,20 @@ def foreach_notree_node(nodetree, callback, traversed): def foreach_cycles_node(callback): traversed = set() for material in bpy.data.materials: - if check_is_new_shading_material(material): - foreach_notree_node(material.node_tree, - callback, - traversed) + if material.node_tree: + foreach_notree_node(material.node_tree, + callback, + traversed) for world in bpy.data.worlds: - if check_is_new_shading_world(world): - foreach_notree_node(world.node_tree, - callback, - traversed) + if world.node_tree: + foreach_notree_node(world.node_tree, + callback, + traversed) for light in bpy.data.lights: - if check_is_new_shading_world(light): - foreach_notree_node(light.node_tree, - callback, - traversed) + if light.node_tree: + foreach_notree_node(light.node_tree, + callback, + traversed) def displacement_node_insert(material, nodetree, traversed): @@ -128,7 +89,7 @@ def displacement_node_insert(material, nodetree, traversed): def displacement_nodes_insert(): traversed = set() for material in bpy.data.materials: - if check_is_new_shading_material(material): + if material.node_tree: displacement_node_insert(material, material.node_tree, traversed) def displacement_principled_nodes(node): @@ -186,7 +147,7 @@ def square_roughness_node_insert(material, nodetree, traversed): def square_roughness_nodes_insert(): traversed = set() for material in bpy.data.materials: - if check_is_new_shading_material(material): + if material.node_tree: square_roughness_node_insert(material, material.node_tree, traversed) @@ -301,7 +262,7 @@ def ambient_occlusion_node_relink(material, nodetree, traversed): def ambient_occlusion_nodes_relink(): traversed = set() for material in bpy.data.materials: - if check_is_new_shading_material(material): + if material.node_tree: ambient_occlusion_node_relink(material, material.node_tree, traversed) diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py index f2c766b2b2d..16b0b107927 100644 --- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py +++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py @@ -122,21 +122,9 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): light_data.spot_size = 1.0471975803375244 # 60 scene.objects.link(light) - if engine == 'BLENDER_RENDER': - scene.render.engine = 'BLENDER_RENDER' - scene.render.alpha_mode = 'TRANSPARENT' - - world.use_sky_blend = True - world.horizon_color = 0.9, 0.9, 0.9 - world.zenith_color = 0.5, 0.5, 0.5 - world.ambient_color = 0.1, 0.1, 0.1 - world.light_settings.use_environment_light = True - world.light_settings.environment_energy = 1.0 - world.light_settings.environment_color = 'SKY_COLOR' - elif engine == 'CYCLES': - scene.render.engine = 'CYCLES' - scene.cycles.film_transparent = True - # TODO: define Cycles world? + scene.render.engine = 'CYCLES' + scene.cycles.film_transparent = True + # TODO: define Cycles world? scene.render.image_settings.file_format = 'PNG' scene.render.image_settings.color_depth = '8' @@ -239,17 +227,6 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): return success - def objects_render_engine_guess(obs): - for obname, libpath in obs: - ob = bpy.data.objects[obname, libpath] - for matslot in ob.material_slots: - mat = matslot.material - if mat and mat.use_nodes and mat.node_tree: - for nd in mat.node_tree.nodes: - if nd.shading_compatibility == {'NEW_SHADING'}: - return 'CYCLES' - return 'BLENDER_RENDER' - def object_bbox_merge(bbox, ob, ob_space, offset_matrix): # Take collections instances into account (including linked one in this case). if ob.type == 'EMPTY' and ob.dupli_type == 'COLLECTION': @@ -360,11 +337,10 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): continue objects = ((root.name, None),) - render_engine = objects_render_engine_guess(objects) - render_context = render_contexts.get(render_engine, None) + render_context = render_contexts.get('CYCLES', None) if render_context is None: - render_context = render_context_create(render_engine, objects_ignored) - render_contexts[render_engine] = render_context + render_context = render_context_create('CYCLES', objects_ignored) + render_contexts['CYCLES'] = render_context scene = bpy.data.scenes[render_context.scene, None] bpy.context.screen.scene = scene @@ -405,11 +381,10 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): # Here too, we do want to keep linked objects members of local collection... objects = tuple((ob.name, ob.library.filepath if ob.library else None) for ob in grp.objects) - render_engine = objects_render_engine_guess(objects) - render_context = render_contexts.get(render_engine, None) + render_context = render_contexts.get('CYCLES', None) if render_context is None: - render_context = render_context_create(render_engine, objects_ignored) - render_contexts[render_engine] = render_context + render_context = render_context_create('CYCLES', objects_ignored) + render_contexts['CYCLES'] = render_context scene = bpy.data.scenes[render_context.scene, None] bpy.context.screen.scene = scene diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 13d6fd10eaa..e72c6c14bfb 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -152,7 +152,7 @@ typedef struct bNodeType { float width, minwidth, maxwidth; float height, minheight, maxheight; - short nclass, flag, compatibility; + short nclass, flag; /* templates for static sockets */ bNodeSocketTemplate *inputs, *outputs; @@ -251,10 +251,6 @@ typedef struct bNodeType { #define NODE_CLASS_SHADER 40 #define NODE_CLASS_LAYOUT 100 -/* nodetype->compatibility */ -#define NODE_OLD_SHADING (1 << 0) -#define NODE_NEW_SHADING (1 << 1) - /* node resize directions */ #define NODE_RESIZE_TOP 1 #define NODE_RESIZE_BOTTOM 2 @@ -600,7 +596,6 @@ void node_type_update(struct bNodeType *ntype, void node_type_exec(struct bNodeType *ntype, NodeInitExecFunction initexecfunc, NodeFreeExecFunction freeexecfunc, NodeExecFunction execfunc); void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpufunc); void node_type_internal_links(struct bNodeType *ntype, void (*update_internal_links)(struct bNodeTree *, struct bNode *)); -void node_type_compatibility(struct bNodeType *ntype, short compatibility); /** \} */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f7cd2bd52dc..7aa0ecdad87 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3333,11 +3333,6 @@ void node_type_internal_links(bNodeType *ntype, void (*update_internal_links)(bN ntype->update_internal_links = update_internal_links; } -void node_type_compatibility(struct bNodeType *ntype, short compatibility) -{ - ntype->compatibility = compatibility; -} - /* callbacks for undefined types */ static bool node_undefined_poll(bNodeType *UNUSED(ntype), bNodeTree *UNUSED(nodetree)) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index b884db1ced4..e3aeb0244e8 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -446,21 +446,12 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) uiBut *but; NodeLinkArg *argN; int first = 1; - int compatibility = 0; - - if (ntree->type == NTREE_SHADER) { - compatibility = NODE_NEW_SHADING; - } /* generate array of node types sorted by UI name */ bNodeType **sorted_ntypes = NULL; BLI_array_declare(sorted_ntypes); NODE_TYPES_BEGIN(ntype) { - if (compatibility && !(ntype->compatibility & compatibility)) { - continue; - } - if (ntype->nclass != nclass) { continue; } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 8ffcb85deed..89ca6b52c75 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -7756,12 +7756,6 @@ static void rna_def_node(BlenderRNA *brna) {NODE_CUSTOM, "CUSTOM", 0, "Custom", "Custom Node"}, {0, NULL, 0, NULL, NULL}}; - static const EnumPropertyItem node_shading_compatibilities[] = { - {NODE_OLD_SHADING, "OLD_SHADING", 0, "Old Shading", "Old shading system compatibility"}, - {NODE_NEW_SHADING, "NEW_SHADING", 0, "New Shading", "New shading system compatibility"}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "Node", NULL); RNA_def_struct_ui_text(srna, "Node", "Node in a node tree"); RNA_def_struct_sdna(srna, "bNode"); @@ -7901,12 +7895,6 @@ static void rna_def_node(BlenderRNA *brna) parm = RNA_def_boolean(func, "result", false, "Result", ""); RNA_def_function_return(func, parm); - prop = RNA_def_property(srna, "shading_compatibility", PROP_ENUM, PROP_NONE); - RNA_def_property_flag(prop, PROP_ENUM_FLAG); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_enum_sdna(prop, NULL, "typeinfo->compatibility"); - RNA_def_property_enum_items(prop, node_shading_compatibilities); - /* registration */ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "typeinfo->idname"); diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index cb04b341c26..2dbb573f305 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -210,7 +210,6 @@ void register_node_type_frame(void) node_type_init(ntype, node_frame_init); node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage); node_type_size(ntype, 150, 100, 0); - node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); ntype->needs_free = 1; nodeRegisterType(ntype); @@ -484,7 +483,6 @@ void register_node_type_group_input(void) node_type_size(ntype, 140, 80, 400); node_type_init(ntype, node_group_input_init); node_type_update(ntype, node_group_input_update, node_group_input_verify); - node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); ntype->needs_free = 1; nodeRegisterType(ntype); @@ -583,7 +581,6 @@ void register_node_type_group_output(void) node_type_size(ntype, 140, 80, 400); node_type_init(ntype, node_group_output_init); node_type_update(ntype, node_group_output_update, node_group_output_verify); - node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); ntype->needs_free = 1; nodeRegisterType(ntype); diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 1ae50dab358..9190f0d53cd 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -226,9 +226,8 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs) do_it = false; /* for groups, only execute outputs for edited group */ if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { - if (node->typeinfo->compatibility & NODE_NEW_SHADING) - if (do_outputs && (node->flag & NODE_DO_OUTPUT)) - do_it = true; + if (do_outputs && (node->flag & NODE_DO_OUTPUT)) + do_it = true; } else { do_it = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_add_shader.c b/source/blender/nodes/shader/nodes/node_shader_add_shader.c index d3bb8fccf71..0661ab59434 100644 --- a/source/blender/nodes/shader/nodes/node_shader_add_shader.c +++ b/source/blender/nodes/shader/nodes/node_shader_add_shader.c @@ -51,7 +51,6 @@ void register_node_type_sh_add_shader(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_ADD_SHADER, "Add Shader", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_add_shader_in, sh_node_add_shader_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c index 4c770984717..76ef257f8a3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c +++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c @@ -62,7 +62,6 @@ void register_node_type_sh_ambient_occlusion(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_AMBIENT_OCCLUSION, "Ambient Occlusion", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_ambient_occlusion_in, sh_node_ambient_occlusion_out); node_type_init(&ntype, node_shader_init_ambient_occlusion); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c index 05091a2709a..aca72ac27cc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.c +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c @@ -76,7 +76,6 @@ void register_node_type_sh_attribute(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_ATTRIBUTE, "Attribute", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_attribute_out); node_type_init(&ntype, node_shader_init_attribute); node_type_storage(&ntype, "NodeShaderAttribute", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_background.c b/source/blender/nodes/shader/nodes/node_shader_background.c index 4ea675f9e0c..38b5883bc1e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_background.c +++ b/source/blender/nodes/shader/nodes/node_shader_background.c @@ -51,7 +51,6 @@ void register_node_type_sh_background(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BACKGROUND, "Background", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_background_in, sh_node_background_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_bevel.c b/source/blender/nodes/shader/nodes/node_shader_bevel.c index dd9bc91e2d1..05161bd453a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bevel.c +++ b/source/blender/nodes/shader/nodes/node_shader_bevel.c @@ -60,7 +60,6 @@ void register_node_type_sh_bevel(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BEVEL, "Bevel", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bevel_in, sh_node_bevel_out); node_type_init(&ntype, node_shader_init_bevel); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.c b/source/blender/nodes/shader/nodes/node_shader_blackbody.c index 7bdce077977..76291df41bc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_blackbody.c +++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.c @@ -54,7 +54,6 @@ void register_node_type_sh_blackbody(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BLACKBODY, "Blackbody", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_socket_templates(&ntype, sh_node_blackbody_in, sh_node_blackbody_out); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c index bb95ed2d32c..d17a5b9ba6e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_brightness.c +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c @@ -52,7 +52,6 @@ void register_node_type_sh_brightcontrast(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c index ee3db99d2ab..c1423867d96 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c @@ -63,7 +63,6 @@ void register_node_type_sh_bsdf_anisotropic(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_ANISOTROPIC, "Anisotropic BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_anisotropic_in, sh_node_bsdf_anisotropic_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_anisotropic); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c index be7012712cc..58a37b0e81d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c @@ -55,7 +55,6 @@ void register_node_type_sh_bsdf_diffuse(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_DIFFUSE, "Diffuse BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_diffuse_in, sh_node_bsdf_diffuse_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c index 3d3173f6862..7b060bc68aa 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c @@ -61,7 +61,6 @@ void register_node_type_sh_bsdf_glass(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_GLASS, "Glass BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_glass_in, sh_node_bsdf_glass_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_glass); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c index eb5bd7b57d8..c3fb43c0ce8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c @@ -60,7 +60,6 @@ void register_node_type_sh_bsdf_glossy(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_GLOSSY, "Glossy BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_glossy_in, sh_node_bsdf_glossy_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_glossy); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c index 9db0e3284b9..d97344ad6a7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c @@ -54,7 +54,6 @@ void register_node_type_sh_bsdf_hair(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_HAIR, "Hair BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_hair_in, sh_node_bsdf_hair_out); node_type_size(&ntype, 150, 60, 200); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c index b4a83c847be..7f02295d45f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c @@ -143,7 +143,6 @@ void register_node_type_sh_bsdf_principled(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_PRINCIPLED, "Principled BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_principled_in, sh_node_bsdf_principled_out); node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, node_shader_init_principled); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c index 949f6a90de5..41dd3f8af3c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c @@ -61,7 +61,6 @@ void register_node_type_sh_bsdf_refraction(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_REFRACTION, "Refraction BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_refraction_in, sh_node_bsdf_refraction_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_refraction); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c index 0470795930b..0754a7e5a3b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c @@ -58,7 +58,6 @@ void register_node_type_sh_bsdf_toon(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_TOON, "Toon BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_toon_in, sh_node_bsdf_toon_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c index 7757ae38efd..2c0949f275c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c @@ -54,7 +54,6 @@ void register_node_type_sh_bsdf_translucent(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSLUCENT, "Translucent BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_translucent_in, sh_node_bsdf_translucent_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c index 441a7c50305..08ddf221804 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c @@ -50,7 +50,6 @@ void register_node_type_sh_bsdf_transparent(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSPARENT, "Transparent BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_transparent_in, sh_node_bsdf_transparent_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c index fec106a131a..ce331f03d4e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c @@ -55,7 +55,6 @@ void register_node_type_sh_bsdf_velvet(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_VELVET, "Velvet BSDF", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bsdf_velvet_in, sh_node_bsdf_velvet_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.c b/source/blender/nodes/shader/nodes/node_shader_bump.c index 6274d132bc7..08b50a886c5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bump.c +++ b/source/blender/nodes/shader/nodes/node_shader_bump.c @@ -68,7 +68,6 @@ void register_node_type_sh_bump(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BUMP, "Bump", NODE_CLASS_OP_VECTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_bump_in, sh_node_bump_out); node_type_storage(&ntype, "", NULL, NULL); node_type_gpu(&ntype, gpu_shader_bump); diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c index dfd712afb29..9089d415759 100644 --- a/source/blender/nodes/shader/nodes/node_shader_camera.c +++ b/source/blender/nodes/shader/nodes/node_shader_camera.c @@ -54,7 +54,6 @@ void register_node_type_sh_camera(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_CAMERA, "Camera Data", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_camera_out); node_type_storage(&ntype, "", NULL, NULL); node_type_gpu(&ntype, gpu_shader_camera); diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index 09fc10a4c71..23b27fc5008 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -238,7 +238,6 @@ void register_node_type_sh_group(void) BLI_assert(ntype.ext.srna != NULL); RNA_struct_blender_type_set(ntype.ext.srna, &ntype); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 140, 60, 400); node_type_label(&ntype, node_group_label); diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 4f3dc92ad02..d5932ff233a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -74,7 +74,6 @@ void register_node_type_sh_curve_vec(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_curve_vec_in, sh_node_curve_vec_out); node_type_init(&ntype, node_shader_init_curve_vec); node_type_size_preset(&ntype, NODE_SIZE_LARGE); @@ -133,7 +132,6 @@ void register_node_type_sh_curve_rgb(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_curve_rgb_in, sh_node_curve_rgb_out); node_type_init(&ntype, node_shader_init_curve_rgb); node_type_size_preset(&ntype, NODE_SIZE_LARGE); diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.c b/source/blender/nodes/shader/nodes/node_shader_displacement.c index c26968e8d14..4480cbdf56b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_displacement.c +++ b/source/blender/nodes/shader/nodes/node_shader_displacement.c @@ -74,7 +74,6 @@ void register_node_type_sh_displacement(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_DISPLACEMENT, "Displacement", NODE_CLASS_OP_VECTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_displacement_in, sh_node_displacement_out); node_type_storage(&ntype, "", NULL, NULL); node_type_init(&ntype, node_shader_init_displacement); diff --git a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c index cd912a4b4cb..e05b0be1e62 100644 --- a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c +++ b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c @@ -77,7 +77,6 @@ void register_node_type_sh_eevee_specular(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_EEVEE_SPECULAR, "Specular", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_eevee_specular_in, sh_node_eevee_specular_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.c b/source/blender/nodes/shader/nodes/node_shader_emission.c index f2ab4a119da..7a7c89be3a0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_emission.c +++ b/source/blender/nodes/shader/nodes/node_shader_emission.c @@ -51,7 +51,6 @@ void register_node_type_sh_emission(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_EMISSION, "Emission", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_emission_in, sh_node_emission_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c index 072abed6c16..cb6b35ac4a7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c +++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c @@ -61,7 +61,6 @@ void register_node_type_sh_fresnel(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_FRESNEL, "Fresnel", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_fresnel_in, sh_node_fresnel_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c index e536d198ed0..4a946e92778 100644 --- a/source/blender/nodes/shader/nodes/node_shader_gamma.c +++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c @@ -62,7 +62,6 @@ void register_node_type_sh_gamma(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_gamma_in, sh_node_gamma_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c index 2af3e3e259a..dfeebcea305 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geometry.c +++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c @@ -55,7 +55,6 @@ void register_node_type_sh_geometry(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_NEW_GEOMETRY, "Geometry", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_geometry_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.c b/source/blender/nodes/shader/nodes/node_shader_hair_info.c index 13259dce9d1..8b2f4b479ad 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hair_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.c @@ -48,7 +48,6 @@ void register_node_type_sh_hair_info(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_HAIR_INFO, "Hair Info", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, outputs); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.c b/source/blender/nodes/shader/nodes/node_shader_holdout.c index 42563f2bfa8..6109022fddf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_holdout.c +++ b/source/blender/nodes/shader/nodes/node_shader_holdout.c @@ -45,7 +45,6 @@ void register_node_type_sh_holdout(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_HOLDOUT, "Holdout", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_holdout_in, sh_node_holdout_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c index 07f1e9e3233..c017765c8e2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c @@ -92,7 +92,6 @@ void register_node_type_sh_hue_sat(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_hue_sat_in, sh_node_hue_sat_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_exec(&ntype, NULL, NULL, node_shader_exec_hue_sat); diff --git a/source/blender/nodes/shader/nodes/node_shader_ies_light.c b/source/blender/nodes/shader/nodes/node_shader_ies_light.c index 8084f445e34..2714d560862 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ies_light.c +++ b/source/blender/nodes/shader/nodes/node_shader_ies_light.c @@ -52,7 +52,6 @@ void register_node_type_sh_tex_ies(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_IES, "IES Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_ies_in, sh_node_tex_ies_out); node_type_init(&ntype, node_shader_init_tex_ies); node_type_storage(&ntype, "NodeShaderTexIES", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c index b1805946f65..448d305b44e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_invert.c +++ b/source/blender/nodes/shader/nodes/node_shader_invert.c @@ -75,7 +75,6 @@ void register_node_type_sh_invert(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_invert_in, sh_node_invert_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_invert); node_type_gpu(&ntype, gpu_shader_invert); diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c index 53bfad833eb..9c0b0a2f5f6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c +++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c @@ -63,7 +63,6 @@ void register_node_type_sh_layer_weight(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_LAYER_WEIGHT, "Layer Weight", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_layer_weight_in, sh_node_layer_weight_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c index 1dd7a945259..f32570eaeaa 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c +++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c @@ -55,7 +55,6 @@ void register_node_type_sh_light_falloff(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_light_falloff_in, sh_node_light_falloff_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.c b/source/blender/nodes/shader/nodes/node_shader_light_path.c index 0e87da2215b..23d01ad4417 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_path.c +++ b/source/blender/nodes/shader/nodes/node_shader_light_path.c @@ -57,7 +57,6 @@ void register_node_type_sh_light_path(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_LIGHT_PATH, "Light Path", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_light_path_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index fdbf23618ef..a84e88e9551 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -107,7 +107,6 @@ void register_node_type_sh_mapping(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out); node_type_size(&ntype, 320, 160, 360); node_type_init(&ntype, node_shader_init_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index bf594325119..e3c52a9bc03 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -299,7 +299,6 @@ void register_node_type_sh_math(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_math_in, sh_node_math_out); node_type_label(&ntype, node_math_label); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index 054b02b220d..b598859ab8e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -87,7 +87,6 @@ void register_node_type_sh_mix_rgb(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_mix_rgb_in, sh_node_mix_rgb_out); node_type_label(&ntype, node_blend_label); node_type_exec(&ntype, NULL, NULL, node_shader_exec_mix_rgb); diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c index 892b41ab058..1d6c76766b3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c +++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c @@ -52,7 +52,6 @@ void register_node_type_sh_mix_shader(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_MIX_SHADER, "Mix Shader", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_mix_shader_in, sh_node_mix_shader_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c index 265f6ac6fab..121cb9cc1a5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal.c @@ -69,7 +69,6 @@ void register_node_type_sh_normal(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_normal); node_type_gpu(&ntype, gpu_shader_normal); diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c index 0d58be76030..3c0fb145987 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c @@ -111,7 +111,6 @@ void register_node_type_sh_normal_map(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_normal_map_in, sh_node_normal_map_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_normal_map); diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.c b/source/blender/nodes/shader/nodes/node_shader_object_info.c index 623df319690..713e2f749f7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_object_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_object_info.c @@ -52,7 +52,6 @@ void register_node_type_sh_object_info(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OBJECT_INFO, "Object Info", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_object_info_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c index 4eb81f4cb5e..f44f5d332cf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c @@ -39,8 +39,7 @@ void register_node_type_sh_output_lamp(void) { static bNodeType ntype; - sh_node_type_base(&ntype, SH_NODE_OUTPUT_LAMP, "Light Output", NODE_CLASS_OUTPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); + sh_node_type_base(&ntype, SH_NODE_OUTPUT_LIGHT, "Light Output", NODE_CLASS_OUTPUT, 0); node_type_socket_templates(&ntype, sh_node_output_lamp_in, NULL); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c index 2eb68f23912..b56d6eca44b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.c @@ -43,7 +43,6 @@ void register_node_type_sh_output_linestyle(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OUTPUT_LINESTYLE, "Line Style Output", NODE_CLASS_OUTPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_output_linestyle_in, NULL); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c index 05837e79f82..81a89177351 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c @@ -55,7 +55,6 @@ void register_node_type_sh_output_material(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OUTPUT_MATERIAL, "Material Output", NODE_CLASS_OUTPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_output_material_in, NULL); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c index 2c115bdda20..1980e6be5a3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_world.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c @@ -51,7 +51,6 @@ void register_node_type_sh_output_world(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_OUTPUT_WORLD, "World Output", NODE_CLASS_OUTPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_output_world_in, NULL); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c index 73c95fa2ba7..34c4d364fac 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c @@ -62,7 +62,6 @@ void register_node_type_sh_particle_info(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING); node_type_socket_templates(&ntype, NULL, outputs); node_type_exec(&ntype, NULL, NULL, node_shader_exec_particle_info); node_type_gpu(&ntype, gpu_shader_particle_info); diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c index dce7e5354e1..0ddad803270 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c @@ -49,7 +49,6 @@ void register_node_type_sh_rgb(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_RGB, "RGB", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_rgb_out); node_type_gpu(&ntype, gpu_shader_rgb); diff --git a/source/blender/nodes/shader/nodes/node_shader_script.c b/source/blender/nodes/shader/nodes/node_shader_script.c index 888e502a7f6..2d13fc214be 100644 --- a/source/blender/nodes/shader/nodes/node_shader_script.c +++ b/source/blender/nodes/shader/nodes/node_shader_script.c @@ -68,7 +68,6 @@ void register_node_type_sh_script(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SCRIPT, "Script", NODE_CLASS_SCRIPT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_init(&ntype, init); node_type_storage(&ntype, "NodeShaderScript", node_free_script, node_copy_script); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c index 148f8e99c8f..09cd997f86b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c @@ -63,7 +63,6 @@ void register_node_type_sh_sephsv(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_sephsv); node_type_gpu(&ntype, gpu_shader_sephsv); @@ -104,7 +103,6 @@ void register_node_type_sh_combhsv(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_combhsv); node_type_gpu(&ntype, gpu_shader_combhsv); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c index bd914399a28..b4810b95d4b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c @@ -64,7 +64,6 @@ void register_node_type_sh_seprgb(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_seprgb); node_type_gpu(&ntype, gpu_shader_seprgb); @@ -108,7 +107,6 @@ void register_node_type_sh_combrgb(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_combrgb); node_type_gpu(&ntype, gpu_shader_combrgb); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c index ba8bf565ca8..bff8e38b8c8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c @@ -54,7 +54,6 @@ void register_node_type_sh_sepxyz(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_sepxyz_in, sh_node_sepxyz_out); node_type_gpu(&ntype, gpu_shader_sepxyz); @@ -85,7 +84,6 @@ void register_node_type_sh_combxyz(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_combxyz_in, sh_node_combxyz_out); node_type_gpu(&ntype, gpu_shader_combxyz); diff --git a/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c b/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c index c565c311efc..8617e3414b5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.c @@ -51,7 +51,6 @@ void register_node_type_sh_shadertorgb(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SHADERTORGB, "Shader to RGB", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_shadertorgb_in, sh_node_shadertorgb_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c index e46494efd34..51167db857b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c +++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c @@ -66,7 +66,6 @@ void register_node_type_sh_squeeze(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SQUEEZE, "Squeeze Value", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_squeeze_in, sh_node_squeeze_out); node_type_storage(&ntype, "", NULL, NULL); node_type_exec(&ntype, NULL, NULL, node_shader_exec_squeeze); diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c index 60442a46da1..57fb9026595 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c @@ -90,7 +90,6 @@ void register_node_type_sh_subsurface_scattering(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SUBSURFACE_SCATTERING, "Subsurface Scattering", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_subsurface_scattering_in, sh_node_subsurface_scattering_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_subsurface_scattering); diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c index f2c59ec8fd8..da3a8e39ccb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tangent.c +++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c @@ -69,7 +69,6 @@ void register_node_type_sh_tangent(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TANGENT, "Tangent", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_tangent_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_tangent); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c index 67fe6d08ffd..227df5e8e56 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c @@ -92,7 +92,6 @@ void register_node_type_sh_tex_brick(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_brick_in, sh_node_tex_brick_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_tex_brick); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c index 633cc9a1d0e..4e065ffde23 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c @@ -70,7 +70,6 @@ void register_node_type_sh_tex_checker(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_CHECKER, "Checker Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_checker_in, sh_node_tex_checker_out); node_type_init(&ntype, node_shader_init_tex_checker); node_type_storage(&ntype, "NodeTexChecker", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c index 360b28d768a..002fdc6d3ae 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c @@ -70,7 +70,6 @@ void register_node_type_sh_tex_coord(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_COORD, "Texture Coordinate", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_tex_coord_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index 02b784ca540..3e52a6c3d7d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -97,7 +97,6 @@ void register_node_type_sh_tex_environment(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_ENVIRONMENT, "Environment Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_environment_in, sh_node_tex_environment_out); node_type_init(&ntype, node_shader_init_tex_environment); node_type_storage(&ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c index 0721a24688f..06f3773e6d8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c @@ -70,7 +70,6 @@ void register_node_type_sh_tex_gradient(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_GRADIENT, "Gradient Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_gradient_in, sh_node_tex_gradient_out); node_type_init(&ntype, node_shader_init_tex_gradient); node_type_storage(&ntype, "NodeTexGradient", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index e27cf02f445..55669b57998 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -121,7 +121,6 @@ void register_node_type_sh_tex_image(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_IMAGE, "Image Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_image_in, sh_node_tex_image_out); node_type_init(&ntype, node_shader_init_tex_image); node_type_storage(&ntype, "NodeTexImage", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c index 14e6cbf337e..deb81b7b78f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c @@ -73,7 +73,6 @@ void register_node_type_sh_tex_magic(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_magic_in, sh_node_tex_magic_out); node_type_init(&ntype, node_shader_init_tex_magic); node_type_storage(&ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c index 48ab45895bc..03f401e7f01 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c @@ -77,7 +77,6 @@ void register_node_type_sh_tex_musgrave(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_musgrave_in, sh_node_tex_musgrave_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_tex_musgrave); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c index 2f6994c6533..e2879528a5f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c @@ -70,7 +70,6 @@ void register_node_type_sh_tex_noise(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out); node_type_init(&ntype, node_shader_init_tex_noise); node_type_storage(&ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c index 436eeeefb4a..1c5f53132bd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c @@ -85,7 +85,6 @@ void register_node_type_sh_tex_pointdensity(void) "Point Density", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_pointdensity_in, sh_node_tex_pointdensity_out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index 8a17ee1e0d2..821d4b41d09 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -70,7 +70,6 @@ void register_node_type_sh_tex_sky(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_SKY, "Sky Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_sky_in, sh_node_tex_sky_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_tex_sky); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c index 7f30d244da6..36b6174059a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c @@ -72,7 +72,6 @@ void register_node_type_sh_tex_voronoi(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_VORONOI, "Voronoi Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_voronoi_in, sh_node_tex_voronoi_out); node_type_init(&ntype, node_shader_init_tex_voronoi); node_type_storage(&ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c index a9071fdbdd4..2b06f66eb63 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c @@ -76,7 +76,6 @@ void register_node_type_sh_tex_wave(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_tex_wave_in, sh_node_tex_wave_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_tex_wave); diff --git a/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c b/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c index 67342e1e836..023f5417e22 100644 --- a/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c +++ b/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.c @@ -40,7 +40,6 @@ void register_node_type_sh_uvalongstroke(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_UVALONGSTROKE, "UV Along Stroke", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_uvalongstroke_out); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_uvmap.c b/source/blender/nodes/shader/nodes/node_shader_uvmap.c index c47bb9022b6..9da1056b47f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_uvmap.c +++ b/source/blender/nodes/shader/nodes/node_shader_uvmap.c @@ -56,7 +56,6 @@ void register_node_type_sh_uvmap(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_UVMAP, "UV Map", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_uvmap_out); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, node_shader_init_uvmap); diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index a1879df3a18..b6581cb18cb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -77,7 +77,6 @@ void register_node_type_sh_valtorgb(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_valtorgb_in, sh_node_valtorgb_out); node_type_init(&ntype, node_shader_init_valtorgb); node_type_size_preset(&ntype, NODE_SIZE_LARGE); @@ -120,7 +119,6 @@ void register_node_type_sh_rgbtobw(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_rgbtobw_in, sh_node_rgbtobw_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_rgbtobw); node_type_gpu(&ntype, gpu_shader_rgbtobw); diff --git a/source/blender/nodes/shader/nodes/node_shader_value.c b/source/blender/nodes/shader/nodes/node_shader_value.c index a1b8717cebc..a143b0118e7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_value.c +++ b/source/blender/nodes/shader/nodes/node_shader_value.c @@ -49,7 +49,6 @@ void register_node_type_sh_value(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_value_out); node_type_gpu(&ntype, gpu_shader_value); diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c index ca5291e6041..8087e1cab41 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c +++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c @@ -141,7 +141,6 @@ void register_node_type_sh_vect_math(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VECT_MATH, "Vector Math", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_vect_math_in, sh_node_vect_math_out); node_type_label(&ntype, node_vect_math_label); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c index d0b16dd5886..63964e27d20 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c +++ b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c @@ -136,7 +136,6 @@ void register_node_type_sh_vect_transform(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VECT_TRANSFORM, "Vector Transform", NODE_CLASS_OP_VECTOR, 0); - node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_init(&ntype, node_shader_init_vect_transform); node_type_socket_templates(&ntype, sh_node_vect_transform_in, sh_node_vect_transform_out); node_type_storage(&ntype, "NodeShaderVectTransform", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c index 79b41509fcc..2a40d98baf9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c +++ b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c @@ -73,7 +73,6 @@ void register_node_type_sh_vector_displacement(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VECTOR_DISPLACEMENT, "Vector Displacement", NODE_CLASS_OP_VECTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_vector_displacement_in, sh_node_vector_displacement_out); node_type_storage(&ntype, "", NULL, NULL); node_type_init(&ntype, node_shader_init_vector_displacement); diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c index 518ab6587b2..d0ba43d1a15 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c +++ b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.c @@ -51,7 +51,6 @@ void register_node_type_sh_volume_absorption(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VOLUME_ABSORPTION, "Volume Absorption", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_volume_absorption_in, sh_node_volume_absorption_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c index 40d24df6845..a88a7ebb21a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c +++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c @@ -153,7 +153,6 @@ void register_node_type_sh_volume_principled(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VOLUME_PRINCIPLED, "Principled Volume", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_volume_principled_in, sh_node_volume_principled_out); node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, node_shader_init_volume_principled); diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c index 34ba179b4a3..0f97d08803a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c +++ b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.c @@ -52,7 +52,6 @@ void register_node_type_sh_volume_scatter(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VOLUME_SCATTER, "Volume Scatter", NODE_CLASS_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_volume_scatter_in, sh_node_volume_scatter_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_wavelength.c b/source/blender/nodes/shader/nodes/node_shader_wavelength.c index f903e314edf..edc4333c000 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wavelength.c +++ b/source/blender/nodes/shader/nodes/node_shader_wavelength.c @@ -44,7 +44,6 @@ void register_node_type_sh_wavelength(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_WAVELENGTH, "Wavelength", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_socket_templates(&ntype, sh_node_wavelength_in, sh_node_wavelength_out); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.c b/source/blender/nodes/shader/nodes/node_shader_wireframe.c index 0b9f3ac347a..11d889def31 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wireframe.c +++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.c @@ -44,7 +44,6 @@ void register_node_type_sh_wireframe(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_WIREFRAME, "Wireframe", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_wireframe_in, sh_node_wireframe_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); -- cgit v1.2.3 From a6340a5068fd6ed8117ce8618f8b5901f324204d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 6 Jul 2018 18:53:51 +0200 Subject: Viewport: in Lookdev shading, disable scene lights and world by default. Now we light with just a user defined HDRI by default, which is useful for material setup and texture painting and lighting without having to set up any scene lights. Previously it would use the scene world without lights by default, which in some files is just black. --- release/datafiles/studiolights/world/sl02.jpg | Bin 49661 -> 0 bytes release/scripts/startup/bl_ui/space_view3d.py | 20 ++++++++------ source/blender/blenkernel/BKE_studiolight.h | 2 +- source/blender/draw/engines/eevee/eevee_lookdev.c | 6 ++--- source/blender/draw/engines/eevee/eevee_private.h | 3 ++- source/blender/makesdna/DNA_view3d_types.h | 3 ++- source/blender/makesrna/intern/rna_space.c | 31 ++++++++++++++++------ 7 files changed, 43 insertions(+), 22 deletions(-) delete mode 100644 release/datafiles/studiolights/world/sl02.jpg diff --git a/release/datafiles/studiolights/world/sl02.jpg b/release/datafiles/studiolights/world/sl02.jpg deleted file mode 100644 index 1c9ce99a0d8..00000000000 Binary files a/release/datafiles/studiolights/world/sl02.jpg and /dev/null differ diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index ce764ef98c7..fa37197f3ff 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3755,14 +3755,18 @@ class VIEW3D_PT_shading_lighting(Panel): sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') elif shading.type == 'MATERIAL': - row = layout.row() - row.template_icon_view(shading, "studio_light", show_labels=True) - sub = row.column() - sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') - if shading.selected_studio_light.orientation == 'WORLD': - layout.row().prop(shading, "studiolight_rotate_z") - layout.row().prop(shading, "studiolight_background_alpha") - layout.prop(shading, "use_scene_light") + col = layout.column(align=True) + col.prop(shading, "use_scene_lights") + col.prop(shading, "use_scene_world") + + if not shading.use_scene_world: + row = layout.row() + row.template_icon_view(shading, "studio_light", show_labels=True) + sub = row.column() + sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') + if shading.selected_studio_light.orientation == 'WORLD': + layout.row().prop(shading, "studiolight_rotate_z") + layout.row().prop(shading, "studiolight_background_alpha") class VIEW3D_PT_shading_color(Panel): diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h index f8a9498724e..fee01fa8abb 100644 --- a/source/blender/blenkernel/BKE_studiolight.h +++ b/source/blender/blenkernel/BKE_studiolight.h @@ -103,7 +103,7 @@ enum StudioLightFlag { #define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE) #define STUDIOLIGHT_FLAG_ORIENTATIONS (STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_VIEWNORMAL) -#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_WORLD) +#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_ORIENTATION_WORLD) #define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD) typedef void StudioLightFreeFunction(struct StudioLight *, void *data); diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index e083c9b5eb5..01599177fa4 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -41,9 +41,9 @@ void EEVEE_lookdev_cache_init( EEVEE_StorageList *stl = vedata->stl; const DRWContextState *draw_ctx = DRW_context_state_get(); View3D *v3d = draw_ctx->v3d; - if (LOOK_DEV_MODE_ENABLED(v3d)) { - StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_WORLD); - if ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) { + if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) { + StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE); + if (sl && (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) { struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); GPUTexture *tex = NULL; diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index c2f9d16361d..e9ba6585943 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -95,7 +95,8 @@ extern struct DrawEngineType draw_engine_eevee_type; #define OVERLAY_ENABLED(v3d) ((v3d) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) #define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->drawtype == OB_MATERIAL)) #define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && (v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV)) -#define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHT)))) +#define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS)))) +#define LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && !(v3d->shading.flag & V3D_SHADING_SCENE_WORLD)) /* World shader variations */ enum { diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 806d6f925ba..331eb216f61 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -361,10 +361,11 @@ enum { V3D_SHADING_OBJECT_OUTLINE = (1 << 0), V3D_SHADING_XRAY = (1 << 1), V3D_SHADING_SHADOW = (1 << 2), - V3D_SHADING_SCENE_LIGHT = (1 << 3), + V3D_SHADING_SCENE_LIGHTS = (1 << 3), V3D_SHADING_SPECULAR_HIGHLIGHT = (1 << 4), V3D_SHADING_CAVITY = (1 << 5), V3D_SHADING_MATCAP_FLIP_X = (1 << 6), + V3D_SHADING_SCENE_WORLD = (1 << 7), }; /* View3DShading->color_type */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 4d85d845081..ab83cedd232 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -800,8 +800,13 @@ static int rna_View3DShading_studio_light_get(PointerRNA *ptr) flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE; } StudioLight *sl = BKE_studiolight_find(dna_storage, flag); - BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE); - return sl->index; + if (sl) { + BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE); + return sl->index; + } + else { + return 0; + } } static void rna_View3DShading_studio_light_set(PointerRNA *ptr, int value) @@ -818,7 +823,9 @@ static void rna_View3DShading_studio_light_set(PointerRNA *ptr, int value) flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE; } StudioLight *sl = BKE_studiolight_findindex(value, flag); - BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE); + if (sl) { + BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE); + } } static const EnumPropertyItem *rna_View3DShading_studio_light_itemf( @@ -846,8 +853,10 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf( bool show_studiolight = false; if (sl->flag & STUDIOLIGHT_INTERNAL) { - /* always show internal lights */ - show_studiolight = true; + /* always show internal lights for solid */ + if (v3d->drawtype == OB_SOLID) { + show_studiolight = true; + } } else { switch (v3d->drawtype) { @@ -2479,10 +2488,16 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "use_scene_light", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SCENE_LIGHT); + prop = RNA_def_property(srna, "use_scene_lights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SCENE_LIGHTS); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Scene Lights", "Render lights and light probes of the scene"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "use_scene_world", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SCENE_WORLD); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Scene Light", "Render lights and light probes of the scene"); + RNA_def_property_ui_text(prop, "Scene World", "Use scene world for lighting"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_specular_highlight", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3 From 252207cc7a808bf70f8ef398eb578b58a3f1099d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 7 Jul 2018 08:36:17 +0200 Subject: Cleanup: redundant poll checks --- release/scripts/startup/bl_ui/space_view3d.py | 34 +++------------------------ 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c8f113f558d..0a365c6a20c 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3395,11 +3395,6 @@ class VIEW3D_PT_view3d_properties(Panel): bl_region_type = 'UI' bl_label = "View" - @classmethod - def poll(cls, context): - view = context.space_data - return (view) - def draw(self, context): layout = self.layout @@ -3443,11 +3438,6 @@ class VIEW3D_PT_view3d_cursor(Panel): bl_region_type = 'UI' bl_label = "3D Cursor" - @classmethod - def poll(cls, context): - view = context.space_data - return (view is not None) - def draw(self, context): layout = self.layout @@ -3462,7 +3452,7 @@ class VIEW3D_PT_view3d_name(Panel): @classmethod def poll(cls, context): - return (context.space_data and context.active_object) + return (context.active_object is not None) def draw(self, context): layout = self.layout @@ -3486,11 +3476,6 @@ class VIEW3D_PT_view3d_display(Panel): bl_label = "Display" bl_options = {'DEFAULT_CLOSED'} - @classmethod - def poll(cls, context): - view = context.space_data - return (view) - def draw(self, context): layout = self.layout @@ -3553,9 +3538,7 @@ class VIEW3D_PT_view3d_stereo(Panel): @classmethod def poll(cls, context): scene = context.scene - - multiview = scene.render.use_multiview - return context.space_data and multiview + return scene.render.use_multiview def draw(self, context): layout = self.layout @@ -3640,11 +3623,6 @@ class VIEW3D_PT_view3d_motion_tracking(Panel): bl_label = "Motion Tracking" bl_options = {'DEFAULT_CLOSED'} - @classmethod - def poll(cls, context): - view = context.space_data - return (view) - def draw_header(self, context): view = context.space_data @@ -3785,8 +3763,7 @@ class VIEW3D_PT_view3d_curvedisplay(Panel): @classmethod def poll(cls, context): - editmesh = context.mode == 'EDIT_CURVE' - return (editmesh) + return (context.mode == 'EDIT_CURVE') def draw(self, context): layout = self.layout @@ -3913,11 +3890,6 @@ class VIEW3D_PT_transform_orientations(Panel): bl_label = "Transform Orientations" bl_options = {'DEFAULT_CLOSED'} - @classmethod - def poll(cls, context): - view = context.space_data - return (view) - def draw(self, context): layout = self.layout -- cgit v1.2.3 From 4b373ed086993e5163c8a9a129400747bf6bed1c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 7 Jul 2018 08:48:35 +0200 Subject: Cleanup: pep8 --- .../modules/bl_i18n_utils/bl_extract_messages.py | 50 ++++++++++------- release/scripts/modules/bl_i18n_utils/utils.py | 63 +++++++++++++--------- source/blender/datatoc/datatoc_icon_split.py | 2 +- source/blender/python/simple_enum_gen.py | 38 ++++++------- 4 files changed, 89 insertions(+), 64 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py index bbeb1780355..10a386039c4 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -120,8 +120,11 @@ def check(check_ctxt, msgs, key, msgsrc, settings): key[1][0].isalpha() and not key[1][0].isupper()): not_capitalized.add(key) if end_point is not None: - if (key[1].strip().endswith('.') and not key[1].strip().endswith('...') and - key[1] not in settings.WARN_MSGID_END_POINT_ALLOWED): + if ( + key[1].strip().endswith('.') and + (not key[1].strip().endswith('...')) and + key[1] not in settings.WARN_MSGID_END_POINT_ALLOWED + ): end_point.add(key) if undoc_ops is not None: if key[1] == settings.UNDOC_OPS_STR: @@ -183,8 +186,10 @@ def print_info(reports, pot): # if py_in_rna and key in py_in_rna: # _print("\t\t-> RNA message also used in py UI code!") if spell_errors and spell_errors.get(key): - lines = ["\t\t-> {}: misspelled, suggestions are ({})".format(w, "'" + "', '".join(errs) + "'") - for w, errs in spell_errors[key]] + lines = [ + "\t\t-> {}: misspelled, suggestions are ({})".format(w, "'" + "', '".join(errs) + "'") + for w, errs in spell_errors[key] + ] _print("\n".join(lines)) _print("\t\t{}".format("\n\t\t".join(pot.msgs[key].sources))) @@ -215,13 +220,13 @@ def dump_rna_messages(msgs, reports, settings, verbose=False): """ def class_blacklist(): blacklist_rna_class = {getattr(bpy.types, cls_id) for cls_id in ( - # core classes - "Context", "Event", "Function", "UILayout", "UnknownType", "Property", "Struct", - # registerable classes - "Panel", "Menu", "Header", "RenderEngine", "Operator", "OperatorMacro", "Macro", "KeyingSetInfo", - # window classes - "Window", - ) + # core classes + "Context", "Event", "Function", "UILayout", "UnknownType", "Property", "Struct", + # registerable classes + "Panel", "Menu", "Header", "RenderEngine", "Operator", "OperatorMacro", "Macro", "KeyingSetInfo", + # window classes + "Window", + ) } # More builtin classes we don't need to parse. @@ -380,6 +385,7 @@ def dump_rna_messages(msgs, reports, settings, verbose=False): # Dump Messages operator_categories = {} + def process_cls_list(cls_list): if not cls_list: return @@ -447,6 +453,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings): i18n_contexts = bpy.app.translations.contexts root_paths = tuple(bpy.utils.resource_path(t) for t in ('USER', 'LOCAL', 'SYSTEM')) + def make_rel(path): for rp in root_paths: if path.startswith(rp): @@ -510,6 +517,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings): return [_extract_string_merge(estr_ls, nds_ls) for estr_ls, nds_ls in bag] i18n_ctxt_ids = {v for v in bpy.app.translations.contexts_C_to_py.values()} + def _ctxt_to_ctxt(node): # We must try, to some extend, to get contexts from vars instead of only literal strings... ctxt = extract_strings(node)[0] @@ -561,9 +569,9 @@ def dump_py_messages_from_files(msgs, reports, files, settings): translate_kw = { "text": ((("text_ctxt",), _ctxt_to_ctxt), (("operator",), _op_to_ctxt), - ), - "msgid": ((("msgctxt",), _ctxt_to_ctxt), ), + "msgid": ((("msgctxt",), _ctxt_to_ctxt), + ), "message": (), } @@ -611,7 +619,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings): func_translate_args[func_id] = pgettext_variants_args for func_id in func_ids: func_translate_args[func_id] = pgettext_variants_args - #print(func_translate_args) + # print(func_translate_args) # Break recursive nodes look up on some kind of nodes. # E.g. we don't want to get strings inside subscripts (blah["foo"])! @@ -666,7 +674,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings): if kw.arg == arg_kw: context_elements[arg_kw] = kw.value break - #print(context_elements) + # print(context_elements) for kws, proc in translate_kw[msgid]: if set(kws) <= context_elements.keys(): args = tuple(context_elements[k] for k in kws) @@ -676,7 +684,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings): msgctxts[msgid] = ctxt break - #print(translate_args) + # print(translate_args) # do nothing if not found for arg_kw, (arg_pos, _) in func_args.items(): msgctxt = msgctxts[arg_kw] @@ -706,7 +714,7 @@ def dump_py_messages(msgs, reports, addons, settings, addons_only=False): return [] if os.path.isdir(path): return [os.path.join(dpath, fn) for dpath, _, fnames in os.walk(path) for fn in fnames - if not fn.startswith("_") and fn.endswith(".py")] + if not fn.startswith("_") and fn.endswith(".py")] return [path] files = [] @@ -738,7 +746,9 @@ def dump_src_messages(msgs, reports, settings): pygettexts = tuple(re.compile(r).search for r in settings.PYGETTEXT_KEYWORDS) _clean_str = re.compile(settings.str_clean_re).finditer - clean_str = lambda s: "".join(m.group("clean") for m in _clean_str(s)) + + def clean_str(s): + return "".join(m.group("clean") for m in _clean_str(s)) def dump_src_file(path, rel_path, msgs, reports, settings): def process_entry(_msgctxt, _msgid): @@ -873,10 +883,10 @@ def dump_messages(do_messages, do_checks, settings): process_msg(msgs, settings.DEFAULT_CONTEXT, cat[1], "Language categories’ labels from bl_i18n_utils/settings.py", reports, None, settings) - #pot.check() + # pot.check() pot.unescape() # Strings gathered in py/C source code may contain escaped chars... print_info(reports, pot) - #pot.check() + # pot.check() if do_messages: print("Writing messages…") diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index 5fdb6b88cbf..880721176e0 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -32,9 +32,9 @@ import tempfile #import time from bl_i18n_utils import ( - settings, - utils_rtl, - ) + settings, + utils_rtl, +) import bpy @@ -44,6 +44,8 @@ from bpy.app.translations import locale_explode _valid_po_path_re = re.compile(r"^\S+:[0-9]+$") + + def is_valid_po_path(path): return bool(_valid_po_path_re.match(path)) @@ -57,9 +59,10 @@ def get_best_similar(data): # We also consider to never make a match when len differs more than -len_key / 2, +len_key * 2 (which is valid # as long as use_similar is not below ~0.7). # Gives an overall ~20% of improvement! - #tmp = difflib.get_close_matches(key[1], similar_pool, n=1, cutoff=use_similar) - #if tmp: - #tmp = tmp[0] + + # tmp = difflib.get_close_matches(key[1], similar_pool, n=1, cutoff=use_similar) + # if tmp: + # tmp = tmp[0] tmp = None s = difflib.SequenceMatcher() s.set_seq2(key[1]) @@ -178,9 +181,11 @@ def enable_addons(addons=None, support=None, disable=False, check_only=False): userpref = bpy.context.user_preferences used_ext = {ext.module for ext in userpref.addons} - ret = [mod for mod in addon_utils.modules() - if ((addons and mod.__name__ in addons) or - (not addons and addon_utils.module_bl_info(mod)["support"] in support))] + ret = [ + mod for mod in addon_utils.modules() + if ((addons and mod.__name__ in addons) or + (not addons and addon_utils.module_bl_info(mod)["support"] in support)) + ] if not check_only: for mod in ret: @@ -229,18 +234,21 @@ class I18nMessage: def _get_msgctxt(self): return "".join(self.msgctxt_lines) + def _set_msgctxt(self, ctxt): self.msgctxt_lines = [ctxt] msgctxt = property(_get_msgctxt, _set_msgctxt) def _get_msgid(self): return "".join(self.msgid_lines) + def _set_msgid(self, msgid): self.msgid_lines = [msgid] msgid = property(_get_msgid, _set_msgid) def _get_msgstr(self): return "".join(self.msgstr_lines) + def _set_msgstr(self, msgstr): self.msgstr_lines = [msgstr] msgstr = property(_get_msgstr, _set_msgstr) @@ -250,12 +258,15 @@ class I18nMessage: lstrip2 = len(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM) return ([l[lstrip1:] for l in self.comment_lines if l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE)] + [l[lstrip2:] for l in self.comment_lines - if l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM)]) + if l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM)]) + def _set_sources(self, sources): cmmlines = self.comment_lines.copy() for l in cmmlines: - if (l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE) or - l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM)): + if ( + l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE) or + l.startswith(self.settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM) + ): self.comment_lines.remove(l) lines_src = [] lines_src_custom = [] @@ -791,7 +802,7 @@ class I18nMessages: if len(k) > 1 and src_rna in src_to_msg: k &= src_to_msg[src_rna] msgmap["rna_tip"]["key"] = k - #print(k) + # print(k) btip = getattr(msgs, msgmap["but_tip"]["msgstr"]) #print("button tip: " + btip) if btip and btip not in {rtip, etip}: @@ -1051,12 +1062,13 @@ class I18nMessages: import subprocess with tempfile.NamedTemporaryFile(mode='w+', encoding="utf-8") as tmp_po_f: self.write_messages_to_po(tmp_po_f) - cmd = (self.settings.GETTEXT_MSGFMT_EXECUTABLE, - "--statistics", # show stats - tmp_po_f.name, - "-o", - fname, - ) + cmd = ( + self.settings.GETTEXT_MSGFMT_EXECUTABLE, + "--statistics", # show stats + tmp_po_f.name, + "-o", + fname, + ) print("Running ", " ".join(cmd)) ret = subprocess.call(cmd) print("Finished.") @@ -1081,6 +1093,7 @@ class I18nMessages: EOT = b"0x04" # Used to concatenate context and msgid _msgid_offset = 0 _msgstr_offset = 0 + def _gen(v): nonlocal _msgid_offset, _msgstr_offset msgid = v.msgid.encode("utf-8") @@ -1188,6 +1201,7 @@ class I18n: def _py_file_get(self): return self.src.get(self.settings.PARSER_PY_ID) + def _py_file_set(self, value): self.src[self.settings.PARSER_PY_ID] = value py_file = property(_py_file_get, _py_file_set) @@ -1252,7 +1266,8 @@ class I18n: _ctx_txt = "s are" else: _ctx_txt = " is" - lines = (("", + lines = (( + "", "Average stats for all {} translations:\n".format(self.nbr_trans), " {:>6.1%} done!\n".format(self.lvl / self.nbr_trans), " {:>6.1%} of messages are tooltips.\n".format(self.lvl_ttips / self.nbr_trans), @@ -1350,10 +1365,10 @@ class I18n: comment_lines = [self.settings.PO_COMMENT_PREFIX + c for c in user_comments] + common_comment_lines self.trans[uid].msgs[key] = I18nMessage(ctxt, [key[1]], [msgstr], comment_lines, False, is_fuzzy, settings=self.settings) - #key = self.settings.PO_HEADER_KEY - #for uid, trans in self.trans.items(): - #if key not in trans.msgs: - #trans.msgs[key] + # key = self.settings.PO_HEADER_KEY + # for uid, trans in self.trans.items(): + # if key not in trans.msgs: + # trans.msgs[key] self.unescape() def write(self, kind, langs=set()): diff --git a/source/blender/datatoc/datatoc_icon_split.py b/source/blender/datatoc/datatoc_icon_split.py index faf8d57be77..e7cc3a71446 100755 --- a/source/blender/datatoc/datatoc_icon_split.py +++ b/source/blender/datatoc/datatoc_icon_split.py @@ -101,7 +101,7 @@ def write_subimage(sub_x, sub_y, sub_w, sub_h, sub_w, sub_h, sub_x, sub_y, # redundant but including to maintain consistency - pixel_w, pixel_h, + pixel_w, pixel_h, )) for y in range(sub_h): diff --git a/source/blender/python/simple_enum_gen.py b/source/blender/python/simple_enum_gen.py index 8ac5c782821..4f3159b9b25 100644 --- a/source/blender/python/simple_enum_gen.py +++ b/source/blender/python/simple_enum_gen.py @@ -1,22 +1,22 @@ - # ***** BEGIN GPL LICENSE BLOCK ***** - # - # This program is free software; you can redistribute it and/or - # modify it under the terms of the GNU General Public License - # as published by the Free Software Foundation; either version 2 - # of the License, or (at your option) any later version. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program; if not, write to the Free Software Foundation, - # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - # - # Contributor(s): Campbell Barton - # - # #**** END GPL LICENSE BLOCK #**** +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +# defs = """ SPACE_EMPTY, -- cgit v1.2.3 From 0f1000ce0b296c1a6e4de3534dd3f3b51926167c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 7 Jul 2018 08:58:37 +0200 Subject: Cleanup: pep8, style --- release/scripts/startup/bl_ui/space_dopesheet.py | 2 +- release/scripts/startup/bl_ui/space_outliner.py | 31 +++++++++++++----------- release/scripts/startup/bl_ui/space_view3d.py | 4 +-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index 92022e019cc..1b89cfd470d 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -283,7 +283,7 @@ class DOPESHEET_HT_editor_buttons(Header): row = layout.row(align=True) row.operator("action.copy", text="", icon='COPYDOWN') row.operator("action.paste", text="", icon='PASTEDOWN') - if st.mode not in ('GPENCIL', 'MASK'): + if st.mode not in {'GPENCIL', 'MASK'}: row.operator("action.paste", text="", icon='PASTEFLIPDOWN').flipped = True diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index 37a5804f12c..965de6b1ce1 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -260,28 +260,31 @@ class OUTLINER_PT_filter(Panel): col = layout.column(align=True) - col.prop(space, "use_filter_collection", text="Collections", icon="GROUP") - col.prop(space, "use_filter_object", text="Objects", icon="OBJECT_DATAMODE") + col.prop(space, "use_filter_collection", text="Collections", icon='GROUP') + col.prop(space, "use_filter_object", text="Objects", icon='OBJECT_DATAMODE') sub = col.column(align=True) sub.active = space.use_filter_object if bpy.data.meshes: - sub.prop(space, "use_filter_object_mesh", text="Meshes", icon="MESH_DATA") + sub.prop(space, "use_filter_object_mesh", text="Meshes", icon='MESH_DATA') if bpy.data.armatures: - sub.prop(space, "use_filter_object_armature", text="Armatures", icon="ARMATURE_DATA") + sub.prop(space, "use_filter_object_armature", text="Armatures", icon='ARMATURE_DATA') if bpy.data.lights: - sub.prop(space, "use_filter_object_light", text="Lights", icon="LIGHT_DATA") + sub.prop(space, "use_filter_object_light", text="Lights", icon='LIGHT_DATA') if bpy.data.cameras: - sub.prop(space, "use_filter_object_camera", text="Cameras", icon="CAMERA_DATA") - - sub.prop(space, "use_filter_object_empty", text="Empties", icon="EMPTY_DATA") - - if bpy.data.curves or \ - bpy.data.metaballs or \ - bpy.data.lightprobes or \ - bpy.data.lattices or \ - bpy.data.fonts or bpy.data.speakers: + sub.prop(space, "use_filter_object_camera", text="Cameras", icon='CAMERA_DATA') + + sub.prop(space, "use_filter_object_empty", text="Empties", icon='EMPTY_DATA') + + if ( + bpy.data.curves or + bpy.data.metaballs or + bpy.data.lightprobes or + bpy.data.lattices or + bpy.data.fonts or + bpy.data.speakers + ): sub.prop(space, "use_filter_object_others", text="Others") subsub = sub.column(align=False) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 8a3acd033f3..b0abb1b3117 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -136,7 +136,7 @@ class VIEW3D_HT_header(Header): trans_icon = getattr(trans_orientation, "icon", "BLANK1") trans_name = getattr(trans_orientation, "name", "Orientation") else: - trans_icon = "VISIBLE_IPO_OFF" + trans_icon = 'VISIBLE_IPO_OFF' trans_name = getattr(current_orientation, "name", "Orientation") row = layout.row(align=True) @@ -3761,7 +3761,7 @@ class VIEW3D_PT_shading_color(Panel): def poll(cls, context): view = context.space_data shading = view.shading - return shading.type in ['SOLID'] + return shading.type == 'SOLID' def draw(self, context): layout = self.layout -- cgit v1.2.3 From 97cd8bfae19666554db17c42b3d2a7cfa16498f8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 7 Jul 2018 11:27:48 +0200 Subject: Cleanup: isinstance can take multiple types --- release/scripts/modules/bpy_extras/keyconfig_utils.py | 4 ++-- release/scripts/startup/bl_ui/properties_texture.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index 92674bfc5f6..3a9570a57c4 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -240,9 +240,9 @@ def _export_properties(prefix, properties, kmi_id, lines=None): lines = [] def string_value(value): - if isinstance(value, str) or isinstance(value, bool) or isinstance(value, float) or isinstance(value, int): + if isinstance(value, (str, bool, float, int)): return repr(value) - elif getattr(value, '__len__', False): + elif hasattr(value, "__len__"): return repr(list(value)) print("Export key configuration: can't write ", value) diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 7da34782364..018f3df6f0d 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -1203,7 +1203,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel): col.prop(tex, "invert", text="Negative") col.prop(tex, "use_stencil") - if isinstance(idblock, Material) or isinstance(idblock, World): + if isinstance(idblock, (Material, World)): col.prop(tex, "default_value", text="DVar", slider=True) if isinstance(idblock, Material): -- cgit v1.2.3 From 5480de3fca8dc4841670e96cdf02759f6ad5e8d2 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 7 Jul 2018 14:41:29 +0300 Subject: Fix scale in Apply Pose As Rest Pose for bendy bones. Scale is multiplicative, and adding it up causes the bone to bloat. --- source/blender/editors/armature/pose_transform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 43dfa2f13d7..2d8f5dbecbe 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -164,8 +164,8 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) curbone->roll2 += pchan->roll2; curbone->ease1 += pchan->ease1; curbone->ease2 += pchan->ease2; - curbone->scaleIn += pchan->scaleIn; - curbone->scaleOut += pchan->scaleOut; + curbone->scaleIn *= pchan->scaleIn; + curbone->scaleOut *= pchan->scaleOut; pchan->curveInX = pchan->curveOutX = 0.0f; pchan->curveInY = pchan->curveOutY = 0.0f; -- cgit v1.2.3 From f7bce99e4dced41b24364dbe247a508f4cc89742 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 7 Jul 2018 19:50:10 +0200 Subject: Keymap: support for reading/writing keymaps as data Instead of running code to create a keymap, store them as data. This allows for keymaps to share content as well as running transformations at load time. --- release/scripts/modules/bpy/utils/__init__.py | 9 +- .../scripts/modules/bpy_extras/keyconfig_utils.py | 7 + .../bpy_extras/keyconfig_utils_experimental.py | 244 +++++++++++++++++++++ release/scripts/startup/bl_operators/wm.py | 2 +- 4 files changed, 259 insertions(+), 3 deletions(-) create mode 100644 release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index 5e5a35b9518..b3257c30a97 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -581,8 +581,13 @@ def keyconfig_set(filepath, report=None): try: error_msg = "" with open(filepath, 'r', encoding='utf-8') as keyfile: - exec(compile(keyfile.read(), filepath, "exec"), - {"__file__": filepath}) + exec( + compile(keyfile.read(), filepath, "exec"), + { + "__file__": filepath, + "__name__": "__main__", + } + ) except: import traceback error_msg = traceback.format_exc() diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index 198fa787abe..a078da2ff2f 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -405,3 +405,10 @@ def keyconfig_test(kc): if testEntry(kc, entry): result = True return result + +# Note, we may eventually replace existing logic with this +# so key configs are always data. +from .keyconfig_utils_experimental import ( + keyconfig_export_as_data, + keyconfig_import_from_data, +) diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py b/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py new file mode 100644 index 00000000000..cb483901d83 --- /dev/null +++ b/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py @@ -0,0 +1,244 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +__all__ = ( + "keyconfig_export_as_data", + "keyconfig_import_from_data", +) + + +def indent(levels): + return levels * " " + + +def round_float_32(f): + from struct import pack, unpack + return unpack("f", pack("f", f))[0] + + +def repr_f32(f): + f_round = round_float_32(f) + f_str = repr(f) + f_str_frac = f_str.partition(".")[2] + if not f_str_frac: + return f_str + for i in range(1, len(f_str_frac)): + f_test = round(f, i) + f_test_round = round_float_32(f_test) + if f_test_round == f_round: + return "%.*f" % (i, f_test) + return f_str + + +def kmi_args_as_data(kmi): + s = [ + f"\"type\": '{kmi.type}'", + f"\"value\": '{kmi.value}'" + ] + + if kmi.any: + s.append("\"any\": True") + else: + if kmi.shift: + s.append("\"shift\": True") + if kmi.ctrl: + s.append("\"ctrl\": True") + if kmi.alt: + s.append("\"alt\": True") + if kmi.oskey: + s.append("\"oskey\": True") + if kmi.key_modifier and kmi.key_modifier != 'NONE': + s.append(f"\"key_modifier\": '{kmi.key_modifier}'") + + return "{" + ", ".join(s) + "}" + + +def _kmi_properties_to_lines_recursive(level, properties, lines): + from bpy.types import OperatorProperties + + def string_value(value): + if isinstance(value, (str, bool, int)): + return repr(value) + elif isinstance(value, float): + return repr_f32(value) + elif getattr(value, '__len__', False): + return repr(tuple(value)) + raise Exception(f"Export key configuration: can't write {value!r}") + + for pname in properties.bl_rna.properties.keys(): + if pname != "rna_type": + value = getattr(properties, pname) + if isinstance(value, OperatorProperties): + lines_test = [] + _kmi_properties_to_lines_recursive(level + 2, value, lines_test) + if lines_test: + lines.append(f"{indent(level)}(\n") + lines.append(f"{indent(level + 1)}\"{pname}\",\n") + lines.append(f"{indent(level + 1)}" "[\n") + lines.extend(lines_test) + lines.append(f"{indent(level + 1)}" "],\n") + lines.append(f"{indent(level)}" "),\n") + del lines_test + elif properties.is_property_set(pname): + value = string_value(value) + lines.append((f"{indent(level)}(\"{pname}\", {value:s}),\n")) + + +def _kmi_properties_to_lines(level, kmi_props, lines): + if kmi_props is None: + return + + lines_test = [f"{indent(level)}\"properties\": " "[\n"] + _kmi_properties_to_lines_recursive(level + 1, kmi_props, lines_test) + if len(lines_test) > 1: + lines_test.append(f"{indent(level)}" "],\n") + lines.extend(lines_test) + + +def _kmi_attrs_or_none(level, kmi): + lines = [] + _kmi_properties_to_lines(level + 1, kmi.properties, lines) + if kmi.active is False: + lines.append(f"{indent(level)}\"active\":" "False,\n") + if not lines: + return None + return "".join(lines) + + +def keyconfig_export_as_data(wm, kc, filepath): + # Alternate foramt + + # Generate a list of keymaps to export: + # + # First add all user_modified keymaps (found in keyconfigs.user.keymaps list), + # then add all remaining keymaps from the currently active custom keyconfig. + # + # This will create a final list of keymaps that can be used as a "diff" against + # the default blender keyconfig, recreating the current setup from a fresh blender + # without needing to export keymaps which haven't been edited. + + from .keyconfig_utils import keyconfig_merge + + class FakeKeyConfig: + keymaps = [] + edited_kc = FakeKeyConfig() + for km in wm.keyconfigs.user.keymaps: + if km.is_user_modified or True: + edited_kc.keymaps.append(km) + # merge edited keymaps with non-default keyconfig, if it exists + if kc != wm.keyconfigs.default: + export_keymaps = keyconfig_merge(edited_kc, kc) + else: + export_keymaps = keyconfig_merge(edited_kc, edited_kc) + + with open(filepath, "w") as fh: + fw = fh.write + fw("keyconfig_data = [\n") + + for km, kc_x in export_keymaps: + km = km.active() + fw(f"{indent(1)}" "(\n") + fw(f"{indent(2)}" f"\"{km.name:s}\",\n") + fw(f"{indent(2)}" "{") + fw(f"\"space_type\": '{km.space_type:s}'") + fw(f", \"region_type\": '{km.region_type:s}'") + # We can detect from the kind of items. + if km.is_modal: + fw(", \"modal\": True") + fw("},\n") + fw(f"{indent(2)}" "{\n") + is_modal = km.is_modal + fw(f"{indent(3)}" "\"items\": [\n") + for kmi in km.keymap_items: + if is_modal: + kmi_id = kmi.propvalue + else: + kmi_id = kmi.idname + + fw(f"{indent(4)}" "(") + kmi_args = kmi_args_as_data(kmi) + kmi_data = _kmi_attrs_or_none(5, kmi) + if kmi_data is not None: + fw("\n" f"{indent(5)}") + fw(f"\"{kmi_id:s}\"") + if kmi_data is None: + fw(f", ") + else: + fw(",\n" f"{indent(5)}") + + fw(kmi_args) + if kmi_data is None: + fw(", None),\n") + else: + fw(",\n") + fw(f"{indent(5)}" "{\n") + fw(kmi_data) + fw(f"{indent(5)}" "}\n") + fw(f"{indent(4)}" "),\n") + + fw(f"{indent(3)}" "],\n") + fw(f"{indent(2)}" "},\n") + fw(f"{indent(1)}" "),\n") + fw("]\n") + fw("\n\n") + fw("if __name__ == \"__main__\":\n") + fw(" import os\n") + fw(" from bpy_extras.keyconfig_utils import keyconfig_import_from_data\n") + fw(" keyconfig_import_from_data(os.path.splitext(os.path.basename(__file__))[0], keyconfig_data)\n") + + +def keyconfig_import_from_data(name, keyconfig_data): + # Load data in the format defined above. + # + # Runs at load time, keep this fast! + + def kmi_props_setattr(kmi_props, attr, value): + if type(value) is list: + kmi_subprop = getattr(kmi_props, attr) + for subattr, subvalue in value: + kmi_props_setattr(kmi_subprop, subattr, subvalue) + return + + try: + setattr(kmi_props, attr, value) + except AttributeError: + print(f"Warning: property '{attr}' not found in keymap item '{kmi_props.__class__.__name__}'") + except Exception as ex: + print(f"Warning: {ex!r}") + + import bpy + wm = bpy.context.window_manager + kc = wm.keyconfigs.new(name) + del name + + for (km_name, km_args, km_content) in keyconfig_data: + km = kc.keymaps.new(km_name, **km_args) + is_modal = km_args.get("modal", False) + new_fn = getattr(km.keymap_items, "new_modal" if is_modal else "new") + for (kmi_idname, kmi_args, kmi_data) in km_content["items"]: + kmi = new_fn(kmi_idname, **kmi_args) + if kmi_data is not None: + if not kmi_data.get("active", True): + kmi.active = False + kmi_props_data = kmi_data.get("properties", None) + if kmi_props_data is not None: + kmi_props = kmi.properties + for attr, value in kmi_props_data: + kmi_props_setattr(kmi_props, attr, value) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index f31ae721fd3..30a90fb11d4 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1636,7 +1636,7 @@ class WM_OT_keyconfig_export(Operator): wm = context.window_manager - keyconfig_utils.keyconfig_export( + keyconfig_utils.keyconfig_export_as_data( wm, wm.keyconfigs.active, self.filepath, -- cgit v1.2.3 From 8467a7a351a52b29780a36a0455a65e61952eb9b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 7 Jul 2018 19:50:37 +0200 Subject: Keymap: store 2.7x map as data instead of running code --- release/scripts/presets/keyconfig/blender_27x.py | 15306 +++++++++++++++------ 1 file changed, 11350 insertions(+), 3956 deletions(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index 5c821bea018..4a394bf3ec7 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -1,3956 +1,11350 @@ -import bpy -from sys import platform - -def kmi_props_setattr(kmi_props, attr, value): - try: - setattr(kmi_props, attr, value) - except AttributeError: - print("Warning: property '%s' not found in keymap item '%s'" % - (attr, kmi_props.__class__.__name__)) - except Exception as e: - print("Warning: %r" % e) - -import os -wm = bpy.context.window_manager -kc = wm.keyconfigs.new(os.path.splitext(os.path.basename(__file__))[0]) -del os - -# Map Image Editor Tool: VIEW, Select Border -km = kc.keymaps.new('Image Editor Tool: VIEW, Select Border', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('uv.select_border', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'deselect', False) - -# Map Image Editor Tool: VIEW, Select Circle -km = kc.keymaps.new('Image Editor Tool: VIEW, Select Circle', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('uv.select_circle', 'ACTIONMOUSE', 'PRESS') - -# Map Image Editor Tool: VIEW, Select Lasso -km = kc.keymaps.new('Image Editor Tool: VIEW, Select Lasso', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('uv.select_lasso', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'deselect', False) - -# Map 3D View Tool: All, Cursor -km = kc.keymaps.new('3D View Tool: All, Cursor', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'cursor_transform', True) -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: OBJECT, Select Border -km = kc.keymaps.new('3D View Tool: OBJECT, Select Border', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.select_border', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('view3d.select_border', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) - -# Map 3D View Tool: OBJECT, Select Circle -km = kc.keymaps.new('3D View Tool: OBJECT, Select Circle', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.select_circle', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('view3d.select_circle', 'ACTIONMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) - -# Map 3D View Tool: OBJECT, Select Lasso -km = kc.keymaps.new('3D View Tool: OBJECT, Select Lasso', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) - -# Map 3D View Tool: OBJECT, Move -km = kc.keymaps.new('3D View Tool: OBJECT, Move', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: OBJECT, Rotate -km = kc.keymaps.new('3D View Tool: OBJECT, Rotate', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.rotate', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: OBJECT, Scale -km = kc.keymaps.new('3D View Tool: OBJECT, Scale', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.resize', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: OBJECT, Ruler/Protractor -km = kc.keymaps.new('3D View Tool: OBJECT, Ruler/Protractor', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.ruler_add', 'EVT_TWEAK_A', 'ANY') - -# Map 3D View Tool: POSE, Breakdowner -km = kc.keymaps.new('3D View Tool: POSE, Breakdowner', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('pose.breakdown', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: POSE, Push -km = kc.keymaps.new('3D View Tool: POSE, Push', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('pose.push', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: POSE, Relax -km = kc.keymaps.new('3D View Tool: POSE, Relax', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('pose.relax', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_ARMATURE, Roll -km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Roll', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'mode', 'BONE_ROLL') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: EDIT_ARMATURE, Bone Size -km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Bone Size', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.transform', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'BONE_SIZE') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: EDIT_ARMATURE, Bone Envelope -km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Bone Envelope', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.transform', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'BONE_ENVELOPE') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: EDIT_ARMATURE, Extrude -km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Extrude', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('armature.click_extrude', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_ARMATURE, Extrude to Cursor -km = kc.keymaps.new('3D View Tool: EDIT_ARMATURE, Extrude to Cursor', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('armature.click_extrude', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_MESH, Add Cube -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Add Cube', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'CLICK') -kmi = km.keymap_items.new('mesh.primitive_cube_add_manipulator', 'EVT_TWEAK_A', 'ANY') - -# Map 3D View Tool: EDIT_MESH, Extrude Region -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Extrude Region', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.extrude_context_move', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties.TRANSFORM_OT_translate, 'release_confirm', True) - -# Map 3D View Tool: EDIT_MESH, Extrude Individual -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Extrude Individual', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.extrude_faces_move', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties.TRANSFORM_OT_shrink_fatten, 'release_confirm', True) - -# Map 3D View Tool: EDIT_MESH, Extrude to Cursor -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Extrude to Cursor', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_MESH, Inset Faces -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Inset Faces', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.inset', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: EDIT_MESH, Bevel -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Bevel', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.bevel', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_MESH, Loop Cut -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Loop Cut', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.loopcut_slide', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_MESH, Offset Edge Loop Cut -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Offset Edge Loop Cut', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.offset_edge_loops_slide', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_MESH, Knife -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Knife', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.knife_tool', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) - -# Map 3D View Tool: EDIT_MESH, Bisect -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Bisect', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.bisect', 'EVT_TWEAK_A', 'ANY') - -# Map 3D View Tool: EDIT_MESH, Poly Build -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Poly Build', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.polybuild_face_at_cursor_move', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties.TRANSFORM_OT_translate, 'release_confirm', True) -kmi = km.keymap_items.new('mesh.polybuild_split_at_cursor_move', 'ACTIONMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties.TRANSFORM_OT_translate, 'release_confirm', True) -kmi = km.keymap_items.new('mesh.polybuild_dissolve_at_cursor', 'ACTIONMOUSE', 'CLICK', alt=True) -kmi = km.keymap_items.new('mesh.polybuild_hover', 'MOUSEMOVE', 'ANY', alt=True) -kmi_props_setattr(kmi.properties, 'use_boundary', False) -kmi = km.keymap_items.new('mesh.polybuild_hover', 'MOUSEMOVE', 'ANY', any=True) -kmi_props_setattr(kmi.properties, 'use_boundary', True) - -# Map 3D View Tool: EDIT_MESH, Spin -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Spin', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.spin', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_MESH, Spin (Duplicate) -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Spin (Duplicate)', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.spin', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'dupli', True) - -# Map 3D View Tool: EDIT_MESH, Smooth -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Smooth', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.vertices_smooth', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_MESH, Randomize -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Randomize', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.vertex_random', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_MESH, Edge Slide -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Edge Slide', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.edge_slide', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: EDIT_MESH, Vertex Slide -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Vertex Slide', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.vert_slide', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: EDIT_MESH, Shrink/Fatten -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Shrink/Fatten', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.shrink_fatten', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: EDIT_MESH, Push/Pull -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Push/Pull', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('transform.push_pull', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'release_confirm', True) - -# Map 3D View Tool: EDIT_MESH, Rip Region -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Rip Region', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.rip_move', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties.TRANSFORM_OT_translate, 'release_confirm', True) - -# Map 3D View Tool: EDIT_MESH, Rip Edge -km = kc.keymaps.new('3D View Tool: EDIT_MESH, Rip Edge', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.rip_edge_edge_move', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: EDIT_CURVE, Draw -km = kc.keymaps.new('3D View Tool: EDIT_CURVE, Draw', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('curve.draw', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) - -# Map 3D View Tool: EDIT_CURVE, Extrude Cursor -km = kc.keymaps.new('3D View Tool: EDIT_CURVE, Extrude Cursor', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('curve.vertex_add', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: PARTICLE, Cursor Click -km = kc.keymaps.new('3D View Tool: PARTICLE, Cursor Click', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'CLICK') - -# Map 3D View Tool: PAINT_WEIGHT, Sample Weight -km = kc.keymaps.new('3D View Tool: PAINT_WEIGHT, Sample Weight', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paint.weight_sample', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: PAINT_WEIGHT, Sample Vertex Group -km = kc.keymaps.new('3D View Tool: PAINT_WEIGHT, Sample Vertex Group', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paint.weight_sample_group', 'ACTIONMOUSE', 'PRESS') - -# Map 3D View Tool: PAINT_WEIGHT, Gradient -km = kc.keymaps.new('3D View Tool: PAINT_WEIGHT, Gradient', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paint.weight_gradient', 'EVT_TWEAK_A', 'ANY') - -# Map Window -km = kc.keymaps.new('Window', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('wm.window_new', 'W', 'PRESS', ctrl=True, alt=True) -if platform == "darwin": - kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', oskey=True) - kmi = km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, oskey=True) - kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_file_open_recent') - kmi = km.keymap_items.new('wm.open_mainfile', 'O', 'PRESS', oskey=True) - kmi = km.keymap_items.new('wm.save_mainfile', 'S', 'PRESS', oskey=True) - kmi = km.keymap_items.new('wm.save_as_mainfile', 'S', 'PRESS', shift=True, oskey=True) - kmi = km.keymap_items.new('wm.quit_blender', 'Q', 'PRESS', oskey=True) -kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.save_homefile', 'U', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_file_open_recent') -kmi = km.keymap_items.new('wm.open_mainfile', 'O', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.open_mainfile', 'F1', 'PRESS') -kmi = km.keymap_items.new('wm.link', 'O', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('wm.append', 'F1', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.save_mainfile', 'S', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.save_mainfile', 'W', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.save_as_mainfile', 'S', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('wm.save_as_mainfile', 'F2', 'PRESS') -kmi = km.keymap_items.new('wm.save_as_mainfile', 'S', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'copy', True) -kmi = km.keymap_items.new('wm.window_fullscreen_toggle', 'F11', 'PRESS', alt=True) -kmi = km.keymap_items.new('wm.quit_blender', 'Q', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.doc_view_manual_ui_context', 'F1', 'PRESS', alt=True) -kmi = km.keymap_items.new('wm.redraw_timer', 'T', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('wm.debug_menu', 'D', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('wm.call_menu', 'NDOF_BUTTON_MENU', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'USERPREF_MT_ndof_settings') -kmi = km.keymap_items.new('wm.search_menu', 'SPACE', 'PRESS') -kmi = km.keymap_items.new('wm.context_set_enum', 'F3', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'NODE_EDITOR') -kmi = km.keymap_items.new('wm.context_set_enum', 'F4', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'CONSOLE') -kmi = km.keymap_items.new('wm.context_set_enum', 'F5', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'VIEW_3D') -kmi = km.keymap_items.new('wm.context_set_enum', 'F6', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'GRAPH_EDITOR') -kmi = km.keymap_items.new('wm.context_set_enum', 'F7', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'PROPERTIES') -kmi = km.keymap_items.new('wm.context_set_enum', 'F8', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'SEQUENCE_EDITOR') -kmi = km.keymap_items.new('wm.context_set_enum', 'F9', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'OUTLINER') -kmi = km.keymap_items.new('wm.context_set_enum', 'F10', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'IMAGE_EDITOR') -kmi = km.keymap_items.new('wm.context_set_enum', 'F11', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'TEXT_EDITOR') -kmi = km.keymap_items.new('wm.context_set_enum', 'F12', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'area.type') -kmi_props_setattr(kmi.properties, 'value', 'DOPESHEET_EDITOR') -kmi = km.keymap_items.new('wm.context_scale_float', 'NDOF_BUTTON_PLUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'user_preferences.inputs.ndof_sensitivity') -kmi_props_setattr(kmi.properties, 'value', 1.1) -kmi = km.keymap_items.new('wm.context_scale_float', 'NDOF_BUTTON_MINUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'user_preferences.inputs.ndof_sensitivity') -kmi_props_setattr(kmi.properties, 'value', 1.0 / 1.0) -kmi = km.keymap_items.new('wm.context_scale_float', 'NDOF_BUTTON_PLUS', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'user_preferences.inputs.ndof_sensitivity') -kmi_props_setattr(kmi.properties, 'value', 1.5) -kmi = km.keymap_items.new('wm.context_scale_float', 'NDOF_BUTTON_MINUS', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'user_preferences.inputs.ndof_sensitivity') -kmi_props_setattr(kmi.properties, 'value', 2.0 / 3.0) -kmi = km.keymap_items.new('info.reports_display_update', 'TIMER_REPORT', 'ANY', any=True) - -# Map Screen -km = kc.keymaps.new('Screen', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('screen.animation_step', 'TIMER0', 'ANY', any=True) -kmi = km.keymap_items.new('screen.region_blend', 'TIMERREGION', 'ANY', any=True) -kmi = km.keymap_items.new('screen.screen_set', 'RIGHT_ARROW', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('screen.screen_set', 'LEFT_ARROW', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('screen.screen_full_area', 'SPACE', 'PRESS', shift=True) -kmi = km.keymap_items.new('screen.screen_full_area', 'SPACE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'use_hide_panels', True) -kmi = km.keymap_items.new('screen.screenshot', 'F3', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('screen.screencast', 'F3', 'PRESS', alt=True) -kmi = km.keymap_items.new('screen.space_context_cycle', 'TAB', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'direction', 'NEXT') -kmi = km.keymap_items.new('screen.space_context_cycle', 'TAB', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'direction', 'PREV') -kmi = km.keymap_items.new('screen.region_quadview', 'Q', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('screen.repeat_history', 'F3', 'PRESS') -kmi = km.keymap_items.new('screen.repeat_last', 'R', 'PRESS', shift=True) -kmi = km.keymap_items.new('screen.region_flip', 'F5', 'PRESS') -kmi = km.keymap_items.new('screen.redo_last', 'F6', 'PRESS') -kmi = km.keymap_items.new('script.reload', 'F8', 'PRESS') -kmi = km.keymap_items.new('file.execute', 'RET', 'PRESS') -kmi = km.keymap_items.new('file.execute', 'NUMPAD_ENTER', 'PRESS') -kmi = km.keymap_items.new('file.cancel', 'ESC', 'PRESS') -if platform == "darwin": - kmi = km.keymap_items.new('ed.undo', 'Z', 'PRESS', oskey=True) - kmi = km.keymap_items.new('ed.redo', 'Z', 'PRESS', shift=True, oskey=True) - kmi = km.keymap_items.new('ed.undo_history', 'Z', 'PRESS', alt=True, oskey=True) -kmi = km.keymap_items.new('ed.undo', 'Z', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('ed.redo', 'Z', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('ed.undo_history', 'Z', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('render.render', 'F12', 'PRESS') -kmi_props_setattr(kmi.properties, 'use_viewport', True) -kmi = km.keymap_items.new('render.render', 'F12', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'animation', True) -kmi_props_setattr(kmi.properties, 'use_viewport', True) -kmi = km.keymap_items.new('render.view_cancel', 'ESC', 'PRESS') -kmi = km.keymap_items.new('render.view_show', 'F11', 'PRESS') -kmi = km.keymap_items.new('render.play_rendered_anim', 'F11', 'PRESS', ctrl=True) -if platform == "darwin": - kmi = km.keymap_items.new('screen.userpref_show', 'COMMA', 'PRESS', oskey=True) -kmi = km.keymap_items.new('screen.userpref_show', 'U', 'PRESS', ctrl=True, alt=True) - -# Map User Interface -km = kc.keymaps.new('User Interface', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('ui.eyedropper_color', 'E', 'PRESS') -kmi = km.keymap_items.new('ui.eyedropper_colorband', 'E', 'PRESS') -kmi = km.keymap_items.new('ui.eyedropper_colorband_point', 'E', 'PRESS', alt=True) -kmi = km.keymap_items.new('ui.eyedropper_id', 'E', 'PRESS') -kmi = km.keymap_items.new('ui.eyedropper_depth', 'E', 'PRESS') -kmi = km.keymap_items.new('ui.copy_data_path_button', 'C', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('ui.copy_data_path_button', 'C', 'PRESS', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'full_path', True) -kmi = km.keymap_items.new('anim.keyframe_insert_button', 'I', 'PRESS') -kmi = km.keymap_items.new('anim.keyframe_delete_button', 'I', 'PRESS', alt=True) -kmi = km.keymap_items.new('anim.keyframe_clear_button', 'I', 'PRESS', shift=True, alt=True) -kmi = km.keymap_items.new('anim.driver_button_add', 'D', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('anim.driver_button_remove', 'D', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('anim.keyingset_button_add', 'K', 'PRESS') -kmi = km.keymap_items.new('anim.keyingset_button_remove', 'K', 'PRESS', alt=True) - -# Map View2D -km = kc.keymaps.new('View2D', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view2d.scroller_activate', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.scroller_activate', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.pan', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.pan', 'MIDDLEMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('view2d.pan', 'TRACKPADPAN', 'ANY') -kmi = km.keymap_items.new('view2d.scroll_right', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('view2d.scroll_left', 'WHEELUPMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('view2d.scroll_down', 'WHEELDOWNMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('view2d.scroll_up', 'WHEELUPMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('view2d.ndof', 'NDOF_MOTION', 'ANY') -kmi = km.keymap_items.new('view2d.zoom_out', 'WHEELOUTMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.zoom_in', 'WHEELINMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.zoom_out', 'NUMPAD_MINUS', 'PRESS') -kmi = km.keymap_items.new('view2d.zoom_in', 'NUMPAD_PLUS', 'PRESS') -kmi = km.keymap_items.new('view2d.zoom', 'TRACKPADPAN', 'ANY', ctrl=True) -kmi = km.keymap_items.new('view2d.smoothview', 'TIMER1', 'ANY', any=True) -kmi = km.keymap_items.new('view2d.scroll_down', 'WHEELDOWNMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.scroll_up', 'WHEELUPMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.scroll_right', 'WHEELDOWNMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.scroll_left', 'WHEELUPMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('view2d.zoom', 'TRACKPADZOOM', 'ANY') -kmi = km.keymap_items.new('view2d.zoom_border', 'B', 'PRESS', shift=True) - -# Map Header -km = kc.keymaps.new('Header', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('screen.header_toolbox', 'RIGHTMOUSE', 'PRESS') - -# Map View2D Buttons List -km = kc.keymaps.new('View2D Buttons List', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view2d.scroller_activate', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.scroller_activate', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.pan', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.pan', 'TRACKPADPAN', 'ANY') -kmi = km.keymap_items.new('view2d.scroll_down', 'WHEELDOWNMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.scroll_up', 'WHEELUPMOUSE', 'PRESS') -kmi = km.keymap_items.new('view2d.scroll_down', 'PAGE_DOWN', 'PRESS') -kmi_props_setattr(kmi.properties, 'page', True) -kmi = km.keymap_items.new('view2d.scroll_up', 'PAGE_UP', 'PRESS') -kmi_props_setattr(kmi.properties, 'page', True) -kmi = km.keymap_items.new('view2d.zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('view2d.zoom', 'TRACKPADZOOM', 'ANY') -kmi = km.keymap_items.new('view2d.zoom', 'TRACKPADPAN', 'ANY', ctrl=True) -kmi = km.keymap_items.new('view2d.zoom_out', 'NUMPAD_MINUS', 'PRESS') -kmi = km.keymap_items.new('view2d.zoom_in', 'NUMPAD_PLUS', 'PRESS') -kmi = km.keymap_items.new('view2d.reset', 'HOME', 'PRESS') - -# Map Frames -km = kc.keymaps.new('Frames', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('screen.frame_offset', 'UP_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'delta', 10) -kmi = km.keymap_items.new('screen.frame_offset', 'DOWN_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'delta', -10) -kmi = km.keymap_items.new('screen.frame_offset', 'LEFT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('screen.frame_offset', 'RIGHT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('screen.frame_offset', 'WHEELDOWNMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('screen.frame_offset', 'WHEELUPMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('screen.frame_jump', 'UP_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'end', True) -kmi = km.keymap_items.new('screen.frame_jump', 'DOWN_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'end', False) -kmi = km.keymap_items.new('screen.frame_jump', 'RIGHT_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'end', True) -kmi = km.keymap_items.new('screen.frame_jump', 'LEFT_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'end', False) -kmi = km.keymap_items.new('screen.keyframe_jump', 'UP_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'next', True) -kmi = km.keymap_items.new('screen.keyframe_jump', 'DOWN_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'next', False) -kmi = km.keymap_items.new('screen.keyframe_jump', 'MEDIA_LAST', 'PRESS') -kmi_props_setattr(kmi.properties, 'next', True) -kmi = km.keymap_items.new('screen.keyframe_jump', 'MEDIA_FIRST', 'PRESS') -kmi_props_setattr(kmi.properties, 'next', False) -kmi = km.keymap_items.new('screen.animation_play', 'A', 'PRESS', alt=True) -kmi = km.keymap_items.new('screen.animation_play', 'A', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'reverse', True) -kmi = km.keymap_items.new('screen.animation_cancel', 'ESC', 'PRESS') -kmi = km.keymap_items.new('screen.animation_play', 'MEDIA_PLAY', 'PRESS') -kmi = km.keymap_items.new('screen.animation_cancel', 'MEDIA_STOP', 'PRESS') - -# Map Property Editor -km = kc.keymaps.new('Property Editor', space_type='PROPERTIES', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('buttons.toolbox', 'RIGHTMOUSE', 'PRESS') - -# Map Markers -km = kc.keymaps.new('Markers', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('marker.add', 'M', 'PRESS') -kmi = km.keymap_items.new('marker.move', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('marker.duplicate', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS') -kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'camera', True) -kmi = km.keymap_items.new('marker.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'camera', True) -kmi = km.keymap_items.new('marker.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('marker.select_all', 'A', 'PRESS') -kmi = km.keymap_items.new('marker.delete', 'X', 'PRESS') -kmi = km.keymap_items.new('marker.delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('marker.move', 'G', 'PRESS') -kmi = km.keymap_items.new('marker.camera_bind', 'B', 'PRESS', ctrl=True) - -# Map Animation -km = kc.keymaps.new('Animation', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('anim.change_frame', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('wm.context_toggle', 'T', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_seconds') -kmi = km.keymap_items.new('anim.previewrange_set', 'P', 'PRESS') -kmi = km.keymap_items.new('anim.previewrange_clear', 'P', 'PRESS', alt=True) - -# Map Dopesheet -km = kc.keymaps.new('Dopesheet', space_type='DOPESHEET_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'column', False) -kmi_props_setattr(kmi.properties, 'channel', False) -kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'column', True) -kmi_props_setattr(kmi.properties, 'channel', False) -kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'column', False) -kmi_props_setattr(kmi.properties, 'channel', False) -kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'column', True) -kmi_props_setattr(kmi.properties, 'channel', False) -kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'column', False) -kmi_props_setattr(kmi.properties, 'channel', True) -kmi = km.keymap_items.new('action.clickselect', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'column', False) -kmi_props_setattr(kmi.properties, 'channel', True) -kmi = km.keymap_items.new('action.select_leftright', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'CHECK') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('action.select_leftright', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'CHECK') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('action.select_leftright', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'LEFT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('action.select_leftright', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'RIGHT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('action.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('action.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('action.select_border', 'B', 'PRESS') -kmi_props_setattr(kmi.properties, 'axis_range', False) -kmi = km.keymap_items.new('action.select_border', 'B', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'axis_range', True) -kmi = km.keymap_items.new('action.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('action.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('action.select_circle', 'C', 'PRESS') -kmi = km.keymap_items.new('action.select_column', 'K', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'KEYS') -kmi = km.keymap_items.new('action.select_column', 'K', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'CFRA') -kmi = km.keymap_items.new('action.select_column', 'K', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'MARKERS_COLUMN') -kmi = km.keymap_items.new('action.select_column', 'K', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'MARKERS_BETWEEN') -kmi = km.keymap_items.new('action.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('action.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('action.select_linked', 'L', 'PRESS') -kmi = km.keymap_items.new('action.frame_jump', 'G', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('action.snap', 'S', 'PRESS', shift=True) -kmi = km.keymap_items.new('action.mirror', 'M', 'PRESS', shift=True) -kmi = km.keymap_items.new('action.handle_type', 'V', 'PRESS') -kmi = km.keymap_items.new('action.interpolation_type', 'T', 'PRESS') -kmi = km.keymap_items.new('action.extrapolation_type', 'E', 'PRESS', shift=True) -kmi = km.keymap_items.new('action.keyframe_type', 'R', 'PRESS') -kmi = km.keymap_items.new('action.sample', 'O', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'DOPESHEET_MT_delete') -kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'DOPESHEET_MT_delete') -kmi = km.keymap_items.new('action.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('action.keyframe_insert', 'I', 'PRESS') -kmi = km.keymap_items.new('action.copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('action.paste', 'V', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('action.paste', 'V', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'flipped', True) -if platform == "darwin": - kmi = km.keymap_items.new('action.copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('action.paste', 'V', 'PRESS', oskey=True) - kmi = km.keymap_items.new('action.paste', 'V', 'PRESS', shift=True, oskey=True) - kmi_props_setattr(kmi.properties, 'flipped', True) -kmi = km.keymap_items.new('action.previewrange_set', 'P', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('action.view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('action.view_all', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('action.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('action.view_frame', 'NUMPAD_0', 'PRESS') -kmi = km.keymap_items.new('anim.channels_editable_toggle', 'TAB', 'PRESS') -kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('transform.transform', 'G', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TIME_TRANSLATE') -kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_S', 'ANY') -kmi_props_setattr(kmi.properties, 'mode', 'TIME_TRANSLATE') -kmi = km.keymap_items.new('transform.transform', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TIME_EXTEND') -kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TIME_SCALE') -kmi = km.keymap_items.new('transform.transform', 'T', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'TIME_SLIDE') -kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_proportional_action') -kmi = km.keymap_items.new('marker.add', 'M', 'PRESS') -kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True) - -# Map Dopesheet Generic -km = kc.keymaps.new('Dopesheet Generic', space_type='DOPESHEET_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('action.properties', 'N', 'PRESS') - -# Map Outliner -km = kc.keymaps.new('Outliner', space_type='OUTLINER', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('outliner.highlight_update', 'MOUSEMOVE', 'ANY', any=True) -kmi = km.keymap_items.new('outliner.item_rename', 'LEFTMOUSE', 'DOUBLE_CLICK') -kmi = km.keymap_items.new('outliner.item_activate', 'LEFTMOUSE', 'CLICK') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'recursive', False) -kmi = km.keymap_items.new('outliner.item_activate', 'LEFTMOUSE', 'CLICK', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'recursive', False) -kmi = km.keymap_items.new('outliner.item_activate', 'LEFTMOUSE', 'CLICK', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'recursive', True) -kmi = km.keymap_items.new('outliner.item_activate', 'LEFTMOUSE', 'CLICK', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'recursive', True) -kmi = km.keymap_items.new('outliner.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('outliner.item_openclose', 'RET', 'PRESS') -kmi_props_setattr(kmi.properties, 'all', False) -kmi = km.keymap_items.new('outliner.item_openclose', 'RET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'all', True) -kmi = km.keymap_items.new('outliner.item_rename', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('outliner.operation', 'RIGHTMOUSE', 'PRESS') -kmi = km.keymap_items.new('outliner.item_drag_drop', 'EVT_TWEAK_L', 'ANY') -kmi = km.keymap_items.new('outliner.show_hierarchy', 'HOME', 'PRESS') -kmi = km.keymap_items.new('outliner.show_active', 'PERIOD', 'PRESS') -kmi = km.keymap_items.new('outliner.show_active', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('outliner.scroll_page', 'PAGE_DOWN', 'PRESS') -kmi_props_setattr(kmi.properties, 'up', False) -kmi = km.keymap_items.new('outliner.scroll_page', 'PAGE_UP', 'PRESS') -kmi_props_setattr(kmi.properties, 'up', True) -kmi = km.keymap_items.new('outliner.show_one_level', 'NUMPAD_PLUS', 'PRESS') -kmi = km.keymap_items.new('outliner.show_one_level', 'NUMPAD_MINUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'open', False) -kmi = km.keymap_items.new('outliner.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('outliner.expanded_toggle', 'A', 'PRESS', shift=True) -kmi = km.keymap_items.new('outliner.keyingset_add_selected', 'K', 'PRESS') -kmi = km.keymap_items.new('outliner.keyingset_remove_selected', 'K', 'PRESS', alt=True) -kmi = km.keymap_items.new('anim.keyframe_insert', 'I', 'PRESS') -kmi = km.keymap_items.new('anim.keyframe_delete', 'I', 'PRESS', alt=True) -kmi = km.keymap_items.new('outliner.drivers_add_selected', 'D', 'PRESS') -kmi = km.keymap_items.new('outliner.drivers_delete_selected', 'D', 'PRESS', alt=True) -kmi = km.keymap_items.new('outliner.collection_new', 'C', 'PRESS') -kmi = km.keymap_items.new('outliner.collection_delete', 'X', 'PRESS') - -# Map 3D View Generic -km = kc.keymaps.new('3D View Generic', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.properties', 'N', 'PRESS') -kmi = km.keymap_items.new('view3d.toolshelf', 'T', 'PRESS') - -# Map Grease Pencil -km = kc.keymaps.new('Grease Pencil', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('gpencil.draw', 'LEFTMOUSE', 'PRESS', key_modifier='D') -kmi_props_setattr(kmi.properties, 'mode', 'DRAW') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('gpencil.draw', 'LEFTMOUSE', 'PRESS', ctrl=True, key_modifier='D') -kmi_props_setattr(kmi.properties, 'mode', 'DRAW_STRAIGHT') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('gpencil.draw', 'RIGHTMOUSE', 'PRESS', ctrl=True, key_modifier='D') -kmi_props_setattr(kmi.properties, 'mode', 'DRAW_POLY') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('gpencil.draw', 'RIGHTMOUSE', 'PRESS', key_modifier='D') -kmi_props_setattr(kmi.properties, 'mode', 'ERASER') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('gpencil.draw', 'ERASER', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'ERASER') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('gpencil.editmode_toggle', 'TAB', 'PRESS', key_modifier='D') -kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS', key_modifier='D') -kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_pie_tool_palette') -kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS', key_modifier='D') -kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_pie_settings_palette') -kmi = km.keymap_items.new('gpencil.blank_frame_add', 'B', 'PRESS', key_modifier='D') -kmi = km.keymap_items.new('gpencil.active_frames_delete_all', 'X', 'PRESS', key_modifier='D') - -# Map Grease Pencil Stroke Edit Mode -km = kc.keymaps.new('Grease Pencil Stroke Edit Mode', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('gpencil.editmode_toggle', 'TAB', 'PRESS') -kmi = km.keymap_items.new('wm.call_menu_pie', 'E', 'PRESS', key_modifier='D') -kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_pie_sculpt') -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'user_preferences.edit.grease_pencil_eraser_radius') -kmi = km.keymap_items.new('gpencil.interpolate', 'E', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('gpencil.interpolate_sequence', 'E', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('gpencil.brush_paint', 'LEFTMOUSE', 'PRESS', key_modifier='E') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('gpencil.brush_paint', 'LEFTMOUSE', 'PRESS', ctrl=True, key_modifier='E') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('gpencil.brush_paint', 'LEFTMOUSE', 'PRESS', shift=True, key_modifier='E') -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.gpencil_sculpt.brush.strength') -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.gpencil_sculpt.brush.size') -kmi = km.keymap_items.new('gpencil.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('gpencil.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('gpencil.select_circle', 'C', 'PRESS') -kmi = km.keymap_items.new('gpencil.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('gpencil.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('gpencil.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('gpencil.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('gpencil.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('gpencil.select', 'SELECTMOUSE', 'PRESS') -kmi = km.keymap_items.new('gpencil.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('gpencil.select', 'SELECTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'entire_strokes', True) -kmi = km.keymap_items.new('gpencil.select_linked', 'L', 'PRESS') -kmi = km.keymap_items.new('gpencil.select_linked', 'L', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('gpencil.select_grouped', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('gpencil.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('gpencil.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('gpencil.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_gpencil_delete') -kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_gpencil_delete') -kmi = km.keymap_items.new('gpencil.dissolve', 'X', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('gpencil.dissolve', 'DEL', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('gpencil.active_frames_delete_all', 'X', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_gpencil_edit_specials') -kmi = km.keymap_items.new('gpencil.stroke_join', 'J', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('gpencil.stroke_join', 'J', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'JOINCOPY') -kmi = km.keymap_items.new('gpencil.copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('gpencil.paste', 'V', 'PRESS', ctrl=True) -if platform == "darwin": - kmi = km.keymap_items.new('gpencil.copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('gpencil.paste', 'V', 'PRESS', oskey=True) -kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'GPENCIL_MT_snap') -kmi = km.keymap_items.new('gpencil.convert', 'C', 'PRESS', alt=True) -kmi = km.keymap_items.new('gpencil.reveal', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('gpencil.hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('gpencil.hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('gpencil.selection_opacity_toggle', 'H', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('gpencil.layer_isolate', 'NUMPAD_ASTERIX', 'PRESS') -kmi = km.keymap_items.new('gpencil.move_to_layer', 'M', 'PRESS') -kmi = km.keymap_items.new('gpencil.brush_select', 'ONE', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 0) -kmi = km.keymap_items.new('gpencil.brush_select', 'TWO', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 1) -kmi = km.keymap_items.new('gpencil.brush_select', 'THREE', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 2) -kmi = km.keymap_items.new('gpencil.brush_select', 'FOUR', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 3) -kmi = km.keymap_items.new('gpencil.brush_select', 'FIVE', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 4) -kmi = km.keymap_items.new('gpencil.brush_select', 'SIX', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 5) -kmi = km.keymap_items.new('gpencil.brush_select', 'SEVEN', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 6) -kmi = km.keymap_items.new('gpencil.brush_select', 'EIGHT', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 7) -kmi = km.keymap_items.new('gpencil.brush_select', 'NINE', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 8) -kmi = km.keymap_items.new('gpencil.brush_select', 'ZERO', 'PRESS') -kmi_props_setattr(kmi.properties, 'index', 9) -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') -kmi = km.keymap_items.new('transform.mirror', 'M', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('transform.bend', 'W', 'PRESS', shift=True) -kmi = km.keymap_items.new('transform.tosphere', 'S', 'PRESS', shift=True, alt=True) -kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'GPENCIL_SHRINKFATTEN') -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED') -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'CONNECTED') - -# Map Face Mask -km = kc.keymaps.new('Face Mask', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paint.face_select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('paint.face_select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('paint.face_select_hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('paint.face_select_hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('paint.face_select_reveal', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('paint.face_select_linked', 'L', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('paint.face_select_linked_pick', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('paint.face_select_linked_pick', 'L', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'deselect', True) - -# Map Weight Paint Vertex Selection -km = kc.keymaps.new('Weight Paint Vertex Selection', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paint.vert_select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('paint.vert_select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('view3d.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('view3d.select_circle', 'C', 'PRESS') - -# Map Pose -km = kc.keymaps.new('Pose', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('object.parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_add') -kmi = km.keymap_items.new('pose.hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('pose.hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('pose.reveal', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_pose_apply') -kmi = km.keymap_items.new('pose.rot_clear', 'R', 'PRESS', alt=True) -kmi = km.keymap_items.new('pose.loc_clear', 'G', 'PRESS', alt=True) -kmi = km.keymap_items.new('pose.scale_clear', 'S', 'PRESS', alt=True) -kmi = km.keymap_items.new('pose.quaternions_flip', 'F', 'PRESS', alt=True) -kmi = km.keymap_items.new('pose.rotation_mode_set', 'R', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('pose.copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('pose.paste', 'V', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'flipped', False) -kmi = km.keymap_items.new('pose.paste', 'V', 'PRESS', shift=True, ctrl=True) -if platform == "darwin": - kmi_props_setattr(kmi.properties, 'flipped', True) - kmi = km.keymap_items.new('pose.copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('pose.paste', 'V', 'PRESS', oskey=True) - kmi_props_setattr(kmi.properties, 'flipped', False) - kmi = km.keymap_items.new('pose.paste', 'V', 'PRESS', shift=True, oskey=True) -kmi_props_setattr(kmi.properties, 'flipped', True) -kmi = km.keymap_items.new('pose.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('pose.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('pose.select_parent', 'P', 'PRESS', shift=True) -kmi = km.keymap_items.new('pose.select_hierarchy', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'PARENT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('pose.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'PARENT') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('pose.select_hierarchy', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'CHILD') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('pose.select_hierarchy', 'RIGHT_BRACKET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'CHILD') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('pose.select_linked', 'L', 'PRESS') -kmi = km.keymap_items.new('pose.select_grouped', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('pose.select_mirror', 'F', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('pose.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('pose.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('pose.ik_add', 'I', 'PRESS', shift=True) -kmi = km.keymap_items.new('pose.ik_clear', 'I', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_pose_group') -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_toggle') -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_enable') -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_disable') -kmi = km.keymap_items.new('armature.layers_show_all', 'ACCENT_GRAVE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('armature.armature_layers', 'M', 'PRESS', shift=True) -kmi = km.keymap_items.new('pose.bone_layers', 'M', 'PRESS') -kmi = km.keymap_items.new('pose.toggle_bone_selection_overlay', 'Z', 'PRESS') -kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'BONE_SIZE') -kmi = km.keymap_items.new('anim.keyframe_insert_menu', 'I', 'PRESS') -kmi = km.keymap_items.new('anim.keyframe_delete_v3d', 'I', 'PRESS', alt=True) -kmi = km.keymap_items.new('anim.keying_set_active_set', 'I', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('poselib.browse_interactive', 'L', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('poselib.pose_add', 'L', 'PRESS', shift=True) -kmi = km.keymap_items.new('poselib.pose_remove', 'L', 'PRESS', alt=True) -kmi = km.keymap_items.new('poselib.pose_rename', 'L', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('pose.push', 'E', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('pose.relax', 'E', 'PRESS', alt=True) -kmi = km.keymap_items.new('pose.breakdown', 'E', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_pose_specials') -kmi = km.keymap_items.new('wm.call_menu', 'P', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_pose_propagate') - -# Map Object Mode -km = kc.keymaps.new('Object Mode', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_proportional_edit_objects') -kmi = km.keymap_items.new('object.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('object.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('object.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('object.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('object.select_linked', 'L', 'PRESS', shift=True) -kmi = km.keymap_items.new('object.select_grouped', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('object.select_mirror', 'M', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'PARENT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'PARENT') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('object.select_hierarchy', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'CHILD') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('object.select_hierarchy', 'RIGHT_BRACKET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'CHILD') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('object.parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('object.parent_no_inverse_set', 'P', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('object.parent_clear', 'P', 'PRESS', alt=True) -kmi = km.keymap_items.new('object.track_set', 'T', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('object.track_clear', 'T', 'PRESS', alt=True) -kmi = km.keymap_items.new('object.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('object.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('object.location_clear', 'G', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'clear_delta', False) -kmi = km.keymap_items.new('object.rotation_clear', 'R', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'clear_delta', False) -kmi = km.keymap_items.new('object.scale_clear', 'S', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'clear_delta', False) -kmi = km.keymap_items.new('object.origin_clear', 'O', 'PRESS', alt=True) -kmi = km.keymap_items.new('object.delete', 'X', 'PRESS') -kmi_props_setattr(kmi.properties, 'use_global', False) -kmi = km.keymap_items.new('object.delete', 'X', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'use_global', True) -kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'use_global', False) -kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'use_global', True) -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_add') -kmi = km.keymap_items.new('object.duplicates_make_real', 'A', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_object_apply') -kmi = km.keymap_items.new('wm.call_menu', 'U', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_make_single_user') -kmi = km.keymap_items.new('wm.call_menu', 'L', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_make_links') -kmi = km.keymap_items.new('object.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('object.duplicate_move_linked', 'D', 'PRESS', alt=True) -kmi = km.keymap_items.new('object.join', 'J', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('object.convert', 'C', 'PRESS', alt=True) -kmi = km.keymap_items.new('object.proxy_make', 'P', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('object.make_local', 'L', 'PRESS') -kmi = km.keymap_items.new('anim.keyframe_insert_menu', 'I', 'PRESS') -kmi = km.keymap_items.new('anim.keyframe_delete_v3d', 'I', 'PRESS', alt=True) -kmi = km.keymap_items.new('anim.keying_set_active_set', 'I', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('collection.create', 'G', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('collection.objects_remove', 'G', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('collection.objects_remove_all', 'G', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('collection.objects_add_active', 'G', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('collection.objects_remove_active', 'G', 'PRESS', shift=True, alt=True) -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_object_specials') -kmi = km.keymap_items.new('object.data_transfer', 'T', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 0) -kmi = km.keymap_items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 1) -kmi = km.keymap_items.new('object.subdivision_set', 'TWO', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 2) -kmi = km.keymap_items.new('object.subdivision_set', 'THREE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 3) -kmi = km.keymap_items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 4) -kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 5) -kmi = km.keymap_items.new('object.move_to_collection', 'M', 'PRESS') - -# Map Paint Curve -km = kc.keymaps.new('Paint Curve', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paintcurve.add_point_slide', 'ACTIONMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('paintcurve.select', 'SELECTMOUSE', 'PRESS') -kmi = km.keymap_items.new('paintcurve.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('paintcurve.slide', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('paintcurve.slide', 'ACTIONMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'align', True) -kmi = km.keymap_items.new('paintcurve.select', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('paintcurve.cursor', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('paintcurve.delete_point', 'X', 'PRESS') -kmi = km.keymap_items.new('paintcurve.delete_point', 'DEL', 'PRESS') -kmi = km.keymap_items.new('paintcurve.draw', 'RET', 'PRESS') -kmi = km.keymap_items.new('paintcurve.draw', 'NUMPAD_ENTER', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') - -# Map Curve -km = kc.keymaps.new('Curve', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_edit_curve_add') -kmi = km.keymap_items.new('curve.handle_type_set', 'V', 'PRESS') -kmi = km.keymap_items.new('curve.vertex_add', 'ACTIONMOUSE', 'CLICK', ctrl=True) -kmi = km.keymap_items.new('curve.draw', 'ACTIONMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('curve.draw', 'PEN', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'wait_for_input', False) -kmi = km.keymap_items.new('curve.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('curve.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('curve.select_row', 'R', 'PRESS', shift=True) -kmi = km.keymap_items.new('curve.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('curve.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('curve.select_linked', 'L', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('curve.select_similar', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('curve.select_linked_pick', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('curve.select_linked_pick', 'L', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('curve.shortest_path_pick', 'SELECTMOUSE', 'CLICK', ctrl=True) -kmi = km.keymap_items.new('curve.separate', 'P', 'PRESS') -kmi = km.keymap_items.new('curve.split', 'Y', 'PRESS') -kmi = km.keymap_items.new('curve.extrude_move', 'E', 'PRESS') -kmi = km.keymap_items.new('curve.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('curve.make_segment', 'F', 'PRESS') -kmi = km.keymap_items.new('curve.cyclic_toggle', 'C', 'PRESS', alt=True) -kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_curve_delete') -kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_curve_delete') -kmi = km.keymap_items.new('curve.dissolve_verts', 'X', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('curve.dissolve_verts', 'DEL', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('curve.tilt_clear', 'T', 'PRESS', alt=True) -kmi = km.keymap_items.new('transform.tilt', 'T', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'CURVE_SHRINKFATTEN') -kmi = km.keymap_items.new('curve.reveal', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('curve.hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('curve.hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('curve.normals_make_consistent', 'N', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('object.vertex_parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_curve_specials') -kmi = km.keymap_items.new('wm.call_menu', 'H', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_hook') -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED') -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'CONNECTED') - -# Map Image Paint -km = kc.keymaps.new('Image Paint', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paint.image_paint', 'LEFTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'NORMAL') -kmi = km.keymap_items.new('paint.image_paint', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'INVERT') -kmi = km.keymap_items.new('paint.brush_colors_flip', 'X', 'PRESS') -kmi = km.keymap_items.new('paint.grab_clone', 'RIGHTMOUSE', 'PRESS') -kmi = km.keymap_items.new('paint.sample_color', 'S', 'PRESS') -kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 0) -kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 1) -kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 2) -kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 3) -kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 4) -kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 5) -kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 6) -kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 7) -kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 8) -kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 9) -kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 10) -kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 11) -kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 12) -kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 13) -kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 14) -kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 15) -kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 16) -kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 17) -kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 18) -kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'image_paint') -kmi_props_setattr(kmi.properties, 'index', 19) -kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 0.9) -kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.image_paint.brush.size') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.image_paint.brush.mask_texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.image_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.image_paint.brush.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color') -kmi_props_setattr(kmi.properties, 'zoom_path', 'space_data.zoom') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.image_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', True) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.image_paint.brush.strength') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.image_paint.brush.mask_texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.image_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.image_paint.brush.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.image_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', True) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.image_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'data_path_secondary', '') -kmi_props_setattr(kmi.properties, 'use_secondary', '') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.image_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.image_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.image_paint.brush.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.image_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.image_paint.brush.mask_texture_slot.angle') -kmi_props_setattr(kmi.properties, 'data_path_secondary', '') -kmi_props_setattr(kmi.properties, 'use_secondary', '') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.image_paint.brush.mask_texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.image_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.image_paint.brush.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.image_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', True) -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'SCALE') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'ROTATION') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'SCALE') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'ROTATION') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'image_paint_object.data.use_paint_mask') -kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.image_paint.brush.use_smooth_stroke') -kmi = km.keymap_items.new('wm.call_menu', 'R', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_angle_control') -kmi = km.keymap_items.new('wm.context_menu_enum', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.image_paint.brush.stroke_method') - -# Map Vertex Paint -km = kc.keymaps.new('Vertex Paint', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paint.vertex_paint', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('paint.brush_colors_flip', 'X', 'PRESS') -kmi = km.keymap_items.new('paint.sample_color', 'S', 'PRESS') -kmi = km.keymap_items.new('paint.vertex_color_set', 'K', 'PRESS', shift=True) -kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 0) -kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 1) -kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 2) -kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 3) -kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 4) -kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 5) -kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 6) -kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 7) -kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 8) -kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 9) -kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 10) -kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 11) -kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 12) -kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 13) -kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 14) -kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 15) -kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 16) -kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 17) -kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 18) -kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'vertex_paint') -kmi_props_setattr(kmi.properties, 'index', 19) -kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 0.9) -kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.vertex_paint.brush.size') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.vertex_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.vertex_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.vertex_paint.brush.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.vertex_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.vertex_paint.brush.strength') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.vertex_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.vertex_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.vertex_paint.brush.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.vertex_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.vertex_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'data_path_secondary', '') -kmi_props_setattr(kmi.properties, 'use_secondary', '') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.vertex_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.vertex_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', 'tool_settings.vertex_paint.brush.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', 'tool_settings.unified_paint_settings.color') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', 'tool_settings.unified_paint_settings.use_unified_color') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.vertex_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'SCALE') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'ROTATION') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'SCALE') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'ROTATION') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'vertex_paint_object.data.use_paint_mask') -kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.vertex_paint.brush.use_smooth_stroke') -kmi = km.keymap_items.new('wm.call_menu', 'R', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_angle_control') -kmi = km.keymap_items.new('wm.context_menu_enum', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.vertex_paint.brush.stroke_method') - -# Map Weight Paint -km = kc.keymaps.new('Weight Paint', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('paint.weight_paint', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('paint.weight_sample', 'ACTIONMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('paint.weight_sample_group', 'ACTIONMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('paint.weight_gradient', 'LEFTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'type', 'LINEAR') -kmi = km.keymap_items.new('paint.weight_gradient', 'LEFTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'type', 'RADIAL') -kmi = km.keymap_items.new('paint.weight_set', 'K', 'PRESS', shift=True) -kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 0) -kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 1) -kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 2) -kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 3) -kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 4) -kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 5) -kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 6) -kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 7) -kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 8) -kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 9) -kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 10) -kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 11) -kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 12) -kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 13) -kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 14) -kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 15) -kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 16) -kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 17) -kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 18) -kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'weight_paint') -kmi_props_setattr(kmi.properties, 'index', 19) -kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 0.9) -kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.weight_paint.brush.size') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.weight_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.weight_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.weight_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.weight_paint.brush.strength') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.weight_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.weight_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.weight_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.radial_control', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.weight_paint.brush.weight') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.weight') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_weight') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.weight_paint.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.weight_paint.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.weight_paint.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.context_menu_enum', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.vertex_paint.brush.stroke_method') -kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'weight_paint_object.data.use_paint_mask') -kmi = km.keymap_items.new('wm.context_toggle', 'V', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'weight_paint_object.data.use_paint_mask_vertex') -kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.weight_paint.brush.use_smooth_stroke') - -# Map Sculpt -km = kc.keymaps.new('Sculpt', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'NORMAL') -kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'INVERT') -kmi = km.keymap_items.new('sculpt.brush_stroke', 'LEFTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'SMOOTH') -kmi = km.keymap_items.new('paint.hide_show', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'action', 'SHOW') -kmi_props_setattr(kmi.properties, 'area', 'INSIDE') -kmi = km.keymap_items.new('paint.hide_show', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'HIDE') -kmi_props_setattr(kmi.properties, 'area', 'INSIDE') -kmi = km.keymap_items.new('paint.hide_show', 'H', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'action', 'SHOW') -kmi_props_setattr(kmi.properties, 'area', 'ALL') -kmi = km.keymap_items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 0) -kmi = km.keymap_items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 1) -kmi = km.keymap_items.new('object.subdivision_set', 'TWO', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 2) -kmi = km.keymap_items.new('object.subdivision_set', 'THREE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 3) -kmi = km.keymap_items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 4) -kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 5) -kmi = km.keymap_items.new('paint.mask_flood_fill', 'M', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'VALUE') -kmi_props_setattr(kmi.properties, 'value', 0.0) -kmi = km.keymap_items.new('paint.mask_flood_fill', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'INVERT') -kmi = km.keymap_items.new('paint.mask_lasso_gesture', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'scene.tool_settings.sculpt.show_mask') -kmi = km.keymap_items.new('sculpt.dynamic_topology_toggle', 'D', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('sculpt.set_detail_size', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('object.subdivision_set', 'PAGE_UP', 'PRESS') -kmi_props_setattr(kmi.properties, 'level', 1) -kmi_props_setattr(kmi.properties, 'relative', True) -kmi = km.keymap_items.new('object.subdivision_set', 'PAGE_DOWN', 'PRESS') -kmi_props_setattr(kmi.properties, 'level', -1) -kmi_props_setattr(kmi.properties, 'relative', True) -kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 0) -kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 1) -kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 2) -kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 3) -kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 4) -kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 5) -kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 6) -kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 7) -kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 8) -kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 9) -kmi = km.keymap_items.new('brush.active_index_set', 'ONE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 10) -kmi = km.keymap_items.new('brush.active_index_set', 'TWO', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 11) -kmi = km.keymap_items.new('brush.active_index_set', 'THREE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 12) -kmi = km.keymap_items.new('brush.active_index_set', 'FOUR', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 13) -kmi = km.keymap_items.new('brush.active_index_set', 'FIVE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 14) -kmi = km.keymap_items.new('brush.active_index_set', 'SIX', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 15) -kmi = km.keymap_items.new('brush.active_index_set', 'SEVEN', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 16) -kmi = km.keymap_items.new('brush.active_index_set', 'EIGHT', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 17) -kmi = km.keymap_items.new('brush.active_index_set', 'NINE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 18) -kmi = km.keymap_items.new('brush.active_index_set', 'ZERO', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'sculpt') -kmi_props_setattr(kmi.properties, 'index', 19) -kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 0.9) -kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.sculpt.brush.size') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.sculpt.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.sculpt.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.sculpt.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.sculpt.brush.strength') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.sculpt.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.sculpt.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.sculpt.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.sculpt.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'data_path_secondary', '') -kmi_props_setattr(kmi.properties, 'use_secondary', '') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.sculpt.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.sculpt.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.sculpt.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'SCALE') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'ROTATION') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'SCALE') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('brush.stencil_control', 'RIGHTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'ROTATION') -kmi_props_setattr(kmi.properties, 'texmode', 'SECONDARY') -kmi = km.keymap_items.new('paint.brush_select', 'X', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'DRAW') -kmi = km.keymap_items.new('paint.brush_select', 'S', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'SMOOTH') -kmi = km.keymap_items.new('paint.brush_select', 'P', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'PINCH') -kmi = km.keymap_items.new('paint.brush_select', 'I', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'INFLATE') -kmi = km.keymap_items.new('paint.brush_select', 'G', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'GRAB') -kmi = km.keymap_items.new('paint.brush_select', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'LAYER') -kmi = km.keymap_items.new('paint.brush_select', 'T', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'FLATTEN') -kmi = km.keymap_items.new('paint.brush_select', 'C', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'CLAY') -kmi = km.keymap_items.new('paint.brush_select', 'C', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'CREASE') -kmi = km.keymap_items.new('paint.brush_select', 'K', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'SNAKE_HOOK') -kmi = km.keymap_items.new('paint.brush_select', 'M', 'PRESS') -kmi_props_setattr(kmi.properties, 'paint_mode', 'SCULPT') -kmi_props_setattr(kmi.properties, 'sculpt_tool', 'MASK') -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi_props_setattr(kmi.properties, 'create_missing', True) -kmi = km.keymap_items.new('wm.context_menu_enum', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.sculpt.brush.stroke_method') -kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.sculpt.brush.use_smooth_stroke') -kmi = km.keymap_items.new('wm.call_menu', 'R', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_angle_control') - -# Map Mesh -km = kc.keymaps.new('Mesh', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mesh.loopcut_slide', 'R', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mesh.offset_edge_loops_slide', 'R', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('mesh.inset', 'I', 'PRESS') -kmi = km.keymap_items.new('mesh.poke', 'P', 'PRESS', alt=True) -kmi = km.keymap_items.new('mesh.bevel', 'B', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'vertex_only', False) -kmi = km.keymap_items.new('mesh.bevel', 'B', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'vertex_only', True) -kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', False) -kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('mesh.edgering_select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', False) -kmi = km.keymap_items.new('mesh.edgering_select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('mesh.shortest_path_pick', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'use_fill', False) -kmi = km.keymap_items.new('mesh.shortest_path_pick', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'use_fill', True) -kmi = km.keymap_items.new('mesh.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('mesh.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('mesh.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mesh.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mesh.select_next_item', 'NUMPAD_PLUS', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('mesh.select_prev_item', 'NUMPAD_MINUS', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('mesh.select_non_manifold', 'M', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('mesh.select_linked', 'L', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mesh.select_linked_pick', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('mesh.select_linked_pick', 'L', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('mesh.faces_select_linked_flat', 'F', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_select_similar') -kmi = km.keymap_items.new('wm.call_menu', 'TAB', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_select_mode') -kmi = km.keymap_items.new('mesh.hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('mesh.hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('mesh.reveal', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('mesh.normals_make_consistent', 'N', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'inside', False) -kmi = km.keymap_items.new('mesh.normals_make_consistent', 'N', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'inside', True) -kmi = km.keymap_items.new('view3d.edit_mesh_extrude_move_normal', 'E', 'PRESS') -kmi = km.keymap_items.new('wm.call_menu', 'E', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_extrude') -kmi = km.keymap_items.new('transform.edge_crease', 'E', 'PRESS', shift=True) -kmi = km.keymap_items.new('mesh.spin', 'R', 'PRESS', alt=True) -kmi = km.keymap_items.new('mesh.fill', 'F', 'PRESS', alt=True) -kmi = km.keymap_items.new('mesh.beautify_fill', 'F', 'PRESS', shift=True, alt=True) -kmi = km.keymap_items.new('mesh.quads_convert_to_tris', 'T', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'quad_method', 'BEAUTY') -kmi_props_setattr(kmi.properties, 'ngon_method', 'BEAUTY') -kmi = km.keymap_items.new('mesh.quads_convert_to_tris', 'T', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'quad_method', 'FIXED') -kmi_props_setattr(kmi.properties, 'ngon_method', 'CLIP') -kmi = km.keymap_items.new('mesh.tris_convert_to_quads', 'J', 'PRESS', alt=True) -kmi = km.keymap_items.new('mesh.rip_move', 'V', 'PRESS') -kmi_props_setattr(kmi.properties.MESH_OT_rip, 'use_fill', False) -kmi = km.keymap_items.new('mesh.rip_move', 'V', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties.MESH_OT_rip, 'use_fill', True) -kmi = km.keymap_items.new('mesh.rip_edge_move', 'D', 'PRESS', alt=True) -kmi = km.keymap_items.new('mesh.merge', 'M', 'PRESS', alt=True) -kmi = km.keymap_items.new('transform.shrink_fatten', 'S', 'PRESS', alt=True) -kmi = km.keymap_items.new('mesh.edge_face_add', 'F', 'PRESS') -kmi = km.keymap_items.new('mesh.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'INFO_MT_mesh_add') -kmi = km.keymap_items.new('mesh.separate', 'P', 'PRESS') -kmi = km.keymap_items.new('mesh.split', 'Y', 'PRESS') -kmi = km.keymap_items.new('mesh.vert_connect_path', 'J', 'PRESS') -kmi = km.keymap_items.new('transform.vert_slide', 'V', 'PRESS', shift=True) -kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'CLICK', ctrl=True) -kmi_props_setattr(kmi.properties, 'rotate_source', True) -kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'CLICK', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'rotate_source', False) -kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_delete') -kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_delete') -kmi = km.keymap_items.new('mesh.dissolve_mode', 'X', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mesh.dissolve_mode', 'DEL', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mesh.knife_tool', 'K', 'PRESS') -kmi_props_setattr(kmi.properties, 'use_occlude_geometry', True) -kmi_props_setattr(kmi.properties, 'only_selected', False) -kmi = km.keymap_items.new('mesh.knife_tool', 'K', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'use_occlude_geometry', False) -kmi_props_setattr(kmi.properties, 'only_selected', True) -kmi = km.keymap_items.new('object.vertex_parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_specials') -kmi = km.keymap_items.new('wm.call_menu', 'F', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_faces') -kmi = km.keymap_items.new('wm.call_menu', 'E', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_edges') -kmi = km.keymap_items.new('wm.call_menu', 'V', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_mesh_vertices') -kmi = km.keymap_items.new('wm.call_menu', 'H', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_hook') -kmi = km.keymap_items.new('wm.call_menu', 'U', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_uv_map') -kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_vertex_group') -kmi = km.keymap_items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 0) -kmi = km.keymap_items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 1) -kmi = km.keymap_items.new('object.subdivision_set', 'TWO', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 2) -kmi = km.keymap_items.new('object.subdivision_set', 'THREE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 3) -kmi = km.keymap_items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 4) -kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'level', 5) -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED') -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'CONNECTED') - -# Map Armature -km = kc.keymaps.new('Armature', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('armature.hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('armature.hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('armature.reveal', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('armature.align', 'A', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('armature.calculate_roll', 'N', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('armature.roll_clear', 'R', 'PRESS', alt=True) -kmi = km.keymap_items.new('armature.switch_direction', 'F', 'PRESS', alt=True) -kmi = km.keymap_items.new('armature.bone_primitive_add', 'A', 'PRESS', shift=True) -kmi = km.keymap_items.new('armature.parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('armature.parent_clear', 'P', 'PRESS', alt=True) -kmi = km.keymap_items.new('armature.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('armature.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('armature.select_mirror', 'M', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('armature.select_hierarchy', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'PARENT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('armature.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'PARENT') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('armature.select_hierarchy', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'CHILD') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('armature.select_hierarchy', 'RIGHT_BRACKET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'CHILD') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('armature.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('armature.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('armature.select_similar', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('armature.select_linked', 'L', 'PRESS') -kmi = km.keymap_items.new('armature.shortest_path_pick', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_armature_delete') -kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_edit_armature_delete') -kmi = km.keymap_items.new('armature.dissolve', 'X', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('armature.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('armature.extrude_move', 'E', 'PRESS') -kmi = km.keymap_items.new('armature.extrude_forked', 'E', 'PRESS', shift=True) -kmi = km.keymap_items.new('armature.click_extrude', 'ACTIONMOUSE', 'CLICK', ctrl=True) -kmi = km.keymap_items.new('armature.fill', 'F', 'PRESS') -kmi = km.keymap_items.new('armature.merge', 'M', 'PRESS', alt=True) -kmi = km.keymap_items.new('armature.split', 'Y', 'PRESS') -kmi = km.keymap_items.new('armature.separate', 'P', 'PRESS') -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_toggle') -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_enable') -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_bone_options_disable') -kmi = km.keymap_items.new('armature.layers_show_all', 'ACCENT_GRAVE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('armature.armature_layers', 'M', 'PRESS', shift=True) -kmi = km.keymap_items.new('armature.bone_layers', 'M', 'PRESS') -kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'BONE_SIZE') -kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'BONE_ENVELOPE') -kmi = km.keymap_items.new('transform.transform', 'R', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'BONE_ROLL') -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_armature_specials') - -# Map Metaball -km = kc.keymaps.new('Metaball', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('object.metaball_add', 'A', 'PRESS', shift=True) -kmi = km.keymap_items.new('mball.reveal_metaelems', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('mball.hide_metaelems', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('mball.hide_metaelems', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('mball.delete_metaelems', 'X', 'PRESS') -kmi = km.keymap_items.new('mball.delete_metaelems', 'DEL', 'PRESS') -kmi = km.keymap_items.new('mball.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('mball.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('mball.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('mball.select_similar', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED') -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'CONNECTED') - -# Map Lattice -km = kc.keymaps.new('Lattice', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('lattice.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('lattice.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('lattice.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('lattice.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('object.vertex_parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('lattice.flip', 'F', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'H', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_hook') -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED') - -# Map Particle -km = kc.keymaps.new('Particle', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('particle.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('particle.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('particle.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('particle.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('particle.select_linked', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('particle.select_linked', 'L', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('particle.delete', 'X', 'PRESS') -kmi = km.keymap_items.new('particle.delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('particle.reveal', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('particle.hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('particle.hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('particle.brush_edit', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('particle.brush_edit', 'LEFTMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.particle_edit.brush.size') -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.particle_edit.brush.strength') -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_particle_specials') -kmi = km.keymap_items.new('particle.weight_set', 'K', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED') - -# Map Font -km = kc.keymaps.new('Font', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('font.style_toggle', 'B', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'style', 'BOLD') -kmi = km.keymap_items.new('font.style_toggle', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'style', 'ITALIC') -kmi = km.keymap_items.new('font.style_toggle', 'U', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'style', 'UNDERLINE') -kmi = km.keymap_items.new('font.style_toggle', 'P', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'style', 'SMALL_CAPS') -kmi = km.keymap_items.new('font.delete', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_OR_SELECTION') -kmi = km.keymap_items.new('font.delete', 'DEL', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') -kmi = km.keymap_items.new('font.delete', 'BACK_SPACE', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_OR_SELECTION') -kmi = km.keymap_items.new('font.delete', 'BACK_SPACE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_OR_SELECTION') -kmi = km.keymap_items.new('font.delete', 'BACK_SPACE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') -kmi = km.keymap_items.new('font.move', 'HOME', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN') -kmi = km.keymap_items.new('font.move', 'END', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'LINE_END') -kmi = km.keymap_items.new('font.move', 'LEFT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('font.move', 'RIGHT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER') -kmi = km.keymap_items.new('font.move', 'LEFT_ARROW', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') -kmi = km.keymap_items.new('font.move', 'RIGHT_ARROW', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') -kmi = km.keymap_items.new('font.move', 'UP_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_LINE') -kmi = km.keymap_items.new('font.move', 'DOWN_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_LINE') -kmi = km.keymap_items.new('font.move', 'PAGE_UP', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_PAGE') -kmi = km.keymap_items.new('font.move', 'PAGE_DOWN', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_PAGE') -kmi = km.keymap_items.new('font.move_select', 'HOME', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN') -kmi = km.keymap_items.new('font.move_select', 'END', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'LINE_END') -kmi = km.keymap_items.new('font.move_select', 'LEFT_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('font.move_select', 'RIGHT_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER') -kmi = km.keymap_items.new('font.move_select', 'LEFT_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') -kmi = km.keymap_items.new('font.move_select', 'RIGHT_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') -kmi = km.keymap_items.new('font.move_select', 'UP_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_LINE') -kmi = km.keymap_items.new('font.move_select', 'DOWN_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_LINE') -kmi = km.keymap_items.new('font.move_select', 'PAGE_UP', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_PAGE') -kmi = km.keymap_items.new('font.move_select', 'PAGE_DOWN', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_PAGE') -kmi = km.keymap_items.new('font.change_spacing', 'LEFT_ARROW', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('font.change_spacing', 'RIGHT_ARROW', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('font.change_character', 'UP_ARROW', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('font.change_character', 'DOWN_ARROW', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('font.select_all', 'A', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('font.text_copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('font.text_cut', 'X', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('font.text_paste', 'V', 'PRESS', ctrl=True) -if platform == "darwin": - kmi = km.keymap_items.new('font.select_all', 'A', 'PRESS', oskey=True) - kmi = km.keymap_items.new('font.text_copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('font.text_cut', 'X', 'PRESS', oskey=True) - kmi = km.keymap_items.new('font.text_paste', 'V', 'PRESS', oskey=True) -kmi = km.keymap_items.new('font.line_break', 'RET', 'PRESS') -kmi = km.keymap_items.new('font.text_insert', 'TEXTINPUT', 'ANY', any=True) -kmi = km.keymap_items.new('font.text_insert', 'BACK_SPACE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'accent', True) - -# Map Object Non-modal -km = kc.keymaps.new('Object Non-modal', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'EDIT') -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'POSE') -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('object.mode_set', 'V', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'VERTEX_PAINT') -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'WEIGHT_PAINT') -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('object.origin_set', 'C', 'PRESS', shift=True, ctrl=True, alt=True) - -# Map 3D View -km = kc.keymaps.new('3D View', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'CLICK') -kmi = km.keymap_items.new('view3d.rotate', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('view3d.move', 'MIDDLEMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('view3d.zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('view3d.dolly', 'MIDDLEMOUSE', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('view3d.view_selected', 'NUMPAD_PERIOD', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'use_all_regions', True) -kmi = km.keymap_items.new('view3d.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi_props_setattr(kmi.properties, 'use_all_regions', False) -kmi = km.keymap_items.new('view3d.view_lock_to_active', 'NUMPAD_PERIOD', 'PRESS', shift=True) -kmi = km.keymap_items.new('view3d.view_lock_clear', 'NUMPAD_PERIOD', 'PRESS', alt=True) -kmi = km.keymap_items.new('view3d.navigate', 'F', 'PRESS', shift=True) -kmi = km.keymap_items.new('view3d.smoothview', 'TIMER1', 'ANY', any=True) -kmi = km.keymap_items.new('view3d.rotate', 'TRACKPADPAN', 'ANY') -kmi = km.keymap_items.new('view3d.rotate', 'MOUSEROTATE', 'ANY') -kmi = km.keymap_items.new('view3d.move', 'TRACKPADPAN', 'ANY', shift=True) -kmi = km.keymap_items.new('view3d.zoom', 'TRACKPADZOOM', 'ANY') -kmi = km.keymap_items.new('view3d.zoom', 'TRACKPADPAN', 'ANY', ctrl=True) -kmi = km.keymap_items.new('view3d.zoom', 'NUMPAD_PLUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('view3d.zoom', 'NUMPAD_MINUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('view3d.zoom', 'EQUAL', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('view3d.zoom', 'MINUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('view3d.zoom', 'WHEELINMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('view3d.zoom', 'WHEELOUTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('view3d.dolly', 'NUMPAD_PLUS', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('view3d.dolly', 'NUMPAD_MINUS', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('view3d.dolly', 'EQUAL', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'delta', 1) -kmi = km.keymap_items.new('view3d.dolly', 'MINUS', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'delta', -1) -kmi = km.keymap_items.new('view3d.zoom_camera_1_to_1', 'NUMPAD_ENTER', 'PRESS', shift=True) -kmi = km.keymap_items.new('view3d.view_center_camera', 'HOME', 'PRESS') -kmi = km.keymap_items.new('view3d.view_center_lock', 'HOME', 'PRESS') -kmi = km.keymap_items.new('view3d.view_center_cursor', 'HOME', 'PRESS', alt=True) -kmi = km.keymap_items.new('view3d.view_center_pick', 'F', 'PRESS', alt=True) -kmi = km.keymap_items.new('view3d.view_all', 'HOME', 'PRESS') -kmi_props_setattr(kmi.properties, 'center', False) -kmi = km.keymap_items.new('view3d.view_all', 'HOME', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'use_all_regions', True) -kmi_props_setattr(kmi.properties, 'center', False) -kmi = km.keymap_items.new('view3d.view_all', 'C', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'center', True) -kmi = km.keymap_items.new('view3d.view_camera', 'NUMPAD_0', 'PRESS') -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_1', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'FRONT') -kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_2', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'ORBITDOWN') -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_3', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_4', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'ORBITLEFT') -kmi = km.keymap_items.new('view3d.view_persportho', 'NUMPAD_5', 'PRESS') -kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_6', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'ORBITRIGHT') -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_7', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'TOP') -kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_8', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'ORBITUP') -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_1', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'BACK') -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_3', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'LEFT') -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_7', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'BOTTOM') -kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_2', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PANDOWN') -kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_4', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PANLEFT') -kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_6', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PANRIGHT') -kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_8', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PANUP') -kmi = km.keymap_items.new('view3d.view_roll', 'NUMPAD_4', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'LEFT') -kmi = km.keymap_items.new('view3d.view_roll', 'NUMPAD_6', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_9', 'PRESS') -kmi_props_setattr(kmi.properties, 'angle', 3.1415927410125732) -kmi_props_setattr(kmi.properties, 'type', 'ORBITRIGHT') -kmi = km.keymap_items.new('view3d.view_pan', 'WHEELUPMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PANRIGHT') -kmi = km.keymap_items.new('view3d.view_pan', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PANLEFT') -kmi = km.keymap_items.new('view3d.view_pan', 'WHEELUPMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PANUP') -kmi = km.keymap_items.new('view3d.view_pan', 'WHEELDOWNMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PANDOWN') -kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELUPMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'type', 'ORBITLEFT') -kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'type', 'ORBITRIGHT') -kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELUPMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'type', 'ORBITUP') -kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELDOWNMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'type', 'ORBITDOWN') -kmi = km.keymap_items.new('view3d.view_roll', 'WHEELUPMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'LEFT') -kmi = km.keymap_items.new('view3d.view_roll', 'WHEELDOWNMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_1', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'FRONT') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_3', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_7', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'TOP') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_1', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'BACK') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_3', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'LEFT') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.view_axis', 'NUMPAD_7', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'BOTTOM') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.ndof_orbit_zoom', 'NDOF_MOTION', 'ANY') -kmi = km.keymap_items.new('view3d.ndof_orbit', 'NDOF_MOTION', 'ANY', ctrl=True) -kmi = km.keymap_items.new('view3d.ndof_pan', 'NDOF_MOTION', 'ANY', shift=True) -kmi = km.keymap_items.new('view3d.ndof_all', 'NDOF_MOTION', 'ANY', shift=True, ctrl=True) -kmi = km.keymap_items.new('view3d.view_selected', 'NDOF_BUTTON_FIT', 'PRESS') -kmi_props_setattr(kmi.properties, 'use_all_regions', False) -kmi = km.keymap_items.new('view3d.view_roll', 'NDOF_BUTTON_ROLL_CCW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'LEFT') -kmi = km.keymap_items.new('view3d.view_roll', 'NDOF_BUTTON_ROLL_CCW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_FRONT', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'FRONT') -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_BACK', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'BACK') -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_LEFT', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'LEFT') -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_RIGHT', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_TOP', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'TOP') -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_BOTTOM', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'BOTTOM') -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_FRONT', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'FRONT') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_RIGHT', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'RIGHT') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.view_axis', 'NDOF_BUTTON_TOP', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'TOP') -kmi_props_setattr(kmi.properties, 'align_active', True) -kmi = km.keymap_items.new('view3d.layers', 'ACCENT_GRAVE', 'PRESS') -kmi_props_setattr(kmi.properties, 'nr', 0) -kmi = km.keymap_items.new('view3d.layers', 'ONE', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 1) -kmi = km.keymap_items.new('view3d.layers', 'TWO', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 2) -kmi = km.keymap_items.new('view3d.layers', 'THREE', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 3) -kmi = km.keymap_items.new('view3d.layers', 'FOUR', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 4) -kmi = km.keymap_items.new('view3d.layers', 'FIVE', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 5) -kmi = km.keymap_items.new('view3d.layers', 'SIX', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 6) -kmi = km.keymap_items.new('view3d.layers', 'SEVEN', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 7) -kmi = km.keymap_items.new('view3d.layers', 'EIGHT', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 8) -kmi = km.keymap_items.new('view3d.layers', 'NINE', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 9) -kmi = km.keymap_items.new('view3d.layers', 'ZERO', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'nr', 10) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'Z', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.shading.type') -kmi_props_setattr(kmi.properties, 'value_1', 'SOLID') -kmi_props_setattr(kmi.properties, 'value_2', 'TEXTURED') -kmi = km.keymap_items.new('view3d.toggle_render', 'Z', 'PRESS', shift=True) -kmi = km.keymap_items.new('view3d.toggle_xray_draw_option', 'Z', 'PRESS') -kmi = km.keymap_items.new('wm.context_toggle', 'Z', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.use_occlude_geometry') -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', False) -kmi_props_setattr(kmi.properties, 'center', False) -kmi_props_setattr(kmi.properties, 'enumerate', False) -kmi_props_setattr(kmi.properties, 'object', False) -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi_props_setattr(kmi.properties, 'center', False) -kmi_props_setattr(kmi.properties, 'enumerate', False) -kmi_props_setattr(kmi.properties, 'object', False) -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', False) -kmi_props_setattr(kmi.properties, 'center', True) -kmi_props_setattr(kmi.properties, 'enumerate', False) -kmi_props_setattr(kmi.properties, 'object', True) -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', False) -kmi_props_setattr(kmi.properties, 'center', False) -kmi_props_setattr(kmi.properties, 'enumerate', True) -kmi_props_setattr(kmi.properties, 'object', False) -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi_props_setattr(kmi.properties, 'center', True) -kmi_props_setattr(kmi.properties, 'enumerate', False) -kmi_props_setattr(kmi.properties, 'object', False) -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', False) -kmi_props_setattr(kmi.properties, 'center', True) -kmi_props_setattr(kmi.properties, 'enumerate', True) -kmi_props_setattr(kmi.properties, 'object', False) -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi_props_setattr(kmi.properties, 'center', False) -kmi_props_setattr(kmi.properties, 'enumerate', True) -kmi_props_setattr(kmi.properties, 'object', False) -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi_props_setattr(kmi.properties, 'center', True) -kmi_props_setattr(kmi.properties, 'enumerate', True) -kmi_props_setattr(kmi.properties, 'object', False) -kmi = km.keymap_items.new('view3d.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('view3d.select_circle', 'C', 'PRESS') -kmi = km.keymap_items.new('view3d.clip_border', 'B', 'PRESS', alt=True) -kmi = km.keymap_items.new('view3d.zoom_border', 'B', 'PRESS', shift=True) -kmi = km.keymap_items.new('view3d.render_border', 'B', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'camera_only', True) -kmi = km.keymap_items.new('view3d.render_border', 'B', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'camera_only', False) -kmi = km.keymap_items.new('view3d.clear_render_border', 'B', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('view3d.camera_to_view', 'NUMPAD_0', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('view3d.object_as_camera', 'NUMPAD_0', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'VIEW3D_MT_snap') -if platform == "darwin": - kmi = km.keymap_items.new('view3d.copybuffer', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('view3d.pastebuffer', 'V', 'PRESS', oskey=True) -kmi = km.keymap_items.new('view3d.copybuffer', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('view3d.pastebuffer', 'V', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'BOUNDING_BOX_CENTER') -kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'MEDIAN_POINT') -kmi = km.keymap_items.new('wm.context_toggle', 'COMMA', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_transform_pivot_point_align') -kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'CURSOR') -kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'INDIVIDUAL_ORIGINS') -kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.transform_pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'ACTIVE_ELEMENT') -kmi = km.keymap_items.new('wm.context_toggle', 'SPACE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_manipulator') -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') -kmi = km.keymap_items.new('transform.bend', 'W', 'PRESS', shift=True) -kmi = km.keymap_items.new('transform.tosphere', 'S', 'PRESS', shift=True, alt=True) -kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('transform.select_orientation', 'SPACE', 'PRESS', alt=True) -kmi = km.keymap_items.new('transform.create_orientation', 'SPACE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'use', True) -kmi = km.keymap_items.new('transform.mirror', 'M', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_snap') -kmi = km.keymap_items.new('wm.context_menu_enum', 'TAB', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.snap_element') -kmi = km.keymap_items.new('object.transform_axis_target', 'T', 'PRESS', shift=True) -kmi = km.keymap_items.new('transform.translate', 'T', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'texture_space', True) -kmi = km.keymap_items.new('transform.resize', 'T', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'texture_space', True) -kmi = km.keymap_items.new('transform.skin_resize', 'A', 'PRESS', ctrl=True) - -# Map Manipulators -km = kc.keymaps.new('Manipulators', space_type='EMPTY', region_type='WINDOW', modal=False) - - -# Map Backdrop Transform Widget -km = kc.keymaps.new('Backdrop Transform Widget', space_type='NODE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Backdrop Crop Widget -km = kc.keymaps.new('Backdrop Crop Widget', space_type='NODE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Sun Beams Widget -km = kc.keymaps.new('Sun Beams Widget', space_type='NODE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Corner Pin Widget -km = kc.keymaps.new('Corner Pin Widget', space_type='NODE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map UV Transform Manipulator -km = kc.keymaps.new('UV Transform Manipulator', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Spot Lamp Widgets -km = kc.keymaps.new('Spot Lamp Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Area Lamp Widgets -km = kc.keymaps.new('Area Lamp Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Target Lamp Widgets -km = kc.keymaps.new('Target Lamp Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Force Field Widgets -km = kc.keymaps.new('Force Field Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Camera Widgets -km = kc.keymaps.new('Camera Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Camera View Widgets -km = kc.keymaps.new('Camera View Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Armature Spline Widgets -km = kc.keymaps.new('Armature Spline Widgets', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map View3D Navigate -km = kc.keymaps.new('View3D Navigate', space_type='VIEW_3D', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('manipulatorgroup.manipulator_tweak', 'LEFTMOUSE', 'PRESS', any=True) - -# Map Animation Channels -km = kc.keymaps.new('Animation Channels', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('anim.channels_click', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'children_only', True) -kmi = km.keymap_items.new('anim.channels_rename', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('anim.channels_rename', 'LEFTMOUSE', 'DOUBLE_CLICK') -kmi = km.keymap_items.new('anim.channel_select_keys', 'LEFTMOUSE', 'DOUBLE_CLICK') -kmi = km.keymap_items.new('anim.channel_select_keys', 'LEFTMOUSE', 'DOUBLE_CLICK', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('anim.channels_select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('anim.channels_select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('anim.channels_select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('anim.channels_select_border', 'EVT_TWEAK_L', 'ANY') -kmi = km.keymap_items.new('anim.channels_delete', 'X', 'PRESS') -kmi = km.keymap_items.new('anim.channels_delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('anim.channels_setting_toggle', 'W', 'PRESS', shift=True) -kmi = km.keymap_items.new('anim.channels_setting_enable', 'W', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('anim.channels_setting_disable', 'W', 'PRESS', alt=True) -kmi = km.keymap_items.new('anim.channels_editable_toggle', 'TAB', 'PRESS') -kmi = km.keymap_items.new('anim.channels_expand', 'NUMPAD_PLUS', 'PRESS') -kmi = km.keymap_items.new('anim.channels_collapse', 'NUMPAD_MINUS', 'PRESS') -kmi = km.keymap_items.new('anim.channels_expand', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'all', False) -kmi = km.keymap_items.new('anim.channels_collapse', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'all', False) -kmi = km.keymap_items.new('anim.channels_move', 'PAGE_UP', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'UP') -kmi = km.keymap_items.new('anim.channels_move', 'PAGE_DOWN', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'DOWN') -kmi = km.keymap_items.new('anim.channels_move', 'PAGE_UP', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'TOP') -kmi = km.keymap_items.new('anim.channels_move', 'PAGE_DOWN', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'BOTTOM') -kmi = km.keymap_items.new('anim.channels_group', 'G', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('anim.channels_ungroup', 'G', 'PRESS', alt=True) - -# Map UV Editor -km = kc.keymaps.new('UV Editor', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('wm.context_toggle', 'Q', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_uv_sculpt') -kmi = km.keymap_items.new('uv.mark_seam', 'E', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('uv.select', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('uv.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('uv.select_loop', 'SELECTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('uv.select_loop', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('uv.select_split', 'Y', 'PRESS') -kmi = km.keymap_items.new('uv.select_border', 'B', 'PRESS') -kmi_props_setattr(kmi.properties, 'pinned', False) -kmi = km.keymap_items.new('uv.select_border', 'B', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'pinned', True) -kmi = km.keymap_items.new('uv.circle_select', 'C', 'PRESS') -kmi = km.keymap_items.new('uv.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('uv.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('uv.select_linked', 'L', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('uv.select_linked_pick', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('uv.select_linked', 'L', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('uv.select_linked_pick', 'L', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('uv.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('uv.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('uv.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('uv.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('uv.select_pinned', 'P', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'IMAGE_MT_uvs_weldalign') -kmi = km.keymap_items.new('uv.stitch', 'V', 'PRESS') -kmi = km.keymap_items.new('uv.pin', 'P', 'PRESS') -kmi_props_setattr(kmi.properties, 'clear', False) -kmi = km.keymap_items.new('uv.pin', 'P', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'clear', True) -kmi = km.keymap_items.new('uv.unwrap', 'E', 'PRESS') -kmi = km.keymap_items.new('uv.minimize_stretch', 'V', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('uv.pack_islands', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('uv.average_islands_scale', 'A', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('uv.hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('uv.hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('uv.reveal', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('uv.cursor_set', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'IMAGE_MT_uvs_snap') -kmi = km.keymap_items.new('wm.call_menu', 'TAB', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'name', 'IMAGE_MT_uvs_select_mode') -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit') -kmi_props_setattr(kmi.properties, 'value_1', 'DISABLED') -kmi_props_setattr(kmi.properties, 'value_2', 'ENABLED') -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') -kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('transform.mirror', 'M', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_snap') -kmi = km.keymap_items.new('wm.context_menu_enum', 'TAB', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.snap_uv_element') - -# Map UV Sculpt -km = kc.keymaps.new('UV Sculpt', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('wm.context_toggle', 'Q', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_uv_sculpt') -kmi = km.keymap_items.new('sculpt.uv_sculpt_stroke', 'LEFTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'NORMAL') -kmi = km.keymap_items.new('sculpt.uv_sculpt_stroke', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'INVERT') -kmi = km.keymap_items.new('sculpt.uv_sculpt_stroke', 'LEFTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'RELAX') -kmi = km.keymap_items.new('brush.scale_size', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 0.9) -kmi = km.keymap_items.new('brush.scale_size', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'scalar', 1.0 / 0.9) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.uv_sculpt.brush.size') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.size') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_size') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.uv_sculpt.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.uv_sculpt.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.uv_sculpt.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('wm.radial_control', 'F', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path_primary', 'tool_settings.uv_sculpt.brush.strength') -kmi_props_setattr(kmi.properties, 'data_path_secondary', 'tool_settings.unified_paint_settings.strength') -kmi_props_setattr(kmi.properties, 'use_secondary', 'tool_settings.unified_paint_settings.use_unified_strength') -kmi_props_setattr(kmi.properties, 'rotation_path', 'tool_settings.uv_sculpt.brush.texture_slot.angle') -kmi_props_setattr(kmi.properties, 'color_path', 'tool_settings.uv_sculpt.brush.cursor_color_add') -kmi_props_setattr(kmi.properties, 'fill_color_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_path', '') -kmi_props_setattr(kmi.properties, 'fill_color_override_test_path', '') -kmi_props_setattr(kmi.properties, 'zoom_path', '') -kmi_props_setattr(kmi.properties, 'image_id', 'tool_settings.uv_sculpt.brush') -kmi_props_setattr(kmi.properties, 'secondary_tex', False) -kmi = km.keymap_items.new('brush.uv_sculpt_tool_set', 'S', 'PRESS') -kmi_props_setattr(kmi.properties, 'tool', 'RELAX') -kmi = km.keymap_items.new('brush.uv_sculpt_tool_set', 'P', 'PRESS') -kmi_props_setattr(kmi.properties, 'tool', 'PINCH') -kmi = km.keymap_items.new('brush.uv_sculpt_tool_set', 'G', 'PRESS') -kmi_props_setattr(kmi.properties, 'tool', 'GRAB') - -# Map Mask Editing -km = kc.keymaps.new('Mask Editing', space_type='EMPTY', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('mask.new', 'N', 'PRESS', alt=True) -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'MASK_MT_add') -kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.proportional_edit_falloff') -kmi_props_setattr(kmi.properties, 'wrap', True) -kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_proportional_edit_mask') -kmi = km.keymap_items.new('mask.add_vertex_slide', 'ACTIONMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mask.add_feather_vertex_slide', 'ACTIONMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('mask.delete', 'X', 'PRESS') -kmi = km.keymap_items.new('mask.delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('mask.select', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', False) -kmi = km.keymap_items.new('mask.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('mask.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('mask.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('mask.select_linked', 'L', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mask.select_linked_pick', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('mask.select_linked_pick', 'L', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('mask.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('mask.select_circle', 'C', 'PRESS') -kmi = km.keymap_items.new('mask.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('mask.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('mask.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mask.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mask.hide_view_clear', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('mask.hide_view_set', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('mask.hide_view_set', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('clip.select', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('mask.cyclic_toggle', 'C', 'PRESS', alt=True) -kmi = km.keymap_items.new('mask.slide_point', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('mask.slide_spline_curvature', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('mask.handle_type_set', 'V', 'PRESS') -kmi = km.keymap_items.new('mask.normals_make_consistent', 'N', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mask.parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mask.parent_clear', 'P', 'PRESS', alt=True) -kmi = km.keymap_items.new('mask.shape_key_insert', 'I', 'PRESS') -kmi = km.keymap_items.new('mask.shape_key_clear', 'I', 'PRESS', alt=True) -kmi = km.keymap_items.new('mask.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('mask.copy_splines', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('mask.paste_splines', 'V', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('uv.cursor_set', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') -kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'MASK_SHRINKFATTEN') - -# Map Graph Editor Generic -km = kc.keymaps.new('Graph Editor Generic', space_type='GRAPH_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('graph.properties', 'N', 'PRESS') -kmi = km.keymap_items.new('graph.extrapolation_type', 'E', 'PRESS', shift=True) -kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('graph.hide', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('graph.hide', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('graph.reveal', 'H', 'PRESS', alt=True) - -# Map Graph Editor -km = kc.keymaps.new('Graph Editor', space_type='GRAPH_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('wm.context_toggle', 'H', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_handles') -kmi = km.keymap_items.new('graph.cursor_set', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'column', False) -kmi_props_setattr(kmi.properties, 'curves', False) -kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'column', True) -kmi_props_setattr(kmi.properties, 'curves', False) -kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'column', False) -kmi_props_setattr(kmi.properties, 'curves', False) -kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'column', True) -kmi_props_setattr(kmi.properties, 'curves', False) -kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'column', False) -kmi_props_setattr(kmi.properties, 'curves', True) -kmi = km.keymap_items.new('graph.clickselect', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'column', False) -kmi_props_setattr(kmi.properties, 'curves', True) -kmi = km.keymap_items.new('graph.select_leftright', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'CHECK') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('graph.select_leftright', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'CHECK') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('graph.select_leftright', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'LEFT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('graph.select_leftright', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'RIGHT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('graph.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('graph.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS') -kmi_props_setattr(kmi.properties, 'axis_range', False) -kmi_props_setattr(kmi.properties, 'include_handles', False) -kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'axis_range', True) -kmi_props_setattr(kmi.properties, 'include_handles', False) -kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'axis_range', False) -kmi_props_setattr(kmi.properties, 'include_handles', True) -kmi = km.keymap_items.new('graph.select_border', 'B', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'axis_range', True) -kmi_props_setattr(kmi.properties, 'include_handles', True) -kmi = km.keymap_items.new('graph.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('graph.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('graph.select_circle', 'C', 'PRESS') -kmi = km.keymap_items.new('graph.select_column', 'K', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'KEYS') -kmi = km.keymap_items.new('graph.select_column', 'K', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'CFRA') -kmi = km.keymap_items.new('graph.select_column', 'K', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'mode', 'MARKERS_COLUMN') -kmi = km.keymap_items.new('graph.select_column', 'K', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'mode', 'MARKERS_BETWEEN') -kmi = km.keymap_items.new('graph.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('graph.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('graph.select_linked', 'L', 'PRESS') -kmi = km.keymap_items.new('graph.frame_jump', 'G', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('graph.snap', 'S', 'PRESS', shift=True) -kmi = km.keymap_items.new('graph.mirror', 'M', 'PRESS', shift=True) -kmi = km.keymap_items.new('graph.handle_type', 'V', 'PRESS') -kmi = km.keymap_items.new('graph.interpolation_type', 'T', 'PRESS') -kmi = km.keymap_items.new('graph.easing_type', 'E', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('graph.smooth', 'O', 'PRESS', alt=True) -kmi = km.keymap_items.new('graph.sample', 'O', 'PRESS', shift=True) -kmi = km.keymap_items.new('graph.bake', 'C', 'PRESS', alt=True) -kmi = km.keymap_items.new('wm.call_menu', 'X', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'GRAPH_MT_delete') -kmi = km.keymap_items.new('wm.call_menu', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'GRAPH_MT_delete') -kmi = km.keymap_items.new('graph.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('graph.keyframe_insert', 'I', 'PRESS') -kmi = km.keymap_items.new('graph.click_insert', 'ACTIONMOUSE', 'CLICK', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('graph.click_insert', 'ACTIONMOUSE', 'CLICK', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('graph.copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('graph.paste', 'V', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('graph.paste', 'V', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'flipped', True) -if platform == "darwin": - kmi = km.keymap_items.new('graph.copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('graph.paste', 'V', 'PRESS', oskey=True) - kmi = km.keymap_items.new('graph.paste', 'V', 'PRESS', shift=True, oskey=True) - kmi_props_setattr(kmi.properties, 'flipped', True) -kmi = km.keymap_items.new('graph.previewrange_set', 'P', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('graph.view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('graph.view_all', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('graph.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('graph.view_frame', 'NUMPAD_0', 'PRESS') -kmi = km.keymap_items.new('graph.fmodifier_add', 'M', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'only_active', False) -kmi = km.keymap_items.new('anim.channels_editable_toggle', 'TAB', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.transform', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TIME_EXTEND') -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') -kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_proportional_fcurve') -kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'BOUNDING_BOX_CENTER') -kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'CURSOR') -kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'INDIVIDUAL_ORIGINS') -kmi = km.keymap_items.new('marker.add', 'M', 'PRESS') -kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True) - -# Map Image Generic -km = kc.keymaps.new('Image Generic', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('image.new', 'N', 'PRESS', alt=True) -kmi = km.keymap_items.new('image.open', 'O', 'PRESS', alt=True) -kmi = km.keymap_items.new('image.reload', 'R', 'PRESS', alt=True) -kmi = km.keymap_items.new('image.read_viewlayers', 'R', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('image.save', 'S', 'PRESS', alt=True) -kmi = km.keymap_items.new('image.save_as', 'F3', 'PRESS') -kmi = km.keymap_items.new('image.properties', 'N', 'PRESS') -kmi = km.keymap_items.new('image.toolshelf', 'T', 'PRESS') -kmi = km.keymap_items.new('image.cycle_render_slot', 'J', 'PRESS') -kmi = km.keymap_items.new('image.cycle_render_slot', 'J', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'reverse', True) - -# Map Image -km = kc.keymaps.new('Image', space_type='IMAGE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('image.view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('image.view_all', 'HOME', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'fit_view', True) -kmi = km.keymap_items.new('image.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('image.view_pan', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('image.view_pan', 'MIDDLEMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('image.view_pan', 'TRACKPADPAN', 'ANY') -kmi = km.keymap_items.new('image.view_all', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('image.view_ndof', 'NDOF_MOTION', 'ANY') -kmi = km.keymap_items.new('image.view_zoom_in', 'WHEELINMOUSE', 'PRESS') -kmi = km.keymap_items.new('image.view_zoom_out', 'WHEELOUTMOUSE', 'PRESS') -kmi = km.keymap_items.new('image.view_zoom_in', 'NUMPAD_PLUS', 'PRESS') -kmi = km.keymap_items.new('image.view_zoom_out', 'NUMPAD_MINUS', 'PRESS') -kmi = km.keymap_items.new('image.view_zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('image.view_zoom', 'TRACKPADZOOM', 'ANY') -kmi = km.keymap_items.new('image.view_zoom', 'TRACKPADPAN', 'ANY', ctrl=True) -kmi = km.keymap_items.new('image.view_zoom_border', 'B', 'PRESS', shift=True) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_8', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'ratio', 8.0) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_4', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'ratio', 4.0) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_2', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'ratio', 2.0) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_8', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'ratio', 8.0) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_4', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'ratio', 4.0) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_2', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'ratio', 2.0) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_1', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 1.0) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_2', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 0.5) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_4', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 0.25) -kmi = km.keymap_items.new('image.view_zoom_ratio', 'NUMPAD_8', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 0.125) -kmi = km.keymap_items.new('image.change_frame', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('image.sample', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('image.curves_point_set', 'ACTIONMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'point', 'BLACK_POINT') -kmi = km.keymap_items.new('image.curves_point_set', 'ACTIONMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'point', 'WHITE_POINT') -kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'EDIT') -kmi_props_setattr(kmi.properties, 'toggle', True) -kmi = km.keymap_items.new('wm.context_set_int', 'ONE', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index') -kmi_props_setattr(kmi.properties, 'value', 0) -kmi = km.keymap_items.new('wm.context_set_int', 'TWO', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index') -kmi_props_setattr(kmi.properties, 'value', 1) -kmi = km.keymap_items.new('wm.context_set_int', 'THREE', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index') -kmi_props_setattr(kmi.properties, 'value', 2) -kmi = km.keymap_items.new('wm.context_set_int', 'FOUR', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index') -kmi_props_setattr(kmi.properties, 'value', 3) -kmi = km.keymap_items.new('wm.context_set_int', 'FIVE', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index') -kmi_props_setattr(kmi.properties, 'value', 4) -kmi = km.keymap_items.new('wm.context_set_int', 'SIX', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index') -kmi_props_setattr(kmi.properties, 'value', 5) -kmi = km.keymap_items.new('wm.context_set_int', 'SEVEN', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index') -kmi_props_setattr(kmi.properties, 'value', 6) -kmi = km.keymap_items.new('wm.context_set_int', 'EIGHT', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.image.render_slots.active_index') -kmi_props_setattr(kmi.properties, 'value', 7) -kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'CENTER') -kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'MEDIAN') -kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'CURSOR') -kmi = km.keymap_items.new('image.render_border', 'B', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('image.clear_render_border', 'B', 'PRESS', ctrl=True, alt=True) - -# Map Node Generic -km = kc.keymaps.new('Node Generic', space_type='NODE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('node.properties', 'N', 'PRESS') -kmi = km.keymap_items.new('node.toolbar', 'T', 'PRESS') - -# Map Node Editor -km = kc.keymaps.new('Node Editor', space_type='NODE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select', 'ACTIONMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select_border', 'EVT_TWEAK_S', 'ANY') -kmi_props_setattr(kmi.properties, 'tweak', True) -kmi = km.keymap_items.new('node.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('node.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('node.select_circle', 'C', 'PRESS') -kmi = km.keymap_items.new('node.link', 'LEFTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'detach', False) -kmi = km.keymap_items.new('node.link', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'detach', True) -kmi = km.keymap_items.new('node.resize', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('node.add_reroute', 'LEFTMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('node.links_cut', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.select_link_viewer', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('node.backimage_move', 'MIDDLEMOUSE', 'PRESS', alt=True) -kmi = km.keymap_items.new('node.backimage_zoom', 'V', 'PRESS') -kmi_props_setattr(kmi.properties, 'factor', 1.0 / 1.2) -kmi = km.keymap_items.new('node.backimage_zoom', 'V', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'factor', 1.2) -kmi = km.keymap_items.new('node.backimage_fit', 'HOME', 'PRESS', alt=True) -kmi = km.keymap_items.new('node.backimage_sample', 'ACTIONMOUSE', 'PRESS', alt=True) -kmi = km.keymap_items.new('node.link_make', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'replace', False) -kmi = km.keymap_items.new('node.link_make', 'F', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'replace', True) -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'NODE_MT_add') -kmi = km.keymap_items.new('node.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('node.duplicate_move_keep_inputs', 'D', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('node.parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.detach', 'P', 'PRESS', alt=True) -kmi = km.keymap_items.new('node.join', 'J', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.hide_toggle', 'H', 'PRESS') -kmi = km.keymap_items.new('node.mute_toggle', 'M', 'PRESS') -kmi = km.keymap_items.new('node.preview_toggle', 'H', 'PRESS', shift=True) -kmi = km.keymap_items.new('node.hide_socket_toggle', 'H', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('node.view_all', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('node.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('node.select_border', 'B', 'PRESS') -kmi_props_setattr(kmi.properties, 'tweak', False) -kmi = km.keymap_items.new('node.delete', 'X', 'PRESS') -kmi = km.keymap_items.new('node.delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('node.delete_reconnect', 'X', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('node.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('node.select_linked_to', 'L', 'PRESS', shift=True) -kmi = km.keymap_items.new('node.select_linked_from', 'L', 'PRESS') -kmi = km.keymap_items.new('node.select_grouped', 'G', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('node.select_grouped', 'G', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('node.select_same_type_step', 'RIGHT_BRACKET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'prev', False) -kmi = km.keymap_items.new('node.select_same_type_step', 'LEFT_BRACKET', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'prev', True) -kmi = km.keymap_items.new('node.find_node', 'F', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.group_make', 'G', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.group_ungroup', 'G', 'PRESS', alt=True) -kmi = km.keymap_items.new('node.group_separate', 'P', 'PRESS') -kmi = km.keymap_items.new('node.group_edit', 'TAB', 'PRESS') -kmi_props_setattr(kmi.properties, 'exit', False) -kmi = km.keymap_items.new('node.group_edit', 'TAB', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'exit', True) -kmi = km.keymap_items.new('node.read_viewlayers', 'R', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.render_changed', 'Z', 'PRESS') -kmi = km.keymap_items.new('node.clipboard_copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.clipboard_paste', 'V', 'PRESS', ctrl=True) -if platform == "darwin": - kmi = km.keymap_items.new('node.clipboard_copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('node.clipboard_paste', 'V', 'PRESS', oskey=True) -kmi = km.keymap_items.new('node.viewer_border', 'B', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.clear_viewer_border', 'B', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('node.translate_attach', 'G', 'PRESS') -kmi = km.keymap_items.new('node.translate_attach', 'EVT_TWEAK_A', 'ANY') -kmi = km.keymap_items.new('node.translate_attach', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi_props_setattr(kmi.properties, 'release_confirm', True) -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_A', 'ANY') -kmi_props_setattr(kmi.properties, 'release_confirm', True) -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi_props_setattr(kmi.properties, 'release_confirm', True) -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') -kmi = km.keymap_items.new('node.move_detach_links', 'D', 'PRESS', alt=True) -kmi = km.keymap_items.new('node.move_detach_links_release', 'EVT_TWEAK_A', 'ANY', alt=True) -kmi = km.keymap_items.new('node.move_detach_links', 'EVT_TWEAK_S', 'ANY', alt=True) -kmi = km.keymap_items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.use_snap') -kmi = km.keymap_items.new('wm.context_menu_enum', 'TAB', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'tool_settings.snap_node_element') - -# Map Info -km = kc.keymaps.new('Info', space_type='INFO', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('info.select_pick', 'SELECTMOUSE', 'PRESS') -kmi = km.keymap_items.new('info.select_all_toggle', 'A', 'PRESS') -kmi = km.keymap_items.new('info.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('info.report_replay', 'R', 'PRESS') -kmi = km.keymap_items.new('info.report_delete', 'X', 'PRESS') -kmi = km.keymap_items.new('info.report_delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('info.report_copy', 'C', 'PRESS', ctrl=True) -if platform == "darwin": - kmi = km.keymap_items.new('info.report_copy', 'C', 'PRESS', oskey=True) - -# Map File Browser -km = kc.keymaps.new('File Browser', space_type='FILE_BROWSER', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('file.parent', 'UP_ARROW', 'PRESS', alt=True) -kmi = km.keymap_items.new('file.previous', 'LEFT_ARROW', 'PRESS', alt=True) -kmi = km.keymap_items.new('file.next', 'RIGHT_ARROW', 'PRESS', alt=True) -kmi = km.keymap_items.new('file.refresh', 'R', 'PRESS') -kmi = km.keymap_items.new('file.parent', 'P', 'PRESS') -kmi = km.keymap_items.new('file.previous', 'BACK_SPACE', 'PRESS') -kmi = km.keymap_items.new('file.next', 'BACK_SPACE', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.context_toggle', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.params.show_hidden') -kmi = km.keymap_items.new('file.directory_new', 'I', 'PRESS') -kmi = km.keymap_items.new('file.delete', 'X', 'PRESS') -kmi = km.keymap_items.new('file.delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('file.smoothscroll', 'TIMER1', 'ANY', any=True) -kmi = km.keymap_items.new('file.bookmark_toggle', 'T', 'PRESS') -kmi = km.keymap_items.new('file.bookmark_add', 'B', 'PRESS', ctrl=True) - -# Map File Browser Main -km = kc.keymaps.new('File Browser Main', space_type='FILE_BROWSER', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('file.execute', 'LEFTMOUSE', 'DOUBLE_CLICK') -kmi_props_setattr(kmi.properties, 'need_active', True) -kmi = km.keymap_items.new('file.refresh', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK') -kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('file.select', 'LEFTMOUSE', 'CLICK', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'fill', True) -kmi = km.keymap_items.new('file.select', 'RIGHTMOUSE', 'CLICK') -kmi_props_setattr(kmi.properties, 'open', False) -kmi = km.keymap_items.new('file.select', 'RIGHTMOUSE', 'CLICK', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'open', False) -kmi = km.keymap_items.new('file.select', 'RIGHTMOUSE', 'CLICK', alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'fill', True) -kmi_props_setattr(kmi.properties, 'open', False) -kmi = km.keymap_items.new('file.select_walk', 'UP_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'UP') -kmi = km.keymap_items.new('file.select_walk', 'UP_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'UP') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('file.select_walk', 'UP_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'direction', 'UP') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'fill', True) -kmi = km.keymap_items.new('file.select_walk', 'DOWN_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'DOWN') -kmi = km.keymap_items.new('file.select_walk', 'DOWN_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'DOWN') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('file.select_walk', 'DOWN_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'direction', 'DOWN') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'fill', True) -kmi = km.keymap_items.new('file.select_walk', 'LEFT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'LEFT') -kmi = km.keymap_items.new('file.select_walk', 'LEFT_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'LEFT') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('file.select_walk', 'LEFT_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'direction', 'LEFT') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'fill', True) -kmi = km.keymap_items.new('file.select_walk', 'RIGHT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'direction', 'RIGHT') -kmi = km.keymap_items.new('file.select_walk', 'RIGHT_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'direction', 'RIGHT') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('file.select_walk', 'RIGHT_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'direction', 'RIGHT') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'fill', True) -kmi = km.keymap_items.new('file.previous', 'BUTTON4MOUSE', 'CLICK') -kmi = km.keymap_items.new('file.next', 'BUTTON5MOUSE', 'CLICK') -kmi = km.keymap_items.new('file.select_all_toggle', 'A', 'PRESS') -kmi = km.keymap_items.new('file.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('file.select_border', 'EVT_TWEAK_L', 'ANY') -kmi = km.keymap_items.new('file.rename', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('file.highlight', 'MOUSEMOVE', 'ANY', any=True) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'increment', 1) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'increment', 10) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'increment', 100) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'increment', -1) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'increment', -10) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'increment', -100) - -# Map File Browser Buttons -km = kc.keymaps.new('File Browser Buttons', space_type='FILE_BROWSER', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'increment', 1) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'increment', 10) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'increment', 100) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS') -kmi_props_setattr(kmi.properties, 'increment', -1) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'increment', -10) -kmi = km.keymap_items.new('file.filenum', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'increment', -100) - -# Map NLA Generic -km = kc.keymaps.new('NLA Generic', space_type='NLA_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('nla.properties', 'N', 'PRESS') -kmi = km.keymap_items.new('nla.tweakmode_enter', 'TAB', 'PRESS') -kmi = km.keymap_items.new('nla.tweakmode_exit', 'TAB', 'PRESS') -kmi = km.keymap_items.new('nla.tweakmode_enter', 'TAB', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'isolate_action', True) -kmi = km.keymap_items.new('nla.tweakmode_exit', 'TAB', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'isolate_action', True) -kmi = km.keymap_items.new('anim.channels_find', 'F', 'PRESS', ctrl=True) - -# Map NLA Channels -km = kc.keymaps.new('NLA Channels', space_type='NLA_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('nla.channels_click', 'LEFTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('nla.channels_click', 'LEFTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('nla.tracks_add', 'A', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'above_selected', False) -kmi = km.keymap_items.new('nla.tracks_add', 'A', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'above_selected', True) -kmi = km.keymap_items.new('nla.tracks_delete', 'X', 'PRESS') -kmi = km.keymap_items.new('nla.tracks_delete', 'DEL', 'PRESS') - -# Map NLA Editor -km = kc.keymaps.new('NLA Editor', space_type='NLA_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('nla.click_select', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('nla.click_select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('nla.select_leftright', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'CHECK') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('nla.select_leftright', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'mode', 'CHECK') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('nla.select_leftright', 'LEFT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'LEFT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('nla.select_leftright', 'RIGHT_BRACKET', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'RIGHT') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('nla.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('nla.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('nla.select_border', 'B', 'PRESS') -kmi_props_setattr(kmi.properties, 'axis_range', False) -kmi = km.keymap_items.new('nla.select_border', 'B', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'axis_range', True) -kmi = km.keymap_items.new('nla.previewrange_set', 'P', 'PRESS', ctrl=True, alt=True) -kmi = km.keymap_items.new('nla.view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('nla.view_all', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('nla.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('nla.view_frame', 'NUMPAD_0', 'PRESS') -kmi = km.keymap_items.new('nla.actionclip_add', 'A', 'PRESS', shift=True) -kmi = km.keymap_items.new('nla.transition_add', 'T', 'PRESS', shift=True) -kmi = km.keymap_items.new('nla.soundclip_add', 'K', 'PRESS', shift=True) -kmi = km.keymap_items.new('nla.meta_add', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('nla.meta_remove', 'G', 'PRESS', alt=True) -kmi = km.keymap_items.new('nla.duplicate', 'D', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'linked', False) -kmi = km.keymap_items.new('nla.duplicate', 'D', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'linked', True) -kmi = km.keymap_items.new('nla.make_single_user', 'U', 'PRESS') -kmi = km.keymap_items.new('nla.delete', 'X', 'PRESS') -kmi = km.keymap_items.new('nla.delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('nla.split', 'Y', 'PRESS') -kmi = km.keymap_items.new('nla.mute_toggle', 'H', 'PRESS') -kmi = km.keymap_items.new('nla.swap', 'F', 'PRESS', alt=True) -kmi = km.keymap_items.new('nla.move_up', 'PAGE_UP', 'PRESS') -kmi = km.keymap_items.new('nla.move_down', 'PAGE_DOWN', 'PRESS') -kmi = km.keymap_items.new('nla.apply_scale', 'A', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('nla.clear_scale', 'S', 'PRESS', alt=True) -kmi = km.keymap_items.new('nla.snap', 'S', 'PRESS', shift=True) -kmi = km.keymap_items.new('nla.fmodifier_add', 'M', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('transform.transform', 'G', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION') -kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_S', 'ANY') -kmi_props_setattr(kmi.properties, 'mode', 'TRANSLATION') -kmi = km.keymap_items.new('transform.transform', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TIME_EXTEND') -kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TIME_SCALE') -kmi = km.keymap_items.new('marker.add', 'M', 'PRESS') -kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True) - -# Map Text Generic -km = kc.keymaps.new('Text Generic', space_type='TEXT_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('text.start_find', 'F', 'PRESS', ctrl=True) -if platform == "darwin": - kmi = km.keymap_items.new('text.start_find', 'F', 'PRESS', oskey=True) -kmi = km.keymap_items.new('text.jump', 'J', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.find', 'G', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.replace', 'H', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.properties', 'T', 'PRESS', ctrl=True) - -# Map Text -km = kc.keymaps.new('Text', space_type='TEXT_EDITOR', region_type='WINDOW', modal=False) - -if platform == "darwin": - kmi = km.keymap_items.new('text.move', 'LEFT_ARROW', 'PRESS', oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN') - kmi = km.keymap_items.new('text.move', 'RIGHT_ARROW', 'PRESS', oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'LINE_END') - kmi = km.keymap_items.new('text.move', 'LEFT_ARROW', 'PRESS', alt=True) - kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') - kmi = km.keymap_items.new('text.move', 'RIGHT_ARROW', 'PRESS', alt=True) - kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') - kmi = km.keymap_items.new('text.move', 'UP_ARROW', 'PRESS', oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'FILE_TOP') - kmi = km.keymap_items.new('text.move', 'DOWN_ARROW', 'PRESS', oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'FILE_BOTTOM') - kmi = km.keymap_items.new('text.move_select', 'LEFT_ARROW', 'PRESS', shift=True, oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN') - kmi = km.keymap_items.new('text.move_select', 'RIGHT_ARROW', 'PRESS', shift=True, oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'LINE_END') - kmi = km.keymap_items.new('text.move_select', 'LEFT_ARROW', 'PRESS', shift=True, alt=True) - kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') - kmi = km.keymap_items.new('text.move_select', 'RIGHT_ARROW', 'PRESS', shift=True, alt=True) - kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') - kmi = km.keymap_items.new('text.move_select', 'UP_ARROW', 'PRESS', shift=True, oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'FILE_TOP') - kmi = km.keymap_items.new('text.move_select', 'DOWN_ARROW', 'PRESS', shift=True, oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'FILE_BOTTOM') - kmi = km.keymap_items.new('text.delete', 'BACK_SPACE', 'PRESS', alt=True) - kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') - kmi = km.keymap_items.new('text.save', 'S', 'PRESS', alt=True, oskey=True) - kmi = km.keymap_items.new('text.save_as', 'S', 'PRESS', shift=True, alt=True, oskey=True) - kmi = km.keymap_items.new('text.cut', 'X', 'PRESS', oskey=True) - kmi = km.keymap_items.new('text.copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('text.paste', 'V', 'PRESS', oskey=True) - kmi = km.keymap_items.new('text.find_set_selected', 'E', 'PRESS', oskey=True) - kmi = km.keymap_items.new('text.select_all', 'A', 'PRESS', oskey=True) - kmi = km.keymap_items.new('text.select_line', 'A', 'PRESS', shift=True, oskey=True) -kmi = km.keymap_items.new('wm.context_cycle_int', 'WHEELUPMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size') -kmi_props_setattr(kmi.properties, 'reverse', False) -kmi = km.keymap_items.new('wm.context_cycle_int', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size') -kmi_props_setattr(kmi.properties, 'reverse', True) -kmi = km.keymap_items.new('wm.context_cycle_int', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size') -kmi_props_setattr(kmi.properties, 'reverse', False) -kmi = km.keymap_items.new('wm.context_cycle_int', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size') -kmi_props_setattr(kmi.properties, 'reverse', True) -kmi = km.keymap_items.new('text.new', 'N', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.open', 'O', 'PRESS', alt=True) -kmi = km.keymap_items.new('text.reload', 'R', 'PRESS', alt=True) -kmi = km.keymap_items.new('text.save', 'S', 'PRESS', alt=True) -kmi = km.keymap_items.new('text.save_as', 'S', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.keymap_items.new('text.run_script', 'P', 'PRESS', alt=True) -kmi = km.keymap_items.new('text.cut', 'X', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.paste', 'V', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.cut', 'DEL', 'PRESS', shift=True) -kmi = km.keymap_items.new('text.copy', 'INSERT', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.paste', 'INSERT', 'PRESS', shift=True) -kmi = km.keymap_items.new('text.duplicate_line', 'D', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.select_all', 'A', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.select_line', 'A', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('text.select_word', 'LEFTMOUSE', 'DOUBLE_CLICK') -kmi = km.keymap_items.new('text.move_lines', 'UP_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'direction', 'UP') -kmi = km.keymap_items.new('text.move_lines', 'DOWN_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'direction', 'DOWN') -kmi = km.keymap_items.new('text.indent', 'TAB', 'PRESS') -kmi = km.keymap_items.new('text.unindent', 'TAB', 'PRESS', shift=True) -kmi = km.keymap_items.new('text.uncomment', 'D', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('text.move', 'HOME', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN') -kmi = km.keymap_items.new('text.move', 'END', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'LINE_END') -kmi = km.keymap_items.new('text.move', 'E', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'LINE_END') -kmi = km.keymap_items.new('text.move', 'E', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'LINE_END') -kmi = km.keymap_items.new('text.move', 'LEFT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('text.move', 'RIGHT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER') -kmi = km.keymap_items.new('text.move', 'LEFT_ARROW', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') -kmi = km.keymap_items.new('text.move', 'RIGHT_ARROW', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') -kmi = km.keymap_items.new('text.move', 'UP_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_LINE') -kmi = km.keymap_items.new('text.move', 'DOWN_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_LINE') -kmi = km.keymap_items.new('text.move', 'PAGE_UP', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_PAGE') -kmi = km.keymap_items.new('text.move', 'PAGE_DOWN', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_PAGE') -kmi = km.keymap_items.new('text.move', 'HOME', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'FILE_TOP') -kmi = km.keymap_items.new('text.move', 'END', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'FILE_BOTTOM') -kmi = km.keymap_items.new('text.move_select', 'HOME', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN') -kmi = km.keymap_items.new('text.move_select', 'END', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'LINE_END') -kmi = km.keymap_items.new('text.move_select', 'LEFT_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('text.move_select', 'RIGHT_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER') -kmi = km.keymap_items.new('text.move_select', 'LEFT_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') -kmi = km.keymap_items.new('text.move_select', 'RIGHT_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') -kmi = km.keymap_items.new('text.move_select', 'UP_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_LINE') -kmi = km.keymap_items.new('text.move_select', 'DOWN_ARROW', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_LINE') -kmi = km.keymap_items.new('text.move_select', 'PAGE_UP', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_PAGE') -kmi = km.keymap_items.new('text.move_select', 'PAGE_DOWN', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_PAGE') -kmi = km.keymap_items.new('text.move_select', 'HOME', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'FILE_TOP') -kmi = km.keymap_items.new('text.move_select', 'END', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'FILE_BOTTOM') -kmi = km.keymap_items.new('text.delete', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER') -kmi = km.keymap_items.new('text.delete', 'BACK_SPACE', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('text.delete', 'BACK_SPACE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('text.delete', 'DEL', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') -kmi = km.keymap_items.new('text.delete', 'BACK_SPACE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') -kmi = km.keymap_items.new('text.overwrite_toggle', 'INSERT', 'PRESS') -kmi = km.keymap_items.new('text.scroll_bar', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('text.scroll_bar', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('text.scroll', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('text.scroll', 'TRACKPADPAN', 'ANY') -kmi = km.keymap_items.new('text.selection_set', 'EVT_TWEAK_L', 'ANY') -kmi = km.keymap_items.new('text.cursor_set', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('text.selection_set', 'LEFTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'select', True) -kmi = km.keymap_items.new('text.scroll', 'WHEELUPMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'lines', -1) -kmi = km.keymap_items.new('text.scroll', 'WHEELDOWNMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'lines', 1) -kmi = km.keymap_items.new('text.line_break', 'RET', 'PRESS') -kmi = km.keymap_items.new('text.line_break', 'NUMPAD_ENTER', 'PRESS') -kmi = km.keymap_items.new('wm.call_menu', 'RIGHTMOUSE', 'PRESS', any=True) -kmi_props_setattr(kmi.properties, 'name', 'TEXT_MT_toolbox') -kmi = km.keymap_items.new('text.autocomplete', 'SPACE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('text.line_number', 'TEXTINPUT', 'ANY', any=True) -kmi = km.keymap_items.new('text.insert', 'TEXTINPUT', 'ANY', any=True) - -# Map SequencerCommon -km = kc.keymaps.new('SequencerCommon', space_type='SEQUENCE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('sequencer.properties', 'N', 'PRESS') -kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'data_path', 'scene.sequence_editor.show_overlay') -kmi = km.keymap_items.new('sequencer.view_toggle', 'TAB', 'PRESS', ctrl=True) - -# Map Sequencer -km = kc.keymaps.new('Sequencer', space_type='SEQUENCE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('sequencer.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('sequencer.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('sequencer.cut', 'K', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'SOFT') -kmi = km.keymap_items.new('sequencer.cut', 'K', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'HARD') -kmi = km.keymap_items.new('sequencer.mute', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('sequencer.mute', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('sequencer.unmute', 'H', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('sequencer.unmute', 'H', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('sequencer.lock', 'L', 'PRESS', shift=True) -kmi = km.keymap_items.new('sequencer.unlock', 'L', 'PRESS', shift=True, alt=True) -kmi = km.keymap_items.new('sequencer.reassign_inputs', 'R', 'PRESS') -kmi = km.keymap_items.new('sequencer.reload', 'R', 'PRESS', alt=True) -kmi = km.keymap_items.new('sequencer.reload', 'R', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'adjust_length', True) -kmi = km.keymap_items.new('sequencer.offset_clear', 'O', 'PRESS', alt=True) -kmi = km.keymap_items.new('sequencer.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.keymap_items.new('sequencer.delete', 'X', 'PRESS') -kmi = km.keymap_items.new('sequencer.delete', 'DEL', 'PRESS') -kmi = km.keymap_items.new('sequencer.copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('sequencer.paste', 'V', 'PRESS', ctrl=True) -if platform == "darwin": - kmi = km.keymap_items.new('sequencer.copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('sequencer.paste', 'V', 'PRESS', oskey=True) -kmi = km.keymap_items.new('sequencer.images_separate', 'Y', 'PRESS') -kmi = km.keymap_items.new('sequencer.meta_toggle', 'TAB', 'PRESS') -kmi = km.keymap_items.new('sequencer.meta_make', 'G', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('sequencer.meta_separate', 'G', 'PRESS', alt=True) -kmi = km.keymap_items.new('sequencer.view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('sequencer.view_all', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('sequencer.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('sequencer.view_frame', 'NUMPAD_0', 'PRESS') -kmi = km.keymap_items.new('sequencer.strip_jump', 'PAGE_UP', 'PRESS') -kmi_props_setattr(kmi.properties, 'next', True) -kmi_props_setattr(kmi.properties, 'center', False) -kmi = km.keymap_items.new('sequencer.strip_jump', 'PAGE_DOWN', 'PRESS') -kmi_props_setattr(kmi.properties, 'next', False) -kmi_props_setattr(kmi.properties, 'center', False) -kmi = km.keymap_items.new('sequencer.strip_jump', 'PAGE_UP', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'next', True) -kmi_props_setattr(kmi.properties, 'center', True) -kmi = km.keymap_items.new('sequencer.strip_jump', 'PAGE_DOWN', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'next', False) -kmi_props_setattr(kmi.properties, 'center', True) -kmi = km.keymap_items.new('sequencer.swap', 'LEFT_ARROW', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'side', 'LEFT') -kmi = km.keymap_items.new('sequencer.swap', 'RIGHT_ARROW', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'side', 'RIGHT') -kmi = km.keymap_items.new('sequencer.gap_remove', 'BACK_SPACE', 'PRESS') -kmi_props_setattr(kmi.properties, 'all', False) -kmi = km.keymap_items.new('sequencer.gap_remove', 'BACK_SPACE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'all', True) -kmi = km.keymap_items.new('sequencer.gap_insert', 'EQUAL', 'PRESS', shift=True) -kmi = km.keymap_items.new('sequencer.snap', 'S', 'PRESS', shift=True) -kmi = km.keymap_items.new('sequencer.swap_inputs', 'S', 'PRESS', alt=True) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'ONE', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 1) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'TWO', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 2) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'THREE', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 3) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'FOUR', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 4) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'FIVE', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 5) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'SIX', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 6) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'SEVEN', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 7) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'EIGHT', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 8) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'NINE', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 9) -kmi = km.keymap_items.new('sequencer.cut_multicam', 'ZERO', 'PRESS') -kmi_props_setattr(kmi.properties, 'camera', 10) -kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'linked_handle', False) -kmi_props_setattr(kmi.properties, 'left_right', 'NONE') -kmi_props_setattr(kmi.properties, 'linked_time', False) -kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'linked_handle', False) -kmi_props_setattr(kmi.properties, 'left_right', 'NONE') -kmi_props_setattr(kmi.properties, 'linked_time', False) -kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'linked_handle', True) -kmi_props_setattr(kmi.properties, 'left_right', 'NONE') -kmi_props_setattr(kmi.properties, 'linked_time', False) -kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'linked_handle', True) -kmi_props_setattr(kmi.properties, 'left_right', 'NONE') -kmi_props_setattr(kmi.properties, 'linked_time', False) -kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', False) -kmi_props_setattr(kmi.properties, 'linked_handle', False) -kmi_props_setattr(kmi.properties, 'left_right', 'MOUSE') -kmi_props_setattr(kmi.properties, 'linked_time', True) -kmi = km.keymap_items.new('sequencer.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi_props_setattr(kmi.properties, 'linked_handle', False) -kmi_props_setattr(kmi.properties, 'left_right', 'NONE') -kmi_props_setattr(kmi.properties, 'linked_time', True) -kmi = km.keymap_items.new('sequencer.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('sequencer.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('sequencer.select_linked_pick', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('sequencer.select_linked_pick', 'L', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('sequencer.select_linked', 'L', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('sequencer.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('sequencer.select_grouped', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'SEQUENCER_MT_add') -kmi = km.keymap_items.new('wm.call_menu', 'C', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'SEQUENCER_MT_change') -kmi = km.keymap_items.new('sequencer.slip', 'S', 'PRESS') -kmi = km.keymap_items.new('wm.context_set_int', 'O', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'scene.sequence_editor.overlay_frame') -kmi_props_setattr(kmi.properties, 'value', 0) -kmi = km.keymap_items.new('transform.seq_slide', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.seq_slide', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.transform', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'mode', 'TIME_EXTEND') -kmi = km.keymap_items.new('marker.add', 'M', 'PRESS') -kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True) - -# Map SequencerPreview -km = kc.keymaps.new('SequencerPreview', space_type='SEQUENCE_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('sequencer.view_all_preview', 'HOME', 'PRESS') -kmi = km.keymap_items.new('sequencer.view_all_preview', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('sequencer.view_ghost_border', 'O', 'PRESS') -kmi = km.keymap_items.new('sequencer.view_zoom_ratio', 'NUMPAD_1', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 1.0) -kmi = km.keymap_items.new('sequencer.sample', 'ACTIONMOUSE', 'PRESS') - -# Map Console -km = kc.keymaps.new('Console', space_type='CONSOLE', region_type='WINDOW', modal=False) - -if platform == "darwin": - kmi = km.keymap_items.new('console.move', 'LEFT_ARROW', 'PRESS', oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN') - kmi = km.keymap_items.new('console.move', 'RIGHT_ARROW', 'PRESS', oskey=True) - kmi_props_setattr(kmi.properties, 'type', 'LINE_END') -kmi = km.keymap_items.new('console.move', 'LEFT_ARROW', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') -kmi = km.keymap_items.new('console.move', 'RIGHT_ARROW', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') -kmi = km.keymap_items.new('console.move', 'HOME', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'LINE_BEGIN') -kmi = km.keymap_items.new('console.move', 'END', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'LINE_END') -kmi = km.keymap_items.new('wm.context_cycle_int', 'WHEELUPMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size') -kmi_props_setattr(kmi.properties, 'reverse', False) -kmi = km.keymap_items.new('wm.context_cycle_int', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size') -kmi_props_setattr(kmi.properties, 'reverse', True) -kmi = km.keymap_items.new('wm.context_cycle_int', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size') -kmi_props_setattr(kmi.properties, 'reverse', False) -kmi = km.keymap_items.new('wm.context_cycle_int', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.font_size') -kmi_props_setattr(kmi.properties, 'reverse', True) -kmi = km.keymap_items.new('console.move', 'LEFT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('console.move', 'RIGHT_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER') -kmi = km.keymap_items.new('console.history_cycle', 'UP_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'reverse', True) -kmi = km.keymap_items.new('console.history_cycle', 'DOWN_ARROW', 'PRESS') -kmi_props_setattr(kmi.properties, 'reverse', False) -kmi = km.keymap_items.new('console.delete', 'DEL', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'NEXT_CHARACTER') -kmi = km.keymap_items.new('console.delete', 'BACK_SPACE', 'PRESS') -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('console.delete', 'BACK_SPACE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_CHARACTER') -kmi = km.keymap_items.new('console.delete', 'DEL', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'NEXT_WORD') -kmi = km.keymap_items.new('console.delete', 'BACK_SPACE', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'type', 'PREVIOUS_WORD') -kmi = km.keymap_items.new('console.clear_line', 'RET', 'PRESS', shift=True) -kmi = km.keymap_items.new('console.clear_line', 'NUMPAD_ENTER', 'PRESS', shift=True) -kmi = km.keymap_items.new('console.execute', 'RET', 'PRESS') -kmi_props_setattr(kmi.properties, 'interactive', True) -kmi = km.keymap_items.new('console.execute', 'NUMPAD_ENTER', 'PRESS') -kmi_props_setattr(kmi.properties, 'interactive', True) -kmi = km.keymap_items.new('console.autocomplete', 'SPACE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('console.copy_as_script', 'C', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('console.copy', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('console.paste', 'V', 'PRESS', ctrl=True) -if platform == "darwin": - kmi = km.keymap_items.new('console.copy', 'C', 'PRESS', oskey=True) - kmi = km.keymap_items.new('console.paste', 'V', 'PRESS', oskey=True) -kmi = km.keymap_items.new('console.select_set', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('console.select_word', 'LEFTMOUSE', 'DOUBLE_CLICK') -kmi = km.keymap_items.new('console.insert', 'TAB', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'text', '\t') -kmi = km.keymap_items.new('console.indent', 'TAB', 'PRESS') -kmi = km.keymap_items.new('console.unindent', 'TAB', 'PRESS', shift=True) -kmi = km.keymap_items.new('console.insert', 'TEXTINPUT', 'ANY', any=True) - -# Map Clip -km = kc.keymaps.new('Clip', space_type='CLIP_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('clip.open', 'O', 'PRESS', alt=True) -kmi = km.keymap_items.new('clip.tools', 'T', 'PRESS') -kmi = km.keymap_items.new('clip.properties', 'N', 'PRESS') -kmi = km.keymap_items.new('clip.track_markers', 'LEFT_ARROW', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'backwards', True) -kmi_props_setattr(kmi.properties, 'sequence', False) -kmi = km.keymap_items.new('clip.track_markers', 'RIGHT_ARROW', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'backwards', False) -kmi_props_setattr(kmi.properties, 'sequence', False) -kmi = km.keymap_items.new('clip.track_markers', 'T', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'backwards', False) -kmi_props_setattr(kmi.properties, 'sequence', True) -kmi = km.keymap_items.new('clip.track_markers', 'T', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'backwards', True) -kmi_props_setattr(kmi.properties, 'sequence', True) -kmi = km.keymap_items.new('wm.context_toggle_enum', 'TAB', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.mode') -kmi_props_setattr(kmi.properties, 'value_1', 'TRACKING') -kmi_props_setattr(kmi.properties, 'value_2', 'MASK') -kmi = km.keymap_items.new('clip.solve_camera', 'S', 'PRESS', shift=True) -kmi = km.keymap_items.new('clip.set_solver_keyframe', 'Q', 'PRESS') -kmi_props_setattr(kmi.properties, 'keyframe', 'KEYFRAME_A') -kmi = km.keymap_items.new('clip.set_solver_keyframe', 'E', 'PRESS') -kmi_props_setattr(kmi.properties, 'keyframe', 'KEYFRAME_B') -kmi = km.keymap_items.new('clip.prefetch', 'P', 'PRESS') - -# Map Clip Editor -km = kc.keymaps.new('Clip Editor', space_type='CLIP_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('clip.view_pan', 'MIDDLEMOUSE', 'PRESS') -kmi = km.keymap_items.new('clip.view_pan', 'MIDDLEMOUSE', 'PRESS', shift=True) -kmi = km.keymap_items.new('clip.view_pan', 'TRACKPADPAN', 'ANY') -kmi = km.keymap_items.new('clip.view_zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('clip.view_zoom', 'TRACKPADZOOM', 'ANY') -kmi = km.keymap_items.new('clip.view_zoom', 'TRACKPADPAN', 'ANY', ctrl=True) -kmi = km.keymap_items.new('clip.view_zoom_in', 'WHEELINMOUSE', 'PRESS') -kmi = km.keymap_items.new('clip.view_zoom_out', 'WHEELOUTMOUSE', 'PRESS') -kmi = km.keymap_items.new('clip.view_zoom_in', 'NUMPAD_PLUS', 'PRESS') -kmi = km.keymap_items.new('clip.view_zoom_out', 'NUMPAD_MINUS', 'PRESS') -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_8', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'ratio', 8.0) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_4', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'ratio', 4.0) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_2', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'ratio', 2.0) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_8', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'ratio', 8.0) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_4', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'ratio', 4.0) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_2', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'ratio', 2.0) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_1', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 1.0) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_2', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 0.5) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_4', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 0.25) -kmi = km.keymap_items.new('clip.view_zoom_ratio', 'NUMPAD_8', 'PRESS') -kmi_props_setattr(kmi.properties, 'ratio', 0.125) -kmi = km.keymap_items.new('clip.view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('clip.view_all', 'F', 'PRESS') -kmi_props_setattr(kmi.properties, 'fit_view', True) -kmi = km.keymap_items.new('clip.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('clip.view_all', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('clip.view_ndof', 'NDOF_MOTION', 'ANY') -kmi = km.keymap_items.new('clip.frame_jump', 'LEFT_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'position', 'PATHSTART') -kmi = km.keymap_items.new('clip.frame_jump', 'RIGHT_ARROW', 'PRESS', shift=True, ctrl=True) -kmi_props_setattr(kmi.properties, 'position', 'PATHEND') -kmi = km.keymap_items.new('clip.frame_jump', 'LEFT_ARROW', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'position', 'FAILEDPREV') -kmi = km.keymap_items.new('clip.frame_jump', 'RIGHT_ARROW', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'position', 'PATHSTART') -kmi = km.keymap_items.new('clip.change_frame', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('clip.select', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('clip.select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('clip.select_all', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('clip.select_all', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('clip.select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('clip.select_circle', 'C', 'PRESS') -kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'name', 'CLIP_MT_select_grouped') -kmi = km.keymap_items.new('clip.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'deselect', False) -kmi = km.keymap_items.new('clip.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True, alt=True) -kmi_props_setattr(kmi.properties, 'deselect', True) -kmi = km.keymap_items.new('clip.add_marker_slide', 'LEFTMOUSE', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('clip.delete_marker', 'DEL', 'PRESS', shift=True) -kmi = km.keymap_items.new('clip.delete_marker', 'X', 'PRESS', shift=True) -kmi = km.keymap_items.new('clip.slide_marker', 'LEFTMOUSE', 'PRESS') -kmi = km.keymap_items.new('clip.disable_markers', 'D', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('clip.delete_track', 'DEL', 'PRESS') -kmi = km.keymap_items.new('clip.delete_track', 'X', 'PRESS') -kmi = km.keymap_items.new('clip.lock_tracks', 'L', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'LOCK') -kmi = km.keymap_items.new('clip.lock_tracks', 'L', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'action', 'UNLOCK') -kmi = km.keymap_items.new('clip.hide_tracks', 'H', 'PRESS') -kmi_props_setattr(kmi.properties, 'unselected', False) -kmi = km.keymap_items.new('clip.hide_tracks', 'H', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'unselected', True) -kmi = km.keymap_items.new('clip.hide_tracks_clear', 'H', 'PRESS', alt=True) -kmi = km.keymap_items.new('clip.slide_plane_marker', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('clip.keyframe_insert', 'I', 'PRESS') -kmi = km.keymap_items.new('clip.keyframe_delete', 'I', 'PRESS', alt=True) -kmi = km.keymap_items.new('clip.join_tracks', 'J', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS') -kmi_props_setattr(kmi.properties, 'name', 'CLIP_MT_tracking_specials') -kmi = km.keymap_items.new('wm.context_toggle', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.lock_selection') -kmi = km.keymap_items.new('wm.context_toggle', 'D', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_disabled') -kmi = km.keymap_items.new('wm.context_toggle', 'S', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.show_marker_search') -kmi = km.keymap_items.new('wm.context_toggle', 'M', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.use_mute_footage') -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') -kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'action', 'REMAINED') -kmi_props_setattr(kmi.properties, 'clear_active', False) -kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'action', 'UPTO') -kmi_props_setattr(kmi.properties, 'clear_active', False) -kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'action', 'ALL') -kmi_props_setattr(kmi.properties, 'clear_active', False) -kmi = km.keymap_items.new('clip.cursor_set', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'BOUNDING_BOX_CENTER') -kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'MEDIAN_POINT') -kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'CURSOR') -kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.pivot_point') -kmi_props_setattr(kmi.properties, 'value', 'INDIVIDUAL_ORIGINS') -kmi = km.keymap_items.new('clip.copy_tracks', 'C', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('clip.paste_tracks', 'V', 'PRESS', ctrl=True) - -# Map Clip Graph Editor -km = kc.keymaps.new('Clip Graph Editor', space_type='CLIP_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('clip.change_frame', 'ACTIONMOUSE', 'PRESS') -kmi = km.keymap_items.new('clip.graph_select', 'SELECTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', False) -kmi = km.keymap_items.new('clip.graph_select', 'SELECTMOUSE', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('clip.graph_select_all_markers', 'A', 'PRESS') -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('clip.graph_select_all_markers', 'I', 'PRESS', ctrl=True) -kmi_props_setattr(kmi.properties, 'action', 'INVERT') -kmi = km.keymap_items.new('clip.graph_select_border', 'B', 'PRESS') -kmi = km.keymap_items.new('clip.graph_delete_curve', 'DEL', 'PRESS') -kmi = km.keymap_items.new('clip.graph_delete_curve', 'X', 'PRESS') -kmi = km.keymap_items.new('clip.graph_delete_knot', 'DEL', 'PRESS', shift=True) -kmi = km.keymap_items.new('clip.graph_delete_knot', 'X', 'PRESS', shift=True) -kmi = km.keymap_items.new('clip.graph_view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('clip.graph_view_all', 'NDOF_BUTTON_FIT', 'PRESS') -kmi = km.keymap_items.new('clip.graph_center_current_frame', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.keymap_items.new('wm.context_toggle', 'L', 'PRESS') -kmi_props_setattr(kmi.properties, 'data_path', 'space_data.lock_time_cursor') -kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', alt=True) -kmi_props_setattr(kmi.properties, 'action', 'REMAINED') -kmi_props_setattr(kmi.properties, 'clear_active', True) -kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'action', 'UPTO') -kmi_props_setattr(kmi.properties, 'clear_active', True) -kmi = km.keymap_items.new('clip.clear_track_path', 'T', 'PRESS', shift=True, alt=True) -kmi_props_setattr(kmi.properties, 'action', 'ALL') -kmi_props_setattr(kmi.properties, 'clear_active', True) -kmi = km.keymap_items.new('clip.graph_disable_markers', 'D', 'PRESS', shift=True) -kmi_props_setattr(kmi.properties, 'action', 'TOGGLE') -kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS') -kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS') -kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS') - -# Map Clip Dopesheet Editor -km = kc.keymaps.new('Clip Dopesheet Editor', space_type='CLIP_EDITOR', region_type='WINDOW', modal=False) - -kmi = km.keymap_items.new('clip.dopesheet_select_channel', 'LEFTMOUSE', 'PRESS') -kmi_props_setattr(kmi.properties, 'extend', True) -kmi = km.keymap_items.new('clip.dopesheet_view_all', 'HOME', 'PRESS') -kmi = km.keymap_items.new('clip.dopesheet_view_all', 'NDOF_BUTTON_FIT', 'PRESS') +keyconfig_data = [ + ( + "Window", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("wm.window_new", {"type": 'W', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("wm.read_homefile", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("wm.save_homefile", {"type": 'U', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'O', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("name", 'INFO_MT_file_open_recent'), + ], + } + ), + ("wm.open_mainfile", {"type": 'O', "value": 'PRESS', "ctrl": True}, None), + ("wm.open_mainfile", {"type": 'F1', "value": 'PRESS'}, None), + ("wm.link", {"type": 'O', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("wm.append", {"type": 'F1', "value": 'PRESS', "shift": True}, None), + ("wm.save_mainfile", {"type": 'S', "value": 'PRESS', "ctrl": True}, None), + ("wm.save_mainfile", {"type": 'W', "value": 'PRESS', "ctrl": True}, None), + ("wm.save_as_mainfile", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("wm.save_as_mainfile", {"type": 'F2', "value": 'PRESS'}, None), + ( + "wm.save_as_mainfile", + {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("copy", True), + ], + } + ), + ("wm.window_fullscreen_toggle", {"type": 'F11', "value": 'PRESS', "alt": True}, None), + ("wm.quit_blender", {"type": 'Q', "value": 'PRESS', "ctrl": True}, None), + ("wm.doc_view_manual_ui_context", {"type": 'F1', "value": 'PRESS', "alt": True}, None), + ("wm.redraw_timer", {"type": 'T', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("wm.debug_menu", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ( + "wm.call_menu", + {"type": 'NDOF_BUTTON_MENU', "value": 'PRESS'}, + { + "properties": [ + ("name", 'USERPREF_MT_ndof_settings'), + ], + } + ), + ("wm.search_menu", {"type": 'SPACE', "value": 'PRESS'}, None), + ( + "wm.context_set_enum", + {"type": 'F3', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'NODE_EDITOR'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F4', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'CONSOLE'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F5', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'VIEW_3D'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F6', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'GRAPH_EDITOR'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F7', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'PROPERTIES'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F8', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'SEQUENCE_EDITOR'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F9', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'OUTLINER'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F10', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'IMAGE_EDITOR'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F11', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'TEXT_EDITOR'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'F12', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'area.type'), + ("value", 'DOPESHEET_EDITOR'), + ], + } + ), + ( + "wm.context_scale_float", + {"type": 'NDOF_BUTTON_PLUS', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'user_preferences.inputs.ndof_sensitivity'), + ("value", 1.1), + ], + } + ), + ( + "wm.context_scale_float", + {"type": 'NDOF_BUTTON_MINUS', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'user_preferences.inputs.ndof_sensitivity'), + ("value", 1.0), + ], + } + ), + ( + "wm.context_scale_float", + {"type": 'NDOF_BUTTON_PLUS', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'user_preferences.inputs.ndof_sensitivity'), + ("value", 1.5), + ], + } + ), + ( + "wm.context_scale_float", + {"type": 'NDOF_BUTTON_MINUS', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'user_preferences.inputs.ndof_sensitivity'), + ("value", 0.6666667), + ], + } + ), + ("info.reports_display_update", {"type": 'TIMER_REPORT', "value": 'ANY', "any": True}, None), + ], + }, + ), + ( + "Screen", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("screen.animation_step", {"type": 'TIMER0', "value": 'ANY', "any": True}, None), + ("screen.region_blend", {"type": 'TIMERREGION', "value": 'ANY', "any": True}, None), + ( + "screen.screen_set", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "screen.screen_set", + {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ("screen.screen_full_area", {"type": 'SPACE', "value": 'PRESS', "shift": True}, None), + ( + "screen.screen_full_area", + {"type": 'SPACE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("use_hide_panels", True), + ], + } + ), + ("screen.screenshot", {"type": 'F3', "value": 'PRESS', "ctrl": True}, None), + ("screen.screencast", {"type": 'F3', "value": 'PRESS', "alt": True}, None), + ( + "screen.space_context_cycle", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("direction", 'NEXT'), + ], + } + ), + ( + "screen.space_context_cycle", + {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("direction", 'PREV'), + ], + } + ), + ("screen.region_quadview", {"type": 'Q', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("screen.repeat_history", {"type": 'F3', "value": 'PRESS'}, None), + ("screen.repeat_last", {"type": 'R', "value": 'PRESS', "shift": True}, None), + ("screen.region_flip", {"type": 'F5', "value": 'PRESS'}, None), + ("screen.redo_last", {"type": 'F6', "value": 'PRESS'}, None), + ("script.reload", {"type": 'F8', "value": 'PRESS'}, None), + ("file.execute", {"type": 'RET', "value": 'PRESS'}, None), + ("file.execute", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), + ("file.cancel", {"type": 'ESC', "value": 'PRESS'}, None), + ("ed.undo", {"type": 'Z', "value": 'PRESS', "ctrl": True}, None), + ("ed.redo", {"type": 'Z', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("ed.undo_history", {"type": 'Z', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ( + "render.render", + {"type": 'F12', "value": 'PRESS'}, + { + "properties": [ + ("use_viewport", True), + ], + } + ), + ( + "render.render", + {"type": 'F12', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("animation", True), + ("use_viewport", True), + ], + } + ), + ("render.view_cancel", {"type": 'ESC', "value": 'PRESS'}, None), + ("render.view_show", {"type": 'F11', "value": 'PRESS'}, None), + ("render.play_rendered_anim", {"type": 'F11', "value": 'PRESS', "ctrl": True}, None), + ("screen.userpref_show", {"type": 'U', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ], + }, + ), + ( + "User Interface", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("ui.eyedropper_color", {"type": 'E', "value": 'PRESS'}, None), + ("ui.eyedropper_colorband", {"type": 'E', "value": 'PRESS'}, None), + ("ui.eyedropper_colorband_point", {"type": 'E', "value": 'PRESS', "alt": True}, None), + ("ui.eyedropper_id", {"type": 'E', "value": 'PRESS'}, None), + ("ui.eyedropper_depth", {"type": 'E', "value": 'PRESS'}, None), + ("ui.copy_data_path_button", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "ui.copy_data_path_button", + {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("full_path", True), + ], + } + ), + ("anim.keyframe_insert_button", {"type": 'I', "value": 'PRESS'}, None), + ("anim.keyframe_delete_button", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("anim.keyframe_clear_button", {"type": 'I', "value": 'PRESS', "shift": True, "alt": True}, None), + ("anim.driver_button_add", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), + ("anim.driver_button_remove", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("anim.keyingset_button_add", {"type": 'K', "value": 'PRESS'}, None), + ("anim.keyingset_button_remove", {"type": 'K', "value": 'PRESS', "alt": True}, None), + ], + }, + ), + ( + "View2D", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("view2d.scroller_activate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("view2d.scroller_activate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), + ("view2d.pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("view2d.scroll_right", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view2d.scroll_left", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None), + ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None), + ("view2d.ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), + ("view2d.zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), + ("view2d.zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), + ("view2d.zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("view2d.zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("view2d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("view2d.smoothview", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), + ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_right", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_left", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), + ("view2d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view2d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("view2d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), + ], + }, + ), + ( + "Header", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("screen.header_toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ], + }, + ), + ( + "View2D Buttons List", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("view2d.scroller_activate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("view2d.scroller_activate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view2d.pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), + ( + "view2d.scroll_down", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + { + "properties": [ + ("page", True), + ], + } + ), + ( + "view2d.scroll_up", + {"type": 'PAGE_UP', "value": 'PRESS'}, + { + "properties": [ + ("page", True), + ], + } + ), + ("view2d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view2d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("view2d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("view2d.zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("view2d.zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("view2d.reset", {"type": 'HOME', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Frames", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "screen.frame_offset", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("delta", 10), + ], + } + ), + ( + "screen.frame_offset", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("delta", -10), + ], + } + ), + ( + "screen.frame_offset", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ( + "screen.frame_offset", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "screen.frame_offset", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "screen.frame_offset", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ( + "screen.frame_jump", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("end", True), + ], + } + ), + ( + "screen.frame_jump", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("end", False), + ], + } + ), + ( + "screen.frame_jump", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("end", True), + ], + } + ), + ( + "screen.frame_jump", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("end", False), + ], + } + ), + ( + "screen.keyframe_jump", + {"type": 'UP_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("next", True), + ], + } + ), + ( + "screen.keyframe_jump", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("next", False), + ], + } + ), + ( + "screen.keyframe_jump", + {"type": 'MEDIA_LAST', "value": 'PRESS'}, + { + "properties": [ + ("next", True), + ], + } + ), + ( + "screen.keyframe_jump", + {"type": 'MEDIA_FIRST', "value": 'PRESS'}, + { + "properties": [ + ("next", False), + ], + } + ), + ("screen.animation_play", {"type": 'A', "value": 'PRESS', "alt": True}, None), + ( + "screen.animation_play", + {"type": 'A', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("reverse", True), + ], + } + ), + ("screen.animation_cancel", {"type": 'ESC', "value": 'PRESS'}, None), + ("screen.animation_play", {"type": 'MEDIA_PLAY', "value": 'PRESS'}, None), + ("screen.animation_cancel", {"type": 'MEDIA_STOP', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Property Editor", + {"space_type": 'PROPERTIES', "region_type": 'WINDOW'}, + { + "items": [ + ("buttons.toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Info", + {"space_type": 'INFO', "region_type": 'WINDOW'}, + { + "items": [ + ("info.select_pick", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), + ("info.select_all_toggle", {"type": 'A', "value": 'PRESS'}, None), + ("info.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("info.report_replay", {"type": 'R', "value": 'PRESS'}, None), + ("info.report_delete", {"type": 'X', "value": 'PRESS'}, None), + ("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "Outliner", + {"space_type": 'OUTLINER', "region_type": 'WINDOW'}, + { + "items": [ + ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), + ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ( + "outliner.item_activate", + {"type": 'LEFTMOUSE', "value": 'CLICK'}, + { + "properties": [ + ("extend", False), + ("recursive", False), + ], + } + ), + ( + "outliner.item_activate", + {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, + { + "properties": [ + ("extend", True), + ("recursive", False), + ], + } + ), + ( + "outliner.item_activate", + {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True}, + { + "properties": [ + ("extend", False), + ("recursive", True), + ], + } + ), + ( + "outliner.item_activate", + {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ("recursive", True), + ], + } + ), + ("outliner.select_border", {"type": 'B', "value": 'PRESS'}, None), + ( + "outliner.item_openclose", + {"type": 'RET', "value": 'PRESS'}, + { + "properties": [ + ("all", False), + ], + } + ), + ( + "outliner.item_openclose", + {"type": 'RET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("all", True), + ], + } + ), + ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("outliner.operation", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), + ("outliner.show_hierarchy", {"type": 'HOME', "value": 'PRESS'}, None), + ("outliner.show_active", {"type": 'PERIOD', "value": 'PRESS'}, None), + ("outliner.show_active", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ( + "outliner.scroll_page", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + { + "properties": [ + ("up", False), + ], + } + ), + ( + "outliner.scroll_page", + {"type": 'PAGE_UP', "value": 'PRESS'}, + { + "properties": [ + ("up", True), + ], + } + ), + ("outliner.show_one_level", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ( + "outliner.show_one_level", + {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, + { + "properties": [ + ("open", False), + ], + } + ), + ( + "outliner.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ("outliner.expanded_toggle", {"type": 'A', "value": 'PRESS', "shift": True}, None), + ("outliner.keyingset_add_selected", {"type": 'K', "value": 'PRESS'}, None), + ("outliner.keyingset_remove_selected", {"type": 'K', "value": 'PRESS', "alt": True}, None), + ("anim.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), + ("anim.keyframe_delete", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("outliner.drivers_add_selected", {"type": 'D', "value": 'PRESS'}, None), + ("outliner.drivers_delete_selected", {"type": 'D', "value": 'PRESS', "alt": True}, None), + ("outliner.collection_new", {"type": 'C', "value": 'PRESS'}, None), + ("outliner.collection_delete", {"type": 'X', "value": 'PRESS'}, None), + ], + }, + ), + ( + "3D View Generic", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("view3d.properties", {"type": 'N', "value": 'PRESS'}, None), + ("view3d.toolshelf", {"type": 'T', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Grease Pencil", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "gpencil.draw", + {"type": 'LEFTMOUSE', "value": 'PRESS', "key_modifier": 'D'}, + { + "properties": [ + ("mode", 'DRAW'), + ("wait_for_input", False), + ], + } + ), + ( + "gpencil.draw", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'D'}, + { + "properties": [ + ("mode", 'DRAW_STRAIGHT'), + ("wait_for_input", False), + ], + } + ), + ( + "gpencil.draw", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'D'}, + { + "properties": [ + ("mode", 'DRAW_POLY'), + ("wait_for_input", False), + ], + } + ), + ( + "gpencil.draw", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "key_modifier": 'D'}, + { + "properties": [ + ("mode", 'ERASER'), + ("wait_for_input", False), + ], + } + ), + ( + "gpencil.draw", + {"type": 'ERASER', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'ERASER'), + ("wait_for_input", False), + ], + } + ), + ("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS', "key_modifier": 'D'}, None), + ( + "wm.call_menu_pie", + {"type": 'Q', "value": 'PRESS', "key_modifier": 'D'}, + { + "properties": [ + ("name", 'GPENCIL_MT_pie_tool_palette'), + ], + } + ), + ( + "wm.call_menu_pie", + {"type": 'W', "value": 'PRESS', "key_modifier": 'D'}, + { + "properties": [ + ("name", 'GPENCIL_MT_pie_settings_palette'), + ], + } + ), + ("gpencil.blank_frame_add", {"type": 'B', "value": 'PRESS', "key_modifier": 'D'}, None), + ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "key_modifier": 'D'}, None), + ], + }, + ), + ( + "Grease Pencil Stroke Edit Mode", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ( + "wm.call_menu_pie", + {"type": 'E', "value": 'PRESS', "key_modifier": 'D'}, + { + "properties": [ + ("name", 'GPENCIL_MT_pie_sculpt'), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path_primary", 'user_preferences.edit.grease_pencil_eraser_radius'), + ], + } + ), + ("gpencil.interpolate", {"type": 'E', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("gpencil.interpolate_sequence", {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "gpencil.brush_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS', "key_modifier": 'E'}, + { + "properties": [ + ("wait_for_input", False), + ], + } + ), + ( + "gpencil.brush_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'E'}, + { + "properties": [ + ("wait_for_input", False), + ], + } + ), + ( + "gpencil.brush_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "key_modifier": 'E'}, + { + "properties": [ + ("wait_for_input", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.gpencil_sculpt.brush.strength'), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("data_path_primary", 'tool_settings.gpencil_sculpt.brush.size'), + ], + } + ), + ( + "gpencil.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "gpencil.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("gpencil.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("gpencil.select_border", {"type": 'B', "value": 'PRESS'}, None), + ( + "gpencil.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "gpencil.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ( + "gpencil.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "gpencil.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("gpencil.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), + ( + "gpencil.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ("toggle", True), + ], + } + ), + ( + "gpencil.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("entire_strokes", True), + ], + } + ), + ("gpencil.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("gpencil.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("gpencil.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ( + "wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_gpencil_delete'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_gpencil_delete'), + ], + } + ), + ("gpencil.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.dissolve", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "shift": True}, None), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'GPENCIL_MT_gpencil_edit_specials'), + ], + } + ), + ("gpencil.stroke_join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ( + "gpencil.stroke_join", + {"type": 'J', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'JOINCOPY'), + ], + } + ), + ("gpencil.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'S', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'GPENCIL_MT_snap'), + ], + } + ), + ("gpencil.convert", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ("gpencil.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ( + "gpencil.hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "gpencil.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("gpencil.selection_opacity_toggle", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.layer_isolate", {"type": 'NUMPAD_ASTERIX', "value": 'PRESS'}, None), + ("gpencil.move_to_layer", {"type": 'M', "value": 'PRESS'}, None), + ( + "gpencil.brush_select", + {"type": 'ONE', "value": 'PRESS'}, + { + "properties": [ + ("index", 0), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'TWO', "value": 'PRESS'}, + { + "properties": [ + ("index", 1), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'THREE', "value": 'PRESS'}, + { + "properties": [ + ("index", 2), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'FOUR', "value": 'PRESS'}, + { + "properties": [ + ("index", 3), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'FIVE', "value": 'PRESS'}, + { + "properties": [ + ("index", 4), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'SIX', "value": 'PRESS'}, + { + "properties": [ + ("index", 5), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'SEVEN', "value": 'PRESS'}, + { + "properties": [ + ("index", 6), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'EIGHT', "value": 'PRESS'}, + { + "properties": [ + ("index", 7), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'NINE', "value": 'PRESS'}, + { + "properties": [ + ("index", 8), + ], + } + ), + ( + "gpencil.brush_select", + {"type": 'ZERO', "value": 'PRESS'}, + { + "properties": [ + ("index", 9), + ], + } + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ("transform.bend", {"type": 'W', "value": 'PRESS', "shift": True}, None), + ("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None), + ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ( + "transform.transform", + {"type": 'S', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'GPENCIL_SHRINKFATTEN'), + ], + } + ), + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'CONNECTED'), + ], + } + ), + ], + }, + ), + ( + "Face Mask", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "paint.face_select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "paint.face_select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ( + "paint.face_select_hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "paint.face_select_hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("paint.face_select_reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("paint.face_select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ( + "paint.face_select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "paint.face_select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ], + }, + ), + ( + "Weight Paint Vertex Selection", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "paint.vert_select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "paint.vert_select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("view3d.select_border", {"type": 'B', "value": 'PRESS'}, None), + ( + "view3d.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "view3d.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Pose", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'INFO_MT_add'), + ], + } + ), + ( + "pose.hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "pose.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("pose.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_pose_apply'), + ], + } + ), + ("pose.rot_clear", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("pose.loc_clear", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ("pose.scale_clear", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("pose.quaternions_flip", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("pose.rotation_mode_set", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("pose.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ( + "pose.paste", + {"type": 'V', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("flipped", False), + ], + } + ), + ( + "pose.paste", + {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("flipped", True), + ], + } + ), + ( + "pose.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "pose.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("pose.select_parent", {"type": 'P', "value": 'PRESS', "shift": True}, None), + ( + "pose.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'PARENT'), + ("extend", False), + ], + } + ), + ( + "pose.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'PARENT'), + ("extend", True), + ], + } + ), + ( + "pose.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'CHILD'), + ("extend", False), + ], + } + ), + ( + "pose.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'CHILD'), + ("extend", True), + ], + } + ), + ("pose.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("pose.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("pose.select_mirror", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("pose.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("pose.constraints_clear", {"type": 'C', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("pose.ik_add", {"type": 'I', "value": 'PRESS', "shift": True}, None), + ("pose.ik_clear", {"type": 'I', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ( + "wm.call_menu", + {"type": 'G', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_pose_group'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_bone_options_toggle'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_bone_options_enable'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_bone_options_disable'), + ], + } + ), + ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None), + ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None), + ("pose.bone_layers", {"type": 'M', "value": 'PRESS'}, None), + ("pose.toggle_bone_selection_overlay", {"type": 'Z', "value": 'PRESS'}, None), + ( + "transform.transform", + {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("mode", 'BONE_SIZE'), + ], + } + ), + ("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None), + ("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("anim.keying_set_active_set", {"type": 'I', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("poselib.browse_interactive", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("poselib.pose_add", {"type": 'L', "value": 'PRESS', "shift": True}, None), + ("poselib.pose_remove", {"type": 'L', "value": 'PRESS', "alt": True}, None), + ("poselib.pose_rename", {"type": 'L', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("pose.push", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), + ("pose.relax", {"type": 'E', "value": 'PRESS', "alt": True}, None), + ("pose.breakdown", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_pose_specials'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'P', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_pose_propagate'), + ], + } + ), + ], + }, + ), + ( + "Object Mode", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.use_proportional_edit_objects'), + ], + } + ), + ( + "object.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "object.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("object.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("object.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("object.select_linked", {"type": 'L', "value": 'PRESS', "shift": True}, None), + ("object.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("object.select_mirror", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "object.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'PARENT'), + ("extend", False), + ], + } + ), + ( + "object.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'PARENT'), + ("extend", True), + ], + } + ), + ( + "object.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'CHILD'), + ("extend", False), + ], + } + ), + ( + "object.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'CHILD'), + ("extend", True), + ], + } + ), + ("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("object.parent_no_inverse_set", {"type": 'P', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("object.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("object.track_set", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), + ("object.track_clear", {"type": 'T', "value": 'PRESS', "alt": True}, None), + ("object.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("object.constraints_clear", {"type": 'C', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ( + "object.location_clear", + {"type": 'G', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("clear_delta", False), + ], + } + ), + ( + "object.rotation_clear", + {"type": 'R', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("clear_delta", False), + ], + } + ), + ( + "object.scale_clear", + {"type": 'S', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("clear_delta", False), + ], + } + ), + ("object.origin_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ( + "object.delete", + {"type": 'X', "value": 'PRESS'}, + { + "properties": [ + ("use_global", False), + ], + } + ), + ( + "object.delete", + {"type": 'X', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("use_global", True), + ], + } + ), + ( + "object.delete", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("use_global", False), + ], + } + ), + ( + "object.delete", + {"type": 'DEL', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("use_global", True), + ], + } + ), + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'INFO_MT_add'), + ], + } + ), + ("object.duplicates_make_real", {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_object_apply'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'U', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_make_single_user'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'L', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_make_links'), + ], + } + ), + ("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True}, None), + ("object.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ("object.convert", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ("object.proxy_make", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("object.make_local", {"type": 'L', "value": 'PRESS'}, None), + ("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None), + ("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("anim.keying_set_active_set", {"type": 'I', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("collection.create", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("collection.objects_remove", {"type": 'G', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("collection.objects_remove_all", {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("collection.objects_add_active", {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("collection.objects_remove_active", {"type": 'G', "value": 'PRESS', "shift": True, "alt": True}, None), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_object_specials'), + ], + } + ), + ("object.data_transfer", {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "object.subdivision_set", + {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 0), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'ONE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 1), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'TWO', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 2), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'THREE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 3), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 4), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 5), + ], + } + ), + ("object.move_to_collection", {"type": 'M', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Paint Curve", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("paintcurve.add_point_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("paintcurve.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), + ( + "paintcurve.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ("paintcurve.slide", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ( + "paintcurve.slide", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("align", True), + ], + } + ), + ( + "paintcurve.select", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("toggle", True), + ], + } + ), + ("paintcurve.cursor", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("paintcurve.delete_point", {"type": 'X', "value": 'PRESS'}, None), + ("paintcurve.delete_point", {"type": 'DEL', "value": 'PRESS'}, None), + ("paintcurve.draw", {"type": 'RET', "value": 'PRESS'}, None), + ("paintcurve.draw", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Curve", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'INFO_MT_edit_curve_add'), + ], + } + ), + ("curve.handle_type_set", {"type": 'V', "value": 'PRESS'}, None), + ("curve.vertex_add", {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, None), + ( + "curve.draw", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("wait_for_input", False), + ], + } + ), + ( + "curve.draw", + {"type": 'PEN', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("wait_for_input", False), + ], + } + ), + ( + "curve.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "curve.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("curve.select_row", {"type": 'R', "value": 'PRESS', "shift": True}, None), + ("curve.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("curve.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("curve.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("curve.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ( + "curve.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "curve.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("curve.shortest_path_pick", {"type": 'SELECTMOUSE', "value": 'CLICK', "ctrl": True}, None), + ("curve.separate", {"type": 'P', "value": 'PRESS'}, None), + ("curve.split", {"type": 'Y', "value": 'PRESS'}, None), + ("curve.extrude_move", {"type": 'E', "value": 'PRESS'}, None), + ("curve.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("curve.make_segment", {"type": 'F', "value": 'PRESS'}, None), + ("curve.cyclic_toggle", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ( + "wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_curve_delete'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_curve_delete'), + ], + } + ), + ("curve.dissolve_verts", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("curve.dissolve_verts", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), + ("curve.tilt_clear", {"type": 'T', "value": 'PRESS', "alt": True}, None), + ("transform.tilt", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), + ( + "transform.transform", + {"type": 'S', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'CURVE_SHRINKFATTEN'), + ], + } + ), + ("curve.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ( + "curve.hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "curve.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("curve.normals_make_consistent", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_curve_specials'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'H', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_hook'), + ], + } + ), + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'CONNECTED'), + ], + } + ), + ], + }, + ), + ( + "Image Paint", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "paint.image_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'NORMAL'), + ], + } + ), + ( + "paint.image_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'INVERT'), + ], + } + ), + ("paint.brush_colors_flip", {"type": 'X', "value": 'PRESS'}, None), + ("paint.grab_clone", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ("paint.sample_color", {"type": 'S', "value": 'PRESS'}, None), + ( + "brush.active_index_set", + {"type": 'ONE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 0), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'TWO', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 1), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'THREE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 2), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 3), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 4), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SIX', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 5), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 6), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 7), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'NINE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 8), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 9), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ONE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 10), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'TWO', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 11), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'THREE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 12), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 13), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 14), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SIX', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 15), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 16), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 17), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'NINE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 18), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'image_paint'), + ("index", 19), + ], + } + ), + ( + "brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 0.9), + ], + } + ), + ( + "brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 1.1111112), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("data_path_primary", 'tool_settings.image_paint.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), + ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.image_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", 'space_data.zoom'), + ("image_id", 'tool_settings.image_paint.brush'), + ("secondary_tex", True), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.image_paint.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), + ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.image_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.image_paint.brush'), + ("secondary_tex", True), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.image_paint.brush.texture_slot.angle'), + ("data_path_secondary", ''), + ("use_secondary", ''), + ("rotation_path", 'tool_settings.image_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.image_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.image_paint.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), + ("data_path_secondary", ''), + ("use_secondary", ''), + ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), + ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.image_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.image_paint.brush'), + ("secondary_tex", True), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TRANSLATION'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'SCALE'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'ROTATION'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'TRANSLATION'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("mode", 'SCALE'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("mode", 'ROTATION'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'M', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'image_paint_object.data.use_paint_mask'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'S', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.image_paint.brush.use_smooth_stroke'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'R', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_angle_control'), + ], + } + ), + ( + "wm.context_menu_enum", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.image_paint.brush.stroke_method'), + ], + } + ), + ], + }, + ), + ( + "Vertex Paint", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("paint.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("paint.brush_colors_flip", {"type": 'X', "value": 'PRESS'}, None), + ("paint.sample_color", {"type": 'S', "value": 'PRESS'}, None), + ("paint.vertex_color_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), + ( + "brush.active_index_set", + {"type": 'ONE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 0), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'TWO', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 1), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'THREE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 2), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 3), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 4), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SIX', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 5), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 6), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 7), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'NINE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 8), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 9), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ONE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 10), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'TWO', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 11), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'THREE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 12), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 13), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 14), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SIX', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 15), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 16), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 17), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'NINE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 18), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'vertex_paint'), + ("index", 19), + ], + } + ), + ( + "brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 0.9), + ], + } + ), + ( + "brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 1.1111112), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("data_path_primary", 'tool_settings.vertex_paint.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.vertex_paint.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.vertex_paint.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.vertex_paint.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.vertex_paint.brush.texture_slot.angle'), + ("data_path_secondary", ''), + ("use_secondary", ''), + ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.vertex_paint.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TRANSLATION'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'SCALE'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'ROTATION'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'TRANSLATION'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("mode", 'SCALE'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("mode", 'ROTATION'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'M', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'vertex_paint_object.data.use_paint_mask'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'S', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.vertex_paint.brush.use_smooth_stroke'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'R', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_angle_control'), + ], + } + ), + ( + "wm.context_menu_enum", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.vertex_paint.brush.stroke_method'), + ], + } + ), + ], + }, + ), + ( + "Weight Paint", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("paint.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("paint.weight_sample", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("paint.weight_sample_group", {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, None), + ( + "paint.weight_gradient", + {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("type", 'LINEAR'), + ], + } + ), + ( + "paint.weight_gradient", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("type", 'RADIAL'), + ], + } + ), + ("paint.weight_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), + ( + "brush.active_index_set", + {"type": 'ONE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 0), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'TWO', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 1), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'THREE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 2), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 3), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 4), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SIX', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 5), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 6), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 7), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'NINE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 8), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 9), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ONE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 10), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'TWO', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 11), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'THREE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 12), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 13), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 14), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SIX', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 15), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 16), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 17), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'NINE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 18), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'weight_paint'), + ("index", 19), + ], + } + ), + ( + "brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 0.9), + ], + } + ), + ( + "brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 1.1111112), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("data_path_primary", 'tool_settings.weight_paint.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.weight_paint.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.weight_paint.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.weight_paint.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("data_path_primary", 'tool_settings.weight_paint.brush.weight'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.weight'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_weight'), + ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.weight_paint.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.context_menu_enum", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.vertex_paint.brush.stroke_method'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'M', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'weight_paint_object.data.use_paint_mask'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'V', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'weight_paint_object.data.use_paint_mask_vertex'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'S', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.weight_paint.brush.use_smooth_stroke'), + ], + } + ), + ], + }, + ), + ( + "Sculpt", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "sculpt.brush_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'NORMAL'), + ], + } + ), + ( + "sculpt.brush_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'INVERT'), + ], + } + ), + ( + "sculpt.brush_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'SMOOTH'), + ], + } + ), + ( + "paint.hide_show", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("action", 'SHOW'), + ("area", 'INSIDE'), + ], + } + ), + ( + "paint.hide_show", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("action", 'HIDE'), + ("area", 'INSIDE'), + ], + } + ), + ( + "paint.hide_show", + {"type": 'H', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("action", 'SHOW'), + ("area", 'ALL'), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 0), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'ONE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 1), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'TWO', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 2), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'THREE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 3), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 4), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 5), + ], + } + ), + ( + "paint.mask_flood_fill", + {"type": 'M', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'VALUE'), + ("value", 0.0), + ], + } + ), + ( + "paint.mask_flood_fill", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'INVERT'), + ], + } + ), + ("paint.mask_lasso_gesture", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "wm.context_toggle", + {"type": 'M', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'scene.tool_settings.sculpt.show_mask'), + ], + } + ), + ("sculpt.dynamic_topology_toggle", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), + ("sculpt.set_detail_size", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ( + "object.subdivision_set", + {"type": 'PAGE_UP', "value": 'PRESS'}, + { + "properties": [ + ("level", 1), + ("relative", True), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + { + "properties": [ + ("level", -1), + ("relative", True), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ONE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 0), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'TWO', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 1), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'THREE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 2), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 3), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 4), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SIX', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 5), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 6), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 7), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'NINE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 8), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 9), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ONE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 10), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'TWO', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 11), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'THREE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 12), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 13), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 14), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SIX', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 15), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 16), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 17), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'NINE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 18), + ], + } + ), + ( + "brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'sculpt'), + ("index", 19), + ], + } + ), + ( + "brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 0.9), + ], + } + ), + ( + "brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 1.1111112), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("data_path_primary", 'tool_settings.sculpt.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.sculpt.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.sculpt.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.sculpt.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.sculpt.brush.texture_slot.angle'), + ("data_path_secondary", ''), + ("use_secondary", ''), + ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.sculpt.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TRANSLATION'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'SCALE'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'ROTATION'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'TRANSLATION'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("mode", 'SCALE'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("mode", 'ROTATION'), + ("texmode", 'SECONDARY'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'X', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'DRAW'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'S', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'SMOOTH'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'P', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'PINCH'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'I', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'INFLATE'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'G', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'GRAB'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'LAYER'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'T', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'FLATTEN'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'C', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'CLAY'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'C', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'CREASE'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'K', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'SNAKE_HOOK'), + ], + } + ), + ( + "paint.brush_select", + {"type": 'M', "value": 'PRESS'}, + { + "properties": [ + ("paint_mode", 'SCULPT'), + ("sculpt_tool", 'MASK'), + ("toggle", True), + ("create_missing", True), + ], + } + ), + ( + "wm.context_menu_enum", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.sculpt.brush.stroke_method'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'S', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.sculpt.brush.use_smooth_stroke'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'R', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_angle_control'), + ], + } + ), + ], + }, + ), + ( + "Mesh", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("mesh.loopcut_slide", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("mesh.offset_edge_loops_slide", {"type": 'R', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("mesh.inset", {"type": 'I', "value": 'PRESS'}, None), + ("mesh.poke", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ( + "mesh.bevel", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("vertex_only", False), + ], + } + ), + ( + "mesh.bevel", + {"type": 'B', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("vertex_only", True), + ], + } + ), + ( + "mesh.loop_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", False), + ], + } + ), + ( + "mesh.loop_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", True), + ], + } + ), + ( + "mesh.edgering_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", False), + ], + } + ), + ( + "mesh.edgering_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", True), + ], + } + ), + ( + "mesh.shortest_path_pick", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("use_fill", False), + ], + } + ), + ( + "mesh.shortest_path_pick", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("use_fill", True), + ], + } + ), + ( + "mesh.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "mesh.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("mesh.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("mesh.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("mesh.select_next_item", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("mesh.select_prev_item", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("mesh.select_non_manifold", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("mesh.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ( + "mesh.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "mesh.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("mesh.faces_select_linked_flat", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ( + "wm.call_menu", + {"type": 'G', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_select_similar'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_select_mode'), + ], + } + ), + ( + "mesh.hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "mesh.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("mesh.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ( + "mesh.normals_make_consistent", + {"type": 'N', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("inside", False), + ], + } + ), + ( + "mesh.normals_make_consistent", + {"type": 'N', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("inside", True), + ], + } + ), + ("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'}, None), + ( + "wm.call_menu", + {"type": 'E', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_extrude'), + ], + } + ), + ("transform.edge_crease", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("mesh.spin", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("mesh.fill", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("mesh.beautify_fill", {"type": 'F', "value": 'PRESS', "shift": True, "alt": True}, None), + ( + "mesh.quads_convert_to_tris", + {"type": 'T', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("quad_method", 'BEAUTY'), + ("ngon_method", 'BEAUTY'), + ], + } + ), + ( + "mesh.quads_convert_to_tris", + {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("quad_method", 'FIXED'), + ("ngon_method", 'CLIP'), + ], + } + ), + ("mesh.tris_convert_to_quads", {"type": 'J', "value": 'PRESS', "alt": True}, None), + ( + "mesh.rip_move", + {"type": 'V', "value": 'PRESS'}, + { + "properties": [ + ( + "MESH_OT_rip", + [ + ("use_fill", False), + ], + ), + ], + } + ), + ( + "mesh.rip_move", + {"type": 'V', "value": 'PRESS', "alt": True}, + { + "properties": [ + ( + "MESH_OT_rip", + [ + ("use_fill", True), + ], + ), + ], + } + ), + ("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True}, None), + ("mesh.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None), + ("transform.shrink_fatten", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("mesh.edge_face_add", {"type": 'F', "value": 'PRESS'}, None), + ("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'INFO_MT_mesh_add'), + ], + } + ), + ("mesh.separate", {"type": 'P', "value": 'PRESS'}, None), + ("mesh.split", {"type": 'Y', "value": 'PRESS'}, None), + ("mesh.vert_connect_path", {"type": 'J', "value": 'PRESS'}, None), + ("transform.vert_slide", {"type": 'V', "value": 'PRESS', "shift": True}, None), + ( + "mesh.dupli_extrude_cursor", + {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, + { + "properties": [ + ("rotate_source", True), + ], + } + ), + ( + "mesh.dupli_extrude_cursor", + {"type": 'ACTIONMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, + { + "properties": [ + ("rotate_source", False), + ], + } + ), + ( + "wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_delete'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_delete'), + ], + } + ), + ("mesh.dissolve_mode", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("mesh.dissolve_mode", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), + ( + "mesh.knife_tool", + {"type": 'K', "value": 'PRESS'}, + { + "properties": [ + ("use_occlude_geometry", True), + ("only_selected", False), + ], + } + ), + ( + "mesh.knife_tool", + {"type": 'K', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("use_occlude_geometry", False), + ("only_selected", True), + ], + } + ), + ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_specials'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_faces'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'E', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_edges'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'V', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_mesh_vertices'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'H', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_hook'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'U', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_uv_map'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'G', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_vertex_group'), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 0), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'ONE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 1), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'TWO', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 2), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'THREE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 3), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 4), + ], + } + ), + ( + "object.subdivision_set", + {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("level", 5), + ], + } + ), + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'CONNECTED'), + ], + } + ), + ], + }, + ), + ( + "Armature", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "armature.hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "armature.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("armature.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("armature.align", {"type": 'A', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("armature.calculate_roll", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("armature.roll_clear", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("armature.switch_direction", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("armature.bone_primitive_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), + ("armature.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("armature.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ( + "armature.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "armature.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ( + "armature.select_mirror", + {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "armature.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'PARENT'), + ("extend", False), + ], + } + ), + ( + "armature.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'PARENT'), + ("extend", True), + ], + } + ), + ( + "armature.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'CHILD'), + ("extend", False), + ], + } + ), + ( + "armature.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'CHILD'), + ("extend", True), + ], + } + ), + ("armature.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("armature.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("armature.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("armature.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("armature.shortest_path_pick", {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_armature_delete'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_edit_armature_delete'), + ], + } + ), + ("armature.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("armature.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("armature.extrude_move", {"type": 'E', "value": 'PRESS'}, None), + ("armature.extrude_forked", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("armature.click_extrude", {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, None), + ("armature.fill", {"type": 'F', "value": 'PRESS'}, None), + ("armature.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None), + ("armature.split", {"type": 'Y', "value": 'PRESS'}, None), + ("armature.separate", {"type": 'P', "value": 'PRESS'}, None), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_bone_options_toggle'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_bone_options_enable'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_bone_options_disable'), + ], + } + ), + ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None), + ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None), + ("armature.bone_layers", {"type": 'M', "value": 'PRESS'}, None), + ( + "transform.transform", + {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("mode", 'BONE_SIZE'), + ], + } + ), + ( + "transform.transform", + {"type": 'S', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'BONE_ENVELOPE'), + ], + } + ), + ( + "transform.transform", + {"type": 'R', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'BONE_ROLL'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_armature_specials'), + ], + } + ), + ], + }, + ), + ( + "Metaball", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("object.metaball_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), + ("mball.reveal_metaelems", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ( + "mball.hide_metaelems", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "mball.hide_metaelems", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("mball.delete_metaelems", {"type": 'X', "value": 'PRESS'}, None), + ("mball.delete_metaelems", {"type": 'DEL', "value": 'PRESS'}, None), + ("mball.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ( + "mball.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "mball.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("mball.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'CONNECTED'), + ], + } + ), + ], + }, + ), + ( + "Lattice", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "lattice.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "lattice.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("lattice.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("lattice.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("lattice.flip", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'H', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_hook'), + ], + } + ), + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + } + ), + ], + }, + ), + ( + "Particle", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "particle.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "particle.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("particle.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("particle.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ( + "particle.select_linked", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "particle.select_linked", + {"type": 'L', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("particle.delete", {"type": 'X', "value": 'PRESS'}, None), + ("particle.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("particle.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ( + "particle.hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "particle.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("particle.brush_edit", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("particle.brush_edit", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("data_path_primary", 'tool_settings.particle_edit.brush.size'), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.particle_edit.brush.strength'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'VIEW3D_MT_particle_specials'), + ], + } + ), + ("particle.weight_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + } + ), + ], + }, + ), + ( + "Font", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "font.style_toggle", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("style", 'BOLD'), + ], + } + ), + ( + "font.style_toggle", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("style", 'ITALIC'), + ], + } + ), + ( + "font.style_toggle", + {"type": 'U', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("style", 'UNDERLINE'), + ], + } + ), + ( + "font.style_toggle", + {"type": 'P', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("style", 'SMALL_CAPS'), + ], + } + ), + ( + "font.delete", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_OR_SELECTION'), + ], + } + ), + ( + "font.delete", + {"type": 'DEL', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'NEXT_WORD'), + ], + } + ), + ( + "font.delete", + {"type": 'BACK_SPACE', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_OR_SELECTION'), + ], + } + ), + ( + "font.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_OR_SELECTION'), + ], + } + ), + ( + "font.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PREVIOUS_WORD'), + ], + } + ), + ( + "font.move", + {"type": 'HOME', "value": 'PRESS'}, + { + "properties": [ + ("type", 'LINE_BEGIN'), + ], + } + ), + ( + "font.move", + {"type": 'END', "value": 'PRESS'}, + { + "properties": [ + ("type", 'LINE_END'), + ], + } + ), + ( + "font.move", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "font.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_CHARACTER'), + ], + } + ), + ( + "font.move", + {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PREVIOUS_WORD'), + ], + } + ), + ( + "font.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'NEXT_WORD'), + ], + } + ), + ( + "font.move", + {"type": 'UP_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_LINE'), + ], + } + ), + ( + "font.move", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_LINE'), + ], + } + ), + ( + "font.move", + {"type": 'PAGE_UP', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_PAGE'), + ], + } + ), + ( + "font.move", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_PAGE'), + ], + } + ), + ( + "font.move_select", + {"type": 'HOME', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'LINE_BEGIN'), + ], + } + ), + ( + "font.move_select", + {"type": 'END', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'LINE_END'), + ], + } + ), + ( + "font.move_select", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "font.move_select", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'NEXT_CHARACTER'), + ], + } + ), + ( + "font.move_select", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'PREVIOUS_WORD'), + ], + } + ), + ( + "font.move_select", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'NEXT_WORD'), + ], + } + ), + ( + "font.move_select", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_LINE'), + ], + } + ), + ( + "font.move_select", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'NEXT_LINE'), + ], + } + ), + ( + "font.move_select", + {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_PAGE'), + ], + } + ), + ( + "font.move_select", + {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'NEXT_PAGE'), + ], + } + ), + ( + "font.change_spacing", + {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ( + "font.change_spacing", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "font.change_character", + {"type": 'UP_ARROW', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "font.change_character", + {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ("font.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ("font.text_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("font.text_cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("font.text_paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("font.line_break", {"type": 'RET', "value": 'PRESS'}, None), + ("font.text_insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + ( + "font.text_insert", + {"type": 'BACK_SPACE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("accent", True), + ], + } + ), + ], + }, + ), + ( + "Object Non-modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "object.mode_set", + {"type": 'TAB', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'EDIT'), + ("toggle", True), + ], + } + ), + ( + "object.mode_set", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'POSE'), + ("toggle", True), + ], + } + ), + ( + "object.mode_set", + {"type": 'V', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'VERTEX_PAINT'), + ("toggle", True), + ], + } + ), + ( + "object.mode_set", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'WEIGHT_PAINT'), + ("toggle", True), + ], + } + ), + ("object.origin_set", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ], + }, + ), + ( + "3D View", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("view3d.cursor3d", {"type": 'ACTIONMOUSE', "value": 'CLICK'}, None), + ("view3d.rotate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view3d.move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), + ("view3d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view3d.dolly", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "view3d.view_selected", + {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("use_all_regions", True), + ], + } + ), + ( + "view3d.view_selected", + {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, + { + "properties": [ + ("use_all_regions", False), + ], + } + ), + ("view3d.view_lock_to_active", {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "shift": True}, None), + ("view3d.view_lock_clear", {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "alt": True}, None), + ("view3d.navigate", {"type": 'F', "value": 'PRESS', "shift": True}, None), + ("view3d.smoothview", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), + ("view3d.rotate", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("view3d.rotate", {"type": 'MOUSEROTATE', "value": 'ANY'}, None), + ("view3d.move", {"type": 'TRACKPADPAN', "value": 'ANY', "shift": True}, None), + ("view3d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("view3d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ( + "view3d.zoom", + {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "view3d.zoom", + {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ( + "view3d.zoom", + {"type": 'EQUAL', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "view3d.zoom", + {"type": 'MINUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ( + "view3d.zoom", + {"type": 'WHEELINMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "view3d.zoom", + {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ( + "view3d.dolly", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "view3d.dolly", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ( + "view3d.dolly", + {"type": 'EQUAL', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("delta", 1), + ], + } + ), + ( + "view3d.dolly", + {"type": 'MINUS', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("delta", -1), + ], + } + ), + ("view3d.zoom_camera_1_to_1", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None), + ("view3d.view_center_camera", {"type": 'HOME', "value": 'PRESS'}, None), + ("view3d.view_center_lock", {"type": 'HOME', "value": 'PRESS'}, None), + ("view3d.view_center_cursor", {"type": 'HOME', "value": 'PRESS', "alt": True}, None), + ("view3d.view_center_pick", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ( + "view3d.view_all", + {"type": 'HOME', "value": 'PRESS'}, + { + "properties": [ + ("center", False), + ], + } + ), + ( + "view3d.view_all", + {"type": 'HOME', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("use_all_regions", True), + ("center", False), + ], + } + ), + ( + "view3d.view_all", + {"type": 'C', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("center", True), + ], + } + ), + ("view3d.view_camera", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ( + "view3d.view_axis", + {"type": 'NUMPAD_1', "value": 'PRESS'}, + { + "properties": [ + ("type", 'FRONT'), + ], + } + ), + ( + "view3d.view_orbit", + {"type": 'NUMPAD_2', "value": 'PRESS'}, + { + "properties": [ + ("type", 'ORBITDOWN'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_3', "value": 'PRESS'}, + { + "properties": [ + ("type", 'RIGHT'), + ], + } + ), + ( + "view3d.view_orbit", + {"type": 'NUMPAD_4', "value": 'PRESS'}, + { + "properties": [ + ("type", 'ORBITLEFT'), + ], + } + ), + ("view3d.view_persportho", {"type": 'NUMPAD_5', "value": 'PRESS'}, None), + ( + "view3d.view_orbit", + {"type": 'NUMPAD_6', "value": 'PRESS'}, + { + "properties": [ + ("type", 'ORBITRIGHT'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_7', "value": 'PRESS'}, + { + "properties": [ + ("type", 'TOP'), + ], + } + ), + ( + "view3d.view_orbit", + {"type": 'NUMPAD_8', "value": 'PRESS'}, + { + "properties": [ + ("type", 'ORBITUP'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_1', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'BACK'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_3', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'LEFT'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_7', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'BOTTOM'), + ], + } + ), + ( + "view3d.view_pan", + {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PANDOWN'), + ], + } + ), + ( + "view3d.view_pan", + {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PANLEFT'), + ], + } + ), + ( + "view3d.view_pan", + {"type": 'NUMPAD_6', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PANRIGHT'), + ], + } + ), + ( + "view3d.view_pan", + {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PANUP'), + ], + } + ), + ( + "view3d.view_roll", + {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'LEFT'), + ], + } + ), + ( + "view3d.view_roll", + {"type": 'NUMPAD_6', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'RIGHT'), + ], + } + ), + ( + "view3d.view_orbit", + {"type": 'NUMPAD_9', "value": 'PRESS'}, + { + "properties": [ + ("angle", 3.1415927), + ("type", 'ORBITRIGHT'), + ], + } + ), + ( + "view3d.view_pan", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PANRIGHT'), + ], + } + ), + ( + "view3d.view_pan", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PANLEFT'), + ], + } + ), + ( + "view3d.view_pan", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PANUP'), + ], + } + ), + ( + "view3d.view_pan", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PANDOWN'), + ], + } + ), + ( + "view3d.view_orbit", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("type", 'ORBITLEFT'), + ], + } + ), + ( + "view3d.view_orbit", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("type", 'ORBITRIGHT'), + ], + } + ), + ( + "view3d.view_orbit", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("type", 'ORBITUP'), + ], + } + ), + ( + "view3d.view_orbit", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("type", 'ORBITDOWN'), + ], + } + ), + ( + "view3d.view_roll", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'LEFT'), + ], + } + ), + ( + "view3d.view_roll", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'RIGHT'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_1', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'FRONT'), + ("align_active", True), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_3', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'RIGHT'), + ("align_active", True), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_7', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'TOP'), + ("align_active", True), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_1', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'BACK'), + ("align_active", True), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_3', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'LEFT'), + ("align_active", True), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NUMPAD_7', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'BOTTOM'), + ("align_active", True), + ], + } + ), + ("view3d.ndof_orbit_zoom", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), + ("view3d.ndof_orbit", {"type": 'NDOF_MOTION', "value": 'ANY', "ctrl": True}, None), + ("view3d.ndof_pan", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True}, None), + ("view3d.ndof_all", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True, "ctrl": True}, None), + ( + "view3d.view_selected", + {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, + { + "properties": [ + ("use_all_regions", False), + ], + } + ), + ( + "view3d.view_roll", + {"type": 'NDOF_BUTTON_ROLL_CCW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'LEFT'), + ], + } + ), + ( + "view3d.view_roll", + {"type": 'NDOF_BUTTON_ROLL_CCW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'RIGHT'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_FRONT', "value": 'PRESS'}, + { + "properties": [ + ("type", 'FRONT'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_BACK', "value": 'PRESS'}, + { + "properties": [ + ("type", 'BACK'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_LEFT', "value": 'PRESS'}, + { + "properties": [ + ("type", 'LEFT'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_RIGHT', "value": 'PRESS'}, + { + "properties": [ + ("type", 'RIGHT'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS'}, + { + "properties": [ + ("type", 'TOP'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_BOTTOM', "value": 'PRESS'}, + { + "properties": [ + ("type", 'BOTTOM'), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_FRONT', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'FRONT'), + ("align_active", True), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_RIGHT', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'RIGHT'), + ("align_active", True), + ], + } + ), + ( + "view3d.view_axis", + {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'TOP'), + ("align_active", True), + ], + } + ), + ( + "view3d.layers", + {"type": 'ACCENT_GRAVE', "value": 'PRESS'}, + { + "properties": [ + ("nr", 0), + ], + } + ), + ( + "view3d.layers", + {"type": 'ONE', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 1), + ], + } + ), + ( + "view3d.layers", + {"type": 'TWO', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 2), + ], + } + ), + ( + "view3d.layers", + {"type": 'THREE', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 3), + ], + } + ), + ( + "view3d.layers", + {"type": 'FOUR', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 4), + ], + } + ), + ( + "view3d.layers", + {"type": 'FIVE', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 5), + ], + } + ), + ( + "view3d.layers", + {"type": 'SIX', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 6), + ], + } + ), + ( + "view3d.layers", + {"type": 'SEVEN', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 7), + ], + } + ), + ( + "view3d.layers", + {"type": 'EIGHT', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 8), + ], + } + ), + ( + "view3d.layers", + {"type": 'NINE', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 9), + ], + } + ), + ( + "view3d.layers", + {"type": 'ZERO', "value": 'PRESS', "any": True}, + { + "properties": [ + ("nr", 10), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'Z', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'space_data.shading.type'), + ("value_1", 'SOLID'), + ("value_2", 'TEXTURED'), + ], + } + ), + ("view3d.toggle_render", {"type": 'Z', "value": 'PRESS', "shift": True}, None), + ("view3d.toggle_xray_draw_option", {"type": 'Z', "value": 'PRESS'}, None), + ( + "wm.context_toggle", + {"type": 'Z', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.use_occlude_geometry'), + ], + } + ), + ( + "view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", False), + ("center", False), + ("enumerate", False), + ("object", False), + ], + } + ), + ( + "view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", True), + ("center", False), + ("enumerate", False), + ("object", False), + ], + } + ), + ( + "view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", False), + ("center", True), + ("enumerate", False), + ("object", True), + ], + } + ), + ( + "view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", False), + ("center", False), + ("enumerate", True), + ("object", False), + ], + } + ), + ( + "view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ("deselect", False), + ("toggle", True), + ("center", True), + ("enumerate", False), + ("object", False), + ], + } + ), + ( + "view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", False), + ("center", True), + ("enumerate", True), + ("object", False), + ], + } + ), + ( + "view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", True), + ("center", False), + ("enumerate", True), + ("object", False), + ], + } + ), + ( + "view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", True), + ("center", True), + ("enumerate", True), + ("object", False), + ], + } + ), + ("view3d.select_border", {"type": 'B', "value": 'PRESS'}, None), + ( + "view3d.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "view3d.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("view3d.clip_border", {"type": 'B', "value": 'PRESS', "alt": True}, None), + ("view3d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), + ( + "view3d.render_border", + {"type": 'B', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("camera_only", True), + ], + } + ), + ( + "view3d.render_border", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("camera_only", False), + ], + } + ), + ("view3d.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("view3d.camera_to_view", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("view3d.object_as_camera", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'S', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'VIEW3D_MT_snap'), + ], + } + ), + ("view3d.copybuffer", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("view3d.pastebuffer", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'BOUNDING_BOX_CENTER'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'MEDIAN_POINT'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'COMMA', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'tool_settings.use_transform_pivot_point_align'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'CURSOR'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'INDIVIDUAL_ORIGINS'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'ACTIVE_ELEMENT'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.show_manipulator'), + ], + } + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.bend", {"type": 'W', "value": 'PRESS', "shift": True}, None), + ("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None), + ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("transform.select_orientation", {"type": 'SPACE', "value": 'PRESS', "alt": True}, None), + ( + "transform.create_orientation", + {"type": 'SPACE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("use", True), + ], + } + ), + ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.context_toggle", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.use_snap'), + ], + } + ), + ( + "wm.context_menu_enum", + {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("data_path", 'tool_settings.snap_element'), + ], + } + ), + ("object.transform_axis_target", {"type": 'T', "value": 'PRESS', "shift": True}, None), + ( + "transform.translate", + {"type": 'T', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("texture_space", True), + ], + } + ), + ( + "transform.resize", + {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("texture_space", True), + ], + } + ), + ("transform.skin_resize", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "Manipulators", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ], + }, + ), + ( + "Backdrop Transform Widget", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Backdrop Transform Widget Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Backdrop Crop Widget", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Backdrop Crop Widget Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Sun Beams Widget", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Sun Beams Widget Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Corner Pin Widget", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Corner Pin Widget Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "UV Transform Manipulator", + {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "UV Transform Manipulator Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Spot Light Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Spot Light Widgets Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Area Light Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Area Light Widgets Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Target Light Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Target Light Widgets Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Force Field Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Force Field Widgets Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Camera Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Camera Widgets Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Camera View Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Camera View Widgets Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Armature Spline Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Armature Spline Widgets Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "View3D Navigate", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "View3D Navigate Tweak Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "View3D Gesture Circle", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), + ("SELECT", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("DESELECT", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), + ("NOP", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), + ("DESELECT", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("NOP", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), + ("SUBTRACT", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), + ("SUBTRACT", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("ADD", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), + ("ADD", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("SIZE", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ], + }, + ), + ( + "Gesture Border", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("SELECT", {"type": 'RIGHTMOUSE', "value": 'RELEASE', "any": True}, None), + ("BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), + ("DESELECT", {"type": 'LEFTMOUSE', "value": 'RELEASE', "shift": True}, None), + ("BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("SELECT", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), + ("BEGIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("DESELECT", {"type": 'MIDDLEMOUSE', "value": 'RELEASE'}, None), + ], + }, + ), + ( + "Gesture Zoom Border", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), + ("BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("IN", {"type": 'LEFTMOUSE', "value": 'RELEASE'}, None), + ("BEGIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("OUT", {"type": 'MIDDLEMOUSE', "value": 'RELEASE'}, None), + ], + }, + ), + ( + "Gesture Straight Line", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), + ("BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("SELECT", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Standard Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("APPLY", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), + ("APPLY", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("APPLY", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("SNAP", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Animation", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("anim.change_frame", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ( + "wm.context_toggle", + {"type": 'T', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.show_seconds'), + ], + } + ), + ("anim.previewrange_set", {"type": 'P', "value": 'PRESS'}, None), + ("anim.previewrange_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ], + }, + ), + ( + "Animation Channels", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("anim.channels_click", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ( + "anim.channels_click", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "anim.channels_click", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("children_only", True), + ], + } + ), + ("anim.channels_rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("anim.channels_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ("anim.channel_select_keys", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ( + "anim.channel_select_keys", + {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ( + "anim.channels_select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "anim.channels_select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("anim.channels_select_border", {"type": 'B', "value": 'PRESS'}, None), + ("anim.channels_select_border", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), + ("anim.channels_delete", {"type": 'X', "value": 'PRESS'}, None), + ("anim.channels_delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("anim.channels_setting_toggle", {"type": 'W', "value": 'PRESS', "shift": True}, None), + ("anim.channels_setting_enable", {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("anim.channels_setting_disable", {"type": 'W', "value": 'PRESS', "alt": True}, None), + ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("anim.channels_expand", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("anim.channels_collapse", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ( + "anim.channels_expand", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("all", False), + ], + } + ), + ( + "anim.channels_collapse", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("all", False), + ], + } + ), + ( + "anim.channels_move", + {"type": 'PAGE_UP', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'UP'), + ], + } + ), + ( + "anim.channels_move", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'DOWN'), + ], + } + ), + ( + "anim.channels_move", + {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'TOP'), + ], + } + ), + ( + "anim.channels_move", + {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'BOTTOM'), + ], + } + ), + ("anim.channels_group", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("anim.channels_ungroup", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ], + }, + ), + ( + "Knife Tool Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("PANNING", {"type": 'MIDDLEMOUSE', "value": 'ANY', "any": True}, None), + ("CANCEL", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "any": True}, None), + ("ADD_CUT", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'SPACE', "value": 'PRESS', "any": True}, None), + ("NEW_CUT", {"type": 'E', "value": 'PRESS'}, None), + ("SNAP_MIDPOINTS_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_MIDPOINTS_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_MIDPOINTS_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_MIDPOINTS_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("IGNORE_SNAP_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("IGNORE_SNAP_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("IGNORE_SNAP_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("IGNORE_SNAP_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("ANGLE_SNAP_TOGGLE", {"type": 'C', "value": 'PRESS'}, None), + ("CUT_THROUGH_TOGGLE", {"type": 'Z', "value": 'PRESS'}, None), + ], + }, + ), + ( + "UV Editor", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "wm.context_toggle", + {"type": 'Q', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.use_uv_sculpt'), + ], + } + ), + ("uv.mark_seam", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), + ( + "uv.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "uv.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "uv.select_loop", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "uv.select_loop", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ("uv.select_split", {"type": 'Y', "value": 'PRESS'}, None), + ( + "uv.select_border", + {"type": 'B', "value": 'PRESS'}, + { + "properties": [ + ("pinned", False), + ], + } + ), + ( + "uv.select_border", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("pinned", True), + ], + } + ), + ("uv.circle_select", {"type": 'C', "value": 'PRESS'}, None), + ( + "uv.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "uv.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ( + "uv.select_linked", + {"type": 'L', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("extend", True), + ("deselect", False), + ], + } + ), + ( + "uv.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("extend", True), + ("deselect", False), + ], + } + ), + ( + "uv.select_linked", + {"type": 'L', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", False), + ("deselect", True), + ], + } + ), + ( + "uv.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", False), + ("deselect", True), + ], + } + ), + ("uv.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("uv.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ( + "uv.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "uv.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("uv.select_pinned", {"type": 'P', "value": 'PRESS', "shift": True}, None), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'IMAGE_MT_uvs_weldalign'), + ], + } + ), + ("uv.stitch", {"type": 'V', "value": 'PRESS'}, None), + ( + "uv.pin", + {"type": 'P', "value": 'PRESS'}, + { + "properties": [ + ("clear", False), + ], + } + ), + ( + "uv.pin", + {"type": 'P', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("clear", True), + ], + } + ), + ("uv.unwrap", {"type": 'E', "value": 'PRESS'}, None), + ("uv.minimize_stretch", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("uv.pack_islands", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("uv.average_islands_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ( + "uv.hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "uv.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("uv.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("uv.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ( + "wm.call_menu", + {"type": 'S', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'IMAGE_MT_uvs_snap'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("name", 'IMAGE_MT_uvs_select_mode'), + ], + } + ), + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + } + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.context_toggle", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.use_snap'), + ], + } + ), + ( + "wm.context_menu_enum", + {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("data_path", 'tool_settings.snap_uv_element'), + ], + } + ), + ], + }, + ), + ( + "Transform Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("TRANSLATE", {"type": 'G', "value": 'PRESS'}, None), + ("ROTATE", {"type": 'R', "value": 'PRESS'}, None), + ("RESIZE", {"type": 'S', "value": 'PRESS'}, None), + ("SNAP_TOGGLE", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), + ("SNAP_INV_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_INV_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ("SNAP_INV_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("SNAP_INV_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("ADD_SNAP", {"type": 'A', "value": 'PRESS'}, None), + ("REMOVE_SNAP", {"type": 'A', "value": 'PRESS', "alt": True}, None), + ("PROPORTIONAL_SIZE_UP", {"type": 'PAGE_UP', "value": 'PRESS'}, None), + ("PROPORTIONAL_SIZE_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS'}, None), + ("PROPORTIONAL_SIZE_UP", {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, None), + ("PROPORTIONAL_SIZE_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, None), + ("PROPORTIONAL_SIZE_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), + ("PROPORTIONAL_SIZE_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), + ("PROPORTIONAL_SIZE_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None), + ("PROPORTIONAL_SIZE_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None), + ("PROPORTIONAL_SIZE", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("EDGESLIDE_EDGE_NEXT", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": True}, None), + ("EDGESLIDE_PREV_NEXT", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": True}, None), + ("AUTOIK_CHAIN_LEN_UP", {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, None), + ("AUTOIK_CHAIN_LEN_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, None), + ("AUTOIK_CHAIN_LEN_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None), + ("AUTOIK_CHAIN_LEN_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None), + ("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS'}, None), + ], + }, + ), + ( + "UV Sculpt", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ( + "wm.context_toggle", + {"type": 'Q', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.use_uv_sculpt'), + ], + } + ), + ( + "sculpt.uv_sculpt_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'NORMAL'), + ], + } + ), + ( + "sculpt.uv_sculpt_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'INVERT'), + ], + } + ), + ( + "sculpt.uv_sculpt_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'RELAX'), + ], + } + ), + ( + "brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 0.9), + ], + } + ), + ( + "brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("scalar", 1.1111112), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("data_path_primary", 'tool_settings.uv_sculpt.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.uv_sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.uv_sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.uv_sculpt.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path_primary", 'tool_settings.uv_sculpt.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.uv_sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.uv_sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.uv_sculpt.brush'), + ("secondary_tex", False), + ], + } + ), + ( + "brush.uv_sculpt_tool_set", + {"type": 'S', "value": 'PRESS'}, + { + "properties": [ + ("tool", 'RELAX'), + ], + } + ), + ( + "brush.uv_sculpt_tool_set", + {"type": 'P', "value": 'PRESS'}, + { + "properties": [ + ("tool", 'PINCH'), + ], + } + ), + ( + "brush.uv_sculpt_tool_set", + {"type": 'G', "value": 'PRESS'}, + { + "properties": [ + ("tool", 'GRAB'), + ], + } + ), + ], + }, + ), + ( + "Paint Stroke Modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Mask Editing", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("mask.new", {"type": 'N', "value": 'PRESS', "alt": True}, None), + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'MASK_MT_add'), + ], + } + ), + ( + "wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.use_proportional_edit_mask'), + ], + } + ), + ("mask.add_vertex_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("mask.add_feather_vertex_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, None), + ("mask.delete", {"type": 'X', "value": 'PRESS'}, None), + ("mask.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ( + "mask.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", False), + ], + } + ), + ( + "mask.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", False), + ("deselect", False), + ("toggle", True), + ], + } + ), + ( + "mask.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "mask.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("mask.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ( + "mask.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "mask.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("mask.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("mask.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ( + "mask.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "mask.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("mask.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("mask.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("mask.hide_view_clear", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ( + "mask.hide_view_set", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "mask.hide_view_set", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ( + "clip.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ("mask.cyclic_toggle", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ("mask.slide_point", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("mask.slide_spline_curvature", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("mask.handle_type_set", {"type": 'V', "value": 'PRESS'}, None), + ("mask.normals_make_consistent", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("mask.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("mask.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("mask.shape_key_insert", {"type": 'I', "value": 'PRESS'}, None), + ("mask.shape_key_clear", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("mask.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("mask.copy_splines", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("mask.paste_splines", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("uv.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ( + "transform.transform", + {"type": 'S', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'MASK_SHRINKFATTEN'), + ], + } + ), + ], + }, + ), + ( + "Markers", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + { + "items": [ + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.move", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("marker.duplicate", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("marker.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), + ( + "marker.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "marker.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("extend", False), + ("camera", True), + ], + } + ), + ( + "marker.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ("camera", True), + ], + } + ), + ("marker.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("marker.select_all", {"type": 'A', "value": 'PRESS'}, None), + ("marker.delete", {"type": 'X', "value": 'PRESS'}, None), + ("marker.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ("marker.move", {"type": 'G', "value": 'PRESS'}, None), + ("marker.camera_bind", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "Eyedropper Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("SAMPLE_CONFIRM", {"type": 'RET', "value": 'RELEASE', "any": True}, None), + ("SAMPLE_CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'RELEASE', "any": True}, None), + ("SAMPLE_CONFIRM", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), + ("SAMPLE_BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ("SAMPLE_RESET", {"type": 'SPACE', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Eyedropper ColorBand PointSampling Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'BACK_SPACE', "value": 'PRESS', "any": True}, None), + ("SAMPLE_CONFIRM", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("SAMPLE_CONFIRM", {"type": 'RET', "value": 'RELEASE', "any": True}, None), + ("SAMPLE_CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'RELEASE', "any": True}, None), + ("SAMPLE_SAMPLE", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ("SAMPLE_RESET", {"type": 'SPACE', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "Outliner Item Drag & Drop Modal Map", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'RELEASE', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "View3D Fly Modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), + ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'SPACE', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("ACCELERATE", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "any": True}, None), + ("DECELERATE", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "any": True}, None), + ("ACCELERATE", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "any": True}, None), + ("DECELERATE", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("PAN_ENABLE", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "any": True}, None), + ("PAN_DISABLE", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), + ("FORWARD", {"type": 'W', "value": 'PRESS'}, None), + ("BACKWARD", {"type": 'S', "value": 'PRESS'}, None), + ("LEFT", {"type": 'A', "value": 'PRESS'}, None), + ("RIGHT", {"type": 'D', "value": 'PRESS'}, None), + ("UP", {"type": 'E', "value": 'PRESS'}, None), + ("DOWN", {"type": 'Q', "value": 'PRESS'}, None), + ("UP", {"type": 'R', "value": 'PRESS'}, None), + ("DOWN", {"type": 'F', "value": 'PRESS'}, None), + ("FORWARD", {"type": 'UP_ARROW', "value": 'PRESS'}, None), + ("BACKWARD", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None), + ("LEFT", {"type": 'LEFT_ARROW', "value": 'PRESS'}, None), + ("RIGHT", {"type": 'RIGHT_ARROW', "value": 'PRESS'}, None), + ("AXIS_LOCK_X", {"type": 'X', "value": 'PRESS'}, None), + ("AXIS_LOCK_Z", {"type": 'Z', "value": 'PRESS'}, None), + ("PRECISION_ENABLE", {"type": 'LEFT_ALT', "value": 'PRESS', "any": True}, None), + ("PRECISION_DISABLE", {"type": 'LEFT_ALT', "value": 'RELEASE', "any": True}, None), + ("PRECISION_ENABLE", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("PRECISION_DISABLE", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("FREELOOK_ENABLE", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("FREELOOK_DISABLE", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "View3D Walk Modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), + ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), + ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), + ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), + ("FAST_ENABLE", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("FAST_DISABLE", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SLOW_ENABLE", {"type": 'LEFT_ALT', "value": 'PRESS', "any": True}, None), + ("SLOW_DISABLE", {"type": 'LEFT_ALT', "value": 'RELEASE', "any": True}, None), + ("FORWARD", {"type": 'W', "value": 'PRESS', "any": True}, None), + ("BACKWARD", {"type": 'S', "value": 'PRESS', "any": True}, None), + ("LEFT", {"type": 'A', "value": 'PRESS', "any": True}, None), + ("RIGHT", {"type": 'D', "value": 'PRESS', "any": True}, None), + ("UP", {"type": 'E', "value": 'PRESS', "any": True}, None), + ("DOWN", {"type": 'Q', "value": 'PRESS', "any": True}, None), + ("FORWARD_STOP", {"type": 'W', "value": 'RELEASE', "any": True}, None), + ("BACKWARD_STOP", {"type": 'S', "value": 'RELEASE', "any": True}, None), + ("LEFT_STOP", {"type": 'A', "value": 'RELEASE', "any": True}, None), + ("RIGHT_STOP", {"type": 'D', "value": 'RELEASE', "any": True}, None), + ("UP_STOP", {"type": 'E', "value": 'RELEASE', "any": True}, None), + ("DOWN_STOP", {"type": 'Q', "value": 'RELEASE', "any": True}, None), + ("FORWARD", {"type": 'UP_ARROW', "value": 'PRESS'}, None), + ("BACKWARD", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None), + ("LEFT", {"type": 'LEFT_ARROW', "value": 'PRESS'}, None), + ("RIGHT", {"type": 'RIGHT_ARROW', "value": 'PRESS'}, None), + ("FORWARD_STOP", {"type": 'UP_ARROW', "value": 'RELEASE', "any": True}, None), + ("BACKWARD_STOP", {"type": 'DOWN_ARROW', "value": 'RELEASE', "any": True}, None), + ("LEFT_STOP", {"type": 'LEFT_ARROW', "value": 'RELEASE', "any": True}, None), + ("RIGHT_STOP", {"type": 'RIGHT_ARROW', "value": 'RELEASE', "any": True}, None), + ("GRAVITY_TOGGLE", {"type": 'TAB', "value": 'PRESS'}, None), + ("GRAVITY_TOGGLE", {"type": 'G', "value": 'PRESS'}, None), + ("JUMP", {"type": 'V', "value": 'PRESS', "any": True}, None), + ("JUMP_STOP", {"type": 'V', "value": 'RELEASE', "any": True}, None), + ("TELEPORT", {"type": 'SPACE', "value": 'PRESS', "any": True}, None), + ("TELEPORT", {"type": 'MIDDLEMOUSE', "value": 'ANY', "any": True}, None), + ("ACCELERATE", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "any": True}, None), + ("DECELERATE", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "any": True}, None), + ("ACCELERATE", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "any": True}, None), + ("DECELERATE", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "View3D Rotate Modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CONFIRM", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), + ("CONFIRM", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ("AXIS_SNAP_ENABLE", {"type": 'LEFT_ALT', "value": 'PRESS', "any": True}, None), + ("AXIS_SNAP_DISABLE", {"type": 'LEFT_ALT', "value": 'RELEASE', "any": True}, None), + ], + }, + ), + ( + "View3D Move Modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CONFIRM", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), + ("CONFIRM", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "View3D Zoom Modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CONFIRM", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), + ("CONFIRM", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "View3D Dolly Modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, + { + "items": [ + ("CONFIRM", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), + ("CONFIRM", {"type": 'ESC', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Graph Editor Generic", + {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("graph.properties", {"type": 'N', "value": 'PRESS'}, None), + ("graph.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ( + "graph.hide", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "graph.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("graph.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ], + }, + ), + ( + "Graph Editor", + {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ( + "wm.context_toggle", + {"type": 'H', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.show_handles'), + ], + } + ), + ("graph.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ( + "graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ("column", False), + ("curves", False), + ], + } + ), + ( + "graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("extend", False), + ("column", True), + ("curves", False), + ], + } + ), + ( + "graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ("column", False), + ("curves", False), + ], + } + ), + ( + "graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("extend", True), + ("column", True), + ("curves", False), + ], + } + ), + ( + "graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", False), + ("column", False), + ("curves", True), + ], + } + ), + ( + "graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", True), + ("column", False), + ("curves", True), + ], + } + ), + ( + "graph.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'CHECK'), + ("extend", False), + ], + } + ), + ( + "graph.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("mode", 'CHECK'), + ("extend", True), + ], + } + ), + ( + "graph.select_leftright", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'LEFT'), + ("extend", False), + ], + } + ), + ( + "graph.select_leftright", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'RIGHT'), + ("extend", False), + ], + } + ), + ( + "graph.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "graph.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ( + "graph.select_border", + {"type": 'B', "value": 'PRESS'}, + { + "properties": [ + ("axis_range", False), + ("include_handles", False), + ], + } + ), + ( + "graph.select_border", + {"type": 'B', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("axis_range", True), + ("include_handles", False), + ], + } + ), + ( + "graph.select_border", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("axis_range", False), + ("include_handles", True), + ], + } + ), + ( + "graph.select_border", + {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("axis_range", True), + ("include_handles", True), + ], + } + ), + ( + "graph.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "graph.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("graph.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ( + "graph.select_column", + {"type": 'K', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'KEYS'), + ], + } + ), + ( + "graph.select_column", + {"type": 'K', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'CFRA'), + ], + } + ), + ( + "graph.select_column", + {"type": 'K', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'MARKERS_COLUMN'), + ], + } + ), + ( + "graph.select_column", + {"type": 'K', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'MARKERS_BETWEEN'), + ], + } + ), + ("graph.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("graph.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("graph.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("graph.frame_jump", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("graph.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("graph.mirror", {"type": 'M', "value": 'PRESS', "shift": True}, None), + ("graph.handle_type", {"type": 'V', "value": 'PRESS'}, None), + ("graph.interpolation_type", {"type": 'T', "value": 'PRESS'}, None), + ("graph.easing_type", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), + ("graph.smooth", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("graph.sample", {"type": 'O', "value": 'PRESS', "shift": True}, None), + ("graph.bake", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ( + "wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + { + "properties": [ + ("name", 'GRAPH_MT_delete'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("name", 'GRAPH_MT_delete'), + ], + } + ), + ("graph.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("graph.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), + ( + "graph.click_insert", + {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "graph.click_insert", + {"type": 'ACTIONMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ("graph.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("graph.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ( + "graph.paste", + {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("flipped", True), + ], + } + ), + ("graph.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("graph.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("graph.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("graph.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("graph.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ( + "graph.fmodifier_add", + {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("only_active", False), + ], + } + ), + ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ( + "transform.transform", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TIME_EXTEND'), + ], + } + ), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ( + "wm.context_toggle", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.use_proportional_fcurve'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'BOUNDING_BOX_CENTER'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'CURSOR'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'INDIVIDUAL_ORIGINS'), + ], + } + ), + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "Image Generic", + {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("image.new", {"type": 'N', "value": 'PRESS', "alt": True}, None), + ("image.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("image.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("image.read_viewlayers", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("image.save", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("image.save_as", {"type": 'F3', "value": 'PRESS'}, None), + ("image.properties", {"type": 'N', "value": 'PRESS'}, None), + ("image.toolshelf", {"type": 'T', "value": 'PRESS'}, None), + ("image.cycle_render_slot", {"type": 'J', "value": 'PRESS'}, None), + ( + "image.cycle_render_slot", + {"type": 'J', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("reverse", True), + ], + } + ), + ], + }, + ), + ( + "Image", + {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("image.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ( + "image.view_all", + {"type": 'HOME', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("fit_view", True), + ], + } + ), + ("image.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), + ("image.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("image.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("image.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), + ("image.view_zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), + ("image.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), + ("image.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("image.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("image.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("image.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("image.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("image.view_zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("ratio", 8.0), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("ratio", 4.0), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("ratio", 2.0), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("ratio", 8.0), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("ratio", 4.0), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("ratio", 2.0), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_1', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 1.0), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 0.5), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 0.25), + ], + } + ), + ( + "image.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 0.125), + ], + } + ), + ("image.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("image.sample", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ( + "image.curves_point_set", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("point", 'BLACK_POINT'), + ], + } + ), + ( + "image.curves_point_set", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("point", 'WHITE_POINT'), + ], + } + ), + ( + "object.mode_set", + {"type": 'TAB', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'EDIT'), + ("toggle", True), + ], + } + ), + ( + "wm.context_set_int", + {"type": 'ONE', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.image.render_slots.active_index'), + ("value", 0), + ], + } + ), + ( + "wm.context_set_int", + {"type": 'TWO', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.image.render_slots.active_index'), + ("value", 1), + ], + } + ), + ( + "wm.context_set_int", + {"type": 'THREE', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.image.render_slots.active_index'), + ("value", 2), + ], + } + ), + ( + "wm.context_set_int", + {"type": 'FOUR', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.image.render_slots.active_index'), + ("value", 3), + ], + } + ), + ( + "wm.context_set_int", + {"type": 'FIVE', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.image.render_slots.active_index'), + ("value", 4), + ], + } + ), + ( + "wm.context_set_int", + {"type": 'SIX', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.image.render_slots.active_index'), + ("value", 5), + ], + } + ), + ( + "wm.context_set_int", + {"type": 'SEVEN', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.image.render_slots.active_index'), + ("value", 6), + ], + } + ), + ( + "wm.context_set_int", + {"type": 'EIGHT', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.image.render_slots.active_index'), + ("value", 7), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'CENTER'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'MEDIAN'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'CURSOR'), + ], + } + ), + ("image.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ("image.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ], + }, + ), + ( + "Node Generic", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("node.properties", {"type": 'N', "value": 'PRESS'}, None), + ("node.toolbar", {"type": 'T', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Node Editor", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ( + "node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select_border", + {"type": 'EVT_TWEAK_S', "value": 'ANY'}, + { + "properties": [ + ("tweak", True), + ], + } + ), + ( + "node.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "node.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("node.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ( + "node.link", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("detach", False), + ], + } + ), + ( + "node.link", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("detach", True), + ], + } + ), + ("node.resize", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("node.add_reroute", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), + ("node.links_cut", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("node.select_link_viewer", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("node.backimage_move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "alt": True}, None), + ( + "node.backimage_zoom", + {"type": 'V', "value": 'PRESS'}, + { + "properties": [ + ("factor", 0.8333333), + ], + } + ), + ( + "node.backimage_zoom", + {"type": 'V', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("factor", 1.2), + ], + } + ), + ("node.backimage_fit", {"type": 'HOME', "value": 'PRESS', "alt": True}, None), + ("node.backimage_sample", {"type": 'ACTIONMOUSE', "value": 'PRESS', "alt": True}, None), + ( + "node.link_make", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("replace", False), + ], + } + ), + ( + "node.link_make", + {"type": 'F', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("replace", True), + ], + } + ), + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'NODE_MT_add'), + ], + } + ), + ("node.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("node.duplicate_move_keep_inputs", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("node.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("node.detach", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("node.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ("node.hide_toggle", {"type": 'H', "value": 'PRESS'}, None), + ("node.mute_toggle", {"type": 'M', "value": 'PRESS'}, None), + ("node.preview_toggle", {"type": 'H', "value": 'PRESS', "shift": True}, None), + ("node.hide_socket_toggle", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), + ("node.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("node.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("node.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ( + "node.select_border", + {"type": 'B', "value": 'PRESS'}, + { + "properties": [ + ("tweak", False), + ], + } + ), + ("node.delete", {"type": 'X', "value": 'PRESS'}, None), + ("node.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("node.delete_reconnect", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ( + "node.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "node.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("node.select_linked_to", {"type": 'L', "value": 'PRESS', "shift": True}, None), + ("node.select_linked_from", {"type": 'L', "value": 'PRESS'}, None), + ( + "node.select_grouped", + {"type": 'G', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "node.select_grouped", + {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "node.select_same_type_step", + {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("prev", False), + ], + } + ), + ( + "node.select_same_type_step", + {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("prev", True), + ], + } + ), + ("node.find_node", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ("node.group_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("node.group_ungroup", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ("node.group_separate", {"type": 'P', "value": 'PRESS'}, None), + ( + "node.group_edit", + {"type": 'TAB', "value": 'PRESS'}, + { + "properties": [ + ("exit", False), + ], + } + ), + ( + "node.group_edit", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("exit", True), + ], + } + ), + ("node.read_viewlayers", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("node.render_changed", {"type": 'Z', "value": 'PRESS'}, None), + ("node.clipboard_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("node.clipboard_paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("node.viewer_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ("node.clear_viewer_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("node.translate_attach", {"type": 'G', "value": 'PRESS'}, None), + ("node.translate_attach", {"type": 'EVT_TWEAK_A', "value": 'ANY'}, None), + ("node.translate_attach", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ( + "transform.translate", + {"type": 'G', "value": 'PRESS'}, + { + "properties": [ + ("release_confirm", True), + ], + } + ), + ( + "transform.translate", + {"type": 'EVT_TWEAK_A', "value": 'ANY'}, + { + "properties": [ + ("release_confirm", True), + ], + } + ), + ( + "transform.translate", + {"type": 'EVT_TWEAK_S', "value": 'ANY'}, + { + "properties": [ + ("release_confirm", True), + ], + } + ), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("node.move_detach_links", {"type": 'D', "value": 'PRESS', "alt": True}, None), + ("node.move_detach_links_release", {"type": 'EVT_TWEAK_A', "value": 'ANY', "alt": True}, None), + ("node.move_detach_links", {"type": 'EVT_TWEAK_S', "value": 'ANY', "alt": True}, None), + ( + "wm.context_toggle", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'tool_settings.use_snap'), + ], + } + ), + ( + "wm.context_menu_enum", + {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("data_path", 'tool_settings.snap_node_element'), + ], + } + ), + ], + }, + ), + ( + "File Browser", + {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, + { + "items": [ + ("file.parent", {"type": 'UP_ARROW', "value": 'PRESS', "alt": True}, None), + ("file.previous", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, None), + ("file.next", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, None), + ("file.refresh", {"type": 'R', "value": 'PRESS'}, None), + ("file.parent", {"type": 'P', "value": 'PRESS'}, None), + ("file.previous", {"type": 'BACK_SPACE', "value": 'PRESS'}, None), + ("file.next", {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, None), + ( + "wm.context_toggle", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.params.show_hidden'), + ], + } + ), + ("file.directory_new", {"type": 'I', "value": 'PRESS'}, None), + ("file.delete", {"type": 'X', "value": 'PRESS'}, None), + ("file.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("file.smoothscroll", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), + ("file.bookmark_toggle", {"type": 'T', "value": 'PRESS'}, None), + ("file.bookmark_add", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "File Browser Main", + {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, + { + "items": [ + ( + "file.execute", + {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, + { + "properties": [ + ("need_active", True), + ], + } + ), + ("file.refresh", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None), + ( + "file.select", + {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "file.select", + {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ("fill", True), + ], + } + ), + ( + "file.select", + {"type": 'RIGHTMOUSE', "value": 'CLICK'}, + { + "properties": [ + ("open", False), + ], + } + ), + ( + "file.select", + {"type": 'RIGHTMOUSE', "value": 'CLICK', "shift": True}, + { + "properties": [ + ("extend", True), + ("open", False), + ], + } + ), + ( + "file.select", + {"type": 'RIGHTMOUSE', "value": 'CLICK', "alt": True}, + { + "properties": [ + ("extend", True), + ("fill", True), + ("open", False), + ], + } + ), + ( + "file.select_walk", + {"type": 'UP_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'UP'), + ], + } + ), + ( + "file.select_walk", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'UP'), + ("extend", True), + ], + } + ), + ( + "file.select_walk", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("direction", 'UP'), + ("extend", True), + ("fill", True), + ], + } + ), + ( + "file.select_walk", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'DOWN'), + ], + } + ), + ( + "file.select_walk", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'DOWN'), + ("extend", True), + ], + } + ), + ( + "file.select_walk", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("direction", 'DOWN'), + ("extend", True), + ("fill", True), + ], + } + ), + ( + "file.select_walk", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'LEFT'), + ], + } + ), + ( + "file.select_walk", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'LEFT'), + ("extend", True), + ], + } + ), + ( + "file.select_walk", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("direction", 'LEFT'), + ("extend", True), + ("fill", True), + ], + } + ), + ( + "file.select_walk", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("direction", 'RIGHT'), + ], + } + ), + ( + "file.select_walk", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("direction", 'RIGHT'), + ("extend", True), + ], + } + ), + ( + "file.select_walk", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("direction", 'RIGHT'), + ("extend", True), + ("fill", True), + ], + } + ), + ("file.previous", {"type": 'BUTTON4MOUSE', "value": 'CLICK'}, None), + ("file.next", {"type": 'BUTTON5MOUSE', "value": 'CLICK'}, None), + ("file.select_all_toggle", {"type": 'A', "value": 'PRESS'}, None), + ("file.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("file.select_border", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), + ("file.rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("file.highlight", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), + ( + "file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, + { + "properties": [ + ("increment", 1), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("increment", 10), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("increment", 100), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, + { + "properties": [ + ("increment", -1), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("increment", -10), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("increment", -100), + ], + } + ), + ], + }, + ), + ( + "File Browser Buttons", + {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, + { + "items": [ + ( + "file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, + { + "properties": [ + ("increment", 1), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("increment", 10), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("increment", 100), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, + { + "properties": [ + ("increment", -1), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("increment", -10), + ], + } + ), + ( + "file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("increment", -100), + ], + } + ), + ], + }, + ), + ( + "Dopesheet Generic", + {"space_type": 'DOPESHEET_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("action.properties", {"type": 'N', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Dopesheet", + {"space_type": 'DOPESHEET_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ( + "action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ("column", False), + ("channel", False), + ], + } + ), + ( + "action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("extend", False), + ("column", True), + ("channel", False), + ], + } + ), + ( + "action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ("column", False), + ("channel", False), + ], + } + ), + ( + "action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("extend", True), + ("column", True), + ("channel", False), + ], + } + ), + ( + "action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", False), + ("column", False), + ("channel", True), + ], + } + ), + ( + "action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("extend", True), + ("column", False), + ("channel", True), + ], + } + ), + ( + "action.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'CHECK'), + ("extend", False), + ], + } + ), + ( + "action.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("mode", 'CHECK'), + ("extend", True), + ], + } + ), + ( + "action.select_leftright", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'LEFT'), + ("extend", False), + ], + } + ), + ( + "action.select_leftright", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'RIGHT'), + ("extend", False), + ], + } + ), + ( + "action.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "action.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ( + "action.select_border", + {"type": 'B', "value": 'PRESS'}, + { + "properties": [ + ("axis_range", False), + ], + } + ), + ( + "action.select_border", + {"type": 'B', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("axis_range", True), + ], + } + ), + ( + "action.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "action.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("action.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ( + "action.select_column", + {"type": 'K', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'KEYS'), + ], + } + ), + ( + "action.select_column", + {"type": 'K', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'CFRA'), + ], + } + ), + ( + "action.select_column", + {"type": 'K', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'MARKERS_COLUMN'), + ], + } + ), + ( + "action.select_column", + {"type": 'K', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("mode", 'MARKERS_BETWEEN'), + ], + } + ), + ("action.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("action.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("action.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("action.frame_jump", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("action.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("action.mirror", {"type": 'M', "value": 'PRESS', "shift": True}, None), + ("action.handle_type", {"type": 'V', "value": 'PRESS'}, None), + ("action.interpolation_type", {"type": 'T', "value": 'PRESS'}, None), + ("action.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("action.keyframe_type", {"type": 'R', "value": 'PRESS'}, None), + ("action.sample", {"type": 'O', "value": 'PRESS', "shift": True}, None), + ( + "wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + { + "properties": [ + ("name", 'DOPESHEET_MT_delete'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("name", 'DOPESHEET_MT_delete'), + ], + } + ), + ("action.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("action.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), + ("action.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("action.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ( + "action.paste", + {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("flipped", True), + ], + } + ), + ("action.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("action.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("action.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("action.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("action.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ( + "transform.transform", + {"type": 'G', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TIME_TRANSLATE'), + ], + } + ), + ( + "transform.transform", + {"type": 'EVT_TWEAK_S', "value": 'ANY'}, + { + "properties": [ + ("mode", 'TIME_TRANSLATE'), + ], + } + ), + ( + "transform.transform", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TIME_EXTEND'), + ], + } + ), + ( + "transform.transform", + {"type": 'S', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TIME_SCALE'), + ], + } + ), + ( + "transform.transform", + {"type": 'T', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("mode", 'TIME_SLIDE'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'tool_settings.use_proportional_action'), + ], + } + ), + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "NLA Generic", + {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("nla.properties", {"type": 'N', "value": 'PRESS'}, None), + ("nla.tweakmode_enter", {"type": 'TAB', "value": 'PRESS'}, None), + ("nla.tweakmode_exit", {"type": 'TAB', "value": 'PRESS'}, None), + ( + "nla.tweakmode_enter", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("isolate_action", True), + ], + } + ), + ( + "nla.tweakmode_exit", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("isolate_action", True), + ], + } + ), + ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "NLA Channels", + {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ( + "nla.channels_click", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "nla.channels_click", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "nla.tracks_add", + {"type": 'A', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("above_selected", False), + ], + } + ), + ( + "nla.tracks_add", + {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("above_selected", True), + ], + } + ), + ("nla.tracks_delete", {"type": 'X', "value": 'PRESS'}, None), + ("nla.tracks_delete", {"type": 'DEL', "value": 'PRESS'}, None), + ], + }, + ), + ( + "NLA Editor", + {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ( + "nla.click_select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "nla.click_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "nla.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("mode", 'CHECK'), + ("extend", False), + ], + } + ), + ( + "nla.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("mode", 'CHECK'), + ("extend", True), + ], + } + ), + ( + "nla.select_leftright", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'LEFT'), + ("extend", False), + ], + } + ), + ( + "nla.select_leftright", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'RIGHT'), + ("extend", False), + ], + } + ), + ( + "nla.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "nla.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ( + "nla.select_border", + {"type": 'B', "value": 'PRESS'}, + { + "properties": [ + ("axis_range", False), + ], + } + ), + ( + "nla.select_border", + {"type": 'B', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("axis_range", True), + ], + } + ), + ("nla.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("nla.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("nla.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("nla.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("nla.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ("nla.actionclip_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), + ("nla.transition_add", {"type": 'T', "value": 'PRESS', "shift": True}, None), + ("nla.soundclip_add", {"type": 'K', "value": 'PRESS', "shift": True}, None), + ("nla.meta_add", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("nla.meta_remove", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ( + "nla.duplicate", + {"type": 'D', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("linked", False), + ], + } + ), + ( + "nla.duplicate", + {"type": 'D', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("linked", True), + ], + } + ), + ("nla.make_single_user", {"type": 'U', "value": 'PRESS'}, None), + ("nla.delete", {"type": 'X', "value": 'PRESS'}, None), + ("nla.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("nla.split", {"type": 'Y', "value": 'PRESS'}, None), + ("nla.mute_toggle", {"type": 'H', "value": 'PRESS'}, None), + ("nla.swap", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("nla.move_up", {"type": 'PAGE_UP', "value": 'PRESS'}, None), + ("nla.move_down", {"type": 'PAGE_DOWN', "value": 'PRESS'}, None), + ("nla.apply_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ("nla.clear_scale", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("nla.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("nla.fmodifier_add", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "transform.transform", + {"type": 'G', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TRANSLATION'), + ], + } + ), + ( + "transform.transform", + {"type": 'EVT_TWEAK_S', "value": 'ANY'}, + { + "properties": [ + ("mode", 'TRANSLATION'), + ], + } + ), + ( + "transform.transform", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TIME_EXTEND'), + ], + } + ), + ( + "transform.transform", + {"type": 'S', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TIME_SCALE'), + ], + } + ), + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "Text Generic", + {"space_type": 'TEXT_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("text.start_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ("text.jump", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ("text.find", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("text.replace", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), + ("text.properties", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "Text", + {"space_type": 'TEXT_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ( + "wm.context_cycle_int", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.font_size'), + ("reverse", False), + ], + } + ), + ( + "wm.context_cycle_int", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.font_size'), + ("reverse", True), + ], + } + ), + ( + "wm.context_cycle_int", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.font_size'), + ("reverse", False), + ], + } + ), + ( + "wm.context_cycle_int", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.font_size'), + ("reverse", True), + ], + } + ), + ("text.new", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("text.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("text.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("text.save", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("text.save_as", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("text.run_script", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("text.cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("text.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("text.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("text.cut", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), + ("text.copy", {"type": 'INSERT', "value": 'PRESS', "ctrl": True}, None), + ("text.paste", {"type": 'INSERT', "value": 'PRESS', "shift": True}, None), + ("text.duplicate_line", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), + ("text.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ("text.select_line", {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("text.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ( + "text.move_lines", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("direction", 'UP'), + ], + } + ), + ( + "text.move_lines", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("direction", 'DOWN'), + ], + } + ), + ("text.indent", {"type": 'TAB', "value": 'PRESS'}, None), + ("text.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), + ("text.uncomment", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ( + "text.move", + {"type": 'HOME', "value": 'PRESS'}, + { + "properties": [ + ("type", 'LINE_BEGIN'), + ], + } + ), + ( + "text.move", + {"type": 'END', "value": 'PRESS'}, + { + "properties": [ + ("type", 'LINE_END'), + ], + } + ), + ( + "text.move", + {"type": 'E', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'LINE_END'), + ], + } + ), + ( + "text.move", + {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'LINE_END'), + ], + } + ), + ( + "text.move", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "text.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_CHARACTER'), + ], + } + ), + ( + "text.move", + {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PREVIOUS_WORD'), + ], + } + ), + ( + "text.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'NEXT_WORD'), + ], + } + ), + ( + "text.move", + {"type": 'UP_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_LINE'), + ], + } + ), + ( + "text.move", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_LINE'), + ], + } + ), + ( + "text.move", + {"type": 'PAGE_UP', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_PAGE'), + ], + } + ), + ( + "text.move", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_PAGE'), + ], + } + ), + ( + "text.move", + {"type": 'HOME', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'FILE_TOP'), + ], + } + ), + ( + "text.move", + {"type": 'END', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'FILE_BOTTOM'), + ], + } + ), + ( + "text.move_select", + {"type": 'HOME', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'LINE_BEGIN'), + ], + } + ), + ( + "text.move_select", + {"type": 'END', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'LINE_END'), + ], + } + ), + ( + "text.move_select", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "text.move_select", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'NEXT_CHARACTER'), + ], + } + ), + ( + "text.move_select", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'PREVIOUS_WORD'), + ], + } + ), + ( + "text.move_select", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'NEXT_WORD'), + ], + } + ), + ( + "text.move_select", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_LINE'), + ], + } + ), + ( + "text.move_select", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'NEXT_LINE'), + ], + } + ), + ( + "text.move_select", + {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_PAGE'), + ], + } + ), + ( + "text.move_select", + {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'NEXT_PAGE'), + ], + } + ), + ( + "text.move_select", + {"type": 'HOME', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'FILE_TOP'), + ], + } + ), + ( + "text.move_select", + {"type": 'END', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("type", 'FILE_BOTTOM'), + ], + } + ), + ( + "text.delete", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_CHARACTER'), + ], + } + ), + ( + "text.delete", + {"type": 'BACK_SPACE', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "text.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "text.delete", + {"type": 'DEL', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'NEXT_WORD'), + ], + } + ), + ( + "text.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PREVIOUS_WORD'), + ], + } + ), + ("text.overwrite_toggle", {"type": 'INSERT', "value": 'PRESS'}, None), + ("text.scroll_bar", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("text.scroll_bar", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("text.scroll", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("text.scroll", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("text.selection_set", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), + ("text.cursor_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ( + "text.selection_set", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("select", True), + ], + } + ), + ( + "text.scroll", + {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("lines", -1), + ], + } + ), + ( + "text.scroll", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("lines", 1), + ], + } + ), + ("text.line_break", {"type": 'RET', "value": 'PRESS'}, None), + ("text.line_break", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), + ( + "wm.call_menu", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, + { + "properties": [ + ("name", 'TEXT_MT_toolbox'), + ], + } + ), + ("text.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None), + ("text.line_number", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + ("text.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + ], + }, + ), + ( + "SequencerCommon", + {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("sequencer.properties", {"type": 'N', "value": 'PRESS'}, None), + ( + "wm.context_toggle", + {"type": 'O', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("data_path", 'scene.sequence_editor.show_overlay'), + ], + } + ), + ("sequencer.view_toggle", {"type": 'TAB', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "Sequencer", + {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ( + "sequencer.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "sequencer.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ( + "sequencer.cut", + {"type": 'K', "value": 'PRESS'}, + { + "properties": [ + ("type", 'SOFT'), + ], + } + ), + ( + "sequencer.cut", + {"type": 'K', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'HARD'), + ], + } + ), + ( + "sequencer.mute", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "sequencer.mute", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ( + "sequencer.unmute", + {"type": 'H', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "sequencer.unmute", + {"type": 'H', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("sequencer.lock", {"type": 'L', "value": 'PRESS', "shift": True}, None), + ("sequencer.unlock", {"type": 'L', "value": 'PRESS', "shift": True, "alt": True}, None), + ("sequencer.reassign_inputs", {"type": 'R', "value": 'PRESS'}, None), + ("sequencer.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ( + "sequencer.reload", + {"type": 'R', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("adjust_length", True), + ], + } + ), + ("sequencer.offset_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("sequencer.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("sequencer.delete", {"type": 'X', "value": 'PRESS'}, None), + ("sequencer.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("sequencer.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.images_separate", {"type": 'Y', "value": 'PRESS'}, None), + ("sequencer.meta_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("sequencer.meta_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.meta_separate", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ("sequencer.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("sequencer.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("sequencer.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("sequencer.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ( + "sequencer.strip_jump", + {"type": 'PAGE_UP', "value": 'PRESS'}, + { + "properties": [ + ("next", True), + ("center", False), + ], + } + ), + ( + "sequencer.strip_jump", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + { + "properties": [ + ("next", False), + ("center", False), + ], + } + ), + ( + "sequencer.strip_jump", + {"type": 'PAGE_UP', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("next", True), + ("center", True), + ], + } + ), + ( + "sequencer.strip_jump", + {"type": 'PAGE_DOWN', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("next", False), + ("center", True), + ], + } + ), + ( + "sequencer.swap", + {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("side", 'LEFT'), + ], + } + ), + ( + "sequencer.swap", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("side", 'RIGHT'), + ], + } + ), + ( + "sequencer.gap_remove", + {"type": 'BACK_SPACE', "value": 'PRESS'}, + { + "properties": [ + ("all", False), + ], + } + ), + ( + "sequencer.gap_remove", + {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("all", True), + ], + } + ), + ("sequencer.gap_insert", {"type": 'EQUAL', "value": 'PRESS', "shift": True}, None), + ("sequencer.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("sequencer.swap_inputs", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ( + "sequencer.cut_multicam", + {"type": 'ONE', "value": 'PRESS'}, + { + "properties": [ + ("camera", 1), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'TWO', "value": 'PRESS'}, + { + "properties": [ + ("camera", 2), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'THREE', "value": 'PRESS'}, + { + "properties": [ + ("camera", 3), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'FOUR', "value": 'PRESS'}, + { + "properties": [ + ("camera", 4), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'FIVE', "value": 'PRESS'}, + { + "properties": [ + ("camera", 5), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'SIX', "value": 'PRESS'}, + { + "properties": [ + ("camera", 6), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'SEVEN', "value": 'PRESS'}, + { + "properties": [ + ("camera", 7), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'EIGHT', "value": 'PRESS'}, + { + "properties": [ + ("camera", 8), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'NINE', "value": 'PRESS'}, + { + "properties": [ + ("camera", 9), + ], + } + ), + ( + "sequencer.cut_multicam", + {"type": 'ZERO', "value": 'PRESS'}, + { + "properties": [ + ("camera", 10), + ], + } + ), + ( + "sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ("linked_handle", False), + ("left_right", 'NONE'), + ("linked_time", False), + ], + } + ), + ( + "sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ("linked_handle", False), + ("left_right", 'NONE'), + ("linked_time", False), + ], + } + ), + ( + "sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("extend", False), + ("linked_handle", True), + ("left_right", 'NONE'), + ("linked_time", False), + ], + } + ), + ( + "sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("extend", True), + ("linked_handle", True), + ("left_right", 'NONE'), + ("linked_time", False), + ], + } + ), + ( + "sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("extend", False), + ("linked_handle", False), + ("left_right", 'MOUSE'), + ("linked_time", True), + ], + } + ), + ( + "sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("extend", True), + ("linked_handle", False), + ("left_right", 'NONE'), + ("linked_time", True), + ], + } + ), + ("sequencer.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ( + "sequencer.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "sequencer.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ("sequencer.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("sequencer.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ( + "wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'SEQUENCER_MT_add'), + ], + } + ), + ( + "wm.call_menu", + {"type": 'C', "value": 'PRESS'}, + { + "properties": [ + ("name", 'SEQUENCER_MT_change'), + ], + } + ), + ("sequencer.slip", {"type": 'S', "value": 'PRESS'}, None), + ( + "wm.context_set_int", + {"type": 'O', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'scene.sequence_editor.overlay_frame'), + ("value", 0), + ], + } + ), + ("transform.seq_slide", {"type": 'G', "value": 'PRESS'}, None), + ("transform.seq_slide", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ( + "transform.transform", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("mode", 'TIME_EXTEND'), + ], + } + ), + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "SequencerPreview", + {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("sequencer.view_all_preview", {"type": 'HOME', "value": 'PRESS'}, None), + ("sequencer.view_all_preview", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("sequencer.view_ghost_border", {"type": 'O', "value": 'PRESS'}, None), + ( + "sequencer.view_zoom_ratio", + {"type": 'NUMPAD_1', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 1.0), + ], + } + ), + ("sequencer.sample", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Console", + {"space_type": 'CONSOLE', "region_type": 'WINDOW'}, + { + "items": [ + ( + "console.move", + {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PREVIOUS_WORD'), + ], + } + ), + ( + "console.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'NEXT_WORD'), + ], + } + ), + ( + "console.move", + {"type": 'HOME', "value": 'PRESS'}, + { + "properties": [ + ("type", 'LINE_BEGIN'), + ], + } + ), + ( + "console.move", + {"type": 'END', "value": 'PRESS'}, + { + "properties": [ + ("type", 'LINE_END'), + ], + } + ), + ( + "wm.context_cycle_int", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.font_size'), + ("reverse", False), + ], + } + ), + ( + "wm.context_cycle_int", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.font_size'), + ("reverse", True), + ], + } + ), + ( + "wm.context_cycle_int", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.font_size'), + ("reverse", False), + ], + } + ), + ( + "wm.context_cycle_int", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.font_size'), + ("reverse", True), + ], + } + ), + ( + "console.move", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "console.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_CHARACTER'), + ], + } + ), + ( + "console.history_cycle", + {"type": 'UP_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("reverse", True), + ], + } + ), + ( + "console.history_cycle", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + { + "properties": [ + ("reverse", False), + ], + } + ), + ( + "console.delete", + {"type": 'DEL', "value": 'PRESS'}, + { + "properties": [ + ("type", 'NEXT_CHARACTER'), + ], + } + ), + ( + "console.delete", + {"type": 'BACK_SPACE', "value": 'PRESS'}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "console.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("type", 'PREVIOUS_CHARACTER'), + ], + } + ), + ( + "console.delete", + {"type": 'DEL', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'NEXT_WORD'), + ], + } + ), + ( + "console.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("type", 'PREVIOUS_WORD'), + ], + } + ), + ("console.clear_line", {"type": 'RET', "value": 'PRESS', "shift": True}, None), + ("console.clear_line", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None), + ( + "console.execute", + {"type": 'RET', "value": 'PRESS'}, + { + "properties": [ + ("interactive", True), + ], + } + ), + ( + "console.execute", + {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, + { + "properties": [ + ("interactive", True), + ], + } + ), + ("console.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None), + ("console.copy_as_script", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("console.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("console.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("console.select_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("console.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ( + "console.insert", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("text", '\t'), + ], + } + ), + ("console.indent", {"type": 'TAB', "value": 'PRESS'}, None), + ("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), + ("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + ], + }, + ), + ( + "Clip", + {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("clip.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("clip.tools", {"type": 'T', "value": 'PRESS'}, None), + ("clip.properties", {"type": 'N', "value": 'PRESS'}, None), + ( + "clip.track_markers", + {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("backwards", True), + ("sequence", False), + ], + } + ), + ( + "clip.track_markers", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("backwards", False), + ("sequence", False), + ], + } + ), + ( + "clip.track_markers", + {"type": 'T', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("backwards", False), + ("sequence", True), + ], + } + ), + ( + "clip.track_markers", + {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("backwards", True), + ("sequence", True), + ], + } + ), + ( + "wm.context_toggle_enum", + {"type": 'TAB', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.mode'), + ("value_1", 'TRACKING'), + ("value_2", 'MASK'), + ], + } + ), + ("clip.solve_camera", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ( + "clip.set_solver_keyframe", + {"type": 'Q', "value": 'PRESS'}, + { + "properties": [ + ("keyframe", 'KEYFRAME_A'), + ], + } + ), + ( + "clip.set_solver_keyframe", + {"type": 'E', "value": 'PRESS'}, + { + "properties": [ + ("keyframe", 'KEYFRAME_B'), + ], + } + ), + ("clip.prefetch", {"type": 'P', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Clip Editor", + {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), + ("clip.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("clip.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("clip.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("clip.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("clip.view_zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), + ("clip.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), + ("clip.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("clip.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("ratio", 8.0), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("ratio", 4.0), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("ratio", 2.0), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("ratio", 8.0), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("ratio", 4.0), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("ratio", 2.0), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_1', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 1.0), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 0.5), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 0.25), + ], + } + ), + ( + "clip.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS'}, + { + "properties": [ + ("ratio", 0.125), + ], + } + ), + ("clip.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ( + "clip.view_all", + {"type": 'F', "value": 'PRESS'}, + { + "properties": [ + ("fit_view", True), + ], + } + ), + ("clip.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("clip.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("clip.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), + ( + "clip.frame_jump", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("position", 'PATHSTART'), + ], + } + ), + ( + "clip.frame_jump", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + { + "properties": [ + ("position", 'PATHEND'), + ], + } + ), + ( + "clip.frame_jump", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("position", 'FAILEDPREV'), + ], + } + ), + ( + "clip.frame_jump", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("position", 'PATHSTART'), + ], + } + ), + ("clip.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ( + "clip.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "clip.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "clip.select_all", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "clip.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("clip.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("clip.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ( + "wm.call_menu", + {"type": 'G', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("name", 'CLIP_MT_select_grouped'), + ], + } + ), + ( + "clip.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, + { + "properties": [ + ("deselect", False), + ], + } + ), + ( + "clip.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, + { + "properties": [ + ("deselect", True), + ], + } + ), + ("clip.add_marker_slide", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("clip.delete_marker", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), + ("clip.delete_marker", {"type": 'X', "value": 'PRESS', "shift": True}, None), + ("clip.slide_marker", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ( + "clip.disable_markers", + {"type": 'D', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ("clip.delete_track", {"type": 'DEL', "value": 'PRESS'}, None), + ("clip.delete_track", {"type": 'X', "value": 'PRESS'}, None), + ( + "clip.lock_tracks", + {"type": 'L', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'LOCK'), + ], + } + ), + ( + "clip.lock_tracks", + {"type": 'L', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("action", 'UNLOCK'), + ], + } + ), + ( + "clip.hide_tracks", + {"type": 'H', "value": 'PRESS'}, + { + "properties": [ + ("unselected", False), + ], + } + ), + ( + "clip.hide_tracks", + {"type": 'H', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("unselected", True), + ], + } + ), + ("clip.hide_tracks_clear", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("clip.slide_plane_marker", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("clip.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), + ("clip.keyframe_delete", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("clip.join_tracks", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ( + "wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + { + "properties": [ + ("name", 'CLIP_MT_tracking_specials'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.lock_selection'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'D', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'space_data.show_disabled'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'S', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("data_path", 'space_data.show_marker_search'), + ], + } + ), + ( + "wm.context_toggle", + {"type": 'M', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.use_mute_footage'), + ], + } + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ( + "clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("action", 'REMAINED'), + ("clear_active", False), + ], + } + ), + ( + "clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("action", 'UPTO'), + ("clear_active", False), + ], + } + ), + ( + "clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("action", 'ALL'), + ("clear_active", False), + ], + } + ), + ("clip.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ( + "wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'BOUNDING_BOX_CENTER'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'MEDIAN_POINT'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'CURSOR'), + ], + } + ), + ( + "wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("data_path", 'space_data.pivot_point'), + ("value", 'INDIVIDUAL_ORIGINS'), + ], + } + ), + ("clip.copy_tracks", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("clip.paste_tracks", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ( + "Clip Graph Editor", + {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ("clip.change_frame", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ( + "clip.graph_select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", False), + ], + } + ), + ( + "clip.graph_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("extend", True), + ], + } + ), + ( + "clip.graph_select_all_markers", + {"type": 'A', "value": 'PRESS'}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ( + "clip.graph_select_all_markers", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + { + "properties": [ + ("action", 'INVERT'), + ], + } + ), + ("clip.graph_select_border", {"type": 'B', "value": 'PRESS'}, None), + ("clip.graph_delete_curve", {"type": 'DEL', "value": 'PRESS'}, None), + ("clip.graph_delete_curve", {"type": 'X', "value": 'PRESS'}, None), + ("clip.graph_delete_knot", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), + ("clip.graph_delete_knot", {"type": 'X', "value": 'PRESS', "shift": True}, None), + ("clip.graph_view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("clip.graph_view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("clip.graph_center_current_frame", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ( + "wm.context_toggle", + {"type": 'L', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.lock_time_cursor'), + ], + } + ), + ( + "clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "alt": True}, + { + "properties": [ + ("action", 'REMAINED'), + ("clear_active", True), + ], + } + ), + ( + "clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("action", 'UPTO'), + ("clear_active", True), + ], + } + ), + ( + "clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, + { + "properties": [ + ("action", 'ALL'), + ("clear_active", True), + ], + } + ), + ( + "clip.graph_disable_markers", + {"type": 'D', "value": 'PRESS', "shift": True}, + { + "properties": [ + ("action", 'TOGGLE'), + ], + } + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ], + }, + ), + ( + "Clip Dopesheet Editor", + {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, + { + "items": [ + ( + "clip.dopesheet_select_channel", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + { + "properties": [ + ("extend", True), + ], + } + ), + ("clip.dopesheet_view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("clip.dopesheet_view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ], + }, + ), + ( + "3D View Tool: OBJECT, Move", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ( + "transform.translate", + {"type": 'EVT_TWEAK_A', "value": 'ANY'}, + { + "properties": [ + ("release_confirm", True), + ], + } + ), + ], + }, + ), + ( + "3D View Tool: OBJECT, Rotate", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ( + "transform.rotate", + {"type": 'EVT_TWEAK_A', "value": 'ANY'}, + { + "properties": [ + ("release_confirm", True), + ], + } + ), + ], + }, + ), + ( + "3D View Tool: OBJECT, Scale", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ( + "transform.resize", + {"type": 'EVT_TWEAK_A', "value": 'ANY'}, + { + "properties": [ + ("release_confirm", True), + ], + } + ), + ], + }, + ), + ( + "3D View Tool: OBJECT, Ruler/Protractor", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("view3d.ruler_add", {"type": 'EVT_TWEAK_A', "value": 'ANY'}, None), + ], + }, + ), + ( + "3D View Tool: PARTICLE, Cursor Click", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("view3d.cursor3d", {"type": 'ACTIONMOUSE', "value": 'CLICK'}, None), + ], + }, + ), + ( + "Spot Lamp Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Area Lamp Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ( + "Target Lamp Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + { + "items": [ + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), +] + + +if __name__ == "__main__": + import os + from bpy_extras.keyconfig_utils import keyconfig_import_from_data + keyconfig_import_from_data(os.path.splitext(os.path.basename(__file__))[0], keyconfig_data) -- cgit v1.2.3 From b5811bccf8a64129e81a96f4bcf12815eae2e032 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 7 Jul 2018 20:03:30 +0200 Subject: Correct recent keymap change, writing all keymaps --- release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py b/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py index cb483901d83..a0ea87d1c93 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py @@ -140,7 +140,7 @@ def keyconfig_export_as_data(wm, kc, filepath): keymaps = [] edited_kc = FakeKeyConfig() for km in wm.keyconfigs.user.keymaps: - if km.is_user_modified or True: + if km.is_user_modified: edited_kc.keymaps.append(km) # merge edited keymaps with non-default keyconfig, if it exists if kc != wm.keyconfigs.default: -- cgit v1.2.3 From 9d43ed521cd085b91decfcfe9a437a5faa317f14 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 12:47:13 +0200 Subject: Cleanup: abbreviate unsigned types (draw manager) --- source/blender/draw/engines/eevee/eevee_private.h | 2 +- source/blender/draw/intern/DRW_render.h | 6 ++--- source/blender/draw/intern/draw_anim_viz.c | 2 +- source/blender/draw/intern/draw_armature.c | 20 +++++++-------- source/blender/draw/intern/draw_cache.c | 12 ++++----- source/blender/draw/intern/draw_cache_impl_mesh.c | 30 +++++++++++----------- .../draw/intern/draw_cache_impl_particles.c | 14 +++++----- source/blender/draw/intern/draw_hair_private.h | 2 +- source/blender/draw/intern/draw_manager.h | 6 ++--- source/blender/draw/intern/draw_manager_text.c | 4 +-- source/blender/draw/intern/draw_manager_text.h | 2 +- source/blender/draw/intern/draw_view.c | 16 ++++++------ source/blender/draw/modes/edit_mesh_mode_text.c | 2 +- source/blender/draw/modes/object_mode.c | 2 +- 14 files changed, 60 insertions(+), 60 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index e9ba6585943..fe01b85758c 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -332,7 +332,7 @@ typedef struct EEVEE_ShadowRender { /* This is just a really long bitflag with special function to access it. */ #define MAX_LIGHTBITS_FIELDS (MAX_LIGHT / 8) typedef struct EEVEE_LightBits { - unsigned char fields[MAX_LIGHTBITS_FIELDS]; + uchar fields[MAX_LIGHTBITS_FIELDS]; } EEVEE_LightBits; typedef struct EEVEE_ShadowCaster { diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index fdb1b87589e..0d443293d04 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -346,9 +346,9 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup); void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]); void DRW_shgroup_call_range_add( DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count); -void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, unsigned int point_count, float (*obmat)[4]); -void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, unsigned int line_count, float (*obmat)[4]); -void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, unsigned int tria_count, float (*obmat)[4]); +void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_count, float (*obmat)[4]); +void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]); +void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]); void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, struct Object *ob); void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, bool bypass_culling); #define DRW_shgroup_call_object_add(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, false) diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c index d19bd54ff5f..e634710980a 100644 --- a/source/blender/draw/intern/draw_anim_viz.c +++ b/source/blender/draw/intern/draw_anim_viz.c @@ -256,7 +256,7 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl, bool show_kf_no = (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) != 0; if ((avs->path_viewflag & (MOTIONPATH_VIEW_FNUMS)) || (show_kf_no && show_keyframes)) { int i; - unsigned char col[4], col_kf[4]; + uchar col[4], col_kf[4]; UI_GetThemeColor3ubv(TH_TEXT_HI, col); UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col_kf); col[3] = col_kf[3] = 255; diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index 3faf8a352b2..9bc8b70b67c 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -514,7 +514,7 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan) } /* This function is for brightening/darkening a given color (like UI_GetThemeColorShade3ubv()) */ -static void cp_shade_color3ub(unsigned char cp[3], const int offset) +static void cp_shade_color3ub(uchar cp[3], const int offset) { int r, g, b; @@ -549,7 +549,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const case PCHAN_COLOR_NORMAL: { if (bcolor) { - unsigned char cp[4] = {255}; + uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { copy_v3_v3_char((char *)cp, bcolor->active); @@ -591,7 +591,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const if (bcolor) { float solid_bcolor[3]; - rgb_uchar_to_float(solid_bcolor, (unsigned char *)bcolor->solid); + rgb_uchar_to_float(solid_bcolor, (uchar *)bcolor->solid); interp_v3_v3v3(fcolor, fcolor, solid_bcolor, 1.0f); } @@ -600,7 +600,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const case PCHAN_COLOR_CONSTS: { if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { - unsigned char cp[4]; + uchar cp[4]; if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 80); else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 80); else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 80); @@ -618,7 +618,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const case PCHAN_COLOR_SPHEREBONE_BASE: { if (bcolor) { - unsigned char cp[4] = {255}; + uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { copy_v3_v3_char((char *)cp, bcolor->active); @@ -649,7 +649,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const case PCHAN_COLOR_SPHEREBONE_END: { if (bcolor) { - unsigned char cp[4] = {255}; + uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { copy_v3_v3_char((char *)cp, bcolor->active); @@ -683,7 +683,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const { /* inner part in background color or constraint */ if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) { - unsigned char cp[4]; + uchar cp[4]; if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 255); else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 255); else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 255); @@ -695,7 +695,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const else { if (bcolor) { const char *cp = bcolor->solid; - rgb_uchar_to_float(fcolor, (unsigned char *)cp); + rgb_uchar_to_float(fcolor, (uchar *)cp); fcolor[3] = 204.f / 255.f; } else { @@ -1588,7 +1588,7 @@ static void draw_armature_edit(Object *ob) /* Draw names of bone */ if (show_text && (arm->flag & ARM_DRAWNAMES)) { - unsigned char color[4]; + uchar color[4]; UI_GetThemeColor4ubv((eBone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, color); float vec[3]; @@ -1702,7 +1702,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4]) /* Draw names of bone */ if (show_text && (arm->flag & ARM_DRAWNAMES)) { - unsigned char color[4]; + uchar color[4]; UI_GetThemeColor4ubv((arm->flag & ARM_POSEMODE) && (bone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, color); float vec[3]; diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index a8d2c2a3642..a6a0472fe86 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2985,7 +2985,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) case PART_DRAW_CROSS: if (!SHC.drw_particle_cross) { static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, axis_id; + static uint pos_id, axis_id; if (format.attrib_ct == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -3032,7 +3032,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) case PART_DRAW_AXIS: if (!SHC.drw_particle_axis) { static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, axis_id; + static uint pos_id, axis_id; if (format.attrib_ct == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -3083,7 +3083,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) int axis = -1; static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, axis_id; + static uint pos_id, axis_id; if (format.attrib_ct == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -3128,8 +3128,8 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) const int vert_ct = segments + 8; const int index_ct = vert_ct + 5; - unsigned char red[3] = {255, 0, 0}; - unsigned char white[3] = {255, 255, 255}; + uchar red[3] = {255, 0, 0}; + uchar white[3] = {255, 255, 255}; static Gwn_VertFormat format = { 0 }; static struct { uint pos, color; } attr_id; @@ -3161,7 +3161,7 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) GWN_indexbuf_add_generic_vert(&elb, 0); if (crosshair_lines) { - unsigned char crosshair_color[3]; + uchar crosshair_color[3]; UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color); GWN_indexbuf_add_primitive_restart(&elb); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index eafcfb007e7..198518cd887 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -116,10 +116,10 @@ typedef struct EdgeAdjacentVerts { } EdgeAdjacentVerts; typedef struct EdgeDrawAttr { - unsigned char v_flag; - unsigned char e_flag; - unsigned char crease; - unsigned char bweight; + uchar v_flag; + uchar e_flag; + uchar crease; + uchar bweight; } EdgeDrawAttr; typedef struct MeshRenderData { @@ -1349,9 +1349,9 @@ enum { * (see gpu_shader_edit_mesh_overlay_geom.glsl) */ }; -static unsigned char mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace *efa) +static uchar mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace *efa) { - unsigned char fflag = 0; + uchar fflag = 0; if (efa == rdata->efa_act) fflag |= VFLAG_FACE_ACTIVE; @@ -1397,10 +1397,10 @@ static void mesh_render_data_edge_flag( } } -static unsigned char mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *eve) +static uchar mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *eve) { - unsigned char vflag = 0; + uchar vflag = 0; /* Current vertex */ if (eve == rdata->eve_act) @@ -1417,8 +1417,8 @@ static void add_overlay_tri( const uint pos_id, const uint vnor_id, const uint lnor_id, const uint data_id, const BMLoop **bm_looptri, const int base_vert_idx) { - unsigned char fflag; - unsigned char vflag; + uchar fflag; + uchar vflag; if (vbo_pos) { /* TODO(sybren): deduplicate this and all the other places it's pasted to in this file. */ @@ -1528,7 +1528,7 @@ static void add_overlay_loose_vert( } if (vbo_data) { - unsigned char vflag[4] = {0, 0, 0, 0}; + uchar vflag[4] = {0, 0, 0, 0}; vflag[0] = mesh_render_data_vertex_flag(rdata, eve); GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx, vflag); } @@ -2886,7 +2886,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( static Gwn_VertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id) { static Gwn_VertFormat format_pos = { 0 }; - static unsigned pos_id; + static uint pos_id; if (format_pos.attrib_ct == 0) { pos_id = GWN_vertformat_attr_add(&format_pos, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2898,7 +2898,7 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno { static Gwn_VertFormat format_nor = { 0 }; static Gwn_VertFormat format_nor_loop = { 0 }; - static unsigned vnor_id, vnor_loop_id, lnor_id; + static uint vnor_id, vnor_loop_id, lnor_id; if (format_nor.attrib_ct == 0) { vnor_id = GWN_vertformat_attr_add(&format_nor, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); vnor_loop_id = GWN_vertformat_attr_add(&format_nor_loop, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); @@ -2918,7 +2918,7 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno static Gwn_VertFormat *edit_mesh_overlay_data_format(uint *r_data_id) { static Gwn_VertFormat format_flag = { 0 }; - static unsigned data_id; + static uint data_id; if (format_flag.attrib_ct == 0) { data_id = GWN_vertformat_attr_add(&format_flag, "data", GWN_COMP_U8, 4, GWN_FETCH_INT); } @@ -3420,7 +3420,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender int j, j_next; for (j = 2, j_next = 0; j_next < 3; j = j_next++) { MEdge *ed = &medge[mloop[mlt->tri[j]].e]; - unsigned int tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v}; + uint tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v}; if (((ed->v1 == tri_edge[0]) && (ed->v2 == tri_edge[1])) || ((ed->v1 == tri_edge[1]) && (ed->v2 == tri_edge[0]))) diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 28693b47c89..3cf47fb5e25 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -263,7 +263,7 @@ static void ensure_seg_pt_count( } } -static void particle_pack_mcol(MCol *mcol, unsigned short r_scol[3]) +static void particle_pack_mcol(MCol *mcol, ushort r_scol[3]) { /* Convert to linear ushort and swizzle */ r_scol[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mcol->b]); @@ -573,7 +573,7 @@ static int particle_batch_cache_fill_segments( } for (int k = 0; k < num_col_layers; k++) { /* TODO Put the conversion outside the loop */ - unsigned short scol[4]; + ushort scol[4]; particle_pack_mcol( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], @@ -600,7 +600,7 @@ static int particle_batch_cache_fill_segments( } for (int k = 0; k < num_col_layers; k++) { /* TODO Put the conversion outside the loop */ - unsigned short scol[4]; + ushort scol[4]; particle_pack_mcol( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], @@ -734,7 +734,7 @@ static int particle_batch_cache_fill_strands_data( copy_v2_v2(t_uv, uv[k]); } for (int k = 0; k < num_col_layers; k++) { - unsigned short *scol = (unsigned short *)GWN_vertbuf_raw_step(col_step + k); + ushort *scol = (ushort *)GWN_vertbuf_raw_step(col_step + k); particle_pack_mcol( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], @@ -1196,7 +1196,7 @@ static void particle_batch_cache_ensure_pos( } static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, rot_id, val_id; + static uint pos_id, rot_id, val_id; int i, curr_point; ParticleData *pa; ParticleKey state; @@ -1420,7 +1420,7 @@ static void particle_batch_cache_ensure_edit_inner_pos( } static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, color_id; + static uint pos_id, color_id; GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); @@ -1491,7 +1491,7 @@ static void particle_batch_cache_ensure_edit_tip_pos( } static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, color_id; + static uint pos_id, color_id; GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h index 2e6c9a0d3c1..28993614688 100644 --- a/source/blender/draw/intern/draw_hair_private.h +++ b/source/blender/draw/intern/draw_hair_private.h @@ -31,7 +31,7 @@ #define __DRAW_HAIR_PRIVATE_H__ #define MAX_LAYER_NAME_CT 3 /* u0123456789, u, a0123456789 */ -#define MAX_LAYER_NAME_LEN DECIMAL_DIGITS_BOUND(unsigned int) + 2 +#define MAX_LAYER_NAME_LEN DECIMAL_DIGITS_BOUND(uint) + 2 #define MAX_THICKRES 2 /* see eHairType */ #define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */ diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index e811e9ea8a9..91a30fa45ae 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -106,8 +106,8 @@ typedef struct DRWCallState { DRWCallVisibilityFn *visibility_cb; void *user_data; - unsigned char flag; - unsigned char cache_id; /* Compared with DST.state_cache_id to see if matrices are still valid. */ + uchar flag; + uchar cache_id; /* Compared with DST.state_cache_id to see if matrices are still valid. */ uint16_t matflag; /* Which matrices to compute. */ /* Culling: Using Bounding Sphere for now for faster culling. * Not ideal for planes. */ @@ -308,7 +308,7 @@ typedef struct DRWManager { DRWInstanceData *object_instance_data[MAX_INSTANCE_DATA_SIZE]; /* State of the object being evaluated if already allocated. */ DRWCallState *ob_state; - unsigned char state_cache_id; /* Could be larger but 254 view changes is already a lot! */ + uchar state_cache_id; /* Could be larger but 254 view changes is already a lot! */ /* Rendering state */ GPUShader *shader; diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c index 1f385b958b8..977374a00c5 100644 --- a/source/blender/draw/intern/draw_manager_text.c +++ b/source/blender/draw/intern/draw_manager_text.c @@ -46,7 +46,7 @@ typedef struct ViewCachedString { struct ViewCachedString *next, *prev; float vec[3]; union { - unsigned char ub[4]; + uchar ub[4]; int pack; } col; short sco[2]; @@ -79,7 +79,7 @@ void DRW_text_cache_add( const float co[3], const char *str, const int str_len, short xoffs, short flag, - const unsigned char col[4]) + const uchar col[4]) { int alloc_len; ViewCachedString *vos; diff --git a/source/blender/draw/intern/draw_manager_text.h b/source/blender/draw/intern/draw_manager_text.h index a675a200924..14c33be4cf8 100644 --- a/source/blender/draw/intern/draw_manager_text.h +++ b/source/blender/draw/intern/draw_manager_text.h @@ -34,7 +34,7 @@ void DRW_text_cache_add( const float co[3], const char *str, const int str_len, short xoffs, short flag, - const unsigned char col[4]); + const uchar col[4]); void DRW_text_cache_draw(struct DRWTextStore *dt, struct ARegion *ar); diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 347932619b9..cab796a62d3 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -116,7 +116,7 @@ static int gridline_count(ARegion *ar, double x0, double y0, double dx) static bool drawgrid_draw( ARegion *ar, double x0, double y0, double dx, int skip_mod, - unsigned pos, unsigned col, GLubyte col_value[3]) + uint pos, uint col, GLubyte col_value[3]) { /* skip every skip_mod lines relative to each axis; they will be overlaid by another drawgrid_draw * always skip exact x0 & y0 axes; they will be drawn later in color @@ -220,7 +220,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - unsigned char col[3], col2[3]; + uchar col[3], col2[3]; UI_GetThemeColor3ubv(TH_GRID, col); if (unit->system) { @@ -369,17 +369,17 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) bool show_axis_y = (v3d->gridflag & V3D_SHOW_Y) != 0; bool show_axis_z = (v3d->gridflag & V3D_SHOW_Z) != 0; - unsigned char col_grid[3], col_axis[3]; + uchar col_grid[3], col_axis[3]; glLineWidth(1.0f); UI_GetThemeColor3ubv(TH_GRID, col_grid); if (show_floor) { - const unsigned vertex_ct = 2 * (gridlines * 4 + 2); + const uint vertex_ct = 2 * (gridlines * 4 + 2); const int sublines = v3d->gridsubdiv; - unsigned char col_bg[3], col_grid_emphasise[3], col_grid_light[3]; + uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3]; Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -583,9 +583,9 @@ void DRW_draw_background(void) glDisable(GL_DEPTH_TEST); Gwn_VertFormat *format = immVertexFormat(); - unsigned pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - unsigned char col_hi[3], col_lo[3]; + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + uchar col_hi[3], col_lo[3]; gpuPushMatrix(); gpuLoadIdentity(); diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c index def96e79eba..56a015d0e6b 100644 --- a/source/blender/draw/modes/edit_mesh_mode_text.c +++ b/source/blender/draw/modes/edit_mesh_mode_text.c @@ -63,7 +63,7 @@ void DRW_edit_mesh_mode_text_measure_stats( char numstr[32]; /* Stores the measurement display text here */ size_t numstr_len; const char *conv_float; /* Use a float conversion matching the grid size */ - unsigned char col[4] = {0, 0, 0, 255}; /* color of the text to draw */ + uchar col[4] = {0, 0, 0, 255}; /* color of the text to draw */ float area; /* area of the face */ float grid = unit->system ? unit->scale_length : v3d->grid; const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 17e4a7b15ce..da44d9d8c0b 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2272,7 +2272,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if ((ob->dtx & OB_DRAWNAME) && DRW_state_show_text()) { struct DRWTextStore *dt = DRW_text_cache_ensure(); - unsigned char color[4]; + uchar color[4]; UI_GetThemeColor4ubv(theme_id, color); DRW_text_cache_add( -- cgit v1.2.3 From 6d72d3c862d321c5d7dfd10483c504e4fa50766f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 12:48:04 +0200 Subject: Cleanup: abbreviate unsigned types (editors, wm) --- .../editors/animation/anim_channels_defines.c | 10 +-- source/blender/editors/animation/anim_draw.c | 6 +- source/blender/editors/animation/anim_markers.c | 2 +- source/blender/editors/animation/keyframes_draw.c | 12 ++-- source/blender/editors/curve/editcurve_paint.c | 2 +- source/blender/editors/gpencil/drawgpencil.c | 44 ++++++------ source/blender/editors/gpencil/gpencil_brush.c | 2 +- source/blender/editors/interface/interface_draw.c | 78 +++++++++++----------- source/blender/editors/interface/interface_icons.c | 12 ++-- source/blender/editors/interface/interface_panel.c | 10 +-- .../blender/editors/interface/interface_widgets.c | 32 ++++----- source/blender/editors/interface/view2d.c | 12 ++-- source/blender/editors/mask/mask_draw.c | 8 +-- source/blender/editors/mesh/editmesh_knife.c | 4 +- source/blender/editors/mesh/editmesh_loopcut.c | 2 +- source/blender/editors/physics/particle_edit.c | 2 +- source/blender/editors/screen/area.c | 22 +++--- source/blender/editors/screen/screen_draw.c | 10 +-- source/blender/editors/sculpt_paint/paint_cursor.c | 12 ++-- source/blender/editors/sculpt_paint/paint_image.c | 2 +- source/blender/editors/sculpt_paint/paint_stroke.c | 2 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 2 +- source/blender/editors/space_action/action_draw.c | 4 +- .../editors/space_clip/clip_dopesheet_draw.c | 10 +-- source/blender/editors/space_clip/clip_draw.c | 14 ++-- .../blender/editors/space_clip/clip_graph_draw.c | 2 +- source/blender/editors/space_clip/clip_utils.c | 2 +- .../blender/editors/space_console/console_draw.c | 2 +- source/blender/editors/space_file/file_draw.c | 8 +-- source/blender/editors/space_graph/graph_draw.c | 8 +-- source/blender/editors/space_graph/space_graph.c | 2 +- source/blender/editors/space_image/image_draw.c | 8 +-- source/blender/editors/space_info/textview.c | 6 +- source/blender/editors/space_nla/nla_draw.c | 10 +-- source/blender/editors/space_node/drawnode.c | 14 ++-- source/blender/editors/space_node/node_draw.c | 10 +-- .../blender/editors/space_outliner/outliner_draw.c | 18 ++--- .../editors/space_sequencer/sequencer_draw.c | 16 ++--- source/blender/editors/space_text/text_draw.c | 12 ++-- source/blender/editors/space_view3d/drawobject.c | 2 +- source/blender/editors/space_view3d/view3d_draw.c | 8 +-- source/blender/editors/space_view3d/view3d_fly.c | 2 +- .../space_view3d/view3d_manipulator_ruler.c | 2 +- source/blender/editors/space_view3d/view3d_ruler.c | 2 +- source/blender/editors/space_view3d/view3d_walk.c | 2 +- source/blender/editors/transform/transform.c | 4 +- .../editors/transform/transform_constraints.c | 2 +- .../blender/editors/transform/transform_generics.c | 2 +- source/blender/editors/transform/transform_snap.c | 4 +- source/blender/editors/uvedit/uvedit_draw.c | 12 ++-- source/blender/gpu/intern/gpu_immediate_util.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 6 +- source/blender/windowmanager/intern/wm_playanim.c | 2 +- source/blender/windowmanager/intern/wm_stereo.c | 12 ++-- 54 files changed, 249 insertions(+), 249 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 5bbaabcc6bc..c70790e0550 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -146,7 +146,7 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); @@ -235,7 +235,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); @@ -3868,7 +3868,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* for F-Curves, draw color-preview of curve behind checkbox */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = (FCurve *)ale->data; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -3924,7 +3924,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* draw red underline if channel is disabled */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -3952,7 +3952,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float short draw_sliders = 0; float ymin_ofs = 0.0f; float color[3]; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 953898a0586..51ba7d9c269 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -142,7 +142,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) GPU_line_width((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -171,7 +171,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_ANIM_ACTIVE, -25, -30); @@ -204,7 +204,7 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d) GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -25, -100); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 5f03704f9f5..c5f7782dcee 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -486,7 +486,7 @@ void ED_markers_draw(const bContext *C, int flag) v2d = UI_view2d_fromcontext(C); if (flag & DRAW_MARKERS_MARGIN) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); const unsigned char shade[4] = {0, 0, 0, 16}; diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index fcccf07190b..e06c443e8f0 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -594,8 +594,8 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa if (block_ct > 0) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBegin(GWN_PRIM_TRIS, 6 * block_ct); @@ -634,10 +634,10 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa if (key_ct > 0) { /* draw keys */ Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); immBegin(GWN_PRIM_POINTS, key_ct); diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 5e3fec93340..ce72a5ffc9f 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -430,7 +430,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); GPU_depth_test(false); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index a79a5052eb8..ec4310213ef 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -151,8 +151,8 @@ static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, f /* draw triangulation data */ if (tot_triangles > 0) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -209,8 +209,8 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short } Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); const tGPspoint *pt = points; @@ -320,9 +320,9 @@ static void gp_draw_stroke_volumetric_buffer(const tGPspoint *points, int totpoi return; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); @@ -347,9 +347,9 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points, int totpoints const float diff_mat[4][4], const float ink[4]) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); @@ -380,9 +380,9 @@ static void gp_draw_stroke_volumetric_3d( const float ink[4]) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); @@ -517,7 +517,7 @@ static void gp_draw_stroke_fill( } BLI_assert(gps->tot_triangles >= 1); - unsigned int pos; + uint pos; if (gps->flag & GP_STROKE_3DSPACE) { pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -576,7 +576,7 @@ static void gp_draw_stroke_point( mul_v3_m4v3(fpt, diff_mat, &pt->x); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); if (sflag & GP_STROKE_3DSPACE) { immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); @@ -618,8 +618,8 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR); @@ -717,8 +717,8 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, int totpoints, short thi float fpt[3]; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBegin(GWN_PRIM_TRI_STRIP, totpoints * 2 + 4); @@ -1151,9 +1151,9 @@ static void gp_draw_strokes_edit( selectColor[3] = alpha; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos; /* specified later */ - unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos; /* specified later */ + uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); if (gps->flag & GP_STROKE_3DSPACE) { pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 75e4c510bcf..0ddd8700c09 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -986,7 +986,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda if (brush) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_smooth(true); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index c336c48f62a..336b996f169 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -159,7 +159,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float int a; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); /* mult */ for (a = 0; a < 7; a++) { @@ -280,8 +280,8 @@ void UI_draw_roundbox_shade_x( int a; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -432,8 +432,8 @@ void UI_draw_roundbox_shade_y( } Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -535,7 +535,7 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo int ofs_y = 4 * U.pixelsize; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); @@ -550,8 +550,8 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highlight[3], unsigned char highlight_fade[3]) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); /* add a 1px offset, looks nicer */ const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - U.pixelsize; const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize; @@ -818,7 +818,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS (rect.ymax + 1) - (rect.ymin - 1)); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -869,7 +869,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS static void waveform_draw_one(float *waveform, int nbr, const float col[3]) { Gwn_VertFormat format = {0}; - unsigned int pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); GWN_vertbuf_data_alloc(vbo, nbr); @@ -957,7 +957,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1215,7 +1215,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN (rect.ymax + 1) - (rect.ymin - 1)); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1404,7 +1404,7 @@ static void ui_draw_colorband_handle( void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *rect) { struct ColorManagedDisplay *display = NULL; - unsigned int position, color; + uint pos_id, col_id; ColorBand *coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin); if (coba == NULL) return; @@ -1419,20 +1419,20 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti float y1 = rect->ymin; Gwn_VertFormat *format = immVertexFormat(); - position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); /* Drawing the checkerboard. */ immUniform4f("color1", UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_DARK / 255.0f, 1.0f); immUniform4f("color2", UI_ALPHA_CHECKER_LIGHT / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 1.0f); immUniform1i("size", 8); - immRectf(position, x1, y1, x1 + sizex, rect->ymax); + immRectf(pos_id, x1, y1, x1 + sizex, rect->ymax); immUnbindProgram(); /* New format */ format = immVertexFormat(); - position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + col_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); /* layer: color ramp */ @@ -1455,9 +1455,9 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti v1[0] = v2[0] = x1 + a; - immAttrib4fv(color, colf); - immVertex2fv(position, v1); - immVertex2fv(position, v2); + immAttrib4fv(col_id, colf); + immVertex2fv(pos_id, v1); + immVertex2fv(pos_id, v2); } immEnd(); @@ -1474,9 +1474,9 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti v1[0] = v2[0] = x1 + a; - immAttrib4f(color, colf[0], colf[1], colf[2], 1.0f); - immVertex2fv(position, v1); - immVertex2fv(position, v2); + immAttrib4f(col_id, colf[0], colf[1], colf[2], 1.0f); + immVertex2fv(pos_id, v1); + immVertex2fv(pos_id, v2); } immEnd(); @@ -1486,27 +1486,27 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti /* New format */ format = immVertexFormat(); - position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* layer: box outline */ immUniformColor4f(0.0f, 0.0f, 0.0f, 1.0f); - imm_draw_box_wire_2d(position, x1, y1, x1 + sizex, rect->ymax); + imm_draw_box_wire_2d(pos_id, x1, y1, x1 + sizex, rect->ymax); /* layer: box outline */ GPU_blend(true); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); immBegin(GWN_PRIM_LINES, 2); - immVertex2f(position, x1, y1); - immVertex2f(position, x1 + sizex, y1); + immVertex2f(pos_id, x1, y1); + immVertex2f(pos_id, x1 + sizex, y1); immEnd(); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f); immBegin(GWN_PRIM_LINES, 2); - immVertex2f(position, x1, y1 - 1); - immVertex2f(position, x1 + sizex, y1 - 1); + immVertex2f(pos_id, x1, y1 - 1); + immVertex2f(pos_id, x1 + sizex, y1 - 1); immEnd(); GPU_blend(false); @@ -1515,7 +1515,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti for (int a = 0; a < coba->tot; a++, cbd++) { if (a != coba->cur) { float pos = x1 + cbd->pos * (sizex - 1) + 1; - ui_draw_colorband_handle(position, rect, pos, &cbd->r, display, false); + ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, false); } } @@ -1523,7 +1523,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti if (coba->tot != 0) { cbd = &coba->data[coba->cur]; float pos = x1 + cbd->pos * (sizex - 1) + 1; - ui_draw_colorband_handle(position, rect, pos, &cbd->r, display, true); + ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, true); } immUnbindProgram(); @@ -1568,7 +1568,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) /* AA circle */ Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv((unsigned char *)wcol->inner); @@ -1675,7 +1675,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti GPU_line_width(1.0f); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* backdrop */ @@ -1807,7 +1807,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* the points, use aspect to make them visible on edges */ format = immVertexFormat(); pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); cmp = cuma->curve; @@ -1926,8 +1926,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U BLI_rctf_size_y(&rect)); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel); @@ -2018,7 +2018,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol float y = 0.5f * (recti->ymin + recti->ymax); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(but->col); @@ -2115,8 +2115,8 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 4748ff3310a..92178e58a58 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -241,7 +241,7 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float viconutil_set_point(pts[1], cx - d2, cy - d); viconutil_set_point(pts[2], cx + d2, cy); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.2f, 0.2f, 0.2f, alpha); @@ -272,10 +272,10 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, int yco = y + h / 2; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); @@ -334,7 +334,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU const int b = x + w / 3 * 2; const int c = x + w; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* XXX: Include alpha into this... */ diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index b930b39ba02..ccb025d534f 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -678,7 +678,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con titlerect.xmin += 5.0f / block->aspect; } - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (!is_subpanel) { @@ -753,7 +753,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con ui_draw_aligned_panel_header(style, block, &titlerect, 'h'); if (show_drag) { - unsigned int col; + uint col; Gwn_VertFormat *format = immVertexFormat(); pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); @@ -1730,8 +1730,8 @@ static void ui_panel_category_draw_tab( int a; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); /* mult */ for (a = 0; a < 4; a++) { @@ -1958,7 +1958,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* begin drawing */ GPU_line_smooth(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw the background */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 4e15737c3e5..cfbf6e711c3 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -512,7 +512,7 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(draw_color); @@ -555,7 +555,7 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(draw_color); @@ -1835,7 +1835,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->item); @@ -1871,7 +1871,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b UI_widgetbase_draw_cache_flush(); GPU_blend(false); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(0.2f, 0.6f, 0.9f); @@ -2422,7 +2422,7 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r /* we draw a number of increasing size alpha quad strips */ alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2474,7 +2474,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir static void ui_hsv_cursor(float x, float y) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2571,8 +2571,8 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -2682,8 +2682,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons /* old below */ Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); immBegin(GWN_PRIM_TRIS, steps * 3 * 6); @@ -2842,7 +2842,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) ui_hsv_cursor(x, y); /* outline */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(0, 0, 0); imm_draw_box_wire_2d(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); @@ -2939,7 +2939,7 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol) 30 }; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_blend(true); @@ -3401,7 +3401,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat UI_widgetbase_draw_cache_flush(); GPU_blend(false); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(bw, bw, bw); @@ -3782,7 +3782,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * /* note: drawextra can change rect +1 or -1, to match round errors of existing previews */ but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* make mask to draw over image */ @@ -4419,7 +4419,7 @@ static void ui_draw_popover_back_impl( /* Draw popover arrow (top/bottom) */ if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->inner); GPU_blend(true); @@ -4556,7 +4556,7 @@ void ui_draw_pie_center(uiBlock *block) } Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)btheme->tui.wcol_pie_menu.outline); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index fc282e50ce2..bf768f26a93 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1340,8 +1340,8 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) return; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBegin(GWN_PRIM_LINES, vertex_count); @@ -1482,8 +1482,8 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) if (count_x > 0 || count_y > 0) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); float theme_color[3]; UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color); @@ -1533,8 +1533,8 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); GPU_line_width(1.0f); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 6b5fce26deb..baeaeb018d7 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -125,7 +125,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin } Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff}; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -213,7 +213,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline mask_spline_color_get(masklay, spline, is_spline_sel, rgb_spline); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); immUniform1f("size", 0.7f * handle_size); @@ -403,7 +403,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* } Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); switch (draw_type) { @@ -747,7 +747,7 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra unsigned int num_lines = BLI_listbase_count(&masklay->splines_shapes); if (num_lines > 0) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 175, 0, 255); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 8f8400e2d20..8a9a5eadbdd 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1007,7 +1007,7 @@ static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd) copy_v3_v3(v2, ray_hit_best[1]); } - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_TRANSFORM); @@ -1048,7 +1048,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void gpuPushMatrix(); gpuMultMatrix(kcd->ob->obmat); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index b437bdca111..87c006095ed 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -116,7 +116,7 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a gpuPushMatrix(); gpuMultMatrix(lcd->ob->obmat); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ub(255, 0, 255); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index a08e35d08a7..10d9c90aeb3 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2892,7 +2892,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) brush = &pset->brush[pset->brushtype]; if (brush) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 255, 255, 128); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 77e178bf0b2..137fd01a146 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -106,7 +106,7 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides) UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); @@ -263,7 +263,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -296,7 +296,7 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) float pad = 0.2f * U.widget_unit; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); GPU_blend(true); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -501,7 +501,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) #if 0 GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(drand48(), drand48(), drand48(), 0.1f); immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin, @@ -2473,7 +2473,7 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(fill_color); immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1); @@ -2692,7 +2692,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y); /* draw top box */ Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_METADATA_BG); immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -2717,7 +2717,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin); /* draw top box */ Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_METADATA_BG); immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -2746,7 +2746,7 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) UI_view2d_view_to_region(&ar->v2d, 1.0f, 1.0f, &x2, &y2); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, 20); @@ -2877,7 +2877,7 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect) void ED_region_cache_draw_background(const ARegion *ar) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(128, 128, 255, 64); immRecti(pos, 0, 0, ar->winx, 8 * UI_DPI_FAC); @@ -2897,7 +2897,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_CFRAME); immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); @@ -2911,7 +2911,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segments, const int *points, const int sfra, const int efra) { if (num_segments) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(128, 128, 255, 128); diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index b5b0d16f6a7..9c46938a90f 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -323,7 +323,7 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) /* Wrap up the corners with a nice embossing. */ rcti rect = sa->totrct; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); @@ -439,7 +439,7 @@ void ED_screen_draw_edges(wmWindow *win) ScrArea *sa; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* Note: first loop only draws if U.pixelsize > 1, skip otherwise */ @@ -477,7 +477,7 @@ void ED_screen_draw_edges(wmWindow *win) */ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_width(1); @@ -518,7 +518,7 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* splitpoint */ @@ -594,7 +594,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2 const float ofs_between_areas) { const float ofs_h = ofs_between_areas * 0.5f; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 815bcd8a050..6b3c358d2ac 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -681,8 +681,8 @@ static void paint_draw_tex_overlay( /* set quad color. Colored overlay does not get blending */ Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); if (col) { immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); @@ -770,8 +770,8 @@ static void paint_draw_cursor_overlay( } Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); @@ -930,7 +930,7 @@ static void paint_draw_curve_cursor(Brush *brush) GPU_blend(true); /* draw the bezier handles and the curve segment between the current and next point */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1118,7 +1118,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) GPU_blend(true); /* TODO: also set blend mode? */ GPU_line_smooth(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* set brush color */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 7f71270c52d..6276a2838f5 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -420,7 +420,7 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 8db78a41252..0ef25eb63a1 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -155,7 +155,7 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata ARegion *ar = stroke->vc.ar; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(paint->paint_cursor_col); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 29b258fc80d..a0ef753e200 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -215,7 +215,7 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN); } - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fvAlpha(brush->add_col, alpha); diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 6105652a4c7..8e521c997fd 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -212,7 +212,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) y = (float)(-ACHANNEL_HEIGHT(ac)); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -404,7 +404,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* iterate over pointcaches on the active object, and draw each one's range */ diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index d50d10d5cc3..60a8c77bcc4 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -131,7 +131,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) unsigned int keyframe_ct = 0; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* don't use totrect set, as the width stays the same @@ -216,9 +216,9 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) /* draw keyframe markers */ format = immVertexFormat(); pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); @@ -316,7 +316,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) float y = (float) CHANNEL_FIRST; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 909f0a55c1c..164565192fd 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -167,7 +167,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points); ED_region_cache_draw_cached_segments(ar, totseg, points, sfra, efra); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* track */ @@ -290,7 +290,7 @@ static void draw_movieclip_muted(ARegion *ar, int width, int height, float zoomx { int x, y; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* find window pixel coordinates of origin */ @@ -452,7 +452,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin i++; } - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1145,8 +1145,8 @@ static void draw_plane_marker_image(Scene *scene, gpuMultMatrix(gl_matrix); Gwn_VertFormat *imm_format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, plane_track->image_opacity); @@ -1414,7 +1414,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie } } - unsigned int position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1598,7 +1598,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, gpuMultMatrix(sc->stabmat); gpuScale2f(width, height); - unsigned int position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index d463f585470..34720b3a627 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -328,7 +328,7 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) UI_view2d_grid_free(grid); if (clip) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_point_size(3.0f); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index c3208260b3b..c94853d4233 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -273,7 +273,7 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 66b203ff612..0ffbe451042 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -159,7 +159,7 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN}; int pen[2]; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); xy[1] += tvc->lheight / 6; console_cursor_wrap_offset(sc->prompt, tvc->console_width, &offl, &offc, NULL); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 4d4845c41b9..0416ecba72c 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -403,7 +403,7 @@ static void file_draw_preview( /* border */ if (use_dropshadow) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); @@ -466,7 +466,7 @@ static void draw_background(FileLayout *layout, View2D *v2d) int i; int sy; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, -7); @@ -504,8 +504,8 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) v2[1] = v2d->cur.ymin; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBegin(GWN_PRIM_LINES, vertex_ct); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 4e9f8cd3733..16658c0d8db 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -286,7 +286,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users) */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); GPU_blend(true); GPU_enable_program_point_size(); @@ -331,8 +331,8 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) int sel, b; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBeginAtMost(GWN_PRIM_LINES, 4 * 2 * fcu->totvert); @@ -459,7 +459,7 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu) if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) GPU_line_smooth(true); GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor((fcu->flag & FCURVE_SELECTED) ? TH_TEXT_HI : TH_TEXT); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index c94f2b00db2..699dc29ff47 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -279,7 +279,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_grid_free(grid); if (((sipo->flag & SIPO_NODRAWCURSOR) == 0) || (sipo->mode == SIPO_MODE_DRIVERS)) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index f70efa00244..24b02106021 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -127,7 +127,7 @@ static void draw_render_info(const bContext *C, (int)(-rd->border.ymin * rd->ysch * rd->size * 0.01f)); } - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_FACE_SELECT); @@ -174,7 +174,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* noisy, high contrast make impossible to read if lower alpha is used. */ @@ -574,7 +574,7 @@ void draw_image_sample_line(SpaceImage *sima) Histogram *hist = &sima->sample_line_hist; Gwn_VertFormat *format = immVertexFormat(); - unsigned int shdr_dashed_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_dashed_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -779,7 +779,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) /* Draw current frame. */ x = (cfra - sfra) / (efra - sfra + 1) * ar->winx; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_CFRAME); immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC); diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index a1e3842f887..5c1b23e140c 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -86,7 +86,7 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2], GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(bg_sel); @@ -192,7 +192,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str if (bg) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(bg); @@ -243,7 +243,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str if (bg) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(bg); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index a21a62dc8e8..b9f92f383c4 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -121,7 +121,7 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa color[3] *= 2.5f; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -143,9 +143,9 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa if (key_ct > 0) { format = immVertexFormat(); pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); immBegin(GWN_PRIM_POINTS, key_ct); @@ -706,7 +706,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) { AnimData *adt = ale->adt; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 118a14c887d..335c135cfba 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2182,7 +2182,7 @@ static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNo const float cross_size = 12 * U.pixelsize; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2227,7 +2227,7 @@ static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bN y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2271,7 +2271,7 @@ static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -3264,7 +3264,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b y + snode->zoom * viewer_border->ymin * ibuf->y, y + snode->zoom * viewer_border->ymax * ibuf->y); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_ACTIVE); @@ -3423,9 +3423,9 @@ static void set_nodelink_vertex( static void nodelink_batch_init(void) { Gwn_VertFormat format = {0}; - unsigned int uv_id = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_U8, 2, GWN_FETCH_INT_TO_FLOAT_UNIT); - unsigned int pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int expand_id = GWN_vertformat_attr_add(&format, "expand", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint uv_id = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_U8, 2, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint expand_id = GWN_vertformat_attr_add(&format, "expand", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC); int vcount = LINK_RESOL * 2; /* curve */ vcount += 2; /* restart strip */ diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index c4ed35faabd..d2e189486df 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -649,7 +649,7 @@ static void node_draw_preview_background(float tile, rctf *rect) float x, y; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -721,7 +721,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) GPU_blend(false); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, +100); imm_draw_box_wire_2d(pos, draw_rect.xmin, draw_rect.ymin, draw_rect.xmax, draw_rect.ymax); @@ -772,8 +772,8 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * UI_view2d_scale_get(v2d, &scale, NULL); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); GPU_blend(true); GPU_enable_program_point_size(); @@ -1102,7 +1102,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b } /* scale widget thing */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(color_id, -10); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index c829b808348..8a8f4715ea3 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -742,7 +742,7 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex) GPU_line_width(1.0f); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); @@ -1740,7 +1740,7 @@ static void outliner_draw_tree_element( /* divider */ { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); unsigned char col[4]; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1797,7 +1797,7 @@ static void outliner_draw_tree_element_floating( const TreeElement *te_insert = te_floating->drag_data->insert_handle; const int line_width = 2; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); int coord_y = te_insert->ys; int coord_x = te_insert->xs; float col[4]; @@ -1902,7 +1902,7 @@ static void outliner_draw_hierarchy_lines_recursive( static void outliner_draw_hierarchy_lines(SpaceOops *soops, ListBase *lb, int startx, int *starty) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); unsigned char col[4]; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1925,7 +1925,7 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * if (TSELEM_OPEN(tselem, soops)) { if (tselem->type == TSE_RNA_STRUCT) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immThemeColorShadeAlpha(TH_BACK, -15, -200); immRecti(pos, 0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); @@ -1938,7 +1938,7 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * outliner_draw_struct_marks(ar, soops, &te->subtree, starty); if (tselem->type == TSE_RNA_STRUCT) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immThemeColorShadeAlpha(TH_BACK, -15, -200); @@ -2008,7 +2008,7 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx, GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); outliner_draw_highlights_recursive( pos, ar, soops, &soops->tree, col_selection, col_highlight, col_searchmatch, @@ -2083,7 +2083,7 @@ static void outliner_back(ARegion *ar) ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, 6); @@ -2114,7 +2114,7 @@ static void outliner_draw_restrictcols(ARegion *ar) { GPU_line_width(1.0f); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); immBegin(GWN_PRIM_LINES, 8); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 7da20131069..fd96cf49313 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -343,7 +343,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, col[3] = 196; /* alpha, used for all meta children */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -719,7 +719,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp; y2 = seq->machine + SEQ_STRIP_OFSTOP; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1231,8 +1231,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq * Do it here because OCIO binds it's own shader. */ Gwn_VertFormat *imm_format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); if (scope) { IMB_freeImBuf(ibuf); @@ -1514,7 +1514,7 @@ static void draw_seq_backdrop(View2D *v2d) { int i; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* darker gray overlay over the view backdrop */ @@ -1593,7 +1593,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) const Sequence *seq = special_seq_update; GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 255, 255, 48); @@ -1613,7 +1613,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw darkened area outside of active timeline @@ -1735,7 +1735,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) { int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(0.2f, 0.2f, 0.2f); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 21cd24cf84c..748a5c05ef1 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -913,7 +913,7 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back) float rad; /* background so highlights don't go behind the scrollbar */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_BACK); immRecti(pos, back->xmin, back->ymin, back->xmax, back->ymax); @@ -967,7 +967,7 @@ static void draw_documentation(const SpaceText *st, ARegion *ar) boxh = (DOC_HEIGHT + 1) * (st->lheight_dpi + TXT_LINE_SPACING); /* Draw panel */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_BACK); @@ -1066,7 +1066,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc /* not needed but stands out nicer */ UI_draw_box_shadow(220, x, y - boxh, x + boxw, y); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_SHADE1); @@ -1089,7 +1089,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc w = st->cwidth * text_get_char_pos(st, str, len); if (item == sel) { - unsigned int posi = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint posi = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_SHADE2); @@ -1130,7 +1130,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar) return; } - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* Draw the selection */ @@ -1443,7 +1443,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) if (st->showlinenrs) { x = TXT_OFFSET + TEXTXLOC; - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_GRID); immRecti(pos, (TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index bca5faa314a..beb323fb21c 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -748,7 +748,7 @@ void ED_draw_object_facemap( const int *facemap_data = CustomData_get_layer(&me->pdata, CD_FACEMAP); if (facemap_data) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(col); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index a428b60643d..2c732586606 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -814,8 +814,8 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBegin(GWN_PRIM_LINES, 6); @@ -859,8 +859,8 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) glDepthMask(GL_FALSE); /* don't overwrite zbuf */ Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index f9fdf8c2cc0..8c6bbaa94da 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -263,7 +263,7 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), y2 = yoff + 0.55f * fly->height; Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c index c33f15c0493..d102fdc6e04 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c @@ -793,7 +793,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) float co_ss_snap[3]; ED_view3d_project_float_global(ar, ruler_item->co[inter->co_index], co_ss_snap, V3D_PROJ_TEST_NOP); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color_act); diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 5911c8224be..4617b92c780 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -703,7 +703,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a float co_ss[3]; ED_view3d_project_float_global(ar, ruler_item->co[ruler_item->co_index], co_ss, V3D_PROJ_TEST_NOP); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color_act); diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index e3e82e8b9c2..7356d4a6eea 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -344,7 +344,7 @@ static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *a } Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index d26da986a6c..e9aeeb6a252 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1774,7 +1774,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) } /* And now, solid lines. */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); UNUSED_VARS_NDEBUG(pos); /* silence warning */ BLI_assert(pos == POS_INDEX); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -6982,7 +6982,7 @@ static void drawEdgeSlide(TransInfo *t) gpuPushMatrix(); gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 9df8264cc76..d40602f8d43 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -823,7 +823,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) if (depth_test_enabled) GPU_depth_test(false); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_GRID); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index b007a8d1b99..3f71915a690 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1132,7 +1132,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis } UI_make_axis_color(col, col2, axis); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ubv(col2); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 9ffd14ad956..68b8b33fcb0 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -165,7 +165,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) invert_m4_m4(imat, rv3d->viewmat); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -219,7 +219,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 411c4838252..24df0a61012 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -168,7 +168,7 @@ static void draw_uvs_shadow(Object *obedit) const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -229,7 +229,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME } } - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -309,8 +309,8 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME col[3] = 0.5f; /* hard coded alpha, not that nice */ Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -495,7 +495,7 @@ static void draw_uvs_other_mesh(Object *ob, const Image *curimage, static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *curimage, const int other_uv_filter) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -536,7 +536,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, ViewLayer *view_la mloopuv = me->mloopuv; } - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index bad878ef4bf..30672af9c02 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -235,7 +235,7 @@ void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2) */ void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2) { - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); immUniform4f("color1", 0.15f, 0.15f, 0.15f, 1.0f); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d7210c4ee29..06e759f1d3f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2569,11 +2569,11 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph } Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); if (rc->gltex) { - unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, rc->gltex); @@ -2701,7 +2701,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fvAlpha(col, 0.5f); diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index ec9db1dd98e..ef7992dcb8c 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -371,7 +371,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf gpuPushMatrix(); gpuLoadIdentity(); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(0, 255, 0); diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c index 2c779ba9c7c..1e9f6d6231b 100644 --- a/source/blender/windowmanager/intern/wm_stereo.c +++ b/source/blender/windowmanager/intern/wm_stereo.c @@ -88,8 +88,8 @@ void wm_stereo3d_draw_interlace(wmWindow *win, ARegion *ar) float halfy = GLA_PIXEL_OFS / ar->winy; Gwn_VertFormat *format = immVertexFormat(); - unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); /* leave GL_TEXTURE0 as the latest active texture */ for (int view = 1; view >= 0; view--) { @@ -164,8 +164,8 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) bool cross_eyed = (win->stereo3d_format->flag & S3D_SIDEBYSIDE_CROSSEYED) != 0; Gwn_VertFormat *format = immVertexFormat(); - unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE); @@ -210,8 +210,8 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) void wm_stereo3d_draw_topbottom(wmWindow *win, int view) { Gwn_VertFormat *format = immVertexFormat(); - unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE); -- cgit v1.2.3 From 392ed710d62ce496491566f9743ad9e66737072a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 12:45:53 +0200 Subject: Cleanup: rename 'ct' to 'len' for size vars --- source/blender/draw/engines/eevee/eevee_bloom.c | 12 ++-- .../draw/engines/eevee/eevee_depth_of_field.c | 4 +- source/blender/draw/engines/eevee/eevee_engine.c | 4 +- .../blender/draw/engines/eevee/eevee_lightprobes.c | 50 ++++++++-------- source/blender/draw/engines/eevee/eevee_lights.c | 68 +++++++++++----------- .../blender/draw/engines/eevee/eevee_materials.c | 16 ++--- source/blender/draw/engines/eevee/eevee_private.h | 14 ++--- source/blender/draw/intern/DRW_render.h | 4 +- source/blender/draw/intern/draw_cache.c | 20 +++---- source/blender/draw/intern/draw_cache_impl_mesh.c | 12 ++-- .../draw/intern/draw_cache_impl_particles.c | 46 +++++++-------- source/blender/draw/intern/draw_hair.c | 4 +- source/blender/draw/intern/draw_hair_private.h | 6 +- source/blender/draw/intern/draw_instance_data.c | 16 ++--- source/blender/draw/intern/draw_manager_data.c | 4 +- source/blender/draw/intern/draw_manager_exec.c | 6 +- source/blender/draw/intern/draw_view.c | 42 ++++++------- 17 files changed, 164 insertions(+), 164 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_bloom.c b/source/blender/draw/engines/eevee/eevee_bloom.c index 8be9c637fbc..2ec6f841409 100644 --- a/source/blender/draw/engines/eevee/eevee_bloom.c +++ b/source/blender/draw/engines/eevee/eevee_bloom.c @@ -132,9 +132,9 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) /* determine the iteration count */ const float minDim = (float)MIN2(blitsize[0], blitsize[1]); const float maxIter = (radius - 8.0f) + log(minDim) / log(2); - const int maxIterInt = effects->bloom_iteration_ct = (int)maxIter; + const int maxIterInt = effects->bloom_iteration_len = (int)maxIter; - CLAMP(effects->bloom_iteration_ct, 1, MAX_BLOOM_STEP); + CLAMP(effects->bloom_iteration_len, 1, MAX_BLOOM_STEP); effects->bloom_sample_scale = 0.5f + maxIter - (float)maxIterInt; effects->bloom_curve_threshold[0] = threshold - knee; @@ -146,7 +146,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) /* Downsample buffers */ copy_v2_v2_int(texsize, blitsize); - for (int i = 0; i < effects->bloom_iteration_ct; ++i) { + for (int i = 0; i < effects->bloom_iteration_len; ++i) { texsize[0] /= 2; texsize[1] /= 2; texsize[0] = MAX2(texsize[0], 2); @@ -165,7 +165,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) /* Upsample buffers */ copy_v2_v2_int(texsize, blitsize); - for (int i = 0; i < effects->bloom_iteration_ct - 1; ++i) { + for (int i = 0; i < effects->bloom_iteration_len - 1; ++i) { texsize[0] /= 2; texsize[1] /= 2; texsize[0] = MAX2(texsize[0], 2); @@ -291,7 +291,7 @@ void EEVEE_bloom_draw(EEVEE_Data *vedata) last = effects->bloom_downsample[0]; - for (int i = 1; i < effects->bloom_iteration_ct; ++i) { + for (int i = 1; i < effects->bloom_iteration_len; ++i) { copy_v2_v2(effects->unf_source_texel_size, effects->downsamp_texel_size[i - 1]); effects->unf_source_buffer = last; @@ -303,7 +303,7 @@ void EEVEE_bloom_draw(EEVEE_Data *vedata) } /* Upsample and accumulate */ - for (int i = effects->bloom_iteration_ct - 2; i >= 0; --i) { + for (int i = effects->bloom_iteration_len - 2; i >= 0; --i) { copy_v2_v2(effects->unf_source_texel_size, effects->downsamp_texel_size[i]); effects->unf_source_buffer = effects->bloom_downsample[i]; effects->unf_base_buffer = last; diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c index 60c6175f4fa..b9f7624552c 100644 --- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c +++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c @@ -208,8 +208,8 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_ /* This create an empty batch of N triangles to be positioned * by the vertex shader 0.4ms against 6ms with instancing */ const float *viewport_size = DRW_viewport_size_get(); - const int sprite_ct = ((int)viewport_size[0] / 2) * ((int)viewport_size[1] / 2); /* brackets matters */ - grp = DRW_shgroup_empty_tri_batch_create(e_data.dof_scatter_sh, psl->dof_scatter, sprite_ct); + const int sprite_len = ((int)viewport_size[0] / 2) * ((int)viewport_size[1] / 2); /* brackets matters */ + grp = DRW_shgroup_empty_tri_batch_create(e_data.dof_scatter_sh, psl->dof_scatter, sprite_len); DRW_shgroup_uniform_texture_ref(grp, "nearBuffer", &effects->dof_down_near); DRW_shgroup_uniform_texture_ref(grp, "farBuffer", &effects->dof_down_far); diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index d2400b8b651..99adc21bf56 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -191,10 +191,10 @@ static void eevee_draw_background(void *vedata) /* Number of iteration: needed for all temporal effect (SSR, volumetrics) * when using opengl render. */ - int loop_ct = (DRW_state_is_image_render() && + int loop_len = (DRW_state_is_image_render() && (stl->effects->enabled_effects & (EFFECT_VOLUMETRIC | EFFECT_SSR)) != 0) ? 4 : 1; - while (loop_ct--) { + while (loop_len--) { float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float clear_depth = 1.0f; uint clear_stencil = 0xFF; diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 0b97496700a..c4cf56483fa 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -127,12 +127,12 @@ static void irradiance_pool_size_get(int visibility_size, int total_samples, int (visibility_size / IRRADIANCE_SAMPLE_SIZE_Y); /* The irradiance itself take one layer, hence the +1 */ - int layer_ct = MIN2(irr_per_vis + 1, IRRADIANCE_MAX_POOL_LAYER); + int layer_len = MIN2(irr_per_vis + 1, IRRADIANCE_MAX_POOL_LAYER); - int texel_ct = (int)ceilf((float)total_samples / (float)(layer_ct - 1)); - r_size[0] = visibility_size * max_ii(1, min_ii(texel_ct, (IRRADIANCE_MAX_POOL_SIZE / visibility_size))); - r_size[1] = visibility_size * max_ii(1, (texel_ct / (IRRADIANCE_MAX_POOL_SIZE / visibility_size))); - r_size[2] = layer_ct; + int texel_len = (int)ceilf((float)total_samples / (float)(layer_len - 1)); + r_size[0] = visibility_size * max_ii(1, min_ii(texel_len, (IRRADIANCE_MAX_POOL_SIZE / visibility_size))); + r_size[1] = visibility_size * max_ii(1, (texel_len / (IRRADIANCE_MAX_POOL_SIZE / visibility_size))); + r_size[2] = layer_len; } static struct GPUTexture *create_hammersley_sample_texture(int samples) @@ -480,8 +480,8 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_filter_glossy_sh, psl->probe_glossy_compute); DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1); - DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_ct, 1); - DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->invsamples_ct, 1); + DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_len, 1); + DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->samples_len_inv, 1); DRW_shgroup_uniform_float(grp, "roughnessSquared", &pinfo->roughness, 1); DRW_shgroup_uniform_float(grp, "lodFactor", &pinfo->lodfactor, 1); DRW_shgroup_uniform_float(grp, "lodMax", &pinfo->lod_rt_max, 1); @@ -501,8 +501,8 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat #ifdef IRRADIANCE_SH_L2 DRW_shgroup_uniform_int(grp, "probeSize", &pinfo->shres, 1); #else - DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_ct, 1); - DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->invsamples_ct, 1); + DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_len, 1); + DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->samples_len_inv, 1); DRW_shgroup_uniform_float(grp, "lodFactor", &pinfo->lodfactor, 1); DRW_shgroup_uniform_float(grp, "lodMax", &pinfo->lod_rt_max, 1); DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); @@ -521,8 +521,8 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat DRW_shgroup_uniform_int(grp, "outputSize", &pinfo->shres, 1); DRW_shgroup_uniform_float(grp, "visibilityRange", &pinfo->visibility_range, 1); DRW_shgroup_uniform_float(grp, "visibilityBlur", &pinfo->visibility_blur, 1); - DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_ct, 1); - DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->invsamples_ct, 1); + DRW_shgroup_uniform_float(grp, "sampleCount", &pinfo->samples_len, 1); + DRW_shgroup_uniform_float(grp, "invSampleCount", &pinfo->samples_len_inv, 1); DRW_shgroup_uniform_float(grp, "storedTexelSize", &pinfo->texel_size, 1); DRW_shgroup_uniform_float(grp, "nearClip", &pinfo->near_clip, 1); DRW_shgroup_uniform_float(grp, "farClip", &pinfo->far_clip, 1); @@ -1100,18 +1100,18 @@ static void glossy_filter_probe( #if 1 /* Variable Sample count (fast) */ switch (i) { - case 0: pinfo->samples_ct = 1.0f; break; - case 1: pinfo->samples_ct = 16.0f; break; - case 2: pinfo->samples_ct = 32.0f; break; - case 3: pinfo->samples_ct = 64.0f; break; - default: pinfo->samples_ct = 128.0f; break; + case 0: pinfo->samples_len = 1.0f; break; + case 1: pinfo->samples_len = 16.0f; break; + case 2: pinfo->samples_len = 32.0f; break; + case 3: pinfo->samples_len = 64.0f; break; + default: pinfo->samples_len = 128.0f; break; } #else /* Constant Sample count (slow) */ - pinfo->samples_ct = 1024.0f; + pinfo->samples_len = 1024.0f; #endif - pinfo->invsamples_ct = 1.0f / pinfo->samples_ct; - pinfo->lodfactor = bias + 0.5f * log((float)(pinfo->target_size * pinfo->target_size) * pinfo->invsamples_ct) / log(2); + pinfo->samples_len_inv = 1.0f / pinfo->samples_len; + pinfo->lodfactor = bias + 0.5f * log((float)(pinfo->target_size * pinfo->target_size) * pinfo->samples_len_inv) / log(2); GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, { GPU_ATTACHMENT_NONE, @@ -1147,10 +1147,10 @@ static void diffuse_filter_probe( int size[2] = {3, 3}; #elif defined(IRRADIANCE_CUBEMAP) int size[2] = {8, 8}; - pinfo->samples_ct = 1024.0f; + pinfo->samples_len = 1024.0f; #elif defined(IRRADIANCE_HL2) int size[2] = {3, 2}; - pinfo->samples_ct = 1024.0f; + pinfo->samples_len = 1024.0f; #endif int cell_per_row = pool_size[0] / size[0]; @@ -1160,8 +1160,8 @@ static void diffuse_filter_probe( #ifndef IRRADIANCE_SH_L2 /* Tweaking parameters to balance perf. vs precision */ const float bias = 0.0f; - pinfo->invsamples_ct = 1.0f / pinfo->samples_ct; - pinfo->lodfactor = bias + 0.5f * log((float)(pinfo->target_size * pinfo->target_size) * pinfo->invsamples_ct) / log(2); + pinfo->samples_len_inv = 1.0f / pinfo->samples_len; + pinfo->lodfactor = bias + 0.5f * log((float)(pinfo->target_size * pinfo->target_size) * pinfo->samples_len_inv) / log(2); pinfo->lod_rt_max = floorf(log2f(pinfo->target_size)) - 2.0f; #else pinfo->shres = 32; /* Less texture fetches & reduce branches */ @@ -1188,8 +1188,8 @@ static void diffuse_filter_probe( /* World irradiance have no visibility */ if (offset > 0) { /* Compute visibility */ - pinfo->samples_ct = 512.0f; /* TODO refine */ - pinfo->invsamples_ct = 1.0f / pinfo->samples_ct; + pinfo->samples_len = 512.0f; /* TODO refine */ + pinfo->samples_len_inv = 1.0f / pinfo->samples_len; pinfo->shres = common_data->prb_irradiance_vis_size; pinfo->visibility_range = vis_range; pinfo->visibility_blur = vis_blur; diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index 2b1bd9fbce3..9214544fb17 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -235,9 +235,9 @@ static GPUShader *eevee_lights_get_store_sh(int shadow_method, bool high_blur, b return *shader; } -static DRWPass *eevee_lights_cube_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_ct) +static DRWPass *eevee_lights_cube_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_len) { - bool high_blur = shadow_samples_ct > 16; + bool high_blur = shadow_samples_len > 16; DRWPass **pass = (high_blur) ? &psl->shadow_cube_store_pass : &psl->shadow_cube_store_high_pass; if (*pass == NULL) { EEVEE_LampsInfo *linfo = sldata->lamps; @@ -252,9 +252,9 @@ static DRWPass *eevee_lights_cube_store_pass_get(EEVEE_PassList *psl, EEVEE_View return *pass; } -static DRWPass *eevee_lights_cascade_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_ct) +static DRWPass *eevee_lights_cascade_store_pass_get(EEVEE_PassList *psl, EEVEE_ViewLayerData *sldata, int shadow_method, int shadow_samples_len) { - bool high_blur = shadow_samples_ct > 16; + bool high_blur = shadow_samples_len > 16; DRWPass **pass = (high_blur) ? &psl->shadow_cascade_store_pass : &psl->shadow_cascade_store_high_pass; if (*pass == NULL) { EEVEE_LampsInfo *linfo = sldata->lamps; @@ -280,8 +280,8 @@ void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) linfo->num_light = 0; linfo->num_cube_layer = 0; linfo->num_cascade_layer = 0; - linfo->gpu_cube_ct = linfo->gpu_cascade_ct = linfo->gpu_shadow_ct = 0; - linfo->cpu_cube_ct = linfo->cpu_cascade_ct = 0; + linfo->gpu_cube_len = linfo->gpu_cascade_len = linfo->gpu_shadow_len = 0; + linfo->cpu_cube_len = linfo->cpu_cascade_len = 0; memset(linfo->light_ref, 0, sizeof(linfo->light_ref)); memset(linfo->shadow_cube_ref, 0, sizeof(linfo->shadow_cube_ref)); memset(linfo->shadow_cascade_ref, 0, sizeof(linfo->shadow_cascade_ref)); @@ -361,56 +361,56 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob) int sh_nbr = 1; /* TODO : MSM */ int cascade_nbr = la->cascade_count; - if ((linfo->gpu_cascade_ct + sh_nbr) <= MAX_SHADOW_CASCADE) { + if ((linfo->gpu_cascade_len + sh_nbr) <= MAX_SHADOW_CASCADE) { /* Save Light object. */ - linfo->shadow_cascade_ref[linfo->cpu_cascade_ct] = ob; + linfo->shadow_cascade_ref[linfo->cpu_cascade_len] = ob; /* Store indices. */ EEVEE_ShadowCascadeData *data = &led->data.scad; - data->shadow_id = linfo->gpu_shadow_ct; - data->cascade_id = linfo->gpu_cascade_ct; + data->shadow_id = linfo->gpu_shadow_len; + data->cascade_id = linfo->gpu_cascade_len; data->layer_id = linfo->num_cascade_layer; /* Increment indices. */ - linfo->gpu_shadow_ct += 1; - linfo->gpu_cascade_ct += sh_nbr; + linfo->gpu_shadow_len += 1; + linfo->gpu_cascade_len += sh_nbr; linfo->num_cascade_layer += sh_nbr * cascade_nbr; - linfo->cpu_cascade_ct += 1; + linfo->cpu_cascade_len += 1; } } else if (la->type == LA_SPOT || la->type == LA_LOCAL || la->type == LA_AREA) { int sh_nbr = 1; /* TODO : MSM */ - if ((linfo->gpu_cube_ct + sh_nbr) <= MAX_SHADOW_CUBE) { + if ((linfo->gpu_cube_len + sh_nbr) <= MAX_SHADOW_CUBE) { /* Save Light object. */ - linfo->shadow_cube_ref[linfo->cpu_cube_ct] = ob; + linfo->shadow_cube_ref[linfo->cpu_cube_len] = ob; /* For light update tracking. */ if ((prev_cube_sh_id >= 0) && (prev_cube_sh_id < linfo->shcaster_backbuffer->count)) { - linfo->new_shadow_id[prev_cube_sh_id] = linfo->cpu_cube_ct; + linfo->new_shadow_id[prev_cube_sh_id] = linfo->cpu_cube_len; } - led->prev_cube_shadow_id = linfo->cpu_cube_ct; + led->prev_cube_shadow_id = linfo->cpu_cube_len; /* Saving lamp bounds for later. */ - BLI_assert(linfo->cpu_cube_ct >= 0 && linfo->cpu_cube_ct < MAX_LIGHT); - copy_v3_v3(linfo->shadow_bounds[linfo->cpu_cube_ct].center, ob->obmat[3]); - linfo->shadow_bounds[linfo->cpu_cube_ct].radius = la->clipend; + BLI_assert(linfo->cpu_cube_len >= 0 && linfo->cpu_cube_len < MAX_LIGHT); + copy_v3_v3(linfo->shadow_bounds[linfo->cpu_cube_len].center, ob->obmat[3]); + linfo->shadow_bounds[linfo->cpu_cube_len].radius = la->clipend; EEVEE_ShadowCubeData *data = &led->data.scd; /* Store indices. */ - data->shadow_id = linfo->gpu_shadow_ct; - data->cube_id = linfo->gpu_cube_ct; + data->shadow_id = linfo->gpu_shadow_len; + data->cube_id = linfo->gpu_cube_len; data->layer_id = linfo->num_cube_layer; /* Increment indices. */ - linfo->gpu_shadow_ct += 1; - linfo->gpu_cube_ct += sh_nbr; + linfo->gpu_shadow_len += 1; + linfo->gpu_cube_len += sh_nbr; linfo->num_cube_layer += sh_nbr; - linfo->cpu_cube_ct += 1; + linfo->cpu_cube_len += 1; } } } @@ -993,7 +993,7 @@ void EEVEE_lights_update(EEVEE_ViewLayerData *sldata) for (i = 0; i < frontbuffer->count; i++, flag++, shcaster++) { /* Run intersection checks to fill the bitfields. */ bsphere = linfo->shadow_bounds; - for (int j = 0; j < linfo->cpu_cube_ct; j++, bsphere++) { + for (int j = 0; j < linfo->cpu_cube_len; j++, bsphere++) { bool iter = sphere_bbox_intersect(bsphere, &shcaster->bbox); lightbits_set_single(&shcaster->bits, j, iter); } @@ -1139,19 +1139,19 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl) filter_pixel_size = max_ff(0.0f, filter_pixel_size - 3.0f); /* Compute number of concentric samples. Depends directly on filter size. */ float pix_size_sqr = filter_pixel_size * filter_pixel_size; - srd->shadow_samples_ct = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr)); + srd->shadow_samples_len = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr)); } else { linfo->filter_size = 0.0f; - srd->shadow_samples_ct = 4; + srd->shadow_samples_len = 4; } - srd->shadow_inv_samples_ct = 1.0f / (float)srd->shadow_samples_ct; + srd->shadow_samples_len_inv = 1.0f / (float)srd->shadow_samples_len; DRW_uniformbuffer_update(sldata->shadow_render_ubo, srd); GPU_framebuffer_texture_layer_attach(sldata->shadow_cube_store_fb, sldata->shadow_cube_pool, 0, evscd->layer_id, 0); GPU_framebuffer_bind(sldata->shadow_cube_store_fb); - DRWPass *store_pass = eevee_lights_cube_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_ct); + DRWPass *store_pass = eevee_lights_cube_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_len); DRW_draw_pass(store_pass); led->need_update = false; @@ -1240,20 +1240,20 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl) filter_pixel_size = max_ff(0.0f, filter_pixel_size - 3.0f); /* Compute number of concentric samples. Depends directly on filter size. */ float pix_size_sqr = filter_pixel_size * filter_pixel_size; - srd->shadow_samples_ct = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr)); + srd->shadow_samples_len = min_ii(max_sample, 4 + 8 * (int)filter_pixel_size + 4 * (int)(pix_size_sqr)); } else { linfo->filter_size = 0.0f; - srd->shadow_samples_ct = 4; + srd->shadow_samples_len = 4; } - srd->shadow_inv_samples_ct = 1.0f / (float)srd->shadow_samples_ct; + srd->shadow_samples_len_inv = 1.0f / (float)srd->shadow_samples_len; DRW_uniformbuffer_update(sldata->shadow_render_ubo, &linfo->shadow_render_data); int layer = evscd->layer_id + linfo->current_shadow_cascade; GPU_framebuffer_texture_layer_attach(sldata->shadow_cascade_store_fb, sldata->shadow_cascade_pool, 0, layer, 0); GPU_framebuffer_bind(sldata->shadow_cascade_store_fb); - DRWPass *store_pass = eevee_lights_cascade_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_ct); + DRWPass *store_pass = eevee_lights_cascade_store_pass_get(psl, sldata, linfo->shadow_method, srd->shadow_samples_len); DRW_draw_pass(store_pass); } } diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 5cc20adf961..4161d11e0c1 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -115,8 +115,8 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h)) { struct GPUTexture *tex; struct GPUFrameBuffer *fb = NULL; - static float samples_ct = 8192.0f; - static float inv_samples_ct = 1.0f / 8192.0f; + static float samples_len = 8192.0f; + static float inv_samples_len = 1.0f / 8192.0f; char *lib_str = BLI_string_joinN( datatoc_bsdf_common_lib_glsl, @@ -130,8 +130,8 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h)) DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR); DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); - DRW_shgroup_uniform_float(grp, "sampleCount", &samples_ct, 1); - DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_ct, 1); + DRW_shgroup_uniform_float(grp, "sampleCount", &samples_len, 1); + DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_len, 1); DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter); @@ -172,9 +172,9 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h) struct GPUTexture *tex; struct GPUTexture *hammersley = create_hammersley_sample_texture(8192); struct GPUFrameBuffer *fb = NULL; - static float samples_ct = 8192.0f; + static float samples_len = 8192.0f; static float a2 = 0.0f; - static float inv_samples_ct = 1.0f / 8192.0f; + static float inv_samples_len = 1.0f / 8192.0f; char *frag_str = BLI_string_joinN( datatoc_bsdf_common_lib_glsl, @@ -192,8 +192,8 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h) DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR); DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); DRW_shgroup_uniform_float(grp, "a2", &a2, 1); - DRW_shgroup_uniform_float(grp, "sampleCount", &samples_ct, 1); - DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_ct, 1); + DRW_shgroup_uniform_float(grp, "sampleCount", &samples_len, 1); + DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_len, 1); DRW_shgroup_uniform_texture(grp, "texHammersley", hammersley); DRW_shgroup_uniform_texture(grp, "utilTex", e_data.util_tex); diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index fe01b85758c..ef1d03c244e 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -325,8 +325,8 @@ typedef struct EEVEE_ShadowRender { float stored_texel_size; float clip_near; float clip_far; - int shadow_samples_ct; - float shadow_inv_samples_ct; + int shadow_samples_len; + float shadow_samples_len_inv; } EEVEE_ShadowRender; /* This is just a really long bitflag with special function to access it. */ @@ -352,8 +352,8 @@ typedef struct EEVEE_LampsInfo { int num_light, cache_num_light; int num_cube_layer, cache_num_cube_layer; int num_cascade_layer, cache_num_cascade_layer; - int gpu_cube_ct, gpu_cascade_ct, gpu_shadow_ct; - int cpu_cube_ct, cpu_cascade_ct; + int gpu_cube_len, gpu_cascade_len, gpu_shadow_len; + int cpu_cube_len, cpu_cascade_len; int update_flag; int shadow_cube_size, shadow_cascade_size, shadow_method; bool shadow_high_bitdepth; @@ -452,8 +452,8 @@ typedef struct EEVEE_LightProbesInfo { int layer; float texel_size; float padding_size; - float samples_ct; - float invsamples_ct; + float samples_len; + float samples_len_inv; float near_clip; float far_clip; float roughness; @@ -563,7 +563,7 @@ typedef struct EEVEE_EffectsInfo { /* Other */ float prev_persmat[4][4]; /* Bloom */ - int bloom_iteration_ct; + int bloom_iteration_len; float source_texel_size[2]; float blit_texel_size[2]; float downsamp_texel_size[MAX_BLOOM_STEP][2]; diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 0d443293d04..f732082018d 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -346,7 +346,7 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup); void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]); void DRW_shgroup_call_range_add( DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count); -void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_count, float (*obmat)[4]); +void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]); void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]); void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]); void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, struct Object *ob); @@ -496,7 +496,7 @@ void DRW_state_lock(DRWState state); void DRW_state_invert_facing(void); -void DRW_state_clip_planes_count_set(uint plane_ct); +void DRW_state_clip_planes_count_set(uint plane_len); void DRW_state_clip_planes_reset(void); /* Culling, return true if object is inside view frustum. */ diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index a6a0472fe86..5c3546f07a7 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2349,26 +2349,26 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) a = axis + 0.31f; /* Axis name */ - int axis_v_ct; + int axis_v_len; float (*axis_verts)[2]; if (axis == 0) { axis_verts = x_axis_name; - axis_v_ct = X_LEN; + axis_v_len = X_LEN; } else if (axis == 1) { axis_verts = y_axis_name; - axis_v_ct = Y_LEN; + axis_v_len = Y_LEN; } else { axis_verts = z_axis_name; - axis_v_ct = Z_LEN; + axis_v_len = Z_LEN; } /* Axis name shadows */ copy_v3_fl(c, 0.0f); c[axis] = 0.3f; for (int j = 0; j < SHADOW_RES; ++j) { - for (int i = 0; i < axis_v_ct; ++i) { + for (int i = 0; i < axis_v_len; ++i) { float tmp[2]; add_v2_v2v2(tmp, axis_verts[i], axis_name_shadow[j]); set_bone_axis_vert(vbo, attr_id.axis, attr_id.pos, attr_id.col, @@ -2379,7 +2379,7 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) /* Axis name */ copy_v3_fl(c, 0.1f); c[axis] = 1.0f; - for (int i = 0; i < axis_v_ct; ++i) { + for (int i = 0; i < axis_v_len; ++i) { set_bone_axis_vert(vbo, attr_id.axis, attr_id.pos, attr_id.col, &v, &a, axis_verts[i], c); } @@ -3125,8 +3125,8 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) const float f20 = 1.0f; const int segments = 16; - const int vert_ct = segments + 8; - const int index_ct = vert_ct + 5; + const int vert_len = segments + 8; + const int index_len = vert_len + 5; uchar red[3] = {255, 0, 0}; uchar white[3] = {255, 255, 255}; @@ -3139,10 +3139,10 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) } Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, GWN_PRIM_LINE_STRIP, index_ct, vert_ct, true); + GWN_indexbuf_init_ex(&elb, GWN_PRIM_LINE_STRIP, index_len, vert_len, true); Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_ct); + GWN_vertbuf_data_alloc(vbo, vert_len); int v = 0; for (int i = 0; i < segments; ++i) { diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 198518cd887..6c6e2d78206 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -1634,7 +1634,7 @@ typedef struct MeshBatchCache { * set srgb conversion for auto attribs.*/ char *auto_layer_names; int *auto_layer_is_srgb; - int auto_layer_ct; + int auto_layer_len; /* settings to determine if cache is invalid */ bool is_maybe_dirty; @@ -1947,22 +1947,22 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, uint auto_names_len = 0; uint auto_ofs = 0; uint auto_id = 0; - cache->auto_layer_ct = 0; + cache->auto_layer_len = 0; for (uint i = 0; i < uv_len; i++) { const char *attrib_name = mesh_render_data_uv_auto_layer_uuid_get(rdata, i); auto_names_len += strlen(attrib_name) + 2; /* include null terminator and b prefix. */ - cache->auto_layer_ct++; + cache->auto_layer_len++; } for (uint i = 0; i < vcol_len; i++) { if (rdata->cd.layers.auto_vcol[i]) { const char *attrib_name = mesh_render_data_vcol_auto_layer_uuid_get(rdata, i); auto_names_len += strlen(attrib_name) + 2; /* include null terminator and b prefix. */ - cache->auto_layer_ct++; + cache->auto_layer_len++; } } auto_names_len += 1; /* add an ultimate '\0' terminator */ cache->auto_layer_names = MEM_callocN(auto_names_len * sizeof(char), "Auto layer name buf"); - cache->auto_layer_is_srgb = MEM_mallocN(cache->auto_layer_ct * sizeof(int), "Auto layer value buf"); + cache->auto_layer_is_srgb = MEM_mallocN(cache->auto_layer_len * sizeof(int), "Auto layer value buf"); for (uint i = 0; i < uv_len; i++) { /* UV */ @@ -4330,7 +4330,7 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( if (auto_layer_names) { *auto_layer_names = cache->auto_layer_names; *auto_layer_is_srgb = cache->auto_layer_is_srgb; - *auto_layer_count = cache->auto_layer_ct; + *auto_layer_count = cache->auto_layer_len; } return cache->shaded_triangles; diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 3cf47fb5e25..60b367f7b1a 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -66,8 +66,8 @@ static void particle_batch_cache_clear(ParticleSystem *psys); typedef struct ParticlePointCache { Gwn_VertBuf *pos; Gwn_Batch *points; - int elems_count; - int point_count; + int elems_len; + int point_len; } ParticlePointCache; typedef struct ParticleBatchCache { @@ -82,11 +82,11 @@ typedef struct ParticleBatchCache { Gwn_VertBuf *edit_inner_pos; Gwn_Batch *edit_inner_points; - int edit_inner_point_count; + int edit_inner_point_len; Gwn_VertBuf *edit_tip_pos; Gwn_Batch *edit_tip_points; - int edit_tip_point_count; + int edit_tip_point_len; /* Settings to determine if cache is invalid. */ bool is_dirty; @@ -225,9 +225,9 @@ static void count_cache_segment_keys( for (int i = 0; i < num_path_cache_keys; i++) { ParticleCacheKey *path = pathcache[i]; if (path->segments > 0) { - hair_cache->strands_count++; - hair_cache->elems_count += path->segments + 2; - hair_cache->point_count += path->segments + 1; + hair_cache->strands_len++; + hair_cache->elems_len += path->segments + 2; + hair_cache->point_len += path->segments + 1; } } } @@ -243,9 +243,9 @@ static void ensure_seg_pt_count( return; } - hair_cache->strands_count = 0; - hair_cache->elems_count = 0; - hair_cache->point_count = 0; + hair_cache->strands_len = 0; + hair_cache->elems_len = 0; + hair_cache->point_len = 0; if (edit != NULL && edit->pathcache != NULL) { count_cache_segment_keys(edit->pathcache, edit->totcached, hair_cache); @@ -761,7 +761,7 @@ static void particle_batch_cache_ensure_procedural_final_points( /* Create a destination buffer for the tranform feedback. Sized appropriately */ /* Thoses are points! not line segments. */ - GWN_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_count); + GWN_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_len); /* Create vbo immediatly to bind to texture buffer. */ GWN_vertbuf_use(cache->final[subdiv].proc_buf); @@ -814,13 +814,13 @@ static void particle_batch_cache_ensure_procedural_strand_data( /* Strand Data */ cache->proc_strand_buf = GWN_vertbuf_create_with_format(&format_data); - GWN_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_count); + GWN_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len); GWN_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step); /* UV layers */ for (int i = 0; i < cache->num_uv_layers; i++) { cache->proc_uv_buf[i] = GWN_vertbuf_create_with_format(&format_uv); - GWN_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_count); + GWN_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); GWN_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); @@ -836,7 +836,7 @@ static void particle_batch_cache_ensure_procedural_strand_data( /* Vertex colors */ for (int i = 0; i < cache->num_col_layers; i++) { cache->proc_col_buf[i] = GWN_vertbuf_create_with_format(&format_col); - GWN_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_count); + GWN_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); GWN_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); @@ -942,7 +942,7 @@ static void particle_batch_cache_ensure_procedural_indices( int verts_per_hair = cache->final[subdiv].strands_res * thickness_res; /* +1 for primitive restart */ - int element_count = (verts_per_hair + 1) * cache->strands_count; + int element_count = (verts_per_hair + 1) * cache->strands_len; Gwn_PrimType prim_type = (thickness_res == 1) ? GWN_PRIM_LINE_STRIP : GWN_PRIM_TRI_STRIP; static Gwn_VertFormat format = { 0 }; @@ -997,7 +997,7 @@ static void particle_batch_cache_ensure_procedural_pos( uint pos_id = GWN_vertformat_attr_add(&format, "posTime", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); cache->proc_point_buf = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->proc_point_buf, cache->point_count); + GWN_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len); Gwn_VertBufRaw pos_step; GWN_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step); @@ -1109,13 +1109,13 @@ static void particle_batch_cache_ensure_pos_and_seg( } hair_cache->pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_count); + GWN_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); Gwn_IndexBufBuilder elb; GWN_indexbuf_init_ex( &elb, GWN_PRIM_LINE_STRIP, - hair_cache->elems_count, hair_cache->point_count, + hair_cache->elems_len, hair_cache->point_len, true); if (num_uv_layers || num_col_layers) { @@ -1392,11 +1392,11 @@ static void ensure_edit_inner_points_count( if (cache->edit_inner_pos != NULL) { return; } - cache->edit_inner_point_count = 0; + cache->edit_inner_point_len = 0; for (int point_index = 0; point_index < edit->totpoint; point_index++) { const PTCacheEditPoint *point = &edit->points[point_index]; BLI_assert(point->totkey >= 1); - cache->edit_inner_point_count += (point->totkey - 1); + cache->edit_inner_point_len += (point->totkey - 1); } } @@ -1431,7 +1431,7 @@ static void particle_batch_cache_ensure_edit_inner_pos( } cache->edit_inner_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_count); + GWN_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len); float selected_color[4], normal_color[4]; edit_colors_get(edit, selected_color, normal_color); @@ -1479,7 +1479,7 @@ static void ensure_edit_tip_points_count( if (cache->edit_tip_pos != NULL) { return; } - cache->edit_tip_point_count = edit->totpoint; + cache->edit_tip_point_len = edit->totpoint; } static void particle_batch_cache_ensure_edit_tip_pos( @@ -1502,7 +1502,7 @@ static void particle_batch_cache_ensure_edit_tip_pos( } cache->edit_tip_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_count); + GWN_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len); float selected_color[4], normal_color[4]; edit_colors_get(edit, selected_color, normal_color); diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 8320ae55179..6ede573199f 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -137,14 +137,14 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex( /* Transform Feedback subdiv. */ if (need_ft_update) { - int final_points_ct = hair_cache->final[subdiv].strands_res * hair_cache->strands_count; + int final_points_len = hair_cache->final[subdiv].strands_res * hair_cache->strands_len; GPUShader *tf_shader = hair_refine_shader_get(PART_REFINE_CATMULL_ROM); DRWShadingGroup *tf_shgrp = DRW_shgroup_transform_feedback_create(tf_shader, g_tf_pass, hair_cache->final[subdiv].proc_buf); DRW_shgroup_uniform_texture(tf_shgrp, "hairPointBuffer", hair_cache->point_tex); DRW_shgroup_uniform_texture(tf_shgrp, "hairStrandBuffer", hair_cache->strand_tex); DRW_shgroup_uniform_int(tf_shgrp, "hairStrandsRes", &hair_cache->final[subdiv].strands_res, 1); - DRW_shgroup_call_procedural_points_add(tf_shgrp, final_points_ct, NULL); + DRW_shgroup_call_procedural_points_add(tf_shgrp, final_points_len, NULL); } return shgrp; diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h index 28993614688..17acd7e6259 100644 --- a/source/blender/draw/intern/draw_hair_private.h +++ b/source/blender/draw/intern/draw_hair_private.h @@ -76,9 +76,9 @@ typedef struct ParticleHairCache { ParticleHairFinalCache final[MAX_HAIR_SUBDIV]; - int strands_count; - int elems_count; - int point_count; + int strands_len; + int elems_len; + int point_len; } ParticleHairCache; bool particles_ensure_procedural_data( diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index 3e4f812af27..e5b5ec31823 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -213,10 +213,10 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) for (int i = 0; i < batching->alloc_size; i++, bbuf++) { if (bbuf->shgroup != NULL) { realloc_size = i + 1; - uint vert_ct = DRW_shgroup_get_instance_count(bbuf->shgroup); - vert_ct += (vert_ct == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ - if (vert_ct + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_ct) { - uint size = vert_ct + BUFFER_VERTS_CHUNK - 1; + uint vert_len = DRW_shgroup_get_instance_count(bbuf->shgroup); + vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ + if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_ct) { + uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; GWN_vertbuf_data_resize(bbuf->vert, size); } @@ -245,10 +245,10 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) for (int i = 0; i < instancing->alloc_size; i++, ibuf++) { if (ibuf->shgroup != NULL) { realloc_size = i + 1; - uint vert_ct = DRW_shgroup_get_instance_count(ibuf->shgroup); - vert_ct += (vert_ct == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ - if (vert_ct + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_ct) { - uint size = vert_ct + BUFFER_VERTS_CHUNK - 1; + uint vert_len = DRW_shgroup_get_instance_count(ibuf->shgroup); + vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ + if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_ct) { + uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; GWN_vertbuf_data_resize(ibuf->vert, size); } diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index db4e16d362a..2e6079e1661 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -412,9 +412,9 @@ static void drw_shgroup_call_procedural_add_ex( BLI_LINKS_APPEND(&shgroup->calls, call); } -void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_count, float (*obmat)[4]) +void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS, point_count, obmat, NULL); + drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS, point_len, obmat, NULL); } void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]) diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 03692fd9475..5957643d090 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -419,10 +419,10 @@ void DRW_state_invert_facing(void) * and if the shaders have support for it (see usage of gl_ClipDistance). * Be sure to call DRW_state_clip_planes_reset() after you finish drawing. **/ -void DRW_state_clip_planes_count_set(uint plane_ct) +void DRW_state_clip_planes_count_set(uint plane_len) { - BLI_assert(plane_ct <= MAX_CLIP_PLANES); - DST.num_clip_planes = plane_ct; + BLI_assert(plane_len <= MAX_CLIP_PLANES); + DST.num_clip_planes = plane_len; } void DRW_state_clip_planes_reset(void) diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index cab796a62d3..59ae8a918f9 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -79,7 +79,7 @@ void DRW_draw_region_info(void) /* ************************* Grid ************************** */ -static void gridline_range(double x0, double dx, double max, int *r_first, int *r_count) +static void gridline_range(double x0, double dx, double max, int *r_first, int *r_len) { /* determine range of gridlines that appear in this Area -- similar calc but separate ranges for x & y * x0 is gridline 0, the axis in screen space @@ -90,11 +90,11 @@ static void gridline_range(double x0, double dx, double max, int *r_first, int * if (first <= last) { *r_first = first; - *r_count = last - first + 1; + *r_len = last - first + 1; } else { *r_first = 0; - *r_count = 0; + *r_len = 0; } } @@ -104,14 +104,14 @@ static int gridline_count(ARegion *ar, double x0, double y0, double dx) * dx is the frequency, shared by x & y directions * pass in dx of smallest (highest precision) grid we want to draw */ - int first, x_ct, y_ct; + int first, x_len, y_len; - gridline_range(x0, dx, ar->winx, &first, &x_ct); - gridline_range(y0, dx, ar->winy, &first, &y_ct); + gridline_range(x0, dx, ar->winx, &first, &x_len); + gridline_range(y0, dx, ar->winy, &first, &y_len); - int total_ct = x_ct + y_ct; + int total_len = x_len + y_len; - return total_ct; + return total_len; } static bool drawgrid_draw( @@ -129,7 +129,7 @@ static bool drawgrid_draw( const float y_max = (float)ar->winy; int first, ct; - int x_ct = 0, y_ct = 0; /* count of lines actually drawn */ + int x_len = 0, y_len = 0; /* count of lines actually drawn */ int lines_skipped_for_next_unit = 0; /* draw vertical lines */ @@ -143,13 +143,13 @@ static bool drawgrid_draw( continue; } - if (x_ct == 0) + if (x_len == 0) immAttrib3ub(col, col_value[0], col_value[1], col_value[2]); float x = (float)(x0 + i * dx); immVertex2f(pos, x, 0.0f); immVertex2f(pos, x, y_max); - ++x_ct; + ++x_len; } /* draw horizontal lines */ @@ -163,13 +163,13 @@ static bool drawgrid_draw( continue; } - if (x_ct + y_ct == 0) + if (x_len + y_len == 0) immAttrib3ub(col, col_value[0], col_value[1], col_value[2]); float y = (float)(y0 + i * dx); immVertex2f(pos, 0.0f, y); immVertex2f(pos, x_max, y); - ++y_ct; + ++y_len; } return lines_skipped_for_next_unit > 0; @@ -249,11 +249,11 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** *grid_unit = bUnit_GetNameDisplay(usys, i); rv3d->gridview = (float)((scalar * (double)v3d->grid) / (double)unit->scale_length); - int gridline_ct = gridline_count(ar, x, y, dx_scalar); - if (gridline_ct == 0) + int gridline_len = gridline_count(ar, x, y, dx_scalar); + if (gridline_len == 0) goto drawgrid_cleanup; /* nothing to draw */ - immBegin(GWN_PRIM_LINES, gridline_ct * 2); + immBegin(GWN_PRIM_LINES, gridline_len * 2); } float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar); @@ -302,11 +302,11 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } } - int gridline_ct = gridline_count(ar, x, y, dx); - if (gridline_ct == 0) + int gridline_len = gridline_count(ar, x, y, dx); + if (gridline_len == 0) goto drawgrid_cleanup; /* nothing to draw */ - immBegin(GWN_PRIM_LINES, gridline_ct * 2); + immBegin(GWN_PRIM_LINES, gridline_len * 2); if (grids_to_draw == 2) { UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2); @@ -376,7 +376,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) UI_GetThemeColor3ubv(TH_GRID, col_grid); if (show_floor) { - const uint vertex_ct = 2 * (gridlines * 4 + 2); + const uint vertex_len = 2 * (gridlines * 4 + 2); const int sublines = v3d->gridsubdiv; uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3]; @@ -387,7 +387,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_ct); + immBegin(GWN_PRIM_LINES, vertex_len); /* draw normal grid lines */ UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10); -- cgit v1.2.3 From 804205babe212972dd800c5a2f6d9ebfb64feefb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 13:05:41 +0200 Subject: Cleanup: rename 'ct' to 'len' for gawain --- intern/gawain/gawain/gwn_batch.h | 6 +- intern/gawain/gawain/gwn_element.h | 10 +- intern/gawain/gawain/gwn_immediate.h | 8 +- intern/gawain/gawain/gwn_shader_interface.h | 2 +- intern/gawain/gawain/gwn_vertex_buffer.h | 12 +- intern/gawain/gawain/gwn_vertex_format.h | 10 +- intern/gawain/gawain/gwn_vertex_format_private.h | 2 +- intern/gawain/src/gwn_attr_binding.c | 4 +- intern/gawain/src/gwn_batch.c | 32 ++--- intern/gawain/src/gwn_buffer_id.cpp | 6 +- intern/gawain/src/gwn_element.c | 48 +++---- intern/gawain/src/gwn_immediate.c | 146 ++++++++++----------- intern/gawain/src/gwn_shader_interface.c | 32 ++--- intern/gawain/src/gwn_vertex_array_id.cpp | 4 +- intern/gawain/src/gwn_vertex_buffer.c | 42 +++--- intern/gawain/src/gwn_vertex_format.c | 50 +++---- source/blender/draw/intern/draw_cache.c | 100 +++++++------- source/blender/draw/intern/draw_cache_impl_curve.c | 12 +- .../blender/draw/intern/draw_cache_impl_displist.c | 4 +- .../blender/draw/intern/draw_cache_impl_lattice.c | 2 +- source/blender/draw/intern/draw_cache_impl_mesh.c | 36 ++--- .../draw/intern/draw_cache_impl_particles.c | 6 +- source/blender/draw/intern/draw_instance_data.c | 4 +- source/blender/draw/intern/draw_manager_data.c | 12 +- .../blender/editors/interface/interface_widgets.c | 2 +- source/blender/editors/mask/mask_draw.c | 6 +- source/blender/editors/space_file/file_draw.c | 8 +- source/blender/editors/uvedit/uvedit_draw.c | 4 +- .../blender/editors/uvedit/uvedit_smart_stitch.c | 2 +- source/blender/gpu/intern/gpu_batch.c | 4 +- source/blender/gpu/intern/gpu_batch_presets.c | 2 +- source/blender/gpu/intern/gpu_buffers.c | 4 +- source/blender/gpu/intern/gpu_texture.c | 12 +- source/blender/python/gawain/gwn_py_types.c | 22 ++-- 34 files changed, 328 insertions(+), 328 deletions(-) diff --git a/intern/gawain/gawain/gwn_batch.h b/intern/gawain/gawain/gwn_batch.h index e0cf66637f6..cf7b0c9f1b5 100644 --- a/intern/gawain/gawain/gwn_batch.h +++ b/intern/gawain/gawain/gwn_batch.h @@ -149,9 +149,9 @@ typedef struct BatchWithOwnVertexBufferAndElementList { Gwn_VertBuf verts; // link batch.verts to this } BatchWithOwnVertexBufferAndElementList; -Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, unsigned v_ct, Gwn_IndexBuf*); -Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, unsigned prim_ct); -Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, unsigned v_ct, unsigned prim_ct); +Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, unsigned v_len, Gwn_IndexBuf*); +Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, unsigned prim_len); +Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, unsigned v_len, unsigned prim_len); // verts: shared, own // elem: none, shared, own Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff); diff --git a/intern/gawain/gawain/gwn_element.h b/intern/gawain/gawain/gwn_element.h index 4bd0c34675a..53a54cdfd76 100644 --- a/intern/gawain/gawain/gwn_element.h +++ b/intern/gawain/gawain/gwn_element.h @@ -24,7 +24,7 @@ typedef enum { } Gwn_IndexBufType; typedef struct Gwn_IndexBuf { - unsigned index_ct; + unsigned index_len; #if GWN_TRACK_INDEX_RANGE Gwn_IndexBufType index_type; uint32_t gl_index_type; @@ -41,8 +41,8 @@ unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf*); typedef struct Gwn_IndexBufBuilder { unsigned max_allowed_index; - unsigned max_index_ct; - unsigned index_ct; + unsigned max_index_len; + unsigned index_len; Gwn_PrimType prim_type; unsigned* data; bool use_prim_restart; @@ -50,10 +50,10 @@ typedef struct Gwn_IndexBufBuilder { // supports all primitive types. -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned index_ct, unsigned vertex_ct, bool use_prim_restart); +void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned index_len, unsigned vertex_len, bool use_prim_restart); // supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS. -void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned prim_ct, unsigned vertex_ct); +void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned prim_len, unsigned vertex_len); void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, unsigned v); void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*); diff --git a/intern/gawain/gawain/gwn_immediate.h b/intern/gawain/gawain/gwn_immediate.h index 35f9c9d9e2c..c3ea2b911a0 100644 --- a/intern/gawain/gawain/gwn_immediate.h +++ b/intern/gawain/gawain/gwn_immediate.h @@ -23,8 +23,8 @@ Gwn_VertFormat* immVertexFormat(void); // returns a cleared vertex format, ready void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first void immUnbindProgram(void); // call after your last immEnd, or before binding another program -void immBegin(Gwn_PrimType, unsigned vertex_ct); // must supply exactly vertex_ct vertices -void immBeginAtMost(Gwn_PrimType, unsigned max_vertex_ct); // can supply fewer vertices +void immBegin(Gwn_PrimType, unsigned vertex_len); // must supply exactly vertex_len vertices +void immBeginAtMost(Gwn_PrimType, unsigned max_vertex_len); // can supply fewer vertices void immEnd(void); // finishes and draws #if IMM_BATCH_COMBO @@ -32,8 +32,8 @@ void immEnd(void); // finishes and draws // immBegin a batch, then use standard immFunctions as usual. // immEnd will finalize the batch instead of drawing. // Then you can draw it as many times as you like! Partially replaces the need for display lists. -Gwn_Batch* immBeginBatch(Gwn_PrimType, unsigned vertex_ct); -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, unsigned vertex_ct); +Gwn_Batch* immBeginBatch(Gwn_PrimType, unsigned vertex_len); +Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, unsigned vertex_len); #endif diff --git a/intern/gawain/gawain/gwn_shader_interface.h b/intern/gawain/gawain/gwn_shader_interface.h index ee3d51fb3cc..b27b12c18d8 100644 --- a/intern/gawain/gawain/gwn_shader_interface.h +++ b/intern/gawain/gawain/gwn_shader_interface.h @@ -65,7 +65,7 @@ typedef struct Gwn_ShaderInterface { Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS]; char* name_buffer; struct Gwn_Batch** batches; // references to batches using this interface - unsigned batches_ct; + unsigned batches_len; } Gwn_ShaderInterface; Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id); diff --git a/intern/gawain/gawain/gwn_vertex_buffer.h b/intern/gawain/gawain/gwn_vertex_buffer.h index b92e4a87698..0eac4838e65 100644 --- a/intern/gawain/gawain/gwn_vertex_buffer.h +++ b/intern/gawain/gawain/gwn_vertex_buffer.h @@ -17,7 +17,7 @@ // How to create a Gwn_VertBuf: // 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts) // 2) GWN_vertformat_attr_add(verts->format, ...) -// 3) GWN_vertbuf_data_alloc(verts, vertex_ct) <-- finalizes/packs vertex format +// 3) GWN_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format // 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer) // Is Gwn_VertBuf always used as part of a Gwn_Batch? @@ -31,8 +31,8 @@ typedef enum { typedef struct Gwn_VertBuf { Gwn_VertFormat format; - unsigned vertex_ct; // number of verts we want to draw - unsigned vertex_alloc; // number of verts data + unsigned vertex_len; /* number of verts we want to draw */ + unsigned vertex_alloc; /* number of verts data */ bool dirty; unsigned char* data; // NULL indicates data in VRAM (unmapped) uint32_t vbo_id; // 0 indicates not yet allocated @@ -54,9 +54,9 @@ void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf*, const Gwn_VertFormat*, Gwn_Us GWN_vertbuf_init_with_format_ex(verts, format, GWN_USAGE_STATIC) unsigned GWN_vertbuf_size_get(const Gwn_VertBuf*); -void GWN_vertbuf_data_alloc(Gwn_VertBuf*, unsigned v_ct); -void GWN_vertbuf_data_resize(Gwn_VertBuf*, unsigned v_ct); -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, unsigned v_ct); +void GWN_vertbuf_data_alloc(Gwn_VertBuf*, unsigned v_len); +void GWN_vertbuf_data_resize(Gwn_VertBuf*, unsigned v_len); +void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, unsigned v_len); // The most important set_attrib variant is the untyped one. Get it right first. // It takes a void* so the app developer is responsible for matching their app data types diff --git a/intern/gawain/gawain/gwn_vertex_format.h b/intern/gawain/gawain/gwn_vertex_format.h index 503c2d03c42..a4593e4615b 100644 --- a/intern/gawain/gawain/gwn_vertex_format.h +++ b/intern/gawain/gawain/gwn_vertex_format.h @@ -42,16 +42,16 @@ typedef struct Gwn_VertAttr { Gwn_VertFetchMode fetch_mode; Gwn_VertCompType comp_type; unsigned gl_comp_type; - unsigned comp_ct; // 1 to 4 or 8 or 12 or 16 + unsigned comp_len; // 1 to 4 or 8 or 12 or 16 unsigned sz; // size in bytes, 1 to 64 unsigned offset; // from beginning of vertex, in bytes - unsigned name_ct; // up to GWN_VERT_ATTR_MAX_NAMES + unsigned name_len; // up to GWN_VERT_ATTR_MAX_NAMES const char* name[GWN_VERT_ATTR_MAX_NAMES]; } Gwn_VertAttr; typedef struct Gwn_VertFormat { - unsigned attrib_ct; // 0 to 16 (GWN_VERT_ATTR_MAX_LEN) - unsigned name_ct; // total count of active vertex attrib + unsigned attr_len; // 0 to 16 (GWN_VERT_ATTR_MAX_LEN) + unsigned name_len; // total count of active vertex attrib unsigned stride; // stride in bytes, 1 to 256 unsigned name_offset; bool packed; @@ -62,7 +62,7 @@ typedef struct Gwn_VertFormat { void GWN_vertformat_clear(Gwn_VertFormat*); void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src); -unsigned GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, unsigned comp_ct, Gwn_VertFetchMode); +unsigned GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, unsigned comp_len, Gwn_VertFetchMode); void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias); // format conversion diff --git a/intern/gawain/gawain/gwn_vertex_format_private.h b/intern/gawain/gawain/gwn_vertex_format_private.h index c1a0f734eda..90cd8412e53 100644 --- a/intern/gawain/gawain/gwn_vertex_format_private.h +++ b/intern/gawain/gawain/gwn_vertex_format_private.h @@ -13,4 +13,4 @@ void VertexFormat_pack(Gwn_VertFormat*); unsigned padding(unsigned offset, unsigned alignment); -unsigned vertex_buffer_size(const Gwn_VertFormat*, unsigned vertex_ct); +unsigned vertex_buffer_size(const Gwn_VertFormat*, unsigned vertex_len); diff --git a/intern/gawain/src/gwn_attr_binding.c b/intern/gawain/src/gwn_attr_binding.c index 7647a927b1e..c702a0ae99d 100644 --- a/intern/gawain/src/gwn_attr_binding.c +++ b/intern/gawain/src/gwn_attr_binding.c @@ -52,10 +52,10 @@ void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding { AttribBinding_clear(binding); - for (unsigned a_idx = 0; a_idx < format->attrib_ct; ++a_idx) + for (unsigned a_idx = 0; a_idx < format->attr_len; ++a_idx) { const Gwn_VertAttr* a = format->attribs + a_idx; - for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx) + for (unsigned n_idx = 0; n_idx < a->name_len; ++n_idx) { const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]); diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c index adc72e171c0..62342cfc42f 100644 --- a/intern/gawain/src/gwn_batch.c +++ b/intern/gawain/src/gwn_batch.c @@ -168,9 +168,9 @@ int GWN_batch_vertbuf_add_ex( if (batch->verts[v] == NULL) { #if TRUST_NO_ONE - // for now all VertexBuffers must have same vertex_ct - assert(verts->vertex_ct == batch->verts[0]->vertex_ct); - // in the near future we will enable instanced attribs which have their own vertex_ct + // for now all VertexBuffers must have same vertex_len + assert(verts->vertex_len == batch->verts[0]->vertex_len); + // in the near future we will enable instanced attribs which have their own vertex_len #endif batch->verts[v] = verts; // TODO: mark dirty so we can keep attrib bindings up-to-date @@ -336,30 +336,30 @@ static void create_bindings(Gwn_VertBuf* verts, const Gwn_ShaderInterface* inter { const Gwn_VertFormat* format = &verts->format; - const unsigned attrib_ct = format->attrib_ct; + const unsigned attr_len = format->attr_len; const unsigned stride = format->stride; GWN_vertbuf_use(verts); - for (unsigned a_idx = 0; a_idx < attrib_ct; ++a_idx) + for (unsigned a_idx = 0; a_idx < attr_len; ++a_idx) { const Gwn_VertAttr* a = format->attribs + a_idx; const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride; - for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx) + for (unsigned n_idx = 0; n_idx < a->name_len; ++n_idx) { const Gwn_ShaderInput* input = GWN_shaderinterface_attr(interface, a->name[n_idx]); if (input == NULL) continue; - if (a->comp_ct == 16 || a->comp_ct == 12 || a->comp_ct == 8) + if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { #if TRUST_NO_ONE assert(a->fetch_mode == GWN_FETCH_FLOAT); assert(a->gl_comp_type == GL_FLOAT); #endif - for (int i = 0; i < a->comp_ct / 4; ++i) + for (int i = 0; i < a->comp_len / 4; ++i) { glEnableVertexAttribArray(input->location + i); glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0); @@ -376,13 +376,13 @@ static void create_bindings(Gwn_VertBuf* verts, const Gwn_ShaderInterface* inter { case GWN_FETCH_FLOAT: case GWN_FETCH_INT_TO_FLOAT: - glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer); + glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); break; case GWN_FETCH_INT_TO_FLOAT_UNIT: - glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer); + glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); break; case GWN_FETCH_INT: - glVertexAttribIPointer(input->location, a->comp_ct, a->gl_comp_type, stride, pointer); + glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer); } } } @@ -564,7 +564,7 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo { // Infer length if vertex count is not given if (v_count == 0) - v_count = batch->inst->vertex_ct; + v_count = batch->inst->vertex_len; if (batch->elem) { @@ -574,21 +574,21 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo primitive_restart_enable(el); #if GWN_TRACK_INDEX_RANGE - glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_ct, el->gl_index_type, 0, v_count, el->base_index); + glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_len, el->gl_index_type, 0, v_count, el->base_index); #else - glDrawElementsInstanced(batch->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0, v_count); + glDrawElementsInstanced(batch->gl_prim_type, el->index_len, GL_UNSIGNED_INT, 0, v_count); #endif if (el->use_prim_restart) primitive_restart_disable(); } else - glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct, v_count); + glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_len, v_count); } else { // Infer length if vertex count is not given if (v_count == 0) - v_count = (batch->elem) ? batch->elem->index_ct : batch->verts[0]->vertex_ct; + v_count = (batch->elem) ? batch->elem->index_len : batch->verts[0]->vertex_len; if (batch->elem) { diff --git a/intern/gawain/src/gwn_buffer_id.cpp b/intern/gawain/src/gwn_buffer_id.cpp index 64bad855ca7..13473f1f28d 100644 --- a/intern/gawain/src/gwn_buffer_id.cpp +++ b/intern/gawain/src/gwn_buffer_id.cpp @@ -39,11 +39,11 @@ GLuint GWN_buf_id_alloc() orphan_mutex.lock(); if (!orphaned_buffer_ids.empty()) { - const auto orphaned_buffer_ct = (unsigned)orphaned_buffer_ids.size(); + const auto orphaned_buffer_len = (unsigned)orphaned_buffer_ids.size(); #if ORPHAN_DEBUG - printf("deleting %u orphaned VBO%s\n", orphaned_buffer_ct, orphaned_buffer_ct == 1 ? "" : "s"); + printf("deleting %u orphaned VBO%s\n", orphaned_buffer_len, orphaned_buffer_len == 1 ? "" : "s"); #endif - glDeleteBuffers(orphaned_buffer_ct, orphaned_buffer_ids.data()); + glDeleteBuffers(orphaned_buffer_len, orphaned_buffer_ids.data()); orphaned_buffer_ids.clear(); } orphan_mutex.unlock(); diff --git a/intern/gawain/src/gwn_element.c b/intern/gawain/src/gwn_element.c index e2fbb657c78..257338fe089 100644 --- a/intern/gawain/src/gwn_element.c +++ b/intern/gawain/src/gwn_element.c @@ -33,23 +33,23 @@ unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) [GWN_INDEX_U16] = sizeof(GLushort), [GWN_INDEX_U32] = sizeof(GLuint) }; - return elem->index_ct * table[elem->index_type]; + return elem->index_len * table[elem->index_type]; #else - return elem->index_ct * sizeof(GLuint); + return elem->index_len * sizeof(GLuint); #endif } -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned index_ct, unsigned vertex_ct, bool use_prim_restart) +void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned index_len, unsigned vertex_len, bool use_prim_restart) { builder->use_prim_restart = use_prim_restart; - builder->max_allowed_index = vertex_ct - 1; - builder->max_index_ct = index_ct; - builder->index_ct = 0; // start empty + builder->max_allowed_index = vertex_len - 1; + builder->max_index_len = index_len; + builder->index_len = 0; // start empty builder->prim_type = prim_type; - builder->data = calloc(builder->max_index_ct, sizeof(unsigned)); + builder->data = calloc(builder->max_index_len, sizeof(unsigned)); } -void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned prim_ct, unsigned vertex_ct) +void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned prim_len, unsigned vertex_len) { unsigned verts_per_prim = 0; switch (prim_type) @@ -73,29 +73,29 @@ void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uns return; } - GWN_indexbuf_init_ex(builder, prim_type, prim_ct * verts_per_prim, vertex_ct, false); + GWN_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); } void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, unsigned v) { #if TRUST_NO_ONE assert(builder->data != NULL); - assert(builder->index_ct < builder->max_index_ct); + assert(builder->index_len < builder->max_index_len); assert(v <= builder->max_allowed_index); #endif - builder->data[builder->index_ct++] = v; + builder->data[builder->index_len++] = v; } void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder* builder) { #if TRUST_NO_ONE assert(builder->data != NULL); - assert(builder->index_ct < builder->max_index_ct); + assert(builder->index_len < builder->max_index_len); assert(builder->use_prim_restart); #endif - builder->data[builder->index_ct++] = GWN_PRIM_RESTART; + builder->data[builder->index_len++] = GWN_PRIM_RESTART; } void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, unsigned v) @@ -147,9 +147,9 @@ void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, unsigned v1, // Everything remains 32 bit while building to keep things simple. // Find min/max after, then convert to smallest index type possible. -static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned* min_out, unsigned* max_out) +static unsigned index_range(const unsigned values[], unsigned value_len, unsigned* min_out, unsigned* max_out) { - if (value_ct == 0) + if (value_len == 0) { *min_out = 0; *max_out = 0; @@ -157,7 +157,7 @@ static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned } unsigned min_value = values[0]; unsigned max_value = values[0]; - for (unsigned i = 1; i < value_ct; ++i) + for (unsigned i = 1; i < value_len; ++i) { const unsigned value = values[i]; if (value == GWN_PRIM_RESTART) @@ -175,7 +175,7 @@ static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) { const unsigned *values = builder->data; - const unsigned index_ct = elem->index_ct; + const unsigned index_len = elem->index_len; // data will never be *larger* than builder->data... // converting in place to avoid extra allocation @@ -189,14 +189,14 @@ static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* ele elem->min_index = 0; elem->max_index -= base; - for (unsigned i = 0; i < index_ct; ++i) + for (unsigned i = 0; i < index_len; ++i) data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); } else { elem->base_index = 0; - for (unsigned i = 0; i < index_ct; ++i) + for (unsigned i = 0; i < index_len; ++i) data[i] = (GLubyte)(values[i]); } } @@ -204,7 +204,7 @@ static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* ele static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) { const unsigned *values = builder->data; - const unsigned index_ct = elem->index_ct; + const unsigned index_len = elem->index_len; // data will never be *larger* than builder->data... // converting in place to avoid extra allocation @@ -218,14 +218,14 @@ static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* el elem->min_index = 0; elem->max_index -= base; - for (unsigned i = 0; i < index_ct; ++i) + for (unsigned i = 0; i < index_len; ++i) data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); } else { elem->base_index = 0; - for (unsigned i = 0; i < index_ct; ++i) + for (unsigned i = 0; i < index_len; ++i) data[i] = (GLushort)(values[i]); } } @@ -245,11 +245,11 @@ void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* ele assert(builder->data != NULL); #endif - elem->index_ct = builder->index_ct; + elem->index_len = builder->index_len; elem->use_prim_restart = builder->use_prim_restart; #if GWN_TRACK_INDEX_RANGE - unsigned range = index_range(builder->data, builder->index_ct, &elem->min_index, &elem->max_index); + unsigned range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index); // count the primitive restart index. if (elem->use_prim_restart) diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c index b0b587d1b8c..c57564fce06 100644 --- a/intern/gawain/src/gwn_immediate.c +++ b/intern/gawain/src/gwn_immediate.c @@ -34,8 +34,8 @@ typedef struct { GLubyte* buffer_data; unsigned buffer_offset; unsigned buffer_bytes_mapped; - unsigned vertex_ct; - bool strict_vertex_ct; + unsigned vertex_len; + bool strict_vertex_len; Gwn_PrimType prim_type; Gwn_VertFormat vertex_format; @@ -73,7 +73,7 @@ void immInit(void) glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); imm.prim_type = GWN_PRIM_NONE; - imm.strict_vertex_ct = true; + imm.strict_vertex_len = true; glBindBuffer(GL_ARRAY_BUFFER, 0); initialized = true; @@ -147,10 +147,10 @@ void immUnbindProgram(void) } #if TRUST_NO_ONE -static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, Gwn_PrimType prim_type) +static bool vertex_count_makes_sense_for_primitive(unsigned vertex_len, Gwn_PrimType prim_type) { - // does vertex_ct make sense for this primitive type? - if (vertex_ct == 0) + // does vertex_len make sense for this primitive type? + if (vertex_len == 0) return false; switch (prim_type) @@ -158,38 +158,38 @@ static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, Gwn_PrimT case GWN_PRIM_POINTS: return true; case GWN_PRIM_LINES: - return vertex_ct % 2 == 0; + return vertex_len % 2 == 0; case GWN_PRIM_LINE_STRIP: case GWN_PRIM_LINE_LOOP: - return vertex_ct >= 2; + return vertex_len >= 2; case GWN_PRIM_LINE_STRIP_ADJ: - return vertex_ct >= 4; + return vertex_len >= 4; case GWN_PRIM_TRIS: - return vertex_ct % 3 == 0; + return vertex_len % 3 == 0; case GWN_PRIM_TRI_STRIP: case GWN_PRIM_TRI_FAN: - return vertex_ct >= 3; + return vertex_len >= 3; default: return false; } } #endif -void immBegin(Gwn_PrimType prim_type, unsigned vertex_ct) +void immBegin(Gwn_PrimType prim_type, unsigned vertex_len) { #if TRUST_NO_ONE assert(initialized); assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun - assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type)); + assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif imm.prim_type = prim_type; - imm.vertex_ct = vertex_ct; + imm.vertex_len = vertex_len; imm.vertex_idx = 0; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; // how many bytes do we need for this draw call? - const unsigned bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_ct); + const unsigned bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_len); #if TRUST_NO_ONE assert(bytes_needed <= IMM_BUFFER_SIZE); @@ -234,7 +234,7 @@ void immBegin(Gwn_PrimType prim_type, unsigned vertex_ct) // printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1); imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, bytes_needed, - GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_ct ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)); + GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_len ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)); #if TRUST_NO_ONE assert(imm.buffer_data != NULL); @@ -244,33 +244,33 @@ void immBegin(Gwn_PrimType prim_type, unsigned vertex_ct) imm.vertex_data = imm.buffer_data; } -void immBeginAtMost(Gwn_PrimType prim_type, unsigned vertex_ct) +void immBeginAtMost(Gwn_PrimType prim_type, unsigned vertex_len) { #if TRUST_NO_ONE - assert(vertex_ct > 0); + assert(vertex_len > 0); #endif - imm.strict_vertex_ct = false; - immBegin(prim_type, vertex_ct); + imm.strict_vertex_len = false; + immBegin(prim_type, vertex_len); } #if IMM_BATCH_COMBO -Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_ct) +Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_len) { #if TRUST_NO_ONE assert(initialized); assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun - assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type)); + assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif imm.prim_type = prim_type; - imm.vertex_ct = vertex_ct; + imm.vertex_len = vertex_len; imm.vertex_idx = 0; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; Gwn_VertBuf* verts = GWN_vertbuf_create_with_format(&imm.vertex_format); - GWN_vertbuf_data_alloc(verts, vertex_ct); + GWN_vertbuf_data_alloc(verts, vertex_len); imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts); imm.vertex_data = verts->data; @@ -281,10 +281,10 @@ Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_ct) return imm.batch; } -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, unsigned vertex_ct) +Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, unsigned vertex_len) { - imm.strict_vertex_ct = false; - return immBeginBatch(prim_type, vertex_ct); + imm.strict_vertex_len = false; + return immBeginBatch(prim_type, vertex_len); } #endif // IMM_BATCH_COMBO @@ -319,7 +319,7 @@ static void immDrawSetup(void) const unsigned stride = imm.vertex_format.stride; - for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx) + for (unsigned a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; @@ -334,13 +334,13 @@ static void immDrawSetup(void) { case GWN_FETCH_FLOAT: case GWN_FETCH_INT_TO_FLOAT: - glVertexAttribPointer(loc, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer); + glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); break; case GWN_FETCH_INT_TO_FLOAT_UNIT: - glVertexAttribPointer(loc, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer); + glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); break; case GWN_FETCH_INT: - glVertexAttribIPointer(loc, a->comp_ct, a->gl_comp_type, stride, pointer); + glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer); } } @@ -355,20 +355,20 @@ void immEnd(void) #endif unsigned buffer_bytes_used; - if (imm.strict_vertex_ct) + if (imm.strict_vertex_len) { #if TRUST_NO_ONE - assert(imm.vertex_idx == imm.vertex_ct); // with all vertices defined + assert(imm.vertex_idx == imm.vertex_len); // with all vertices defined #endif buffer_bytes_used = imm.buffer_bytes_mapped; } else { #if TRUST_NO_ONE - assert(imm.vertex_idx <= imm.vertex_ct); + assert(imm.vertex_idx <= imm.vertex_len); #endif - // printf("used %u of %u verts,", imm.vertex_idx, imm.vertex_ct); - if (imm.vertex_idx == imm.vertex_ct) + // printf("used %u of %u verts,", imm.vertex_idx, imm.vertex_len); + if (imm.vertex_idx == imm.vertex_len) { buffer_bytes_used = imm.buffer_bytes_mapped; } @@ -377,8 +377,8 @@ void immEnd(void) #if TRUST_NO_ONE assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type)); #endif - imm.vertex_ct = imm.vertex_idx; - buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_ct); + imm.vertex_len = imm.vertex_idx; + buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_len); // unused buffer bytes are available to the next immBegin // printf(" %u of %u bytes\n", buffer_bytes_used, imm.buffer_bytes_mapped); } @@ -393,7 +393,7 @@ void immEnd(void) { if (buffer_bytes_used != imm.buffer_bytes_mapped) { - GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_ct); + GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); // TODO: resize only if vertex count is much smaller } @@ -406,10 +406,10 @@ void immEnd(void) { glUnmapBuffer(GL_ARRAY_BUFFER); - if (imm.vertex_ct > 0) + if (imm.vertex_len > 0) { immDrawSetup(); - glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_ct); + glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_len); } glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -421,7 +421,7 @@ void immEnd(void) // prep for next immBegin imm.prim_type = GWN_PRIM_NONE; - imm.strict_vertex_ct = true; + imm.strict_vertex_len = true; } static void setAttribValueBit(unsigned attrib_id) @@ -443,10 +443,10 @@ void immAttrib1f(unsigned attrib_id, float x) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_ct == 1); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 1); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -463,10 +463,10 @@ void immAttrib2f(unsigned attrib_id, float x, float y) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_ct == 2); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -484,10 +484,10 @@ void immAttrib3f(unsigned attrib_id, float x, float y, float z) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_ct == 3); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 3); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -506,10 +506,10 @@ void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_ct == 4); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 4); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -529,10 +529,10 @@ void immAttrib1u(unsigned attrib_id, unsigned x) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U32); - assert(attrib->comp_ct == 1); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 1); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -548,10 +548,10 @@ void immAttrib2i(unsigned attrib_id, int x, int y) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_I32); - assert(attrib->comp_ct == 2); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -568,10 +568,10 @@ void immAttrib2s(unsigned attrib_id, short x, short y) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_I16); - assert(attrib->comp_ct == 2); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -603,10 +603,10 @@ void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U8); - assert(attrib->comp_ct == 3); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 3); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -625,10 +625,10 @@ void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U8); - assert(attrib->comp_ct == 4); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 4); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -656,8 +656,8 @@ void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]) void immSkipAttrib(unsigned attrib_id) { #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib_id < imm.vertex_format.attr_len); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -668,7 +668,7 @@ static void immEndVertex(void) // and move on to the next vertex { #if TRUST_NO_ONE assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair - assert(imm.vertex_idx < imm.vertex_ct); + assert(imm.vertex_idx < imm.vertex_len); #endif // have all attribs been assigned values? @@ -679,7 +679,7 @@ static void immEndVertex(void) // and move on to the next vertex assert(imm.vertex_idx > 0); // first vertex must have all attribs specified #endif - for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx) + for (unsigned a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { if ((imm.unassigned_attrib_bits >> a_idx) & 1) { diff --git a/intern/gawain/src/gwn_shader_interface.c b/intern/gawain/src/gwn_shader_interface.c index 16451573bba..d18af234fb0 100644 --- a/intern/gawain/src/gwn_shader_interface.c +++ b/intern/gawain/src/gwn_shader_interface.c @@ -203,19 +203,19 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program); #endif - GLint max_attrib_name_len, attrib_ct; + GLint max_attrib_name_len, attr_len; glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len); - glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attrib_ct); + glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attr_len); - GLint max_ubo_name_len, ubo_ct; + GLint max_ubo_name_len, ubo_len; glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len); - glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_ct); + glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_len); - const uint32_t name_buffer_len = attrib_ct * max_attrib_name_len + ubo_ct * max_ubo_name_len; + const uint32_t name_buffer_len = attr_len * max_attrib_name_len + ubo_len * max_ubo_name_len; shaderface->name_buffer = malloc(name_buffer_len); // Attributes - for (uint32_t i = 0; i < attrib_ct; ++i) + for (uint32_t i = 0; i < attr_len; ++i) { Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; @@ -245,7 +245,7 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) } // Uniform Blocks - for (uint32_t i = 0; i < ubo_ct; ++i) + for (uint32_t i = 0; i < ubo_len; ++i) { Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; @@ -274,8 +274,8 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) } // Batches ref buffer - shaderface->batches_ct = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = calloc(shaderface->batches_ct, sizeof(Gwn_Batch*)); + shaderface->batches_len = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = calloc(shaderface->batches_len, sizeof(Gwn_Batch*)); return shaderface; } @@ -289,7 +289,7 @@ void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) // Free memory used by name_buffer. free(shaderface->name_buffer); // Remove this interface from all linked Batches vao cache. - for (int i = 0; i < shaderface->batches_ct; ++i) + for (int i = 0; i < shaderface->batches_len; ++i) if (shaderface->batches[i] != NULL) gwn_batch_remove_interface_ref(shaderface->batches[i], shaderface); @@ -333,16 +333,16 @@ const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shade void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) { int i; // find first unused slot - for (i = 0; i < shaderface->batches_ct; ++i) + for (i = 0; i < shaderface->batches_len; ++i) if (shaderface->batches[i] == NULL) break; - if (i == shaderface->batches_ct) + if (i == shaderface->batches_len) { // Not enough place, realloc the array. - i = shaderface->batches_ct; - shaderface->batches_ct += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_ct); + i = shaderface->batches_len; + shaderface->batches_len += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_len); memset(shaderface->batches + i, 0, sizeof(Gwn_Batch*) * GWN_SHADERINTERFACE_REF_ALLOC_COUNT); } @@ -351,7 +351,7 @@ void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batc void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) { - for (int i = 0; i < shaderface->batches_ct; ++i) + for (int i = 0; i < shaderface->batches_len; ++i) { if (shaderface->batches[i] == batch) { diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp index d4b89a0f62b..70294565e6a 100644 --- a/intern/gawain/src/gwn_vertex_array_id.cpp +++ b/intern/gawain/src/gwn_vertex_array_id.cpp @@ -60,8 +60,8 @@ static void clear_orphans(Gwn_Context* ctx) ctx->orphans_mutex.lock(); if (!ctx->orphaned_vertarray_ids.empty()) { - unsigned orphan_ct = (unsigned)ctx->orphaned_vertarray_ids.size(); - glDeleteVertexArrays(orphan_ct, ctx->orphaned_vertarray_ids.data()); + unsigned orphan_len = (unsigned)ctx->orphaned_vertarray_ids.size(); + glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data()); ctx->orphaned_vertarray_ids.clear(); } ctx->orphans_mutex.unlock(); diff --git a/intern/gawain/src/gwn_vertex_buffer.c b/intern/gawain/src/gwn_vertex_buffer.c index f621b4c01b9..a372c62bd0a 100644 --- a/intern/gawain/src/gwn_vertex_buffer.c +++ b/intern/gawain/src/gwn_vertex_buffer.c @@ -81,11 +81,11 @@ void GWN_vertbuf_discard(Gwn_VertBuf* verts) unsigned GWN_vertbuf_size_get(const Gwn_VertBuf* verts) { - return vertex_buffer_size(&verts->format, verts->vertex_ct); + return vertex_buffer_size(&verts->format, verts->vertex_len); } // create a new allocation, discarding any existing data -void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_ct) +void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_len) { Gwn_VertFormat* format = &verts->format; if (!format->packed) @@ -93,7 +93,7 @@ void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_ct) #if TRUST_NO_ONE // catch any unnecessary use - assert(verts->vertex_alloc != v_ct || verts->data == NULL); + assert(verts->vertex_alloc != v_len || verts->data == NULL); #endif // only create the buffer the 1st time @@ -105,49 +105,49 @@ void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_ct) free(verts->data); #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_ct); + unsigned new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif verts->dirty = true; - verts->vertex_ct = verts->vertex_alloc = v_ct; + verts->vertex_len = verts->vertex_alloc = v_len; verts->data = malloc(sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); } // resize buffer keeping existing data -void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, unsigned v_ct) +void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, unsigned v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); - assert(verts->vertex_alloc != v_ct); + assert(verts->vertex_alloc != v_len); #endif #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_ct); + unsigned new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif verts->dirty = true; - verts->vertex_ct = verts->vertex_alloc = v_ct; + verts->vertex_len = verts->vertex_alloc = v_len; verts->data = realloc(verts->data, sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); } // set vertex count but does not change allocation // only this many verts will be uploaded to the GPU and rendered // this is usefull for streaming data -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, unsigned v_ct) +void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, unsigned v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); // only for dynamic data - assert(v_ct <= verts->vertex_alloc); + assert(v_len <= verts->vertex_alloc); #endif #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_ct); + unsigned new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif - verts->vertex_ct = v_ct; + verts->vertex_len = v_len; } void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, unsigned a_idx, unsigned v_idx, const void* data) @@ -156,7 +156,7 @@ void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, unsigned a_idx, unsigned v_idx, co const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE - assert(a_idx < format->attrib_ct); + assert(a_idx < format->attr_len); assert(v_idx < verts->vertex_alloc); assert(verts->data != NULL); #endif @@ -171,7 +171,7 @@ void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, unsigned a_idx, const void* data) const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE - assert(a_idx < format->attrib_ct); + assert(a_idx < format->attr_len); #endif const unsigned stride = a->sz; // tightly packed input data @@ -185,22 +185,22 @@ void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, unsigned a_idx, unsigned s const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE - assert(a_idx < format->attrib_ct); + assert(a_idx < format->attr_len); assert(verts->data != NULL); #endif verts->dirty = true; - const unsigned vertex_ct = verts->vertex_ct; + const unsigned vertex_len = verts->vertex_len; - if (format->attrib_ct == 1 && stride == format->stride) + if (format->attr_len == 1 && stride == format->stride) { // we can copy it all at once - memcpy(verts->data, data, vertex_ct * a->sz); + memcpy(verts->data, data, vertex_len * a->sz); } else { // we must copy it per vertex - for (unsigned v = 0; v < vertex_ct; ++v) + for (unsigned v = 0; v < vertex_len; ++v) memcpy((GLubyte*)verts->data + a->offset + v * format->stride, (const GLubyte*)data + v * stride, a->sz); } } @@ -211,7 +211,7 @@ void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, unsigned a_idx, Gwn_VertB const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE - assert(a_idx < format->attrib_ct); + assert(a_idx < format->attr_len); assert(verts->data != NULL); #endif diff --git a/intern/gawain/src/gwn_vertex_format.c b/intern/gawain/src/gwn_vertex_format.c index c180c304d28..122de12ec6e 100644 --- a/intern/gawain/src/gwn_vertex_format.c +++ b/intern/gawain/src/gwn_vertex_format.c @@ -25,13 +25,13 @@ void GWN_vertformat_clear(Gwn_VertFormat* format) #if TRUST_NO_ONE memset(format, 0, sizeof(Gwn_VertFormat)); #else - format->attrib_ct = 0; + format->attr_len = 0; format->packed = false; format->name_offset = 0; - format->name_ct = 0; + format->name_len = 0; for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++) - format->attribs[i].name_ct = 0; + format->attribs[i].name_len = 0; #endif } @@ -40,8 +40,8 @@ void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) // copy regular struct fields memcpy(dest, src, sizeof(Gwn_VertFormat)); - for (unsigned i = 0; i < dest->attrib_ct; i++) - for (unsigned j = 0; j < dest->attribs[i].name_ct; j++) + for (unsigned i = 0; i < dest->attr_len; i++) + for (unsigned j = 0; j < dest->attribs[i].name_len; j++) dest->attribs[i].name[j] = (char *)dest + (src->attribs[i].name[j] - ((char *)src)); } @@ -77,7 +77,7 @@ static unsigned attrib_sz(const Gwn_VertAttr *a) if (a->comp_type == GWN_COMP_I10) return 4; // always packed as 10_10_10_2 - return a->comp_ct * comp_sz(a->comp_type); + return a->comp_len * comp_sz(a->comp_type); } static unsigned attrib_align(const Gwn_VertAttr *a) @@ -86,19 +86,19 @@ static unsigned attrib_align(const Gwn_VertAttr *a) return 4; // always packed as 10_10_10_2 unsigned c = comp_sz(a->comp_type); - if (a->comp_ct == 3 && c <= 2) + if (a->comp_len == 3 && c <= 2) return 4 * c; // AMD HW can't fetch these well, so pad it out (other vendors too?) else return c; // most fetches are ok if components are naturally aligned } -unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_ct) +unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) { #if TRUST_NO_ONE assert(format->packed && format->stride > 0); #endif - return format->stride * vertex_ct; + return format->stride * vertex_len; } static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) @@ -130,13 +130,13 @@ static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) return name_copy; } -unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_ct, Gwn_VertFetchMode fetch_mode) +unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_len, Gwn_VertFetchMode fetch_mode) { #if TRUST_NO_ONE - assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more - assert(format->attrib_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more + assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more + assert(format->attr_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more assert(!format->packed); // packed means frozen/locked - assert((comp_ct >= 1 && comp_ct <= 4) || comp_ct == 8 || comp_ct == 12 || comp_ct == 16); + assert((comp_len >= 1 && comp_len <= 4) || comp_len == 8 || comp_len == 12 || comp_len == 16); switch (comp_type) { case GWN_COMP_F32: @@ -146,25 +146,25 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V case GWN_COMP_I10: // 10_10_10 format intended for normals (xyz) or colors (rgb) // extra component packed.w can be manually set to { -2, -1, 0, 1 } - assert(comp_ct == 3 || comp_ct == 4); + assert(comp_len == 3 || comp_len == 4); assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); // not strictly required, may relax later break; default: // integer types can be kept as int or converted/normalized to float assert(fetch_mode != GWN_FETCH_FLOAT); // only support float matrices (see Batch_update_program_bindings) - assert(comp_ct != 8 && comp_ct != 12 && comp_ct != 16); + assert(comp_len != 8 && comp_len != 12 && comp_len != 16); } #endif - format->name_ct++; // multiname support + format->name_len++; // multiname support - const unsigned attrib_id = format->attrib_ct++; + const unsigned attrib_id = format->attr_len++; Gwn_VertAttr* attrib = format->attribs + attrib_id; - attrib->name[attrib->name_ct++] = copy_attrib_name(format, name); + attrib->name[attrib->name_len++] = copy_attrib_name(format, name); attrib->comp_type = comp_type; attrib->gl_comp_type = convert_comp_type_to_gl(comp_type); - attrib->comp_ct = (comp_type == GWN_COMP_I10) ? 4 : comp_ct; // system needs 10_10_10_2 to be 4 or BGRA + attrib->comp_len = (comp_type == GWN_COMP_I10) ? 4 : comp_len; // system needs 10_10_10_2 to be 4 or BGRA attrib->sz = attrib_sz(attrib); attrib->offset = 0; // offsets & stride are calculated later (during pack) attrib->fetch_mode = fetch_mode; @@ -174,13 +174,13 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias) { - Gwn_VertAttr* attrib = format->attribs + (format->attrib_ct - 1); + Gwn_VertAttr* attrib = format->attribs + (format->attr_len - 1); #if TRUST_NO_ONE - assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more - assert(attrib->name_ct < GWN_VERT_ATTR_MAX_NAMES); + assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more + assert(attrib->name_len < GWN_VERT_ATTR_MAX_NAMES); #endif - format->name_ct++; // multiname support - attrib->name[attrib->name_ct++] = copy_attrib_name(format, alias); + format->name_len++; // multiname support + attrib->name[attrib->name_len++] = copy_attrib_name(format, alias); } unsigned padding(unsigned offset, unsigned alignment) @@ -220,7 +220,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) show_pack(0, a0->sz, 0); #endif - for (unsigned a_idx = 1; a_idx < format->attrib_ct; ++a_idx) + for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) { Gwn_VertAttr* a = format->attribs + a_idx; unsigned mid_padding = padding(offset, attrib_align(a)); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 5c3546f07a7..2251285be74 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -164,7 +164,7 @@ static Gwn_VertBuf *fill_arrows_vbo(const float scale) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -211,7 +211,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -263,7 +263,7 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, uvs; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -291,7 +291,7 @@ Gwn_Batch *DRW_cache_quad_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, uvs; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -344,7 +344,7 @@ Gwn_Batch *DRW_cache_cube_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -369,7 +369,7 @@ Gwn_Batch *DRW_cache_circle_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -400,7 +400,7 @@ Gwn_Batch *DRW_cache_square_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -427,7 +427,7 @@ Gwn_Batch *DRW_cache_single_line_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -452,7 +452,7 @@ Gwn_Batch *DRW_cache_single_line_endpoints_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -476,7 +476,7 @@ Gwn_Batch *DRW_cache_screenspace_circle_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -613,7 +613,7 @@ Gwn_Batch *DRW_cache_plain_axes_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -644,7 +644,7 @@ Gwn_Batch *DRW_cache_single_arrow_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -700,7 +700,7 @@ Gwn_Batch *DRW_cache_empty_cone_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -752,7 +752,7 @@ Gwn_Batch *DRW_cache_axis_names_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* Using 3rd component as axis indicator */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -810,7 +810,7 @@ Gwn_Batch *DRW_cache_image_plane_get(void) const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; static Gwn_VertFormat format = { 0 }; static struct { uint pos, texCoords; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.texCoords = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -831,7 +831,7 @@ Gwn_Batch *DRW_cache_image_plane_wire_get(void) const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); @@ -854,7 +854,7 @@ Gwn_Batch *DRW_cache_field_wind_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -891,7 +891,7 @@ Gwn_Batch *DRW_cache_field_force_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -929,7 +929,7 @@ Gwn_Batch *DRW_cache_field_vortex_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -966,7 +966,7 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1015,7 +1015,7 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1070,7 +1070,7 @@ Gwn_Batch *DRW_cache_lamp_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -1102,7 +1102,7 @@ Gwn_Batch *DRW_cache_lamp_shadows_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -1133,7 +1133,7 @@ Gwn_Batch *DRW_cache_lamp_sunrays_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -1168,7 +1168,7 @@ Gwn_Batch *DRW_cache_lamp_area_square_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1201,7 +1201,7 @@ Gwn_Batch *DRW_cache_lamp_area_disk_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1235,7 +1235,7 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1313,7 +1313,7 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, n1, n2; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -1372,7 +1372,7 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1410,7 +1410,7 @@ Gwn_Batch *DRW_cache_speaker_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1483,7 +1483,7 @@ Gwn_Batch *DRW_cache_lightprobe_cube_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1528,7 +1528,7 @@ Gwn_Batch *DRW_cache_lightprobe_grid_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1581,7 +1581,7 @@ Gwn_Batch *DRW_cache_lightprobe_planar_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1709,7 +1709,7 @@ Gwn_Batch *DRW_cache_bone_octahedral_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor, snor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -1875,7 +1875,7 @@ Gwn_Batch *DRW_cache_bone_box_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor, snor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -1942,7 +1942,7 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1989,7 +1989,7 @@ Gwn_Batch *DRW_cache_bone_envelope_outline_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos0, pos1, pos2; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.pos2 = GWN_vertformat_attr_add(&format, "pos2", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -2045,7 +2045,7 @@ Gwn_Batch *DRW_cache_bone_point_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2081,7 +2081,7 @@ Gwn_Batch *DRW_cache_bone_point_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -2115,7 +2115,7 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos0, pos1; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -2172,7 +2172,7 @@ Gwn_Batch *DRW_cache_bone_stick_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, flag; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.flag = GWN_vertformat_attr_add(&format, "flag", GWN_COMP_U32, 1, GWN_FETCH_INT); } @@ -2314,7 +2314,7 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint axis, pos, col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.axis = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); attr_id.pos = GWN_vertformat_attr_add(&format, "screenPos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.col = GWN_vertformat_attr_add(&format, "colorAxis", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -2456,7 +2456,7 @@ Gwn_Batch *DRW_cache_camera_get(void) if (!SHC.drw_camera) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); } @@ -2489,7 +2489,7 @@ Gwn_Batch *DRW_cache_camera_frame_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); } @@ -2515,7 +2515,7 @@ Gwn_Batch *DRW_cache_camera_tria_get(void) if (!SHC.drw_camera_tria) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); } @@ -2552,7 +2552,7 @@ Gwn_Batch *DRW_cache_single_vert_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2987,7 +2987,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) static Gwn_VertFormat format = { 0 }; static uint pos_id, axis_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -3034,7 +3034,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) static Gwn_VertFormat format = { 0 }; static uint pos_id, axis_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -3085,7 +3085,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) static Gwn_VertFormat format = { 0 }; static uint pos_id, axis_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -3133,7 +3133,7 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) static Gwn_VertFormat format = { 0 }; static struct { uint pos, color; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.color = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); } diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 1bf34953dc6..4de1dfd24f5 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -503,7 +503,7 @@ static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, Cur if (cache->wire.verts == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -581,7 +581,7 @@ static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, C if (cache->normal.verts == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -675,7 +675,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) if (cache->overlay.verts == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); @@ -743,7 +743,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); @@ -850,7 +850,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, C EditFont *ef = rdata->text.edit_font; static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -924,7 +924,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, C if (cache->text.cursor == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index 3eecff024a1..8d187af0501 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -122,7 +122,7 @@ Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -228,7 +228,7 @@ Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(Lis static Gwn_VertFormat shaded_triangles_format = { 0 }; static struct { uint pos, nor, uv; } attr_id; - if (shaded_triangles_format.attrib_ct == 0) { + if (shaded_triangles_format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&shaded_triangles_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&shaded_triangles_format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 6046d9854fb..99dce2d7343 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -507,7 +507,7 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt) if (cache->overlay_verts == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 6c6e2d78206..7a72622cb9e 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -2159,7 +2159,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( static Gwn_VertFormat format = { 0 }; static struct { uint uv; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.uv = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -2222,7 +2222,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( if (*r_vbo == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); } @@ -2374,7 +2374,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( if (cache->ed_fcenter_pos_with_nor_and_sel == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.data = GWN_vertformat_attr_add(&format, "norAndFlag", GWN_COMP_I10, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); } @@ -2418,7 +2418,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( if (cache->ed_edge_pos == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2463,7 +2463,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( if (cache->ed_vert_pos == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2513,7 +2513,7 @@ static Gwn_VertBuf *mesh_create_facedot_select_id( { static Gwn_VertFormat format = { 0 }; static struct { uint pos, col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -2561,7 +2561,7 @@ static Gwn_VertBuf *mesh_create_edges_select_id( { static Gwn_VertFormat format = { 0 }; static struct { uint pos, col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -2611,7 +2611,7 @@ static Gwn_VertBuf *mesh_create_verts_select_id( { static Gwn_VertFormat format = { 0 }; static struct { uint pos, col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -2671,7 +2671,7 @@ static Gwn_VertBuf *mesh_create_tri_weights( static Gwn_VertFormat format = { 0 }; static struct { uint col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2731,7 +2731,7 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors( static Gwn_VertFormat format = { 0 }; static struct { uint col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); } @@ -2791,7 +2791,7 @@ static Gwn_VertBuf *mesh_create_tri_select_id( static Gwn_VertFormat format = { 0 }; static struct { uint col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -2847,7 +2847,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( if (cache->pos_in_order == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* Normal is padded so that the vbo can be used as a buffer texture */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); @@ -2887,7 +2887,7 @@ static Gwn_VertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id) { static Gwn_VertFormat format_pos = { 0 }; static uint pos_id; - if (format_pos.attrib_ct == 0) { + if (format_pos.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format_pos, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } *r_pos_id = pos_id; @@ -2899,7 +2899,7 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno static Gwn_VertFormat format_nor = { 0 }; static Gwn_VertFormat format_nor_loop = { 0 }; static uint vnor_id, vnor_loop_id, lnor_id; - if (format_nor.attrib_ct == 0) { + if (format_nor.attr_len == 0) { vnor_id = GWN_vertformat_attr_add(&format_nor, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); vnor_loop_id = GWN_vertformat_attr_add(&format_nor_loop, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); lnor_id = GWN_vertformat_attr_add(&format_nor_loop, "lnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); @@ -2919,7 +2919,7 @@ static Gwn_VertFormat *edit_mesh_overlay_data_format(uint *r_data_id) { static Gwn_VertFormat format_flag = { 0 }; static uint data_id; - if (format_flag.attrib_ct == 0) { + if (format_flag.attr_len == 0) { data_id = GWN_vertformat_attr_add(&format_flag, "data", GWN_COMP_U8, 4, GWN_FETCH_INT); } *r_data_id = data_id; @@ -3657,7 +3657,7 @@ static Gwn_VertBuf *mesh_create_edge_pos_with_sel( static Gwn_VertFormat format = { 0 }; static struct { uint pos, sel; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.sel = GWN_vertformat_attr_add(&format, "select", GWN_COMP_U8, 1, GWN_FETCH_INT); } @@ -3744,7 +3744,7 @@ static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data( static Gwn_VertFormat format = { 0 }; static struct { uint data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_I8, 1, GWN_FETCH_INT); } @@ -3997,7 +3997,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) /* create batch from DM */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, n1, n2; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 60b367f7b1a..df67d34d566 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -1219,7 +1219,7 @@ static void particle_batch_cache_ensure_pos( GWN_VERTBUF_DISCARD_SAFE(point_cache->pos); - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); rot_id = GWN_vertformat_attr_add(&format, "rot", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); @@ -1424,7 +1424,7 @@ static void particle_batch_cache_ensure_edit_inner_pos( GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); @@ -1495,7 +1495,7 @@ static void particle_batch_cache_ensure_edit_tip_pos( GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index e5b5ec31823..e322d4780d5 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -215,7 +215,7 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) realloc_size = i + 1; uint vert_len = DRW_shgroup_get_instance_count(bbuf->shgroup); vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ - if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_ct) { + if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_len) { uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; GWN_vertbuf_data_resize(bbuf->vert, size); @@ -247,7 +247,7 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) realloc_size = i + 1; uint vert_len = DRW_shgroup_get_instance_count(ibuf->shgroup); vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ - if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_ct) { + if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_len) { uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; GWN_vertbuf_data_resize(ibuf->vert, size); diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 2e6079e1661..c259633982e 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -553,7 +553,7 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at { #ifdef USE_GPU_SELECT if (G.f & G_PICKSEL) { - if (shgroup->instance_count == shgroup->inst_selectid->vertex_ct) { + if (shgroup->instance_count == shgroup->inst_selectid->vertex_len) { GWN_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32); } GWN_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id); @@ -564,7 +564,7 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at UNUSED_VARS_NDEBUG(attr_len); for (int i = 0; i < attr_len; ++i) { - if (shgroup->instance_count == shgroup->instance_vbo->vertex_ct) { + if (shgroup->instance_count == shgroup->instance_vbo->vertex_len) { GWN_vertbuf_data_resize(shgroup->instance_vbo, shgroup->instance_count + 32); } GWN_vertbuf_attr_set(shgroup->instance_vbo, i, shgroup->instance_count, attr[i]); @@ -651,7 +651,7 @@ static void drw_shgroup_instance_init( shgroup->instance_geom = batch; #ifndef NDEBUG - shgroup->attribs_count = format->attrib_ct; + shgroup->attribs_count = format->attr_len; #endif DRW_instancing_buffer_request(DST.idatalist, format, batch, shgroup, @@ -662,7 +662,7 @@ static void drw_shgroup_instance_init( /* Not actually used for rendering but alloced in one chunk. * Plus we don't have to care about ownership. */ static Gwn_VertFormat inst_select_format = {0}; - if (inst_select_format.attrib_ct == 0) { + if (inst_select_format.attr_len == 0) { GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT); } Gwn_Batch *batch_dummy; /* Not used */ @@ -679,7 +679,7 @@ static void drw_shgroup_batching_init( drw_shgroup_init(shgroup, shader); #ifndef NDEBUG - shgroup->attribs_count = (format != NULL) ? format->attrib_ct : 0; + shgroup->attribs_count = (format != NULL) ? format->attr_len : 0; #endif BLI_assert(format != NULL); @@ -698,7 +698,7 @@ static void drw_shgroup_batching_init( if (G.f & G_PICKSEL) { /* Not actually used for rendering but alloced in one chunk. */ static Gwn_VertFormat inst_select_format = {0}; - if (inst_select_format.attrib_ct == 0) { + if (inst_select_format.attr_len == 0) { GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT); } Gwn_Batch *batch; /* Not used */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index cfbf6e711c3..03ff6593c59 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -259,7 +259,7 @@ static struct { static Gwn_VertFormat *vflag_format(void) { - if (g_ui_batch_cache.format.attrib_ct == 0) { + if (g_ui_batch_cache.format.attr_len == 0) { Gwn_VertFormat *format = &g_ui_batch_cache.format; g_ui_batch_cache.vflag_id = GWN_vertformat_attr_add(format, "vflag", GWN_COMP_U32, 1, GWN_FETCH_INT); } diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index baeaeb018d7..4717ef309f3 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -371,10 +371,10 @@ static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char r } } -static void mask_draw_array(unsigned int pos, Gwn_PrimType prim_type, const float (*points)[2], unsigned int vertex_ct) +static void mask_draw_array(unsigned int pos, Gwn_PrimType prim_type, const float (*points)[2], unsigned int vertex_len) { - immBegin(prim_type, vertex_ct); - for (unsigned int i = 0; i < vertex_ct; ++i) { + immBegin(prim_type, vertex_len); + for (unsigned int i = 0; i < vertex_len; ++i) { immVertex2fv(pos, points[i]); } immEnd(); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 0416ecba72c..42ad34b659b 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -486,14 +486,14 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) const int step = (layout->tile_w + 2 * layout->tile_border_x); - unsigned int vertex_ct = 0; + unsigned int vertex_len = 0; int sx = (int)v2d->tot.xmin; while (sx < v2d->cur.xmax) { sx += step; - vertex_ct += 4; /* vertex_count = 2 points per line * 2 lines per divider */ + vertex_len += 4; /* vertex_count = 2 points per line * 2 lines per divider */ } - if (vertex_ct > 0) { + if (vertex_len > 0) { int v1[2], v2[2]; unsigned char col_hi[3], col_lo[3]; @@ -508,7 +508,7 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_ct); + immBegin(GWN_PRIM_LINES, vertex_len); sx = (int)v2d->tot.xmin; while (sx < v2d->cur.xmax) { diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 24df0a61012..f0d6b5c2a71 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -765,7 +765,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immEnd(); /* Then draw each face contour separately. */ - if (loop_vbo->vertex_ct != 0) { + if (loop_vbo->vertex_len != 0) { GWN_batch_program_use_begin(loop_batch); unsigned int index = 0, loop_vbo_count; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { @@ -792,7 +792,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* Create a color buffer. */ static Gwn_VertFormat format = { 0 }; static uint shdr_col; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { shdr_col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); } diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 9091f3eff0b..c3737787933 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1567,7 +1567,7 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar static Gwn_VertFormat format = { 0 }; static unsigned int pos_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 59d88e81822..6194e720156 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -126,7 +126,7 @@ Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( /* We have vertices and tris, make a batch from this. */ static Gwn_VertFormat format = {0}; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -230,7 +230,7 @@ Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( /* We have vertices and tris, make a batch from this. */ static Gwn_VertFormat format = {0}; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c index 10cbd16490b..eaf0a6821ff 100644 --- a/source/blender/gpu/intern/gpu_batch_presets.c +++ b/source/blender/gpu/intern/gpu_batch_presets.c @@ -65,7 +65,7 @@ static ListBase presets_list = {NULL, NULL}; static Gwn_VertFormat *preset_3D_format(void) { - if (g_presets_3d.format.attrib_ct == 0) { + if (g_presets_3d.format.attr_len == 0) { Gwn_VertFormat *format = &g_presets_3d.format; g_presets_3d.attr_id.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); g_presets_3d.attr_id.nor = GWN_vertformat_attr_add(format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 688386810ea..dfaa5cb5d72 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -133,7 +133,7 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int v /* match 'VertexBufferFormat' */ static Gwn_VertFormat format = {0}; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { g_vbo_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); g_vbo_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); g_vbo_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); @@ -142,7 +142,7 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int v buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_DYNAMIC); GWN_vertbuf_data_alloc(buffers->vert_buf, vert_ct); } - else if (vert_ct != buffers->vert_buf->vertex_ct) { + else if (vert_ct != buffers->vert_buf->vertex_len) { GWN_vertbuf_data_resize(buffers->vert_buf, vert_ct); } #else diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index ae037ca442e..b7385bdf07c 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -823,12 +823,12 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) Gwn_VertAttr *attr = &format->attribs[0]; /* Detect incompatible cases (not supported by texture buffers) */ - BLI_assert(format->attrib_ct == 1 && vert->vbo_id != 0); - BLI_assert(attr->comp_ct != 3); /* Not until OGL 4.0 */ + BLI_assert(format->attr_len == 1 && vert->vbo_id != 0); + BLI_assert(attr->comp_len != 3); /* Not until OGL 4.0 */ BLI_assert(attr->comp_type != GWN_COMP_I10); BLI_assert(attr->fetch_mode != GWN_FETCH_INT_TO_FLOAT); - unsigned int byte_per_comp = attr->sz / attr->comp_ct; + unsigned int byte_per_comp = attr->sz / attr->comp_len; bool is_uint = ELEM(attr->comp_type, GWN_COMP_U8, GWN_COMP_U16, GWN_COMP_U32); /* Cannot fetch signed int or 32bit ints as normalized float. */ @@ -839,7 +839,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) GPUTextureFormat data_type; switch (attr->fetch_mode) { case GWN_FETCH_FLOAT: - switch (attr->comp_ct) { + switch (attr->comp_len) { case 1: data_type = GPU_R32F; break; case 2: data_type = GPU_RG32F; break; // case 3: data_type = GPU_RGB32F; break; /* Not supported */ @@ -847,7 +847,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) } break; case GWN_FETCH_INT: - switch (attr->comp_ct) { + switch (attr->comp_len) { case 1: switch (byte_per_comp) { case 1: data_type = (is_uint) ? GPU_R8UI : GPU_R8I; break; @@ -872,7 +872,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) } break; case GWN_FETCH_INT_TO_FLOAT_UNIT: - switch (attr->comp_ct) { + switch (attr->comp_len) { case 1: data_type = (byte_per_comp == 1) ? GPU_R8 : GPU_R16; break; case 2: data_type = (byte_per_comp == 1) ? GPU_RG8 : GPU_RG16; break; default: data_type = (byte_per_comp == 1) ? GPU_RGBA8 : GPU_RGBA16; break; diff --git a/source/blender/python/gawain/gwn_py_types.c b/source/blender/python/gawain/gwn_py_types.c index 9ddad009a12..7527830eb63 100644 --- a/source/blender/python/gawain/gwn_py_types.c +++ b/source/blender/python/gawain/gwn_py_types.c @@ -210,7 +210,7 @@ static void fill_format_elem(void *data_dst_void, PyObject *py_src, const Gwn_Ve /* No error checking, callers must run PyErr_Occurred */ static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr) { - const uint len = attr->comp_ct; + const uint len = attr->comp_len; /** * Args are constants, so range checks will be optimized out if they're nop's. @@ -247,15 +247,15 @@ static bool bpygwn_vertbuf_fill_impl( const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast); - if (seq_len != vbo->vertex_ct) { + if (seq_len != vbo->vertex_len) { PyErr_Format(PyExc_ValueError, "Expected a sequence of size %d, got %d", - vbo->vertex_ct, seq_len); + vbo->vertex_len, seq_len); } PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast); - if (attr->comp_ct == 1) { + if (attr->comp_len == 1) { for (uint i = 0; i < seq_len; i++) { uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step); PyObject *item = seq_items[i]; @@ -273,10 +273,10 @@ static bool bpygwn_vertbuf_fill_impl( ok = false; goto finally; } - if (PyTuple_GET_SIZE(item) != attr->comp_ct) { + if (PyTuple_GET_SIZE(item) != attr->comp_len) { PyErr_Format(PyExc_ValueError, "expected a tuple of size %d, got %d", - attr->comp_ct, PyTuple_GET_SIZE(item)); + attr->comp_len, PyTuple_GET_SIZE(item)); ok = false; goto finally; } @@ -300,7 +300,7 @@ finally: #if 0 static int bpygwn_find_id(const Gwn_VertFormat *fmt, const char *id) { - for (int i = 0; i < fmt->attrib_ct; i++) { + for (int i = 0; i < fmt->attr_len; i++) { for (uint j = 0; j < fmt->name_ct; j++) { if (STREQ(fmt->attribs[i].name[j], id)) { return i; @@ -346,7 +346,7 @@ static PyObject *bpygwn_VertFormat_attr_add(BPyGwn_VertFormat *self, PyObject *a Gwn_VertFetchMode fetch_mode; } params; - if (self->fmt.attrib_ct == GWN_VERT_ATTR_MAX_LEN) { + if (self->fmt.attr_len == GWN_VERT_ATTR_MAX_LEN) { PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GWN_VERT_ATTR_MAX_LEN)); return NULL; } @@ -440,7 +440,7 @@ static PyObject *bpygwn_VertBuf_fill(BPyGwn_VertBuf *self, PyObject *args, PyObj return NULL; } - if (params.id >= self->buf->format.attrib_ct) { + if (params.id >= self->buf->format.attr_len) { PyErr_Format(PyExc_ValueError, "Format id %d out of range", params.id); @@ -532,10 +532,10 @@ static PyObject *bpygwn_VertBatch_vertbuf_add(BPyGwn_Batch *self, BPyGwn_VertBuf return NULL; } - if (self->batch->verts[0]->vertex_ct != py_buf->buf->vertex_ct) { + if (self->batch->verts[0]->vertex_len != py_buf->buf->vertex_len) { PyErr_Format(PyExc_TypeError, "Expected %d length, got %d", - self->batch->verts[0]->vertex_ct, py_buf->buf->vertex_ct); + self->batch->verts[0]->vertex_len, py_buf->buf->vertex_len); return NULL; } -- cgit v1.2.3 From 9fb912518425e52e7b13c35dd79770c2715c8dd6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 13:14:49 +0200 Subject: Cleanup: rename 'ct' to 'len' for gpu --- source/blender/gpu/GPU_framebuffer.h | 2 +- source/blender/gpu/GPU_material.h | 2 +- source/blender/gpu/intern/gpu_buffers.c | 10 +++++----- source/blender/gpu/intern/gpu_framebuffer.c | 4 ++-- source/blender/gpu/intern/gpu_material.c | 28 ++++++++++++++-------------- source/blender/python/gawain/gwn_py_types.c | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h index 084ee4c0459..ddf485c3c21 100644 --- a/source/blender/gpu/GPU_framebuffer.h +++ b/source/blender/gpu/GPU_framebuffer.h @@ -117,7 +117,7 @@ void GPU_framebuffer_texture_detach_slot( GPU_framebuffer_config_array(*(_fb), config, (sizeof(config) / sizeof(GPUAttachment))); \ } while (0) -void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_ct); +void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len); #define GPU_ATTACHMENT_NONE \ {.tex = NULL, .layer = -1, .mip = 0} diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index a65c09152ee..8ddb7b87c4a 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -241,7 +241,7 @@ GPUBuiltin GPU_get_material_builtins(GPUMaterial *material); void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], short *falloff_type, float *sharpness); struct GPUUniformBuffer *GPU_material_sss_profile_get( - GPUMaterial *material, int sample_ct, struct GPUTexture **tex_profile); + GPUMaterial *material, int sample_len, struct GPUTexture **tex_profile); /* High level functions to create and use GPU materials */ GPUMaterial *GPU_material_from_nodetree_find( diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index dfaa5cb5d72..1a4750652cc 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -126,7 +126,7 @@ static void gpu_material_diffuse_get(int UNUSED(nr), float diff[4]) /* Allocates a non-initialized buffer to be sent to GPU. * Return is false it indicates that the memory map failed. */ -static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int vert_ct) +static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int vert_len) { if (buffers->vert_buf == NULL) { /* Initialize vertex buffer */ @@ -140,15 +140,15 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int v } #if 0 buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_DYNAMIC); - GWN_vertbuf_data_alloc(buffers->vert_buf, vert_ct); + GWN_vertbuf_data_alloc(buffers->vert_buf, vert_len); } - else if (vert_ct != buffers->vert_buf->vertex_len) { - GWN_vertbuf_data_resize(buffers->vert_buf, vert_ct); + else if (vert_len != buffers->vert_buf->vertex_len) { + GWN_vertbuf_data_resize(buffers->vert_buf, vert_len); } #else buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC); } - GWN_vertbuf_data_alloc(buffers->vert_buf, vert_ct); + GWN_vertbuf_data_alloc(buffers->vert_buf, vert_len); #endif return buffers->vert_buf->data != NULL; } diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index eabd501f1d5..ffc72718e42 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -300,7 +300,7 @@ void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, GPUTexture *tex) * Setting GPUAttachment.mip to -1 will leave the texture in this slot. * Setting GPUAttachment.tex to NULL will detach the texture in this slot. **/ -void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_ct) +void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len) { if (config[0].tex) { BLI_assert(GPU_texture_depth(config[0].tex)); @@ -317,7 +317,7 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *confi } int slot = 0; - for (int i = 1; i < config_ct; ++i, ++slot) { + for (int i = 1; i < config_len; ++i, ++slot) { if (config[i].tex != NULL) { BLI_assert(GPU_texture_depth(config[i].tex) == false); gpu_framebuffer_texture_attach_ex(fb, config[i].tex, slot, config[i].layer, config[i].mip); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index c224e3e0e32..bd0e35f5ab6 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -354,7 +354,7 @@ static float eval_integral(float x0, float x1, short falloff_type, float sharpne #undef INTEGRAL_RESOLUTION static void compute_sss_kernel( - GPUSssKernelData *kd, float radii[3], int sample_ct, int falloff_type, float sharpness) + GPUSssKernelData *kd, float radii[3], int sample_len, int falloff_type, float sharpness) { float rad[3]; /* Minimum radius */ @@ -390,13 +390,13 @@ static void compute_sss_kernel( } /* Compute samples locations on the 1d kernel [-1..1] */ - sss_calculate_offsets(kd, sample_ct, SSS_EXPONENT); + sss_calculate_offsets(kd, sample_len, SSS_EXPONENT); /* Weights sum for normalization */ float sum[3] = {0.0f, 0.0f, 0.0f}; /* Compute integral of each sample footprint */ - for (int i = 0; i < sample_ct; i++) { + for (int i = 0; i < sample_len; i++) { float x0, x1; if (i == 0) { @@ -406,8 +406,8 @@ static void compute_sss_kernel( x0 = (kd->kernel[i - 1][3] + kd->kernel[i][3]) / 2.0f; } - if (i == sample_ct - 1) { - x1 = kd->kernel[sample_ct - 1][3] + fabsf(kd->kernel[sample_ct - 2][3] - kd->kernel[sample_ct - 1][3]) / 2.0f; + if (i == sample_len - 1) { + x1 = kd->kernel[sample_len - 1][3] + fabsf(kd->kernel[sample_len - 2][3] - kd->kernel[sample_len - 1][3]) / 2.0f; } else { x1 = (kd->kernel[i][3] + kd->kernel[i + 1][3]) / 2.0f; @@ -428,25 +428,25 @@ static void compute_sss_kernel( for (int i = 0; i < 3; ++i) { if (sum[i] > 0.0f) { /* Normalize */ - for (int j = 0; j < sample_ct; j++) { + for (int j = 0; j < sample_len; j++) { kd->kernel[j][i] /= sum[i]; } } else { /* Avoid 0 kernel sum. */ - kd->kernel[sample_ct / 2][i] = 1.0f; + kd->kernel[sample_len / 2][i] = 1.0f; } } /* Put center sample at the start of the array (to sample first) */ float tmpv[4]; - copy_v4_v4(tmpv, kd->kernel[sample_ct / 2]); - for (int i = sample_ct / 2; i > 0; i--) { + copy_v4_v4(tmpv, kd->kernel[sample_len / 2]); + for (int i = sample_len / 2; i > 0; i--) { copy_v4_v4(kd->kernel[i], kd->kernel[i - 1]); } copy_v4_v4(kd->kernel[0], tmpv); - kd->samples = sample_ct; + kd->samples = sample_len; } #define INTEGRAL_RESOLUTION 512 @@ -523,12 +523,12 @@ void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], shor } } -struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_ct, GPUTexture **tex_profile) +struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_len, GPUTexture **tex_profile) { if (!material->sss_enabled) return NULL; - if (material->sss_dirty || (material->sss_samples != sample_ct)) { + if (material->sss_dirty || (material->sss_samples != sample_len)) { GPUSssKernelData kd; float sharpness = material->sss_sharpness; @@ -536,7 +536,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int /* XXX Black magic but it seems to fit. Maybe because we integrate -1..1 */ sharpness *= 0.5f; - compute_sss_kernel(&kd, material->sss_radii, sample_ct, material->sss_falloff, sharpness); + compute_sss_kernel(&kd, material->sss_radii, sample_len, material->sss_falloff, sharpness); /* Update / Create UBO */ GPU_uniformbuffer_update(material->sss_profile, &kd); @@ -553,7 +553,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int MEM_freeN(translucence_profile); - material->sss_samples = sample_ct; + material->sss_samples = sample_len; material->sss_dirty = false; } diff --git a/source/blender/python/gawain/gwn_py_types.c b/source/blender/python/gawain/gwn_py_types.c index 7527830eb63..bdf0be9f7e1 100644 --- a/source/blender/python/gawain/gwn_py_types.c +++ b/source/blender/python/gawain/gwn_py_types.c @@ -301,7 +301,7 @@ finally: static int bpygwn_find_id(const Gwn_VertFormat *fmt, const char *id) { for (int i = 0; i < fmt->attr_len; i++) { - for (uint j = 0; j < fmt->name_ct; j++) { + for (uint j = 0; j < fmt->name_len; j++) { if (STREQ(fmt->attribs[i].name[j], id)) { return i; } -- cgit v1.2.3 From 73d2d75eeda3b15e1ca1a3136ad9818cd230dbbc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 13:19:10 +0200 Subject: Cleanup: rename 'ct' to 'len' for editors --- .../shaders/workbench_shadow_caps_geom.glsl | 12 +++++----- .../workbench/shaders/workbench_shadow_geom.glsl | 12 +++++----- source/blender/editors/animation/keyframes_draw.c | 16 ++++++------- source/blender/editors/interface/interface_draw.c | 12 +++++----- source/blender/editors/interface/interface_panel.c | 14 +++++------ .../editors/space_clip/clip_dopesheet_draw.c | 12 +++++----- source/blender/editors/space_nla/nla_draw.c | 6 ++--- source/blender/editors/space_node/node_draw.c | 28 +++++++++++----------- .../editors/space_sequencer/sequencer_draw.c | 6 ++--- 9 files changed, 59 insertions(+), 59 deletions(-) diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl index 948392bd8ee..d8c8f22ed1c 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl @@ -6,24 +6,24 @@ #ifdef DOUBLE_MANIFOLD # ifdef USE_INVOC_EXT -# define invoc_ct 2 +# define invoc_len 2 # else -# define vert_ct 6 +# define vert_len 6 # endif #else # ifdef USE_INVOC_EXT -# define invoc_ct 2 +# define invoc_len 2 # else -# define vert_ct 6 +# define vert_len 6 # endif #endif #ifdef USE_INVOC_EXT -layout(triangles, invocations = invoc_ct) in; +layout(triangles, invocations = invoc_len) in; layout(triangle_strip, max_vertices = 3) out; #else layout(triangles) in; -layout(triangle_strip, max_vertices = vert_ct) out; +layout(triangle_strip, max_vertices = vert_len) out; #endif uniform vec3 lightDirection = vec3(0.57, 0.57, -0.57); diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl index 5a31aa34932..7418f86a58e 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_geom.glsl @@ -6,24 +6,24 @@ #ifdef DOUBLE_MANIFOLD # ifdef USE_INVOC_EXT -# define invoc_ct 2 +# define invoc_len 2 # else -# define vert_ct 8 +# define vert_len 8 # endif #else # ifdef USE_INVOC_EXT -# define invoc_ct 1 +# define invoc_len 1 # else -# define vert_ct 4 +# define vert_len 4 # endif #endif #ifdef USE_INVOC_EXT -layout(lines_adjacency, invocations = invoc_ct) in; +layout(lines_adjacency, invocations = invoc_len) in; layout(triangle_strip, max_vertices = 4) out; #else layout(lines_adjacency) in; -layout(triangle_strip, max_vertices = vert_ct) out; +layout(triangle_strip, max_vertices = vert_len) out; #endif uniform vec3 lightDirection = vec3(0.57, 0.57, -0.57); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index e06c443e8f0..78ce24db503 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -585,20 +585,20 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa copy_v4_v4(unsel_mhcol, unsel_color); unsel_mhcol[3] *= 0.8f; - unsigned int block_ct = 0; + uint block_len = 0; for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) { if (actkeyblock_is_valid(ab, keys)) { - block_ct++; + block_len++; } } - if (block_ct > 0) { + if (block_len > 0) { Gwn_VertFormat *format = immVertexFormat(); uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_TRIS, 6 * block_ct); + immBegin(GWN_PRIM_TRIS, 6 * block_len); for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) { if (actkeyblock_is_valid(ab, keys)) { if (ab->flag & ACTKEYBLOCK_FLAG_MOVING_HOLD) { @@ -622,16 +622,16 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa if (keys) { /* count keys */ - unsigned int key_ct = 0; + uint key_len = 0; for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) { /* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw * - this might give some improvements, since we current have to flip between view/region matrices */ if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) - key_ct++; + key_len++; } - if (key_ct > 0) { + if (key_len > 0) { /* draw keys */ Gwn_VertFormat *format = immVertexFormat(); uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -640,7 +640,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, key_ct); + immBegin(GWN_PRIM_POINTS, key_len); for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) { if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) { diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 336b996f169..0a8a6d1f832 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -166,16 +166,16 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float mul_v2_fl(vec[a], rad); } - unsigned int vert_ct = 0; - vert_ct += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 9 : 1; - vert_ct += (roundboxtype & UI_CNR_TOP_RIGHT) ? 9 : 1; - vert_ct += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1; - vert_ct += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1; + uint vert_len = 0; + vert_len += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 9 : 1; + vert_len += (roundboxtype & UI_CNR_TOP_RIGHT) ? 9 : 1; + vert_len += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1; + vert_len += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_ct); + immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_len); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { immVertex2f(pos, maxx - rad, miny); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index ccb025d534f..538f188c436 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1738,22 +1738,22 @@ static void ui_panel_category_draw_tab( mul_v2_fl(vec[a], rad); } - unsigned int vert_ct = 0; + uint vert_len = 0; if (use_highlight) { - vert_ct += (roundboxtype & UI_CNR_TOP_RIGHT) ? 6 : 1; - vert_ct += (roundboxtype & UI_CNR_TOP_LEFT) ? 6 : 1; + vert_len += (roundboxtype & UI_CNR_TOP_RIGHT) ? 6 : 1; + vert_len += (roundboxtype & UI_CNR_TOP_LEFT) ? 6 : 1; } if (use_highlight && !use_shadow) { - vert_ct++; + vert_len++; } else { - vert_ct += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 6 : 1; - vert_ct += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 6 : 1; + vert_len += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 6 : 1; + vert_len += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 6 : 1; } immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_STRIP, vert_ct); + immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_STRIP, vert_len); /* start with corner right-top */ if (use_highlight) { diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 60a8c77bcc4..76450cba3cb 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -128,7 +128,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) float strip[4], selected_strip[4]; float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); - unsigned int keyframe_ct = 0; + uint keyframe_len = 0; Gwn_VertFormat *format = immVertexFormat(); uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -186,10 +186,10 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) if (start_frame != end_frame) { immRectf(pos_id, start_frame, (float) y - STRIP_HEIGHT_HALF, end_frame, (float) y + STRIP_HEIGHT_HALF); - keyframe_ct += 2; + keyframe_len += 2; } else { - keyframe_ct++; + keyframe_len++; } } @@ -199,7 +199,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) MovieTrackingMarker *marker = &track->markers[i]; if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0) { - keyframe_ct++; + keyframe_len++; } i++; @@ -212,7 +212,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) immUnbindProgram(); - if (keyframe_ct > 0) { + if (keyframe_len > 0) { /* draw keyframe markers */ format = immVertexFormat(); pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -222,7 +222,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, keyframe_ct); + immBegin(GWN_PRIM_POINTS, keyframe_len); /* all same size with black outline */ immAttrib1f(size_id, 2.0f * STRIP_HEIGHT_HALF); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index b9f92f383c4..3f1bd0db74c 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -138,9 +138,9 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa /* count keys before drawing */ /* Note: It's safe to cast DLRBT_Tree, as it's designed to degrade down to a ListBase */ - unsigned int key_ct = BLI_listbase_count((ListBase *)&keys); + uint key_len = BLI_listbase_count((ListBase *)&keys); - if (key_ct > 0) { + if (key_len > 0) { format = immVertexFormat(); pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); @@ -148,7 +148,7 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, key_ct); + immBegin(GWN_PRIM_POINTS, key_len); /* - disregard the selection status of keyframes so they draw a certain way * - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index d2e189486df..5b91796d41c 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -758,10 +758,10 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *node, bool draw_outputs, bool select_all) { - const unsigned int total_input_ct = BLI_listbase_count(&node->inputs); - const unsigned int total_output_ct = BLI_listbase_count(&node->outputs); + const uint total_input_len = BLI_listbase_count(&node->inputs); + const uint total_output_len = BLI_listbase_count(&node->outputs); - if (total_input_ct + total_output_ct == 0) { + if (total_input_len + total_output_len == 0) { return; } @@ -788,17 +788,17 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * immUniform1f("outlineWidth", 1.0f); immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 0.6f); - immBeginAtMost(GWN_PRIM_POINTS, total_input_ct + total_output_ct); + immBeginAtMost(GWN_PRIM_POINTS, total_input_len + total_output_len); } /* socket inputs */ - short selected_input_ct = 0; + short selected_input_len = 0; bNodeSocket *sock; for (sock = node->inputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; if (select_all || (sock->flag & SELECT)) { - ++selected_input_ct; + ++selected_input_len; continue; } @@ -806,13 +806,13 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * } /* socket outputs */ - short selected_output_ct = 0; + short selected_output_len = 0; if (draw_outputs) { for (sock = node->outputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; if (select_all || (sock->flag & SELECT)) { - ++selected_output_ct; + ++selected_output_len; continue; } @@ -825,36 +825,36 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * } /* go back and draw selected sockets */ - if (selected_input_ct + selected_output_ct > 0) { + if (selected_input_len + selected_output_len > 0) { /* outline for selected sockets */ float c[3]; UI_GetThemeColor3fv(TH_TEXT_HI, c); immUniform4f("outlineColor", c[0], c[1], c[2], 1.0f); immUniform1f("outlineWidth", 1.5f); - immBegin(GWN_PRIM_POINTS, selected_input_ct + selected_output_ct); + immBegin(GWN_PRIM_POINTS, selected_input_len + selected_output_len); - if (selected_input_ct) { + if (selected_input_len) { /* socket inputs */ for (sock = node->inputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; if (select_all || (sock->flag & SELECT)) { node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col); - if (--selected_input_ct == 0) + if (--selected_input_len == 0) break; /* stop as soon as last one is drawn */ } } } - if (selected_output_ct) { + if (selected_output_len) { /* socket outputs */ for (sock = node->outputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; if (select_all || (sock->flag & SELECT)) { node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col); - if (--selected_output_ct == 0) + if (--selected_output_len == 0) break; /* stop as soon as last one is drawn */ } } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index fd96cf49313..a10eda5c3e6 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1539,10 +1539,10 @@ static void draw_seq_backdrop(View2D *v2d) /* Darker lines separating the horizontal bands */ i = max_ii(1, ((int)v2d->cur.ymin) - 1); - int line_ct = (int)v2d->cur.ymax - i + 1; + int line_len = (int)v2d->cur.ymax - i + 1; immUniformThemeColor(TH_GRID); - immBegin(GWN_PRIM_LINES, line_ct * 2); - while (line_ct--) { + immBegin(GWN_PRIM_LINES, line_len * 2); + while (line_len--) { immVertex2f(pos, v2d->cur.xmax, i); immVertex2f(pos, v2d->cur.xmin, i); } -- cgit v1.2.3 From 907dd3d34a2f876622da1b4561df939a7d5836e9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 21:15:39 +0200 Subject: Fix crash in lamp preview render Missing NULL check in object type filtering. --- source/blender/draw/intern/draw_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 7e40966f9c8..a1e44e479d4 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1564,7 +1564,7 @@ void DRW_render_object_iter( DRW_hair_init(); - const int object_type_exclude_viewport = draw_ctx->v3d->object_type_exclude_viewport; + const int object_type_exclude_viewport = draw_ctx->v3d ? draw_ctx->v3d->object_type_exclude_viewport : 0; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) { if ((object_type_exclude_viewport & (1 << ob->type)) == 0) { -- cgit v1.2.3 From aed82dafff8f7f0f30a7b7c1c7180d13ec52b052 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 11:57:59 +0200 Subject: Icons: support for drawing event icons Use for drawing modal operator header keys. --- source/blender/editors/include/UI_icons.h | 52 ++++ source/blender/editors/include/UI_interface.h | 4 + source/blender/editors/interface/CMakeLists.txt | 1 + source/blender/editors/interface/interface_icons.c | 152 +++++++++++ .../editors/interface/interface_icons_event.c | 295 +++++++++++++++++++++ .../blender/editors/interface/interface_intern.h | 5 + .../blender/windowmanager/intern/wm_event_system.c | 45 +++- 7 files changed, 546 insertions(+), 8 deletions(-) create mode 100644 source/blender/editors/interface/interface_icons_event.c diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 68318835a00..a63855439f4 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -1032,3 +1032,55 @@ DEF_VICO(COLORSET_17_VEC) DEF_VICO(COLORSET_18_VEC) DEF_VICO(COLORSET_19_VEC) DEF_VICO(COLORSET_20_VEC) + +/* Events */ +DEF_ICON(EVENT_A) +DEF_ICON(EVENT_B) +DEF_ICON(EVENT_C) +DEF_ICON(EVENT_D) +DEF_ICON(EVENT_E) +DEF_ICON(EVENT_F) +DEF_ICON(EVENT_G) +DEF_ICON(EVENT_H) +DEF_ICON(EVENT_I) +DEF_ICON(EVENT_J) +DEF_ICON(EVENT_K) +DEF_ICON(EVENT_L) +DEF_ICON(EVENT_M) +DEF_ICON(EVENT_N) +DEF_ICON(EVENT_O) +DEF_ICON(EVENT_P) +DEF_ICON(EVENT_Q) +DEF_ICON(EVENT_R) +DEF_ICON(EVENT_S) +DEF_ICON(EVENT_T) +DEF_ICON(EVENT_U) +DEF_ICON(EVENT_V) +DEF_ICON(EVENT_W) +DEF_ICON(EVENT_X) +DEF_ICON(EVENT_Y) +DEF_ICON(EVENT_Z) +DEF_ICON(EVENT_SHIFT) +DEF_ICON(EVENT_CTRL) +DEF_ICON(EVENT_ALT) +DEF_ICON(EVENT_OS) +DEF_ICON(EVENT_F1) +DEF_ICON(EVENT_F2) +DEF_ICON(EVENT_F3) +DEF_ICON(EVENT_F4) +DEF_ICON(EVENT_F5) +DEF_ICON(EVENT_F6) +DEF_ICON(EVENT_F7) +DEF_ICON(EVENT_F8) +DEF_ICON(EVENT_F9) +DEF_ICON(EVENT_F10) +DEF_ICON(EVENT_F11) +DEF_ICON(EVENT_F12) +DEF_ICON(EVENT_ESC) +DEF_ICON(EVENT_TAB) +DEF_ICON(EVENT_PAGEUP) +DEF_ICON(EVENT_PAGEDOWN) +DEF_ICON(EVENT_HOME) +DEF_ICON(EVENT_END) +DEF_ICON(EVENT_RETURN) +/* add as needed. */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 8a758d01809..4114c209894 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -76,6 +76,7 @@ struct wmEvent; struct wmManipulator; struct wmMsgBus; struct wmKeyMap; +struct wmKeyMapItem; typedef struct uiBut uiBut; typedef struct uiBlock uiBlock; @@ -723,6 +724,9 @@ enum { int UI_icon_from_id(struct ID *id); int UI_icon_from_report_type(int type); +int UI_icon_from_event_type(short event_type, short event_value); +int UI_icon_from_keymap_item(const struct wmKeyMapItem *kmi, int r_icon_mod[4]); + uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip); uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip); uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip); diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index ee18f956cac..cf172441be1 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -54,6 +54,7 @@ set(SRC interface_eyedropper_driver.c interface_handlers.c interface_icons.c + interface_icons_event.c interface_layout.c interface_ops.c interface_panel.c diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 92178e58a58..9c5a4392f78 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -108,6 +108,7 @@ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); #define ICON_TYPE_BUFFER 3 #define ICON_TYPE_VECTOR 4 #define ICON_TYPE_GEOM 5 +#define ICON_TYPE_EVENT 6 /* draw keymap entries using custom renderer. */ typedef struct DrawInfo { int type; @@ -126,6 +127,14 @@ typedef struct DrawInfo { struct { int x, y, w, h; } texture; + struct { + /* Can be packed into a single int. */ + short event_type; + short event_value; + int icon; + /* Allow lookups. */ + struct DrawInfo *next; + } input; } data; } DrawInfo; @@ -437,6 +446,143 @@ static void init_brush_icons(void) #undef INIT_BRUSH_ICON } +static DrawInfo *g_di_event_list = NULL; + +int UI_icon_from_event_type(short event_type, short event_value) +{ + if (event_type == RIGHTSHIFTKEY) { + event_type = LEFTSHIFTKEY; + } + else if (event_type == RIGHTCTRLKEY) { + event_type = LEFTCTRLKEY; + } + else if (event_type == RIGHTALTKEY) { + event_type = LEFTALTKEY; + } + else if (event_type == EVT_TWEAK_L) { + event_type = LEFTMOUSE; + event_value = KM_CLICK_DRAG; + } + else if (event_type == EVT_TWEAK_M) { + event_type = MIDDLEMOUSE; + event_value = KM_CLICK_DRAG; + } + else if (event_type == EVT_TWEAK_R) { + event_type = RIGHTMOUSE; + event_value = KM_CLICK_DRAG; + } + + DrawInfo *di = g_di_event_list; + do { + if (di->data.input.event_type == event_type) { + return di->data.input.icon; + } + } while ((di = di->data.input.next)); + + if (event_type == LEFTMOUSE) { + return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_LMB : ICON_MOUSE_LMB_DRAG; + } + else if (event_type == MIDDLEMOUSE) { + return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_MMB : ICON_MOUSE_MMB_DRAG; + } + else if (event_type == RIGHTMOUSE) { + return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_RMB : ICON_MOUSE_RMB_DRAG; + } + + return ICON_NONE; +} + +int UI_icon_from_keymap_item(const wmKeyMapItem *kmi, int r_icon_mod[4]) +{ + if (r_icon_mod) { + memset(r_icon_mod, 0x0, sizeof(int[4])); + int i = 0; + if (!ELEM(kmi->ctrl, KM_NOTHING, KM_ANY)) { + r_icon_mod[i++] = ICON_EVENT_CTRL; + } + if (!ELEM(kmi->alt, KM_NOTHING, KM_ANY)) { + r_icon_mod[i++] = ICON_EVENT_ALT; + } + if (!ELEM(kmi->shift, KM_NOTHING, KM_ANY)) { + r_icon_mod[i++] = ICON_EVENT_SHIFT; + } + if (!ELEM(kmi->oskey, KM_NOTHING, KM_ANY)) { + r_icon_mod[i++] = ICON_EVENT_OS; + } + } + return UI_icon_from_event_type(kmi->type, kmi->val); +} + +static void init_event_icons(void) +{ + DrawInfo *di_next = NULL; + +#define INIT_EVENT_ICON(icon_id, type, value) \ + { \ + DrawInfo *di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_EVENT); \ + di->data.input.event_type = type; \ + di->data.input.event_value = value; \ + di->data.input.icon = icon_id; \ + di->data.input.next = di_next; \ + di_next = di; \ + } + /* end INIT_EVENT_ICON */ + + const int w = 16; /* DUMMY */ + + INIT_EVENT_ICON(ICON_EVENT_A, AKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_B, BKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_C, CKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_D, DKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_E, EKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F, FKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_G, GKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_H, HKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_I, IKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_J, JKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_K, KKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_L, LKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_M, MKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_N, NKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_O, OKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_P, PKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_Q, QKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_R, RKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_S, SKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_T, TKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_U, UKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_V, VKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_W, WKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_X, XKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_Y, YKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_Z, ZKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_SHIFT, LEFTSHIFTKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_CTRL, LEFTCTRLKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_ALT, LEFTALTKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_OS, OSKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F1, F1KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F2, F2KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F3, F3KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F4, F4KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F5, F5KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F6, F6KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F7, F7KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F8, F8KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F9, F9KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F10, F10KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F11, F11KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_F12, F12KEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_ESC, ESCKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_TAB, TABKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_PAGEUP, PAGEUPKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_PAGEDOWN, PAGEDOWNKEY, KM_ANY); + INIT_EVENT_ICON(ICON_EVENT_RETURN, RETKEY, KM_ANY); + + g_di_event_list = di_next; + +#undef INIT_EVENT_ICON +} + static void icon_verify_datatoc(IconImage *iimg) { /* if it has own rect, things are all OK */ @@ -795,6 +941,7 @@ void UI_icons_init(int first_dyn_id) init_iconfile_list(&iconfilelist); init_internal_icons(); init_brush_icons(); + init_event_icons(); #endif } @@ -1285,6 +1432,11 @@ static void icon_draw_size( icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, rgb, desaturate); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } + else if (di->type == ICON_TYPE_EVENT) { + const short event_type = di->data.input.event_type; + const short event_value = di->data.input.event_value; + icon_draw_rect_input(x, y, w, h, alpha, event_type, event_value); + } else if (di->type == ICON_TYPE_TEXTURE) { /* texture image use premul alpha for correct scaling */ GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c new file mode 100644 index 00000000000..dc444b98b2c --- /dev/null +++ b/source/blender/editors/interface/interface_icons_event.c @@ -0,0 +1,295 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/interface/interface_icons_event.c + * \ingroup edinterface + * + * A special set of icons to represent input devices, + * this is a mix of text (via fonts) and a handful of custom glyphs for special keys. + * + * Event codes are used as identifiers. + */ + +#include +#include +#include + +#include "MEM_guardedalloc.h" + +#include "GPU_draw.h" +#include "GPU_matrix.h" +#include "GPU_batch.h" +#include "GPU_immediate.h" +#include "GPU_state.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_fileops_types.h" +#include "BLI_math_vector.h" + +#include "DNA_brush_types.h" +#include "DNA_curve_types.h" +#include "DNA_dynamicpaint_types.h" +#include "DNA_object_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_workspace_types.h" + +#include "RNA_access.h" +#include "RNA_enum_types.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_icons.h" +#include "BKE_appdir.h" +#include "BKE_studiolight.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "IMB_thumbs.h" + +#include "BIF_glutil.h" +#include "BLF_api.h" + +#include "DEG_depsgraph.h" + +#include "DRW_engine.h" + +#include "ED_datafiles.h" +#include "ED_keyframes_draw.h" +#include "ED_render.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "interface_intern.h" + +static void icon_draw_rect_input_small_text_ex( + const rctf *rect, const float color[4], const float margin[2], const char *str, + int font_size) +{ + BLF_batch_draw_flush(); + const int font_id = BLF_default(); + BLF_color4fv(font_id, color); + BLF_size(font_id, font_size * U.pixelsize, U.dpi); + BLF_position(font_id, rect->xmin + margin[0] * 2, rect->ymin + margin[1] * 5, 0.0f); + BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX); + BLF_batch_draw_flush(); +} + +static void icon_draw_rect_input_small_text( + const rctf *rect, const float color[4], const float margin[2], const char *str) +{ + icon_draw_rect_input_small_text_ex(rect, color, margin, str, 8); +} + +static void icon_draw_rect_input_default_text( + const rctf *rect, + const float color[4], const float margin[2], const char *str) +{ + BLF_batch_draw_flush(); + const int font_id = BLF_default(); + BLF_color4fv(font_id, color); + BLF_position(font_id, (int)(rect->xmin + margin[0] * 5), (int)(rect->ymin + margin[1] * 5), 0.0f); + BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX); + BLF_batch_draw_flush(); +} + +static void icon_draw_rect_input_mono_text( + const rctf *rect, + const float color[4], const float margin[2], const char *str) +{ + BLF_batch_draw_flush(); + const int font_id = blf_mono_font; + BLF_color4fv(font_id, color); + BLF_size(font_id, 20 * U.pixelsize, U.dpi); + BLF_position(font_id, (int)(rect->xmin + margin[0] * 5), (int)(rect->ymin + margin[1] * 5), 0.0f); + BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX); + BLF_batch_draw_flush(); +} + +static void icon_draw_rect_input_line_prim( + const rctf *rect, + const float color[4], + const int prim, + const char lines[][2], int lines_len) +{ + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + BLI_assert(ELEM(prim, GWN_PRIM_LINE_LOOP, GWN_PRIM_LINE_STRIP)); + const uint pos_id = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor4fv(color); + immBegin(prim, lines_len); + float w_inv = BLI_rctf_size_x(rect) / 255.0f; + float h_inv = BLI_rctf_size_y(rect) / 255.0f; + for (int i = 0; i < lines_len; i++) { + immVertex2f( + pos_id, + round_fl_to_int(rect->xmin + ((float)lines[i][0] * w_inv)), + round_fl_to_int(rect->ymin + ((float)lines[i][1] * h_inv)) + ); + } + immEnd(); + immUnbindProgram(); + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); +} + +void icon_draw_rect_input( + float x, float y, int w, int h, float UNUSED(alpha), + short event_type, short UNUSED(event_value)) +{ + float color[4]; + const float margin[2] = {w / 20.0f, h / 20.0f}; + UI_GetThemeColor4fv(TH_TEXT, color); + UI_draw_roundbox_corner_set(UI_CNR_ALL); + UI_draw_roundbox_aa( + false, + (int)x, + (int)y, + (int)(x + w), + (int)(y + h), 4.0f, color + ); + + const rctf rect = { + .xmin = x, + .ymin = y, + .xmax = x + w, + .ymax = y + h, + }; + + const bool simple_text = false; + + if ((event_type >= AKEY) || (ZKEY <= event_type)) { + char str[2] = {'A' + (event_type - AKEY), '\0'}; + icon_draw_rect_input_default_text(&rect, color, margin, str); + } + if ((event_type >= F1KEY) || (F12KEY <= event_type)) { + char str[3] = {'F', '1' + (event_type - F1KEY), '\0'}; + icon_draw_rect_input_default_text(&rect, color, margin, str); + } + else if (event_type == LEFTSHIFTKEY) { + if (simple_text) { + icon_draw_rect_input_small_text(&rect, color, margin, "Shift"); + } + else { + rctf rect_ofs = rect; + BLI_rctf_translate(&rect_ofs, (w / -14.0f), (w / -14.0f)); + icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x87, 0xa7, 0x0}); + } + } + else if (event_type == LEFTCTRLKEY) { + if (simple_text) { + icon_draw_rect_input_small_text(&rect, color, margin, "Ctrl"); + } + else { + rctf rect_ofs = rect; + BLI_rctf_translate(&rect_ofs, (w / -16.0f), 0.0f); + icon_draw_rect_input_default_text(&rect_ofs, color, margin, "^"); + } + } + else if (event_type == LEFTALTKEY) { + if (simple_text) { + icon_draw_rect_input_small_text(&rect, color, margin, "Alt"); + } + else { + rctf rect_ofs = rect; + BLI_rctf_translate(&rect_ofs, (w / -8.0f), 0.0f); + icon_draw_rect_input_default_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x8c, 0xa5, 0x0}); + } + } + else if (event_type == OSKEY) { + icon_draw_rect_input_small_text(&rect, color, margin, "OS"); + } + else if (event_type == DELKEY) { + icon_draw_rect_input_small_text(&rect, color, margin, "Del"); + } + else if (event_type == TABKEY) { + if (simple_text) { + icon_draw_rect_input_small_text(&rect, color, margin, "Tab"); + } + else { + rctf rect_ofs = rect; + BLI_rctf_translate(&rect_ofs, (w / -12.0f), (w / -12.0f)); + icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x86, 0xb9, 0x0}); + } + } + else if (event_type == HOMEKEY) { + if (simple_text) { + icon_draw_rect_input_small_text(&rect, color, margin, "Home"); + } + else { + rctf rect_ofs = rect; + BLI_rctf_translate(&rect_ofs, (w / -12.0f), (w / -12.0f)); + icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x87, 0xa4, 0x0}); + } + } + else if (event_type == ENDKEY) { + if (simple_text) { + icon_draw_rect_input_small_text(&rect, color, margin, "End"); + } + else { + rctf rect_ofs = rect; + BLI_rctf_translate(&rect_ofs, (w / -12.0f), (w / -12.0f)); + icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x87, 0xa5, 0x0}); + } + } + else if (event_type == RETKEY) { + if (simple_text) { + icon_draw_rect_input_small_text(&rect, color, margin, "Ret"); + } + else { + rctf rect_ofs = rect; + BLI_rctf_translate(&rect_ofs, (w / -8.0f), (w / -6.0f)); + icon_draw_rect_input_mono_text(&rect_ofs, color, margin, (const char[]){0xe2, 0x8f, 0x8e, 0x0}); + } + } + else if (event_type == ESCKEY) { + icon_draw_rect_input_small_text(&rect, color, margin, "Esc"); + } + else if (event_type == PAGEUPKEY) { + icon_draw_rect_input_small_text_ex(&rect, color, margin, (const char[]){'P', 0xe2, 0x86, 0x91, 0x0}, 10); + } + else if (event_type == PAGEDOWNKEY) { + icon_draw_rect_input_small_text_ex(&rect, color, margin, (const char[]){'P', 0xe2, 0x86, 0x93, 0x0}, 10); + } + else if (event_type == LEFTARROWKEY) { + icon_draw_rect_input_default_text(&rect, color, margin, (const char[]){0xe2, 0x86, 0x90, 0x0}); + } + else if (event_type == UPARROWKEY) { + icon_draw_rect_input_default_text(&rect, color, margin, (const char[]){0xe2, 0x86, 0x91, 0x0}); + } + else if (event_type == RIGHTARROWKEY) { + icon_draw_rect_input_default_text(&rect, color, margin, (const char[]){0xe2, 0x86, 0x92, 0x0}); + } + else if (event_type == DOWNARROWKEY) { + icon_draw_rect_input_default_text(&rect, color, margin, (const char[]){0xe2, 0x86, 0x93, 0x0}); + } + else if (event_type == SPACEKEY) { + const uchar lines[] = {60, 118, 60, 60, 195, 60, 195, 118}; + icon_draw_rect_input_line_prim( + &rect, color, GWN_PRIM_LINE_STRIP, + (const void *)lines, ARRAY_SIZE(lines) / 2); + } +} diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 0b76e311cc7..ffc389c6dfd 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -789,6 +789,11 @@ void uiStyleInit(void); void ui_icon_ensure_deferred(const struct bContext *C, const int icon_id, const bool big); int ui_id_icon_get(const struct bContext *C, struct ID *id, const bool big); +/* interface_icons_event.c */ +void icon_draw_rect_input( + float x, float y, int w, int h, float alpha, + short event_type, short event_value); + /* resources.c */ void init_userdef_do_versions(struct Main *bmain); void ui_theme_init_default(void); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 19889f57261..4f5578e452d 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -4546,14 +4546,43 @@ bool WM_window_modal_keymap_status_draw( if (!items[i].identifier[0]) { continue; } - char buf[UI_MAX_DRAW_STR]; - int available_len = sizeof(buf); - char *p = buf; - WM_modalkeymap_operator_items_to_string_buf(ot, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p); - p -= 1; - if (p > buf) { - BLI_snprintf(p, available_len, ": %s", items[i].name); - uiItemL(row, buf, 0); + + bool show_text = true; + + { + /* warning: O(n^2) */ + wmKeyMapItem *kmi = NULL; + for (kmi = keymap->items.first; kmi; kmi = kmi->next) { + if (kmi->propvalue == items[i].value) { + break; + } + } + if (kmi != NULL) { + if (kmi->val == KM_RELEASE) { + /* Assume release events just disable something which was toggled on. */ + continue; + } + int icon_mod[4]; + int icon = UI_icon_from_keymap_item(kmi, icon_mod); + if (icon != 0) { + for (int j = 0; j < ARRAY_SIZE(icon_mod) && icon_mod[j]; j++) { + uiItemL(row, "", icon_mod[j]); + } + uiItemL(row, items[i].name, icon); + show_text = false; + } + } + } + if (show_text) { + char buf[UI_MAX_DRAW_STR]; + int available_len = sizeof(buf); + char *p = buf; + WM_modalkeymap_operator_items_to_string_buf(ot, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p); + p -= 1; + if (p > buf) { + BLI_snprintf(p, available_len, ": %s", items[i].name); + uiItemL(row, buf, 0); + } } } return true; -- cgit v1.2.3 From 4ab37b3225ad10798942671e4dad372e80220093 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 06:28:05 +0200 Subject: 3D View: select exclude w/ ob-center enabled --- source/blender/editors/space_view3d/view3d_select.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b7dbb09e1a4..0f82dfa775c 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1062,6 +1062,8 @@ static Base *object_mouse_select_menu( short baseCount = 0; bool ok; LinkNode *linklist = NULL; + const int object_type_exclude_select = ( + vc->v3d->object_type_exclude_viewport | vc->v3d->object_type_exclude_select); /* handle base->object->select_color */ CTX_DATA_BEGIN (C, Base *, base, selectable_bases) @@ -1079,6 +1081,9 @@ static Base *object_mouse_select_menu( } } else { + if (object_type_exclude_select & (1 << base->object->type)) { + continue; + } const int dist = 15 * U.pixelsize; if (ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) { const int delta_px[2] = {base->sx - mval[0], base->sy - mval[1]}; @@ -1447,9 +1452,13 @@ static bool ed_object_select_pick( basact = object_mouse_select_menu(C, &vc, NULL, 0, mval, toggle); } else { + const int object_type_exclude_select = ( + vc.v3d->object_type_exclude_viewport | vc.v3d->object_type_exclude_select); base = startbase; while (base) { - if (BASE_SELECTABLE(base)) { + if (BASE_SELECTABLE(base) && + ((object_type_exclude_select & (1 << base->object->type)) == 0)) + { float screen_co[2]; if (ED_view3d_project_float_global( ar, base->object->obmat[3], screen_co, -- cgit v1.2.3 From 9856dd9fec7dc838cea00728766f6ee9801ebf7e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 06:38:07 +0200 Subject: Cleanup: right shift --- source/blender/editors/include/UI_interface.h | 115 +++++++++++++++----------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 1fd951c23c5..51f79e05bf9 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -511,7 +511,7 @@ void UI_but_drag_set_path(uiBut *but, const char *path, const bool use_free); void UI_but_drag_set_name(uiBut *but, const char *name); void UI_but_drag_set_value(uiBut *but); void UI_but_drag_set_image( - uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale, const bool use_free); + uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale, const bool use_free); bool UI_but_active_drop_name(struct bContext *C); bool UI_but_active_drop_color(struct bContext *C); @@ -549,13 +549,14 @@ bool UI_but_online_manual_id_from_active( * - R: RNA * - O: operator */ -uiBut *uiDefBut(uiBlock *block, - int type, int retval, const char *str, - int x1, int y1, - short x2, short y2, - void *poin, - float min, float max, - float a1, float a2, const char *tip); +uiBut *uiDefBut( + uiBlock *block, + int type, int retval, const char *str, + int x1, int y1, + short x2, short y2, + void *poin, + float min, float max, + float a1, float a2, const char *tip); uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); @@ -569,13 +570,14 @@ uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip); uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip); -uiBut *uiDefIconBut(uiBlock *block, - int type, int retval, int icon, - int x1, int y1, - short x2, short y2, - void *poin, - float min, float max, - float a1, float a2, const char *tip); +uiBut *uiDefIconBut( + uiBlock *block, + int type, int retval, int icon, + int x1, int y1, + short x2, short y2, + void *poin, + float min, float max, + float a1, float a2, const char *tip); uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); @@ -589,13 +591,14 @@ uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x, uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x, int y, short width, short height, const char *tip); uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x, int y, short width, short height, const char *tip); -uiBut *uiDefIconTextBut(uiBlock *block, - int type, int retval, int icon, const char *str, - int x1, int y1, - short x2, short y2, - void *poin, - float min, float max, - float a1, float a2, const char *tip); +uiBut *uiDefIconTextBut( + uiBlock *block, + int type, int retval, int icon, const char *str, + int x1, int y1, + short x2, short y2, + void *poin, + float min, float max, + float a1, float a2, const char *tip); uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); @@ -694,9 +697,10 @@ uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *keypoin, short *modkeypoin, const char *tip); uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip); -uiBut *uiDefSearchButO_ptr(uiBlock *block, struct wmOperatorType *ot, struct IDProperty *properties, - void *arg, int retval, int icon, int maxlen, int x, int y, - short width, short height, float a1, float a2, const char *tip); +uiBut *uiDefSearchButO_ptr( + uiBlock *block, struct wmOperatorType *ot, struct IDProperty *properties, + void *arg, int retval, int icon, int maxlen, int x, int y, + short width, short height, float a1, float a2, const char *tip); uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2); int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align); @@ -745,8 +749,9 @@ void UI_but_func_tooltip_set(uiBut *but, uiButToolTipFunc func, void *argN); void UI_but_tooltip_refresh(struct bContext *C, uiBut *but); void UI_but_tooltip_timer_remove(struct bContext *C, uiBut *but); -bool UI_textbutton_activate_rna(const struct bContext *C, struct ARegion *ar, - const void *rna_poin_data, const char *rna_prop_id); +bool UI_textbutton_activate_rna( + const struct bContext *C, struct ARegion *ar, + const void *rna_poin_data, const char *rna_prop_id); bool UI_textbutton_activate_but(const struct bContext *C, uiBut *but); void UI_but_focus_on_enter_event(struct wmWindow *win, uiBut *but); @@ -780,8 +785,9 @@ void UI_panels_end(const struct bContext *C, struct ARegion *ar, int *x, int *y) void UI_panels_draw(const struct bContext *C, struct ARegion *ar); struct Panel *UI_panel_find_by_type(struct ARegion *ar, struct PanelType *pt); -struct Panel *UI_panel_begin(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, - struct PanelType *pt, struct Panel *pa, bool *r_open); +struct Panel *UI_panel_begin( + struct ScrArea *sa, struct ARegion *ar, uiBlock *block, + struct PanelType *pt, struct Panel *pa, bool *r_open); void UI_panel_end(uiBlock *block, int width, int height); void UI_panels_scale(struct ARegion *ar, float new_width); @@ -922,8 +928,9 @@ uiLayout *uiLayoutRow(uiLayout *layout, bool align); uiLayout *uiLayoutColumn(uiLayout *layout, bool align); uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, bool align); uiLayout *uiLayoutBox(uiLayout *layout); -uiLayout *uiLayoutListBox(uiLayout *layout, struct uiList *ui_list, struct PointerRNA *ptr, struct PropertyRNA *prop, - struct PointerRNA *actptr, struct PropertyRNA *actprop); +uiLayout *uiLayoutListBox( + uiLayout *layout, struct uiList *ui_list, struct PointerRNA *ptr, struct PropertyRNA *prop, + struct PointerRNA *actptr, struct PropertyRNA *actprop); uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align); uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align); uiLayout *uiLayoutOverlap(uiLayout *layout); @@ -941,27 +948,33 @@ void uiTemplateIDBrowse( void uiTemplateIDPreview( uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int rows, int cols, int filter); -void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname, - const char *proptypename, const char *text); -void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, - struct PointerRNA *root_ptr, const char *text); +void uiTemplateAnyID( + uiLayout *layout, struct PointerRNA *ptr, const char *propname, + const char *proptypename, const char *text); +void uiTemplatePathBuilder( + uiLayout *layout, struct PointerRNA *ptr, const char *propname, + struct PointerRNA *root_ptr, const char *text); uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); -void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, bool show_buttons, struct ID *parent, - struct MTex *slot, const char *preview_id); +void uiTemplatePreview( + uiLayout *layout, struct bContext *C, struct ID *id, bool show_buttons, struct ID *parent, + struct MTex *slot, const char *preview_id); void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool expand); void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool show_labels, float icon_scale); void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname); void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname); void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname); -void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, - bool levels, bool brush, bool neg_slope); +void uiTemplateCurveMapping( + uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, + bool levels, bool brush, bool neg_slope); void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic); void uiTemplatePalette(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool color); -void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, - PointerRNA *used_ptr, const char *used_propname, int active_layer); -void uiTemplateGameStates(uiLayout *layout, struct PointerRNA *ptr, const char *propname, - PointerRNA *used_ptr, const char *used_propname, int active_state); +void uiTemplateLayers( + uiLayout *layout, struct PointerRNA *ptr, const char *propname, + PointerRNA *used_ptr, const char *used_propname, int active_layer); +void uiTemplateGameStates( + uiLayout *layout, struct PointerRNA *ptr, const char *propname, + PointerRNA *used_ptr, const char *used_propname, int active_state); void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, bool compact, bool multiview); void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, bool color_management); void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA *stereo3d_format_ptr); @@ -972,9 +985,10 @@ void uiTemplateImageInfo(uiLayout *layout, struct bContext *C, struct Image *ima void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void UI_but_func_operator_search(uiBut *but); void uiTemplateOperatorSearch(uiLayout *layout); -void uiTemplateOperatorPropertyButs(const struct bContext *C, uiLayout *layout, struct wmOperator *op, - bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), - const char label_align, const short flag); +void uiTemplateOperatorPropertyButs( + const struct bContext *C, uiLayout *layout, struct wmOperator *op, + bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), + const char label_align, const short flag); void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C); void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C); @@ -985,10 +999,11 @@ void uiTemplateCacheFile(uiLayout *layout, struct bContext *C, struct PointerRNA /* Default UIList class name, keep in sync with its declaration in bl_ui/__init__.py */ #define UI_UL_DEFAULT_CLASS_NAME "UI_UL_list" -void uiTemplateList(uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id, - struct PointerRNA *dataptr, const char *propname, struct PointerRNA *active_dataptr, - const char *active_propname, const char *item_dyntip_propname, - int rows, int maxrows, int layout_type, int columns); +void uiTemplateList( + uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id, + struct PointerRNA *dataptr, const char *propname, struct PointerRNA *active_dataptr, + const char *active_propname, const char *item_dyntip_propname, + int rows, int maxrows, int layout_type, int columns); void uiTemplateNodeLink(uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input); void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input); void uiTemplateTextureUser(uiLayout *layout, struct bContext *C); -- cgit v1.2.3 From 70e28241267ab440e84ca3dc8661fa9de6b52ed8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 07:29:12 +0200 Subject: Keymap: remove some hard coded transform events Also re-order for display purposes --- source/blender/editors/transform/transform.c | 48 +++++++++++++--------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 3f9534751c1..9f652b631bf 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -802,14 +802,8 @@ enum { wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) { static const EnumPropertyItem modal_items[] = { - {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, - {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, - {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, - {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap On", ""}, - {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""}, - {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""}, + {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {TFM_MODAL_AXIS_X, "AXIS_X", 0, "Orientation X axis", ""}, {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Orientation Y axis", ""}, {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Orientation Z axis", ""}, @@ -817,6 +811,9 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Orientation Y plane", ""}, {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Orientation Z plane", ""}, {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""}, + {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap", ""}, + {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""}, + {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""}, {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""}, {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""}, {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""}, @@ -829,6 +826,9 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""}, {TFM_MODAL_PROPSIZE, "PROPORTIONAL_SIZE", 0, "Adjust Proportional Influence", ""}, {TFM_MODAL_INSERTOFS_TOGGLE_DIR, "INSERTOFS_TOGGLE_DIR", 0, "Toggle Direction for Node Auto-offset", ""}, + {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, + {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, {0, NULL, 0, NULL, NULL} }; @@ -840,10 +840,21 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) keymap = WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items); /* items for modal map */ - WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL); - WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); - WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); - WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL); + WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL); + + WM_modalkeymap_add_item(keymap, XKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_X); + WM_modalkeymap_add_item(keymap, YKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_Y); + WM_modalkeymap_add_item(keymap, ZKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_Z); + + WM_modalkeymap_add_item(keymap, XKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_X); + WM_modalkeymap_add_item(keymap, YKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_Y); + WM_modalkeymap_add_item(keymap, ZKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_Z); + + WM_modalkeymap_add_item(keymap, CKEY, KM_PRESS, 0, 0, TFM_MODAL_CONS_OFF); WM_modalkeymap_add_item(keymap, GKEY, KM_PRESS, 0, 0, TFM_MODAL_TRANSLATE); WM_modalkeymap_add_item(keymap, RKEY, KM_PRESS, 0, 0, TFM_MODAL_ROTATE); @@ -1393,21 +1404,6 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; } } - else { - if (!(t->flag & T_NO_CONSTRAINT)) { - stopConstraint(t); - t->redraw |= TREDRAW_HARD; - handled = true; - } - } - break; - case XKEY: - case YKEY: - case ZKEY: - if (!(t->flag & T_NO_CONSTRAINT)) { - transform_event_xyz_constraint(t, event->type, cmode); - handled = true; - } break; case OKEY: if (t->flag & T_PROP_EDIT && event->shift) { -- cgit v1.2.3 From 6793aebad2217d99222076eb71c3c2d6db0aefcb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 07:39:26 +0200 Subject: Cleanup: remove 'Orientation' from keymap item name It's constraint not an orientation, in transform context it can be inferred. --- source/blender/editors/transform/transform.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 9f652b631bf..ad7c0980bca 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -804,13 +804,13 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) static const EnumPropertyItem modal_items[] = { {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, - {TFM_MODAL_AXIS_X, "AXIS_X", 0, "Orientation X axis", ""}, - {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Orientation Y axis", ""}, - {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Orientation Z axis", ""}, - {TFM_MODAL_PLANE_X, "PLANE_X", 0, "Orientation X plane", ""}, - {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Orientation Y plane", ""}, - {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Orientation Z plane", ""}, - {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""}, + {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X axis", ""}, + {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y axis", ""}, + {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z axis", ""}, + {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X plane", ""}, + {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y plane", ""}, + {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z plane", ""}, + {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""}, {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap", ""}, {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""}, {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""}, -- cgit v1.2.3 From 32396b316455c5b207b1103f03ddc4c8e81cfd00 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 08:39:09 +0200 Subject: WM: support for filtering modal keymap items Modal keymap display often shows items which aren't used, add a poll funciton to hide these from the status bar. --- source/blender/makesdna/DNA_windowmanager_types.h | 2 ++ source/blender/windowmanager/intern/wm_event_system.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index bd2811d3306..80ad3840a8f 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -331,6 +331,8 @@ typedef struct wmKeyMap { /* runtime */ /** Verify if enabled in the current context, use #WM_keymap_poll instead of direct calls. */ bool (*poll)(struct bContext *); + bool (*poll_modal_item)(const struct wmOperator *op, int value); + /** For modal, #EnumPropertyItem for now. */ const void *modal_items; } wmKeyMap; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 4f5578e452d..7e2198eed7a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -4524,14 +4524,14 @@ bool WM_window_modal_keymap_status_draw( uiLayout *layout) { wmKeyMap *keymap = NULL; - wmOperatorType *ot = NULL; + wmOperator *op = NULL; for (wmEventHandler *handler = win->modalhandlers.first; handler; handler = handler->next) { if (handler->op) { /* 'handler->keymap' could be checked too, seems not to be used. */ wmKeyMap *keymap_test = handler->op->type->modalkeymap; if (keymap_test && keymap_test->modal_items) { keymap = keymap_test; - ot = handler->op->type; + op = handler->op; break; } } @@ -4546,6 +4546,11 @@ bool WM_window_modal_keymap_status_draw( if (!items[i].identifier[0]) { continue; } + if ((keymap->poll_modal_item != NULL) && + (keymap->poll_modal_item(op, items[i].value) == false)) + { + continue; + } bool show_text = true; @@ -4577,7 +4582,8 @@ bool WM_window_modal_keymap_status_draw( char buf[UI_MAX_DRAW_STR]; int available_len = sizeof(buf); char *p = buf; - WM_modalkeymap_operator_items_to_string_buf(ot, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p); + WM_modalkeymap_operator_items_to_string_buf( + op->type, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p); p -= 1; if (p > buf) { BLI_snprintf(p, available_len, ": %s", items[i].name); -- cgit v1.2.3 From d2923d7d62fd486bdcef04edea7e25dc787e7108 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 08:41:48 +0200 Subject: UI: hide redundant transform keymap items --- source/blender/editors/transform/transform.c | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 506ec024203..c350283597e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -813,6 +813,71 @@ enum { TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27, }; +static bool transform_modal_item_poll(const wmOperator *op, int value) +{ + const TransInfo *t = op->customdata; + switch (value) { + case TFM_MODAL_PROPSIZE: + case TFM_MODAL_PROPSIZE_UP: + case TFM_MODAL_PROPSIZE_DOWN: + { + if ((t->flag & T_PROP_EDIT) == 0) { + return false; + } + break; + } + case TFM_MODAL_ADD_SNAP: + case TFM_MODAL_REMOVE_SNAP: + { + if (t->spacetype != SPACE_VIEW3D) { + return false; + } + break; + } + case TFM_MODAL_AXIS_Z: + { + if (t->flag & T_2D_EDIT) { + return false; + } + break; + } + case TFM_MODAL_PLANE_X: + case TFM_MODAL_PLANE_Y: + case TFM_MODAL_PLANE_Z: + { + if (t->flag & T_2D_EDIT) { + return false; + } + break; + } + case TFM_MODAL_EDGESLIDE_UP: + case TFM_MODAL_EDGESLIDE_DOWN: + { + if (t->mode != TFM_EDGE_SLIDE) { + return false; + } + break; + } + case TFM_MODAL_INSERTOFS_TOGGLE_DIR: + { + if (t->spacetype != SPACE_NODE) { + return false; + } + break; + } + case TFM_MODAL_AUTOIK_LEN_INC: + case TFM_MODAL_AUTOIK_LEN_DEC: + { + if ((t->flag & T_AUTOIK) == 0) { + return false; + } + break; + } + + } + return true; +} + /* called in transform_ops.c, on each regeneration of keymaps */ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) { @@ -853,6 +918,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) if (keymap && keymap->modal_items) return NULL; keymap = WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items); + keymap->poll_modal_item = transform_modal_item_poll; /* items for modal map */ WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); -- cgit v1.2.3 From b24232ff349d8f3c6b1ee0712b138c933458ad37 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 08:55:06 +0200 Subject: Keymap: Remove modal keymaps from blender_27x Hard coded keys have been removed from transform. Since these keymaps will likely remain unchanged, remove them to avoid maintenance overhead. --- release/scripts/presets/keyconfig/blender_27x.py | 586 ----------------------- 1 file changed, 586 deletions(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index 4a394bf3ec7..c6a9c00c901 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -6074,26 +6074,6 @@ keyconfig_data = [ ], }, ), - ( - "Backdrop Transform Widget Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Backdrop Crop Widget", {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, @@ -6103,26 +6083,6 @@ keyconfig_data = [ ], }, ), - ( - "Backdrop Crop Widget Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Sun Beams Widget", {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, @@ -6132,26 +6092,6 @@ keyconfig_data = [ ], }, ), - ( - "Sun Beams Widget Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Corner Pin Widget", {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, @@ -6161,26 +6101,6 @@ keyconfig_data = [ ], }, ), - ( - "Corner Pin Widget Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "UV Transform Manipulator", {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, @@ -6190,26 +6110,6 @@ keyconfig_data = [ ], }, ), - ( - "UV Transform Manipulator Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Spot Light Widgets", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, @@ -6219,26 +6119,6 @@ keyconfig_data = [ ], }, ), - ( - "Spot Light Widgets Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Area Light Widgets", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, @@ -6249,26 +6129,6 @@ keyconfig_data = [ ], }, ), - ( - "Area Light Widgets Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Target Light Widgets", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, @@ -6278,26 +6138,6 @@ keyconfig_data = [ ], }, ), - ( - "Target Light Widgets Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Force Field Widgets", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, @@ -6307,26 +6147,6 @@ keyconfig_data = [ ], }, ), - ( - "Force Field Widgets Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Camera Widgets", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, @@ -6336,26 +6156,6 @@ keyconfig_data = [ ], }, ), - ( - "Camera Widgets Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Camera View Widgets", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, @@ -6365,26 +6165,6 @@ keyconfig_data = [ ], }, ), - ( - "Camera View Widgets Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Armature Spline Widgets", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, @@ -6394,26 +6174,6 @@ keyconfig_data = [ ], }, ), - ( - "Armature Spline Widgets Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "View3D Navigate", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, @@ -6423,105 +6183,6 @@ keyconfig_data = [ ], }, ), - ( - "View3D Navigate Tweak Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("PRECISION_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), - ( - "View3D Gesture Circle", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), - ("SELECT", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("DESELECT", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), - ("NOP", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), - ("DESELECT", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("NOP", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), - ("SUBTRACT", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), - ("SUBTRACT", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), - ("ADD", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), - ("ADD", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), - ("SIZE", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ], - }, - ), - ( - "Gesture Border", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("SELECT", {"type": 'RIGHTMOUSE', "value": 'RELEASE', "any": True}, None), - ("BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), - ("DESELECT", {"type": 'LEFTMOUSE', "value": 'RELEASE', "shift": True}, None), - ("BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("SELECT", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), - ("BEGIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("DESELECT", {"type": 'MIDDLEMOUSE', "value": 'RELEASE'}, None), - ], - }, - ), - ( - "Gesture Zoom Border", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), - ("BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("IN", {"type": 'LEFTMOUSE', "value": 'RELEASE'}, None), - ("BEGIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("OUT", {"type": 'MIDDLEMOUSE', "value": 'RELEASE'}, None), - ], - }, - ), - ( - "Gesture Straight Line", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), - ("BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("SELECT", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), - ], - }, - ), - ( - "Standard Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("APPLY", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), - ("APPLY", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("APPLY", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("SNAP", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), ( "Animation", {"space_type": 'EMPTY', "region_type": 'WINDOW'}, @@ -6666,33 +6327,6 @@ keyconfig_data = [ ], }, ), - ( - "Knife Tool Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("PANNING", {"type": 'MIDDLEMOUSE', "value": 'ANY', "any": True}, None), - ("CANCEL", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "any": True}, None), - ("ADD_CUT", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'SPACE', "value": 'PRESS', "any": True}, None), - ("NEW_CUT", {"type": 'E', "value": 'PRESS'}, None), - ("SNAP_MIDPOINTS_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_MIDPOINTS_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_MIDPOINTS_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_MIDPOINTS_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("IGNORE_SNAP_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("IGNORE_SNAP_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("IGNORE_SNAP_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("IGNORE_SNAP_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("ANGLE_SNAP_TOGGLE", {"type": 'C', "value": 'PRESS'}, None), - ("CUT_THROUGH_TOGGLE", {"type": 'Z', "value": 'PRESS'}, None), - ], - }, - ), ( "UV Editor", {"space_type": 'EMPTY', "region_type": 'WINDOW'}, @@ -6961,44 +6595,6 @@ keyconfig_data = [ ], }, ), - ( - "Transform Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("TRANSLATE", {"type": 'G', "value": 'PRESS'}, None), - ("ROTATE", {"type": 'R', "value": 'PRESS'}, None), - ("RESIZE", {"type": 'S', "value": 'PRESS'}, None), - ("SNAP_TOGGLE", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), - ("SNAP_INV_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_INV_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_INV_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_INV_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("ADD_SNAP", {"type": 'A', "value": 'PRESS'}, None), - ("REMOVE_SNAP", {"type": 'A', "value": 'PRESS', "alt": True}, None), - ("PROPORTIONAL_SIZE_UP", {"type": 'PAGE_UP', "value": 'PRESS'}, None), - ("PROPORTIONAL_SIZE_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS'}, None), - ("PROPORTIONAL_SIZE_UP", {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, None), - ("PROPORTIONAL_SIZE_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, None), - ("PROPORTIONAL_SIZE_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), - ("PROPORTIONAL_SIZE_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), - ("PROPORTIONAL_SIZE_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None), - ("PROPORTIONAL_SIZE_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None), - ("PROPORTIONAL_SIZE", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ("EDGESLIDE_EDGE_NEXT", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": True}, None), - ("EDGESLIDE_PREV_NEXT", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": True}, None), - ("AUTOIK_CHAIN_LEN_UP", {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, None), - ("AUTOIK_CHAIN_LEN_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, None), - ("AUTOIK_CHAIN_LEN_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None), - ("AUTOIK_CHAIN_LEN_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None), - ("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS'}, None), - ], - }, - ), ( "UV Sculpt", {"space_type": 'EMPTY', "region_type": 'WINDOW'}, @@ -7126,15 +6722,6 @@ keyconfig_data = [ ], }, ), - ( - "Paint Stroke Modal", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ], - }, - ), ( "Mask Editing", {"space_type": 'EMPTY', "region_type": 'WINDOW'}, @@ -7359,179 +6946,6 @@ keyconfig_data = [ ], }, ), - ( - "Eyedropper Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("SAMPLE_CONFIRM", {"type": 'RET', "value": 'RELEASE', "any": True}, None), - ("SAMPLE_CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'RELEASE', "any": True}, None), - ("SAMPLE_CONFIRM", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), - ("SAMPLE_BEGIN", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ("SAMPLE_RESET", {"type": 'SPACE', "value": 'RELEASE', "any": True}, None), - ], - }, - ), - ( - "Eyedropper ColorBand PointSampling Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'BACK_SPACE', "value": 'PRESS', "any": True}, None), - ("SAMPLE_CONFIRM", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("SAMPLE_CONFIRM", {"type": 'RET', "value": 'RELEASE', "any": True}, None), - ("SAMPLE_CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'RELEASE', "any": True}, None), - ("SAMPLE_SAMPLE", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ("SAMPLE_RESET", {"type": 'SPACE', "value": 'RELEASE', "any": True}, None), - ], - }, - ), - ( - "Outliner Item Drag & Drop Modal Map", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'RELEASE', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'RELEASE', "any": True}, None), - ], - }, - ), - ( - "View3D Fly Modal", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), - ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'SPACE', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("ACCELERATE", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "any": True}, None), - ("DECELERATE", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "any": True}, None), - ("ACCELERATE", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "any": True}, None), - ("DECELERATE", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ("PAN_ENABLE", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "any": True}, None), - ("PAN_DISABLE", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), - ("FORWARD", {"type": 'W', "value": 'PRESS'}, None), - ("BACKWARD", {"type": 'S', "value": 'PRESS'}, None), - ("LEFT", {"type": 'A', "value": 'PRESS'}, None), - ("RIGHT", {"type": 'D', "value": 'PRESS'}, None), - ("UP", {"type": 'E', "value": 'PRESS'}, None), - ("DOWN", {"type": 'Q', "value": 'PRESS'}, None), - ("UP", {"type": 'R', "value": 'PRESS'}, None), - ("DOWN", {"type": 'F', "value": 'PRESS'}, None), - ("FORWARD", {"type": 'UP_ARROW', "value": 'PRESS'}, None), - ("BACKWARD", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None), - ("LEFT", {"type": 'LEFT_ARROW', "value": 'PRESS'}, None), - ("RIGHT", {"type": 'RIGHT_ARROW', "value": 'PRESS'}, None), - ("AXIS_LOCK_X", {"type": 'X', "value": 'PRESS'}, None), - ("AXIS_LOCK_Z", {"type": 'Z', "value": 'PRESS'}, None), - ("PRECISION_ENABLE", {"type": 'LEFT_ALT', "value": 'PRESS', "any": True}, None), - ("PRECISION_DISABLE", {"type": 'LEFT_ALT', "value": 'RELEASE', "any": True}, None), - ("PRECISION_ENABLE", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("PRECISION_DISABLE", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("FREELOOK_ENABLE", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("FREELOOK_DISABLE", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ], - }, - ), - ( - "View3D Walk Modal", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'ANY', "any": True}, None), - ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), - ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), - ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), - ("FAST_ENABLE", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("FAST_DISABLE", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("SLOW_ENABLE", {"type": 'LEFT_ALT', "value": 'PRESS', "any": True}, None), - ("SLOW_DISABLE", {"type": 'LEFT_ALT', "value": 'RELEASE', "any": True}, None), - ("FORWARD", {"type": 'W', "value": 'PRESS', "any": True}, None), - ("BACKWARD", {"type": 'S', "value": 'PRESS', "any": True}, None), - ("LEFT", {"type": 'A', "value": 'PRESS', "any": True}, None), - ("RIGHT", {"type": 'D', "value": 'PRESS', "any": True}, None), - ("UP", {"type": 'E', "value": 'PRESS', "any": True}, None), - ("DOWN", {"type": 'Q', "value": 'PRESS', "any": True}, None), - ("FORWARD_STOP", {"type": 'W', "value": 'RELEASE', "any": True}, None), - ("BACKWARD_STOP", {"type": 'S', "value": 'RELEASE', "any": True}, None), - ("LEFT_STOP", {"type": 'A', "value": 'RELEASE', "any": True}, None), - ("RIGHT_STOP", {"type": 'D', "value": 'RELEASE', "any": True}, None), - ("UP_STOP", {"type": 'E', "value": 'RELEASE', "any": True}, None), - ("DOWN_STOP", {"type": 'Q', "value": 'RELEASE', "any": True}, None), - ("FORWARD", {"type": 'UP_ARROW', "value": 'PRESS'}, None), - ("BACKWARD", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None), - ("LEFT", {"type": 'LEFT_ARROW', "value": 'PRESS'}, None), - ("RIGHT", {"type": 'RIGHT_ARROW', "value": 'PRESS'}, None), - ("FORWARD_STOP", {"type": 'UP_ARROW', "value": 'RELEASE', "any": True}, None), - ("BACKWARD_STOP", {"type": 'DOWN_ARROW', "value": 'RELEASE', "any": True}, None), - ("LEFT_STOP", {"type": 'LEFT_ARROW', "value": 'RELEASE', "any": True}, None), - ("RIGHT_STOP", {"type": 'RIGHT_ARROW', "value": 'RELEASE', "any": True}, None), - ("GRAVITY_TOGGLE", {"type": 'TAB', "value": 'PRESS'}, None), - ("GRAVITY_TOGGLE", {"type": 'G', "value": 'PRESS'}, None), - ("JUMP", {"type": 'V', "value": 'PRESS', "any": True}, None), - ("JUMP_STOP", {"type": 'V', "value": 'RELEASE', "any": True}, None), - ("TELEPORT", {"type": 'SPACE', "value": 'PRESS', "any": True}, None), - ("TELEPORT", {"type": 'MIDDLEMOUSE', "value": 'ANY', "any": True}, None), - ("ACCELERATE", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "any": True}, None), - ("DECELERATE", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "any": True}, None), - ("ACCELERATE", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "any": True}, None), - ("DECELERATE", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "View3D Rotate Modal", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CONFIRM", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), - ("CONFIRM", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ("AXIS_SNAP_ENABLE", {"type": 'LEFT_ALT', "value": 'PRESS', "any": True}, None), - ("AXIS_SNAP_DISABLE", {"type": 'LEFT_ALT', "value": 'RELEASE', "any": True}, None), - ], - }, - ), - ( - "View3D Move Modal", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CONFIRM", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), - ("CONFIRM", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "View3D Zoom Modal", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CONFIRM", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), - ("CONFIRM", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "View3D Dolly Modal", - {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True}, - { - "items": [ - ("CONFIRM", {"type": 'MIDDLEMOUSE', "value": 'RELEASE', "any": True}, None), - ("CONFIRM", {"type": 'ESC', "value": 'PRESS', "any": True}, None), - ], - }, - ), ( "Graph Editor Generic", {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'}, -- cgit v1.2.3 From ce885edfee80c41838de3fe6446530f27cf4d77d Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Mon, 9 Jul 2018 12:57:51 +0200 Subject: UI: Remove 1 pixel gap between panel header and background --- source/blender/editors/interface/interface_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 538f188c436..27afdcdd202 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -691,7 +691,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) { /* draw with background color */ immUniformThemeColor(TH_PANEL_HEADER); - immRectf(pos, minx, headrect.ymin + 1, maxx, y); + immRectf(pos, minx, headrect.ymin, maxx, y); immBegin(GWN_PRIM_LINES, 4); -- cgit v1.2.3 From a7249636409a9371599d93760cff2d1a37da32ad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 13:38:10 +0200 Subject: Fix object mode menu crashing w/o active object --- source/blender/editors/space_view3d/view3d_buttons.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index bcf9a7c4ad1..8fa327d8782 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1226,7 +1226,7 @@ void VIEW3D_OT_properties(wmOperatorType *ot) static int view3d_object_mode_menu(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_active_object(C); - if (ob->type == OB_ARMATURE) { + if (ob && ((ob->mode & OB_MODE_EDIT) == 0) && (ELEM(ob->type, OB_ARMATURE))) { ED_object_mode_toggle(C, OB_MODE_POSE); return OPERATOR_CANCELLED; } -- cgit v1.2.3 From 53c24bf97c436edc326362184003a482cb42b8d1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 14:06:51 +0200 Subject: Keymap: macos only operator search key: Cmd-F Add Cmd-F for apple because it's not easily available on some systems. --- source/blender/windowmanager/intern/wm_operators.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 06e759f1d3f..d7e503b6c03 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3996,6 +3996,11 @@ void wm_window_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "WM_OT_quit_blender", QKEY, KM_PRESS, KM_CTRL, 0); + /* F-Keys are a hassle on some macos systems. */ +#ifdef __APPLE__ + WM_keymap_add_item(keymap, "WM_OT_search_menu", FKEY, KM_PRESS, KM_OSKEY, 0); +#endif + #ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "WM_OT_doc_view_manual_ui_context", F1KEY, KM_PRESS, KM_ALT, 0); -- cgit v1.2.3 From bf02c4ba000485b726c174aca1edb52f3acd3eb4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 14:08:25 +0200 Subject: Keymap: Add back Shift-R 'repeat last' This may be used often in a workflow, so keep the key. --- source/blender/editors/screen/screen_ops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4a8ab724c9a..381a20feca4 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4888,9 +4888,11 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* tests */ WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + + WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0); + #ifdef USE_WM_KEYMAP_27X WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", RKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCRIPT_OT_reload", F8KEY, KM_PRESS, 0, 0); -- cgit v1.2.3 From f84956738ba4e97f30553a675b643f6648afce1d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 6 Jul 2018 12:33:12 +0200 Subject: Depsgraph: Forbid flush from copy-on-write operations down the road Old behavior: tagging ID with DEG_TAG_COPY_ON_WRITE will do copy-on-write (as requested), but will also flush changes to all operations with depends on it. This means, for example, tagging object for copy-on-write will force its modifier stack to be evaluated. This was needed in the earlier days of copy-on-write when things were not well defined and when lots of areas were not doing proper tagging. New behavior: tagging ID with DEG_TAG_COPY_ON_WRITE will only ensure copy of the dadatblock is up to date, without flushing updates to any dependencies. This means following things: - We can update parts of ID without invoking heavy computation of other parts of same ID. For example, tagging object for COPY_ON_WRITE update on mode change will not force modifiers stack to update. - If some dependent datablock is dependent on pointers which are invalidated by copy-on-write (like, evaluated mesh referencing custom data layers from original mesh), this will either require explicit tag or explicit relation in the dependency graph. Currently can not find a faulty case since tagging of mesh happens with either 0 (which means, everything) or with GEOMETRY, which also forces all dependent modifier stacks to be re-evaluated. This fixes missing PBVH when going into sculpt mode (sculpt mode toggle was tagging object for COPY_ON_WRITE update, which was forcing modifier stack to be updated, which was freeing PBVH. Some other operations might also become faster with this change. --- source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 1e0420ef6bc..1eaf53a0afc 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -2209,10 +2209,7 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node /* Component explicitly requests to not add relation. */ continue; } - int rel_flag = 0; - if (comp_node->type == DEG_NODE_TYPE_ANIMATION) { - rel_flag |= DEPSREL_FLAG_NO_FLUSH; - } + int rel_flag = DEPSREL_FLAG_NO_FLUSH; /* All entry operations of each component should wait for a proper * copy of ID. */ -- cgit v1.2.3 From d37929c85b88066ca044050ba520627b6364d93c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 9 Jul 2018 14:17:36 +0200 Subject: Depsgraph: Force modifier stack update when mesh is copied Modifier stack might reference arrays from mesh, so if any of sub-data pointer changed, modifier stack is to be re-evaluated. --- source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 1eaf53a0afc..7a5d2b4afa4 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -2186,7 +2186,7 @@ void DepsgraphRelationBuilder::build_nested_shapekey(ID *owner, Key *key) void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node) { ID *id_orig = id_node->id_orig; - + const ID_Type id_type = GS(id_orig->name); TimeSourceKey time_source_key; OperationKey copy_on_write_key(id_orig, DEG_NODE_TYPE_COPY_ON_WRITE, @@ -2210,6 +2210,9 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node continue; } int rel_flag = DEPSREL_FLAG_NO_FLUSH; + if (id_type == ID_ME && comp_node->type == DEG_NODE_TYPE_GEOMETRY) { + rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; + } /* All entry operations of each component should wait for a proper * copy of ID. */ -- cgit v1.2.3 From edb78d528b24f208ecd61ad5ddfee82014858a67 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 14:12:31 +0200 Subject: Keymap: Remove AccentGrave for each Use only F3 for search since this is a common enough key and it turns out having AccentGrave access on non US layouts is too unreliable. --- source/blender/editors/space_view3d/view3d_ops.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 00f0dea8fe2..59f018503e1 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -311,7 +311,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "center", true); #endif - WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_view_pie", ACCENTGRAVEKEY, KM_CLICK_DRAG, 0, 0); + WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_view_pie", ACCENTGRAVEKEY, KM_PRESS, 0, 0); /* numpad view hotkeys*/ WM_keymap_add_item(keymap, "VIEW3D_OT_view_camera", PAD0, KM_PRESS, 0, 0); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d7e503b6c03..926169e77fd 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -4015,8 +4015,6 @@ void wm_window_keymap(wmKeyConfig *keyconf) #endif /* menus that can be accessed anywhere in blender */ - WM_keymap_add_item(keymap, "WM_OT_search_menu", ACCENTGRAVEKEY, KM_CLICK, 0, 0); - WM_keymap_add_menu(keymap, "SCREEN_MT_user_menu", QKEY, KM_PRESS, 0, 0); #ifdef WITH_INPUT_NDOF -- cgit v1.2.3 From e8bc8bf618b6fdc03c3b4b10dacb54b13bcbcbce Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Mon, 9 Jul 2018 15:36:30 +0200 Subject: UI: Minor tweaks to default theme Based on feedback from the 'User Feedback' devtalk forum * More opaque panels for the viewport * Darker state colors * Current frame color consistency for MCE --- release/datafiles/userdef/userdef_default_theme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 55827f7b222..2b84585b8a5 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -107,7 +107,7 @@ const bTheme U_theme_default = { .text_sel = RGBA(0xffffffff), .shaded = 1, .shadetop = -4, - .roundness = 0.4f, + .roundness = 0.2f, }, .wcol_tab = { .outline = RGBA(0x2d2d2dff), @@ -220,11 +220,11 @@ const bTheme U_theme_default = { .roundness = 0.2f, }, .wcol_state = { - .inner_anim = RGBA(0x73be4cff), + .inner_anim = RGBA(0x53992eff), .inner_anim_sel = RGBA(0x5aa633ff), - .inner_key = RGBA(0xf0eb64ff), + .inner_key = RGBA(0xb3ae36ff), .inner_key_sel = RGBA(0xd7d34bff), - .inner_driven = RGBA(0xb400ffff), + .inner_driven = RGBA(0x9000ccff), .inner_driven_sel = RGBA(0x9900e6ff), .inner_overridden = RGBA(0x19c3c300), .inner_overridden_sel = RGBA(0x118f8f00), @@ -288,8 +288,8 @@ const bTheme U_theme_default = { .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0xffffffff), .panelcolors = { - .header = RGBA(0x424242cc), - .back = RGBA(0x333333b3), + .header = RGBA(0x424242e6), + .back = RGBA(0x333333f0), .sub_back = RGBA(0x0000003e), .show_header = 1, .show_back = 1, @@ -900,7 +900,7 @@ const bTheme U_theme_default = { }, .strip = RGBA(0x0c0a0a80), .strip_select = RGBA(0xff8c00ff), - .cframe = RGBA(0x308837ff), + .cframe = RGBA(0x5680c2ff), .handle_auto = RGBA(0x909000ff), .handle_align = RGBA(0x803060ff), .handle_sel_auto = RGBA(0xf0ff40ff), -- cgit v1.2.3 From edeb9e5b01626f0dcdf6c0f1c9b8c891bc681e5f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 9 Jul 2018 15:36:06 +0200 Subject: Fix T55868: duplicating collection instances fails sometimes. --- source/blender/blenkernel/intern/collection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 1d9cc9bb8d0..0c93f304218 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -473,7 +473,7 @@ static bool collection_object_add(Main *bmain, Collection *collection, Object *o { if (ob->dup_group) { /* Cyclic dependency check. */ - if (collection_find_child_recursive(collection, ob->dup_group)) { + if (collection_find_child_recursive(ob->dup_group, collection)) { return false; } } -- cgit v1.2.3 From 0e6abf414f1417383848883391cfdbd6f080f26a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 16:43:40 +0200 Subject: Keymap: use Shift-AccentGrave for fly/walk mode --- source/blender/editors/space_view3d/view3d_ops.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 59f018503e1..0fd109f858d 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -312,6 +312,7 @@ void view3d_keymap(wmKeyConfig *keyconf) #endif WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_view_pie", ACCENTGRAVEKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_navigate", ACCENTGRAVEKEY, KM_PRESS, KM_SHIFT, 0); /* numpad view hotkeys*/ WM_keymap_add_item(keymap, "VIEW3D_OT_view_camera", PAD0, KM_PRESS, 0, 0); -- cgit v1.2.3 From be8855a2ef03c918cd8a7bd13dc315a37d5bfc80 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 17:00:09 +0200 Subject: UI: move visibility panel into the side bar --- release/scripts/startup/bl_ui/space_view3d.py | 101 ++++++++++++-------------- 1 file changed, 47 insertions(+), 54 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index b0abb1b3117..c905dc51b0e 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -112,14 +112,6 @@ class VIEW3D_HT_header(Header): sub.active = overlay.show_overlays sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay") - layout.popover( - text="", - icon='HIDE_OFF', - space_type='VIEW_3D', - region_type='HEADER', - panel_type="VIEW3D_PT_object_type_visibility", - ) - layout.separator_spacer() # Mode & Transform Settings @@ -3697,6 +3689,52 @@ class VIEW3D_PT_view3d_cursor(Panel): layout.column().prop(view, "cursor_location", text="Location") +class VIEW3D_PT_object_type_visibility(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'UI' + bl_label = "View Object Types" + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + view = context.space_data + + col = layout.column() + + split = col.split() + + heading_pair = ("Visible", "Selectable") + attr_object_types = ( + "mesh", + "curve", + "surf", + "meta", + "font", + "armature", + "lattice", + "empty", + "camera", + "lamp", + "light_probe", + "speaker", + ) + + attr_vis = [f"show_object_viewport_{attr}" for attr in attr_object_types] + attr_sel = [f"show_object_select_{attr}" for attr in attr_object_types] + + sub = split.column() + sub.label("Visible") + for attr_v in attr_vis: + sub.prop(view, attr_v) + + sub = split.column() + sub.label("Selectable") + for attr_v, attr_s in zip(attr_vis, attr_sel): + row = sub.row(align=True) + row.active = getattr(view, attr_v) + row.prop(view, attr_s) + + class VIEW3D_PT_shading(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' @@ -4129,51 +4167,6 @@ class VIEW3D_PT_overlay_paint(Panel): col.prop(overlay, "show_paint_wire") -class VIEW3D_PT_object_type_visibility(Panel): - bl_space_type = 'VIEW_3D' - bl_region_type = 'HEADER' - bl_label = "Object Visibility" - - def draw(self, context): - layout = self.layout - view = context.space_data - - col = layout.column() - - split = col.split() - - heading_pair = ("Visible", "Selectable") - attr_object_types = ( - "mesh", - "curve", - "surf", - "meta", - "font", - "armature", - "lattice", - "empty", - "camera", - "lamp", - "light_probe", - "speaker", - ) - - attr_vis = [f"show_object_viewport_{attr}" for attr in attr_object_types] - attr_sel = [f"show_object_select_{attr}" for attr in attr_object_types] - - sub = split.column() - sub.label("Visible") - for attr_v in attr_vis: - sub.prop(view, attr_v) - - sub = split.column() - sub.label("Selectable") - for attr_v, attr_s in zip(attr_vis, attr_sel): - row = sub.row(align=True) - row.active = getattr(view, attr_v) - row.prop(view, attr_s) - - class VIEW3D_PT_pivot_point(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' @@ -4505,6 +4498,7 @@ classes = ( VIEW3D_PT_view3d_properties, VIEW3D_PT_view3d_camera_lock, VIEW3D_PT_view3d_cursor, + VIEW3D_PT_object_type_visibility, VIEW3D_PT_quad_view, VIEW3D_PT_view3d_stereo, VIEW3D_PT_shading, @@ -4518,7 +4512,6 @@ classes = ( VIEW3D_PT_overlay_pose, VIEW3D_PT_overlay_paint, VIEW3D_PT_overlay_sculpt, - VIEW3D_PT_object_type_visibility, VIEW3D_PT_pivot_point, VIEW3D_PT_snapping, VIEW3D_PT_transform_orientations, -- cgit v1.2.3 From cf9f0b35be1b489c03f015b5ee78d0042fa4c9fb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 17:36:25 +0200 Subject: UI: add search to popup toolbar Add for convenience only. --- release/scripts/startup/bl_operators/wm.py | 4 ++++ .../scripts/startup/bl_ui/space_toolsystem_common.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 30a90fb11d4..a01298f5696 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -2398,6 +2398,10 @@ class WM_OT_toolbar(Operator): def draw_menu(popover, context): layout = popover.layout + + layout.operator_context = 'INVOKE_DEFAULT' + layout.operator("wm.search_menu", text="Search Commands...", icon='VIEWZOOM') + cls.draw_cls(layout, context, detect_layout=False, scale_y=1.0) wm.popover(draw_menu, ui_units_x=8, keymap=keymap) diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 2d7afb7a56a..7fe8360b4da 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -624,7 +624,10 @@ def keymap_from_context(context, space_type): """ Keymap for popup toolbar, currently generated each time. """ + + use_search = False # allows double tap use_simple_keymap = False + km_name = "Toolbar Popup" wm = context.window_manager keyconf = wm.keyconfigs.active @@ -634,6 +637,10 @@ def keymap_from_context(context, space_type): for kmi in keymap.keymap_items: keymap.keymap_items.remove(kmi) + if use_search: + kmi_search = wm.keyconfigs.find_item_from_operator(idname="wm.toolbar")[1] + kmi_search_type = None if not kmi_search else kmi_search.type + items = [] cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) for i, item in enumerate( @@ -679,6 +686,16 @@ def keymap_from_context(context, space_type): ) kmi.properties.name = item.text + if use_search: + # Disallow overlap + if kmi_search_type == kmi_found_type: + kmi_search_type = None + + if use_search: + # Support double-tap for search. + if kmi_search_type: + keymap.keymap_items.new("wm.search_menu", type=kmi_search_type, value='PRESS') + wm.keyconfigs.update() return keymap -- cgit v1.2.3 From 5a56e4997f9667da1fbe76d69ee7294fa13a9dc6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 9 Jul 2018 17:41:04 +0200 Subject: Depsgraph: Fix non-working drivers after recent relations change --- source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 7a5d2b4afa4..23e50f125ba 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -2213,6 +2213,9 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node if (id_type == ID_ME && comp_node->type == DEG_NODE_TYPE_GEOMETRY) { rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; } + if (comp_node->type == DEG_NODE_TYPE_PARAMETERS) { + rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; + } /* All entry operations of each component should wait for a proper * copy of ID. */ -- cgit v1.2.3 From 8c528a4f0aaf62737f5a768e4190609925134ca0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 17:57:05 +0200 Subject: Cleanup: use const transform args --- source/blender/editors/transform/transform.h | 10 +++++----- source/blender/editors/transform/transform_snap.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 017bbfc8a5e..5f738804579 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -695,8 +695,8 @@ void snapGridIncrementAction(TransInfo *t, float *val, GearsType action); void snapSequenceBounds(TransInfo *t, const int mval[2]); -bool activeSnap(TransInfo *t); -bool validSnap(TransInfo *t); +bool activeSnap(const TransInfo *t); +bool validSnap(const TransInfo *t); void initSnapping(struct TransInfo *t, struct wmOperator *op); void freeSnapping(struct TransInfo *t); @@ -706,10 +706,10 @@ void applySnapping(TransInfo *t, float *vec); void resetSnapping(TransInfo *t); eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event); void drawSnapping(const struct bContext *C, TransInfo *t); -bool usingSnappingNormal(TransInfo *t); -bool validSnappingNormal(TransInfo *t); +bool usingSnappingNormal(const TransInfo *t); +bool validSnappingNormal(const TransInfo *t); -void getSnapPoint(TransInfo *t, float vec[3]); +void getSnapPoint(const TransInfo *t, float vec[3]); void addSnapPoint(TransInfo *t); eRedrawFlag updateSelectedSnapPoint(TransInfo *t); void removeSnapPoint(TransInfo *t); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 5ea826521ed..8bc53127b4c 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -122,13 +122,13 @@ int BIF_snappingSupported(Object *obedit) } #endif -bool validSnap(TransInfo *t) +bool validSnap(const TransInfo *t) { return (t->tsnap.status & (POINT_INIT | TARGET_INIT)) == (POINT_INIT | TARGET_INIT) || (t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT); } -bool activeSnap(TransInfo *t) +bool activeSnap(const TransInfo *t) { return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) || ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT); @@ -471,12 +471,12 @@ void resetSnapping(TransInfo *t) t->tsnap.snapNodeBorder = 0; } -bool usingSnappingNormal(TransInfo *t) +bool usingSnappingNormal(const TransInfo *t) { return t->tsnap.align; } -bool validSnappingNormal(TransInfo *t) +bool validSnappingNormal(const TransInfo *t) { if (validSnap(t)) { if (!is_zero_v3(t->tsnap.snapNormal)) { @@ -807,7 +807,7 @@ void removeSnapPoint(TransInfo *t) } } -void getSnapPoint(TransInfo *t, float vec[3]) +void getSnapPoint(const TransInfo *t, float vec[3]) { if (t->tsnap.points.first) { TransSnapPoint *p; -- cgit v1.2.3 From 113b053d5b4681022679405c4587cf50ba112418 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 18:13:13 +0200 Subject: WM: add utility function to refresh status bar --- source/blender/windowmanager/WM_api.h | 3 ++- .../blender/windowmanager/intern/wm_event_system.c | 25 +++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1f5e3aa2461..6d577afdbf9 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -608,7 +608,8 @@ bool WM_event_is_ime_switch(const struct wmEvent *event); const char *WM_window_cursor_keymap_status_get(const struct wmWindow *win, int button_index, int type_index); void WM_window_cursor_keymap_status_refresh(struct bContext *C, struct wmWindow *win); -struct ScrArea *WM_window_find_area_status(struct wmWindow *win, struct bScreen *sc); +void WM_window_status_area_tag_redraw(struct wmWindow *win); +struct ScrArea *WM_window_status_area_find(struct wmWindow *win, struct bScreen *sc); bool WM_window_modal_keymap_status_draw( struct bContext *C, struct wmWindow *win, struct uiLayout *layout); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 7e2198eed7a..8469dc9da0e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1973,11 +1973,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand if (op->type->modalkeymap) { wmWindow *win = CTX_wm_window(C); - bScreen *sc = WM_window_get_active_screen(win); - ScrArea *sa = WM_window_find_area_status(win, sc); - if (sa != NULL) { - ED_area_tag_redraw(sa); - } + WM_window_status_area_tag_redraw(win); } } else { @@ -3211,11 +3207,7 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op) BLI_addhead(&win->modalhandlers, handler); if (op->type->modalkeymap) { - bScreen *sc = WM_window_get_active_screen(win); - ScrArea *sa = WM_window_find_area_status(win, sc); - if (sa != NULL) { - ED_area_tag_redraw(sa); - } + WM_window_status_area_tag_redraw(win); } return handler; @@ -4352,7 +4344,7 @@ const char *WM_window_cursor_keymap_status_get(const wmWindow *win, int button_i * Similar to #BKE_screen_area_map_find_area_xy and related functions, * use here since the ara is stored in the window manager. */ -ScrArea *WM_window_find_area_status(wmWindow *win, bScreen *screen) +ScrArea *WM_window_status_area_find(wmWindow *win, bScreen *screen) { if (screen->state == SCREENFULL) { return NULL; @@ -4367,10 +4359,19 @@ ScrArea *WM_window_find_area_status(wmWindow *win, bScreen *screen) return sa_statusbar; } +void WM_window_status_area_tag_redraw(wmWindow *win) +{ + bScreen *sc = WM_window_get_active_screen(win); + ScrArea *sa = WM_window_status_area_find(win, sc); + if (sa != NULL) { + ED_area_tag_redraw(sa); + } +} + void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa_statusbar = WM_window_find_area_status(win, screen); + ScrArea *sa_statusbar = WM_window_status_area_find(win, screen); if (sa_statusbar == NULL) { return; } -- cgit v1.2.3 From 881cc17ffa71c0717e1bf3c23187e052231f8b4a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 17:58:58 +0200 Subject: UI: hide status bar items when --- source/blender/editors/transform/transform.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index c350283597e..6745f64cb88 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -832,6 +832,12 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) if (t->spacetype != SPACE_VIEW3D) { return false; } + else if (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) { + return false; + } + else if (!validSnap(t)) { + return false; + } break; } case TFM_MODAL_AXIS_Z: @@ -850,6 +856,13 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) } break; } + case TFM_MODAL_CONS_OFF: + { + if ((t->con.mode & CON_APPLY) == 0) { + return false; + } + break; + } case TFM_MODAL_EDGESLIDE_UP: case TFM_MODAL_EDGESLIDE_DOWN: { @@ -873,7 +886,6 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) } break; } - } return true; } @@ -1613,6 +1625,12 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; } + if (t->redraw && + !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) + { + WM_window_status_area_tag_redraw(CTX_wm_window(t->context)); + } + if (handled || t->redraw) { return 0; } -- cgit v1.2.3 From 07e368cb5f6a4f73164a70794e884970d171d909 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jul 2018 18:25:25 +0200 Subject: UI: hide status bar constraints when not used --- source/blender/editors/transform/transform.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 6745f64cb88..1f2589d8a0c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -840,20 +840,21 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) } break; } + case TFM_MODAL_AXIS_X: + case TFM_MODAL_AXIS_Y: case TFM_MODAL_AXIS_Z: - { - if (t->flag & T_2D_EDIT) { - return false; - } - break; - } case TFM_MODAL_PLANE_X: case TFM_MODAL_PLANE_Y: case TFM_MODAL_PLANE_Z: { - if (t->flag & T_2D_EDIT) { + if (t->flag & T_NO_CONSTRAINT) { return false; } + if (!ELEM(value, TFM_MODAL_AXIS_X, TFM_MODAL_AXIS_Y)) { + if (t->flag & T_2D_EDIT) { + return false; + } + } break; } case TFM_MODAL_CONS_OFF: -- cgit v1.2.3 From 845899d373df4fa5e692c828d6af151309169c87 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 9 Jul 2018 23:27:06 +0200 Subject: UI: tweak image menu layout to match file menu more. --- release/scripts/startup/bl_ui/space_image.py | 33 ++++++++++++++------------ source/blender/editors/space_image/image_ops.c | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index e20c3ccd7f5..1303e46ab6c 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -191,30 +191,33 @@ class IMAGE_MT_image(Menu): sima = context.space_data ima = sima.image - - layout.operator("image.new") - layout.operator("image.open") - show_render = sima.show_render - layout.operator("image.read_viewlayers") + layout.operator("image.new", text="New") + layout.operator("image.open", text="Open...") - layout.operator("image.save_dirty", text="Save All Images") + layout.operator("image.read_viewlayers") if ima: if not show_render: - layout.operator("image.replace") - layout.operator("image.reload") + layout.operator("image.replace", text="Replace...") + layout.operator("image.reload", text="Reload") - layout.operator("image.save") - layout.operator("image.save_as") - layout.operator("image.save_as", text="Save a Copy").copy = True + layout.operator("image.external_edit", "Edit Externally") - if ima.source == 'SEQUENCE': - layout.operator("image.save_sequence") + layout.separator() - layout.operator("image.external_edit", "Edit Externally") + if ima: + layout.operator("image.save", text="Save") + layout.operator("image.save_as", text="Save As...") + layout.operator("image.save_as", text="Save a Copy...").copy = True + + if ima and ima.source == 'SEQUENCE': + layout.operator("image.save_sequence") + layout.operator("image.save_dirty", text="Save All Images") + + if ima: layout.separator() layout.menu("IMAGE_MT_image_invert") @@ -222,7 +225,7 @@ class IMAGE_MT_image(Menu): if not show_render: if not ima.packed_file: layout.separator() - layout.operator("image.pack") + layout.operator("image.pack", text="Pack") # only for dirty && specific image types, perhaps # this could be done in operator poll too diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index f852f601db2..650b48b3b1c 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3700,7 +3700,7 @@ static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op)) void IMAGE_OT_read_viewlayers(wmOperatorType *ot) { - ot->name = "Read View Layers"; + ot->name = "Open Cached Render"; ot->idname = "IMAGE_OT_read_viewlayers"; ot->description = "Read all the current scene's view layers from cache, as needed"; -- cgit v1.2.3 From 8373544df30a0e24b080a03c4d4c0b5108c4932d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 9 Jul 2018 23:33:20 +0200 Subject: Fix T55776: crash with multiple windows and reload new. There were a number of cases where immActivate() and immDeactivate() could get out of sync, causing crashes due to using a freed mutex lock. Refactor the code now to hopefully avoid this always. --- intern/gawain/src/gwn_immediate.c | 3 - source/blender/makesrna/intern/rna_userdef.c | 8 +-- source/blender/windowmanager/intern/wm_files.c | 13 ++-- source/blender/windowmanager/intern/wm_init_exit.c | 3 +- source/blender/windowmanager/intern/wm_playanim.c | 6 +- source/blender/windowmanager/intern/wm_window.c | 83 ++++++++++++---------- 6 files changed, 61 insertions(+), 55 deletions(-) diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c index c57564fce06..d43e52cc525 100644 --- a/intern/gawain/src/gwn_immediate.c +++ b/intern/gawain/src/gwn_immediate.c @@ -77,8 +77,6 @@ void immInit(void) glBindBuffer(GL_ARRAY_BUFFER, 0); initialized = true; - - immActivate(); } void immActivate(void) @@ -106,7 +104,6 @@ void immDeactivate(void) void immDestroy(void) { - immDeactivate(); GWN_buf_id_free(imm.vbo_id); initialized = false; } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9ac93efe347..f088ac9f442 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -143,17 +143,11 @@ static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe } /* also used by buffer swap switching */ -static void rna_userdef_dpi_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_userdef_dpi_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { /* font's are stored at each DPI level, without this we can easy load 100's of fonts */ BLF_cache_clear(); - /* force setting drawable again */ - wmWindowManager *wm = bmain->wm.first; - if (wm) { - wm->windrawable = NULL; - } - WM_main_add_notifier(NC_WINDOW, NULL); /* full redraw */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); /* refresh region sizes */ } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 6b727a57370..0c3f4fb5181 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -186,13 +186,18 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) ED_editors_exit(C); } -static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWindow *win) +static void wm_window_substitute_old(wmWindowManager *oldwm, wmWindowManager *wm, wmWindow *oldwin, wmWindow *win) { win->ghostwin = oldwin->ghostwin; win->gwnctx = oldwin->gwnctx; win->active = oldwin->active; - if (win->active) + if (win->active) { wm->winactive = win; + } + if (oldwm->windrawable == oldwin) { + oldwm->windrawable = NULL; + wm->windrawable = win; + } if (!G.background) /* file loading in background mode still calls this */ GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ @@ -281,13 +286,13 @@ static void wm_window_match_replace_by_file_wm( if (oldwin->winid == win->winid) { has_match = true; - wm_window_substitute_old(wm, oldwin, win); + wm_window_substitute_old(oldwm, wm, oldwin, win); } } } /* make sure at least one window is kept open so we don't lose the context, check T42303 */ if (!has_match) { - wm_window_substitute_old(wm, oldwm->windows.first, wm->windows.first); + wm_window_substitute_old(oldwm, wm, oldwm->windows.first, wm->windows.first); } wm_close_and_free_all(C, current_wm_list); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index c1af7153b62..183e58e5a15 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -491,8 +491,6 @@ void WM_exit_ext(bContext *C, const bool do_python) #endif GPU_free_unused_buffers(G_MAIN); - - GPU_exit(); } BKE_blender_free(); /* blender.c, does entire library and spacetypes */ @@ -515,6 +513,7 @@ void WM_exit_ext(bContext *C, const bool do_python) if (opengl_is_init) { GPU_pass_cache_free(); DRW_opengl_context_destroy(); + GPU_exit(); } #ifdef WITH_INTERNATIONAL diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index ef7992dcb8c..003932930ed 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -1283,6 +1283,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) /* initialize OpenGL immediate mode */ g_WS.gwn_context = GWN_context_create(); GPU_init(); + immActivate(); /* initialize the font */ BLF_init(); @@ -1551,8 +1552,6 @@ static char *wm_main_playanim_intern(int argc, const char **argv) GPU_shader_free_builtin_shaders(); - GPU_exit(); - if (g_WS.gwn_context) { GWN_context_active_set(g_WS.gwn_context); GWN_context_discard(g_WS.gwn_context); @@ -1561,6 +1560,9 @@ static char *wm_main_playanim_intern(int argc, const char **argv) BLF_exit(); + immDeactivate(); + GPU_exit(); + GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window); /* early exit, IMB and BKE should be exited only in end */ diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index e4ccf074bab..4f86d05d515 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -122,6 +122,9 @@ static struct WMInitStruct { /* ******** win open & close ************ */ +static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate); +static void wm_window_clear_drawable(wmWindowManager *wm); + /* XXX this one should correctly check for apple top header... * done for Cocoa : returns window contents (and not frame) max size*/ void wm_get_screensize(int *r_width, int *r_height) @@ -176,10 +179,19 @@ static void wm_window_check_position(rcti *rect) if (rect->ymin < 0) rect->ymin = 0; } - static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win) { if (win->ghostwin) { + if (win == wm->windrawable) { + /* Prevents non-drawable state of main windows (bugs #22967, + * #25071 and possibly #22477 too). */ + wm_window_clear_drawable(wm); + } + + if (win == wm->winactive) { + wm->winactive = NULL; + } + /* We need this window's opengl context active to discard it. */ GHOST_ActivateWindowDrawingContext(win->ghostwin); GWN_context_active_set(win->gwnctx); @@ -191,9 +203,6 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win) win->ghostwin = NULL; win->gwnctx = NULL; - /* prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */ - wm->windrawable = NULL; - wm->winactive = NULL; } } @@ -513,21 +522,8 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) ED_screen_exit(C, win, screen); } - if (win_other) { - BLF_batch_reset(); - gpu_batch_presets_reset(); - immDeactivate(); - } - wm_window_free(C, wm, win); - /* keep imediatemode active before the next `wm_window_make_drawable` call */ - if (win_other) { - GHOST_ActivateWindowDrawingContext(win_other->ghostwin); - GWN_context_active_set(win_other->gwnctx); - immActivate(); - } - /* if temp screen, delete it after window free (it stops jobs that can access it) */ if (screen && screen->temp) { Main *bmain = CTX_data_main(C); @@ -646,19 +642,19 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm if (ghostwin) { GHOST_RectangleHandle bounds; - /* XXX Fix crash when a new window is created. - * However this should be move somewhere else. (fclem) */ - BLF_batch_reset(); - gpu_batch_presets_reset(); + /* Clear drawable so we can set the new window. */ + wm_window_clear_drawable(wm); win->gwnctx = GWN_context_create(); - /* the new window has already been made drawable upon creation */ - wm->windrawable = win; - /* needed so we can detect the graphics card below */ GPU_init(); + /* Set window as drawable upon creation. Note this has already been + * it has already been activated by GHOST_CreateWindow. */ + bool activate = false; + wm_window_set_drawable(wm, win, activate); + win->ghostwin = ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ @@ -1095,24 +1091,41 @@ static int query_qual(modifierKeyType qual) return val; } +static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate) +{ + BLI_assert(ELEM(wm->windrawable, NULL, win)); + + wm->windrawable = win; + if (activate) { + GHOST_ActivateWindowDrawingContext(win->ghostwin); + } + GWN_context_active_set(win->gwnctx); + immActivate(); +} + +static void wm_window_clear_drawable(wmWindowManager *wm) +{ + if (wm->windrawable) { + BLF_batch_reset(); + gpu_batch_presets_reset(); + immDeactivate(); + wm->windrawable = NULL; + } +} + void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) { BLI_assert(GPU_framebuffer_current_get() == 0); if (win != wm->windrawable && win->ghostwin) { // win->lmbut = 0; /* keeps hanging when mousepressed while other window opened */ + wm_window_clear_drawable(wm); - wm->windrawable = win; if (G.debug & G_DEBUG_EVENTS) { printf("%s: set drawable %d\n", __func__, win->winid); } - BLF_batch_reset(); - gpu_batch_presets_reset(); - immDeactivate(); - GHOST_ActivateWindowDrawingContext(win->ghostwin); - GWN_context_active_set(win->gwnctx); - immActivate(); + wm_window_set_drawable(wm, win, true); /* this can change per window */ WM_window_set_dpi(win); @@ -1132,12 +1145,8 @@ void wm_window_reset_drawable(void) wmWindow *win = wm->windrawable; if (win && win->ghostwin) { - BLF_batch_reset(); - gpu_batch_presets_reset(); - immDeactivate(); - GHOST_ActivateWindowDrawingContext(win->ghostwin); - GWN_context_active_set(win->gwnctx); - immActivate(); + wm_window_clear_drawable(wm); + wm_window_set_drawable(wm, win, true); } } -- cgit v1.2.3 From 1112f49a14ba3bdf2c960a61a1975458e3ee986f Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 10 Jul 2018 00:47:08 +0200 Subject: UI: Cleanup - Remove Show Panel Header and Background A toggle for this is no longer required now that both header and background colors are RGBA (disabling Show Header is the same setting the alpha to 0). Thanks Brecht for reviewing! --- release/datafiles/userdef/userdef_default_theme.c | 34 ------------ source/blender/editors/include/UI_resources.h | 2 - .../blender/editors/interface/interface_layout.c | 20 ++++--- source/blender/editors/interface/interface_panel.c | 63 ++++++---------------- source/blender/editors/interface/resources.c | 8 --- source/blender/makesdna/DNA_userdef_types.h | 3 +- source/blender/makesrna/intern/rna_userdef.c | 8 --- 7 files changed, 27 insertions(+), 111 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 2b84585b8a5..e8c8f051c07 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -265,8 +265,6 @@ const bTheme U_theme_default = { .header = RGBA(0x42424200), .back = RGBA(0x00000028), .sub_back = RGBA(0x00000024), - .show_header = 1, - .show_back = 1, }, .vertex_size = 3, .outline_width = 1, @@ -291,8 +289,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242e6), .back = RGBA(0x333333f0), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .gradients = { .gradient = RGBA(0x39393900), @@ -384,8 +380,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .hilite = RGBA(0x4f76b3ff), .vertex_size = 3, @@ -416,8 +410,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .shade1 = RGBA(0x96969600), .shade2 = RGBA(0x2e2e2e64), @@ -464,8 +456,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .vertex_size = 3, .outline_width = 1, @@ -504,8 +494,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .shade1 = RGBA(0xc0c0c000), .shade2 = RGBA(0x70707064), @@ -559,8 +547,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .shade1 = RGBA(0x96969600), .grid = RGBA(0x5e5e5eff), @@ -604,8 +590,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .shade1 = RGBA(0xa0a0a000), .grid = RGBA(0x404040ff), @@ -648,8 +632,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .wire_edit = RGBA(0xc0c0c0ff), .vertex_select = RGBA(0xff8500ff), @@ -704,8 +686,6 @@ const bTheme U_theme_default = { .header = RGBA(0x42424200), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .shade2 = RGBA(0x19191aff), .hilite = RGBA(0xff0000ff), @@ -742,8 +722,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .vertex_size = 3, .outline_width = 1, @@ -780,8 +758,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .shade2 = RGBA(0x7f707064), .wire = RGBA(0x808080ff), @@ -833,8 +809,6 @@ const bTheme U_theme_default = { .header = RGBA(0x42424200), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .vertex_size = 3, .outline_width = 1, @@ -860,8 +834,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .console_output = RGBA(0xb3c2ffff), .console_input = RGBA(0xffffffff), @@ -895,8 +867,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .strip = RGBA(0x0c0a0a80), .strip_select = RGBA(0xff8c00ff), @@ -939,8 +909,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .vertex_size = 3, .outline_width = 1, @@ -965,8 +933,6 @@ const bTheme U_theme_default = { .header = RGBA(0x424242cc), .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), - .show_header = 1, - .show_back = 1, }, .vertex_size = 3, .outline_width = 1, diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index cab0fa8645d..5e6c346d9cf 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -75,8 +75,6 @@ typedef enum ThemeColorID { TH_PANEL_HEADER, TH_PANEL_BACK, TH_PANEL_SUB_BACK, - TH_PANEL_SHOW_HEADER, - TH_PANEL_SHOW_BACK, TH_BUTBACK, TH_BUTBACK_TEXT, diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 16016a799ef..159e8b1d022 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -4326,7 +4326,7 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout) static void ui_paneltype_draw_impl( - bContext *C, PanelType *pt, uiLayout *layout, bool show_header) + bContext *C, PanelType *pt, uiLayout *layout) { Panel *panel = MEM_callocN(sizeof(Panel), "popover panel"); panel->type = pt; @@ -4335,15 +4335,13 @@ static void ui_paneltype_draw_impl( uiLayout *last_item = layout->items.last; /* Draw main panel. */ - if (show_header) { - uiLayout *row = uiLayoutRow(layout, false); - if (pt->draw_header) { - panel->layout = row; - pt->draw_header(C, panel); - panel->layout = NULL; - } - uiItemL(row, pt->label, ICON_NONE); + uiLayout *row = uiLayoutRow(layout, false); + if (pt->draw_header) { + panel->layout = row; + pt->draw_header(C, panel); + panel->layout = NULL; } + uiItemL(row, pt->label, ICON_NONE); panel->layout = layout; pt->draw(C, panel); @@ -4363,7 +4361,7 @@ static void ui_paneltype_draw_impl( } uiLayout *col = uiLayoutColumn(layout, false); - ui_paneltype_draw_impl(C, child_pt, col, true); + ui_paneltype_draw_impl(C, child_pt, col); } } } @@ -4377,7 +4375,7 @@ void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout) CTX_store_set(C, layout->context); } - ui_paneltype_draw_impl(C, pt, layout, false); + ui_paneltype_draw_impl(C, pt, layout); if (layout->context) { CTX_store_set(C, NULL); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 27afdcdd202..79d92eedfa3 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -580,9 +580,8 @@ static void ui_draw_panel_dragwidget(unsigned int pos, unsigned int col, const r const int x_ofs = y_ofs; int i_x, i_y; - int col_id = UI_GetThemeValue(TH_PANEL_SHOW_HEADER) ? TH_PANEL_HEADER : TH_PANEL_BACK; - UI_GetThemeColorShade4fv(col_id, col_tint, col_high); - UI_GetThemeColorShade4fv(col_id, -col_tint, col_dark); + UI_GetThemeColorShade4fv(TH_PANEL_HEADER, col_tint, col_high); + UI_GetThemeColorShade4fv(TH_PANEL_BACK, -col_tint, col_dark); /* draw multiple boxes */ immBegin(GWN_PRIM_TRIS, 4 * 2 * (6 * 2)); @@ -688,43 +687,19 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con GPU_blend(true); - if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) { - /* draw with background color */ - immUniformThemeColor(TH_PANEL_HEADER); - immRectf(pos, minx, headrect.ymin, maxx, y); + /* draw with background color */ + immUniformThemeColor(TH_PANEL_HEADER); + immRectf(pos, minx, headrect.ymin, maxx, y); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GWN_PRIM_LINES, 4); - immVertex2f(pos, minx, y); - immVertex2f(pos, maxx, y); + immVertex2f(pos, minx, y); + immVertex2f(pos, maxx, y); - immVertex2f(pos, minx, y); - immVertex2f(pos, maxx, y); + immVertex2f(pos, minx, y); + immVertex2f(pos, maxx, y); - immEnd(); - } - else if (!(panel->runtime_flag & PNL_FIRST)) { - /* draw embossed separator */ - - if (is_closed_x == false) { - minx += 5.0f / block->aspect; - maxx -= 5.0f / block->aspect; - } - - immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); - - immBegin(GWN_PRIM_LINES, 2); - immVertex2f(pos, minx, y); - immVertex2f(pos, maxx, y); - immEnd(); - - immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f); - - immBegin(GWN_PRIM_LINES, 2); - immVertex2f(pos, minx, y - 1); - immVertex2f(pos, maxx, y - 1); - immEnd(); - } + immEnd(); GPU_blend(false); } @@ -798,17 +773,13 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + GPU_blend(true); + /* panel backdrop */ - if (is_subpanel) { - GPU_blend(true); - immUniformThemeColor(TH_PANEL_SUB_BACK); - immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); - } - else if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) { - GPU_blend(true); - immUniformThemeColor(TH_PANEL_BACK); - immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); - } + int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK; + + immUniformThemeColor(panel_col); + immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); if (panel->control & UI_PNL_SCALE) ui_draw_panel_scalewidget(pos, rect); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 3a67b8ff0ba..aa71c31c541 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -260,14 +260,6 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp = ts->panelcolors.back; break; case TH_PANEL_SUB_BACK: cp = ts->panelcolors.sub_back; break; - case TH_PANEL_SHOW_HEADER: - cp = &setting; - setting = ts->panelcolors.show_header; - break; - case TH_PANEL_SHOW_BACK: - cp = &setting; - setting = ts->panelcolors.show_back; - break; case TH_BUTBACK: cp = ts->button; break; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index d2782dee9ff..1e199904356 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -156,8 +156,7 @@ typedef struct uiPanelColors { char header[4]; char back[4]; char sub_back[4]; - short show_header; - short show_back; + char pad2[4]; } uiPanelColors; typedef struct uiGradientColors { diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f088ac9f442..aa6eb4c4dc2 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1029,14 +1029,6 @@ static void rna_def_userdef_theme_ui_panel(BlenderRNA *brna) prop = RNA_def_property(srna, "sub_back", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_ui_text(prop, "Sub Background", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - - prop = RNA_def_property(srna, "show_header", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_ui_text(prop, "Show Header", ""); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - - prop = RNA_def_property(srna, "show_back", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_ui_text(prop, "Show Background", ""); - RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_theme_ui_gradient(BlenderRNA *brna) -- cgit v1.2.3 From f51c6efbc183aa10c143f1e4a2588e14163c2f9f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 06:51:25 +0200 Subject: Fix transform plane constraint orientation cycle Regression since 2.79b release --- source/blender/editors/transform/transform.c | 41 ++++++++++------------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ad7c0980bca..58c8837328a 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -895,7 +895,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) return keymap; } -static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode) +static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode, bool is_plane) { if (!(t->flag & T_NO_CONSTRAINT)) { int constraint_axis, constraint_plane; @@ -948,17 +948,21 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm else { short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : V3D_MANIP_LOCAL); - if (!(t->modifiers & MOD_CONSTRAINT_PLANE)) + if (is_plane == false) { setUserConstraint(t, orientation, constraint_axis, msg2); - else if (t->modifiers & MOD_CONSTRAINT_PLANE) + } + else { setUserConstraint(t, orientation, constraint_plane, msg3); + } } } else { - if (!(t->modifiers & MOD_CONSTRAINT_PLANE)) + if (is_plane == false) { setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2); - else if (t->modifiers & MOD_CONSTRAINT_PLANE) + } + else { setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3); + } } } t->redraw |= TREDRAW_HARD; @@ -1136,57 +1140,42 @@ int transformEvent(TransInfo *t, const wmEvent *event) break; case TFM_MODAL_AXIS_X: if (!(t->flag & T_NO_CONSTRAINT)) { - transform_event_xyz_constraint(t, XKEY, cmode); + transform_event_xyz_constraint(t, XKEY, cmode, false); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_AXIS_Y: if ((t->flag & T_NO_CONSTRAINT) == 0) { - transform_event_xyz_constraint(t, YKEY, cmode); + transform_event_xyz_constraint(t, YKEY, cmode, false); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_AXIS_Z: if ((t->flag & (T_NO_CONSTRAINT)) == 0) { - transform_event_xyz_constraint(t, ZKEY, cmode); + transform_event_xyz_constraint(t, ZKEY, cmode, false); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_PLANE_X: if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { - if (cmode == 'X') { - stopConstraint(t); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS1 | CON_AXIS2), IFACE_("locking %s X")); - } + transform_event_xyz_constraint(t, XKEY, cmode, true); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_PLANE_Y: if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { - if (cmode == 'Y') { - stopConstraint(t); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS2), IFACE_("locking %s Y")); - } + transform_event_xyz_constraint(t, YKEY, cmode, true); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_PLANE_Z: if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { - if (cmode == 'Z') { - stopConstraint(t); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS1), IFACE_("locking %s Z")); - } + transform_event_xyz_constraint(t, ZKEY, cmode, true); t->redraw |= TREDRAW_HARD; handled = true; } -- cgit v1.2.3 From 81210103104980c9052de491a0b4defd003c2d1e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 06:54:39 +0200 Subject: Transform: default constraint to user orientation Previously global was always used before the current orientation, the order is now reversed, which assumes the user wants to first use the value they set, with the global secondary. --- source/blender/editors/transform/transform.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index d0934e0acb0..b2fa363007f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1036,12 +1036,12 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm } else if (!edit_2d) { if (cmode == axis) { - if (t->con.orientation != V3D_MANIP_GLOBAL) { + if (t->con.orientation != t->current_orientation) { stopConstraint(t); } else { - short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ? - t->current_orientation : V3D_MANIP_LOCAL); + const short orientation = ( + (t->current_orientation != V3D_MANIP_GLOBAL) ? V3D_MANIP_GLOBAL : V3D_MANIP_LOCAL); if (is_plane == false) { setUserConstraint(t, orientation, constraint_axis, msg2); } @@ -1052,10 +1052,10 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm } else { if (is_plane == false) { - setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2); + setUserConstraint(t, t->current_orientation, constraint_axis, msg2); } else { - setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3); + setUserConstraint(t, t->current_orientation, constraint_plane, msg3); } } } -- cgit v1.2.3 From 521f188af6bfa3e47e0aa41547502960e887b064 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 07:10:28 +0200 Subject: Fix workspace not freeing tool properties --- source/blender/blenkernel/intern/workspace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c index 783baebd525..a5e93c8d765 100644 --- a/source/blender/blenkernel/intern/workspace.c +++ b/source/blender/blenkernel/intern/workspace.c @@ -165,10 +165,10 @@ void BKE_workspace_free(WorkSpace *workspace) tref_next = tref->next; if (tref->runtime) { MEM_freeN(tref->runtime); - if (tref->properties) { - IDP_FreeProperty(tref->properties); - MEM_freeN(tref->properties); - } + } + if (tref->properties) { + IDP_FreeProperty(tref->properties); + MEM_freeN(tref->properties); } } BLI_freelistN(&workspace->tools); -- cgit v1.2.3 From f9107eae6a30649d4637e55e8ffdb124a7b0ef7a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 07:41:49 +0200 Subject: Keymap: minor changes for keymap display --- source/blender/editors/space_view3d/view3d_edit.c | 4 +-- source/blender/editors/space_view3d/view3d_fly.c | 33 ++++++++++++----------- source/blender/editors/space_view3d/view3d_walk.c | 32 +++++++++++----------- source/blender/editors/transform/transform.c | 4 +-- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index f34866b00cd..b02e4ad9764 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -555,8 +555,8 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf) static const EnumPropertyItem modal_items[] = { {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {VIEWROT_MODAL_AXIS_SNAP_ENABLE, "AXIS_SNAP_ENABLE", 0, "Enable Axis Snap", ""}, - {VIEWROT_MODAL_AXIS_SNAP_DISABLE, "AXIS_SNAP_DISABLE", 0, "Disable Axis Snap", ""}, + {VIEWROT_MODAL_AXIS_SNAP_ENABLE, "AXIS_SNAP_ENABLE", 0, "Axis Snap", ""}, + {VIEWROT_MODAL_AXIS_SNAP_DISABLE, "AXIS_SNAP_DISABLE", 0, "Axis Snap (Off)", ""}, {VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"}, {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"}, diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 65d66df4824..c68b5e97414 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -98,29 +98,30 @@ typedef enum eFlyPanState { void fly_modal_keymap(wmKeyConfig *keyconf) { static const EnumPropertyItem modal_items[] = { - {FLY_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {FLY_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {FLY_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""}, - {FLY_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""}, + {FLY_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, - {FLY_MODAL_PAN_ENABLE, "PAN_ENABLE", 0, "Pan Enable", ""}, - {FLY_MODAL_PAN_DISABLE, "PAN_DISABLE", 0, "Pan Disable", ""}, + {FLY_MODAL_DIR_FORWARD, "FORWARD", 0, "Forward", ""}, + {FLY_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Backward", ""}, + {FLY_MODAL_DIR_LEFT, "LEFT", 0, "Left", ""}, + {FLY_MODAL_DIR_RIGHT, "RIGHT", 0, "Right", ""}, + {FLY_MODAL_DIR_UP, "UP", 0, "Up", ""}, + {FLY_MODAL_DIR_DOWN, "DOWN", 0, "Down", ""}, - {FLY_MODAL_DIR_FORWARD, "FORWARD", 0, "Fly Forward", ""}, - {FLY_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Fly Backward", ""}, - {FLY_MODAL_DIR_LEFT, "LEFT", 0, "Fly Left", ""}, - {FLY_MODAL_DIR_RIGHT, "RIGHT", 0, "Fly Right", ""}, - {FLY_MODAL_DIR_UP, "UP", 0, "Fly Up", ""}, - {FLY_MODAL_DIR_DOWN, "DOWN", 0, "Fly Down", ""}, + {FLY_MODAL_PAN_ENABLE, "PAN_ENABLE", 0, "Pan", ""}, + {FLY_MODAL_PAN_DISABLE, "PAN_DISABLE", 0, "Pan (Off)", ""}, + + {FLY_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""}, + {FLY_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""}, {FLY_MODAL_AXIS_LOCK_X, "AXIS_LOCK_X", 0, "X Axis Correction", "X axis correction (toggle)"}, {FLY_MODAL_AXIS_LOCK_Z, "AXIS_LOCK_Z", 0, "X Axis Correction", "Z axis correction (toggle)"}, - {FLY_MODAL_PRECISION_ENABLE, "PRECISION_ENABLE", 0, "Precision Enable", ""}, - {FLY_MODAL_PRECISION_DISABLE, "PRECISION_DISABLE", 0, "Precision Disable", ""}, + {FLY_MODAL_PRECISION_ENABLE, "PRECISION_ENABLE", 0, "Precision", ""}, + {FLY_MODAL_PRECISION_DISABLE, "PRECISION_DISABLE", 0, "Precision (Off)", ""}, - {FLY_MODAL_FREELOOK_ENABLE, "FREELOOK_ENABLE", 0, "Rotation Enable", ""}, - {FLY_MODAL_FREELOOK_DISABLE, "FREELOOK_DISABLE", 0, "Rotation Disable", ""}, + {FLY_MODAL_FREELOOK_ENABLE, "FREELOOK_ENABLE", 0, "Rotation", ""}, + {FLY_MODAL_FREELOOK_DISABLE, "FREELOOK_DISABLE", 0, "Rotation (Off)", ""}, {0, NULL, 0, NULL, NULL}}; @@ -133,8 +134,8 @@ void fly_modal_keymap(wmKeyConfig *keyconf) keymap = WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items); /* items for modal map */ - WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, FLY_MODAL_CANCEL); + WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, FLY_MODAL_CONFIRM); WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, FLY_MODAL_CONFIRM); diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index f780ca35f30..97c00f1be37 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -129,18 +129,15 @@ typedef enum eWalkGravityState { void walk_modal_keymap(wmKeyConfig *keyconf) { static const EnumPropertyItem modal_items[] = { - {WALK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {WALK_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + {WALK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, - {WALK_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""}, - {WALK_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""}, - - {WALK_MODAL_DIR_FORWARD, "FORWARD", 0, "Move Forward", ""}, - {WALK_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Move Backward", ""}, - {WALK_MODAL_DIR_LEFT, "LEFT", 0, "Move Left (Strafe)", ""}, - {WALK_MODAL_DIR_RIGHT, "RIGHT", 0, "Move Right (Strafe)", ""}, - {WALK_MODAL_DIR_UP, "UP", 0, "Move Up", ""}, - {WALK_MODAL_DIR_DOWN, "DOWN", 0, "Move Down", ""}, + {WALK_MODAL_DIR_FORWARD, "FORWARD", 0, "Forward", ""}, + {WALK_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Backward", ""}, + {WALK_MODAL_DIR_LEFT, "LEFT", 0, "Left (Strafe)", ""}, + {WALK_MODAL_DIR_RIGHT, "RIGHT", 0, "Right (Strafe)", ""}, + {WALK_MODAL_DIR_UP, "UP", 0, "Up", ""}, + {WALK_MODAL_DIR_DOWN, "DOWN", 0, "Down", ""}, {WALK_MODAL_DIR_FORWARD_STOP, "FORWARD_STOP", 0, "Stop Move Forward", ""}, {WALK_MODAL_DIR_BACKWARD_STOP, "BACKWARD_STOP", 0, "Stop Mode Backward", ""}, @@ -151,14 +148,17 @@ void walk_modal_keymap(wmKeyConfig *keyconf) {WALK_MODAL_TELEPORT, "TELEPORT", 0, "Teleport", "Move forward a few units at once"}, - {WALK_MODAL_FAST_ENABLE, "FAST_ENABLE", 0, "Fast Enable", "Move faster (walk or fly)"}, - {WALK_MODAL_FAST_DISABLE, "FAST_DISABLE", 0, "Fast Disable", "Resume regular speed"}, + {WALK_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""}, + {WALK_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""}, + + {WALK_MODAL_FAST_ENABLE, "FAST_ENABLE", 0, "Fast", "Move faster (walk or fly)"}, + {WALK_MODAL_FAST_DISABLE, "FAST_DISABLE", 0, "Fast (Off)", "Resume regular speed"}, - {WALK_MODAL_SLOW_ENABLE, "SLOW_ENABLE", 0, "Slow Enable", "Move slower (walk or fly)"}, - {WALK_MODAL_SLOW_DISABLE, "SLOW_DISABLE", 0, "Slow Disable", "Resume regular speed"}, + {WALK_MODAL_SLOW_ENABLE, "SLOW_ENABLE", 0, "Slow", "Move slower (walk or fly)"}, + {WALK_MODAL_SLOW_DISABLE, "SLOW_DISABLE", 0, "Slow (Off)", "Resume regular speed"}, {WALK_MODAL_JUMP, "JUMP", 0, "Jump", "Jump when in walk mode"}, - {WALK_MODAL_JUMP_STOP, "JUMP_STOP", 0, "Jump Stop", "Stop pushing jump"}, + {WALK_MODAL_JUMP_STOP, "JUMP_STOP", 0, "Jump (Off)", "Stop pushing jump"}, {WALK_MODAL_TOGGLE, "GRAVITY_TOGGLE", 0, "Toggle Gravity", "Toggle gravity effect"}, @@ -173,8 +173,8 @@ void walk_modal_keymap(wmKeyConfig *keyconf) keymap = WM_modalkeymap_add(keyconf, "View3D Walk Modal", modal_items); /* items for modal map */ - WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, WALK_MODAL_CANCEL); + WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, WALK_MODAL_CONFIRM); WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, WALK_MODAL_CONFIRM); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 58c8837328a..d9e36d0963a 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -811,8 +811,8 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y plane", ""}, {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z plane", ""}, {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""}, - {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap", ""}, - {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""}, + {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""}, + {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Snap Invert (Off)", ""}, {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""}, {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""}, {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""}, -- cgit v1.2.3 From 2386436520750a797df24c4ff3fa535288412f15 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 08:16:45 +0200 Subject: Fix T55880: Crash dragging file into image editor Caused by b4ccec67429b4 --- source/blender/editors/interface/interface_templates.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index f80e4e486d6..6110d5f3466 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -390,12 +390,15 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) /* for new/open operators */ void UI_context_active_but_prop_get_templateID( - bContext *C, - PointerRNA *r_ptr, PropertyRNA **r_prop) + bContext *C, + PointerRNA *r_ptr, PropertyRNA **r_prop) { TemplateID *template_ui; uiBut *but = UI_context_active_but_get(C); + memset(r_ptr, 0, sizeof(*r_ptr)); + *r_prop = NULL; + if (but && but->func_argN) { template_ui = but->func_argN; *r_ptr = template_ui->ptr; -- cgit v1.2.3 From 3a07b2124bb2c43b856ae53c7d97d5d86867077e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 08:24:05 +0200 Subject: Fix T55877: Crash snapping non-edit-mesh to grid --- source/blender/editors/interface/interface_templates.c | 6 ++---- source/blender/editors/space_view3d/view3d_snap.c | 9 --------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6110d5f3466..b56904b4caa 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -390,14 +390,12 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) /* for new/open operators */ void UI_context_active_but_prop_get_templateID( - bContext *C, - PointerRNA *r_ptr, PropertyRNA **r_prop) + bContext *C, + PointerRNA *r_ptr, PropertyRNA **r_prop) { TemplateID *template_ui; uiBut *but = UI_context_active_but_get(C); - memset(r_ptr, 0, sizeof(*r_ptr)); - *r_prop = NULL; if (but && but->func_argN) { template_ui = but->func_argN; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 606c07cd1fa..11575f8b1f3 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -92,15 +92,6 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { obedit = objects[ob_index]; - BMEditMesh *em = BKE_editmesh_from_object(obedit); - - if ((em->bm->totvertsel == 0) && - (em->bm->totedgesel == 0) && - (em->bm->totfacesel == 0)) - { - continue; - } - if (ED_transverts_check_obedit(obedit)) { ED_transverts_create_from_obedit(&tvs, obedit, 0); } -- cgit v1.2.3 From ab14da272d8252eb20dc5f5285cf3d5d2e683216 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 08:34:19 +0200 Subject: Reverted T55880 fix by accident --- source/blender/editors/interface/interface_templates.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index b56904b4caa..6110d5f3466 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -390,12 +390,14 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) /* for new/open operators */ void UI_context_active_but_prop_get_templateID( - bContext *C, - PointerRNA *r_ptr, PropertyRNA **r_prop) + bContext *C, + PointerRNA *r_ptr, PropertyRNA **r_prop) { TemplateID *template_ui; uiBut *but = UI_context_active_but_get(C); + memset(r_ptr, 0, sizeof(*r_ptr)); + *r_prop = NULL; if (but && but->func_argN) { template_ui = but->func_argN; -- cgit v1.2.3 From 96bae0f882034a1e0496261df2c3254d1ca13083 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 09:00:26 +0200 Subject: Fix T55879: Crash setting render presets Any RNA using 'rna_SceneCamera_update' crashed when set from Python. --- source/blender/makesrna/intern/rna_scene.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 5b7377eed17..6b312634b50 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1842,8 +1842,9 @@ static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po Scene *scene = (Scene *)ptr->id.data; Object *camera = scene->camera; - if (camera) - DEG_id_tag_update(&camera->id, 0); + if (camera && (camera->type == OB_CAMERA)) { + DEG_id_tag_update(&camera->id, OB_RECALC_DATA); + } } static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) -- cgit v1.2.3 From 9536f920e375cddbb83e55c53e50a3b8cab54ce6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 09:29:30 +0200 Subject: Cleanup: style --- source/blender/blenkernel/intern/studiolight.c | 44 +++++++++++----------- .../depsgraph/intern/builder/deg_builder.cc | 2 +- .../draw/engines/workbench/workbench_effect_aa.c | 3 +- .../draw/engines/workbench/workbench_effect_taa.c | 9 ++--- .../draw/engines/workbench/workbench_forward.c | 9 +++-- .../draw/engines/workbench/workbench_materials.c | 9 ++--- source/blender/editors/interface/interface_icons.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 2 +- source/blender/makesrna/intern/rna_lamp.c | 2 +- source/blender/nodes/shader/node_shader_tree.c | 4 +- 10 files changed, 41 insertions(+), 45 deletions(-) diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 468a961627e..dbe5228b6ea 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -120,7 +120,7 @@ static void studiolight_free(struct StudioLight *sl) STUDIOLIGHT_DELETE_ICON(sl->icon_id_matcap_flipped); #undef STUDIOLIGHT_DELETE_ICON - for (int index = 0 ; index < 6 ; index ++) { + for (int index = 0; index < 6; index++) { IMB_SAFE_FREE(sl->radiance_cubemap_buffers[index]); } GPU_TEXTURE_SAFE_FREE(sl->equirectangular_radiance_gputexture); @@ -152,7 +152,7 @@ static struct StudioLight *studiolight_create(int flag) sl->icon_id_irradiance = BKE_icon_ensure_studio_light(sl, STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE); } - for (int index = 0 ; index < 6 ; index ++) { + for (int index = 0; index < 6; index++) { sl->radiance_cubemap_buffers[index] = NULL; } @@ -193,9 +193,9 @@ static void studiolight_calculate_radiance_buffer( float xf; float *color = colbuf; - for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++, yf += add_y) { + for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y++, yf += add_y) { xf = start_x; - for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++, xf += add_x) { + for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x++, xf += add_x) { direction[index_x] = xf; direction[index_y] = yf; direction[index_z] = z; @@ -234,7 +234,7 @@ static void studiolight_create_equirectangular_radiance_gputexture(StudioLight * float *offset4 = ibuf->rect_float; float *offset3 = sl->gpu_matcap_3components; - for (int i = 0 ; i < ibuf->x * ibuf->y; i++) { + for (int i = 0; i < ibuf->x * ibuf->y; i++) { copy_v3_v3(offset3, offset4); offset3 += 3; offset4 += 4; @@ -336,8 +336,8 @@ BLI_INLINE void studiolight_evaluate_radiance_buffer( float angle; float *radiance_color = radiance_buffer->rect_float; float direction[3]; - for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) { - for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) { + for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y++) { + for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x++) { // calculate light direction; direction[zoffset] = zvalue; direction[xoffset] = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f; @@ -345,7 +345,7 @@ BLI_INLINE void studiolight_evaluate_radiance_buffer( normalize_v3(direction); angle = fmax(0.0f, dot_v3v3(direction, normal)); madd_v3_v3fl(color, radiance_color, angle); - (*hits) ++; + (*hits)++; radiance_color += 4; } } @@ -504,7 +504,7 @@ static void studiolight_calculate_spherical_harmonics_coefficient(StudioLight *s } case 11: { - coef = (0.9461746957575601f * nz * nx * (-1.0f +7.0f*ny2)) / -24.0f; + coef = (0.9461746957575601f * nz * nx * (-1.0f + 7.0f * ny2)) / -24.0f; break; } case 12: @@ -514,7 +514,7 @@ static void studiolight_calculate_spherical_harmonics_coefficient(StudioLight *s } case 13: { - coef = ((105.0f*ny4-90.0f*ny2+9.0f)/28.359261614f) / -24.0f; + coef = ((105.0f * ny4 - 90.0f * ny2 + 9.0f) / 28.359261614f) / -24.0f; break; } case 14: @@ -621,7 +621,7 @@ static void studiolight_apply_spherical_harmonics_windowing(StudioLight *sl, flo /* Apply windowing lambda */ index = 0; - for (int level = 0; level <= STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL; level ++) { + for (int level = 0; level <= STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL; level++) { float s = 1.0f / (1.0f + lambda * SQUARE(level) * SQUARE(level + 1.0f)); for (int m = -1; m <= level; m++) { @@ -666,9 +666,9 @@ BLI_INLINE void studiolight_sample_spherical_harmonics(StudioLight *sl, float co const float nz4 = SQUARE(nz2); madd_v3_v3fl(color, sl->spherical_harmonics_coefs[9], 2.5033429417967046f * nx * nz * (nx2 - nz2)); madd_v3_v3fl(color, sl->spherical_harmonics_coefs[10], -1.7701307697799304f * nz * ny * (3.0f * nx2 - nz2)); - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[11], 0.9461746957575601f * nz * nx * (-1.0f + 7.0f*ny2)); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[11], 0.9461746957575601f * nz * nx * (-1.0f + 7.0f * ny2)); madd_v3_v3fl(color, sl->spherical_harmonics_coefs[12], -0.6690465435572892f * nz * ny * (-3.0f + 7.0f * ny2)); - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[13], (105.0f*ny4-90.0f*ny2+9.0f)/28.359261614f); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[13], (105.0f * ny4 - 90.0f * ny2 + 9.0f) / 28.359261614f); madd_v3_v3fl(color, sl->spherical_harmonics_coefs[14], -0.6690465435572892f * nx * ny * (-3.0f + 7.0f * ny2)); madd_v3_v3fl(color, sl->spherical_harmonics_coefs[15], 0.9461746957575601f * (nx2 - nz2) * (-1.0f + 7.0f * ny2)); madd_v3_v3fl(color, sl->spherical_harmonics_coefs[16], -1.7701307697799304f * nx * ny * (nx2 - 3.0f * nz2)); @@ -683,7 +683,7 @@ static void studiolight_calculate_diffuse_light(StudioLight *sl) if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED); - for (int comp = 0; comp < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; comp ++) { + for (int comp = 0; comp < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; comp++) { studiolight_calculate_spherical_harmonics_coefficient(sl, comp); } @@ -705,8 +705,8 @@ static void studiolight_calculate_diffuse_light(StudioLight *sl) static float texel_coord_solid_angle(float a_U, float a_V, int a_Size) { //scale up to [-1, 1] range (inclusive), offset by 0.5 to point to texel center. - float u = (2.0f * ((float)a_U + 0.5f) / (float)a_Size ) - 1.0f; - float v = (2.0f * ((float)a_V + 0.5f) / (float)a_Size ) - 1.0f; + float u = (2.0f * ((float)a_U + 0.5f) / (float)a_Size) - 1.0f; + float v = (2.0f * ((float)a_V + 0.5f) / (float)a_Size) - 1.0f; float resolution_inv = 1.0f / a_Size; @@ -729,8 +729,8 @@ BLI_INLINE void studiolight_evaluate_specular_radiance_buffer( float angle; float *radiance_color = radiance_buffer->rect_float; float direction[3]; - for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) { - for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) { + for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y++) { + for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x++) { // calculate light direction; float u = (x / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f; float v = (y / (float)STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) - 0.5f; @@ -823,10 +823,10 @@ static void studiolight_calculate_irradiance_equirectangular_image(StudioLight * float *colbuf = MEM_mallocN(STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH * STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT * sizeof(float[4]), __func__); float *color = colbuf; - for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT ; y ++) { + for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT; y++) { float yf = y / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT; - for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH ; x ++) { + for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; x++) { float xf = x / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; float dir[3]; equirectangular_to_direction(dir, xf, yf); @@ -875,8 +875,8 @@ static void studiolight_calculate_light_direction(StudioLight *sl) /* go over every pixel, determine light, if higher calc direction off the light */ float new_light; float *color = ibuf->rect_float; - for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT; y ++) { - for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; x ++) { + for (int y = 0; y < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT; y++) { + for (int x = 0; x < STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; x++) { new_light = color[0] + color[1] + color[2]; if (new_light > best_light) { float u = x / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 34da29652a4..4cbc7700947 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -70,7 +70,7 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) } if (flag != 0) { DEG_graph_id_tag_update(bmain, - (::Depsgraph*)graph, + (::Depsgraph *)graph, id_node->id_orig, flag); } diff --git a/source/blender/draw/engines/workbench/workbench_effect_aa.c b/source/blender/draw/engines/workbench/workbench_effect_aa.c index 95a81649522..f1d5d5d6078 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_aa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_aa.c @@ -67,8 +67,7 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx) * the workbench_taa_draw_screen_end will fill the history buffer * for the other iterations. */ - if (effect_info->jitter_index == 1) - { + if (effect_info->jitter_index == 1) { GPU_framebuffer_bind(dfbl->color_only_fb); DRW_transform_to_display(tx); } diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c index 302cb27cbb9..fbeccc19660 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_taa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c @@ -105,8 +105,7 @@ int workbench_taa_calculate_num_iterations(WORKBENCH_Data *vedata) { result = 16; } - else - { + else { result = 32; } } @@ -288,11 +287,9 @@ void workbench_taa_draw_scene_end(WORKBENCH_Data *vedata) void workbench_taa_view_updated(WORKBENCH_Data *vedata) { WORKBENCH_StorageList *stl = vedata->stl; - if (stl) - { + if (stl) { WORKBENCH_EffectInfo *effect_info = stl->effects; - if (effect_info) - { + if (effect_info) { effect_info->view_updated = true; } } diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 76172443c2d..24ba3aa8981 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -176,14 +176,15 @@ static WORKBENCH_MaterialData *get_or_create_material_data( material->shgrp = grp; /* Depth */ - if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR) - { - material->shgrp_object_outline = DRW_shgroup_create(e_data.object_outline_texture_sh, psl->object_outline_pass); + if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR) { + material->shgrp_object_outline = DRW_shgroup_create( + e_data.object_outline_texture_sh, psl->object_outline_pass); GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false, 0.0f); DRW_shgroup_uniform_texture(material->shgrp_object_outline, "image", tex); } else { - material->shgrp_object_outline = DRW_shgroup_create(e_data.object_outline_sh, psl->object_outline_pass); + material->shgrp_object_outline = DRW_shgroup_create( + e_data.object_outline_sh, psl->object_outline_pass); } material->object_id = engine_object_data->object_id; DRW_shgroup_uniform_int(material->shgrp_object_outline, "object_id", &material->object_id, 1); diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 6755bf82ecd..54e8aa1c3b3 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -129,8 +129,7 @@ uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template) result += BLI_ghashutil_uinthash_v4_murmur(input); /* add texture reference */ - if (material_template->ima) - { + if (material_template->ima) { result += BLI_ghashutil_inthash_p_murmur(material_template->ima); } @@ -182,10 +181,10 @@ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *i return color_type; } -void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material) +void workbench_material_shgroup_uniform( + WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material) { - if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR) - { + if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR) { GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false, 0.0f); DRW_shgroup_uniform_texture(grp, "image", tex); } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 9c5a4392f78..62413e2434c 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1444,7 +1444,7 @@ static void icon_draw_size( di->data.texture.w, di->data.texture.h, alpha, rgb); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } - else if (di->type== ICON_TYPE_MONO_TEXTURE) { + else if (di->type == ICON_TYPE_MONO_TEXTURE) { /* icon that matches text color, assumed to be white */ float text_color[4]; UI_GetThemeColor4fv(TH_TEXT, text_color); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index baaa2d638a3..77f4da2d16b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3528,7 +3528,7 @@ static void sculpt_topology_update(Sculpt *sd, Object *ob, Brush *brush, Unified } if ((sd->flags & SCULPT_DYNTOPO_COLLAPSE) || - (brush->sculpt_tool == SCULPT_TOOL_SIMPLIFY)) + (brush->sculpt_tool == SCULPT_TOOL_SIMPLIFY)) { mode |= PBVH_Collapse; } diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 1fb76a93e27..573540ee641 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -20,7 +20,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/makesrna/intern/rna_light.c +/** \file blender/makesrna/intern/rna_lamp.c * \ingroup RNA */ diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 32c9244735d..919af171756 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -243,11 +243,11 @@ bNode *ntreeShaderOutputNode(bNodeTree *ntree, int target) if (output_node == NULL) { output_node = node; } - else if(output_node->custom1 == SHD_OUTPUT_ALL) { + else if (output_node->custom1 == SHD_OUTPUT_ALL) { output_node = node; } else if ((node->flag & NODE_DO_OUTPUT) && - !(output_node->flag & NODE_DO_OUTPUT)) + !(output_node->flag & NODE_DO_OUTPUT)) { output_node = node; } -- cgit v1.2.3 From 10b976d2eb8a5de24c19bbb469005d59c6cd7c17 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 09:37:39 +0200 Subject: Fix 3D cursor update Changing the values for the 3D cursor wasn't updating. --- source/blender/makesrna/intern/rna_space.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index ab83cedd232..78174c10128 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -545,6 +545,14 @@ static void rna_View3D_Cursor_rotation_set(PointerRNA *ptr, const float *values) copy_qt_qt(cursor->rotation, values); } +static void rna_View3D_Cursor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +{ + View3D *v3d = ptr->data; + if (v3d->localvd == NULL) { + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); + } +} + static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); @@ -2844,14 +2852,14 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "3D Cursor Location", "3D cursor location for this view (dependent on local view setting)"); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_View3D_Cursor_update"); prop = RNA_def_property(srna, "cursor_rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_array(prop, 4); RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_rotation_get", "rna_View3D_Cursor_rotation_set", NULL); RNA_def_property_ui_text(prop, "3D Cursor Rotation", "Rotation in quaternions (keep normalized)"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_View3D_Cursor_update"); prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_UNIT_CAMERA); RNA_def_property_float_sdna(prop, NULL, "lens"); -- cgit v1.2.3 From 1b559438888be03fde1edab7f7811522c448f15c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 09:56:57 +0200 Subject: UI: add colon to prefs headings --- release/scripts/startup/bl_ui/space_userpref.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 8d560ff8815..e44fd6e09db 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -267,7 +267,7 @@ class USERPREF_PT_interface(Panel): col.separator() - col.label("Development") + col.label("Development:") col.prop(view, "show_tooltips_python") col.prop(view, "show_developer_ui") @@ -326,7 +326,7 @@ class USERPREF_PT_interface(Panel): col.prop(view, "show_splash") - col.label("Warnings") + col.label("Warnings:") col.prop(view, "use_quit_dialog") col.separator() @@ -526,13 +526,13 @@ class USERPREF_PT_system(Panel): col.prop(system, "use_16bit_textures") col.separator() - col.label(text="Selection") + col.label(text="Selection:") col.prop(system, "select_method", text="") col.prop(system, "use_select_pick_depth") col.separator() - col.label(text="Anisotropic Filtering") + col.label(text="Anisotropic Filtering:") col.prop(system, "anisotropic_filter", text="") col.separator() -- cgit v1.2.3 From 04570e91202cf0b9af4322adf4d5389b862b593d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 10 Jul 2018 10:29:24 +0200 Subject: Fix T55484: Border zoom fails in Edit-Mode --- source/blender/draw/engines/basic/basic_engine.c | 34 +++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 2c771578514..4348f2182a4 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -146,22 +146,24 @@ static void basic_cache_populate(void *vedata, Object *ob) } const DRWContextState *draw_ctx = DRW_context_state_get(); - if (ob == draw_ctx->object_edit) { - return; - } - - for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) { - if (!psys_check_enabled(ob, psys, false)) { - continue; - } - if (!DRW_check_psys_visible_within_active_context(ob, psys)) { - continue; - } - ParticleSettings *part = psys->part; - const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as; - if (draw_as == PART_DRAW_PATH) { - struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL); - DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL); + if (ob != draw_ctx->object_edit) { + for (ParticleSystem *psys = ob->particlesystem.first; + psys != NULL; + psys = psys->next) + { + if (!psys_check_enabled(ob, psys, false)) { + continue; + } + if (!DRW_check_psys_visible_within_active_context(ob, psys)) { + continue; + } + ParticleSettings *part = psys->part; + const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as + : part->draw_as; + if (draw_as == PART_DRAW_PATH) { + struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL); + DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL); + } } } -- cgit v1.2.3 From 358e1181b5afdd818bdb27d7e1a716079ad4aac2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 10:56:37 +0200 Subject: Keymap: remove Shift-B in camera view We already have Ctrl-B for setting the border, no need for two keys to do the same thing. --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/editors/space_view3d/view3d_edit.c | 13 +------------ source/blender/editors/space_view3d/view3d_ops.c | 3 --- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c905dc51b0e..27950060fed 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -692,7 +692,7 @@ class VIEW3D_MT_view_borders(Menu): def draw(self, context): layout = self.layout layout.operator("view3d.clip_border", text="Clipping Border...") - layout.operator("view3d.render_border", text="Render Border...").camera_only = False + layout.operator("view3d.render_border", text="Render Border...") layout.separator() diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 95040e04d20..743dae6964f 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3223,7 +3223,6 @@ void VIEW3D_OT_view_center_lock(wmOperatorType *ot) static int render_border_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); @@ -3233,17 +3232,13 @@ static int render_border_exec(bContext *C, wmOperator *op) rcti rect; rctf vb, border; - const bool camera_only = RNA_boolean_get(op->ptr, "camera_only"); - - if (camera_only && rv3d->persp != RV3D_CAMOB) - return OPERATOR_PASS_THROUGH; - /* get border select values using rna */ WM_operator_properties_border_to_rcti(op, &rect); /* calculate range */ if (rv3d->persp == RV3D_CAMOB) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); } else { @@ -3297,8 +3292,6 @@ static int render_border_exec(bContext *C, wmOperator *op) void VIEW3D_OT_render_border(wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name = "Set Render Border"; ot->description = "Set the boundaries of the border render and enable border render"; @@ -3317,10 +3310,6 @@ void VIEW3D_OT_render_border(wmOperatorType *ot) /* properties */ WM_operator_properties_border(ot); - - prop = RNA_def_boolean(ot->srna, "camera_only", false, "Camera Only", - "Set render border for camera view and final render only"); - RNA_def_property_flag(prop, PROP_HIDDEN); } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 0fd109f858d..18b63151c8e 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -495,10 +495,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0); - kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "camera_only", true); kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "camera_only", false); WM_keymap_add_item(keymap, "VIEW3D_OT_clear_render_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); -- cgit v1.2.3 From 719629f2aa8cc146427b68bd6fcf422bdd1e52b0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 10 Jul 2018 10:59:06 +0200 Subject: GHOST: Fix memory leak in X11 DPI query The X resource database is to be explicitly destroyed. This fixes 46 bytes leak per every window DPI query (which happens a lot on window move/resize and even on areas resize). Unfortunately, this does not fully fix the leak since the known leak: https://bugs.freedesktop.org/show_bug.cgi?id=94604 --- intern/ghost/intern/GHOST_WindowX11.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 933bcd7f012..dc701062df8 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -1697,6 +1697,7 @@ getDPIHint() } } } + XrmDestroyDatabase(xrdb); } /* Fallback to calculating DPI using X reported DPI, set using xrandr --dpi */ -- cgit v1.2.3 From f70fbad1666a5997910320b4cda3a747eee725d5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 11:00:43 +0200 Subject: Keymap: update 2.7x map Remove Shift-B, operator option is removed. --- release/scripts/presets/keyconfig/blender_27x.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index c6a9c00c901..dad408636e8 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -5898,15 +5898,6 @@ keyconfig_data = [ ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None), ("view3d.clip_border", {"type": 'B', "value": 'PRESS', "alt": True}, None), ("view3d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), - ( - "view3d.render_border", - {"type": 'B', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("camera_only", True), - ], - } - ), ( "view3d.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, -- cgit v1.2.3 From cec8ca6619e32b0a9e92d7aba8220c6207858290 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 11:02:07 +0200 Subject: Missing from last commit --- release/scripts/presets/keyconfig/blender_27x.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index dad408636e8..cc21699f6c4 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -5898,15 +5898,7 @@ keyconfig_data = [ ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None), ("view3d.clip_border", {"type": 'B', "value": 'PRESS', "alt": True}, None), ("view3d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), - ( - "view3d.render_border", - {"type": 'B', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("camera_only", False), - ], - } - ), + ("view3d.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), ("view3d.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), ("view3d.camera_to_view", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True, "alt": True}, None), ("view3d.object_as_camera", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True}, None), -- cgit v1.2.3 From 80373bc4d2b4b22d21088957163c19b537f64c7e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 10 Jul 2018 11:25:47 +0200 Subject: CMake: Disable OpenAL and JACK when AUDASPACE is disabled Previously CMake was raising a fatal error, which wasn't too helpful. There is still some fatal messages about Audaspace and Game Engine, but the latter one is on it's EOL and is removed in Blender 2.8. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46d91286467..da333286478 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -638,10 +638,12 @@ endif() if(NOT WITH_AUDASPACE) if(WITH_OPENAL) - message(FATAL_ERROR "WITH_OPENAL requires WITH_AUDASPACE") + message(WARNING "WITH_OPENAL requires WITH_AUDASPACE which is disabled") + set(WITH_OPENAL OFF) endif() if(WITH_JACK) - message(FATAL_ERROR "WITH_JACK requires WITH_AUDASPACE") + message(WARNING "WITH_JACK requires WITH_AUDASPACE which is disabled") + set(WITH_JACK OFF) endif() if(WITH_GAMEENGINE) message(FATAL_ERROR "WITH_GAMEENGINE requires WITH_AUDASPACE") -- cgit v1.2.3 From c236c80de43245c001ac09ae8d2f067caa929a8a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Jul 2018 11:39:57 +0200 Subject: Fix T55884: shader node linked menu showing incompatible nodes. --- source/blender/editors/space_node/node_templates.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index e3aeb0244e8..8667056a687 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -452,6 +452,10 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) BLI_array_declare(sorted_ntypes); NODE_TYPES_BEGIN(ntype) { + if (!(ntype->poll && ntype->poll(ntype, ntree))) { + continue; + } + if (ntype->nclass != nclass) { continue; } -- cgit v1.2.3 From 97f2f211ed849ff39b9aae2f1256acfd9e31097d Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 10 Jul 2018 11:41:59 +0200 Subject: Fix T55772: Crashes opening a file Bad handling of some weird 'temp' screens in 2.8 doversion. --- source/blender/blenloader/intern/versioning_280.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 3bdd4db3b94..5e27d72caa2 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -164,7 +164,18 @@ static void do_version_workspaces_after_lib_link(Main *bmain) for (wmWindow *win = wm->windows.first; win; win = win->next) { bScreen *screen_parent = screen_parent_find(win->screen); bScreen *screen = screen_parent ? screen_parent : win->screen; + + if (screen->temp) { + /* We do not generate a new workspace for those screens... still need to set some data in win. */ + win->workspace_hook = BKE_workspace_instance_hook_create(bmain); + win->scene = screen->scene; + /* Deprecated from now on! */ + win->screen = NULL; + continue; + } + WorkSpace *workspace = BLI_findstring(&bmain->workspaces, screen->id.name + 2, offsetof(ID, name) + 2); + BLI_assert(workspace != NULL); ListBase *layouts = BKE_workspace_layouts_get(workspace); win->workspace_hook = BKE_workspace_instance_hook_create(bmain); -- cgit v1.2.3 From 726e868889b0d2fad4a8ee48e6b3142a06c5c262 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 11:45:05 +0200 Subject: 3D View: allow border zoom from camera --- source/blender/editors/space_view3d/view3d_edit.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 743dae6964f..b6e20def432 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3490,6 +3490,13 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) /* clamp after because we may have been zooming out */ CLAMP(new_dist, dist_range[0], dist_range[1]); + /* TODO(campbell): 'is_camera_lock' not currently working well. */ + const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d); + if ((rv3d->persp == RV3D_CAMOB) && (is_camera_lock == false)) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); + ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP); + } + ED_view3d_smooth_view( C, v3d, ar, smooth_viewtx, &(const V3D_SmoothParams) {.ofs = new_ofs, .dist = &new_dist}); @@ -3501,18 +3508,6 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int view3d_zoom_border_invoke(bContext *C, wmOperator *op, const wmEvent *event) -{ - View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d = CTX_wm_region_view3d(C); - - /* if in camera view do not exec the operator so we do not conflict with set render border*/ - if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) - return WM_gesture_border_invoke(C, op, event); - else - return OPERATOR_PASS_THROUGH; -} - void VIEW3D_OT_zoom_border(wmOperatorType *ot) { /* identifiers */ @@ -3521,7 +3516,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) ot->idname = "VIEW3D_OT_zoom_border"; /* api callbacks */ - ot->invoke = view3d_zoom_border_invoke; + ot->invoke = WM_gesture_border_invoke; ot->exec = view3d_zoom_border_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; -- cgit v1.2.3 From 445f1d82a174845702c40e35f2d499ac22b44ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 6 Jul 2018 11:15:52 +0200 Subject: Added comment for DEG_TAG_PSYS_xxx and PSYS_RECALC_xxx relation --- source/blender/depsgraph/DEG_depsgraph.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index 0174b002292..71376d94ca8 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -130,7 +130,7 @@ typedef enum eDepsgraph_Tag { DEG_TAG_GEOMETRY = (1 << 1), /* Time changed and animation is to be re-evaluated, OB_RECALC_TIME. */ DEG_TAG_TIME = (1 << 2), - /* Particle system changed. */ + /* Particle system changed; values are aligned with PSYS_RECALC_xxx. */ DEG_TAG_PSYS_REDO = (1 << 3), DEG_TAG_PSYS_RESET = (1 << 4), DEG_TAG_PSYS_TYPE = (1 << 5), -- cgit v1.2.3 From 6807b4318f25a581b7ec75739bd36cf8b07086b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 5 Jul 2018 15:30:00 +0200 Subject: Ocean Modifier: ported from DerivedMesh to Mesh --- source/blender/modifiers/intern/MOD_ocean.c | 85 +++++++++++++++-------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 52bd3e874b6..26011cfc121 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -31,6 +31,7 @@ #include "DNA_customdata_types.h" #include "DNA_object_types.h" +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_scene_types.h" @@ -40,9 +41,9 @@ #include "BLI_task.h" #include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_ocean.h" @@ -344,9 +345,9 @@ static void generate_ocean_geometry_uvs( } } -static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) +static Mesh *generate_ocean_geometry(OceanModifierData *omd) { - DerivedMesh *result; + Mesh *result; GenerateOceanGeometryData gogd; @@ -371,13 +372,13 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) gogd.sx /= gogd.rx; gogd.sy /= gogd.ry; - result = CDDM_new(num_verts, 0, 0, num_polys * 4, num_polys); + result = BKE_mesh_new_nomain(num_verts, 0, 0, num_polys * 4, num_polys); - gogd.mverts = CDDM_get_verts(result); - gogd.mpolys = CDDM_get_polys(result); - gogd.mloops = CDDM_get_loops(result); + gogd.mverts = result->mvert; + gogd.mpolys = result->mpoly; + gogd.mloops = result->mloop; - gogd.origindex = CustomData_get_layer(&result->polyData, CD_ORIGINDEX); + gogd.origindex = CustomData_get_layer(&result->pdata, CD_ORIGINDEX); ParallelRangeSettings settings; BLI_parallel_range_settings_defaults(&settings); @@ -389,11 +390,11 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) /* create faces */ BLI_task_parallel_range(0, gogd.res_y, &gogd, generate_ocean_geometry_polygons, &settings); - CDDM_calc_edges(result); + BKE_mesh_calc_edges(result, false, false); /* add uvs */ - if (CustomData_number_of_layers(&result->loopData, CD_MLOOPUV) < MAX_MTFACE) { - gogd.mloopuvs = CustomData_add_layer(&result->loopData, CD_MLOOPUV, CD_CALLOC, NULL, num_polys * 4); + if (CustomData_number_of_layers(&result->ldata, CD_MLOOPUV) < MAX_MTFACE) { + gogd.mloopuvs = CustomData_add_layer(&result->ldata, CD_MLOOPUV, CD_CALLOC, NULL, num_polys * 4); if (gogd.mloopuvs) { /* unlikely to fail */ gogd.ix = 1.0 / gogd.rx; @@ -403,19 +404,19 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) } } - result->dirty |= DM_DIRTY_NORMALS; + result->runtime.cd_dirty_vert |= CD_MASK_NORMAL; return result; } -static DerivedMesh *doOcean( +static Mesh *doOcean( ModifierData *md, Scene *scene, Object *ob, - DerivedMesh *derivedData, + Mesh *mesh, int UNUSED(useRenderParams)) { OceanModifierData *omd = (OceanModifierData *) md; - DerivedMesh *dm = NULL; + Mesh *result = NULL; OceanResult ocr; MVert *mverts; @@ -433,7 +434,7 @@ static DerivedMesh *doOcean( /* can happen in when size is small, avoid bad array lookups later and quit now */ if (!isfinite(size_co_inv)) { - return derivedData; + return mesh; } /* update modifier */ @@ -457,31 +458,36 @@ static DerivedMesh *doOcean( } if (omd->geometry_mode == MOD_OCEAN_GEOM_GENERATE) { - dm = generate_ocean_geometry(omd); - DM_ensure_normals(dm); + result = generate_ocean_geometry(omd); + BKE_mesh_ensure_normals(result); } else if (omd->geometry_mode == MOD_OCEAN_GEOM_DISPLACE) { - dm = CDDM_copy(derivedData); + BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, + LIB_ID_CREATE_NO_MAIN | + LIB_ID_CREATE_NO_USER_REFCOUNT | + LIB_ID_CREATE_NO_DEG_TAG | + LIB_ID_COPY_NO_PREVIEW, + false); } cfra = scene->r.cfra; CLAMP(cfra, omd->bakestart, omd->bakeend); cfra -= omd->bakestart; /* shift to 0 based */ - mverts = dm->getVertArray(dm); + mverts = result->mvert; /* add vcols before displacement - allows lookup based on position */ if (omd->flag & MOD_OCEAN_GENERATE_FOAM) { - if (CustomData_number_of_layers(&dm->loopData, CD_MLOOPCOL) < MAX_MCOL) { - const int num_polys = dm->getNumPolys(dm); - const int num_loops = dm->getNumLoops(dm); - MLoop *mloops = dm->getLoopArray(dm); + if (CustomData_number_of_layers(&result->ldata, CD_MLOOPCOL) < MAX_MCOL) { + const int num_polys = result->totpoly; + const int num_loops = result->totloop; + MLoop *mloops = result->mloop; MLoopCol *mloopcols = CustomData_add_layer_named( - &dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->foamlayername); + &result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->foamlayername); if (mloopcols) { /* unlikely to fail */ - MPoly *mpolys = dm->getPolyArray(dm); + MPoly *mpolys = result->mpoly; MPoly *mp; for (i = 0, mp = mpolys; i < num_polys; i++, mp++) { @@ -518,7 +524,7 @@ static DerivedMesh *doOcean( /* Note: tried to parallelized that one and previous foam loop, but gives 20% slower results... odd. */ { - const int num_verts = dm->getNumVerts(dm); + const int num_verts = result->totvert; for (i = 0; i < num_verts; i++) { float *vco = mverts[i].co; @@ -543,31 +549,30 @@ static DerivedMesh *doOcean( #undef OCEAN_CO - return dm; + return result; } #else /* WITH_OCEANSIM */ -static DerivedMesh *doOcean( +static Mesh *doOcean( ModifierData *UNUSED(md), Scene *UNUSED(scene), Object *UNUSED(ob), - DerivedMesh *derivedData, + Mesh *mesh, int UNUSED(useRenderParams)) { - /* unused */ - return derivedData; + return mesh; } #endif /* WITH_OCEANSIM */ -static DerivedMesh *applyModifier( +static Mesh *applyModifier( ModifierData *md, const ModifierEvalContext *ctx, - DerivedMesh *derivedData) + Mesh *mesh) { - DerivedMesh *result; + Mesh *result; Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); - result = doOcean(md, scene, ctx->object, derivedData, 0); + result = doOcean(md, scene, ctx->object, mesh, 0); - if (result != derivedData) - result->dirty |= DM_DIRTY_NORMALS; + if (result != mesh) + result->runtime.cd_dirty_vert |= CD_MASK_NORMAL; return result; } @@ -588,14 +593,14 @@ ModifierTypeInfo modifierType_Ocean = { /* deformVerts_DM */ NULL, /* deformVertsEM_DM */ NULL, /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ applyModifier, + /* applyModifier_DM */ NULL, /* applyModifierEM_DM */NULL, /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, + /* applyModifier */ applyModifier, /* applyModifierEM */ NULL, /* initData */ initData, -- cgit v1.2.3 From b9bef10d1953bda4e1eb882bdc525815c2e32e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 5 Jul 2018 15:41:58 +0200 Subject: Ported mesh_create_derived_view() to mesh_create_eval_final_view() --- source/blender/blenkernel/BKE_DerivedMesh.h | 3 --- source/blender/blenkernel/BKE_mesh_runtime.h | 9 +++++++++ source/blender/blenkernel/intern/DerivedMesh.c | 24 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index e497e84b7e0..cdf0d683779 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -532,9 +532,6 @@ DerivedMesh *getEditDerivedBMesh( /* same as above but wont use render settings */ DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]); -DerivedMesh *mesh_create_derived_view( - struct Depsgraph *depsgraph, struct Scene *scene, - struct Object *ob, CustomDataMask dataMask); DerivedMesh *mesh_create_derived_no_deform( struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float (*vertCos)[3], diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h index 8ff097eb61b..e673a30c0b3 100644 --- a/source/blender/blenkernel/BKE_mesh_runtime.h +++ b/source/blender/blenkernel/BKE_mesh_runtime.h @@ -94,6 +94,15 @@ struct Mesh *mesh_create_eval_final_index_render( struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, CustomDataMask dataMask, int index); +#ifdef USE_DERIVEDMESH +struct DerivedMesh *mesh_create_derived_view( + struct Depsgraph *depsgraph, struct Scene *scene, + struct Object *ob, CustomDataMask dataMask); +#endif +struct Mesh *mesh_create_eval_final_view( + struct Depsgraph *depsgraph, struct Scene *scene, + struct Object *ob, CustomDataMask dataMask); + void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb); /* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */ diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 4fe689523e0..9c4aae7cda5 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -3182,6 +3182,8 @@ struct Mesh *mesh_create_eval_final_index_render( return final; } +#ifdef USE_DERIVEDMESH +/* Deprecated, use `mesh_create_eval_final_view` instead. */ DerivedMesh *mesh_create_derived_view( struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask) @@ -3202,6 +3204,28 @@ DerivedMesh *mesh_create_derived_view( return final; } +#endif + +Mesh *mesh_create_eval_final_view( + struct Depsgraph *depsgraph, Scene *scene, + Object *ob, CustomDataMask dataMask) +{ + Mesh *final; + + /* XXX hack + * psys modifier updates particle state when called during dupli-list generation, + * which can lead to wrong transforms. This disables particle system modifier execution. + */ + ob->transflag |= OB_NO_PSYS_UPDATE; + + mesh_calc_modifiers( + depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false, false, + NULL, &final); + + ob->transflag &= ~OB_NO_PSYS_UPDATE; + + return final; +} DerivedMesh *mesh_create_derived_no_deform( struct Depsgraph *depsgraph, Scene *scene, Object *ob, -- cgit v1.2.3 From de55ae56ae5d871b5bc7fa6383c90ef89d66fcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 5 Jul 2018 16:23:35 +0200 Subject: Ocean Modifier: refactored the delayed-refresh approach The approach of setting 'refresh' flags on the modifier, and performing the associated actions when the modifier is being evaluated, is a bad one. Instead, we use the separation of the original and the evaluated copy to 'refresh' certain things (because they simply aren't set at all on the original). Other actions are now done directly with BKE_ocean_xxx functions on the original data, intead of during evaluation. --- source/blender/blenkernel/BKE_ocean.h | 4 ++ source/blender/blenkernel/intern/ocean.c | 8 ++++ source/blender/blenloader/intern/readfile.c | 3 +- source/blender/editors/object/object_modifier.c | 10 +++-- source/blender/makesdna/DNA_modifier_types.h | 9 +--- source/blender/makesrna/intern/rna_modifier.c | 7 ++-- source/blender/modifiers/intern/MOD_ocean.c | 56 +++++++------------------ 7 files changed, 38 insertions(+), 59 deletions(-) diff --git a/source/blender/blenkernel/BKE_ocean.h b/source/blender/blenkernel/BKE_ocean.h index 3ea104e656a..b917a1ad3da 100644 --- a/source/blender/blenkernel/BKE_ocean.h +++ b/source/blender/blenkernel/BKE_ocean.h @@ -31,6 +31,8 @@ extern "C" { #endif +struct OceanModifierData; + typedef struct OceanResult { float disp[3]; float normal[3]; @@ -99,6 +101,8 @@ void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, in void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j); void BKE_ocean_free_cache(struct OceanCache *och); +void BKE_ocean_free_modifier_cache(struct OceanModifierData *omd); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 7f3f916964a..98dd59aca61 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_modifier_types.h" #include "DNA_scene_types.h" #include "BLI_math.h" @@ -1512,3 +1513,10 @@ void BKE_ocean_bake(struct Ocean *UNUSED(o), struct OceanCache *UNUSED(och), (void)update_cb; } #endif /* WITH_OCEANSIM */ + +void BKE_ocean_free_modifier_cache(struct OceanModifierData *omd) +{ + BKE_ocean_free_cache(omd->oceancache); + omd->oceancache = NULL; + omd->cached = false; +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index effaa592080..3eb0626307b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5225,8 +5225,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) else if (md->type == eModifierType_Ocean) { OceanModifierData *omd = (OceanModifierData *)md; omd->oceancache = NULL; - omd->ocean = BKE_ocean_add(); - omd->refresh = MOD_OCEAN_REFRESH_RESET; + omd->ocean = NULL; } else if (md->type == eModifierType_Warp) { WarpModifierData *tmd = (WarpModifierData *)md; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 31a53bed201..e50efcf20ee 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -2083,7 +2083,7 @@ static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData typedef struct OceanBakeJob { /* from wmJob */ - void *owner; + struct Object *owner; short *stop, *do_update; float *progress; int current_frame; @@ -2149,6 +2149,9 @@ static void oceanbake_endjob(void *customdata) oj->omd->oceancache = oj->och; oj->omd->cached = true; + + Object *ob = oj->owner; + DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); } static int ocean_bake_exec(bContext *C, wmOperator *op) @@ -2169,8 +2172,8 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; if (free) { - omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + BKE_ocean_free_modifier_cache(omd); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -2232,6 +2235,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN); oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job"); + oj->owner = ob; oj->ocean = ocean; oj->och = och; oj->omd = omd; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index ed25727b740..ecece648ce1 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -997,7 +997,7 @@ typedef struct OceanModifierData { char geometry_mode; char flag; - char refresh; + char pad2; short repeat_x; short repeat_y; @@ -1017,13 +1017,6 @@ enum { MOD_OCEAN_GEOM_SIM_ONLY = 2, }; -enum { - MOD_OCEAN_REFRESH_RESET = (1 << 0), - /* MOD_OCEAN_REFRESH_SIM = (1 << 1), */ - /* MOD_OCEAN_REFRESH_ADD = (1 << 2), */ - MOD_OCEAN_REFRESH_CLEAR_CACHE = (1 << 3), - /* MOD_OCEAN_REFRESH_TOPOLOGY = (1 << 4), */ -}; enum { MOD_OCEAN_GENERATE_FOAM = (1 << 0), diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 50246c3f9ac..57b12d6a3fd 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -50,6 +50,7 @@ #include "BKE_mesh_mapping.h" #include "BKE_mesh_remap.h" #include "BKE_multires.h" +#include "BKE_ocean.h" #include "BKE_smoke.h" /* For smokeModifier_free & smokeModifier_createType */ #include "RNA_access.h" @@ -739,8 +740,7 @@ static void rna_OceanModifier_init_update(Main *bmain, Scene *scene, PointerRNA { OceanModifierData *omd = (OceanModifierData *)ptr->data; - omd->refresh |= MOD_OCEAN_REFRESH_RESET | MOD_OCEAN_REFRESH_CLEAR_CACHE; - + BKE_ocean_free_modifier_cache(omd); rna_Modifier_update(bmain, scene, ptr); } @@ -754,8 +754,7 @@ static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value) if ((old_value == 0.0f && value > 0.0f) || (old_value > 0.0f && value == 0.0f)) { - omd->refresh |= MOD_OCEAN_REFRESH_RESET; - omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; + BKE_ocean_free_modifier_cache(omd); } } diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 26011cfc121..b4c028a44e3 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -61,13 +61,6 @@ static void init_cache_data(Object *ob, struct OceanModifierData *omd) omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); } -static void clear_cache_data(struct OceanModifierData *omd) -{ - BKE_ocean_free_cache(omd->oceancache); - omd->oceancache = NULL; - omd->cached = false; -} - /* keep in sync with init_ocean_modifier_bake(), object_modifier.c */ static void init_ocean_modifier(struct OceanModifierData *omd) { @@ -91,8 +84,6 @@ static void init_ocean_modifier(struct OceanModifierData *omd) static void simulate_ocean_modifier(struct OceanModifierData *omd) { - if (!omd || !omd->ocean) return; - BKE_ocean_simulate(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount); } #endif /* WITH_OCEANSIM */ @@ -126,8 +117,6 @@ static void initData(ModifierData *md) omd->seed = 0; omd->time = 1.0; - omd->refresh = 0; - omd->size = 1.0; omd->repeat_x = 1; omd->repeat_y = 1; @@ -174,10 +163,8 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); - tomd->refresh = 0; - - /* XXX todo: copy cache runtime too */ - tomd->cached = 0; + /* The oceancache object will be recreated for this copy + * automatically when cached=true */ tomd->oceancache = NULL; tomd->ocean = BKE_ocean_add(); @@ -409,19 +396,18 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd) return result; } -static Mesh *doOcean( - ModifierData *md, Scene *scene, Object *ob, - Mesh *mesh, - int UNUSED(useRenderParams)) +static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { OceanModifierData *omd = (OceanModifierData *) md; + int cfra_scene = (int)DEG_get_ctime(ctx->depsgraph); + Object *ob = ctx->object; Mesh *result = NULL; OceanResult ocr; MVert *mverts; - int cfra; + int cfra_for_cache; int i, j; /* use cached & inverted value for speed @@ -437,21 +423,12 @@ static Mesh *doOcean( return mesh; } - /* update modifier */ - if (omd->refresh & MOD_OCEAN_REFRESH_RESET) { - init_ocean_modifier(omd); - } - if (omd->refresh & MOD_OCEAN_REFRESH_CLEAR_CACHE) { - clear_cache_data(omd); - } - omd->refresh = 0; - /* do ocean simulation */ if (omd->cached == true) { if (!omd->oceancache) { init_cache_data(ob, omd); } - BKE_ocean_simulate_cache(omd->oceancache, scene->r.cfra); + BKE_ocean_simulate_cache(omd->oceancache, cfra_scene); } else { simulate_ocean_modifier(omd); @@ -470,9 +447,9 @@ static Mesh *doOcean( false); } - cfra = scene->r.cfra; - CLAMP(cfra, omd->bakestart, omd->bakeend); - cfra -= omd->bakestart; /* shift to 0 based */ + cfra_for_cache = cfra_scene; + CLAMP(cfra_for_cache, omd->bakestart, omd->bakeend); + cfra_for_cache -= omd->bakestart; /* shift to 0 based */ mverts = result->mvert; @@ -501,7 +478,7 @@ static Mesh *doOcean( float foam; if (omd->oceancache && omd->cached == true) { - BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); + BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra_for_cache, u, v); foam = ocr.foam; CLAMP(foam, 0.0f, 1.0f); } @@ -532,7 +509,7 @@ static Mesh *doOcean( const float v = OCEAN_CO(size_co_inv, vco[1]); if (omd->oceancache && omd->cached == true) { - BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); + BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra_for_cache, u, v); } else { BKE_ocean_eval_uv(omd->ocean, &ocr, u, v); @@ -552,10 +529,7 @@ static Mesh *doOcean( return result; } #else /* WITH_OCEANSIM */ -static Mesh *doOcean( - ModifierData *UNUSED(md), Scene *UNUSED(scene), Object *UNUSED(ob), - Mesh *mesh, - int UNUSED(useRenderParams)) +static Mesh *doOcean(ModifierData *UNUSED(md), const ModifierEvalContext *UNUSED(ctx), Mesh *mesh) { return mesh; } @@ -566,10 +540,8 @@ static Mesh *applyModifier( Mesh *mesh) { Mesh *result; - Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); - - result = doOcean(md, scene, ctx->object, mesh, 0); + result = doOcean(md, ctx, mesh); if (result != mesh) result->runtime.cd_dirty_vert |= CD_MASK_NORMAL; -- cgit v1.2.3 From 0c8452ad99035fa560a1c19a3b4a404bdbbd9ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 10 Jul 2018 11:57:01 +0200 Subject: Ocean Modifier: removed duplicated code Some code was copied with 'keep in sync with xxx' comments added to it. --- source/blender/blenkernel/BKE_ocean.h | 1 + source/blender/blenkernel/intern/ocean.c | 18 ++++++++++++++++++ source/blender/editors/object/object_modifier.c | 21 +-------------------- source/blender/modifiers/intern/MOD_ocean.c | 25 ++----------------------- 4 files changed, 22 insertions(+), 43 deletions(-) diff --git a/source/blender/blenkernel/BKE_ocean.h b/source/blender/blenkernel/BKE_ocean.h index b917a1ad3da..3bf1af12704 100644 --- a/source/blender/blenkernel/BKE_ocean.h +++ b/source/blender/blenkernel/BKE_ocean.h @@ -74,6 +74,7 @@ typedef struct OceanCache { struct Ocean *BKE_ocean_add(void); void BKE_ocean_free_data(struct Ocean *oc); void BKE_ocean_free(struct Ocean *oc); +void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd); void BKE_ocean_init( struct Ocean *o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp, diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 98dd59aca61..b68823626d7 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -836,6 +836,24 @@ struct Ocean *BKE_ocean_add(void) return oc; } +void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd) +{ + short do_heightfield, do_chop, do_normals, do_jacobian; + + do_heightfield = true; + do_chop = (omd->chop_amount > 0); + do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); + do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); + + BKE_ocean_free_data(ocean); + BKE_ocean_init(ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution, + omd->spatial_size, omd->spatial_size, + omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, + omd->depth, omd->time, + do_heightfield, do_chop, do_normals, do_jacobian, + omd->seed); +} + void BKE_ocean_init(struct Ocean *o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp, float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals, short do_jacobian, int seed) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index e50efcf20ee..5ee30992621 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -2062,25 +2062,6 @@ static bool ocean_bake_poll(bContext *C) return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0); } -/* copied from init_ocean_modifier, MOD_ocean.c */ -static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData *omd) -{ - int do_heightfield, do_chop, do_normals, do_jacobian; - - if (!omd || !oc) return; - - do_heightfield = true; - do_chop = (omd->chop_amount > 0); - do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); - do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); - - BKE_ocean_init(oc, omd->resolution * omd->resolution, omd->resolution * omd->resolution, omd->spatial_size, omd->spatial_size, - omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, - omd->depth, omd->time, - do_heightfield, do_chop, do_normals, do_jacobian, - omd->seed); -} - typedef struct OceanBakeJob { /* from wmJob */ struct Object *owner; @@ -2213,7 +2194,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) /* make a copy of ocean to use for baking - threadsafety */ ocean = BKE_ocean_add(); - init_ocean_modifier_bake(ocean, omd); + BKE_ocean_init_from_modifier(ocean, omd); #if 0 BKE_ocean_bake(ocean, och); diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index b4c028a44e3..5aafd9b1877 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -61,27 +61,6 @@ static void init_cache_data(Object *ob, struct OceanModifierData *omd) omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); } -/* keep in sync with init_ocean_modifier_bake(), object_modifier.c */ -static void init_ocean_modifier(struct OceanModifierData *omd) -{ - int do_heightfield, do_chop, do_normals, do_jacobian; - - if (!omd || !omd->ocean) return; - - do_heightfield = true; - do_chop = (omd->chop_amount > 0); - do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); - do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); - - BKE_ocean_free_data(omd->ocean); - BKE_ocean_init(omd->ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution, - omd->spatial_size, omd->spatial_size, - omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, - omd->depth, omd->time, - do_heightfield, do_chop, do_normals, do_jacobian, - omd->seed); -} - static void simulate_ocean_modifier(struct OceanModifierData *omd) { BKE_ocean_simulate(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount); @@ -131,7 +110,7 @@ static void initData(ModifierData *md) omd->foamlayername[0] = '\0'; /* layer name empty by default */ omd->ocean = BKE_ocean_add(); - init_ocean_modifier(omd); + BKE_ocean_init_from_modifier(omd->ocean, omd); simulate_ocean_modifier(omd); #else /* WITH_OCEANSIM */ /* unused */ @@ -168,7 +147,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla tomd->oceancache = NULL; tomd->ocean = BKE_ocean_add(); - init_ocean_modifier(tomd); + BKE_ocean_init_from_modifier(tomd->ocean, tomd); simulate_ocean_modifier(tomd); #else /* WITH_OCEANSIM */ /* unused */ -- cgit v1.2.3 From 25619443bba4b9dda8e6194662683e91be99b247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 10 Jul 2018 11:58:01 +0200 Subject: Ocean Modifier: prevent crashing on 'Apply Modifier' button The 'Apply Modifier' button calls the modifier code on the original object instead of an evaluated copy, which doesn't have an initialised Ocean *. --- source/blender/blenkernel/BKE_ocean.h | 1 + source/blender/blenkernel/intern/ocean.c | 16 ++++++++++++++++ source/blender/modifiers/intern/MOD_ocean.c | 12 ++++++++++++ 3 files changed, 29 insertions(+) diff --git a/source/blender/blenkernel/BKE_ocean.h b/source/blender/blenkernel/BKE_ocean.h index 3bf1af12704..e18a063ff52 100644 --- a/source/blender/blenkernel/BKE_ocean.h +++ b/source/blender/blenkernel/BKE_ocean.h @@ -74,6 +74,7 @@ typedef struct OceanCache { struct Ocean *BKE_ocean_add(void); void BKE_ocean_free_data(struct Ocean *oc); void BKE_ocean_free(struct Ocean *oc); +bool BKE_ocean_ensure(struct OceanModifierData *omd); void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd); void BKE_ocean_init( diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index b68823626d7..ab0130019b8 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -836,6 +836,17 @@ struct Ocean *BKE_ocean_add(void) return oc; } +bool BKE_ocean_ensure(struct OceanModifierData *omd) +{ + if (omd->ocean) { + return false; + } + + omd->ocean = BKE_ocean_add(); + BKE_ocean_init_from_modifier(omd->ocean, omd); + return true; +} + void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd) { short do_heightfield, do_chop, do_normals, do_jacobian; @@ -1530,6 +1541,11 @@ void BKE_ocean_bake(struct Ocean *UNUSED(o), struct OceanCache *UNUSED(och), /* unused */ (void)update_cb; } + +void BKE_ocean_init_from_modifier(struct Ocean *UNUSED(ocean), struct OceanModifierData const *UNUSED(omd)) +{ +} + #endif /* WITH_OCEANSIM */ void BKE_ocean_free_modifier_cache(struct OceanModifierData *omd) diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 5aafd9b1877..12845b27166 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -380,6 +380,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes OceanModifierData *omd = (OceanModifierData *) md; int cfra_scene = (int)DEG_get_ctime(ctx->depsgraph); Object *ob = ctx->object; + bool allocated_ocean = false; Mesh *result = NULL; OceanResult ocr; @@ -410,6 +411,12 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes BKE_ocean_simulate_cache(omd->oceancache, cfra_scene); } else { + /* omd->ocean is NULL on an original object (in contrast to an evaluated one). + * We can create a new one, but we have to free it as well once we're done. + * This function is only called on an original object when applying the modifier + * using the 'Apply Modifier' button, and thus it is not called frequently for + * simulation. */ + allocated_ocean |= BKE_ocean_ensure(omd); simulate_ocean_modifier(omd); } @@ -503,6 +510,11 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes } } + if (allocated_ocean) { + BKE_ocean_free(omd->ocean); + omd->ocean = NULL; + } + #undef OCEAN_CO return result; -- cgit v1.2.3 From e4ce5fd8d2e8d38ebdac5b1caf779a3c1dedfd52 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 10 Jul 2018 12:14:08 +0200 Subject: Modifiers: Use bool for boolean flag in isDisabled --- source/blender/blenkernel/BKE_modifier.h | 2 +- source/blender/modifiers/intern/MOD_armature.c | 2 +- source/blender/modifiers/intern/MOD_boolean.c | 2 +- source/blender/modifiers/intern/MOD_cast.c | 2 +- source/blender/modifiers/intern/MOD_curve.c | 2 +- source/blender/modifiers/intern/MOD_datatransfer.c | 2 +- source/blender/modifiers/intern/MOD_displace.c | 2 +- source/blender/modifiers/intern/MOD_hook.c | 2 +- source/blender/modifiers/intern/MOD_laplaciandeform.c | 2 +- source/blender/modifiers/intern/MOD_laplaciansmooth.c | 4 ++-- source/blender/modifiers/intern/MOD_lattice.c | 2 +- source/blender/modifiers/intern/MOD_meshcache.c | 2 +- source/blender/modifiers/intern/MOD_meshdeform.c | 2 +- source/blender/modifiers/intern/MOD_meshsequencecache.c | 2 +- source/blender/modifiers/intern/MOD_none.c | 2 +- source/blender/modifiers/intern/MOD_normal_edit.c | 2 +- source/blender/modifiers/intern/MOD_particleinstance.c | 2 +- source/blender/modifiers/intern/MOD_shrinkwrap.c | 2 +- source/blender/modifiers/intern/MOD_smooth.c | 2 +- source/blender/modifiers/intern/MOD_subsurf.c | 2 +- source/blender/modifiers/intern/MOD_surfacedeform.c | 2 +- source/blender/modifiers/intern/MOD_warp.c | 2 +- source/blender/modifiers/intern/MOD_weightvgedit.c | 2 +- source/blender/modifiers/intern/MOD_weightvgmix.c | 2 +- source/blender/modifiers/intern/MOD_weightvgproximity.c | 2 +- 25 files changed, 26 insertions(+), 26 deletions(-) diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 987bb59cba3..d0b9d2adc5b 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -317,7 +317,7 @@ typedef struct ModifierTypeInfo { * * This function is optional (assumes never disabled if not present). */ - bool (*isDisabled)(const struct Scene *scene, struct ModifierData *md, int userRenderParams); + bool (*isDisabled)(const struct Scene *scene, struct ModifierData *md, bool userRenderParams); /* Add the appropriate relations to the dependency graph. * diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index a069b261067..c44b65dffec 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -85,7 +85,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( return dataMask; } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { ArmatureModifierData *amd = (ArmatureModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 6cea7b8fece..db1078fa677 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -76,7 +76,7 @@ static void initData(ModifierData *md) bmd->double_threshold = 1e-6f; } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { BooleanModifierData *bmd = (BooleanModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index cd6cd709b1d..a0901b6d838 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -63,7 +63,7 @@ static void initData(ModifierData *md) cmd->object = NULL; } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { CastModifierData *cmd = (CastModifierData *) md; short flag; diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index e90ff939b68..b74b63e2478 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -71,7 +71,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams)) +static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams)) { CurveModifierData *cmd = (CurveModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c index 8e025059d6c..ac45ce8732d 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.c +++ b/source/blender/modifiers/intern/MOD_datatransfer.c @@ -133,7 +133,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { DataTransferModifierData *dtmd = (DataTransferModifierData *) md; /* If no source object, bypass. */ diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index ac8fb91bc8d..1b8b7120058 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -138,7 +138,7 @@ static void foreachTexLink( walk(userData, ob, md, "texture"); } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { DisplaceModifierData *dmd = (DisplaceModifierData *) md; return ((!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) || dmd->strength == 0.0f); diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 4b34bdd2c16..a1629d8c1f2 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -96,7 +96,7 @@ static void freeData(ModifierData *md) MEM_SAFE_FREE(hmd->indexar); } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { HookModifierData *hmd = (HookModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index 0224d412ba6..2406739e6df 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -715,7 +715,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla tlmd->cache_system = NULL; } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md; if (lmd->anchor_grp_name[0]) return 0; diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c index 580de4b1572..19838a2b637 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c @@ -81,7 +81,7 @@ struct BLaplacianSystem { typedef struct BLaplacianSystem LaplacianSystem; static CustomDataMask required_data_mask(Object *ob, ModifierData *md); -static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, int useRenderParams); +static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, bool useRenderParams); static float compute_volume(const float center[3], float (*vertexCos)[3], const MPoly *mpoly, int numPolys, const MLoop *mloop); static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numPolys, int a_numLoops, int a_numVerts); static void delete_laplacian_system(LaplacianSystem *sys); @@ -474,7 +474,7 @@ static void init_data(ModifierData *md) smd->defgrp_name[0] = '\0'; } -static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md; short flag; diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index 540876ac339..3acd39bf19d 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -67,7 +67,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams)) { LatticeModifierData *lmd = (LatticeModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c index 9d6dfc0e1eb..8d2ac001e2d 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.c @@ -72,7 +72,7 @@ static bool dependsOnTime(ModifierData *md) return (mcmd->play_mode == MOD_MESHCACHE_PLAY_CFEA); } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { MeshCacheModifierData *mcmd = (MeshCacheModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 05e1568f780..9bfbbc4e44e 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -109,7 +109,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c index fd8676d6653..cef55bf467b 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.c +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c @@ -79,7 +79,7 @@ static void freeData(ModifierData *md) } } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c index c973bd18830..7a6a5b94b8e 100644 --- a/source/blender/modifiers/intern/MOD_none.c +++ b/source/blender/modifiers/intern/MOD_none.c @@ -43,7 +43,7 @@ * no other functions will be called */ -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *UNUSED(md), int UNUSED(userRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *UNUSED(md), bool UNUSED(userRenderParams)) { return true; } diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c index ae67296dda7..14af389668c 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.c @@ -524,7 +524,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, walk(userData, ob, &enmd->target, IDWALK_CB_NOP); } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { NormalEditModifierData *enmd = (NormalEditModifierData *)md; diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index bb6ed8e8344..edafcd6fcb9 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -88,7 +88,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } -static bool isDisabled(const struct Scene *scene, ModifierData *md, int useRenderParams) +static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRenderParams) { ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md; ParticleSystem *psys; diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index 72c1c1552c7..5497673a52d 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -84,7 +84,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md; return !smd->target; diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 280a795fae8..29508524f9c 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -61,7 +61,7 @@ static void initData(ModifierData *md) smd->defgrp_name[0] = '\0'; } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { SmoothModifierData *smd = (SmoothModifierData *) md; short flag; diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 5a5b596eaab..f532c168b04 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -91,7 +91,7 @@ static void freeData(ModifierData *md) } } -static bool isDisabled(const Scene *scene, ModifierData *md, int useRenderParams) +static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParams) { SubsurfModifierData *smd = (SubsurfModifierData *) md; int levels = (useRenderParams) ? smd->renderLevels : smd->levels; diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index 0c58d47d53f..6dbeed9b4c8 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -1195,7 +1195,7 @@ static void deformVertsEM( surfacedeformModifier_do(md, ctx, vertexCos, numVerts, ctx->object); } -static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 69bf44d8b68..a8f305bcc13 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -109,7 +109,7 @@ static void freeData(ModifierData *md) } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams)) { WarpModifierData *wmd = (WarpModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index a2f9319ad51..a34ed1baaff 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -148,7 +148,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; /* If no vertex group, bypass. */ diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 90bd5acff62..b6a7228b171 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -185,7 +185,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; /* If no vertex group, bypass. */ diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 88e33f28eaf..05b1ec19253 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -358,7 +358,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) { WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; /* If no vertex group, bypass. */ -- cgit v1.2.3 From 39b1842335c8ed949b776993686fb27f090655e5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Jul 2018 12:31:27 +0200 Subject: Fix T55882: crash closing user preferences window in some cases. --- source/blender/windowmanager/intern/wm_window.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 4f86d05d515..fcd74f32bde 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -182,11 +182,11 @@ static void wm_window_check_position(rcti *rect) static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win) { if (win->ghostwin) { - if (win == wm->windrawable) { - /* Prevents non-drawable state of main windows (bugs #22967, - * #25071 and possibly #22477 too). */ - wm_window_clear_drawable(wm); - } + /* Prevents non-drawable state of main windows (bugs #22967, + * #25071 and possibly #22477 too). Always clear it even if + * this window was not the drawable one, because we mess with + * drawing context to discard the GW context. */ + wm_window_clear_drawable(wm); if (win == wm->winactive) { wm->winactive = NULL; -- cgit v1.2.3 From b23404d701c3b16931711ac534218c77d2e97a2a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 14:10:12 +0200 Subject: 3D View: overlay option to show bones Allows drawing motion paths without the bones. --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/draw/modes/pose_mode.c | 3 +++ source/blender/makesdna/DNA_view3d_types.h | 1 + source/blender/makesrna/intern/rna_space.c | 5 +++++ 4 files changed, 10 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 27950060fed..cf2c9641971 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3897,6 +3897,7 @@ class VIEW3D_PT_overlay(Panel): #sub.prop(overlay, "show_onion_skins") sub.prop(overlay, "show_face_orientation") sub.prop(overlay, "show_backface_culling") + sub.prop(overlay, "show_bones", text="Bones") if shading.type == 'MATERIAL': sub.prop(overlay, "show_look_dev") diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index 84c3bff406a..2c24b29c881 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -202,6 +202,9 @@ static void POSE_cache_populate(void *vedata, Object *ob) * and similar functionalities. For now we handle only pose bones. */ if (ob->type == OB_ARMATURE) { + if (draw_ctx->v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES) { + return; + } if (DRW_pose_mode_armature(ob, draw_ctx->obact)) { DRWArmaturePasses passes = { .bone_solid = psl->bone_solid, diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 331eb216f61..1f0476e9db7 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -386,6 +386,7 @@ enum { V3D_OVERLAY_HIDE_TEXT = (1 << 5), V3D_OVERLAY_HIDE_MOTION_PATHS = (1 << 6), V3D_OVERLAY_ONION_SKINS = (1 << 7), + V3D_OVERLAY_HIDE_BONES = (1 << 8), }; /* View3DOverlay->edit_flag */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 78174c10128..81efcf3c4dd 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2637,6 +2637,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Text", "Display overlay text"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_bones", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_BONES); + RNA_def_property_ui_text(prop, "Show Bones", "Display bones"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_face_orientation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_FACE_ORIENTATION); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); -- cgit v1.2.3 From c17cb50ae282f0f04d399ac4f9fa2f3c5eb548bb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 10 Jul 2018 14:36:04 +0200 Subject: OpenSubdiv: Make more flexible C-API to specify FVar interpolation --- intern/opensubdiv/opensubdiv_converter.cc | 48 +++++++++++++++------- intern/opensubdiv/opensubdiv_converter_capi.h | 15 +++++-- .../intern/CCGSubSurf_opensubdiv_converter.c | 26 ++++++++---- 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/intern/opensubdiv/opensubdiv_converter.cc b/intern/opensubdiv/opensubdiv_converter.cc index ea41a56768f..fec15b118ae 100644 --- a/intern/opensubdiv/opensubdiv_converter.cc +++ b/intern/opensubdiv/opensubdiv_converter.cc @@ -542,7 +542,7 @@ namespace { OpenSubdiv::Sdc::SchemeType get_capi_scheme_type(OpenSubdiv_SchemeType type) { - switch(type) { + switch (type) { case OSD_SCHEME_BILINEAR: return OpenSubdiv::Sdc::SCHEME_BILINEAR; case OSD_SCHEME_CATMARK: @@ -550,10 +550,29 @@ OpenSubdiv::Sdc::SchemeType get_capi_scheme_type(OpenSubdiv_SchemeType type) case OSD_SCHEME_LOOP: return OpenSubdiv::Sdc::SCHEME_LOOP; } - assert(!"Unknown sceme type passed via C-API"); + assert(!"Unknown scheme type passed via C-API"); return OpenSubdiv::Sdc::SCHEME_CATMARK; } +OpenSubdiv::Sdc::Options::FVarLinearInterpolation +get_capi_fvar_linear_interpolation( + OpenSubdiv_FVarLinearInterpolation linear_interpolation) +{ + typedef OpenSubdiv::Sdc::Options Options; + switch (linear_interpolation) { + case OSD_FVAR_LINEAR_INTERPOLATION_NONE: + return Options::FVAR_LINEAR_NONE; + case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY: + return Options::FVAR_LINEAR_CORNERS_ONLY; + case OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES: + return Options::FVAR_LINEAR_BOUNDARIES; + case OSD_FVAR_LINEAR_INTERPOLATION_ALL: + return Options::FVAR_LINEAR_ALL; + } + assert(!"Unknown fvar linear interpolation passed via C-API"); + return Options::FVAR_LINEAR_NONE; +} + } /* namespace */ struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr( @@ -562,17 +581,15 @@ struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr( typedef OpenSubdiv::Sdc::Options Options; using OpenSubdiv::Far::TopologyRefinerFactory; - OpenSubdiv::Sdc::SchemeType scheme_type = - get_capi_scheme_type(converter->get_type(converter)); + const OpenSubdiv::Sdc::SchemeType scheme_type = + get_capi_scheme_type(converter->get_scheme_type(converter)); + const Options::FVarLinearInterpolation linear_interpolation = + get_capi_fvar_linear_interpolation( + converter->get_fvar_linear_interpolation(converter)); Options options; options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY); options.SetCreasingMethod(Options::CREASE_UNIFORM); - if (converter->get_subdiv_uvs(converter)) { - options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_CORNERS_ONLY); - } - else { - options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_ALL); - } + options.SetFVarLinearInterpolation(linear_interpolation); TopologyRefinerFactory::Options topology_options(scheme_type, options); @@ -663,14 +680,17 @@ int openSubdiv_topologyRefnerCompareConverter( const int num_faces = base_level.GetNumFaces(); /* Quick preliminary check. */ OpenSubdiv::Sdc::SchemeType scheme_type = - get_capi_scheme_type(converter->get_type(converter)); + get_capi_scheme_type(converter->get_scheme_type(converter)); if (scheme_type != refiner->GetSchemeType()) { return false; } const Options options = refiner->GetSchemeOptions(); - Options::FVarLinearInterpolation interp = options.GetFVarLinearInterpolation(); - const bool subdiv_uvs = (interp != Options::FVAR_LINEAR_ALL); - if (converter->get_subdiv_uvs(converter) != subdiv_uvs) { + const Options::FVarLinearInterpolation interp = + options.GetFVarLinearInterpolation(); + const Options::FVarLinearInterpolation new_interp = + get_capi_fvar_linear_interpolation( + converter->get_fvar_linear_interpolation(converter)); + if (new_interp != interp) { return false; } if (converter->get_num_verts(converter) != num_verts || diff --git a/intern/opensubdiv/opensubdiv_converter_capi.h b/intern/opensubdiv/opensubdiv_converter_capi.h index 6eda6ae5d8a..ea4f20c5961 100644 --- a/intern/opensubdiv/opensubdiv_converter_capi.h +++ b/intern/opensubdiv/opensubdiv_converter_capi.h @@ -41,13 +41,22 @@ typedef enum OpenSubdiv_SchemeType { OSD_SCHEME_LOOP, } OpenSubdiv_SchemeType; +typedef enum OpenSubdiv_FVarLinearInterpolation { + OSD_FVAR_LINEAR_INTERPOLATION_NONE, + OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY, + OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES, + OSD_FVAR_LINEAR_INTERPOLATION_ALL, +} OpenSubdiv_FVarLinearInterpolation; + typedef struct OpenSubdiv_Converter { /* TODO(sergey): Needs to be implemented. */ /* OpenSubdiv::Sdc::Options get_options() const; */ - OpenSubdiv_SchemeType (*get_type)(const OpenSubdiv_Converter *converter); + OpenSubdiv_SchemeType (*get_scheme_type)( + const OpenSubdiv_Converter *converter); - bool (*get_subdiv_uvs)(const OpenSubdiv_Converter *converter); + OpenSubdiv_FVarLinearInterpolation (*get_fvar_linear_interpolation)( + const OpenSubdiv_Converter *converter); int (*get_num_faces)(const OpenSubdiv_Converter *converter); int (*get_num_edges)(const OpenSubdiv_Converter *converter); @@ -86,7 +95,6 @@ typedef struct OpenSubdiv_Converter { int *vert_faces); /* Face-varying data. */ - int (*get_num_uv_layers)(const OpenSubdiv_Converter *converter); void (*precalc_uv_layer)(const OpenSubdiv_Converter *converter, int layer); @@ -99,6 +107,7 @@ typedef struct OpenSubdiv_Converter { int face, int corner); + /* User data associated with this converter. */ void (*free_user_data)(const OpenSubdiv_Converter *converter); void *user_data; } OpenSubdiv_Converter; diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c index f1f82f458aa..8c1ba0c3782 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c @@ -84,11 +84,14 @@ static OpenSubdiv_SchemeType conv_dm_get_type( return OSD_SCHEME_CATMARK; } -static bool conv_dm_get_subdiv_uvs( +static OpenSubdiv_FVarLinearInterpolation conv_dm_get_fvar_linear_interpolation( const OpenSubdiv_Converter *converter) { ConvDMStorage *storage = converter->user_data; - return (storage->ss->osd_subdiv_uvs); + if (storage->ss->osd_subdiv_uvs) { + return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY; + } + return OSD_FVAR_LINEAR_INTERPOLATION_ALL; } static int conv_dm_get_num_faces(const OpenSubdiv_Converter *converter) @@ -429,9 +432,10 @@ void ccgSubSurf_converter_setup_from_derivedmesh( { ConvDMStorage *user_data; - converter->get_type = conv_dm_get_type; + converter->get_scheme_type = conv_dm_get_type; - converter->get_subdiv_uvs = conv_dm_get_subdiv_uvs; + converter->get_fvar_linear_interpolation = + conv_dm_get_fvar_linear_interpolation; converter->get_num_faces = conv_dm_get_num_faces; converter->get_num_edges = conv_dm_get_num_edges; @@ -526,11 +530,14 @@ static OpenSubdiv_SchemeType conv_ccg_get_bilinear_type( } } -static bool conv_ccg_get_subdiv_uvs( - const OpenSubdiv_Converter *converter) +static OpenSubdiv_FVarLinearInterpolation +conv_ccg_get_fvar_linear_interpolation(const OpenSubdiv_Converter *converter) { CCGSubSurf *ss = converter->user_data; - return (ss->osd_subdiv_uvs); + if (ss->osd_subdiv_uvs) { + return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY; + } + return OSD_FVAR_LINEAR_INTERPOLATION_ALL; } static int conv_ccg_get_num_faces(const OpenSubdiv_Converter *converter) @@ -710,9 +717,10 @@ static int conv_ccg_get_face_corner_uv_index(const OpenSubdiv_Converter *UNUSED( void ccgSubSurf_converter_setup_from_ccg(CCGSubSurf *ss, OpenSubdiv_Converter *converter) { - converter->get_type = conv_ccg_get_bilinear_type; + converter->get_scheme_type = conv_ccg_get_bilinear_type; - converter->get_subdiv_uvs = conv_ccg_get_subdiv_uvs; + converter->get_fvar_linear_interpolation = + conv_ccg_get_fvar_linear_interpolation; converter->get_num_faces = conv_ccg_get_num_faces; converter->get_num_edges = conv_ccg_get_num_edges; -- cgit v1.2.3 From d0920fba1609b864adb38f0ec469e6b1581890e4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 10 Jul 2018 14:37:34 +0200 Subject: OpenSubdiv: Fix wrong topology refiner cast --- intern/opensubdiv/opensubdiv_evaluator_capi.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.cc b/intern/opensubdiv/opensubdiv_evaluator_capi.cc index c4a128213dd..049c0aad3bf 100644 --- a/intern/opensubdiv/opensubdiv_evaluator_capi.cc +++ b/intern/opensubdiv/opensubdiv_evaluator_capi.cc @@ -42,6 +42,7 @@ #include #include "opensubdiv_intern.h" +#include "opensubdiv_topology_refiner.h" #include "MEM_guardedalloc.h" @@ -341,7 +342,7 @@ OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr( int subsurf_level) { /* TODO(sergey): Look into re-using refiner with GLMesh. */ - TopologyRefiner *refiner = (TopologyRefiner *)topology_refiner; + TopologyRefiner *refiner = topology_refiner->osd_refiner; if(refiner == NULL) { /* Happens on bad topology. */ return NULL; -- cgit v1.2.3 From 785159e6e4dfc5c010baab626667132020e1ddc7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 14:56:40 +0200 Subject: Numeric Input: remove fake-editing option Numeric input allowed mix of editing and hotkeys which were interpreted as modifiers instead of using as numeric input. This meant entering '1.0*3' needed to be typed as '1.0**3' ('*' to activate, and again to multiply). Pressing '/' gave the reciprocal of the current number which could be useful. Test removing this feature, so only full numeric input is supported. --- source/blender/editors/util/numinput.c | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index a139f0e3c87..f67ea1d5989 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -48,12 +48,16 @@ #include "ED_numinput.h" #include "UI_interface.h" +/* Numeric input which isn't allowing full numeric editing. */ +// #define USE_FAKE_EDIT /* NumInput.flag */ enum { /* (1 << 8) and below are reserved for public flags! */ NUM_EDIT_FULL = (1 << 9), /* Enable full editing, with units and math operators support. */ +#ifdef USE_FAKE_EDIT NUM_FAKE_EDITED = (1 << 10), /* Fake edited state (temp, avoids issue with backspace). */ +#endif }; /* NumInput.val_flag[] */ @@ -61,8 +65,10 @@ enum { /* (1 << 8) and below are reserved for public flags! */ NUM_EDITED = (1 << 9), /* User has edited this value somehow. */ NUM_INVALID = (1 << 10), /* Current expression for this value is invalid. */ +#ifdef USE_FAKE_EDIT NUM_NEGATE = (1 << 11), /* Current expression's result has to be negated. */ NUM_INVERSE = (1 << 12), /* Current expression's result has to be inverted. */ +#endif }; /* ************************** Functions *************************** */ @@ -109,6 +115,7 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings) char before_cursor[NUM_STR_REP_LEN]; char val[16]; +#ifdef USE_FAKE_EDIT if (n->val_flag[i] & NUM_NEGATE) { heading_exp = (n->val_flag[i] & NUM_INVERSE) ? "-1/(" : "-("; trailing_exp = ")"; @@ -117,6 +124,7 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings) heading_exp = "1/("; trailing_exp = ")"; } +#endif if (n->val_flag[i] & NUM_INVALID) { BLI_strncpy(val, "Invalid", sizeof(val)); @@ -156,9 +164,11 @@ bool hasNumInput(const NumInput *n) { short i; +#ifdef USE_FAKE_EDIT if (n->flag & NUM_FAKE_EDITED) { return true; } +#endif for (i = 0; i <= n->idx_max; i++) { if (n->val_flag[i] & NUM_EDITED) { @@ -179,10 +189,13 @@ bool applyNumInput(NumInput *n, float *vec) if (hasNumInput(n)) { for (j = 0; j <= n->idx_max; j++) { +#ifdef USE_FAKE_EDIT if (n->flag & NUM_FAKE_EDITED) { val = n->val[j]; } - else { + else +#endif + { /* if AFFECTALL and no number typed and cursor not on number, use first number */ i = (n->flag & NUM_AFFECT_ALL && n->idx != j && !(n->val_flag[j] & NUM_EDITED)) ? 0 : j; val = (!(n->val_flag[i] & NUM_EDITED) && n->val_flag[i] & NUM_NULL_ONE) ? 1.0f : n->val[i]; @@ -202,7 +215,9 @@ bool applyNumInput(NumInput *n, float *vec) } vec[j] = val; } +#ifdef USE_FAKE_EDIT n->flag &= ~NUM_FAKE_EDITED; +#endif return true; } else { @@ -261,6 +276,18 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) short dir = STRCUR_DIR_NEXT, mode = STRCUR_JUMP_NONE; int cur; +#ifndef USE_FAKE_EDIT + if ((event->ctrl == 0) && (event->alt == 0) && + strchr("01234567890@%^&*-+/{}()[]<>.|", event->ascii)) + { + if (!(n->flag & NUM_EDIT_FULL)) { + n->flag |= NUM_EDITED; + n->flag |= NUM_EDIT_FULL; + n->val_flag[idx] |= NUM_EDITED; + } + } +#endif + switch (event->type) { case EVT_MODAL_MAP: if (ELEM(event->val, NUM_MODAL_INCREMENT_UP, NUM_MODAL_INCREMENT_DOWN)) { @@ -282,7 +309,11 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) n->val_flag[0] &= ~NUM_EDITED; n->val_flag[1] &= ~NUM_EDITED; n->val_flag[2] &= ~NUM_EDITED; +#ifdef USE_FAKE_EDIT n->flag |= NUM_FAKE_EDITED; +#else + n->flag |= NUM_EDIT_FULL; +#endif updated = true; break; } @@ -347,7 +378,9 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) } return false; case TABKEY: +#ifdef USE_FAKE_EDIT n->val_flag[idx] &= ~(NUM_NEGATE | NUM_INVERSE); +#endif idx = (idx + idx_max + (event->ctrl ? 0 : 2)) % (idx_max + 1); n->idx = idx; @@ -382,6 +415,8 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) } break; #endif + +#ifdef USE_FAKE_EDIT case PADMINUS: case MINUSKEY: if (event->ctrl || !(n->flag & NUM_EDIT_FULL)) { @@ -396,6 +431,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) updated = true; } break; +#endif case CKEY: if (event->ctrl) { /* Copy current str to the copypaste buffer. */ @@ -431,6 +467,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) ascii[0] = event->ascii; } +#ifdef USE_FAKE_EDIT /* XXX Hack around keyboards without direct access to '=' nor '*'... */ if (ELEM(ascii[0], '=', '*')) { if (!(n->flag & NUM_EDIT_FULL)) { @@ -443,6 +480,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) return true; } } +#endif /* Up to this point, if we have a ctrl modifier, skip. * This allows to still access most of modals' shortcuts even in numinput mode. @@ -511,6 +549,8 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) UNUSED_VARS(C); #endif /* WITH_PYTHON */ + +#ifdef USE_FAKE_EDIT if (n->val_flag[idx] & NUM_NEGATE) { n->val[idx] = -n->val[idx]; } @@ -526,6 +566,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) } n->val[idx] = (float)val; } +#endif if (UNLIKELY(!isfinite(n->val[idx]))) { n->val[idx] = val_prev; -- cgit v1.2.3 From dfd192ce41f7e4923db0642f22a587862656bbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 10 Jul 2018 13:17:32 +0200 Subject: GPUTexture: Refactor of texture creation & new feature - Texture creation now requires explicit data type. - GPU_texture_add_mipmap enable explicit mipmap upload. - GPU_texture_get_mipmap_size can be used to get the size of a mipmap level of an existing GPUTexture - GPU_texture_read let you read back data from a gpu texture. --- source/blender/blenfont/intern/blf_glyph.c | 4 +- source/blender/blenkernel/intern/studiolight.c | 4 +- source/blender/gpu/GPU_texture.h | 26 +- source/blender/gpu/intern/gpu_texture.c | 513 +++++++++++++++++-------- 4 files changed, 386 insertions(+), 161 deletions(-) diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 84388bedb7b..8dc11443124 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -239,7 +239,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) } unsigned char *pixels = MEM_callocN((size_t)gc->p2_width * (size_t)gc->p2_height, "BLF texture init"); - GPUTexture *tex = GPU_texture_create_2D(gc->p2_width, gc->p2_height, GPU_R8, (const float *)pixels, error); + GPUTexture *tex = GPU_texture_create_nD(gc->p2_width, gc->p2_height, 0, 2, pixels, GPU_R8, GPU_DATA_UNSIGNED_BYTE, 0, false, error); MEM_freeN(pixels); gc->textures[gc->texture_current] = tex; GPU_texture_bind(tex, 0); @@ -476,7 +476,7 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) BLI_assert(g->height > 0); } - GPU_texture_update_sub(g->tex, g->bitmap, g->offset_x, g->offset_y, 0, g->width, g->height, 0); + GPU_texture_update_sub(g->tex, GPU_DATA_UNSIGNED_BYTE, g->bitmap, g->offset_x, g->offset_y, 0, g->width, g->height, 0); g->uv[0][0] = ((float)g->offset_x) / ((float)gc->p2_width); g->uv[0][1] = ((float)g->offset_y) / ((float)gc->p2_height); diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index dbe5228b6ea..200c50e5c23 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -239,8 +239,8 @@ static void studiolight_create_equirectangular_radiance_gputexture(StudioLight * offset3 += 3; offset4 += 4; } - sl->equirectangular_radiance_gputexture = GPU_texture_create_2D( - ibuf->x, ibuf->y, GPU_R11F_G11F_B10F, sl->gpu_matcap_3components, error); + sl->equirectangular_radiance_gputexture = GPU_texture_create_nD( + ibuf->x, ibuf->y, 0, 2, sl->gpu_matcap_3components, GPU_R11F_G11F_B10F, GPU_DATA_FLOAT, 0, false, error); } else { sl->equirectangular_radiance_gputexture = GPU_texture_create_2D( diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 341abeba72f..3ed9014d431 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -144,8 +144,23 @@ typedef enum GPUTextureFormat { GPU_DEPTH_COMPONENT16, } GPUTextureFormat; +typedef enum GPUDataFormat { + GPU_DATA_FLOAT, + GPU_DATA_INT, + GPU_DATA_UNSIGNED_INT, + GPU_DATA_UNSIGNED_BYTE, + GPU_DATA_UNSIGNED_INT_24_8, + GPU_DATA_10_11_11_REV, +} GPUDataFormat; + unsigned int GPU_texture_memory_usage_get(void); +/* TODO make it static function again. (create function with GPUDataFormat exposed) */ +GPUTexture *GPU_texture_create_nD( + int w, int h, int d, int n, const void *pixels, + GPUTextureFormat tex_format, GPUDataFormat gpu_data_format, int samples, + const bool can_rescale, char err_out[256]); + GPUTexture *GPU_texture_create_1D( int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]); GPUTexture *GPU_texture_create_2D( @@ -168,11 +183,15 @@ GPUTexture *GPU_texture_from_blender( struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time); GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap); -void GPU_texture_update(GPUTexture *tex, const void *pixels); +void GPU_texture_add_mipmap(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl, const void *pixels); + +void GPU_texture_update(GPUTexture *tex, GPUDataFormat data_format, const void *pixels); void GPU_texture_update_sub( - GPUTexture *tex, const void *pixels, + GPUTexture *tex, GPUDataFormat gpu_data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth); +void *GPU_texture_read(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl); + void GPU_invalid_tex_init(void); void GPU_invalid_tex_bind(int mode); void GPU_invalid_tex_free(void); @@ -202,6 +221,7 @@ int GPU_texture_detach_framebuffer(GPUTexture *tex, struct GPUFrameBuffer *fb); int GPU_texture_target(const GPUTexture *tex); int GPU_texture_width(const GPUTexture *tex); int GPU_texture_height(const GPUTexture *tex); +int GPU_texture_layers(const GPUTexture *tex); GPUTextureFormat GPU_texture_format(const GPUTexture *tex); int GPU_texture_samples(const GPUTexture *tex); bool GPU_texture_cube(const GPUTexture *tex); @@ -210,6 +230,8 @@ bool GPU_texture_stencil(const GPUTexture *tex); bool GPU_texture_integer(const GPUTexture *tex); int GPU_texture_opengl_bindcode(const GPUTexture *tex); +void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *size); + #ifdef __cplusplus } #endif diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index b7385bdf07c..d9248e06dfb 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -134,73 +134,159 @@ unsigned int GPU_texture_memory_usage_get(void) /* -------------------------------- */ -static GLenum gpu_texture_get_format( - int components, GPUTextureFormat data_type, - GLenum *format, GLenum *data_format, GPUTextureFormatFlag *format_flag, unsigned int *bytesize) +static int gpu_get_component_count(GPUTextureFormat format) +{ + switch (format) { + case GPU_RGBA8: + case GPU_RGBA16F: + case GPU_RGBA16: + case GPU_RGBA32F: + return 4; + case GPU_RGB16F: + case GPU_R11F_G11F_B10F: + return 3; + case GPU_RG8: + case GPU_RG16: + case GPU_RG16F: + case GPU_RG16I: + case GPU_RG16UI: + case GPU_RG32F: + return 2; + default: + return 1; + } +} + +/* Definitely not complete, edit according to the gl specification. */ +static void gpu_validate_data_format(GPUTextureFormat tex_format, GPUDataFormat data_format) +{ + if (ELEM(tex_format, GPU_DEPTH_COMPONENT24, + GPU_DEPTH_COMPONENT16, + GPU_DEPTH_COMPONENT32F)) + { + BLI_assert(data_format == GPU_DATA_FLOAT); + } + else if (tex_format == GPU_DEPTH24_STENCIL8) { + BLI_assert(data_format == GPU_DATA_UNSIGNED_INT_24_8); + } + else { + /* Integer formats */ + if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) { + if (ELEM(tex_format, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) { + BLI_assert(data_format == GPU_DATA_UNSIGNED_INT); + } + else { + BLI_assert(data_format == GPU_DATA_INT); + } + } + /* Byte formats */ + else if (ELEM(tex_format, GPU_R8, GPU_RG8, GPU_RGBA8)) { + BLI_assert(ELEM(data_format, GPU_DATA_UNSIGNED_BYTE, GPU_DATA_FLOAT)); + } + /* Special case */ + else if (ELEM(tex_format, GPU_R11F_G11F_B10F)) { + BLI_assert(ELEM(data_format, GPU_DATA_10_11_11_REV, GPU_DATA_FLOAT)); + } + /* Float formats */ + else { + BLI_assert(ELEM(data_format, GPU_DATA_FLOAT)); + } + } +} + +static GPUDataFormat gpu_get_data_format_from_tex_format(GPUTextureFormat tex_format) +{ + if (ELEM(tex_format, GPU_DEPTH_COMPONENT24, + GPU_DEPTH_COMPONENT16, + GPU_DEPTH_COMPONENT32F)) + { + return GPU_DATA_FLOAT; + } + else if (tex_format == GPU_DEPTH24_STENCIL8) { + return GPU_DATA_UNSIGNED_INT_24_8; + } + else { + /* Integer formats */ + if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) { + if (ELEM(tex_format, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) { + return GPU_DATA_UNSIGNED_INT; + } + else { + return GPU_DATA_INT; + } + } + /* Byte formats */ + else if (ELEM(tex_format, GPU_R8)) { + return GPU_DATA_UNSIGNED_BYTE; + } + /* Special case */ + else if (ELEM(tex_format, GPU_R11F_G11F_B10F)) { + return GPU_DATA_10_11_11_REV; + } + else { + return GPU_DATA_FLOAT; + } + } +} + +/* Definitely not complete, edit according to the gl specification. */ +static GLenum gpu_get_gl_dataformat(GPUTextureFormat data_type, GPUTextureFormatFlag *format_flag) { if (ELEM(data_type, GPU_DEPTH_COMPONENT24, GPU_DEPTH_COMPONENT16, GPU_DEPTH_COMPONENT32F)) { *format_flag |= GPU_FORMAT_DEPTH; - *data_format = GL_FLOAT; - *format = GL_DEPTH_COMPONENT; + return GL_DEPTH_COMPONENT; } else if (data_type == GPU_DEPTH24_STENCIL8) { *format_flag |= GPU_FORMAT_DEPTH | GPU_FORMAT_STENCIL; - *data_format = GL_UNSIGNED_INT_24_8; - *format = GL_DEPTH_STENCIL; + return GL_DEPTH_STENCIL; } else { /* Integer formats */ if (ELEM(data_type, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) { - if (ELEM(data_type, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) { - *data_format = GL_UNSIGNED_INT; - } - else { - *data_format = GL_INT; - } - *format_flag |= GPU_FORMAT_INTEGER; - switch (components) { - case 1: *format = GL_RED_INTEGER; break; - case 2: *format = GL_RG_INTEGER; break; - case 3: *format = GL_RGB_INTEGER; break; - case 4: *format = GL_RGBA_INTEGER; break; - default: break; + switch (gpu_get_component_count(data_type)) { + case 1: return GL_RED_INTEGER; break; + case 2: return GL_RG_INTEGER; break; + case 3: return GL_RGB_INTEGER; break; + case 4: return GL_RGBA_INTEGER; break; } } else if (ELEM(data_type, GPU_R8)) { - *data_format = GL_UNSIGNED_BYTE; - *format = GL_RED; + *format_flag |= GPU_FORMAT_FLOAT; + return GL_RED; } else { - *data_format = GL_FLOAT; *format_flag |= GPU_FORMAT_FLOAT; - switch (components) { - case 1: *format = GL_RED; break; - case 2: *format = GL_RG; break; - case 3: *format = GL_RGB; break; - case 4: *format = GL_RGBA; break; - default: break; + switch (gpu_get_component_count(data_type)) { + case 1: return GL_RED; break; + case 2: return GL_RG; break; + case 3: return GL_RGB; break; + case 4: return GL_RGBA; break; } } } + BLI_assert(0); + *format_flag |= GPU_FORMAT_FLOAT; + return GL_RGBA; +} + +static unsigned int gpu_get_bytesize(GPUTextureFormat data_type) +{ switch (data_type) { case GPU_RGBA32F: - *bytesize = 32; - break; + return 32; case GPU_RG32F: case GPU_RGBA16F: case GPU_RGBA16: - *bytesize = 16; - break; + return 16; case GPU_RGB16F: - *bytesize = 12; - break; + return 12; case GPU_RG16F: case GPU_RG16I: case GPU_RG16UI: @@ -212,28 +298,28 @@ static GLenum gpu_texture_get_format( case GPU_R32F: case GPU_R32UI: case GPU_R32I: - *bytesize = 4; - break; + return 4; case GPU_DEPTH_COMPONENT24: - *bytesize = 3; - break; + return 3; case GPU_DEPTH_COMPONENT16: case GPU_R16F: + case GPU_R16UI: case GPU_R16I: case GPU_RG8: - *bytesize = 2; - break; + return 2; case GPU_R8: - *bytesize = 1; - break; + return 1; default: - *bytesize = 0; - break; + BLI_assert(!"Texture format incorrect or unsupported\n"); + return 0; } +} +static GLenum gpu_get_gl_internalformat(GPUTextureFormat format) +{ /* You can add any of the available type to this list * For available types see GPU_texture.h */ - switch (data_type) { + switch (format) { /* Formats texture & renderbuffer */ case GPU_RGBA32F: return GL_RGBA32F; case GPU_RGBA16F: return GL_RGBA16F; @@ -265,31 +351,29 @@ static GLenum gpu_texture_get_format( case GPU_DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT24; case GPU_DEPTH_COMPONENT16: return GL_DEPTH_COMPONENT16; default: - fprintf(stderr, "Texture format incorrect or unsupported\n"); + BLI_assert(!"Texture format incorrect or unsupported\n"); return 0; } } -static int gpu_texture_get_component_count(GPUTextureFormat format) +static GLenum gpu_get_gl_datatype(GPUDataFormat format) { switch (format) { - case GPU_RGBA8: - case GPU_RGBA16F: - case GPU_RGBA16: - case GPU_RGBA32F: - return 4; - case GPU_RGB16F: - case GPU_R11F_G11F_B10F: - return 3; - case GPU_RG8: - case GPU_RG16: - case GPU_RG16F: - case GPU_RG16I: - case GPU_RG16UI: - case GPU_RG32F: - return 2; + case GPU_DATA_FLOAT: + return GL_FLOAT; + case GPU_DATA_INT: + return GL_INT; + case GPU_DATA_UNSIGNED_INT: + return GL_UNSIGNED_INT; + case GPU_DATA_UNSIGNED_BYTE: + return GL_UNSIGNED_BYTE; + case GPU_DATA_UNSIGNED_INT_24_8: + return GL_UNSIGNED_INT_24_8; + case GPU_DATA_10_11_11_REV: + return GL_UNSIGNED_INT_10F_11F_11F_REV; default: - return 1; + BLI_assert(!"Unhandled data format"); + return GL_FLOAT; } } @@ -331,22 +415,22 @@ static float *GPU_texture_3D_rescale(GPUTexture *tex, int w, int h, int d, int c /* This tries to allocate video memory for a given texture * If alloc fails, lower the resolution until it fits. */ static bool gpu_texture_try_alloc( - GPUTexture *tex, GLenum proxy, GLenum internalformat, GLenum format, GLenum data_format, + GPUTexture *tex, GLenum proxy, GLenum internalformat, GLenum data_format, GLenum data_type, int channels, bool try_rescale, const float *fpixels, float **rescaled_fpixels) { int r_width; switch (proxy) { case GL_PROXY_TEXTURE_1D: - glTexImage1D(proxy, 0, internalformat, tex->w, 0, format, data_format, NULL); + glTexImage1D(proxy, 0, internalformat, tex->w, 0, data_format, data_type, NULL); break; case GL_PROXY_TEXTURE_1D_ARRAY: case GL_PROXY_TEXTURE_2D: - glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, format, data_format, NULL); + glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, NULL); break; case GL_PROXY_TEXTURE_2D_ARRAY: case GL_PROXY_TEXTURE_3D: - glTexImage3D(proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, format, data_format, NULL); + glTexImage3D(proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, NULL); break; } @@ -367,11 +451,11 @@ static bool gpu_texture_try_alloc( if (tex->d == 0 && proxy == GL_PROXY_TEXTURE_3D) break; if (proxy == GL_PROXY_TEXTURE_1D) - glTexImage1D(proxy, 0, internalformat, tex->w, 0, format, data_format, NULL); + glTexImage1D(proxy, 0, internalformat, tex->w, 0, data_format, data_type, NULL); else if (proxy == GL_PROXY_TEXTURE_2D) - glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, format, data_format, NULL); + glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, NULL); else if (proxy == GL_PROXY_TEXTURE_3D) - glTexImage3D(proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, format, data_format, NULL); + glTexImage3D(proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, NULL); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &r_width); } @@ -384,6 +468,7 @@ static bool gpu_texture_try_alloc( /* Do nothing for now */ return false; case GL_PROXY_TEXTURE_3D: + BLI_assert(data_type == GL_FLOAT); *rescaled_fpixels = GPU_texture_3D_rescale(tex, w, h, d, channels, fpixels); return (bool)*rescaled_fpixels; } @@ -393,9 +478,9 @@ static bool gpu_texture_try_alloc( return (r_width > 0); } -static GPUTexture *GPU_texture_create_nD( - int w, int h, int d, int n, const float *fpixels, - GPUTextureFormat data_type, int samples, +GPUTexture *GPU_texture_create_nD( + int w, int h, int d, int n, const void *pixels, + GPUTextureFormat tex_format, GPUDataFormat gpu_data_format, int samples, const bool can_rescale, char err_out[256]) { if (samples) { @@ -409,8 +494,9 @@ static GPUTexture *GPU_texture_create_nD( tex->samples = samples; tex->number = -1; tex->refcount = 1; - tex->format = data_type; - tex->components = gpu_texture_get_component_count(data_type); + tex->format = tex_format; + tex->components = gpu_get_component_count(tex_format); + tex->bytesize = gpu_get_bytesize(tex_format); tex->format_flag = 0; if (n == 2) { @@ -434,12 +520,14 @@ static GPUTexture *GPU_texture_create_nD( return NULL; } + gpu_validate_data_format(tex_format, gpu_data_format); + if (samples && n == 2 && d == 0) tex->target = GL_TEXTURE_2D_MULTISAMPLE; - GLenum format, internalformat, data_format; - internalformat = gpu_texture_get_format(tex->components, data_type, &format, &data_format, - &tex->format_flag, &tex->bytesize); + GLenum internalformat = gpu_get_gl_internalformat(tex_format); + GLenum data_format = gpu_get_gl_dataformat(tex_format, &tex->format_flag); + GLenum data_type = gpu_get_gl_datatype(gpu_data_format); gpu_texture_memory_footprint_add(tex); @@ -448,9 +536,9 @@ static GPUTexture *GPU_texture_create_nD( if (!tex->bindcode) { if (err_out) - BLI_snprintf(err_out, 256, "GPUTexture: texture create failed"); + BLI_snprintf(err_out, 256, "GPUTexture: texture create failed\n"); else - fprintf(stderr, "GPUTexture: texture create failed"); + fprintf(stderr, "GPUTexture: texture create failed\n"); GPU_texture_free(tex); return NULL; } @@ -474,9 +562,9 @@ static GPUTexture *GPU_texture_create_nD( proxy = GL_PROXY_TEXTURE_3D; } - float *rescaled_fpixels = NULL; - bool valid = gpu_texture_try_alloc(tex, proxy, internalformat, format, data_format, tex->components, can_rescale, - fpixels, &rescaled_fpixels); + float *rescaled_pixels = NULL; + bool valid = gpu_texture_try_alloc(tex, proxy, internalformat, data_format, data_type, tex->components, can_rescale, + pixels, &rescaled_pixels); if (!valid) { if (err_out) BLI_snprintf(err_out, 256, "GPUTexture: texture alloc failed"); @@ -487,7 +575,7 @@ static GPUTexture *GPU_texture_create_nD( } /* Upload Texture */ - const float *pix = (rescaled_fpixels) ? rescaled_fpixels : fpixels; + const float *pix = (rescaled_pixels) ? rescaled_pixels : pixels; if (tex->target == GL_TEXTURE_2D || tex->target == GL_TEXTURE_2D_MULTISAMPLE || @@ -496,21 +584,21 @@ static GPUTexture *GPU_texture_create_nD( if (samples) { glTexImage2DMultisample(tex->target, samples, internalformat, tex->w, tex->h, true); if (pix) - glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, format, data_format, pix); + glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, data_format, data_type, pix); } else { - glTexImage2D(tex->target, 0, internalformat, tex->w, tex->h, 0, format, data_format, pix); + glTexImage2D(tex->target, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, pix); } } else if (tex->target == GL_TEXTURE_1D) { - glTexImage1D(tex->target, 0, internalformat, tex->w, 0, format, data_format, pix); + glTexImage1D(tex->target, 0, internalformat, tex->w, 0, data_format, data_type, pix); } else { - glTexImage3D(tex->target, 0, internalformat, tex->w, tex->h, tex->d, 0, format, data_format, pix); + glTexImage3D(tex->target, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, pix); } - if (rescaled_fpixels) - MEM_freeN(rescaled_fpixels); + if (rescaled_pixels) + MEM_freeN(rescaled_pixels); /* Texture Parameters */ if (GPU_texture_stencil(tex) || /* Does not support filtering */ @@ -547,11 +635,9 @@ static GPUTexture *GPU_texture_cube_create( int w, int d, const float *fpixels_px, const float *fpixels_py, const float *fpixels_pz, const float *fpixels_nx, const float *fpixels_ny, const float *fpixels_nz, - GPUTextureFormat data_type, + GPUTextureFormat tex_format, GPUDataFormat gpu_data_format, char err_out[256]) { - GLenum format, internalformat, data_format; - GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture"); tex->w = w; tex->h = w; @@ -559,8 +645,9 @@ static GPUTexture *GPU_texture_cube_create( tex->samples = 0; tex->number = -1; tex->refcount = 1; - tex->format = data_type; - tex->components = gpu_texture_get_component_count(data_type); + tex->format = tex_format; + tex->components = gpu_get_component_count(tex_format); + tex->bytesize = gpu_get_bytesize(tex_format); tex->format_flag = GPU_FORMAT_CUBE; if (d == 0) { @@ -571,8 +658,9 @@ static GPUTexture *GPU_texture_cube_create( // tex->target_base = tex->target = GL_TEXTURE_CUBE_MAP_ARRAY; } - internalformat = gpu_texture_get_format(tex->components, data_type, &format, &data_format, - &tex->format_flag, &tex->bytesize); + GLenum internalformat = gpu_get_gl_internalformat(tex_format); + GLenum data_format = gpu_get_gl_dataformat(tex_format, &tex->format_flag); + GLenum data_type = gpu_get_gl_datatype(gpu_data_format); gpu_texture_memory_footprint_add(tex); @@ -581,9 +669,9 @@ static GPUTexture *GPU_texture_cube_create( if (!tex->bindcode) { if (err_out) - BLI_snprintf(err_out, 256, "GPUTexture: texture create failed"); + BLI_snprintf(err_out, 256, "GPUTexture: texture create failed\n"); else - fprintf(stderr, "GPUTexture: texture create failed"); + fprintf(stderr, "GPUTexture: texture create failed\n"); GPU_texture_free(tex); return NULL; } @@ -591,12 +679,12 @@ static GPUTexture *GPU_texture_cube_create( glBindTexture(tex->target, tex->bindcode); /* Upload Texture */ - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_px); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_py); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_pz); - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_nx); - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_ny); - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalformat, tex->w, tex->h, 0, format, data_format, fpixels_nz); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_px); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_py); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_pz); + glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_nx); + glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_ny); + glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, fpixels_nz); /* Texture Parameters */ if (GPU_texture_stencil(tex) || /* Does not support filtering */ @@ -625,36 +713,37 @@ static GPUTexture *GPU_texture_cube_create( return tex; } -/* Special buffer textures. data_type must be compatible with the buffer content. */ -GPUTexture *GPU_texture_create_buffer(GPUTextureFormat data_type, const GLuint buffer) +/* Special buffer textures. tex_format must be compatible with the buffer content. */ +GPUTexture *GPU_texture_create_buffer(GPUTextureFormat tex_format, const GLuint buffer) { GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture"); tex->number = -1; tex->refcount = 1; - tex->format = data_type; - tex->components = gpu_texture_get_component_count(data_type); + tex->format = tex_format; + tex->components = gpu_get_component_count(tex_format); tex->format_flag = 0; tex->target_base = tex->target = GL_TEXTURE_BUFFER; - - GLenum format, internalformat, data_format; - internalformat = gpu_texture_get_format(tex->components, data_type, &format, &data_format, - &tex->format_flag, &tex->bytesize); - - if (!(ELEM(data_type, GPU_R8, GPU_R16) || - ELEM(data_type, GPU_R16F, GPU_R32F) || - ELEM(data_type, GPU_R8I, GPU_R16I, GPU_R32I) || - ELEM(data_type, GPU_R8UI, GPU_R16UI, GPU_R32UI) || - ELEM(data_type, GPU_RG8, GPU_RG16) || - ELEM(data_type, GPU_RG16F, GPU_RG32F) || - ELEM(data_type, GPU_RG8I, GPU_RG16I, GPU_RG32I) || - ELEM(data_type, GPU_RG8UI, GPU_RG16UI, GPU_RG32UI) || - //ELEM(data_type, GPU_RGB32F, GPU_RGB32I, GPU_RGB32UI) || /* Not available until gl 4.0 */ - ELEM(data_type, GPU_RGBA8, GPU_RGBA16) || - ELEM(data_type, GPU_RGBA16F, GPU_RGBA32F) || - ELEM(data_type, GPU_RGBA8I, GPU_RGBA16I, GPU_RGBA32I) || - ELEM(data_type, GPU_RGBA8UI, GPU_RGBA16UI, GPU_RGBA32UI))) + tex->bytesize = gpu_get_bytesize(tex_format); + + GLenum internalformat = gpu_get_gl_internalformat(tex_format); + + gpu_get_gl_dataformat(tex_format, &tex->format_flag); + + if (!(ELEM(tex_format, GPU_R8, GPU_R16) || + ELEM(tex_format, GPU_R16F, GPU_R32F) || + ELEM(tex_format, GPU_R8I, GPU_R16I, GPU_R32I) || + ELEM(tex_format, GPU_R8UI, GPU_R16UI, GPU_R32UI) || + ELEM(tex_format, GPU_RG8, GPU_RG16) || + ELEM(tex_format, GPU_RG16F, GPU_RG32F) || + ELEM(tex_format, GPU_RG8I, GPU_RG16I, GPU_RG32I) || + ELEM(tex_format, GPU_RG8UI, GPU_RG16UI, GPU_RG32UI) || + //ELEM(tex_format, GPU_RGB32F, GPU_RGB32I, GPU_RGB32UI) || /* Not available until gl 4.0 */ + ELEM(tex_format, GPU_RGBA8, GPU_RGBA16) || + ELEM(tex_format, GPU_RGBA16F, GPU_RGBA32F) || + ELEM(tex_format, GPU_RGBA8I, GPU_RGBA16I, GPU_RGBA32I) || + ELEM(tex_format, GPU_RGBA8UI, GPU_RGBA16UI, GPU_RGBA32UI))) { - fprintf(stderr, "GPUTexture: invalid format for texture buffer"); + fprintf(stderr, "GPUTexture: invalid format for texture buffer\n"); GPU_texture_free(tex); return NULL; } @@ -663,9 +752,9 @@ GPUTexture *GPU_texture_create_buffer(GPUTextureFormat data_type, const GLuint b glGenTextures(1, &tex->bindcode); if (!tex->bindcode) { - fprintf(stderr, "GPUTexture: texture create failed"); + fprintf(stderr, "GPUTexture: texture create failed\n"); GPU_texture_free(tex); - BLI_assert(0 && "glGenTextures failled: Are you sure a valid OGL context is active on this thread?"); + BLI_assert(0 && "glGenTextures failled: Are you sure a valid OGL context is active on this thread?\n"); return NULL; } @@ -766,40 +855,45 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap) } GPUTexture *GPU_texture_create_1D( - int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]) + int w, GPUTextureFormat tex_format, const float *pixels, char err_out[256]) { - return GPU_texture_create_nD(w, 0, 0, 1, pixels, data_type, 0, false, err_out); + GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format); + return GPU_texture_create_nD(w, 0, 0, 1, pixels, tex_format, data_format, 0, false, err_out); } GPUTexture *GPU_texture_create_2D( - int w, int h, GPUTextureFormat data_type, const float *pixels, char err_out[256]) + int w, int h, GPUTextureFormat tex_format, const float *pixels, char err_out[256]) { - return GPU_texture_create_nD(w, h, 0, 2, pixels, data_type, 0, false, err_out); + GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format); + return GPU_texture_create_nD(w, h, 0, 2, pixels, tex_format, data_format, 0, false, err_out); } GPUTexture *GPU_texture_create_2D_multisample( - int w, int h, GPUTextureFormat data_type, const float *pixels, int samples, char err_out[256]) + int w, int h, GPUTextureFormat tex_format, const float *pixels, int samples, char err_out[256]) { - return GPU_texture_create_nD(w, h, 0, 2, pixels, data_type, samples, false, err_out); + GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format); + return GPU_texture_create_nD(w, h, 0, 2, pixels, tex_format, data_format, samples, false, err_out); } GPUTexture *GPU_texture_create_2D_array( - int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256]) + int w, int h, int d, GPUTextureFormat tex_format, const float *pixels, char err_out[256]) { - return GPU_texture_create_nD(w, h, d, 2, pixels, data_type, 0, false, err_out); + GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format); + return GPU_texture_create_nD(w, h, d, 2, pixels, tex_format, data_format, 0, false, err_out); } GPUTexture *GPU_texture_create_3D( - int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256]) + int w, int h, int d, GPUTextureFormat tex_format, const float *pixels, char err_out[256]) { - return GPU_texture_create_nD(w, h, d, 3, pixels, data_type, 0, true, err_out); + GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format); + return GPU_texture_create_nD(w, h, d, 3, pixels, tex_format, data_format, 0, true, err_out); } GPUTexture *GPU_texture_create_cube( - int w, GPUTextureFormat data_type, const float *fpixels, char err_out[256]) + int w, GPUTextureFormat tex_format, const float *fpixels, char err_out[256]) { const float *fpixels_px, *fpixels_py, *fpixels_pz, *fpixels_nx, *fpixels_ny, *fpixels_nz; - const int channels = gpu_texture_get_component_count(data_type); + const int channels = gpu_get_component_count(tex_format); if (fpixels) { fpixels_px = fpixels + 0 * w * w * channels; @@ -814,7 +908,7 @@ GPUTexture *GPU_texture_create_cube( } return GPU_texture_cube_create(w, 0, fpixels_px, fpixels_py, fpixels_pz, fpixels_nx, fpixels_ny, fpixels_nz, - data_type, err_out); + tex_format, GPU_DATA_FLOAT, err_out); } GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) @@ -886,17 +980,56 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) return GPU_texture_create_buffer(data_type, vert->vbo_id); } +void GPU_texture_add_mipmap( + GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl, const void *pixels) +{ + BLI_assert((int)tex->format > -1); + BLI_assert(tex->components > -1); + + gpu_validate_data_format(tex->format, gpu_data_format); + + GLenum internalformat = gpu_get_gl_internalformat(tex->format); + GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag); + GLenum data_type = gpu_get_gl_datatype(gpu_data_format); + + glBindTexture(tex->target, tex->bindcode); + + int size[3]; + GPU_texture_get_mipmap_size(tex, miplvl, size); + + switch (tex->target) { + case GL_TEXTURE_1D: + glTexImage1D(tex->target, miplvl, internalformat, size[0], 0, data_format, data_type, pixels); + break; + case GL_TEXTURE_2D: + case GL_TEXTURE_1D_ARRAY: + glTexImage2D(tex->target, miplvl, internalformat, size[0], size[1], 0, data_format, data_type, pixels); + break; + case GL_TEXTURE_3D: + case GL_TEXTURE_2D_ARRAY: + glTexImage3D(tex->target, miplvl, internalformat, size[0], size[1], size[2], 0, data_format, data_type, pixels); + break; + case GL_TEXTURE_2D_MULTISAMPLE: + /* Multisample textures cannot have mipmaps. */ + default: + BLI_assert(!"tex->target mode not supported"); + } + + glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_MAX_LEVEL, miplvl); + + glBindTexture(tex->target, 0); +} + void GPU_texture_update_sub( - GPUTexture *tex, const void *pixels, + GPUTexture *tex, GPUDataFormat gpu_data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth) { BLI_assert((int)tex->format > -1); BLI_assert(tex->components > -1); - GLenum format, data_format; + GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag); + GLenum data_type = gpu_get_gl_datatype(gpu_data_format); GLint alignment; - gpu_texture_get_format(tex->components, tex->format, &format, &data_format, - &tex->format_flag, &tex->bytesize); /* The default pack size for textures is 4, which won't work for byte based textures */ if (tex->bytesize == 1) { @@ -906,21 +1039,21 @@ void GPU_texture_update_sub( glBindTexture(tex->target, tex->bindcode); switch (tex->target) { + case GL_TEXTURE_1D: + glTexSubImage1D(tex->target, 0, offset_x, width, data_format, data_type, pixels); + break; case GL_TEXTURE_2D: case GL_TEXTURE_2D_MULTISAMPLE: case GL_TEXTURE_1D_ARRAY: glTexSubImage2D( tex->target, 0, offset_x, offset_y, - width, height, format, data_format, pixels); - break; - case GL_TEXTURE_1D: - glTexSubImage1D(tex->target, 0, offset_x, width, format, data_format, pixels); + width, height, data_format, data_type, pixels); break; case GL_TEXTURE_3D: case GL_TEXTURE_2D_ARRAY: glTexSubImage3D( tex->target, 0, offset_x, offset_y, offset_z, - width, height, depth, format, data_format, pixels); + width, height, depth, data_format, data_type, pixels); break; default: BLI_assert(!"tex->target mode not supported"); @@ -933,9 +1066,53 @@ void GPU_texture_update_sub( glBindTexture(tex->target, 0); } -void GPU_texture_update(GPUTexture *tex, const void *pixels) +void *GPU_texture_read(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplvl) { - GPU_texture_update_sub(tex, pixels, 0, 0, 0, tex->w, tex->h, tex->d); + int size[3] = {0, 0, 0}; + GPU_texture_get_mipmap_size(tex, miplvl, size); + + gpu_validate_data_format(tex->format, gpu_data_format); + + size_t buf_size = gpu_texture_memory_footprint_compute(tex); + size_t samples_count = max_ii(1, tex->samples); + + samples_count *= size[0]; + samples_count *= max_ii(1, size[1]); + samples_count *= max_ii(1, size[2]); + + switch (gpu_data_format) { + case GPU_DATA_FLOAT: + buf_size = sizeof(float) * samples_count * tex->components; + break; + case GPU_DATA_INT: + case GPU_DATA_UNSIGNED_INT: + buf_size = sizeof(int) * samples_count * tex->components; + break; + case GPU_DATA_UNSIGNED_INT_24_8: + case GPU_DATA_10_11_11_REV: + buf_size = sizeof(int) * samples_count; + break; + case GPU_DATA_UNSIGNED_BYTE: + break; + } + + void *buf = MEM_mallocN(buf_size, "GPU_texture_read"); + + GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag); + GLenum data_type = gpu_get_gl_datatype(gpu_data_format); + + glBindTexture(tex->target, tex->bindcode); + + glGetTexImage(tex->target, miplvl, data_format, data_type, buf); + + glBindTexture(tex->target, 0); + + return buf; +} + +void GPU_texture_update(GPUTexture *tex, GPUDataFormat data_format, const void *pixels) +{ + GPU_texture_update_sub(tex, data_format, pixels, 0, 0, 0, tex->w, tex->h, tex->d); } void GPU_invalid_tex_init(void) @@ -1199,6 +1376,11 @@ int GPU_texture_height(const GPUTexture *tex) return tex->h; } +int GPU_texture_layers(const GPUTexture *tex) +{ + return tex->d; +} + GPUTextureFormat GPU_texture_format(const GPUTexture *tex) { return tex->format; @@ -1260,3 +1442,24 @@ int GPU_texture_detach_framebuffer(GPUTexture *tex, GPUFrameBuffer *fb) BLI_assert(!"Error: Texture: Framebuffer is not attached"); return 0; } + +void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *size) +{ + /* TODO assert if lvl is bellow the limit of 1px in each dimension. */ + int div = 1 << lvl; + size[0] = max_ii(1, tex->w / div); + + if (tex->target == GL_TEXTURE_1D_ARRAY) { + size[1] = tex->h; + } + else if (tex->h > 0) { + size[1] = max_ii(1, tex->h / div); + } + + if (tex->target == GL_TEXTURE_2D_ARRAY) { + size[2] = tex->d; + } + else if (tex->d > 0) { + size[2] = max_ii(1, tex->d / div); + } +} -- cgit v1.2.3 From 873d7f7e14e080f75e75ed7c6c07f326e588cecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 10 Jul 2018 14:14:55 +0200 Subject: DrawData: Change drawdata to a generic struct shared accross ID types This makes tagging much more generic and make the world updates more in line with the new tagging system (Depsgraph). --- source/blender/blenkernel/BKE_world.h | 6 - source/blender/blenkernel/intern/object.c | 11 +- source/blender/blenkernel/intern/world.c | 13 +- source/blender/depsgraph/CMakeLists.txt | 1 + .../depsgraph/intern/builder/deg_builder_nodes.cc | 4 +- .../intern/eval/deg_eval_copy_on_write.cc | 25 ++-- .../depsgraph/intern/eval/deg_eval_flush.cc | 10 +- source/blender/draw/DRW_engine.h | 3 + source/blender/draw/engines/eevee/eevee_data.c | 72 +++++++---- source/blender/draw/engines/eevee/eevee_engine.c | 27 +++- .../blender/draw/engines/eevee/eevee_lightprobes.c | 3 +- source/blender/draw/engines/eevee/eevee_private.h | 12 +- .../draw/engines/workbench/workbench_deferred.c | 12 +- .../draw/engines/workbench/workbench_forward.c | 8 +- .../draw/engines/workbench/workbench_private.h | 8 +- source/blender/draw/intern/DRW_render.h | 15 +-- source/blender/draw/intern/draw_manager.c | 142 +++++++++++++++++---- source/blender/draw/modes/object_mode.c | 12 +- source/blender/editors/render/render_update.c | 3 - source/blender/makesdna/DNA_ID.h | 21 +++ source/blender/makesdna/DNA_object_types.h | 18 +-- source/blender/makesdna/DNA_world_types.h | 4 +- 22 files changed, 280 insertions(+), 150 deletions(-) diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h index f703fefec97..6a9a75828e5 100644 --- a/source/blender/blenkernel/BKE_world.h +++ b/source/blender/blenkernel/BKE_world.h @@ -44,10 +44,4 @@ struct World *BKE_world_copy(struct Main *bmain, const struct World *wrld); struct World *BKE_world_localize(struct World *wrld); void BKE_world_make_local(struct Main *bmain, struct World *wrld, const bool lib_local); -/* Evaluation. */ - -struct Depsgraph; - -void BKE_world_eval(struct Depsgraph *depsgraph, struct World *world); - #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a7c13ab2a81..95e408f593e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -424,6 +424,8 @@ void BKE_object_free(Object *ob) { BKE_animdata_free((ID *)ob, false); + DRW_drawdata_free((ID *)ob); + /* BKE__free shall never touch to ID->us. Never ever. */ BKE_object_free_modifiers(ob, LIB_ID_CREATE_NO_USER_REFCOUNT); @@ -451,13 +453,6 @@ void BKE_object_free(Object *ob) sbFree(ob); - for (ObjectEngineData *oed = ob->drawdata.first; oed; oed = oed->next) { - if (oed->free != NULL) { - oed->free(oed); - } - } - BLI_freelistN(&ob->drawdata); - BKE_sculptsession_free(ob); BLI_freelistN(&ob->pc_ids); @@ -1210,7 +1205,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_ ob_dst->derivedFinal = NULL; BLI_listbase_clear(&ob_dst->gpulamp); - BLI_listbase_clear(&ob_dst->drawdata); + BLI_listbase_clear((ListBase *)&ob_dst->drawdata); BLI_listbase_clear(&ob_dst->pc_ids); ob_dst->avs = ob_src->avs; diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 69096ad7a08..3e1a9a4f57b 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -53,6 +53,8 @@ #include "BKE_node.h" #include "BKE_world.h" +#include "DRW_engine.h" + #include "DEG_depsgraph.h" #include "GPU_material.h" @@ -62,6 +64,8 @@ void BKE_world_free(World *wrld) { BKE_animdata_free((ID *)wrld, false); + DRW_drawdata_free((ID *)wrld); + /* is no lib link block, but world extension */ if (wrld->nodetree) { ntreeFreeTree(wrld->nodetree); @@ -119,6 +123,7 @@ void BKE_world_copy_data(Main *bmain, World *wrld_dst, const World *wrld_src, co } BLI_listbase_clear(&wrld_dst->gpumaterial); + BLI_listbase_clear((ListBase *)&wrld_dst->drawdata); if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { BKE_previewimg_id_copy(&wrld_dst->id, &wrld_src->id); @@ -154,6 +159,7 @@ World *BKE_world_localize(World *wrld) wrldn->preview = NULL; BLI_listbase_clear(&wrldn->gpumaterial); + BLI_listbase_clear((ListBase *)&wrldn->drawdata); return wrldn; } @@ -163,10 +169,3 @@ void BKE_world_make_local(Main *bmain, World *wrld, const bool lib_local) BKE_id_make_local_generic(bmain, &wrld->id, true, lib_local); } -void BKE_world_eval(struct Depsgraph *depsgraph, World *world) -{ - DEG_debug_print_eval(depsgraph, __func__, world->id.name, world); - if (!BLI_listbase_is_empty(&world->gpumaterial)) { - world->update_flag = 1; - } -} diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index 0673a3177b7..185a98f2a2b 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -28,6 +28,7 @@ set(INC ../blenkernel ../blenlib ../bmesh + ../draw ../makesdna ../makesrna ../modifiers diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index cb455130d4c..ab7ddb507a0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -873,9 +873,7 @@ void DepsgraphNodeBuilder::build_world(World *world) /* world itself */ add_operation_node(&world->id, DEG_NODE_TYPE_SHADING, - function_bind(BKE_world_eval, - _1, - get_cow_datablock(world)), + NULL, DEG_OPCODE_WORLD_UPDATE); /* world's nodetree */ if (world->nodetree != NULL) { diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 447a8af6235..794cc22f4e3 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -70,6 +70,8 @@ extern "C" { #include "DNA_object_types.h" #include "DNA_particle_types.h" +#include "DRW_engine.h" + #ifdef NESTED_ID_NASTY_WORKAROUND # include "DNA_curve_types.h" # include "DNA_key_types.h" @@ -713,7 +715,6 @@ typedef struct ObjectRuntimeBackup { CurveCache *curve_cache; Object_Runtime runtime; short base_flag; - ListBase drawdata; } ObjectRuntimeBackup; /* Make a backup of object's evaluation runtime data, additionally @@ -740,9 +741,6 @@ static void deg_backup_object_runtime( object->curve_cache = NULL; /* Make a backup of base flags. */ object_runtime_backup->base_flag = object->base_flag; - /* Make backup of object draw data.*/ - object_runtime_backup->drawdata = object->drawdata; - BLI_listbase_clear(&object->drawdata); } static void deg_restore_object_runtime( @@ -782,8 +780,6 @@ static void deg_restore_object_runtime( object->curve_cache = object_runtime_backup->curve_cache; } object->base_flag = object_runtime_backup->base_flag; - /* Restore draw data. */ - object->drawdata = object_runtime_backup->drawdata; } ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, @@ -812,6 +808,8 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, */ ListBase gpumaterial_backup; ListBase *gpumaterial_ptr = NULL; + DrawDataList drawdata_backup; + DrawDataList *drawdata_ptr = NULL; ObjectRuntimeBackup object_runtime_backup = {NULL}; if (check_datablock_expanded(id_cow)) { switch (id_type) { @@ -847,9 +845,11 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, break; } case ID_OB: - deg_backup_object_runtime((Object *)id_cow, - &object_runtime_backup); + { + Object *ob = (Object *)id_cow; + deg_backup_object_runtime(ob, &object_runtime_backup); break; + } default: break; } @@ -857,6 +857,11 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, gpumaterial_backup = *gpumaterial_ptr; gpumaterial_ptr->first = gpumaterial_ptr->last = NULL; } + drawdata_ptr = DRW_drawdatalist_from_id(id_cow); + if (drawdata_ptr != NULL) { + drawdata_backup = *drawdata_ptr; + drawdata_ptr->first = drawdata_ptr->last = NULL; + } } deg_free_copy_on_write_datablock(id_cow); deg_expand_copy_on_write_datablock(depsgraph, id_node); @@ -864,6 +869,10 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, if (gpumaterial_ptr != NULL) { *gpumaterial_ptr = gpumaterial_backup; } + /* Restore DrawData. */ + if (drawdata_ptr != NULL) { + *drawdata_ptr = drawdata_backup; + } if (id_type == ID_OB) { deg_restore_object_runtime((Object *)id_cow, &object_runtime_backup); } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index bd31931d0a9..16cb1b394f6 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -46,6 +46,8 @@ extern "C" { #include "DNA_object_types.h" + +#include "DRW_engine.h" } /* extern "C" */ #include "DEG_depsgraph.h" @@ -219,12 +221,12 @@ BLI_INLINE OperationDepsNode *flush_schedule_children( void flush_engine_data_update(ID *id) { - if (GS(id->name) != ID_OB) { + DrawDataList *drawdata = DRW_drawdatalist_from_id(id); + if (drawdata == NULL) { return; } - Object *object = (Object *)id; - LISTBASE_FOREACH(ObjectEngineData *, engine_data, &object->drawdata) { - engine_data->recalc |= id->recalc; + LISTBASE_FOREACH(DrawData *, dd, drawdata) { + dd->recalc |= id->recalc; } } diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index d126dcb71aa..d2a3bab9b20 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -138,4 +138,7 @@ void DRW_opengl_context_disable(void); void DRW_deferred_shader_remove(struct GPUMaterial *mat); +struct DrawDataList *DRW_drawdatalist_from_id(struct ID *id); +void DRW_drawdata_free(struct ID *id); + #endif /* __DRW_ENGINE_H__ */ diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c index e9883cc3054..bf039871d52 100644 --- a/source/blender/draw/engines/eevee/eevee_data.c +++ b/source/blender/draw/engines/eevee/eevee_data.c @@ -91,9 +91,9 @@ EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure(void) /* Object data. */ -static void eevee_object_data_init(ObjectEngineData *engine_data) +static void eevee_object_data_init(DrawData *dd) { - EEVEE_ObjectEngineData *eevee_data = (EEVEE_ObjectEngineData *)engine_data; + EEVEE_ObjectEngineData *eevee_data = (EEVEE_ObjectEngineData *)dd; eevee_data->shadow_caster_id = -1; } @@ -102,15 +102,15 @@ EEVEE_ObjectEngineData *EEVEE_object_data_get(Object *ob) if (ELEM(ob->type, OB_LIGHTPROBE, OB_LAMP)) { return NULL; } - return (EEVEE_ObjectEngineData *)DRW_object_engine_data_get( - ob, &draw_engine_eevee_type); + return (EEVEE_ObjectEngineData *)DRW_drawdata_get( + &ob->id, &draw_engine_eevee_type); } EEVEE_ObjectEngineData *EEVEE_object_data_ensure(Object *ob) { BLI_assert(!ELEM(ob->type, OB_LIGHTPROBE, OB_LAMP)); - return (EEVEE_ObjectEngineData *)DRW_object_engine_data_ensure( - ob, + return (EEVEE_ObjectEngineData *)DRW_drawdata_ensure( + &ob->id, &draw_engine_eevee_type, sizeof(EEVEE_ObjectEngineData), eevee_object_data_init, @@ -119,18 +119,10 @@ EEVEE_ObjectEngineData *EEVEE_object_data_ensure(Object *ob) /* Light probe data. */ -static void eevee_lightprobe_data_init(ObjectEngineData *engine_data) +static void eevee_lightprobe_data_init(DrawData *dd) { - EEVEE_LightProbeEngineData *ped = (EEVEE_LightProbeEngineData *)engine_data; - ped->need_full_update = true; - ped->need_update = true; -} - -static void eevee_lightprobe_data_free(ObjectEngineData *engine_data) -{ - EEVEE_LightProbeEngineData *ped = (EEVEE_LightProbeEngineData *)engine_data; - - BLI_freelistN(&ped->captured_object_list); + EEVEE_LightProbeEngineData *ped = (EEVEE_LightProbeEngineData *)dd; + ped->need_update = false; } EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob) @@ -138,26 +130,26 @@ EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob) if (ob->type != OB_LIGHTPROBE) { return NULL; } - return (EEVEE_LightProbeEngineData *)DRW_object_engine_data_get( - ob, &draw_engine_eevee_type); + return (EEVEE_LightProbeEngineData *)DRW_drawdata_get( + &ob->id, &draw_engine_eevee_type); } EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_ensure(Object *ob) { BLI_assert(ob->type == OB_LIGHTPROBE); - return (EEVEE_LightProbeEngineData *)DRW_object_engine_data_ensure( - ob, + return (EEVEE_LightProbeEngineData *)DRW_drawdata_ensure( + &ob->id, &draw_engine_eevee_type, sizeof(EEVEE_LightProbeEngineData), eevee_lightprobe_data_init, - eevee_lightprobe_data_free); + NULL); } /* Lamp data. */ -static void eevee_lamp_data_init(ObjectEngineData *engine_data) +static void eevee_lamp_data_init(DrawData *dd) { - EEVEE_LampEngineData *led = (EEVEE_LampEngineData *)engine_data; + EEVEE_LampEngineData *led = (EEVEE_LampEngineData *)dd; led->need_update = true; led->prev_cube_shadow_id = -1; } @@ -167,17 +159,41 @@ EEVEE_LampEngineData *EEVEE_lamp_data_get(Object *ob) if (ob->type != OB_LAMP) { return NULL; } - return (EEVEE_LampEngineData *)DRW_object_engine_data_get( - ob, &draw_engine_eevee_type); + return (EEVEE_LampEngineData *)DRW_drawdata_get( + &ob->id, &draw_engine_eevee_type); } EEVEE_LampEngineData *EEVEE_lamp_data_ensure(Object *ob) { BLI_assert(ob->type == OB_LAMP); - return (EEVEE_LampEngineData *)DRW_object_engine_data_ensure( - ob, + return (EEVEE_LampEngineData *)DRW_drawdata_ensure( + &ob->id, &draw_engine_eevee_type, sizeof(EEVEE_LampEngineData), eevee_lamp_data_init, NULL); } + +/* World data. */ + +static void eevee_world_data_init(DrawData *dd) +{ + EEVEE_WorldEngineData *wed = (EEVEE_WorldEngineData *)dd; + wed->dd.recalc |= 1; +} + +EEVEE_WorldEngineData *EEVEE_world_data_get(World *wo) +{ + return (EEVEE_WorldEngineData *)DRW_drawdata_get( + &wo->id, &draw_engine_eevee_type); +} + +EEVEE_WorldEngineData *EEVEE_world_data_ensure(World *wo) +{ + return (EEVEE_WorldEngineData *)DRW_drawdata_ensure( + &wo->id, + &draw_engine_eevee_type, + sizeof(EEVEE_WorldEngineData), + eevee_world_data_init, + NULL); +} diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 99adc21bf56..70af3b4067c 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -365,21 +365,31 @@ static void eevee_view_update(void *vedata) static void eevee_id_object_update(void *UNUSED(vedata), Object *object) { - /* This is a bit mask of components which update is to be ignored. */ EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(object); - if (ped != NULL && ped->engine_data.recalc != 0) { + if (ped != NULL && ped->dd.recalc != 0) { ped->need_full_update = true; - ped->engine_data.recalc = 0; + ped->dd.recalc = 0; } EEVEE_LampEngineData *led = EEVEE_lamp_data_get(object); - if (led != NULL && led->engine_data.recalc != 0) { + if (led != NULL && led->dd.recalc != 0) { led->need_update = true; - led->engine_data.recalc = 0; + led->dd.recalc = 0; } EEVEE_ObjectEngineData *oedata = EEVEE_object_data_get(object); - if (oedata != NULL && oedata->engine_data.recalc != 0) { + if (oedata != NULL && oedata->dd.recalc != 0) { oedata->need_update = true; - oedata->engine_data.recalc = 0; + oedata->dd.recalc = 0; + } +} + +static void eevee_id_world_update(void *vedata, World *wo) +{ + EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; + + EEVEE_WorldEngineData *wedata = EEVEE_world_data_ensure(wo); + + if (wedata != NULL && wedata->dd.recalc != 0) { + wedata->dd.recalc = 0; } } @@ -387,6 +397,9 @@ static void eevee_id_update(void *vedata, ID *id) { /* Handle updates based on ID type. */ switch (GS(id->name)) { + case ID_WO: + eevee_id_world_update(vedata, (World *)id); + break; case ID_OB: eevee_id_object_update(vedata, (Object *)id); break; diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index c4cf56483fa..95b015cb044 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -451,13 +451,12 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat } } - if (wo->update_flag != 0 || pinfo->prev_world != wo || pinfo->prev_wo_sh_compiled != wo_sh_compiled) { + if (pinfo->prev_world != wo || pinfo->prev_wo_sh_compiled != wo_sh_compiled) { pinfo->update_world |= PROBE_UPDATE_ALL; pinfo->studiolight_index = 0; pinfo->prev_wo_sh_compiled = wo_sh_compiled; pinfo->prev_world = wo; } - wo->update_flag = 0; } else if (pinfo->prev_world) { pinfo->update_world |= PROBE_UPDATE_ALL; diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index ef1d03c244e..fe837baf20e 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -711,7 +711,7 @@ typedef struct EEVEE_ShadowCascadeData { * It works with even if the object is in multiple layers * because we don't get the same "Object *" for each layer. */ typedef struct EEVEE_LampEngineData { - ObjectEngineData engine_data; + DrawData dd; bool need_update; /* This needs to be out of the union to avoid undefined behaviour. */ @@ -724,7 +724,7 @@ typedef struct EEVEE_LampEngineData { } EEVEE_LampEngineData; typedef struct EEVEE_LightProbeEngineData { - ObjectEngineData engine_data; + DrawData dd; /* NOTE: need_full_update is set by dependency graph when the probe or it's * object is updated. This triggers full probe update, including it's @@ -752,7 +752,7 @@ typedef struct EEVEE_LightProbeEngineData { } EEVEE_LightProbeEngineData; typedef struct EEVEE_ObjectEngineData { - ObjectEngineData engine_data; + DrawData dd; Object *ob; /* self reference */ EEVEE_LightProbeVisTest *test_data; @@ -762,6 +762,10 @@ typedef struct EEVEE_ObjectEngineData { uint shadow_caster_id; } EEVEE_ObjectEngineData; +typedef struct EEVEE_WorldEngineData { + DrawData dd; +} EEVEE_WorldEngineData; + /* *********************************** */ typedef struct EEVEE_Data { @@ -810,6 +814,8 @@ EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob); EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_ensure(Object *ob); EEVEE_LampEngineData *EEVEE_lamp_data_get(Object *ob); EEVEE_LampEngineData *EEVEE_lamp_data_ensure(Object *ob); +EEVEE_WorldEngineData *EEVEE_world_data_get(World *wo); +EEVEE_WorldEngineData *EEVEE_world_data_ensure(World *wo); /* eevee_materials.c */ struct GPUTexture *EEVEE_materials_get_util_tex(void); /* XXX */ diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index d153728a000..784ed861014 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -258,9 +258,9 @@ static struct GPUTexture *create_jitter_texture(int num_samples) /* Functions */ -static void workbench_init_object_data(ObjectEngineData *engine_data) +static void workbench_init_object_data(DrawData *dd) { - WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)engine_data; + WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)dd; data->object_id = ((e_data.next_object_id++) & 0xff) + 1; data->shadow_bbox_dirty = true; } @@ -561,8 +561,8 @@ static WORKBENCH_MaterialData *get_or_create_material_data( WORKBENCH_PassList *psl = vedata->psl; WORKBENCH_PrivateData *wpd = stl->g_data; WORKBENCH_MaterialData *material; - WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_object_engine_data_ensure( - ob, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL); + WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_drawdata_ensure( + &ob->id, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL); WORKBENCH_MaterialData material_template; /* Solid */ @@ -731,8 +731,8 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) // DRW_shgroup_call_sculpt_add(wpd->shadow_shgrp, ob, ob->obmat); } else { - WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_object_engine_data_ensure( - ob, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL); + WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_drawdata_ensure( + &ob->id, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL); if (studiolight_object_cast_visible_shadow(wpd, ob, engine_object_data)) { diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 24ba3aa8981..e921b2ac2f7 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -126,9 +126,9 @@ static char *workbench_build_forward_composite_frag(void) return str; } -static void workbench_init_object_data(ObjectEngineData *engine_data) +static void workbench_init_object_data(DrawData *dd) { - WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)engine_data; + WORKBENCH_ObjectData *data = (WORKBENCH_ObjectData *)dd; data->object_id = ((e_data.next_object_id++) & 0xff) + 1; } @@ -139,8 +139,8 @@ static WORKBENCH_MaterialData *get_or_create_material_data( WORKBENCH_PassList *psl = vedata->psl; WORKBENCH_PrivateData *wpd = stl->g_data; WORKBENCH_MaterialData *material; - WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_object_engine_data_ensure( - ob, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL); + WORKBENCH_ObjectData *engine_object_data = (WORKBENCH_ObjectData *)DRW_drawdata_ensure( + &ob->id, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL); WORKBENCH_MaterialData material_template; DRWShadingGroup *grp; diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index a8fa1beb3b7..4210e03f470 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -201,12 +201,8 @@ typedef struct WORKBENCH_MaterialData { } WORKBENCH_MaterialData; typedef struct WORKBENCH_ObjectData { - struct ObjectEngineData *next, *prev; - struct DrawEngineType *engine_type; - /* Only nested data, NOT the engine data itself. */ - ObjectEngineDataFreeCb free; - /* Accumulated recalc flags, which corresponds to ID->recalc flags. */ - int recalc; + DrawData dd; + /* Shadow direction in local object space. */ float shadow_dir[3], shadow_depth; float shadow_min[3], shadow_max[3]; /* Min, max in shadow space */ diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index f732082018d..e0c8cb36e2f 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -44,6 +44,7 @@ #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_scene_types.h" +#include "DNA_world_types.h" #include "GPU_framebuffer.h" #include "GPU_texture.h" @@ -460,16 +461,14 @@ void **DRW_view_layer_engine_data_ensure_ex( void **DRW_view_layer_engine_data_ensure( DrawEngineType *engine_type, void (*callback)(void *storage)); -/* Objects */ -ObjectEngineData *DRW_object_engine_data_get(Object *ob, DrawEngineType *engine_type); -ObjectEngineData *DRW_object_engine_data_ensure( - Object *ob, +/* DrawData */ +DrawData *DRW_drawdata_get(ID *ib, DrawEngineType *engine_type); +DrawData *DRW_drawdata_ensure( + ID *id, DrawEngineType *engine_type, size_t size, - ObjectEngineDataInitCb init_cb, - ObjectEngineDataFreeCb free_cb); -struct LampEngineData *DRW_lamp_engine_data_ensure(Object *ob, struct RenderEngineType *engine_type); -void DRW_lamp_engine_data_free(struct LampEngineData *led); + DrawDataInitCb init_cb, + DrawDataFreeCb free_cb); /* Settings */ bool DRW_object_is_renderable(struct Object *ob); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index a1e44e479d4..311a223dcdd 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -44,6 +44,7 @@ #include "DNA_camera_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_world_types.h" #include "ED_space_api.h" #include "ED_screen.h" @@ -696,34 +697,96 @@ void **DRW_view_layer_engine_data_ensure(DrawEngineType *engine_type, void (*cal /* -------------------------------------------------------------------- */ -/** \name Objects (DRW_object) +/** \name Draw Data (DRW_drawdata) * \{ */ -ObjectEngineData *DRW_object_engine_data_get(Object *ob, DrawEngineType *engine_type) +/* Used for DRW_drawdata_from_id() + * All ID-datablocks which have their own 'local' DrawData + * should have the same arrangement in their structs. + */ +typedef struct IdDdtTemplate { + ID id; + struct AnimData *adt; + DrawDataList drawdata; +} IdDdtTemplate; + +/* Check if ID can have AnimData */ +static bool id_type_can_have_drawdata(const short id_type) +{ + /* Only some ID-blocks have this info for now */ + /* TODO: finish adding this for the other blocktypes */ + switch (id_type) { + /* has DrawData */ + case ID_OB: + case ID_WO: + return true; + + /* no DrawData */ + default: + return false; + } +} + +static bool id_can_have_drawdata(const ID *id) +{ + /* sanity check */ + if (id == NULL) + return false; + + return id_type_can_have_drawdata(GS(id->name)); +} + +/* Get DrawData from the given ID-block. In order for this to work, we assume that + * the DrawData pointer is stored in the struct in the same fashion as in IdDdtTemplate. + */ +DrawDataList *DRW_drawdatalist_from_id(ID *id) +{ + /* only some ID-blocks have this info for now, so we cast the + * types that do to be of type IdDdtTemplate, and extract the + * DrawData that way + */ + if (id_can_have_drawdata(id)) { + IdDdtTemplate *idt = (IdDdtTemplate *)id; + return &idt->drawdata; + } + else + return NULL; +} + +DrawData *DRW_drawdata_get(ID *id, DrawEngineType *engine_type) { - for (ObjectEngineData *oed = ob->drawdata.first; oed; oed = oed->next) { - if (oed->engine_type == engine_type) { - return oed; + DrawDataList *drawdata = DRW_drawdatalist_from_id(id); + + if (drawdata == NULL) + return NULL; + + LISTBASE_FOREACH(DrawData *, dd, drawdata) { + if (dd->engine_type == engine_type) { + return dd; } } return NULL; } -ObjectEngineData *DRW_object_engine_data_ensure( - Object *ob, +DrawData *DRW_drawdata_ensure( + ID *id, DrawEngineType *engine_type, size_t size, - ObjectEngineDataInitCb init_cb, - ObjectEngineDataFreeCb free_cb) + DrawDataInitCb init_cb, + DrawDataFreeCb free_cb) { - BLI_assert(size >= sizeof(ObjectEngineData)); + BLI_assert(size >= sizeof(DrawData)); + BLI_assert(id_can_have_drawdata(id)); /* Try to re-use existing data. */ - ObjectEngineData *oed = DRW_object_engine_data_get(ob, engine_type); - if (oed != NULL) { - return oed; + DrawData *dd = DRW_drawdata_get(id, engine_type); + if (dd != NULL) { + return dd; } + + DrawDataList *drawdata = DRW_drawdatalist_from_id(id); + /* Allocate new data. */ - if ((ob->base_flag & BASE_FROMDUPLI) != 0) { + if ((GS(id->name) == ID_OB) && (((Object *)id)->base_flag & BASE_FROMDUPLI) != 0) { /* NOTE: data is not persistent in this case. It is reset each redraw. */ BLI_assert(free_cb == NULL); /* No callback allowed. */ /* Round to sizeof(float) for DRW_instance_data_request(). */ @@ -734,21 +797,37 @@ ObjectEngineData *DRW_object_engine_data_ensure( if (DST.object_instance_data[fsize] == NULL) { DST.object_instance_data[fsize] = DRW_instance_data_request(DST.idatalist, fsize); } - oed = (ObjectEngineData *)DRW_instance_data_next(DST.object_instance_data[fsize]); - memset(oed, 0, size); + dd = (DrawData *)DRW_instance_data_next(DST.object_instance_data[fsize]); + memset(dd, 0, size); } else { - oed = MEM_callocN(size, "ObjectEngineData"); + dd = MEM_callocN(size, "DrawData"); } - oed->engine_type = engine_type; - oed->free = free_cb; + dd->engine_type = engine_type; + dd->free = free_cb; /* Perform user-side initialization, if needed. */ if (init_cb != NULL) { - init_cb(oed); + init_cb(dd); } /* Register in the list. */ - BLI_addtail(&ob->drawdata, oed); - return oed; + BLI_addtail((ListBase *)drawdata, dd); + return dd; +} + +void DRW_drawdata_free(ID *id) +{ + DrawDataList *drawdata = DRW_drawdatalist_from_id(id); + + if (drawdata == NULL) + return; + + LISTBASE_FOREACH(DrawData *, dd, drawdata) { + if (dd->free != NULL) { + dd->free(dd); + } + } + + BLI_freelistN((ListBase *)drawdata); } /** \} */ @@ -794,6 +873,22 @@ static void drw_engines_cache_init(void) } } +static void drw_engines_world_update(Scene *scene) +{ + if (scene->world == NULL) { + return; + } + + for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + DrawEngineType *engine = link->data; + ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); + + if (engine->id_update) { + engine->id_update(data, &scene->world->id); + } + } +} + static void drw_engines_cache_populate(Object *ob) { DST.ob_state = NULL; @@ -1273,6 +1368,7 @@ void DRW_draw_render_loop_ex( { PROFILE_START(stime); drw_engines_cache_init(); + drw_engines_world_update(scene); const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) @@ -1697,6 +1793,7 @@ void DRW_draw_select_loop( { drw_engines_cache_init(); + drw_engines_world_update(scene); if (use_obedit) { #if 0 @@ -1891,6 +1988,7 @@ void DRW_draw_depth_loop( { drw_engines_cache_init(); + drw_engines_world_update(scene); const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index da44d9d8c0b..359b4eb77e4 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1355,14 +1355,14 @@ static void DRW_shgroup_lamp(OBJECT_StorageList *stl, Object *ob, ViewLayer *vie static float zero = 0.0f; typedef struct LampEngineData { - ObjectEngineData engine_data; + DrawData dd; float shape_mat[4][4]; float spot_blend_mat[4][4]; } LampEngineData; LampEngineData *lamp_engine_data = - (LampEngineData *)DRW_object_engine_data_ensure( - ob, + (LampEngineData *)DRW_drawdata_ensure( + &ob->id, &draw_engine_object_type, sizeof(LampEngineData), NULL, @@ -1712,7 +1712,7 @@ static void DRW_shgroup_speaker(OBJECT_StorageList *stl, Object *ob, ViewLayer * } typedef struct OBJECT_LightProbeEngineData { - ObjectEngineData engine_data; + DrawData dd; float prb_mats[6][4][4]; float probe_cube_mat[4][4]; @@ -1733,8 +1733,8 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color); OBJECT_LightProbeEngineData *prb_data = - (OBJECT_LightProbeEngineData *)DRW_object_engine_data_ensure( - ob, + (OBJECT_LightProbeEngineData *)DRW_drawdata_ensure( + &ob->id, &draw_engine_object_type, sizeof(OBJECT_LightProbeEngineData), NULL, diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 97fd7295a7b..e473b98b4a1 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -294,9 +294,6 @@ static void world_changed(Main *UNUSED(bmain), World *wo) /* icons */ BKE_icon_changed(BKE_icon_id_ensure(&wo->id)); - /* XXX temporary flag waiting for depsgraph proper tagging */ - wo->update_flag = 1; - /* glsl */ if (wo->id.recalc & ID_RECALC) { if (!BLI_listbase_is_empty(&defmaterial.gpumaterial)) { diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index fa97fd53f32..ec71f28cb23 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -45,6 +45,27 @@ struct ID; struct PackedFile; struct GPUTexture; +/* Runtime display data */ +struct DrawData; +typedef void (*DrawDataInitCb)(struct DrawData *engine_data); +typedef void (*DrawDataFreeCb)(struct DrawData *engine_data); + +# +# +typedef struct DrawData { + struct DrawData *next, *prev; + struct DrawEngineType *engine_type; + /* Only nested data, NOT the engine data itself. */ + DrawDataFreeCb free; + /* Accumulated recalc flags, which corresponds to ID->recalc flags. */ + int recalc; +} DrawData; + +typedef struct DrawDataList { + struct DrawData *first, *last; +} DrawDataList; + + typedef struct IDPropertyData { void *pointer; ListBase group; diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 3bcc0fb6dcc..999ebe0ccc3 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -76,22 +76,6 @@ typedef struct bFaceMap { char pad[7]; } bFaceMap; -/* Object Runtime display data */ -struct ObjectEngineData; -typedef void (*ObjectEngineDataInitCb)(struct ObjectEngineData *engine_data); -typedef void (*ObjectEngineDataFreeCb)(struct ObjectEngineData *engine_data); - -# -# -typedef struct ObjectEngineData { - struct ObjectEngineData *next, *prev; - struct DrawEngineType *engine_type; - /* Only nested data, NOT the engine data itself. */ - ObjectEngineDataFreeCb free; - /* Accumulated recalc flags, which corresponds to ID->recalc flags. */ - int recalc; -} ObjectEngineData; - #define MAX_VGROUP_NAME 64 /* bDeformGroup->flag */ @@ -163,6 +147,7 @@ typedef struct Object_Runtime { typedef struct Object { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ + struct DrawDataList drawdata; /* runtime (must be immediately after id for utilities to use it). */ struct SculptSession *sculpt; @@ -312,7 +297,6 @@ typedef struct Object { struct PreviewImage *preview; - ListBase drawdata; /* runtime, ObjectEngineData */ int pad6; int select_color; diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index 2e38a402abb..7769833a835 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -51,6 +51,7 @@ struct MTex; typedef struct World { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ + DrawDataList drawdata; /* runtime (must be immediately after id for utilities to use it). */ char _pad0[4]; short texact, mistype; @@ -81,8 +82,7 @@ typedef struct World { short flag, pad3[3]; struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */ - short pr_texture, use_nodes, pad; - short update_flag; /* XXX temporary flag waiting for depsgraph proper tagging */ + short pr_texture, use_nodes, pad[2]; /* previews */ struct PreviewImage *preview; -- cgit v1.2.3 From c90a0d5dda535a42697503e130b0c2fc123fe491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 10 Jul 2018 14:40:28 +0200 Subject: DRW: Add new features from lightcache branch - Change gl_context_mutex to a ticket mutex ensuring interactivity even when rendering. - Add DRW_custom_pipeline for using DRW outside of the viewport and render pipeline. - DRW_opengl_render_context_*** and DRW_gawain_render_context_*** to use with DRW_custom_pipeline. - Add possibility to bypass deferred compilation on demand (not User demand). - Add union to access DRWMatrixState members more easily. --- source/blender/draw/DRW_engine.h | 5 + .../blender/draw/engines/eevee/eevee_materials.c | 29 +++--- source/blender/draw/intern/DRW_render.h | 28 ++++- source/blender/draw/intern/draw_manager.c | 115 +++++++++++++++++---- source/blender/draw/intern/draw_manager.h | 2 +- source/blender/draw/intern/draw_manager_shader.c | 20 ++-- 6 files changed, 150 insertions(+), 49 deletions(-) diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index d2a3bab9b20..ab2001dcb6a 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -136,6 +136,11 @@ void DRW_opengl_context_destroy(void); void DRW_opengl_context_enable(void); void DRW_opengl_context_disable(void); +void DRW_opengl_render_context_enable(void *re_gl_context); +void DRW_opengl_render_context_disable(void *re_gl_context); +void DRW_gawain_render_context_enable(void *re_gwn_context); +void DRW_gawain_render_context_disable(void *re_gwn_context); + void DRW_deferred_shader_remove(struct GPUMaterial *mat); struct DrawDataList *DRW_drawdatalist_from_id(struct ID *id); diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 4161d11e0c1..4a7e97756a9 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -654,14 +654,14 @@ struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, Wor const void *engine = &DRW_engine_viewport_eevee_type; const int options = VAR_WORLD_PROBE; - GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options); + GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options, false); if (mat != NULL) { return mat; } return DRW_shader_create_from_world( scene, wo, engine, options, datatoc_background_vert_glsl, NULL, e_data.frag_shader_lib, - SHADER_DEFINES "#define PROBE_CAPTURE\n"); + SHADER_DEFINES "#define PROBE_CAPTURE\n", false); } struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, World *wo) @@ -669,14 +669,14 @@ struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, Wor const void *engine = &DRW_engine_viewport_eevee_type; int options = VAR_WORLD_BACKGROUND; - GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options); + GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options, true); if (mat != NULL) { return mat; } return DRW_shader_create_from_world( scene, wo, engine, options, datatoc_background_vert_glsl, NULL, e_data.frag_shader_lib, - SHADER_DEFINES "#define WORLD_BACKGROUND\n"); + SHADER_DEFINES "#define WORLD_BACKGROUND\n", true); } struct GPUMaterial *EEVEE_material_world_volume_get(struct Scene *scene, World *wo) @@ -684,7 +684,7 @@ struct GPUMaterial *EEVEE_material_world_volume_get(struct Scene *scene, World * const void *engine = &DRW_engine_viewport_eevee_type; int options = VAR_WORLD_VOLUME; - GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options); + GPUMaterial *mat = DRW_shader_find_from_world(wo, engine, options, true); if (mat != NULL) { return mat; } @@ -694,7 +694,7 @@ struct GPUMaterial *EEVEE_material_world_volume_get(struct Scene *scene, World * mat = DRW_shader_create_from_world( scene, wo, engine, options, datatoc_volumetric_vert_glsl, datatoc_volumetric_geom_glsl, e_data.volume_shader_lib, - defines); + defines, true); MEM_freeN(defines); @@ -719,7 +719,7 @@ struct GPUMaterial *EEVEE_material_mesh_get( options |= eevee_material_shadow_option(shadow_method); - GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options); + GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true); if (mat) { return mat; } @@ -729,7 +729,7 @@ struct GPUMaterial *EEVEE_material_mesh_get( mat = DRW_shader_create_from_material( scene, ma, engine, options, e_data.vert_shader_str, NULL, e_data.frag_shader_lib, - defines); + defines, true); MEM_freeN(defines); @@ -741,7 +741,7 @@ struct GPUMaterial *EEVEE_material_mesh_volume_get(struct Scene *scene, Material const void *engine = &DRW_engine_viewport_eevee_type; int options = VAR_MAT_VOLUME; - GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options); + GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true); if (mat != NULL) { return mat; } @@ -751,7 +751,7 @@ struct GPUMaterial *EEVEE_material_mesh_volume_get(struct Scene *scene, Material mat = DRW_shader_create_from_material( scene, ma, engine, options, datatoc_volumetric_vert_glsl, datatoc_volumetric_geom_glsl, e_data.volume_shader_lib, - defines); + defines, true); MEM_freeN(defines); @@ -775,7 +775,7 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get( if (is_shadow) options |= VAR_MAT_SHADOW; - GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options); + GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true); if (mat) { return mat; } @@ -791,7 +791,8 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get( (is_shadow) ? datatoc_shadow_vert_glsl : e_data.vert_shader_str, NULL, frag_str, - defines); + defines, + true); MEM_freeN(frag_str); MEM_freeN(defines); @@ -807,7 +808,7 @@ struct GPUMaterial *EEVEE_material_hair_get( options |= eevee_material_shadow_option(shadow_method); - GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options); + GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true); if (mat) { return mat; } @@ -817,7 +818,7 @@ struct GPUMaterial *EEVEE_material_hair_get( mat = DRW_shader_create_from_material( scene, ma, engine, options, e_data.vert_shader_str, NULL, e_data.frag_shader_lib, - defines); + defines, true); MEM_freeN(defines); diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index e0c8cb36e2f..4d1b8269494 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -240,14 +240,14 @@ struct GPUShader *DRW_shader_create_2D(const char *frag, const char *defines); struct GPUShader *DRW_shader_create_3D(const char *frag, const char *defines); struct GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines); struct GPUShader *DRW_shader_create_3D_depth_only(void); -struct GPUMaterial *DRW_shader_find_from_world(struct World *wo, const void *engine_type, int options); -struct GPUMaterial *DRW_shader_find_from_material(struct Material *ma, const void *engine_type, int options); +struct GPUMaterial *DRW_shader_find_from_world(struct World *wo, const void *engine_type, int options, bool no_deferred); +struct GPUMaterial *DRW_shader_find_from_material(struct Material *ma, const void *engine_type, int options, bool no_deferred); struct GPUMaterial *DRW_shader_create_from_world( struct Scene *scene, struct World *wo, const void *engine_type, int options, - const char *vert, const char *geom, const char *frag_lib, const char *defines); + const char *vert, const char *geom, const char *frag_lib, const char *defines, bool no_deferred); struct GPUMaterial *DRW_shader_create_from_material( struct Scene *scene, struct Material *ma, const void *engine_type, int options, - const char *vert, const char *geom, const char *frag_lib, const char *defines); + const char *vert, const char *geom, const char *frag_lib, const char *defines, bool no_deferred); void DRW_shader_free(struct GPUShader *shader); #define DRW_SHADER_FREE_SAFE(shader) do { \ if (shader != NULL) { \ @@ -410,6 +410,7 @@ void DRW_pass_sort_shgroup_z(DRWPass *pass); /* Viewport */ typedef enum { + /* keep in sync with the union struct DRWMatrixState. */ DRW_MAT_PERS = 0, DRW_MAT_PERSINV, DRW_MAT_VIEW, @@ -421,7 +422,18 @@ typedef enum { } DRWViewportMatrixType; typedef struct DRWMatrixState { - float mat[DRW_MAT_COUNT][4][4]; + union { + float mat[DRW_MAT_COUNT][4][4]; + struct { + /* keep in sync with the enum DRWViewportMatrixType. */ + float persmat[4][4]; + float persinv[4][4]; + float viewmat[4][4]; + float viewinv[4][4]; + float winmat[4][4]; + float wininv[4][4]; + }; + }; } DRWMatrixState; void DRW_viewport_init(const bContext *C); @@ -454,6 +466,12 @@ void DRW_render_object_iter( void (*callback)(void *vedata, struct Object *ob, struct RenderEngine *engine, struct Depsgraph *depsgraph)); void DRW_render_instance_buffer_finish(void); +void DRW_custom_pipeline( + DrawEngineType *draw_engine_type, + struct Depsgraph *depsgraph, + void (*callback)(void *vedata, void *user_data), + void *user_data); + /* ViewLayers */ void *DRW_view_layer_engine_data_get(DrawEngineType *engine_type); void **DRW_view_layer_engine_data_ensure_ex( diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 311a223dcdd..30f7742fd35 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1256,7 +1256,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx) /* XXX Really nasty locking. But else this could * be executed by the material previews thread * while rendering a viewport. */ - BLI_mutex_lock(&DST.gl_context_mutex); + BLI_ticket_mutex_lock(DST.gl_context_mutex); /* Reset before using it. */ drw_state_prepare_clean_for_draw(&DST); @@ -1284,7 +1284,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx) drw_engines_disable(); - BLI_mutex_unlock(&DST.gl_context_mutex); + BLI_ticket_mutex_unlock(DST.gl_context_mutex); } } @@ -1554,14 +1554,10 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) /* Changing Context */ if (re_gl_context != NULL) { - /* TODO get rid of the blocking. Only here because of the static global DST. */ - BLI_mutex_lock(&DST.gl_context_mutex); - WM_opengl_context_activate(re_gl_context); + DRW_opengl_render_context_enable(re_gl_context); + /* We need to query gwn context after a gl context has been bound. */ re_gwn_context = RE_gwn_context_get(render); - if (GWN_context_active_get() == NULL) { - GWN_context_active_set(re_gwn_context); - } - DRW_shape_cache_reset(); /* XXX fix that too. */ + DRW_gawain_render_context_enable(re_gwn_context); } else { DRW_opengl_context_enable(); @@ -1640,12 +1636,8 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) /* Changing Context */ if (re_gl_context != NULL) { - DRW_shape_cache_reset(); /* XXX fix that too. */ - glFlush(); - GWN_context_active_set(NULL); - WM_opengl_context_release(re_gl_context); - /* TODO get rid of the blocking. */ - BLI_mutex_unlock(&DST.gl_context_mutex); + DRW_gawain_render_context_disable(re_gwn_context); + DRW_opengl_render_context_disable(re_gl_context); } else { DRW_opengl_context_disable(); @@ -1671,6 +1663,56 @@ void DRW_render_object_iter( DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END } +/* Assume a valid gl context is bound (and that the gl_context_mutex has been aquired). + * This function only setup DST and execute the given function. + * Warning: similar to DRW_render_to_image you cannot use default lists (dfbl & dtxl). */ +void DRW_custom_pipeline( + DrawEngineType *draw_engine_type, + struct Depsgraph *depsgraph, + void (*callback)(void *vedata, void *user_data), + void *user_data) +{ + Scene *scene = DEG_get_evaluated_scene(depsgraph); + ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); + + /* Reset before using it. */ + drw_state_prepare_clean_for_draw(&DST); + DST.options.is_image_render = true; + DST.options.is_scene_render = true; + DST.options.draw_background = false; + + DST.draw_ctx = (DRWContextState){ + .scene = scene, + .view_layer = view_layer, + .engine_type = NULL, + .depsgraph = depsgraph, + .object_mode = OB_MODE_OBJECT, + }; + drw_context_state_init(); + + DST.viewport = GPU_viewport_create(); + const int size[2] = {1, 1}; + GPU_viewport_size_set(DST.viewport, size); + + drw_viewport_var_init(); + + DRW_hair_init(); + + ViewportEngineData *data = drw_viewport_engine_data_ensure(draw_engine_type); + + /* Execute the callback */ + callback(data, user_data); + DST.buffer_finish_called = false; + + GPU_viewport_free(DST.viewport); + GPU_framebuffer_restore(); + +#ifdef DEBUG + /* Avoid accidental reuse. */ + drw_state_ensure_not_reused(&DST); +#endif +} + static struct DRWSelectBuffer { struct GPUFrameBuffer *framebuffer; struct GPUTexture *texture_depth; @@ -2280,7 +2322,7 @@ void DRW_opengl_context_create(void) { BLI_assert(DST.gl_context == NULL); /* Ensure it's called once */ - BLI_mutex_init(&DST.gl_context_mutex); + DST.gl_context_mutex = BLI_ticket_mutex_alloc(); if (!G.background) { immDeactivate(); } @@ -2305,7 +2347,7 @@ void DRW_opengl_context_destroy(void) GWN_context_active_set(DST.gwn_context); GWN_context_discard(DST.gwn_context); WM_opengl_context_dispose(DST.gl_context); - BLI_mutex_end(&DST.gl_context_mutex); + BLI_ticket_mutex_free(DST.gl_context_mutex); } } @@ -2315,7 +2357,7 @@ void DRW_opengl_context_enable(void) /* IMPORTANT: We dont support immediate mode in render mode! * This shall remain in effect until immediate mode supports * multiple threads. */ - BLI_mutex_lock(&DST.gl_context_mutex); + BLI_ticket_mutex_lock(DST.gl_context_mutex); if (BLI_thread_is_main()) { if (!G.background) { immDeactivate(); @@ -2349,8 +2391,43 @@ void DRW_opengl_context_disable(void) GWN_context_active_set(NULL); } - BLI_mutex_unlock(&DST.gl_context_mutex); + BLI_ticket_mutex_unlock(DST.gl_context_mutex); } } +void DRW_opengl_render_context_enable(void *re_gl_context) +{ + /* If thread is main you should use DRW_opengl_context_enable(). */ + BLI_assert(!BLI_thread_is_main()); + + /* TODO get rid of the blocking. Only here because of the static global DST. */ + BLI_ticket_mutex_lock(DST.gl_context_mutex); + WM_opengl_context_activate(re_gl_context); +} + +void DRW_opengl_render_context_disable(void *re_gl_context) +{ + glFlush(); + WM_opengl_context_release(re_gl_context); + /* TODO get rid of the blocking. */ + BLI_ticket_mutex_unlock(DST.gl_context_mutex); +} + +/* Needs to be called AFTER DRW_opengl_render_context_enable() */ +void DRW_gawain_render_context_enable(void *re_gwn_context) +{ + /* If thread is main you should use DRW_opengl_context_enable(). */ + BLI_assert(!BLI_thread_is_main()); + + GWN_context_active_set(re_gwn_context); + DRW_shape_cache_reset(); /* XXX fix that too. */ +} + +/* Needs to be called BEFORE DRW_opengl_render_context_disable() */ +void DRW_gawain_render_context_disable(void *UNUSED(re_gwn_context)) +{ + DRW_shape_cache_reset(); /* XXX fix that too. */ + GWN_context_active_set(NULL); +} + /** \} */ diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 91a30fa45ae..6eae3459c2b 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -373,7 +373,7 @@ typedef struct DRWManager { * the top portion of the struct so DO NOT MOVE IT! */ void *gl_context; /* Unique ghost context used by the draw manager. */ Gwn_Context *gwn_context; - ThreadMutex gl_context_mutex; /* Mutex to lock the drw manager and avoid concurent context usage. */ + TicketMutex *gl_context_mutex; /* Mutex to lock the drw manager and avoid concurent context usage. */ /** GPU Resource State: Memory storage between drawing. */ struct { diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index 435c6c77e59..b0aec4a7600 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -154,10 +154,10 @@ static void drw_deferred_shader_compilation_free(void *custom_data) MEM_freeN(comp); } -static void drw_deferred_shader_add(GPUMaterial *mat) +static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred) { /* Do not deferre the compilation if we are rendering for image. */ - if (DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION) { + if (DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION || !deferred) { /* Double checking that this GPUMaterial is not going to be * compiled by another thread. */ DRW_deferred_shader_remove(mat); @@ -308,10 +308,10 @@ GPUShader *DRW_shader_create_3D_depth_only(void) return GPU_shader_get_builtin_shader(GPU_SHADER_3D_DEPTH_ONLY); } -GPUMaterial *DRW_shader_find_from_world(World *wo, const void *engine_type, int options) +GPUMaterial *DRW_shader_find_from_world(World *wo, const void *engine_type, int options, bool deferred) { GPUMaterial *mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine_type, options); - if (DRW_state_is_image_render()) { + if (DRW_state_is_image_render() || !deferred) { if (mat != NULL && GPU_material_status(mat) == GPU_MAT_QUEUED) { /* XXX Hack : we return NULL so that the engine will call DRW_shader_create_from_XXX * with the shader code and we will resume the compilation from there. */ @@ -321,10 +321,10 @@ GPUMaterial *DRW_shader_find_from_world(World *wo, const void *engine_type, int return mat; } -GPUMaterial *DRW_shader_find_from_material(Material *ma, const void *engine_type, int options) +GPUMaterial *DRW_shader_find_from_material(Material *ma, const void *engine_type, int options, bool deferred) { GPUMaterial *mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine_type, options); - if (DRW_state_is_image_render()) { + if (DRW_state_is_image_render() || !deferred) { if (mat != NULL && GPU_material_status(mat) == GPU_MAT_QUEUED) { /* XXX Hack : we return NULL so that the engine will call DRW_shader_create_from_XXX * with the shader code and we will resume the compilation from there. */ @@ -336,7 +336,7 @@ GPUMaterial *DRW_shader_find_from_material(Material *ma, const void *engine_type GPUMaterial *DRW_shader_create_from_world( struct Scene *scene, World *wo, const void *engine_type, int options, - const char *vert, const char *geom, const char *frag_lib, const char *defines) + const char *vert, const char *geom, const char *frag_lib, const char *defines, bool deferred) { GPUMaterial *mat = NULL; if (DRW_state_is_image_render()) { @@ -350,7 +350,7 @@ GPUMaterial *DRW_shader_create_from_world( } if (GPU_material_status(mat) == GPU_MAT_QUEUED) { - drw_deferred_shader_add(mat); + drw_deferred_shader_add(mat, deferred); } return mat; @@ -358,7 +358,7 @@ GPUMaterial *DRW_shader_create_from_world( GPUMaterial *DRW_shader_create_from_material( struct Scene *scene, Material *ma, const void *engine_type, int options, - const char *vert, const char *geom, const char *frag_lib, const char *defines) + const char *vert, const char *geom, const char *frag_lib, const char *defines, bool deferred) { GPUMaterial *mat = NULL; if (DRW_state_is_image_render()) { @@ -372,7 +372,7 @@ GPUMaterial *DRW_shader_create_from_material( } if (GPU_material_status(mat) == GPU_MAT_QUEUED) { - drw_deferred_shader_add(mat); + drw_deferred_shader_add(mat, deferred); } return mat; -- cgit v1.2.3 From 97f90d48a02eef89949532b166f57ea178ee5a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 10 Jul 2018 14:46:36 +0200 Subject: Object Mode: Change Lightprobe display. --- source/blender/draw/modes/object_mode.c | 8 +++++--- .../draw/modes/shaders/object_lightprobe_grid_vert.glsl | 13 ++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 359b4eb77e4..2ac16906102 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -908,7 +908,7 @@ static void OBJECT_cache_init(void *vedata) } { - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_POINT; DRWPass *pass = psl->lightprobes = DRW_pass_create("Object Probe Pass", state); struct Gwn_Batch *sphere = DRW_cache_sphere_get(); struct Gwn_Batch *quad = DRW_cache_quad_get(); @@ -1785,8 +1785,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl DRW_shgroup_uniform_vec3(grp, "increment_y", prb_data->increment_y, 1); DRW_shgroup_uniform_vec3(grp, "increment_z", prb_data->increment_z, 1); DRW_shgroup_uniform_ivec3(grp, "grid_resolution", &prb->grid_resolution_x, 1); - DRW_shgroup_uniform_float(grp, "sphere_size", &prb->data_draw_size, 1); - DRW_shgroup_call_instances_add(grp, DRW_cache_sphere_get(), NULL, &prb_data->cell_count); + DRW_shgroup_call_procedural_points_add(grp, prb_data->cell_count, NULL); } else if (prb->type == LIGHTPROBE_TYPE_CUBE) { prb_data->draw_size = prb->data_draw_size * 0.1f; @@ -1794,6 +1793,9 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl copy_v3_v3(prb_data->probe_cube_mat[3], ob->obmat[3]); DRWShadingGroup *grp = shgroup_theme_id_to_probe_cube_outline_shgrp(stl, theme_id); + /* TODO remove or change the drawing of the cube probes. Theses line draws nothing on purpose + * to keep the call ids correct. */ + zero_m4(prb_data->probe_cube_mat); DRW_shgroup_call_dynamic_add(grp, call_id, &prb_data->draw_size, prb_data->probe_cube_mat); } else { diff --git a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl index d9616076dbf..bcdf5adca55 100644 --- a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl +++ b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl @@ -1,7 +1,4 @@ -in vec3 pos; -in vec3 nor; - uniform mat4 ViewProjectionMatrix; uniform float sphere_size; @@ -10,6 +7,7 @@ uniform vec3 corner; uniform vec3 increment_x; uniform vec3 increment_y; uniform vec3 increment_z; +uniform vec3 screen_vecs[2]; uniform int call_id; /* we don't want the builtin callId which would be 0. */ uniform int baseId; @@ -20,16 +18,17 @@ void main() { vec3 ls_cell_location; /* Keep in sync with update_irradiance_probe */ - ls_cell_location.z = float(gl_InstanceID % grid_resolution.z); - ls_cell_location.y = float((gl_InstanceID / grid_resolution.z) % grid_resolution.y); - ls_cell_location.x = float(gl_InstanceID / (grid_resolution.z * grid_resolution.y)); + ls_cell_location.z = float(gl_VertexID % grid_resolution.z); + ls_cell_location.y = float((gl_VertexID / grid_resolution.z) % grid_resolution.y); + ls_cell_location.x = float(gl_VertexID / (grid_resolution.z * grid_resolution.y)); vec3 ws_cell_location = corner + (increment_x * ls_cell_location.x + increment_y * ls_cell_location.y + increment_z * ls_cell_location.z); - gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0); + gl_Position = ViewProjectionMatrix * vec4(ws_cell_location, 1.0); + gl_PointSize = 2.0f; finalId = uint(baseId + call_id); } -- cgit v1.2.3 From 1a43e081873415754950766edaddad220adf67bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 10 Jul 2018 15:02:25 +0200 Subject: Eevee: LightCache: Initial Implementation This separate probe rendering from viewport rendering, making possible to run the baking in another thread (non blocking and faster). The baked lighting is saved in the blend file. Nothing needs to be recomputed on load. There is a few missing bits / bugs: - Cache cannot be saved to disk as a separate file, it is saved in the DNA for now making file larger and memory usage higher. - Auto update only cubemaps does update the grids (bug). - Probes cannot be updated individually (considered as dynamic). - Light Cache cannot be (re)generated during render. --- release/scripts/startup/bl_ui/properties_render.py | 34 + source/blender/blenkernel/intern/scene.c | 15 + source/blender/blenloader/CMakeLists.txt | 1 + source/blender/blenloader/intern/readblenentry.c | 6 + source/blender/blenloader/intern/readfile.c | 96 +- source/blender/blenloader/intern/readfile.h | 3 + source/blender/blenloader/intern/versioning_280.c | 7 + source/blender/blenloader/intern/writefile.c | 36 + .../intern/eval/deg_eval_copy_on_write.cc | 18 + source/blender/draw/CMakeLists.txt | 2 + source/blender/draw/engines/eevee/eevee_data.c | 27 +- source/blender/draw/engines/eevee/eevee_engine.c | 16 +- .../blender/draw/engines/eevee/eevee_lightcache.c | 1141 ++++++++++++ .../blender/draw/engines/eevee/eevee_lightcache.h | 59 + .../blender/draw/engines/eevee/eevee_lightprobes.c | 1896 ++++++++------------ source/blender/draw/engines/eevee/eevee_lights.c | 2 +- source/blender/draw/engines/eevee/eevee_lookdev.c | 57 +- .../blender/draw/engines/eevee/eevee_materials.c | 10 +- source/blender/draw/engines/eevee/eevee_private.h | 152 +- source/blender/draw/engines/eevee/eevee_render.c | 34 +- .../draw/engines/eevee/eevee_screen_raytrace.c | 3 +- source/blender/draw/engines/eevee/eevee_volumes.c | 3 +- .../shaders/lightprobe_cube_display_frag.glsl | 17 +- .../shaders/lightprobe_cube_display_vert.glsl | 49 +- .../shaders/lightprobe_grid_display_frag.glsl | 14 +- .../shaders/lightprobe_grid_display_vert.glsl | 35 +- .../draw/engines/eevee/shaders/lightprobe_lib.glsl | 1 + .../engines/eevee/shaders/lit_surface_frag.glsl | 11 +- source/blender/editors/render/render_intern.h | 3 + source/blender/editors/render/render_ops.c | 3 + source/blender/editors/render/render_shading.c | 181 ++ source/blender/editors/space_view3d/space_view3d.c | 23 + source/blender/makesdna/DNA_lightprobe_types.h | 72 + source/blender/makesdna/DNA_scene_types.h | 9 + source/blender/makesrna/intern/rna_scene.c | 32 + source/blender/windowmanager/WM_api.h | 1 + source/blender/windowmanager/WM_types.h | 1 + 37 files changed, 2722 insertions(+), 1348 deletions(-) create mode 100644 source/blender/draw/engines/eevee/eevee_lightcache.c create mode 100644 source/blender/draw/engines/eevee/eevee_lightcache.h diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 580c31465b3..ff36d2494ea 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -712,15 +712,49 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel): def draw(self, context): layout = self.layout layout.use_property_split = True + layout.use_property_decorate = False # No animation. scene = context.scene props = scene.eevee col = layout.column() + col.operator("scene.light_cache_bake", text="Bake Indirect Lighting", icon='RENDER_STILL') + col.operator("scene.light_cache_bake", text="Bake Cubemap Only", icon='LIGHTPROBE_CUBEMAP').subset = "CUBEMAPS" + col.operator("scene.light_cache_free", text="Free Lighting Cache") + + cache_info = scene.eevee.gi_cache_info + if cache_info: + col.label(text=cache_info) + + col.prop(props, "gi_auto_bake") + col.prop(props, "gi_diffuse_bounces") col.prop(props, "gi_cubemap_resolution") col.prop(props, "gi_visibility_resolution", text="Diffuse Occlusion") + layout.use_property_split = False + row = layout.split(percentage=0.5) + row.alignment = 'RIGHT' + row.label("Cubemap Display") + + sub = row.row(align=True) + sub.prop(props, "gi_cubemap_draw_size", text="Size") + if props.gi_show_cubemaps : + sub.prop(props, "gi_show_cubemaps", text="", toggle=True, icon='HIDE_OFF') + else: + sub.prop(props, "gi_show_cubemaps", text="", toggle=True, icon='HIDE_ON') + + row = layout.split(percentage=0.5) + row.alignment = 'RIGHT' + row.label("Irradiance Display") + + sub = row.row(align=True) + sub.prop(props, "gi_irradiance_draw_size", text="Size") + if props.gi_show_irradiance : + sub.prop(props, "gi_show_irradiance", text="", toggle=True, icon='HIDE_OFF') + else: + sub.prop(props, "gi_show_irradiance", text="", toggle=True, icon='HIDE_ON') + class RENDER_PT_eevee_film(RenderButtonsPanel, Panel): bl_label = "Film" diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 1b309d76f61..2b2fc2fc767 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -102,6 +102,9 @@ #include "DEG_depsgraph_query.h" #include "RE_engine.h" +#include "RE_engine.h" + +#include "engines/eevee/eevee_lightcache.h" #include "PIL_time.h" @@ -316,6 +319,9 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons else { sce_dst->preview = NULL; } + + sce_dst->eevee.light_cache = NULL; + /* TODO Copy the cache. */ } Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) @@ -511,6 +517,11 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user) sce->master_collection = NULL; } + if (sce->eevee.light_cache) { + EEVEE_lightcache_free(sce->eevee.light_cache); + sce->eevee.light_cache = NULL; + } + /* These are freed on doversion. */ BLI_assert(sce->layer_properties == NULL); } @@ -814,6 +825,8 @@ void BKE_scene_init(Scene *sce) sce->eevee.gi_diffuse_bounces = 3; sce->eevee.gi_cubemap_resolution = 512; sce->eevee.gi_visibility_resolution = 32; + sce->eevee.gi_cubemap_draw_size = 0.3f; + sce->eevee.gi_irradiance_draw_size = 0.1f; sce->eevee.taa_samples = 16; sce->eevee.taa_render_samples = 64; @@ -856,6 +869,8 @@ void BKE_scene_init(Scene *sce) sce->eevee.shadow_cube_size = 512; sce->eevee.shadow_cascade_size = 1024; + sce->eevee.light_cache = NULL; + sce->eevee.flag = SCE_EEVEE_VOLUMETRIC_LIGHTS | SCE_EEVEE_VOLUMETRIC_COLORED | diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index b340aa28324..72fa155553d 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -30,6 +30,7 @@ set(INC ../blenlib ../blentranslation ../depsgraph + ../draw ../imbuf ../makesdna ../makesrna diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 7488d62bb3c..6fd77c34977 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -393,6 +393,9 @@ BlendFileData *BLO_read_from_memfile( /* makes lookup of existing images in old main */ blo_make_image_pointer_map(fd, oldmain); + /* makes lookup of existing light caches in old main */ + blo_make_scene_pointer_map(fd, oldmain); + /* makes lookup of existing video clips in old main */ blo_make_movieclip_pointer_map(fd, oldmain); @@ -403,6 +406,9 @@ BlendFileData *BLO_read_from_memfile( bfd = blo_read_file_internal(fd, filename); + /* ensures relinked light caches are not freed */ + blo_end_scene_pointer_map(fd, oldmain); + /* ensures relinked images are not freed */ blo_end_image_pointer_map(fd, oldmain); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3eb0626307b..db3c1894e8c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -158,6 +158,8 @@ #include "BKE_colortools.h" #include "BKE_workspace.h" +#include "DRW_engine.h" + #include "DEG_depsgraph.h" #include "NOD_common.h" @@ -1339,6 +1341,8 @@ void blo_freefiledata(FileData *fd) oldnewmap_free(fd->imamap); if (fd->movieclipmap) oldnewmap_free(fd->movieclipmap); + if (fd->scenemap) + oldnewmap_free(fd->scenemap); if (fd->soundmap) oldnewmap_free(fd->soundmap); if (fd->packedmap) @@ -1526,6 +1530,13 @@ static void *newimaadr(FileData *fd, const void *adr) /* used to restore im return NULL; } +static void *newsceadr(FileData *fd, const void *adr) /* used to restore scene data after undo */ +{ + if (fd->scenemap && adr) + return oldnewmap_lookup_and_inc(fd->scenemap, adr, true); + return NULL; +} + static void *newmclipadr(FileData *fd, const void *adr) /* used to restore movie clip data after undo */ { if (fd->movieclipmap && adr) @@ -1631,6 +1642,37 @@ void blo_clear_proxy_pointers_from_lib(Main *oldmain) } } +void blo_make_scene_pointer_map(FileData *fd, Main *oldmain) +{ + Scene *sce = oldmain->scene.first; + + fd->scenemap = oldnewmap_new(); + + for (; sce; sce = sce->id.next) { + if (sce->eevee.light_cache) { + struct LightCache *light_cache = sce->eevee.light_cache; + oldnewmap_insert(fd->scenemap, light_cache, light_cache, 0); + } + } +} + +void blo_end_scene_pointer_map(FileData *fd, Main *oldmain) +{ + OldNew *entry = fd->scenemap->entries; + Scene *sce = oldmain->scene.first; + int i; + + /* used entries were restored, so we put them to zero */ + for (i = 0; i < fd->scenemap->nentries; i++, entry++) { + if (entry->nr > 0) + entry->newp = NULL; + } + + for (; sce; sce = sce->id.next) { + sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache); + } +} + void blo_make_image_pointer_map(FileData *fd, Main *oldmain) { Image *ima = oldmain->image.first; @@ -2301,6 +2343,11 @@ static void direct_link_id(FileData *fd, ID *id) id->override_static = newdataadr(fd, id->override_static); link_list_ex(fd, &id->override_static->properties, direct_link_id_override_property_cb); } + + DrawDataList *drawdata = DRW_drawdatalist_from_id(id); + if (drawdata) { + BLI_listbase_clear((ListBase *)drawdata); + } } /* ************ READ CurveMapping *************** */ @@ -5492,7 +5539,6 @@ static void direct_link_object(FileData *fd, Object *ob) ob->derivedFinal = NULL; BKE_object_runtime_reset(ob); BLI_listbase_clear(&ob->gpulamp); - BLI_listbase_clear(&ob->drawdata); link_list(fd, &ob->pc_ids); /* Runtime curve data */ @@ -5739,6 +5785,41 @@ static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb } } +static void direct_link_lightcache_texture(FileData *fd, LightCacheTexture *lctex) +{ + lctex->tex = NULL; + + if (lctex->data) { + lctex->data = newdataadr(fd, lctex->data); + if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { + int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] * lctex->tex_size[2]; + + if (lctex->data_type == LIGHTCACHETEX_FLOAT) { + BLI_endian_switch_float_array((float *)lctex->data, data_size * sizeof(float)); + } + else if (lctex->data_type == LIGHTCACHETEX_UINT) { + BLI_endian_switch_uint32_array((unsigned int *)lctex->data, data_size * sizeof(unsigned int)); + } + } + } +} + +static void direct_link_lightcache(FileData *fd, LightCache *cache) +{ + direct_link_lightcache_texture(fd, &cache->cube_tx); + direct_link_lightcache_texture(fd, &cache->grid_tx); + + if (cache->cube_mips) { + cache->cube_mips = newdataadr(fd, cache->cube_mips); + for (int i = 0; i < cache->mips_len; ++i) { + direct_link_lightcache_texture(fd, &cache->cube_mips[i]); + } + } + + cache->cube_data = newdataadr(fd, cache->cube_data); + cache->grid_data = newdataadr(fd, cache->grid_data); +} + /* check for cyclic set-scene, * libs can cause this case which is normally prevented, see (T#####) */ #define USE_SETSCENE_CHECK @@ -6299,6 +6380,19 @@ static void direct_link_scene(FileData *fd, Scene *sce) direct_link_view_layer(fd, view_layer); } + if (fd->memfile) { + /* If it's undo try to recover the cache. */ + if (fd->scenemap) sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache); + else sce->eevee.light_cache = NULL; + } + else { + /* else read the cache from file. */ + if (sce->eevee.light_cache) { + sce->eevee.light_cache = newdataadr(fd, sce->eevee.light_cache); + direct_link_lightcache(fd, sce->eevee.light_cache); + } + } + sce->layer_properties = newdataadr(fd, sce->layer_properties); IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 9c699db5583..10f0c7a2942 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -90,6 +90,7 @@ typedef struct FileData { struct OldNewMap *libmap; struct OldNewMap *imamap; struct OldNewMap *movieclipmap; + struct OldNewMap *scenemap; struct OldNewMap *soundmap; struct OldNewMap *packedmap; @@ -140,6 +141,8 @@ FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *rep void blo_clear_proxy_pointers_from_lib(Main *oldmain); void blo_make_image_pointer_map(FileData *fd, Main *oldmain); void blo_end_image_pointer_map(FileData *fd, Main *oldmain); +void blo_make_scene_pointer_map(FileData *fd, Main *oldmain); +void blo_end_scene_pointer_map(FileData *fd, Main *oldmain); void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain); void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain); void blo_make_sound_pointer_map(FileData *fd, Main *oldmain); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 5e27d72caa2..c9ab174d5e2 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1541,6 +1541,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_cubemap_draw_size")) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { + scene->eevee.gi_irradiance_draw_size = 0.1f; + scene->eevee.gi_cubemap_draw_size = 0.3f; + } + } + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->toolsettings->manipulator_flag == 0) { scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 0a2d09d0c86..049b2e8617c 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2479,6 +2479,36 @@ static void write_view_layer(WriteData *wd, ViewLayer *view_layer) write_layer_collections(wd, &view_layer->layer_collections); } +static void write_lightcache_texture(WriteData *wd, LightCacheTexture *tex) +{ + if (tex->data) { + size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2]; + if (tex->data_type == LIGHTCACHETEX_FLOAT) { + data_size *= sizeof(float); + } + else if (tex->data_type == LIGHTCACHETEX_UINT) { + data_size *= sizeof(unsigned int); + } + writedata(wd, DATA, data_size, tex->data); + } +} + +static void write_lightcache(WriteData *wd, LightCache *cache) +{ + write_lightcache_texture(wd, &cache->grid_tx); + write_lightcache_texture(wd, &cache->cube_tx); + + if (cache->cube_mips) { + writestruct(wd, DATA, LightCacheTexture, cache->mips_len, cache->cube_mips); + for (int i = 0; i < cache->mips_len; ++i) { + write_lightcache_texture(wd, &cache->cube_mips[i]); + } + } + + writestruct(wd, DATA, LightGridCache, cache->grid_len, cache->grid_data); + writestruct(wd, DATA, LightProbeCache, cache->cube_len, cache->cube_data); +} + static void write_scene(WriteData *wd, Scene *sce) { /* write LibData */ @@ -2679,6 +2709,12 @@ static void write_scene(WriteData *wd, Scene *sce) write_collection_nolib(wd, sce->master_collection); } + /* Eevee Lightcache */ + if (sce->eevee.light_cache && !wd->use_memfile) { + writestruct(wd, DATA, LightCache, 1, sce->eevee.light_cache); + write_lightcache(wd, sce->eevee.light_cache); + } + /* Freed on doversion. */ BLI_assert(sce->layer_properties == NULL); } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 794cc22f4e3..20aec0ba5ed 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -555,6 +555,13 @@ void update_special_pointers(const Depsgraph *depsgraph, update_particle_system_orig_pointers(object_orig, object_cow); break; } + case ID_SCE: + { + Scene *scene_cow = (Scene *)id_cow; + const Scene *scene_orig = (const Scene *)id_orig; + scene_cow->eevee.light_cache = scene_orig->eevee.light_cache; + break; + } default: break; } @@ -926,6 +933,12 @@ void discard_mesh_edit_mode_pointers(ID *id_cow) mesh_cow->edit_btmesh = NULL; } +void discard_scene_pointers(ID *id_cow) +{ + Scene *scene_cow = (Scene *)id_cow; + scene_cow->eevee.light_cache = NULL; +} + /* NULL-ify all edit mode pointers which points to data from * original object. */ @@ -948,6 +961,11 @@ void discard_edit_mode_pointers(ID *id_cow) case ID_LT: discard_lattice_edit_mode_pointers(id_cow); break; + case ID_SCE: + /* Not really edit mode but still needs to run before + * BKE_libblock_free_datablock() */ + discard_scene_pointers(id_cow); + break; default: break; } diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index d7b7129114e..2183bc26755 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -96,6 +96,7 @@ set(SRC engines/eevee/eevee_depth_of_field.c engines/eevee/eevee_effects.c engines/eevee/eevee_engine.c + engines/eevee/eevee_lightcache.c engines/eevee/eevee_lightprobes.c engines/eevee/eevee_lights.c engines/eevee/eevee_lookdev.c @@ -137,6 +138,7 @@ set(SRC modes/edit_mesh_mode_intern.h engines/basic/basic_engine.h engines/eevee/eevee_engine.h + engines/eevee/eevee_lightcache.h engines/eevee/eevee_lut.h engines/eevee/eevee_private.h engines/external/external_engine.h diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c index bf039871d52..96e784b524c 100644 --- a/source/blender/draw/engines/eevee/eevee_data.c +++ b/source/blender/draw/engines/eevee/eevee_data.c @@ -28,6 +28,7 @@ #include "DRW_render.h" #include "eevee_private.h" +#include "eevee_lightcache.h" static void eevee_view_layer_data_free(void *storage) { @@ -53,6 +54,11 @@ static void eevee_view_layer_data_free(void *storage) MEM_SAFE_FREE(sldata->shcasters_buffers[1].shadow_casters); MEM_SAFE_FREE(sldata->shcasters_buffers[1].flags); + if (sldata->fallback_lightcache) { + EEVEE_lightcache_free(sldata->fallback_lightcache); + sldata->fallback_lightcache = NULL; + } + /* Probes */ MEM_SAFE_FREE(sldata->probes); DRW_UBO_FREE_SAFE(sldata->probe_ubo); @@ -60,15 +66,6 @@ static void eevee_view_layer_data_free(void *storage) DRW_UBO_FREE_SAFE(sldata->planar_ubo); DRW_UBO_FREE_SAFE(sldata->common_ubo); DRW_UBO_FREE_SAFE(sldata->clip_ubo); - GPU_FRAMEBUFFER_FREE_SAFE(sldata->probe_filter_fb); - for (int i = 0; i < 6; ++i) { - GPU_FRAMEBUFFER_FREE_SAFE(sldata->probe_face_fb[i]); - } - DRW_TEXTURE_FREE_SAFE(sldata->probe_rt); - DRW_TEXTURE_FREE_SAFE(sldata->probe_depth_rt); - DRW_TEXTURE_FREE_SAFE(sldata->probe_pool); - DRW_TEXTURE_FREE_SAFE(sldata->irradiance_pool); - DRW_TEXTURE_FREE_SAFE(sldata->irradiance_rt); } EEVEE_ViewLayerData *EEVEE_view_layer_data_get(void) @@ -77,6 +74,18 @@ EEVEE_ViewLayerData *EEVEE_view_layer_data_get(void) &draw_engine_eevee_type); } +EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure_ex(struct ViewLayer *view_layer) +{ + EEVEE_ViewLayerData **sldata = (EEVEE_ViewLayerData **)DRW_view_layer_engine_data_ensure_ex( + view_layer, &draw_engine_eevee_type, &eevee_view_layer_data_free); + + if (*sldata == NULL) { + *sldata = MEM_callocN(sizeof(**sldata), "EEVEE_ViewLayerData"); + } + + return *sldata; +} + EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure(void) { EEVEE_ViewLayerData **sldata = (EEVEE_ViewLayerData **)DRW_view_layer_engine_data_ensure( diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 70af3b4067c..adbe165354a 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -123,7 +123,7 @@ static void eevee_cache_init(void *vedata) EEVEE_volumes_cache_init(sldata, vedata); } -static void eevee_cache_populate(void *vedata, Object *ob) +void EEVEE_cache_populate(void *vedata, Object *ob) { EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); @@ -146,7 +146,7 @@ static void eevee_cache_populate(void *vedata, Object *ob) /* TODO: Special case for dupli objects because we cannot save the object pointer. */ } else { - EEVEE_lightprobes_cache_add(sldata, ob); + EEVEE_lightprobes_cache_add(sldata, vedata, ob); } } else if (ob->type == OB_LAMP) { @@ -282,7 +282,9 @@ static void eevee_draw_background(void *vedata) EEVEE_subsurface_compute(sldata, vedata); EEVEE_reflection_compute(sldata, vedata); EEVEE_occlusion_draw_debug(sldata, vedata); - DRW_draw_pass(psl->probe_display); + if (psl->probe_display) { + DRW_draw_pass(psl->probe_display); + } EEVEE_refraction_compute(sldata, vedata); /* Opaque refraction */ @@ -367,7 +369,7 @@ static void eevee_id_object_update(void *UNUSED(vedata), Object *object) { EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(object); if (ped != NULL && ped->dd.recalc != 0) { - ped->need_full_update = true; + ped->need_update = (ped->dd.recalc & (ID_RECALC_TRANSFORM | ID_RECALC_COPY_ON_WRITE)) != 0; ped->dd.recalc = 0; } EEVEE_LampEngineData *led = EEVEE_lamp_data_get(object); @@ -385,10 +387,14 @@ static void eevee_id_object_update(void *UNUSED(vedata), Object *object) static void eevee_id_world_update(void *vedata, World *wo) { EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; + LightCache *lcache = stl->g_data->light_cache; EEVEE_WorldEngineData *wedata = EEVEE_world_data_ensure(wo); if (wedata != NULL && wedata->dd.recalc != 0) { + if ((lcache->flag & (LIGHTCACHE_BAKED | LIGHTCACHE_BAKING)) == 0) { + lcache->flag |= LIGHTCACHE_UPDATE_WORLD; + } wedata->dd.recalc = 0; } } @@ -446,7 +452,7 @@ DrawEngineType draw_engine_eevee_type = { &eevee_engine_init, &eevee_engine_free, &eevee_cache_init, - &eevee_cache_populate, + &EEVEE_cache_populate, &eevee_cache_finish, &eevee_draw_background, NULL, /* Everything is drawn in the background pass (see comment on function) */ diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c new file mode 100644 index 00000000000..bf3ee34a03e --- /dev/null +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -0,0 +1,1141 @@ +/* + * Copyright 2016, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Institute + * + */ + +/** \file eevee_lightcache.c + * \ingroup draw_engine + * + * Eevee's indirect lighting cache. + */ + +#include "DRW_render.h" + +#include "BKE_global.h" +#include "BKE_blender.h" + +#include "BLI_threads.h" + +#include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" + +#include "BKE_object.h" + +#include "DNA_lightprobe_types.h" +#include "DNA_group_types.h" + +#include "PIL_time.h" + +#include "eevee_lightcache.h" +#include "eevee_private.h" + +#include "../../../intern/gawain/gawain/gwn_context.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "wm_window.h" + +/* Rounded to nearest PowerOfTwo */ +#if defined(IRRADIANCE_SH_L2) +#define IRRADIANCE_SAMPLE_SIZE_X 4 /* 3 in reality */ +#define IRRADIANCE_SAMPLE_SIZE_Y 4 /* 3 in reality */ +#elif defined(IRRADIANCE_CUBEMAP) +#define IRRADIANCE_SAMPLE_SIZE_X 8 +#define IRRADIANCE_SAMPLE_SIZE_Y 8 +#elif defined(IRRADIANCE_HL2) +#define IRRADIANCE_SAMPLE_SIZE_X 4 /* 3 in reality */ +#define IRRADIANCE_SAMPLE_SIZE_Y 2 +#endif + +#ifdef IRRADIANCE_SH_L2 +/* we need a signed format for Spherical Harmonics */ +# define IRRADIANCE_FORMAT GPU_RGBA16F +#else +# define IRRADIANCE_FORMAT GPU_RGBA8 +#endif + +#define IRRADIANCE_MAX_POOL_LAYER 256 /* OpenGL 3.3 core requirement, can be extended but it's already very big */ +#define IRRADIANCE_MAX_POOL_SIZE 1024 +#define MAX_IRRADIANCE_SAMPLES \ + (IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_X) * \ + (IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_Y) + +/* TODO should be replace by a more elegant alternative. */ +extern void DRW_opengl_context_enable(void); +extern void DRW_opengl_context_disable(void); + +extern void DRW_opengl_render_context_enable(void *re_gl_context); +extern void DRW_opengl_render_context_disable(void *re_gl_context); +extern void DRW_gawain_render_context_enable(void *re_gwn_context); +extern void DRW_gawain_render_context_disable(void *re_gwn_context); + +typedef struct EEVEE_LightBake { + Depsgraph *depsgraph; + ViewLayer *view_layer; + ViewLayer *view_layer_input; + LightCache *lcache; + Scene *scene; + struct Main *bmain; + + LightProbe **probe; /* Current probe being rendered. */ + GPUTexture *rt_color; /* Target cube color texture. */ + GPUTexture *rt_depth; /* Target cube depth texture. */ + GPUFrameBuffer *rt_fb[6]; /* Target cube framebuffers. */ + GPUFrameBuffer *store_fb; /* Storage framebuffer. */ + int rt_res; /* Cube render target resolution. */ + + /* Shared */ + int layer; /* Target layer to store the data to. */ + float samples_ct, invsamples_ct; /* Sample count for the convolution. */ + float lod_factor; /* Sampling bias during convolution step. */ + float lod_max; /* Max cubemap LOD to sample when convolving. */ + int cube_len, grid_len; /* Number of probes to render + world probe. */ + + /* Irradiance grid */ + EEVEE_LightGrid *grid; /* Current probe being rendered (UBO data). */ + int irr_cube_res; /* Target cubemap at MIP 0. */ + int irr_size[3]; /* Size of the irradiance texture. */ + int total_irr_samples; /* Total for all grids */ + int grid_sample; /* Nth sample of the current grid being rendered. */ + int grid_sample_len; /* Total number of samples for the current grid. */ + int grid_curr; /* Nth grid in the cache being rendered. */ + int bounce_curr, bounce_len; /* The current light bounce being evaluated. */ + float vis_range, vis_blur; /* Sample Visibility compression and bluring. */ + float vis_res; /* Resolution of the Visibility shadowmap. */ + GPUTexture *grid_prev; /* Result of previous light bounce. */ + LightProbe **grid_prb; /* Pointer to the id.data of the probe object. */ + + /* Reflection probe */ + EEVEE_LightProbe *cube; /* Current probe being rendered (UBO data). */ + int ref_cube_res; /* Target cubemap at MIP 0. */ + int cube_offset; /* Index of the current cube. */ + float probemat[6][4][4]; /* ViewProjection matrix for each cube face. */ + float texel_size, padding_size; /* Texel and padding size for the final octahedral map. */ + float roughness; /* Roughness level of the current mipmap. */ + LightProbe **cube_prb; /* Pointer to the id.data of the probe object. */ + + /* Dummy Textures */ + struct GPUTexture *dummy_color, *dummy_depth; + struct GPUTexture *dummy_layer_color; + + int total, done; /* to compute progress */ + short *stop, *do_update; + float *progress; + + bool resource_only; /* For only handling the resources. */ + bool own_resources; + bool own_light_cache; /* If the lightcache was created for baking, it's first owned by the baker. */ + int delay; /* ms. delay the start of the baking to not slowdown interactions (TODO remove) */ + + void *gl_context, *gwn_context; /* If running in parallel (in a separate thread), use this context. */ +} EEVEE_LightBake; + +/* -------------------------------------------------------------------- */ + +/** \name Light Cache + * \{ */ + +/* Return memory footprint in bytes. */ +static unsigned int eevee_lightcache_memsize_get(LightCache *lcache) +{ + unsigned int size = 0; + if (lcache->grid_tx.data) { + size += MEM_allocN_len(lcache->grid_tx.data); + } + if (lcache->cube_tx.data) { + size += MEM_allocN_len(lcache->cube_tx.data); + for (int mip = 0; mip < lcache->mips_len; ++mip) { + size += MEM_allocN_len(lcache->cube_mips[mip].data); + } + } + return size; +} + +static int eevee_lightcache_irradiance_sample_count(LightCache *lcache) +{ + int total_irr_samples = 0; + + for (int i = 1; i < lcache->grid_len; ++i) { + EEVEE_LightGrid *egrid = lcache->grid_data + i; + total_irr_samples += egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2]; + } + return total_irr_samples; +} + +void EEVEE_lightcache_info_update(SceneEEVEE *eevee) +{ + LightCache *lcache = eevee->light_cache; + + if (lcache != NULL) { + char formatted_mem[15]; + BLI_str_format_byte_unit(formatted_mem, eevee_lightcache_memsize_get(lcache), true); + + int irr_samples = eevee_lightcache_irradiance_sample_count(lcache); + + BLI_snprintf(eevee->light_cache_info, sizeof(eevee->light_cache_info), IFACE_("%d Ref. Cubemaps, %d Irr. Samples (%s in memory)"), lcache->cube_len - 1, irr_samples, formatted_mem); + } + else { + BLI_strncpy(eevee->light_cache_info, IFACE_("No light cache in this scene."), sizeof(eevee->light_cache_info)); + } +} + +static void irradiance_pool_size_get(int visibility_size, int total_samples, int r_size[3]) +{ + /* Compute how many irradiance samples we can store per visibility sample. */ + int irr_per_vis = (visibility_size / IRRADIANCE_SAMPLE_SIZE_X) * + (visibility_size / IRRADIANCE_SAMPLE_SIZE_Y); + + /* The irradiance itself take one layer, hence the +1 */ + int layer_ct = MIN2(irr_per_vis + 1, IRRADIANCE_MAX_POOL_LAYER); + + int texel_ct = (int)ceilf((float)total_samples / (float)(layer_ct - 1)); + r_size[0] = visibility_size * max_ii(1, min_ii(texel_ct, (IRRADIANCE_MAX_POOL_SIZE / visibility_size))); + r_size[1] = visibility_size * max_ii(1, (texel_ct / (IRRADIANCE_MAX_POOL_SIZE / visibility_size))); + r_size[2] = layer_ct; +} + +static bool EEVEE_lightcache_validate( + const LightCache *light_cache, + const int cube_len, + const int cube_res, + const int grid_len, + const int irr_size[3]) +{ + if (light_cache) { + /* See if we need the same amount of texture space. */ + if ((irr_size[0] == light_cache->grid_tx.tex_size[0]) && + (irr_size[1] == light_cache->grid_tx.tex_size[1]) && + (irr_size[2] == light_cache->grid_tx.tex_size[2]) && + (grid_len != light_cache->grid_len)) + { + int mip_len = (int)(floorf(log2f(cube_res)) - MIN_CUBE_LOD_LEVEL); + if ((cube_res == light_cache->cube_tx.tex_size[0]) && + (cube_len == light_cache->cube_tx.tex_size[2]) && + (mip_len == light_cache->mips_len)) + { + return true; + } + } + } + return false; +} + +LightCache *EEVEE_lightcache_create( + const int grid_len, + const int cube_len, + const int cube_size, + const int vis_size, + const int irr_size[3]) +{ + LightCache *light_cache = MEM_callocN(sizeof(LightCache), "LightCache"); + + light_cache->cube_data = MEM_callocN(sizeof(EEVEE_LightProbe) * cube_len, "EEVEE_LightProbe"); + light_cache->grid_data = MEM_callocN(sizeof(EEVEE_LightGrid) * grid_len, "EEVEE_LightGrid"); + + light_cache->grid_tx.tex = DRW_texture_create_2D_array(irr_size[0], irr_size[1], irr_size[2], IRRADIANCE_FORMAT, DRW_TEX_FILTER, NULL); + light_cache->grid_tx.tex_size[0] = irr_size[0]; + light_cache->grid_tx.tex_size[1] = irr_size[1]; + light_cache->grid_tx.tex_size[2] = irr_size[2]; + + light_cache->cube_tx.tex = DRW_texture_create_2D_array(cube_size, cube_size, cube_len, GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL); + light_cache->cube_tx.tex_size[0] = cube_size; + light_cache->cube_tx.tex_size[1] = cube_size; + light_cache->cube_tx.tex_size[2] = cube_len; + + light_cache->mips_len = (int)(floorf(log2f(cube_size)) - MIN_CUBE_LOD_LEVEL); + light_cache->vis_res = vis_size; + light_cache->ref_res = cube_size; + + light_cache->cube_mips = MEM_callocN(sizeof(LightCacheTexture) * light_cache->mips_len, "LightCacheTexture"); + + for (int mip = 0; mip < light_cache->mips_len; ++mip) { + GPU_texture_get_mipmap_size(light_cache->cube_tx.tex, mip + 1, light_cache->cube_mips[mip].tex_size); + } + + light_cache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | LIGHTCACHE_UPDATE_GRID; + + return light_cache; +} + +void EEVEE_lightcache_load(LightCache *lcache) +{ + if (lcache->grid_tx.tex == NULL && lcache->grid_tx.data) { + lcache->grid_tx.tex = GPU_texture_create_nD(lcache->grid_tx.tex_size[0], + lcache->grid_tx.tex_size[1], + lcache->grid_tx.tex_size[2], + 2, + lcache->grid_tx.data, + IRRADIANCE_FORMAT, + GPU_DATA_UNSIGNED_BYTE, + 0, + false, + NULL); + GPU_texture_bind(lcache->grid_tx.tex, 0); + GPU_texture_filter_mode(lcache->grid_tx.tex, true); + GPU_texture_unbind(lcache->grid_tx.tex); + } + + if (lcache->cube_tx.tex == NULL && lcache->cube_tx.data) { + lcache->cube_tx.tex = GPU_texture_create_nD(lcache->cube_tx.tex_size[0], + lcache->cube_tx.tex_size[1], + lcache->cube_tx.tex_size[2], + 2, + lcache->cube_tx.data, + GPU_R11F_G11F_B10F, + GPU_DATA_10_11_11_REV, + 0, + false, + NULL); + GPU_texture_bind(lcache->cube_tx.tex, 0); + GPU_texture_mipmap_mode(lcache->cube_tx.tex, true, true); + for (int mip = 0; mip < lcache->mips_len; ++mip) { + GPU_texture_add_mipmap(lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, mip + 1, lcache->cube_mips[mip].data); + } + GPU_texture_unbind(lcache->cube_tx.tex); + } +} + +static void eevee_lightbake_readback_irradiance(LightCache *lcache) +{ + MEM_SAFE_FREE(lcache->grid_tx.data); + lcache->grid_tx.data = GPU_texture_read(lcache->grid_tx.tex, GPU_DATA_UNSIGNED_BYTE, 0); + lcache->grid_tx.data_type = LIGHTCACHETEX_BYTE; + lcache->grid_tx.components = 4; +} + +static void eevee_lightbake_readback_reflections(LightCache *lcache) +{ + MEM_SAFE_FREE(lcache->cube_tx.data); + lcache->cube_tx.data = GPU_texture_read(lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, 0); + lcache->cube_tx.data_type = LIGHTCACHETEX_UINT; + lcache->cube_tx.components = 1; + + for (int mip = 0; mip < lcache->mips_len; ++mip) { + LightCacheTexture *cube_mip = lcache->cube_mips + mip; + MEM_SAFE_FREE(cube_mip->data); + GPU_texture_get_mipmap_size(lcache->cube_tx.tex, mip + 1, cube_mip->tex_size); + + cube_mip->data = GPU_texture_read(lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, mip + 1); + cube_mip->data_type = LIGHTCACHETEX_UINT; + cube_mip->components = 1; + } +} + +void EEVEE_lightcache_free(LightCache *lcache) +{ + DRW_TEXTURE_FREE_SAFE(lcache->cube_tx.tex); + MEM_SAFE_FREE(lcache->cube_tx.data); + DRW_TEXTURE_FREE_SAFE(lcache->grid_tx.tex); + MEM_SAFE_FREE(lcache->grid_tx.data); + + if (lcache->cube_mips) { + for (int i = 0; i < lcache->mips_len; ++i) { + MEM_SAFE_FREE(lcache->cube_mips[i].data); + } + MEM_SAFE_FREE(lcache->cube_mips); + } + + MEM_SAFE_FREE(lcache->cube_data); + MEM_SAFE_FREE(lcache->grid_data); + MEM_freeN(lcache); +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Light Bake Context + * \{ */ + +static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake) +{ + if (lbake->gl_context) { + DRW_opengl_render_context_enable(lbake->gl_context); + if (lbake->gwn_context == NULL) { + lbake->gwn_context = GWN_context_create(); + } + DRW_gawain_render_context_enable(lbake->gwn_context); + } + else { + DRW_opengl_context_enable(); + } +} + +static void eevee_lightbake_context_disable(EEVEE_LightBake *lbake) +{ + if (lbake->gl_context) { + DRW_gawain_render_context_disable(lbake->gwn_context); + DRW_opengl_render_context_disable(lbake->gl_context); + } + else { + DRW_opengl_context_disable(); + } +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Light Bake Job + * \{ */ + +static void eevee_lightbake_count_probes(EEVEE_LightBake *lbake) +{ + Depsgraph *depsgraph = lbake->depsgraph; + + /* At least one of each for the world */ + lbake->grid_len = lbake->cube_len = lbake->total_irr_samples = 1; + + DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) + { + if (!BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_FOR_RENDER)) { + continue; + } + + if (ob->type == OB_LIGHTPROBE) { + LightProbe *prb = (LightProbe *)ob->data; + + if (prb->type == LIGHTPROBE_TYPE_GRID) { + lbake->total_irr_samples += prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z; + lbake->grid_len++; + } + else if (prb->type == LIGHTPROBE_TYPE_CUBE) { + lbake->cube_len++; + } + } + } + DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END; +} + +static void eevee_lightbake_create_render_target(EEVEE_LightBake *lbake, int rt_res) +{ + lbake->rt_depth = DRW_texture_create_cube(rt_res, GPU_DEPTH_COMPONENT24, 0, NULL); + lbake->rt_color = DRW_texture_create_cube(rt_res, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL); + + for (int i = 0; i < 6; ++i) { + GPU_framebuffer_ensure_config(&lbake->rt_fb[i], { + GPU_ATTACHMENT_TEXTURE_CUBEFACE(lbake->rt_depth, i), + GPU_ATTACHMENT_TEXTURE_CUBEFACE(lbake->rt_color, i) + }); + } + + GPU_framebuffer_ensure_config(&lbake->store_fb, { + GPU_ATTACHMENT_NONE, + GPU_ATTACHMENT_NONE + }); +} + +static void eevee_lightbake_create_resources(EEVEE_LightBake *lbake) +{ + Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph); + SceneEEVEE *eevee = &scene_eval->eevee; + + lbake->bounce_len = eevee->gi_diffuse_bounces; + lbake->vis_res = eevee->gi_visibility_resolution; + lbake->rt_res = eevee->gi_cubemap_resolution; + + irradiance_pool_size_get(lbake->vis_res, lbake->total_irr_samples, lbake->irr_size); + + lbake->ref_cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(lbake->rt_res); + + lbake->cube_prb = MEM_callocN(sizeof(LightProbe *) * lbake->cube_len, "EEVEE Cube visgroup ptr"); + lbake->grid_prb = MEM_callocN(sizeof(LightProbe *) * lbake->grid_len, "EEVEE Grid visgroup ptr"); + + lbake->grid_prev = DRW_texture_create_2D_array(lbake->irr_size[0], lbake->irr_size[1], lbake->irr_size[2], + IRRADIANCE_FORMAT, DRW_TEX_FILTER, NULL); + + /* Ensure Light Cache is ready to accept new data. If not recreate one. + * WARNING: All the following must be threadsafe. It's currently protected + * by the DRW mutex. */ + lbake->lcache = eevee->light_cache; + + /* TODO validate irradiance and reflection cache independantly... */ + if (lbake->lcache != NULL && + !EEVEE_lightcache_validate(lbake->lcache, lbake->cube_len, lbake->ref_cube_res, lbake->grid_len, lbake->irr_size)) + { + eevee->light_cache = lbake->lcache = NULL; + } + + if (lbake->lcache == NULL) { + lbake->lcache = EEVEE_lightcache_create(lbake->grid_len, + lbake->cube_len, + lbake->ref_cube_res, + lbake->vis_res, + lbake->irr_size); + lbake->lcache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | LIGHTCACHE_UPDATE_GRID; + lbake->lcache->vis_res = lbake->vis_res; + lbake->own_light_cache = true; + + eevee->light_cache = lbake->lcache; + } + + EEVEE_lightcache_load(eevee->light_cache); + + lbake->lcache->flag |= LIGHTCACHE_BAKING; + lbake->lcache->cube_len = 1; +} + +wmJob *EEVEE_lightbake_job_create( + struct wmWindowManager *wm, struct wmWindow *win, struct Main *bmain, + struct ViewLayer *view_layer, struct Scene *scene, int delay) +{ + EEVEE_LightBake *lbake = NULL; + + /* only one render job at a time */ + if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) + return NULL; + + wmJob *wm_job = WM_jobs_get(wm, win, scene, "Bake Lighting", + WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_LIGHT_BAKE); + + /* If job exists do not recreate context and depsgraph. */ + EEVEE_LightBake *old_lbake = (EEVEE_LightBake *)WM_jobs_customdata_get(wm_job); + + if (old_lbake && (old_lbake->view_layer_input == view_layer) && (old_lbake->bmain == bmain)) { + lbake = MEM_callocN(sizeof(EEVEE_LightBake), "EEVEE_LightBake"); + /* Cannot reuse depsgraph for now because we cannot get the update from the + * main database directly. TODO reuse depsgraph and only update positions. */ + /* lbake->depsgraph = old_lbake->depsgraph; */ + lbake->depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER); + + lbake->scene = scene; + lbake->bmain = bmain; + lbake->view_layer_input = view_layer; + lbake->gl_context = old_lbake->gl_context; + lbake->own_resources = true; + lbake->delay = delay; + + old_lbake->own_resources = false; + + if (old_lbake->stop != NULL) { + *old_lbake->stop = 1; + } + } + else { + lbake = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, true); + lbake->delay = delay; + } + + WM_jobs_customdata_set(wm_job, lbake, EEVEE_lightbake_job_data_free); + WM_jobs_timer(wm_job, 0.4, NC_SCENE | NA_EDITED, 0); + WM_jobs_callbacks(wm_job, EEVEE_lightbake_job, NULL, EEVEE_lightbake_update, EEVEE_lightbake_update); + + G.is_break = false; + + return wm_job; +} + +/* MUST run on the main thread. */ +void *EEVEE_lightbake_job_data_alloc( + struct Main *bmain, struct ViewLayer *view_layer, struct Scene *scene, bool run_as_job) +{ + BLI_assert(BLI_thread_is_main()); + + EEVEE_LightBake *lbake = MEM_callocN(sizeof(EEVEE_LightBake), "EEVEE_LightBake"); + + lbake->depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER); + lbake->scene = scene; + lbake->bmain = bmain; + lbake->view_layer_input = view_layer; + lbake->own_resources = true; + lbake->own_light_cache = false; + + if (run_as_job) { + lbake->gl_context = WM_opengl_context_create(); + wm_window_reset_drawable(); + } + + return lbake; +} + +void EEVEE_lightbake_job_data_free(void *custom_data) +{ + EEVEE_LightBake *lbake = (EEVEE_LightBake *)custom_data; + + /* TODO reuse depsgraph. */ + /* if (lbake->own_resources) { */ + DEG_graph_free(lbake->depsgraph); + /* } */ + + MEM_SAFE_FREE(lbake->cube_prb); + MEM_SAFE_FREE(lbake->grid_prb); + + MEM_freeN(lbake); +} + +static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake) +{ + if (lbake->gl_context) { + DRW_opengl_render_context_enable(lbake->gl_context); + DRW_gawain_render_context_enable(lbake->gwn_context); + } + else if (!lbake->resource_only) { + DRW_opengl_context_enable(); + } + + if (lbake->own_light_cache) { + EEVEE_lightcache_free(lbake->lcache); + lbake->lcache = NULL; + } + + DRW_TEXTURE_FREE_SAFE(lbake->rt_depth); + DRW_TEXTURE_FREE_SAFE(lbake->rt_color); + DRW_TEXTURE_FREE_SAFE(lbake->grid_prev); + GPU_FRAMEBUFFER_FREE_SAFE(lbake->store_fb); + for (int i = 0; i < 6; ++i) { + GPU_FRAMEBUFFER_FREE_SAFE(lbake->rt_fb[i]); + } + + if (lbake->gwn_context) { + DRW_gawain_render_context_disable(lbake->gwn_context); + DRW_gawain_render_context_enable(lbake->gwn_context); + GWN_context_discard(lbake->gwn_context); + } + + if (lbake->gl_context && lbake->own_resources) { + /* Delete the baking context. */ + DRW_opengl_render_context_disable(lbake->gl_context); + WM_opengl_context_dispose(lbake->gl_context); + lbake->gwn_context = NULL; + lbake->gl_context = NULL; + } + else if (lbake->gl_context) { + DRW_opengl_render_context_disable(lbake->gl_context); + } + else if (!lbake->resource_only) { + DRW_opengl_context_disable(); + } +} + +/* Cache as in draw cache not light cache. */ +static void eevee_lightbake_cache_create(EEVEE_Data *vedata, EEVEE_LightBake *lbake) +{ + EEVEE_StorageList *stl = vedata->stl; + EEVEE_FramebufferList *fbl = vedata->fbl; + EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); + Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph); + /* Disable all effects BUT high bitdepth shadows. */ + scene_eval->eevee.flag &= SCE_EEVEE_SHADOW_HIGH_BITDEPTH; + scene_eval->eevee.taa_samples = 1; + + stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__); + stl->g_data->background_alpha = 1.0f; + + /* XXX TODO remove this. This is in order to make the init functions work. */ + DRWMatrixState dummy_mats = {{{{{0}}}}}; + DRW_viewport_matrix_override_set_all(&dummy_mats); + + if (sldata->common_ubo == NULL) { + sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data), &sldata->common_data); + } + if (sldata->clip_ubo == NULL) { + sldata->clip_ubo = DRW_uniformbuffer_create(sizeof(sldata->clip_data), &sldata->clip_data); + } + + EEVEE_effects_init(sldata, vedata, NULL); + EEVEE_materials_init(sldata, stl, fbl); + EEVEE_lights_init(sldata); + EEVEE_lightprobes_init(sldata, vedata); + + EEVEE_effects_cache_init(sldata, vedata); + EEVEE_materials_cache_init(sldata, vedata); + EEVEE_lights_cache_init(sldata, vedata); + EEVEE_lightprobes_cache_init(sldata, vedata); + + EEVEE_lightbake_cache_init(sldata, vedata, lbake->rt_color, lbake->rt_depth); + + if (lbake->probe) { + EEVEE_LightProbesInfo *pinfo = sldata->probes; + LightProbe *prb = *lbake->probe; + pinfo->vis_data.collection = prb->visibility_grp; + pinfo->vis_data.invert = prb->flag & LIGHTPROBE_FLAG_INVERT_GROUP; + pinfo->vis_data.cached = false; + } + DRW_render_object_iter(vedata, NULL, lbake->depsgraph, EEVEE_render_cache); + + EEVEE_materials_cache_finish(vedata); + EEVEE_lights_cache_finish(sldata); + EEVEE_lightprobes_cache_finish(sldata, vedata); + + DRW_render_instance_buffer_finish(); + DRW_hair_update(); +} + +static void eevee_lightbake_copy_irradiance(EEVEE_LightBake *lbake, LightCache *lcache) +{ + DRW_TEXTURE_FREE_SAFE(lbake->grid_prev); + + /* Copy texture by reading back and reuploading it. */ + float *tex = GPU_texture_read(lcache->grid_tx.tex, GPU_DATA_FLOAT, 0); + lbake->grid_prev = DRW_texture_create_2D_array(lbake->irr_size[0], lbake->irr_size[1], lbake->irr_size[2], + IRRADIANCE_FORMAT, DRW_TEX_FILTER, tex); + + MEM_freeN(tex); +} + +static void eevee_lightbake_render_world_sample(void *ved, void *user_data) +{ + EEVEE_Data *vedata = (EEVEE_Data *)ved; + EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); + EEVEE_LightBake *lbake = (EEVEE_LightBake *)user_data; + Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph); + LightCache *lcache = scene_eval->eevee.light_cache; + + /* TODO do this once for the whole bake when we have independant DRWManagers. */ + eevee_lightbake_cache_create(vedata, lbake); + + EEVEE_lightbake_render_world(sldata, vedata, lbake->rt_fb); + EEVEE_lightbake_filter_glossy(sldata, vedata, lbake->rt_color, lbake->store_fb, 0, 1.0f, lcache->mips_len); + EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake->rt_color, lbake->store_fb, 0, 1.0f); + + /* Clear the cache to avoid white values in the grid. */ + GPU_framebuffer_texture_attach(lbake->store_fb, lbake->grid_prev, 0, 0); + GPU_framebuffer_bind(lbake->store_fb); + /* Clear to 1.0f for visibility. */ + GPU_framebuffer_clear_color(lbake->store_fb, ((float[4]){1.0f, 1.0f, 1.0f, 1.0f})); + DRW_draw_pass(vedata->psl->probe_grid_fill); + + SWAP(GPUTexture *, lbake->grid_prev, lcache->grid_tx.tex); + + /* Make a copy for later. */ + eevee_lightbake_copy_irradiance(lbake, lcache); + + lcache->cube_len = 1; + lcache->grid_len = lbake->grid_len; + + lcache->flag |= LIGHTCACHE_CUBE_READY | LIGHTCACHE_GRID_READY; + lcache->flag &= ~LIGHTCACHE_UPDATE_WORLD; +} + +static void cell_id_to_grid_loc(EEVEE_LightGrid *egrid, int cell_idx, int r_local_cell[3]) +{ + /* Keep in sync with lightprobe_grid_display_vert */ + r_local_cell[2] = cell_idx % egrid->resolution[2]; + r_local_cell[1] = (cell_idx / egrid->resolution[2]) % egrid->resolution[1]; + r_local_cell[0] = cell_idx / (egrid->resolution[2] * egrid->resolution[1]); +} + +static void compute_cell_id( + EEVEE_LightGrid *egrid, LightProbe *probe, + int cell_idx, int *r_final_idx, int r_local_cell[3], int *r_stride) +{ + const int cell_count = probe->grid_resolution_x * probe->grid_resolution_y * probe->grid_resolution_z; + + /* Add one for level 0 */ + int max_lvl = (int)floorf(log2f((float)MAX3(probe->grid_resolution_x, + probe->grid_resolution_y, + probe->grid_resolution_z))); + + int visited_cells = 0; + for (int lvl = max_lvl; lvl >= 0; --lvl) { + *r_stride = 1 << lvl; + int prev_stride = *r_stride << 1; + for (int i = 0; i < cell_count; ++i) { + *r_final_idx = i; + cell_id_to_grid_loc(egrid, *r_final_idx, r_local_cell); + if (((r_local_cell[0] % *r_stride) == 0) && + ((r_local_cell[1] % *r_stride) == 0) && + ((r_local_cell[2] % *r_stride) == 0)) + { + if (!(((r_local_cell[0] % prev_stride) == 0) && + ((r_local_cell[1] % prev_stride) == 0) && + ((r_local_cell[2] % prev_stride) == 0)) || + ((i == 0) && (lvl == max_lvl))) + { + if (visited_cells == cell_idx) { + return; + } + else { + visited_cells++; + } + } + } + } + } + + BLI_assert(0); +} + +static void grid_loc_to_world_loc(EEVEE_LightGrid *egrid, int local_cell[3], float r_pos[3]) +{ + copy_v3_v3(r_pos, egrid->corner); + madd_v3_v3fl(r_pos, egrid->increment_x, local_cell[0]); + madd_v3_v3fl(r_pos, egrid->increment_y, local_cell[1]); + madd_v3_v3fl(r_pos, egrid->increment_z, local_cell[2]); +} + +static void eevee_lightbake_render_grid_sample(void *ved, void *user_data) +{ + EEVEE_Data *vedata = (EEVEE_Data *)ved; + EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); + EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; + EEVEE_LightBake *lbake = (EEVEE_LightBake *)user_data; + EEVEE_LightGrid *egrid = lbake->grid; + LightProbe *prb = *lbake->probe; + Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph); + LightCache *lcache = scene_eval->eevee.light_cache; + int grid_loc[3], sample_id, sample_offset, stride; + float pos[3]; + const bool is_last_bounce_sample = ((egrid->offset + lbake->grid_sample) == (lbake->total_irr_samples - 1)); + + /* No bias for rendering the probe. */ + egrid->level_bias = 1.0f; + + /* Use the previous bounce for rendering this bounce. */ + SWAP(GPUTexture *, lbake->grid_prev, lcache->grid_tx.tex); + + /* TODO do this once for the whole bake when we have independant DRWManagers. + * Warning: Some of the things above require this. */ + eevee_lightbake_cache_create(vedata, lbake); + + /* Compute sample position */ + compute_cell_id(egrid, prb, lbake->grid_sample, &sample_id, grid_loc, &stride); + sample_offset = egrid->offset + sample_id; + + grid_loc_to_world_loc(egrid, grid_loc, pos); + + /* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */ + common_data->spec_toggle = false; + common_data->prb_num_planar = 0; + common_data->prb_num_render_cube = 0; + if (lbake->bounce_curr == 0) { + common_data->prb_num_render_grid = 0; + } + DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); + + EEVEE_lightbake_render_scene(sldata, vedata, lbake->rt_fb, pos, prb->clipsta, prb->clipend); + + /* Restore before filtering. */ + SWAP(GPUTexture *, lbake->grid_prev, lcache->grid_tx.tex); + + EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake->rt_color, lbake->store_fb, sample_offset, prb->intensity); + + if (lbake->bounce_curr == 0) { + /* We only need to filter the visibility for the first bounce. */ + EEVEE_lightbake_filter_visibility(sldata, vedata, lbake->rt_depth, lbake->store_fb, sample_offset, + prb->clipsta, prb->clipend, egrid->visibility_range, + prb->vis_blur, lbake->vis_res); + } + + /* Update level for progressive update. */ + if (is_last_bounce_sample) { + egrid->level_bias = 1.0f; + } + else if (lbake->bounce_curr == 0) { + egrid->level_bias = (float)(stride << 1); + } + + /* Only run this for the last sample of a bounce. */ + if (is_last_bounce_sample) { + eevee_lightbake_copy_irradiance(lbake, lcache); + } + + /* If it is the last sample grid sample (and last bounce). */ + if ((lbake->bounce_curr == lbake->bounce_len - 1) && + (lbake->grid_curr == lbake->grid_len - 1) && + (lbake->grid_sample == lbake->grid_sample_len - 1)) + { + lcache->flag &= ~LIGHTCACHE_UPDATE_GRID; + } +} + +static void eevee_lightbake_render_probe_sample(void *ved, void *user_data) +{ + EEVEE_Data *vedata = (EEVEE_Data *)ved; + EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); + EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; + EEVEE_LightBake *lbake = (EEVEE_LightBake *)user_data; + Scene *scene_eval = DEG_get_evaluated_scene(lbake->depsgraph); + LightCache *lcache = scene_eval->eevee.light_cache; + EEVEE_LightProbe *eprobe = lbake->cube; + LightProbe *prb = *lbake->probe; + + /* TODO do this once for the whole bake when we have independant DRWManagers. */ + eevee_lightbake_cache_create(vedata, lbake); + + /* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */ + common_data->spec_toggle = false; + common_data->prb_num_planar = 0; + common_data->prb_num_render_cube = 0; + DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); + + EEVEE_lightbake_render_scene(sldata, vedata, lbake->rt_fb, eprobe->position, prb->clipsta, prb->clipend); + EEVEE_lightbake_filter_glossy(sldata, vedata, lbake->rt_color, lbake->store_fb, lbake->cube_offset, prb->intensity, lcache->mips_len); + + lcache->cube_len += 1; + + /* If it's the last probe. */ + if (lbake->cube_offset == lbake->cube_len - 1) { + lcache->flag &= ~LIGHTCACHE_UPDATE_CUBE; + } +} + +static float eevee_lightbake_grid_influence_volume(EEVEE_LightGrid *grid) +{ + return mat4_to_scale(grid->mat); +} + +static float eevee_lightbake_cube_influence_volume(EEVEE_LightProbe *eprb) +{ + return mat4_to_scale(eprb->attenuationmat); +} + +static bool eevee_lightbake_grid_comp(EEVEE_LightGrid *grid_a, EEVEE_LightGrid *grid_b) +{ + float vol_a = eevee_lightbake_grid_influence_volume(grid_a); + float vol_b = eevee_lightbake_grid_influence_volume(grid_b); + return (vol_a < vol_b); +} + +static bool eevee_lightbake_cube_comp(EEVEE_LightProbe *prb_a, EEVEE_LightProbe *prb_b) +{ + float vol_a = eevee_lightbake_cube_influence_volume(prb_a); + float vol_b = eevee_lightbake_cube_influence_volume(prb_b); + return (vol_a < vol_b); +} + +#define SORT_PROBE(elems_type, prbs, elems, elems_len, comp_fn) \ +{ \ + bool sorted = false; \ + while (!sorted) { \ + sorted = true; \ + for (int i = 0; i < (elems_len) - 1; ++i) { \ + if ((comp_fn)((elems) + i, (elems) + i+1)) { \ + SWAP(elems_type, (elems)[i], (elems)[i+1]); \ + SWAP(LightProbe *, (prbs)[i], (prbs)[i+1]); \ + sorted = false; \ + } \ + } \ + } \ +} + +static void eevee_lightbake_gather_probes(EEVEE_LightBake *lbake) +{ + Depsgraph *depsgraph = lbake->depsgraph; + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + LightCache *lcache = scene_eval->eevee.light_cache; + + /* At least one for the world */ + int grid_len = 1; + int cube_len = 1; + int total_irr_samples = 1; + + /* Convert all lightprobes to tight UBO data from all lightprobes in the scene. + * This allows a large number of probe to be precomputed (even dupli ones). */ + DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) + { + if (!BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_FOR_RENDER)) { + continue; + } + + if (ob->type == OB_LIGHTPROBE) { + LightProbe *prb = (LightProbe *)ob->data; + + if (prb->type == LIGHTPROBE_TYPE_GRID) { + lbake->grid_prb[grid_len] = prb; + EEVEE_LightGrid *egrid = &lcache->grid_data[grid_len++]; + EEVEE_lightprobes_grid_data_from_object(ob, egrid, &total_irr_samples); + } + else if (prb->type == LIGHTPROBE_TYPE_CUBE) { + lbake->cube_prb[cube_len] = prb; + EEVEE_LightProbe *eprobe = &lcache->cube_data[cube_len++]; + EEVEE_lightprobes_cube_data_from_object(ob, eprobe); + } + } + } + DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END; + + SORT_PROBE(EEVEE_LightGrid, lbake->grid_prb + 1, lcache->grid_data + 1, lbake->grid_len - 1, eevee_lightbake_grid_comp); + SORT_PROBE(EEVEE_LightProbe, lbake->cube_prb + 1, lcache->cube_data + 1, lbake->cube_len - 1, eevee_lightbake_cube_comp); + + lbake->total = lbake->total_irr_samples * lbake->bounce_len + lbake->cube_len; + lbake->done = 0; +} + +void EEVEE_lightbake_update(void *custom_data) +{ + EEVEE_LightBake *lbake = (EEVEE_LightBake *)custom_data; + Scene *scene_orig = lbake->scene; + + /* If a new lightcache was created, free the old one and reference the new. */ + if (lbake->lcache && scene_orig->eevee.light_cache != lbake->lcache) { + if (scene_orig->eevee.light_cache != NULL) { + EEVEE_lightcache_free(scene_orig->eevee.light_cache); + } + scene_orig->eevee.light_cache = lbake->lcache; + lbake->own_light_cache = false; + } + + EEVEE_lightcache_info_update(&lbake->scene->eevee); + + DEG_id_tag_update(&scene_orig->id, DEG_TAG_COPY_ON_WRITE); +} + +static bool lightbake_do_sample(EEVEE_LightBake *lbake, void (*render_callback)(void *ved, void *user_data)) +{ + if (G.is_break == true || *lbake->stop) { + return false; + } + + Depsgraph *depsgraph = lbake->depsgraph; + + /* TODO: make DRW manager instanciable (and only lock on drawing) */ + eevee_lightbake_context_enable(lbake); + DRW_custom_pipeline(&draw_engine_eevee_type, depsgraph, render_callback, lbake); + lbake->done += 1; + *lbake->progress = lbake->done / (float)lbake->total; + *lbake->do_update = 1; + eevee_lightbake_context_disable(lbake); + + return true; +} + +void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float *progress) +{ + EEVEE_LightBake *lbake = (EEVEE_LightBake *)custom_data; + Depsgraph *depsgraph = lbake->depsgraph; + int frame = 0; /* TODO make it user param. */ + + DEG_graph_relations_update(depsgraph, lbake->bmain, lbake->scene, lbake->view_layer_input); + DEG_evaluate_on_framechange(lbake->bmain, depsgraph, frame); + + lbake->view_layer = DEG_get_evaluated_view_layer(depsgraph); + lbake->stop = stop; + lbake->do_update = do_update; + lbake->progress = progress; + + /* Count lightprobes */ + eevee_lightbake_count_probes(lbake); + + /* We need to create the FBOs in the right context. + * We cannot do it in the main thread. */ + eevee_lightbake_context_enable(lbake); + eevee_lightbake_create_resources(lbake); + eevee_lightbake_create_render_target(lbake, lbake->rt_res); + eevee_lightbake_context_disable(lbake); + + /* Gather all probes data */ + eevee_lightbake_gather_probes(lbake); + + LightCache *lcache = lbake->lcache; + + /* HACK: Sleep to delay the first rendering operation + * that causes a small freeze (caused by VBO generation) + * because this step is locking at this moment. */ + /* TODO remove this. */ + if (lbake->delay) { + PIL_sleep_ms(lbake->delay); + } + + /* Render world irradiance and reflection first */ + if (lcache->flag & LIGHTCACHE_UPDATE_WORLD) { + lbake->probe = NULL; + lightbake_do_sample(lbake, eevee_lightbake_render_world_sample); + } + + /* Render irradiance grids */ + if (lcache->flag & LIGHTCACHE_UPDATE_GRID) { + for (lbake->bounce_curr = 0; lbake->bounce_curr < lbake->bounce_len; ++lbake->bounce_curr) { + /* Bypass world, start at 1. */ + lbake->probe = lbake->grid_prb + 1; + lbake->grid = lcache->grid_data + 1; + for (lbake->grid_curr = 1; + lbake->grid_curr < lbake->grid_len; + ++lbake->grid_curr, ++lbake->probe, ++lbake->grid) + { + LightProbe *prb = *lbake->probe; + lbake->grid_sample_len = prb->grid_resolution_x * + prb->grid_resolution_y * + prb->grid_resolution_z; + for (lbake->grid_sample = 0; + lbake->grid_sample < lbake->grid_sample_len; + ++lbake->grid_sample) + { + lightbake_do_sample(lbake, eevee_lightbake_render_grid_sample); + } + } + } + } + + /* Render reflections */ + if (lcache->flag & LIGHTCACHE_UPDATE_CUBE) { + /* Bypass world, start at 1. */ + lbake->probe = lbake->cube_prb + 1; + lbake->cube = lcache->cube_data + 1; + for (lbake->cube_offset = 1; + lbake->cube_offset < lbake->cube_len; + ++lbake->cube_offset, ++lbake->probe, ++lbake->cube) + { + lightbake_do_sample(lbake, eevee_lightbake_render_probe_sample); + } + } + + /* Read the resulting lighting data to save it to file/disk. */ + eevee_lightbake_context_enable(lbake); + eevee_lightbake_readback_irradiance(lcache); + eevee_lightbake_readback_reflections(lcache); + eevee_lightbake_context_disable(lbake); + + lcache->flag |= LIGHTCACHE_BAKED; + lcache->flag &= ~LIGHTCACHE_BAKING; + + /* Assume that if lbake->gl_context is NULL + * we are not running in this in a job, so update + * the scene lightcache pointer before deleting it. */ + if (lbake->gl_context == NULL) { + BLI_assert(BLI_thread_is_main()); + EEVEE_lightbake_update(lbake); + } + + eevee_lightbake_delete_resources(lbake); +} + +/* This is to update the world irradiance and reflection contribution from + * within the viewport drawing (does not have the overhead of a full light cache rebuild.) */ +void EEVEE_lightbake_update_world_quick(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, const Scene *scene) +{ + LightCache *lcache = vedata->stl->g_data->light_cache; + + EEVEE_LightBake lbake = { + .resource_only = true + }; + + /* Create resources. */ + eevee_lightbake_create_render_target(&lbake, scene->eevee.gi_cubemap_resolution); + + EEVEE_lightbake_cache_init(sldata, vedata, lbake.rt_color, lbake.rt_depth); + + EEVEE_lightbake_render_world(sldata, vedata, lbake.rt_fb); + EEVEE_lightbake_filter_glossy(sldata, vedata, lbake.rt_color, lbake.store_fb, 0, 1.0f, lcache->mips_len); + EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake.rt_color, lbake.store_fb, 0, 1.0f); + + /* Don't hide grids if they are already rendered. */ + lcache->grid_len = max_ii(1, lcache->grid_len); + lcache->cube_len = 1; + + lcache->flag |= LIGHTCACHE_CUBE_READY | LIGHTCACHE_GRID_READY; + lcache->flag &= ~LIGHTCACHE_UPDATE_WORLD; + + eevee_lightbake_delete_resources(&lbake); +} + +/** \} */ diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.h b/source/blender/draw/engines/eevee/eevee_lightcache.h new file mode 100644 index 00000000000..b58a0544c59 --- /dev/null +++ b/source/blender/draw/engines/eevee/eevee_lightcache.h @@ -0,0 +1,59 @@ +/* + * Copyright 2018, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Institute + * + */ + +/** \file eevee_lightcache.h + * \ingroup eevee + */ + +#ifndef __EEVEE_LIGHTCACHE_H__ +#define __EEVEE_LIGHTCACHE_H__ + +#include "BLI_sys_types.h" /* for bool */ + +struct ViewLayer; +struct Scene; +struct SceneEEVEE; +struct LightCache; +struct EEVEE_ViewLayerData; +struct EEVEE_Data; +struct EEVEE_LightBake; + +/* Light Bake */ +struct wmJob *EEVEE_lightbake_job_create( + struct wmWindowManager *wm, struct wmWindow *win, struct Main *bmain, + struct ViewLayer *view_layer, struct Scene *scene, int delay); +void *EEVEE_lightbake_job_data_alloc(struct Main *bmain, struct ViewLayer *viewlayer, struct Scene *scene, bool run_as_job); +void EEVEE_lightbake_job_data_free(void *custom_data); +void EEVEE_lightbake_update(void *custom_data); +void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float *progress); + +void EEVEE_lightbake_update_world_quick(struct EEVEE_ViewLayerData *sldata, struct EEVEE_Data *vedata, const Scene *scene); + +/* Light Cache */ +struct LightCache *EEVEE_lightcache_create( + const int grid_len, const int cube_len, + const int cube_size, const int vis_size, + const int irr_size[3]); +void EEVEE_lightcache_free(struct LightCache *lcache); +void EEVEE_lightcache_load(struct LightCache *lcache); +void EEVEE_lightcache_info_update(struct SceneEEVEE *eevee); + +#endif /* __EEVEE_LIGHTCACHE_H__ */ \ No newline at end of file diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 95b015cb044..1cb9a957211 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -20,7 +20,7 @@ */ /** \file eevee_lightprobes.c - * \ingroup DNA + * \ingroup draw_engine */ #include "DRW_render.h" @@ -46,27 +46,14 @@ #include "DEG_depsgraph_query.h" #include "eevee_engine.h" +#include "eevee_lightcache.h" #include "eevee_private.h" #include "ED_screen.h" -/* Rounded to nearest PowerOfTwo */ -#if defined(IRRADIANCE_SH_L2) -#define IRRADIANCE_SAMPLE_SIZE_X 4 /* 3 in reality */ -#define IRRADIANCE_SAMPLE_SIZE_Y 4 /* 3 in reality */ -#elif defined(IRRADIANCE_CUBEMAP) -#define IRRADIANCE_SAMPLE_SIZE_X 8 -#define IRRADIANCE_SAMPLE_SIZE_Y 8 -#elif defined(IRRADIANCE_HL2) -#define IRRADIANCE_SAMPLE_SIZE_X 4 /* 3 in reality */ -#define IRRADIANCE_SAMPLE_SIZE_Y 2 -#endif +#include "WM_api.h" +#include "WM_types.h" -#define IRRADIANCE_MAX_POOL_LAYER 256 /* OpenGL 3.3 core requirement, can be extended but it's already very big */ -#define IRRADIANCE_MAX_POOL_SIZE 1024 -#define MAX_IRRADIANCE_SAMPLES \ - (IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_X) * \ - (IRRADIANCE_MAX_POOL_SIZE / IRRADIANCE_SAMPLE_SIZE_Y) #define HAMMERSLEY_SIZE 1024 static struct { @@ -120,19 +107,30 @@ extern GlobalsUboStorage ts; /* *********** FUNCTIONS *********** */ -static void irradiance_pool_size_get(int visibility_size, int total_samples, int r_size[3]) +/* TODO find a better way than this. This does not support dupli objects if + * the original object is hidden. */ +bool EEVEE_lightprobes_obj_visibility_cb(bool vis_in, void *user_data) { - /* Compute how many irradiance samples we can store per visibility sample. */ - int irr_per_vis = (visibility_size / IRRADIANCE_SAMPLE_SIZE_X) * - (visibility_size / IRRADIANCE_SAMPLE_SIZE_Y); + EEVEE_ObjectEngineData *oed = (EEVEE_ObjectEngineData *)user_data; + + /* test disabled if group is NULL */ + if (oed->test_data->collection == NULL) + return vis_in; + + if (oed->test_data->cached == false) + oed->ob_vis_dirty = true; + + /* early out, don't need to compute ob_vis yet. */ + if (vis_in == false) + return vis_in; - /* The irradiance itself take one layer, hence the +1 */ - int layer_len = MIN2(irr_per_vis + 1, IRRADIANCE_MAX_POOL_LAYER); + if (oed->ob_vis_dirty) { + oed->ob_vis_dirty = false; + oed->ob_vis = BKE_collection_has_object_recursive(oed->test_data->collection, oed->ob); + oed->ob_vis = (oed->test_data->invert) ? !oed->ob_vis : oed->ob_vis; + } - int texel_len = (int)ceilf((float)total_samples / (float)(layer_len - 1)); - r_size[0] = visibility_size * max_ii(1, min_ii(texel_len, (IRRADIANCE_MAX_POOL_SIZE / visibility_size))); - r_size[1] = visibility_size * max_ii(1, (texel_len / (IRRADIANCE_MAX_POOL_SIZE / visibility_size))); - r_size[2] = layer_len; + return vis_in && oed->ob_vis; } static struct GPUTexture *create_hammersley_sample_texture(int samples) @@ -156,11 +154,11 @@ static struct GPUTexture *create_hammersley_sample_texture(int samples) static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref) { + EEVEE_TextureList *txl = vedata->txl; + /* XXX TODO OPTIMISATION : This is a complete waist of texture memory. * Instead of allocating each planar probe for each viewport, * only alloc them once using the biggest viewport resolution. */ - EEVEE_TextureList *txl = vedata->txl; - const float *viewport_size = DRW_viewport_size_get(); /* TODO get screen percentage from layer setting */ @@ -275,7 +273,7 @@ static void lightprobe_shaders_init(void) datatoc_common_view_lib_glsl, datatoc_lightprobe_cube_display_vert_glsl); - e_data.probe_cube_display_sh = DRW_shader_create(vert_str, NULL, shader_str, NULL); + e_data.probe_cube_display_sh = DRW_shader_create(vert_str, NULL, shader_str, SHADER_DEFINES); MEM_freeN(vert_str); MEM_freeN(shader_str); @@ -302,178 +300,65 @@ static void lightprobe_shaders_init(void) e_data.hammersley = create_hammersley_sample_texture(HAMMERSLEY_SIZE); } -void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *UNUSED(vedata)) +void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) { EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; - bool update_all = false; + EEVEE_StorageList *stl = vedata->stl; + const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); - /* Shaders */ if (!e_data.probe_filter_glossy_sh) { lightprobe_shaders_init(); } + if ((scene_eval->eevee.light_cache == NULL) && + (sldata->fallback_lightcache == NULL)) { +#if defined(IRRADIANCE_SH_L2) + int grid_res = 4; +#elif defined(IRRADIANCE_CUBEMAP) + int grid_res = 8; +#elif defined(IRRADIANCE_HL2) + int grid_res = 4; +#endif + int cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(scene_eval->eevee.gi_cubemap_resolution); + int vis_res = scene_eval->eevee.gi_visibility_resolution; + + sldata->fallback_lightcache = EEVEE_lightcache_create(1, 1, cube_res, vis_res, (int[3]){grid_res, grid_res, 1}); + } + + stl->g_data->light_cache = (scene_eval->eevee.light_cache) ? scene_eval->eevee.light_cache : sldata->fallback_lightcache; + + EEVEE_lightcache_load(stl->g_data->light_cache); + if (!sldata->probes) { sldata->probes = MEM_callocN(sizeof(EEVEE_LightProbesInfo), "EEVEE_LightProbesInfo"); - sldata->probes->grid_initialized = false; sldata->probe_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightProbe) * MAX_PROBE, NULL); sldata->grid_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightGrid) * MAX_GRID, NULL); sldata->planar_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_PlanarReflection) * MAX_PLANAR, NULL); } - /* Only start doing probes if all materials have finished compiling. */ - sldata->probes->all_materials_updated = true; + common_data->prb_num_planar = 0; + common_data->prb_num_render_cube = 1; + common_data->prb_num_render_grid = 1; common_data->spec_toggle = true; common_data->ssr_toggle = true; common_data->sss_toggle = true; - int prop_bounce_num = scene_eval->eevee.gi_diffuse_bounces; - if (sldata->probes->num_bounce != prop_bounce_num) { - sldata->probes->num_bounce = prop_bounce_num; - update_all = true; - } - - int prop_cubemap_res = scene_eval->eevee.gi_cubemap_resolution; - if (sldata->probes->cubemap_res != prop_cubemap_res) { - sldata->probes->cubemap_res = prop_cubemap_res; - update_all = true; - - sldata->probes->target_size = prop_cubemap_res >> 1; - - DRW_TEXTURE_FREE_SAFE(sldata->probe_depth_rt); - DRW_TEXTURE_FREE_SAFE(sldata->probe_rt); - DRW_TEXTURE_FREE_SAFE(sldata->probe_pool); - } - - const int visibility_res = scene_eval->eevee.gi_visibility_resolution; - if (common_data->prb_irradiance_vis_size != visibility_res) { - common_data->prb_irradiance_vis_size = visibility_res; - update_all = true; - } - - if (update_all) { - sldata->probes->update_world |= PROBE_UPDATE_ALL; - sldata->probes->updated_bounce = 0; - sldata->probes->grid_initialized = false; - } - - /* Setup Render Target Cubemap */ - if (!sldata->probe_rt) { - sldata->probe_depth_rt = DRW_texture_create_cube(sldata->probes->target_size, GPU_DEPTH_COMPONENT24, 0, NULL); - sldata->probe_rt = DRW_texture_create_cube(sldata->probes->target_size, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL); - } - - for (int i = 0; i < 6; ++i) { - GPU_framebuffer_ensure_config(&sldata->probe_face_fb[i], { - GPU_ATTACHMENT_TEXTURE_CUBEFACE(sldata->probe_depth_rt, i), - GPU_ATTACHMENT_TEXTURE_CUBEFACE(sldata->probe_rt, i) - }); - } - /* Placeholder planar pool: used when rendering planar reflections (avoid dependency loop). */ if (!e_data.planar_pool_placeholder) { e_data.planar_pool_placeholder = DRW_texture_create_2D_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER, NULL); } - - if (!e_data.depth_placeholder) { - e_data.depth_placeholder = DRW_texture_create_2D(1, 1, GPU_DEPTH_COMPONENT24, 0, NULL); - } - if (!e_data.depth_array_placeholder) { - e_data.depth_array_placeholder = DRW_texture_create_2D_array(1, 1, 1, GPU_DEPTH_COMPONENT24, 0, NULL); - } } -void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) +/* Only init the passes usefull for rendering the light cache. */ +void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, GPUTexture *rt_color, GPUTexture *rt_depth) { - EEVEE_TextureList *txl = vedata->txl; EEVEE_PassList *psl = vedata->psl; - EEVEE_StorageList *stl = vedata->stl; + LightCache *light_cache = vedata->stl->g_data->light_cache; EEVEE_LightProbesInfo *pinfo = sldata->probes; - /* Make sure no aditionnal visibility check runs by default. */ - pinfo->vis_data.collection = NULL; - - pinfo->do_cube_update = false; - pinfo->num_cube = 1; /* at least one for the world */ - pinfo->num_grid = 1; - pinfo->num_planar = 0; - pinfo->total_irradiance_samples = 1; - memset(pinfo->probes_cube_ref, 0, sizeof(pinfo->probes_cube_ref)); - memset(pinfo->probes_grid_ref, 0, sizeof(pinfo->probes_grid_ref)); - memset(pinfo->probes_planar_ref, 0, sizeof(pinfo->probes_planar_ref)); - - { - psl->probe_background = DRW_pass_create("World Probe Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); - - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); - DRWShadingGroup *grp = NULL; - - const DRWContextState *draw_ctx = DRW_context_state_get(); - Scene *scene = draw_ctx->scene; - World *wo = scene->world; - - float *col = ts.colorBackground; - - /* LookDev */ - EEVEE_lookdev_cache_init(vedata, &grp, e_data.probe_default_studiolight_sh, psl->probe_background, wo, pinfo); - /* END */ - if (!grp && wo) { - col = &wo->horr; - bool wo_sh_compiled = true; - - if (wo->use_nodes && wo->nodetree) { - static float error_col[3] = {1.0f, 0.0f, 1.0f}; - static float compile_col[3] = {0.5f, 0.5f, 0.5f}; - struct GPUMaterial *gpumat = EEVEE_material_world_lightprobe_get(scene, wo); - - GPUMaterialStatus status = GPU_material_status(gpumat); - - switch (status) { - case GPU_MAT_SUCCESS: - grp = DRW_shgroup_material_create(gpumat, psl->probe_background); - DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1); - DRW_shgroup_call_add(grp, geom, NULL); - wo_sh_compiled = true; - break; - case GPU_MAT_QUEUED: - pinfo->all_materials_updated = false; - wo_sh_compiled = false; - /* TODO Bypass probe compilation. */ - col = compile_col; - break; - case GPU_MAT_FAILED: - default: - wo_sh_compiled = true; - col = error_col; - break; - } - } - - if (pinfo->prev_world != wo || pinfo->prev_wo_sh_compiled != wo_sh_compiled) { - pinfo->update_world |= PROBE_UPDATE_ALL; - pinfo->studiolight_index = 0; - pinfo->prev_wo_sh_compiled = wo_sh_compiled; - pinfo->prev_world = wo; - } - } - else if (pinfo->prev_world) { - pinfo->update_world |= PROBE_UPDATE_ALL; - pinfo->studiolight_index = 0; - pinfo->prev_wo_sh_compiled = false; - pinfo->prev_world = NULL; - } - - /* Fallback if shader fails or if not using nodetree. */ - if (grp == NULL) { - grp = DRW_shgroup_create(e_data.probe_default_sh, psl->probe_background); - DRW_shgroup_uniform_vec3(grp, "color", col, 1); - DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1); - DRW_shgroup_call_add(grp, geom, NULL); - } - } - { psl->probe_glossy_compute = DRW_pass_create("LightProbe Glossy Compute", DRW_STATE_WRITE_COLOR); @@ -489,7 +374,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat DRW_shgroup_uniform_int(grp, "Layer", &pinfo->layer, 1); DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); // DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter); - DRW_shgroup_uniform_texture(grp, "probeHdr", sldata->probe_rt); + DRW_shgroup_uniform_texture(grp, "probeHdr", rt_color); DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL); } @@ -507,7 +392,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); #endif DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1); - DRW_shgroup_uniform_texture(grp, "probeHdr", sldata->probe_rt); + DRW_shgroup_uniform_texture(grp, "probeHdr", rt_color); struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); @@ -526,7 +411,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat DRW_shgroup_uniform_float(grp, "nearClip", &pinfo->near_clip, 1); DRW_shgroup_uniform_float(grp, "farClip", &pinfo->far_clip, 1); DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); - DRW_shgroup_uniform_texture(grp, "probeDepth", sldata->probe_depth_rt); + DRW_shgroup_uniform_texture(grp, "probeDepth", rt_depth); struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); @@ -536,37 +421,115 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat psl->probe_grid_fill = DRW_pass_create("LightProbe Grid Floodfill", DRW_STATE_WRITE_COLOR); DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_grid_fill_sh, psl->probe_grid_fill); - DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &sldata->irradiance_pool); + DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &light_cache->grid_tx.tex); struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); } +} + +void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) +{ + EEVEE_TextureList *txl = vedata->txl; + EEVEE_PassList *psl = vedata->psl; + EEVEE_StorageList *stl = vedata->stl; + EEVEE_LightProbesInfo *pinfo = sldata->probes; + LightCache *lcache = stl->g_data->light_cache; + const DRWContextState *draw_ctx = DRW_context_state_get(); + const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); + + pinfo->num_planar = 0; + pinfo->vis_data.collection = NULL; + pinfo->do_grid_update = false; + pinfo->do_cube_update = false; { + psl->probe_background = DRW_pass_create("World Probe Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); + + struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + DRWShadingGroup *grp = NULL; + + Scene *scene = draw_ctx->scene; + World *wo = scene->world; + + float *col = ts.colorBackground; + + /* LookDev */ + EEVEE_lookdev_cache_init(vedata, &grp, e_data.probe_default_studiolight_sh, psl->probe_background, wo, pinfo); + /* END */ + if (!grp && wo) { + col = &wo->horr; + + if (wo->use_nodes && wo->nodetree) { + static float error_col[3] = {1.0f, 0.0f, 1.0f}; + struct GPUMaterial *gpumat = EEVEE_material_world_lightprobe_get(scene, wo); + + GPUMaterialStatus status = GPU_material_status(gpumat); + + switch (status) { + case GPU_MAT_SUCCESS: + grp = DRW_shgroup_material_create(gpumat, psl->probe_background); + DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1); + DRW_shgroup_call_add(grp, geom, NULL); + break; + default: + col = error_col; + break; + } + } + } + + /* Fallback if shader fails or if not using nodetree. */ + if (grp == NULL) { + grp = DRW_shgroup_create(e_data.probe_default_sh, psl->probe_background); + DRW_shgroup_uniform_vec3(grp, "color", col, 1); + DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1); + DRW_shgroup_call_add(grp, geom, NULL); + } + } + + if (DRW_state_draw_support()) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK; psl->probe_display = DRW_pass_create("LightProbe Display", state); - DRW_shgroup_instance_format(e_data.format_probe_display_cube, { - {"probe_id", DRW_ATTRIB_INT, 1}, - {"probe_location", DRW_ATTRIB_FLOAT, 3}, - {"sphere_size", DRW_ATTRIB_FLOAT, 1}, - }); + /* Cube Display */ + if (scene_eval->eevee.flag & SCE_EEVEE_SHOW_CUBEMAPS && lcache->cube_len > 1) { + int cube_len = lcache->cube_len - 1; /* don't count the world. */ + DRWShadingGroup *grp = DRW_shgroup_empty_tri_batch_create(e_data.probe_cube_display_sh, + psl->probe_display, cube_len * 2); + DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &lcache->cube_tx.tex); + DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo); + DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); + DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2); + DRW_shgroup_uniform_float_copy(grp, "sphere_size", scene_eval->eevee.gi_cubemap_draw_size * 0.5f); + } - DRWShadingGroup *grp = DRW_shgroup_instance_create( - e_data.probe_cube_display_sh, - psl->probe_display, - DRW_cache_sphere_get(), - e_data.format_probe_display_cube); - stl->g_data->cube_display_shgrp = grp; - DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &sldata->probe_pool); - DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); + /* Grid Display */ + if (scene_eval->eevee.flag & SCE_EEVEE_SHOW_IRRADIANCE) { + EEVEE_LightGrid *egrid = lcache->grid_data + 1; + for (int p = 1; p < lcache->grid_len; ++p, egrid++) { + DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.probe_grid_display_sh, psl->probe_display); + DRW_shgroup_uniform_int(shgrp, "offset", &egrid->offset, 1); + DRW_shgroup_uniform_ivec3(shgrp, "grid_resolution", egrid->resolution, 1); + DRW_shgroup_uniform_vec3(shgrp, "corner", egrid->corner, 1); + DRW_shgroup_uniform_vec3(shgrp, "increment_x", egrid->increment_x, 1); + DRW_shgroup_uniform_vec3(shgrp, "increment_y", egrid->increment_y, 1); + DRW_shgroup_uniform_vec3(shgrp, "increment_z", egrid->increment_z, 1); + DRW_shgroup_uniform_vec3(shgrp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2); + DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &lcache->grid_tx.tex); + DRW_shgroup_uniform_float_copy(shgrp, "sphere_size", scene_eval->eevee.gi_irradiance_draw_size * 0.5f); + int tri_count = egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2] * 2; + DRW_shgroup_call_procedural_triangles_add(shgrp, tri_count, NULL); + } + } + /* Planar Display */ DRW_shgroup_instance_format(e_data.format_probe_display_planar, { {"probe_id", DRW_ATTRIB_INT, 1}, {"probe_mat", DRW_ATTRIB_FLOAT, 16}, }); - grp = DRW_shgroup_instance_create( + DRWShadingGroup *grp = DRW_shgroup_instance_create( e_data.probe_planar_display_sh, psl->probe_display, DRW_cache_quad_get(), @@ -574,6 +537,9 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat stl->g_data->planar_display_shgrp = grp; DRW_shgroup_uniform_texture_ref(grp, "probePlanars", &txl->planar_pool); } + else { + stl->g_data->planar_display_shgrp = NULL; + } { psl->probe_planar_downsample_ps = DRW_pass_create("LightProbe Planar Downsample", DRW_STATE_WRITE_COLOR); @@ -585,514 +551,560 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat } } -bool EEVEE_lightprobes_obj_visibility_cb(bool vis_in, void *user_data) +static bool eevee_lightprobes_culling_test(Object *ob) { - EEVEE_ObjectEngineData *oed = (EEVEE_ObjectEngineData *)user_data; - - /* test disabled if group is NULL */ - if (oed->test_data->collection == NULL) - return vis_in; - - if (oed->test_data->cached == false) - oed->ob_vis_dirty = true; - - /* early out, don't need to compute ob_vis yet. */ - if (vis_in == false) - return vis_in; + LightProbe *probe = (LightProbe *)ob->data; - if (oed->ob_vis_dirty) { - oed->ob_vis_dirty = false; - oed->ob_vis = BKE_collection_has_object_recursive(oed->test_data->collection, oed->ob); - oed->ob_vis = (oed->test_data->invert) ? !oed->ob_vis : oed->ob_vis; + switch (probe->type) { + case LIGHTPROBE_TYPE_PLANAR: + { + /* See if this planar probe is inside the view frustum. If not, no need to update it. */ + /* NOTE: this could be bypassed if we want feedback loop mirrors for rendering. */ + BoundBox bbox; float tmp[4][4]; + const float min[3] = {-1.0f, -1.0f, -1.0f}; + const float max[3] = { 1.0f, 1.0f, 1.0f}; + BKE_boundbox_init_from_minmax(&bbox, min, max); + + copy_m4_m4(tmp, ob->obmat); + normalize_v3(tmp[2]); + mul_v3_fl(tmp[2], probe->distinf); + + for (int v = 0; v < 8; ++v) { + mul_m4_v3(tmp, bbox.vec[v]); + } + return DRW_culling_box_test(&bbox); + } + case LIGHTPROBE_TYPE_CUBE: + return true; /* TODO */ + case LIGHTPROBE_TYPE_GRID: + return true; /* TODO */ } - - return vis_in && oed->ob_vis; + BLI_assert(0); + return true; } -void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, Object *ob) +void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *ob) { EEVEE_LightProbesInfo *pinfo = sldata->probes; LightProbe *probe = (LightProbe *)ob->data; if ((probe->type == LIGHTPROBE_TYPE_CUBE && pinfo->num_cube >= MAX_PROBE) || (probe->type == LIGHTPROBE_TYPE_GRID && pinfo->num_grid >= MAX_PROBE) || - (probe->type == LIGHTPROBE_TYPE_PLANAR && pinfo->num_grid >= MAX_PLANAR)) + (probe->type == LIGHTPROBE_TYPE_PLANAR && pinfo->num_planar >= MAX_PLANAR)) { - printf("Too much probes in the scene !!!\n"); + printf("Too many probes in the view !!!\n"); return; } if (probe->type == LIGHTPROBE_TYPE_PLANAR) { - /* See if this planar probe is inside the view frustum. If not, no need to update it. */ - /* NOTE: this could be bypassed if we want feedback loop mirrors for rendering. */ - BoundBox bbox; float tmp[4][4]; - const float min[3] = {-1.0f, -1.0f, -1.0f}; - const float max[3] = { 1.0f, 1.0f, 1.0f}; - BKE_boundbox_init_from_minmax(&bbox, min, max); - - copy_m4_m4(tmp, ob->obmat); - normalize_v3(tmp[2]); - mul_v3_fl(tmp[2], probe->distinf); - - for (int v = 0; v < 8; ++v) { - mul_m4_v3(tmp, bbox.vec[v]); - } - if (!DRW_culling_box_test(&bbox)) { + if (!eevee_lightprobes_culling_test(ob)) { return; /* Culled */ } - } - - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - - ped->num_cell = probe->grid_resolution_x * probe->grid_resolution_y * probe->grid_resolution_z; - - if ((probe->type == LIGHTPROBE_TYPE_GRID) && - ((pinfo->total_irradiance_samples + ped->num_cell) >= MAX_IRRADIANCE_SAMPLES)) - { - printf("Too much grid samples !!!\n"); - return; - } - - if (ped->need_full_update) { - ped->need_full_update = false; - - ped->need_update = true; - ped->probe_id = 0; - if (probe->type == LIGHTPROBE_TYPE_GRID) { - ped->updated_cells = 0; - ped->updated_lvl = 0; - pinfo->updated_bounce = 0; - pinfo->grid_initialized = false; + EEVEE_lightprobes_planar_data_from_object(ob, + &pinfo->planar_data[pinfo->num_planar], + &pinfo->planar_vis_tests[pinfo->num_planar]); + /* Debug Display */ + DRWShadingGroup *grp = vedata->stl->g_data->planar_display_shgrp; + if (grp && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) { + DRW_shgroup_call_dynamic_add(grp, &pinfo->num_planar, ob->obmat); } - } - if (pinfo->update_world) { - ped->need_update = true; - ped->updated_cells = 0; - ped->updated_lvl = 0; - ped->probe_id = 0; + pinfo->num_planar++; } - - pinfo->do_cube_update |= ped->need_update; - - switch (probe->type) { - case LIGHTPROBE_TYPE_CUBE: - pinfo->probes_cube_ref[pinfo->num_cube] = ob; - pinfo->num_cube++; - break; - case LIGHTPROBE_TYPE_PLANAR: - pinfo->probes_planar_ref[pinfo->num_planar] = ob; - pinfo->num_planar++; - break; - case LIGHTPROBE_TYPE_GRID: - pinfo->probes_grid_ref[pinfo->num_grid] = ob; - pinfo->num_grid++; - pinfo->total_irradiance_samples += ped->num_cell; - break; + else { + EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); + if (ped->need_update) { + if (probe->type == LIGHTPROBE_TYPE_GRID) { + pinfo->do_grid_update = true; + } + else { + pinfo->do_cube_update = true; + } + ped->need_update = false; + } } } -/* TODO find a nice name to push it to math_matrix.c */ -static void scale_m4_v3(float R[4][4], float v[3]) +void EEVEE_lightprobes_grid_data_from_object(Object *ob, EEVEE_LightGrid *egrid, int *offset) { - for (int i = 0; i < 4; ++i) - mul_v3_v3(R[i], v); + LightProbe *probe = (LightProbe *)ob->data; + + copy_v3_v3_int(egrid->resolution, &probe->grid_resolution_x); + + /* Save current offset and advance it for the next grid. */ + egrid->offset = *offset; + *offset += egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2]; + + /* Add one for level 0 */ + float fac = 1.0f / max_ff(1e-8f, probe->falloff); + egrid->attenuation_scale = fac / max_ff(1e-8f, probe->distinf); + egrid->attenuation_bias = fac; + + /* Update transforms */ + float cell_dim[3], half_cell_dim[3]; + cell_dim[0] = 2.0f / egrid->resolution[0]; + cell_dim[1] = 2.0f / egrid->resolution[1]; + cell_dim[2] = 2.0f / egrid->resolution[2]; + + mul_v3_v3fl(half_cell_dim, cell_dim, 0.5f); + + /* Matrix converting world space to cell ranges. */ + invert_m4_m4(egrid->mat, ob->obmat); + + /* First cell. */ + copy_v3_fl(egrid->corner, -1.0f); + add_v3_v3(egrid->corner, half_cell_dim); + mul_m4_v3(ob->obmat, egrid->corner); + + /* Opposite neighbor cell. */ + copy_v3_fl3(egrid->increment_x, cell_dim[0], 0.0f, 0.0f); + add_v3_v3(egrid->increment_x, half_cell_dim); + add_v3_fl(egrid->increment_x, -1.0f); + mul_m4_v3(ob->obmat, egrid->increment_x); + sub_v3_v3(egrid->increment_x, egrid->corner); + + copy_v3_fl3(egrid->increment_y, 0.0f, cell_dim[1], 0.0f); + add_v3_v3(egrid->increment_y, half_cell_dim); + add_v3_fl(egrid->increment_y, -1.0f); + mul_m4_v3(ob->obmat, egrid->increment_y); + sub_v3_v3(egrid->increment_y, egrid->corner); + + copy_v3_fl3(egrid->increment_z, 0.0f, 0.0f, cell_dim[2]); + add_v3_v3(egrid->increment_z, half_cell_dim); + add_v3_fl(egrid->increment_z, -1.0f); + mul_m4_v3(ob->obmat, egrid->increment_z); + sub_v3_v3(egrid->increment_z, egrid->corner); + + /* Visibility bias */ + egrid->visibility_bias = 0.05f * probe->vis_bias; + egrid->visibility_bleed = probe->vis_bleedbias; + egrid->visibility_range = 1.0f + sqrtf(max_fff(len_squared_v3(egrid->increment_x), + len_squared_v3(egrid->increment_y), + len_squared_v3(egrid->increment_z))); } -static void EEVEE_planar_reflections_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl) +void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *eprobe) { - EEVEE_LightProbesInfo *pinfo = sldata->probes; - Object *ob; + LightProbe *probe = (LightProbe *)ob->data; - for (int i = 0; (ob = pinfo->probes_planar_ref[i]) && (i < MAX_PLANAR); i++) { - LightProbe *probe = (LightProbe *)ob->data; - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); + /* Update transforms */ + copy_v3_v3(eprobe->position, ob->obmat[3]); - ped->probe_id = i; + /* Attenuation */ + eprobe->attenuation_type = probe->attenuation_type; + eprobe->attenuation_fac = 1.0f / max_ff(1e-8f, probe->falloff); - /* Debug Display */ - if (DRW_state_draw_support() && - (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) - { - DRW_shgroup_call_dynamic_add(stl->g_data->planar_display_shgrp, &ped->probe_id, ob->obmat); - } + unit_m4(eprobe->attenuationmat); + scale_m4_fl(eprobe->attenuationmat, probe->distinf); + mul_m4_m4m4(eprobe->attenuationmat, ob->obmat, eprobe->attenuationmat); + invert_m4(eprobe->attenuationmat); + + /* Parallax */ + unit_m4(eprobe->parallaxmat); + + if ((probe->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) { + eprobe->parallax_type = probe->parallax_type; + scale_m4_fl(eprobe->parallaxmat, probe->distpar); + } + else { + eprobe->parallax_type = probe->attenuation_type; + scale_m4_fl(eprobe->parallaxmat, probe->distinf); } + + mul_m4_m4m4(eprobe->parallaxmat, ob->obmat, eprobe->parallaxmat); + invert_m4(eprobe->parallaxmat); } -static void EEVEE_planar_reflections_updates(EEVEE_ViewLayerData *sldata) +void EEVEE_lightprobes_planar_data_from_object(Object *ob, EEVEE_PlanarReflection *eplanar, EEVEE_LightProbeVisTest *vis_test) { - EEVEE_LightProbesInfo *pinfo = sldata->probes; - Object *ob; - float mtx[4][4], normat[4][4], imat[4][4], rangemat[4][4]; - - float viewmat[4][4]; - DRW_viewport_matrix_get(viewmat, DRW_MAT_VIEW); + LightProbe *probe = (LightProbe *)ob->data; + float normat[4][4], imat[4][4]; + + vis_test->collection = probe->visibility_grp; + vis_test->invert = probe->flag & LIGHTPROBE_FLAG_INVERT_GROUP; + vis_test->cached = false; + + /* Computing mtx : matrix that mirror position around object's XY plane. */ + normalize_m4_m4(normat, ob->obmat); /* object > world */ + invert_m4_m4(imat, normat); /* world > object */ + /* XY reflection plane */ + imat[0][2] = -imat[0][2]; + imat[1][2] = -imat[1][2]; + imat[2][2] = -imat[2][2]; + imat[3][2] = -imat[3][2]; /* world > object > mirrored obj */ + mul_m4_m4m4(eplanar->mtx, normat, imat); /* world > object > mirrored obj > world */ + + /* Compute clip plane equation / normal. */ + copy_v3_v3(eplanar->plane_equation, ob->obmat[2]); + normalize_v3(eplanar->plane_equation); /* plane normal */ + eplanar->plane_equation[3] = -dot_v3v3(eplanar->plane_equation, ob->obmat[3]); + eplanar->clipsta = probe->clipsta; + + /* Compute XY clip planes. */ + normalize_v3_v3(eplanar->clip_vec_x, ob->obmat[0]); + normalize_v3_v3(eplanar->clip_vec_y, ob->obmat[1]); + + float vec[3] = {0.0f, 0.0f, 0.0f}; + vec[0] = 1.0f; vec[1] = 0.0f; vec[2] = 0.0f; + mul_m4_v3(ob->obmat, vec); /* Point on the edge */ + eplanar->clip_edge_x_pos = dot_v3v3(eplanar->clip_vec_x, vec); + + vec[0] = 0.0f; vec[1] = 1.0f; vec[2] = 0.0f; + mul_m4_v3(ob->obmat, vec); /* Point on the edge */ + eplanar->clip_edge_y_pos = dot_v3v3(eplanar->clip_vec_y, vec); + + vec[0] = -1.0f; vec[1] = 0.0f; vec[2] = 0.0f; + mul_m4_v3(ob->obmat, vec); /* Point on the edge */ + eplanar->clip_edge_x_neg = dot_v3v3(eplanar->clip_vec_x, vec); + + vec[0] = 0.0f; vec[1] = -1.0f; vec[2] = 0.0f; + mul_m4_v3(ob->obmat, vec); /* Point on the edge */ + eplanar->clip_edge_y_neg = dot_v3v3(eplanar->clip_vec_y, vec); + + /* Facing factors */ + float max_angle = max_ff(1e-2f, probe->falloff) * M_PI * 0.5f; + float min_angle = 0.0f; + eplanar->facing_scale = 1.0f / max_ff(1e-8f, cosf(min_angle) - cosf(max_angle)); + eplanar->facing_bias = -min_ff(1.0f - 1e-8f, cosf(max_angle)) * eplanar->facing_scale; + + /* Distance factors */ + float max_dist = probe->distinf; + float min_dist = min_ff(1.0f - 1e-8f, 1.0f - probe->falloff) * probe->distinf; + eplanar->attenuation_scale = -1.0f / max_ff(1e-8f, max_dist - min_dist); + eplanar->attenuation_bias = max_dist * -eplanar->attenuation_scale; +} - zero_m4(rangemat); - rangemat[0][0] = rangemat[1][1] = rangemat[2][2] = 0.5f; - rangemat[3][0] = rangemat[3][1] = rangemat[3][2] = 0.5f; - rangemat[3][3] = 1.0f; +static void lightbake_planar_compute_render_matrices( + EEVEE_PlanarReflection *eplanar, DRWMatrixState *r_matstate, const float viewmat[4][4]) +{ + /* Reflect Camera Matrix. */ + mul_m4_m4m4(r_matstate->viewmat, viewmat, eplanar->mtx); + /* TODO FOV margin */ + /* Temporal sampling jitter should be already applied to the DRW_MAT_WIN. */ + DRW_viewport_matrix_get(r_matstate->winmat, DRW_MAT_WIN); + /* Apply Projection Matrix. */ + mul_m4_m4m4(r_matstate->persmat, r_matstate->winmat, r_matstate->viewmat); + + /* This is the matrix used to reconstruct texture coordinates. + * We use the original view matrix because it does not create + * visual artifacts if receiver is not perfectly aligned with + * the planar reflection probe. */ + mul_m4_m4m4(eplanar->reflectionmat, r_matstate->winmat, viewmat); /* TODO FOV margin */ + /* Convert from [-1, 1] to [0, 1] (NDC to Texture coord). */ + mul_m4_m4m4(eplanar->reflectionmat, texcomat, eplanar->reflectionmat); +} - /* PLANAR REFLECTION */ - for (int i = 0; (ob = pinfo->probes_planar_ref[i]) && (i < MAX_PLANAR); i++) { - LightProbe *probe = (LightProbe *)ob->data; - EEVEE_PlanarReflection *eplanar = &pinfo->planar_data[i]; - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - /* Computing mtx : matrix that mirror position around object's XY plane. */ - normalize_m4_m4(normat, ob->obmat); /* object > world */ - invert_m4_m4(imat, normat); /* world > object */ - float reflect[3] = {1.0f, 1.0f, -1.0f}; /* XY reflection plane */ - scale_m4_v3(imat, reflect); /* world > object > mirrored obj */ - mul_m4_m4m4(mtx, normat, imat); /* world > object > mirrored obj > world */ - /* Reflect Camera Matrix. */ - mul_m4_m4m4(ped->mats.mat[DRW_MAT_VIEW], viewmat, mtx); - /* TODO FOV margin */ - /* Temporal sampling jitter should be already applied to the DRW_MAT_WIN. */ - DRW_viewport_matrix_get(ped->mats.mat[DRW_MAT_WIN], DRW_MAT_WIN); - /* Apply Projection Matrix. */ - mul_m4_m4m4(ped->mats.mat[DRW_MAT_PERS], ped->mats.mat[DRW_MAT_WIN], ped->mats.mat[DRW_MAT_VIEW]); - /* This is the matrix used to reconstruct texture coordinates. - * We use the original view matrix because it does not create - * visual artifacts if receiver is not perfectly aligned with - * the planar reflection probe. */ - mul_m4_m4m4(eplanar->reflectionmat, ped->mats.mat[DRW_MAT_WIN], viewmat); /* TODO FOV margin */ - /* Convert from [-1, 1] to [0, 1] (NDC to Texture coord). */ - mul_m4_m4m4(eplanar->reflectionmat, rangemat, eplanar->reflectionmat); - - /* Compute clip plane equation / normal. */ - float refpoint[3]; - copy_v3_v3(eplanar->plane_equation, ob->obmat[2]); - normalize_v3(eplanar->plane_equation); /* plane normal */ - eplanar->plane_equation[3] = -dot_v3v3(eplanar->plane_equation, ob->obmat[3]); - - /* Compute offset plane equation (fix missing texels near reflection plane). */ - copy_v3_v3(ped->planer_eq_offset, eplanar->plane_equation); - mul_v3_v3fl(refpoint, eplanar->plane_equation, -probe->clipsta); - add_v3_v3(refpoint, ob->obmat[3]); - ped->planer_eq_offset[3] = -dot_v3v3(eplanar->plane_equation, refpoint); - - /* Compute XY clip planes. */ - normalize_v3_v3(eplanar->clip_vec_x, ob->obmat[0]); - normalize_v3_v3(eplanar->clip_vec_y, ob->obmat[1]); - - float vec[3] = {0.0f, 0.0f, 0.0f}; - vec[0] = 1.0f; vec[1] = 0.0f; vec[2] = 0.0f; - mul_m4_v3(ob->obmat, vec); /* Point on the edge */ - eplanar->clip_edge_x_pos = dot_v3v3(eplanar->clip_vec_x, vec); - - vec[0] = 0.0f; vec[1] = 1.0f; vec[2] = 0.0f; - mul_m4_v3(ob->obmat, vec); /* Point on the edge */ - eplanar->clip_edge_y_pos = dot_v3v3(eplanar->clip_vec_y, vec); - - vec[0] = -1.0f; vec[1] = 0.0f; vec[2] = 0.0f; - mul_m4_v3(ob->obmat, vec); /* Point on the edge */ - eplanar->clip_edge_x_neg = dot_v3v3(eplanar->clip_vec_x, vec); - - vec[0] = 0.0f; vec[1] = -1.0f; vec[2] = 0.0f; - mul_m4_v3(ob->obmat, vec); /* Point on the edge */ - eplanar->clip_edge_y_neg = dot_v3v3(eplanar->clip_vec_y, vec); - - /* Facing factors */ - float max_angle = max_ff(1e-2f, probe->falloff) * M_PI * 0.5f; - float min_angle = 0.0f; - eplanar->facing_scale = 1.0f / max_ff(1e-8f, cosf(min_angle) - cosf(max_angle)); - eplanar->facing_bias = -min_ff(1.0f - 1e-8f, cosf(max_angle)) * eplanar->facing_scale; - - /* Distance factors */ - float max_dist = probe->distinf; - float min_dist = min_ff(1.0f - 1e-8f, 1.0f - probe->falloff) * probe->distinf; - eplanar->attenuation_scale = -1.0f / max_ff(1e-8f, max_dist - min_dist); - eplanar->attenuation_bias = max_dist * -eplanar->attenuation_scale; - } +static void eevee_lightprobes_extract_from_cache(EEVEE_LightProbesInfo *pinfo, LightCache *lcache) +{ + /* copy the entire cache for now (up to MAX_PROBE) */ + /* TODO Frutum cull to only add visible probes. */ + memcpy(pinfo->probe_data, lcache->cube_data, sizeof(EEVEE_LightProbe) * max_ii(1, min_ii(lcache->cube_len, MAX_PROBE))); + /* TODO compute the max number of grid based on sample count. */ + memcpy(pinfo->grid_data, lcache->grid_data, sizeof(EEVEE_LightGrid) * max_ii(1, min_ii(lcache->grid_len, MAX_GRID))); } -static void EEVEE_lightprobes_updates(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl, EEVEE_StorageList *stl) +void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) { + EEVEE_StorageList *stl = vedata->stl; + LightCache *light_cache = stl->g_data->light_cache; EEVEE_LightProbesInfo *pinfo = sldata->probes; - Object *ob; - - /* CUBE REFLECTION */ - for (int i = 1; (ob = pinfo->probes_cube_ref[i]) && (i < MAX_PROBE); i++) { - LightProbe *probe = (LightProbe *)ob->data; - EEVEE_LightProbe *eprobe = &pinfo->probe_data[i]; - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - /* Update transforms */ - copy_v3_v3(eprobe->position, ob->obmat[3]); + eevee_lightprobes_extract_from_cache(sldata->probes, light_cache); - /* Attenuation */ - eprobe->attenuation_type = probe->attenuation_type; - eprobe->attenuation_fac = 1.0f / max_ff(1e-8f, probe->falloff); + DRW_uniformbuffer_update(sldata->probe_ubo, &sldata->probes->probe_data); + DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data); - unit_m4(eprobe->attenuationmat); - scale_m4_fl(eprobe->attenuationmat, probe->distinf); - mul_m4_m4m4(eprobe->attenuationmat, ob->obmat, eprobe->attenuationmat); - invert_m4(eprobe->attenuationmat); + /* For shading, save max level of the octahedron map */ + sldata->common_data.prb_lod_cube_max = (float)light_cache->mips_len - 1.0f; + sldata->common_data.prb_lod_planar_max = (float)MAX_PLANAR_LOD_LEVEL; + sldata->common_data.prb_irradiance_vis_size = light_cache->vis_res; + sldata->common_data.prb_num_render_cube = max_ii(1, light_cache->cube_len); + sldata->common_data.prb_num_render_grid = max_ii(1, light_cache->grid_len); + sldata->common_data.prb_num_planar = pinfo->num_planar; - /* Parallax */ - float dist; - if ((probe->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) { - eprobe->parallax_type = probe->parallax_type; - dist = probe->distpar; - } - else { - eprobe->parallax_type = probe->attenuation_type; - dist = probe->distinf; - } + if (pinfo->num_planar != pinfo->cache_num_planar) { + DRW_TEXTURE_FREE_SAFE(vedata->txl->planar_pool); + DRW_TEXTURE_FREE_SAFE(vedata->txl->planar_depth); + pinfo->cache_num_planar = pinfo->num_planar; + } + planar_pool_ensure_alloc(vedata, pinfo->num_planar); - unit_m4(eprobe->parallaxmat); - scale_m4_fl(eprobe->parallaxmat, dist); - mul_m4_m4m4(eprobe->parallaxmat, ob->obmat, eprobe->parallaxmat); - invert_m4(eprobe->parallaxmat); + /* If lightcache auto-update is enable we tag the relevant part + * of the cache to update and fire up a baking job. */ + if (!DRW_state_is_image_render() && !DRW_state_is_opengl_render() && + (pinfo->do_grid_update || pinfo->do_cube_update)) + { + const DRWContextState *draw_ctx = DRW_context_state_get(); + BLI_assert(draw_ctx->evil_C); - /* Debug Display */ - if (DRW_state_draw_support() && - (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) - { - ped->probe_size = probe->data_draw_size * 0.1f; - DRW_shgroup_call_dynamic_add( - stl->g_data->cube_display_shgrp, &ped->probe_id, ob->obmat[3], &ped->probe_size); + if (draw_ctx->scene->eevee.flag & SCE_EEVEE_GI_AUTOBAKE) { + Scene *scene_orig = DEG_get_input_scene(draw_ctx->depsgraph); + if (scene_orig->eevee.light_cache != NULL) { + if (pinfo->do_grid_update) { + scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_GRID; + } + /* If we update grid we need to update the cubemaps too. + * So always refresh cubemaps. */ + scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_CUBE; + } + + /* Use a notifier to trigger the operator after drawing. */ + WM_event_add_notifier(draw_ctx->evil_C, NC_LIGHTPROBE, scene_orig); } } +} - /* IRRADIANCE GRID */ - int offset = 1; /* to account for the world probe */ - for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) { - LightProbe *probe = (LightProbe *)ob->data; - EEVEE_LightGrid *egrid = &pinfo->grid_data[i]; - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); +/* -------------------------------------------------------------------- */ - /* If one grid has move we need to recompute all the lighting. */ - if (!pinfo->grid_initialized) { - ped->updated_cells = 0; - ped->updated_lvl = 0; - ped->need_update = true; - } +/** \name Rendering + * \{ */ - /* Add one for level 0 */ - ped->max_lvl = 1.0f + floorf(log2f((float)MAX3(probe->grid_resolution_x, - probe->grid_resolution_y, - probe->grid_resolution_z))); - - egrid->offset = offset; - float fac = 1.0f / max_ff(1e-8f, probe->falloff); - egrid->attenuation_scale = fac / max_ff(1e-8f, probe->distinf); - egrid->attenuation_bias = fac; - - /* Set offset for the next grid */ - offset += ped->num_cell; - - /* Update transforms */ - float cell_dim[3], half_cell_dim[3]; - cell_dim[0] = 2.0f / (float)(probe->grid_resolution_x); - cell_dim[1] = 2.0f / (float)(probe->grid_resolution_y); - cell_dim[2] = 2.0f / (float)(probe->grid_resolution_z); - - mul_v3_v3fl(half_cell_dim, cell_dim, 0.5f); - - /* Matrix converting world space to cell ranges. */ - invert_m4_m4(egrid->mat, ob->obmat); - - /* First cell. */ - copy_v3_fl(egrid->corner, -1.0f); - add_v3_v3(egrid->corner, half_cell_dim); - mul_m4_v3(ob->obmat, egrid->corner); - - /* Opposite neighbor cell. */ - copy_v3_fl3(egrid->increment_x, cell_dim[0], 0.0f, 0.0f); - add_v3_v3(egrid->increment_x, half_cell_dim); - add_v3_fl(egrid->increment_x, -1.0f); - mul_m4_v3(ob->obmat, egrid->increment_x); - sub_v3_v3(egrid->increment_x, egrid->corner); - - copy_v3_fl3(egrid->increment_y, 0.0f, cell_dim[1], 0.0f); - add_v3_v3(egrid->increment_y, half_cell_dim); - add_v3_fl(egrid->increment_y, -1.0f); - mul_m4_v3(ob->obmat, egrid->increment_y); - sub_v3_v3(egrid->increment_y, egrid->corner); - - copy_v3_fl3(egrid->increment_z, 0.0f, 0.0f, cell_dim[2]); - add_v3_v3(egrid->increment_z, half_cell_dim); - add_v3_fl(egrid->increment_z, -1.0f); - mul_m4_v3(ob->obmat, egrid->increment_z); - sub_v3_v3(egrid->increment_z, egrid->corner); - - copy_v3_v3_int(egrid->resolution, &probe->grid_resolution_x); - - /* Visibility bias */ - egrid->visibility_bias = 0.05f * probe->vis_bias; - egrid->visibility_bleed = probe->vis_bleedbias; - egrid->visibility_range = ( - sqrtf(max_fff(len_squared_v3(egrid->increment_x), - len_squared_v3(egrid->increment_y), - len_squared_v3(egrid->increment_z))) + 1.0f); +typedef struct EEVEE_BakeRenderData{ + EEVEE_Data *vedata; + EEVEE_ViewLayerData *sldata; + struct GPUFrameBuffer **face_fb; /* should contain 6 framebuffer */ +} EEVEE_BakeRenderData; - /* Debug Display */ - if (DRW_state_draw_support() && - (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) - { - DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_grid_display_sh, psl->probe_display); - DRW_shgroup_uniform_int(grp, "offset", &egrid->offset, 1); - DRW_shgroup_uniform_ivec3(grp, "grid_resolution", egrid->resolution, 1); - DRW_shgroup_uniform_vec3(grp, "corner", egrid->corner, 1); - DRW_shgroup_uniform_vec3(grp, "increment_x", egrid->increment_x, 1); - DRW_shgroup_uniform_vec3(grp, "increment_y", egrid->increment_y, 1); - DRW_shgroup_uniform_vec3(grp, "increment_z", egrid->increment_z, 1); - DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &sldata->irradiance_pool); - DRW_shgroup_uniform_float(grp, "sphere_size", &probe->data_draw_size, 1); - DRW_shgroup_call_instances_add(grp, DRW_cache_sphere_get(), NULL, (uint *)&ped->num_cell); - } +static void render_cubemap( + void (*callback)(int face, EEVEE_BakeRenderData *user_data), EEVEE_BakeRenderData *user_data, + const float pos[3], float clipsta, float clipend) +{ + DRWMatrixState matstate; + + /* Move to capture position */ + float posmat[4][4]; + unit_m4(posmat); + negate_v3_v3(posmat[3], pos); + + perspective_m4(matstate.winmat, -clipsta, clipsta, -clipsta, clipsta, clipsta, clipend); + invert_m4_m4(matstate.wininv, matstate.winmat); + + /* 1 - Render to each cubeface individually. + * We do this instead of using geometry shader because a) it's faster, + * b) it's easier than fixing the nodetree shaders (for view dependant effects). */ + for (int i = 0; i < 6; ++i) { + /* Setup custom matrices */ + mul_m4_m4m4(matstate.viewmat, cubefacemat[i], posmat); + mul_m4_m4m4(matstate.persmat, matstate.winmat, matstate.viewmat); + invert_m4_m4(matstate.persinv, matstate.persmat); + invert_m4_m4(matstate.viewinv, matstate.viewmat); + invert_m4_m4(matstate.wininv, matstate.winmat); + + DRW_viewport_matrix_override_set_all(&matstate); + + callback(i, user_data); } } -void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) +static void render_reflections( + void (*callback)(int face, EEVEE_BakeRenderData *user_data), EEVEE_BakeRenderData *user_data, + EEVEE_PlanarReflection *planar_data, int ref_count) { - EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; - EEVEE_LightProbesInfo *pinfo = sldata->probes; - Object *ob; + DRWMatrixState matstate; - /* Setup enough layers. */ - /* Free textures if number mismatch. */ - if (pinfo->num_cube != pinfo->cache_num_cube) { - DRW_TEXTURE_FREE_SAFE(sldata->probe_pool); - pinfo->cache_num_cube = pinfo->num_cube; - } + float original_viewmat[4][4]; + DRW_viewport_matrix_get(original_viewmat, DRW_MAT_VIEW); - if (pinfo->num_planar != pinfo->cache_num_planar) { - DRW_TEXTURE_FREE_SAFE(vedata->txl->planar_pool); - DRW_TEXTURE_FREE_SAFE(vedata->txl->planar_depth); - pinfo->cache_num_planar = pinfo->num_planar; - } - - int irr_size[3]; - irradiance_pool_size_get(common_data->prb_irradiance_vis_size, pinfo->total_irradiance_samples, irr_size); + for (int i = 0; i < ref_count; ++i) { + /* Setup custom matrices */ + lightbake_planar_compute_render_matrices(planar_data + i, &matstate, original_viewmat); + invert_m4_m4(matstate.persinv, matstate.persmat); + invert_m4_m4(matstate.viewinv, matstate.viewmat); + invert_m4_m4(matstate.wininv, matstate.winmat); + DRW_viewport_matrix_override_set_all(&matstate); - if ((irr_size[0] != pinfo->cache_irradiance_size[0]) || - (irr_size[1] != pinfo->cache_irradiance_size[1]) || - (irr_size[2] != pinfo->cache_irradiance_size[2])) - { - DRW_TEXTURE_FREE_SAFE(sldata->irradiance_pool); - DRW_TEXTURE_FREE_SAFE(sldata->irradiance_rt); - copy_v3_v3_int(pinfo->cache_irradiance_size, irr_size); + callback(i, user_data); } +} - /* XXX this should be run each frame as it ensure planar_depth is set */ - planar_pool_ensure_alloc(vedata, pinfo->num_planar); +static void lightbake_render_world_face(int face, EEVEE_BakeRenderData *user_data) +{ + EEVEE_PassList *psl = user_data->vedata->psl; + struct GPUFrameBuffer **face_fb = user_data->face_fb; - if (!sldata->probe_pool) { - sldata->probe_pool = DRW_texture_create_2D_array(pinfo->cubemap_res, pinfo->cubemap_res, max_ff(1, pinfo->num_cube), - GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL); - if (sldata->probe_filter_fb) { - GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0); - } - /* Tag probes to refresh */ - pinfo->update_world |= PROBE_UPDATE_CUBE; - } + /* For world probe, we don't need to clear the color buffer + * since we render the background directly. */ + GPU_framebuffer_bind(face_fb[face]); + GPU_framebuffer_clear_depth(face_fb[face], 1.0f); + DRW_draw_pass(psl->probe_background); +} - if ((pinfo->update_world & PROBE_UPDATE_CUBE) != 0) { - common_data->prb_num_render_cube = 0; - for (int i = 1; (ob = pinfo->probes_cube_ref[i]) && (i < MAX_PROBE); i++) { - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - ped->need_update = true; - ped->ready_to_shade = false; - ped->probe_id = 0; - } - } +void EEVEE_lightbake_render_world(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata, struct GPUFrameBuffer *face_fb[6]) +{ + EEVEE_BakeRenderData brdata = { + .vedata = vedata, + .face_fb = face_fb + }; -#ifdef IRRADIANCE_SH_L2 - /* we need a signed format for Spherical Harmonics */ - int irradiance_format = GPU_RGBA16F; -#else - int irradiance_format = GPU_RGBA8; -#endif + render_cubemap(lightbake_render_world_face, &brdata, (float[3]){0.0f}, 1.0f, 10.0f); +} - if (!sldata->irradiance_pool || !sldata->irradiance_rt) { - if (!sldata->irradiance_pool) { - sldata->irradiance_pool = DRW_texture_create_2D_array(irr_size[0], irr_size[1], irr_size[2], - irradiance_format, DRW_TEX_FILTER, NULL); - } - if (!sldata->irradiance_rt) { - sldata->irradiance_rt = DRW_texture_create_2D_array(irr_size[0], irr_size[1], irr_size[2], - irradiance_format, DRW_TEX_FILTER, NULL); - } - /* Tag probes to refresh */ - pinfo->update_world |= PROBE_UPDATE_GRID; - pinfo->grid_initialized = false; - } +static void lightbake_render_scene_face(int face, EEVEE_BakeRenderData *user_data) +{ + EEVEE_ViewLayerData *sldata = user_data->sldata; + EEVEE_PassList *psl = user_data->vedata->psl; + struct GPUFrameBuffer **face_fb = user_data->face_fb; - if ((pinfo->update_world & PROBE_UPDATE_GRID) != 0) { - common_data->prb_num_render_grid = 0; - pinfo->updated_bounce = 0; - for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_PROBE); i++) { - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - ped->need_update = true; - ped->updated_cells = 0; - } - } + /* Be sure that cascaded shadow maps are updated. */ + EEVEE_draw_shadows(sldata, psl); - if (common_data->prb_num_render_grid > pinfo->num_grid) { - /* This can happen when deleting a probe. */ - common_data->prb_num_render_grid = pinfo->num_grid; - } + GPU_framebuffer_bind(face_fb[face]); + GPU_framebuffer_clear_depth(face_fb[face], 1.0f); - EEVEE_planar_reflections_cache_finish(sldata, vedata->stl); + DRW_draw_pass(psl->depth_pass); + DRW_draw_pass(psl->depth_pass_cull); + DRW_draw_pass(psl->probe_background); + DRW_draw_pass(psl->material_pass); + DRW_draw_pass(psl->sss_pass); /* Only output standard pass */ + EEVEE_draw_default_passes(psl); +} - EEVEE_lightprobes_updates(sldata, vedata->psl, vedata->stl); +/* Render the scene to the probe_rt texture. */ +void EEVEE_lightbake_render_scene( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUFrameBuffer *face_fb[6], + const float pos[3], float near_clip, float far_clip) +{ + EEVEE_BakeRenderData brdata = { + .vedata = vedata, + .sldata = sldata, + .face_fb = face_fb + }; - DRW_uniformbuffer_update(sldata->probe_ubo, &sldata->probes->probe_data); - DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data); + render_cubemap(lightbake_render_scene_face, &brdata, pos, near_clip, far_clip); } -static void downsample_planar(void *vedata, int level) +static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *user_data) { - EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; - EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; + EEVEE_Data *vedata = user_data->vedata; + EEVEE_ViewLayerData *sldata = user_data->sldata; + EEVEE_PassList *psl = vedata->psl; + EEVEE_TextureList *txl = vedata->txl; + EEVEE_FramebufferList *fbl = vedata->fbl; + EEVEE_LightProbesInfo *pinfo = sldata->probes; + EEVEE_PlanarReflection *eplanar = pinfo->planar_data + layer; - const float *size = DRW_viewport_size_get(); - copy_v2_v2(stl->g_data->planar_texel_size, size); - for (int i = 0; i < level - 1; ++i) { - stl->g_data->planar_texel_size[0] /= 2.0f; - stl->g_data->planar_texel_size[1] /= 2.0f; - min_ff(floorf(stl->g_data->planar_texel_size[0]), 1.0f); - min_ff(floorf(stl->g_data->planar_texel_size[1]), 1.0f); + GPU_framebuffer_ensure_config(&fbl->planarref_fb, { + GPU_ATTACHMENT_TEXTURE_LAYER(txl->planar_depth, layer), + GPU_ATTACHMENT_TEXTURE_LAYER(txl->planar_pool, layer) + }); + + /* Use visibility info for this planar reflection. */ + pinfo->vis_data = pinfo->planar_vis_tests[layer]; + + /* Avoid using the texture attached to framebuffer when rendering. */ + /* XXX */ + GPUTexture *tmp_planar_pool = txl->planar_pool; + GPUTexture *tmp_planar_depth = txl->planar_depth; + txl->planar_pool = e_data.planar_pool_placeholder; + txl->planar_depth = e_data.depth_array_placeholder; + + /* Be sure that cascaded shadow maps are updated. */ + DRW_stats_group_start("Planar Reflection"); + + /* Be sure that cascaded shadow maps are updated. */ + EEVEE_draw_shadows(sldata, psl); + /* Since we are rendering with an inverted view matrix, we need + * to invert the facing for backface culling to be the same. */ + DRW_state_invert_facing(); + /* Compute offset plane equation (fix missing texels near reflection plane). */ + copy_v4_v4(sldata->clip_data.clip_planes[0], eplanar->plane_equation); + sldata->clip_data.clip_planes[0][3] += eplanar->clipsta; + /* Set clipping plane */ + DRW_uniformbuffer_update(sldata->clip_ubo, &sldata->clip_data); + DRW_state_clip_planes_count_set(1); + + GPU_framebuffer_bind(fbl->planarref_fb); + GPU_framebuffer_clear_depth(fbl->planarref_fb, 1.0); + + /* Slight modification: we handle refraction as normal + * shading and don't do SSRefraction. */ + + DRW_draw_pass(psl->depth_pass_clip); + DRW_draw_pass(psl->depth_pass_clip_cull); + DRW_draw_pass(psl->refract_depth_pass); + DRW_draw_pass(psl->refract_depth_pass_cull); + + DRW_draw_pass(psl->probe_background); + EEVEE_create_minmax_buffer(vedata, tmp_planar_depth, layer); + EEVEE_occlusion_compute(sldata, vedata, tmp_planar_depth, layer); + + GPU_framebuffer_bind(fbl->planarref_fb); + + /* Shading pass */ + EEVEE_draw_default_passes(psl); + DRW_draw_pass(psl->material_pass); + DRW_draw_pass(psl->sss_pass); /* Only output standard pass */ + DRW_draw_pass(psl->refract_pass); + + /* Transparent */ + if (DRW_state_is_image_render()) { + /* Do the reordering only for offline because it can be costly. */ + DRW_pass_sort_shgroup_z(psl->transparent_pass); } - invert_v2(stl->g_data->planar_texel_size); + DRW_draw_pass(psl->transparent_pass); - DRW_draw_pass(psl->probe_planar_downsample_ps); + DRW_state_invert_facing(); + DRW_state_clip_planes_reset(); + + DRW_stats_group_end(); + + /* Restore */ + txl->planar_pool = tmp_planar_pool; + txl->planar_depth = tmp_planar_depth; +} + +static void eevee_lightbake_render_scene_to_planars( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) +{ + EEVEE_BakeRenderData brdata = { + .vedata = vedata, + .sldata = sldata, + }; + + render_reflections(lightbake_render_scene_reflected, &brdata, sldata->probes->planar_data, sldata->probes->num_planar); } +/** \} */ -/* Glossy filter probe_rt to probe_pool at index probe_idx */ -static void glossy_filter_probe( - EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, EEVEE_PassList *psl, int probe_idx, float intensity) +/* -------------------------------------------------------------------- */ + +/** \name Filtering + * \{ */ + +/* Glossy filter rt_color to light_cache->cube_tx.tex at index probe_idx */ +void EEVEE_lightbake_filter_glossy( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, + struct GPUTexture *rt_color, struct GPUFrameBuffer *fb, + int probe_idx, float intensity, int maxlevel) { + EEVEE_PassList *psl = vedata->psl; EEVEE_LightProbesInfo *pinfo = sldata->probes; + LightCache *light_cache = vedata->stl->g_data->light_cache; - pinfo->intensity_fac = intensity; + float target_size = (float)GPU_texture_width(rt_color); /* Max lod used from the render target probe */ - pinfo->lod_rt_max = floorf(log2f(pinfo->target_size)) - 2.0f; + pinfo->lod_rt_max = floorf(log2f(target_size)) - 2.0f; + pinfo->intensity_fac = intensity; /* Start fresh */ - GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, { + GPU_framebuffer_ensure_config(&fb, { GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_NONE }); /* 2 - Let gpu create Mipmaps for Filtered Importance Sampling. */ /* Bind next framebuffer to be able to gen. mips for probe_rt. */ - EEVEE_downsample_cube_buffer(vedata, sldata->probe_rt, (int)(pinfo->lod_rt_max)); + EEVEE_downsample_cube_buffer(vedata, rt_color, (int)(pinfo->lod_rt_max)); /* 3 - Render to probe array to the specified layer, do prefiltering. */ - float mipsize = pinfo->cubemap_res; - const int maxlevel = (int)floorf(log2f(pinfo->cubemap_res)); - const int min_lod_level = 3; - for (int i = 0; i < maxlevel - min_lod_level; i++) { + int mipsize = GPU_texture_width(light_cache->cube_tx.tex); + for (int i = 0; i < maxlevel + 1; i++) { float bias = (i == 0) ? -1.0f : 1.0f; - pinfo->texel_size = 1.0f / mipsize; - pinfo->padding_size = powf(2.0f, (float)(maxlevel - min_lod_level - 1 - i)); + pinfo->texel_size = 1.0f / (float)mipsize; + pinfo->padding_size = (float)(1 << (maxlevel - i - 1)); pinfo->padding_size *= pinfo->texel_size; pinfo->layer = probe_idx; - pinfo->roughness = (float)i / ((float)maxlevel - 4.0f); + pinfo->roughness = i / (float)maxlevel; pinfo->roughness *= pinfo->roughness; /* Disney Roughness */ pinfo->roughness *= pinfo->roughness; /* Distribute Roughness accros lod more evenly */ CLAMP(pinfo->roughness, 1e-8f, 0.99999f); /* Avoid artifacts */ @@ -1110,35 +1122,34 @@ static void glossy_filter_probe( #endif pinfo->samples_len_inv = 1.0f / pinfo->samples_len; - pinfo->lodfactor = bias + 0.5f * log((float)(pinfo->target_size * pinfo->target_size) * pinfo->samples_len_inv) / log(2); + pinfo->lodfactor = bias + 0.5f * log((float)(target_size * target_size) * pinfo->samples_len_inv) / log(2); - GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, { + GPU_framebuffer_ensure_config(&fb, { GPU_ATTACHMENT_NONE, - GPU_ATTACHMENT_TEXTURE_MIP(sldata->probe_pool, i) + GPU_ATTACHMENT_TEXTURE_MIP(light_cache->cube_tx.tex, i) }); - GPU_framebuffer_bind(sldata->probe_filter_fb); - GPU_framebuffer_viewport_set(sldata->probe_filter_fb, 0, 0, mipsize, mipsize); + GPU_framebuffer_bind(fb); + GPU_framebuffer_viewport_set(fb, 0, 0, mipsize, mipsize); DRW_draw_pass(psl->probe_glossy_compute); mipsize /= 2; CLAMP_MIN(mipsize, 1); } - /* For shading, save max level of the octahedron map */ - sldata->common_data.prb_lod_cube_max = (float)(maxlevel - min_lod_level) - 1.0f; } -/* Diffuse filter probe_rt to irradiance_pool at index probe_idx */ -static void diffuse_filter_probe( - EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, EEVEE_PassList *psl, int offset, - float clipsta, float clipend, float vis_range, float vis_blur, float intensity) +/* Diffuse filter rt_color to light_cache->grid_tx.tex at index grid_offset */ +void EEVEE_lightbake_filter_diffuse( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, + struct GPUTexture *rt_color, struct GPUFrameBuffer *fb, + int grid_offset, float intensity) { - EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; + EEVEE_PassList *psl = vedata->psl; EEVEE_LightProbesInfo *pinfo = sldata->probes; + LightCache *light_cache = vedata->stl->g_data->light_cache; - pinfo->intensity_fac = intensity; + float target_size = (float)GPU_texture_width(rt_color); - int pool_size[3]; - irradiance_pool_size_get(common_data->prb_irradiance_vis_size, pinfo->total_irradiance_samples, pool_size); + pinfo->intensity_fac = intensity; /* find cell position on the virtual 3D texture */ /* NOTE : Keep in sync with load_irradiance_cell() */ @@ -1152,377 +1163,114 @@ static void diffuse_filter_probe( pinfo->samples_len = 1024.0f; #endif - int cell_per_row = pool_size[0] / size[0]; - int x = size[0] * (offset % cell_per_row); - int y = size[1] * (offset / cell_per_row); + int cell_per_row = GPU_texture_width(light_cache->grid_tx.tex) / size[0]; + int x = size[0] * (grid_offset % cell_per_row); + int y = size[1] * (grid_offset / cell_per_row); #ifndef IRRADIANCE_SH_L2 /* Tweaking parameters to balance perf. vs precision */ const float bias = 0.0f; pinfo->samples_len_inv = 1.0f / pinfo->samples_len; - pinfo->lodfactor = bias + 0.5f * log((float)(pinfo->target_size * pinfo->target_size) * pinfo->samples_len_inv) / log(2); - pinfo->lod_rt_max = floorf(log2f(pinfo->target_size)) - 2.0f; + pinfo->lodfactor = bias + 0.5f * log((float)(target_size * target_size) * pinfo->samples_len_inv) / log(2); + pinfo->lod_rt_max = floorf(log2f(target_size)) - 2.0f; #else pinfo->shres = 32; /* Less texture fetches & reduce branches */ pinfo->lod_rt_max = 2.0f; /* Improve cache reuse */ #endif /* Start fresh */ - GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, { + GPU_framebuffer_ensure_config(&fb, { GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_NONE }); - /* 4 - Compute spherical harmonics */ - EEVEE_downsample_cube_buffer(vedata, sldata->probe_rt, (int)(pinfo->lod_rt_max)); + /* 4 - Compute diffuse irradiance */ + EEVEE_downsample_cube_buffer(vedata, rt_color, (int)(pinfo->lod_rt_max)); - GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, { + GPU_framebuffer_ensure_config(&fb, { GPU_ATTACHMENT_NONE, - GPU_ATTACHMENT_TEXTURE_LAYER(sldata->irradiance_rt, 0) + GPU_ATTACHMENT_TEXTURE_LAYER(light_cache->grid_tx.tex, 0) }); - GPU_framebuffer_bind(sldata->probe_filter_fb); - GPU_framebuffer_viewport_set(sldata->probe_filter_fb, x, y, size[0], size[1]); + GPU_framebuffer_bind(fb); + GPU_framebuffer_viewport_set(fb, x, y, size[0], size[1]); DRW_draw_pass(psl->probe_diffuse_compute); - - /* World irradiance have no visibility */ - if (offset > 0) { - /* Compute visibility */ - pinfo->samples_len = 512.0f; /* TODO refine */ - pinfo->samples_len_inv = 1.0f / pinfo->samples_len; - pinfo->shres = common_data->prb_irradiance_vis_size; - pinfo->visibility_range = vis_range; - pinfo->visibility_blur = vis_blur; - pinfo->near_clip = -clipsta; - pinfo->far_clip = -clipend; - pinfo->texel_size = 1.0f / (float)common_data->prb_irradiance_vis_size; - - int cell_per_col = pool_size[1] / common_data->prb_irradiance_vis_size; - cell_per_row = pool_size[0] / common_data->prb_irradiance_vis_size; - x = common_data->prb_irradiance_vis_size * (offset % cell_per_row); - y = common_data->prb_irradiance_vis_size * ((offset / cell_per_row) % cell_per_col); - int layer = 1 + ((offset / cell_per_row) / cell_per_col); - const int vis_size = common_data->prb_irradiance_vis_size; - - GPU_framebuffer_ensure_config(&sldata->probe_filter_fb, { - GPU_ATTACHMENT_NONE, - GPU_ATTACHMENT_TEXTURE_LAYER(sldata->irradiance_rt, layer) - }); - GPU_framebuffer_bind(sldata->probe_filter_fb); - GPU_framebuffer_viewport_set(sldata->probe_filter_fb, x, y, vis_size, vis_size); - DRW_draw_pass(psl->probe_visibility_compute); - } } -/* Render the scene to the probe_rt texture. */ -static void render_scene_to_probe( +/* Filter rt_depth to light_cache->grid_tx.tex at index grid_offset */ +void EEVEE_lightbake_filter_visibility( EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, - const float pos[3], float clipsta, float clipend) + struct GPUTexture *UNUSED(rt_depth), struct GPUFrameBuffer *fb, + int grid_offset, float clipsta, float clipend, + float vis_range, float vis_blur, int vis_size) { - EEVEE_TextureList *txl = vedata->txl; EEVEE_PassList *psl = vedata->psl; EEVEE_LightProbesInfo *pinfo = sldata->probes; + LightCache *light_cache = vedata->stl->g_data->light_cache; - DRWMatrixState matstate; - float (*viewmat)[4] = matstate.mat[DRW_MAT_VIEW]; - float (*viewinv)[4] = matstate.mat[DRW_MAT_VIEWINV]; - float (*persmat)[4] = matstate.mat[DRW_MAT_PERS]; - float (*persinv)[4] = matstate.mat[DRW_MAT_PERSINV]; - float (*winmat)[4] = matstate.mat[DRW_MAT_WIN]; - float (*wininv)[4] = matstate.mat[DRW_MAT_WININV]; - - float posmat[4][4]; - unit_m4(posmat); - - /* Move to capture position */ - negate_v3_v3(posmat[3], pos); - - /* 1 - Render to each cube-face individually. - * We do this instead of using geometry shader because a) it's faster, - * b) it's easier than fixing the node-tree shaders (for view dependent effects). */ - pinfo->layer = 0; - perspective_m4(winmat, -clipsta, clipsta, -clipsta, clipsta, clipsta, clipend); - - /* Avoid using the texture attached to framebuffer when rendering. */ - /* XXX */ - GPUTexture *tmp_planar_pool = txl->planar_pool; - GPUTexture *tmp_maxz = txl->maxzbuffer; - txl->planar_pool = e_data.planar_pool_placeholder; - txl->maxzbuffer = e_data.depth_placeholder; - - DRW_stats_group_start("Cubemap Render"); - - /* Update common uniforms */ - DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); - - for (int i = 0; i < 6; ++i) { - /* Recompute only on 1st drawloop. */ - pinfo->vis_data.cached = (i != 0); - - DRW_stats_group_start("Cubemap Face"); - - /* Setup custom matrices */ - mul_m4_m4m4(viewmat, cubefacemat[i], posmat); - mul_m4_m4m4(persmat, winmat, viewmat); - invert_m4_m4(persinv, persmat); - invert_m4_m4(viewinv, viewmat); - invert_m4_m4(wininv, winmat); - - DRW_viewport_matrix_override_set_all(&matstate); - - /* Be sure that cascaded shadow maps are updated. */ - EEVEE_draw_shadows(sldata, psl); - - GPU_framebuffer_bind(sldata->probe_face_fb[i]); - GPU_framebuffer_clear_depth(sldata->probe_face_fb[i], 1.0); - - /* Depth prepass */ - DRW_draw_pass(psl->depth_pass); - DRW_draw_pass(psl->depth_pass_cull); - - DRW_draw_pass(psl->probe_background); - - // EEVEE_create_minmax_buffer(vedata, sldata->probe_depth_rt); - - /* Rebind Target FB */ - GPU_framebuffer_bind(sldata->probe_face_fb[i]); - - /* Shading pass */ - EEVEE_draw_default_passes(psl); - DRW_draw_pass(psl->material_pass); - DRW_draw_pass(psl->sss_pass); /* Only output standard pass */ - - DRW_stats_group_end(); - } - - DRW_stats_group_end(); - - /* Make sure no aditionnal visibility check runs after this. */ - pinfo->vis_data.collection = NULL; - - /* Restore */ - txl->planar_pool = tmp_planar_pool; - txl->maxzbuffer = tmp_maxz; -} - -static void render_scene_to_planar( - EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, int layer, - EEVEE_LightProbeEngineData *ped) -{ - EEVEE_LightProbesInfo *pinfo = sldata->probes; - EEVEE_FramebufferList *fbl = vedata->fbl; - EEVEE_TextureList *txl = vedata->txl; - EEVEE_PassList *psl = vedata->psl; - - float (*viewmat)[4] = ped->mats.mat[DRW_MAT_VIEW]; - float (*viewinv)[4] = ped->mats.mat[DRW_MAT_VIEWINV]; - float (*persmat)[4] = ped->mats.mat[DRW_MAT_PERS]; - float (*persinv)[4] = ped->mats.mat[DRW_MAT_PERSINV]; - float (*winmat)[4] = ped->mats.mat[DRW_MAT_WIN]; - float (*wininv)[4] = ped->mats.mat[DRW_MAT_WININV]; - - invert_m4_m4(viewinv, viewmat); - invert_m4_m4(persinv, persmat); - invert_m4_m4(wininv, winmat); - - DRW_stats_group_start("Planar Reflection"); - - DRW_viewport_matrix_override_set_all(&ped->mats); - - /* Don't reuse previous visibility. */ - pinfo->vis_data.cached = false; - - /* Be sure that cascaded shadow maps are updated. */ - EEVEE_draw_shadows(sldata, psl); - - /* Since we are rendering with an inverted view matrix, we need - * to invert the facing for back-face culling to be the same. */ - DRW_state_invert_facing(); - /* Set clipping plan */ - copy_v4_v4(sldata->clip_data.clip_planes[0], ped->planer_eq_offset); - DRW_uniformbuffer_update(sldata->clip_ubo, &sldata->clip_data); - DRW_state_clip_planes_count_set(1); - - GPU_framebuffer_ensure_config(&fbl->planarref_fb, { - GPU_ATTACHMENT_TEXTURE_LAYER(txl->planar_depth, layer), - GPU_ATTACHMENT_TEXTURE_LAYER(txl->planar_pool, layer) + pinfo->samples_len = 512.0f; /* TODO refine */ + pinfo->samples_len_inv = 1.0f / pinfo->samples_len; + pinfo->shres = vis_size; + pinfo->visibility_range = vis_range; + pinfo->visibility_blur = vis_blur; + pinfo->near_clip = -clipsta; + pinfo->far_clip = -clipend; + pinfo->texel_size = 1.0f / (float)vis_size; + + int cell_per_col = GPU_texture_height(light_cache->grid_tx.tex) / vis_size; + int cell_per_row = GPU_texture_width(light_cache->grid_tx.tex) / vis_size; + int x = vis_size * (grid_offset % cell_per_row); + int y = vis_size * ((grid_offset / cell_per_row) % cell_per_col); + int layer = 1 + ((grid_offset / cell_per_row) / cell_per_col); + + GPU_framebuffer_ensure_config(&fb, { + GPU_ATTACHMENT_NONE, + GPU_ATTACHMENT_TEXTURE_LAYER(light_cache->grid_tx.tex, layer) }); - - GPU_framebuffer_bind(fbl->planarref_fb); - GPU_framebuffer_clear_depth(fbl->planarref_fb, 1.0); - - /* Avoid using the texture attached to framebuffer when rendering. */ - /* XXX */ - GPUTexture *tmp_planar_pool = txl->planar_pool; - GPUTexture *tmp_planar_depth = txl->planar_depth; - txl->planar_pool = e_data.planar_pool_placeholder; - txl->planar_depth = e_data.depth_array_placeholder; - - /* Slight modification: we handle refraction as normal - * shading and don't do SSRefraction. */ - - /* Depth prepass */ - DRW_draw_pass(psl->depth_pass_clip); - DRW_draw_pass(psl->depth_pass_clip_cull); - DRW_draw_pass(psl->refract_depth_pass); - DRW_draw_pass(psl->refract_depth_pass_cull); - - /* Background */ - DRW_draw_pass(psl->probe_background); - - EEVEE_create_minmax_buffer(vedata, tmp_planar_depth, layer); - - /* Compute GTAO Horizons */ - EEVEE_occlusion_compute(sldata, vedata, tmp_planar_depth, layer); - - /* Rebind Planar FB */ - GPU_framebuffer_bind(fbl->planarref_fb); - - /* Shading pass */ - EEVEE_draw_default_passes(psl); - DRW_draw_pass(psl->material_pass); - DRW_draw_pass(psl->sss_pass); /* Only output standard pass */ - DRW_draw_pass(psl->refract_pass); - - /* Transparent */ - if (DRW_state_is_image_render()) { - /* Do the reordering only for offline because it can be costly. */ - DRW_pass_sort_shgroup_z(psl->transparent_pass); - } - DRW_draw_pass(psl->transparent_pass); - - DRW_state_invert_facing(); - DRW_state_clip_planes_reset(); - - DRW_stats_group_end(); - - /* Make sure no aditionnal visibility check runs after this. */ - pinfo->vis_data.collection = NULL; - - /* Restore */ - txl->planar_pool = tmp_planar_pool; - txl->planar_depth = tmp_planar_depth; + GPU_framebuffer_bind(fb); + GPU_framebuffer_viewport_set(fb, x, y, vis_size, vis_size); + DRW_draw_pass(psl->probe_visibility_compute); } -static void render_world_to_probe(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl) +/* Actually a simple downsampling */ +static void downsample_planar(void *vedata, int level) { - EEVEE_LightProbesInfo *pinfo = sldata->probes; - DRWMatrixState matstate; - float (*viewmat)[4] = matstate.mat[DRW_MAT_VIEW]; - float (*viewinv)[4] = matstate.mat[DRW_MAT_VIEWINV]; - float (*persmat)[4] = matstate.mat[DRW_MAT_PERS]; - float (*persinv)[4] = matstate.mat[DRW_MAT_PERSINV]; - float (*winmat)[4] = matstate.mat[DRW_MAT_WIN]; - float (*wininv)[4] = matstate.mat[DRW_MAT_WININV]; - - /* For world probe, we don't need to clear since we render the background directly. */ - pinfo->layer = 0; - - perspective_m4(winmat, -0.1f, 0.1f, -0.1f, 0.1f, 0.1f, 1.0f); - invert_m4_m4(wininv, winmat); - - for (int i = 0; i < 6; ++i) { - /* Setup custom matrices */ - copy_m4_m4(viewmat, cubefacemat[i]); - mul_m4_m4m4(persmat, winmat, viewmat); - invert_m4_m4(persinv, persmat); - invert_m4_m4(viewinv, viewmat); - DRW_viewport_matrix_override_set_all(&matstate); + EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl; + EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; - GPU_framebuffer_bind(sldata->probe_face_fb[i]); - GPU_framebuffer_clear_depth(sldata->probe_face_fb[i], 1.0f); - DRW_draw_pass(psl->probe_background); + const float *size = DRW_viewport_size_get(); + copy_v2_v2(stl->g_data->planar_texel_size, size); + for (int i = 0; i < level - 1; ++i) { + stl->g_data->planar_texel_size[0] /= 2.0f; + stl->g_data->planar_texel_size[1] /= 2.0f; + min_ff(floorf(stl->g_data->planar_texel_size[0]), 1.0f); + min_ff(floorf(stl->g_data->planar_texel_size[1]), 1.0f); } -} - -static void lightprobe_cell_grid_location_get(EEVEE_LightGrid *egrid, int cell_idx, float r_local_cell[3]) -{ - /* Keep in sync with lightprobe_grid_display_vert */ - r_local_cell[2] = (float)(cell_idx % egrid->resolution[2]); - r_local_cell[1] = (float)((cell_idx / egrid->resolution[2]) % egrid->resolution[1]); - r_local_cell[0] = (float)(cell_idx / (egrid->resolution[2] * egrid->resolution[1])); -} + invert_v2(stl->g_data->planar_texel_size); -static void lightprobe_cell_world_location_get(EEVEE_LightGrid *egrid, float local_cell[3], float r_pos[3]) -{ - float tmp[3]; - - copy_v3_v3(r_pos, egrid->corner); - mul_v3_v3fl(tmp, egrid->increment_x, local_cell[0]); - add_v3_v3(r_pos, tmp); - mul_v3_v3fl(tmp, egrid->increment_y, local_cell[1]); - add_v3_v3(r_pos, tmp); - mul_v3_v3fl(tmp, egrid->increment_z, local_cell[2]); - add_v3_v3(r_pos, tmp); + DRW_draw_pass(psl->probe_planar_downsample_ps); } -static void lightprobes_refresh_world(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) +static void EEVEE_lightbake_filter_planar(EEVEE_Data *vedata) { - EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; - EEVEE_LightProbesInfo *pinfo = sldata->probes; - EEVEE_PassList *psl = vedata->psl; - EEVEE_StorageList *stl = vedata->stl; - DRWMatrixState saved_mats; - - /* We need to save the Matrices before overidding them */ - DRW_viewport_matrix_get_all(&saved_mats); - - render_world_to_probe(sldata, psl); - if (pinfo->update_world & PROBE_UPDATE_CUBE) { - glossy_filter_probe(sldata, vedata, psl, 0, 1.0); - common_data->prb_num_render_cube = 1; - } - if (pinfo->update_world & PROBE_UPDATE_GRID) { - diffuse_filter_probe(sldata, vedata, psl, 0, 0.0, 0.0, 0.0, 0.0, 1.0); - - SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt); + EEVEE_TextureList *txl = vedata->txl; + EEVEE_FramebufferList *fbl = vedata->fbl; - GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0); - GPU_framebuffer_bind(sldata->probe_filter_fb); - DRW_draw_pass(psl->probe_grid_fill); + DRW_stats_group_start("Planar Probe Downsample"); - common_data->prb_num_render_grid = 1; - /* Reset volume history. */ - stl->effects->volume_current_sample = -1; - common_data->vol_history_alpha = 0.0f; - } - pinfo->update_world = 0; - DRW_viewport_request_redraw(); - /* Do not let this frame accumulate. */ - stl->effects->taa_current_sample = 1; + GPU_framebuffer_ensure_config(&fbl->planar_downsample_fb, { + GPU_ATTACHMENT_NONE, + GPU_ATTACHMENT_TEXTURE(txl->planar_pool) + }); - DRW_viewport_matrix_override_set_all(&saved_mats); + GPU_framebuffer_recursive_downsample(fbl->planar_downsample_fb, MAX_PLANAR_LOD_LEVEL, &downsample_planar, vedata); + DRW_stats_group_end(); } -static void lightprobes_refresh_initialize_grid(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) -{ - EEVEE_LightProbesInfo *pinfo = sldata->probes; - EEVEE_PassList *psl = vedata->psl; - if (pinfo->grid_initialized) { - /* Grid is already initialized, nothing to do. */ - return; - } - /* Flood fill with world irradiance. */ - GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0); - GPU_framebuffer_bind(sldata->probe_filter_fb); - DRW_draw_pass(psl->probe_grid_fill); - - SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt); - - GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0); - GPU_framebuffer_bind(sldata->probe_filter_fb); - DRW_draw_pass(psl->probe_grid_fill); - - SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt); - - pinfo->grid_initialized = true; -} +/** \} */ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) { EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; - EEVEE_FramebufferList *fbl = vedata->fbl; - EEVEE_TextureList *txl = vedata->txl; - Object *ob; EEVEE_LightProbesInfo *pinfo = sldata->probes; DRWMatrixState saved_mats; @@ -1533,9 +1281,6 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v return; } - EEVEE_planar_reflections_updates(sldata); - DRW_uniformbuffer_update(sldata->planar_ubo, &sldata->probes->planar_data); - /* We need to save the Matrices before overidding them */ DRW_viewport_matrix_get_all(&saved_mats); @@ -1547,13 +1292,13 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); - for (int i = 0; (ob = pinfo->probes_planar_ref[i]) && (i < MAX_PLANAR); i++) { - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - LightProbe *prb = (LightProbe *)ob->data; - pinfo->vis_data.collection = prb->visibility_grp; - pinfo->vis_data.invert = prb->flag & LIGHTPROBE_FLAG_INVERT_GROUP; - render_scene_to_planar(sldata, vedata, i, ped); - } + /* Rendering happens here! */ + eevee_lightbake_render_scene_to_planars(sldata, vedata); + + /* Make sure no aditionnal visibility check runs after this. */ + pinfo->vis_data.collection = NULL; + + DRW_uniformbuffer_update(sldata->planar_ubo, &sldata->probes->planar_data); /* Restore */ common_data->prb_num_planar = pinfo->num_planar; @@ -1562,17 +1307,7 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v /* Prefilter for SSR */ if ((vedata->stl->effects->enabled_effects & EFFECT_SSR) != 0) { - const int max_lod = 9; - DRW_stats_group_start("Planar Probe Downsample"); - - GPU_framebuffer_ensure_config(&fbl->planar_downsample_fb, { - GPU_ATTACHMENT_NONE, - GPU_ATTACHMENT_TEXTURE(txl->planar_pool) - }); - GPU_framebuffer_recursive_downsample(fbl->planar_downsample_fb, max_lod, &downsample_planar, vedata); - /* For shading, save max level of the planar map */ - common_data->prb_lod_planar_max = (float)(max_lod); - DRW_stats_group_end(); + EEVEE_lightbake_filter_planar(vedata); } DRW_viewport_matrix_override_set_all(&saved_mats); @@ -1586,239 +1321,18 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v common_data->ssr_toggle = vedata->stl->g_data->valid_double_buffer; } -static void lightprobes_refresh_cube(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) -{ - EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; - EEVEE_PassList *psl = vedata->psl; - EEVEE_StorageList *stl = vedata->stl; - EEVEE_LightProbesInfo *pinfo = sldata->probes; - Object *ob; - for (int i = 1; (ob = pinfo->probes_cube_ref[i]) && (i < MAX_PROBE); i++) { - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - if (!ped->need_update) { - continue; - } - LightProbe *prb = (LightProbe *)ob->data; - pinfo->vis_data.collection = prb->visibility_grp; - pinfo->vis_data.invert = prb->flag & LIGHTPROBE_FLAG_INVERT_GROUP; - render_scene_to_probe(sldata, vedata, ob->obmat[3], prb->clipsta, prb->clipend); - glossy_filter_probe(sldata, vedata, psl, i, prb->intensity); - ped->need_update = false; - ped->probe_id = i; - if (!ped->ready_to_shade) { - common_data->prb_num_render_cube++; - ped->ready_to_shade = true; - } -#if 0 - printf("Update Cubemap %d\n", i); -#endif - DRW_viewport_request_redraw(); - /* Do not let this frame accumulate. */ - stl->effects->taa_current_sample = 1; - /* Only do one probe per frame */ - return; - } - - pinfo->do_cube_update = false; -} - -static void lightprobes_refresh_all_no_world(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) -{ - EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; - EEVEE_PassList *psl = vedata->psl; - EEVEE_StorageList *stl = vedata->stl; - EEVEE_LightProbesInfo *pinfo = sldata->probes; - Object *ob; - const DRWContextState *draw_ctx = DRW_context_state_get(); - RegionView3D *rv3d = draw_ctx->rv3d; - - if (draw_ctx->evil_C != NULL) { - /* Only compute probes if not navigating or in playback */ - struct wmWindowManager *wm = CTX_wm_manager(draw_ctx->evil_C); - if (((rv3d->rflag & RV3D_NAVIGATING) != 0) || ED_screen_animation_no_scrub(wm) != NULL) { - return; - } - } - /* We need to save the Matrices before overidding them */ - DRWMatrixState saved_mats; - DRW_viewport_matrix_get_all(&saved_mats); - /* Make sure grid is initialized. */ - lightprobes_refresh_initialize_grid(sldata, vedata); - /* Reflection probes depend on diffuse lighting thus on irradiance grid, - * so update them first. */ - while (pinfo->updated_bounce < pinfo->num_bounce) { - common_data->prb_num_render_grid = pinfo->num_grid; - /* TODO(sergey): This logic can be split into smaller functions. */ - for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) { - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - if (!ped->need_update) { - continue; - } - EEVEE_LightGrid *egrid = &pinfo->grid_data[i]; - LightProbe *prb = (LightProbe *)ob->data; - /* Find the next cell corresponding to the current level. */ - bool valid_cell = false; - int cell_id = ped->updated_cells; - float pos[3], grid_loc[3]; - /* Other levels */ - int current_stride = 1 << max_ii(0, ped->max_lvl - ped->updated_lvl); - int prev_stride = current_stride << 1; - bool do_rendering = true; - while (!valid_cell) { - cell_id = ped->updated_cells; - lightprobe_cell_grid_location_get(egrid, cell_id, grid_loc); - if (ped->updated_lvl == 0 && cell_id == 0) { - valid_cell = true; - ped->updated_cells = ped->num_cell; - continue; - } - else if (((((int)grid_loc[0] % current_stride) == 0) && - (((int)grid_loc[1] % current_stride) == 0) && - (((int)grid_loc[2] % current_stride) == 0)) && - !((((int)grid_loc[0] % prev_stride) == 0) && - (((int)grid_loc[1] % prev_stride) == 0) && - (((int)grid_loc[2] % prev_stride) == 0))) - { - valid_cell = true; - } - ped->updated_cells++; - if (ped->updated_cells > ped->num_cell) { - do_rendering = false; - break; - } - } - if (do_rendering) { - lightprobe_cell_world_location_get(egrid, grid_loc, pos); - SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt); - /* Temporary Remove all probes. */ - int tmp_num_render_grid = common_data->prb_num_render_grid; - int tmp_num_render_cube = common_data->prb_num_render_cube; - int tmp_num_planar = common_data->prb_num_planar; - float tmp_level_bias = egrid->level_bias; - common_data->prb_num_render_cube = 0; - common_data->prb_num_planar = 0; - /* Use light from previous bounce when capturing radiance. */ - if (pinfo->updated_bounce == 0) { - /* But not on first bounce. */ - common_data->prb_num_render_grid = 0; - } - else { - /* Remove bias */ - egrid->level_bias = (float)(1 << 0); - DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data); - } - pinfo->vis_data.collection = prb->visibility_grp; - pinfo->vis_data.invert = prb->flag & LIGHTPROBE_FLAG_INVERT_GROUP; - render_scene_to_probe(sldata, vedata, pos, prb->clipsta, prb->clipend); - diffuse_filter_probe(sldata, vedata, psl, egrid->offset + cell_id, - prb->clipsta, prb->clipend, egrid->visibility_range, prb->vis_blur, - prb->intensity); - /* To see what is going on. */ - SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt); - /* Restore */ - common_data->prb_num_render_cube = tmp_num_render_cube; - pinfo->num_planar = tmp_num_planar; - if (pinfo->updated_bounce == 0) { - common_data->prb_num_render_grid = tmp_num_render_grid; - } - else { - egrid->level_bias = tmp_level_bias; - DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data); - } -#if 0 - printf("Updated Grid %d : cell %d / %d, bounce %d / %d\n", - i, cell_id + 1, ped->num_cell, pinfo->updated_bounce + 1, pinfo->num_bounce); -#endif - } - if (ped->updated_cells >= ped->num_cell) { - ped->updated_lvl++; - ped->updated_cells = 0; - if (ped->updated_lvl > ped->max_lvl) { - ped->need_update = false; - } - egrid->level_bias = (float)(1 << max_ii(0, ped->max_lvl - ped->updated_lvl + 1)); - DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data); - } - /* Only do one probe per frame */ - DRW_viewport_request_redraw(); - /* Do not let this frame accumulate. */ - stl->effects->taa_current_sample = 1; - /* Reset volume history. */ - stl->effects->volume_current_sample = -1; - common_data->vol_history_alpha = 0.0f; - /* Restore matrices */ - DRW_viewport_matrix_override_set_all(&saved_mats); - return; - } - - pinfo->updated_bounce++; - common_data->prb_num_render_grid = pinfo->num_grid; - - if (pinfo->updated_bounce < pinfo->num_bounce) { - /* Retag all grids to update for next bounce */ - for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) { - EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_ensure(ob); - ped->need_update = true; - ped->updated_cells = 0; - ped->updated_lvl = 0; - } - /* Reset the next buffer so we can see the progress. */ - /* irradiance_rt is already the next rt because of the previous SWAP */ - GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->irradiance_rt, 0, 0); - GPU_framebuffer_bind(sldata->probe_filter_fb); - DRW_draw_pass(psl->probe_grid_fill); - - GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0); - /* Swap AFTER */ - SWAP(GPUTexture *, sldata->irradiance_pool, sldata->irradiance_rt); - } - } - /* Refresh cube probe when needed. */ - lightprobes_refresh_cube(sldata, vedata); - /* Restore matrices */ - DRW_viewport_matrix_override_set_all(&saved_mats); -} - -bool EEVEE_lightprobes_all_probes_ready(EEVEE_ViewLayerData *sldata, EEVEE_Data *UNUSED(vedata)) -{ - EEVEE_LightProbesInfo *pinfo = sldata->probes; - EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; - - return ((pinfo->do_cube_update == false) && - (pinfo->updated_bounce == pinfo->num_bounce) && - (common_data->prb_num_render_cube == pinfo->num_cube)); -} - void EEVEE_lightprobes_refresh(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) { - EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; - EEVEE_LightProbesInfo *pinfo = sldata->probes; - - /* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */ - common_data->spec_toggle = false; - common_data->ssr_toggle = false; - common_data->sss_toggle = false; - - /* Disable AO until we find a way to hide really bad discontinuities between cubefaces. */ - float tmp_ao_dist = common_data->ao_dist; - float tmp_ao_settings = common_data->ao_settings; - common_data->ao_settings = 0.0f; - common_data->ao_dist = 0.0f; + const DRWContextState *draw_ctx = DRW_context_state_get(); + const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); + LightCache *light_cache = vedata->stl->g_data->light_cache; - /* Render world in priority */ - if (pinfo->update_world) { - lightprobes_refresh_world(sldata, vedata); + if (light_cache->flag & LIGHTCACHE_UPDATE_WORLD) { + DRWMatrixState saved_mats; + DRW_viewport_matrix_get_all(&saved_mats); + EEVEE_lightbake_update_world_quick(sldata, vedata, scene_eval); + DRW_viewport_matrix_override_set_all(&saved_mats); } - else if (EEVEE_lightprobes_all_probes_ready(sldata, vedata) == false && pinfo->all_materials_updated) { - lightprobes_refresh_all_no_world(sldata, vedata); - } - - /* Restore */ - common_data->spec_toggle = true; - common_data->ssr_toggle = true; - common_data->sss_toggle = true; - common_data->ao_dist = tmp_ao_dist; - common_data->ao_settings = tmp_ao_settings; } void EEVEE_lightprobes_free(void) diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index 9214544fb17..0f0d9d281c9 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -148,7 +148,7 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata) DRW_TEXTURE_FREE_SAFE(sldata->shadow_cube_blur); /* Compute adequate size for the octahedral map. */ - linfo->shadow_cube_store_size = (int)ceil(sqrt((sh_cube_size * sh_cube_size) * 6.0f)); + linfo->shadow_cube_store_size = OCTAHEDRAL_SIZE_FROM_CUBESIZE(sh_cube_size); CLAMP(linfo->shadow_cube_store_size, 1, 4096); CLAMP(sh_cube_size, 1, 4096); diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 01599177fa4..2e568d97c07 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -30,15 +30,31 @@ #include "DNA_screen_types.h" #include "DNA_world_types.h" +#include "DEG_depsgraph_query.h" + #include "ED_screen.h" #include "eevee_private.h" +#include "eevee_lightcache.h" + +static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata) +{ + EEVEE_StorageList *stl = vedata->stl; + EEVEE_TextureList *txl = vedata->txl; + + MEM_SAFE_FREE(stl->lookdev_lightcache); + MEM_SAFE_FREE(stl->lookdev_grid_data); + MEM_SAFE_FREE(stl->lookdev_cube_data); + DRW_TEXTURE_FREE_SAFE(txl->lookdev_grid_tx); + DRW_TEXTURE_FREE_SAFE(txl->lookdev_cube_tx); +} void EEVEE_lookdev_cache_init( EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass, World *world, EEVEE_LightProbesInfo *pinfo) { EEVEE_StorageList *stl = vedata->stl; + EEVEE_TextureList *txl = vedata->txl; const DRWContextState *draw_ctx = DRW_context_state_get(); View3D *v3d = draw_ctx->v3d; if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) { @@ -47,6 +63,43 @@ void EEVEE_lookdev_cache_init( struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); GPUTexture *tex = NULL; + /* If one of the component is missing we start from scratch. */ + if ((stl->lookdev_grid_data == NULL) || + (stl->lookdev_cube_data == NULL) || + (txl->lookdev_grid_tx == NULL) || + (txl->lookdev_cube_tx == NULL)) + { + eevee_lookdev_lightcache_delete(vedata); + } + + if (stl->lookdev_lightcache == NULL) { + const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); +#if defined(IRRADIANCE_SH_L2) + int grid_res = 4; +#elif defined(IRRADIANCE_CUBEMAP) + int grid_res = 8; +#elif defined(IRRADIANCE_HL2) + int grid_res = 4; +#endif + int cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(scene_eval->eevee.gi_cubemap_resolution); + int vis_res = scene_eval->eevee.gi_visibility_resolution; + + stl->lookdev_lightcache = EEVEE_lightcache_create(1, 1, cube_res, vis_res, (int[3]){grid_res, grid_res, 1}); + + /* We do this to use a special light cache for lookdev. + * This lightcache needs to be per viewport. But we need to + * have correct freeing when the viewport is closed. So we + * need to reference all textures to the txl and the memblocks + * to the stl. */ + stl->lookdev_grid_data = stl->lookdev_lightcache->grid_data; + stl->lookdev_cube_data = stl->lookdev_lightcache->cube_data; + stl->lookdev_cube_mips = stl->lookdev_lightcache->cube_mips; + txl->lookdev_grid_tx = stl->lookdev_lightcache->grid_tx.tex; + txl->lookdev_cube_tx = stl->lookdev_lightcache->cube_tx.tex; + } + + stl->g_data->light_cache = stl->lookdev_lightcache; + *grp = DRW_shgroup_create(shader, pass); axis_angle_to_mat3_single(stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z); DRW_shgroup_uniform_mat3(*grp, "StudioLightMatrix", stl->g_data->studiolight_matrix); @@ -77,11 +130,9 @@ void EEVEE_lookdev_cache_init( ((pinfo->studiolight_index != sl->index) || (pinfo->studiolight_rot_z != v3d->shading.studiolight_rot_z))) { - pinfo->update_world |= PROBE_UPDATE_ALL; + stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD; pinfo->studiolight_index = sl->index; pinfo->studiolight_rot_z = v3d->shading.studiolight_rot_z; - pinfo->prev_wo_sh_compiled = false; - pinfo->prev_world = NULL; } } } diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 4a7e97756a9..20d755d2245 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -362,6 +362,8 @@ static void add_standard_uniforms( DRWShadingGroup *shgrp, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, int *ssr_id, float *refract_depth, bool use_ssrefraction, bool use_alpha_blend) { + LightCache *lcache = vedata->stl->g_data->light_cache; + if (ssr_id == NULL) { static int no_ssr = -1.0f; ssr_id = &no_ssr; @@ -393,12 +395,12 @@ static void add_standard_uniforms( /* TODO if diffuse bsdf */ if (true) { - DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &sldata->irradiance_pool); + DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &lcache->grid_tx.tex); } /* TODO if glossy bsdf */ if (true) { - DRW_shgroup_uniform_texture_ref(shgrp, "probeCubes", &sldata->probe_pool); + DRW_shgroup_uniform_texture_ref(shgrp, "probeCubes", &lcache->cube_tx.tex); DRW_shgroup_uniform_texture_ref(shgrp, "probePlanars", &vedata->txl->planar_pool); DRW_shgroup_uniform_int(shgrp, "outputSsrId", ssr_id, 1); } @@ -972,7 +974,6 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_shgroup_call_add(grp, geom, NULL); break; case GPU_MAT_QUEUED: - sldata->probes->all_materials_updated = false; /* TODO Bypass probe compilation. */ col = compile_col; break; @@ -1229,7 +1230,6 @@ static void material_opaque( } case GPU_MAT_QUEUED: { - sldata->probes->all_materials_updated = false; /* TODO Bypass probe compilation. */ color_p = compile_col; metal_p = spec_p = rough_p = ½ @@ -1316,7 +1316,6 @@ static void material_transparent( } case GPU_MAT_QUEUED: { - sldata->probes->all_materials_updated = false; /* TODO Bypass probe compilation. */ color_p = compile_col; metal_p = spec_p = rough_p = ½ @@ -1646,7 +1645,6 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, } case GPU_MAT_QUEUED: { - sldata->probes->all_materials_updated = false; color_p = compile_col; metal_p = spec_p = rough_p = ½ break; diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index fe837baf20e..e2a875dca1f 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -26,11 +26,14 @@ #ifndef __EEVEE_PRIVATE_H__ #define __EEVEE_PRIVATE_H__ +#include "DNA_lightprobe_types.h" + struct Object; struct EEVEE_BoundSphere; struct EEVEE_ShadowCasterBuffer; struct RenderLayer; struct RenderResult; +struct GPUFrameBuffer; extern struct DrawEngineType draw_engine_eevee_type; @@ -98,6 +101,10 @@ extern struct DrawEngineType draw_engine_eevee_type; #define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS)))) #define LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && !(v3d->shading.flag & V3D_SHADING_SCENE_WORLD)) +#define OCTAHEDRAL_SIZE_FROM_CUBESIZE(cube_size) ((int)ceilf(sqrtf((cube_size * cube_size) * 6.0f))) +#define MIN_CUBE_LOD_LEVEL 3 +#define MAX_PLANAR_LOD_LEVEL 9 + /* World shader variations */ enum { VAR_WORLD_BACKGROUND = 0, @@ -132,6 +139,27 @@ enum { VAR_MAT_SSSALBED = (1 << 17), }; +/* ************ PROBE UBO ************* */ + +/* They are the same struct as their Cache siblings. + * typedef'ing just to keep the naming consistent with + * other eevee types. */ +typedef LightProbeCache EEVEE_LightProbe; +typedef LightGridCache EEVEE_LightGrid; + +typedef struct EEVEE_PlanarReflection { + float plane_equation[4]; + float clip_vec_x[3], attenuation_scale; + float clip_vec_y[3], attenuation_bias; + float clip_edge_x_pos, clip_edge_x_neg; + float clip_edge_y_pos, clip_edge_y_neg; + float facing_scale, facing_bias, clipsta, pad; + float reflectionmat[4][4]; /* Used for sampling the texture. */ + float mtx[4][4]; /* Not used in shader. TODO move elsewhere. */ +} EEVEE_PlanarReflection; + +/* --------------------------------------- */ + typedef struct EEVEE_BoundSphere { float center[3], radius; } EEVEE_BoundSphere; @@ -272,6 +300,9 @@ typedef struct EEVEE_TextureList { struct GPUTexture *volume_scatter_history; struct GPUTexture *volume_transmittance_history; + struct GPUTexture *lookdev_grid_tx; + struct GPUTexture *lookdev_cube_tx; + struct GPUTexture *planar_pool; struct GPUTexture *planar_depth; @@ -288,6 +319,10 @@ typedef struct EEVEE_StorageList { struct EEVEE_PrivateData *g_data; + struct LightCache *lookdev_lightcache; + EEVEE_LightProbe *lookdev_cube_data; + EEVEE_LightGrid *lookdev_grid_data; + LightCacheTexture *lookdev_cube_mips; } EEVEE_StorageList; /* ************ LIGHT UBO ************* */ @@ -392,42 +427,11 @@ enum { LIGHT_UPDATE_SHADOW_CUBE = (1 << 0), }; -/* ************ PROBE UBO ************* */ -typedef struct EEVEE_LightProbe { - float position[3], parallax_type; - float attenuation_fac; - float attenuation_type; - float pad3[2]; - float attenuationmat[4][4]; - float parallaxmat[4][4]; -} EEVEE_LightProbe; - -typedef struct EEVEE_LightGrid { - float mat[4][4]; - int resolution[3], offset; - float corner[3], attenuation_scale; - float increment_x[3], attenuation_bias; /* world space vector between 2 opposite cells */ - float increment_y[3], level_bias; - float increment_z[3], pad4; - float visibility_bias, visibility_bleed, visibility_range, pad5; -} EEVEE_LightGrid; - -typedef struct EEVEE_PlanarReflection { - float plane_equation[4]; - float clip_vec_x[3], attenuation_scale; - float clip_vec_y[3], attenuation_bias; - float clip_edge_x_pos, clip_edge_x_neg; - float clip_edge_y_pos, clip_edge_y_neg; - float facing_scale, facing_bias, pad[2]; - float reflectionmat[4][4]; -} EEVEE_PlanarReflection; - /* ************ PROBE DATA ************* */ - typedef struct EEVEE_LightProbeVisTest { + struct Collection *collection; /* Skip test if NULL */ bool invert; bool cached; /* Reuse last test results */ - struct Collection *collection; /* Skip test if NULL */ } EEVEE_LightProbeVisTest; typedef struct EEVEE_LightProbesInfo { @@ -440,13 +444,9 @@ typedef struct EEVEE_LightProbesInfo { int updated_bounce; int num_bounce; int cubemap_res; - int target_size; - int grid_initialized; - struct World *prev_world; - int update_world; - bool prev_wo_sh_compiled; + /* Update */ bool do_cube_update; - bool all_materials_updated; + bool do_grid_update; /* For rendering probes */ float probemat[6][4][4]; int layer; @@ -465,15 +465,11 @@ typedef struct EEVEE_LightProbesInfo { int shres; int studiolight_index; float studiolight_rot_z; - /* List of probes in the scene. */ - /* XXX This is fragile, can get out of sync quickly. */ - struct Object *probes_cube_ref[MAX_PROBE]; - struct Object *probes_grid_ref[MAX_GRID]; - struct Object *probes_planar_ref[MAX_PLANAR]; + EEVEE_LightProbeVisTest planar_vis_tests[MAX_PLANAR]; /* UBO Storage : data used by UBO */ - struct EEVEE_LightProbe probe_data[MAX_PROBE]; - struct EEVEE_LightGrid grid_data[MAX_GRID]; - struct EEVEE_PlanarReflection planar_data[MAX_PLANAR]; + EEVEE_LightProbe probe_data[MAX_PROBE]; + EEVEE_LightGrid grid_data[MAX_GRID]; + EEVEE_PlanarReflection planar_data[MAX_PLANAR]; /* Probe Visibility Collection */ EEVEE_LightProbeVisTest vis_data; } EEVEE_LightProbesInfo; @@ -673,24 +669,18 @@ typedef struct EEVEE_ViewLayerData { struct GPUUniformBuffer *grid_ubo; struct GPUUniformBuffer *planar_ubo; - struct GPUFrameBuffer *probe_filter_fb; - struct GPUFrameBuffer *probe_face_fb[6]; - - struct GPUTexture *probe_rt; - struct GPUTexture *probe_depth_rt; - struct GPUTexture *probe_pool; - struct GPUTexture *irradiance_pool; - struct GPUTexture *irradiance_rt; - /* Common Uniform Buffer */ struct EEVEE_CommonUniformBuffer common_data; struct GPUUniformBuffer *common_ubo; struct EEVEE_ClipPlanesUniformBuffer clip_data; struct GPUUniformBuffer *clip_ubo; + + struct LightCache *fallback_lightcache; } EEVEE_ViewLayerData; /* ************ OBJECT DATA ************ */ + typedef struct EEVEE_LightData { short light_id, shadow_id; } EEVEE_LightData; @@ -726,29 +716,7 @@ typedef struct EEVEE_LampEngineData { typedef struct EEVEE_LightProbeEngineData { DrawData dd; - /* NOTE: need_full_update is set by dependency graph when the probe or it's - * object is updated. This triggers full probe update, including it's - * "progressive" GI refresh. - * - * need_update is always set to truth when need_full_update is tagged, but - * might also be forced to be kept truth during GI refresh stages. - * - * TODO(sergey): Is there a way to avoid two flags here, or at least make - * it more clear what's going on here? - */ - bool need_full_update; bool need_update; - - bool ready_to_shade; - int updated_cells; - int updated_lvl; - int num_cell; - int max_lvl; - int probe_id; /* Only used for display data */ - float probe_size; /* Only used for display data */ - DRWMatrixState mats; /* For planar probes */ - float planer_eq_offset[4]; - struct ListBase captured_object_list; } EEVEE_LightProbeEngineData; typedef struct EEVEE_ObjectEngineData { @@ -790,6 +758,8 @@ typedef struct EEVEE_PrivateData { struct DRWShadingGroup *planar_display_shgrp; struct GHash *material_hash; float background_alpha; /* TODO find a better place for this. */ + /* Chosen lightcache: can come from Lookdev or the viewlayer. */ + struct LightCache *light_cache; /* For planar probes */ float planar_texel_size[2]; /* For double buffering */ @@ -807,6 +777,7 @@ typedef struct EEVEE_PrivateData { /* eevee_data.c */ EEVEE_ViewLayerData *EEVEE_view_layer_data_get(void); +EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure_ex(struct ViewLayer *view_layer); EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure(void); EEVEE_ObjectEngineData *EEVEE_object_data_get(Object *ob); EEVEE_ObjectEngineData *EEVEE_object_data_ensure(Object *ob); @@ -855,17 +826,37 @@ void EEVEE_lights_update(EEVEE_ViewLayerData *sldata); void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl); void EEVEE_lights_free(void); + /* eevee_lightprobes.c */ bool EEVEE_lightprobes_obj_visibility_cb(bool vis_in, void *user_data); -bool EEVEE_lightprobes_all_probes_ready(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); -void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, Object *ob); +void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *ob); void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_lightprobes_refresh(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_lightprobes_free(void); +void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, GPUTexture *rt_color, GPUTexture *rt_depth); +void EEVEE_lightbake_render_world( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUFrameBuffer *face_fb[6]); +void EEVEE_lightbake_render_scene( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUFrameBuffer *face_fb[6], + const float pos[3], float near_clip, float far_clip); +void EEVEE_lightbake_filter_glossy( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUTexture *rt_color, struct GPUFrameBuffer *fb, + int probe_idx, float intensity, int maxlevel); +void EEVEE_lightbake_filter_diffuse( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUTexture *rt_color, struct GPUFrameBuffer *fb, + int grid_offset, float intensity); +void EEVEE_lightbake_filter_visibility( + EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct GPUTexture *rt_depth, struct GPUFrameBuffer *fb, + int grid_offset, float clipsta, float clipend, float vis_range, float vis_blur, int vis_size); + +void EEVEE_lightprobes_grid_data_from_object(Object *ob, EEVEE_LightGrid *prb_data, int *offset); +void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *prb_data); +void EEVEE_lightprobes_planar_data_from_object(Object *ob, EEVEE_PlanarReflection *eplanar, EEVEE_LightProbeVisTest *vis_test); + /* eevee_depth_of_field.c */ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *camera); void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); @@ -954,6 +945,9 @@ void EEVEE_render_update_passes(struct RenderEngine *engine, struct Scene *scene void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass, struct World *world, EEVEE_LightProbesInfo *pinfo); void EEVEE_lookdev_draw_background(EEVEE_Data *vedata); +/** eevee_engine.c */ +void EEVEE_cache_populate(void *vedata, Object *ob); + /* Shadow Matrix */ static const float texcomat[4][4] = { /* From NDC to TexCo */ {0.5f, 0.0f, 0.0f, 0.0f}, diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index c650a6945ac..bc1bd97bdde 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -134,17 +134,31 @@ void EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph * EEVEE_volumes_cache_init(sldata, vedata); } +/* Used by light cache. in this case engine is NULL. */ void EEVEE_render_cache( void *vedata, struct Object *ob, struct RenderEngine *engine, struct Depsgraph *UNUSED(depsgraph)) { EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); - - char info[42]; - BLI_snprintf(info, sizeof(info), "Syncing %s", ob->id.name + 2); - RE_engine_update_stats(engine, NULL, info); + EEVEE_LightProbesInfo *pinfo = sldata->probes; bool cast_shadow = false; + if (pinfo->vis_data.collection) { + /* Used for rendering probe with visibility groups. */ + bool ob_vis = BKE_collection_has_object_recursive(pinfo->vis_data.collection, ob); + ob_vis = (pinfo->vis_data.invert) ? !ob_vis : ob_vis; + + if (!ob_vis) { + return; + } + } + + if (engine) { + char info[42]; + BLI_snprintf(info, sizeof(info), "Syncing %s", ob->id.name + 2); + RE_engine_update_stats(engine, NULL, info); + } + if (ob->base_flag & BASE_VISIBLE) { EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow); } @@ -154,7 +168,7 @@ void EEVEE_render_cache( EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow); } else if (ob->type == OB_LIGHTPROBE) { - EEVEE_lightprobes_cache_add(sldata, ob); + EEVEE_lightprobes_cache_add(sldata, vedata, ob); } else if (ob->type == OB_LAMP) { EEVEE_lights_cache_add(sldata, ob); @@ -477,14 +491,8 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl DRW_viewport_matrix_override_set(g_data->viewinv, DRW_MAT_VIEWINV); /* Refresh Probes */ - while (EEVEE_lightprobes_all_probes_ready(sldata, vedata) == false) { - RE_engine_update_stats(engine, NULL, "Updating Probes"); - EEVEE_lightprobes_refresh(sldata, vedata); - /* Refreshing probes can take some times, allow exit. */ - if (RE_engine_test_break(engine)) { - return; - } - } + RE_engine_update_stats(engine, NULL, "Updating Probes"); + EEVEE_lightprobes_refresh(sldata, vedata); EEVEE_lightprobes_refresh_planar(sldata, vedata); DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c index 74760b9c828..ef949c32eed 100644 --- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c +++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c @@ -187,6 +187,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v EEVEE_StorageList *stl = vedata->stl; EEVEE_TextureList *txl = vedata->txl; EEVEE_EffectsInfo *effects = stl->effects; + LightCache *lcache = stl->g_data->light_cache; struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); @@ -230,7 +231,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data.depth_src); DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &effects->ssr_normal_input); DRW_shgroup_uniform_texture_ref(grp, "specroughBuffer", &effects->ssr_specrough_input); - DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &sldata->probe_pool); + DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &lcache->cube_tx.tex); DRW_shgroup_uniform_texture_ref(grp, "probePlanars", &vedata->txl->planar_pool); DRW_shgroup_uniform_texture_ref(grp, "planarDepth", &vedata->txl->planar_depth); DRW_shgroup_uniform_texture_ref(grp, "hitBuffer", &effects->ssr_hit_output); diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 560f898b275..d0cea65d05e 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -349,6 +349,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) EEVEE_StorageList *stl = vedata->stl; EEVEE_TextureList *txl = vedata->txl; EEVEE_EffectsInfo *effects = stl->effects; + LightCache *lcache = stl->g_data->light_cache; EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; if ((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) { @@ -417,7 +418,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) psl->volumetric_scatter_ps = DRW_pass_create("Volumetric Scattering", DRW_STATE_WRITE_COLOR); grp = DRW_shgroup_empty_tri_batch_create(scatter_sh, psl->volumetric_scatter_ps, common_data->vol_tex_size[2]); - DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &sldata->irradiance_pool); + DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &lcache->grid_tx.tex); DRW_shgroup_uniform_texture_ref(grp, "shadowCubeTexture", &sldata->shadow_cube_pool); DRW_shgroup_uniform_texture_ref(grp, "shadowCascadeTexture", &sldata->shadow_cascade_pool); DRW_shgroup_uniform_texture_ref(grp, "volumeScattering", &txl->volume_prop_scattering); diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl index d10f4bc0d42..5a72244cfbe 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl @@ -1,15 +1,18 @@ flat in int pid; -in vec3 worldNormal; -in vec3 worldPosition; +in vec2 quadCoord; out vec4 FragColor; void main() { - vec3 V = (ProjectionMatrix[3][3] == 0.0) /* if perspective */ - ? normalize(cameraPos - worldPosition) - : cameraForward; - vec3 N = normalize(worldNormal); - FragColor = vec4(textureLod_octahedron(probeCubes, vec4(reflect(-V, N), pid), 0.0, prbLodCubeMax).rgb, 1.0); + float dist_sqr = dot(quadCoord, quadCoord); + + /* Discard outside the circle. */ + if (dist_sqr > 1.0) + discard; + + vec3 view_nor = vec3(quadCoord, sqrt(max(0.0, 1.0 - dist_sqr))); + vec3 world_ref = mat3(ViewMatrixInverse) * reflect(vec3(0.0, 0.0, -1.0), view_nor); + FragColor = vec4(textureLod_octahedron(probeCubes, vec4(world_ref, pid), 0.0, prbLodCubeMax).rgb, 1.0); } diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl index b0a6cbe1707..b327878b63d 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl @@ -1,26 +1,43 @@ -in vec3 pos; +/* XXX TODO fix code duplication */ +struct CubeData { + vec4 position_type; + vec4 attenuation_fac_type; + mat4 influencemat; + mat4 parallaxmat; +}; -/* Instance attrib */ -in int probe_id; -in vec3 probe_location; -in float sphere_size; +layout(std140) uniform probe_block { + CubeData probes_data[MAX_PROBE]; +}; + +uniform float sphere_size; +uniform vec3 screen_vecs[2]; flat out int pid; -out vec3 worldNormal; -out vec3 worldPosition; +out vec2 quadCoord; + +const vec2 pos[6] = vec2[6]( + vec2(-1.0, -1.0), + vec2( 1.0, -1.0), + vec2(-1.0, 1.0), + + vec2( 1.0, -1.0), + vec2( 1.0, 1.0), + vec2(-1.0, 1.0) +); void main() { - pid = probe_id; + pid = 1 + (gl_VertexID / 6); /* +1 for the world */ + int vert_id = gl_VertexID % 6; + + quadCoord = pos[vert_id]; - /* While this is not performant, we do this to - * match the object mode engine instancing shader. */ - mat4 offsetmat = mat4(1.0); /* Identity */ - offsetmat[3].xyz = probe_location; + vec3 ws_location = probes_data[pid].position_type.xyz; + vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y; + ws_location += screen_pos * sphere_size; - vec4 wpos = offsetmat * vec4(pos * sphere_size, 1.0); - worldPosition = wpos.xyz; - gl_Position = ViewProjectionMatrix * wpos; - worldNormal = normalize(pos); + gl_Position = ViewProjectionMatrix * vec4(ws_location, 1.0); + gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */ } diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl index d333ad34bb0..fd8eb157aa5 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl @@ -1,11 +1,19 @@ flat in int cellOffset; -in vec3 worldNormal; +in vec2 quadCoord; out vec4 FragColor; void main() { - IrradianceData ir_data = load_irradiance_cell(cellOffset, worldNormal); - FragColor = vec4(compute_irradiance(worldNormal, ir_data), 1.0); + float dist_sqr = dot(quadCoord, quadCoord); + + /* Discard outside the circle. */ + if (dist_sqr > 1.0) + discard; + + vec3 view_nor = vec3(quadCoord, sqrt(max(0.0, 1.0 - dist_sqr))); + vec3 world_nor = mat3(ViewMatrixInverse) * view_nor; + IrradianceData ir_data = load_irradiance_cell(cellOffset, world_nor); + FragColor = vec4(compute_irradiance(world_nor, ir_data), 1.0); } diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl index a017a791e41..7a92b55e530 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl @@ -1,6 +1,4 @@ -in vec3 pos; - uniform float sphere_size; uniform int offset; uniform ivec3 grid_resolution; @@ -8,25 +6,44 @@ uniform vec3 corner; uniform vec3 increment_x; uniform vec3 increment_y; uniform vec3 increment_z; +uniform vec3 screen_vecs[2]; flat out int cellOffset; -out vec3 worldNormal; +out vec2 quadCoord; + +const vec2 pos[6] = vec2[6]( + vec2(-1.0, -1.0), + vec2( 1.0, -1.0), + vec2(-1.0, 1.0), + + vec2( 1.0, -1.0), + vec2( 1.0, 1.0), + vec2(-1.0, 1.0) +); void main() { + int cell_id = gl_VertexID / 6; + int vert_id = gl_VertexID % 6; + vec3 ls_cell_location; /* Keep in sync with update_irradiance_probe */ - ls_cell_location.z = float(gl_InstanceID % grid_resolution.z); - ls_cell_location.y = float((gl_InstanceID / grid_resolution.z) % grid_resolution.y); - ls_cell_location.x = float(gl_InstanceID / (grid_resolution.z * grid_resolution.y)); + ls_cell_location.z = float(cell_id % grid_resolution.z); + ls_cell_location.y = float((cell_id / grid_resolution.z) % grid_resolution.y); + ls_cell_location.x = float(cell_id / (grid_resolution.z * grid_resolution.y)); - cellOffset = offset + gl_InstanceID; + cellOffset = offset + cell_id; vec3 ws_cell_location = corner + (increment_x * ls_cell_location.x + increment_y * ls_cell_location.y + increment_z * ls_cell_location.z); - gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0); - worldNormal = normalize(pos); + + quadCoord = pos[vert_id]; + vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y; + ws_cell_location += screen_pos * sphere_size; + + gl_Position = ViewProjectionMatrix * vec4(ws_cell_location , 1.0); + gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */ } diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl index 0ffc0cc4b49..6ae13e0102d 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl @@ -27,6 +27,7 @@ struct PlanarData { vec4 clip_edges; vec4 facing_scale_bias; mat4 reflectionmat; /* transform world space into reflection texture space */ + mat4 unused; }; #define pl_plane_eq plane_equation diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl index 644b449c03e..22194c22f39 100644 --- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl @@ -256,7 +256,7 @@ void CLOSURE_NAME( PlanarData pd = planars_data[i]; /* Fade on geometric normal. */ - float fade = probe_attenuation_planar(pd, worldPosition, worldNormal, roughness); + float fade = probe_attenuation_planar(pd, worldPosition, (gl_FrontFacing) ? worldNormal : -worldNormal, roughness); if (fade > 0.0) { if (!(ssrToggle && ssr_id == outputSsrId)) { @@ -404,7 +404,7 @@ void CLOSURE_NAME( spec_occlu = 1.0; } - out_spec += spec_accum.rgb * ssr_spec * spec_occlu * float(specToggle); + out_spec += spec_accum.rgb * ssr_spec * spec_occlu; #endif #ifdef CLOSURE_REFRACTION @@ -419,7 +419,12 @@ void CLOSURE_NAME( vec2 C_brdf_lut = texture(utilTex, vec3(C_uv, 1.0)).rg; vec3 C_fresnel = F_ibl(vec3(0.04), brdf_lut) * specular_occlusion(NV, final_ao, C_roughness); - out_spec += C_spec_accum.rgb * C_fresnel * float(specToggle) * C_intensity; + out_spec += C_spec_accum.rgb * C_fresnel * C_intensity; +#endif + +#ifdef CLOSURE_GLOSSY + /* Global toggle for lightprobe baking. */ + out_spec *= float(specToggle); #endif /* ---------------------------------------------------------------- */ diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h index 77bf16f5e22..585a7999290 100644 --- a/source/blender/editors/render/render_intern.h +++ b/source/blender/editors/render/render_intern.h @@ -56,6 +56,9 @@ void MATERIAL_OT_paste(struct wmOperatorType *ot); void SCENE_OT_view_layer_add(struct wmOperatorType *ot); void SCENE_OT_view_layer_remove(struct wmOperatorType *ot); +void SCENE_OT_light_cache_bake(struct wmOperatorType *ot); +void SCENE_OT_light_cache_free(struct wmOperatorType *ot); + void SCENE_OT_render_view_add(struct wmOperatorType *ot); void SCENE_OT_render_view_remove(struct wmOperatorType *ot); diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index fd534dd9129..7961ea27fdc 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -62,6 +62,9 @@ void ED_operatortypes_render(void) WM_operatortype_append(SCENE_OT_render_view_add); WM_operatortype_append(SCENE_OT_render_view_remove); + WM_operatortype_append(SCENE_OT_light_cache_bake); + WM_operatortype_append(SCENE_OT_light_cache_free); + #ifdef WITH_FREESTYLE WM_operatortype_append(SCENE_OT_freestyle_module_add); WM_operatortype_append(SCENE_OT_freestyle_module_remove); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 1673e0d7ca0..8077079a9b5 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -33,6 +33,7 @@ #include "DNA_curve_types.h" #include "DNA_lamp_types.h" +#include "DNA_lightprobe_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" @@ -94,6 +95,8 @@ #include "RE_pipeline.h" +#include "engines/eevee/eevee_lightcache.h" + #include "render_intern.h" // own include /********************** material slot operators *********************/ @@ -673,6 +676,184 @@ void SCENE_OT_view_layer_remove(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; } +/********************** light cache operators *********************/ +enum { + LIGHTCACHE_SUBSET_ALL = 0, + LIGHTCACHE_SUBSET_DIRTY, + LIGHTCACHE_SUBSET_CUBE, +}; + +static void light_cache_bake_tag_cache(Scene *scene, wmOperator *op) +{ + if (scene->eevee.light_cache != NULL) { + int subset = RNA_enum_get(op->ptr, "subset"); + switch (subset) { + case LIGHTCACHE_SUBSET_ALL: + scene->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_GRID | LIGHTCACHE_UPDATE_CUBE; + break; + case LIGHTCACHE_SUBSET_CUBE: + scene->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_CUBE; + break; + case LIGHTCACHE_SUBSET_DIRTY: + /* Leave tag untouched. */ + break; + } + } +} + +/* catch esc */ +static int light_cache_bake_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + Scene *scene = (Scene *) op->customdata; + + /* no running blender, remove handler and pass through */ + if (0 == WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) { + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; + } + + /* running render */ + switch (event->type) { + case ESCKEY: + return OPERATOR_RUNNING_MODAL; + } + return OPERATOR_PASS_THROUGH; +} + +static void light_cache_bake_cancel(bContext *C, wmOperator *op) +{ + wmWindowManager *wm = CTX_wm_manager(C); + Scene *scene = (Scene *) op->customdata; + + /* kill on cancel, because job is using op->reports */ + WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER); +} + +/* executes blocking render */ +static int light_cache_bake_exec(bContext *C, wmOperator *op) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + + G.is_break = false; + + /* TODO abort if selected engine is not eevee. */ + void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, false); + + light_cache_bake_tag_cache(scene, op); + + short stop = 0, do_update; float progress; /* Not actually used. */ + EEVEE_lightbake_job(rj, &stop, &do_update, &progress); + EEVEE_lightbake_job_data_free(rj); + + // no redraw needed, we leave state as we entered it + ED_update_for_newframe(bmain, CTX_data_depsgraph(C)); + + WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); + + return OPERATOR_FINISHED; +} + +static int light_cache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + int delay = RNA_int_get(op->ptr, "delay"); + + wmJob *wm_job = EEVEE_lightbake_job_create(wm, win, bmain, view_layer, scene, delay); + + if (!wm_job) { + return OPERATOR_CANCELLED; + } + + /* add modal handler for ESC */ + WM_event_add_modal_handler(C, op); + + light_cache_bake_tag_cache(scene, op); + + /* store actual owner of job, so modal operator could check for it, + * the reason of this is that active scene could change when rendering + * several layers from compositor [#31800] + */ + op->customdata = scene; + + WM_jobs_start(wm, wm_job); + + WM_cursor_wait(0); + + return OPERATOR_RUNNING_MODAL; +} + +void SCENE_OT_light_cache_bake(wmOperatorType *ot) +{ + static const EnumPropertyItem light_cache_subset_items[] = { + {LIGHTCACHE_SUBSET_ALL, "ALL", 0, "All LightProbes", "Bake both irradiance grids and reflection cubemaps"}, + {LIGHTCACHE_SUBSET_DIRTY, "DIRTY", 0, "Dirty Only", "Only bake lightprobes that are marked as dirty"}, + {LIGHTCACHE_SUBSET_CUBE, "CUBEMAPS", 0, "Cubemaps Only", "Try to only bake reflection cubemaps if irradiance " + "grids are up to date"}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name = "Bake Light Cache"; + ot->idname = "SCENE_OT_light_cache_bake"; + ot->description = "Bake the active view layer lighting"; + + /* api callbacks */ + ot->invoke = light_cache_bake_invoke; + ot->modal = light_cache_bake_modal; + ot->cancel = light_cache_bake_cancel; + ot->exec = light_cache_bake_exec; + + ot->prop = RNA_def_int(ot->srna, "delay", 0, 0, 2000, "Delay", "Delay in millisecond before baking starts", 0, 2000); + RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); + + ot->prop = RNA_def_enum(ot->srna, "subset", light_cache_subset_items, 0, "Subset", "Subset of probes to update"); + RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); +} + +static bool light_cache_free_poll(bContext *C) +{ + Scene *scene = CTX_data_scene(C); + + return scene->eevee.light_cache; +} + +static int light_cache_free_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + + if (!scene->eevee.light_cache) { + return OPERATOR_CANCELLED; + } + + EEVEE_lightcache_free(scene->eevee.light_cache); + scene->eevee.light_cache = NULL; + + EEVEE_lightcache_info_update(&scene->eevee); + + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); + + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_light_cache_free(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Free Light Cache"; + ot->idname = "SCENE_OT_light_cache_free"; + ot->description = "Free cached indirect lighting"; + + /* api callbacks */ + ot->exec = light_cache_free_exec; + ot->poll = light_cache_free_poll; +} + /********************** render view operators *********************/ static bool render_view_remove_poll(bContext *C) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 83189159086..9aaced3e583 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -683,6 +683,18 @@ static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) } } +static void view3d_lightcache_update(bContext *C) +{ + PointerRNA op_ptr; + + WM_operator_properties_create(&op_ptr, "SCENE_OT_light_cache_bake"); + RNA_int_set(&op_ptr, "delay", 200); + RNA_enum_set_identifier(C, &op_ptr, "subset", "DIRTY"); + + WM_operator_name_call(C, "SCENE_OT_light_cache_bake", WM_OP_INVOKE_DEFAULT, &op_ptr); + + WM_operator_properties_free(&op_ptr); +} /* region dropbox definition */ static void view3d_dropboxes(void) @@ -980,6 +992,9 @@ static void view3d_main_region_listener( break; } break; + case NC_LIGHTPROBE: + ED_area_tag_refresh(sa); + break; case NC_IMAGE: /* this could be more fine grained checks if we had * more context than just the region */ @@ -1409,6 +1424,13 @@ static void space_view3d_listener( } } +static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(sa)) +{ + /* This is only used by the auto lightprobe refresh for the moment. + * So we don't need to check anything to know what to do. */ + view3d_lightcache_update((bContext *)C); +} + const char *view3d_context_dir[] = { "active_base", "active_object", NULL }; @@ -1509,6 +1531,7 @@ void ED_spacetype_view3d(void) st->free = view3d_free; st->init = view3d_init; st->listener = space_view3d_listener; + st->refresh = space_view3d_refresh; st->duplicate = view3d_duplicate; st->operatortypes = view3d_operatortypes; st->keymap = view3d_keymap; diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h index 86d4645ecf5..c06d75a4021 100644 --- a/source/blender/makesdna/DNA_lightprobe_types.h +++ b/source/blender/makesdna/DNA_lightprobe_types.h @@ -106,6 +106,78 @@ enum { LIGHTPROBE_SHAPE_BOX = 1, }; +/* ------- Eevee LightProbes ------- */ +/* Needs to be there because written to file + * with the lightcache. */ + +typedef struct LightProbeCache { + float position[3], parallax_type; + float attenuation_fac; + float attenuation_type; + float pad3[2]; + float attenuationmat[4][4]; + float parallaxmat[4][4]; +} LightProbeCache; + +typedef struct LightGridCache { + float mat[4][4]; + int resolution[3], offset; /* offset to the first irradiance sample in the pool. */ + float corner[3], attenuation_scale; + float increment_x[3], attenuation_bias; /* world space vector between 2 opposite cells */ + float increment_y[3], level_bias; + float increment_z[3], pad4; + float visibility_bias, visibility_bleed, visibility_range, pad5; +} LightGridCache; + +/* ------ Eevee Lightcache ------- */ + +typedef struct LightCacheTexture { + struct GPUTexture *tex; + /* Copy of GPU datas to create GPUTextures on file read. */ + char *data; + int tex_size[3]; + char data_type; + char components; + char pad[2]; +} LightCacheTexture; + +typedef struct LightCache { + int flag; + /* only a single cache for now */ + int cube_len, grid_len; /* Number of probes to use for rendering. */ + int mips_len; /* Number of mipmap level to use. */ + int vis_res, ref_res; /* Size of a visibility/reflection sample. */ + int pad[2]; + /* In the future, we could create a bigger texture containing + * multiple caches (for animation) and interpolate between the + * caches overtime to another texture. */ + LightCacheTexture grid_tx; + LightCacheTexture cube_tx; /* Contains data for mipmap level 0. */ + LightCacheTexture *cube_mips; /* Does not contains valid GPUTexture, only data. */ + /* All lightprobes data contained in the cache. */ + LightProbeCache *cube_data; + LightGridCache *grid_data; +} LightCache; + +/* LightCache->flag */ +enum { + LIGHTCACHE_BAKED = (1 << 0), + LIGHTCACHE_BAKING = (1 << 1), + LIGHTCACHE_CUBE_READY = (1 << 2), + LIGHTCACHE_GRID_READY = (1 << 3), + /* Update tagging */ + LIGHTCACHE_UPDATE_CUBE = (1 << 4), + LIGHTCACHE_UPDATE_GRID = (1 << 5), + LIGHTCACHE_UPDATE_WORLD = (1 << 6), +}; + +/* EEVEE_LightCacheTexture->data_type */ +enum { + LIGHTCACHETEX_BYTE = (1 << 0), + LIGHTCACHETEX_FLOAT = (1 << 1), + LIGHTCACHETEX_UINT = (1 << 2), +}; + #ifdef __cplusplus } #endif diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index f8d7e657b76..e6ad7835b24 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1389,6 +1389,9 @@ typedef struct SceneEEVEE { int gi_cubemap_resolution; int gi_visibility_resolution; + float gi_cubemap_draw_size; + float gi_irradiance_draw_size; + int taa_samples; int taa_render_samples; int sss_samples; @@ -1428,6 +1431,9 @@ typedef struct SceneEEVEE { int shadow_method; int shadow_cube_size; int shadow_cascade_size; + + struct LightCache *light_cache; + char light_cache_info[64]; } SceneEEVEE; /* *************************************************************** */ @@ -2101,6 +2107,9 @@ enum { SCE_EEVEE_SSR_ENABLED = (1 << 14), SCE_EEVEE_SSR_REFRACTION = (1 << 15), SCE_EEVEE_SSR_HALF_RESOLUTION = (1 << 16), + SCE_EEVEE_SHOW_IRRADIANCE = (1 << 17), + SCE_EEVEE_SHOW_CUBEMAPS = (1 << 18), + SCE_EEVEE_GI_AUTOBAKE = (1 << 19), }; /* SceneEEVEE->shadow_method */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 6b312634b50..68b1f5a74aa 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -5815,6 +5815,38 @@ static void rna_def_scene_eevee(BlenderRNA *brna) "Size of the shadow map applied to each irradiance sample"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + prop = RNA_def_property(srna, "gi_show_irradiance", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHOW_IRRADIANCE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Show Irradiance Cache", "Display irradiance samples in the viewport"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gi_show_cubemaps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHOW_CUBEMAPS); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Show Cubemap Cache", "Display captured cubemaps in the viewport"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gi_irradiance_draw_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.05f, 10.0f); + RNA_def_property_float_default(prop, 0.1f); + RNA_def_property_ui_text(prop, "Irradiance Draw Size", "Size of the irradiance sample spheres to debug captured light"); + + prop = RNA_def_property(srna, "gi_cubemap_draw_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.05f, 10.0f); + RNA_def_property_float_default(prop, 0.3f); + RNA_def_property_ui_text(prop, "Cubemap Draw Size", "Size of the cubemap spheres to debug captured light"); + + prop = RNA_def_property(srna, "gi_auto_bake", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GI_AUTOBAKE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Auto Bake", "Auto bake indirect lighting when editing probes"); + + prop = RNA_def_property(srna, "gi_cache_info", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "light_cache_info"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Light Cache Info", "Info on current cache status"); + /* Temporal Anti-Aliasing (super sampling) */ prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE); RNA_def_property_int_default(prop, 16); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 6d577afdbf9..ccbed11e6e8 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -524,6 +524,7 @@ enum { WM_JOB_TYPE_ALEMBIC, WM_JOB_TYPE_SHADER_COMPILATION, WM_JOB_TYPE_STUDIOLIGHT, + WM_JOB_TYPE_LIGHT_BAKE, /* add as needed, screencast, seq proxy build * if having hard coded values is a problem */ }; diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 8e05822dd55..8b7633b635b 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -257,6 +257,7 @@ typedef struct wmNotifier { #define NC_GPENCIL (22<<24) #define NC_LINESTYLE (23<<24) #define NC_CAMERA (24<<24) +#define NC_LIGHTPROBE (25<<24) /* data type, 256 entries is enough, it can overlap */ #define NOTE_DATA 0x00FF0000 -- cgit v1.2.3 From 0a04314d0669bfd3b63fca75474e7fb9749fe8f1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Jul 2018 12:43:10 +0200 Subject: Fix popovers showing unnecessary titles. --- source/blender/editors/interface/interface_layout.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 159e8b1d022..16016a799ef 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -4326,7 +4326,7 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout) static void ui_paneltype_draw_impl( - bContext *C, PanelType *pt, uiLayout *layout) + bContext *C, PanelType *pt, uiLayout *layout, bool show_header) { Panel *panel = MEM_callocN(sizeof(Panel), "popover panel"); panel->type = pt; @@ -4335,13 +4335,15 @@ static void ui_paneltype_draw_impl( uiLayout *last_item = layout->items.last; /* Draw main panel. */ - uiLayout *row = uiLayoutRow(layout, false); - if (pt->draw_header) { - panel->layout = row; - pt->draw_header(C, panel); - panel->layout = NULL; + if (show_header) { + uiLayout *row = uiLayoutRow(layout, false); + if (pt->draw_header) { + panel->layout = row; + pt->draw_header(C, panel); + panel->layout = NULL; + } + uiItemL(row, pt->label, ICON_NONE); } - uiItemL(row, pt->label, ICON_NONE); panel->layout = layout; pt->draw(C, panel); @@ -4361,7 +4363,7 @@ static void ui_paneltype_draw_impl( } uiLayout *col = uiLayoutColumn(layout, false); - ui_paneltype_draw_impl(C, child_pt, col); + ui_paneltype_draw_impl(C, child_pt, col, true); } } } @@ -4375,7 +4377,7 @@ void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout) CTX_store_set(C, layout->context); } - ui_paneltype_draw_impl(C, pt, layout); + ui_paneltype_draw_impl(C, pt, layout, false); if (layout->context) { CTX_store_set(C, NULL); -- cgit v1.2.3 From dd7a727910dd02d830d11d726acf52fd88ea6e8e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Jul 2018 15:35:59 +0200 Subject: Fix accidentally removed particle function in GLSL, still not supported though. --- source/blender/gpu/shaders/gpu_shader_material.glsl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 3affacf5203..2496170db3f 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -170,6 +170,23 @@ void color_to_blender_normal_new_shading(vec3 color, out vec3 normal) /*********** SHADER NODES ***************/ +void particle_info( + vec4 sprops, vec4 loc, vec3 vel, vec3 avel, + out float index, out float random, out float age, + out float life_time, out vec3 location, + out float size, out vec3 velocity, out vec3 angular_velocity) +{ + index = sprops.x; + random = loc.w; + age = sprops.y; + life_time = sprops.z; + size = sprops.w; + + location = loc.xyz; + velocity = vel; + angular_velocity = avel; +} + void vect_normalize(vec3 vin, out vec3 vout) { vout = normalize(vin); -- cgit v1.2.3 From e6dccb4b01f9c62d101dbb52d3e7f7cb7d138afa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Jul 2018 14:11:12 +0200 Subject: Fix T55826, fix T55804: crash after copying scene with linked objects. --- source/blender/blenkernel/intern/layer.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 80329a1d328..2f5c8e7817e 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -346,7 +346,9 @@ void BKE_view_layer_base_select(struct ViewLayer *view_layer, Base *selbase) /**************************** Copy View Layer and Layer Collections ***********************/ -static void layer_collections_copy_data(ListBase *layer_collections_dst, const ListBase *layer_collections_src) +static void layer_collections_copy_data( + ViewLayer *view_layer_dst, const ViewLayer *view_layer_src, + ListBase *layer_collections_dst, const ListBase *layer_collections_src) { BLI_duplicatelist(layer_collections_dst, layer_collections_src); @@ -355,9 +357,15 @@ static void layer_collections_copy_data(ListBase *layer_collections_dst, const L while (layer_collection_dst != NULL) { layer_collections_copy_data( + view_layer_dst, + view_layer_src, &layer_collection_dst->layer_collections, &layer_collection_src->layer_collections); + if (layer_collection_src == view_layer_src->active_collection) { + view_layer_dst->active_collection = layer_collection_dst; + } + layer_collection_dst = layer_collection_dst->next; layer_collection_src = layer_collection_src->next; } @@ -369,7 +377,7 @@ static void layer_collections_copy_data(ListBase *layer_collections_dst, const L * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ void BKE_view_layer_copy_data( - Scene *UNUSED(scene_dst), const Scene *UNUSED(scene_src), + Scene *scene_dst, const Scene *UNUSED(scene_src), ViewLayer *view_layer_dst, const ViewLayer *view_layer_src, const int flag) { @@ -396,9 +404,15 @@ void BKE_view_layer_copy_data( } } - layer_collections_copy_data(&view_layer_dst->layer_collections, &view_layer_src->layer_collections); + view_layer_dst->active_collection = NULL; + layer_collections_copy_data( + view_layer_dst, + view_layer_src, + &view_layer_dst->layer_collections, + &view_layer_src->layer_collections); - // TODO: not always safe to free BKE_layer_collection_sync(scene_dst, view_layer_dst); + LayerCollection *lc_scene_dst = view_layer_dst->layer_collections.first; + lc_scene_dst->collection = scene_dst->master_collection; } void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, const char *newname) @@ -598,6 +612,10 @@ static int layer_collection_sync( BLI_findptr(lb_scene, lc->collection, offsetof(CollectionChild, collection)) : NULL; if (!collection) { + if (lc == view_layer->active_collection) { + view_layer->active_collection = NULL; + } + /* Free recursively. */ layer_collection_free(view_layer, lc); BLI_freelinkN(lb_layer, lc); -- cgit v1.2.3 From c10ece49baea0458f44668d8ad92764c2c361c90 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 17:10:38 +0200 Subject: Fix for recent numeric input checks --- source/blender/editors/util/numinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index f67ea1d5989..4de61395314 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -277,7 +277,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) int cur; #ifndef USE_FAKE_EDIT - if ((event->ctrl == 0) && (event->alt == 0) && + if ((event->ctrl == 0) && (event->alt == 0) && (event->ascii != '\0') && strchr("01234567890@%^&*-+/{}()[]<>.|", event->ascii)) { if (!(n->flag & NUM_EDIT_FULL)) { -- cgit v1.2.3 From 2574ee3d3878c8a78fb2ff1955b10ed20f0ad892 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 17:28:19 +0200 Subject: Image: remove fields option for image sequences Remove support for loading interlaced image sequences because its less common now to record interlaced video, the option to de-interlace video on load remains. --- source/blender/blenkernel/intern/camera.c | 1 - source/blender/blenkernel/intern/image.c | 11 ++--- source/blender/blenkernel/intern/object.c | 1 - source/blender/blenkernel/intern/texture.c | 2 - source/blender/blenloader/intern/versioning_260.c | 1 - .../blender/blenloader/intern/versioning_legacy.c | 19 --------- source/blender/editors/space_image/image_buttons.c | 19 --------- source/blender/editors/space_image/image_ops.c | 1 - source/blender/editors/space_image/space_image.c | 1 - source/blender/makesdna/DNA_image_types.h | 6 +-- source/blender/makesdna/DNA_texture_types.h | 4 +- source/blender/makesrna/intern/rna_image.c | 49 ---------------------- .../nodes/composite/nodes/node_composite_image.c | 1 - .../composite/nodes/node_composite_splitViewer.c | 1 - .../nodes/composite/nodes/node_composite_viewer.c | 1 - .../shader/nodes/node_shader_tex_environment.c | 1 - .../nodes/shader/nodes/node_shader_tex_image.c | 1 - .../nodes/texture/nodes/node_texture_image.c | 1 - 18 files changed, 8 insertions(+), 113 deletions(-) diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 778eb17f822..4203e0455f8 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -977,7 +977,6 @@ CameraBGImage *BKE_camera_background_image_new(Camera *cam) bgpic->scale = 1.0f; bgpic->alpha = 0.5f; - bgpic->iuser.fie_ima = 2; bgpic->iuser.ok = 1; bgpic->iuser.flag |= IMA_ANIM_ALWAYS; bgpic->flag |= CAM_BGIMG_FLAG_EXPANDED; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index b5abdcae2d4..b6aeebd81a5 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -3129,7 +3129,7 @@ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr) #endif /* WITH_OPENEXR */ /* common stuff to do with images after loading */ -static void image_initialize_after_load(Image *ima, ImBuf *ibuf) +static void image_initialize_after_load(Image *ima, ImBuf *UNUSED(ibuf)) { /* Preview is NULL when it has never been used as an icon before. * Never handle previews/icons outside of main thread. */ @@ -3137,11 +3137,6 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) BKE_icon_changed(BKE_icon_id_ensure(&ima->id)); } - /* fields */ - if (ima->flag & IMA_FIELDS) { - if (ima->flag & IMA_STD_FIELD) de_interlace_st(ibuf); - else de_interlace_ng(ibuf); - } /* timer */ BKE_image_tag_time(ima); @@ -4249,7 +4244,7 @@ void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool) int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, bool *r_is_in_range) { - const int len = (iuser->fie_ima * iuser->frames) / 2; + const int len = iuser->frames; if (r_is_in_range) { *r_is_in_range = false; @@ -4290,7 +4285,7 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, bool if (fieldnr) cfra++; /* transform to images space */ - framenr = (cfra + iuser->fie_ima - 2) / iuser->fie_ima; + framenr = cfra; if (framenr > iuser->frames) framenr = iuser->frames; if (iuser->cycl) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 95e408f593e..14794bd7061 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2480,7 +2480,6 @@ void BKE_object_empty_draw_type_set(Object *ob, const int value) ob->iuser->flag |= IMA_ANIM_ALWAYS; ob->iuser->frames = 100; ob->iuser->sfra = 1; - ob->iuser->fie_ima = 2; } } else { diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index ad60e81fe19..c5a208e3aca 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -233,7 +233,6 @@ void BKE_texture_default(Tex *tex) tex->texfilter = TXF_EWA; tex->afmax = 8; tex->xrepeat = tex->yrepeat = 1; - tex->fie_ima = 2; tex->sfra = 1; tex->frames = 0; tex->offset = 0; @@ -267,7 +266,6 @@ void BKE_texture_default(Tex *tex) tex->vn_distm = 0; tex->vn_coltype = 0; - tex->iuser.fie_ima = 2; tex->iuser.ok = 1; tex->iuser.frames = 100; tex->iuser.sfra = 1; diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index c405e385e9f..7a032dc3c90 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -1254,7 +1254,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) tex->iuser.frames = 1; tex->iuser.sfra = 1; - tex->iuser.fie_ima = 2; tex->iuser.ok = 1; } } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 8dae3b235c2..87fc61a8644 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -380,7 +380,6 @@ static void do_version_ntree_242_2(bNodeTree *ntree) iuser->sfra = nia->sfra; iuser->offset = nia->nr-1; iuser->cycl = nia->cyclic; - iuser->fie_ima = 2; iuser->ok = 1; node->storage = iuser; @@ -389,7 +388,6 @@ static void do_version_ntree_242_2(bNodeTree *ntree) else { ImageUser *iuser = node->storage = MEM_callocN(sizeof(ImageUser), "node image user"); iuser->sfra = 1; - iuser->fie_ima = 2; iuser->ok = 1; } } @@ -1844,13 +1842,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) ima = blo_do_versions_newlibadr(fd, lib, tex->ima); if (tex->imaflag & TEX_ANIM5_) ima->source = IMA_SRC_MOVIE; - if (tex->imaflag & TEX_FIELDS_) - ima->flag |= IMA_FIELDS; - if (tex->imaflag & TEX_STD_FIELD_) - ima->flag |= IMA_STD_FIELD; } tex->iuser.frames = tex->frames; - tex->iuser.fie_ima = (char)tex->fie_ima; tex->iuser.offset = tex->offset; tex->iuser.sfra = tex->sfra; tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC_)!=0; @@ -1864,18 +1857,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->nodetree) do_version_ntree_242_2(ma->nodetree); - - for (sc = bmain->screen.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { - SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_IMAGE) { - ((SpaceImage *)sl)->iuser.fie_ima = 2; - } - } - } - } } if (bmain->subversionfile < 4) { diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 191f57961c9..1d8c6721b64 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -1000,25 +1000,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char col = uiLayoutColumn(layout, false); uiItemR(col, &imaptr, "use_deinterlace", 0, IFACE_("Deinterlace"), ICON_NONE); } - - split = uiLayoutSplit(layout, 0.0f, false); - - col = uiLayoutColumn(split, false); - /* XXX Why only display fields_per_frame only for video image types? - * And why allow fields for non-video image types at all??? */ - if (BKE_image_is_animated(ima)) { - uiLayout *subsplit = uiLayoutSplit(col, 0.0f, false); - uiLayout *subcol = uiLayoutColumn(subsplit, false); - uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE); - subcol = uiLayoutColumn(subsplit, false); - uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields")); - uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE); - } - else - uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, false); - uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); - uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 650b48b3b1c..29d63493a3c 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1340,7 +1340,6 @@ static int image_open_exec(bContext *C, wmOperator *op) else { iuser->offset = frame_ofs - 1; } - iuser->fie_ima = 2; iuser->scene = scene; BKE_image_init_imageuser(ima, iuser); } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 9d89e21289d..650f377787a 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -177,7 +177,6 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA | SI_COORDFLOATS; simage->iuser.ok = true; - simage->iuser.fie_ima = 2; simage->iuser.frames = 100; simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS; diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index 26d7f089f8b..a7ec121efda 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -51,7 +51,7 @@ typedef struct ImageUser { int framenr; /* movies, sequences: current to display */ int frames; /* total amount of frames to use */ int offset, sfra; /* offset within movie, start frame in global time */ - char fie_ima, cycl; /* fields/image in movie, cyclic flag */ + char _pad, cycl; /* cyclic flag */ char ok; char multiview_eye; /* multiview current eye - for internal use of drawing routines */ @@ -157,8 +157,8 @@ typedef struct Image { /* Image.flag */ enum { - IMA_FIELDS = (1 << 0), - IMA_STD_FIELD = (1 << 1), + // IMA_FIELDS = (1 << 0), + // IMA_STD_FIELD = (1 << 1), #ifdef DNA_DEPRECATED IMA_DO_PREMUL = (1 << 2), /* deprecated, should not be used */ #endif diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index ca420195b99..42198e22c6b 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -192,7 +192,7 @@ typedef struct Tex { short extend; /* variables disabled, moved to struct iuser */ - short fie_ima; + short _pad0; int len; int frames, offset, sfra; @@ -319,7 +319,7 @@ typedef struct ColorMapping { /* imaflag unused, only for version check */ #ifdef DNA_DEPRECATED_ALLOW -#define TEX_FIELDS_ 8 +// #define TEX_FIELDS_ 8 #define TEX_ANIMCYCLIC_ 64 #define TEX_ANIM5_ 128 #define TEX_ANTIALI_ 256 diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 3d12debe0b5..1759eb812e6 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -99,27 +99,6 @@ static void rna_Image_source_set(PointerRNA *ptr, int value) } } -static void rna_Image_fields_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) -{ - Image *ima = ptr->id.data; - ImBuf *ibuf; - void *lock; - - ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); - - if (ibuf) { - short nr = 0; - - if (!(ima->flag & IMA_FIELDS) && (ibuf->flags & IB_fields)) nr = 1; - if ((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr = 1; - - if (nr) - BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE); - } - - BKE_image_release_ibuf(ima, ibuf, lock); -} - static void rna_Image_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Image *ima = ptr->id.data; @@ -562,13 +541,6 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_ImageUser_update"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "fie_ima"); - RNA_def_property_range(prop, 1, 200); - RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)"); - RNA_def_property_update(prop, 0, "rna_ImageUser_update"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "layer"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */ @@ -672,11 +644,6 @@ static void rna_def_image(BlenderRNA *brna) {IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""}, {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem prop_field_order_items[] = { - {0, "EVEN", 0, "Upper First", "Upper field first"}, - {IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"}, - {0, NULL, 0, NULL, NULL} - }; static const EnumPropertyItem alpha_mode_items[] = { {IMA_ALPHA_STRAIGHT, "STRAIGHT", 0, "Straight", "Transparent RGB and alpha pixels are unmodified"}, {IMA_ALPHA_PREMUL, "PREMUL", 0, "Premultiplied", "Transparent RGB pixels are multiplied by the alpha channel"}, @@ -727,22 +694,6 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Packed Files", "Collection of packed images"); - prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE); - RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_field_order_items); - RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines are displayed first)"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); - RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS); - RNA_def_property_ui_text(prop, "Fields", "Use fields of the image"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - - prop = RNA_def_property(srna, "use_view_as_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER); diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index a754066dea3..78956f63e8a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -304,7 +304,6 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node) node->storage = iuser; iuser->frames = 1; iuser->sfra = 1; - iuser->fie_ima = 2; iuser->ok = 1; iuser->flag |= IMA_ANIM_ALWAYS; diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index f7008bc9ae4..863c8af66bb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -47,7 +47,6 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user"); node->storage = iuser; iuser->sfra = 1; - iuser->fie_ima = 2; iuser->ok = 1; node->custom1 = 50; /* default 50% split */ diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index f82b0d7206a..6221202398a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -49,7 +49,6 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node) ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user"); node->storage = iuser; iuser->sfra = 1; - iuser->fie_ima = 2; iuser->ok = 1; node->custom3 = 0.5f; node->custom4 = 0.5f; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index 3e52a6c3d7d..41860df5670 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -48,7 +48,6 @@ static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode *no tex->projection = SHD_PROJ_EQUIRECTANGULAR; tex->iuser.frames = 1; tex->iuser.sfra = 1; - tex->iuser.fie_ima = 2; tex->iuser.ok = 1; node->storage = tex; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index 55669b57998..2bbe3617bee 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -48,7 +48,6 @@ static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node) tex->color_space = SHD_COLORSPACE_COLOR; tex->iuser.frames = 1; tex->iuser.sfra = 1; - tex->iuser.fie_ima = 2; tex->iuser.ok = 1; node->storage = tex; diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index 0d70eff15e3..4fccab27b24 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -93,7 +93,6 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node) ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user"); node->storage = iuser; iuser->sfra = 1; - iuser->fie_ima = 2; iuser->ok = 1; iuser->flag |= IMA_ANIM_ALWAYS; } -- cgit v1.2.3 From 77964b2efb859e27caf48dab5b7a3e0707291c89 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 9 Jul 2018 16:25:22 +0200 Subject: Fix Cycles standalone build issue with OpenColorIO. --- intern/cycles/app/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt index cfca45600a5..936da0075fe 100644 --- a/intern/cycles/app/CMakeLists.txt +++ b/intern/cycles/app/CMakeLists.txt @@ -60,6 +60,10 @@ link_directories(${OPENIMAGEIO_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH}) +if(WITH_OPENCOLORIO) + link_directories(${OPENCOLORIO_LIBPATH}) +endif() + add_definitions(${GL_DEFINITIONS}) include_directories(${INC}) @@ -81,7 +85,6 @@ macro(cycles_target_link_libraries target) target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES}) endif() if(WITH_OPENCOLORIO) - link_directories(${OPENCOLORIO_LIBPATH}) target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES}) endif() target_link_libraries( -- cgit v1.2.3 From 7f5e4a819c4cd30861e424a28a47e0c0a5d1837a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 9 Jul 2018 16:31:18 +0200 Subject: GHOST/Windows: don't prefer swap copy method. This is no longer needed with the new offscreen draw method, so use whatever is default and hopefully fastest. Fixes console warnings in some setups that don't have swap copy. --- intern/ghost/intern/GHOST_ContextWGL.cpp | 104 +++---------------------------- intern/ghost/intern/GHOST_ContextWGL.h | 10 +-- 2 files changed, 10 insertions(+), 104 deletions(-) diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp index 035b0c268c6..9605f7ddff2 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cpp +++ b/intern/ghost/intern/GHOST_ContextWGL.cpp @@ -199,10 +199,6 @@ static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd, PIXELFORMATDESCRIPTOR weight++; #endif - /* want swap copy capability -- it matters a lot */ - if (pfd.dwFlags & PFD_SWAP_COPY) - weight += 16; - return weight; } @@ -404,7 +400,6 @@ static void makeAttribList( std::vector& out, bool stereoVisual, int numOfAASamples, - int swapMethod, bool needAlpha, bool needStencil, bool sRGB) @@ -424,9 +419,6 @@ static void makeAttribList( out.push_back(WGL_ACCELERATION_ARB); out.push_back(WGL_FULL_ACCELERATION_ARB); - out.push_back(WGL_SWAP_METHOD_ARB); - out.push_back(swapMethod); - if (stereoVisual) { out.push_back(WGL_STEREO_ARB); out.push_back(GL_TRUE); @@ -468,13 +460,12 @@ static void makeAttribList( } -int GHOST_ContextWGL::_choose_pixel_format_arb_2( +int GHOST_ContextWGL::_choose_pixel_format_arb_1( bool stereoVisual, - int *numOfAASamples, + int numOfAASamples, bool needAlpha, bool needStencil, - bool sRGB, - int swapMethod) + bool sRGB) { std::vector iAttributes; @@ -486,12 +477,12 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2( int samples; // guard against some insanely high number of samples - if (*numOfAASamples > 64) { + if (numOfAASamples > 64) { fprintf(stderr, "Warning! Clamping number of samples to 64.\n"); samples = 64; } else { - samples = *numOfAASamples; + samples = numOfAASamples; } // request a format with as many samples as possible, but not more than requested @@ -500,7 +491,6 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2( iAttributes, stereoVisual, samples, - swapMethod, needAlpha, needStencil, sRGB); @@ -549,13 +539,11 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2( int actualSamples, alphaBits; wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, iQuery, &actualSamples); - if (actualSamples != *numOfAASamples) { + if (actualSamples != numOfAASamples) { fprintf(stderr, "Warning! Unable to find a multisample pixel format that supports exactly %d samples. " "Substituting one that uses %d samples.\n", - *numOfAASamples, actualSamples); - - *numOfAASamples = actualSamples; // set context property to actual value + numOfAASamples, actualSamples); } if (needAlpha) { iQuery[0] = WGL_ALPHA_BITS_ARB; @@ -566,69 +554,6 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2( } } } - else { - *numOfAASamples = 0; - } - return iPixelFormat; -} - - -int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, - int numOfAASamples, - bool needAlpha, - bool needStencil, - bool sRGB, - int *swapMethodOut) -{ - int iPixelFormat; - int copyPixelFormat = 0; - int undefPixelFormat = 0; - int exchPixelFormat = 0; - int copyNumOfAASamples = 0; - int undefNumOfAASamples = 0; - int exchNumOfAASamples = 0; - - *swapMethodOut = WGL_SWAP_COPY_ARB; - copyNumOfAASamples = numOfAASamples; - copyPixelFormat = _choose_pixel_format_arb_2( - stereoVisual, ©NumOfAASamples, needAlpha, needStencil, sRGB, *swapMethodOut); - - if (copyPixelFormat == 0 || copyNumOfAASamples < numOfAASamples) { - *swapMethodOut = WGL_SWAP_UNDEFINED_ARB; - undefNumOfAASamples = numOfAASamples; - undefPixelFormat = _choose_pixel_format_arb_2( - stereoVisual, &undefNumOfAASamples, needAlpha, needStencil, sRGB, *swapMethodOut); - - if (undefPixelFormat == 0 || undefNumOfAASamples < numOfAASamples) { - *swapMethodOut = WGL_SWAP_EXCHANGE_ARB; - exchNumOfAASamples = numOfAASamples; - exchPixelFormat = _choose_pixel_format_arb_2( - stereoVisual, &exchNumOfAASamples, needAlpha, needStencil, sRGB, *swapMethodOut); - if (exchPixelFormat == 0 || exchNumOfAASamples < numOfAASamples) { - // the number of AA samples cannot be met, take the highest - if (undefPixelFormat != 0 && undefNumOfAASamples >= exchNumOfAASamples) { - exchNumOfAASamples = undefNumOfAASamples; - exchPixelFormat = undefPixelFormat; - *swapMethodOut = WGL_SWAP_UNDEFINED_ARB; - } - if (copyPixelFormat != 0 && copyNumOfAASamples >= exchNumOfAASamples) { - exchNumOfAASamples = copyNumOfAASamples; - exchPixelFormat = copyPixelFormat; - *swapMethodOut = WGL_SWAP_COPY_ARB; - } - } - iPixelFormat = exchPixelFormat; - m_numOfAASamples = exchNumOfAASamples; - } - else { - iPixelFormat = undefPixelFormat; - m_numOfAASamples = undefNumOfAASamples; - } - } - else { - iPixelFormat = copyPixelFormat; - m_numOfAASamples = copyNumOfAASamples; - } return iPixelFormat; } @@ -641,15 +566,13 @@ int GHOST_ContextWGL::choose_pixel_format_arb( bool sRGB) { int iPixelFormat; - int swapMethodOut; iPixelFormat = _choose_pixel_format_arb_1( stereoVisual, numOfAASamples, needAlpha, needStencil, - sRGB, - &swapMethodOut); + sRGB); if (iPixelFormat == 0 && stereoVisual) { fprintf(stderr, "Warning! Unable to find a stereo pixel format.\n"); @@ -659,19 +582,11 @@ int GHOST_ContextWGL::choose_pixel_format_arb( numOfAASamples, needAlpha, needStencil, - sRGB, - &swapMethodOut); + sRGB); m_stereoVisual = false; // set context property to actual value } - if (swapMethodOut != WGL_SWAP_COPY_ARB) { - fprintf(stderr, - "Warning! Unable to find a pixel format that supports WGL_SWAP_COPY_ARB. " - "Substituting one that uses %s.\n", - swapMethodOut == WGL_SWAP_UNDEFINED_ARB ? "WGL_SWAP_UNDEFINED_ARB" : "WGL_SWAP_EXCHANGE_ARB"); - } - return iPixelFormat; } @@ -689,7 +604,6 @@ int GHOST_ContextWGL::choose_pixel_format( (DWORD) ( PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | - PFD_SWAP_COPY | /* support swap copy */ PFD_DOUBLEBUFFER | /* support double-buffering */ (stereoVisual ? PFD_STEREO : 0) |/* support stereo */ ( diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h index 2ffe9523008..07ed7f4d2ef 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.h +++ b/intern/ghost/intern/GHOST_ContextWGL.h @@ -131,15 +131,7 @@ private: int numOfAASamples, bool needAlpha, bool needStencil, - bool sRGB, - int *swapMethodOut); - - int _choose_pixel_format_arb_2(bool stereoVisual, - int *numOfAASamples, - bool needAlpha, - bool needStencil, - bool sRGB, - int swapMethod); + bool sRGB); void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD); -- cgit v1.2.3 From a6ea38d345b77f740a553fdc053afead814c58f1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Jul 2018 17:54:20 +0200 Subject: Cleanup: remove unused interlace code after removal of fields. --- source/blender/blenkernel/BKE_image.h | 2 - source/blender/blenkernel/intern/image.c | 70 ---------------------- source/blender/blenkernel/intern/writeavi.c | 2 - source/blender/imbuf/IMB_imbuf.h | 1 - source/blender/imbuf/IMB_imbuf_types.h | 1 - source/blender/imbuf/intern/allocimbuf.c | 1 - source/blender/imbuf/intern/divers.c | 56 ----------------- source/blender/imbuf/intern/readimage.c | 1 - source/blender/imbuf/intern/stereoimbuf.c | 2 - source/blender/render/intern/source/imagetexture.c | 36 +++++------ 10 files changed, 16 insertions(+), 156 deletions(-) diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 060ed4536a4..a41d9582add 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -114,8 +114,6 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struc struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]); struct anim *openanim_noload(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]); -void BKE_image_de_interlace(struct Image *ima, int odd); - void BKE_image_make_local(struct Main *bmain, struct Image *ima, const bool lib_local); void BKE_image_tag_time(struct Image *ima); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index b6aeebd81a5..bf27d6021b6 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -186,76 +186,6 @@ void BKE_images_exit(void) BLI_spin_end(&image_spin); } -/* ******** IMAGE PROCESSING ************* */ - -static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ -{ - struct ImBuf *tbuf1, *tbuf2; - - if (ibuf == NULL) return; - if (ibuf->flags & IB_fields) return; - ibuf->flags |= IB_fields; - - if (ibuf->rect) { - /* make copies */ - tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect); - tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect); - - ibuf->x *= 2; - - IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); - IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y); - - ibuf->x /= 2; - IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y); - IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y); - - IMB_freeImBuf(tbuf1); - IMB_freeImBuf(tbuf2); - } - ibuf->y /= 2; -} - -static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ -{ - struct ImBuf *tbuf1, *tbuf2; - - if (ibuf == NULL) return; - if (ibuf->flags & IB_fields) return; - ibuf->flags |= IB_fields; - - if (ibuf->rect) { - /* make copies */ - tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect); - tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect); - - ibuf->x *= 2; - - IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); - IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y); - - ibuf->x /= 2; - IMB_rectcpy(ibuf, tbuf2, 0, 0, 0, 0, tbuf2->x, tbuf2->y); - IMB_rectcpy(ibuf, tbuf1, 0, tbuf2->y, 0, 0, tbuf1->x, tbuf1->y); - - IMB_freeImBuf(tbuf1); - IMB_freeImBuf(tbuf2); - } - ibuf->y /= 2; -} - -void BKE_image_de_interlace(Image *ima, int odd) -{ - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); - if (ibuf) { - if (odd) - de_interlace_st(ibuf); - else - de_interlace_ng(ibuf); - } - BKE_image_release_ibuf(ima, ibuf, NULL); -} - /* ***************** ALLOC & FREE, DATA MANAGING *************** */ static void image_free_cached_frames(Image *image) diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 994592ec307..1db239b3c6f 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -197,8 +197,6 @@ static int start_avi(void *context_v, Scene *UNUSED(scene), RenderData *rd, int avi->interlace = 0; avi->odd_fields = 0; -/* avi->interlace = rd->mode & R_FIELDS; */ -/* avi->odd_fields = (rd->mode & R_ODDFIELD) ? 1 : 0; */ printf("Created avi: %s\n", name); return 1; diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 75f8df99e63..04ce2d6eaa3 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -431,7 +431,6 @@ bool IMB_isfloat(struct ImBuf *ibuf); * \attention Defined in divers.c */ void IMB_de_interlace(struct ImBuf *ibuf); -void IMB_interlace(struct ImBuf *ibuf); /* create char buffer, color corrected if necessary, for ImBufs that lack one */ void IMB_rect_from_float(struct ImBuf *ibuf); diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index ee51854d7ed..e83357ac82e 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -242,7 +242,6 @@ typedef struct ImBuf { #define IB_rect (1 << 0) #define IB_test (1 << 1) -#define IB_fields (1 << 2) #define IB_zbuf (1 << 3) #define IB_mem (1 << 4) #define IB_rectfloat (1 << 5) diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 589955d2ab3..58554693aeb 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -521,7 +521,6 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1) x = ibuf1->x; y = ibuf1->y; - if (ibuf1->flags & IB_fields) y *= 2; ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags); if (ibuf2 == NULL) return NULL; diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 2b6fa573e63..e6635080163 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -45,62 +45,6 @@ #include "MEM_guardedalloc.h" -/**************************** Interlace/Deinterlace **************************/ - -void IMB_de_interlace(ImBuf *ibuf) -{ - ImBuf *tbuf1, *tbuf2; - - if (ibuf == NULL) return; - if (ibuf->flags & IB_fields) return; - ibuf->flags |= IB_fields; - - if (ibuf->rect) { - /* make copies */ - tbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect); - tbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect); - - ibuf->x *= 2; - IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); - IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y); - - ibuf->x /= 2; - IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y); - IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y); - - IMB_freeImBuf(tbuf1); - IMB_freeImBuf(tbuf2); - } - ibuf->y /= 2; -} - -void IMB_interlace(ImBuf *ibuf) -{ - ImBuf *tbuf1, *tbuf2; - - if (ibuf == NULL) return; - ibuf->flags &= ~IB_fields; - - ibuf->y *= 2; - - if (ibuf->rect) { - /* make copies */ - tbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect); - tbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect); - - IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); - IMB_rectcpy(tbuf2, ibuf, 0, 0, 0, tbuf2->y, ibuf->x, ibuf->y); - - ibuf->x *= 2; - IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y); - IMB_rectcpy(ibuf, tbuf2, tbuf2->x, 0, 0, 0, tbuf2->x, tbuf2->y); - ibuf->x /= 2; - - IMB_freeImBuf(tbuf1); - IMB_freeImBuf(tbuf2); - } -} - /************************* Floyd-Steinberg dithering *************************/ typedef struct DitherContext { diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 0b4490a3beb..0cb1ab4b2c5 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -230,7 +230,6 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename)); for (a = 1; a < ibuf->miptot; a++) BLI_strncpy(ibuf->mipmap[a - 1]->cachename, filepath_tx, sizeof(ibuf->cachename)); - if (flags & IB_fields) IMB_de_interlace(ibuf); } close(file); diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.c index a4418443790..7c58815c216 100644 --- a/source/blender/imbuf/intern/stereoimbuf.c +++ b/source/blender/imbuf/intern/stereoimbuf.c @@ -722,7 +722,6 @@ ImBuf *IMB_stereo3d_ImBuf(ImageFormatData *im_format, ImBuf *ibuf_left, ImBuf *i ibuf_stereo->rect_colorspace = ibuf_left->rect_colorspace; ibuf_stereo->float_colorspace = ibuf_left->float_colorspace; - /* copy flags for IB_fields and other settings */ ibuf_stereo->flags = ibuf_left->flags; imb_stereo3d_data_initialize( @@ -1233,7 +1232,6 @@ void IMB_ImBufFromStereo3d( ibuf_left = IMB_allocImBuf(width, height, ibuf_stereo3d->planes, (is_float ? IB_rectfloat : IB_rect)); ibuf_right = IMB_allocImBuf(width, height, ibuf_stereo3d->planes, (is_float ? IB_rectfloat : IB_rect)); - /* copy flags for IB_fields and other settings */ ibuf_left->flags = ibuf_stereo3d->flags; ibuf_right->flags = ibuf_stereo3d->flags; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 1e9ad79e599..3a31413c5cd 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -873,29 +873,25 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl static void image_mipmap_test(Tex *tex, ImBuf *ibuf) { if (tex->imaflag & TEX_MIPMAP) { - if ((ibuf->flags & IB_fields) == 0) { - - if (ibuf->mipmap[0] && (ibuf->userflags & IB_MIPMAP_INVALID)) { - BLI_thread_lock(LOCK_IMAGE); - if (ibuf->userflags & IB_MIPMAP_INVALID) { - IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); - ibuf->userflags &= ~IB_MIPMAP_INVALID; - } - BLI_thread_unlock(LOCK_IMAGE); - } - if (ibuf->mipmap[0] == NULL) { - BLI_thread_lock(LOCK_IMAGE); - if (ibuf->mipmap[0] == NULL) - IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); - BLI_thread_unlock(LOCK_IMAGE); - } - /* if no mipmap could be made, fall back on non-mipmap render */ - if (ibuf->mipmap[0] == NULL) { - tex->imaflag &= ~TEX_MIPMAP; + if (ibuf->mipmap[0] && (ibuf->userflags & IB_MIPMAP_INVALID)) { + BLI_thread_lock(LOCK_IMAGE); + if (ibuf->userflags & IB_MIPMAP_INVALID) { + IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); + ibuf->userflags &= ~IB_MIPMAP_INVALID; } + BLI_thread_unlock(LOCK_IMAGE); + } + if (ibuf->mipmap[0] == NULL) { + BLI_thread_lock(LOCK_IMAGE); + if (ibuf->mipmap[0] == NULL) + IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); + BLI_thread_unlock(LOCK_IMAGE); + } + /* if no mipmap could be made, fall back on non-mipmap render */ + if (ibuf->mipmap[0] == NULL) { + tex->imaflag &= ~TEX_MIPMAP; } } - } static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], float dxt[2], float dyt[2], TexResult *texres, struct ImagePool *pool, const bool skip_load_image) -- cgit v1.2.3 From debfbdc27941eeadc8c875c35bf8a13519c87bb4 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 10 Jul 2018 18:21:44 +0200 Subject: UI: Single-column and sub-panels for Image Texture properties --- .../scripts/startup/bl_ui/properties_texture.py | 125 +++++++++++---------- 1 file changed, 67 insertions(+), 58 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 16e29d1ecc8..077ecb21d3e 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -383,113 +383,121 @@ class TEXTURE_PT_image(TextureTypePanel, Panel): layout = self.layout tex = context.texture - layout.template_image(tex, "image", tex.image_user) def texture_filter_common(tex, layout): - layout.label(text="Filter:") - layout.prop(tex, "filter_type", text="") + layout.prop(tex, "filter_type", text="Filter Type") if tex.use_mipmap and tex.filter_type in {'AREA', 'EWA', 'FELINE'}: if tex.filter_type == 'FELINE': layout.prop(tex, "filter_lightprobes", text="Light Probes") else: layout.prop(tex, "filter_eccentricity", text="Eccentricity") - layout.prop(tex, "filter_size") - layout.prop(tex, "use_filter_size_min") + layout.prop(tex, "filter_size", text="Size") + layout.prop(tex, "use_filter_size_min", text="Minimum Size") class TEXTURE_PT_image_sampling(TextureTypePanel, Panel): - bl_label = "Image Sampling" + bl_label = "Sampling" bl_options = {'DEFAULT_CLOSED'} + bl_parent_id = 'TEXTURE_PT_image' tex_type = 'IMAGE' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw(self, context): layout = self.layout + layout.use_property_split = True + flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False) idblock = context_tex_datablock(context) tex = context.texture slot = getattr(context, "texture_slot", None) - split = layout.split() - - col = split.column() - col.label(text="Alpha:") - row = col.row() - row.active = bool(tex.image and tex.image.use_alpha) - row.prop(tex, "use_alpha", text="Use") - col.prop(tex, "use_calculate_alpha", text="Calculate") - col.prop(tex, "invert_alpha", text="Invert") - col.separator() + col = flow.column() col.prop(tex, "use_flip_axis", text="Flip X/Y Axis") + col.prop(tex, "use_interpolation") - col = split.column() + col.separator() + col = flow.column() col.prop(tex, "use_mipmap") - row = col.row() - row.active = tex.use_mipmap - row.prop(tex, "use_mipmap_gauss") - col.prop(tex, "use_interpolation") + sub = col.column() + sub.active = tex.use_mipmap + sub.prop(tex, "use_mipmap_gauss", text="Gaussian Filter") + + col.separator() + col = flow.column() texture_filter_common(tex, col) +class TEXTURE_PT_image_alpha(TextureTypePanel, Panel): + bl_label = "Alpha" + bl_options = {'DEFAULT_CLOSED'} + bl_parent_id = 'TEXTURE_PT_image' + + def draw_header(self, context): + tex = context.texture + self.layout.prop(tex, "use_alpha", text="") + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + tex = context.texture + + col = layout.column() + col.active = bool(tex.image and tex.image.use_alpha) + col.prop(tex, "use_calculate_alpha", text="Calculate") + col.prop(tex, "invert_alpha", text="Invert") + + class TEXTURE_PT_image_mapping(TextureTypePanel, Panel): - bl_label = "Image Mapping" + bl_label = "Mapping" bl_options = {'DEFAULT_CLOSED'} + bl_parent_id = 'TEXTURE_PT_image' tex_type = 'IMAGE' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw(self, context): layout = self.layout + layout.use_property_split = True + flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False) tex = context.texture - layout.prop(tex, "extension") - - split = layout.split() + col = flow.column() + col.prop(tex, "extension") if tex.extension == 'REPEAT': - col = split.column(align=True) - col.label(text="Repeat:") - col.prop(tex, "repeat_x", text="X") - col.prop(tex, "repeat_y", text="Y") - - col = split.column(align=True) - col.label(text="Mirror:") - row = col.row(align=True) - row.prop(tex, "use_mirror_x", text="X") - row.active = (tex.repeat_x > 1) - row = col.row(align=True) - row.prop(tex, "use_mirror_y", text="Y") - row.active = (tex.repeat_y > 1) - layout.separator() + sub = col.column(align=True) + sub.prop(tex, "repeat_x", text="Repeat X") + sub.prop(tex, "repeat_y", text="Y") - elif tex.extension == 'CHECKER': - col = split.column(align=True) - row = col.row(align=True) - row.prop(tex, "use_checker_even", text="Even") - row.prop(tex, "use_checker_odd", text="Odd") + sub = col.column() + sub.prop(tex, "use_mirror_x", text="Mirror X") + sub.active = (tex.repeat_x > 1) - col = split.column() - col.prop(tex, "checker_distance", text="Distance") + sub = col.column() + sub.prop(tex, "use_mirror_y", text="Y") + sub.active = (tex.repeat_y > 1) - layout.separator() + elif tex.extension == 'CHECKER': + col = layout.column(align=True) + col.prop(tex, "use_checker_even", text="Even") + col.prop(tex, "use_checker_odd", text="Odd") - split = layout.split() + col = layout.column() + col.prop(tex, "checker_distance", text="Distance") - col = split.column(align=True) + col = flow.column() + sub = col.column(align=True) # col.prop(tex, "crop_rectangle") - col.label(text="Crop Minimum:") - col.prop(tex, "crop_min_x", text="X") - col.prop(tex, "crop_min_y", text="Y") + sub.prop(tex, "crop_min_x", text="Crop Minimum X") + sub.prop(tex, "crop_min_y", text="Y") - col = split.column(align=True) - col.label(text="Crop Maximum:") - col.prop(tex, "crop_max_x", text="X") - col.prop(tex, "crop_max_y", text="Y") + sub = col.column(align=True) + sub.prop(tex, "crop_max_x", text="Crop Maximum X") + sub.prop(tex, "crop_max_y", text="Y") class TEXTURE_PT_musgrave(TextureTypePanel, Panel): @@ -789,6 +797,7 @@ classes = ( TEXTURE_PT_blend, TEXTURE_PT_stucci, TEXTURE_PT_image, + TEXTURE_PT_image_alpha, TEXTURE_PT_image_sampling, TEXTURE_PT_image_mapping, TEXTURE_PT_musgrave, -- cgit v1.2.3 From 245d0d6bb71376ce782ec03bb1622309b9f38aab Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 10 Jul 2018 18:22:16 +0200 Subject: UI: Textures - Move Colors panel below texture-specific panels --- .../scripts/startup/bl_ui/properties_texture.py | 68 +++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 077ecb21d3e..1859b4bf3e8 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -199,39 +199,6 @@ class TEXTURE_PT_node_mapping(TextureButtonsPanel, Panel): row.prop(mapping, "mapping_z", text="") -class TEXTURE_PT_colors(TextureButtonsPanel, Panel): - bl_label = "Colors" - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} - - @classmethod - def poll(cls, context): - tex = context.texture - return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES) - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - - tex = context.texture - - col = layout.column() - sub = col.column(align=True) - sub.prop(tex, "factor_red", text="Multiply R") - sub.prop(tex, "factor_green", text="G") - sub.prop(tex, "factor_blue", text="B") - - col.prop(tex, "intensity") - col.prop(tex, "contrast") - col.prop(tex, "saturation") - - col.prop(tex, "use_clamp", text="Clamp") - col.prop(tex, "use_color_ramp", text="Ramp") - if tex.use_color_ramp: - layout.use_property_split = False - layout.template_color_ramp(tex, "color_ramp", expand=True) - - class TextureTypePanel(TextureButtonsPanel): @classmethod @@ -770,6 +737,39 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel): col.prop(tex, "use_stencil") +class TEXTURE_PT_colors(TextureButtonsPanel, Panel): + bl_label = "Colors" + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + tex = context.texture + return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + tex = context.texture + + col = layout.column() + sub = col.column(align=True) + sub.prop(tex, "factor_red", text="Multiply R") + sub.prop(tex, "factor_green", text="G") + sub.prop(tex, "factor_blue", text="B") + + col.prop(tex, "intensity") + col.prop(tex, "contrast") + col.prop(tex, "saturation") + + col.prop(tex, "use_clamp", text="Clamp") + col.prop(tex, "use_color_ramp", text="Ramp") + if tex.use_color_ramp: + layout.use_property_split = False + layout.template_color_ramp(tex, "color_ramp", expand=True) + + class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} _context_path = "texture" @@ -789,7 +789,6 @@ classes = ( TEXTURE_PT_node_mapping, TEXTURE_PT_mapping, TEXTURE_PT_influence, - TEXTURE_PT_colors, TEXTURE_PT_clouds, TEXTURE_PT_wood, TEXTURE_PT_marble, @@ -803,6 +802,7 @@ classes = ( TEXTURE_PT_musgrave, TEXTURE_PT_voronoi, TEXTURE_PT_distortednoise, + TEXTURE_PT_colors, TEXTURE_PT_custom_props, ) -- cgit v1.2.3 From 8a3366a494cf2939138a96cb93a2b666a3be77c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Jul 2018 18:30:45 +0200 Subject: 3D View: option to hide object overlays This hides extra wires and details you may want to disable, name may be changed. --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/draw/modes/object_mode.c | 30 ++++++++++++++++++++++++++- source/blender/makesdna/DNA_view3d_types.h | 1 + source/blender/makesrna/intern/rna_space.c | 5 +++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index cf2c9641971..d9f17f70e20 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3897,6 +3897,7 @@ class VIEW3D_PT_overlay(Panel): #sub.prop(overlay, "show_onion_skins") sub.prop(overlay, "show_face_orientation") sub.prop(overlay, "show_backface_culling") + sub.prop(overlay, "show_ornaments", text="Ornaments") sub.prop(overlay, "show_bones", text="Bones") if shading.type == 'MATERIAL': sub.prop(overlay, "show_look_dev") diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 2ac16906102..0726c3660d5 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2131,6 +2131,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) bool do_outlines = (draw_ctx->v3d->flag & V3D_SELECT_OUTLINE) && ((ob->base_flag & BASE_SELECTED) != 0); bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0); + const bool hide_object_extra = (v3d->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) != 0; if (do_outlines) { if ((ob != draw_ctx->object_edit) && !((ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT))) { @@ -2156,6 +2157,9 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) switch (ob->type) { case OB_MESH: { + if (hide_object_extra) { + break; + } if (ob != draw_ctx->object_edit) { Mesh *me = ob->data; if (me->totedge == 0) { @@ -2188,6 +2192,9 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) case OB_LATTICE: { if (ob != draw_ctx->object_edit) { + if (hide_object_extra) { + break; + } struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false); if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); @@ -2201,6 +2208,9 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) case OB_CURVE: { if (ob != draw_ctx->object_edit) { + if (hide_object_extra) { + break; + } struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob); if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); @@ -2218,22 +2228,40 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) break; } case OB_LAMP: + if (hide_object_extra) { + break; + } DRW_shgroup_lamp(stl, ob, view_layer); break; case OB_CAMERA: - DRW_shgroup_camera(stl, ob, view_layer); + if (hide_object_extra) { + break; + } + DRW_shgroup_camera(stl, ob, view_layer); break; case OB_EMPTY: + if (hide_object_extra) { + break; + } DRW_shgroup_empty(stl, psl, ob, view_layer); break; case OB_SPEAKER: + if (hide_object_extra) { + break; + } DRW_shgroup_speaker(stl, ob, view_layer); break; case OB_LIGHTPROBE: + if (hide_object_extra) { + break; + } DRW_shgroup_lightprobe(stl, psl, ob, view_layer); break; case OB_ARMATURE: { + if (v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES) { + break; + } bArmature *arm = ob->data; if (arm->edbo == NULL) { if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) { diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 1f0476e9db7..b21d6814289 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -387,6 +387,7 @@ enum { V3D_OVERLAY_HIDE_MOTION_PATHS = (1 << 6), V3D_OVERLAY_ONION_SKINS = (1 << 7), V3D_OVERLAY_HIDE_BONES = (1 << 8), + V3D_OVERLAY_HIDE_OBJECT_XTRAS = (1 << 9), }; /* View3DOverlay->edit_flag */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 81efcf3c4dd..752972b0797 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2637,6 +2637,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Text", "Display overlay text"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_ornaments", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_OBJECT_XTRAS); + RNA_def_property_ui_text(prop, "Ornaments", "Object details, including empty wire, cameras and other extras"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_bones", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_BONES); RNA_def_property_ui_text(prop, "Show Bones", "Display bones"); -- cgit v1.2.3 From 0953e8af988a0de800cfeb8606ede0f515c589f2 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 10 Jul 2018 20:25:50 +0200 Subject: UI: Single-column for object type visibility --- release/scripts/startup/bl_ui/space_view3d.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index d9f17f70e20..b484bf08c3b 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3697,12 +3697,12 @@ class VIEW3D_PT_object_type_visibility(Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True + view = context.space_data col = layout.column() - split = col.split() - heading_pair = ("Visible", "Selectable") attr_object_types = ( "mesh", @@ -3722,17 +3722,13 @@ class VIEW3D_PT_object_type_visibility(Panel): attr_vis = [f"show_object_viewport_{attr}" for attr in attr_object_types] attr_sel = [f"show_object_select_{attr}" for attr in attr_object_types] - sub = split.column() - sub.label("Visible") - for attr_v in attr_vis: - sub.prop(view, attr_v) - - sub = split.column() - sub.label("Selectable") for attr_v, attr_s in zip(attr_vis, attr_sel): - row = sub.row(align=True) + icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON' + + row = col.row(align=True) + row.prop(view, attr_v) row.active = getattr(view, attr_v) - row.prop(view, attr_s) + row.prop(view, attr_s, text="", icon=icon_s, emboss=False) class VIEW3D_PT_shading(Panel): -- cgit v1.2.3 From 44ee942440b056d20ddb73fa5efa6661fb0b8103 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 10 Jul 2018 20:26:18 +0200 Subject: UI: Default theme roundness consistency for toggles --- release/datafiles/userdef/userdef_default_theme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index e8c8f051c07..6be56c3134d 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -87,7 +87,7 @@ const bTheme U_theme_default = { .item = RGBA(0x191919ff), .text = RGBA(0xeeeeeeff), .text_sel = RGBA(0xffffffff), - .roundness = 0.4f, + .roundness = 0.2f, }, .wcol_num = { .outline = RGBA(0x444444ff), -- cgit v1.2.3 From 17bc05672681754a76e60c690a99eb9af71467f9 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 01:21:38 +0200 Subject: UI: Default theme - minor tweaks to console colors closer to text editor's --- release/datafiles/userdef/userdef_default_theme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 6be56c3134d..666fb03596c 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -667,7 +667,7 @@ const bTheme U_theme_default = { .metadatatext = RGBA(0xffffffff), }, .text = { - .back = RGBA(0x27272700), + .back = RGBA(0x30303000), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), @@ -815,7 +815,7 @@ const bTheme U_theme_default = { .facedot_size = 4, }, .tconsole = { - .back = RGBA(0x27272700), + .back = RGBA(0x30303000), .title = RGBA(0xeeeeeeff), .text = RGBA(0xffffffff), .text_hi = RGBA(0xffffffff), @@ -835,11 +835,11 @@ const bTheme U_theme_default = { .back = RGBA(0x333333b3), .sub_back = RGBA(0x0000003e), }, - .console_output = RGBA(0xb3c2ffff), - .console_input = RGBA(0xffffffff), - .console_info = RGBA(0x47b347ff), - .console_error = RGBA(0xde6f6fff), - .console_cursor = RGBA(0xde5959ff), + .console_output = RGBA(0x71a8ffff), + .console_input = RGBA(0xf2f2f2ff), + .console_info = RGBA(0x95d600ff), + .console_error = RGBA(0xff4d84ff), + .console_cursor = RGBA(0xff0000ff), .console_select = RGBA(0xffffff30), .vertex_size = 3, .outline_width = 1, -- cgit v1.2.3 From 0ed54cf9ba9f5b5df8fbcbe15243dd88621205a0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 11 Jul 2018 10:19:56 +0200 Subject: Depsgraph: Fix face dependency cycle when bone uses id property from self --- source/blender/depsgraph/intern/depsgraph.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 34fb20ee2ba..241c3fb9ac3 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -128,9 +128,9 @@ static bool pointer_to_component_node_criteria( bPoseChannel *pchan = (bPoseChannel *)ptr->data; if (prop != NULL && RNA_property_is_idprop(prop)) { *type = DEG_NODE_TYPE_PARAMETERS; - *subdata = ""; - *operation_code = DEG_OPCODE_PARAMETERS_EVAL; - *operation_name = pchan->name; + *operation_code = DEG_OPCODE_ID_PROPERTY; + *operation_name = RNA_property_identifier((PropertyRNA *)prop); + *operation_name_tag = -1; } else { /* Bone - generally, we just want the bone component. */ -- cgit v1.2.3 From 64d40c82c324f7029e27ff59a4b1ca3200cddbef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 10:25:02 +0200 Subject: Revert "Transform: default constraint to user orientation" This reverts commit 81210103104980c9052de491a0b4defd003c2d1e. After user feedback this has the downside of having no predictable way of transforming in global space. Since toggling between global/user is reversed when global is the user axis. --- source/blender/editors/transform/transform.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index db974c3b4db..15c830e45d0 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1036,12 +1036,12 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm } else if (!edit_2d) { if (cmode == axis) { - if (t->con.orientation != t->current_orientation) { + if (t->con.orientation != V3D_MANIP_GLOBAL) { stopConstraint(t); } else { - const short orientation = ( - (t->current_orientation != V3D_MANIP_GLOBAL) ? V3D_MANIP_GLOBAL : V3D_MANIP_LOCAL); + short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ? + t->current_orientation : V3D_MANIP_LOCAL); if (is_plane == false) { setUserConstraint(t, orientation, constraint_axis, msg2); } @@ -1052,10 +1052,10 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm } else { if (is_plane == false) { - setUserConstraint(t, t->current_orientation, constraint_axis, msg2); + setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2); } else { - setUserConstraint(t, t->current_orientation, constraint_plane, msg3); + setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3); } } } -- cgit v1.2.3 From c17611af951e46fb82bf43d7449240f2f829b78f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 10:38:01 +0200 Subject: Manipulator: changes for overlay options There are now 3 categories in the overlay popover: - Navigation - Active (camera, lamp... etc) - Tool (manipulator) The user preference for mini axis now controls if the mini axis displays minimal or a full-interactive widget. Part of design: T55863 --- release/scripts/startup/bl_ui/space_userpref.py | 12 ++--- release/scripts/startup/bl_ui/space_view3d.py | 14 +++++ .../blenloader/intern/versioning_defaults.c | 1 - source/blender/draw/intern/draw_manager.c | 2 +- source/blender/editors/interface/resources.c | 2 +- .../manipulator_library/manipulator_draw_utils.c | 13 +---- .../manipulator_types/arrow3d_manipulator.c | 6 --- .../editors/mesh/editmesh_add_manipulator.c | 2 +- source/blender/editors/mesh/editmesh_bevel.c | 8 +-- source/blender/editors/mesh/editmesh_bisect.c | 10 ++-- .../blender/editors/mesh/editmesh_extrude_spin.c | 2 +- source/blender/editors/mesh/editmesh_inset.c | 8 +-- source/blender/editors/space_view3d/space_view3d.c | 2 - source/blender/editors/space_view3d/view3d_draw.c | 9 ++-- .../space_view3d/view3d_manipulator_armature.c | 7 ++- .../space_view3d/view3d_manipulator_camera.c | 8 ++- .../space_view3d/view3d_manipulator_empty.c | 5 +- .../space_view3d/view3d_manipulator_forcefield.c | 5 +- .../editors/space_view3d/view3d_manipulator_lamp.c | 4 +- .../space_view3d/view3d_manipulator_navigate.c | 11 ++-- source/blender/editors/space_view3d/view3d_ops.c | 2 +- source/blender/editors/transform/transform.h | 2 +- .../blender/editors/transform/transform_generics.c | 6 +-- .../editors/transform/transform_manipulator_3d.c | 5 ++ source/blender/makesdna/DNA_userdef_types.h | 4 +- source/blender/makesdna/DNA_view3d_types.h | 10 ++-- source/blender/makesrna/intern/rna_space.c | 19 ++++++- source/blender/makesrna/intern/rna_userdef.c | 60 +++++----------------- 28 files changed, 118 insertions(+), 121 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index e44fd6e09db..ca96c79b2b4 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -238,15 +238,15 @@ class USERPREF_PT_interface(Panel): col.separator() - col.prop(view, "show_manipulator_navigate") + # col.prop(view, "show_manipulator_navigate") sub = col.column(align=True) - sub.prop(view, "show_mini_axis", text="Display Mini Axis") - sub.active = not view.show_manipulator_navigate + sub.label("3D Viewport Axis:") + sub.row().prop(view, "mini_axis_type", expand=True) sub = col.column(align=True) - sub.active = view.show_mini_axis + sub.active = view.mini_axis_type == 'MINIMAL' sub.prop(view, "mini_axis_size", text="Size") sub.prop(view, "mini_axis_brightness", text="Brightness") @@ -258,9 +258,7 @@ class USERPREF_PT_interface(Panel): #col.label(text="Open Toolbox Delay:") #col.prop(view, "open_left_mouse_delay", text="Hold LMB") #col.prop(view, "open_right_mouse_delay", text="Hold RMB") - col.prop(view, "show_manipulator", text="Transform Manipulator") - # Currently not working - # col.prop(view, "show_manipulator_shaded") + col.prop(view, "show_manipulator", text="Manipulators") sub = col.column() sub.active = view.show_manipulator sub.prop(view, "manipulator_size", text="Size") diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index b484bf08c3b..3e97877c115 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3882,6 +3882,20 @@ class VIEW3D_PT_overlay(Panel): sub = split.column() sub.prop(view, "show_manipulator", text="Manipulators") + has_manipulator = view.show_manipulator + subsub = sub.column() + subsub.active = has_manipulator + subsub.prop(view, "show_manipulator_navigate", text="Navigate") + del subsub + sub = split.column() + sub.active = has_manipulator + sub.prop(view, "show_manipulator_context", text="Active Object") + sub.prop(view, "show_manipulator_tool", text="Active Tools") + + col.separator() + + split = col.split() + sub = split.column() sub.prop(overlay, "show_text", text="Text") sub.prop(overlay, "show_cursor", text="3D Cursor") sub.prop(overlay, "show_outline_selected") diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index d43000e859e..bd7334516ca 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -71,7 +71,6 @@ void BLO_update_defaults_userpref_blend(void) /* Defaults from T54943 (phase 1). */ U.flag &= ~USER_TOOLTIPS_PYTHON; U.uiflag |= USER_AUTOPERSP; - U.manipulator_flag |= USER_MANIPULATOR_DRAW_NAVIGATE; U.uiflag2 |= USER_REGION_OVERLAP; U.versions = 1; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 30f7742fd35..be067b0464d 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1440,7 +1440,7 @@ void DRW_draw_render_loop_ex( if (DST.draw_ctx.evil_C) { /* needed so manipulator isn't obscured */ if (((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && - ((v3d->twflag & V3D_MANIPULATOR_DRAW) != 0)) + ((v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0)) { glDisable(GL_DEPTH_TEST); DRW_draw_manipulator_3d(); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index aa71c31c541..c279c949e62 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1383,7 +1383,7 @@ void init_userdef_do_versions(Main *bmain) if (U.rvisize == 0) { U.rvisize = 15; U.rvibright = 8; - U.uiflag |= USER_SHOW_ROTVIEWICON; + U.uiflag |= USER_SHOW_MANIPULATOR_AXIS; } } diff --git a/source/blender/editors/manipulator_library/manipulator_draw_utils.c b/source/blender/editors/manipulator_library/manipulator_draw_utils.c index a0b226b7502..80181c57115 100644 --- a/source/blender/editors/manipulator_library/manipulator_draw_utils.c +++ b/source/blender/editors/manipulator_library/manipulator_draw_utils.c @@ -59,12 +59,11 @@ /** * Main draw call for ManipulatorGeomInfo data */ -void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const bool select, const float color[4]) +void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const bool UNUSED(select), const float color[4]) { /* TODO store the Batches inside the ManipulatorGeomInfo and updated it when geom changes * So we don't need to re-created and discard it every time */ - const bool use_lighting = true || (!select && ((U.manipulator_flag & USER_MANIPULATOR_SHADED) != 0)); Gwn_VertBuf *vbo; Gwn_IndexBuf *el; Gwn_Batch *batch; @@ -72,11 +71,6 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo Gwn_VertFormat format = {0}; uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint nor_id; - - if (use_lighting) { - nor_id = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - } /* Elements */ GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, info->ntris, info->nverts); @@ -91,11 +85,6 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo GWN_vertbuf_attr_fill(vbo, pos_id, info->verts); - if (use_lighting) { - /* Normals are expected to be smooth. */ - GWN_vertbuf_attr_fill(vbo, nor_id, info->normals); - } - batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, el, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c index a5bcef7ed5e..0430a12bc99 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c @@ -163,16 +163,10 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float len = 0.25f; const float width = 0.06f; - const bool use_lighting = (!select && ((U.manipulator_flag & USER_MANIPULATOR_SHADED) != 0)); /* translate to line end */ gpuTranslate3f(0.0f, 0.0f, arrow_length); - if (use_lighting) { - immUnbindProgram(); - immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR); - } - imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8); imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1); } diff --git a/source/blender/editors/mesh/editmesh_add_manipulator.c b/source/blender/editors/mesh/editmesh_add_manipulator.c index bfeccfe33a4..f1704972e81 100644 --- a/source/blender/editors/mesh/editmesh_add_manipulator.c +++ b/source/blender/editors/mesh/editmesh_add_manipulator.c @@ -379,7 +379,7 @@ static int add_primitive_cube_manipulator_invoke(bContext *C, wmOperator *op, co int ret = add_primitive_cube_manipulator_exec(C, op); if (ret & OPERATOR_FINISHED) { /* Setup manipulators */ - if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) { + if (v3d && ((v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0)) { ARegion *ar = CTX_wm_region(C); wmManipulatorMap *mmap = ar->manipulator_map; wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find("MESH_WGT_add_bounds", false); diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 6c5133c93c8..2b6f8914a02 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -95,7 +95,7 @@ typedef struct { /* modal only */ float mcenter[2]; void *draw_handle_pixel; - short twflag; + short mpr_flag; short value_mode; /* Which value does mouse movement and numeric input affect? */ float segments; /* Segments as float so smooth mouse pan works in small increments */ } BevelData; @@ -201,8 +201,8 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) G.moving = G_TRANSFORM_EDIT; if (v3d) { - opdata->twflag = v3d->twflag; - v3d->twflag = 0; + opdata->mpr_flag = v3d->mpr_flag; + v3d->mpr_flag = 0; } } @@ -284,7 +284,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op) } ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel); if (v3d) { - v3d->twflag = opdata->twflag; + v3d->mpr_flag = opdata->mpr_flag; } G.moving = 0; } diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 568983e47ee..ee8adeb2c52 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -70,7 +70,7 @@ typedef struct { /* modal only */ BMBackup mesh_backup; bool is_first; - short twflag; + short mpr_flag; } BisectData; static bool mesh_bisect_interactive_calc( @@ -156,8 +156,8 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* misc other vars */ G.moving = G_TRANSFORM_EDIT; - opdata->twflag = v3d->twflag; - v3d->twflag = 0; + opdata->mpr_flag = v3d->mpr_flag; + v3d->mpr_flag = 0; /* initialize modal callout */ ED_workspace_status_text(C, IFACE_("LMB: Click and drag to draw cut line")); @@ -169,7 +169,7 @@ static void edbm_bisect_exit(bContext *C, BisectData *opdata) { View3D *v3d = CTX_wm_view3d(C); EDBM_redo_state_free(&opdata->mesh_backup, NULL, false); - v3d->twflag = opdata->twflag; + v3d->mpr_flag = opdata->mpr_flag; G.moving = 0; } @@ -199,7 +199,7 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Setup manipulators */ { View3D *v3d = CTX_wm_view3d(C); - if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) { + if (v3d && (v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0) { WM_manipulator_group_type_ensure("MESH_WGT_bisect"); } } diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index f98d7dacac8..5c1b9ccc178 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -511,7 +511,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e #ifdef USE_MANIPULATOR if (ret & OPERATOR_FINISHED) { /* Setup manipulators */ - if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) { + if (v3d && ((v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0)) { WM_manipulator_group_type_ensure("MESH_WGT_spin"); } } diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 8758fa66a14..251e328ee84 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -78,7 +78,7 @@ typedef struct { /* modal only */ float mcenter[2]; void *draw_handle_pixel; - short twflag; + short mpr_flag; } InsetData; @@ -173,8 +173,8 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL); G.moving = G_TRANSFORM_EDIT; if (v3d) { - opdata->twflag = v3d->twflag; - v3d->twflag = 0; + opdata->mpr_flag = v3d->mpr_flag; + v3d->mpr_flag = 0; } } @@ -196,7 +196,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) } ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel); if (v3d) { - v3d->twflag = opdata->twflag; + v3d->mpr_flag = opdata->mpr_flag; } G.moving = 0; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 9aaced3e583..39315dcd64f 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -348,8 +348,6 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->near = 0.01f; v3d->far = 1000.0f; - v3d->twflag |= U.manipulator_flag & V3D_MANIPULATOR_DRAW; - v3d->bundle_size = 0.2f; v3d->bundle_drawtype = OB_PLAINAXES; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 2c732586606..62e9d4ee3bf 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1203,11 +1203,14 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(of BLF_batch_draw_begin(); - if (((U.uiflag & USER_SHOW_ROTVIEWICON) != 0) && - ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && + if ((U.uiflag & USER_SHOW_MANIPULATOR_AXIS) || + (v3d->flag2 & V3D_RENDER_OVERRIDE) || /* No need to display manipulator and this info. */ - ((U.manipulator_flag & USER_MANIPULATOR_DRAW_NAVIGATE) == 0)) + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_NAVIGATE))) { + /* pass */ + } + else { draw_view_axis(rv3d, &rect); } diff --git a/source/blender/editors/space_view3d/view3d_manipulator_armature.c b/source/blender/editors/space_view3d/view3d_manipulator_armature.c index abbd6c888b2..17dc4d8eb4a 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_armature.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_armature.c @@ -135,7 +135,12 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGro if (arm->drawtype == ARM_B_BONE) { if (arm->act_bone && arm->act_bone->segments > 1) { View3D *v3d = CTX_wm_view3d(C); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { + /* pass */ + } + else { return true; } } diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c index 023e16c070e..29f380c6334 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_camera.c @@ -64,7 +64,9 @@ struct CameraWidgetGroup { static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { return false; } @@ -358,7 +360,9 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupTy } View3D *v3d = CTX_wm_view3d(C); - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { return false; } diff --git a/source/blender/editors/space_view3d/view3d_manipulator_empty.c b/source/blender/editors/space_view3d/view3d_manipulator_empty.c index fc15ec593f5..16424c39bb8 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_empty.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_empty.c @@ -107,7 +107,10 @@ static void manipulator_empty_image_prop_matrix_set( static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { return false; } diff --git a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c index b42f49e6d1c..e4535004c8f 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c @@ -55,7 +55,10 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { return false; } diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c index 0e1015a66f1..39e908ec99d 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c @@ -55,7 +55,9 @@ static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { return false; } diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c index 9eb3ca89c55..465faf70fcd 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c @@ -179,14 +179,13 @@ struct NavigateWidgetGroup { static bool WIDGETGROUP_navigate_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + if (((U.uiflag & USER_SHOW_MANIPULATOR_AXIS) == 0) || + (v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_NAVIGATE))) + { return false; } - - if (U.manipulator_flag & USER_MANIPULATOR_DRAW_NAVIGATE) { - return true; - } - return false; + return true; } diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 18b63151c8e..fb9cf917701 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -541,7 +541,7 @@ void view3d_keymap(wmKeyConfig *keyconf) #else kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); #endif - RNA_string_set(kmi->ptr, "data_path", "space_data.show_manipulator"); + RNA_string_set(kmi->ptr, "data_path", "space_data.show_manipulator_tool"); transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 6685f785247..b022d5a3058 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -505,7 +505,7 @@ typedef struct TransInfo { short current_orientation; TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */ - short twflag; /* backup from view3d, to restore on end */ + short mpr_flag; /* backup from view3d, to restore on end */ short prop_mode; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 3f71915a690..303fa26bd4a 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1350,8 +1350,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* turn manipulator off during transform */ if (t->flag & T_MODAL) { - t->twflag = v3d->twflag; - v3d->twflag = 0; + t->mpr_flag = v3d->mpr_flag; + v3d->mpr_flag = 0; } if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) { @@ -1690,7 +1690,7 @@ void postTrans(bContext *C, TransInfo *t) View3D *v3d = t->sa->spacedata.first; /* restore manipulator */ if (t->flag & T_MODAL) { - v3d->twflag = t->twflag; + v3d->mpr_flag = t->mpr_flag; } } diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index 94bd1c92130..fa56e8d10be 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -1596,6 +1596,11 @@ static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmMani WM_manipulator_group_type_unlink_delayed_ptr(wgt); return false; } + + View3D *v3d = CTX_wm_view3d(C); + if (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_TOOL)) { + return false; + } return true; } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1e199904356..45c6b9634f4 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -751,7 +751,7 @@ typedef enum eUserpref_UI_Flag { USER_ORBIT_SELECTION = (1 << 14), USER_DEPTH_NAVIGATE = (1 << 15), USER_HIDE_DOT = (1 << 16), - USER_SHOW_ROTVIEWICON = (1 << 17), + USER_SHOW_MANIPULATOR_AXIS = (1 << 17), USER_SHOW_VIEWPORTNAME = (1 << 18), USER_CAM_LOCK_NO_PARENT = (1 << 19), USER_ZOOM_TO_MOUSEPOS = (1 << 20), @@ -876,8 +876,6 @@ typedef enum eGP_UserdefSettings { enum { USER_MANIPULATOR_DRAW = (1 << 0), - USER_MANIPULATOR_DRAW_NAVIGATE = (1 << 1), - USER_MANIPULATOR_SHADED = (1 << 8), }; /* Color Picker Types. diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index b21d6814289..b02661754bd 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -237,7 +237,7 @@ typedef struct View3D { char gridflag; /* transform manipulator info */ - char twtype, _pad5, twflag; + char _pad5[2], mpr_flag; short flag3; @@ -450,9 +450,13 @@ enum { #define V3D_MANIP_CURSOR 5 #define V3D_MANIP_CUSTOM 1024 -/* View3d->twflag (also) */ +/* View3d.mpr_flag (also) */ enum { - V3D_MANIPULATOR_DRAW = (1 << 0), + /** All manipulators. */ + V3D_MANIPULATOR_HIDE = (1 << 0), + V3D_MANIPULATOR_HIDE_NAVIGATE = (1 << 1), + V3D_MANIPULATOR_HIDE_CONTEXT = (1 << 2), + V3D_MANIPULATOR_HIDE_TOOL = (1 << 3), }; #define RV3D_CAMZOOM_MIN -30 diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 752972b0797..67c345914dc 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2926,8 +2926,23 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "twflag", V3D_MANIPULATOR_DRAW); - RNA_def_property_ui_text(prop, "Manipulator", "Use a 3D manipulator widget for controlling transforms"); + RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE); + RNA_def_property_ui_text(prop, "Manipulator", "Show manipulators of all types"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_manipulator_navigate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_NAVIGATE); + RNA_def_property_ui_text(prop, "Navigate Manipulator", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_manipulator_context", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_CONTEXT); + RNA_def_property_ui_text(prop, "Context Manipulator", "Context sensitive manipulators for the active item"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_manipulator_tool", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_TOOL); + RNA_def_property_ui_text(prop, "Tool Manipulator", "Active tool manipulator"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index aa6eb4c4dc2..517e4047515 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -165,36 +165,6 @@ static void rna_userdef_language_update(Main *UNUSED(bmain), Scene *UNUSED(scene UI_reinit_font(); } -static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - UserDef *userdef = (UserDef *)ptr->data; - - /* lame, loop over all views and set */ - bScreen *sc; - ScrArea *sa; - SpaceLink *sl; - - /* from scene copy to the other views */ - for (sc = bmain->screen.first; sc; sc = sc->id.next) { - for (sa = sc->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - if (userdef->manipulator_flag & USER_MANIPULATOR_DRAW) { - v3d->twflag |= V3D_MANIPULATOR_DRAW; - } - else { - v3d->twflag &= ~V3D_MANIPULATOR_DRAW; - } - } - } - } - } - - rna_userdef_update(bmain, scene, ptr); -} - - static void rna_userdef_script_autoexec_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { UserDef *userdef = (UserDef *)ptr->data; @@ -3733,10 +3703,17 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Rotate Around Selection", "Use selection as the pivot point"); /* mini axis */ - prop = RNA_def_property(srna, "show_mini_axis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_ROTVIEWICON); - RNA_def_property_ui_text(prop, "Show Mini Axes", - "Show a small rotating 3D axes in the bottom left corner of the 3D View"); + static const EnumPropertyItem mini_axis_type_items[] = { + {0, "MINIMAL", 0, "Simple Axis", ""}, + {USER_SHOW_MANIPULATOR_AXIS, "MANIPULATOR", 0, "Interactive Navigation", ""}, + {0, NULL, 0, NULL, NULL} + }; + + prop = RNA_def_property(srna, "mini_axis_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mini_axis_type_items); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "uiflag"); + RNA_def_property_ui_text(prop, "Mini Axes Type", + "Show a small rotating 3D axes in the top right corner of the 3D View"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_NONE); @@ -3764,21 +3741,8 @@ static void rna_def_userdef_view(BlenderRNA *brna) /* 3D transform widget */ prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW); - RNA_def_property_ui_text(prop, "Manipulator", "Use 3D transform manipulator"); - RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update"); - - prop = RNA_def_property(srna, "show_manipulator_navigate", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW_NAVIGATE); - RNA_def_property_ui_text(prop, "Navigate Manipulator", "Use 3D navigation manipulator"); - RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update"); - - /* TODO, expose once it's working. */ -#if 0 - prop = RNA_def_property(srna, "show_manipulator_shaded", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_SHADED); - RNA_def_property_ui_text(prop, "Manipulator Shaded", "Use 3D transform manipulator"); + RNA_def_property_ui_text(prop, "Manipulators", "Use transform manipulators by default"); RNA_def_property_update(prop, 0, "rna_userdef_update"); -#endif prop = RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "manipulator_size"); -- cgit v1.2.3 From ccc9f476cae786790e62303069f938a4f1cd2b14 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 11:02:03 +0200 Subject: Fix empty-images not using selection color --- source/blender/draw/modes/object_mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 0726c3660d5..de4b8ffb193 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -835,7 +835,7 @@ static void DRW_shgroup_empty_image( { DRW_shgroup_instance_format(e_data.empty_image_wire_format, { - {"objectColor", DRW_ATTRIB_FLOAT, 4}, + {"color", DRW_ATTRIB_FLOAT, 4}, {"size", DRW_ATTRIB_FLOAT, 1}, {"offset", DRW_ATTRIB_FLOAT, 2}, {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16} -- cgit v1.2.3 From 2b963ecb81d9854d4d3c3e761ee04d6d500c05c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 11:39:58 +0200 Subject: Cleanup: duplicate versioning block --- .../blender/blenloader/intern/versioning_legacy.c | 27 ---------------------- 1 file changed, 27 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index c4868af76cf..3511aefc2a5 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1597,33 +1597,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } } - if (bmain->versionfile <= 231) { - /* new bit flags for showing/hiding grid floor and axes */ - bScreen *sc = bmain->screen.first; - - while (sc) { - ScrArea *sa = sc->areabase.first; - while (sa) { - SpaceLink *sl = sa->spacedata.first; - while (sl) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D*) sl; - - if (v3d->gridflag == 0) { - v3d->gridflag |= V3D_SHOW_X; - v3d->gridflag |= V3D_SHOW_Y; - v3d->gridflag |= V3D_SHOW_FLOOR; - v3d->gridflag &= ~V3D_SHOW_Z; - } - } - sl = sl->next; - } - sa = sa->next; - } - sc = sc->id.next; - } - } - if (bmain->versionfile <= 231) { Material *ma = bmain->mat.first; bScreen *sc = bmain->screen.first; -- cgit v1.2.3 From ff39cbdc86ce671c91d0bacf5466ff089d4d5b4f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 11:59:11 +0200 Subject: 3D View: any view axis also showing grid Setting accidentally impacted in ortho view. --- source/blender/draw/modes/object_mode.c | 51 +++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index de4b8ffb193..2a6a7fae612 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -468,33 +468,54 @@ static void OBJECT_engine_init(void *vedata) if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) { e_data.grid_flag = PLANE_YZ; - e_data.grid_flag |= SHOW_AXIS_Y; - e_data.grid_flag |= SHOW_AXIS_Z; - e_data.grid_flag |= SHOW_GRID; - e_data.grid_flag |= GRID_BACK; + if (show_axis_y) { + e_data.grid_flag |= SHOW_AXIS_Y; + } + if (show_axis_z) { + e_data.grid_flag |= SHOW_AXIS_Z; + } + if (show_floor) { + e_data.grid_flag |= SHOW_GRID; + e_data.grid_flag |= GRID_BACK; + } } else if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) { e_data.grid_flag = PLANE_XY; - e_data.grid_flag |= SHOW_AXIS_X; - e_data.grid_flag |= SHOW_AXIS_Y; - e_data.grid_flag |= SHOW_GRID; - e_data.grid_flag |= GRID_BACK; + if (show_axis_x) { + e_data.grid_flag |= SHOW_AXIS_X; + } + if (show_axis_y) { + e_data.grid_flag |= SHOW_AXIS_Y; + } + if (show_floor) { + e_data.grid_flag |= SHOW_GRID; + e_data.grid_flag |= GRID_BACK; + } } else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) { e_data.grid_flag = PLANE_XZ; - e_data.grid_flag |= SHOW_AXIS_X; - e_data.grid_flag |= SHOW_AXIS_Z; - e_data.grid_flag |= SHOW_GRID; - e_data.grid_flag |= GRID_BACK; + if (show_axis_x) { + e_data.grid_flag |= SHOW_AXIS_X; + } + if (show_axis_z) { + e_data.grid_flag |= SHOW_AXIS_Z; + } + if (show_floor) { + e_data.grid_flag |= SHOW_GRID; + e_data.grid_flag |= GRID_BACK; + } } else { /* RV3D_VIEW_USER */ e_data.grid_flag = PLANE_XY; - if (show_axis_x) + if (show_axis_x) { e_data.grid_flag |= SHOW_AXIS_X; - if (show_axis_y) + } + if (show_axis_y) { e_data.grid_flag |= SHOW_AXIS_Y; - if (show_floor) + } + if (show_floor) { e_data.grid_flag |= SHOW_GRID; + } } } -- cgit v1.2.3 From fdc0f4ad90973d43ccdf4892821dfc82c3ab3329 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 11 Jul 2018 12:13:04 +0200 Subject: Fix Use Nodes not working for Cycles lights. --- intern/cycles/blender/addon/ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 6688874de49..03ce3835365 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1056,7 +1056,7 @@ class CYCLES_OT_use_shading_nodes(Operator): @classmethod def poll(cls, context): return (getattr(context, "material", False) or getattr(context, "world", False) or - getattr(context, "lamp", False)) + getattr(context, "light", False)) def execute(self, context): if context.material: -- cgit v1.2.3 From 3eab8156d369f40de9d8c23672b1de28491ea920 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 11 Jul 2018 12:30:48 +0200 Subject: UI: don't change scrollbar size on mouse move, only fade. It's not necessary to do both, and trying to hit a target that changes size is annoying. --- source/blender/blenloader/intern/readfile.c | 1 - source/blender/editors/include/UI_view2d.h | 2 -- source/blender/editors/interface/view2d.c | 9 ++++----- source/blender/editors/screen/screen_ops.c | 8 -------- source/blender/makesdna/DNA_view2d_types.h | 3 +-- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index db3c1894e8c..6bc0a634599 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6528,7 +6528,6 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) ar->v2d.tab_cur = 0; ar->v2d.sms = NULL; ar->v2d.alpha_hor = ar->v2d.alpha_vert = 255; /* visible by default */ - ar->v2d.size_hor = ar->v2d.size_vert = 0; BLI_listbase_clear(&ar->panels_category); BLI_listbase_clear(&ar->handlers); BLI_listbase_clear(&ar->uiblocks); diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index d407878d063..4c4ee1e01c5 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -103,8 +103,6 @@ enum eView2D_Gridlines { /* ------ Defines for Scrollers ----- */ /* scroller area */ -#define V2D_SCROLL_HEIGHT_MIN (0.25f * U.widget_unit) -#define V2D_SCROLL_WIDTH_MIN (0.25f * U.widget_unit) #define V2D_SCROLL_HEIGHT (0.45f * U.widget_unit) #define V2D_SCROLL_WIDTH (0.45f * U.widget_unit) /* For scrollers with scale markings (text written onto them) */ diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index bf768f26a93..1b449877abe 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -153,11 +153,10 @@ static void view2d_masks(View2D *v2d, bool check_scrollers) * - if they overlap, they must not occupy the corners (which are reserved for other widgets) */ if (scroll) { - int scroll_width = (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) ? V2D_SCROLL_WIDTH_TEXT : v2d->size_vert; - int scroll_height = (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) ? V2D_SCROLL_HEIGHT_TEXT : v2d->size_hor; - - CLAMP_MIN(scroll_width, V2D_SCROLL_WIDTH_MIN); - CLAMP_MIN(scroll_height, V2D_SCROLL_HEIGHT_MIN); + const int scroll_width = (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) ? + V2D_SCROLL_WIDTH_TEXT : V2D_SCROLL_WIDTH; + const int scroll_height = (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) ? + V2D_SCROLL_HEIGHT_TEXT : V2D_SCROLL_HEIGHT; /* vertical scroller */ if (scroll & V2D_SCROLL_LEFT) { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 381a20feca4..09bd7625eac 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -743,7 +743,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo if (az->direction == AZ_SCROLL_HOR) { az->alpha = 1.0f; v2d->alpha_hor = 255; - v2d->size_hor = V2D_SCROLL_HEIGHT; redraw = true; } } @@ -751,7 +750,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo if (az->direction == AZ_SCROLL_VERT) { az->alpha = 1.0f; v2d->alpha_vert = 255; - v2d->size_vert = V2D_SCROLL_WIDTH; redraw = true; } } @@ -765,9 +763,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo alpha = 1.0f - dist_fac; v2d->alpha_hor = alpha * 255; - v2d->size_hor = round_fl_to_int( - V2D_SCROLL_HEIGHT - - ((V2D_SCROLL_HEIGHT - V2D_SCROLL_HEIGHT_MIN) * dist_fac)); } else if (az->direction == AZ_SCROLL_VERT) { dist_fac = BLI_rcti_length_x(&v2d->vert, local_xy[0]) / AZONEFADEIN; @@ -775,9 +770,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo alpha = 1.0f - dist_fac; v2d->alpha_vert = alpha * 255; - v2d->size_vert = round_fl_to_int( - V2D_SCROLL_WIDTH - - ((V2D_SCROLL_WIDTH - V2D_SCROLL_WIDTH_MIN) * dist_fac)); } az->alpha = alpha; redraw = true; diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h index ebeb639e8aa..e2d8d836368 100644 --- a/source/blender/makesdna/DNA_view2d_types.h +++ b/source/blender/makesdna/DNA_view2d_types.h @@ -66,8 +66,7 @@ typedef struct View2D { /* Usually set externally (as in, not in view2d files). */ char alpha_vert, alpha_hor; /* alpha of vertical and horizontal scrollbars (range is [0, 255]) */ - short size_vert, size_hor; /* Dynamic size for scrollers without scale markers (no V2D_SCROLL_SCALE_FOO) */ - short pad; + short pad[3]; /* animated smooth view */ struct SmoothView2DStore *sms; -- cgit v1.2.3 From c37ca437209f00ffe1b56cef2a5e8bbf390e669a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 11 Jul 2018 10:36:13 +0200 Subject: OpenSubdiv: Changes in C-API - Made OpenSubdiv_GLMesh private Previously, it was still accessible via C-API from C++ code. - Don't implicitly refine evaluator when updating coarse positions, now there is an explicit call to do this. Allows to first apply all changes to the coarse mesh and then refine once. - Added coarse positions update from a continuous buffer with given starts offset and stride. Allows to update coarse positions directly from MVert array. - Refiner is no longer freed when CPU evaluator is created. Allows to re-use refiner for multiple purposes. --- intern/opensubdiv/opensubdiv_capi.cc | 1 + intern/opensubdiv/opensubdiv_capi.h | 72 ++++++----- intern/opensubdiv/opensubdiv_evaluator_capi.cc | 140 ++++++++++++--------- intern/opensubdiv/opensubdiv_gl_mesh.h | 40 ++++++ intern/opensubdiv/opensubdiv_gpu_capi.cc | 1 + .../blenkernel/intern/CCGSubSurf_opensubdiv.c | 3 +- 6 files changed, 162 insertions(+), 95 deletions(-) create mode 100644 intern/opensubdiv/opensubdiv_gl_mesh.h diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc index bb865bc0e0f..638039f4f3e 100644 --- a/intern/opensubdiv/opensubdiv_capi.cc +++ b/intern/opensubdiv/opensubdiv_capi.cc @@ -70,6 +70,7 @@ #include #include +#include "opensubdiv_gl_mesh.h" #include "opensubdiv_intern.h" #include "opensubdiv_topology_refiner.h" diff --git a/intern/opensubdiv/opensubdiv_capi.h b/intern/opensubdiv/opensubdiv_capi.h index 2c3fcee7dbb..c29d08a77e1 100644 --- a/intern/opensubdiv/opensubdiv_capi.h +++ b/intern/opensubdiv/opensubdiv_capi.h @@ -32,22 +32,12 @@ extern "C" { // Types declaration. struct OpenSubdiv_GLMesh; +struct OpenSubdiv_GLMeshDescr; struct OpenSubdiv_GLMeshFVarData; struct OpenSubdiv_TopologyRefinerDescr; typedef struct OpenSubdiv_GLMesh OpenSubdiv_GLMesh; -#ifdef __cplusplus -struct OpenSubdiv_GLMeshDescr; - -typedef struct OpenSubdiv_GLMesh { - int evaluator_type; - OpenSubdiv_GLMeshDescr *descriptor; - OpenSubdiv_TopologyRefinerDescr *topology_refiner; - OpenSubdiv_GLMeshFVarData *fvar_data; -} OpenSubdiv_GLMesh; -#endif - // Keep this a bitmask os it's possible to pass available // evaluators to Blender. enum { @@ -86,11 +76,7 @@ void openSubdiv_osdGLMeshBindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh); const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefiner( OpenSubdiv_GLMesh *gl_mesh); -/* ** Initialize/Deinitialize global OpenGL drawing buffers/GLSL programs ** */ -bool openSubdiv_osdGLDisplayInit(void); -void openSubdiv_osdGLDisplayDeinit(void); - -/* ** Evaluator API ** */ +/* ============================= Evaluator API ============================== */ struct OpenSubdiv_EvaluatorDescr; typedef struct OpenSubdiv_EvaluatorDescr OpenSubdiv_EvaluatorDescr; @@ -100,17 +86,29 @@ OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr( struct OpenSubdiv_TopologyRefinerDescr *topology_refiner, int subsurf_level); -void openSubdiv_deleteEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr); - -void openSubdiv_setEvaluatorCoarsePositions(OpenSubdiv_EvaluatorDescr *evaluator_descr, - float *positions, - int start_vert, - int num_vert); - -void openSubdiv_setEvaluatorVaryingData(OpenSubdiv_EvaluatorDescr *evaluator_descr, - float *varying_data, - int start_vert, - int num_vert); +void openSubdiv_deleteEvaluatorDescr( + OpenSubdiv_EvaluatorDescr *evaluator_descr); + +void openSubdiv_setEvaluatorCoarsePositions( + OpenSubdiv_EvaluatorDescr *evaluator_descr, + const float *positions, + int start_vertex_index, + int num_vertices); +void openSubdiv_setEvaluatorVaryingData( + OpenSubdiv_EvaluatorDescr *evaluator_descr, + const float *varying_data, + int start_vertex_index, + int num_vertices); + +void openSubdiv_setEvaluatorCoarsePositionsFromBuffer( + OpenSubdiv_EvaluatorDescr *evaluator_descr, + const void *buffer, + int start_offset, + int stride, + int start_vertex_index, + int num_vertices); + +void openSubdiv_refineEvaluator(OpenSubdiv_EvaluatorDescr *evaluator_descr); void openSubdiv_evaluateLimit(OpenSubdiv_EvaluatorDescr *evaluator_descr, int osd_face_index, @@ -124,15 +122,18 @@ void openSubdiv_evaluateVarying(OpenSubdiv_EvaluatorDescr *evaluator_descr, float face_u, float face_v, float varying[3]); -/* ** Actual drawing ** */ +/* ============================== Mesh drawing =============================== */ + +/* Initialize/Deinitialize global OpenGL drawing buffers/GLSL programs. */ +bool openSubdiv_osdGLDisplayInit(void); +void openSubdiv_osdGLDisplayDeinit(void); /* Initialize all the invariants which stays the same for every single path, * for example lighting model stays untouched for the whole mesh. * * TODO(sergey): Some of the stuff could be initialized once for all meshes. */ -void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl, - int active_uv_index); +void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl, int active_uv_index); /* Draw specified patches. */ void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh, @@ -140,12 +141,15 @@ void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh, int start_patch, int num_patches); -void openSubdiv_osdGLAllocFVar(struct OpenSubdiv_TopologyRefinerDescr *topology_refiner, - OpenSubdiv_GLMesh *gl_mesh, - const float *fvar_data); +void openSubdiv_osdGLAllocFVar( + struct OpenSubdiv_TopologyRefinerDescr *topology_refiner, + OpenSubdiv_GLMesh *gl_mesh, + const float *fvar_data); + void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh); -/* ** Utility functions ** */ +/* =========================== Utility functions ============================ */ + int openSubdiv_getAvailableEvaluators(void); void openSubdiv_init(void); void openSubdiv_cleanup(void); diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.cc b/intern/opensubdiv/opensubdiv_evaluator_capi.cc index 049c0aad3bf..fb5313b8501 100644 --- a/intern/opensubdiv/opensubdiv_evaluator_capi.cc +++ b/intern/opensubdiv/opensubdiv_evaluator_capi.cc @@ -118,7 +118,7 @@ protected: * is small enough and better to be allocated in stack rather * than in heap. * - * TODO(sergey): Check if bare arrays could be used by CPU evalautor. + * TODO(sergey): Check if bare arrays could be used by CPU evaluator. */ template class StackAllocatedBuffer { @@ -142,7 +142,7 @@ protected: /* Volatile evaluator which can be used from threads. * - * TODO(sergey): Make it possible to evaluate coordinates in chuncks. + * TODO(sergey): Make it possible to evaluate coordinates in chunks. */ templateRefineUniform(options); - /* Generate stencil table to update the bi-cubic patches control * vertices after they have been re-posed (both for vertex & varying * interpolation). */ - StencilTableFactory::Options soptions; - soptions.generateOffsets = true; - soptions.generateIntermediateLevels = false; - - vertex_stencils = StencilTableFactory::Create(*refiner, soptions); - - soptions.interpolationMode = StencilTableFactory::INTERPOLATE_VARYING; - varying_stencils = StencilTableFactory::Create(*refiner, soptions); - + StencilTableFactory::Options vertex_stencil_options; + vertex_stencil_options.generateOffsets = true; + vertex_stencil_options.generateIntermediateLevels = false; + const StencilTable *vertex_stencils = + StencilTableFactory::Create(*refiner, vertex_stencil_options); + StencilTableFactory::Options varying_stencil_options; + varying_stencil_options.generateOffsets = true; + varying_stencil_options.generateIntermediateLevels = false; + varying_stencil_options.interpolationMode = + StencilTableFactory::INTERPOLATE_VARYING; + const StencilTable *varying_stencils = + StencilTableFactory::Create(*refiner, varying_stencil_options); /* Generate bi-cubic patch table for the limit surface. */ PatchTableFactory::Options poptions; poptions.SetEndCapType(PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS); - - const PatchTable *patch_table = PatchTableFactory::Create(*refiner, poptions); - + const PatchTable *patch_table = + PatchTableFactory::Create(*refiner, poptions); /* Append local points stencils. */ - /* TODO(sergey): Do we really need to worry about local points stencils? */ - if (const StencilTable *local_point_stencil_table = - patch_table->GetLocalPointStencilTable()) - { + const StencilTable *local_point_stencil_table = + patch_table->GetLocalPointStencilTable(); + if (local_point_stencil_table != NULL) { const StencilTable *table = - StencilTableFactory::AppendLocalPointStencilTable(*refiner, - vertex_stencils, - local_point_stencil_table); + StencilTableFactory::AppendLocalPointStencilTable( + *refiner, + vertex_stencils, + local_point_stencil_table); delete vertex_stencils; vertex_stencils = table; } - if (const StencilTable *local_point_varying_stencil_table = - patch_table->GetLocalPointVaryingStencilTable()) - { + const StencilTable *local_point_varying_stencil_table = + patch_table->GetLocalPointVaryingStencilTable(); + if (local_point_varying_stencil_table != NULL) { const StencilTable *table = - StencilTableFactory::AppendLocalPointStencilTable(*refiner, - varying_stencils, - local_point_varying_stencil_table); + StencilTableFactory::AppendLocalPointStencilTable( + *refiner, + varying_stencils, + local_point_varying_stencil_table); delete varying_stencils; varying_stencils = table; } - /* Total number of vertices = coarse verts + refined verts + gregory basis verts. */ - num_total_verts = vertex_stencils->GetNumControlVertices() + - vertex_stencils->GetNumStencils(); - + /* Total number of vertices = coarse verts + refined verts + gregory + * basis verts. + */ + const int num_total_verts = vertex_stencils->GetNumControlVertices() + + vertex_stencils->GetNumStencils(); const int num_coarse_verts = refiner->GetLevel(0).GetNumVertices(); - + /* Create OpenSubdiv's CPU side evaluator. */ CpuEvalOutput *eval_output = new CpuEvalOutput(vertex_stencils, varying_stencils, num_coarse_verts, num_total_verts, patch_table); - OpenSubdiv::Far::PatchMap *patch_map = new PatchMap(*patch_table); - + /* Wrap everything we need into an object which we control from our + * side. + */ OpenSubdiv_EvaluatorDescr *evaluator_descr; evaluator_descr = OBJECT_GUARDED_NEW(OpenSubdiv_EvaluatorDescr); evaluator_descr->eval_output = eval_output; evaluator_descr->patch_map = patch_map; evaluator_descr->patch_table = patch_table; - - /* TOOD(sergey): Look into whether w've got duplicated stencils arrays. */ + /* TOOD(sergey): Look into whether we've got duplicated stencils arrays. */ delete varying_stencils; delete vertex_stencils; - - delete refiner; - return evaluator_descr; } @@ -437,27 +432,52 @@ void openSubdiv_deleteEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr) OBJECT_GUARDED_DELETE(evaluator_descr, OpenSubdiv_EvaluatorDescr); } -void openSubdiv_setEvaluatorCoarsePositions(OpenSubdiv_EvaluatorDescr *evaluator_descr, - float *positions, - int start_vert, - int num_verts) +void openSubdiv_setEvaluatorCoarsePositions( + OpenSubdiv_EvaluatorDescr *evaluator_descr, + const float *positions, + int start_vertex_index, + int num_vertices) { /* TODO(sergey): Add sanity check on indices. */ - evaluator_descr->eval_output->UpdateData(positions, start_vert, num_verts); - /* TODO(sergey): Consider moving this to a separate call, - * so we can updatwe coordinates in chunks. - */ - evaluator_descr->eval_output->Refine(); + evaluator_descr->eval_output->UpdateData(positions, + start_vertex_index, + num_vertices); +} + +void openSubdiv_setEvaluatorVaryingData( + OpenSubdiv_EvaluatorDescr *evaluator_descr, + const float *varying_data, + int start_vertex_index, + int num_vertices) +{ + /* TODO(sergey): Add sanity check on indices. */ + evaluator_descr->eval_output->UpdateVaryingData(varying_data, + start_vertex_index, + num_vertices); } -void openSubdiv_setEvaluatorVaryingData(OpenSubdiv_EvaluatorDescr *evaluator_descr, - float *varying_data, - int start_vert, - int num_verts) +void openSubdiv_setEvaluatorCoarsePositionsFromBuffer( + OpenSubdiv_EvaluatorDescr *evaluator_descr, + const void *buffer, + int start_offset, + int stride, + int start_vertex_index, + int num_vertices) { + const unsigned char *current_buffer = (unsigned char *)buffer; + current_buffer += start_offset; /* TODO(sergey): Add sanity check on indices. */ - evaluator_descr->eval_output->UpdateVaryingData(varying_data, start_vert, num_verts); - /* TODO(sergey): Get rid of this ASAP. */ + for (int i = 0; i < num_vertices; ++i) { + const int current_vertex_index = start_vertex_index + i; + evaluator_descr->eval_output->UpdateData((float *)current_buffer, + current_vertex_index, + 1); + current_buffer += stride; + } +} + +void openSubdiv_refineEvaluator(OpenSubdiv_EvaluatorDescr *evaluator_descr) +{ evaluator_descr->eval_output->Refine(); } diff --git a/intern/opensubdiv/opensubdiv_gl_mesh.h b/intern/opensubdiv/opensubdiv_gl_mesh.h new file mode 100644 index 00000000000..1e99fc5bce4 --- /dev/null +++ b/intern/opensubdiv/opensubdiv_gl_mesh.h @@ -0,0 +1,40 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __OPENSUBDIV_GL_MESH_H__ +#define __OPENSUBDIV_GL_MESH_H__ + +struct OpenSubdiv_GLMeshDescr; +struct OpenSubdiv_TopologyRefinerDescr; +struct OpenSubdiv_GLMeshFVarData; + +typedef struct OpenSubdiv_GLMesh { + int evaluator_type; + OpenSubdiv_GLMeshDescr *descriptor; + OpenSubdiv_TopologyRefinerDescr *topology_refiner; + OpenSubdiv_GLMeshFVarData *fvar_data; +} OpenSubdiv_GLMesh; + +#endif /* __OPENSUBDIV_GL_MESH_H__ */ diff --git a/intern/opensubdiv/opensubdiv_gpu_capi.cc b/intern/opensubdiv/opensubdiv_gpu_capi.cc index 7d8085c1ff5..d28b48ddd18 100644 --- a/intern/opensubdiv/opensubdiv_gpu_capi.cc +++ b/intern/opensubdiv/opensubdiv_gpu_capi.cc @@ -45,6 +45,7 @@ #include "MEM_guardedalloc.h" #include "opensubdiv_capi.h" +#include "opensubdiv_gl_mesh.h" #include "opensubdiv_topology_refiner.h" using OpenSubdiv::Osd::GLMeshInterface; diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c index fc4220277eb..46204898709 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c @@ -198,7 +198,7 @@ void ccgSubSurf_checkTopologyChanged(CCGSubSurf *ss, DerivedMesh *dm) ss->osd_topology_refiner = NULL; } - /* Reste CPU side. */ + /* Reset CPU side. */ if (ss->osd_evaluator != NULL) { openSubdiv_deleteEvaluatorDescr(ss->osd_evaluator); ss->osd_evaluator = NULL; @@ -523,6 +523,7 @@ static void opensubdiv_updateEvaluatorCoarsePositions(CCGSubSurf *ss) (float *)positions, 0, num_basis_verts); + openSubdiv_refineEvaluator(ss->osd_evaluator); MEM_freeN(positions); } -- cgit v1.2.3 From ef30fa3739a5d23a8c9acfbfc12f0f612e59dc89 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 11 Jul 2018 12:55:03 +0200 Subject: Fix crash in combing after changing scene property --- .../depsgraph/intern/builder/deg_builder_relations.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 23e50f125ba..bba1ba67962 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -2213,7 +2213,23 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node if (id_type == ID_ME && comp_node->type == DEG_NODE_TYPE_GEOMETRY) { rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; } - if (comp_node->type == DEG_NODE_TYPE_PARAMETERS) { + /* Notes on exceptions: + * - Parameters component is where drivers are living. Changing any + * of the (custom) properties in the original datablock (even the + * ones which do not imply other component update) need to make + * sure drivers are properly updated. + * This way, for example, changing ID property will properly poke + * all drivers to be updated. + * + * - View layers have cached array of bases in them, which is not + * copied by copy-on-write, and not preserved. PROBABLY it is better + * to preserve that cache in copy-on-write, but for the time being + * we allow flush to layer collections component which will ensure + * that cached array fo bases exists and is up-to-date. + */ + if (comp_node->type == DEG_NODE_TYPE_PARAMETERS || + comp_node->type == DEG_NODE_TYPE_LAYER_COLLECTIONS) + { rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; } /* All entry operations of each component should wait for a proper -- cgit v1.2.3 From 1d83fe82bc265391635b8bc642cad5e4fc8d0004 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 13:02:22 +0200 Subject: Cleanup: simplify RNA names --- release/scripts/startup/bl_ui/space_view3d.py | 6 +++--- source/blender/blenloader/intern/versioning_280.c | 4 ++-- source/blender/draw/intern/draw_manager.c | 2 +- source/blender/draw/modes/pose_mode.c | 6 +++--- source/blender/editors/armature/pose_edit.c | 2 +- source/blender/editors/space_view3d/space_view3d.c | 2 +- source/blender/makesdna/DNA_view3d_types.h | 4 ++-- source/blender/makesrna/intern/rna_space.c | 12 ++++++------ 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 3e97877c115..7e5b46f25cb 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4115,10 +4115,10 @@ class VIEW3D_PT_overlay_pose(Panel): col.active = display_all col.prop(overlay, "show_transparent_bones") row = col.split(0.65) - row.prop(overlay, "show_bone_selection") + row.prop(overlay, "show_bone_select") sub = row.column() - sub.active = display_all and overlay.show_bone_selection - sub.prop(overlay, "bone_selection_alpha", text="") + sub.active = display_all and overlay.show_bone_select + sub.prop(overlay, "bone_select_alpha", text="") class VIEW3D_PT_overlay_edit_armature(Panel): diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index c9ab174d5e2..bd66d9a4707 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1465,13 +1465,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } - if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "bone_selection_alpha")) { + if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "bone_select_alpha")) { for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - v3d->overlay.bone_selection_alpha = 0.5f; + v3d->overlay.bone_select_alpha = 0.5f; } } } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index be067b0464d..d8e1aa2c7a4 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1788,7 +1788,7 @@ void DRW_draw_select_loop( obedit_mode = CTX_MODE_EDIT_ARMATURE; } } - if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECTION) { + if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT) { if (!(v3d->flag2 & V3D_RENDER_OVERRIDE)) { Object *obpose = OBPOSE_FROM_OBACT(obact); if (obpose) { diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index 2c24b29c881..90bbd3580cb 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -87,7 +87,7 @@ static bool POSE_is_bone_selection_overlay_active(void) { const DRWContextState *dcs = DRW_context_state_get(); const View3D *v3d = dcs->v3d; - return v3d && (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECTION) && OBPOSE_FROM_OBACT(dcs->obact); + return v3d && (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT) && OBPOSE_FROM_OBACT(dcs->obact); } static void POSE_engine_init(void *UNUSED(vedata)) @@ -155,8 +155,8 @@ static void POSE_cache_init(void *vedata) { if (POSE_is_bone_selection_overlay_active()) { - copy_v4_fl4(ppd->blend_color, 0.0f, 0.0f, 0.0f, v3d->overlay.bone_selection_alpha); - copy_v4_fl4(ppd->blend_color_invert, 0.0f, 0.0f, 0.0f, pow(v3d->overlay.bone_selection_alpha, 4)); + copy_v4_fl4(ppd->blend_color, 0.0f, 0.0f, 0.0f, v3d->overlay.bone_select_alpha); + copy_v4_fl4(ppd->blend_color_invert, 0.0f, 0.0f, 0.0f, pow(v3d->overlay.bone_select_alpha, 4)); DRWShadingGroup *grp; psl->bone_selection = DRW_pass_create( "Bone Selection", diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 661492ba056..39f532ef1db 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -1256,7 +1256,7 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot) static int toggle_bone_selection_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); - v3d->overlay.flag ^= V3D_OVERLAY_BONE_SELECTION; + v3d->overlay.flag ^= V3D_OVERLAY_BONE_SELECT; ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C)); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 39315dcd64f..5cff64218ec 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -334,7 +334,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV; v3d->overlay.wireframe_threshold = 0.5f; - v3d->overlay.bone_selection_alpha = 0.5f; + v3d->overlay.bone_select_alpha = 0.5f; v3d->overlay.texture_paint_mode_opacity = 0.8; v3d->overlay.weight_paint_mode_opacity = 0.8; v3d->overlay.vertex_paint_mode_opacity = 0.8; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index b02661754bd..365fe125e83 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -175,7 +175,7 @@ typedef struct View3DOverlay { /* Armature edit/pose mode settings */ int arm_flag; - float bone_selection_alpha; + float bone_select_alpha; /* Other settings */ float wireframe_threshold; @@ -380,7 +380,7 @@ enum { enum { V3D_OVERLAY_FACE_ORIENTATION = (1 << 0), V3D_OVERLAY_HIDE_CURSOR = (1 << 1), - V3D_OVERLAY_BONE_SELECTION = (1 << 2), + V3D_OVERLAY_BONE_SELECT = (1 << 2), V3D_OVERLAY_LOOK_DEV = (1 << 3), V3D_OVERLAY_WIREFRAMES = (1 << 4), V3D_OVERLAY_HIDE_TEXT = (1 << 5), diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 67c345914dc..b24a9fbeffd 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2653,14 +2653,14 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Face Orientation", "Show the Face Orientation Overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_bone_selection", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_BONE_SELECTION); + prop = RNA_def_property(srna, "show_bone_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_BONE_SELECT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Bone Selection", "Show the Bone Selection Overlay"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "bone_selection_alpha", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "overlay.bone_selection_alpha"); + prop = RNA_def_property(srna, "bone_select_alpha", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.bone_select_alpha"); RNA_def_property_float_default(prop, 0.5f); RNA_def_property_ui_text(prop, "Opacity", "Opacity to use for bone selection"); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -2682,13 +2682,13 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) prop = RNA_def_property(srna, "show_look_dev", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_LOOK_DEV); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Look Dev", "Show Look Development Balls and Palette"); + RNA_def_property_ui_text(prop, "Look Dev Preview", "Show look development balls and palette"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_wireframes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_WIREFRAMES); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Wireframes", "Show face edges wires"); + RNA_def_property_ui_text(prop, "Wireframe", "Show face edges wires"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "wireframe_threshold", PROP_FLOAT, PROP_FACTOR); -- cgit v1.2.3 From e461d01657cb7fd8fc6765660d096abec08133de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 13:07:30 +0200 Subject: Cleanup: remove redundant operator --- source/blender/editors/armature/armature_intern.h | 1 - source/blender/editors/armature/armature_ops.c | 6 ++--- source/blender/editors/armature/pose_edit.c | 32 ----------------------- 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index a37a2bada08..7c0dd09a237 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -137,7 +137,6 @@ void POSE_OT_rotation_mode_set(struct wmOperatorType *ot); void POSE_OT_quaternions_flip(struct wmOperatorType *ot); void POSE_OT_bone_layers(struct wmOperatorType *ot); -void POSE_OT_toggle_bone_selection_overlay(struct wmOperatorType *ot); /* ******************************************************* */ /* Pose Tool Utilities (for PoseLib, Pose Sliding, etc.) */ diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 8ea03fa242d..039bb7f1847 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -132,8 +132,6 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_bone_layers); - WM_operatortype_append(POSE_OT_toggle_bone_selection_overlay); - WM_operatortype_append(POSE_OT_propagate); /* POSELIB */ @@ -377,7 +375,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "POSE_OT_toggle_bone_selection_overlay", ZKEY, KM_PRESS, 0, 0); + + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ZKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "space_data.overlay.show_bone_select"); /* special transforms: */ /* 1) envelope/b-bone size */ diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 39f532ef1db..a9ba8c405ba 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -1248,35 +1248,3 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } - -/* -------------------------------------------------------------------- */ -/** \name Toggle Bone selection Overlay Operator - * \{ */ - -static int toggle_bone_selection_exec(bContext *C, wmOperator *UNUSED(op)) -{ - View3D *v3d = CTX_wm_view3d(C); - v3d->overlay.flag ^= V3D_OVERLAY_BONE_SELECT; - ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C)); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); - return OPERATOR_FINISHED; -} - -static bool pose_select_linked_poll(bContext *C) -{ - return (ED_operator_view3d_active(C) && ED_operator_posemode(C)); -} - -void POSE_OT_toggle_bone_selection_overlay(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Toggle Bone Selection Overlay"; - ot->description = "Toggle bone selection overlay of the viewport"; - ot->idname = "POSE_OT_toggle_bone_selection_overlay"; - - /* api callbacks */ - ot->exec = toggle_bone_selection_exec; - ot->poll = pose_select_linked_poll; -} - -/** \} */ -- cgit v1.2.3 From e3cbff606c9e767f2aee3d6c20df3ca8220137bf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 13:13:07 +0200 Subject: Keymap: update 2.7x map --- release/scripts/presets/keyconfig/blender_27x.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index cc21699f6c4..e9f64183d9a 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -1425,7 +1425,16 @@ keyconfig_data = [ ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None), ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None), ("pose.bone_layers", {"type": 'M', "value": 'PRESS'}, None), - ("pose.toggle_bone_selection_overlay", {"type": 'Z', "value": 'PRESS'}, None), + ( + "wm.context_toggle", + {"type": 'Z', "value": 'PRESS'}, + { + "properties": [ + ("data_path", 'space_data.overlay.show_bone_select'), + ], + } + ), + ( "transform.transform", {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, -- cgit v1.2.3 From 78fc4b592aae07da3196c845b07764a08be779ba Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 13:00:05 +0200 Subject: UI: Re-arrange Overlays popover Organize content in categories/sub-panels. The result is a more organized but slightly taller popover. Once sub-panels are implemented code-wise, the alignment issues (like panel label) and extra space between the content and panels headers will be reduced. Together with the ability to have certain less-used popovers collapsed by default, this will make the popover more compact. Part of design: T55863 --- release/scripts/startup/bl_ui/space_view3d.py | 189 +++++++++++++++++++------- 1 file changed, 142 insertions(+), 47 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 7e5b46f25cb..e2350d52eb9 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3867,86 +3867,176 @@ class VIEW3D_PT_overlay(Panel): bl_label = "Overlays" bl_ui_units_x = 14 + def draw(self, context): + pass + + +class VIEW3D_PT_overlay_manipulators(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay' + bl_label = "Manipulators" + + def draw_header(self, context): + view = context.space_data + self.layout.prop(view, "show_manipulator", text="") + def draw(self, context): layout = self.layout view = context.space_data - shading = view.shading overlay = view.overlay display_all = overlay.show_overlays col = layout.column() col.active = display_all - split = col.split() + row = col.row(align=True) + row.active = view.show_manipulator + row.prop(view, "show_manipulator_navigate", text="Navigate", toggle=True) + row.prop(view, "show_manipulator_context", text="Active Object", toggle=True) + row.prop(view, "show_manipulator_tool", text="Active Tools", toggle=True) + +class VIEW3D_PT_overlay_guides(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay' + bl_label = "Guides" + + def draw(self, context): + layout = self.layout + + view = context.space_data + overlay = view.overlay + shading = view.shading + display_all = overlay.show_overlays + + col = layout.column() + + split = col.split() sub = split.column() - sub.prop(view, "show_manipulator", text="Manipulators") - has_manipulator = view.show_manipulator - subsub = sub.column() - subsub.active = has_manipulator - subsub.prop(view, "show_manipulator_navigate", text="Navigate") - del subsub + sub.prop(overlay, "show_floor", text="Grid") + + if overlay.show_floor: + sub = col.column(align=True) + sub.active = bool(overlay.show_floor or view.region_quadviews or not view.region_3d.is_perspective) + subsub = sub.row(align=True) + subsub.active = overlay.show_floor + subsub.prop(overlay, "grid_scale", text="Scale") + subsub.prop(overlay, "grid_subdivisions", text="Subdivisions") + + sub = split.column() - sub.active = has_manipulator - sub.prop(view, "show_manipulator_context", text="Active Object") - sub.prop(view, "show_manipulator_tool", text="Active Tools") + row = sub.row() + row.label(text="Axes") - col.separator() + subrow = row.row(align=True) + subrow.prop(overlay, "show_axis_x", text="X", toggle=True) + subrow.prop(overlay, "show_axis_y", text="Y", toggle=True) + subrow.prop(overlay, "show_axis_z", text="Z", toggle=True) split = col.split() sub = split.column() - sub.prop(overlay, "show_text", text="Text") sub.prop(overlay, "show_cursor", text="3D Cursor") - sub.prop(overlay, "show_outline_selected") - sub.prop(overlay, "show_all_objects_origin") - sub = split.column() + if shading.type == 'MATERIAL': + sub = split.column() + sub.prop(overlay, "show_look_dev") + + +class VIEW3D_PT_overlay_object(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay' + bl_label = "Objects" + + def draw(self, context): + layout = self.layout + view = context.space_data + overlay = view.overlay + shading = view.shading + + col = layout.column(align=True) + split = col.split() + + sub = split.column(align=True) + sub.prop(overlay, "show_ornaments", text="Ornaments") sub.prop(overlay, "show_relationship_lines") + sub.prop(overlay, "show_all_objects_origin") + + sub = split.column(align=True) + sub.prop(overlay, "show_bones", text="Bones") sub.prop(overlay, "show_motion_paths") + sub.prop(overlay, "show_outline_selected") + + +class VIEW3D_PT_overlay_geometry(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay' + bl_label = "Geometry" + + def draw(self, context): + layout = self.layout + view = context.space_data + overlay = view.overlay + shading = view.shading + + col = layout.column() + + split = col.split() + sub = split.column(align=True) + + icon_w = 'CHECKBOX_HLT' if overlay.show_wireframes else 'CHECKBOX_DEHLT' + + row = sub.row(align=True) + row.prop(overlay, "show_wireframes", text="", icon=icon_w) + sub = row.row(align=True) + sub.active = overlay.show_wireframes + sub.prop(overlay, "wireframe_threshold", text="Wireframes") + + sub = split.column(align=True) + sub.prop(overlay, "show_backface_culling") #sub.prop(overlay, "show_onion_skins") + + col = layout.column(align=True) + split = col.split() + sub = split.column(align=True) sub.prop(overlay, "show_face_orientation") - sub.prop(overlay, "show_backface_culling") - sub.prop(overlay, "show_ornaments", text="Ornaments") - sub.prop(overlay, "show_bones", text="Bones") - if shading.type == 'MATERIAL': - sub.prop(overlay, "show_look_dev") - row = col.row() - row.prop(overlay, "show_wireframes") - sub = row.row() - sub.active = overlay.show_wireframes - sub.prop(overlay, "wireframe_threshold", text="") +class VIEW3D_PT_overlay_motion_tracking(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay' + bl_label = "Motion Tracking" - col = layout.column() - col.active = display_all - split = col.split(percentage=0.55) - split.prop(overlay, "show_floor", text="Grid Floor") + def draw_header(self, context): + view = context.space_data + self.layout.prop(view, "show_reconstruction", text="") - row = split.row(align=True) - row.prop(overlay, "show_axis_x", text="X", toggle=True) - row.prop(overlay, "show_axis_y", text="Y", toggle=True) - row.prop(overlay, "show_axis_z", text="Z", toggle=True) + def draw(self, context): + layout = self.layout + view = context.space_data - if overlay.show_floor: - sub = col.column(align=True) - sub.active = bool(overlay.show_floor or view.region_quadviews or not view.region_3d.is_perspective) - subsub = sub.column(align=True) - subsub.active = overlay.show_floor - subsub.prop(overlay, "grid_scale", text="Scale") - subsub.prop(overlay, "grid_subdivisions", text="Subdivisions") + col = layout.column() - col.prop(view, "show_reconstruction", text="Motion Tracking") if view.show_reconstruction: - sub = col.column(align=True) + split = col.split() + + sub = split.column(align=True) sub.active = view.show_reconstruction sub.prop(view, "show_camera_path", text="Camera Path") - sub.prop(view, "show_bundle_names", text="3D Marker Names") - sub.label(text="Track Type and Size:") - row = sub.row(align=True) + + sub = split.column() + sub.prop(view, "show_bundle_names", text="Marker Names") + + col = layout.column() + col.label(text="Tracks:") + row = col.row(align=True) row.prop(view, "tracks_draw_type", text="") - row.prop(view, "tracks_draw_size", text="") + row.prop(view, "tracks_draw_size", text="Size") class VIEW3D_PT_overlay_edit_mesh(Panel): @@ -4518,6 +4608,11 @@ classes = ( VIEW3D_PT_shading_color, VIEW3D_PT_shading_options, VIEW3D_PT_overlay, + VIEW3D_PT_overlay_manipulators, + VIEW3D_PT_overlay_guides, + VIEW3D_PT_overlay_object, + VIEW3D_PT_overlay_geometry, + VIEW3D_PT_overlay_motion_tracking, VIEW3D_PT_overlay_edit_mesh, VIEW3D_PT_overlay_edit_curve, VIEW3D_PT_overlay_edit_armature, -- cgit v1.2.3 From 160959152ebc980130c2c56bab3471167257eece Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 13:06:01 +0200 Subject: UI: 3D Viewport Header - swap position of shading/snapping settings When tweaking the shading/overlays settings through the popovers, these get on the way of the content in the viewport. Making it hard to see the result of our changes. Unfortunately this breaks consistency with other headers where the snapping tools are aligned to the right, but the benefits outweigh the costs. --- release/scripts/startup/bl_ui/space_view3d.py | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index e2350d52eb9..e3f3d05defb 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -97,23 +97,6 @@ class VIEW3D_HT_header(Header): layout.separator_spacer() - # Viewport Settings - row = layout.row(align=True) - row.prop(shading, "type", text="", expand=True) - - sub = row.row(align=True) - sub.enabled = shading.type != 'RENDERED' - sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading") - - row = layout.row(align=True) - row.prop(overlay, "show_overlays", icon='WIRE', text="") - - sub = row.row(align=True) - sub.active = overlay.show_overlays - sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay") - - layout.separator_spacer() - # Mode & Transform Settings scene = context.scene @@ -223,6 +206,23 @@ class VIEW3D_HT_header(Header): text="", ) + layout.separator_spacer() + + # Viewport Settings + row = layout.row(align=True) + row.prop(shading, "type", text="", expand=True) + + sub = row.row(align=True) + sub.enabled = shading.type != 'RENDERED' + sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading") + + row = layout.row(align=True) + row.prop(overlay, "show_overlays", icon='WIRE', text="") + + sub = row.row(align=True) + sub.active = overlay.show_overlays + sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay") + class VIEW3D_MT_editor_menus(Menu): bl_space_type = 'VIEW3D_MT_editor_menus' -- cgit v1.2.3 From 55d44a3b6bab2bd91fd1a15de6a18db592b196b3 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 13:24:04 +0200 Subject: UI: Move Object Type Visibility next to shading/overlay settings Group Object Type Visibility with the viewport settings in the header. The eye icon is a placeholder. A new icon is needed to better communicate the user at a glance if all (or none) object types are enabled, or why certain types are not visible/selectable in the viewport. Part of design: T55863 --- release/scripts/startup/bl_ui/space_view3d.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index e3f3d05defb..9c8a4265146 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -209,6 +209,13 @@ class VIEW3D_HT_header(Header): layout.separator_spacer() # Viewport Settings + layout.popover( + space_type='VIEW_3D', + region_type='HEADER', + panel_type="VIEW3D_PT_object_type_visibility", + icon="HIDE_OFF", + text="") + row = layout.row(align=True) row.prop(shading, "type", text="", expand=True) @@ -3691,9 +3698,9 @@ class VIEW3D_PT_view3d_cursor(Panel): class VIEW3D_PT_object_type_visibility(Panel): bl_space_type = 'VIEW_3D' - bl_region_type = 'UI' + bl_region_type = 'HEADER' bl_label = "View Object Types" - bl_options = {'DEFAULT_CLOSED'} + bl_ui_units_x = 6 def draw(self, context): layout = self.layout -- cgit v1.2.3 From 7f77ee70f1bb95875805eba15806dae4959698c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 13:58:10 +0200 Subject: UI: minor tweaks to overlay panel Position 'outline selected' more prominently, gives more useful behavior when dragging over the left column. --- release/scripts/startup/bl_ui/space_view3d.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 9c8a4265146..bf02a297b53 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -210,11 +210,12 @@ class VIEW3D_HT_header(Header): # Viewport Settings layout.popover( - space_type='VIEW_3D', - region_type='HEADER', - panel_type="VIEW3D_PT_object_type_visibility", - icon="HIDE_OFF", - text="") + space_type='VIEW_3D', + region_type='HEADER', + panel_type="VIEW3D_PT_object_type_visibility", + icon="HIDE_OFF", + text="", + ) row = layout.row(align=True) row.prop(shading, "type", text="", expand=True) @@ -3933,7 +3934,6 @@ class VIEW3D_PT_overlay_guides(Panel): subsub.prop(overlay, "grid_scale", text="Scale") subsub.prop(overlay, "grid_subdivisions", text="Subdivisions") - sub = split.column() row = sub.row() row.label(text="Axes") @@ -3970,12 +3970,12 @@ class VIEW3D_PT_overlay_object(Panel): sub = split.column(align=True) sub.prop(overlay, "show_ornaments", text="Ornaments") sub.prop(overlay, "show_relationship_lines") - sub.prop(overlay, "show_all_objects_origin") + sub.prop(overlay, "show_outline_selected") sub = split.column(align=True) sub.prop(overlay, "show_bones", text="Bones") sub.prop(overlay, "show_motion_paths") - sub.prop(overlay, "show_outline_selected") + sub.prop(overlay, "show_all_objects_origin") class VIEW3D_PT_overlay_geometry(Panel): @@ -4001,7 +4001,7 @@ class VIEW3D_PT_overlay_geometry(Panel): row.prop(overlay, "show_wireframes", text="", icon=icon_w) sub = row.row(align=True) sub.active = overlay.show_wireframes - sub.prop(overlay, "wireframe_threshold", text="Wireframes") + sub.prop(overlay, "wireframe_threshold", text="Wireframe") sub = split.column(align=True) sub.prop(overlay, "show_backface_culling") -- cgit v1.2.3 From 117fd0247715bff6c265bb75f727112ce1fcb3cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 14:04:17 +0200 Subject: UI: correct panel default-closed --- release/scripts/startup/bl_ui/properties_physics_rigidbody.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py index de8bca229e4..db59665e21d 100644 --- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py @@ -102,7 +102,7 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel): class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel): bl_label = "Dynamics" bl_parent_id = 'PHYSICS_PT_rigid_body' - bl_default_closed = True + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @classmethod -- cgit v1.2.3 From 59b4c675361b54b32b6238855fe4a82117cc48c7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 11 Jul 2018 14:32:06 +0200 Subject: Minor cleanup to logic in BKE's imbuf releasing code. --- source/blender/blenkernel/intern/image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 76cf7317b19..c520714b076 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -4095,12 +4095,12 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock) void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock) { - if (lock) { + if (lock != NULL) { /* for getting image during threaded render / compositing, need to release */ if (lock == ima) { BLI_thread_unlock(LOCK_VIEWER); /* viewer image */ } - else if (lock) { + else { RE_ReleaseResultImage(lock); /* render result */ BLI_thread_unlock(LOCK_VIEWER); /* view image imbuf */ } -- cgit v1.2.3 From 08274433e1bd9db5a2a27e5d2f8862e9cc3f27f0 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 11 Jul 2018 14:32:43 +0200 Subject: Fix T55912: saving Viewer Node image error. Images from viewer node needs the lock parameter... --- source/blender/makesrna/intern/rna_image_api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 916ba660249..b6ba06a84d5 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -118,7 +118,9 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *reports) { - ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); + void *lock; + + ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); if (ibuf) { char filename[FILE_MAX]; BLI_strncpy(filename, image->name, sizeof(filename)); @@ -145,7 +147,7 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); } - BKE_image_release_ibuf(image, ibuf, NULL); + BKE_image_release_ibuf(image, ibuf, &lock); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image); } -- cgit v1.2.3 From ddedf6124e174502f2733ec4e42327ae2fd9d850 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 15:22:57 +0200 Subject: Revert removal of fake editing for numeric input Revert changes from 785159e6e4dfc5c010baab626667132020e1ddc7 but keep 'ifdef'. @mont29 maintains this area and prefers to keep existing logic. Note that there was misunderstanding that '*' was intended only to be a backup key for '=' for keyboards which require holding a modifier. --- source/blender/editors/util/numinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 4de61395314..8bd5c9640a5 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -49,7 +49,7 @@ #include "UI_interface.h" /* Numeric input which isn't allowing full numeric editing. */ -// #define USE_FAKE_EDIT +#define USE_FAKE_EDIT /* NumInput.flag */ enum { -- cgit v1.2.3 From 4116435e2be139d40b27df827cdc9825cedd90f1 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 11 Jul 2018 15:45:17 +0200 Subject: Fix T55914: Blender 2.8 Crashes when increasing the repeat count for a track in NLA Logical mistake in repeated strips drawing code. --- source/blender/editors/space_nla/nla_draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 3f1bd0db74c..5b68c7b6bb7 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -512,13 +512,13 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri } /* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */ - if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f) == 0) { + if ((strip->type == NLASTRIP_TYPE_CLIP) && strip->repeat > 1.0f) { float repeatLen = (strip->actend - strip->actstart) * strip->scale; /* only draw lines for whole-numbered repeats, starting from the first full-repeat * up to the last full repeat (but not if it lies on the end of the strip) */ - immBeginAtMost(GWN_PRIM_LINES, 2 * (strip->repeat - 1)); + immBeginAtMost(GWN_PRIM_LINES, 2 * floorf(strip->repeat)); for (int i = 1; i < strip->repeat; i++) { float repeatPos = strip->start + (repeatLen * i); -- cgit v1.2.3 From 05b6b5d2347503687854055b7570e988c4a2a729 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 16:05:05 +0200 Subject: UI: Re-arrange Shading popover * Unify X-Ray/Shadow toggle and factor, using the whole width gives you finer control * Shadow settings next to intensity slider * Cavity settings next to Ridge/Valley sliders * Collapse Cavity settings when not used * Make MatCap preview and browser dialog smaller. MatCaps are added by the user so she is already familiar with how they look. No need to preview them that big while browsing. To see the MatCaps in detail we have the User Preferences/Asset Manager. Having popovers inside popovers triggers some minor glitches that will be addressed later. (e.g. they open on mouse over and the popover arrow is not aligned) --- release/scripts/startup/bl_ui/space_view3d.py | 121 ++++++++++++++++++++------ 1 file changed, 94 insertions(+), 27 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index bf02a297b53..55c08717e55 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3765,15 +3765,17 @@ class VIEW3D_PT_shading_lighting(Panel): layout.row().prop(shading, "light", expand=True) if shading.light == 'STUDIO': row = layout.row() - row.template_icon_view(shading, "studio_light", show_labels=True) + row.scale_y = 0.8 + row.template_icon_view(shading, "studio_light", show_labels=True, scale=3) sub = row.column() sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') if shading.selected_studio_light.orientation == 'WORLD': - layout.row().prop(shading, "studiolight_rotate_z") + layout.row().prop(shading, "studiolight_rotate_z", text="Rotation") elif shading.light == 'MATCAP': row = layout.row() - row.template_icon_view(shading, "studio_light", show_labels=True) + row.scale_y = 0.8 + row.template_icon_view(shading, "studio_light", show_labels=True, scale=3) sub = row.column() sub.operator('VIEW3D_OT_toggle_matcap_flip', emboss=False, text="", icon='ARROW_LEFTRIGHT') sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') @@ -3785,11 +3787,11 @@ class VIEW3D_PT_shading_lighting(Panel): if not shading.use_scene_world: row = layout.row() - row.template_icon_view(shading, "studio_light", show_labels=True) + row.template_icon_view(shading, "studio_light", show_labels=True, scale=3) sub = row.column() sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') if shading.selected_studio_light.orientation == 'WORLD': - layout.row().prop(shading, "studiolight_rotate_z") + layout.row().prop(shading, "studiolight_rotate_z", text="Rotation") layout.row().prop(shading, "studiolight_background_alpha") @@ -3835,45 +3837,108 @@ class VIEW3D_PT_shading_options(Panel): view = context.space_data shading = view.shading - if not shading.light == 'MATCAP': - row = layout.row() - row.prop(shading, "show_specular_highlight") + col = layout.column() - row = layout.split(0.4) - row.prop(shading, "show_xray") - sub = row.row() - sub.active = shading.show_xray - sub.prop(shading, "xray_alpha", text="") + is_xray = shading.show_xray + is_shadows = shading.show_shadows - row = layout.split(0.4) - row.active = not shading.show_xray - row.prop(shading, "show_shadows") + icon_x = 'CHECKBOX_HLT' if is_xray else 'CHECKBOX_DEHLT' + row = col.row() + row.prop(shading, "show_xray", text="") sub = row.row() - sub.active = shading.show_shadows and not shading.show_xray - sub.prop(shading, "shadow_intensity", text="") + sub.active = is_xray + sub.prop(shading, "xray_alpha", text="X-Ray") - row = layout.split(0.4) - row.active = not shading.show_xray + icon_s = 'CHECKBOX_HLT' if is_shadows else 'CHECKBOX_DEHLT' + row = col.row() + row.prop(shading, "show_shadows", text="") + row.active = not is_xray + sub = row.row(align=True) + sub.active = is_shadows + sub.prop(shading, "shadow_intensity", text="Shadow") + sub.popover( + space_type='VIEW_3D', + region_type='HEADER', + panel_type="VIEW3D_PT_shading_options_shadow", + icon='SCRIPTWIN', + text="" + ) + + col = layout.column() + row = col.row() + row.active = not is_xray row.prop(shading, "show_cavity") - sub = row.column(align=True) - sub.active = not shading.show_xray and shading.show_cavity - sub.prop(shading, "cavity_ridge_factor") - sub.prop(shading, "cavity_valley_factor") - row = layout.split(0.4) + if shading.show_cavity: + sub = col.row(align=True) + sub.active = not shading.show_xray and shading.show_cavity + sub.prop(shading, "cavity_ridge_factor") + sub.prop(shading, "cavity_valley_factor") + sub.popover( + space_type='VIEW_3D', + region_type='HEADER', + panel_type="VIEW3D_PT_shading_options_ssao", + icon='SCRIPTWIN', + text="" + ) + + row = layout.split() row.prop(shading, "show_object_outline") sub = row.row() sub.active = shading.show_object_outline sub.prop(shading, "object_outline_color", text="") - layout.prop(view, "show_world") + col = layout.column() + if not shading.light == 'MATCAP': + col.prop(shading, "show_specular_highlight") + + col.prop(view, "show_world") + + +class VIEW3D_PT_shading_options_shadow(Panel): + bl_label = "Shadow Settings" + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + + @classmethod + def poll(cls, context): + return True + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + scene = context.scene + + col = layout.column() + col.prop(scene.display, "light_direction") + col.prop(scene.display, "shadow_shift") + + +class VIEW3D_PT_shading_options_ssao(Panel): + bl_label = "SSAO Settings" + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + + @classmethod + def poll(cls, context): + return True + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + scene = context.scene + + col = layout.column(align=True) + col.prop(scene.display, "matcap_ssao_samples") + col.prop(scene.display, "matcap_ssao_distance") + col.prop(scene.display, "matcap_ssao_attenuation") class VIEW3D_PT_overlay(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_label = "Overlays" - bl_ui_units_x = 14 + bl_ui_units_x = 13 def draw(self, context): pass @@ -4614,6 +4679,8 @@ classes = ( VIEW3D_PT_shading_lighting, VIEW3D_PT_shading_color, VIEW3D_PT_shading_options, + VIEW3D_PT_shading_options_shadow, + VIEW3D_PT_shading_options_ssao, VIEW3D_PT_overlay, VIEW3D_PT_overlay_manipulators, VIEW3D_PT_overlay_guides, -- cgit v1.2.3 From 0ae440eba5ea17686ac2dc75a48c2f674420f394 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 16:06:19 +0200 Subject: UI: Overlay popover - Wireframe slider style same as in shading popover Avoids having to switch between two icons, which was misaligned anyway. --- release/scripts/startup/bl_ui/space_view3d.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 55c08717e55..b47cfdc8071 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4057,26 +4057,21 @@ class VIEW3D_PT_overlay_geometry(Panel): col = layout.column() - split = col.split() - sub = split.column(align=True) - - icon_w = 'CHECKBOX_HLT' if overlay.show_wireframes else 'CHECKBOX_DEHLT' - - row = sub.row(align=True) - row.prop(overlay, "show_wireframes", text="", icon=icon_w) - sub = row.row(align=True) + row = col.row() + row.prop(overlay, "show_wireframes", text="") + sub = row.row() sub.active = overlay.show_wireframes sub.prop(overlay, "wireframe_threshold", text="Wireframe") - sub = split.column(align=True) - sub.prop(overlay, "show_backface_culling") - #sub.prop(overlay, "show_onion_skins") - col = layout.column(align=True) split = col.split() sub = split.column(align=True) sub.prop(overlay, "show_face_orientation") + sub = split.column(align=True) + #sub.prop(overlay, "show_onion_skins") + sub.prop(overlay, "show_backface_culling") + class VIEW3D_PT_overlay_motion_tracking(Panel): bl_space_type = 'VIEW_3D' -- cgit v1.2.3 From 7552972de0a2403d93699ad4a63882080fbde6f3 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 16:07:32 +0200 Subject: UI: Remove duplicate Viewport Display panel from Scene properties The Shadow and SSAO settings here are accessible from the Shading popover. --- release/scripts/startup/bl_ui/properties_scene.py | 37 ----------------------- 1 file changed, 37 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 1394a9388d0..d0fce0a2582 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -481,41 +481,6 @@ class SCENE_PT_simplify_render(SceneButtonsPanel, Panel): col.prop(rd, "simplify_child_particles_render", text="Max Child Particles") -class SCENE_PT_viewport_display(SceneButtonsPanel, Panel): - bl_label = "Viewport Display" - bl_options = {'DEFAULT_CLOSED'} - - @classmethod - def poll(cls, context): - return True - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - scene = context.scene - col = layout.column() - col.prop(scene.display, "light_direction") - col.prop(scene.display, "shadow_shift") - - -class SCENE_PT_viewport_display_ssao(SceneButtonsPanel, Panel): - bl_label = "Screen Space Ambient Occlusion" - bl_parent_id = "SCENE_PT_viewport_display" - - @classmethod - def poll(cls, context): - return True - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - scene = context.scene - col = layout.column() - col.prop(scene.display, "matcap_ssao_samples") - col.prop(scene.display, "matcap_ssao_distance") - col.prop(scene.display, "matcap_ssao_attenuation") - - class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} _context_path = "scene" @@ -531,8 +496,6 @@ classes = ( SCENE_PT_keying_set_paths, SCENE_PT_color_management, SCENE_PT_color_management_curves, - SCENE_PT_viewport_display, - SCENE_PT_viewport_display_ssao, SCENE_PT_audio, SCENE_PT_physics, SCENE_PT_rigid_body_world, -- cgit v1.2.3 From b1c2f4d468c91a257fbc696700521509325aa6f4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 16:31:28 +0200 Subject: Numeric Input: preference to default to advanced --- release/scripts/startup/bl_ui/space_userpref.py | 1 + source/blender/editors/interface/resources.c | 2 +- source/blender/editors/util/numinput.c | 19 +++++++++++-------- source/blender/makesdna/DNA_userdef_types.h | 2 +- source/blender/makesrna/intern/rna_userdef.c | 8 ++++++++ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index ca96c79b2b4..939e958375a 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -434,6 +434,7 @@ class USERPREF_PT_edit(Panel): col.label(text="Transform:") col.prop(edit, "use_drag_immediately") + col.prop(edit, "use_numeric_input_advanced") row.separator() row.separator() diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index c279c949e62..a2b1aa1f251 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1562,7 +1562,7 @@ void init_userdef_do_versions(Main *bmain) if (!USER_VERSION_ATLEAST(278, 6)) { /* Clear preference flags for re-use. */ U.flag &= ~( - USER_FLAG_DEPRECATED_1 | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 | + USER_FLAG_NUMINPUT_ADVANCED | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 | USER_FLAG_DEPRECATED_6 | USER_FLAG_DEPRECATED_7 | USER_FLAG_DEPRECATED_9 | USER_DEVELOPER_UI); U.uiflag &= ~( diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 8bd5c9640a5..f64182d2ad6 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -276,17 +276,20 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) short dir = STRCUR_DIR_NEXT, mode = STRCUR_JUMP_NONE; int cur; -#ifndef USE_FAKE_EDIT - if ((event->ctrl == 0) && (event->alt == 0) && (event->ascii != '\0') && - strchr("01234567890@%^&*-+/{}()[]<>.|", event->ascii)) +#ifdef USE_FAKE_EDIT + if (U.flag & USER_FLAG_NUMINPUT_ADVANCED) +#endif { - if (!(n->flag & NUM_EDIT_FULL)) { - n->flag |= NUM_EDITED; - n->flag |= NUM_EDIT_FULL; - n->val_flag[idx] |= NUM_EDITED; + if ((event->ctrl == 0) && (event->alt == 0) && (event->ascii != '\0') && + strchr("01234567890@%^&*-+/{}()[]<>.|", event->ascii)) + { + if (!(n->flag & NUM_EDIT_FULL)) { + n->flag |= NUM_EDITED; + n->flag |= NUM_EDIT_FULL; + n->val_flag[idx] |= NUM_EDITED; + } } } -#endif switch (event->type) { case EVT_MODAL_MAP: diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 45c6b9634f4..5b8f6fcb73f 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -673,7 +673,7 @@ typedef enum eUserPref_Section { /* UserDef.flag */ typedef enum eUserPref_Flag { USER_AUTOSAVE = (1 << 0), - USER_FLAG_DEPRECATED_1 = (1 << 1), /* cleared */ + USER_FLAG_NUMINPUT_ADVANCED = (1 << 1), USER_FLAG_DEPRECATED_2 = (1 << 2), /* cleared */ USER_FLAG_DEPRECATED_3 = (1 << 3), /* cleared */ /* USER_SCENEGLOBAL = (1 << 4), deprecated */ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 517e4047515..3d116482656 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3845,6 +3845,14 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Release confirms", "Moving things with a mouse drag confirms when releasing the button"); + prop = RNA_def_property(srna, "use_numeric_input_advanced", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_FLAG_NUMINPUT_ADVANCED); + RNA_def_property_ui_text( + prop, "Default to Advanced Numeric Input", + "When entering numbers while transforming, " + "default to advanced mode for full math expression evaluation"); + + /* Undo */ prop = RNA_def_property(srna, "undo_steps", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "undosteps"); -- cgit v1.2.3 From ad03a06d3c46f7a1ddb81e5d2c1406457b8f4507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 11 Jul 2018 16:54:10 +0200 Subject: Eevee: LightCache: Fix autobake starting when it should not --- source/blender/draw/engines/eevee/eevee_lightprobes.c | 7 ++++--- source/blender/editors/space_view3d/space_view3d.c | 18 +++++++++++++++--- source/blender/makesdna/DNA_lightprobe_types.h | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 1cb9a957211..b58e389b558 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -846,10 +846,11 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved /* If we update grid we need to update the cubemaps too. * So always refresh cubemaps. */ scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_CUBE; + /* Tag the lightcache to auto update. */ + scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_AUTO; + /* Use a notifier to trigger the operator after drawing. */ + WM_event_add_notifier(draw_ctx->evil_C, NC_LIGHTPROBE, scene_orig); } - - /* Use a notifier to trigger the operator after drawing. */ - WM_event_add_notifier(draw_ctx->evil_C, NC_LIGHTPROBE, scene_orig); } } } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 5cff64218ec..43b6a1b0621 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -32,6 +32,7 @@ #include #include +#include "DNA_lightprobe_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -685,6 +686,13 @@ static void view3d_lightcache_update(bContext *C) { PointerRNA op_ptr; + Scene *scene = CTX_data_scene(C); + + if (strcmp(scene->r.engine, RE_engine_id_BLENDER_EEVEE) != 0) { + /* Only do auto bake if eevee is the active engine */ + return; + } + WM_operator_properties_create(&op_ptr, "SCENE_OT_light_cache_bake"); RNA_int_set(&op_ptr, "delay", 200); RNA_enum_set_identifier(C, &op_ptr, "subset", "DIRTY"); @@ -1424,9 +1432,13 @@ static void space_view3d_listener( static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(sa)) { - /* This is only used by the auto lightprobe refresh for the moment. - * So we don't need to check anything to know what to do. */ - view3d_lightcache_update((bContext *)C); + Scene *scene = CTX_data_scene(C); + LightCache *lcache = scene->eevee.light_cache; + + if (lcache && (lcache->flag & LIGHTCACHE_UPDATE_AUTO) != 0) { + lcache->flag &= ~LIGHTCACHE_UPDATE_AUTO; + view3d_lightcache_update((bContext *)C); + } } const char *view3d_context_dir[] = { diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h index c06d75a4021..81286e5e4d0 100644 --- a/source/blender/makesdna/DNA_lightprobe_types.h +++ b/source/blender/makesdna/DNA_lightprobe_types.h @@ -169,6 +169,7 @@ enum { LIGHTCACHE_UPDATE_CUBE = (1 << 4), LIGHTCACHE_UPDATE_GRID = (1 << 5), LIGHTCACHE_UPDATE_WORLD = (1 << 6), + LIGHTCACHE_UPDATE_AUTO = (1 << 7), }; /* EEVEE_LightCacheTexture->data_type */ -- cgit v1.2.3 From cbfe522bb320cc98ebd30930c354fd4b31b2a753 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 17:16:10 +0200 Subject: Fix manipulator hiding cursor Manipulator highlight, then transform would hide the mouse cursor. --- .../windowmanager/manipulators/intern/wm_manipulator_intern.h | 2 ++ .../blender/windowmanager/manipulators/intern/wm_manipulator_map.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h index a131c6c5069..ecf4ffd2ac4 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h @@ -114,6 +114,8 @@ struct wmManipulatorMap { /* cursor location at point of entering modal (see: WM_MANIPULATOR_GRAB_CURSOR) */ int event_xy[2]; short event_grabcursor; + /* until we have nice cursor push/pop API. */ + int last_cursor; } mmap_context; }; diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c index 7b06382b029..76668702bd1 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c @@ -861,17 +861,18 @@ bool wm_manipulatormap_highlight_set( if (mpr) { mpr->state |= WM_MANIPULATOR_STATE_HIGHLIGHT; mpr->highlight_part = part; + mmap->mmap_context.last_cursor = -1; if (C && mpr->type->cursor_get) { wmWindow *win = CTX_wm_window(C); - win->lastcursor = win->cursor; + mmap->mmap_context.last_cursor = win->cursor; WM_cursor_set(win, mpr->type->cursor_get(mpr)); } } else { - if (C) { + if (C && mmap->mmap_context.last_cursor != -1) { wmWindow *win = CTX_wm_window(C); - WM_cursor_set(win, win->lastcursor); + WM_cursor_set(win, mmap->mmap_context.last_cursor); } } -- cgit v1.2.3 From 8bab591758289a5cf7bc4e5cd6b0322a5c8915e3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 17:22:57 +0200 Subject: UI: overlay panel minor tweak Move face-orientation to less prominent location since its more of a debugging option. --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index b47cfdc8071..92d9797b7ba 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4066,11 +4066,11 @@ class VIEW3D_PT_overlay_geometry(Panel): col = layout.column(align=True) split = col.split() sub = split.column(align=True) - sub.prop(overlay, "show_face_orientation") + sub.prop(overlay, "show_backface_culling") sub = split.column(align=True) #sub.prop(overlay, "show_onion_skins") - sub.prop(overlay, "show_backface_culling") + sub.prop(overlay, "show_face_orientation") class VIEW3D_PT_overlay_motion_tracking(Panel): -- cgit v1.2.3 From b90646dc0e3dcfae6fe52eab32542cebf5a60b0e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 18:09:19 +0200 Subject: Transform Manipulator: fix scale handle selection The scale handles couldn't be accessed when rotation was enabled and they pointed away from the view. --- source/blender/editors/transform/transform_manipulator_3d.c | 2 ++ .../windowmanager/manipulators/WM_manipulator_types.h | 2 ++ .../windowmanager/manipulators/intern/wm_manipulator_map.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index fa56e8d10be..7dc72ddff6f 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -1248,6 +1248,8 @@ static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + man->manipulators[MAN_AXIS_ROT_T]->flag |= WM_MANIPULATOR_SELECT_BACKGROUND; + return man; } diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h index e4482e797e3..ee2f833858a 100644 --- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h +++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h @@ -84,6 +84,8 @@ typedef enum eWM_ManipulatorFlag { * Hide the cursor and lock it's position while interacting with this manipulator. */ WM_MANIPULATOR_GRAB_CURSOR = (1 << 6), + /** Don't write into the depth buffer when selecting. */ + WM_MANIPULATOR_SELECT_BACKGROUND = (1 << 7), } eWM_ManipulatorFlag; /** diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c index 76668702bd1..2a3aa5df197 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c @@ -460,6 +460,7 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */ bool is_depth_prev = false; + bool is_depth_skip_prev = false; for (LinkData *link = visible_manipulators->first; link; link = link->next) { mpr = link->data; @@ -477,6 +478,14 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible } is_depth_prev = is_depth; } + bool is_depth_skip = (mpr->flag & WM_MANIPULATOR_SELECT_BACKGROUND) != 0; + if (is_depth_skip == is_depth_skip_prev) { + /* pass */ + } + else { + glDepthMask(!is_depth_skip); + is_depth_skip_prev = is_depth_skip; + } /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected manipulator part id */ @@ -489,6 +498,9 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible if (is_depth_prev) { glDisable(GL_DEPTH_TEST); } + if (is_depth_skip_prev) { + glDepthMask(true); + } } static int manipulator_find_intersected_3d_intern( -- cgit v1.2.3 From 5db8f6d18947a6d8534b8e5768ba779109a645ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 11 Jul 2018 18:20:14 +0200 Subject: Edit Mesh: Fix missing loose edges if vertex is at local origin --- source/blender/draw/modes/edit_mesh_mode.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 700132e0ee4..1e05b154974 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -147,7 +147,7 @@ static int EDIT_MESH_sh_index(ToolSettings *tsettings, RegionView3D *rv3d, bool return result; } -static char *EDIT_MESH_sh_defines(ToolSettings *tsettings, RegionView3D *rv3d, bool anti_alias) +static char *EDIT_MESH_sh_defines(ToolSettings *tsettings, RegionView3D *rv3d, bool anti_alias, bool looseedge) { const int selectmode = tsettings->selectmode; const int fast_mode = rv3d->rflag & RV3D_NAVIGATING; @@ -174,7 +174,10 @@ static char *EDIT_MESH_sh_defines(ToolSettings *tsettings, RegionView3D *rv3d, b if (anti_alias) { BLI_dynstr_append(ds, "#define ANTI_ALIASING\n"); } - BLI_dynstr_append(ds, "#define VERTEX_FACING\n"); + + if (!looseedge) { + BLI_dynstr_append(ds, "#define VERTEX_FACING\n"); + } str = BLI_dynstr_get_cstring(ds); BLI_dynstr_free(ds); @@ -198,7 +201,7 @@ static GPUShader *EDIT_MESH_ensure_shader(ToolSettings *tsettings, RegionView3D const int index = EDIT_MESH_sh_index(tsettings, rv3d, fast_mode); if (looseedge) { if (!e_data.overlay_loose_edge_sh_cache[index]) { - char *defines = EDIT_MESH_sh_defines(tsettings, rv3d, true); + char *defines = EDIT_MESH_sh_defines(tsettings, rv3d, true, true); char *lib = EDIT_MESH_sh_lib(); e_data.overlay_loose_edge_sh_cache[index] = DRW_shader_create_with_lib( datatoc_edit_mesh_overlay_vert_glsl, @@ -213,7 +216,7 @@ static GPUShader *EDIT_MESH_ensure_shader(ToolSettings *tsettings, RegionView3D } else { if (!e_data.overlay_tri_sh_cache[index]) { - char *defines = EDIT_MESH_sh_defines(tsettings, rv3d, true); + char *defines = EDIT_MESH_sh_defines(tsettings, rv3d, true, false); char *lib = EDIT_MESH_sh_lib(); e_data.overlay_tri_sh_cache[index] = DRW_shader_create_with_lib( datatoc_edit_mesh_overlay_vert_glsl, -- cgit v1.2.3 From 78988e175ae4904c043a6ca8499887b69c024c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 11 Jul 2018 18:33:35 +0200 Subject: Fix T55915 DOF Number of blades wrong logic Thanks @kostex for the fix. --- source/blender/makesrna/intern/rna_scene.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 68b1f5a74aa..0c734a8e7c7 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1982,12 +1982,15 @@ static void rna_GPUDOFSettings_blades_set(PointerRNA *ptr, const int value) { GPUDOFSettings *dofsettings = (GPUDOFSettings *)ptr->data; - if (value < 3 && dofsettings->num_blades > 2) - dofsettings->num_blades = 0; - else if (value > 0 && dofsettings->num_blades == 0) - dofsettings->num_blades = 3; - else + if (value == 1 || value == 2) { + if (dofsettings->num_blades == 0) { + dofsettings->num_blades = 3; + } else { + dofsettings->num_blades = 0; + } + } else { dofsettings->num_blades = value; + } } static void rna_GPUDOFSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) -- cgit v1.2.3 From ccfc66edec5c1fca3fb92c3aac4d9a5b710024d1 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 18:33:48 +0200 Subject: UI: Add missing Viewport Info to Overlay popover --- release/scripts/startup/bl_ui/space_view3d.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 92d9797b7ba..40eeb14761e 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4011,10 +4011,11 @@ class VIEW3D_PT_overlay_guides(Panel): split = col.split() sub = split.column() sub.prop(overlay, "show_cursor", text="3D Cursor") + sub = split.column() + sub.prop(overlay, "show_text", text="Viewport Info") if shading.type == 'MATERIAL': - sub = split.column() - sub.prop(overlay, "show_look_dev") + col.prop(overlay, "show_look_dev") class VIEW3D_PT_overlay_object(Panel): -- cgit v1.2.3 From 4299f62114ff1666002fe3037eda3a5c1954f206 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 18:38:39 +0200 Subject: UI: Re-arrange Overlay popover for Mesh Edit Mode Sub-panels for shading, measurement, normals, freestyle and developer. Less-used sub-panels will be collapsed by default once their implementation is complete (fixing spacing between sub-panels, adding the triangle to collapse, etc). Also added missing check for overlays on/off on existing sub-panels. --- release/scripts/startup/bl_ui/space_view3d.py | 231 ++++++++++++++++++++------ 1 file changed, 180 insertions(+), 51 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 40eeb14761e..08a88ece34e 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3986,6 +3986,7 @@ class VIEW3D_PT_overlay_guides(Panel): display_all = overlay.show_overlays col = layout.column() + col.active = display_all split = col.split() sub = split.column() @@ -4029,8 +4030,11 @@ class VIEW3D_PT_overlay_object(Panel): view = context.space_data overlay = view.overlay shading = view.shading + display_all = overlay.show_overlays col = layout.column(align=True) + col.active = display_all + split = col.split() sub = split.column(align=True) @@ -4055,8 +4059,10 @@ class VIEW3D_PT_overlay_geometry(Panel): view = context.space_data overlay = view.overlay shading = view.shading + display_all = overlay.show_overlays col = layout.column() + col.active = display_all row = col.row() row.prop(overlay, "show_wireframes", text="") @@ -4087,8 +4093,10 @@ class VIEW3D_PT_overlay_motion_tracking(Panel): def draw(self, context): layout = self.layout view = context.space_data + display_all = overlay.show_overlays col = layout.column() + col.active = display_all if view.show_reconstruction: split = col.split() @@ -4111,7 +4119,7 @@ class VIEW3D_PT_overlay_edit_mesh(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_parent_id = 'VIEW3D_PT_overlay' - bl_label = "Edit Mesh" + bl_label = "Mesh Edit Mode" @classmethod def poll(cls, context): @@ -4121,14 +4129,10 @@ class VIEW3D_PT_overlay_edit_mesh(Panel): layout = self.layout view = context.space_data - shading = view.shading overlay = view.overlay - tool_settings = context.tool_settings display_all = overlay.show_overlays data = context.active_object.data - statvis = tool_settings.statvis with_freestyle = bpy.app.build_options.freestyle - show_developer_ui = context.user_preferences.view.show_developer_ui col = layout.column() col.active = display_all @@ -4136,73 +4140,193 @@ class VIEW3D_PT_overlay_edit_mesh(Panel): split = col.split() sub = split.column() - sub.prop(data, "show_faces", text="Faces") sub.prop(data, "show_edges", text="Edges") - sub.prop(data, "show_edge_crease", text="Creases") - sub.prop(data, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural) - sub.prop(data, "show_edge_bevel_weight", text="Bevel") - if not with_freestyle: - sub.prop(data, "show_edge_seams", text="Seams") - sub = split.column() - sub.prop(overlay, "show_occlude_wire") - sub.prop(data, "show_extra_edge_length", text="Edge Length") - sub.prop(data, "show_extra_edge_angle", text="Edge Angle") - sub.prop(data, "show_extra_face_area", text="Face Area") - sub.prop(data, "show_extra_face_angle", text="Face Angle") + sub.prop(data, "show_faces", text="Faces") - if show_developer_ui: - sub.prop(data, "show_extra_indices", text="Indices") + row = col.row(align=True) + row.prop(data, "show_edge_crease", text="Creases", toggle=True) + row.prop(data, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural, toggle=True) + row.prop(data, "show_edge_bevel_weight", text="Bevel", toggle=True) - if with_freestyle: - col.label(text="Freestyle:") - row = col.row() - row.prop(data, "show_freestyle_edge_marks", text="Edge Marks") - row.prop(data, "show_freestyle_face_marks", text="Face Marks") + if not with_freestyle: row.prop(data, "show_edge_seams", text="Seams") - col.label(text="Normals:") - row = col.row(align=True) - row.prop(overlay, "show_vertex_normals", text="", icon='VERTEXSEL') - row.prop(overlay, "show_split_normals", text="", icon='LOOPSEL') - row.prop(overlay, "show_face_normals", text="", icon='FACESEL') +class VIEW3D_PT_overlay_edit_mesh_shading(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh' + bl_label = "Shading" - sub = row.row(align=True) - sub.active = overlay.show_vertex_normals or overlay.show_face_normals or overlay.show_split_normals - sub.prop(overlay, "normals_length", text="Size") + @classmethod + def poll(cls, context): + return context.mode == 'EDIT_MESH' + + def draw(self, context): + layout = self.layout + + view = context.space_data + overlay = view.overlay + tool_settings = context.tool_settings + display_all = overlay.show_overlays + data = context.active_object.data + statvis = tool_settings.statvis - col.prop(overlay, "show_weight") + col = layout.column() + col.active = display_all + + col.prop(overlay, "show_occlude_wire") + + col.prop(overlay, "show_weight", text="Vertex Group Weights") if overlay.show_weight: - col.label("Show Zero Weights:") - col.row().prop(tool_settings, "vertex_group_user", expand=True) + row = col.split() + row.label(text="Zero Weights") + row.prop(tool_settings, "vertex_group_user", text="") col.prop(data, "show_statvis", text="Mesh Analysis") if data.show_statvis: - sub = col.column() + col = col.column() + + sub = col.split() sub.active = data.show_statvis - sub.prop(statvis, "type") + sub.label(text="Type") + sub.prop(statvis, "type", text="") + statvis_type = statvis.type if statvis_type == 'OVERHANG': - row = sub.row(align=True) - row.prop(statvis, "overhang_min", text="") - row.prop(statvis, "overhang_max", text="") - sub.row().prop(statvis, "overhang_axis", expand=True) + row = col.row(align=True) + row.prop(statvis, "overhang_min", text="Minimum") + row.prop(statvis, "overhang_max", text="Maximum") + col.row().prop(statvis, "overhang_axis", expand=True) elif statvis_type == 'THICKNESS': - row = sub.row(align=True) - row.prop(statvis, "thickness_min", text="") - row.prop(statvis, "thickness_max", text="") - sub.prop(statvis, "thickness_samples") + row = col.row(align=True) + row.prop(statvis, "thickness_min", text="Minimum") + row.prop(statvis, "thickness_max", text="Maximum") + col.prop(statvis, "thickness_samples") elif statvis_type == 'INTERSECT': pass elif statvis_type == 'DISTORT': - row = sub.row(align=True) - row.prop(statvis, "distort_min", text="") - row.prop(statvis, "distort_max", text="") + row = col.row(align=True) + row.prop(statvis, "distort_min", text="Minimum") + row.prop(statvis, "distort_max", text="Maximum") elif statvis_type == 'SHARP': - row = sub.row(align=True) - row.prop(statvis, "sharp_min", text="") - row.prop(statvis, "sharp_max", text="") + row = col.row(align=True) + row.prop(statvis, "sharp_min", text="Minimum") + row.prop(statvis, "sharp_max", text="Maximum") + + +class VIEW3D_PT_overlay_edit_mesh_measurement(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh' + bl_label = "Measurement" + + @classmethod + def poll(cls, context): + return context.mode == 'EDIT_MESH' + + def draw(self, context): + layout = self.layout + + view = context.space_data + overlay = view.overlay + display_all = overlay.show_overlays + data = context.active_object.data + + col = layout.column() + col.active = display_all + + split = col.split() + + sub = split.column() + sub.prop(data, "show_extra_edge_length", text="Edge Length") + sub.prop(data, "show_extra_edge_angle", text="Edge Angle") + + sub = split.column() + sub.prop(data, "show_extra_face_area", text="Face Area") + sub.prop(data, "show_extra_face_angle", text="Face Angle") + + +class VIEW3D_PT_overlay_edit_mesh_normals(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh' + bl_label = "Normals" + + @classmethod + def poll(cls, context): + return context.mode == 'EDIT_MESH' + + def draw(self, context): + layout = self.layout + + view = context.space_data + overlay = view.overlay + display_all = overlay.show_overlays + + col = layout.column() + col.active = display_all + + row = col.row(align=True) + row.prop(overlay, "show_vertex_normals", text="", icon='VERTEXSEL') + row.prop(overlay, "show_split_normals", text="", icon='LOOPSEL') + row.prop(overlay, "show_face_normals", text="", icon='FACESEL') + + sub = row.row(align=True) + sub.active = overlay.show_vertex_normals or overlay.show_face_normals or overlay.show_split_normals + sub.prop(overlay, "normals_length", text="Size") + + +class VIEW3D_PT_overlay_edit_mesh_freestyle(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay' + bl_label = "Freestyle" + + @classmethod + def poll(cls, context): + return context.mode == 'EDIT_MESH' and bpy.app.build_options.freestyle + + def draw(self, context): + layout = self.layout + + view = context.space_data + overlay = view.overlay + display_all = overlay.show_overlays + data = context.active_object.data + + col = layout.column() + col.active = display_all + + row = col.row() + row.prop(data, "show_freestyle_edge_marks", text="Edge Marks") + row.prop(data, "show_freestyle_face_marks", text="Face Marks") + row.prop(data, "show_edge_seams", text="Seams") + + +class VIEW3D_PT_overlay_edit_mesh_developer(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay_edit_mesh' + bl_label = "Developer" + + @classmethod + def poll(cls, context): + return context.mode == 'EDIT_MESH' and context.user_preferences.view.show_developer_ui + + def draw(self, context): + layout = self.layout + + view = context.space_data + overlay = view.overlay + display_all = overlay.show_overlays + data = context.active_object.data + + col = layout.column() + col.active = display_all + + col.prop(data, "show_extra_indices", text="Indices") class VIEW3D_PT_overlay_edit_curve(Panel): @@ -4684,6 +4808,11 @@ classes = ( VIEW3D_PT_overlay_geometry, VIEW3D_PT_overlay_motion_tracking, VIEW3D_PT_overlay_edit_mesh, + VIEW3D_PT_overlay_edit_mesh_shading, + VIEW3D_PT_overlay_edit_mesh_measurement, + VIEW3D_PT_overlay_edit_mesh_normals, + VIEW3D_PT_overlay_edit_mesh_freestyle, + VIEW3D_PT_overlay_edit_mesh_developer, VIEW3D_PT_overlay_edit_curve, VIEW3D_PT_overlay_edit_armature, VIEW3D_PT_overlay_pose, -- cgit v1.2.3 From 960784e719364f418f5858cf7aad555f3ba06889 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 18:46:08 +0200 Subject: UI: Overlay panel fix for display_all --- release/scripts/startup/bl_ui/space_view3d.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 08a88ece34e..a132983dbb9 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4058,7 +4058,6 @@ class VIEW3D_PT_overlay_geometry(Panel): layout = self.layout view = context.space_data overlay = view.overlay - shading = view.shading display_all = overlay.show_overlays col = layout.column() @@ -4071,6 +4070,8 @@ class VIEW3D_PT_overlay_geometry(Panel): sub.prop(overlay, "wireframe_threshold", text="Wireframe") col = layout.column(align=True) + col.active = display_all + split = col.split() sub = split.column(align=True) sub.prop(overlay, "show_backface_culling") @@ -4093,6 +4094,7 @@ class VIEW3D_PT_overlay_motion_tracking(Panel): def draw(self, context): layout = self.layout view = context.space_data + overlay = view.overlay display_all = overlay.show_overlays col = layout.column() -- cgit v1.2.3 From 9bf1868eaebc3bed10cc360f13f858e7b4321159 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 18:54:42 +0200 Subject: UI: Rename Bone Select to Fade Geometry in Overlay popover Part of design: T55863 --- release/scripts/startup/bl_ui/space_view3d.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index a132983dbb9..b04c695d6cf 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4398,11 +4398,12 @@ class VIEW3D_PT_overlay_pose(Panel): col = layout.column() col.active = display_all col.prop(overlay, "show_transparent_bones") - row = col.split(0.65) - row.prop(overlay, "show_bone_select") - sub = row.column() + + row = col.row() + row.prop(overlay, "show_bone_select", text="") + sub = row.row() sub.active = display_all and overlay.show_bone_select - sub.prop(overlay, "bone_select_alpha", text="") + sub.prop(overlay, "bone_select_alpha", text="Fade Geometry") class VIEW3D_PT_overlay_edit_armature(Panel): -- cgit v1.2.3 From 4e9d039ef70e7593160396b526745c7136cfb85d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 18:51:04 +0200 Subject: 3D View: option not to draw center dots While this is a fairly obscure option, it means it's possible to disable all overlays except for any overlays the users wants to see. --- release/scripts/startup/bl_ui/space_view3d.py | 5 ++++- source/blender/draw/modes/object_mode.c | 4 ++++ source/blender/makesdna/DNA_view3d_types.h | 1 + source/blender/makesrna/intern/rna_space.c | 7 ++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index b04c695d6cf..c8a1a9c8ef1 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4045,7 +4045,10 @@ class VIEW3D_PT_overlay_object(Panel): sub = split.column(align=True) sub.prop(overlay, "show_bones", text="Bones") sub.prop(overlay, "show_motion_paths") - sub.prop(overlay, "show_all_objects_origin") + sub.prop(overlay, "show_object_origins") + subsub = sub.column() + subsub.active = overlay.show_object_origins + subsub.prop(overlay, "show_object_origins_all") class VIEW3D_PT_overlay_geometry(Panel): diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 2a6a7fae612..6c99024312c 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1975,6 +1975,10 @@ static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob) static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob, ViewLayer *view_layer, View3D *v3d) { + if (v3d->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_ORIGINS) { + return; + } + const bool is_library = ob->id.us > 1 || ID_IS_LINKED(ob); DRWShadingGroup *shgroup; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 365fe125e83..e0ab3a744f1 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -388,6 +388,7 @@ enum { V3D_OVERLAY_ONION_SKINS = (1 << 7), V3D_OVERLAY_HIDE_BONES = (1 << 8), V3D_OVERLAY_HIDE_OBJECT_XTRAS = (1 << 9), + V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10), }; /* View3DOverlay->edit_flag */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index b24a9fbeffd..c3378a68884 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2609,7 +2609,12 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) "Show an outline highlight around selected objects in non-wireframe views"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_all_objects_origin", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_object_origins", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_OBJECT_ORIGINS); + RNA_def_property_ui_text(prop, "Object Origins", "Show object center dots"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_object_origins_all", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_DRAW_CENTERS); RNA_def_property_ui_text(prop, "All Object Origins", "Show the object origin center dot for all (selected and unselected) objects"); -- cgit v1.2.3 From c643f02b072064c4a0fa4cc16873c42dbb080399 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 19:00:54 +0200 Subject: UI: Fix Seams button drawing differently --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c8a1a9c8ef1..fa7cb2fa38b 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4155,7 +4155,7 @@ class VIEW3D_PT_overlay_edit_mesh(Panel): row.prop(data, "show_edge_bevel_weight", text="Bevel", toggle=True) if not with_freestyle: - row.prop(data, "show_edge_seams", text="Seams") + row.prop(data, "show_edge_seams", text="Seams", toggle=True) class VIEW3D_PT_overlay_edit_mesh_shading(Panel): -- cgit v1.2.3 From 4b57bb0387753f574b3965c461cb55dc0dfa624c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 19:00:24 +0200 Subject: UI: overlay, remove redundant 'object' term --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index fa7cb2fa38b..0581cc6044a 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4045,10 +4045,10 @@ class VIEW3D_PT_overlay_object(Panel): sub = split.column(align=True) sub.prop(overlay, "show_bones", text="Bones") sub.prop(overlay, "show_motion_paths") - sub.prop(overlay, "show_object_origins") + sub.prop(overlay, "show_object_origins", text="Origins") subsub = sub.column() subsub.active = overlay.show_object_origins - subsub.prop(overlay, "show_object_origins_all") + subsub.prop(overlay, "show_object_origins_all", text="Origins (All)") class VIEW3D_PT_overlay_geometry(Panel): -- cgit v1.2.3 From 4880b71d54e3a0f7fbc564bd769e311532370de9 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 11 Jul 2018 20:10:27 +0200 Subject: UI: Flip Overlays/Shading position This brings the Object Visibility dropdown closer to overlays which also controls visibility of elements int he viewport, so it makes more sense there. Also placing the Overlays settings closer to the viewport. --- release/scripts/startup/bl_ui/space_view3d.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 0581cc6044a..d6e04eca72d 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -217,20 +217,18 @@ class VIEW3D_HT_header(Header): text="", ) - row = layout.row(align=True) - row.prop(shading, "type", text="", expand=True) - - sub = row.row(align=True) - sub.enabled = shading.type != 'RENDERED' - sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading") - row = layout.row(align=True) row.prop(overlay, "show_overlays", icon='WIRE', text="") - sub = row.row(align=True) sub.active = overlay.show_overlays sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay") + row = layout.row(align=True) + row.prop(shading, "type", text="", expand=True) + sub = row.row(align=True) + sub.enabled = shading.type != 'RENDERED' + sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading") + class VIEW3D_MT_editor_menus(Menu): bl_space_type = 'VIEW3D_MT_editor_menus' -- cgit v1.2.3 From e3c85aaca74fc7bd2a9da43a0396a886363bc93d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 20:23:19 +0200 Subject: Manipulator: expose use_select_background via RNA --- source/blender/makesrna/intern/rna_wm_manipulator.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c index 6d9a4bbe6c9..f1abaa73e70 100644 --- a/source/blender/makesrna/intern/rna_wm_manipulator.c +++ b/source/blender/makesrna/intern/rna_wm_manipulator.c @@ -405,6 +405,7 @@ RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_MANIPUL RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE); RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN); RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_MANIPULATOR_GRAB_CURSOR); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_MANIPULATOR_SELECT_BACKGROUND); /* wmManipulator.state */ RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT); @@ -1135,6 +1136,12 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) prop, "rna_Manipulator_flag_use_draw_scale_get", "rna_Manipulator_flag_use_draw_scale_set"); RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix"); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_SELECT_BACKGROUND */ + prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_select_background_get", "rna_Manipulator_flag_use_select_background_set"); + RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); /* wmManipulator.state (readonly) */ /* WM_MANIPULATOR_STATE_HIGHLIGHT */ -- cgit v1.2.3 From b843753ad56a89035faeeb94dbeb39060c0c9630 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 11 Jul 2018 21:30:37 +0200 Subject: Buildbot: initial configuration for Visual Studio 2017. --- build_files/buildbot/slave_compile.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index ff19bcce758..c43bb88b270 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -78,7 +78,13 @@ if 'cmake' in builder: # cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc') elif builder.startswith('win'): - if builder.endswith('_vc2015'): + if builder.endswith('_vc2017'): + if builder.startswith('win64'): + cmake_options.extend(['-G', 'Visual Studio 15 2017 Win64']) + elif builder.startswith('win32'): + bits = 32 + cmake_options.extend(['-G', 'Visual Studio 15 2017']) + elif builder.endswith('_vc2015'): if builder.startswith('win64'): cmake_options.extend(['-G', 'Visual Studio 14 2015 Win64']) elif builder.startswith('win32'): -- cgit v1.2.3 From 09aa799e5331a9da666f8a6325b038a866b1f35d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 22:18:09 +0200 Subject: PyAPI: Use annotations for RNA definitions - Logical use of fields since they define type information. - Avoids using ordered-dict metaclass. Properties using regular assignments will print a warning and load, however the order is undefined. --- intern/cycles/blender/addon/properties.py | 28 +-- release/scripts/modules/bpy_extras/io_utils.py | 22 +- .../scripts/modules/bpy_extras/keyconfig_utils.py | 1 + release/scripts/modules/bpy_extras/object_utils.py | 6 +- release/scripts/modules/bpy_types.py | 32 +-- .../scripts/startup/bl_operators/add_mesh_torus.py | 16 +- release/scripts/startup/bl_operators/anim.py | 30 +-- release/scripts/startup/bl_operators/clip.py | 2 +- release/scripts/startup/bl_operators/console.py | 4 +- release/scripts/startup/bl_operators/file.py | 40 ++-- release/scripts/startup/bl_operators/freestyle.py | 8 +- release/scripts/startup/bl_operators/image.py | 2 +- release/scripts/startup/bl_operators/mesh.py | 4 +- release/scripts/startup/bl_operators/node.py | 12 +- release/scripts/startup/bl_operators/object.py | 29 ++- .../scripts/startup/bl_operators/object_align.py | 8 +- .../startup/bl_operators/object_quick_effects.py | 32 +-- .../bl_operators/object_randomize_transform.py | 20 +- release/scripts/startup/bl_operators/presets.py | 25 +-- release/scripts/startup/bl_operators/rigidbody.py | 12 +- release/scripts/startup/bl_operators/sequencer.py | 2 +- .../startup/bl_operators/uvcalc_follow_active.py | 2 +- .../startup/bl_operators/uvcalc_lightmap.py | 14 +- .../startup/bl_operators/uvcalc_smart_project.py | 10 +- .../startup/bl_operators/vertexpaint_dirt.py | 10 +- release/scripts/startup/bl_operators/view3d.py | 12 +- release/scripts/startup/bl_operators/wm.py | 226 +++++++++++---------- release/scripts/templates_py/addon_add_object.py | 2 +- release/scripts/templates_py/custom_nodes.py | 13 +- .../scripts/templates_py/manipulator_operator.py | 4 +- .../scripts/templates_py/operator_file_export.py | 6 +- .../scripts/templates_py/operator_file_import.py | 6 +- release/scripts/templates_py/operator_mesh_add.py | 14 +- release/scripts/templates_py/operator_modal.py | 4 +- .../scripts/templates_py/operator_modal_view3d.py | 2 +- release/scripts/templates_py/ui_list.py | 6 +- source/blender/python/intern/bpy_intern_string.c | 4 +- source/blender/python/intern/bpy_intern_string.h | 2 +- source/blender/python/intern/bpy_rna.c | 33 +-- 39 files changed, 339 insertions(+), 366 deletions(-) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 85947b4bd28..51e887d08ca 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -17,12 +17,14 @@ # import bpy -from bpy.props import (BoolProperty, - EnumProperty, - FloatProperty, - IntProperty, - PointerProperty, - StringProperty) +from bpy.props import ( + BoolProperty, + EnumProperty, + FloatProperty, + IntProperty, + PointerProperty, + StringProperty, +) # enums @@ -1198,12 +1200,14 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup): def unregister(cls): del bpy.types.Scene.cycles_curves + def update_render_passes(self, context): scene = context.scene rd = scene.render view_layer = context.view_layer view_layer.update_render_passes() + class CyclesRenderLayerSettings(bpy.types.PropertyGroup): @classmethod def register(cls): @@ -1358,13 +1362,13 @@ class CyclesPreferences(bpy.types.AddonPreferences): list.append(('OPENCL', "OpenCL", "Use OpenCL for GPU acceleration", 2)) return list - compute_device_type = EnumProperty( - name="Compute Device Type", - description="Device to use for computation (rendering with Cycles)", - items=get_device_types, - ) + compute_device_type: EnumProperty( + name="Compute Device Type", + description="Device to use for computation (rendering with Cycles)", + items=get_device_types, + ) - devices = bpy.props.CollectionProperty(type=CyclesDeviceSettings) + devices: bpy.props.CollectionProperty(type=CyclesDeviceSettings) def find_existing_device_entry(self, device): for device_entry in self.devices: diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index e2c2e4c9b93..a0c1c3e5c84 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -52,25 +52,19 @@ def _check_axis_conversion(op): class ExportHelper: - filepath = StringProperty( + filepath: StringProperty( name="File Path", description="Filepath used for exporting the file", maxlen=1024, subtype='FILE_PATH', ) - check_existing = BoolProperty( + check_existing: BoolProperty( name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'}, ) - # needed for mix-ins - order = [ - "filepath", - "check_existing", - ] - # subclasses can override with decorator # True == use ext, False == no ext, None == do nothing. check_extension = True @@ -112,18 +106,13 @@ class ExportHelper: class ImportHelper: - filepath = StringProperty( + filepath: StringProperty( name="File Path", description="Filepath used for importing the file", maxlen=1024, subtype='FILE_PATH', ) - # needed for mix-ins - order = [ - "filepath", - ] - def invoke(self, context, event): context.window_manager.fileselect_add(self) return {'RUNNING_MODAL'} @@ -173,11 +162,6 @@ def orientation_helper_factory(name, axis_forward='Y', axis_up='Z'): update=_update_axis_up, ) - members["order"] = [ - "axis_forward", - "axis_up", - ] - return type(name, (object,), members) diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index a078da2ff2f..7e5e1fb855c 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -406,6 +406,7 @@ def keyconfig_test(kc): result = True return result + # Note, we may eventually replace existing logic with this # so key configs are always data. from .keyconfig_utils_experimental import ( diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index fcecb4cdd61..7719e2f6e30 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -194,16 +194,16 @@ class AddObjectHelper: if not self.view_align: self.rotation.zero() - view_align = BoolProperty( + view_align: BoolProperty( name="Align to View", default=False, update=view_align_update_callback, ) - location = FloatVectorProperty( + location: FloatVectorProperty( name="Location", subtype='TRANSLATION', ) - rotation = FloatVectorProperty( + rotation: FloatVectorProperty( name="Rotation", subtype='EULER', ) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index c4bf8422d3f..b317ae18955 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -568,39 +568,13 @@ class RNAMeta(type): return "bl_rna" in cls.__dict__ -class OrderedDictMini(dict): - - def __init__(self, *args): - self.order = [] - dict.__init__(self, args) - - def __setitem__(self, key, val): - dict.__setitem__(self, key, val) - if key not in self.order: - self.order.append(key) - - def __delitem__(self, key): - dict.__delitem__(self, key) - self.order.remove(key) - - class RNAMetaPropGroup(StructMetaPropGroup, RNAMeta): pass -class OrderedMeta(RNAMeta): - - def __init__(cls, name, bases, attributes): - if attributes.__class__ is OrderedDictMini: - cls.order = attributes.order - - def __prepare__(name, bases, **kwargs): - return OrderedDictMini() # collections.OrderedDict() - - # Same as 'Operator' # only without 'as_keywords' -class Manipulator(StructRNA, metaclass=OrderedMeta): +class Manipulator(StructRNA): __slots__ = () def __getattribute__(self, attr): @@ -700,7 +674,7 @@ class Manipulator(StructRNA, metaclass=OrderedMeta): # Only defined so operators members can be used by accessing self.order # with doc generation 'self.properties.bl_rna.properties' can fail -class Operator(StructRNA, metaclass=OrderedMeta): +class Operator(StructRNA): __slots__ = () def __getattribute__(self, attr): @@ -732,7 +706,7 @@ class Operator(StructRNA, metaclass=OrderedMeta): if attr not in ignore} -class Macro(StructRNA, metaclass=OrderedMeta): +class Macro(StructRNA): # bpy_types is imported before ops is defined # so we have to do a local import on each run __slots__ = () diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index cc7f69ca7ca..4460af173ff 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -134,19 +134,19 @@ class AddTorus(Operator, object_utils.AddObjectHelper): self.abso_major_rad = self.major_radius + self.minor_radius self.abso_minor_rad = self.major_radius - self.minor_radius - major_segments = IntProperty( + major_segments: IntProperty( name="Major Segments", description="Number of segments for the main ring of the torus", min=3, max=256, default=48, ) - minor_segments = IntProperty( + minor_segments: IntProperty( name="Minor Segments", description="Number of segments for the minor ring of the torus", min=3, max=256, default=12, ) - mode = bpy.props.EnumProperty( + mode: bpy.props.EnumProperty( name="Torus Dimensions", items=(("MAJOR_MINOR", "Major/Minor", "Use the major/minor radii for torus dimensions"), @@ -154,7 +154,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper): "Use the exterior/interior radii for torus dimensions")), update=mode_update_callback, ) - major_radius = FloatProperty( + major_radius: FloatProperty( name="Major Radius", description=("Radius from the origin to the " "center of the cross sections"), @@ -163,7 +163,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper): subtype='DISTANCE', unit='LENGTH', ) - minor_radius = FloatProperty( + minor_radius: FloatProperty( name="Minor Radius", description="Radius of the torus' cross section", min=0.01, max=100.0, @@ -171,7 +171,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper): subtype='DISTANCE', unit='LENGTH', ) - abso_major_rad = FloatProperty( + abso_major_rad: FloatProperty( name="Exterior Radius", description="Total Exterior Radius of the torus", min=0.01, max=100.0, @@ -179,7 +179,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper): subtype='DISTANCE', unit='LENGTH', ) - abso_minor_rad = FloatProperty( + abso_minor_rad: FloatProperty( name="Interior Radius", description="Total Interior Radius of the torus", min=0.01, max=100.0, @@ -187,7 +187,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper): subtype='DISTANCE', unit='LENGTH', ) - generate_uvs = BoolProperty( + generate_uvs: BoolProperty( name="Generate UVs", description="Generate a default UV map", default=False, diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index d898239d7a9..31325cf0b50 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -40,20 +40,20 @@ class ANIM_OT_keying_set_export(Operator): bl_idname = "anim.keying_set_export" bl_label = "Export Keying Set..." - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( name="Filter folders", default=True, options={'HIDDEN'}, ) - filter_text = BoolProperty( + filter_text: BoolProperty( name="Filter text", default=True, options={'HIDDEN'}, ) - filter_python = BoolProperty( + filter_python: BoolProperty( name="Filter python", default=True, options={'HIDDEN'}, @@ -203,51 +203,51 @@ class BakeAction(Operator): bl_label = "Bake Action" bl_options = {'REGISTER', 'UNDO'} - frame_start = IntProperty( + frame_start: IntProperty( name="Start Frame", description="Start frame for baking", min=0, max=300000, default=1, ) - frame_end = IntProperty( + frame_end: IntProperty( name="End Frame", description="End frame for baking", min=1, max=300000, default=250, ) - step = IntProperty( + step: IntProperty( name="Frame Step", description="Frame Step", min=1, max=120, default=1, ) - only_selected = BoolProperty( + only_selected: BoolProperty( name="Only Selected Bones", description="Only key selected bones (Pose baking only)", default=True, ) - visual_keying = BoolProperty( + visual_keying: BoolProperty( name="Visual Keying", description="Keyframe from the final transformations (with constraints applied)", default=False, ) - clear_constraints = BoolProperty( + clear_constraints: BoolProperty( name="Clear Constraints", description="Remove all constraints from keyed object/bones, and do 'visual' keying", default=False, ) - clear_parents = BoolProperty( + clear_parents: BoolProperty( name="Clear Parents", description="Bake animation onto the object then clear parents (objects only)", default=False, ) - use_current_action = BoolProperty( + use_current_action: BoolProperty( name="Overwrite Current Action", description="Bake animation into current action, instead of creating a new one " "(useful for baking only part of bones in an armature)", default=False, ) - bake_types = EnumProperty( + bake_types: EnumProperty( name="Bake Data", description="Which data's transformations to bake", options={'ENUM_FLAG'}, @@ -302,7 +302,7 @@ class ClearUselessActions(Operator): bl_label = "Clear Useless Actions" bl_options = {'REGISTER', 'UNDO'} - only_unused = BoolProperty( + only_unused: BoolProperty( name="Only Unused", description="Only unused (Fake User only) actions get considered", default=True, @@ -341,7 +341,7 @@ class UpdateAnimatedTransformConstraint(Operator): bl_label = "Update Animated Transform Constraints" bl_options = {'REGISTER', 'UNDO'} - use_convert_to_radians = BoolProperty( + use_convert_to_radians: BoolProperty( name="Convert To Radians", description="Convert fcurves/drivers affecting rotations to radians (Warning: use this only once!)", default=True, diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index 95c4bbbfba9..2717a4f62a3 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -133,7 +133,7 @@ class CLIP_OT_filter_tracks(bpy.types.Operator): bl_idname = "clip.filter_tracks" bl_options = {'UNDO', 'REGISTER'} - track_threshold = FloatProperty( + track_threshold: FloatProperty( name="Track Threshold", description="Filter Threshold to select problematic tracks", default=5.0, diff --git a/release/scripts/startup/bl_operators/console.py b/release/scripts/startup/bl_operators/console.py index 2d32f84805e..b62b9310224 100644 --- a/release/scripts/startup/bl_operators/console.py +++ b/release/scripts/startup/bl_operators/console.py @@ -37,7 +37,7 @@ class ConsoleExec(Operator): bl_idname = "console.execute" bl_label = "Console Execute" - interactive = BoolProperty( + interactive: BoolProperty( options={'SKIP_SAVE'}, ) @@ -137,7 +137,7 @@ class ConsoleLanguage(Operator): bl_idname = "console.language" bl_label = "Console Language" - language = StringProperty( + language: StringProperty( name="Language", maxlen=32, ) diff --git a/release/scripts/startup/bl_operators/file.py b/release/scripts/startup/bl_operators/file.py index cf03b4fccdb..44948879fe6 100644 --- a/release/scripts/startup/bl_operators/file.py +++ b/release/scripts/startup/bl_operators/file.py @@ -37,56 +37,56 @@ class WM_OT_previews_batch_generate(Operator): # ----------- # File props. - files = CollectionProperty( + files: CollectionProperty( type=bpy.types.OperatorFileListElement, options={'HIDDEN', 'SKIP_SAVE'}, ) - directory = StringProperty( + directory: StringProperty( maxlen=1024, subtype='FILE_PATH', options={'HIDDEN', 'SKIP_SAVE'}, ) # Show only images/videos, and directories! - filter_blender = BoolProperty( + filter_blender: BoolProperty( default=True, options={'HIDDEN', 'SKIP_SAVE'}, ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( default=True, options={'HIDDEN', 'SKIP_SAVE'}, ) # ----------- # Own props. - use_scenes = BoolProperty( + use_scenes: BoolProperty( default=True, name="Scenes", description="Generate scenes' previews", ) - use_collections = BoolProperty( + use_collections: BoolProperty( default=True, name="Collections", description="Generate collections' previews", ) - use_objects = BoolProperty( + use_objects: BoolProperty( default=True, name="Objects", description="Generate objects' previews", ) - use_intern_data = BoolProperty( + use_intern_data: BoolProperty( default=True, name="Mat/Tex/...", description="Generate 'internal' previews (materials, textures, images, etc.)", ) - use_trusted = BoolProperty( + use_trusted: BoolProperty( default=False, name="Trusted Blend Files", description="Enable python evaluation for selected files", ) - use_backups = BoolProperty( + use_backups: BoolProperty( default=True, name="Save Backups", description="Keep a backup (.blend1) version of the files when saving with generated previews", @@ -147,56 +147,56 @@ class WM_OT_previews_batch_clear(Operator): # ----------- # File props. - files = CollectionProperty( + files: CollectionProperty( type=bpy.types.OperatorFileListElement, options={'HIDDEN', 'SKIP_SAVE'}, ) - directory = StringProperty( + directory: StringProperty( maxlen=1024, subtype='FILE_PATH', options={'HIDDEN', 'SKIP_SAVE'}, ) # Show only images/videos, and directories! - filter_blender = BoolProperty( + filter_blender: BoolProperty( default=True, options={'HIDDEN', 'SKIP_SAVE'}, ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( default=True, options={'HIDDEN', 'SKIP_SAVE'}, ) # ----------- # Own props. - use_scenes = BoolProperty( + use_scenes: BoolProperty( default=True, name="Scenes", description="Clear scenes' previews", ) - use_collections = BoolProperty( + use_collections: BoolProperty( default=True, name="Collections", description="Clear collections' previews", ) - use_objects = BoolProperty( + use_objects: BoolProperty( default=True, name="Objects", description="Clear objects' previews", ) - use_intern_data = BoolProperty( + use_intern_data: BoolProperty( default=True, name="Mat/Tex/...", description="Clear 'internal' previews (materials, textures, images, etc.)", ) - use_trusted = BoolProperty( + use_trusted: BoolProperty( default=False, name="Trusted Blend Files", description="Enable python evaluation for selected files", ) - use_backups = BoolProperty( + use_backups: BoolProperty( default=True, name="Save Backups", description="Keep a backup (.blend1) version of the files when saving with cleared previews", diff --git a/release/scripts/startup/bl_operators/freestyle.py b/release/scripts/startup/bl_operators/freestyle.py index 88368792b8b..894808de3ed 100644 --- a/release/scripts/startup/bl_operators/freestyle.py +++ b/release/scripts/startup/bl_operators/freestyle.py @@ -34,13 +34,13 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator): bl_label = "Fill Range by Selection" bl_options = {'INTERNAL'} - type = EnumProperty( + type: EnumProperty( name="Type", description="Type of the modifier to work on", items=(("COLOR", "Color", "Color modifier type"), ("ALPHA", "Alpha", "Alpha modifier type"), ("THICKNESS", "Thickness", "Thickness modifier type")), ) - name = StringProperty( + name: StringProperty( name="Name", description="Name of the modifier to work on", ) @@ -198,9 +198,9 @@ class SCENE_OT_freestyle_module_open(bpy.types.Operator): bl_label = "Open Style Module File" bl_options = {'INTERNAL'} - filepath = StringProperty(subtype='FILE_PATH') + filepath: StringProperty(subtype='FILE_PATH') - make_internal = BoolProperty( + make_internal: BoolProperty( name="Make internal", description="Make module file internal after loading", default=True) diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 5c5ca329cda..28e5e59d780 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -29,7 +29,7 @@ class EditExternally(Operator): bl_label = "Image Edit Externally" bl_options = {'REGISTER'} - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', ) diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index f07c1ccb549..a7475dcc6ef 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -33,7 +33,7 @@ class MeshMirrorUV(Operator): bl_label = "Copy Mirrored UV coords" bl_options = {'REGISTER', 'UNDO'} - direction = EnumProperty( + direction: EnumProperty( name="Axis Direction", items=( ('POSITIVE', "Positive", ""), @@ -41,7 +41,7 @@ class MeshMirrorUV(Operator): ), ) - precision = IntProperty( + precision: IntProperty( name="Precision", description=("Tolerance for finding vertex duplicates"), min=1, max=16, diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py index bb8f991e526..fbebee2d8a1 100644 --- a/release/scripts/startup/bl_operators/node.py +++ b/release/scripts/startup/bl_operators/node.py @@ -34,7 +34,7 @@ from bpy.props import ( class NodeSetting(PropertyGroup): - value = StringProperty( + value: StringProperty( name="Value", description="Python expression to be evaluated " "as the initial node setting", @@ -45,16 +45,16 @@ class NodeSetting(PropertyGroup): # Base class for node 'Add' operators class NodeAddOperator: - type = StringProperty( + type: StringProperty( name="Node Type", description="Node type", ) - use_transform = BoolProperty( + use_transform: BoolProperty( name="Use Transform", description="Start transform operator after inserting the node", default=False, ) - settings = CollectionProperty( + settings: CollectionProperty( name="Settings", description="Settings to be applied on the newly created node", type=NodeSetting, @@ -152,7 +152,7 @@ class NODE_OT_add_and_link_node(NodeAddOperator, Operator): bl_label = "Add and Link Node" bl_options = {'REGISTER', 'UNDO'} - link_socket_index = IntProperty( + link_socket_index: IntProperty( name="Link Socket Index", description="Index of the socket to link", ) @@ -210,7 +210,7 @@ class NODE_OT_add_search(NodeAddOperator, Operator): return item return None - node_item = EnumProperty( + node_item: EnumProperty( name="Node Type", description="Node type", items=node_enum_items, diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index fb321463d33..be379ec6089 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -35,19 +35,19 @@ class SelectPattern(Operator): bl_label = "Select Pattern" bl_options = {'REGISTER', 'UNDO'} - pattern = StringProperty( + pattern: StringProperty( name="Pattern", description="Name filter using '*', '?' and " "'[abc]' unix style wildcards", maxlen=64, default="*", ) - case_sensitive = BoolProperty( + case_sensitive: BoolProperty( name="Case Sensitive", description="Do a case sensitive compare", default=False, ) - extend = BoolProperty( + extend: BoolProperty( name="Extend", description="Extend the existing selection", default=True, @@ -115,7 +115,7 @@ class SelectCamera(Operator): bl_label = "Select Camera" bl_options = {'REGISTER', 'UNDO'} - extend = BoolProperty( + extend: BoolProperty( name="Extend", description="Extend the selection", default=False @@ -152,15 +152,15 @@ class SelectHierarchy(Operator): bl_label = "Select Hierarchy" bl_options = {'REGISTER', 'UNDO'} - direction = EnumProperty( + direction: EnumProperty( items=(('PARENT', "Parent", ""), ('CHILD', "Child", ""), ), name="Direction", description="Direction to select in the hierarchy", - default='PARENT') - - extend = BoolProperty( + default='PARENT', + ) + extend: BoolProperty( name="Extend", description="Extend the existing selection", default=False, @@ -221,14 +221,13 @@ class SubdivisionSet(Operator): bl_label = "Subdivision Set" bl_options = {'REGISTER', 'UNDO'} - level = IntProperty( + level: IntProperty( name="Level", min=-100, max=100, soft_min=-6, soft_max=6, default=1, ) - - relative = BoolProperty( + relative: BoolProperty( name="Relative", description=("Apply the subsurf level as an offset " "relative to the current level"), @@ -312,7 +311,7 @@ class ShapeTransfer(Operator): bl_label = "Transfer Shape Key" bl_options = {'REGISTER', 'UNDO'} - mode = EnumProperty( + mode: EnumProperty( items=(('OFFSET', "Offset", "Apply the relative positional offset", @@ -330,7 +329,7 @@ class ShapeTransfer(Operator): description="Relative shape positions to the new shape method", default='OFFSET', ) - use_clamp = BoolProperty( + use_clamp: BoolProperty( name="Clamp Offset", description=("Clamp the transformation to the distance each " "vertex moves in the original shape"), @@ -696,7 +695,7 @@ class TransformsToDeltas(Operator): bl_label = "Transforms to Deltas" bl_options = {'REGISTER', 'UNDO'} - mode = EnumProperty( + mode: EnumProperty( items=( ('ALL', "All Transforms", "Transfer location, rotation, and scale transforms"), ('LOC', "Location", "Transfer location transforms only"), @@ -707,7 +706,7 @@ class TransformsToDeltas(Operator): description="Which transforms to transfer", default='ALL', ) - reset_values = BoolProperty( + reset_values: BoolProperty( name="Reset Values", description=("Clear transform values after transferring to deltas"), default=True, diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index 11c1514e4bf..f627fd30162 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -363,7 +363,7 @@ class AlignObjects(Operator): bl_label = "Align Objects" bl_options = {'REGISTER', 'UNDO'} - bb_quality = BoolProperty( + bb_quality: BoolProperty( name="High Quality", description=( "Enables high quality calculation of the " @@ -372,7 +372,7 @@ class AlignObjects(Operator): ), default=True, ) - align_mode = EnumProperty( + align_mode: EnumProperty( name="Align Mode:", description="Side of object to use for alignment", items=( @@ -382,7 +382,7 @@ class AlignObjects(Operator): ), default='OPT_2', ) - relative_to = EnumProperty( + relative_to: EnumProperty( name="Relative To:", description="Reference location to align to", items=( @@ -393,7 +393,7 @@ class AlignObjects(Operator): ), default='OPT_4', ) - align_axis = EnumProperty( + align_axis: EnumProperty( name="Align", description="Align to axis", items=( diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index f087022b6fd..36dc1b46590 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -52,7 +52,7 @@ class QuickFur(Operator): bl_label = "Quick Fur" bl_options = {'REGISTER', 'UNDO'} - density = EnumProperty( + density: EnumProperty( name="Fur Density", items=( ('LIGHT', "Light", ""), @@ -61,13 +61,13 @@ class QuickFur(Operator): ), default='MEDIUM', ) - view_percentage = IntProperty( + view_percentage: IntProperty( name="View %", min=1, max=100, soft_min=1, soft_max=100, default=10, ) - length = FloatProperty( + length: FloatProperty( name="Length", min=0.001, max=100, soft_min=0.01, soft_max=10, @@ -118,7 +118,7 @@ class QuickExplode(Operator): bl_label = "Quick Explode" bl_options = {'REGISTER', 'UNDO'} - style = EnumProperty( + style: EnumProperty( name="Explode Style", items=( ('EXPLODE', "Explode", ""), @@ -126,40 +126,40 @@ class QuickExplode(Operator): ), default='EXPLODE', ) - amount = IntProperty( + amount: IntProperty( name="Amount of pieces", min=2, max=10000, soft_min=2, soft_max=10000, default=100, ) - frame_duration = IntProperty( + frame_duration: IntProperty( name="Duration", min=1, max=300000, soft_min=1, soft_max=10000, default=50, ) - frame_start = IntProperty( + frame_start: IntProperty( name="Start Frame", min=1, max=300000, soft_min=1, soft_max=10000, default=1, ) - frame_end = IntProperty( + frame_end: IntProperty( name="End Frame", min=1, max=300000, soft_min=1, soft_max=10000, default=10, ) - velocity = FloatProperty( + velocity: FloatProperty( name="Outwards Velocity", min=0, max=300000, soft_min=0, soft_max=10, default=1, ) - fade = BoolProperty( + fade: BoolProperty( name="Fade", description="Fade the pieces over time", default=True, @@ -306,7 +306,7 @@ class QuickSmoke(Operator): bl_label = "Quick Smoke" bl_options = {'REGISTER', 'UNDO'} - style = EnumProperty( + style: EnumProperty( name="Smoke Style", items=( ('SMOKE', "Smoke", ""), @@ -316,7 +316,7 @@ class QuickSmoke(Operator): default='SMOKE', ) - show_flows = BoolProperty( + show_flows: BoolProperty( name="Render Smoke Objects", description="Keep the smoke objects visible during rendering", default=False, @@ -410,7 +410,7 @@ class QuickFluid(Operator): bl_label = "Quick Fluid" bl_options = {'REGISTER', 'UNDO'} - style = EnumProperty( + style: EnumProperty( name="Fluid Style", items=( ('INFLOW', "Inflow", ""), @@ -418,19 +418,19 @@ class QuickFluid(Operator): ), default='BASIC', ) - initial_velocity = FloatVectorProperty( + initial_velocity: FloatVectorProperty( name="Initial Velocity", description="Initial velocity of the fluid", min=-100.0, max=100.0, default=(0.0, 0.0, 0.0), subtype='VELOCITY', ) - show_flows = BoolProperty( + show_flows: BoolProperty( name="Render Fluid Objects", description="Keep the fluid objects visible during rendering", default=False, ) - start_baking = BoolProperty( + start_baking: BoolProperty( name="Start Fluid Bake", description=("Start baking the fluid immediately " "after creating the domain object"), diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index dbc9461ad5a..6e2dad079ee 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -103,25 +103,25 @@ class RandomizeLocRotSize(Operator): bl_label = "Randomize Transform" bl_options = {'REGISTER', 'UNDO'} - random_seed = IntProperty( + random_seed: IntProperty( name="Random Seed", description="Seed value for the random generator", min=0, max=10000, default=0, ) - use_delta = BoolProperty( + use_delta: BoolProperty( name="Transform Delta", description=("Randomize delta transform values " "instead of regular transform"), default=False, ) - use_loc = BoolProperty( + use_loc: BoolProperty( name="Randomize Location", description="Randomize the location values", default=True, ) - loc = FloatVectorProperty( + loc: FloatVectorProperty( name="Location", description=("Maximum distance the objects " "can spread over each axis"), @@ -130,12 +130,12 @@ class RandomizeLocRotSize(Operator): default=(0.0, 0.0, 0.0), subtype='TRANSLATION', ) - use_rot = BoolProperty( + use_rot: BoolProperty( name="Randomize Rotation", description="Randomize the rotation values", default=True, ) - rot = FloatVectorProperty( + rot: FloatVectorProperty( name="Rotation", description="Maximum rotation over each axis", min=-3.141592, # math.pi @@ -143,25 +143,25 @@ class RandomizeLocRotSize(Operator): default=(0.0, 0.0, 0.0), subtype='EULER', ) - use_scale = BoolProperty( + use_scale: BoolProperty( name="Randomize Scale", description="Randomize the scale values", default=True, ) - scale_even = BoolProperty( + scale_even: BoolProperty( name="Scale Even", description="Use the same scale value for all axis", default=False, ) - '''scale_min = FloatProperty( + '''scale_min: FloatProperty( name="Minimun Scale Factor", description="Lowest scale percentage possible", min=-1.0, max=1.0, precision=3, default=0.15, )''' - scale = FloatVectorProperty( + scale: FloatVectorProperty( name="Scale", description="Maximum scale randomization over each axis", min=-100.0, diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 780183fb713..55e61be6370 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -41,28 +41,21 @@ class AddPresetBase: # only because invoke_props_popup requires. Also do not add to search menu. bl_options = {'REGISTER', 'INTERNAL'} - name = StringProperty( + name: StringProperty( name="Name", description="Name of the preset, used to make the path name", maxlen=64, options={'SKIP_SAVE'}, ) - remove_name = BoolProperty( + remove_name: BoolProperty( default=False, options={'HIDDEN', 'SKIP_SAVE'}, ) - remove_active = BoolProperty( + remove_active: BoolProperty( default=False, options={'HIDDEN', 'SKIP_SAVE'}, ) - # needed for mix-ins - order = [ - "name", - "remove_name", - "remove_active", - ] - @staticmethod def as_filename(name): # could reuse for other presets @@ -225,11 +218,11 @@ class ExecutePreset(Operator): bl_idname = "script.execute_preset" bl_label = "Execute a Python Preset" - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', options={'SKIP_SAVE'}, ) - menu_idname = StringProperty( + menu_idname: StringProperty( name="Menu ID Name", description="ID name of the menu this was called from", options={'SKIP_SAVE'}, @@ -264,7 +257,7 @@ class PresetMenu(Panel): bl_space_type = 'PROPERTIES' bl_region_type = 'HEADER' bl_label = "Presets" - path_menu = Menu.path_menu + path_menu: Menu.path_menu @classmethod def draw_panel_header(cls, layout): @@ -333,7 +326,7 @@ class AddPresetCamera(AddPresetBase, Operator): preset_subdir = "camera" - use_focal_length = BoolProperty( + use_focal_length: BoolProperty( name="Include Focal Length", description="Include focal length into the preset", options={'SKIP_SAVE'}, @@ -480,7 +473,7 @@ class AddPresetTrackingCamera(AddPresetBase, Operator): preset_subdir = "tracking_camera" - use_focal_length = BoolProperty( + use_focal_length: BoolProperty( name="Include Focal Length", description="Include focal length into the preset", options={'SKIP_SAVE'}, @@ -605,7 +598,7 @@ class AddPresetOperator(AddPresetBase, Operator): bl_label = "Operator Preset" preset_menu = "WM_MT_operator_presets" - operator = StringProperty( + operator: StringProperty( name="Operator", maxlen=64, options={'HIDDEN', 'SKIP_SAVE'}, diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py index 9fa8188e946..36150a63895 100644 --- a/release/scripts/startup/bl_operators/rigidbody.py +++ b/release/scripts/startup/bl_operators/rigidbody.py @@ -92,19 +92,19 @@ class BakeToKeyframes(Operator): bl_label = "Bake To Keyframes" bl_options = {'REGISTER', 'UNDO'} - frame_start = IntProperty( + frame_start: IntProperty( name="Start Frame", description="Start frame for baking", min=0, max=300000, default=1, ) - frame_end = IntProperty( + frame_end: IntProperty( name="End Frame", description="End frame for baking", min=1, max=300000, default=250, ) - step = IntProperty( + step: IntProperty( name="Frame Step", description="Frame Step", min=1, max=120, @@ -216,7 +216,7 @@ class ConnectRigidBodies(Operator): bl_label = "Connect Rigid Bodies" bl_options = {'REGISTER', 'UNDO'} - con_type = EnumProperty( + con_type: EnumProperty( name="Type", description="Type of generated constraint", # XXX Would be nice to get icons too, but currently not possible ;) @@ -226,7 +226,7 @@ class ConnectRigidBodies(Operator): ), default='FIXED', ) - pivot_type = EnumProperty( + pivot_type: EnumProperty( name="Location", description="Constraint pivot location", items=( @@ -236,7 +236,7 @@ class ConnectRigidBodies(Operator): ), default='CENTER', ) - connection_pattern = EnumProperty( + connection_pattern: EnumProperty( name="Connection Pattern", description="Pattern used to connect objects", items=( diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py index c9a7aa93805..b1152157cf8 100644 --- a/release/scripts/startup/bl_operators/sequencer.py +++ b/release/scripts/startup/bl_operators/sequencer.py @@ -82,7 +82,7 @@ class SequencerCutMulticam(Operator): bl_label = "Cut multicam" bl_options = {'REGISTER', 'UNDO'} - camera = IntProperty( + camera: IntProperty( name="Camera", min=1, max=32, soft_min=1, soft_max=32, diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py index 7620b354a08..5c870849cc5 100644 --- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -226,7 +226,7 @@ class FollowActiveQuads(Operator): bl_label = "Follow Active Quads" bl_options = {'REGISTER', 'UNDO'} - mode = bpy.props.EnumProperty( + mode: bpy.props.EnumProperty( name="Edge Length Mode", description="Method to space UV edge loops", items=(('EVEN', "Even", "Space all UVs evenly"), diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index 0d5bc3136a5..95a3d18304b 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -616,7 +616,7 @@ class LightMapPack(Operator): # This fixes infinite image creation reported there [#30968] (sergey) bl_options = {'UNDO'} - PREF_CONTEXT = bpy.props.EnumProperty( + PREF_CONTEXT: bpy.props.EnumProperty( name="Selection", items=( ('SEL_FACES', "Selected Faces", "Space all UVs evenly"), @@ -626,7 +626,7 @@ class LightMapPack(Operator): ) # Image & UVs... - PREF_PACK_IN_ONE = BoolProperty( + PREF_PACK_IN_ONE: BoolProperty( name="Share Tex Space", description=( "Objects Share texture space, map all objects " @@ -634,12 +634,12 @@ class LightMapPack(Operator): ), default=True, ) - PREF_NEW_UVLAYER = BoolProperty( + PREF_NEW_UVLAYER: BoolProperty( name="New UV Map", description="Create a new UV map for every mesh packed", default=False, ) - PREF_APPLY_IMAGE = BoolProperty( + PREF_APPLY_IMAGE: BoolProperty( name="New Image", description=( "Assign new images for every mesh (only one if " @@ -647,20 +647,20 @@ class LightMapPack(Operator): ), default=False, ) - PREF_IMG_PX_SIZE = IntProperty( + PREF_IMG_PX_SIZE: IntProperty( name="Image Size", description="Width and Height for the new image", min=64, max=5000, default=512, ) # UV Packing... - PREF_BOX_DIV = IntProperty( + PREF_BOX_DIV: IntProperty( name="Pack Quality", description="Pre Packing before the complex boxpack", min=1, max=48, default=12, ) - PREF_MARGIN_DIV = FloatProperty( + PREF_MARGIN_DIV: FloatProperty( name="Margin", description="Size of the margin as a division of the UV", min=0.001, max=1.0, diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index aebc0ae0313..fe15b9fa345 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -1055,31 +1055,31 @@ class SmartProject(Operator): bl_label = "Smart UV Project" bl_options = {'REGISTER', 'UNDO'} - angle_limit = FloatProperty( + angle_limit: FloatProperty( name="Angle Limit", description="Lower for more projection groups, higher for less distortion", min=1.0, max=89.0, default=66.0, ) - island_margin = FloatProperty( + island_margin: FloatProperty( name="Island Margin", description="Margin to reduce bleed from adjacent islands", unit='LENGTH', subtype='DISTANCE', min=0.0, max=1.0, default=0.0, ) - user_area_weight = FloatProperty( + user_area_weight: FloatProperty( name="Area Weight", description="Weight projections vector by faces with larger areas", min=0.0, max=1.0, default=0.0, ) - use_aspect = BoolProperty( + use_aspect: BoolProperty( name="Correct Aspect", description="Map UVs taking image aspect ratio into account", default=True ) - stretch_to_bounds = BoolProperty( + stretch_to_bounds: BoolProperty( name="Stretch to UV Bounds", description="Stretch the final output to texture bounds", default=True, diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index 1173e0047bb..335c3d8bbda 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -138,33 +138,33 @@ class VertexPaintDirt(Operator): bl_label = "Dirty Vertex Colors" bl_options = {'REGISTER', 'UNDO'} - blur_strength = FloatProperty( + blur_strength: FloatProperty( name="Blur Strength", description="Blur strength per iteration", min=0.01, max=1.0, default=1.0, ) - blur_iterations = IntProperty( + blur_iterations: IntProperty( name="Blur Iterations", description="Number of times to blur the colors (higher blurs more)", min=0, max=40, default=1, ) - clean_angle = FloatProperty( + clean_angle: FloatProperty( name="Highlight Angle", description="Less than 90 limits the angle used in the tonal range", min=0.0, max=pi, default=pi, unit="ROTATION", ) - dirt_angle = FloatProperty( + dirt_angle: FloatProperty( name="Dirt Angle", description="Less than 90 limits the angle used in the tonal range", min=0.0, max=pi, default=0.0, unit="ROTATION", ) - dirt_only = BoolProperty( + dirt_only: BoolProperty( name="Dirt Only", description="Don't calculate cleans for convex areas", default=False, diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py index f56c83be7d1..b43f4446802 100644 --- a/release/scripts/startup/bl_operators/view3d.py +++ b/release/scripts/startup/bl_operators/view3d.py @@ -143,37 +143,37 @@ class VIEW3D_OT_select_or_deselect_all(Operator): bl_idname = "view3d.select_or_deselect_all" bl_options = {'UNDO'} - extend = BoolProperty( + extend: BoolProperty( name="Extend", description="Extend selection instead of deselecting everything first", default=False, ) - toggle = BoolProperty( + toggle: BoolProperty( name="Toggle", description="Toggle the selection", default=False, ) - deselect = BoolProperty( + deselect: BoolProperty( name="Deselect", description="Remove from selection", default=False, ) - center = BoolProperty( + center: BoolProperty( name="Center", description="Use the object center when selecting, in editmode used to extend object selection", default=False, ) - enumerate = BoolProperty( + enumerate: BoolProperty( name="Enumerate", description="List objects under the mouse (object mode only)", default=False, ) - object = BoolProperty( + object: BoolProperty( name="Object", description="Use object selection (editmode only)", default=False, diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index a01298f5696..fe367973323 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -162,12 +162,12 @@ class BRUSH_OT_active_index_set(Operator): bl_idname = "brush.active_index_set" bl_label = "Set Brush Number" - mode = StringProperty( + mode: StringProperty( name="Mode", description="Paint mode to set brush for", maxlen=1024, ) - index = IntProperty( + index: IntProperty( name="Number", description="Brush number", ) @@ -199,8 +199,8 @@ class WM_OT_context_set_boolean(Operator): bl_label = "Context Set Boolean" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = BoolProperty( + data_path: rna_path_prop + value: BoolProperty( name="Value", description="Assignment value", default=True, @@ -215,13 +215,13 @@ class WM_OT_context_set_int(Operator): # same as enum bl_label = "Context Set" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = IntProperty( + data_path: rna_path_prop + value: IntProperty( name="Value", description="Assign value", default=0, ) - relative = rna_relative_prop + relative: rna_relative_prop execute = execute_context_assign @@ -232,8 +232,8 @@ class WM_OT_context_scale_float(Operator): bl_label = "Context Scale Float" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = FloatProperty( + data_path: rna_path_prop + value: FloatProperty( name="Value", description="Assign value", default=1.0, @@ -260,13 +260,13 @@ class WM_OT_context_scale_int(Operator): bl_label = "Context Scale Int" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = FloatProperty( + data_path: rna_path_prop + value: FloatProperty( name="Value", description="Assign value", default=1.0, ) - always_step = BoolProperty( + always_step: BoolProperty( name="Always Step", description="Always adjust the value by a minimum of 1 when 'value' is not 1.0", default=True, @@ -303,13 +303,13 @@ class WM_OT_context_set_float(Operator): # same as enum bl_label = "Context Set Float" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = FloatProperty( + data_path: rna_path_prop + value: FloatProperty( name="Value", description="Assignment value", default=0.0, ) - relative = rna_relative_prop + relative: rna_relative_prop execute = execute_context_assign @@ -320,8 +320,8 @@ class WM_OT_context_set_string(Operator): # same as enum bl_label = "Context Set String" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = StringProperty( + data_path: rna_path_prop + value: StringProperty( name="Value", description="Assign value", maxlen=1024, @@ -336,8 +336,8 @@ class WM_OT_context_set_enum(Operator): bl_label = "Context Set Enum" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = StringProperty( + data_path: rna_path_prop + value: StringProperty( name="Value", description="Assignment value (as a string)", maxlen=1024, @@ -352,8 +352,8 @@ class WM_OT_context_set_value(Operator): bl_label = "Context Set Value" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = StringProperty( + data_path: rna_path_prop + value: StringProperty( name="Value", description="Assignment value (as a string)", maxlen=1024, @@ -373,7 +373,7 @@ class WM_OT_context_toggle(Operator): bl_label = "Context Toggle" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop + data_path: rna_path_prop def execute(self, context): data_path = self.data_path @@ -392,13 +392,13 @@ class WM_OT_context_toggle_enum(Operator): bl_label = "Context Toggle Values" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value_1 = StringProperty( + data_path: rna_path_prop + value_1: StringProperty( name="Value", description="Toggle enum", maxlen=1024, ) - value_2 = StringProperty( + value_2: StringProperty( name="Value", description="Toggle enum", maxlen=1024, @@ -431,9 +431,9 @@ class WM_OT_context_cycle_int(Operator): bl_label = "Context Int Cycle" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - reverse = rna_reverse_prop - wrap = rna_wrap_prop + data_path: rna_path_prop + reverse: rna_reverse_prop + wrap: rna_wrap_prop def execute(self, context): data_path = self.data_path @@ -467,9 +467,9 @@ class WM_OT_context_cycle_enum(Operator): bl_label = "Context Enum Cycle" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - reverse = rna_reverse_prop - wrap = rna_wrap_prop + data_path: rna_path_prop + reverse: rna_reverse_prop + wrap: rna_wrap_prop def execute(self, context): data_path = self.data_path @@ -524,8 +524,8 @@ class WM_OT_context_cycle_array(Operator): bl_label = "Context Array Cycle" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - reverse = rna_reverse_prop + data_path: rna_path_prop + reverse: rna_reverse_prop def execute(self, context): data_path = self.data_path @@ -549,7 +549,8 @@ class WM_OT_context_menu_enum(Operator): bl_idname = "wm.context_menu_enum" bl_label = "Context Enum Menu" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop + + data_path: rna_path_prop def execute(self, context): data_path = self.data_path @@ -575,7 +576,8 @@ class WM_OT_context_pie_enum(Operator): bl_idname = "wm.context_pie_enum" bl_label = "Context Enum Pie" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop + + data_path: rna_path_prop def invoke(self, context, event): wm = context.window_manager @@ -602,12 +604,13 @@ class WM_OT_operator_pie_enum(Operator): bl_idname = "wm.operator_pie_enum" bl_label = "Operator Enum Pie" bl_options = {'UNDO', 'INTERNAL'} - data_path = StringProperty( + + data_path: StringProperty( name="Operator", description="Operator name (in python as string)", maxlen=1024, ) - prop_string = StringProperty( + prop_string: StringProperty( name="Property", description="Property name (as a string)", maxlen=1024, @@ -646,8 +649,8 @@ class WM_OT_context_set_id(Operator): bl_label = "Set Library ID" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path_prop - value = StringProperty( + data_path: rna_path_prop + value: StringProperty( name="Value", description="Assign value", maxlen=1024, @@ -697,10 +700,10 @@ class WM_OT_context_collection_boolean_set(Operator): bl_label = "Context Collection Boolean Set" bl_options = {'UNDO', 'REGISTER', 'INTERNAL'} - data_path_iter = data_path_iter - data_path_item = data_path_item + data_path_iter: data_path_iter + data_path_item: data_path_item - type = EnumProperty( + type: EnumProperty( name="Type", items=(('TOGGLE', "Toggle", ""), ('ENABLE', "Enable", ""), @@ -756,22 +759,22 @@ class WM_OT_context_modal_mouse(Operator): bl_label = "Context Modal Mouse" bl_options = {'GRAB_CURSOR', 'BLOCKING', 'UNDO', 'INTERNAL'} - data_path_iter = data_path_iter - data_path_item = data_path_item - header_text = StringProperty( + data_path_iter: data_path_iter + data_path_item: data_path_item + header_text: StringProperty( name="Header Text", description="Text to display in header during scale", ) - input_scale = FloatProperty( + input_scale: FloatProperty( description="Scale the mouse movement by this value before applying the delta", default=0.01, ) - invert = BoolProperty( + invert: BoolProperty( description="Invert the mouse input", default=False, ) - initial_x = IntProperty(options={'HIDDEN'}) + initial_x: IntProperty(options={'HIDDEN'}) def _values_store(self, context): data_path_iter = self.data_path_iter @@ -864,7 +867,7 @@ class WM_OT_url_open(Operator): bl_label = "" bl_options = {'INTERNAL'} - url = StringProperty( + url: StringProperty( name="URL", description="URL to open", ) @@ -881,7 +884,7 @@ class WM_OT_path_open(Operator): bl_label = "" bl_options = {'INTERNAL'} - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', options={'SKIP_SAVE'}, ) @@ -996,7 +999,7 @@ class WM_OT_doc_view_manual(Operator): bl_idname = "wm.doc_view_manual" bl_label = "View Manual" - doc_id = doc_id + doc_id: doc_id @staticmethod def _find_reference(rna_id, url_mapping, verbose=True): @@ -1050,7 +1053,7 @@ class WM_OT_doc_view(Operator): bl_idname = "wm.doc_view" bl_label = "View Documentation" - doc_id = doc_id + doc_id: doc_id if bpy.app.version_cycle == "release": _prefix = ("https://docs.blender.org/api/blender_python_api_current") else: @@ -1114,16 +1117,16 @@ class WM_OT_properties_edit(Operator): # register only because invoke_props_popup requires. bl_options = {'REGISTER', 'INTERNAL'} - data_path = rna_path - property = rna_property - value = rna_value - min = rna_min - max = rna_max - use_soft_limits = rna_use_soft_limits - is_overridable_static = rna_is_overridable_static - soft_min = rna_min - soft_max = rna_max - description = StringProperty( + data_path: rna_path + property: rna_property + value: rna_value + min: rna_min + max: rna_max + use_soft_limits: rna_use_soft_limits + is_overridable_static: rna_is_overridable_static + soft_min: rna_min + soft_max: rna_max + description: StringProperty( name="Tooltip", ) @@ -1319,7 +1322,7 @@ class WM_OT_properties_add(Operator): bl_label = "Add Property" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path + data_path: rna_path def execute(self, context): from rna_prop_ui import ( @@ -1362,7 +1365,7 @@ class WM_OT_properties_context_change(Operator): bl_label = "" bl_options = {'INTERNAL'} - context = StringProperty( + context: StringProperty( name="Context", maxlen=64, ) @@ -1378,8 +1381,8 @@ class WM_OT_properties_remove(Operator): bl_label = "Remove Property" bl_options = {'UNDO', 'INTERNAL'} - data_path = rna_path - property = rna_property + data_path: rna_path + property: rna_property def execute(self, context): from rna_prop_ui import ( @@ -1400,7 +1403,7 @@ class WM_OT_keyconfig_activate(Operator): bl_idname = "wm.keyconfig_activate" bl_label = "Activate Keyconfig" - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', ) @@ -1435,7 +1438,7 @@ class WM_OT_appconfig_activate(Operator): bl_idname = "wm.appconfig_activate" bl_label = "Activate Application Configuration" - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', ) @@ -1460,7 +1463,7 @@ class WM_OT_sysinfo(Operator): bl_idname = "wm.sysinfo" bl_label = "Save System Info" - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', options={'SKIP_SAVE'}, ) @@ -1538,26 +1541,26 @@ class WM_OT_keyconfig_import(Operator): bl_idname = "wm.keyconfig_import" bl_label = "Import Key Configuration..." - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', default="keymap.py", ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( name="Filter folders", default=True, options={'HIDDEN'}, ) - filter_text = BoolProperty( + filter_text: BoolProperty( name="Filter text", default=True, options={'HIDDEN'}, ) - filter_python = BoolProperty( + filter_python: BoolProperty( name="Filter python", default=True, options={'HIDDEN'}, ) - keep_original = BoolProperty( + keep_original: BoolProperty( name="Keep original", description="Keep original file after copying to configuration folder", default=True, @@ -1605,21 +1608,21 @@ class WM_OT_keyconfig_export(Operator): bl_idname = "wm.keyconfig_export" bl_label = "Export Key Configuration..." - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', default="keymap.py", ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( name="Filter folders", default=True, options={'HIDDEN'}, ) - filter_text = BoolProperty( + filter_text: BoolProperty( name="Filter text", default=True, options={'HIDDEN'}, ) - filter_python = BoolProperty( + filter_python: BoolProperty( name="Filter python", default=True, options={'HIDDEN'}, @@ -1655,7 +1658,7 @@ class WM_OT_keymap_restore(Operator): bl_idname = "wm.keymap_restore" bl_label = "Restore Key Map(s)" - all = BoolProperty( + all: BoolProperty( name="All Keymaps", description="Restore all keymaps to default", ) @@ -1678,7 +1681,7 @@ class WM_OT_keyitem_restore(Operator): bl_idname = "wm.keyitem_restore" bl_label = "Restore Key Map Item" - item_id = IntProperty( + item_id: IntProperty( name="Item Identifier", description="Identifier of the item to remove", ) @@ -1725,7 +1728,7 @@ class WM_OT_keyitem_remove(Operator): bl_idname = "wm.keyitem_remove" bl_label = "Remove Key Map Item" - item_id = IntProperty( + item_id: IntProperty( name="Item Identifier", description="Identifier of the item to remove", ) @@ -1793,7 +1796,7 @@ class WM_OT_addon_enable(Operator): bl_idname = "wm.addon_enable" bl_label = "Enable Add-on" - module = StringProperty( + module: StringProperty( name="Module", description="Module name of the add-on to enable", ) @@ -1839,7 +1842,7 @@ class WM_OT_addon_disable(Operator): bl_idname = "wm.addon_disable" bl_label = "Disable Add-on" - module = StringProperty( + module: StringProperty( name="Module", description="Module name of the add-on to disable", ) @@ -1868,7 +1871,7 @@ class WM_OT_owner_enable(Operator): bl_idname = "wm.owner_enable" bl_label = "Enable Add-on" - owner_id = StringProperty( + owner_id: StringProperty( name="UI Tag", ) @@ -1883,7 +1886,7 @@ class WM_OT_owner_disable(Operator): bl_idname = "wm.owner_disable" bl_label = "Disable UI Tag" - owner_id = StringProperty( + owner_id: StringProperty( name="UI Tag", ) @@ -1899,20 +1902,20 @@ class WM_OT_theme_install(Operator): bl_idname = "wm.theme_install" bl_label = "Install Theme..." - overwrite = BoolProperty( + overwrite: BoolProperty( name="Overwrite", description="Remove existing theme file if exists", default=True, ) - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( name="Filter folders", default=True, options={'HIDDEN'}, ) - filter_glob = StringProperty( + filter_glob: StringProperty( default="*.xml", options={'HIDDEN'}, ) @@ -1976,31 +1979,31 @@ class WM_OT_addon_install(Operator): bl_idname = "wm.addon_install" bl_label = "Install Add-on from File..." - overwrite = BoolProperty( + overwrite: BoolProperty( name="Overwrite", description="Remove existing add-ons with the same ID", default=True, ) - target = EnumProperty( + target: EnumProperty( name="Target Path", items=(('DEFAULT', "Default", ""), ('PREFS', "User Prefs", "")), ) - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( name="Filter folders", default=True, options={'HIDDEN'}, ) - filter_python = BoolProperty( + filter_python: BoolProperty( name="Filter python", default=True, options={'HIDDEN'}, ) - filter_glob = StringProperty( + filter_glob: StringProperty( default="*.py;*.zip", options={'HIDDEN'}, ) @@ -2130,7 +2133,7 @@ class WM_OT_addon_remove(Operator): bl_idname = "wm.addon_remove" bl_label = "Remove Add-on" - module = StringProperty( + module: StringProperty( name="Module", description="Module name of the add-on to remove", ) @@ -2190,7 +2193,7 @@ class WM_OT_addon_expand(Operator): bl_label = "" bl_options = {'INTERNAL'} - module = StringProperty( + module: StringProperty( name="Module", description="Module name of the add-on to expand", ) @@ -2214,7 +2217,7 @@ class WM_OT_addon_userpref_show(Operator): bl_label = "" bl_options = {'INTERNAL'} - module = StringProperty( + module: StringProperty( name="Module", description="Module name of the add-on to expand", ) @@ -2245,21 +2248,21 @@ class WM_OT_app_template_install(Operator): bl_idname = "wm.app_template_install" bl_label = "Install Template from File..." - overwrite = BoolProperty( + overwrite: BoolProperty( name="Overwrite", description="Remove existing template with the same ID", default=True, ) - filepath = StringProperty( + filepath: StringProperty( subtype='FILE_PATH', ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( name="Filter folders", default=True, options={'HIDDEN'}, ) - filter_glob = StringProperty( + filter_glob: StringProperty( default="*.zip", options={'HIDDEN'}, ) @@ -2344,19 +2347,18 @@ class WM_OT_tool_set_by_name(Operator): bl_idname = "wm.tool_set_by_name" bl_label = "Set Tool By Name" - name = StringProperty( + name: StringProperty( name="Text", description="Display name of the tool", ) - - cycle = BoolProperty( + cycle: BoolProperty( name="Cycle", description="Cycle through tools in this group", default=False, options={'SKIP_SAVE'}, ) - space_type = rna_space_type_prop + space_type: rna_space_type_prop def execute(self, context): from bl_ui.space_toolsystem_common import ( @@ -2414,23 +2416,23 @@ class WM_OT_studiolight_install(Operator): bl_idname = "wm.studiolight_install" bl_label = "Install Custom Studio Light" - files = CollectionProperty( + files: CollectionProperty( name="File Path", type=OperatorFileListElement, ) - directory = StringProperty( + directory: StringProperty( subtype='DIR_PATH', ) - filter_folder = BoolProperty( + filter_folder: BoolProperty( name="Filter folders", default=True, options={'HIDDEN'}, ) - filter_glob = StringProperty( + filter_glob: StringProperty( default="*.png;*.jpg;*.hdr;*.exr", options={'HIDDEN'}, ) - orientation = EnumProperty( + orientation: EnumProperty( items=( ("MATCAP", "MatCap", ""), ("WORLD", "World", ""), @@ -2480,7 +2482,7 @@ class WM_OT_studiolight_install(Operator): class WM_OT_studiolight_uninstall(Operator): bl_idname = 'wm.studiolight_uninstall' bl_label = "Uninstall Studio Light" - index = bpy.props.IntProperty() + index: bpy.props.IntProperty() def _remove_path(self, path): if path.exists(): diff --git a/release/scripts/templates_py/addon_add_object.py b/release/scripts/templates_py/addon_add_object.py index b74c0f8ee25..d26f3d351bf 100644 --- a/release/scripts/templates_py/addon_add_object.py +++ b/release/scripts/templates_py/addon_add_object.py @@ -45,7 +45,7 @@ class OBJECT_OT_add_object(Operator, AddObjectHelper): bl_label = "Add Mesh Object" bl_options = {'REGISTER', 'UNDO'} - scale = FloatVectorProperty( + scale: FloatVectorProperty( name="scale", default=(1.0, 1.0, 1.0), subtype='TRANSLATION', diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py index 23d8ee55e72..7e4e89dafeb 100644 --- a/release/scripts/templates_py/custom_nodes.py +++ b/release/scripts/templates_py/custom_nodes.py @@ -30,10 +30,15 @@ class MyCustomSocket(NodeSocket): ('DOWN', "Down", "Where your feet are"), ('UP', "Up", "Where your head should be"), ('LEFT', "Left", "Not right"), - ('RIGHT', "Right", "Not left") + ('RIGHT', "Right", "Not left"), ) - my_enum_prop = bpy.props.EnumProperty(name="Direction", description="Just an example", items=my_items, default='UP') + my_enum_prop: bpy.props.EnumProperty( + name="Direction", + description="Just an example", + items=my_items, + default='UP', + ) # Optional function for drawing the socket input value def draw(self, context, layout, node, text): @@ -71,8 +76,8 @@ class MyCustomNode(Node, MyCustomTreeNode): # These work just like custom properties in ID data blocks # Extensive information can be found under # http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Properties - my_string_prop = bpy.props.StringProperty() - my_float_prop = bpy.props.FloatProperty(default=3.1415926) + my_string_prop: bpy.props.StringProperty() + my_float_prop: bpy.props.FloatProperty(default=3.1415926) # === Optional Functions === # Initialization function, called when a new node is created. diff --git a/release/scripts/templates_py/manipulator_operator.py b/release/scripts/templates_py/manipulator_operator.py index 35e1c5b4fd1..61796489a95 100644 --- a/release/scripts/templates_py/manipulator_operator.py +++ b/release/scripts/templates_py/manipulator_operator.py @@ -39,11 +39,11 @@ class SelectSideOfPlane(Operator): bl_label = "Select Side of Plane" bl_options = {'REGISTER', 'UNDO'} - plane_co = FloatVectorProperty( + plane_co: FloatVectorProperty( size=3, default=(0, 0, 0), ) - plane_no = FloatVectorProperty( + plane_no: FloatVectorProperty( size=3, default=(0, 0, 1), ) diff --git a/release/scripts/templates_py/operator_file_export.py b/release/scripts/templates_py/operator_file_export.py index 8a1eb4ae54c..4ea817d3507 100644 --- a/release/scripts/templates_py/operator_file_export.py +++ b/release/scripts/templates_py/operator_file_export.py @@ -25,7 +25,7 @@ class ExportSomeData(Operator, ExportHelper): # ExportHelper mixin class uses this filename_ext = ".txt" - filter_glob = StringProperty( + filter_glob: StringProperty( default="*.txt", options={'HIDDEN'}, maxlen=255, # Max internal buffer length, longer would be clamped. @@ -33,13 +33,13 @@ class ExportSomeData(Operator, ExportHelper): # List of operator properties, the attributes will be assigned # to the class instance from the operator settings before calling. - use_setting = BoolProperty( + use_setting: BoolProperty( name="Example Boolean", description="Example Tooltip", default=True, ) - type = EnumProperty( + type: EnumProperty( name="Example Enum", description="Choose between two items", items=( diff --git a/release/scripts/templates_py/operator_file_import.py b/release/scripts/templates_py/operator_file_import.py index 9856b6a9040..b932b008c49 100644 --- a/release/scripts/templates_py/operator_file_import.py +++ b/release/scripts/templates_py/operator_file_import.py @@ -28,7 +28,7 @@ class ImportSomeData(Operator, ImportHelper): # ImportHelper mixin class uses this filename_ext = ".txt" - filter_glob = StringProperty( + filter_glob: StringProperty( default="*.txt", options={'HIDDEN'}, maxlen=255, # Max internal buffer length, longer would be clamped. @@ -36,13 +36,13 @@ class ImportSomeData(Operator, ImportHelper): # List of operator properties, the attributes will be assigned # to the class instance from the operator settings before calling. - use_setting = BoolProperty( + use_setting: BoolProperty( name="Example Boolean", description="Example Tooltip", default=True, ) - type = EnumProperty( + type: EnumProperty( name="Example Enum", description="Choose between two items", items=( diff --git a/release/scripts/templates_py/operator_mesh_add.py b/release/scripts/templates_py/operator_mesh_add.py index 407956a0fda..6b39ef7bbba 100644 --- a/release/scripts/templates_py/operator_mesh_add.py +++ b/release/scripts/templates_py/operator_mesh_add.py @@ -49,25 +49,25 @@ class AddBox(bpy.types.Operator): bl_label = "Add Box" bl_options = {'REGISTER', 'UNDO'} - width = FloatProperty( + width: FloatProperty( name="Width", description="Box Width", min=0.01, max=100.0, default=1.0, ) - height = FloatProperty( + height: FloatProperty( name="Height", description="Box Height", min=0.01, max=100.0, default=1.0, ) - depth = FloatProperty( + depth: FloatProperty( name="Depth", description="Box Depth", min=0.01, max=100.0, default=1.0, ) - layers = BoolVectorProperty( + layers: BoolVectorProperty( name="Layers", description="Object Layers", size=20, @@ -75,15 +75,15 @@ class AddBox(bpy.types.Operator): ) # generic transform props - view_align = BoolProperty( + view_align: BoolProperty( name="Align to View", default=False, ) - location = FloatVectorProperty( + location: FloatVectorProperty( name="Location", subtype='TRANSLATION', ) - rotation = FloatVectorProperty( + rotation: FloatVectorProperty( name="Rotation", subtype='EULER', ) diff --git a/release/scripts/templates_py/operator_modal.py b/release/scripts/templates_py/operator_modal.py index 88e5ee80590..c242e3b67b9 100644 --- a/release/scripts/templates_py/operator_modal.py +++ b/release/scripts/templates_py/operator_modal.py @@ -7,8 +7,8 @@ class ModalOperator(bpy.types.Operator): bl_idname = "object.modal_operator" bl_label = "Simple Modal Operator" - first_mouse_x = IntProperty() - first_value = FloatProperty() + first_mouse_x: IntProperty() + first_value: FloatProperty() def modal(self, context, event): if event.type == 'MOUSEMOVE': diff --git a/release/scripts/templates_py/operator_modal_view3d.py b/release/scripts/templates_py/operator_modal_view3d.py index 65bab3489b4..9d371446829 100644 --- a/release/scripts/templates_py/operator_modal_view3d.py +++ b/release/scripts/templates_py/operator_modal_view3d.py @@ -8,7 +8,7 @@ class ViewOperator(bpy.types.Operator): bl_idname = "view3d.modal_operator" bl_label = "Simple View Operator" - offset = FloatVectorProperty( + offset: FloatVectorProperty( name="Offset", size=3, ) diff --git a/release/scripts/templates_py/ui_list.py b/release/scripts/templates_py/ui_list.py index 92e1b29d2ae..f6b82356a78 100644 --- a/release/scripts/templates_py/ui_list.py +++ b/release/scripts/templates_py/ui_list.py @@ -7,8 +7,10 @@ class MESH_UL_mylist(bpy.types.UIList): # E.g. VGROUP_EMPTY = 1 << 0 # Custom properties, saved with .blend file. E.g. - # use_filter_empty = bpy.props.BoolProperty(name="Filter Empty", default=False, options=set(), - # description="Whether to filter empty vertex groups") + # use_filter_empty: bpy.props.BoolProperty( + # name="Filter Empty", default=False, options=set(), + # description="Whether to filter empty vertex groups", + # ) # Called for each drawn item. def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag): diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.c index 6911e985e93..41276963fc9 100644 --- a/source/blender/python/intern/bpy_intern_string.c +++ b/source/blender/python/intern/bpy_intern_string.c @@ -36,6 +36,7 @@ static PyObject *bpy_intern_str_arr[16]; +PyObject *bpy_intern_str___annotations__; PyObject *bpy_intern_str___doc__; PyObject *bpy_intern_str___main__; PyObject *bpy_intern_str___module__; @@ -47,7 +48,6 @@ PyObject *bpy_intern_str_bl_rna; PyObject *bpy_intern_str_bl_target_properties; PyObject *bpy_intern_str_bpy_types; PyObject *bpy_intern_str_frame; -PyObject *bpy_intern_str_order; PyObject *bpy_intern_str_properties; PyObject *bpy_intern_str_register; PyObject *bpy_intern_str_self; @@ -60,6 +60,7 @@ void bpy_intern_string_init(void) #define BPY_INTERN_STR(var, str) \ { var = bpy_intern_str_arr[i++] = PyUnicode_FromString(str); } (void)0 + BPY_INTERN_STR(bpy_intern_str___annotations__, "__annotations__"); BPY_INTERN_STR(bpy_intern_str___doc__, "__doc__"); BPY_INTERN_STR(bpy_intern_str___main__, "__main__"); BPY_INTERN_STR(bpy_intern_str___module__, "__module__"); @@ -71,7 +72,6 @@ void bpy_intern_string_init(void) BPY_INTERN_STR(bpy_intern_str_bl_target_properties, "bl_target_properties"); BPY_INTERN_STR(bpy_intern_str_bpy_types, "bpy.types"); BPY_INTERN_STR(bpy_intern_str_frame, "frame"); - BPY_INTERN_STR(bpy_intern_str_order, "order"); BPY_INTERN_STR(bpy_intern_str_properties, "properties"); BPY_INTERN_STR(bpy_intern_str_register, "register"); BPY_INTERN_STR(bpy_intern_str_self, "self"); diff --git a/source/blender/python/intern/bpy_intern_string.h b/source/blender/python/intern/bpy_intern_string.h index 998c312c321..41cd58f9c3d 100644 --- a/source/blender/python/intern/bpy_intern_string.h +++ b/source/blender/python/intern/bpy_intern_string.h @@ -30,6 +30,7 @@ void bpy_intern_string_init(void); void bpy_intern_string_exit(void); +extern PyObject *bpy_intern_str___annotations__; extern PyObject *bpy_intern_str___doc__; extern PyObject *bpy_intern_str___main__; extern PyObject *bpy_intern_str___module__; @@ -41,7 +42,6 @@ extern PyObject *bpy_intern_str_bl_rna; extern PyObject *bpy_intern_str_bl_target_properties; extern PyObject *bpy_intern_str_bpy_types; extern PyObject *bpy_intern_str_frame; -extern PyObject *bpy_intern_str_order; extern PyObject *bpy_intern_str_properties; extern PyObject *bpy_intern_str_register; extern PyObject *bpy_intern_str_self; diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 3e1c85d7f9f..00ff63f7275 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -7423,29 +7423,38 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict) { + PyObject *fields_dict; PyObject *item, *key; - PyObject *order; Py_ssize_t pos = 0; int ret = 0; /* in both cases PyDict_CheckExact(class_dict) will be true even * though Operators have a metaclass dict namespace */ + if ((fields_dict = PyDict_GetItem(class_dict, bpy_intern_str___annotations__)) && PyDict_CheckExact(fields_dict)) { + while (PyDict_Next(fields_dict, &pos, &key, &item)) { + ret = deferred_register_prop(srna, key, item); - if ((order = PyDict_GetItem(class_dict, bpy_intern_str_order)) && PyList_CheckExact(order)) { - for (pos = 0; pos < PyList_GET_SIZE(order); pos++) { - key = PyList_GET_ITEM(order, pos); - /* however unlikely its possible - * fails in py 3.3 beta with __qualname__ */ - if ((item = PyDict_GetItem(class_dict, key))) { - ret = deferred_register_prop(srna, key, item); - if (ret != 0) { - break; - } + if (ret != 0) { + break; } } } - else { + + { + /* This block can be removed once 2.8x is released and fields are in use. */ + bool has_warning = false; while (PyDict_Next(class_dict, &pos, &key, &item)) { + if (pyrna_is_deferred_prop(item)) { + if (!has_warning) { + PyC_StackSpit(); + printf("Warning: class %.200s " + "contains a properties which should be a field!\n", + RNA_struct_identifier(srna)); + has_warning = true; + } + printf(" make field: %.200s.%.200s\n", + RNA_struct_identifier(srna), _PyUnicode_AsString(key)); + } ret = deferred_register_prop(srna, key, item); if (ret != 0) -- cgit v1.2.3 From d28d202fd113810ad05b572b785b106fcfb00992 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jul 2018 23:13:37 +0200 Subject: PyAPI: remove bpy.utils.register_module Remove bpy.utils.register_module() & logic tracked RNA classes. --- release/scripts/modules/bpy/utils/__init__.py | 58 --------------------------- release/scripts/modules/bpy_types.py | 20 +-------- 2 files changed, 1 insertion(+), 77 deletions(-) diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index b3257c30a97..80e48697b2f 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -34,7 +34,6 @@ __all__ = ( "refresh_script_paths", "app_template_paths", "register_class", - "register_module", "register_manual_map", "unregister_manual_map", "register_classes_factory", @@ -50,7 +49,6 @@ __all__ = ( "smpte_from_seconds", "units", "unregister_class", - "unregister_module", "user_resource", ) @@ -166,10 +164,6 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): for module_name in [ext.module for ext in _user_preferences.addons]: _addon_utils.disable(module_name) - # *AFTER* unregistering all add-ons, otherwise all calls to - # unregister_module() will silently fail (do nothing). - _bpy_types.TypeMap.clear() - def register_module_call(mod): register = getattr(mod, "register", None) if register: @@ -655,58 +649,6 @@ def user_resource(resource_type, path="", create=False): return target_path -def _bpy_module_classes(module, is_registered=False): - typemap_list = _bpy_types.TypeMap.get(module, ()) - i = 0 - while i < len(typemap_list): - cls_weakref = typemap_list[i] - cls = cls_weakref() - - if cls is None: - del typemap_list[i] - else: - if is_registered == cls.is_registered: - yield cls - i += 1 - - -def register_module(module, verbose=False): - if verbose: - print("bpy.utils.register_module(%r): ..." % module) - cls = None - for cls in _bpy_module_classes(module, is_registered=False): - if verbose: - print(" %r" % cls) - try: - register_class(cls) - except: - print("bpy.utils.register_module(): " - "failed to registering class %r" % cls) - import traceback - traceback.print_exc() - if verbose: - print("done.\n") - if cls is None: - raise Exception("register_module(%r): defines no classes" % module) - - -def unregister_module(module, verbose=False): - if verbose: - print("bpy.utils.unregister_module(%r): ..." % module) - for cls in _bpy_module_classes(module, is_registered=True): - if verbose: - print(" %r" % cls) - try: - unregister_class(cls) - except: - print("bpy.utils.unregister_module(): " - "failed to unregistering class %r" % cls) - import traceback - traceback.print_exc() - if verbose: - print("done.\n") - - def register_classes_factory(classes): """ Utility function to create register and unregister functions diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index b317ae18955..3bdf92f8e63 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -533,10 +533,6 @@ class Text(bpy_types.ID): self.write(string) -# values are module: [(cls, path, line), ...] -TypeMap = {} - - class Sound(bpy_types.ID): __slots__ = () @@ -548,21 +544,7 @@ class Sound(bpy_types.ID): class RNAMeta(type): - - def __new__(cls, name, bases, classdict, **args): - result = type.__new__(cls, name, bases, classdict) - if bases and bases[0] is not StructRNA: - from _weakref import ref as ref - module = result.__module__ - - # first part of packages only - if "." in module: - module = module[:module.index(".")] - - TypeMap.setdefault(module, []).append(ref(result)) - - return result - + # TODO(campbell): move to C-API @property def is_registered(cls): return "bl_rna" in cls.__dict__ -- cgit v1.2.3 From 1db47a2ccd1e68994bf8140eba6cc2a26a2bc91f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 08:28:06 +0200 Subject: Fix PyRNA class registration w/ Python 3.7 In Python3.7 this now raises an error. --- source/blender/python/intern/bpy_rna.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 9052b6f580a..80b0aa7a51b 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -7577,10 +7577,12 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v if (!(flag & PROP_REGISTER)) continue; + /* TODO(campbell): Use Python3.7x _PyObject_LookupAttr(), also in the macro below. */ identifier = RNA_property_identifier(prop); item = PyObject_GetAttrString(py_class, identifier); if (item == NULL) { + PyErr_Clear(); /* Sneaky workaround to use the class name as the bl_idname */ #define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \ @@ -7596,6 +7598,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v } \ Py_DECREF(item); \ } \ + else { \ + PyErr_Clear(); \ + } \ } /* intentionally allow else here */ if (false) {} /* needed for macro */ -- cgit v1.2.3 From b328a59373a231f749bd0d17fb3bc385002a5946 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 09:13:18 +0200 Subject: Icons: support setting blender, inkscape commands --- release/datafiles/blender_icons_update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/datafiles/blender_icons_update.py b/release/datafiles/blender_icons_update.py index 68f4ef23082..3aeb6697824 100755 --- a/release/datafiles/blender_icons_update.py +++ b/release/datafiles/blender_icons_update.py @@ -11,8 +11,8 @@ def run(cmd): BASEDIR = os.path.abspath(os.path.dirname(__file__)) -inkscape_bin = "inkscape" -blender_bin = "blender" +inkscape_bin = os.environ.get("INKSCAPE_BIN", "inkscape") +blender_bin = os.environ.get("BLENDER_BIN", "blender") if sys.platform == 'darwin': inkscape_app_path = '/Applications/Inkscape.app/Contents/Resources/script' -- cgit v1.2.3 From 963da9ff6e1c87bf340b5832f0c1ba2c28cbb338 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 09:38:19 +0200 Subject: UI: 4-state icon for view visibility popover This is a quick way to see if some of the object types in the scene are hidden or unselected. Icon design may change. --- release/datafiles/blender_icons.svg | 590 +++++++++++++++++++++ .../blender_icons16/icon16_vis_sel_00.dat | Bin 0 -> 1048 bytes .../blender_icons16/icon16_vis_sel_01.dat | Bin 0 -> 1048 bytes .../blender_icons16/icon16_vis_sel_10.dat | Bin 0 -> 1048 bytes .../blender_icons16/icon16_vis_sel_11.dat | Bin 0 -> 1048 bytes .../blender_icons32/icon32_vis_sel_00.dat | Bin 0 -> 4120 bytes .../blender_icons32/icon32_vis_sel_01.dat | Bin 0 -> 4120 bytes .../blender_icons32/icon32_vis_sel_10.dat | Bin 0 -> 4120 bytes .../blender_icons32/icon32_vis_sel_11.dat | Bin 0 -> 4120 bytes release/scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/editors/datafiles/CMakeLists.txt | 4 + source/blender/editors/include/UI_icons.h | 10 +- source/blender/makesrna/intern/rna_space.c | 15 + 13 files changed, 614 insertions(+), 7 deletions(-) create mode 100644 release/datafiles/blender_icons16/icon16_vis_sel_00.dat create mode 100644 release/datafiles/blender_icons16/icon16_vis_sel_01.dat create mode 100644 release/datafiles/blender_icons16/icon16_vis_sel_10.dat create mode 100644 release/datafiles/blender_icons16/icon16_vis_sel_11.dat create mode 100644 release/datafiles/blender_icons32/icon32_vis_sel_00.dat create mode 100644 release/datafiles/blender_icons32/icon32_vis_sel_01.dat create mode 100644 release/datafiles/blender_icons32/icon32_vis_sel_10.dat create mode 100644 release/datafiles/blender_icons32/icon32_vis_sel_11.dat diff --git a/release/datafiles/blender_icons.svg b/release/datafiles/blender_icons.svg index a14f2903b71..4174c575e67 100644 --- a/release/datafiles/blender_icons.svg +++ b/release/datafiles/blender_icons.svg @@ -32021,6 +32021,190 @@ style="fill:url(#linearGradient25387-9);fill-rule:evenodd;stroke:none" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + data; + /* Ignore selection values when view is off, intent is to show if visible objects aren't selectable. */ + const int view_value = (v3d->object_type_exclude_viewport != 0); + const int select_value = (v3d->object_type_exclude_select & ~v3d->object_type_exclude_viewport) != 0; + return ICON_VIS_SEL_11 + (view_value << 1) + select_value; +} + static PointerRNA rna_SpaceView3D_shading_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_View3DShading, ptr->data); @@ -3113,6 +3122,12 @@ static void rna_def_space_view3d(BlenderRNA *brna) } } + + /* Heper for drawing the icon. */ + prop = RNA_def_property(srna, "icon_from_show_object_viewport", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_SpaceView3D_icon_from_show_object_viewport_get", NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Visibility Iconm", ""); } /* Nested Structs */ -- cgit v1.2.3 From 21b6983b9d2ea41e596071e73056442adc658b3d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 10:07:32 +0200 Subject: UI: minor edits to overlay popover - Rename "Viewport Info" to "Text Info". Name was too vague, nearly everything is information, this currently only controls overlay text. - Swap text-info & 3D-cursor, making 3D-cursor less prominent. --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index dd8f1e4611f..7067cd6deca 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4009,9 +4009,9 @@ class VIEW3D_PT_overlay_guides(Panel): split = col.split() sub = split.column() - sub.prop(overlay, "show_cursor", text="3D Cursor") + sub.prop(overlay, "show_text", text="Text Info") sub = split.column() - sub.prop(overlay, "show_text", text="Viewport Info") + sub.prop(overlay, "show_cursor", text="3D Cursor") if shading.type == 'MATERIAL': col.prop(overlay, "show_look_dev") -- cgit v1.2.3 From 864a4cf64becfd63864832c9019a79b8926f2d39 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 10:37:20 +0200 Subject: Keymap: Modifiers to control mesh elem switching Shift/Ctrl control extend/expand when number keys are used to switch modes. --- source/blender/editors/mesh/mesh_ops.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 910076011d4..2bfc0634f1e 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -336,23 +336,21 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "vertex_only", true); /* selecting */ - - kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX); - kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE); - kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE); - - kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX); - RNA_boolean_set(kmi->ptr, "use_extend", true); - kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", TWOKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "type", SCE_SELECT_EDGE); - RNA_boolean_set(kmi->ptr, "use_extend", true); - kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", THREEKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "type", SCE_SELECT_FACE); - RNA_boolean_set(kmi->ptr, "use_extend", true); + for (int i = 0; i < 4; i++) { + const bool is_extend = (i & 1); + const bool is_expand = (i & 2); + const int key_modifier = (is_extend ? KM_SHIFT : 0) | (is_expand ? KM_CTRL : 0); + for (int j = 0; j < 3; j++) { + kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY + j, KM_PRESS, key_modifier, 0); + RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX << j); + if (is_extend) { + RNA_boolean_set(kmi->ptr, "use_extend", true); + } + if (is_expand) { + RNA_boolean_set(kmi->ptr, "use_expand", true); + } + } + } /* standard mouse selection goes via space_view3d */ kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); -- cgit v1.2.3 From 77928c2a091581939ec40231ce043c6a2f3bf783 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 10:48:18 +0200 Subject: UI: Group geometry in object visibility popover Makes it easy to quickly hide all non-geometry. --- release/scripts/startup/bl_ui/space_view3d.py | 53 ++++++++++++++++----------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 7067cd6deca..e3463017237 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3709,32 +3709,41 @@ class VIEW3D_PT_object_type_visibility(Panel): col = layout.column() - heading_pair = ("Visible", "Selectable") - attr_object_types = ( - "mesh", - "curve", - "surf", - "meta", - "font", - "armature", - "lattice", - "empty", - "camera", - "lamp", - "light_probe", - "speaker", + attr_object_types_all = ( + ( + "mesh", + "curve", + "surf", + "meta", + "font", + ), + ( + "armature", + "lattice", + "empty", + "camera", + "lamp", + "light_probe", + "speaker", + ), ) - attr_vis = [f"show_object_viewport_{attr}" for attr in attr_object_types] - attr_sel = [f"show_object_select_{attr}" for attr in attr_object_types] + is_first = True + for attr_object_types in attr_object_types_all: + if is_first is False: + col.separator() + is_first = False - for attr_v, attr_s in zip(attr_vis, attr_sel): - icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON' + attr_vis = ["show_object_viewport_" f"{attr:s}" for attr in attr_object_types] + attr_sel = ["show_object_select_" f"{attr:s}" for attr in attr_object_types] - row = col.row(align=True) - row.prop(view, attr_v) - row.active = getattr(view, attr_v) - row.prop(view, attr_s, text="", icon=icon_s, emboss=False) + for attr_v, attr_s in zip(attr_vis, attr_sel): + icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON' + + row = col.row(align=True) + row.prop(view, attr_v) + row.active = getattr(view, attr_v) + row.prop(view, attr_s, text="", icon=icon_s, emboss=False) class VIEW3D_PT_shading(Panel): -- cgit v1.2.3 From 75d69eab69307891f197ff1c93b8a7e4454cccf7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 10:54:30 +0200 Subject: Minor cleanup to last commit No need to make attr-lists with the current layout logic. --- release/scripts/startup/bl_ui/space_view3d.py | 53 ++++++++++++--------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index e3463017237..db5efeb43c2 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3709,41 +3709,36 @@ class VIEW3D_PT_object_type_visibility(Panel): col = layout.column() - attr_object_types_all = ( - ( - "mesh", - "curve", - "surf", - "meta", - "font", - ), - ( - "armature", - "lattice", - "empty", - "camera", - "lamp", - "light_probe", - "speaker", - ), + attr_object_types = ( + "mesh", + "curve", + "surf", + "meta", + "font", + None, + "armature", + "lattice", + "empty", + "camera", + "lamp", + "light_probe", + "speaker", ) - is_first = True - for attr_object_types in attr_object_types_all: - if is_first is False: + for attr in attr_object_types: + if attr is None: col.separator() - is_first = False + continue - attr_vis = ["show_object_viewport_" f"{attr:s}" for attr in attr_object_types] - attr_sel = ["show_object_select_" f"{attr:s}" for attr in attr_object_types] + attr_v = "show_object_viewport_" f"{attr:s}" + attr_s = "show_object_select_" f"{attr:s}" - for attr_v, attr_s in zip(attr_vis, attr_sel): - icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON' + icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON' - row = col.row(align=True) - row.prop(view, attr_v) - row.active = getattr(view, attr_v) - row.prop(view, attr_s, text="", icon=icon_s, emboss=False) + row = col.row(align=True) + row.prop(view, attr_v) + row.active = getattr(view, attr_v) + row.prop(view, attr_s, text="", icon=icon_s, emboss=False) class VIEW3D_PT_shading(Panel): -- cgit v1.2.3 From 0108ce1fe5b9b4f24b5bdce4924e9b058d0edfa3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 11:03:13 +0200 Subject: Cleanup: pep8, cycles --- intern/cycles/blender/addon/__init__.py | 6 +- intern/cycles/blender/addon/engine.py | 15 +- intern/cycles/blender/addon/properties.py | 1644 ++++++++++++------------- intern/cycles/blender/addon/ui.py | 20 +- intern/cycles/blender/addon/version_update.py | 64 +- 5 files changed, 883 insertions(+), 866 deletions(-) diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py index a2d6262fb20..038126278aa 100644 --- a/intern/cycles/blender/addon/__init__.py +++ b/intern/cycles/blender/addon/__init__.py @@ -45,9 +45,9 @@ if "bpy" in locals(): import bpy from . import ( - engine, - version_update, - ) + engine, + version_update, +) class CyclesRender(bpy.types.RenderEngine): diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index 1f97eff9bd0..08c6a65e5ad 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -82,15 +82,17 @@ def _parse_command_line(): if args.cycles_resumable_current_chunk is not None: import _cycles _cycles.set_resumable_chunk( - int(args.cycles_resumable_num_chunks), - int(args.cycles_resumable_current_chunk)) + int(args.cycles_resumable_num_chunks), + int(args.cycles_resumable_current_chunk), + ) elif args.cycles_resumable_start_chunk is not None and \ - args.cycles_resumable_end_chunk: + args.cycles_resumable_end_chunk: import _cycles _cycles.set_resumable_chunk_range( - int(args.cycles_resumable_num_chunks), - int(args.cycles_resumable_start_chunk), - int(args.cycles_resumable_end_chunk)) + int(args.cycles_resumable_num_chunks), + int(args.cycles_resumable_start_chunk), + int(args.cycles_resumable_end_chunk), + ) def init(): @@ -206,6 +208,7 @@ def system_info(): import _cycles return _cycles.system_info() + def register_passes(engine, scene, srl): engine.register_pass(scene, srl, "Combined", 4, "RGBA", 'COLOR') diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 4484dcfbfd7..c97d942af9d 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -31,7 +31,7 @@ import _cycles enum_devices = ( ('CPU', "CPU", "Use CPU for rendering"), ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in the system tab in the user preferences"), - ) +) if _cycles.with_network: enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),) @@ -39,34 +39,34 @@ if _cycles.with_network: enum_feature_set = ( ('SUPPORTED', "Supported", "Only use finished and supported features"), ('EXPERIMENTAL', "Experimental", "Use experimental and incomplete features that might be broken or change in the future", 'ERROR', 1), - ) +) enum_displacement_methods = ( ('BUMP', "Bump Only", "Bump mapping to simulate the appearance of displacement"), ('DISPLACEMENT', "Displacement Only", "Use true displacement of surface only, requires fine subdivision"), ('BOTH', "Displacement and Bump", "Combination of true displacement and bump mapping for finer detail"), - ) +) enum_bvh_layouts = ( ('BVH2', "BVH2", "", 1), ('BVH4', "BVH4", "", 2), - ) +) enum_bvh_types = ( ('DYNAMIC_BVH', "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"), ('STATIC_BVH', "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster"), - ) +) enum_filter_types = ( ('BOX', "Box", "Box filter"), ('GAUSSIAN', "Gaussian", "Gaussian filter"), ('BLACKMAN_HARRIS', "Blackman-Harris", "Blackman-Harris filter"), - ) +) enum_aperture_types = ( ('RADIUS', "Radius", "Directly change the size of the aperture"), ('FSTOP', "F-stop", "Change the size of the aperture by f-stop"), - ) +) enum_panorama_types = ( ('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"), @@ -74,23 +74,23 @@ enum_panorama_types = ( ('FISHEYE_EQUISOLID', "Fisheye Equisolid", "Similar to most fisheye modern lens, takes sensor dimensions into consideration"), ('MIRRORBALL', "Mirror Ball", "Uses the mirror ball mapping"), - ) +) enum_curve_primitives = ( ('TRIANGLES', "Triangles", "Create triangle geometry around strands"), ('LINE_SEGMENTS', "Line Segments", "Use line segment primitives"), ('CURVE_SEGMENTS', "Curve Segments", "Use segmented cardinal curve primitives"), - ) +) enum_triangle_curves = ( ('CAMERA_TRIANGLES', "Planes", "Create individual triangles forming planes that face camera"), ('TESSELLATED_TRIANGLES', "Tessellated", "Create mesh surrounding each strand"), - ) +) enum_curve_shape = ( ('RIBBONS', "Ribbons", "Ignore thickness of each strand"), ('THICK', "Thick", "Use thickness of strand when rendering"), - ) +) enum_tile_order = ( ('CENTER', "Center", "Render from center to the edges"), @@ -99,46 +99,46 @@ enum_tile_order = ( ('TOP_TO_BOTTOM', "Top to Bottom", "Render from top to bottom"), ('BOTTOM_TO_TOP', "Bottom to Top", "Render from bottom to top"), ('HILBERT_SPIRAL', "Hilbert Spiral", "Render in a Hilbert Spiral"), - ) +) enum_use_layer_samples = ( ('USE', "Use", "Per render layer number of samples override scene samples"), ('BOUNDED', "Bounded", "Bound per render layer number of samples by global samples"), ('IGNORE', "Ignore", "Ignore per render layer number of samples"), - ) +) enum_sampling_pattern = ( ('SOBOL', "Sobol", "Use Sobol random sampling pattern"), ('CORRELATED_MUTI_JITTER', "Correlated Multi-Jitter", "Use Correlated Multi-Jitter random sampling pattern"), - ) +) enum_integrator = ( ('BRANCHED_PATH', "Branched Path Tracing", "Path tracing integrator that branches on the first bounce, giving more control over the number of light and material samples"), ('PATH', "Path Tracing", "Pure path tracing integrator"), - ) +) enum_volume_sampling = ( ('DISTANCE', "Distance", "Use distance sampling, best for dense volumes with lights far away"), ('EQUIANGULAR', "Equiangular", "Use equiangular sampling, best for volumes with low density with light inside or near the volume"), ('MULTIPLE_IMPORTANCE', "Multiple Importance", "Combine distance and equi-angular sampling for volumes where neither method is ideal"), - ) +) enum_volume_interpolation = ( ('LINEAR', "Linear", "Good smoothness and speed"), ('CUBIC', "Cubic", "Smoothed high quality interpolation, but slower") - ) +) enum_world_mis = ( ('NONE', "None", "Don't sample the background, faster but might cause noise for non-solid backgrounds"), ('AUTOMATIC', "Auto", "Automatically try to determine the best setting"), ('MANUAL', "Manual", "Manually set the resolution of the sampling map, higher values are slower and require more memory but reduce noise") - ) +) enum_device_type = ( ('CPU', "CPU", "CPU", 0), ('CUDA', "CUDA", "CUDA", 1), ('OPENCL', "OpenCL", "OpenCL", 2) - ) +) enum_texture_limit = ( ('OFF', "No Limit", "No texture size limit", 0), @@ -149,423 +149,424 @@ enum_texture_limit = ( ('2048', "2048", "Limit texture size to 2048 pixels", 5), ('4096', "4096", "Limit texture size to 4096 pixels", 6), ('8192', "8192", "Limit texture size to 8192 pixels", 7), - ) +) + class CyclesRenderSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.Scene.cycles = PointerProperty( - name="Cycles Render Settings", - description="Cycles render settings", - type=cls, - ) + name="Cycles Render Settings", + description="Cycles render settings", + type=cls, + ) cls.device = EnumProperty( - name="Device", - description="Device to use for rendering", - items=enum_devices, - default='CPU', - ) + name="Device", + description="Device to use for rendering", + items=enum_devices, + default='CPU', + ) cls.feature_set = EnumProperty( - name="Feature Set", - description="Feature set to use for rendering", - items=enum_feature_set, - default='SUPPORTED', - ) + name="Feature Set", + description="Feature set to use for rendering", + items=enum_feature_set, + default='SUPPORTED', + ) cls.shading_system = BoolProperty( - name="Open Shading Language", - description="Use Open Shading Language (CPU rendering only)", - ) + name="Open Shading Language", + description="Use Open Shading Language (CPU rendering only)", + ) cls.progressive = EnumProperty( - name="Integrator", - description="Method to sample lights and materials", - items=enum_integrator, - default='PATH', - ) + name="Integrator", + description="Method to sample lights and materials", + items=enum_integrator, + default='PATH', + ) cls.use_square_samples = BoolProperty( - name="Square Samples", - description="Square sampling values for easier artist control", - default=False, - ) + name="Square Samples", + description="Square sampling values for easier artist control", + default=False, + ) cls.samples = IntProperty( - name="Samples", - description="Number of samples to render for each pixel", - min=1, max=2147483647, - default=128, - ) + name="Samples", + description="Number of samples to render for each pixel", + min=1, max=2147483647, + default=128, + ) cls.preview_samples = IntProperty( - name="Preview Samples", - description="Number of samples to render in the viewport, unlimited if 0", - min=0, max=2147483647, - default=32, - ) + name="Preview Samples", + description="Number of samples to render in the viewport, unlimited if 0", + min=0, max=2147483647, + default=32, + ) cls.preview_pause = BoolProperty( - name="Pause Preview", - description="Pause all viewport preview renders", - default=False, - ) + name="Pause Preview", + description="Pause all viewport preview renders", + default=False, + ) cls.preview_active_layer = BoolProperty( - name="Preview Active Layer", - description="Preview active render layer in viewport", - default=False, - ) + name="Preview Active Layer", + description="Preview active render layer in viewport", + default=False, + ) cls.aa_samples = IntProperty( - name="AA Samples", - description="Number of antialiasing samples to render for each pixel", - min=1, max=2097151, - default=128, - ) + name="AA Samples", + description="Number of antialiasing samples to render for each pixel", + min=1, max=2097151, + default=128, + ) cls.preview_aa_samples = IntProperty( - name="AA Samples", - description="Number of antialiasing samples to render in the viewport, unlimited if 0", - min=0, max=2097151, - default=32, - ) + name="AA Samples", + description="Number of antialiasing samples to render in the viewport, unlimited if 0", + min=0, max=2097151, + default=32, + ) cls.diffuse_samples = IntProperty( - name="Diffuse Samples", - description="Number of diffuse bounce samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + name="Diffuse Samples", + description="Number of diffuse bounce samples to render for each AA sample", + min=1, max=1024, + default=1, + ) cls.glossy_samples = IntProperty( - name="Glossy Samples", - description="Number of glossy bounce samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + name="Glossy Samples", + description="Number of glossy bounce samples to render for each AA sample", + min=1, max=1024, + default=1, + ) cls.transmission_samples = IntProperty( - name="Transmission Samples", - description="Number of transmission bounce samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + name="Transmission Samples", + description="Number of transmission bounce samples to render for each AA sample", + min=1, max=1024, + default=1, + ) cls.ao_samples = IntProperty( - name="Ambient Occlusion Samples", - description="Number of ambient occlusion samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + name="Ambient Occlusion Samples", + description="Number of ambient occlusion samples to render for each AA sample", + min=1, max=1024, + default=1, + ) cls.mesh_light_samples = IntProperty( - name="Mesh Light Samples", - description="Number of mesh emission light samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + name="Mesh Light Samples", + description="Number of mesh emission light samples to render for each AA sample", + min=1, max=1024, + default=1, + ) cls.subsurface_samples = IntProperty( - name="Subsurface Samples", - description="Number of subsurface scattering samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + name="Subsurface Samples", + description="Number of subsurface scattering samples to render for each AA sample", + min=1, max=1024, + default=1, + ) cls.volume_samples = IntProperty( - name="Volume Samples", - description="Number of volume scattering samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + name="Volume Samples", + description="Number of volume scattering samples to render for each AA sample", + min=1, max=1024, + default=1, + ) cls.sampling_pattern = EnumProperty( - name="Sampling Pattern", - description="Random sampling pattern used by the integrator", - items=enum_sampling_pattern, - default='SOBOL', - ) + name="Sampling Pattern", + description="Random sampling pattern used by the integrator", + items=enum_sampling_pattern, + default='SOBOL', + ) cls.use_layer_samples = EnumProperty( - name="Layer Samples", - description="How to use per render layer sample settings", - items=enum_use_layer_samples, - default='USE', - ) + name="Layer Samples", + description="How to use per render layer sample settings", + items=enum_use_layer_samples, + default='USE', + ) cls.sample_all_lights_direct = BoolProperty( - name="Sample All Direct Lights", - description="Sample all lights (for direct samples), rather than randomly picking one", - default=True, - ) + name="Sample All Direct Lights", + description="Sample all lights (for direct samples), rather than randomly picking one", + default=True, + ) cls.sample_all_lights_indirect = BoolProperty( - name="Sample All Indirect Lights", - description="Sample all lights (for indirect samples), rather than randomly picking one", - default=True, - ) + name="Sample All Indirect Lights", + description="Sample all lights (for indirect samples), rather than randomly picking one", + default=True, + ) cls.light_sampling_threshold = FloatProperty( - name="Light Sampling Threshold", - description="Probabilistically terminate light samples when the light contribution is below this threshold (more noise but faster rendering). " - "Zero disables the test and never ignores lights", - min=0.0, max=1.0, - default=0.01, - ) + name="Light Sampling Threshold", + description="Probabilistically terminate light samples when the light contribution is below this threshold (more noise but faster rendering). " + "Zero disables the test and never ignores lights", + min=0.0, max=1.0, + default=0.01, + ) cls.caustics_reflective = BoolProperty( - name="Reflective Caustics", - description="Use reflective caustics, resulting in a brighter image (more noise but added realism)", - default=True, - ) + name="Reflective Caustics", + description="Use reflective caustics, resulting in a brighter image (more noise but added realism)", + default=True, + ) cls.caustics_refractive = BoolProperty( - name="Refractive Caustics", - description="Use refractive caustics, resulting in a brighter image (more noise but added realism)", - default=True, - ) + name="Refractive Caustics", + description="Use refractive caustics, resulting in a brighter image (more noise but added realism)", + default=True, + ) cls.blur_glossy = FloatProperty( - name="Filter Glossy", - description="Adaptively blur glossy shaders after blurry bounces, " - "to reduce noise at the cost of accuracy", - min=0.0, max=10.0, - default=1.0, - ) + name="Filter Glossy", + description="Adaptively blur glossy shaders after blurry bounces, " + "to reduce noise at the cost of accuracy", + min=0.0, max=10.0, + default=1.0, + ) cls.max_bounces = IntProperty( - name="Max Bounces", - description="Total maximum number of bounces", - min=0, max=1024, - default=12, - ) + name="Max Bounces", + description="Total maximum number of bounces", + min=0, max=1024, + default=12, + ) cls.diffuse_bounces = IntProperty( - name="Diffuse Bounces", - description="Maximum number of diffuse reflection bounces, bounded by total maximum", - min=0, max=1024, - default=4, - ) + name="Diffuse Bounces", + description="Maximum number of diffuse reflection bounces, bounded by total maximum", + min=0, max=1024, + default=4, + ) cls.glossy_bounces = IntProperty( - name="Glossy Bounces", - description="Maximum number of glossy reflection bounces, bounded by total maximum", - min=0, max=1024, - default=4, - ) + name="Glossy Bounces", + description="Maximum number of glossy reflection bounces, bounded by total maximum", + min=0, max=1024, + default=4, + ) cls.transmission_bounces = IntProperty( - name="Transmission Bounces", - description="Maximum number of transmission bounces, bounded by total maximum", - min=0, max=1024, - default=12, - ) + name="Transmission Bounces", + description="Maximum number of transmission bounces, bounded by total maximum", + min=0, max=1024, + default=12, + ) cls.volume_bounces = IntProperty( - name="Volume Bounces", - description="Maximum number of volumetric scattering events", - min=0, max=1024, - default=0, - ) + name="Volume Bounces", + description="Maximum number of volumetric scattering events", + min=0, max=1024, + default=0, + ) cls.transparent_max_bounces = IntProperty( - name="Transparent Max Bounces", - description="Maximum number of transparent bounces", - min=0, max=1024, - default=8, - ) + name="Transparent Max Bounces", + description="Maximum number of transparent bounces", + min=0, max=1024, + default=8, + ) cls.volume_step_size = FloatProperty( - name="Step Size", - description="Distance between volume shader samples when rendering the volume " - "(lower values give more accurate and detailed results, but also increased render time)", - default=0.1, - min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4 - ) + name="Step Size", + description="Distance between volume shader samples when rendering the volume " + "(lower values give more accurate and detailed results, but also increased render time)", + default=0.1, + min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4 + ) cls.volume_max_steps = IntProperty( - name="Max Steps", - description="Maximum number of steps through the volume before giving up, " - "to avoid extremely long render times with big objects or small step sizes", - default=1024, - min=2, max=65536 - ) + name="Max Steps", + description="Maximum number of steps through the volume before giving up, " + "to avoid extremely long render times with big objects or small step sizes", + default=1024, + min=2, max=65536 + ) cls.dicing_rate = FloatProperty( - name="Dicing Rate", - description="Size of a micropolygon in pixels", - min=0.1, max=1000.0, soft_min=0.5, - default=1.0, - subtype="PIXEL" - ) + name="Dicing Rate", + description="Size of a micropolygon in pixels", + min=0.1, max=1000.0, soft_min=0.5, + default=1.0, + subtype="PIXEL" + ) cls.preview_dicing_rate = FloatProperty( - name="Preview Dicing Rate", - description="Size of a micropolygon in pixels during preview render", - min=0.1, max=1000.0, soft_min=0.5, - default=8.0, - subtype="PIXEL" - ) + name="Preview Dicing Rate", + description="Size of a micropolygon in pixels during preview render", + min=0.1, max=1000.0, soft_min=0.5, + default=8.0, + subtype="PIXEL" + ) cls.max_subdivisions = IntProperty( - name="Max Subdivisions", - description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation", - min=0, max=16, - default=12, - ) + name="Max Subdivisions", + description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation", + min=0, max=16, + default=12, + ) cls.dicing_camera = PointerProperty( - name="Dicing Camera", - description="Camera to use as reference point when subdividing geometry, useful to avoid crawling " - "artifacts in animations when the scene camera is moving", - type=bpy.types.Object, - poll=lambda self, obj: obj.type == 'CAMERA', - ) + name="Dicing Camera", + description="Camera to use as reference point when subdividing geometry, useful to avoid crawling " + "artifacts in animations when the scene camera is moving", + type=bpy.types.Object, + poll=lambda self, obj: obj.type == 'CAMERA', + ) cls.offscreen_dicing_scale = FloatProperty( - name="Offscreen Dicing Scale", - description="Multiplier for dicing rate of geometry outside of the camera view. The dicing rate " - "of objects is gradually increased the further they are outside the camera view. " - "Lower values provide higher quality reflections and shadows for off screen objects, " - "while higher values use less memory", - min=1.0, soft_max=25.0, - default=4.0, - ) + name="Offscreen Dicing Scale", + description="Multiplier for dicing rate of geometry outside of the camera view. The dicing rate " + "of objects is gradually increased the further they are outside the camera view. " + "Lower values provide higher quality reflections and shadows for off screen objects, " + "while higher values use less memory", + min=1.0, soft_max=25.0, + default=4.0, + ) cls.film_exposure = FloatProperty( - name="Exposure", - description="Image brightness scale", - min=0.0, max=10.0, - default=1.0, - ) + name="Exposure", + description="Image brightness scale", + min=0.0, max=10.0, + default=1.0, + ) cls.film_transparent = BoolProperty( - name="Transparent", - description="World background is transparent, for compositing the render over another background", - default=False, - ) + name="Transparent", + description="World background is transparent, for compositing the render over another background", + default=False, + ) cls.film_transparent_glass = BoolProperty( - name="Transparent Glass", - description="Render transmissive surfaces as transparent, for compositing glass over another background", - default=False, - ) + name="Transparent Glass", + description="Render transmissive surfaces as transparent, for compositing glass over another background", + default=False, + ) cls.film_transparent_roughness = FloatProperty( - name="Transparent Roughness Threshold", - description="For transparent transmission, keep surfaces with roughness above the threshold opaque", - min=0.0, max=1.0, - default=0.1, - ) + name="Transparent Roughness Threshold", + description="For transparent transmission, keep surfaces with roughness above the threshold opaque", + min=0.0, max=1.0, + default=0.1, + ) # Really annoyingly, we have to keep it around for a few releases, # otherwise forward compatibility breaks in really bad manner: CRASH! # # TODO(sergey): Remove this during 2.8x series of Blender. cls.filter_type = EnumProperty( - name="Filter Type", - description="Pixel filter type", - items=enum_filter_types, - default='BLACKMAN_HARRIS', - ) + name="Filter Type", + description="Pixel filter type", + items=enum_filter_types, + default='BLACKMAN_HARRIS', + ) cls.pixel_filter_type = EnumProperty( - name="Filter Type", - description="Pixel filter type", - items=enum_filter_types, - default='BLACKMAN_HARRIS', - ) + name="Filter Type", + description="Pixel filter type", + items=enum_filter_types, + default='BLACKMAN_HARRIS', + ) cls.filter_width = FloatProperty( - name="Filter Width", - description="Pixel filter width", - min=0.01, max=10.0, - default=1.5, - ) + name="Filter Width", + description="Pixel filter width", + min=0.01, max=10.0, + default=1.5, + ) cls.seed = IntProperty( - name="Seed", - description="Seed value for integrator to get different noise patterns", - min=0, max=2147483647, - default=0, - ) + name="Seed", + description="Seed value for integrator to get different noise patterns", + min=0, max=2147483647, + default=0, + ) cls.use_animated_seed = BoolProperty( - name="Use Animated Seed", - description="Use different seed values (and hence noise patterns) at different frames", - default=False, - ) + name="Use Animated Seed", + description="Use different seed values (and hence noise patterns) at different frames", + default=False, + ) cls.sample_clamp_direct = FloatProperty( - name="Clamp Direct", - description="If non-zero, the maximum value for a direct sample, " - "higher values will be scaled down to avoid too " - "much noise and slow convergence at the cost of accuracy", - min=0.0, max=1e8, - default=0.0, - ) + name="Clamp Direct", + description="If non-zero, the maximum value for a direct sample, " + "higher values will be scaled down to avoid too " + "much noise and slow convergence at the cost of accuracy", + min=0.0, max=1e8, + default=0.0, + ) cls.sample_clamp_indirect = FloatProperty( - name="Clamp Indirect", - description="If non-zero, the maximum value for an indirect sample, " - "higher values will be scaled down to avoid too " - "much noise and slow convergence at the cost of accuracy", - min=0.0, max=1e8, - default=10.0, - ) + name="Clamp Indirect", + description="If non-zero, the maximum value for an indirect sample, " + "higher values will be scaled down to avoid too " + "much noise and slow convergence at the cost of accuracy", + min=0.0, max=1e8, + default=10.0, + ) cls.debug_tile_size = IntProperty( - name="Tile Size", - description="", - min=1, max=4096, - default=1024, - ) + name="Tile Size", + description="", + min=1, max=4096, + default=1024, + ) cls.preview_start_resolution = IntProperty( - name="Start Resolution", - description="Resolution to start rendering preview at, " - "progressively increasing it to the full viewport size", - min=8, max=16384, - default=64, - ) + name="Start Resolution", + description="Resolution to start rendering preview at, " + "progressively increasing it to the full viewport size", + min=8, max=16384, + default=64, + ) cls.debug_reset_timeout = FloatProperty( - name="Reset timeout", - description="", - min=0.01, max=10.0, - default=0.1, - ) + name="Reset timeout", + description="", + min=0.01, max=10.0, + default=0.1, + ) cls.debug_cancel_timeout = FloatProperty( - name="Cancel timeout", - description="", - min=0.01, max=10.0, - default=0.1, - ) + name="Cancel timeout", + description="", + min=0.01, max=10.0, + default=0.1, + ) cls.debug_text_timeout = FloatProperty( - name="Text timeout", - description="", - min=0.01, max=10.0, - default=1.0, - ) + name="Text timeout", + description="", + min=0.01, max=10.0, + default=1.0, + ) cls.debug_bvh_type = EnumProperty( - name="Viewport BVH Type", - description="Choose between faster updates, or faster render", - items=enum_bvh_types, - default='DYNAMIC_BVH', - ) + name="Viewport BVH Type", + description="Choose between faster updates, or faster render", + items=enum_bvh_types, + default='DYNAMIC_BVH', + ) cls.debug_use_spatial_splits = BoolProperty( - name="Use Spatial Splits", - description="Use BVH spatial splits: longer builder time, faster render", - default=False, - ) + name="Use Spatial Splits", + description="Use BVH spatial splits: longer builder time, faster render", + default=False, + ) cls.debug_use_hair_bvh = BoolProperty( - name="Use Hair BVH", - description="Use special type BVH optimized for hair (uses more ram but renders faster)", - default=True, - ) + name="Use Hair BVH", + description="Use special type BVH optimized for hair (uses more ram but renders faster)", + default=True, + ) cls.debug_bvh_time_steps = IntProperty( - name="BVH Time Steps", - description="Split BVH primitives by this number of time steps to speed up render time in cost of memory", - default=0, - min=0, max=16, - ) + name="BVH Time Steps", + description="Split BVH primitives by this number of time steps to speed up render time in cost of memory", + default=0, + min=0, max=16, + ) cls.tile_order = EnumProperty( - name="Tile Order", - description="Tile order for rendering", - items=enum_tile_order, - default='HILBERT_SPIRAL', - options=set(), # Not animatable! - ) + name="Tile Order", + description="Tile order for rendering", + items=enum_tile_order, + default='HILBERT_SPIRAL', + options=set(), # Not animatable! + ) cls.use_progressive_refine = BoolProperty( - name="Progressive Refine", - description="Instead of rendering each tile until it is finished, " - "refine the whole image progressively " - "(this renders somewhat slower, " - "but time can be saved by manually stopping the render when the noise is low enough)", - default=False, - ) + name="Progressive Refine", + description="Instead of rendering each tile until it is finished, " + "refine the whole image progressively " + "(this renders somewhat slower, " + "but time can be saved by manually stopping the render when the noise is low enough)", + default=False, + ) cls.bake_type = EnumProperty( name="Bake Type", @@ -584,34 +585,34 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): ('GLOSSY', "Glossy", ""), ('TRANSMISSION', "Transmission", ""), ('SUBSURFACE', "Subsurface", ""), - ), - ) + ), + ) cls.use_camera_cull = BoolProperty( - name="Use Camera Cull", - description="Allow objects to be culled based on the camera frustum", - default=False, - ) + name="Use Camera Cull", + description="Allow objects to be culled based on the camera frustum", + default=False, + ) cls.camera_cull_margin = FloatProperty( - name="Camera Cull Margin", - description="Margin for the camera space culling", - default=0.1, - min=0.0, max=5.0 - ) + name="Camera Cull Margin", + description="Margin for the camera space culling", + default=0.1, + min=0.0, max=5.0 + ) cls.use_distance_cull = BoolProperty( - name="Use Distance Cull", - description="Allow objects to be culled based on the distance from camera", - default=False, - ) + name="Use Distance Cull", + description="Allow objects to be culled based on the distance from camera", + default=False, + ) cls.distance_cull_margin = FloatProperty( - name="Cull Distance", - description="Cull objects which are further away from camera than this distance", - default=50, - min=0.0 - ) + name="Cull Distance", + description="Cull objects which are further away from camera than this distance", + default=50, + min=0.0 + ) cls.motion_blur_position = EnumProperty( name="Motion Blur Position", @@ -621,8 +622,8 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): ('START', "Start on Frame", "The shutter opens at the current frame"), ('CENTER', "Center on Frame", "The shutter is open during the current frame"), ('END', "End on Frame", "The shutter closes at the current frame"), - ), - ) + ), + ) cls.rolling_shutter_type = EnumProperty( name="Shutter Type", @@ -632,43 +633,43 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): ('NONE', "None", "No rolling shutter effect used"), ('TOP', "Top-Bottom", "Sensor is being scanned from top to bottom") # TODO(seergey): Are there real cameras with different scanning direction? - ), - ) + ), + ) cls.rolling_shutter_duration = FloatProperty( name="Rolling Shutter Duration", description="Scanline \"exposure\" time for the rolling shutter effect", default=0.1, min=0.0, max=1.0, - ) + ) cls.texture_limit = EnumProperty( name="Viewport Texture Limit", default='OFF', description="Limit texture size used by viewport rendering", items=enum_texture_limit - ) + ) cls.texture_limit_render = EnumProperty( name="Render Texture Limit", default='OFF', description="Limit texture size used by final rendering", items=enum_texture_limit - ) + ) cls.ao_bounces = IntProperty( name="AO Bounces", default=0, description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature", min=0, max=1024, - ) + ) cls.ao_bounces_render = IntProperty( name="AO Bounces Render", default=0, description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature", min=0, max=1024, - ) + ) # Various fine-tuning debug flags @@ -683,10 +684,10 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): cls.debug_use_cpu_sse3 = BoolProperty(name="SSE3", default=True) cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True) cls.debug_bvh_layout = EnumProperty( - name="BVH Layout", - items=enum_bvh_layouts, - default='BVH4', - ) + name="BVH Layout", + items=enum_bvh_layouts, + default='BVH4', + ) cls.debug_use_cpu_split_kernel = BoolProperty(name="Split Kernel", default=False) cls.debug_use_cuda_adaptive_compile = BoolProperty(name="Adaptive Compile", default=False) @@ -699,9 +700,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): ('DEFAULT', "Default", ""), ('MEGA', "Mega", ""), ('SPLIT', "Split", ""), - ), + ), update=devices_update_callback - ) + ) cls.debug_opencl_device_type = EnumProperty( name="OpenCL Device Type", @@ -713,20 +714,20 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): ('CPU', "CPU", ""), ('GPU', "GPU", ""), ('ACCELERATOR', "Accelerator", ""), - ), + ), update=devices_update_callback - ) + ) cls.debug_opencl_kernel_single_program = BoolProperty( name="Single Program", default=True, update=devices_update_callback, - ) + ) cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False) cls.debug_opencl_mem_limit = IntProperty(name="Memory limit", default=0, - description="Artificial limit on OpenCL memory usage in MB (0 to disable limit)") + description="Artificial limit on OpenCL memory usage in MB (0 to disable limit)") @classmethod def unregister(cls): @@ -739,101 +740,101 @@ class CyclesCameraSettings(bpy.types.PropertyGroup): import math bpy.types.Camera.cycles = PointerProperty( - name="Cycles Camera Settings", - description="Cycles camera settings", - type=cls, - ) + name="Cycles Camera Settings", + description="Cycles camera settings", + type=cls, + ) cls.aperture_type = EnumProperty( - name="Aperture Type", - description="Use f-stop number or aperture radius", - items=enum_aperture_types, - default='RADIUS', - ) + name="Aperture Type", + description="Use f-stop number or aperture radius", + items=enum_aperture_types, + default='RADIUS', + ) cls.aperture_fstop = FloatProperty( - name="Aperture f-stop", - description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)", - min=0.0, soft_min=0.1, soft_max=64.0, - default=5.6, - step=10, - precision=1, - ) + name="Aperture f-stop", + description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)", + min=0.0, soft_min=0.1, soft_max=64.0, + default=5.6, + step=10, + precision=1, + ) cls.aperture_size = FloatProperty( - name="Aperture Size", - description="Radius of the aperture for depth of field (higher values give more defocus)", - min=0.0, soft_max=10.0, - default=0.0, - step=1, - precision=4, - subtype='DISTANCE', - ) + name="Aperture Size", + description="Radius of the aperture for depth of field (higher values give more defocus)", + min=0.0, soft_max=10.0, + default=0.0, + step=1, + precision=4, + subtype='DISTANCE', + ) cls.aperture_blades = IntProperty( - name="Aperture Blades", - description="Number of blades in aperture for polygonal bokeh (at least 3)", - min=0, max=100, - default=0, - ) + name="Aperture Blades", + description="Number of blades in aperture for polygonal bokeh (at least 3)", + min=0, max=100, + default=0, + ) cls.aperture_rotation = FloatProperty( - name="Aperture Rotation", - description="Rotation of blades in aperture", - soft_min=-math.pi, soft_max=math.pi, - subtype='ANGLE', - default=0, - ) + name="Aperture Rotation", + description="Rotation of blades in aperture", + soft_min=-math.pi, soft_max=math.pi, + subtype='ANGLE', + default=0, + ) cls.aperture_ratio = FloatProperty( - name="Aperture Ratio", - description="Distortion to simulate anamorphic lens bokeh", - min=0.01, soft_min=1.0, soft_max=2.0, - default=1.0, - precision=4, - ) + name="Aperture Ratio", + description="Distortion to simulate anamorphic lens bokeh", + min=0.01, soft_min=1.0, soft_max=2.0, + default=1.0, + precision=4, + ) cls.panorama_type = EnumProperty( - name="Panorama Type", - description="Distortion to use for the calculation", - items=enum_panorama_types, - default='FISHEYE_EQUISOLID', - ) + name="Panorama Type", + description="Distortion to use for the calculation", + items=enum_panorama_types, + default='FISHEYE_EQUISOLID', + ) cls.fisheye_fov = FloatProperty( - name="Field of View", - description="Field of view for the fisheye lens", - min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi, - subtype='ANGLE', - default=math.pi, - ) + name="Field of View", + description="Field of view for the fisheye lens", + min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi, + subtype='ANGLE', + default=math.pi, + ) cls.fisheye_lens = FloatProperty( - name="Fisheye Lens", - description="Lens focal length (mm)", - min=0.01, soft_max=15.0, max=100.0, - default=10.5, - ) + name="Fisheye Lens", + description="Lens focal length (mm)", + min=0.01, soft_max=15.0, max=100.0, + default=10.5, + ) cls.latitude_min = FloatProperty( - name="Min Latitude", - description="Minimum latitude (vertical angle) for the equirectangular lens", - min=-0.5 * math.pi, max=0.5 * math.pi, - subtype='ANGLE', - default=-0.5 * math.pi, - ) + name="Min Latitude", + description="Minimum latitude (vertical angle) for the equirectangular lens", + min=-0.5 * math.pi, max=0.5 * math.pi, + subtype='ANGLE', + default=-0.5 * math.pi, + ) cls.latitude_max = FloatProperty( - name="Max Latitude", - description="Maximum latitude (vertical angle) for the equirectangular lens", - min=-0.5 * math.pi, max=0.5 * math.pi, - subtype='ANGLE', - default=0.5 * math.pi, - ) + name="Max Latitude", + description="Maximum latitude (vertical angle) for the equirectangular lens", + min=-0.5 * math.pi, max=0.5 * math.pi, + subtype='ANGLE', + default=0.5 * math.pi, + ) cls.longitude_min = FloatProperty( - name="Min Longitude", - description="Minimum longitude (horizontal angle) for the equirectangular lens", - min=-math.pi, max=math.pi, - subtype='ANGLE', - default=-math.pi, - ) + name="Min Longitude", + description="Minimum longitude (horizontal angle) for the equirectangular lens", + min=-math.pi, max=math.pi, + subtype='ANGLE', + default=-math.pi, + ) cls.longitude_max = FloatProperty( - name="Max Longitude", - description="Maximum longitude (horizontal angle) for the equirectangular lens", - min=-math.pi, max=math.pi, - subtype='ANGLE', - default=math.pi, - ) + name="Max Longitude", + description="Maximum longitude (horizontal angle) for the equirectangular lens", + min=-math.pi, max=math.pi, + subtype='ANGLE', + default=math.pi, + ) @classmethod def unregister(cls): @@ -844,49 +845,49 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.Material.cycles = PointerProperty( - name="Cycles Material Settings", - description="Cycles material settings", - type=cls, - ) + name="Cycles Material Settings", + description="Cycles material settings", + type=cls, + ) cls.sample_as_light = BoolProperty( - name="Multiple Importance Sample", - description="Use multiple importance sampling for this material, " - "disabling may reduce overall noise for large " - "objects that emit little light compared to other light sources", - default=True, - ) + name="Multiple Importance Sample", + description="Use multiple importance sampling for this material, " + "disabling may reduce overall noise for large " + "objects that emit little light compared to other light sources", + default=True, + ) cls.use_transparent_shadow = BoolProperty( - name="Transparent Shadows", - description="Use transparent shadows for this material if it contains a Transparent BSDF, " - "disabling will render faster but not give accurate shadows", - default=True, - ) + name="Transparent Shadows", + description="Use transparent shadows for this material if it contains a Transparent BSDF, " + "disabling will render faster but not give accurate shadows", + default=True, + ) cls.homogeneous_volume = BoolProperty( - name="Homogeneous Volume", - description="When using volume rendering, assume volume has the same density everywhere " - "(not using any textures), for faster rendering", - default=False, - ) + name="Homogeneous Volume", + description="When using volume rendering, assume volume has the same density everywhere " + "(not using any textures), for faster rendering", + default=False, + ) cls.volume_sampling = EnumProperty( - name="Volume Sampling", - description="Sampling method to use for volumes", - items=enum_volume_sampling, - default='MULTIPLE_IMPORTANCE', - ) + name="Volume Sampling", + description="Sampling method to use for volumes", + items=enum_volume_sampling, + default='MULTIPLE_IMPORTANCE', + ) cls.volume_interpolation = EnumProperty( - name="Volume Interpolation", - description="Interpolation method to use for smoke/fire volumes", - items=enum_volume_interpolation, - default='LINEAR', - ) + name="Volume Interpolation", + description="Interpolation method to use for smoke/fire volumes", + items=enum_volume_interpolation, + default='LINEAR', + ) cls.displacement_method = EnumProperty( - name="Displacement Method", - description="Method to use for the displacement", - items=enum_displacement_methods, - default='DISPLACEMENT', - ) + name="Displacement Method", + description="Method to use for the displacement", + items=enum_displacement_methods, + default='DISPLACEMENT', + ) @classmethod def unregister(cls): @@ -897,39 +898,39 @@ class CyclesLampSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.Lamp.cycles = PointerProperty( - name="Cycles Lamp Settings", - description="Cycles lamp settings", - type=cls, - ) + name="Cycles Lamp Settings", + description="Cycles lamp settings", + type=cls, + ) cls.cast_shadow = BoolProperty( - name="Cast Shadow", - description="Lamp casts shadows", - default=True, - ) + name="Cast Shadow", + description="Lamp casts shadows", + default=True, + ) cls.samples = IntProperty( - name="Samples", - description="Number of light samples to render for each AA sample", - min=1, max=10000, - default=1, - ) + name="Samples", + description="Number of light samples to render for each AA sample", + min=1, max=10000, + default=1, + ) cls.max_bounces = IntProperty( - name="Max Bounces", - description="Maximum number of bounces the light will contribute to the render", - min=0, max=1024, - default=1024, - ) + name="Max Bounces", + description="Maximum number of bounces the light will contribute to the render", + min=0, max=1024, + default=1024, + ) cls.use_multiple_importance_sampling = BoolProperty( - name="Multiple Importance Sample", - description="Use multiple importance sampling for the lamp, " - "reduces noise for area lamps and sharp glossy materials", - default=True, - ) + name="Multiple Importance Sample", + description="Use multiple importance sampling for the lamp, " + "reduces noise for area lamps and sharp glossy materials", + default=True, + ) cls.is_portal = BoolProperty( - name="Is Portal", - description="Use this area lamp to guide sampling of the background, " - "note that this will make the lamp invisible", - default=False, - ) + name="Is Portal", + description="Use this area lamp to guide sampling of the background, " + "note that this will make the lamp invisible", + default=False, + ) @classmethod def unregister(cls): @@ -940,54 +941,54 @@ class CyclesWorldSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.World.cycles = PointerProperty( - name="Cycles World Settings", - description="Cycles world settings", - type=cls, - ) + name="Cycles World Settings", + description="Cycles world settings", + type=cls, + ) cls.sampling_method = EnumProperty( - name="Sampling method", - description="How to sample the background light", - items=enum_world_mis, - default='AUTOMATIC', - ) + name="Sampling method", + description="How to sample the background light", + items=enum_world_mis, + default='AUTOMATIC', + ) cls.sample_map_resolution = IntProperty( - name="Map Resolution", - description="Importance map size is resolution x resolution/2; " - "higher values potentially produce less noise, at the cost of memory and speed", - min=4, max=8192, - default=1024, - ) + name="Map Resolution", + description="Importance map size is resolution x resolution/2; " + "higher values potentially produce less noise, at the cost of memory and speed", + min=4, max=8192, + default=1024, + ) cls.samples = IntProperty( - name="Samples", - description="Number of light samples to render for each AA sample", - min=1, max=10000, - default=1, - ) + name="Samples", + description="Number of light samples to render for each AA sample", + min=1, max=10000, + default=1, + ) cls.max_bounces = IntProperty( - name="Max Bounces", - description="Maximum number of bounces the background light will contribute to the render", - min=0, max=1024, - default=1024, - ) + name="Max Bounces", + description="Maximum number of bounces the background light will contribute to the render", + min=0, max=1024, + default=1024, + ) cls.homogeneous_volume = BoolProperty( - name="Homogeneous Volume", - description="When using volume rendering, assume volume has the same density everywhere" - "(not using any textures), for faster rendering", - default=False, - ) + name="Homogeneous Volume", + description="When using volume rendering, assume volume has the same density everywhere" + "(not using any textures), for faster rendering", + default=False, + ) cls.volume_sampling = EnumProperty( - name="Volume Sampling", - description="Sampling method to use for volumes", - items=enum_volume_sampling, - default='EQUIANGULAR', - ) + name="Volume Sampling", + description="Sampling method to use for volumes", + items=enum_volume_sampling, + default='EQUIANGULAR', + ) cls.volume_interpolation = EnumProperty( - name="Volume Interpolation", - description="Interpolation method to use for volumes", - items=enum_volume_interpolation, - default='LINEAR', - ) + name="Volume Interpolation", + description="Interpolation method to use for volumes", + items=enum_volume_interpolation, + default='LINEAR', + ) @classmethod def unregister(cls): @@ -998,47 +999,47 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.Object.cycles_visibility = PointerProperty( - name="Cycles Visibility Settings", - description="Cycles visibility settings", - type=cls, - ) + name="Cycles Visibility Settings", + description="Cycles visibility settings", + type=cls, + ) bpy.types.World.cycles_visibility = PointerProperty( - name="Cycles Visibility Settings", - description="Cycles visibility settings", - type=cls, - ) + name="Cycles Visibility Settings", + description="Cycles visibility settings", + type=cls, + ) cls.camera = BoolProperty( - name="Camera", - description="Object visibility for camera rays", - default=True, - ) + name="Camera", + description="Object visibility for camera rays", + default=True, + ) cls.diffuse = BoolProperty( - name="Diffuse", - description="Object visibility for diffuse reflection rays", - default=True, - ) + name="Diffuse", + description="Object visibility for diffuse reflection rays", + default=True, + ) cls.glossy = BoolProperty( - name="Glossy", - description="Object visibility for glossy reflection rays", - default=True, - ) + name="Glossy", + description="Object visibility for glossy reflection rays", + default=True, + ) cls.transmission = BoolProperty( - name="Transmission", - description="Object visibility for transmission rays", - default=True, - ) + name="Transmission", + description="Object visibility for transmission rays", + default=True, + ) cls.shadow = BoolProperty( - name="Shadow", - description="Object visibility for shadow rays", - default=True, - ) + name="Shadow", + description="Object visibility for shadow rays", + default=True, + ) cls.scatter = BoolProperty( - name="Volume Scatter", - description="Object visibility for volume scatter rays", - default=True, - ) + name="Volume Scatter", + description="Object visibility for volume scatter rays", + default=True, + ) @classmethod def unregister(cls): @@ -1050,20 +1051,20 @@ class CyclesMeshSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.Mesh.cycles = PointerProperty( - name="Cycles Mesh Settings", - description="Cycles mesh settings", - type=cls, - ) + name="Cycles Mesh Settings", + description="Cycles mesh settings", + type=cls, + ) bpy.types.Curve.cycles = PointerProperty( - name="Cycles Mesh Settings", - description="Cycles mesh settings", - type=cls, - ) + name="Cycles Mesh Settings", + description="Cycles mesh settings", + type=cls, + ) bpy.types.MetaBall.cycles = PointerProperty( - name="Cycles Mesh Settings", - description="Cycles mesh settings", - type=cls, - ) + name="Cycles Mesh Settings", + description="Cycles mesh settings", + type=cls, + ) @classmethod def unregister(cls): @@ -1076,69 +1077,68 @@ class CyclesObjectSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.Object.cycles = PointerProperty( - name="Cycles Object Settings", - description="Cycles object settings", - type=cls, - ) + name="Cycles Object Settings", + description="Cycles object settings", + type=cls, + ) cls.use_motion_blur = BoolProperty( - name="Use Motion Blur", - description="Use motion blur for this object", - default=True, - ) + name="Use Motion Blur", + description="Use motion blur for this object", + default=True, + ) cls.use_deform_motion = BoolProperty( - name="Use Deformation Motion", - description="Use deformation motion blur for this object", - default=True, - ) + name="Use Deformation Motion", + description="Use deformation motion blur for this object", + default=True, + ) cls.motion_steps = IntProperty( - name="Motion Steps", - description="Control accuracy of motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))", - min=1, soft_max=8, - default=1, - ) + name="Motion Steps", + description="Control accuracy of motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))", + min=1, soft_max=8, + default=1, + ) cls.use_camera_cull = BoolProperty( - name="Use Camera Cull", - description="Allow this object and its duplicators to be culled by camera space culling", - default=False, - ) + name="Use Camera Cull", + description="Allow this object and its duplicators to be culled by camera space culling", + default=False, + ) cls.use_distance_cull = BoolProperty( - name="Use Distance Cull", - description="Allow this object and its duplicators to be culled by distance from camera", - default=False, - ) + name="Use Distance Cull", + description="Allow this object and its duplicators to be culled by distance from camera", + default=False, + ) cls.use_adaptive_subdivision = BoolProperty( - name="Use Adaptive Subdivision", - description="Use adaptive render time subdivision", - default=False, - ) + name="Use Adaptive Subdivision", + description="Use adaptive render time subdivision", + default=False, + ) cls.dicing_rate = FloatProperty( - name="Dicing Scale", - description="Multiplier for scene dicing rate (located in the Geometry Panel)", - min=0.1, max=1000.0, soft_min=0.5, - default=1.0, - ) + name="Dicing Scale", + description="Multiplier for scene dicing rate (located in the Geometry Panel)", + min=0.1, max=1000.0, soft_min=0.5, + default=1.0, + ) cls.is_shadow_catcher = BoolProperty( - name="Shadow Catcher", - description="Only render shadows on this object, for compositing renders into real footage", - default=False, - ) + name="Shadow Catcher", + description="Only render shadows on this object, for compositing renders into real footage", + default=False, + ) cls.is_holdout = BoolProperty( - name="Holdout", - description="Render objects as a holdout or matte, creating a " - "hole in the image with zero alpha, to fill out in " - "compositing with real footange or another render", - default=False, - ) - + name="Holdout", + description="Render objects as a holdout or matte, creating a " + "hole in the image with zero alpha, to fill out in " + "compositing with real footange or another render", + default=False, + ) @classmethod def unregister(cls): @@ -1149,192 +1149,194 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.Scene.cycles_curves = PointerProperty( - name="Cycles Hair Rendering Settings", - description="Cycles hair rendering settings", - type=cls, - ) + name="Cycles Hair Rendering Settings", + description="Cycles hair rendering settings", + type=cls, + ) cls.primitive = EnumProperty( - name="Primitive", - description="Type of primitive used for hair rendering", - items=enum_curve_primitives, - default='LINE_SEGMENTS', - ) + name="Primitive", + description="Type of primitive used for hair rendering", + items=enum_curve_primitives, + default='LINE_SEGMENTS', + ) cls.shape = EnumProperty( - name="Shape", - description="Form of hair", - items=enum_curve_shape, - default='THICK', - ) + name="Shape", + description="Form of hair", + items=enum_curve_shape, + default='THICK', + ) cls.cull_backfacing = BoolProperty( - name="Cull back-faces", - description="Do not test the back-face of each strand", - default=True, - ) + name="Cull back-faces", + description="Do not test the back-face of each strand", + default=True, + ) cls.use_curves = BoolProperty( - name="Use Cycles Hair Rendering", - description="Activate Cycles hair rendering for particle system", - default=True, - ) + name="Use Cycles Hair Rendering", + description="Activate Cycles hair rendering for particle system", + default=True, + ) cls.resolution = IntProperty( - name="Resolution", - description="Resolution of generated mesh", - min=3, max=64, - default=3, - ) + name="Resolution", + description="Resolution of generated mesh", + min=3, max=64, + default=3, + ) cls.minimum_width = FloatProperty( - name="Minimal width", - description="Minimal pixel width for strands (0 - deactivated)", - min=0.0, max=100.0, - default=0.0, - ) + name="Minimal width", + description="Minimal pixel width for strands (0 - deactivated)", + min=0.0, max=100.0, + default=0.0, + ) cls.maximum_width = FloatProperty( - name="Maximal width", - description="Maximum extension that strand radius can be increased by", - min=0.0, max=100.0, - default=0.1, - ) + name="Maximal width", + description="Maximum extension that strand radius can be increased by", + min=0.0, max=100.0, + default=0.1, + ) cls.subdivisions = IntProperty( - name="Subdivisions", - description="Number of subdivisions used in Cardinal curve intersection (power of 2)", - min=0, max=24, - default=4, - ) + name="Subdivisions", + description="Number of subdivisions used in Cardinal curve intersection (power of 2)", + min=0, max=24, + default=4, + ) @classmethod def unregister(cls): del bpy.types.Scene.cycles_curves + def update_render_passes(self, context): scene = context.scene rd = scene.render rl = rd.layers.active rl.update_render_passes() + class CyclesRenderLayerSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.SceneRenderLayer.cycles = PointerProperty( - name="Cycles SceneRenderLayer Settings", - description="Cycles SceneRenderLayer Settings", - type=cls, - ) + name="Cycles SceneRenderLayer Settings", + description="Cycles SceneRenderLayer Settings", + type=cls, + ) cls.pass_debug_bvh_traversed_nodes = BoolProperty( - name="Debug BVH Traversed Nodes", - description="Store Debug BVH Traversed Nodes pass", - default=False, - update=update_render_passes, - ) + name="Debug BVH Traversed Nodes", + description="Store Debug BVH Traversed Nodes pass", + default=False, + update=update_render_passes, + ) cls.pass_debug_bvh_traversed_instances = BoolProperty( - name="Debug BVH Traversed Instances", - description="Store Debug BVH Traversed Instances pass", - default=False, - update=update_render_passes, - ) + name="Debug BVH Traversed Instances", + description="Store Debug BVH Traversed Instances pass", + default=False, + update=update_render_passes, + ) cls.pass_debug_bvh_intersections = BoolProperty( - name="Debug BVH Intersections", - description="Store Debug BVH Intersections", - default=False, - update=update_render_passes, - ) + name="Debug BVH Intersections", + description="Store Debug BVH Intersections", + default=False, + update=update_render_passes, + ) cls.pass_debug_ray_bounces = BoolProperty( - name="Debug Ray Bounces", - description="Store Debug Ray Bounces pass", - default=False, - update=update_render_passes, - ) + name="Debug Ray Bounces", + description="Store Debug Ray Bounces pass", + default=False, + update=update_render_passes, + ) cls.pass_debug_render_time = BoolProperty( - name="Debug Render Time", - description="Render time in milliseconds per sample and pixel", - default=False, - update=update_render_passes, - ) + name="Debug Render Time", + description="Render time in milliseconds per sample and pixel", + default=False, + update=update_render_passes, + ) cls.use_pass_volume_direct = BoolProperty( - name="Volume Direct", - description="Deliver direct volumetric scattering pass", - default=False, - update=update_render_passes, - ) + name="Volume Direct", + description="Deliver direct volumetric scattering pass", + default=False, + update=update_render_passes, + ) cls.use_pass_volume_indirect = BoolProperty( - name="Volume Indirect", - description="Deliver indirect volumetric scattering pass", - default=False, - update=update_render_passes, - ) + name="Volume Indirect", + description="Deliver indirect volumetric scattering pass", + default=False, + update=update_render_passes, + ) cls.use_denoising = BoolProperty( - name="Use Denoising", - description="Denoise the rendered image", - default=False, - update=update_render_passes, - ) + name="Use Denoising", + description="Denoise the rendered image", + default=False, + update=update_render_passes, + ) cls.denoising_diffuse_direct = BoolProperty( - name="Diffuse Direct", - description="Denoise the direct diffuse lighting", - default=True, - ) + name="Diffuse Direct", + description="Denoise the direct diffuse lighting", + default=True, + ) cls.denoising_diffuse_indirect = BoolProperty( - name="Diffuse Indirect", - description="Denoise the indirect diffuse lighting", - default=True, - ) + name="Diffuse Indirect", + description="Denoise the indirect diffuse lighting", + default=True, + ) cls.denoising_glossy_direct = BoolProperty( - name="Glossy Direct", - description="Denoise the direct glossy lighting", - default=True, - ) + name="Glossy Direct", + description="Denoise the direct glossy lighting", + default=True, + ) cls.denoising_glossy_indirect = BoolProperty( - name="Glossy Indirect", - description="Denoise the indirect glossy lighting", - default=True, - ) + name="Glossy Indirect", + description="Denoise the indirect glossy lighting", + default=True, + ) cls.denoising_transmission_direct = BoolProperty( - name="Transmission Direct", - description="Denoise the direct transmission lighting", - default=True, - ) + name="Transmission Direct", + description="Denoise the direct transmission lighting", + default=True, + ) cls.denoising_transmission_indirect = BoolProperty( - name="Transmission Indirect", - description="Denoise the indirect transmission lighting", - default=True, - ) + name="Transmission Indirect", + description="Denoise the indirect transmission lighting", + default=True, + ) cls.denoising_subsurface_direct = BoolProperty( - name="Subsurface Direct", - description="Denoise the direct subsurface lighting", - default=True, - ) + name="Subsurface Direct", + description="Denoise the direct subsurface lighting", + default=True, + ) cls.denoising_subsurface_indirect = BoolProperty( - name="Subsurface Indirect", - description="Denoise the indirect subsurface lighting", - default=True, - ) + name="Subsurface Indirect", + description="Denoise the indirect subsurface lighting", + default=True, + ) cls.denoising_strength = FloatProperty( - name="Denoising Strength", - description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)", - min=0.0, max=1.0, - default=0.5, - ) + name="Denoising Strength", + description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)", + min=0.0, max=1.0, + default=0.5, + ) cls.denoising_feature_strength = FloatProperty( - name="Denoising Feature Strength", - description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)", - min=0.0, max=1.0, - default=0.5, - ) + name="Denoising Feature Strength", + description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)", + min=0.0, max=1.0, + default=0.5, + ) cls.denoising_radius = IntProperty( - name="Denoising Radius", - description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)", - min=1, max=25, - default=8, + name="Denoising Radius", + description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)", + min=1, max=25, + default=8, ) cls.denoising_relative_pca = BoolProperty( - name="Relative filter", - description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)", - default=False, + name="Relative filter", + description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)", + default=False, ) cls.denoising_store_passes = BoolProperty( - name="Store denoising passes", - description="Store the denoising feature passes and the noisy image", - default=False, - update=update_render_passes, + name="Store denoising passes", + description="Store the denoising feature passes and the noisy image", + default=False, + update=update_render_passes, ) @classmethod @@ -1346,39 +1348,39 @@ class CyclesCurveSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.ParticleSettings.cycles = PointerProperty( - name="Cycles Hair Settings", - description="Cycles hair settings", - type=cls, - ) + name="Cycles Hair Settings", + description="Cycles hair settings", + type=cls, + ) cls.radius_scale = FloatProperty( - name="Radius Scaling", - description="Multiplier of width properties", - min=0.0, max=1000.0, - default=0.01, - ) + name="Radius Scaling", + description="Multiplier of width properties", + min=0.0, max=1000.0, + default=0.01, + ) cls.root_width = FloatProperty( - name="Root Size", - description="Strand's width at root", - min=0.0, max=1000.0, - default=1.0, - ) + name="Root Size", + description="Strand's width at root", + min=0.0, max=1000.0, + default=1.0, + ) cls.tip_width = FloatProperty( - name="Tip Multiplier", - description="Strand's width at tip", - min=0.0, max=1000.0, - default=0.0, - ) + name="Tip Multiplier", + description="Strand's width at tip", + min=0.0, max=1000.0, + default=0.0, + ) cls.shape = FloatProperty( - name="Strand Shape", - description="Strand shape parameter", - min=-1.0, max=1.0, - default=0.0, - ) + name="Strand Shape", + description="Strand shape parameter", + min=-1.0, max=1.0, + default=0.0, + ) cls.use_closetip = BoolProperty( - name="Close tip", - description="Set tip radius to zero", - default=True, - ) + name="Close tip", + description="Set tip radius to zero", + default=True, + ) @classmethod def unregister(cls): @@ -1408,10 +1410,10 @@ class CyclesPreferences(bpy.types.AddonPreferences): return list compute_device_type = EnumProperty( - name="Compute Device Type", - description="Device to use for computation (rendering with Cycles)", - items=get_device_types, - ) + name="Compute Device Type", + description="Device to use for computation (rendering with Cycles)", + items=get_device_types, + ) devices = bpy.props.CollectionProperty(type=CyclesDeviceSettings) @@ -1421,7 +1423,6 @@ class CyclesPreferences(bpy.types.AddonPreferences): return device_entry return None - def update_device_entries(self, device_list): for device in device_list: if not device[1] in {'CUDA', 'OPENCL', 'CPU'}: @@ -1431,15 +1432,14 @@ class CyclesPreferences(bpy.types.AddonPreferences): if not entry: # Create new entry if no existing one was found entry = self.devices.add() - entry.id = device[2] + entry.id = device[2] entry.name = device[0] entry.type = device[1] - entry.use = entry.type != 'CPU' + entry.use = entry.type != 'CPU' elif entry.name != device[0]: # Update name in case it changed entry.name = device[0] - def get_devices(self): import _cycles # Layout of the device tuples: (Name, Type, Persistent ID) @@ -1465,7 +1465,6 @@ class CyclesPreferences(bpy.types.AddonPreferences): opencl_devices.extend(cpu_devices) return cuda_devices, opencl_devices - def get_num_gpu_devices(self): import _cycles device_list = _cycles.available_devices() @@ -1478,11 +1477,9 @@ class CyclesPreferences(bpy.types.AddonPreferences): num += 1 return num - def has_active_device(self): return self.get_num_gpu_devices() > 0 - def draw_impl(self, layout, context): layout.label(text="Cycles Compute Device:") layout.row().prop(self, "compute_device_type", expand=True) @@ -1500,7 +1497,6 @@ class CyclesPreferences(bpy.types.AddonPreferences): for device in opencl_devices: box.prop(device, "use", text=device.name) - def draw(self, context): self.draw_impl(self.layout, context) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 2b11a2eefb0..5edbcb19672 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -19,10 +19,10 @@ import bpy from bpy.types import ( - Panel, - Menu, - Operator, - ) + Panel, + Menu, + Operator, +) class CYCLES_MT_sampling_presets(Menu): @@ -86,6 +86,7 @@ def use_sample_all_lights(context): return cscene.sample_all_lights_direct or cscene.sample_all_lights_indirect + def show_device_active(context): cscene = context.scene.cycles if cscene.device != 'GPU': @@ -965,9 +966,9 @@ class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): return context.lamp and \ - not (context.lamp.type == 'AREA' and - context.lamp.cycles.is_portal) \ - and CyclesButtonsPanel.poll(context) + not (context.lamp.type == 'AREA' and + context.lamp.cycles.is_portal) \ + and CyclesButtonsPanel.poll(context) def draw(self, context): self.layout.template_preview(context.lamp) @@ -1035,7 +1036,7 @@ class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel): def poll(cls, context): return context.lamp and not (context.lamp.type == 'AREA' and context.lamp.cycles.is_portal) and \ - CyclesButtonsPanel.poll(context) + CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout @@ -1741,6 +1742,7 @@ class CYCLES_SCENE_PT_simplify(CyclesButtonsPanel, Panel): col = split.column() col.prop(cscene, "ao_bounces_render") + def draw_device(self, context): scene = context.scene layout = self.layout @@ -1823,7 +1825,7 @@ def get_panels(): 'WORLD_PT_mist', 'WORLD_PT_preview', 'WORLD_PT_world' - } + } panels = [] for panel in bpy.types.Panel.__subclasses__(): diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py index f9f0b5fb59d..f14fe9abc3d 100644 --- a/intern/cycles/blender/addon/version_update.py +++ b/intern/cycles/blender/addon/version_update.py @@ -75,19 +75,25 @@ def foreach_cycles_node(callback): traversed = set() for material in bpy.data.materials: if check_is_new_shading_material(material): - foreach_notree_node(material.node_tree, - callback, - traversed) + foreach_notree_node( + material.node_tree, + callback, + traversed, + ) for world in bpy.data.worlds: if check_is_new_shading_world(world): - foreach_notree_node(world.node_tree, - callback, - traversed) + foreach_notree_node( + world.node_tree, + callback, + traversed, + ) for lamp in bpy.data.lamps: if check_is_new_shading_world(lamp): - foreach_notree_node(lamp.node_tree, - callback, - traversed) + foreach_notree_node( + lamp.node_tree, + callback, + traversed, + ) def displacement_node_insert(material, nodetree, traversed): @@ -102,10 +108,12 @@ def displacement_node_insert(material, nodetree, traversed): # Gather links to replace displacement_links = [] for link in nodetree.links: - if link.to_node.bl_idname == 'ShaderNodeOutputMaterial' and \ - link.from_node.bl_idname != 'ShaderNodeDisplacement' and \ - link.to_socket.identifier == 'Displacement': - displacement_links.append(link) + if ( + link.to_node.bl_idname == 'ShaderNodeOutputMaterial' and + link.from_node.bl_idname != 'ShaderNodeDisplacement' and + link.to_socket.identifier == 'Displacement' + ): + displacement_links.append(link) # Replace links with displacement node for link in displacement_links: @@ -117,20 +125,22 @@ def displacement_node_insert(material, nodetree, traversed): nodetree.links.remove(link) node = nodetree.nodes.new(type='ShaderNodeDisplacement') - node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0]); - node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1]); + node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0]) + node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1]) node.inputs['Scale'].default_value = 0.1 node.inputs['Midlevel'].default_value = 0.0 nodetree.links.new(from_socket, node.inputs['Height']) nodetree.links.new(node.outputs['Displacement'], to_socket) + def displacement_nodes_insert(): traversed = set() for material in bpy.data.materials: if check_is_new_shading_material(material): displacement_node_insert(material, material.node_tree, traversed) + def displacement_principled_nodes(node): if node.bl_idname == 'ShaderNodeDisplacement': if node.space != 'WORLD': @@ -139,6 +149,7 @@ def displacement_principled_nodes(node): if node.subsurface_method != 'RANDOM_WALK': node.subsurface_method = 'BURLEY' + def square_roughness_node_insert(material, nodetree, traversed): if nodetree in traversed: return @@ -163,7 +174,7 @@ def square_roughness_node_insert(material, nodetree, traversed): for link in nodetree.links: if link.to_node.bl_idname in roughness_node_types and \ link.to_socket.identifier == 'Roughness': - roughness_links.append(link) + roughness_links.append(link) # Replace links with sqrt node for link in roughness_links: @@ -176,13 +187,14 @@ def square_roughness_node_insert(material, nodetree, traversed): node = nodetree.nodes.new(type='ShaderNodeMath') node.operation = 'POWER' - node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0]); - node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1]); + node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0]) + node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1]) nodetree.links.new(from_socket, node.inputs[0]) node.inputs[1].default_value = 0.5 nodetree.links.new(node.outputs['Value'], to_socket) + def square_roughness_nodes_insert(): traversed = set() for material in bpy.data.materials: @@ -288,7 +300,7 @@ def ambient_occlusion_node_relink(material, nodetree, traversed): ao_links = [] for link in nodetree.links: if link.from_node.bl_idname == 'ShaderNodeAmbientOcclusion': - ao_links.append(link) + ao_links.append(link) # Replace links for link in ao_links: @@ -298,6 +310,7 @@ def ambient_occlusion_node_relink(material, nodetree, traversed): nodetree.links.remove(link) nodetree.links.new(from_node.outputs['Color'], to_socket) + def ambient_occlusion_nodes_relink(): traversed = set() for material in bpy.data.materials: @@ -335,9 +348,11 @@ def do_versions(self): for scene in bpy.data.scenes: cscene = scene.cycles sample_clamp = cscene.get("sample_clamp", False) - if (sample_clamp and + if ( + sample_clamp and not cscene.is_property_set("sample_clamp_direct") and - not cscene.is_property_set("sample_clamp_indirect")): + not cscene.is_property_set("sample_clamp_indirect") + ): cscene.sample_clamp_direct = sample_clamp cscene.sample_clamp_indirect = sample_clamp @@ -353,10 +368,11 @@ def do_versions(self): if bpy.data.version <= (2, 72, 0): for scene in bpy.data.scenes: cscene = scene.cycles - if (cscene.get("no_caustics", False) and + if ( + cscene.get("no_caustics", False) and not cscene.is_property_set("caustics_reflective") and - not cscene.is_property_set("caustics_refractive")): - + not cscene.is_property_set("caustics_refractive") + ): cscene.caustics_reflective = False cscene.caustics_refractive = False -- cgit v1.2.3 From e387a4e768ea8328e2636eade5ed6a0be747f7a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 11:16:22 +0200 Subject: Cleanup: style, duplicate header --- source/blender/blenkernel/intern/scene.c | 1 - source/blender/draw/engines/basic/basic_engine.c | 5 ++--- source/blender/draw/engines/eevee/eevee_lightprobes.c | 5 +++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 2b2fc2fc767..8299d785cfc 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -101,7 +101,6 @@ #include "DEG_depsgraph_debug.h" #include "DEG_depsgraph_query.h" -#include "RE_engine.h" #include "RE_engine.h" #include "engines/eevee/eevee_lightcache.h" diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 4348f2182a4..5a315cde2b5 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -150,7 +150,7 @@ static void basic_cache_populate(void *vedata, Object *ob) for (ParticleSystem *psys = ob->particlesystem.first; psys != NULL; psys = psys->next) - { + { if (!psys_check_enabled(ob, psys, false)) { continue; } @@ -158,8 +158,7 @@ static void basic_cache_populate(void *vedata, Object *ob) continue; } ParticleSettings *part = psys->part; - const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as - : part->draw_as; + const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as; if (draw_as == PART_DRAW_PATH) { struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL); DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL); diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index b58e389b558..1b341aced07 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -313,7 +313,8 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) } if ((scene_eval->eevee.light_cache == NULL) && - (sldata->fallback_lightcache == NULL)) { + (sldata->fallback_lightcache == NULL)) + { #if defined(IRRADIANCE_SH_L2) int grid_res = 4; #elif defined(IRRADIANCE_CUBEMAP) @@ -860,7 +861,7 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved /** \name Rendering * \{ */ -typedef struct EEVEE_BakeRenderData{ +typedef struct EEVEE_BakeRenderData { EEVEE_Data *vedata; EEVEE_ViewLayerData *sldata; struct GPUFrameBuffer **face_fb; /* should contain 6 framebuffer */ -- cgit v1.2.3 From d75b8e5f01d92a9bd4e92763f3d3b3bc4df75db4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 11:19:22 +0200 Subject: Cleanup: header guards --- source/blender/bmesh/intern/bmesh_query.h | 6 +++--- source/blender/bmesh/intern/bmesh_query_inline.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_query.h b/source/blender/bmesh/intern/bmesh_query.h index cb3af88c316..51956761d8f 100644 --- a/source/blender/bmesh/intern/bmesh_query.h +++ b/source/blender/bmesh/intern/bmesh_query.h @@ -20,8 +20,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef __BMESH_QUERIES_H__ -#define __BMESH_QUERIES_H__ +#ifndef __BMESH_QUERY_H__ +#define __BMESH_QUERY_H__ /** \file blender/bmesh/intern/bmesh_query.h * \ingroup bmesh @@ -198,4 +198,4 @@ float bmesh_subd_falloff_calc(const int falloff, float val) ATTR_WARN_UNUSED_RES #include "bmesh_query_inline.h" -#endif /* __BMESH_QUERIES_H__ */ +#endif /* __BMESH_QUERY_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_query_inline.h b/source/blender/bmesh/intern/bmesh_query_inline.h index 1bd77d23ded..92be3639dce 100644 --- a/source/blender/bmesh/intern/bmesh_query_inline.h +++ b/source/blender/bmesh/intern/bmesh_query_inline.h @@ -23,8 +23,8 @@ */ -#ifndef __BMESH_QUERIES_INLINE_H__ -#define __BMESH_QUERIES_INLINE_H__ +#ifndef __BMESH_QUERY_INLINE_H__ +#define __BMESH_QUERY_INLINE_H__ /** * Returns whether or not a given vertex is @@ -166,4 +166,4 @@ BLI_INLINE bool BM_vert_is_wire_endpoint(const BMVert *v) return false; } -#endif /* __BMESH_QUERIES_INLINE_H__ */ +#endif /* __BMESH_QUERY_INLINE_H__ */ -- cgit v1.2.3 From 5cdfb74dd82a9eb1fd802f361576d7dbf168def9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 11:43:37 +0200 Subject: Keymap: add utility function for panel popups --- source/blender/windowmanager/WM_keymap.h | 4 ++++ source/blender/windowmanager/intern/wm_keymap.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index d1f6d268835..afde7f64b81 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -66,6 +66,10 @@ wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, in int val, int modifier, int keymodifier); wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); +wmKeyMapItem *WM_keymap_add_panel( + struct wmKeyMap *keymap, + short space_type, short region_type, const char *idname, + int type, int val, int modifier, int keymodifier); wmKeyMapItem *WM_keymap_add_tool(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 9c435297069..82363c4c21b 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -509,6 +509,20 @@ wmKeyMapItem *WM_keymap_add_menu_pie(wmKeyMap *keymap, const char *idname, int t return kmi; } +wmKeyMapItem *WM_keymap_add_panel( + wmKeyMap *keymap, + short space_type, short region_type, const char *idname, + int type, int val, int modifier, int keymodifier) +{ + wmKeyMapItem *kmi = WM_keymap_add_item(keymap, "WM_OT_call_panel", type, val, modifier, keymodifier); + RNA_enum_set(kmi->ptr, "space_type", space_type); + RNA_enum_set(kmi->ptr, "region_type", region_type); + RNA_string_set(kmi->ptr, "name", idname); + /* TODO: we might want to disable this. */ + RNA_boolean_set(kmi->ptr, "keep_open", false); + return kmi; +} + /* tool wrapper for WM_keymap_add_item */ wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) { -- cgit v1.2.3 From 98c215f4db06c8ad022bb288a02fb0ff424b7de4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 11:44:20 +0200 Subject: Keymap: add 3D view snap popup The key was available for other spaces, removed because it conflicted with changes which have since been reverted. --- source/blender/editors/transform/transform_ops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 889be92f1f2..4de475e05b9 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -1123,6 +1123,8 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap"); + WM_keymap_add_panel(keymap, SPACE_VIEW3D, RGN_TYPE_HEADER, "VIEW3D_PT_snapping", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + /* Will fall-through to texture-space transform. */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_transform_axis_target", TKEY, KM_PRESS, KM_SHIFT, 0); -- cgit v1.2.3 From 9a5fb0209e6e94112be4d390316933ab84e8e2df Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 12 Jul 2018 11:46:32 +0200 Subject: Fix T55949: increase color management exposure hard range. --- source/blender/makesrna/intern/rna_color.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 080916bfbf8..aa1164068d8 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -1128,8 +1128,9 @@ static void rna_def_colormanage(BlenderRNA *brna) prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "exposure"); - RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_float_default(prop, 0.0f); + RNA_def_property_range(prop, -32.0f, 32.0f); + RNA_def_property_ui_range(prop, -10.0f, 10.0f, 1, 3); RNA_def_property_ui_text(prop, "Exposure", "Exposure (stops) applied before display transform"); RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update"); -- cgit v1.2.3 From c21488df5a830af494d13b353e78cbf81de1595c Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 12 Jul 2018 13:37:29 +0200 Subject: Fix T55945: Outliner crash crashed when using filtering and no item was found ('Blender File' mode) Reviewed By: brecht Differential Revision: https://developer.blender.org/D3535 --- .../blender/editors/space_outliner/outliner_tree.c | 40 ++++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 9f6c944c914..28890e42139 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -2160,28 +2160,30 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa } /* make hierarchy */ ten = soops->tree.first; - ten = ten->next; /* first one is main */ - while (ten) { - TreeElement *nten = ten->next, *par; - tselem = TREESTORE(ten); - lib = (Library *)tselem->id; - if (lib && lib->parent) { - par = (TreeElement *)lib->parent->id.newid; - if (tselem->id->tag & LIB_TAG_INDIRECT) { - /* Only remove from 'first level' if lib is not also directly used. */ - BLI_remlink(&soops->tree, ten); - BLI_addtail(&par->subtree, ten); - ten->parent = par; - } - else { - /* Else, make a new copy of the libtree for our parent. */ - TreeElement *dupten = outliner_add_library_contents(mainvar, soops, &par->subtree, lib); - if (dupten) { - dupten->parent = par; + if (ten != NULL) { + ten = ten->next; /* first one is main */ + while (ten) { + TreeElement *nten = ten->next, *par; + tselem = TREESTORE(ten); + lib = (Library *)tselem->id; + if (lib && lib->parent) { + par = (TreeElement *)lib->parent->id.newid; + if (tselem->id->tag & LIB_TAG_INDIRECT) { + /* Only remove from 'first level' if lib is not also directly used. */ + BLI_remlink(&soops->tree, ten); + BLI_addtail(&par->subtree, ten); + ten->parent = par; + } + else { + /* Else, make a new copy of the libtree for our parent. */ + TreeElement *dupten = outliner_add_library_contents(mainvar, soops, &par->subtree, lib); + if (dupten) { + dupten->parent = par; + } } } + ten = nten; } - ten = nten; } /* restore newid pointers */ for (lib = mainvar->library.first; lib; lib = lib->id.next) -- cgit v1.2.3 From 753a600e354f21618e24e9071ef5d88f1913fcd8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 14:43:35 +0200 Subject: PyAPI: add undo redo handlers Useful so Python can clean up before/after undo steps. --- source/blender/blenlib/BLI_callbacks.h | 4 +++ source/blender/editors/undo/ed_undo.c | 39 +++++++++++++++++++++++-- source/blender/python/intern/bpy_app_handlers.c | 4 +++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index 6eb45107488..3db7d2d87f1 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -49,6 +49,10 @@ typedef enum { BLI_CB_EVT_LOAD_POST, BLI_CB_EVT_SAVE_PRE, BLI_CB_EVT_SAVE_POST, + BLI_CB_EVT_UNDO_PRE, + BLI_CB_EVT_UNDO_POST, + BLI_CB_EVT_REDO_PRE, + BLI_CB_EVT_REDO_POST, BLI_CB_EVT_SCENE_UPDATE_PRE, BLI_CB_EVT_SCENE_UPDATE_POST, BLI_CB_EVT_GAME_PRE, diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 5f5b7b330f9..b4268dac863 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -38,6 +38,8 @@ #include "DNA_scene_types.h" #include "BLI_utildefines.h" +#include "BLI_callbacks.h" +#include "BLI_listbase.h" #include "BLT_translation.h" @@ -119,17 +121,50 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) return ED_undo_gpencil_step(C, step, undoname); } + UndoStep *step_data_from_name = NULL; + int step_for_callback = step; + if (undoname != NULL) { + step_data_from_name = BKE_undosys_step_find_by_name(wm->undo_stack, undoname); + if (step_data_from_name == NULL) { + return OPERATOR_CANCELLED; + } + + /* TODO(campbell), could use simple optimization. */ + BLI_assert(step_data_from_name != wm->undo_stack->step_active); + step_for_callback = ( + BLI_findindex(&wm->undo_stack->steps, step_data_from_name) < + BLI_findindex(&wm->undo_stack->steps, wm->undo_stack->step_active)) ? 1 : -1; + } + + /* App-Handlers (pre). */ + { + /* Note: ignore grease pencil for now. */ + Main *bmain = CTX_data_main(C); + wm->op_undo_depth++; + BLI_callback_exec(bmain, &scene->id, (step_for_callback > 0) ? BLI_CB_EVT_UNDO_PRE : BLI_CB_EVT_REDO_PRE); + wm->op_undo_depth--; + } + + /* Undo System */ { if (undoname) { - UndoStep *step_data = BKE_undosys_step_find_by_name(wm->undo_stack, undoname); - BKE_undosys_step_undo_with_data(wm->undo_stack, C, step_data); + BKE_undosys_step_undo_with_data(wm->undo_stack, C, step_data_from_name); } else { BKE_undosys_step_undo_compat_only(wm->undo_stack, C, step); } } + /* App-Handlers (post). */ + { + Main *bmain = CTX_data_main(C); + scene = CTX_data_scene(C); + wm->op_undo_depth++; + BLI_callback_exec(bmain, &scene->id, step_for_callback > 0 ? BLI_CB_EVT_UNDO_PRE : BLI_CB_EVT_REDO_PRE); + wm->op_undo_depth--; + } + WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL); diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 90aa22de5bf..ded5ead93aa 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -59,6 +59,10 @@ static PyStructSequence_Field app_cb_info_fields[] = { {(char *)"load_post", (char *)"on loading a new blend file (after)"}, {(char *)"save_pre", (char *)"on saving a blend file (before)"}, {(char *)"save_post", (char *)"on saving a blend file (after)"}, + {(char *)"undo_pre", (char *)"on loading an undo step (before)"}, + {(char *)"undo_post", (char *)"on loading an undo step (after)"}, + {(char *)"redo_pre", (char *)"on loading a redo step (before)"}, + {(char *)"redo_post", (char *)"on loading a redo step (after)"}, {(char *)"scene_update_pre", (char *)"on every scene data update. Does not imply that anything changed in the " "scene, just that the dependency graph is about to be reevaluated, and the " "scene is about to be updated by Blender's animation system."}, -- cgit v1.2.3 From 415018778ccc53ccca37019c5eb88276a76c1fe8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 15:21:39 +0200 Subject: PyAPI: show line, not call-stack for field warning Was too noisy and hard to tell warnings from exceptions. --- source/blender/python/intern/bpy_rna.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 36df7c25867..b288e311633 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -7446,10 +7446,10 @@ static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict) while (PyDict_Next(class_dict, &pos, &key, &item)) { if (pyrna_is_deferred_prop(item)) { if (!has_warning) { - PyC_StackSpit(); printf("Warning: class %.200s " "contains a properties which should be a field!\n", RNA_struct_identifier(srna)); + PyC_LineSpit(); has_warning = true; } printf(" make field: %.200s.%.200s\n", -- cgit v1.2.3 From 5aff20dfd51760574e748d48171da0e62d0a3841 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 15:25:05 +0200 Subject: UI: add toggle fullscreen to window context menu --- release/scripts/startup/bl_ui/space_topbar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 5129b5648ce..96ef2e51e60 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -563,6 +563,8 @@ class TOPBAR_MT_window_specials(Menu): layout.operator("screen.area_dupli") + layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER') + layout.separator() layout.operator("screen.area_split", text="Horizontal Split").direction = 'HORIZONTAL' -- cgit v1.2.3 From 0c41d61008f1cfb58b160d8459d8ffdb652871d8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 16:55:16 +0200 Subject: WM: snap to fractions when resizing areas Snap to fractions in 1/(2,3,4,8), Nice for less arbitrary layouts. --- source/blender/editors/screen/screen_ops.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 09bd7625eac..cd5bdf07c6c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1372,10 +1372,29 @@ static int area_snap_calc_location( int snap_dist; int dist; { - /* Test the snap to middle. */ - int middle = origval + (bigger - smaller) / 2; - snap_dist = abs(m_loc - middle); - final_loc = middle; + const float div_array[] = { + /* Middle. */ + 1.0f / 2.0f, + /* Thirds. */ + 1.0f / 3.0f, 2.0f / 3.0f, + /* Quaters. */ + 1.0f / 4.0f, 3.0f / 4.0f, + /* Eighth. */ + 1.0f / 8.0f, 3.0f / 8.0f, + 5.0f / 8.0f, 7.0f / 8.0f, + }; + /* Test the snap to the best division. */ + const int axis_min = origval - smaller; + const float axis_span_fl = (float)(bigger + smaller); + int snap_dist_best = INT_MAX; + for (int i = 0; i < ARRAY_SIZE(div_array); i++) { + const int value = axis_min + round_fl_to_int(axis_span_fl * div_array[i]); + snap_dist = abs(m_loc - value); + if (snap_dist < snap_dist_best) { + snap_dist_best = snap_dist; + final_loc = value; + } + } } for (const ScrVert *v1 = sc->vertbase.first; v1; v1 = v1->next) { -- cgit v1.2.3 From e77d2b4e3f1a1eb2072b29e1f9c6ab3ba3b175e5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Jul 2018 21:32:18 +0200 Subject: Cleanup: remove legacy mesh save support This was used for saving files for Blender 2.6x. --- source/blender/blenkernel/BKE_global.h | 4 +- source/blender/blenkernel/BKE_mesh.h | 3 - source/blender/blenkernel/intern/mesh_evaluate.c | 127 +---------------------- source/blender/blenloader/intern/writefile.c | 89 +--------------- source/blender/makesdna/DNA_mesh_types.h | 3 - source/blender/windowmanager/intern/wm_files.c | 16 --- 6 files changed, 6 insertions(+), 236 deletions(-) diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 34eff9d7959..0ce560532d5 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -190,12 +190,12 @@ enum { /* On write, make backup `.blend1`, `.blend2` ... files, when the users preference is enabled */ #define G_FILE_HISTORY (1 << 25) /* BMesh option to save as older mesh format */ -#define G_FILE_MESH_COMPAT (1 << 26) +// #define G_FILE_MESH_COMPAT (1 << 26) /* On write, restore paths after editing them (G_FILE_RELATIVE_REMAP) */ #define G_FILE_SAVE_COPY (1 << 27) #define G_FILE_GLSL_NO_ENV_LIGHTING (1 << 28) -#define G_FILE_FLAGS_RUNTIME (G_FILE_NO_UI | G_FILE_RELATIVE_REMAP | G_FILE_MESH_COMPAT | G_FILE_SAVE_COPY) +#define G_FILE_FLAGS_RUNTIME (G_FILE_NO_UI | G_FILE_RELATIVE_REMAP | G_FILE_SAVE_COPY) /* ENDIAN_ORDER: indicates what endianness the platform where the file was * written had. */ diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 060bb606c2c..6d2a431f667 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -347,9 +347,6 @@ void BKE_mesh_recalc_looptri( const struct MVert *mvert, int totloop, int totpoly, struct MLoopTri *mlooptri); -int BKE_mesh_mpoly_to_mface( - struct CustomData *fdata, struct CustomData *ldata, - struct CustomData *pdata, int totface, int totloop, int totpoly); void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh); void BKE_mesh_do_versions_convert_mfaces_to_mpolys(struct Mesh *mesh); void BKE_mesh_convert_mfaces_to_mpolys_ex( diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index 0c6693be3af..6a3d74aec64 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -3160,130 +3160,9 @@ void BKE_mesh_recalc_looptri( #undef ML_TO_MLT } -/* -------------------------------------------------------------------- */ - - -#ifdef USE_BMESH_SAVE_AS_COMPAT - -/** - * This function recreates a tessellation. - * returns number of tessellation faces. - * - * for forwards compat only quad->tri polys to mface, skip ngons. - */ -int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, - struct CustomData *pdata, int totface, int UNUSED(totloop), int totpoly) -{ - MLoop *mloop; - - unsigned int lindex[4]; - int i; - int k; - - MPoly *mp, *mpoly; - MFace *mface, *mf; - - const int numTex = CustomData_number_of_layers(pdata, CD_MTEXPOLY); - const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL); - const bool hasPCol = CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL); - const bool hasOrigSpace = CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP); - const bool hasLNor = CustomData_has_layer(ldata, CD_NORMAL); - - /* over-alloc, ngons will be skipped */ - mface = MEM_malloc_arrayN((size_t)totpoly, sizeof(*mface), __func__); - - mpoly = CustomData_get_layer(pdata, CD_MPOLY); - mloop = CustomData_get_layer(ldata, CD_MLOOP); - - mp = mpoly; - k = 0; - for (i = 0; i < totpoly; i++, mp++) { - if (ELEM(mp->totloop, 3, 4)) { - const unsigned int mp_loopstart = (unsigned int)mp->loopstart; - mf = &mface[k]; - - mf->mat_nr = mp->mat_nr; - mf->flag = mp->flag; - - mf->v1 = mp_loopstart + 0; - mf->v2 = mp_loopstart + 1; - mf->v3 = mp_loopstart + 2; - mf->v4 = (mp->totloop == 4) ? (mp_loopstart + 3) : 0; - - /* abuse edcode for temp storage and clear next loop */ - mf->edcode = (char)mp->totloop; /* only ever 3 or 4 */ - - k++; - } - } - - CustomData_free(fdata, totface); - - totface = k; - - CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface); - - CustomData_from_bmeshpoly(fdata, pdata, ldata, totface); - - mp = mpoly; - k = 0; - for (i = 0; i < totpoly; i++, mp++) { - if (ELEM(mp->totloop, 3, 4)) { - mf = &mface[k]; - - if (mf->edcode == 3) { - /* sort loop indices to ensure winding is correct */ - /* NO SORT - looks like we can skip this */ - - lindex[0] = mf->v1; - lindex[1] = mf->v2; - lindex[2] = mf->v3; - lindex[3] = 0; /* unused */ - - /* transform loop indices to vert indices */ - mf->v1 = mloop[mf->v1].v; - mf->v2 = mloop[mf->v2].v; - mf->v3 = mloop[mf->v3].v; - - BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, - lindex, k, i, 3, - numTex, numCol, hasPCol, hasOrigSpace, hasLNor); - test_index_face(mf, fdata, k, 3); - } - else { - /* sort loop indices to ensure winding is correct */ - /* NO SORT - looks like we can skip this */ - - lindex[0] = mf->v1; - lindex[1] = mf->v2; - lindex[2] = mf->v3; - lindex[3] = mf->v4; - - /* transform loop indices to vert indices */ - mf->v1 = mloop[mf->v1].v; - mf->v2 = mloop[mf->v2].v; - mf->v3 = mloop[mf->v3].v; - mf->v4 = mloop[mf->v4].v; - - BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, - lindex, k, i, 4, - numTex, numCol, hasPCol, hasOrigSpace, hasLNor); - test_index_face(mf, fdata, k, 4); - } - - mf->edcode = 0; - - k++; - } - } - - return k; -} -#endif /* USE_BMESH_SAVE_AS_COMPAT */ - - -static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata, - MFace *mface, int totloop, int findex, int loopstart, int numTex, int numCol) +static void bm_corners_to_loops_ex( + ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata, + MFace *mface, int totloop, int findex, int loopstart, int numTex, int numCol) { MTFace *texface; MTexPoly *texpoly; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 0e67bde6883..e3a901f4211 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -341,10 +341,6 @@ typedef struct { * Will be NULL for UNDO. */ WriteWrap *ww; - -#ifdef USE_BMESH_SAVE_AS_COMPAT - bool use_mesh_compat; /* option to save with older mesh format */ -#endif } WriteData; static WriteData *writedata_new(WriteWrap *ww) @@ -2187,12 +2183,6 @@ static void write_customdata( static void write_mesh(WriteData *wd, Mesh *mesh) { -#ifdef USE_BMESH_SAVE_AS_COMPAT - const bool save_for_old_blender = wd->use_mesh_compat; /* option to save with older mesh format */ -#else - const bool save_for_old_blender = false; -#endif - CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE]; CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE]; CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE]; @@ -2201,19 +2191,17 @@ static void write_mesh(WriteData *wd, Mesh *mesh) if (mesh->id.us > 0 || wd->use_memfile) { /* write LibData */ - if (!save_for_old_blender) { + { /* write a copy of the mesh, don't modify in place because it is * not thread safe for threaded renders that are reading this */ Mesh *old_mesh = mesh; Mesh copy_mesh = *mesh; mesh = ©_mesh; -#ifdef USE_BMESH_SAVE_WITHOUT_MFACE /* cache only - don't write */ mesh->mface = NULL; mesh->totface = 0; memset(&mesh->fdata, 0, sizeof(mesh->fdata)); -#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */ /** * Those calls: @@ -2224,11 +2212,7 @@ static void write_mesh(WriteData *wd, Mesh *mesh) */ CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff)); -#ifndef USE_BMESH_SAVE_WITHOUT_MFACE /* Do not copy org fdata in this case!!! */ - CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff)); -#else flayers = flayers_buff; -#endif CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); @@ -2253,73 +2237,6 @@ static void write_mesh(WriteData *wd, Mesh *mesh) /* restore pointer */ mesh = old_mesh; } - else { - -#ifdef USE_BMESH_SAVE_AS_COMPAT - /* write a copy of the mesh, don't modify in place because it is - * not thread safe for threaded renders that are reading this */ - Mesh *old_mesh = mesh; - Mesh copy_mesh = *mesh; - mesh = ©_mesh; - - mesh->mpoly = NULL; - mesh->mface = NULL; - mesh->totface = 0; - mesh->totpoly = 0; - mesh->totloop = 0; - CustomData_reset(&mesh->fdata); - CustomData_reset(&mesh->pdata); - CustomData_reset(&mesh->ldata); - mesh->edit_btmesh = NULL; - - /* now fill in polys to mfaces */ - /* XXX This breaks writing design, by using temp allocated memory, which will likely generate - * duplicates in stored 'old' addresses. - * This is very bad, but do not see easy way to avoid this, aside from generating those data - * outside of save process itself. - * Maybe we can live with this, though? - */ - mesh->totface = BKE_mesh_mpoly_to_mface( - &mesh->fdata, &old_mesh->ldata, &old_mesh->pdata, - mesh->totface, old_mesh->totloop, old_mesh->totpoly); - - BKE_mesh_update_customdata_pointers(mesh, false); - - CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); - CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff)); - CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff)); -#if 0 - CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); - CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); -#endif - - writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh); - write_iddata(wd, &mesh->id); - - /* direct data */ - if (mesh->adt) { - write_animdata(wd, mesh->adt); - } - - writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat); - /* writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); */ /* pre-bmesh NULL's */ - - write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0); - write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0); - write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0); - /* harmless for older blender versioins but _not_ writing these keeps file size down */ -#if 0 - write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0); - write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0); -#endif - - CustomData_free(&mesh->fdata, mesh->totface); - flayers = NULL; - - /* restore pointer */ - mesh = old_mesh; -#endif /* USE_BMESH_SAVE_AS_COMPAT */ - } } if (vlayers && vlayers != vlayers_buff) { @@ -3845,10 +3762,6 @@ static bool write_file_handle( wd = mywrite_begin(ww, compare, current); -#ifdef USE_BMESH_SAVE_AS_COMPAT - wd->use_mesh_compat = (write_flags & G_FILE_MESH_COMPAT) != 0; -#endif - #ifdef USE_NODE_COMPAT_CUSTOMNODES /* don't write compatibility data on undo */ if (!current) { diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 36fb54e6c61..a667d0e578d 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -232,9 +232,6 @@ enum { /* this is so we can save bmesh files that load in trunk, ignoring NGons * will eventually be removed */ -#define USE_BMESH_SAVE_AS_COMPAT -#define USE_BMESH_SAVE_WITHOUT_MFACE - /* enable this so meshes get tessfaces calculated by default */ /* #define USE_TESSFACE_DEFAULT */ diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index cb4949d4062..19b48e3f79e 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -64,7 +64,6 @@ #include "BLF_api.h" -#include "DNA_mesh_types.h" /* only for USE_BMESH_SAVE_AS_COMPAT */ #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_userdef_types.h" @@ -2088,16 +2087,6 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) RNA_boolean_get(op->ptr, "copy")), G_FILE_SAVE_COPY); -#ifdef USE_BMESH_SAVE_AS_COMPAT - SET_FLAG_FROM_TEST( - fileflags, - (RNA_struct_find_property(op->ptr, "use_mesh_compat") && - RNA_boolean_get(op->ptr, "use_mesh_compat")), - G_FILE_MESH_COMPAT); -#else -# error "don't remove by accident" -#endif - if (wm_file_write(C, path, fileflags, op->reports) != 0) return OPERATOR_CANCELLED; @@ -2147,11 +2136,6 @@ void WM_OT_save_as_mainfile(wmOperatorType *ot) prop = RNA_def_boolean(ot->srna, "copy", false, "Save Copy", "Save a copy of the actual working state but does not make saved file active"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); -#ifdef USE_BMESH_SAVE_AS_COMPAT - RNA_def_boolean(ot->srna, "use_mesh_compat", false, "Legacy Mesh Format", - "Save using legacy mesh format (no ngons) - WARNING: only saves tris and quads, other ngons will " - "be lost (no implicit triangulation)"); -#endif } static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -- cgit v1.2.3 From 6d3ff55e1c55c1437cd5cbe099c1e025716b3442 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 08:14:16 +0200 Subject: Correct error mixing fraction/screen snap Thanks @mano-wii for pointing out --- source/blender/editors/screen/screen_ops.c | 43 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index cd5bdf07c6c..3ec54cd73bb 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1350,27 +1350,29 @@ static int area_snap_calc_location( const int bigger, const int smaller) { BLI_assert(snap_type != SNAP_NONE); - int final_loc = -1; - const int m_loc = origval + delta; + int m_cursor_final = -1; + const int m_cursor = origval + delta; + const int m_span = (float)(bigger + smaller); + const int m_min = origval - smaller; + // const int axis_max = axis_min + m_span; switch (snap_type) { case SNAP_AREAGRID: - final_loc = m_loc; + m_cursor_final = m_cursor; if (delta != bigger && delta != -smaller) { - final_loc -= (m_loc % AREAGRID); - CLAMP(final_loc, origval - smaller, origval + bigger); + m_cursor_final -= (m_cursor % AREAGRID); + CLAMP(m_cursor_final, origval - smaller, origval + bigger); } break; case SNAP_BIGGER_SMALLER_ONLY: - final_loc = (m_loc >= bigger) ? bigger : smaller; + m_cursor_final = (m_cursor >= bigger) ? bigger : smaller; break; case SNAP_MIDPOINT_AND_ADJACENT: { const int axis = (dir == 'v') ? 0 : 1; - int snap_dist; - int dist; + int snap_dist_best = INT_MAX; { const float div_array[] = { /* Middle. */ @@ -1384,15 +1386,12 @@ static int area_snap_calc_location( 5.0f / 8.0f, 7.0f / 8.0f, }; /* Test the snap to the best division. */ - const int axis_min = origval - smaller; - const float axis_span_fl = (float)(bigger + smaller); - int snap_dist_best = INT_MAX; for (int i = 0; i < ARRAY_SIZE(div_array); i++) { - const int value = axis_min + round_fl_to_int(axis_span_fl * div_array[i]); - snap_dist = abs(m_loc - value); - if (snap_dist < snap_dist_best) { - snap_dist_best = snap_dist; - final_loc = value; + const int m_cursor_test = m_min + round_fl_to_int(m_span * div_array[i]); + const int snap_dist_test = abs(m_cursor - m_cursor_test); + if (snap_dist_best >= snap_dist_test) { + snap_dist_best = snap_dist_test; + m_cursor_final = m_cursor_test; } } } @@ -1411,10 +1410,10 @@ static int area_snap_calc_location( const int v_loc2 = (&v2->vec.x)[axis]; /* Do not snap to the vertices at the ends. */ if ((origval - smaller) < v_loc2 && v_loc2 < (origval + bigger)) { - dist = abs(m_loc - v_loc2); - if (dist <= snap_dist) { - snap_dist = dist; - final_loc = v_loc2; + const int snap_dist_test = abs(m_cursor - v_loc2); + if (snap_dist_best >= snap_dist_test) { + snap_dist_best = snap_dist_test; + m_cursor_final = v_loc2; } } } @@ -1427,9 +1426,9 @@ static int area_snap_calc_location( } BLI_assert(ELEM(snap_type, SNAP_BIGGER_SMALLER_ONLY) || - IN_RANGE_INCL(final_loc, origval - smaller, origval + bigger)); + IN_RANGE_INCL(m_cursor_final, origval - smaller, origval + bigger)); - return final_loc; + return m_cursor_final; } /* moves selected screen edge amount of delta, used by split & move */ -- cgit v1.2.3 From a81d0108fc8c7cdea14042e7a59ab00ba2633e72 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 08:18:18 +0200 Subject: Cleanup: rename snap enum --- source/blender/editors/screen/screen_ops.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 3ec54cd73bb..a837b32b0bb 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1201,11 +1201,11 @@ typedef struct sAreaMoveData { SNAP_NONE = 0, /* Snap to an invisible grid with a unit defined in AREAGRID */ SNAP_AREAGRID, - /* Snap to mid-point and adjacent edges. */ - SNAP_MIDPOINT_AND_ADJACENT, + /* Snap to fraction (half, third.. etc) and adjacent edges. */ + SNAP_FRACTION_AND_ADJACENT, /* Snap to either bigger or smaller, nothing in-between (used for * global areas). This has priority over other snap types, if it is - * used, toggling SNAP_MIDPOINT_AND_ADJACENT doesn't work. */ + * used, toggling SNAP_FRACTION_AND_ADJACENT doesn't work. */ SNAP_BIGGER_SMALLER_ONLY, } snap_type; } sAreaMoveData; @@ -1369,7 +1369,7 @@ static int area_snap_calc_location( m_cursor_final = (m_cursor >= bigger) ? bigger : smaller; break; - case SNAP_MIDPOINT_AND_ADJACENT: + case SNAP_FRACTION_AND_ADJACENT: { const int axis = (dir == 'v') ? 0 : 1; int snap_dist_best = INT_MAX; @@ -1580,7 +1580,7 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event) case KM_MODAL_SNAP_ON: if (md->snap_type != SNAP_BIGGER_SMALLER_ONLY) { - md->snap_type = SNAP_MIDPOINT_AND_ADJACENT; + md->snap_type = SNAP_FRACTION_AND_ADJACENT; } break; @@ -2062,7 +2062,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) if (sd->previewmode == 0) { if (sd->do_snap) { const int snap_loc = area_snap_calc_location( - CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir, + CTX_wm_screen(C), SNAP_FRACTION_AND_ADJACENT, sd->delta, sd->origval, dir, sd->bigger, sd->smaller); sd->delta = snap_loc - sd->origval; } @@ -2090,7 +2090,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1; const int snap_loc = area_snap_calc_location( - CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir, + CTX_wm_screen(C), SNAP_FRACTION_AND_ADJACENT, sd->delta, sd->origval, dir, sd->origmin + sd->origsize, -sd->origmin); sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0; -- cgit v1.2.3 From fb5597540decca4b490089134890d3e575477e95 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 08:36:10 +0200 Subject: Cleanup: right shift arguments --- source/blender/blenkernel/intern/mesh.c | 48 +++-- source/blender/blenkernel/intern/mesh_convert.c | 16 +- source/blender/blenkernel/intern/mesh_evaluate.c | 252 +++++++++++++---------- source/blender/blenkernel/intern/mesh_mapping.c | 83 ++++---- source/blender/blenkernel/intern/mesh_remap.c | 81 +++++--- source/blender/blenkernel/intern/mesh_validate.c | 51 ++--- 6 files changed, 297 insertions(+), 234 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 4fabf9ebdf8..6d481472074 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -347,8 +347,9 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me) /* Mark an arbitrary vertex as root */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - vs = CustomData_bmesh_get(&bm->vdata, v->head.data, - CD_MVERT_SKIN); + vs = CustomData_bmesh_get( + &bm->vdata, v->head.data, + CD_MVERT_SKIN); vs->flag |= MVERT_SKIN_ROOT; break; } @@ -356,11 +357,12 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me) } else { if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) { - vs = CustomData_add_layer(&me->vdata, - CD_MVERT_SKIN, - CD_DEFAULT, - NULL, - me->totvert); + vs = CustomData_add_layer( + &me->vdata, + CD_MVERT_SKIN, + CD_DEFAULT, + NULL, + me->totvert); /* Mark an arbitrary vertex as root */ if (vs) { @@ -550,8 +552,9 @@ void BKE_mesh_make_local(Main *bmain, Mesh *me, const bool lib_local) BKE_id_make_local_generic(bmain, &me->id, true, lib_local); } -bool BKE_mesh_uv_cdlayer_rename_index(Mesh *me, const int poly_index, const int loop_index, const int face_index, - const char *new_name, const bool do_tessface) +bool BKE_mesh_uv_cdlayer_rename_index( + Mesh *me, const int poly_index, const int loop_index, const int face_index, + const char *new_name, const bool do_tessface) { CustomData *pdata, *ldata, *fdata; CustomDataLayer *cdlp, *cdlu, *cdlf; @@ -1037,9 +1040,10 @@ int poly_get_adj_loops_from_vert( const MLoop *mloop, unsigned int vert, unsigned int r_adj[2]) { - int corner = poly_find_loop_from_vert(poly, - &mloop[poly->loopstart], - vert); + int corner = poly_find_loop_from_vert( + poly, + &mloop[poly->loopstart], + vert); if (corner != -1) { #if 0 /* unused - this loop */ @@ -1147,11 +1151,12 @@ void BKE_mesh_ensure_navmesh(Mesh *me) void BKE_mesh_tessface_calc(Mesh *mesh) { - mesh->totface = BKE_mesh_recalc_tessellation(&mesh->fdata, &mesh->ldata, &mesh->pdata, - mesh->mvert, - mesh->totface, mesh->totloop, mesh->totpoly, - /* calc normals right after, don't copy from polys here */ - false); + mesh->totface = BKE_mesh_recalc_tessellation( + &mesh->fdata, &mesh->ldata, &mesh->pdata, + mesh->mvert, + mesh->totface, mesh->totloop, mesh->totpoly, + /* calc normals right after, don't copy from polys here */ + false); BKE_mesh_update_customdata_pointers(mesh, true); } @@ -1370,8 +1375,8 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac else { polynors = MEM_malloc_arrayN(mesh->totpoly, sizeof(float[3]), __func__); BKE_mesh_calc_normals_poly( - mesh->mvert, NULL, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, polynors, false); + mesh->mvert, NULL, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, polynors, false); free_polynors = true; } @@ -1650,8 +1655,9 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals) /* **** Depsgraph evaluation **** */ -void BKE_mesh_eval_geometry(EvaluationContext *UNUSED(eval_ctx), - Mesh *mesh) +void BKE_mesh_eval_geometry( + EvaluationContext *UNUSED(eval_ctx), + Mesh *mesh) { DEG_debug_print_eval(__func__, mesh->id.name, mesh); if (mesh->bb == NULL || (mesh->bb->flag & BOUNDBOX_DIRTY)) { diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index d376c90f1c2..c801c5dcb01 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -123,9 +123,10 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me) /** * Specialized function to use when we _know_ existing edges don't overlap with poly edges. */ -static void make_edges_mdata_extend(MEdge **r_alledge, int *r_totedge, - const MPoly *mpoly, MLoop *mloop, - const int totpoly) +static void make_edges_mdata_extend( + MEdge **r_alledge, int *r_totedge, + const MPoly *mpoly, MLoop *mloop, + const int totpoly) { int totedge = *r_totedge; int totedge_new; @@ -498,10 +499,11 @@ void BKE_mesh_from_nurbs_displist( cu = ob->data; if (dm == NULL) { - if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert, - &alledge, &totedge, &allloop, - &allpoly, (use_orco_uv) ? &alluv : NULL, - &totloop, &totpoly) != 0) + if (BKE_mesh_nurbs_displist_to_mdata( + ob, dispbase, &allvert, &totvert, + &alledge, &totedge, &allloop, + &allpoly, (use_orco_uv) ? &alluv : NULL, + &totloop, &totpoly) != 0) { /* Error initializing */ return; diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index 6a3d74aec64..279ab777529 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -337,9 +337,10 @@ void BKE_mesh_calc_normals(Mesh *mesh) #ifdef DEBUG_TIME TIMEIT_START_AVERAGED(BKE_mesh_calc_normals); #endif - BKE_mesh_calc_normals_poly(mesh->mvert, NULL, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL, false); + BKE_mesh_calc_normals_poly( + mesh->mvert, NULL, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL, false); #ifdef DEBUG_TIME TIMEIT_END_AVERAGED(BKE_mesh_calc_normals); #endif @@ -487,8 +488,9 @@ MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr) * Beware, this modifies ref_vec and other_vec in place! * In case no valid space can be generated, ref_alpha and ref_beta are set to zero (which means 'use auto lnors'). */ -void BKE_lnor_space_define(MLoopNorSpace *lnor_space, const float lnor[3], - float vec_ref[3], float vec_other[3], BLI_Stack *edge_vectors) +void BKE_lnor_space_define( + MLoopNorSpace *lnor_space, const float lnor[3], + float vec_ref[3], float vec_other[3], BLI_Stack *edge_vectors) { const float pi2 = (float)M_PI * 2.0f; float tvec[3], dtp; @@ -770,8 +772,9 @@ static void mesh_edges_sharp_tag( e2l[1] = (mp->flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID; } else if (e2l[1] == INDEX_UNSET) { - const bool is_angle_sharp = (check_angle && - dot_v3v3(polynors[loop_to_poly[e2l[0]]], polynors[mp_index]) < split_angle_cos); + const bool is_angle_sharp = ( + check_angle && + dot_v3v3(polynors[loop_to_poly[e2l[0]]], polynors[mp_index]) < split_angle_cos); /* Second loop using this edge, time to test its sharpness. * An edge is sharp if it is tagged as such, or its face is not smooth, @@ -1104,8 +1107,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli /* Find next loop of the smooth fan. */ BKE_mesh_loop_manifold_fan_around_vert_next( - mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index, - &mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index); + mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index, + &mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index); e2lfan_curr = edge_to_loops[mlfan_curr->e]; } @@ -1241,8 +1244,8 @@ static bool loop_split_generator_check_cyclic_smooth_fan( while (true) { /* Find next loop of the smooth fan. */ BKE_mesh_loop_manifold_fan_around_vert_next( - mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index, - &mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index); + mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index, + &mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index); e2lfan_curr = edge_to_loops[mlfan_curr->e]; @@ -1591,9 +1594,10 @@ static void mesh_normals_loop_custom_set( BLI_SMALLSTACK_DECLARE(clnors_data, short *); /* Compute current lnor spacearr. */ - BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops, - mpolys, polynors, numPolys, use_split_normals, split_angle, - &lnors_spacearr, NULL, loop_to_poly); + BKE_mesh_normals_loop_split( + mverts, numVerts, medges, numEdges, mloops, lnors, numLoops, + mpolys, polynors, numPolys, use_split_normals, split_angle, + &lnors_spacearr, NULL, loop_to_poly); /* Set all given zero vectors to their default value. */ if (use_vertices) { @@ -1701,9 +1705,10 @@ static void mesh_normals_loop_custom_set( /* And now, recompute our new auto lnors and lnor spacearr! */ BKE_lnor_spacearr_clear(&lnors_spacearr); - BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops, - mpolys, polynors, numPolys, use_split_normals, split_angle, - &lnors_spacearr, NULL, loop_to_poly); + BKE_mesh_normals_loop_split( + mverts, numVerts, medges, numEdges, mloops, lnors, numLoops, + mpolys, polynors, numPolys, use_split_normals, split_angle, + &lnors_spacearr, NULL, loop_to_poly); } else { BLI_BITMAP_SET_ALL(done_loops, true, (size_t)numLoops); @@ -1775,8 +1780,9 @@ void BKE_mesh_normals_loop_custom_set( MPoly *mpolys, const float (*polynors)[3], const int numPolys, short (*r_clnors_data)[2]) { - mesh_normals_loop_custom_set(mverts, numVerts, medges, numEdges, mloops, r_custom_loopnors, numLoops, - mpolys, polynors, numPolys, r_clnors_data, false); + mesh_normals_loop_custom_set( + mverts, numVerts, medges, numEdges, mloops, r_custom_loopnors, numLoops, + mpolys, polynors, numPolys, r_clnors_data, false); } void BKE_mesh_normals_loop_custom_from_vertices_set( @@ -1785,8 +1791,9 @@ void BKE_mesh_normals_loop_custom_from_vertices_set( MPoly *mpolys, const float (*polynors)[3], const int numPolys, short (*r_clnors_data)[2]) { - mesh_normals_loop_custom_set(mverts, numVerts, medges, numEdges, mloops, r_custom_vertnors, numLoops, - mpolys, polynors, numPolys, r_clnors_data, true); + mesh_normals_loop_custom_set( + mverts, numVerts, medges, numEdges, mloops, r_custom_vertnors, numLoops, + mpolys, polynors, numPolys, r_clnors_data, true); } /** @@ -1864,8 +1871,9 @@ static void get_position(const SMikkTSpaceContext *pContext, float r_co[3], cons copy_v3_v3(r_co, p_mesh->mverts[p_mesh->mloops[loop_idx].v].co); } -static void get_texture_coordinate(const SMikkTSpaceContext *pContext, float r_uv[2], const int face_idx, - const int vert_idx) +static void get_texture_coordinate( + const SMikkTSpaceContext *pContext, float r_uv[2], const int face_idx, + const int vert_idx) { BKEMeshToTangent *p_mesh = (BKEMeshToTangent *)pContext->m_pUserData; copy_v2_v2(r_uv, p_mesh->luvs[p_mesh->mpolys[face_idx].loopstart + vert_idx].uv); @@ -1877,8 +1885,9 @@ static void get_normal(const SMikkTSpaceContext *pContext, float r_no[3], const copy_v3_v3(r_no, p_mesh->lnors[p_mesh->mpolys[face_idx].loopstart + vert_idx]); } -static void set_tspace(const SMikkTSpaceContext *pContext, const float fv_tangent[3], const float face_sign, - const int face_idx, const int vert_idx) +static void set_tspace( + const SMikkTSpaceContext *pContext, const float fv_tangent[3], const float face_sign, + const int face_idx, const int vert_idx) { BKEMeshToTangent *p_mesh = (BKEMeshToTangent *)pContext->m_pUserData; float *p_res = p_mesh->tangents[p_mesh->mpolys[face_idx].loopstart + vert_idx]; @@ -1965,8 +1974,9 @@ void BKE_mesh_loop_tangents(Mesh *mesh, const char *uvmap, float (*r_looptangent return; } - BKE_mesh_loop_tangents_ex(mesh->mvert, mesh->totvert, mesh->mloop, r_looptangents, - loopnors, loopuvs, mesh->totloop, mesh->mpoly, mesh->totpoly, reports); + BKE_mesh_loop_tangents_ex( + mesh->mvert, mesh->totvert, mesh->mloop, r_looptangents, + loopnors, loopuvs, mesh->totloop, mesh->mpoly, mesh->totpoly, reports); } /** \} */ @@ -2016,19 +2026,19 @@ void BKE_mesh_calc_poly_normal( mesh_calc_ngon_normal(mpoly, loopstart, mvarray, r_no); } else if (mpoly->totloop == 3) { - normal_tri_v3(r_no, - mvarray[loopstart[0].v].co, - mvarray[loopstart[1].v].co, - mvarray[loopstart[2].v].co - ); + normal_tri_v3( + r_no, + mvarray[loopstart[0].v].co, + mvarray[loopstart[1].v].co, + mvarray[loopstart[2].v].co); } else if (mpoly->totloop == 4) { - normal_quad_v3(r_no, - mvarray[loopstart[0].v].co, - mvarray[loopstart[1].v].co, - mvarray[loopstart[2].v].co, - mvarray[loopstart[3].v].co - ); + normal_quad_v3( + r_no, + mvarray[loopstart[0].v].co, + mvarray[loopstart[1].v].co, + mvarray[loopstart[2].v].co, + mvarray[loopstart[3].v].co); } else { /* horrible, two sided face! */ r_no[0] = 0.0; @@ -2068,19 +2078,19 @@ void BKE_mesh_calc_poly_normal_coords( mesh_calc_ngon_normal_coords(mpoly, loopstart, vertex_coords, r_no); } else if (mpoly->totloop == 3) { - normal_tri_v3(r_no, - vertex_coords[loopstart[0].v], - vertex_coords[loopstart[1].v], - vertex_coords[loopstart[2].v] - ); + normal_tri_v3( + r_no, + vertex_coords[loopstart[0].v], + vertex_coords[loopstart[1].v], + vertex_coords[loopstart[2].v]); } else if (mpoly->totloop == 4) { - normal_quad_v3(r_no, - vertex_coords[loopstart[0].v], - vertex_coords[loopstart[1].v], - vertex_coords[loopstart[2].v], - vertex_coords[loopstart[3].v] - ); + normal_quad_v3( + r_no, + vertex_coords[loopstart[0].v], + vertex_coords[loopstart[1].v], + vertex_coords[loopstart[2].v], + vertex_coords[loopstart[3].v]); } else { /* horrible, two sided face! */ r_no[0] = 0.0; @@ -2108,19 +2118,19 @@ void BKE_mesh_calc_poly_center( const MVert *mvarray, float r_cent[3]) { if (mpoly->totloop == 3) { - mid_v3_v3v3v3(r_cent, - mvarray[loopstart[0].v].co, - mvarray[loopstart[1].v].co, - mvarray[loopstart[2].v].co - ); + mid_v3_v3v3v3( + r_cent, + mvarray[loopstart[0].v].co, + mvarray[loopstart[1].v].co, + mvarray[loopstart[2].v].co); } else if (mpoly->totloop == 4) { - mid_v3_v3v3v3v3(r_cent, - mvarray[loopstart[0].v].co, - mvarray[loopstart[1].v].co, - mvarray[loopstart[2].v].co, - mvarray[loopstart[3].v].co - ); + mid_v3_v3v3v3v3( + r_cent, + mvarray[loopstart[0].v].co, + mvarray[loopstart[1].v].co, + mvarray[loopstart[2].v].co, + mvarray[loopstart[3].v].co); } else { mesh_calc_ngon_center(mpoly, loopstart, mvarray, r_cent); @@ -2133,10 +2143,10 @@ float BKE_mesh_calc_poly_area( const MVert *mvarray) { if (mpoly->totloop == 3) { - return area_tri_v3(mvarray[loopstart[0].v].co, - mvarray[loopstart[1].v].co, - mvarray[loopstart[2].v].co - ); + return area_tri_v3( + mvarray[loopstart[0].v].co, + mvarray[loopstart[1].v].co, + mvarray[loopstart[2].v].co); } else { int i; @@ -2247,8 +2257,9 @@ static float mesh_calc_poly_area_centroid( } #if 0 /* slow version of the function below */ -void BKE_mesh_calc_poly_angles(MPoly *mpoly, MLoop *loopstart, - MVert *mvarray, float angles[]) +void BKE_mesh_calc_poly_angles( + MPoly *mpoly, MLoop *loopstart, + MVert *mvarray, float angles[]) { MLoop *ml; MLoop *mloop = &loopstart[-mpoly->loopstart]; @@ -2620,8 +2631,9 @@ void BKE_mesh_loops_to_mface_corners( * * \note when mface is not NULL, mface[face_index].v4 is used to test quads, else, loopindices[face_index][3] is used. */ -void BKE_mesh_loops_to_tessdata(CustomData *fdata, CustomData *ldata, CustomData *pdata, MFace *mface, - int *polyindices, unsigned int (*loopindices)[4], const int num_faces) +void BKE_mesh_loops_to_tessdata( + CustomData *fdata, CustomData *ldata, CustomData *pdata, MFace *mface, + int *polyindices, unsigned int (*loopindices)[4], const int num_faces) { /* Note: performances are sub-optimal when we get a NULL mface, we could be ~25% quicker with dedicated code... * Issue is, unless having two different functions with nearly the same code, there's not much ways to solve @@ -3221,8 +3233,9 @@ static void bm_corners_to_loops_ex( if (CustomData_external_test(fdata, CD_MDISPS)) { if (id && fdata->external) { - CustomData_external_add(ldata, id, CD_MDISPS, - totloop, fdata->external->filename); + CustomData_external_add( + ldata, id, CD_MDISPS, + totloop, fdata->external->filename); } } @@ -3260,10 +3273,11 @@ static void bm_corners_to_loops_ex( void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) { - BKE_mesh_convert_mfaces_to_mpolys_ex(&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata, - mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly, - mesh->medge, mesh->mface, - &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly); + BKE_mesh_convert_mfaces_to_mpolys_ex( + &mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata, + mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly, + mesh->medge, mesh->mface, + &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly); BKE_mesh_update_customdata_pointers(mesh, true); } @@ -3280,21 +3294,23 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) */ void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh) { - BKE_mesh_convert_mfaces_to_mpolys_ex(&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata, - mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly, - mesh->medge, mesh->mface, - &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly); + BKE_mesh_convert_mfaces_to_mpolys_ex( + &mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata, + mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly, + mesh->medge, mesh->mface, + &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly); CustomData_bmesh_do_versions_update_active_layers(&mesh->fdata, &mesh->pdata, &mesh->ldata); BKE_mesh_update_customdata_pointers(mesh, true); } -void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata, - int totedge_i, int totface_i, int totloop_i, int totpoly_i, - MEdge *medge, MFace *mface, - int *r_totloop, int *r_totpoly, - MLoop **r_mloop, MPoly **r_mpoly) +void BKE_mesh_convert_mfaces_to_mpolys_ex( + ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata, + int totedge_i, int totface_i, int totloop_i, int totpoly_i, + MEdge *medge, MFace *mface, + int *r_totloop, int *r_totpoly, + MLoop **r_mloop, MPoly **r_mpoly) { MFace *mf; MLoop *ml, *mloop; @@ -3518,10 +3534,11 @@ void BKE_mesh_polygons_flip( /* update the hide flag for edges and faces from the corresponding * flag in verts */ -void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert, - const MLoop *mloop, - MEdge *medge, const int totedge, - MPoly *mpoly, const int totpoly) +void BKE_mesh_flush_hidden_from_verts_ex( + const MVert *mvert, + const MLoop *mloop, + MEdge *medge, const int totedge, + MPoly *mpoly, const int totpoly) { int i, j; @@ -3547,15 +3564,17 @@ void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert, } void BKE_mesh_flush_hidden_from_verts(Mesh *me) { - BKE_mesh_flush_hidden_from_verts_ex(me->mvert, me->mloop, - me->medge, me->totedge, - me->mpoly, me->totpoly); + BKE_mesh_flush_hidden_from_verts_ex( + me->mvert, me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); } -void BKE_mesh_flush_hidden_from_polys_ex(MVert *mvert, - const MLoop *mloop, - MEdge *medge, const int UNUSED(totedge), - const MPoly *mpoly, const int totpoly) +void BKE_mesh_flush_hidden_from_polys_ex( + MVert *mvert, + const MLoop *mloop, + MEdge *medge, const int UNUSED(totedge), + const MPoly *mpoly, const int totpoly) { const MPoly *mp; int i; @@ -3588,18 +3607,20 @@ void BKE_mesh_flush_hidden_from_polys_ex(MVert *mvert, } void BKE_mesh_flush_hidden_from_polys(Mesh *me) { - BKE_mesh_flush_hidden_from_polys_ex(me->mvert, me->mloop, - me->medge, me->totedge, - me->mpoly, me->totpoly); + BKE_mesh_flush_hidden_from_polys_ex( + me->mvert, me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); } /** * simple poly -> vert/edge selection. */ -void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert, - const MLoop *mloop, - MEdge *medge, const int totedge, - const MPoly *mpoly, const int totpoly) +void BKE_mesh_flush_select_from_polys_ex( + MVert *mvert, const int totvert, + const MLoop *mloop, + MEdge *medge, const int totedge, + const MPoly *mpoly, const int totpoly) { MVert *mv; MEdge *med; @@ -3633,16 +3654,18 @@ void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert, } void BKE_mesh_flush_select_from_polys(Mesh *me) { - BKE_mesh_flush_select_from_polys_ex(me->mvert, me->totvert, - me->mloop, - me->medge, me->totedge, - me->mpoly, me->totpoly); + BKE_mesh_flush_select_from_polys_ex( + me->mvert, me->totvert, + me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); } -void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(totvert), - const MLoop *mloop, - MEdge *medge, const int totedge, - MPoly *mpoly, const int totpoly) +void BKE_mesh_flush_select_from_verts_ex( + const MVert *mvert, const int UNUSED(totvert), + const MLoop *mloop, + MEdge *medge, const int totedge, + MPoly *mpoly, const int totpoly) { MEdge *med; MPoly *mp; @@ -3687,10 +3710,11 @@ void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(to } void BKE_mesh_flush_select_from_verts(Mesh *me) { - BKE_mesh_flush_select_from_verts_ex(me->mvert, me->totvert, - me->mloop, - me->medge, me->totedge, - me->mpoly, me->totpoly); + BKE_mesh_flush_select_from_verts_ex( + me->mvert, me->totvert, + me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); } /** \} */ @@ -3718,7 +3742,7 @@ void BKE_mesh_calc_relative_deform( const float (*vert_cos_dst)[3], const float (*vert_cos_org)[3], - float (*vert_cos_new)[3]) + float (*vert_cos_new)[3]) { const MPoly *mp; int i; diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c index 0143125490e..699d6bce2b0 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.c +++ b/source/blender/blenkernel/intern/mesh_mapping.c @@ -243,9 +243,10 @@ static void mesh_vert_poly_or_loop_map_create( * Generates a map where the key is the vertex and the value is a list of polys that use that vertex as a corner. * The lists are allocated from one memory pool. */ -void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem, - const MPoly *mpoly, const MLoop *mloop, - int totvert, int totpoly, int totloop) +void BKE_mesh_vert_poly_map_create( + MeshElemMap **r_map, int **r_mem, + const MPoly *mpoly, const MLoop *mloop, + int totvert, int totpoly, int totloop) { mesh_vert_poly_or_loop_map_create(r_map, r_mem, mpoly, mloop, totvert, totpoly, totloop, false); } @@ -254,9 +255,10 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem, * Generates a map where the key is the vertex and the value is a list of loops that use that vertex as a corner. * The lists are allocated from one memory pool. */ -void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map, int **r_mem, - const MPoly *mpoly, const MLoop *mloop, - int totvert, int totpoly, int totloop) +void BKE_mesh_vert_loop_map_create( + MeshElemMap **r_map, int **r_mem, + const MPoly *mpoly, const MLoop *mloop, + int totvert, int totpoly, int totloop) { mesh_vert_poly_or_loop_map_create(r_map, r_mem, mpoly, mloop, totvert, totpoly, totloop, true); } @@ -310,8 +312,9 @@ void BKE_mesh_vert_looptri_map_create( * Generates a map where the key is the vertex and the value is a list of edges that use that vertex as an endpoint. * The lists are allocated from one memory pool. */ -void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem, - const MEdge *medge, int totvert, int totedge) +void BKE_mesh_vert_edge_map_create( + MeshElemMap **r_map, int **r_mem, + const MEdge *medge, int totvert, int totedge) { MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, "vert-edge map"); int *indices = MEM_mallocN(sizeof(int[2]) * (size_t)totedge, "vert-edge map mem"); @@ -397,10 +400,11 @@ void BKE_mesh_vert_edge_vert_map_create( * Loops indices of a same poly are contiguous and in winding order. * The lists are allocated from one memory pool. */ -void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, int **r_mem, - const MEdge *UNUSED(medge), const int totedge, - const MPoly *mpoly, const int totpoly, - const MLoop *mloop, const int totloop) +void BKE_mesh_edge_loop_map_create( + MeshElemMap **r_map, int **r_mem, + const MEdge *UNUSED(medge), const int totedge, + const MPoly *mpoly, const int totpoly, + const MLoop *mloop, const int totloop) { MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totedge, "edge-poly map"); int *indices = MEM_mallocN(sizeof(int) * (size_t)totloop * 2, "edge-poly map mem"); @@ -450,10 +454,11 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, int **r_mem, * Generates a map where the key is the edge and the value is a list of polygons that use that edge. * The lists are allocated from one memory pool. */ -void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem, - const MEdge *UNUSED(medge), const int totedge, - const MPoly *mpoly, const int totpoly, - const MLoop *mloop, const int totloop) +void BKE_mesh_edge_poly_map_create( + MeshElemMap **r_map, int **r_mem, + const MEdge *UNUSED(medge), const int totedge, + const MPoly *mpoly, const int totpoly, + const MLoop *mloop, const int totloop) { MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totedge, "edge-poly map"); int *indices = MEM_mallocN(sizeof(int) * (size_t)totloop, "edge-poly map mem"); @@ -509,9 +514,10 @@ void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem, * ``totfinal`` could be ``tottessface`` and ``final_origindex`` its ORIGINDEX customdata. * This would allow an MPoly to loop over its tessfaces. */ -void BKE_mesh_origindex_map_create(MeshElemMap **r_map, int **r_mem, - const int totsource, - const int *final_origindex, const int totfinal) +void BKE_mesh_origindex_map_create( + MeshElemMap **r_map, int **r_mem, + const int totsource, + const int *final_origindex, const int totfinal) { MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totsource, "poly-tessface map"); int *indices = MEM_mallocN(sizeof(int) * (size_t)totfinal, "poly-tessface map mem"); @@ -632,8 +638,9 @@ static void poly_edge_loop_islands_calc( } if (!edge_poly_map) { - BKE_mesh_edge_poly_map_create(&edge_poly_map, &edge_poly_mem, - medge, totedge, mpoly, totpoly, mloop, totloop); + BKE_mesh_edge_poly_map_create( + &edge_poly_map, &edge_poly_mem, + medge, totedge, mpoly, totpoly, mloop, totloop); } poly_groups = MEM_callocN(sizeof(int) * (size_t)totpoly, __func__); @@ -786,10 +793,11 @@ static bool poly_is_island_boundary_smooth_cb( * (0 being used as 'invalid' flag). * Note it's callers's responsibility to MEM_freeN returned array. */ -int *BKE_mesh_calc_smoothgroups(const MEdge *medge, const int totedge, - const MPoly *mpoly, const int totpoly, - const MLoop *mloop, const int totloop, - int *r_totgroup, const bool use_bitflags) +int *BKE_mesh_calc_smoothgroups( + const MEdge *medge, const int totedge, + const MPoly *mpoly, const int totpoly, + const MLoop *mloop, const int totloop, + int *r_totgroup, const bool use_bitflags) { int *poly_groups = NULL; @@ -987,21 +995,23 @@ static bool mesh_calc_islands_loop_poly_uv( BKE_mesh_loop_islands_clear(r_island_store); BKE_mesh_loop_islands_init(r_island_store, MISLAND_TYPE_LOOP, totloop, MISLAND_TYPE_POLY, MISLAND_TYPE_EDGE); - BKE_mesh_edge_poly_map_create(&edge_poly_map, &edge_poly_mem, - edges, totedge, polys, totpoly, loops, totloop); + BKE_mesh_edge_poly_map_create( + &edge_poly_map, &edge_poly_mem, + edges, totedge, polys, totpoly, loops, totloop); if (luvs) { - BKE_mesh_edge_loop_map_create(&edge_loop_map, &edge_loop_mem, - edges, totedge, polys, totpoly, loops, totloop); + BKE_mesh_edge_loop_map_create( + &edge_loop_map, &edge_loop_mem, + edges, totedge, polys, totpoly, loops, totloop); edge_boundary_check_data.loops = loops; edge_boundary_check_data.luvs = luvs; edge_boundary_check_data.edge_loop_map = edge_loop_map; } poly_edge_loop_islands_calc( - edges, totedge, polys, totpoly, loops, totloop, edge_poly_map, false, - mesh_check_island_boundary_uv, luvs ? &edge_boundary_check_data : NULL, - &poly_groups, &num_poly_groups, &edge_borders, &num_edge_borders); + edges, totedge, polys, totpoly, loops, totloop, edge_poly_map, false, + mesh_check_island_boundary_uv, luvs ? &edge_boundary_check_data : NULL, + &poly_groups, &num_poly_groups, &edge_borders, &num_edge_borders); if (!num_poly_groups) { /* Should never happen... */ @@ -1051,8 +1061,9 @@ static bool mesh_calc_islands_loop_poly_uv( } } - BKE_mesh_loop_islands_add(r_island_store, num_lidx, loop_indices, num_pidx, poly_indices, - num_einnercuts, edge_innercut_indices); + BKE_mesh_loop_islands_add( + r_island_store, num_lidx, loop_indices, num_pidx, poly_indices, + num_einnercuts, edge_innercut_indices); } MEM_freeN(edge_poly_map); @@ -1089,7 +1100,7 @@ bool BKE_mesh_calc_islands_loop_poly_edgeseam( MeshIslandStore *r_island_store) { return mesh_calc_islands_loop_poly_uv( - verts, totvert, edges, totedge, polys, totpoly, loops, totloop, NULL, r_island_store); + verts, totvert, edges, totedge, polys, totpoly, loops, totloop, NULL, r_island_store); } /** @@ -1113,7 +1124,7 @@ bool BKE_mesh_calc_islands_loop_poly_uvmap( { BLI_assert(luvs != NULL); return mesh_calc_islands_loop_poly_uv( - verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store); + verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store); } /** \} */ diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c index eef8657482f..77aefc04f5f 100644 --- a/source/blender/blenkernel/intern/mesh_remap.c +++ b/source/blender/blenkernel/intern/mesh_remap.c @@ -669,8 +669,9 @@ void BKE_mesh_remap_calc_edges_from_dm( v_dst_to_src_map[i].hit_dist = -1.0f; } - BKE_mesh_vert_edge_map_create(&vert_to_edge_src_map, &vert_to_edge_src_map_mem, - edges_src, num_verts_src, num_edges_src); + BKE_mesh_vert_edge_map_create( + &vert_to_edge_src_map, &vert_to_edge_src_map_mem, + edges_src, num_verts_src, num_edges_src); dm_src->getVertCos(dm_src, vcos_src); @@ -932,8 +933,9 @@ void BKE_mesh_remap_calc_edges_from_dm( indices[sources_num] = j; sources_num++; } - mesh_remap_item_define(r_map, i, hit_dist_accum / totweights, 0, - sources_num, indices, weights); + mesh_remap_item_define( + r_map, i, hit_dist_accum / totweights, 0, + sources_num, indices, weights); } else { /* No source for this dest edge! */ @@ -1147,8 +1149,9 @@ void BKE_mesh_remap_calc_loops_from_dm( BLI_AStarGraph *as_graphdata = NULL; BLI_AStarSolution as_solution = {0}; - const int isld_steps_src = islands_precision_src ? - max_ii((int)(ASTAR_STEPS_MAX * islands_precision_src + 0.499f), 1) : 0; + const int isld_steps_src = ( + islands_precision_src ? + max_ii((int)(ASTAR_STEPS_MAX * islands_precision_src + 0.499f), 1) : 0); float (*poly_nors_src)[3] = NULL; float (*loop_nors_src)[3] = NULL; @@ -1220,8 +1223,9 @@ void BKE_mesh_remap_calc_loops_from_dm( CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); } if (dirty_nors_dst) { - BKE_mesh_calc_normals_poly(verts_dst, NULL, numverts_dst, loops_dst, polys_dst, - numloops_dst, numpolys_dst, poly_nors_dst, true); + BKE_mesh_calc_normals_poly( + verts_dst, NULL, numverts_dst, loops_dst, polys_dst, + numloops_dst, numpolys_dst, poly_nors_dst, true); } } if (need_lnors_dst) { @@ -1234,10 +1238,11 @@ void BKE_mesh_remap_calc_loops_from_dm( loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, numloops_dst); CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); } - BKE_mesh_normals_loop_split(verts_dst, numverts_dst, edges_dst, numedges_dst, - loops_dst, loop_nors_dst, numloops_dst, - polys_dst, (const float (*)[3])poly_nors_dst, numpolys_dst, - use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL); + BKE_mesh_normals_loop_split( + verts_dst, numverts_dst, edges_dst, numedges_dst, + loops_dst, loop_nors_dst, numloops_dst, + polys_dst, (const float (*)[3])poly_nors_dst, numpolys_dst, + use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL); } } if (need_pnors_src || need_lnors_src) { @@ -1254,17 +1259,20 @@ void BKE_mesh_remap_calc_loops_from_dm( } if (use_from_vert) { - BKE_mesh_vert_loop_map_create(&vert_to_loop_map_src, &vert_to_loop_map_src_buff, - polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src); + BKE_mesh_vert_loop_map_create( + &vert_to_loop_map_src, &vert_to_loop_map_src_buff, + polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src); if (mode & MREMAP_USE_POLY) { - BKE_mesh_vert_poly_map_create(&vert_to_poly_map_src, &vert_to_poly_map_src_buff, - polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src); + BKE_mesh_vert_poly_map_create( + &vert_to_poly_map_src, &vert_to_poly_map_src_buff, + polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src); } } /* Needed for islands (or plain mesh) to AStar graph conversion. */ - BKE_mesh_edge_poly_map_create(&edge_to_poly_map_src, &edge_to_poly_map_src_buff, - edges_src, num_edges_src, polys_src, num_polys_src, loops_src, num_loops_src); + BKE_mesh_edge_poly_map_create( + &edge_to_poly_map_src, &edge_to_poly_map_src_buff, + edges_src, num_edges_src, polys_src, num_polys_src, loops_src, num_loops_src); if (use_from_vert) { loop_to_poly_map_src = MEM_mallocN(sizeof(*loop_to_poly_map_src) * (size_t)num_loops_src, __func__); poly_cents_src = MEM_mallocN(sizeof(*poly_cents_src) * (size_t)num_polys_src, __func__); @@ -1345,8 +1353,9 @@ void BKE_mesh_remap_calc_loops_from_dm( } } /* verts 'ownership' is transfered to treedata here, which will handle its freeing. */ - bvhtree_from_mesh_verts_ex(&treedata[tindex], verts_src, num_verts_src, verts_allocated_src, - verts_active, num_verts_active, 0.0, 2, 6); + bvhtree_from_mesh_verts_ex( + &treedata[tindex], verts_src, num_verts_src, verts_allocated_src, + verts_active, num_verts_active, 0.0, 2, 6); if (verts_allocated_src) { verts_allocated_src = false; /* Only 'give' our verts once, to first tree! */ } @@ -1481,13 +1490,15 @@ void BKE_mesh_remap_calc_loops_from_dm( BLI_assert(index_src != -1); const float dot = dot_v3v3(nors_src[index_src], *nor_dst); - pidx_src = (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ? - loop_to_poly_map_src[index_src] : index_src; + pidx_src = ( + (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ? + loop_to_poly_map_src[index_src] : index_src); /* WARNING! This is not the *real* lidx_src in case of POLYNOR, we only use it * to check we stay on current island (all loops from a given poly are * on same island!). */ - lidx_src = (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ? - index_src : polys_src[pidx_src].loopstart; + lidx_src = ( + (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ? + index_src : polys_src[pidx_src].loopstart); /* A same vert may be at the boundary of several islands! Hence, we have to ensure * poly/loop we are currently considering *belongs* to current island! */ @@ -1506,7 +1517,7 @@ void BKE_mesh_remap_calc_loops_from_dm( if (!pcent_dst_valid) { BKE_mesh_calc_poly_center( - mp_dst, &loops_dst[mp_dst->loopstart], verts_dst, pcent_dst); + mp_dst, &loops_dst[mp_dst->loopstart], verts_dst, pcent_dst); pcent_dst_valid = true; } pcent_src = poly_cents_src[pidx_src]; @@ -1737,8 +1748,9 @@ void BKE_mesh_remap_calc_loops_from_dm( BLI_space_transform_apply(space_transform, tmp_co); } - pidx_src = use_islands ? best_island->indices[last_valid_pidx_isld_src] : - last_valid_pidx_isld_src; + pidx_src = ( + use_islands ? best_island->indices[last_valid_pidx_isld_src] : + last_valid_pidx_isld_src); mp_src = &polys_src[pidx_src]; ml_src = &loops_src[mp_src->loopstart]; for (j = 0; j < mp_src->totloop; j++, ml_src++) { @@ -1822,8 +1834,9 @@ void BKE_mesh_remap_calc_loops_from_dm( BLI_space_transform_apply(space_transform, tmp_co); } - pidx_src = use_islands ? best_island->indices[last_valid_pidx_isld_src] : - last_valid_pidx_isld_src; + pidx_src = ( + use_islands ? best_island->indices[last_valid_pidx_isld_src] : + last_valid_pidx_isld_src); mp_src = &polys_src[pidx_src]; /* Create that one on demand. */ @@ -1984,8 +1997,9 @@ void BKE_mesh_remap_calc_polys_from_dm( CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); } if (dirty_nors_dst) { - BKE_mesh_calc_normals_poly(verts_dst, NULL, numverts_dst, loops_dst, polys_dst, numloops_dst, numpolys_dst, - poly_nors_dst, true); + BKE_mesh_calc_normals_poly( + verts_dst, NULL, numverts_dst, loops_dst, polys_dst, numloops_dst, numpolys_dst, + poly_nors_dst, true); } } @@ -2168,8 +2182,9 @@ void BKE_mesh_remap_calc_polys_from_dm( tri_vidx_2d[1][2] = 3; } else { - BLI_polyfill_calc(poly_vcos_2d, (unsigned int)mp->totloop, -1, - (unsigned int (*)[3])tri_vidx_2d); + BLI_polyfill_calc( + poly_vcos_2d, (unsigned int)mp->totloop, -1, + (unsigned int (*)[3])tri_vidx_2d); } for (j = 0; j < tris_num; j++) { diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 946677e0ab2..5c835bbf0fa 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -212,15 +212,16 @@ static int search_polyloop_cmp(const void *v1, const void *v2) * * \return false if no changes needed to be made. */ -bool BKE_mesh_validate_arrays(Mesh *mesh, - MVert *mverts, unsigned int totvert, - MEdge *medges, unsigned int totedge, - MFace *mfaces, unsigned int totface, - MLoop *mloops, unsigned int totloop, - MPoly *mpolys, unsigned int totpoly, - MDeformVert *dverts, /* assume totvert length */ - const bool do_verbose, const bool do_fixes, - bool *r_changed) +bool BKE_mesh_validate_arrays( + Mesh *mesh, + MVert *mverts, unsigned int totvert, + MEdge *medges, unsigned int totedge, + MFace *mfaces, unsigned int totface, + MLoop *mloops, unsigned int totloop, + MPoly *mpolys, unsigned int totpoly, + MDeformVert *dverts, /* assume totvert length */ + const bool do_verbose, const bool do_fixes, + bool *r_changed) { # define REMOVE_EDGE_TAG(_me) { _me->v2 = _me->v1; free_flag.edges = do_fixes; } (void)0 # define IS_REMOVED_EDGE(_me) (_me->v2 == _me->v1) @@ -875,9 +876,10 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, return is_valid; } -static bool mesh_validate_customdata(CustomData *data, CustomDataMask mask, - const bool do_verbose, const bool do_fixes, - bool *r_change) +static bool mesh_validate_customdata( + CustomData *data, CustomDataMask mask, + const bool do_verbose, const bool do_fixes, + bool *r_change) { bool is_valid = true; bool has_fixes = false; @@ -928,11 +930,12 @@ static bool mesh_validate_customdata(CustomData *data, CustomDataMask mask, /** * \returns is_valid. */ -bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, - CustomData *ldata, CustomData *pdata, - const bool check_meshmask, - const bool do_verbose, const bool do_fixes, - bool *r_change) +bool BKE_mesh_validate_all_customdata( + CustomData *vdata, CustomData *edata, + CustomData *ldata, CustomData *pdata, + const bool check_meshmask, + const bool do_verbose, const bool do_fixes, + bool *r_change) { bool is_valid = true; bool is_change_v, is_change_e, is_change_l, is_change_p; @@ -1268,9 +1271,10 @@ struct EdgeSort { }; /* edges have to be added with lowest index first for sorting */ -static void to_edgesort(struct EdgeSort *ed, - unsigned int v1, unsigned int v2, - char is_loose, short is_draw) +static void to_edgesort( + struct EdgeSort *ed, + unsigned int v1, unsigned int v2, + char is_loose, short is_draw) { if (v1 < v2) { ed->v1 = v1; ed->v2 = v2; @@ -1419,9 +1423,10 @@ void BKE_mesh_calc_edges_legacy(Mesh *me, const bool use_old) MEdge *medge; int totedge = 0; - mesh_calc_edges_mdata(me->mvert, me->mface, me->mloop, me->mpoly, - me->totvert, me->totface, me->totloop, me->totpoly, - use_old, &medge, &totedge); + mesh_calc_edges_mdata( + me->mvert, me->mface, me->mloop, me->mpoly, + me->totvert, me->totface, me->totloop, me->totpoly, + use_old, &medge, &totedge); if (totedge == 0) { /* flag that mesh has edges */ -- cgit v1.2.3 From 8a429b03e130cb77378cabd35b2f4a8f8dd3f1d2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 08:42:34 +0200 Subject: Cleanup: style --- release/scripts/startup/bl_ui/properties_render.py | 4 ++-- release/scripts/startup/bl_ui/space_userpref.py | 1 - release/scripts/startup/bl_ui/space_view3d.py | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index ff36d2494ea..a7cfee5ed8f 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -739,7 +739,7 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel): sub = row.row(align=True) sub.prop(props, "gi_cubemap_draw_size", text="Size") - if props.gi_show_cubemaps : + if props.gi_show_cubemaps: sub.prop(props, "gi_show_cubemaps", text="", toggle=True, icon='HIDE_OFF') else: sub.prop(props, "gi_show_cubemaps", text="", toggle=True, icon='HIDE_ON') @@ -750,7 +750,7 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel): sub = row.row(align=True) sub.prop(props, "gi_irradiance_draw_size", text="Size") - if props.gi_show_irradiance : + if props.gi_show_irradiance: sub.prop(props, "gi_show_irradiance", text="", toggle=True, icon='HIDE_OFF') else: sub.prop(props, "gi_show_irradiance", text="", toggle=True, icon='HIDE_ON') diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 939e958375a..806b57e0297 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1473,7 +1473,6 @@ class USERPREF_PT_addons(Panel): sub.active = is_enabled sub.label(text="%s: %s" % (info["category"], info["name"])) - # WARNING: 2.8x exception, may be removed # use disabled state for old add-ons, chances are they are broken. if info.get("blender", (0,)) < (2, 80): diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index db5efeb43c2..53e4346550e 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3710,12 +3710,14 @@ class VIEW3D_PT_object_type_visibility(Panel): col = layout.column() attr_object_types = ( + # Geometry "mesh", "curve", "surf", "meta", "font", None, + # Other "armature", "lattice", "empty", -- cgit v1.2.3 From 8f884c22f11226d85c15ffc6f517b6220b6bb574 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 13 Jul 2018 08:55:07 +0200 Subject: Keymap: dope-sheet hotkey to change falloff --- source/blender/editors/include/ED_object.h | 1 + source/blender/editors/space_action/action_ops.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 29f7edaebf0..38545137740 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -62,6 +62,7 @@ struct Depsgraph; struct uiLayout; #include "DNA_object_enums.h" +#include "BLI_compiler_attrs.h" /* object_edit.c */ struct Object *ED_object_context(struct bContext *C); /* context.object */ diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index a4bbfd5cd7f..a4b96e76066 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -39,6 +39,7 @@ #include "ED_anim_api.h" #include "ED_markers.h" #include "ED_transform.h" +#include "ED_object.h" #include "action_intern.h" @@ -266,6 +267,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_action"); + ED_keymap_proportional_cycle(keyconf, keymap); /* special markers hotkeys for anim editors: see note in definition of this function */ ED_marker_keymap_animedit_conflictfree(keymap); -- cgit v1.2.3 From 8c957468bcd5159ddedcecd33a87ce75e0d7637f Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 13 Jul 2018 09:05:17 +0200 Subject: Keymap: dope-sheet hotkey to change falloff --- source/blender/editors/include/ED_object.h | 2 ++ source/blender/editors/space_action/action_ops.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index a8536e6f71c..d40c4f8dec9 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -53,8 +53,10 @@ struct wmOperatorType; struct PointerRNA; struct PropertyRNA; struct EnumPropertyItem; +struct wmWindowManager; #include "DNA_object_enums.h" +#include "BLI_compiler_attrs.h" /* object_edit.c */ struct Object *ED_object_context(struct bContext *C); /* context.object */ diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 551db8c4faa..32407286258 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -39,6 +39,7 @@ #include "ED_anim_api.h" #include "ED_markers.h" #include "ED_transform.h" +#include "ED_object.h" #include "action_intern.h" @@ -261,6 +262,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_action"); + ED_keymap_proportional_cycle(keyconf, keymap); /* special markers hotkeys for anim editors: see note in definition of this function */ ED_marker_keymap_animedit_conflictfree(keymap); -- cgit v1.2.3 From b2d8f834446c5545efae8a824a6197e2b338ec00 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 09:18:46 +0200 Subject: Keymap: run search by its key in tools popup The button & key are displayed here, so its best if the shortcut works. --- .../startup/bl_ui/space_toolsystem_common.py | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 7fe8360b4da..ffd95ec7c64 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -625,6 +625,16 @@ def keymap_from_context(context, space_type): Keymap for popup toolbar, currently generated each time. """ + def modifier_keywords_from_item(kmi): + return { + "any": kmi.any, + "shift": kmi.shift, + "ctrl": kmi.ctrl, + "alt": kmi.alt, + "oskey": kmi.oskey, + "key_modifier": kmi.key_modifier, + } + use_search = False # allows double tap use_simple_keymap = False @@ -677,12 +687,7 @@ def keymap_from_context(context, space_type): idname="wm.tool_set_by_name", type=kmi_found_type, value='PRESS', - any=kmi_found.any, - shift=kmi_found.shift, - ctrl=kmi_found.ctrl, - alt=kmi_found.alt, - oskey=kmi_found.oskey, - key_modifier=kmi_found.key_modifier, + **modifier_keywords_from_item(kmi_found), ) kmi.properties.name = item.text @@ -695,6 +700,16 @@ def keymap_from_context(context, space_type): # Support double-tap for search. if kmi_search_type: keymap.keymap_items.new("wm.search_menu", type=kmi_search_type, value='PRESS') + else: + # The shortcut will show, so we better support running it. + kmi_search = wm.keyconfigs.find_item_from_operator(idname="wm.search_menu")[1] + if kmi_search: + keymap.keymap_items.new( + "wm.search_menu", + type=kmi_search.type, + value='PRESS', + **modifier_keywords_from_item(kmi_search), + ) wm.keyconfigs.update() return keymap -- cgit v1.2.3 From f27449d117c616183732293e62ee099320f23585 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 10:00:36 +0200 Subject: Fix T55920: viewport "navigate" shows on transform --- source/blender/editors/mesh/editmesh_bevel.c | 2 +- source/blender/editors/mesh/editmesh_bisect.c | 2 +- source/blender/editors/mesh/editmesh_inset.c | 2 +- source/blender/editors/transform/transform_generics.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 2b6f8914a02..58246a60362 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -202,7 +202,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) if (v3d) { opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = 0; + v3d->mpr_flag = V3D_MANIPULATOR_HIDE; } } diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index ee8adeb2c52..579cd5e4e08 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -157,7 +157,7 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* misc other vars */ G.moving = G_TRANSFORM_EDIT; opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = 0; + v3d->mpr_flag = V3D_MANIPULATOR_HIDE; /* initialize modal callout */ ED_workspace_status_text(C, IFACE_("LMB: Click and drag to draw cut line")); diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 251e328ee84..1f1d2f5a2e1 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -174,7 +174,7 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) G.moving = G_TRANSFORM_EDIT; if (v3d) { opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = 0; + v3d->mpr_flag = V3D_MANIPULATOR_HIDE; } } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 303fa26bd4a..c79c28a99da 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1351,7 +1351,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* turn manipulator off during transform */ if (t->flag & T_MODAL) { t->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = 0; + v3d->mpr_flag = V3D_MANIPULATOR_HIDE; } if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) { -- cgit v1.2.3 From 252ebf6bfdb52d8d02adb46b8ba0712bd8392aa5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 10:26:24 +0200 Subject: Cleanup: split keymap lookups into own functions More will be added in 2.8, keep this manageable. --- source/blender/editors/interface/interface.c | 84 ++++++++++++++++++---------- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e5c3ebf2695..e51822ac125 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -942,7 +942,6 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) * but this could be supported */ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_strip) { - if (do_strip && (but->flag & UI_BUT_HAS_SEP_CHAR)) { char *cpoin = strrchr(but->str, UI_SEP_CHAR); if (cpoin) { @@ -973,43 +972,70 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str } } -static bool ui_but_event_operator_string( +/* -------------------------------------------------------------------- */ +/** \name Find Key Shortcut for Button + * + * - #ui_but_event_operator_string (and helpers) + * - #ui_but_event_property_operator_string + * \{ */ + +static bool ui_but_event_operator_string_from_operator( const bContext *C, uiBut *but, char *buf, const size_t buf_len) { - MenuType *mt; + BLI_assert(but->optype != NULL); bool found = false; + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - if (but->optype) { - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - - if (WM_key_event_operator_string( - C, but->optype->idname, but->opcontext, prop, true, - buf, buf_len)) - { - found = true; - } + if (WM_key_event_operator_string( + C, but->optype->idname, but->opcontext, prop, true, + buf, buf_len)) + { + found = true; } - else if ((mt = UI_but_menutype_get(but))) { - IDProperty *prop_menu; - IDProperty *prop_menu_name; + return found; +} - /* annoying, create a property */ - IDPropertyTemplate val = {0}; - prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */ - IDP_AddToGroup(prop_menu, (prop_menu_name = IDP_NewString("", "name", sizeof(mt->idname)))); +static bool ui_but_event_operator_string_from_menu( + const bContext *C, uiBut *but, + char *buf, const size_t buf_len) +{ + MenuType *mt = UI_but_menutype_get(but); + BLI_assert(mt != NULL); - IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname)); + bool found = false; + IDProperty *prop_menu, *prop_menu_name; - if (WM_key_event_operator_string( - C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, - buf, buf_len)) - { - found = true; - } + /* annoying, create a property */ + IDPropertyTemplate val = {0}; + prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */ + IDP_AddToGroup(prop_menu, (prop_menu_name = IDP_NewString("", "name", sizeof(mt->idname)))); + + IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname)); - IDP_FreeProperty(prop_menu); - MEM_freeN(prop_menu); + if (WM_key_event_operator_string( + C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, + buf, buf_len)) + { + found = true; + } + + IDP_FreeProperty(prop_menu); + MEM_freeN(prop_menu); + return found; +} + +static bool ui_but_event_operator_string( + const bContext *C, uiBut *but, + char *buf, const size_t buf_len) +{ + bool found = false; + + if (but->optype != NULL) { + found = ui_but_event_operator_string_from_operator(C, but, buf, buf_len); + } + else if (UI_but_menutype_get(but) != NULL) { + found = ui_but_event_operator_string_from_menu(C, but, buf, buf_len); } return found; @@ -1131,6 +1157,8 @@ static bool ui_but_event_property_operator_string( return found; } +/** \} */ + /** * This goes in a seemingly weird pattern: * -- cgit v1.2.3 From f4213c1408619d1071004247ed099e2ba98a3e9a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 10:51:49 +0200 Subject: Cleanup: id-property API use Also clarify comments. --- source/blender/blenkernel/intern/idprop.c | 6 +++--- source/blender/editors/interface/interface.c | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index cefd3f5807e..7a526d31567 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -886,7 +886,6 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is case IDP_ID: return (IDP_Id(prop1) == IDP_Id(prop2)); default: - /* should never get here */ BLI_assert(0); break; } @@ -988,7 +987,8 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char * prop->data.pointer = MEM_mallocN(DEFAULT_ALLOC_FOR_NULL_STRINGS, "id property string 1"); *IDP_String(prop) = '\0'; prop->totallen = DEFAULT_ALLOC_FOR_NULL_STRINGS; - prop->len = 1; /*NULL string, has len of 1 to account for null byte.*/ + /* NULL string, has len of 1 to account for null byte. */ + prop->len = 1; } else { BLI_assert((int)val->string.len <= (int)strlen(st) + 1); @@ -1003,8 +1003,8 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char * } case IDP_GROUP: { + /* Values are set properly by calloc. */ prop = MEM_callocN(sizeof(IDProperty), "IDProperty group"); - /* heh I think all needed values are set properly by calloc anyway :) */ break; } case IDP_ID: diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e51822ac125..82ae4de07af 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1004,14 +1004,12 @@ static bool ui_but_event_operator_string_from_menu( BLI_assert(mt != NULL); bool found = false; - IDProperty *prop_menu, *prop_menu_name; + IDProperty *prop_menu; /* annoying, create a property */ IDPropertyTemplate val = {0}; prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */ - IDP_AddToGroup(prop_menu, (prop_menu_name = IDP_NewString("", "name", sizeof(mt->idname)))); - - IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname)); + IDP_AddToGroup(prop_menu, IDP_NewString(mt->idname, "name", sizeof(mt->idname))); if (WM_key_event_operator_string( C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, -- cgit v1.2.3 From 399cbd3b6bb9e23333ecc37231c8149056affda1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 10:57:25 +0200 Subject: UI: show popover shortcuts in tooltip --- source/blender/editors/interface/interface.c | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 6df54c0a31c..3e01c5f356f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -998,6 +998,41 @@ static bool ui_but_event_operator_string_from_menu( return found; } +static bool ui_but_event_operator_string_from_panel( + const bContext *C, uiBut *but, + char *buf, const size_t buf_len) +{ + /** Nearly exact copy of #ui_but_event_operator_string_from_menu */ + PanelType *pt = UI_but_paneltype_get(but); + BLI_assert(pt != NULL); + + bool found = false; + IDProperty *prop_panel; + + /* annoying, create a property */ + IDPropertyTemplate val = {0}; + prop_panel = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */ + IDP_AddToGroup(prop_panel, IDP_NewString(pt->idname, "name", sizeof(pt->idname))); + IDP_AddToGroup(prop_panel, IDP_New(IDP_INT, &(IDPropertyTemplate){ .i = pt->space_type, }, "space_type")); + IDP_AddToGroup(prop_panel, IDP_New(IDP_INT, &(IDPropertyTemplate){ .i = pt->region_type, }, "region_type")); + + for (int i = 0; i < 2; i++) { + /* FIXME(campbell): We can't reasonably search all configurations - long term. */ + IDP_ReplaceInGroup(prop_panel, IDP_New(IDP_INT, &(IDPropertyTemplate){ .i = i, }, "keep_open")); + if (WM_key_event_operator_string( + C, "WM_OT_call_panel", WM_OP_INVOKE_REGION_WIN, prop_panel, true, + buf, buf_len)) + { + found = true; + break; + } + } + + IDP_FreeProperty(prop_panel); + MEM_freeN(prop_panel); + return found; +} + static bool ui_but_event_operator_string( const bContext *C, uiBut *but, char *buf, const size_t buf_len) @@ -1010,6 +1045,9 @@ static bool ui_but_event_operator_string( else if (UI_but_menutype_get(but) != NULL) { found = ui_but_event_operator_string_from_menu(C, but, buf, buf_len); } + else if (UI_but_paneltype_get(but) != NULL) { + found = ui_but_event_operator_string_from_panel(C, but, buf, buf_len); + } return found; } -- cgit v1.2.3 From 30bffb5a3afa2fde165d4fb63a115310d5ddc3e3 Mon Sep 17 00:00:00 2001 From: Charlie Jolly Date: Thu, 12 Jul 2018 23:40:18 +0200 Subject: Nodes: add sqrt, ceil, floor and fract to math nodes. This works for Cycles, Eevee, texture nodes and compositing. It helps to reduce the number of math nodes required in various node setups. Differential Revision: https://developer.blender.org/D3537 --- intern/cycles/kernel/shaders/node_math.osl | 20 +++++++++ intern/cycles/kernel/svm/svm_math_util.h | 8 ++++ intern/cycles/kernel/svm/svm_types.h | 4 ++ intern/cycles/render/nodes.cpp | 4 ++ source/blender/compositor/nodes/COM_MathNode.cpp | 12 ++++++ .../operations/COM_MathBaseOperation.cpp | 47 ++++++++++++++++++++++ .../compositor/operations/COM_MathBaseOperation.h | 24 +++++++++++ .../blender/gpu/shaders/gpu_shader_material.glsl | 23 +++++++++++ source/blender/makesdna/DNA_node_types.h | 4 ++ source/blender/makesrna/intern/rna_nodetree.c | 4 ++ .../blender/nodes/shader/nodes/node_shader_math.c | 46 ++++++++++++++++++++- .../nodes/texture/nodes/node_texture_math.c | 27 +++++++++++++ 12 files changed, 222 insertions(+), 1 deletion(-) diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl index c5fcbc311d3..aa9f6e671c3 100644 --- a/intern/cycles/kernel/shaders/node_math.osl +++ b/intern/cycles/kernel/shaders/node_math.osl @@ -40,6 +40,18 @@ float safe_modulo(float a, float b) return result; } +float safe_sqrt(float a) +{ + float result; + + if (a > 0.0) + result = sqrt(a); + else + result = 0.0; + + return result; +} + float safe_log(float a, float b) { if (a < 0.0 || b < 0.0) @@ -97,6 +109,14 @@ shader node_math( Value = fabs(Value1); else if (type == "arctan2") Value = atan2(Value1, Value2); + else if (type == "floor") + Value = floor(Value1); + else if (type == "ceil") + Value = ceil(Value1); + else if (type == "fract") + Value = Value1 - floor(Value1); + else if (type == "sqrt") + Value = safe_sqrt(Value1); if (use_clamp) Value = clamp(Value, 0.0, 1.0); diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h index 04864bd610a..d3490ab284f 100644 --- a/intern/cycles/kernel/svm/svm_math_util.h +++ b/intern/cycles/kernel/svm/svm_math_util.h @@ -94,6 +94,14 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2) Fac = fabsf(Fac1); else if(type == NODE_MATH_ARCTAN2) Fac = atan2f(Fac1, Fac2); + else if (type == NODE_MATH_FLOOR) + Fac = floorf(Fac1); + else if (type == NODE_MATH_CEIL) + Fac = ceilf(Fac1); + else if (type == NODE_MATH_FRACT) + Fac = Fac1 - floorf(Fac1); + else if (type == NODE_MATH_SQRT) + Fac = safe_sqrtf(Fac1); else if(type == NODE_MATH_CLAMP) Fac = saturate(Fac1); else diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index b94a83b6712..0fde5126434 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -261,6 +261,10 @@ typedef enum NodeMath { NODE_MATH_MODULO, NODE_MATH_ABSOLUTE, NODE_MATH_ARCTAN2, + NODE_MATH_FLOOR, + NODE_MATH_CEIL, + NODE_MATH_FRACT, + NODE_MATH_SQRT, NODE_MATH_CLAMP /* used for the clamp UI option */ } NodeMath; diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index beff7f91348..fe2916d21d4 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -5071,6 +5071,10 @@ NODE_DEFINE(MathNode) type_enum.insert("modulo", NODE_MATH_MODULO); type_enum.insert("absolute", NODE_MATH_ABSOLUTE); type_enum.insert("arctan2", NODE_MATH_ARCTAN2); + type_enum.insert("floor", NODE_MATH_FLOOR); + type_enum.insert("ceil", NODE_MATH_CEIL); + type_enum.insert("fract", NODE_MATH_FRACT); + type_enum.insert("sqrt", NODE_MATH_SQRT); SOCKET_ENUM(type, "Type", type_enum, NODE_MATH_ADD); SOCKET_BOOLEAN(use_clamp, "Use Clamp", false); diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp index d16300ebff4..25c617a3487 100644 --- a/source/blender/compositor/nodes/COM_MathNode.cpp +++ b/source/blender/compositor/nodes/COM_MathNode.cpp @@ -89,6 +89,18 @@ void MathNode::convertToOperations(NodeConverter &converter, const CompositorCon case NODE_MATH_ATAN2: operation = new MathArcTan2Operation(); break; + case NODE_MATH_FLOOR: + operation = new MathFloorOperation(); + break; + case NODE_MATH_CEIL: + operation = new MathCeilOperation(); + break; + case NODE_MATH_FRACT: + operation = new MathFractOperation(); + break; + case NODE_MATH_SQRT: + operation = new MathSqrtOperation(); + break; } if (operation) { diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp index 0a515da1877..99385a5073a 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp @@ -356,3 +356,50 @@ void MathArcTan2Operation::executePixelSampled(float output[4], float x, float y clampIfNeeded(output); } + +void MathFloorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) +{ + float inputValue1[4]; + + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + + output[0] = floor(inputValue1[0]); + + clampIfNeeded(output); +} + +void MathCeilOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) +{ + float inputValue1[4]; + + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + + output[0] = ceil(inputValue1[0]); + + clampIfNeeded(output); +} + +void MathFractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) +{ + float inputValue1[4]; + + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + + output[0] = inputValue1[0] - floor(inputValue1[0]); + + clampIfNeeded(output); +} + +void MathSqrtOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) +{ + float inputValue1[4]; + + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + + if (inputValue1[0] > 0) + output[0] = sqrt(inputValue1[0]); + else + output[0] = 0.0f; + + clampIfNeeded(output); +} diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h index c636117451f..5435cc82ba7 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.h +++ b/source/blender/compositor/operations/COM_MathBaseOperation.h @@ -175,4 +175,28 @@ public: void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; +class MathFloorOperation : public MathBaseOperation { +public: + MathFloorOperation() : MathBaseOperation() {} + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); +}; + +class MathCeilOperation : public MathBaseOperation { +public: + MathCeilOperation() : MathBaseOperation() {} + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); +}; + +class MathFractOperation : public MathBaseOperation { +public: + MathFractOperation() : MathBaseOperation() {} + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); +}; + +class MathSqrtOperation : public MathBaseOperation { +public: + MathSqrtOperation() : MathBaseOperation() {} + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); +}; + #endif diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index ce9e82b34f8..2cb92fd1cbc 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -418,6 +418,29 @@ void math_atan2(float val1, float val2, out float outval) outval = atan(val1, val2); } +void math_floor(float val, out float outval) +{ + outval = floor(val); +} + +void math_ceil(float val, out float outval) +{ + outval = ceil(val); +} + +void math_fract(float val, out float outval) +{ + outval = val - floor(val); +} + +void math_sqrt(float val, out float outval) +{ + if (val > 0.0) + outval = sqrt(val); + else + outval = 0.0; +} + void squeeze(float val, float width, float center, out float outval) { outval = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width))); diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index b95506cea48..f6d92a95c3a 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -1073,6 +1073,10 @@ enum { NODE_MATH_MOD = 17, NODE_MATH_ABS = 18, NODE_MATH_ATAN2 = 19, + NODE_MATH_FLOOR = 20, + NODE_MATH_CEIL = 21, + NODE_MATH_FRACT = 22, + NODE_MATH_SQRT = 23, }; /* mix rgb node flags */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a2ab00a482b..5fe42e11765 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -141,6 +141,10 @@ const EnumPropertyItem rna_enum_node_math_items[] = { {NODE_MATH_MOD, "MODULO", 0, "Modulo", ""}, {NODE_MATH_ABS, "ABSOLUTE", 0, "Absolute", ""}, {NODE_MATH_ATAN2, "ARCTAN2", 0, "Arctan2", ""}, + {NODE_MATH_FLOOR, "FLOOR", 0, "Floor", ""}, + {NODE_MATH_CEIL, "CEIL", 0, "Ceil", ""}, + {NODE_MATH_FRACT, "FRACT", 0, "Fract", ""}, + {NODE_MATH_SQRT, "SQRT", 0, "Square Root", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index 0a75a0f8bf0..605c869099a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -226,6 +226,46 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode r = atan2(a, b); break; } + case NODE_MATH_FLOOR: + { + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + r = floorf(a); + else + r = floorf(b); + break; + } + case NODE_MATH_CEIL: + { + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + r = ceilf(a); + else + r = ceilf(b); + break; + } + case NODE_MATH_FRACT: + { + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + r = a - floorf(a); + else + r = b - floorf(b); + break; + } + case NODE_MATH_SQRT: + { + if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ + if (a > 0) + r = sqrt(a); + else + r = 0.0; + } + else { + if (b > 0) + r = sqrt(b); + else + r = 0.0; + } + break; + } } if (node->custom2 & SHD_MATH_CLAMP) { CLAMP(r, 0.0f, 1.0f); @@ -240,7 +280,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED( "math_divide", "math_sine", "math_cosine", "math_tangent", "math_asin", "math_acos", "math_atan", "math_pow", "math_log", "math_min", "math_max", "math_round", "math_less_than", "math_greater_than", "math_modulo", "math_abs", - "math_atan2" + "math_atan2", "math_floor", "math_ceil", "math_fract", "math_sqrt" }; switch (node->custom1) { @@ -266,6 +306,10 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED( case NODE_MATH_ATAN: case NODE_MATH_ROUND: case NODE_MATH_ABS: + case NODE_MATH_FLOOR: + case NODE_MATH_FRACT: + case NODE_MATH_CEIL: + case NODE_MATH_SQRT: if (in[0].hasinput || !in[1].hasinput) { /* use only first item and terminator */ GPUNodeStack tmp_in[2]; diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c index d8dc2a62625..f786a293080 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ b/source/blender/nodes/texture/nodes/node_texture_math.c @@ -195,6 +195,33 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor break; } + case NODE_MATH_FLOOR: + { + *out = floorf(in0); + break; + } + + case NODE_MATH_CEIL: + { + *out = ceilf(in0); + break; + } + + case NODE_MATH_FRACT: + { + *out = in0 - floorf(in0); + break; + } + + case NODE_MATH_SQRT: + { + if (in0 > 0.0f) + *out = sqrtf(in0); + else + *out = 0.0f; + break; + } + default: { BLI_assert(0); -- cgit v1.2.3 From 8ff3f7f6013f730f5325dbcbbfcb4e78fae19bbb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 12:15:18 +0200 Subject: Cleanup: move WM type registration into own files Type registration is mostly boiler plate logic, which can be separated from other API's. --- source/blender/windowmanager/CMakeLists.txt | 7 +- source/blender/windowmanager/intern/wm.c | 124 ------ source/blender/windowmanager/intern/wm_init_exit.c | 2 + source/blender/windowmanager/intern/wm_menu_type.c | 105 +++++ .../windowmanager/intern/wm_operator_type.c | 483 +++++++++++++++++++++ source/blender/windowmanager/intern/wm_operators.c | 416 +----------------- .../blender/windowmanager/intern/wm_uilist_type.c | 98 +++++ source/blender/windowmanager/wm.h | 1 + 8 files changed, 695 insertions(+), 541 deletions(-) create mode 100644 source/blender/windowmanager/intern/wm_menu_type.c create mode 100644 source/blender/windowmanager/intern/wm_operator_type.c create mode 100644 source/blender/windowmanager/intern/wm_uilist_type.c diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 50f99251489..810cceb5fc3 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -53,7 +53,6 @@ set(INC_SYS set(SRC intern/wm.c - intern/wm_playanim.c intern/wm_cursors.c intern/wm_dragdrop.c intern/wm_draw.c @@ -65,12 +64,16 @@ set(SRC intern/wm_init_exit.c intern/wm_jobs.c intern/wm_keymap.c + intern/wm_menu_type.c intern/wm_operator_props.c + intern/wm_operator_type.c intern/wm_operators.c + intern/wm_playanim.c + intern/wm_stereo.c intern/wm_subwindow.c intern/wm_tooltip.c + intern/wm_uilist_type.c intern/wm_window.c - intern/wm_stereo.c WM_api.h WM_keymap.h diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index b3b8bf5734d..132789aade4 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -222,130 +222,6 @@ void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot) } /* ************ uiListType handling ************** */ - -static GHash *uilisttypes_hash = NULL; - -uiListType *WM_uilisttype_find(const char *idname, bool quiet) -{ - uiListType *ult; - - if (idname[0]) { - ult = BLI_ghash_lookup(uilisttypes_hash, idname); - if (ult) { - return ult; - } - } - - if (!quiet) { - printf("search for unknown uilisttype %s\n", idname); - } - - return NULL; -} - -bool WM_uilisttype_add(uiListType *ult) -{ - BLI_ghash_insert(uilisttypes_hash, ult->idname, ult); - return 1; -} - -void WM_uilisttype_freelink(uiListType *ult) -{ - bool ok; - - ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN); - - BLI_assert(ok); - (void)ok; -} - -/* called on initialize WM_init() */ -void WM_uilisttype_init(void) -{ - uilisttypes_hash = BLI_ghash_str_new_ex("uilisttypes_hash gh", 16); -} - -void WM_uilisttype_free(void) -{ - GHashIterator gh_iter; - - GHASH_ITER (gh_iter, uilisttypes_hash) { - uiListType *ult = BLI_ghashIterator_getValue(&gh_iter); - if (ult->ext.free) { - ult->ext.free(ult->ext.data); - } - } - - BLI_ghash_free(uilisttypes_hash, NULL, MEM_freeN); - uilisttypes_hash = NULL; -} - -/* ************ MenuType handling ************** */ - -static GHash *menutypes_hash = NULL; - -MenuType *WM_menutype_find(const char *idname, bool quiet) -{ - MenuType *mt; - - if (idname[0]) { - mt = BLI_ghash_lookup(menutypes_hash, idname); - if (mt) - return mt; - } - - if (!quiet) - printf("search for unknown menutype %s\n", idname); - - return NULL; -} - -bool WM_menutype_add(MenuType *mt) -{ - BLI_ghash_insert(menutypes_hash, mt->idname, mt); - return true; -} - -void WM_menutype_freelink(MenuType *mt) -{ - bool ok; - - ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN); - - BLI_assert(ok); - (void)ok; -} - -/* called on initialize WM_init() */ -void WM_menutype_init(void) -{ - /* reserve size is set based on blender default setup */ - menutypes_hash = BLI_ghash_str_new_ex("menutypes_hash gh", 512); -} - -void WM_menutype_free(void) -{ - GHashIterator gh_iter; - - GHASH_ITER (gh_iter, menutypes_hash) { - MenuType *mt = BLI_ghashIterator_getValue(&gh_iter); - if (mt->ext.free) { - mt->ext.free(mt->ext.data); - } - } - - BLI_ghash_free(menutypes_hash, NULL, MEM_freeN); - menutypes_hash = NULL; -} - -bool WM_menutype_poll(bContext *C, MenuType *mt) -{ - if (mt->poll != NULL) { - return mt->poll(C, mt); - } - return true; -} - /* ****************************************** */ void WM_keymap_init(bContext *C) diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 449a0a91a01..088327fa611 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -166,6 +166,8 @@ void WM_init(bContext *C, int argc, const char **argv) BKE_addon_pref_type_init(); wm_operatortype_init(); + wm_operatortypes_register(); + WM_menutype_init(); WM_uilisttype_init(); diff --git a/source/blender/windowmanager/intern/wm_menu_type.c b/source/blender/windowmanager/intern/wm_menu_type.c new file mode 100644 index 00000000000..58e85716bf1 --- /dev/null +++ b/source/blender/windowmanager/intern/wm_menu_type.c @@ -0,0 +1,105 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/intern/wm_menu_type.c + * \ingroup wm + * + * Menu Registry. + */ + +#include "BLI_sys_types.h" + +#include "DNA_windowmanager_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + +#include "BKE_context.h" +#include "BKE_library.h" +#include "BKE_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +static GHash *menutypes_hash = NULL; + +MenuType *WM_menutype_find(const char *idname, bool quiet) +{ + MenuType *mt; + + if (idname[0]) { + mt = BLI_ghash_lookup(menutypes_hash, idname); + if (mt) + return mt; + } + + if (!quiet) + printf("search for unknown menutype %s\n", idname); + + return NULL; +} + +bool WM_menutype_add(MenuType *mt) +{ + BLI_ghash_insert(menutypes_hash, mt->idname, mt); + return true; +} + +void WM_menutype_freelink(MenuType *mt) +{ + bool ok; + + ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN); + + BLI_assert(ok); + (void)ok; +} + +/* called on initialize WM_init() */ +void WM_menutype_init(void) +{ + /* reserve size is set based on blender default setup */ + menutypes_hash = BLI_ghash_str_new_ex("menutypes_hash gh", 512); +} + +void WM_menutype_free(void) +{ + GHashIterator gh_iter; + + GHASH_ITER (gh_iter, menutypes_hash) { + MenuType *mt = BLI_ghashIterator_getValue(&gh_iter); + if (mt->ext.free) { + mt->ext.free(mt->ext.data); + } + } + + BLI_ghash_free(menutypes_hash, NULL, MEM_freeN); + menutypes_hash = NULL; +} + +bool WM_menutype_poll(bContext *C, MenuType *mt) +{ + if (mt->poll != NULL) { + return mt->poll(C, mt); + } + return true; +} diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c new file mode 100644 index 00000000000..35efdb2c4a2 --- /dev/null +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -0,0 +1,483 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/intern/wm_operator_type.c + * \ingroup wm + * + * Operator Registry. + */ + +#include "MEM_guardedalloc.h" + +#include "CLG_log.h" + +#include "DNA_ID.h" +#include "DNA_screen_types.h" +#include "DNA_scene_types.h" +#include "DNA_userdef_types.h" +#include "DNA_windowmanager_types.h" + +#include "BLT_translation.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + +#include "BKE_context.h" +#include "BKE_idprop.h" +#include "BKE_library.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "wm.h" +#include "wm_event_system.h" + +#define UNDOCUMENTED_OPERATOR_TIP N_("(undocumented operator)") + +static void wm_operatortype_free_macro(wmOperatorType *ot); + +/* -------------------------------------------------------------------- */ +/** \name Operator Type Registry + * \{ */ + +static GHash *global_ops_hash = NULL; + +wmOperatorType *WM_operatortype_find(const char *idname, bool quiet) +{ + if (idname[0]) { + wmOperatorType *ot; + + /* needed to support python style names without the _OT_ syntax */ + char idname_bl[OP_MAX_TYPENAME]; + WM_operator_bl_idname(idname_bl, idname); + + ot = BLI_ghash_lookup(global_ops_hash, idname_bl); + if (ot) { + return ot; + } + + if (!quiet) { + CLOG_INFO(WM_LOG_OPERATORS, 0, "search for unknown operator '%s', '%s'\n", idname_bl, idname); + } + } + else { + if (!quiet) { + CLOG_INFO(WM_LOG_OPERATORS, 0, "search for empty operator"); + } + } + + return NULL; +} + +/* caller must free */ +void WM_operatortype_iter(GHashIterator *ghi) +{ + BLI_ghashIterator_init(ghi, global_ops_hash); +} + +/* all ops in 1 list (for time being... needs evaluation later) */ +void WM_operatortype_append(void (*opfunc)(wmOperatorType *)) +{ + wmOperatorType *ot; + + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); + ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); + /* Set the default i18n context now, so that opfunc can redefine it if needed! */ + RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; + opfunc(ot); + + if (ot->name == NULL) { + CLOG_ERROR(WM_LOG_OPERATORS, "Operator '%s' has no name property", ot->idname); + } + + /* XXX All ops should have a description but for now allow them not to. */ + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP); + RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); + + BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); +} + +void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata) +{ + wmOperatorType *ot; + + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); + ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); + /* Set the default i18n context now, so that opfunc can redefine it if needed! */ + RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; + opfunc(ot, userdata); + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP); + RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); + + BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); +} + + +/* called on initialize WM_exit() */ +void WM_operatortype_remove_ptr(wmOperatorType *ot) +{ + BLI_assert(ot == WM_operatortype_find(ot->idname, false)); + + RNA_struct_free(&BLENDER_RNA, ot->srna); + + if (ot->last_properties) { + IDP_FreeProperty(ot->last_properties); + MEM_freeN(ot->last_properties); + } + + if (ot->macro.first) + wm_operatortype_free_macro(ot); + + BLI_ghash_remove(global_ops_hash, ot->idname, NULL, NULL); + + WM_keyconfig_update_operatortype(); + + MEM_freeN(ot); +} + +bool WM_operatortype_remove(const char *idname) +{ + wmOperatorType *ot = WM_operatortype_find(idname, 0); + + if (ot == NULL) + return false; + + WM_operatortype_remove_ptr(ot); + + return true; +} + +/* called on initialize WM_init() */ +void wm_operatortype_init(void) +{ + /* reserve size is set based on blender default setup */ + global_ops_hash = BLI_ghash_str_new_ex("wm_operatortype_init gh", 2048); +} + +static void operatortype_ghash_free_cb(wmOperatorType *ot) +{ + if (ot->last_properties) { + IDP_FreeProperty(ot->last_properties); + MEM_freeN(ot->last_properties); + } + + if (ot->macro.first) + wm_operatortype_free_macro(ot); + + if (ot->ext.srna) /* python operator, allocs own string */ + MEM_freeN((void *)ot->idname); + + MEM_freeN(ot); +} + +void wm_operatortype_free(void) +{ + BLI_ghash_free(global_ops_hash, NULL, (GHashValFreeFP)operatortype_ghash_free_cb); + global_ops_hash = NULL; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Operator Macro Type + * \{ */ + +typedef struct { + int retval; +} MacroData; + +static void wm_macro_start(wmOperator *op) +{ + if (op->customdata == NULL) { + op->customdata = MEM_callocN(sizeof(MacroData), "MacroData"); + } +} + +static int wm_macro_end(wmOperator *op, int retval) +{ + if (retval & OPERATOR_CANCELLED) { + MacroData *md = op->customdata; + + if (md->retval & OPERATOR_FINISHED) { + retval |= OPERATOR_FINISHED; + retval &= ~OPERATOR_CANCELLED; + } + } + + /* if modal is ending, free custom data */ + if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) { + if (op->customdata) { + MEM_freeN(op->customdata); + op->customdata = NULL; + } + } + + return retval; +} + +/* macro exec only runs exec calls */ +static int wm_macro_exec(bContext *C, wmOperator *op) +{ + wmOperator *opm; + int retval = OPERATOR_FINISHED; + + wm_macro_start(op); + + for (opm = op->macro.first; opm; opm = opm->next) { + + if (opm->type->exec) { + retval = opm->type->exec(C, opm); + OPERATOR_RETVAL_CHECK(retval); + + if (retval & OPERATOR_FINISHED) { + MacroData *md = op->customdata; + md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ + } + else { + break; /* operator didn't finish, end macro */ + } + } + else { + CLOG_WARN(WM_LOG_OPERATORS, "'%s' cant exec macro", opm->type->idname); + } + } + + return wm_macro_end(op, retval); +} + +static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent *event, wmOperator *opm) +{ + int retval = OPERATOR_FINISHED; + + /* start from operator received as argument */ + for (; opm; opm = opm->next) { + if (opm->type->invoke) + retval = opm->type->invoke(C, opm, event); + else if (opm->type->exec) + retval = opm->type->exec(C, opm); + + OPERATOR_RETVAL_CHECK(retval); + + BLI_movelisttolist(&op->reports->list, &opm->reports->list); + + if (retval & OPERATOR_FINISHED) { + MacroData *md = op->customdata; + md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ + } + else { + break; /* operator didn't finish, end macro */ + } + } + + return wm_macro_end(op, retval); +} + +static int wm_macro_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + wm_macro_start(op); + return wm_macro_invoke_internal(C, op, event, op->macro.first); +} + +static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + wmOperator *opm = op->opm; + int retval = OPERATOR_FINISHED; + + if (opm == NULL) { + CLOG_ERROR(WM_LOG_OPERATORS, "macro error, calling NULL modal()"); + } + else { + retval = opm->type->modal(C, opm, event); + OPERATOR_RETVAL_CHECK(retval); + + /* if we're halfway through using a tool and cancel it, clear the options [#37149] */ + if (retval & OPERATOR_CANCELLED) { + WM_operator_properties_clear(opm->ptr); + } + + /* if this one is done but it's not the last operator in the macro */ + if ((retval & OPERATOR_FINISHED) && opm->next) { + MacroData *md = op->customdata; + + md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ + + retval = wm_macro_invoke_internal(C, op, event, opm->next); + + /* if new operator is modal and also added its own handler */ + if (retval & OPERATOR_RUNNING_MODAL && op->opm != opm) { + wmWindow *win = CTX_wm_window(C); + wmEventHandler *handler; + + handler = BLI_findptr(&win->modalhandlers, op, offsetof(wmEventHandler, op)); + if (handler) { + BLI_remlink(&win->modalhandlers, handler); + wm_event_free_handler(handler); + } + + /* if operator is blocking, grab cursor + * This may end up grabbing twice, but we don't care. + * */ + if (op->opm->type->flag & OPTYPE_BLOCKING) { + int bounds[4] = {-1, -1, -1, -1}; + const bool wrap = ( + (U.uiflag & USER_CONTINUOUS_MOUSE) && + ((op->opm->flag & OP_IS_MODAL_GRAB_CURSOR) || (op->opm->type->flag & OPTYPE_GRAB_CURSOR))); + + if (wrap) { + ARegion *ar = CTX_wm_region(C); + if (ar) { + bounds[0] = ar->winrct.xmin; + bounds[1] = ar->winrct.ymax; + bounds[2] = ar->winrct.xmax; + bounds[3] = ar->winrct.ymin; + } + } + + WM_cursor_grab_enable(win, wrap, false, bounds); + } + } + } + } + + return wm_macro_end(op, retval); +} + +static void wm_macro_cancel(bContext *C, wmOperator *op) +{ + /* call cancel on the current modal operator, if any */ + if (op->opm && op->opm->type->cancel) { + op->opm->type->cancel(C, op->opm); + } + + wm_macro_end(op, OPERATOR_CANCELLED); +} + +/* Names have to be static for now */ +wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag) +{ + wmOperatorType *ot; + const char *i18n_context; + + if (WM_operatortype_find(idname, true)) { + CLOG_ERROR(WM_LOG_OPERATORS, "operator %s exists, cannot create macro", idname); + return NULL; + } + + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); + ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); + + ot->idname = idname; + ot->name = name; + ot->description = description; + ot->flag = OPTYPE_MACRO | flag; + + ot->exec = wm_macro_exec; + ot->invoke = wm_macro_invoke; + ot->modal = wm_macro_modal; + ot->cancel = wm_macro_cancel; + ot->poll = NULL; + + if (!ot->description) /* XXX All ops should have a description but for now allow them not to. */ + ot->description = UNDOCUMENTED_OPERATOR_TIP; + + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); + RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); + /* Use i18n context from ext.srna if possible (py operators). */ + i18n_context = ot->ext.srna ? RNA_struct_translation_context(ot->ext.srna) : BLT_I18NCONTEXT_OPERATOR_DEFAULT; + RNA_def_struct_translation_context(ot->srna, i18n_context); + ot->translation_context = i18n_context; + + BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); + + return ot; +} + +void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata) +{ + wmOperatorType *ot; + + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); + ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); + + ot->flag = OPTYPE_MACRO; + ot->exec = wm_macro_exec; + ot->invoke = wm_macro_invoke; + ot->modal = wm_macro_modal; + ot->cancel = wm_macro_cancel; + ot->poll = NULL; + + if (!ot->description) + ot->description = UNDOCUMENTED_OPERATOR_TIP; + + /* Set the default i18n context now, so that opfunc can redefine it if needed! */ + RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; + opfunc(ot, userdata); + + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); + RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); + + BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); +} + +wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname) +{ + wmOperatorTypeMacro *otmacro = MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro"); + + BLI_strncpy(otmacro->idname, idname, OP_MAX_TYPENAME); + + /* do this on first use, since operatordefinitions might have been not done yet */ + WM_operator_properties_alloc(&(otmacro->ptr), &(otmacro->properties), idname); + WM_operator_properties_sanitize(otmacro->ptr, 1); + + BLI_addtail(&ot->macro, otmacro); + + { + /* operator should always be found but in the event its not. don't segfault */ + wmOperatorType *otsub = WM_operatortype_find(idname, 0); + if (otsub) { + RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna, + otsub->name, otsub->description); + } + } + + return otmacro; +} + +static void wm_operatortype_free_macro(wmOperatorType *ot) +{ + wmOperatorTypeMacro *otmacro; + + for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) { + if (otmacro->ptr) { + WM_operator_properties_free(otmacro->ptr); + MEM_freeN(otmacro->ptr); + } + } + BLI_freelistN(&ot->macro); +} + +/** \} */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b81790abaad..d2fb49ffd57 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -119,395 +119,9 @@ #include "wm_files.h" #include "wm_window.h" -static GHash *global_ops_hash = NULL; - #define UNDOCUMENTED_OPERATOR_TIP N_("(undocumented operator)") /* ************ operator API, exported ********** */ - - -wmOperatorType *WM_operatortype_find(const char *idname, bool quiet) -{ - if (idname[0]) { - wmOperatorType *ot; - - /* needed to support python style names without the _OT_ syntax */ - char idname_bl[OP_MAX_TYPENAME]; - WM_operator_bl_idname(idname_bl, idname); - - ot = BLI_ghash_lookup(global_ops_hash, idname_bl); - if (ot) { - return ot; - } - - if (!quiet) { - CLOG_INFO(WM_LOG_OPERATORS, 0, "search for unknown operator '%s', '%s'\n", idname_bl, idname); - } - } - else { - if (!quiet) { - CLOG_INFO(WM_LOG_OPERATORS, 0, "search for empty operator"); - } - } - - return NULL; -} - -/* caller must free */ -void WM_operatortype_iter(GHashIterator *ghi) -{ - BLI_ghashIterator_init(ghi, global_ops_hash); -} - -/* all ops in 1 list (for time being... needs evaluation later) */ -void WM_operatortype_append(void (*opfunc)(wmOperatorType *)) -{ - wmOperatorType *ot; - - ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); - ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); - /* Set the default i18n context now, so that opfunc can redefine it if needed! */ - RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); - ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; - opfunc(ot); - - if (ot->name == NULL) { - CLOG_ERROR(WM_LOG_OPERATORS, "Operator '%s' has no name property", ot->idname); - } - - /* XXX All ops should have a description but for now allow them not to. */ - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP); - RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); - - BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); -} - -void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata) -{ - wmOperatorType *ot; - - ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); - ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); - /* Set the default i18n context now, so that opfunc can redefine it if needed! */ - RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); - ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; - opfunc(ot, userdata); - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP); - RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); - - BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); -} - -/* ********************* macro operator ******************** */ - -typedef struct { - int retval; -} MacroData; - -static void wm_macro_start(wmOperator *op) -{ - if (op->customdata == NULL) { - op->customdata = MEM_callocN(sizeof(MacroData), "MacroData"); - } -} - -static int wm_macro_end(wmOperator *op, int retval) -{ - if (retval & OPERATOR_CANCELLED) { - MacroData *md = op->customdata; - - if (md->retval & OPERATOR_FINISHED) { - retval |= OPERATOR_FINISHED; - retval &= ~OPERATOR_CANCELLED; - } - } - - /* if modal is ending, free custom data */ - if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) { - if (op->customdata) { - MEM_freeN(op->customdata); - op->customdata = NULL; - } - } - - return retval; -} - -/* macro exec only runs exec calls */ -static int wm_macro_exec(bContext *C, wmOperator *op) -{ - wmOperator *opm; - int retval = OPERATOR_FINISHED; - - wm_macro_start(op); - - for (opm = op->macro.first; opm; opm = opm->next) { - - if (opm->type->exec) { - retval = opm->type->exec(C, opm); - OPERATOR_RETVAL_CHECK(retval); - - if (retval & OPERATOR_FINISHED) { - MacroData *md = op->customdata; - md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ - } - else { - break; /* operator didn't finish, end macro */ - } - } - else { - CLOG_WARN(WM_LOG_OPERATORS, "'%s' cant exec macro", opm->type->idname); - } - } - - return wm_macro_end(op, retval); -} - -static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent *event, wmOperator *opm) -{ - int retval = OPERATOR_FINISHED; - - /* start from operator received as argument */ - for (; opm; opm = opm->next) { - if (opm->type->invoke) - retval = opm->type->invoke(C, opm, event); - else if (opm->type->exec) - retval = opm->type->exec(C, opm); - - OPERATOR_RETVAL_CHECK(retval); - - BLI_movelisttolist(&op->reports->list, &opm->reports->list); - - if (retval & OPERATOR_FINISHED) { - MacroData *md = op->customdata; - md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ - } - else { - break; /* operator didn't finish, end macro */ - } - } - - return wm_macro_end(op, retval); -} - -static int wm_macro_invoke(bContext *C, wmOperator *op, const wmEvent *event) -{ - wm_macro_start(op); - return wm_macro_invoke_internal(C, op, event, op->macro.first); -} - -static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event) -{ - wmOperator *opm = op->opm; - int retval = OPERATOR_FINISHED; - - if (opm == NULL) { - CLOG_ERROR(WM_LOG_OPERATORS, "macro error, calling NULL modal()"); - } - else { - retval = opm->type->modal(C, opm, event); - OPERATOR_RETVAL_CHECK(retval); - - /* if we're halfway through using a tool and cancel it, clear the options [#37149] */ - if (retval & OPERATOR_CANCELLED) { - WM_operator_properties_clear(opm->ptr); - } - - /* if this one is done but it's not the last operator in the macro */ - if ((retval & OPERATOR_FINISHED) && opm->next) { - MacroData *md = op->customdata; - - md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ - - retval = wm_macro_invoke_internal(C, op, event, opm->next); - - /* if new operator is modal and also added its own handler */ - if (retval & OPERATOR_RUNNING_MODAL && op->opm != opm) { - wmWindow *win = CTX_wm_window(C); - wmEventHandler *handler; - - handler = BLI_findptr(&win->modalhandlers, op, offsetof(wmEventHandler, op)); - if (handler) { - BLI_remlink(&win->modalhandlers, handler); - wm_event_free_handler(handler); - } - - /* if operator is blocking, grab cursor - * This may end up grabbing twice, but we don't care. - * */ - if (op->opm->type->flag & OPTYPE_BLOCKING) { - int bounds[4] = {-1, -1, -1, -1}; - const bool wrap = ( - (U.uiflag & USER_CONTINUOUS_MOUSE) && - ((op->opm->flag & OP_IS_MODAL_GRAB_CURSOR) || (op->opm->type->flag & OPTYPE_GRAB_CURSOR))); - - if (wrap) { - ARegion *ar = CTX_wm_region(C); - if (ar) { - bounds[0] = ar->winrct.xmin; - bounds[1] = ar->winrct.ymax; - bounds[2] = ar->winrct.xmax; - bounds[3] = ar->winrct.ymin; - } - } - - WM_cursor_grab_enable(win, wrap, false, bounds); - } - } - } - } - - return wm_macro_end(op, retval); -} - -static void wm_macro_cancel(bContext *C, wmOperator *op) -{ - /* call cancel on the current modal operator, if any */ - if (op->opm && op->opm->type->cancel) { - op->opm->type->cancel(C, op->opm); - } - - wm_macro_end(op, OPERATOR_CANCELLED); -} - -/* Names have to be static for now */ -wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag) -{ - wmOperatorType *ot; - const char *i18n_context; - - if (WM_operatortype_find(idname, true)) { - CLOG_ERROR(WM_LOG_OPERATORS, "operator %s exists, cannot create macro", idname); - return NULL; - } - - ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); - ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); - - ot->idname = idname; - ot->name = name; - ot->description = description; - ot->flag = OPTYPE_MACRO | flag; - - ot->exec = wm_macro_exec; - ot->invoke = wm_macro_invoke; - ot->modal = wm_macro_modal; - ot->cancel = wm_macro_cancel; - ot->poll = NULL; - - if (!ot->description) /* XXX All ops should have a description but for now allow them not to. */ - ot->description = UNDOCUMENTED_OPERATOR_TIP; - - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); - RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); - /* Use i18n context from ext.srna if possible (py operators). */ - i18n_context = ot->ext.srna ? RNA_struct_translation_context(ot->ext.srna) : BLT_I18NCONTEXT_OPERATOR_DEFAULT; - RNA_def_struct_translation_context(ot->srna, i18n_context); - ot->translation_context = i18n_context; - - BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); - - return ot; -} - -void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata) -{ - wmOperatorType *ot; - - ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); - ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); - - ot->flag = OPTYPE_MACRO; - ot->exec = wm_macro_exec; - ot->invoke = wm_macro_invoke; - ot->modal = wm_macro_modal; - ot->cancel = wm_macro_cancel; - ot->poll = NULL; - - if (!ot->description) - ot->description = UNDOCUMENTED_OPERATOR_TIP; - - /* Set the default i18n context now, so that opfunc can redefine it if needed! */ - RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); - ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; - opfunc(ot, userdata); - - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); - RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); - - BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); -} - -wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname) -{ - wmOperatorTypeMacro *otmacro = MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro"); - - BLI_strncpy(otmacro->idname, idname, OP_MAX_TYPENAME); - - /* do this on first use, since operatordefinitions might have been not done yet */ - WM_operator_properties_alloc(&(otmacro->ptr), &(otmacro->properties), idname); - WM_operator_properties_sanitize(otmacro->ptr, 1); - - BLI_addtail(&ot->macro, otmacro); - - { - /* operator should always be found but in the event its not. don't segfault */ - wmOperatorType *otsub = WM_operatortype_find(idname, 0); - if (otsub) { - RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna, - otsub->name, otsub->description); - } - } - - return otmacro; -} - -static void wm_operatortype_free_macro(wmOperatorType *ot) -{ - wmOperatorTypeMacro *otmacro; - - for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) { - if (otmacro->ptr) { - WM_operator_properties_free(otmacro->ptr); - MEM_freeN(otmacro->ptr); - } - } - BLI_freelistN(&ot->macro); -} - -void WM_operatortype_remove_ptr(wmOperatorType *ot) -{ - BLI_assert(ot == WM_operatortype_find(ot->idname, false)); - - RNA_struct_free(&BLENDER_RNA, ot->srna); - - if (ot->last_properties) { - IDP_FreeProperty(ot->last_properties); - MEM_freeN(ot->last_properties); - } - - if (ot->macro.first) - wm_operatortype_free_macro(ot); - - BLI_ghash_remove(global_ops_hash, ot->idname, NULL, NULL); - - WM_keyconfig_update_operatortype(); - - MEM_freeN(ot); -} - -bool WM_operatortype_remove(const char *idname) -{ - wmOperatorType *ot = WM_operatortype_find(idname, 0); - - if (ot == NULL) - return false; - - WM_operatortype_remove_ptr(ot); - - return true; -} - /** * Remove memory of all previously executed tools. */ @@ -3457,22 +3071,6 @@ static void WM_OT_doc_view_manual_ui_context(wmOperatorType *ot) /* ******************************************************* */ -static void operatortype_ghash_free_cb(wmOperatorType *ot) -{ - if (ot->last_properties) { - IDP_FreeProperty(ot->last_properties); - MEM_freeN(ot->last_properties); - } - - if (ot->macro.first) - wm_operatortype_free_macro(ot); - - if (ot->ext.srna) /* python operator, allocs own string */ - MEM_freeN((void *)ot->idname); - - MEM_freeN(ot); -} - /* ******************************************************* */ /* toggle 3D for current window, turning it fullscreen if needed */ static void WM_OT_stereo3d_set(wmOperatorType *ot) @@ -3504,20 +3102,8 @@ static void WM_OT_stereo3d_set(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/* ******************************************************* */ -/* called on initialize WM_exit() */ -void wm_operatortype_free(void) +void wm_operatortypes_register(void) { - BLI_ghash_free(global_ops_hash, NULL, (GHashValFreeFP)operatortype_ghash_free_cb); - global_ops_hash = NULL; -} - -/* called on initialize WM_init() */ -void wm_operatortype_init(void) -{ - /* reserve size is set based on blender default setup */ - global_ops_hash = BLI_ghash_str_new_ex("wm_operatortype_init gh", 2048); - WM_operatortype_append(WM_OT_window_close); WM_operatortype_append(WM_OT_window_duplicate); WM_operatortype_append(WM_OT_read_history); diff --git a/source/blender/windowmanager/intern/wm_uilist_type.c b/source/blender/windowmanager/intern/wm_uilist_type.c new file mode 100644 index 00000000000..52619a09218 --- /dev/null +++ b/source/blender/windowmanager/intern/wm_uilist_type.c @@ -0,0 +1,98 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/intern/wm_uilist_type.c + * \ingroup wm + * + * UI List Registry. + */ + +#include "BLI_sys_types.h" + +#include "DNA_windowmanager_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + +#include "BKE_context.h" +#include "BKE_library.h" +#include "BKE_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +static GHash *uilisttypes_hash = NULL; + +uiListType *WM_uilisttype_find(const char *idname, bool quiet) +{ + uiListType *ult; + + if (idname[0]) { + ult = BLI_ghash_lookup(uilisttypes_hash, idname); + if (ult) { + return ult; + } + } + + if (!quiet) { + printf("search for unknown uilisttype %s\n", idname); + } + + return NULL; +} + +bool WM_uilisttype_add(uiListType *ult) +{ + BLI_ghash_insert(uilisttypes_hash, ult->idname, ult); + return 1; +} + +void WM_uilisttype_freelink(uiListType *ult) +{ + bool ok; + + ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN); + + BLI_assert(ok); + (void)ok; +} + +/* called on initialize WM_init() */ +void WM_uilisttype_init(void) +{ + uilisttypes_hash = BLI_ghash_str_new_ex("uilisttypes_hash gh", 16); +} + +void WM_uilisttype_free(void) +{ + GHashIterator gh_iter; + + GHASH_ITER (gh_iter, uilisttypes_hash) { + uiListType *ult = BLI_ghashIterator_getValue(&gh_iter); + if (ult->ext.free) { + ult->ext.free(ult->ext.data); + } + } + + BLI_ghash_free(uilisttypes_hash, NULL, MEM_freeN); + uilisttypes_hash = NULL; +} diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index c0b0e731f4b..5f850a076f0 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -59,6 +59,7 @@ void wm_operator_register(bContext *C, wmOperator *op); void wm_operatortype_free(void); void wm_operatortype_init(void); void wm_window_keymap(wmKeyConfig *keyconf); +void wm_operatortypes_register(void); /* wm_gesture.c */ void wm_gesture_draw(struct wmWindow *win); -- cgit v1.2.3 From f6367ecfb65502a1ec40c5e382800b2ac214a499 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 12:46:10 +0200 Subject: Cleanup: operator type API, header --- source/blender/windowmanager/WM_api.h | 31 +++++++++++----------- .../windowmanager/intern/wm_operator_type.c | 21 +++++++++++++++ source/blender/windowmanager/intern/wm_operators.c | 20 -------------- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 95d5a481385..2ae2a65e2c9 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -261,19 +261,6 @@ void WM_operator_type_set(struct wmOperator *op, struct wmOperatorType *ot); void WM_operator_stack_clear(struct wmWindowManager *wm); void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot); -struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet); -void WM_operatortype_iter(struct GHashIterator *ghi); -void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *)); -void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata); -void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata); -void WM_operatortype_remove_ptr(struct wmOperatorType *ot); -bool WM_operatortype_remove(const char *idname); -void WM_operatortype_last_properties_clear_all(void); - -struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag); -struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname); - - bool WM_operator_poll (struct bContext *C, struct wmOperatorType *ot); bool WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context); int WM_operator_call_ex(struct bContext *C, struct wmOperator *op, const bool store); @@ -367,14 +354,28 @@ void WM_operator_bl_idname(char *to, const char *from); void WM_operator_py_idname(char *to, const char *from); bool WM_operator_py_idname_ok_or_report(struct ReportList *reports, const char *classname, const char *idname); -/* *************** uilist types ******************** */ + +/* wm_operator_type.c */ +struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet); +void WM_operatortype_iter(struct GHashIterator *ghi); +void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *)); +void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata); +void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata); +void WM_operatortype_remove_ptr(struct wmOperatorType *ot); +bool WM_operatortype_remove(const char *idname); +void WM_operatortype_last_properties_clear_all(void); + +struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag); +struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname); + +/* wm_uilist_type.c */ void WM_uilisttype_init(void); struct uiListType *WM_uilisttype_find(const char *idname, bool quiet); bool WM_uilisttype_add(struct uiListType *ult); void WM_uilisttype_freelink(struct uiListType *ult); void WM_uilisttype_free(void); -/* *************** menu types ******************** */ +/* wm_menu_type.c */ void WM_menutype_init(void); struct MenuType *WM_menutype_find(const char *idname, bool quiet); bool WM_menutype_add(struct MenuType *mt); diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 35efdb2c4a2..62b378e0866 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -199,6 +199,27 @@ void wm_operatortype_free(void) global_ops_hash = NULL; } +/** + * Remove memory of all previously executed tools. + */ +void WM_operatortype_last_properties_clear_all(void) +{ + GHashIterator iter; + + for (WM_operatortype_iter(&iter); + (!BLI_ghashIterator_done(&iter)); + (BLI_ghashIterator_step(&iter))) + { + wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); + + if (ot->last_properties) { + IDP_FreeProperty(ot->last_properties); + MEM_freeN(ot->last_properties); + ot->last_properties = NULL; + } + } +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d2fb49ffd57..ffa6b0fc371 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -122,26 +122,6 @@ #define UNDOCUMENTED_OPERATOR_TIP N_("(undocumented operator)") /* ************ operator API, exported ********** */ -/** - * Remove memory of all previously executed tools. - */ -void WM_operatortype_last_properties_clear_all(void) -{ - GHashIterator iter; - - for (WM_operatortype_iter(&iter); - (!BLI_ghashIterator_done(&iter)); - (BLI_ghashIterator_step(&iter))) - { - wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); - - if (ot->last_properties) { - IDP_FreeProperty(ot->last_properties); - MEM_freeN(ot->last_properties); - ot->last_properties = NULL; - } - } -} /* SOME_OT_op -> some.op */ void WM_operator_py_idname(char *to, const char *from) -- cgit v1.2.3 From 5eaa8bf02d3bf9a531cdd30183800168119d14b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 17:37:00 +0200 Subject: Fix bad assert on redo --- source/blender/editors/undo/ed_undo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 7bbb2479a52..b604b1db56f 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -131,8 +131,9 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) return OPERATOR_CANCELLED; } - /* TODO(campbell), could use simple optimization. */ - BLI_assert(step_data_from_name != wm->undo_stack->step_active); + /* happens on redo. */ + // BLI_assert(step_data_from_name != wm->undo_stack->step_active); + /* TODO(campbell): could use simple optimization. */ step_for_callback = ( BLI_findindex(&wm->undo_stack->steps, step_data_from_name) < BLI_findindex(&wm->undo_stack->steps, wm->undo_stack->step_active)) ? 1 : -1; -- cgit v1.2.3 From 7774ad7dd3fbdd6335922fb5c04a43bf163bae38 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Fri, 13 Jul 2018 17:58:22 +0200 Subject: UI: Wider Dyntopo popover to fit all settings Suggested by kostex_mb on IRC --- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 62cff9d6e42..87c6a3840ae 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -888,6 +888,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel): bl_context = ".sculpt_mode" # dot on purpose (access from topbar) bl_label = "Dyntopo" bl_options = {'DEFAULT_CLOSED'} + bl_ui_units_x = 12 @classmethod def poll(cls, context): @@ -906,6 +907,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel): def draw(self, context): layout = self.layout layout.use_property_split = True + layout.use_property_decorate = False toolsettings = context.tool_settings sculpt = toolsettings.sculpt -- cgit v1.2.3 From a6ec402f5a8038718a2a034cf84f1f3f90b125ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 17:59:26 +0200 Subject: Remove invalid assert --- source/blender/editors/undo/ed_undo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index b4268dac863..a13fa4af4e2 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -130,7 +130,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) } /* TODO(campbell), could use simple optimization. */ - BLI_assert(step_data_from_name != wm->undo_stack->step_active); + /* Pointers match on redo. */ step_for_callback = ( BLI_findindex(&wm->undo_stack->steps, step_data_from_name) < BLI_findindex(&wm->undo_stack->steps, wm->undo_stack->step_active)) ? 1 : -1; -- cgit v1.2.3 From 87535dd73d3a2b76f7ede2448a2c471a40c79aaa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 18:16:05 +0200 Subject: Makefile: add note about environment vars --- GNUmakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 23903d36e63..049040f29dd 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -236,7 +236,9 @@ help: .FORCE @echo " * check_descriptions - check for duplicate/invalid descriptions" @echo "" @echo "Utilities (not associated with building blender)" - @echo " * icons - updates PNG icons from SVG files." + @echo " * icons - Updates PNG icons from SVG files." + @echo " Set environment variables 'BLENDER_BIN' and 'INKSCAPE_BIN'" + @echo " to define your own commands." @echo " * tgz - create a compressed archive of the source code." @echo " * update - updates git and all submodules" @echo "" -- cgit v1.2.3 From dc00d66c897fb30b2742812f2669fa79a941839e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 12 Jul 2018 16:36:44 +0200 Subject: UI: only show API defined custom properties when Developer Extras is on. These are intended to behave just like any other builting property, so no to always show them in the Custom Properties panels for regular users. --- release/scripts/modules/rna_prop_ui.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index e50922593de..bdb0751c973 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -129,6 +129,7 @@ def draw(layout, context, context_member, property_type, use_edit=True): props.data_path = context_member del row + show_developer_ui = context.user_preferences.view.show_developer_ui rna_properties = {prop.identifier for prop in rna_item.bl_rna.properties if prop.is_runtime} if items else None for key, val in items: @@ -136,6 +137,12 @@ def draw(layout, context, context_member, property_type, use_edit=True): if key == '_RNA_UI': continue + is_rna = (key in rna_properties) + + # only show API defined for developers + if is_rna and not show_developer_ui: + continue + row = layout.row() to_dict = getattr(val, "to_dict", None) to_list = getattr(val, "to_list", None) @@ -161,8 +168,6 @@ def draw(layout, context, context_member, property_type, use_edit=True): row.label(text=key, translate=False) # explicit exception for arrays - is_rna = (key in rna_properties) - if to_dict or to_list: row.label(text=val_draw, translate=False) else: -- cgit v1.2.3 From 23ca12ec477b2c5f9de40832c81fe93ec49ad75a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 13 Jul 2018 12:05:51 +0200 Subject: Viewport: don't show look dev shader balls by default. We will show these in the shading workspace by default, but for most new 3D viewports that you open these are not needed. --- source/blender/blenloader/intern/versioning_280.c | 2 +- source/blender/editors/space_view3d/space_view3d.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index bd66d9a4707..a078b794536 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1100,7 +1100,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) v3d->overlay.backwire_opacity = 0.5f; v3d->overlay.normals_length = 0.1f; - v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV; + v3d->overlay.flag = 0; } } } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 43b6a1b0621..691baaf48f7 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -333,7 +333,6 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->shading.cavity_ridge_factor = 1.0f; copy_v3_fl(v3d->shading.single_color, 0.8f); - v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV; v3d->overlay.wireframe_threshold = 0.5f; v3d->overlay.bone_select_alpha = 0.5f; v3d->overlay.texture_paint_mode_opacity = 0.8; -- cgit v1.2.3 From cfe2c3213f4721f5cc04305308132fefd1f4d112 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 13 Jul 2018 18:09:51 +0200 Subject: Fix T55965: shrinkwrap modifier apply not working. --- source/blender/editors/object/object_modifier.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 5ee30992621..11d0fd9f9d5 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -691,23 +691,29 @@ int ED_object_modifier_apply( if (md != ob->modifiers.first) BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected"); + /* Get evaluated modifier, so object links pointer to evaluated data, + * but still use original object it is applied to the original mesh. */ + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); + ModifierData *md_eval = (ob_eval) ? modifiers_findByName(ob_eval, md->name) : md; + /* allow apply of a not-realtime modifier, by first re-enabling realtime. */ - prev_mode = md->mode; - md->mode |= eModifierMode_Realtime; + prev_mode = md_eval->mode; + md_eval->mode |= eModifierMode_Realtime; if (mode == MODIFIER_APPLY_SHAPE) { - if (!modifier_apply_shape(bmain, reports, depsgraph, scene, ob, md)) { - md->mode = prev_mode; + if (!modifier_apply_shape(bmain, reports, depsgraph, scene, ob, md_eval)) { + md_eval->mode = prev_mode; return 0; } } else { - if (!modifier_apply_obdata(reports, depsgraph, scene, ob, md)) { - md->mode = prev_mode; + if (!modifier_apply_obdata(reports, depsgraph, scene, ob, md_eval)) { + md_eval->mode = prev_mode; return 0; } } + md_eval->mode = prev_mode; BLI_remlink(&ob->modifiers, md); modifier_free(md); -- cgit v1.2.3 From 4ca298309620c65e390ccb52e5921bddfd69c31e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 13 Jul 2018 18:12:19 +0200 Subject: Fix missing panels in texture properties with image texture. --- release/scripts/startup/bl_ui/properties_texture.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 1859b4bf3e8..b08b47fbe77 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -370,6 +370,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, Panel): bl_options = {'DEFAULT_CLOSED'} bl_parent_id = 'TEXTURE_PT_image' tex_type = 'IMAGE' + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw(self, context): layout = self.layout @@ -402,6 +403,8 @@ class TEXTURE_PT_image_alpha(TextureTypePanel, Panel): bl_label = "Alpha" bl_options = {'DEFAULT_CLOSED'} bl_parent_id = 'TEXTURE_PT_image' + tex_type = 'IMAGE' + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw_header(self, context): tex = context.texture @@ -424,6 +427,7 @@ class TEXTURE_PT_image_mapping(TextureTypePanel, Panel): bl_options = {'DEFAULT_CLOSED'} bl_parent_id = 'TEXTURE_PT_image' tex_type = 'IMAGE' + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw(self, context): layout = self.layout -- cgit v1.2.3 From 6845306c68a874cb1a9171d6a08a1578eea41a8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 18:56:59 +0200 Subject: Correct recent menu split Somehow duplicate API didn't error when linking. --- source/blender/windowmanager/intern/wm.c | 74 ---------------------- source/blender/windowmanager/intern/wm_menu_type.c | 10 +++ 2 files changed, 10 insertions(+), 74 deletions(-) diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 9e7136dc81d..f92cc511449 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -282,80 +282,6 @@ void WM_uilisttype_free(void) uilisttypes_hash = NULL; } -/* ************ MenuType handling ************** */ - -static GHash *menutypes_hash = NULL; - -MenuType *WM_menutype_find(const char *idname, bool quiet) -{ - MenuType *mt; - - if (idname[0]) { - mt = BLI_ghash_lookup(menutypes_hash, idname); - if (mt) - return mt; - } - - if (!quiet) - printf("search for unknown menutype %s\n", idname); - - return NULL; -} - -bool WM_menutype_add(MenuType *mt) -{ - BLI_ghash_insert(menutypes_hash, mt->idname, mt); - return true; -} - -void WM_menutype_freelink(MenuType *mt) -{ - bool ok; - - ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN); - - BLI_assert(ok); - (void)ok; -} - -/* called on initialize WM_init() */ -void WM_menutype_init(void) -{ - /* reserve size is set based on blender default setup */ - menutypes_hash = BLI_ghash_str_new_ex("menutypes_hash gh", 512); -} - -void WM_menutype_free(void) -{ - GHashIterator gh_iter; - - GHASH_ITER (gh_iter, menutypes_hash) { - MenuType *mt = BLI_ghashIterator_getValue(&gh_iter); - if (mt->ext.free) { - mt->ext.free(mt->ext.data); - } - } - - BLI_ghash_free(menutypes_hash, NULL, MEM_freeN); - menutypes_hash = NULL; -} - -bool WM_menutype_poll(bContext *C, MenuType *mt) -{ - /* If we're tagged, only use compatible. */ - if (mt->owner_id[0] != '\0') { - const WorkSpace *workspace = CTX_wm_workspace(C); - if (BKE_workspace_owner_id_check(workspace, mt->owner_id) == false) { - return false; - } - } - - if (mt->poll != NULL) { - return mt->poll(C, mt); - } - return true; -} - /* ****************************************** */ void WM_keymap_init(bContext *C) diff --git a/source/blender/windowmanager/intern/wm_menu_type.c b/source/blender/windowmanager/intern/wm_menu_type.c index 58e85716bf1..97ca5690954 100644 --- a/source/blender/windowmanager/intern/wm_menu_type.c +++ b/source/blender/windowmanager/intern/wm_menu_type.c @@ -27,6 +27,7 @@ #include "BLI_sys_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_workspace_types.h" #include "MEM_guardedalloc.h" @@ -36,6 +37,7 @@ #include "BKE_context.h" #include "BKE_library.h" #include "BKE_screen.h" +#include "BKE_workspace.h" #include "WM_api.h" #include "WM_types.h" @@ -98,6 +100,14 @@ void WM_menutype_free(void) bool WM_menutype_poll(bContext *C, MenuType *mt) { + /* If we're tagged, only use compatible. */ + if (mt->owner_id[0] != '\0') { + const WorkSpace *workspace = CTX_wm_workspace(C); + if (BKE_workspace_owner_id_check(workspace, mt->owner_id) == false) { + return false; + } + } + if (mt->poll != NULL) { return mt->poll(C, mt); } -- cgit v1.2.3 From af0fc660499a63b367dcc63222d0baee93aa665c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 18:39:46 +0200 Subject: WM: register global list of panel types Allows simple lookups for popovers. --- source/blender/makesrna/intern/rna_ui.c | 4 + source/blender/windowmanager/CMakeLists.txt | 1 + source/blender/windowmanager/WM_api.h | 7 ++ source/blender/windowmanager/intern/wm_init_exit.c | 2 + .../blender/windowmanager/intern/wm_panel_type.c | 86 ++++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 source/blender/windowmanager/intern/wm_panel_type.c diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 7bec598351e..a271df464b7 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -205,6 +205,8 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type) BLI_freelistN(&pt->children); BLI_freelinkN(&art->paneltypes, pt); + WM_paneltype_remove(pt); + /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); } @@ -313,6 +315,8 @@ static StructRNA *rna_Panel_register( } } + WM_paneltype_add(pt); + /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index eb01332fc26..67674dae4f3 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -71,6 +71,7 @@ set(SRC intern/wm_operator_props.c intern/wm_operator_type.c intern/wm_operators.c + intern/wm_panel_type.c intern/wm_playanim.c intern/wm_stereo.c intern/wm_subwindow.c diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 68cbc3828fc..32900b75514 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -441,6 +441,13 @@ void WM_menutype_freelink(struct MenuType *mt); void WM_menutype_free(void); bool WM_menutype_poll(struct bContext *C, struct MenuType *mt); +/* wm_panel_type.c */ +void WM_paneltype_init(void); +void WM_paneltype_clear(void); +struct PanelType *WM_paneltype_find(const char *idname, bool quiet); +bool WM_paneltype_add(struct PanelType *mt); +void WM_paneltype_remove(struct PanelType *mt); + /* wm_gesture_ops.c */ int WM_gesture_border_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_border_modal (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 6c374f3d8d4..463508674d5 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -209,6 +209,7 @@ void WM_init(bContext *C, int argc, const char **argv) wm_operatortype_init(); wm_operatortypes_register(); + WM_paneltype_init(); /* Lookup table only. */ WM_menutype_init(); WM_uilisttype_init(); wm_manipulatortype_init(); @@ -453,6 +454,7 @@ void WM_exit_ext(bContext *C, const bool do_python) } } + WM_paneltype_clear(); BKE_addon_pref_type_free(); wm_operatortype_free(); wm_dropbox_free(); diff --git a/source/blender/windowmanager/intern/wm_panel_type.c b/source/blender/windowmanager/intern/wm_panel_type.c new file mode 100644 index 00000000000..ef1a55281c9 --- /dev/null +++ b/source/blender/windowmanager/intern/wm_panel_type.c @@ -0,0 +1,86 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/intern/wm_panel_type.c + * \ingroup wm + * + * Panel Registry. + * + * \note Unlike menu, and other registries, this doesn't *own* the PanelType. + * + * For popups/popovers only, regions handle panel types by including them in local lists. + */ + +#include "BLI_sys_types.h" + +#include "DNA_windowmanager_types.h" + +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + +#include "BKE_screen.h" + +#include "WM_api.h" + +static GHash *g_paneltypes_hash = NULL; + +PanelType *WM_paneltype_find(const char *idname, bool quiet) +{ + PanelType *pt; + + if (idname[0]) { + pt = BLI_ghash_lookup(g_paneltypes_hash, idname); + if (pt) + return pt; + } + + if (!quiet) + printf("search for unknown paneltype %s\n", idname); + + return NULL; +} + +bool WM_paneltype_add(PanelType *pt) +{ + BLI_ghash_insert(g_paneltypes_hash, pt->idname, pt); + return true; +} + +void WM_paneltype_remove(PanelType *pt) +{ + bool ok; + + ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL); + + BLI_assert(ok); + (void)ok; +} + +/* called on initialize WM_init() */ +void WM_paneltype_init(void) +{ + /* reserve size is set based on blender default setup */ + g_paneltypes_hash = BLI_ghash_str_new_ex("g_paneltypes_hash gh", 512); +} + +void WM_paneltype_clear(void) +{ + BLI_ghash_free(g_paneltypes_hash, NULL, NULL); +} -- cgit v1.2.3 From cca87ccc753a85b447872a259c9d3e3f07ec1c13 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 19:13:44 +0200 Subject: UI: remove space/region from popover args Instead use global panel-type list. --- release/scripts/startup/bl_operators/presets.py | 8 ++---- release/scripts/startup/bl_ui/space_dopesheet.py | 4 +-- release/scripts/startup/bl_ui/space_graph.py | 4 +-- release/scripts/startup/bl_ui/space_nla.py | 4 +-- release/scripts/startup/bl_ui/space_outliner.py | 10 ++++---- release/scripts/startup/bl_ui/space_time.py | 8 ++---- release/scripts/startup/bl_ui/space_view3d.py | 30 +++++++--------------- source/blender/editors/animation/drivers.c | 4 +-- source/blender/editors/include/UI_interface.h | 4 +-- .../blender/editors/interface/interface_layout.c | 25 +++--------------- .../editors/interface/interface_region_popover.c | 9 +++---- source/blender/editors/transform/transform_ops.c | 2 +- source/blender/makesrna/intern/rna_ui_api.c | 11 +++----- source/blender/windowmanager/WM_keymap.h | 5 +--- source/blender/windowmanager/intern/wm_keymap.c | 7 +---- source/blender/windowmanager/intern/wm_operators.c | 8 +----- 16 files changed, 38 insertions(+), 105 deletions(-) diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 55e61be6370..530194e5bb7 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -263,9 +263,7 @@ class PresetMenu(Panel): def draw_panel_header(cls, layout): layout.emboss = 'NONE' layout.popover( - cls.bl_space_type, - cls.bl_region_type, - cls.__name__, + panel=cls.__name__, icon='PRESET', text="", ) @@ -276,9 +274,7 @@ class PresetMenu(Panel): text = cls.bl_label layout.popover( - cls.bl_space_type, - cls.bl_region_type, - cls.__name__, + panel=cls.__name__, icon='PRESET', text=text, ) diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index 1b89cfd470d..efd5e195fb8 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -263,9 +263,7 @@ class DOPESHEET_HT_editor_buttons(Header): row.prop(st.dopesheet, "filter_text", text="") layout.popover( - space_type='DOPESHEET_EDITOR', - region_type='HEADER', - panel_type="DOPESHEET_PT_filters", + panel="DOPESHEET_PT_filters", text="", icon='FILTER', ) diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index de5dcdbc36d..eacfb364130 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -60,9 +60,7 @@ class GRAPH_HT_header(Header): row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED') layout.popover( - space_type='GRAPH_EDITOR', - region_type='HEADER', - panel_type="GRAPH_PT_filters", + panel="GRAPH_PT_filters", text="", icon='FILTER', ) diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 4bf338b89d6..4e20001b133 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -44,9 +44,7 @@ class NLA_HT_header(Header): dopesheet_filter(layout, context) layout.popover( - space_type='NLA_EDITOR', - region_type='HEADER', - panel_type="NLA_PT_filters", + panel="NLA_PT_filters", text="", icon='FILTER', ) diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index 965de6b1ce1..97fae2690fd 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -49,11 +49,11 @@ class OUTLINER_HT_header(Header): row = layout.row(align=True) if display_mode in {'VIEW_LAYER'}: - row.popover(space_type='OUTLINER', - region_type='HEADER', - panel_type="OUTLINER_PT_filter", - text="", - icon='FILTER') + row.popover( + panel="OUTLINER_PT_filter", + text="", + icon='FILTER', + ) elif display_mode in {'LIBRARIES', 'ORPHAN_DATA'}: row.prop(space, "use_filter_id_type", text="", icon='FILTER') sub = row.row(align=True) diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index 9db2afd62b4..99e5f6b08e5 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -94,15 +94,11 @@ class TIME_MT_editor_menus(Menu): row = layout.row() sub = row.row(align=True) sub.popover( - space_type='DOPESHEET_EDITOR', - region_type='HEADER', - panel_type="TIME_PT_playback", + panel="TIME_PT_playback", text="Playback", ) sub.popover( - space_type='DOPESHEET_EDITOR', - region_type='HEADER', - panel_type="TIME_PT_keyframing_settings", + panel="TIME_PT_keyframing_settings", text="Keying", ) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 53e4346550e..50914a15fba 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -116,9 +116,7 @@ class VIEW3D_HT_header(Header): row = layout.row(align=True) row.popover( - space_type='VIEW_3D', - region_type='HEADER', - panel_type="VIEW3D_PT_transform_orientations", + panel="VIEW3D_PT_transform_orientations", text=trans_name, icon=trans_icon, ) @@ -155,11 +153,9 @@ class VIEW3D_HT_header(Header): sub = row.row(align=True) sub.popover( - space_type='VIEW_3D', - region_type='HEADER', - panel_type="VIEW3D_PT_snapping", + panel="VIEW3D_PT_snapping", icon=icon, - text="" + text="", ) # Proportional editing @@ -199,9 +195,7 @@ class VIEW3D_HT_header(Header): act_pivot_point = bpy.types.ToolSettings.bl_rna.properties["transform_pivot_point"].enum_items[pivot_point] row = layout.row(align=True) row.popover( - space_type='VIEW_3D', - region_type='HEADER', - panel_type="VIEW3D_PT_pivot_point", + panel="VIEW3D_PT_pivot_point", icon=act_pivot_point.icon, text="", ) @@ -210,9 +204,7 @@ class VIEW3D_HT_header(Header): # Viewport Settings layout.popover( - space_type='VIEW_3D', - region_type='HEADER', - panel_type="VIEW3D_PT_object_type_visibility", + panel="VIEW3D_PT_object_type_visibility", icon_value=view.icon_from_show_object_viewport, text="", ) @@ -221,13 +213,13 @@ class VIEW3D_HT_header(Header): row.prop(overlay, "show_overlays", icon='WIRE', text="") sub = row.row(align=True) sub.active = overlay.show_overlays - sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay") + sub.popover(panel="VIEW3D_PT_overlay") row = layout.row(align=True) row.prop(shading, "type", text="", expand=True) sub = row.row(align=True) sub.enabled = shading.type != 'RENDERED' - sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading") + sub.popover(panel="VIEW3D_PT_shading") class VIEW3D_MT_editor_menus(Menu): @@ -3861,9 +3853,7 @@ class VIEW3D_PT_shading_options(Panel): sub.active = is_shadows sub.prop(shading, "shadow_intensity", text="Shadow") sub.popover( - space_type='VIEW_3D', - region_type='HEADER', - panel_type="VIEW3D_PT_shading_options_shadow", + panel="VIEW3D_PT_shading_options_shadow", icon='SCRIPTWIN', text="" ) @@ -3879,9 +3869,7 @@ class VIEW3D_PT_shading_options(Panel): sub.prop(shading, "cavity_ridge_factor") sub.prop(shading, "cavity_valley_factor") sub.popover( - space_type='VIEW_3D', - region_type='HEADER', - panel_type="VIEW3D_PT_shading_options_ssao", + panel="VIEW3D_PT_shading_options_ssao", icon='SCRIPTWIN', text="" ) diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 99725c7da99..fe57909be75 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -953,7 +953,7 @@ static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent * /* 2) Show editing panel for setting up this driver */ /* TODO: Use a different one from the editing popever, so we can have the single/all toggle? */ - UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports); + UI_popover_panel_invoke(C, "GRAPH_PT_drivers_popover", true, op->reports); } return OPERATOR_INTERFACE; @@ -1041,7 +1041,7 @@ static int edit_driver_button_exec(bContext *C, wmOperator *op) UI_context_active_but_prop_get(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop) { - UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports); + UI_popover_panel_invoke(C, "GRAPH_PT_drivers_popover", true, op->reports); } return OPERATOR_INTERFACE; diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d23748356fa..251f2b92acd 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -444,7 +444,7 @@ void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *b typedef struct uiPopover uiPopover; int UI_popover_panel_invoke( - struct bContext *C, int space_id, int region_id, const char *idname, + struct bContext *C, const char *idname, bool keep_open, struct ReportList *reports); uiPopover *UI_popover_begin(struct bContext *C, int menu_width) ATTR_NONNULL(1); @@ -1170,7 +1170,7 @@ void uiItemPopoverPanel_ptr( const char *name, int icon); void uiItemPopoverPanel( uiLayout *layout, struct bContext *C, - int space_id, int region_id, const char *panelname, + const char *panelname, const char *name, int icon); void uiItemPopoverPanelFromGroup( uiLayout *layout, struct bContext *C, diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 16016a799ef..82ed4c5acba 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2185,32 +2185,13 @@ void uiItemPopoverPanel_ptr(uiLayout *layout, bContext *C, PanelType *pt, const void uiItemPopoverPanel( uiLayout *layout, bContext *C, - int space_id, int region_id, const char *panel_type, - const char *name, int icon) + const char *panel_type, const char *name, int icon) { - SpaceType *st = BKE_spacetype_from_id(space_id); - if (st == NULL) { - RNA_warning("space type not found %d", space_id); - return; - } - ARegionType *art = BKE_regiontype_from_id(st, region_id); - if (art == NULL) { - RNA_warning("region type not found %d", region_id); - return; - } - - PanelType *pt; - for (pt = art->paneltypes.first; pt; pt = pt->next) { - if (STREQ(pt->idname, panel_type)) { - break; - } - } - + PanelType *pt = WM_paneltype_find(panel_type, true); if (pt == NULL) { - RNA_warning("area type not found %s", panel_type); + RNA_warning("Panel type not found '%s'", panel_type); return; } - uiItemPopoverPanel_ptr(layout, C, pt, name, icon); } diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c index 35856b6c8b2..376e367f4da 100644 --- a/source/blender/editors/interface/interface_region_popover.c +++ b/source/blender/editors/interface/interface_region_popover.c @@ -277,16 +277,13 @@ uiPopupBlockHandle *ui_popover_panel_create( * \{ */ int UI_popover_panel_invoke( - bContext *C, int space_id, int region_id, const char *idname, + bContext *C, const char *idname, bool keep_open, ReportList *reports) { uiLayout *layout; - PanelType *pt = UI_paneltype_find(space_id, region_id, idname); + PanelType *pt = WM_paneltype_find(idname, true); if (pt == NULL) { - BKE_reportf( - reports, RPT_ERROR, - "Panel \"%s\" not found (space %d, region %d)", - idname, space_id, region_id); + BKE_reportf(reports, RPT_ERROR, "Panel \"%s\" not found", idname); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 4de475e05b9..eedf6f50a1f 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -1123,7 +1123,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap"); - WM_keymap_add_panel(keymap, SPACE_VIEW3D, RGN_TYPE_HEADER, "VIEW3D_PT_snapping", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + WM_keymap_add_panel(keymap, "VIEW3D_PT_snapping", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); /* Will fall-through to texture-space transform. */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_transform_axis_target", TKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 74117b43d91..c9ce9ae7961 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -277,8 +277,7 @@ static void rna_uiItemM( static void rna_uiItemPopoverPanel( uiLayout *layout, bContext *C, - int space_type, int region_type, const char *panel_type, - const char *name, const char *text_ctxt, + const char *panel_type, const char *name, const char *text_ctxt, bool translate, int icon, int icon_value) { /* Get translated name (label). */ @@ -288,7 +287,7 @@ static void rna_uiItemPopoverPanel( icon = icon_value; } - uiItemPopoverPanel(layout, C, space_type, region_type, panel_type, name, icon); + uiItemPopoverPanel(layout, C, panel_type, name, icon); } static void rna_uiItemPopoverPanelFromGroup( @@ -717,11 +716,7 @@ void RNA_api_ui_layout(StructRNA *srna) func = RNA_def_function(srna, "popover", "rna_uiItemPopoverPanel"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); - parm = RNA_def_enum(func, "space_type", rna_enum_space_type_items, 0, "Space Type", ""); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum(func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", ""); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_string(func, "panel_type", NULL, 0, "", "Identifier of the panel"); + parm = RNA_def_string(func, "panel", NULL, 0, "", "Identifier of the panel"); api_ui_item_common(func); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED); diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index afde7f64b81..547028c88f9 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -66,10 +66,7 @@ wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, in int val, int modifier, int keymodifier); wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); -wmKeyMapItem *WM_keymap_add_panel( - struct wmKeyMap *keymap, - short space_type, short region_type, const char *idname, - int type, int val, int modifier, int keymodifier); +wmKeyMapItem *WM_keymap_add_panel(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); wmKeyMapItem *WM_keymap_add_tool(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 82363c4c21b..a95ccf36fdb 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -509,14 +509,9 @@ wmKeyMapItem *WM_keymap_add_menu_pie(wmKeyMap *keymap, const char *idname, int t return kmi; } -wmKeyMapItem *WM_keymap_add_panel( - wmKeyMap *keymap, - short space_type, short region_type, const char *idname, - int type, int val, int modifier, int keymodifier) +wmKeyMapItem *WM_keymap_add_panel(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) { wmKeyMapItem *kmi = WM_keymap_add_item(keymap, "WM_OT_call_panel", type, val, modifier, keymodifier); - RNA_enum_set(kmi->ptr, "space_type", space_type); - RNA_enum_set(kmi->ptr, "region_type", region_type); RNA_string_set(kmi->ptr, "name", idname); /* TODO: we might want to disable this. */ RNA_boolean_set(kmi->ptr, "keep_open", false); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 5cb95f2b3c5..dd9b8324b11 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1778,11 +1778,9 @@ static int wm_call_panel_exec(bContext *C, wmOperator *op) { char idname[BKE_ST_MAXNAME]; RNA_string_get(op->ptr, "name", idname); - const int space_type = RNA_enum_get(op->ptr, "space_type"); - const int region_type = RNA_enum_get(op->ptr, "region_type"); const bool keep_open = RNA_boolean_get(op->ptr, "keep_open"); - return UI_popover_panel_invoke(C, space_type, region_type, idname, keep_open, op->reports); + return UI_popover_panel_invoke(C, idname, keep_open, op->reports); } static void WM_OT_call_panel(wmOperatorType *ot) @@ -1800,10 +1798,6 @@ static void WM_OT_call_panel(wmOperatorType *ot) prop = RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_enum(ot->srna, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", ""); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_enum(ot->srna, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", ""); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "keep_open", true, "Keep Open", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -- cgit v1.2.3 From bc12c6f542fcb6ba848d7e3e93e1639d9849cbfe Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Fri, 13 Jul 2018 20:11:57 +0200 Subject: UI: Align Lighting sub-panel of the Shading popover This better aligns the matcap/hdri browser, rotation/background sliders and preferences/flip matcap button. The remaining sub-panels are not perfeclty aligned yet, once the sub-panels separation is more prominent (and they can be collapsed) we can align those. Thanks devtalk forum for feedback! --- release/scripts/startup/bl_ui/space_view3d.py | 58 ++++++++++++++++++--------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 50914a15fba..f9b69b8de66 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3757,38 +3757,56 @@ class VIEW3D_PT_shading_lighting(Panel): view = context.space_data shading = view.shading + col = layout.column() + split = col.split(0.9) + if shading.type == 'SOLID': - layout.row().prop(shading, "light", expand=True) + split.row().prop(shading, "light", expand=True) + col = split.column() + + split = layout.split(0.9) + col = split.column() + sub = col.row() + sub.scale_y = 0.6 # smaller matcap/hdri preview + if shading.light == 'STUDIO': - row = layout.row() - row.scale_y = 0.8 - row.template_icon_view(shading, "studio_light", show_labels=True, scale=3) - sub = row.column() - sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') + sub.template_icon_view(shading, "studio_light", show_labels=True, scale=3) + if shading.selected_studio_light.orientation == 'WORLD': - layout.row().prop(shading, "studiolight_rotate_z", text="Rotation") + col.prop(shading, "studiolight_rotate_z", text="Rotation") + + col = split.column() + col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') elif shading.light == 'MATCAP': - row = layout.row() - row.scale_y = 0.8 - row.template_icon_view(shading, "studio_light", show_labels=True, scale=3) - sub = row.column() - sub.operator('VIEW3D_OT_toggle_matcap_flip', emboss=False, text="", icon='ARROW_LEFTRIGHT') - sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') + sub.template_icon_view(shading, "studio_light", show_labels=True, scale=3) + + col = split.column() + col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') + col.operator('VIEW3D_OT_toggle_matcap_flip', emboss=False, text="", icon='ARROW_LEFTRIGHT') elif shading.type == 'MATERIAL': - col = layout.column(align=True) col.prop(shading, "use_scene_lights") col.prop(shading, "use_scene_world") if not shading.use_scene_world: - row = layout.row() - row.template_icon_view(shading, "studio_light", show_labels=True, scale=3) - sub = row.column() - sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') + col = layout.column() + split = col.split(0.9) + + col = split.column() + sub = col.row() + sub.scale_y = 0.6 + sub.template_icon_view(shading, "studio_light", show_labels=True, scale=3) + + col = split.column() + col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') + if shading.selected_studio_light.orientation == 'WORLD': - layout.row().prop(shading, "studiolight_rotate_z", text="Rotation") - layout.row().prop(shading, "studiolight_background_alpha") + split = layout.split(0.9) + col = split.column() + col.prop(shading, "studiolight_rotate_z", text="Rotation") + col.prop(shading, "studiolight_background_alpha") + col = split.column() # to align properly with above class VIEW3D_PT_shading_color(Panel): -- cgit v1.2.3 From d9e79b0756f2ef23ed4321f5f215062c9fbbcddd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 20:22:05 +0200 Subject: Add include missing in release builds --- source/blender/windowmanager/intern/wm_panel_type.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_panel_type.c b/source/blender/windowmanager/intern/wm_panel_type.c index ef1a55281c9..2c541db55a6 100644 --- a/source/blender/windowmanager/intern/wm_panel_type.c +++ b/source/blender/windowmanager/intern/wm_panel_type.c @@ -28,6 +28,8 @@ * For popups/popovers only, regions handle panel types by including them in local lists. */ +#include + #include "BLI_sys_types.h" #include "DNA_windowmanager_types.h" -- cgit v1.2.3 From cb22dd6f5d8c7d27ba7e093592a6a4ed8722b636 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Fri, 13 Jul 2018 01:36:34 +0200 Subject: UI: Capital letters for property --- source/blender/makesrna/intern/rna_movieclip.c | 2 +- source/blender/makesrna/intern/rna_space.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index aa976775ad1..aded4229a3c 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -251,7 +251,7 @@ static void rna_def_moviecliUser(BlenderRNA *brna) prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "render_size"); RNA_def_property_enum_items(prop, clip_render_size_items); - RNA_def_property_ui_text(prop, "Proxy render size", + RNA_def_property_ui_text(prop, "Proxy Render Size", "Draw preview using full resolution or different proxy resolutions"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update"); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index b98ec3b0204..b89a4f09d9f 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3577,7 +3577,7 @@ static void rna_def_space_sequencer(BlenderRNA *brna) prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "render_size"); RNA_def_property_enum_items(prop, proxy_render_size_items); - RNA_def_property_ui_text(prop, "Proxy render size", + RNA_def_property_ui_text(prop, "Proxy Render Size", "Draw preview using full resolution or different proxy resolutions"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); -- cgit v1.2.3 From 5d6d565792819a3b4fe2bb39ab7d4ce70042453f Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Fri, 13 Jul 2018 01:37:28 +0200 Subject: VSE: Add image strips with alpha over as blend type --- source/blender/editors/space_sequencer/sequencer_add.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index a8688b26280..5d2ceced904 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -879,6 +879,8 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) strip = seq->strip; se = strip->stripdata; + seq->blend_mode = SEQ_TYPE_ALPHAOVER; + if (use_placeholders) { sequencer_image_seq_reserve_frames(op, se, seq_load.len, minframe, numdigits); } -- cgit v1.2.3 From 19a55b5a007725bc659f057312a4a70894b6a467 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Sat, 14 Jul 2018 01:37:01 +0200 Subject: UI: More descriptive tooltip --- source/blender/editors/space_view3d/view3d_snap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 11575f8b1f3..7799854db49 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -802,7 +802,7 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot) { /* identifiers */ ot->name = "Snap Cursor to Center"; - ot->description = "Snap cursor to the Center"; + ot->description = "Snap cursor to world origin"; ot->idname = "VIEW3D_OT_snap_cursor_to_center"; /* api callbacks */ -- cgit v1.2.3 From 9ca8f40790db6c40f260090a380be7ddb18e1dfa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 09:02:36 +0200 Subject: Keymap: remove double space in tool-keymap --- release/scripts/startup/bl_ui/space_toolsystem_toolbar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index b0bff84b8eb..527dfdc3c6f 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -874,7 +874,7 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel): bl_options = {'HIDE_HEADER'} # Satisfy the 'ToolSelectPanelHelper' API. - keymap_prefix = "Image Editor Tool: " + keymap_prefix = "Image Editor Tool:" @classmethod def tools_from_context(cls, context, mode=None): @@ -925,7 +925,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): bl_options = {'HIDE_HEADER'} # Satisfy the 'ToolSelectPanelHelper' API. - keymap_prefix = "3D View Tool: " + keymap_prefix = "3D View Tool:" @classmethod def tools_from_context(cls, context, mode=None): -- cgit v1.2.3 From 7d73ba904e3e69c1aa9b878aa2549581bb23e63b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 09:30:50 +0200 Subject: Cleanup: minor change for f-string use --- release/scripts/startup/bl_operators/screen_play_rendered_anim.py | 2 +- release/scripts/startup/bl_ui/space_text.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 46cf07be0f5..27c8487eaa9 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -149,7 +149,7 @@ class PlayRenderedAnim(Operator): opts = [file, f"{scene.frame_start:d}-{scene.frame_end:d}"] cmd.extend(opts) elif preset == 'RV': - opts = ["-fps", str(rd.fps), "-play", f"[ {file} ]"] + opts = ["-fps", str(rd.fps), "-play", f"[ {file:s} ]"] cmd.extend(opts) elif preset == 'MPLAYER': opts = [] diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index d0067012ffe..fc93956b14b 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -67,12 +67,12 @@ class TEXT_HT_header(Header): if text.filepath: if text.is_dirty: row.label( - iface_(f"File: *{text.filepath} (unsaved)"), + iface_(f"File: *{text.filepath:s} (unsaved)"), translate=False, ) else: row.label( - iface_(f"File: {text.filepath}"), + iface_(f"File: {text.filepath:s}"), translate=False, ) else: -- cgit v1.2.3 From 43973410f3c0a6ab17be3a7899c64fee1787c61e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 09:30:59 +0200 Subject: Cleanup: use f-string for addon_utils --- release/scripts/modules/addon_utils.py | 70 +++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index c4097bed33b..5cb313ec41b 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -78,7 +78,7 @@ def modules_refresh(module_cache=addons_fake_modules): try: file_mod = open(mod_path, "r", encoding='UTF-8') except OSError as ex: - print("Error opening file %r: %s" % (mod_path, ex)) + print("Error opening file:", mod_path, ex) return None with file_mod: @@ -116,7 +116,7 @@ def modules_refresh(module_cache=addons_fake_modules): try: ast_data = ast.parse(data, filename=mod_path) except: - print("Syntax error 'ast.parse' can't read %r" % mod_path) + print("Syntax error 'ast.parse' can't read:", repr(mod_path)) import traceback traceback.print_exc() ast_data = None @@ -138,7 +138,7 @@ def modules_refresh(module_cache=addons_fake_modules): mod.__file__ = mod_path mod.__time__ = os.path.getmtime(mod_path) except: - print("AST error parsing bl_info for %s" % mod_name) + print("AST error parsing bl_info for:", mod_name) import traceback traceback.print_exc() raise @@ -148,8 +148,11 @@ def modules_refresh(module_cache=addons_fake_modules): return mod else: - print("fake_module: addon missing 'bl_info' " - "gives bad performance!: %r" % mod_path) + print( + "fake_module: addon missing 'bl_info' " + "gives bad performance!:", + repr(mod_path), + ) return None modules_stale = set(module_cache.keys()) @@ -167,17 +170,21 @@ def modules_refresh(module_cache=addons_fake_modules): mod = module_cache.get(mod_name) if mod: if mod.__file__ != mod_path: - print("multiple addons with the same name:\n %r\n %r" % - (mod.__file__, mod_path)) + print( + "multiple addons with the same name:\n" + " " f"{mod.__file__!r}" "\n" + " " f"{mod_path!r}" + ) error_duplicates.append((mod.bl_info["name"], mod.__file__, mod_path)) elif mod.__time__ != os.path.getmtime(mod_path): - print("reloading addon:", - mod_name, - mod.__time__, - os.path.getmtime(mod_path), - mod_path, - ) + print( + "reloading addon:", + mod_name, + mod.__time__, + os.path.getmtime(mod_path), + repr(mod_path), + ) del module_cache[mod_name] mod = None @@ -233,10 +240,12 @@ def check(module_name): ) if loaded_state is Ellipsis: - print("Warning: addon-module %r found module " - "but without __addon_enabled__ field, " - "possible name collision from file: %r" % - (module_name, getattr(mod, "__file__", ""))) + print( + "Warning: addon-module " f"{module_name:s}" " found module " + "but without '__addon_enabled__' field, " + "possible name collision from file:", + repr(getattr(mod, "__file__", "")), + ) loaded_state = False @@ -303,8 +312,10 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non try: mod.unregister() except Exception as ex: - print("Exception in module unregister(): %r" % - getattr(mod, "__file__", module_name)) + print( + "Exception in module unregister():", + repr(getattr(mod, "__file__", module_name)), + ) handle_error(ex) return None @@ -313,7 +324,7 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non mtime_new = os.path.getmtime(mod.__file__) if mtime_orig != mtime_new: import importlib - print("module changed on disk:", mod.__file__, "reloading...") + print("module changed on disk:", repr(mod.__file__), "reloading...") try: importlib.reload(mod) @@ -343,7 +354,7 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non except Exception as ex: # if the addon doesn't exist, dont print full traceback if type(ex) is ImportError and ex.name == module_name: - print("addon not found: %r" % module_name) + print("addon not found:", repr(module_name)) else: handle_error(ex) @@ -358,8 +369,10 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non try: mod.register() except Exception as ex: - print("Exception in module register(): %r" % - getattr(mod, "__file__", module_name)) + print( + "Exception in module register():", + getattr(mod, "__file__", module_name), + ) handle_error(ex) del sys.modules[module_name] if default_set: @@ -406,12 +419,15 @@ def disable(module_name, *, default_set=False, handle_error=None): try: mod.unregister() except Exception as ex: - print("Exception in module unregister(): %r" % - getattr(mod, "__file__", module_name)) + mod_path = getattr(mod, "__file__", module_name) + print("Exception in module unregister():", repr(mod_path)) + del mod_path handle_error(ex) else: - print("addon_utils.disable: %s not %s." % - (module_name, "disabled" if mod is None else "loaded")) + print( + "addon_utils.disable: " f"{module_name:s}" " not", + ("disabled" if mod is None else "loaded") + ) # could be in more than once, unlikely but better do this just in case. if default_set: -- cgit v1.2.3 From 0f340a1fa2827d6426e5ac4c686ff1a1e0d4fa8e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 09:32:52 +0200 Subject: Cleanup: f-string use --- release/scripts/startup/bl_ui/space_outliner.py | 4 ++-- release/scripts/startup/bl_ui/space_toolsystem_common.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index 97fae2690fd..8f722c4d3ce 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -220,8 +220,8 @@ class OUTLINER_MT_object(Menu): if object_mode in {'EDIT', 'POSE'}: name = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode].name - layout.operator("outliner.object_operation", text=f"{name} Set").type = 'OBJECT_MODE_ENTER' - layout.operator("outliner.object_operation", text=f"{name} Clear").type = 'OBJECT_MODE_EXIT' + layout.operator("outliner.object_operation", text=f"{name:s} Set").type = 'OBJECT_MODE_ENTER' + layout.operator("outliner.object_operation", text=f"{name:s} Clear").type = 'OBJECT_MODE_EXIT' del name layout.separator() diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index ffd95ec7c64..9cc57bc2c87 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -293,7 +293,7 @@ class ToolSelectPanelHelper: def _km_action_simple(cls, kc, context_mode, text, keymap_fn): if context_mode is None: context_mode = "All" - km_idname = f"{cls.keymap_prefix} {context_mode}, {text}" + km_idname = f"{cls.keymap_prefix:s} {context_mode:s}, {text:s}" km = kc.keymaps.get(km_idname) if km is None: km = kc.keymaps.new(km_idname, space_type=cls.bl_space_type, region_type='WINDOW') -- cgit v1.2.3 From 50e3cd0bb3ffd92b7811887e99e69e581813c8ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 10:15:46 +0200 Subject: Keymap: option to export all keymaps Useful to store a snapshot of the current keymap state so changes to the default keymap are ignored. Also useful for testing keymap export works properly. --- release/scripts/modules/bpy_extras/keyconfig_utils.py | 8 +++++--- release/scripts/startup/bl_operators/wm.py | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index 3a9570a57c4..0ff6595eca9 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -296,8 +296,10 @@ def _kmistr(kmi, is_modal): return "".join(s) -def keyconfig_export(wm, kc, filepath): - +def keyconfig_export( + wm, kc, filepath, *, + all_keymaps=False, +): f = open(filepath, "w") f.write("import bpy\n") @@ -327,7 +329,7 @@ def keyconfig_export(wm, kc, filepath): keymaps = [] edited_kc = FakeKeyConfig() for km in wm.keyconfigs.user.keymaps: - if km.is_user_modified: + if all_keymaps or km.is_user_modified: edited_kc.keymaps.append(km) # merge edited keymaps with non-default keyconfig, if it exists if kc != wm.keyconfigs.default: diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 5b12f6196a4..238c34f6853 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1629,6 +1629,11 @@ class WM_OT_keyconfig_export(Operator): bl_idname = "wm.keyconfig_export" bl_label = "Export Key Configuration..." + all_keymaps = BoolProperty( + name="All Keymaps", + default=False, + description="Write all keymaps (not just user modified)", + ) filepath = StringProperty( subtype='FILE_PATH', default="keymap.py", @@ -1664,6 +1669,7 @@ class WM_OT_keyconfig_export(Operator): wm, wm.keyconfigs.active, self.filepath, + all_keymaps=self.all_keymaps, ) return {'FINISHED'} -- cgit v1.2.3 From ceba8e28b7d1d00e9201fc626a8cd936893ea9d7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 10:19:53 +0200 Subject: Rename operator property from last commit Restore operator had same option named differently. --- release/scripts/startup/bl_operators/wm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 238c34f6853..edca3a521ee 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1629,7 +1629,7 @@ class WM_OT_keyconfig_export(Operator): bl_idname = "wm.keyconfig_export" bl_label = "Export Key Configuration..." - all_keymaps = BoolProperty( + all = BoolProperty( name="All Keymaps", default=False, description="Write all keymaps (not just user modified)", @@ -1669,7 +1669,7 @@ class WM_OT_keyconfig_export(Operator): wm, wm.keyconfigs.active, self.filepath, - all_keymaps=self.all_keymaps, + all_keymaps=self.all, ) return {'FINISHED'} -- cgit v1.2.3 From f9aab3b091bcdc2b4f075022489ec231b44e7c29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 11:29:48 +0200 Subject: Keymap: reduce right shift in generated keymaps --- .../bpy_extras/keyconfig_utils_experimental.py | 52 +++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py b/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py index 6e7b0205a65..cd82460e8e0 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils_experimental.py @@ -25,7 +25,7 @@ __all__ = ( def indent(levels): - return levels * " " + return levels * " " def round_float_32(f): @@ -89,26 +89,26 @@ def _kmi_properties_to_lines_recursive(level, properties, lines): lines_test = [] _kmi_properties_to_lines_recursive(level + 2, value, lines_test) if lines_test: - lines.append(f"{indent(level)}(\n") - lines.append(f"{indent(level + 1)}\"{pname}\",\n") - lines.append(f"{indent(level + 1)}" "[\n") + lines.append(f"(") + lines.append(f"\"{pname}\",\n") + lines.append(f"{indent(level + 3)}" "[") lines.extend(lines_test) - lines.append(f"{indent(level + 1)}" "],\n") - lines.append(f"{indent(level)}" "),\n") + lines.append("],\n") + lines.append(f"{indent(level + 3)}" "),\n" f"{indent(level + 2)}") del lines_test elif properties.is_property_set(pname): value = string_value(value) - lines.append((f"{indent(level)}(\"{pname}\", {value:s}),\n")) + lines.append((f"(\"{pname}\", {value:s}),\n" f"{indent(level + 2)}")) def _kmi_properties_to_lines(level, kmi_props, lines): if kmi_props is None: return - lines_test = [f"{indent(level)}\"properties\": " "[\n"] - _kmi_properties_to_lines_recursive(level + 1, kmi_props, lines_test) + lines_test = [f"\"properties\":\n" f"{indent(level + 1)}" "["] + _kmi_properties_to_lines_recursive(level, kmi_props, lines_test) if len(lines_test) > 1: - lines_test.append(f"{indent(level)}" "],\n") + lines_test.append("],\n") lines.extend(lines_test) @@ -150,12 +150,12 @@ def keyconfig_export_as_data(wm, kc, filepath, *, all_keymaps=False): with open(filepath, "w") as fh: fw = fh.write - fw("keyconfig_data = [\n") + fw("keyconfig_data = \\\n[") for km, kc_x in export_keymaps: km = km.active() - fw(f"{indent(1)}" "(\n") - fw(f"{indent(2)}" f"\"{km.name:s}\",\n") + fw("(") + fw(f"\"{km.name:s}\",\n") fw(f"{indent(2)}" "{") fw(f"\"space_type\": '{km.space_type:s}'") fw(f", \"region_type\": '{km.region_type:s}'") @@ -163,20 +163,18 @@ def keyconfig_export_as_data(wm, kc, filepath, *, all_keymaps=False): if km.is_modal: fw(", \"modal\": True") fw("},\n") - fw(f"{indent(2)}" "{\n") + fw(f"{indent(2)}" "{") is_modal = km.is_modal - fw(f"{indent(3)}" "\"items\": [\n") + fw(f"\"items\":\n") + fw(f"{indent(3)}[") for kmi in km.keymap_items: if is_modal: kmi_id = kmi.propvalue else: kmi_id = kmi.idname - - fw(f"{indent(4)}" "(") + fw(f"(") kmi_args = kmi_args_as_data(kmi) - kmi_data = _kmi_attrs_or_none(5, kmi) - if kmi_data is not None: - fw("\n" f"{indent(5)}") + kmi_data = _kmi_attrs_or_none(4, kmi) fw(f"\"{kmi_id:s}\"") if kmi_data is None: fw(f", ") @@ -188,14 +186,16 @@ def keyconfig_export_as_data(wm, kc, filepath, *, all_keymaps=False): fw(", None),\n") else: fw(",\n") - fw(f"{indent(5)}" "{\n") + fw(f"{indent(5)}" "{") fw(kmi_data) - fw(f"{indent(5)}" "}\n") - fw(f"{indent(4)}" "),\n") + fw(f"{indent(6)}") + fw("},\n" f"{indent(5)}") + fw("),\n") + fw(f"{indent(4)}") + fw("],\n" f"{indent(3)}") + fw("},\n" f"{indent(2)}") + fw("),\n" f"{indent(1)}") - fw(f"{indent(3)}" "],\n") - fw(f"{indent(2)}" "},\n") - fw(f"{indent(1)}" "),\n") fw("]\n") fw("\n\n") fw("if __name__ == \"__main__\":\n") -- cgit v1.2.3 From bb2c47a3298876e0fe3048af54840c1335539dcb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 11:42:36 +0200 Subject: Keymap: reduce right shift in 2.7x keymap --- release/scripts/presets/keyconfig/blender_27x.py | 19389 +++++++++------------ 1 file changed, 8639 insertions(+), 10750 deletions(-) diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index e9f64183d9a..c71b7456cff 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -1,10753 +1,8642 @@ -keyconfig_data = [ - ( - "Window", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("wm.window_new", {"type": 'W', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("wm.read_homefile", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), - ("wm.save_homefile", {"type": 'U', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'O', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("name", 'INFO_MT_file_open_recent'), - ], - } - ), - ("wm.open_mainfile", {"type": 'O', "value": 'PRESS', "ctrl": True}, None), - ("wm.open_mainfile", {"type": 'F1', "value": 'PRESS'}, None), - ("wm.link", {"type": 'O', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("wm.append", {"type": 'F1', "value": 'PRESS', "shift": True}, None), - ("wm.save_mainfile", {"type": 'S', "value": 'PRESS', "ctrl": True}, None), - ("wm.save_mainfile", {"type": 'W', "value": 'PRESS', "ctrl": True}, None), - ("wm.save_as_mainfile", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("wm.save_as_mainfile", {"type": 'F2', "value": 'PRESS'}, None), - ( - "wm.save_as_mainfile", - {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("copy", True), - ], - } - ), - ("wm.window_fullscreen_toggle", {"type": 'F11', "value": 'PRESS', "alt": True}, None), - ("wm.quit_blender", {"type": 'Q', "value": 'PRESS', "ctrl": True}, None), - ("wm.doc_view_manual_ui_context", {"type": 'F1', "value": 'PRESS', "alt": True}, None), - ("wm.redraw_timer", {"type": 'T', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("wm.debug_menu", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ( - "wm.call_menu", - {"type": 'NDOF_BUTTON_MENU', "value": 'PRESS'}, - { - "properties": [ - ("name", 'USERPREF_MT_ndof_settings'), - ], - } - ), - ("wm.search_menu", {"type": 'SPACE', "value": 'PRESS'}, None), - ( - "wm.context_set_enum", - {"type": 'F3', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'NODE_EDITOR'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F4', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'CONSOLE'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F5', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'VIEW_3D'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F6', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'GRAPH_EDITOR'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F7', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'PROPERTIES'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F8', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'SEQUENCE_EDITOR'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F9', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'OUTLINER'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F10', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'IMAGE_EDITOR'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F11', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'TEXT_EDITOR'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'F12', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'area.type'), - ("value", 'DOPESHEET_EDITOR'), - ], - } - ), - ( - "wm.context_scale_float", - {"type": 'NDOF_BUTTON_PLUS', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'user_preferences.inputs.ndof_sensitivity'), - ("value", 1.1), - ], - } - ), - ( - "wm.context_scale_float", - {"type": 'NDOF_BUTTON_MINUS', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'user_preferences.inputs.ndof_sensitivity'), - ("value", 1.0), - ], - } - ), - ( - "wm.context_scale_float", - {"type": 'NDOF_BUTTON_PLUS', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'user_preferences.inputs.ndof_sensitivity'), - ("value", 1.5), - ], - } - ), - ( - "wm.context_scale_float", - {"type": 'NDOF_BUTTON_MINUS', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'user_preferences.inputs.ndof_sensitivity'), - ("value", 0.6666667), - ], - } - ), - ("info.reports_display_update", {"type": 'TIMER_REPORT', "value": 'ANY', "any": True}, None), - ], - }, - ), - ( - "Screen", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("screen.animation_step", {"type": 'TIMER0', "value": 'ANY', "any": True}, None), - ("screen.region_blend", {"type": 'TIMERREGION', "value": 'ANY', "any": True}, None), - ( - "screen.screen_set", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "screen.screen_set", - {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ("screen.screen_full_area", {"type": 'SPACE', "value": 'PRESS', "shift": True}, None), - ( - "screen.screen_full_area", - {"type": 'SPACE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("use_hide_panels", True), - ], - } - ), - ("screen.screenshot", {"type": 'F3', "value": 'PRESS', "ctrl": True}, None), - ("screen.screencast", {"type": 'F3', "value": 'PRESS', "alt": True}, None), - ( - "screen.space_context_cycle", - {"type": 'TAB', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("direction", 'NEXT'), - ], - } - ), - ( - "screen.space_context_cycle", - {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("direction", 'PREV'), - ], - } - ), - ("screen.region_quadview", {"type": 'Q', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("screen.repeat_history", {"type": 'F3', "value": 'PRESS'}, None), - ("screen.repeat_last", {"type": 'R', "value": 'PRESS', "shift": True}, None), - ("screen.region_flip", {"type": 'F5', "value": 'PRESS'}, None), - ("screen.redo_last", {"type": 'F6', "value": 'PRESS'}, None), - ("script.reload", {"type": 'F8', "value": 'PRESS'}, None), - ("file.execute", {"type": 'RET', "value": 'PRESS'}, None), - ("file.execute", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), - ("file.cancel", {"type": 'ESC', "value": 'PRESS'}, None), - ("ed.undo", {"type": 'Z', "value": 'PRESS', "ctrl": True}, None), - ("ed.redo", {"type": 'Z', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("ed.undo_history", {"type": 'Z', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ( - "render.render", - {"type": 'F12', "value": 'PRESS'}, - { - "properties": [ - ("use_viewport", True), - ], - } - ), - ( - "render.render", - {"type": 'F12', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("animation", True), - ("use_viewport", True), - ], - } - ), - ("render.view_cancel", {"type": 'ESC', "value": 'PRESS'}, None), - ("render.view_show", {"type": 'F11', "value": 'PRESS'}, None), - ("render.play_rendered_anim", {"type": 'F11', "value": 'PRESS', "ctrl": True}, None), - ("screen.userpref_show", {"type": 'U', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ], - }, - ), - ( - "User Interface", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("ui.eyedropper_color", {"type": 'E', "value": 'PRESS'}, None), - ("ui.eyedropper_colorband", {"type": 'E', "value": 'PRESS'}, None), - ("ui.eyedropper_colorband_point", {"type": 'E', "value": 'PRESS', "alt": True}, None), - ("ui.eyedropper_id", {"type": 'E', "value": 'PRESS'}, None), - ("ui.eyedropper_depth", {"type": 'E', "value": 'PRESS'}, None), - ("ui.copy_data_path_button", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "ui.copy_data_path_button", - {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("full_path", True), - ], - } - ), - ("anim.keyframe_insert_button", {"type": 'I', "value": 'PRESS'}, None), - ("anim.keyframe_delete_button", {"type": 'I', "value": 'PRESS', "alt": True}, None), - ("anim.keyframe_clear_button", {"type": 'I', "value": 'PRESS', "shift": True, "alt": True}, None), - ("anim.driver_button_add", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), - ("anim.driver_button_remove", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("anim.keyingset_button_add", {"type": 'K', "value": 'PRESS'}, None), - ("anim.keyingset_button_remove", {"type": 'K', "value": 'PRESS', "alt": True}, None), - ], - }, - ), - ( - "View2D", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("view2d.scroller_activate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("view2d.scroller_activate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), - ("view2d.pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ("view2d.scroll_right", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("view2d.scroll_left", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None), - ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None), - ("view2d.ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), - ("view2d.zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), - ("view2d.zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), - ("view2d.zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), - ("view2d.zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), - ("view2d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), - ("view2d.smoothview", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), - ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), - ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), - ("view2d.scroll_right", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), - ("view2d.scroll_left", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), - ("view2d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("view2d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), - ("view2d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), - ], - }, - ), - ( - "Header", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("screen.header_toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), - ], - }, - ), - ( - "View2D Buttons List", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("view2d.scroller_activate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("view2d.scroller_activate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("view2d.pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), - ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), - ( - "view2d.scroll_down", - {"type": 'PAGE_DOWN', "value": 'PRESS'}, - { - "properties": [ - ("page", True), - ], - } - ), - ( - "view2d.scroll_up", - {"type": 'PAGE_UP', "value": 'PRESS'}, - { - "properties": [ - ("page", True), - ], - } - ), - ("view2d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("view2d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), - ("view2d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), - ("view2d.zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), - ("view2d.zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), - ("view2d.reset", {"type": 'HOME', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Frames", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "screen.frame_offset", - {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("delta", 10), - ], - } - ), - ( - "screen.frame_offset", - {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("delta", -10), - ], - } - ), - ( - "screen.frame_offset", - {"type": 'LEFT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ( - "screen.frame_offset", - {"type": 'RIGHT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "screen.frame_offset", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "screen.frame_offset", - {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ( - "screen.frame_jump", - {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("end", True), - ], - } - ), - ( - "screen.frame_jump", - {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("end", False), - ], - } - ), - ( - "screen.frame_jump", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("end", True), - ], - } - ), - ( - "screen.frame_jump", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("end", False), - ], - } - ), - ( - "screen.keyframe_jump", - {"type": 'UP_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("next", True), - ], - } - ), - ( - "screen.keyframe_jump", - {"type": 'DOWN_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("next", False), - ], - } - ), - ( - "screen.keyframe_jump", - {"type": 'MEDIA_LAST', "value": 'PRESS'}, - { - "properties": [ - ("next", True), - ], - } - ), - ( - "screen.keyframe_jump", - {"type": 'MEDIA_FIRST', "value": 'PRESS'}, - { - "properties": [ - ("next", False), - ], - } - ), - ("screen.animation_play", {"type": 'A', "value": 'PRESS', "alt": True}, None), - ( - "screen.animation_play", - {"type": 'A', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("reverse", True), - ], - } - ), - ("screen.animation_cancel", {"type": 'ESC', "value": 'PRESS'}, None), - ("screen.animation_play", {"type": 'MEDIA_PLAY', "value": 'PRESS'}, None), - ("screen.animation_cancel", {"type": 'MEDIA_STOP', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Property Editor", - {"space_type": 'PROPERTIES', "region_type": 'WINDOW'}, - { - "items": [ - ("buttons.toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Info", - {"space_type": 'INFO', "region_type": 'WINDOW'}, - { - "items": [ - ("info.select_pick", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), - ("info.select_all_toggle", {"type": 'A', "value": 'PRESS'}, None), - ("info.select_border", {"type": 'B', "value": 'PRESS'}, None), - ("info.report_replay", {"type": 'R', "value": 'PRESS'}, None), - ("info.report_delete", {"type": 'X', "value": 'PRESS'}, None), - ("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None), - ("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "Outliner", - {"space_type": 'OUTLINER', "region_type": 'WINDOW'}, - { - "items": [ - ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), - ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), - ( - "outliner.item_activate", - {"type": 'LEFTMOUSE', "value": 'CLICK'}, - { - "properties": [ - ("extend", False), - ("recursive", False), - ], - } - ), - ( - "outliner.item_activate", - {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, - { - "properties": [ - ("extend", True), - ("recursive", False), - ], - } - ), - ( - "outliner.item_activate", - {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True}, - { - "properties": [ - ("extend", False), - ("recursive", True), - ], - } - ), - ( - "outliner.item_activate", - {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ("recursive", True), - ], - } - ), - ("outliner.select_border", {"type": 'B', "value": 'PRESS'}, None), - ( - "outliner.item_openclose", - {"type": 'RET', "value": 'PRESS'}, - { - "properties": [ - ("all", False), - ], - } - ), - ( - "outliner.item_openclose", - {"type": 'RET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("all", True), - ], - } - ), - ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("outliner.operation", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), - ("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), - ("outliner.show_hierarchy", {"type": 'HOME', "value": 'PRESS'}, None), - ("outliner.show_active", {"type": 'PERIOD', "value": 'PRESS'}, None), - ("outliner.show_active", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ( - "outliner.scroll_page", - {"type": 'PAGE_DOWN', "value": 'PRESS'}, - { - "properties": [ - ("up", False), - ], - } - ), - ( - "outliner.scroll_page", - {"type": 'PAGE_UP', "value": 'PRESS'}, - { - "properties": [ - ("up", True), - ], - } - ), - ("outliner.show_one_level", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), - ( - "outliner.show_one_level", - {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, - { - "properties": [ - ("open", False), - ], - } - ), - ( - "outliner.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ("outliner.expanded_toggle", {"type": 'A', "value": 'PRESS', "shift": True}, None), - ("outliner.keyingset_add_selected", {"type": 'K', "value": 'PRESS'}, None), - ("outliner.keyingset_remove_selected", {"type": 'K', "value": 'PRESS', "alt": True}, None), - ("anim.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), - ("anim.keyframe_delete", {"type": 'I', "value": 'PRESS', "alt": True}, None), - ("outliner.drivers_add_selected", {"type": 'D', "value": 'PRESS'}, None), - ("outliner.drivers_delete_selected", {"type": 'D', "value": 'PRESS', "alt": True}, None), - ("outliner.collection_new", {"type": 'C', "value": 'PRESS'}, None), - ("outliner.collection_delete", {"type": 'X', "value": 'PRESS'}, None), - ], - }, - ), - ( - "3D View Generic", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("view3d.properties", {"type": 'N', "value": 'PRESS'}, None), - ("view3d.toolshelf", {"type": 'T', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Grease Pencil", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "gpencil.draw", - {"type": 'LEFTMOUSE', "value": 'PRESS', "key_modifier": 'D'}, - { - "properties": [ - ("mode", 'DRAW'), - ("wait_for_input", False), - ], - } - ), - ( - "gpencil.draw", - {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'D'}, - { - "properties": [ - ("mode", 'DRAW_STRAIGHT'), - ("wait_for_input", False), - ], - } - ), - ( - "gpencil.draw", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'D'}, - { - "properties": [ - ("mode", 'DRAW_POLY'), - ("wait_for_input", False), - ], - } - ), - ( - "gpencil.draw", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "key_modifier": 'D'}, - { - "properties": [ - ("mode", 'ERASER'), - ("wait_for_input", False), - ], - } - ), - ( - "gpencil.draw", - {"type": 'ERASER', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'ERASER'), - ("wait_for_input", False), - ], - } - ), - ("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS', "key_modifier": 'D'}, None), - ( - "wm.call_menu_pie", - {"type": 'Q', "value": 'PRESS', "key_modifier": 'D'}, - { - "properties": [ - ("name", 'GPENCIL_MT_pie_tool_palette'), - ], - } - ), - ( - "wm.call_menu_pie", - {"type": 'W', "value": 'PRESS', "key_modifier": 'D'}, - { - "properties": [ - ("name", 'GPENCIL_MT_pie_settings_palette'), - ], - } - ), - ("gpencil.blank_frame_add", {"type": 'B', "value": 'PRESS', "key_modifier": 'D'}, None), - ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "key_modifier": 'D'}, None), - ], - }, - ), - ( - "Grease Pencil Stroke Edit Mode", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS'}, None), - ( - "wm.call_menu_pie", - {"type": 'E', "value": 'PRESS', "key_modifier": 'D'}, - { - "properties": [ - ("name", 'GPENCIL_MT_pie_sculpt'), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path_primary", 'user_preferences.edit.grease_pencil_eraser_radius'), - ], - } - ), - ("gpencil.interpolate", {"type": 'E', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("gpencil.interpolate_sequence", {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "gpencil.brush_paint", - {"type": 'LEFTMOUSE', "value": 'PRESS', "key_modifier": 'E'}, - { - "properties": [ - ("wait_for_input", False), - ], - } - ), - ( - "gpencil.brush_paint", - {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'E'}, - { - "properties": [ - ("wait_for_input", False), - ], - } - ), - ( - "gpencil.brush_paint", - {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "key_modifier": 'E'}, - { - "properties": [ - ("wait_for_input", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.gpencil_sculpt.brush.strength'), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("data_path_primary", 'tool_settings.gpencil_sculpt.brush.size'), - ], - } - ), - ( - "gpencil.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "gpencil.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("gpencil.select_circle", {"type": 'C', "value": 'PRESS'}, None), - ("gpencil.select_border", {"type": 'B', "value": 'PRESS'}, None), - ( - "gpencil.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "gpencil.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ( - "gpencil.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "gpencil.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("gpencil.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), - ( - "gpencil.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ("toggle", True), - ], - } - ), - ( - "gpencil.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("entire_strokes", True), - ], - } - ), - ("gpencil.select_linked", {"type": 'L', "value": 'PRESS'}, None), - ("gpencil.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), - ("gpencil.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), - ("gpencil.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("gpencil.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ( - "wm.call_menu", - {"type": 'X', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_gpencil_delete'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_gpencil_delete'), - ], - } - ), - ("gpencil.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), - ("gpencil.dissolve", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), - ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "shift": True}, None), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'GPENCIL_MT_gpencil_edit_specials'), - ], - } - ), - ("gpencil.stroke_join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), - ( - "gpencil.stroke_join", - {"type": 'J', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'JOINCOPY'), - ], - } - ), - ("gpencil.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("gpencil.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'S', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'GPENCIL_MT_snap'), - ], - } - ), - ("gpencil.convert", {"type": 'C', "value": 'PRESS', "alt": True}, None), - ("gpencil.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ( - "gpencil.hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "gpencil.hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("gpencil.selection_opacity_toggle", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), - ("gpencil.layer_isolate", {"type": 'NUMPAD_ASTERIX', "value": 'PRESS'}, None), - ("gpencil.move_to_layer", {"type": 'M', "value": 'PRESS'}, None), - ( - "gpencil.brush_select", - {"type": 'ONE', "value": 'PRESS'}, - { - "properties": [ - ("index", 0), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'TWO', "value": 'PRESS'}, - { - "properties": [ - ("index", 1), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'THREE', "value": 'PRESS'}, - { - "properties": [ - ("index", 2), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'FOUR', "value": 'PRESS'}, - { - "properties": [ - ("index", 3), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'FIVE', "value": 'PRESS'}, - { - "properties": [ - ("index", 4), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'SIX', "value": 'PRESS'}, - { - "properties": [ - ("index", 5), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'SEVEN', "value": 'PRESS'}, - { - "properties": [ - ("index", 6), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'EIGHT', "value": 'PRESS'}, - { - "properties": [ - ("index", 7), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'NINE', "value": 'PRESS'}, - { - "properties": [ - ("index", 8), - ], - } - ), - ( - "gpencil.brush_select", - {"type": 'ZERO', "value": 'PRESS'}, - { - "properties": [ - ("index", 9), - ], - } - ), - ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), - ("transform.bend", {"type": 'W', "value": 'PRESS', "shift": True}, None), - ("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None), - ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ( - "transform.transform", - {"type": 'S', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'GPENCIL_SHRINKFATTEN'), - ], - } - ), - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'ENABLED'), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'CONNECTED'), - ], - } - ), - ], - }, - ), - ( - "Face Mask", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "paint.face_select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "paint.face_select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ( - "paint.face_select_hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "paint.face_select_hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("paint.face_select_reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ("paint.face_select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), - ( - "paint.face_select_linked_pick", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "paint.face_select_linked_pick", - {"type": 'L', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ], - }, - ), - ( - "Weight Paint Vertex Selection", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "paint.vert_select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "paint.vert_select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("view3d.select_border", {"type": 'B', "value": 'PRESS'}, None), - ( - "view3d.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "view3d.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Pose", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'INFO_MT_add'), - ], - } - ), - ( - "pose.hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "pose.hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("pose.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_pose_apply'), - ], - } - ), - ("pose.rot_clear", {"type": 'R', "value": 'PRESS', "alt": True}, None), - ("pose.loc_clear", {"type": 'G', "value": 'PRESS', "alt": True}, None), - ("pose.scale_clear", {"type": 'S', "value": 'PRESS', "alt": True}, None), - ("pose.quaternions_flip", {"type": 'F', "value": 'PRESS', "alt": True}, None), - ("pose.rotation_mode_set", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), - ("pose.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ( - "pose.paste", - {"type": 'V', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("flipped", False), - ], - } - ), - ( - "pose.paste", - {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("flipped", True), - ], - } - ), - ( - "pose.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "pose.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("pose.select_parent", {"type": 'P', "value": 'PRESS', "shift": True}, None), - ( - "pose.select_hierarchy", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'PARENT'), - ("extend", False), - ], - } - ), - ( - "pose.select_hierarchy", - {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'PARENT'), - ("extend", True), - ], - } - ), - ( - "pose.select_hierarchy", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'CHILD'), - ("extend", False), - ], - } - ), - ( - "pose.select_hierarchy", - {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'CHILD'), - ("extend", True), - ], - } - ), - ("pose.select_linked", {"type": 'L', "value": 'PRESS'}, None), - ("pose.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), - ("pose.select_mirror", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("pose.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("pose.constraints_clear", {"type": 'C', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("pose.ik_add", {"type": 'I', "value": 'PRESS', "shift": True}, None), - ("pose.ik_clear", {"type": 'I', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ( - "wm.call_menu", - {"type": 'G', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_pose_group'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_bone_options_toggle'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_bone_options_enable'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_bone_options_disable'), - ], - } - ), - ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None), - ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None), - ("pose.bone_layers", {"type": 'M', "value": 'PRESS'}, None), - ( - "wm.context_toggle", - {"type": 'Z', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.overlay.show_bone_select'), - ], - } - ), - - ( - "transform.transform", - {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("mode", 'BONE_SIZE'), - ], - } - ), - ("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None), - ("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None), - ("anim.keying_set_active_set", {"type": 'I', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ("poselib.browse_interactive", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), - ("poselib.pose_add", {"type": 'L', "value": 'PRESS', "shift": True}, None), - ("poselib.pose_remove", {"type": 'L', "value": 'PRESS', "alt": True}, None), - ("poselib.pose_rename", {"type": 'L', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("pose.push", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), - ("pose.relax", {"type": 'E', "value": 'PRESS', "alt": True}, None), - ("pose.breakdown", {"type": 'E', "value": 'PRESS', "shift": True}, None), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_pose_specials'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'P', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_pose_propagate'), - ], - } - ), - ], - }, - ), - ( - "Object Mode", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.use_proportional_edit_objects'), - ], - } - ), - ( - "object.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "object.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("object.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("object.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("object.select_linked", {"type": 'L', "value": 'PRESS', "shift": True}, None), - ("object.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), - ("object.select_mirror", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "object.select_hierarchy", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'PARENT'), - ("extend", False), - ], - } - ), - ( - "object.select_hierarchy", - {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'PARENT'), - ("extend", True), - ], - } - ), - ( - "object.select_hierarchy", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'CHILD'), - ("extend", False), - ], - } - ), - ( - "object.select_hierarchy", - {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'CHILD'), - ("extend", True), - ], - } - ), - ("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ("object.parent_no_inverse_set", {"type": 'P', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("object.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), - ("object.track_set", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), - ("object.track_clear", {"type": 'T', "value": 'PRESS', "alt": True}, None), - ("object.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("object.constraints_clear", {"type": 'C', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ( - "object.location_clear", - {"type": 'G', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("clear_delta", False), - ], - } - ), - ( - "object.rotation_clear", - {"type": 'R', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("clear_delta", False), - ], - } - ), - ( - "object.scale_clear", - {"type": 'S', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("clear_delta", False), - ], - } - ), - ("object.origin_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None), - ( - "object.delete", - {"type": 'X', "value": 'PRESS'}, - { - "properties": [ - ("use_global", False), - ], - } - ), - ( - "object.delete", - {"type": 'X', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("use_global", True), - ], - } - ), - ( - "object.delete", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("use_global", False), - ], - } - ), - ( - "object.delete", - {"type": 'DEL', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("use_global", True), - ], - } - ), - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'INFO_MT_add'), - ], - } - ), - ("object.duplicates_make_real", {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_object_apply'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'U', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_make_single_user'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'L', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_make_links'), - ], - } - ), - ("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True}, None), - ("object.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), - ("object.convert", {"type": 'C', "value": 'PRESS', "alt": True}, None), - ("object.proxy_make", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("object.make_local", {"type": 'L', "value": 'PRESS'}, None), - ("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None), - ("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None), - ("anim.keying_set_active_set", {"type": 'I', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ("collection.create", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), - ("collection.objects_remove", {"type": 'G', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("collection.objects_remove_all", {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ("collection.objects_add_active", {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("collection.objects_remove_active", {"type": 'G', "value": 'PRESS', "shift": True, "alt": True}, None), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_object_specials'), - ], - } - ), - ("object.data_transfer", {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "object.subdivision_set", - {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 0), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'ONE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 1), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'TWO', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 2), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'THREE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 3), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 4), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 5), - ], - } - ), - ("object.move_to_collection", {"type": 'M', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Paint Curve", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("paintcurve.add_point_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("paintcurve.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), - ( - "paintcurve.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ("paintcurve.slide", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ( - "paintcurve.slide", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("align", True), - ], - } - ), - ( - "paintcurve.select", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("toggle", True), - ], - } - ), - ("paintcurve.cursor", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ("paintcurve.delete_point", {"type": 'X', "value": 'PRESS'}, None), - ("paintcurve.delete_point", {"type": 'DEL', "value": 'PRESS'}, None), - ("paintcurve.draw", {"type": 'RET', "value": 'PRESS'}, None), - ("paintcurve.draw", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Curve", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'INFO_MT_edit_curve_add'), - ], - } - ), - ("curve.handle_type_set", {"type": 'V', "value": 'PRESS'}, None), - ("curve.vertex_add", {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, None), - ( - "curve.draw", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("wait_for_input", False), - ], - } - ), - ( - "curve.draw", - {"type": 'PEN', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("wait_for_input", False), - ], - } - ), - ( - "curve.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "curve.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("curve.select_row", {"type": 'R', "value": 'PRESS', "shift": True}, None), - ("curve.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("curve.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("curve.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), - ("curve.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), - ( - "curve.select_linked_pick", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "curve.select_linked_pick", - {"type": 'L', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("curve.shortest_path_pick", {"type": 'SELECTMOUSE', "value": 'CLICK', "ctrl": True}, None), - ("curve.separate", {"type": 'P', "value": 'PRESS'}, None), - ("curve.split", {"type": 'Y', "value": 'PRESS'}, None), - ("curve.extrude_move", {"type": 'E', "value": 'PRESS'}, None), - ("curve.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("curve.make_segment", {"type": 'F', "value": 'PRESS'}, None), - ("curve.cyclic_toggle", {"type": 'C', "value": 'PRESS', "alt": True}, None), - ( - "wm.call_menu", - {"type": 'X', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_curve_delete'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_curve_delete'), - ], - } - ), - ("curve.dissolve_verts", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), - ("curve.dissolve_verts", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), - ("curve.tilt_clear", {"type": 'T', "value": 'PRESS', "alt": True}, None), - ("transform.tilt", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), - ( - "transform.transform", - {"type": 'S', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'CURVE_SHRINKFATTEN'), - ], - } - ), - ("curve.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ( - "curve.hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "curve.hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("curve.normals_make_consistent", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), - ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_curve_specials'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'H', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_hook'), - ], - } - ), - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'ENABLED'), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'CONNECTED'), - ], - } - ), - ], - }, - ), - ( - "Image Paint", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "paint.image_paint", - {"type": 'LEFTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'NORMAL'), - ], - } - ), - ( - "paint.image_paint", - {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'INVERT'), - ], - } - ), - ("paint.brush_colors_flip", {"type": 'X', "value": 'PRESS'}, None), - ("paint.grab_clone", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), - ("paint.sample_color", {"type": 'S', "value": 'PRESS'}, None), - ( - "brush.active_index_set", - {"type": 'ONE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 0), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'TWO', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 1), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'THREE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 2), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FOUR', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 3), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FIVE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 4), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SIX', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 5), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SEVEN', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 6), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'EIGHT', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 7), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'NINE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 8), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ZERO', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 9), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ONE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 10), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'TWO', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 11), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'THREE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 12), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FOUR', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 13), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FIVE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 14), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SIX', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 15), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SEVEN', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 16), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'EIGHT', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 17), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'NINE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 18), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ZERO', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'image_paint'), - ("index", 19), - ], - } - ), - ( - "brush.scale_size", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 0.9), - ], - } - ), - ( - "brush.scale_size", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 1.1111112), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("data_path_primary", 'tool_settings.image_paint.brush.size'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), - ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), - ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), - ("fill_color_path", 'tool_settings.image_paint.brush.color'), - ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), - ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), - ("zoom_path", 'space_data.zoom'), - ("image_id", 'tool_settings.image_paint.brush'), - ("secondary_tex", True), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.image_paint.brush.strength'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), - ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), - ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), - ("fill_color_path", 'tool_settings.image_paint.brush.color'), - ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), - ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), - ("zoom_path", ''), - ("image_id", 'tool_settings.image_paint.brush'), - ("secondary_tex", True), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.image_paint.brush.texture_slot.angle'), - ("data_path_secondary", ''), - ("use_secondary", ''), - ("rotation_path", 'tool_settings.image_paint.brush.texture_slot.angle'), - ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), - ("fill_color_path", 'tool_settings.image_paint.brush.color'), - ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), - ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), - ("zoom_path", ''), - ("image_id", 'tool_settings.image_paint.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), - ("data_path_secondary", ''), - ("use_secondary", ''), - ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), - ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), - ("fill_color_path", 'tool_settings.image_paint.brush.color'), - ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), - ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), - ("zoom_path", ''), - ("image_id", 'tool_settings.image_paint.brush'), - ("secondary_tex", True), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TRANSLATION'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'SCALE'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'ROTATION'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'TRANSLATION'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("mode", 'SCALE'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("mode", 'ROTATION'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'M', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'image_paint_object.data.use_paint_mask'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'S', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.image_paint.brush.use_smooth_stroke'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'R', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_angle_control'), - ], - } - ), - ( - "wm.context_menu_enum", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.image_paint.brush.stroke_method'), - ], - } - ), - ], - }, - ), - ( - "Vertex Paint", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("paint.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("paint.brush_colors_flip", {"type": 'X', "value": 'PRESS'}, None), - ("paint.sample_color", {"type": 'S', "value": 'PRESS'}, None), - ("paint.vertex_color_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), - ( - "brush.active_index_set", - {"type": 'ONE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 0), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'TWO', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 1), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'THREE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 2), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FOUR', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 3), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FIVE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 4), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SIX', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 5), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SEVEN', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 6), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'EIGHT', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 7), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'NINE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 8), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ZERO', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 9), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ONE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 10), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'TWO', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 11), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'THREE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 12), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FOUR', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 13), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FIVE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 14), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SIX', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 15), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SEVEN', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 16), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'EIGHT', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 17), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'NINE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 18), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ZERO', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'vertex_paint'), - ("index", 19), - ], - } - ), - ( - "brush.scale_size", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 0.9), - ], - } - ), - ( - "brush.scale_size", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 1.1111112), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("data_path_primary", 'tool_settings.vertex_paint.brush.size'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), - ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), - ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), - ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), - ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), - ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), - ("zoom_path", ''), - ("image_id", 'tool_settings.vertex_paint.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.vertex_paint.brush.strength'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), - ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), - ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), - ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), - ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), - ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), - ("zoom_path", ''), - ("image_id", 'tool_settings.vertex_paint.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.vertex_paint.brush.texture_slot.angle'), - ("data_path_secondary", ''), - ("use_secondary", ''), - ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), - ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), - ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), - ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), - ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), - ("zoom_path", ''), - ("image_id", 'tool_settings.vertex_paint.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TRANSLATION'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'SCALE'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'ROTATION'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'TRANSLATION'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("mode", 'SCALE'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("mode", 'ROTATION'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'M', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'vertex_paint_object.data.use_paint_mask'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'S', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.vertex_paint.brush.use_smooth_stroke'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'R', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_angle_control'), - ], - } - ), - ( - "wm.context_menu_enum", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.vertex_paint.brush.stroke_method'), - ], - } - ), - ], - }, - ), - ( - "Weight Paint", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("paint.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("paint.weight_sample", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("paint.weight_sample_group", {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, None), - ( - "paint.weight_gradient", - {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("type", 'LINEAR'), - ], - } - ), - ( - "paint.weight_gradient", - {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("type", 'RADIAL'), - ], - } - ), - ("paint.weight_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), - ( - "brush.active_index_set", - {"type": 'ONE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 0), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'TWO', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 1), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'THREE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 2), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FOUR', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 3), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FIVE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 4), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SIX', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 5), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SEVEN', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 6), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'EIGHT', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 7), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'NINE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 8), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ZERO', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 9), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ONE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 10), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'TWO', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 11), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'THREE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 12), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FOUR', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 13), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FIVE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 14), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SIX', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 15), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SEVEN', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 16), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'EIGHT', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 17), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'NINE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 18), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ZERO', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'weight_paint'), - ("index", 19), - ], - } - ), - ( - "brush.scale_size", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 0.9), - ], - } - ), - ( - "brush.scale_size", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 1.1111112), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("data_path_primary", 'tool_settings.weight_paint.brush.size'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), - ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), - ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), - ("fill_color_path", ''), - ("fill_color_override_path", ''), - ("fill_color_override_test_path", ''), - ("zoom_path", ''), - ("image_id", 'tool_settings.weight_paint.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.weight_paint.brush.strength'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), - ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), - ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), - ("fill_color_path", ''), - ("fill_color_override_path", ''), - ("fill_color_override_test_path", ''), - ("zoom_path", ''), - ("image_id", 'tool_settings.weight_paint.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("data_path_primary", 'tool_settings.weight_paint.brush.weight'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.weight'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_weight'), - ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), - ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), - ("fill_color_path", ''), - ("fill_color_override_path", ''), - ("fill_color_override_test_path", ''), - ("zoom_path", ''), - ("image_id", 'tool_settings.weight_paint.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.context_menu_enum", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.vertex_paint.brush.stroke_method'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'M', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'weight_paint_object.data.use_paint_mask'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'V', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'weight_paint_object.data.use_paint_mask_vertex'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'S', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.weight_paint.brush.use_smooth_stroke'), - ], - } - ), - ], - }, - ), - ( - "Sculpt", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "sculpt.brush_stroke", - {"type": 'LEFTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'NORMAL'), - ], - } - ), - ( - "sculpt.brush_stroke", - {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'INVERT'), - ], - } - ), - ( - "sculpt.brush_stroke", - {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'SMOOTH'), - ], - } - ), - ( - "paint.hide_show", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("action", 'SHOW'), - ("area", 'INSIDE'), - ], - } - ), - ( - "paint.hide_show", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("action", 'HIDE'), - ("area", 'INSIDE'), - ], - } - ), - ( - "paint.hide_show", - {"type": 'H', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("action", 'SHOW'), - ("area", 'ALL'), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 0), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'ONE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 1), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'TWO', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 2), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'THREE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 3), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 4), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 5), - ], - } - ), - ( - "paint.mask_flood_fill", - {"type": 'M', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'VALUE'), - ("value", 0.0), - ], - } - ), - ( - "paint.mask_flood_fill", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'INVERT'), - ], - } - ), - ("paint.mask_lasso_gesture", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "wm.context_toggle", - {"type": 'M', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'scene.tool_settings.sculpt.show_mask'), - ], - } - ), - ("sculpt.dynamic_topology_toggle", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), - ("sculpt.set_detail_size", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ( - "object.subdivision_set", - {"type": 'PAGE_UP', "value": 'PRESS'}, - { - "properties": [ - ("level", 1), - ("relative", True), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'PAGE_DOWN', "value": 'PRESS'}, - { - "properties": [ - ("level", -1), - ("relative", True), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ONE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 0), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'TWO', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 1), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'THREE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 2), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FOUR', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 3), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FIVE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 4), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SIX', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 5), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SEVEN', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 6), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'EIGHT', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 7), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'NINE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 8), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ZERO', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 9), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ONE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 10), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'TWO', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 11), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'THREE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 12), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FOUR', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 13), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'FIVE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 14), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SIX', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 15), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'SEVEN', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 16), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'EIGHT', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 17), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'NINE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 18), - ], - } - ), - ( - "brush.active_index_set", - {"type": 'ZERO', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'sculpt'), - ("index", 19), - ], - } - ), - ( - "brush.scale_size", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 0.9), - ], - } - ), - ( - "brush.scale_size", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 1.1111112), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("data_path_primary", 'tool_settings.sculpt.brush.size'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), - ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), - ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), - ("fill_color_path", ''), - ("fill_color_override_path", ''), - ("fill_color_override_test_path", ''), - ("zoom_path", ''), - ("image_id", 'tool_settings.sculpt.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.sculpt.brush.strength'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), - ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), - ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), - ("fill_color_path", ''), - ("fill_color_override_path", ''), - ("fill_color_override_test_path", ''), - ("zoom_path", ''), - ("image_id", 'tool_settings.sculpt.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.sculpt.brush.texture_slot.angle'), - ("data_path_secondary", ''), - ("use_secondary", ''), - ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), - ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), - ("fill_color_path", ''), - ("fill_color_override_path", ''), - ("fill_color_override_test_path", ''), - ("zoom_path", ''), - ("image_id", 'tool_settings.sculpt.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TRANSLATION'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'SCALE'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'ROTATION'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'TRANSLATION'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("mode", 'SCALE'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "brush.stencil_control", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("mode", 'ROTATION'), - ("texmode", 'SECONDARY'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'X', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'DRAW'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'S', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'SMOOTH'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'P', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'PINCH'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'I', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'INFLATE'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'G', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'GRAB'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'LAYER'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'T', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'FLATTEN'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'C', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'CLAY'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'C', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'CREASE'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'K', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'SNAKE_HOOK'), - ], - } - ), - ( - "paint.brush_select", - {"type": 'M', "value": 'PRESS'}, - { - "properties": [ - ("paint_mode", 'SCULPT'), - ("sculpt_tool", 'MASK'), - ("toggle", True), - ("create_missing", True), - ], - } - ), - ( - "wm.context_menu_enum", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.sculpt.brush.stroke_method'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'S', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.sculpt.brush.use_smooth_stroke'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'R', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_angle_control'), - ], - } - ), - ], - }, - ), - ( - "Mesh", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("mesh.loopcut_slide", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), - ("mesh.offset_edge_loops_slide", {"type": 'R', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("mesh.inset", {"type": 'I', "value": 'PRESS'}, None), - ("mesh.poke", {"type": 'P', "value": 'PRESS', "alt": True}, None), - ( - "mesh.bevel", - {"type": 'B', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("vertex_only", False), - ], - } - ), - ( - "mesh.bevel", - {"type": 'B', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("vertex_only", True), - ], - } - ), - ( - "mesh.loop_select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", False), - ], - } - ), - ( - "mesh.loop_select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", True), - ], - } - ), - ( - "mesh.edgering_select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", False), - ], - } - ), - ( - "mesh.edgering_select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", True), - ], - } - ), - ( - "mesh.shortest_path_pick", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("use_fill", False), - ], - } - ), - ( - "mesh.shortest_path_pick", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("use_fill", True), - ], - } - ), - ( - "mesh.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "mesh.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("mesh.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("mesh.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("mesh.select_next_item", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("mesh.select_prev_item", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("mesh.select_non_manifold", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ("mesh.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), - ( - "mesh.select_linked_pick", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "mesh.select_linked_pick", - {"type": 'L', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("mesh.faces_select_linked_flat", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ( - "wm.call_menu", - {"type": 'G', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_select_similar'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'TAB', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_select_mode'), - ], - } - ), - ( - "mesh.hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "mesh.hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("mesh.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ( - "mesh.normals_make_consistent", - {"type": 'N', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("inside", False), - ], - } - ), - ( - "mesh.normals_make_consistent", - {"type": 'N', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("inside", True), - ], - } - ), - ("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'}, None), - ( - "wm.call_menu", - {"type": 'E', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_extrude'), - ], - } - ), - ("transform.edge_crease", {"type": 'E', "value": 'PRESS', "shift": True}, None), - ("mesh.spin", {"type": 'R', "value": 'PRESS', "alt": True}, None), - ("mesh.fill", {"type": 'F', "value": 'PRESS', "alt": True}, None), - ("mesh.beautify_fill", {"type": 'F', "value": 'PRESS', "shift": True, "alt": True}, None), - ( - "mesh.quads_convert_to_tris", - {"type": 'T', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("quad_method", 'BEAUTY'), - ("ngon_method", 'BEAUTY'), - ], - } - ), - ( - "mesh.quads_convert_to_tris", - {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("quad_method", 'FIXED'), - ("ngon_method", 'CLIP'), - ], - } - ), - ("mesh.tris_convert_to_quads", {"type": 'J', "value": 'PRESS', "alt": True}, None), - ( - "mesh.rip_move", - {"type": 'V', "value": 'PRESS'}, - { - "properties": [ - ( - "MESH_OT_rip", - [ - ("use_fill", False), - ], - ), - ], - } - ), - ( - "mesh.rip_move", - {"type": 'V', "value": 'PRESS', "alt": True}, - { - "properties": [ - ( - "MESH_OT_rip", - [ - ("use_fill", True), - ], - ), - ], - } - ), - ("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True}, None), - ("mesh.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None), - ("transform.shrink_fatten", {"type": 'S', "value": 'PRESS', "alt": True}, None), - ("mesh.edge_face_add", {"type": 'F', "value": 'PRESS'}, None), - ("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'INFO_MT_mesh_add'), - ], - } - ), - ("mesh.separate", {"type": 'P', "value": 'PRESS'}, None), - ("mesh.split", {"type": 'Y', "value": 'PRESS'}, None), - ("mesh.vert_connect_path", {"type": 'J', "value": 'PRESS'}, None), - ("transform.vert_slide", {"type": 'V', "value": 'PRESS', "shift": True}, None), - ( - "mesh.dupli_extrude_cursor", - {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, - { - "properties": [ - ("rotate_source", True), - ], - } - ), - ( - "mesh.dupli_extrude_cursor", - {"type": 'ACTIONMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, - { - "properties": [ - ("rotate_source", False), - ], - } - ), - ( - "wm.call_menu", - {"type": 'X', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_delete'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_delete'), - ], - } - ), - ("mesh.dissolve_mode", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), - ("mesh.dissolve_mode", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), - ( - "mesh.knife_tool", - {"type": 'K', "value": 'PRESS'}, - { - "properties": [ - ("use_occlude_geometry", True), - ("only_selected", False), - ], - } - ), - ( - "mesh.knife_tool", - {"type": 'K', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("use_occlude_geometry", False), - ("only_selected", True), - ], - } - ), - ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_specials'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'F', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_faces'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'E', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_edges'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'V', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_mesh_vertices'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'H', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_hook'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'U', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_uv_map'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'G', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_vertex_group'), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 0), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'ONE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 1), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'TWO', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 2), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'THREE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 3), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 4), - ], - } - ), - ( - "object.subdivision_set", - {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("level", 5), - ], - } - ), - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'ENABLED'), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'CONNECTED'), - ], - } - ), - ], - }, - ), - ( - "Armature", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "armature.hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "armature.hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("armature.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ("armature.align", {"type": 'A', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("armature.calculate_roll", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), - ("armature.roll_clear", {"type": 'R', "value": 'PRESS', "alt": True}, None), - ("armature.switch_direction", {"type": 'F', "value": 'PRESS', "alt": True}, None), - ("armature.bone_primitive_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), - ("armature.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ("armature.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), - ( - "armature.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "armature.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ( - "armature.select_mirror", - {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "armature.select_hierarchy", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'PARENT'), - ("extend", False), - ], - } - ), - ( - "armature.select_hierarchy", - {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'PARENT'), - ("extend", True), - ], - } - ), - ( - "armature.select_hierarchy", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'CHILD'), - ("extend", False), - ], - } - ), - ( - "armature.select_hierarchy", - {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'CHILD'), - ("extend", True), - ], - } - ), - ("armature.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("armature.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("armature.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), - ("armature.select_linked", {"type": 'L', "value": 'PRESS'}, None), - ("armature.shortest_path_pick", {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'X', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_armature_delete'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_edit_armature_delete'), - ], - } - ), - ("armature.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), - ("armature.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("armature.extrude_move", {"type": 'E', "value": 'PRESS'}, None), - ("armature.extrude_forked", {"type": 'E', "value": 'PRESS', "shift": True}, None), - ("armature.click_extrude", {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, None), - ("armature.fill", {"type": 'F', "value": 'PRESS'}, None), - ("armature.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None), - ("armature.split", {"type": 'Y', "value": 'PRESS'}, None), - ("armature.separate", {"type": 'P', "value": 'PRESS'}, None), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_bone_options_toggle'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_bone_options_enable'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_bone_options_disable'), - ], - } - ), - ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None), - ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None), - ("armature.bone_layers", {"type": 'M', "value": 'PRESS'}, None), - ( - "transform.transform", - {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("mode", 'BONE_SIZE'), - ], - } - ), - ( - "transform.transform", - {"type": 'S', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'BONE_ENVELOPE'), - ], - } - ), - ( - "transform.transform", - {"type": 'R', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'BONE_ROLL'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_armature_specials'), - ], - } - ), - ], - }, - ), - ( - "Metaball", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("object.metaball_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), - ("mball.reveal_metaelems", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ( - "mball.hide_metaelems", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "mball.hide_metaelems", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("mball.delete_metaelems", {"type": 'X', "value": 'PRESS'}, None), - ("mball.delete_metaelems", {"type": 'DEL', "value": 'PRESS'}, None), - ("mball.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ( - "mball.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "mball.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("mball.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'ENABLED'), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'CONNECTED'), - ], - } - ), - ], - }, - ), - ( - "Lattice", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "lattice.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "lattice.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("lattice.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("lattice.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ("lattice.flip", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'H', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_hook'), - ], - } - ), - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'ENABLED'), - ], - } - ), - ], - }, - ), - ( - "Particle", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "particle.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "particle.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("particle.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("particle.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ( - "particle.select_linked", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "particle.select_linked", - {"type": 'L', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("particle.delete", {"type": 'X', "value": 'PRESS'}, None), - ("particle.delete", {"type": 'DEL', "value": 'PRESS'}, None), - ("particle.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ( - "particle.hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "particle.hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("particle.brush_edit", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("particle.brush_edit", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("data_path_primary", 'tool_settings.particle_edit.brush.size'), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.particle_edit.brush.strength'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'VIEW3D_MT_particle_specials'), - ], - } - ), - ("particle.weight_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'ENABLED'), - ], - } - ), - ], - }, - ), - ( - "Font", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "font.style_toggle", - {"type": 'B', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("style", 'BOLD'), - ], - } - ), - ( - "font.style_toggle", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("style", 'ITALIC'), - ], - } - ), - ( - "font.style_toggle", - {"type": 'U', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("style", 'UNDERLINE'), - ], - } - ), - ( - "font.style_toggle", - {"type": 'P', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("style", 'SMALL_CAPS'), - ], - } - ), - ( - "font.delete", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_OR_SELECTION'), - ], - } - ), - ( - "font.delete", - {"type": 'DEL', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'NEXT_WORD'), - ], - } - ), - ( - "font.delete", - {"type": 'BACK_SPACE', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_OR_SELECTION'), - ], - } - ), - ( - "font.delete", - {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_OR_SELECTION'), - ], - } - ), - ( - "font.delete", - {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PREVIOUS_WORD'), - ], - } - ), - ( - "font.move", - {"type": 'HOME', "value": 'PRESS'}, - { - "properties": [ - ("type", 'LINE_BEGIN'), - ], - } - ), - ( - "font.move", - {"type": 'END', "value": 'PRESS'}, - { - "properties": [ - ("type", 'LINE_END'), - ], - } - ), - ( - "font.move", - {"type": 'LEFT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "font.move", - {"type": 'RIGHT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_CHARACTER'), - ], - } - ), - ( - "font.move", - {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PREVIOUS_WORD'), - ], - } - ), - ( - "font.move", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'NEXT_WORD'), - ], - } - ), - ( - "font.move", - {"type": 'UP_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_LINE'), - ], - } - ), - ( - "font.move", - {"type": 'DOWN_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_LINE'), - ], - } - ), - ( - "font.move", - {"type": 'PAGE_UP', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_PAGE'), - ], - } - ), - ( - "font.move", - {"type": 'PAGE_DOWN', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_PAGE'), - ], - } - ), - ( - "font.move_select", - {"type": 'HOME', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'LINE_BEGIN'), - ], - } - ), - ( - "font.move_select", - {"type": 'END', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'LINE_END'), - ], - } - ), - ( - "font.move_select", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "font.move_select", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'NEXT_CHARACTER'), - ], - } - ), - ( - "font.move_select", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'PREVIOUS_WORD'), - ], - } - ), - ( - "font.move_select", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'NEXT_WORD'), - ], - } - ), - ( - "font.move_select", - {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_LINE'), - ], - } - ), - ( - "font.move_select", - {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'NEXT_LINE'), - ], - } - ), - ( - "font.move_select", - {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_PAGE'), - ], - } - ), - ( - "font.move_select", - {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'NEXT_PAGE'), - ], - } - ), - ( - "font.change_spacing", - {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ( - "font.change_spacing", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "font.change_character", - {"type": 'UP_ARROW', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "font.change_character", - {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ("font.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), - ("font.text_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("font.text_cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), - ("font.text_paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ("font.line_break", {"type": 'RET', "value": 'PRESS'}, None), - ("font.text_insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), - ( - "font.text_insert", - {"type": 'BACK_SPACE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("accent", True), - ], - } - ), - ], - }, - ), - ( - "Object Non-modal", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "object.mode_set", - {"type": 'TAB', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'EDIT'), - ("toggle", True), - ], - } - ), - ( - "object.mode_set", - {"type": 'TAB', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'POSE'), - ("toggle", True), - ], - } - ), - ( - "object.mode_set", - {"type": 'V', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'VERTEX_PAINT'), - ("toggle", True), - ], - } - ), - ( - "object.mode_set", - {"type": 'TAB', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'WEIGHT_PAINT'), - ("toggle", True), - ], - } - ), - ("object.origin_set", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ], - }, - ), - ( - "3D View", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("view3d.cursor3d", {"type": 'ACTIONMOUSE', "value": 'CLICK'}, None), - ("view3d.rotate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("view3d.move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), - ("view3d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("view3d.dolly", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "view3d.view_selected", - {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("use_all_regions", True), - ], - } - ), - ( - "view3d.view_selected", - {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, - { - "properties": [ - ("use_all_regions", False), - ], - } - ), - ("view3d.view_lock_to_active", {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "shift": True}, None), - ("view3d.view_lock_clear", {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "alt": True}, None), - ("view3d.navigate", {"type": 'F', "value": 'PRESS', "shift": True}, None), - ("view3d.smoothview", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), - ("view3d.rotate", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ("view3d.rotate", {"type": 'MOUSEROTATE', "value": 'ANY'}, None), - ("view3d.move", {"type": 'TRACKPADPAN', "value": 'ANY', "shift": True}, None), - ("view3d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), - ("view3d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), - ( - "view3d.zoom", - {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "view3d.zoom", - {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ( - "view3d.zoom", - {"type": 'EQUAL', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "view3d.zoom", - {"type": 'MINUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ( - "view3d.zoom", - {"type": 'WHEELINMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "view3d.zoom", - {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ( - "view3d.dolly", - {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "view3d.dolly", - {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ( - "view3d.dolly", - {"type": 'EQUAL', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("delta", 1), - ], - } - ), - ( - "view3d.dolly", - {"type": 'MINUS', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("delta", -1), - ], - } - ), - ("view3d.zoom_camera_1_to_1", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None), - ("view3d.view_center_camera", {"type": 'HOME', "value": 'PRESS'}, None), - ("view3d.view_center_lock", {"type": 'HOME', "value": 'PRESS'}, None), - ("view3d.view_center_cursor", {"type": 'HOME', "value": 'PRESS', "alt": True}, None), - ("view3d.view_center_pick", {"type": 'F', "value": 'PRESS', "alt": True}, None), - ( - "view3d.view_all", - {"type": 'HOME', "value": 'PRESS'}, - { - "properties": [ - ("center", False), - ], - } - ), - ( - "view3d.view_all", - {"type": 'HOME', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("use_all_regions", True), - ("center", False), - ], - } - ), - ( - "view3d.view_all", - {"type": 'C', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("center", True), - ], - } - ), - ("view3d.view_camera", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), - ( - "view3d.view_axis", - {"type": 'NUMPAD_1', "value": 'PRESS'}, - { - "properties": [ - ("type", 'FRONT'), - ], - } - ), - ( - "view3d.view_orbit", - {"type": 'NUMPAD_2', "value": 'PRESS'}, - { - "properties": [ - ("type", 'ORBITDOWN'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_3', "value": 'PRESS'}, - { - "properties": [ - ("type", 'RIGHT'), - ], - } - ), - ( - "view3d.view_orbit", - {"type": 'NUMPAD_4', "value": 'PRESS'}, - { - "properties": [ - ("type", 'ORBITLEFT'), - ], - } - ), - ("view3d.view_persportho", {"type": 'NUMPAD_5', "value": 'PRESS'}, None), - ( - "view3d.view_orbit", - {"type": 'NUMPAD_6', "value": 'PRESS'}, - { - "properties": [ - ("type", 'ORBITRIGHT'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_7', "value": 'PRESS'}, - { - "properties": [ - ("type", 'TOP'), - ], - } - ), - ( - "view3d.view_orbit", - {"type": 'NUMPAD_8', "value": 'PRESS'}, - { - "properties": [ - ("type", 'ORBITUP'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_1', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'BACK'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_3', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'LEFT'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_7', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'BOTTOM'), - ], - } - ), - ( - "view3d.view_pan", - {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PANDOWN'), - ], - } - ), - ( - "view3d.view_pan", - {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PANLEFT'), - ], - } - ), - ( - "view3d.view_pan", - {"type": 'NUMPAD_6', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PANRIGHT'), - ], - } - ), - ( - "view3d.view_pan", - {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PANUP'), - ], - } - ), - ( - "view3d.view_roll", - {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'LEFT'), - ], - } - ), - ( - "view3d.view_roll", - {"type": 'NUMPAD_6', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'RIGHT'), - ], - } - ), - ( - "view3d.view_orbit", - {"type": 'NUMPAD_9', "value": 'PRESS'}, - { - "properties": [ - ("angle", 3.1415927), - ("type", 'ORBITRIGHT'), - ], - } - ), - ( - "view3d.view_pan", - {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PANRIGHT'), - ], - } - ), - ( - "view3d.view_pan", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PANLEFT'), - ], - } - ), - ( - "view3d.view_pan", - {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PANUP'), - ], - } - ), - ( - "view3d.view_pan", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PANDOWN'), - ], - } - ), - ( - "view3d.view_orbit", - {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("type", 'ORBITLEFT'), - ], - } - ), - ( - "view3d.view_orbit", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("type", 'ORBITRIGHT'), - ], - } - ), - ( - "view3d.view_orbit", - {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("type", 'ORBITUP'), - ], - } - ), - ( - "view3d.view_orbit", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("type", 'ORBITDOWN'), - ], - } - ), - ( - "view3d.view_roll", - {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'LEFT'), - ], - } - ), - ( - "view3d.view_roll", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'RIGHT'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_1', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'FRONT'), - ("align_active", True), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_3', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'RIGHT'), - ("align_active", True), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_7', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'TOP'), - ("align_active", True), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_1', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'BACK'), - ("align_active", True), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_3', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'LEFT'), - ("align_active", True), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NUMPAD_7', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'BOTTOM'), - ("align_active", True), - ], - } - ), - ("view3d.ndof_orbit_zoom", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), - ("view3d.ndof_orbit", {"type": 'NDOF_MOTION', "value": 'ANY', "ctrl": True}, None), - ("view3d.ndof_pan", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True}, None), - ("view3d.ndof_all", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True, "ctrl": True}, None), - ( - "view3d.view_selected", - {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, - { - "properties": [ - ("use_all_regions", False), - ], - } - ), - ( - "view3d.view_roll", - {"type": 'NDOF_BUTTON_ROLL_CCW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'LEFT'), - ], - } - ), - ( - "view3d.view_roll", - {"type": 'NDOF_BUTTON_ROLL_CCW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'RIGHT'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_FRONT', "value": 'PRESS'}, - { - "properties": [ - ("type", 'FRONT'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_BACK', "value": 'PRESS'}, - { - "properties": [ - ("type", 'BACK'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_LEFT', "value": 'PRESS'}, - { - "properties": [ - ("type", 'LEFT'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_RIGHT', "value": 'PRESS'}, - { - "properties": [ - ("type", 'RIGHT'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS'}, - { - "properties": [ - ("type", 'TOP'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_BOTTOM', "value": 'PRESS'}, - { - "properties": [ - ("type", 'BOTTOM'), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_FRONT', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'FRONT'), - ("align_active", True), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_RIGHT', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'RIGHT'), - ("align_active", True), - ], - } - ), - ( - "view3d.view_axis", - {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'TOP'), - ("align_active", True), - ], - } - ), - ( - "view3d.layers", - {"type": 'ACCENT_GRAVE', "value": 'PRESS'}, - { - "properties": [ - ("nr", 0), - ], - } - ), - ( - "view3d.layers", - {"type": 'ONE', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 1), - ], - } - ), - ( - "view3d.layers", - {"type": 'TWO', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 2), - ], - } - ), - ( - "view3d.layers", - {"type": 'THREE', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 3), - ], - } - ), - ( - "view3d.layers", - {"type": 'FOUR', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 4), - ], - } - ), - ( - "view3d.layers", - {"type": 'FIVE', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 5), - ], - } - ), - ( - "view3d.layers", - {"type": 'SIX', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 6), - ], - } - ), - ( - "view3d.layers", - {"type": 'SEVEN', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 7), - ], - } - ), - ( - "view3d.layers", - {"type": 'EIGHT', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 8), - ], - } - ), - ( - "view3d.layers", - {"type": 'NINE', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 9), - ], - } - ), - ( - "view3d.layers", - {"type": 'ZERO', "value": 'PRESS', "any": True}, - { - "properties": [ - ("nr", 10), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'Z', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'space_data.shading.type'), - ("value_1", 'SOLID'), - ("value_2", 'TEXTURED'), - ], - } - ), - ("view3d.toggle_render", {"type": 'Z', "value": 'PRESS', "shift": True}, None), - ("view3d.toggle_xray_draw_option", {"type": 'Z', "value": 'PRESS'}, None), - ( - "wm.context_toggle", - {"type": 'Z', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.use_occlude_geometry'), - ], - } - ), - ( - "view3d.select", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", False), - ("center", False), - ("enumerate", False), - ("object", False), - ], - } - ), - ( - "view3d.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", True), - ("center", False), - ("enumerate", False), - ("object", False), - ], - } - ), - ( - "view3d.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", False), - ("center", True), - ("enumerate", False), - ("object", True), - ], - } - ), - ( - "view3d.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", False), - ("center", False), - ("enumerate", True), - ("object", False), - ], - } - ), - ( - "view3d.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ("deselect", False), - ("toggle", True), - ("center", True), - ("enumerate", False), - ("object", False), - ], - } - ), - ( - "view3d.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", False), - ("center", True), - ("enumerate", True), - ("object", False), - ], - } - ), - ( - "view3d.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", True), - ("center", False), - ("enumerate", True), - ("object", False), - ], - } - ), - ( - "view3d.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", True), - ("center", True), - ("enumerate", True), - ("object", False), - ], - } - ), - ("view3d.select_border", {"type": 'B', "value": 'PRESS'}, None), - ( - "view3d.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "view3d.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None), - ("view3d.clip_border", {"type": 'B', "value": 'PRESS', "alt": True}, None), - ("view3d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), - ("view3d.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), - ("view3d.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("view3d.camera_to_view", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("view3d.object_as_camera", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'S', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'VIEW3D_MT_snap'), - ], - } - ), - ("view3d.copybuffer", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("view3d.pastebuffer", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.context_set_enum", - {"type": 'COMMA', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.transform_pivot_point'), - ("value", 'BOUNDING_BOX_CENTER'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'tool_settings.transform_pivot_point'), - ("value", 'MEDIAN_POINT'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'COMMA', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'tool_settings.use_transform_pivot_point_align'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'PERIOD', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.transform_pivot_point'), - ("value", 'CURSOR'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'tool_settings.transform_pivot_point'), - ("value", 'INDIVIDUAL_ORIGINS'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'PERIOD', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'tool_settings.transform_pivot_point'), - ("value", 'ACTIVE_ELEMENT'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.show_manipulator'), - ], - } - ), - ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ("transform.bend", {"type": 'W', "value": 'PRESS', "shift": True}, None), - ("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None), - ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ("transform.select_orientation", {"type": 'SPACE', "value": 'PRESS', "alt": True}, None), - ( - "transform.create_orientation", - {"type": 'SPACE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("use", True), - ], - } - ), - ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.context_toggle", - {"type": 'TAB', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.use_snap'), - ], - } - ), - ( - "wm.context_menu_enum", - {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("data_path", 'tool_settings.snap_element'), - ], - } - ), - ("object.transform_axis_target", {"type": 'T', "value": 'PRESS', "shift": True}, None), - ( - "transform.translate", - {"type": 'T', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("texture_space", True), - ], - } - ), - ( - "transform.resize", - {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("texture_space", True), - ], - } - ), - ("transform.skin_resize", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "Manipulators", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ], - }, - ), - ( - "Backdrop Transform Widget", - {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Backdrop Crop Widget", - {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Sun Beams Widget", - {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Corner Pin Widget", - {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "UV Transform Manipulator", - {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Spot Light Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Area Light Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Target Light Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Force Field Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Camera Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Camera View Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Armature Spline Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "View3D Navigate", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Animation", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("anim.change_frame", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ( - "wm.context_toggle", - {"type": 'T', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.show_seconds'), - ], - } - ), - ("anim.previewrange_set", {"type": 'P', "value": 'PRESS'}, None), - ("anim.previewrange_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), - ], - }, - ), - ( - "Animation Channels", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("anim.channels_click", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ( - "anim.channels_click", - {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "anim.channels_click", - {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("children_only", True), - ], - } - ), - ("anim.channels_rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("anim.channels_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), - ("anim.channel_select_keys", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), - ( - "anim.channel_select_keys", - {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), - ( - "anim.channels_select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "anim.channels_select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("anim.channels_select_border", {"type": 'B', "value": 'PRESS'}, None), - ("anim.channels_select_border", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), - ("anim.channels_delete", {"type": 'X', "value": 'PRESS'}, None), - ("anim.channels_delete", {"type": 'DEL', "value": 'PRESS'}, None), - ("anim.channels_setting_toggle", {"type": 'W', "value": 'PRESS', "shift": True}, None), - ("anim.channels_setting_enable", {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("anim.channels_setting_disable", {"type": 'W', "value": 'PRESS', "alt": True}, None), - ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), - ("anim.channels_expand", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), - ("anim.channels_collapse", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), - ( - "anim.channels_expand", - {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("all", False), - ], - } - ), - ( - "anim.channels_collapse", - {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("all", False), - ], - } - ), - ( - "anim.channels_move", - {"type": 'PAGE_UP', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'UP'), - ], - } - ), - ( - "anim.channels_move", - {"type": 'PAGE_DOWN', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'DOWN'), - ], - } - ), - ( - "anim.channels_move", - {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'TOP'), - ], - } - ), - ( - "anim.channels_move", - {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'BOTTOM'), - ], - } - ), - ("anim.channels_group", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), - ("anim.channels_ungroup", {"type": 'G', "value": 'PRESS', "alt": True}, None), - ], - }, - ), - ( - "UV Editor", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "wm.context_toggle", - {"type": 'Q', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.use_uv_sculpt'), - ], - } - ), - ("uv.mark_seam", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), - ( - "uv.select", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "uv.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "uv.select_loop", - {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "uv.select_loop", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ("uv.select_split", {"type": 'Y', "value": 'PRESS'}, None), - ( - "uv.select_border", - {"type": 'B', "value": 'PRESS'}, - { - "properties": [ - ("pinned", False), - ], - } - ), - ( - "uv.select_border", - {"type": 'B', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("pinned", True), - ], - } - ), - ("uv.circle_select", {"type": 'C', "value": 'PRESS'}, None), - ( - "uv.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "uv.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ( - "uv.select_linked", - {"type": 'L', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("extend", True), - ("deselect", False), - ], - } - ), - ( - "uv.select_linked_pick", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("extend", True), - ("deselect", False), - ], - } - ), - ( - "uv.select_linked", - {"type": 'L', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", False), - ("deselect", True), - ], - } - ), - ( - "uv.select_linked_pick", - {"type": 'L', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", False), - ("deselect", True), - ], - } - ), - ("uv.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("uv.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ( - "uv.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "uv.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("uv.select_pinned", {"type": 'P', "value": 'PRESS', "shift": True}, None), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'IMAGE_MT_uvs_weldalign'), - ], - } - ), - ("uv.stitch", {"type": 'V', "value": 'PRESS'}, None), - ( - "uv.pin", - {"type": 'P', "value": 'PRESS'}, - { - "properties": [ - ("clear", False), - ], - } - ), - ( - "uv.pin", - {"type": 'P', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("clear", True), - ], - } - ), - ("uv.unwrap", {"type": 'E', "value": 'PRESS'}, None), - ("uv.minimize_stretch", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ("uv.pack_islands", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ("uv.average_islands_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), - ( - "uv.hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "uv.hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("uv.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ("uv.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ( - "wm.call_menu", - {"type": 'S', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'IMAGE_MT_uvs_snap'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'TAB', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("name", 'IMAGE_MT_uvs_select_mode'), - ], - } - ), - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit'), - ("value_1", 'DISABLED'), - ("value_2", 'ENABLED'), - ], - } - ), - ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.context_toggle", - {"type": 'TAB', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.use_snap'), - ], - } - ), - ( - "wm.context_menu_enum", - {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("data_path", 'tool_settings.snap_uv_element'), - ], - } - ), - ], - }, - ), - ( - "UV Sculpt", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ( - "wm.context_toggle", - {"type": 'Q', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.use_uv_sculpt'), - ], - } - ), - ( - "sculpt.uv_sculpt_stroke", - {"type": 'LEFTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'NORMAL'), - ], - } - ), - ( - "sculpt.uv_sculpt_stroke", - {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'INVERT'), - ], - } - ), - ( - "sculpt.uv_sculpt_stroke", - {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'RELAX'), - ], - } - ), - ( - "brush.scale_size", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 0.9), - ], - } - ), - ( - "brush.scale_size", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("scalar", 1.1111112), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("data_path_primary", 'tool_settings.uv_sculpt.brush.size'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), - ("rotation_path", 'tool_settings.uv_sculpt.brush.texture_slot.angle'), - ("color_path", 'tool_settings.uv_sculpt.brush.cursor_color_add'), - ("fill_color_path", ''), - ("fill_color_override_path", ''), - ("fill_color_override_test_path", ''), - ("zoom_path", ''), - ("image_id", 'tool_settings.uv_sculpt.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "wm.radial_control", - {"type": 'F', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path_primary", 'tool_settings.uv_sculpt.brush.strength'), - ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), - ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), - ("rotation_path", 'tool_settings.uv_sculpt.brush.texture_slot.angle'), - ("color_path", 'tool_settings.uv_sculpt.brush.cursor_color_add'), - ("fill_color_path", ''), - ("fill_color_override_path", ''), - ("fill_color_override_test_path", ''), - ("zoom_path", ''), - ("image_id", 'tool_settings.uv_sculpt.brush'), - ("secondary_tex", False), - ], - } - ), - ( - "brush.uv_sculpt_tool_set", - {"type": 'S', "value": 'PRESS'}, - { - "properties": [ - ("tool", 'RELAX'), - ], - } - ), - ( - "brush.uv_sculpt_tool_set", - {"type": 'P', "value": 'PRESS'}, - { - "properties": [ - ("tool", 'PINCH'), - ], - } - ), - ( - "brush.uv_sculpt_tool_set", - {"type": 'G', "value": 'PRESS'}, - { - "properties": [ - ("tool", 'GRAB'), - ], - } - ), - ], - }, - ), - ( - "Mask Editing", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("mask.new", {"type": 'N', "value": 'PRESS', "alt": True}, None), - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'MASK_MT_add'), - ], - } - ), - ( - "wm.context_cycle_enum", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.proportional_edit_falloff'), - ("wrap", True), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.use_proportional_edit_mask'), - ], - } - ), - ("mask.add_vertex_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("mask.add_feather_vertex_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, None), - ("mask.delete", {"type": 'X', "value": 'PRESS'}, None), - ("mask.delete", {"type": 'DEL', "value": 'PRESS'}, None), - ( - "mask.select", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", False), - ], - } - ), - ( - "mask.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", False), - ("deselect", False), - ("toggle", True), - ], - } - ), - ( - "mask.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "mask.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("mask.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), - ( - "mask.select_linked_pick", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "mask.select_linked_pick", - {"type": 'L', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("mask.select_border", {"type": 'B', "value": 'PRESS'}, None), - ("mask.select_circle", {"type": 'C', "value": 'PRESS'}, None), - ( - "mask.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "mask.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("mask.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("mask.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("mask.hide_view_clear", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ( - "mask.hide_view_set", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "mask.hide_view_set", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ( - "clip.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ("mask.cyclic_toggle", {"type": 'C', "value": 'PRESS', "alt": True}, None), - ("mask.slide_point", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ("mask.slide_spline_curvature", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ("mask.handle_type_set", {"type": 'V', "value": 'PRESS'}, None), - ("mask.normals_make_consistent", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), - ("mask.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ("mask.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), - ("mask.shape_key_insert", {"type": 'I', "value": 'PRESS'}, None), - ("mask.shape_key_clear", {"type": 'I', "value": 'PRESS', "alt": True}, None), - ("mask.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("mask.copy_splines", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("mask.paste_splines", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ("uv.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ( - "transform.transform", - {"type": 'S', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'MASK_SHRINKFATTEN'), - ], - } - ), - ], - }, - ), - ( - "Markers", - {"space_type": 'EMPTY', "region_type": 'WINDOW'}, - { - "items": [ - ("marker.add", {"type": 'M', "value": 'PRESS'}, None), - ("marker.move", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ("marker.duplicate", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("marker.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), - ( - "marker.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "marker.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("extend", False), - ("camera", True), - ], - } - ), - ( - "marker.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ("camera", True), - ], - } - ), - ("marker.select_border", {"type": 'B', "value": 'PRESS'}, None), - ("marker.select_all", {"type": 'A', "value": 'PRESS'}, None), - ("marker.delete", {"type": 'X', "value": 'PRESS'}, None), - ("marker.delete", {"type": 'DEL', "value": 'PRESS'}, None), - ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), - ("marker.move", {"type": 'G', "value": 'PRESS'}, None), - ("marker.camera_bind", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "Graph Editor Generic", - {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("graph.properties", {"type": 'N', "value": 'PRESS'}, None), - ("graph.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None), - ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), - ( - "graph.hide", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "graph.hide", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("graph.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ], - }, - ), - ( - "Graph Editor", - {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ( - "wm.context_toggle", - {"type": 'H', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.show_handles'), - ], - } - ), - ("graph.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ( - "graph.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ("column", False), - ("curves", False), - ], - } - ), - ( - "graph.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("extend", False), - ("column", True), - ("curves", False), - ], - } - ), - ( - "graph.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ("column", False), - ("curves", False), - ], - } - ), - ( - "graph.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("extend", True), - ("column", True), - ("curves", False), - ], - } - ), - ( - "graph.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", False), - ("column", False), - ("curves", True), - ], - } - ), - ( - "graph.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", True), - ("column", False), - ("curves", True), - ], - } - ), - ( - "graph.select_leftright", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'CHECK'), - ("extend", False), - ], - } - ), - ( - "graph.select_leftright", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("mode", 'CHECK'), - ("extend", True), - ], - } - ), - ( - "graph.select_leftright", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'LEFT'), - ("extend", False), - ], - } - ), - ( - "graph.select_leftright", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'RIGHT'), - ("extend", False), - ], - } - ), - ( - "graph.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "graph.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ( - "graph.select_border", - {"type": 'B', "value": 'PRESS'}, - { - "properties": [ - ("axis_range", False), - ("include_handles", False), - ], - } - ), - ( - "graph.select_border", - {"type": 'B', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("axis_range", True), - ("include_handles", False), - ], - } - ), - ( - "graph.select_border", - {"type": 'B', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("axis_range", False), - ("include_handles", True), - ], - } - ), - ( - "graph.select_border", - {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("axis_range", True), - ("include_handles", True), - ], - } - ), - ( - "graph.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "graph.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("graph.select_circle", {"type": 'C', "value": 'PRESS'}, None), - ( - "graph.select_column", - {"type": 'K', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'KEYS'), - ], - } - ), - ( - "graph.select_column", - {"type": 'K', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'CFRA'), - ], - } - ), - ( - "graph.select_column", - {"type": 'K', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'MARKERS_COLUMN'), - ], - } - ), - ( - "graph.select_column", - {"type": 'K', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'MARKERS_BETWEEN'), - ], - } - ), - ("graph.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("graph.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("graph.select_linked", {"type": 'L', "value": 'PRESS'}, None), - ("graph.frame_jump", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), - ("graph.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), - ("graph.mirror", {"type": 'M', "value": 'PRESS', "shift": True}, None), - ("graph.handle_type", {"type": 'V', "value": 'PRESS'}, None), - ("graph.interpolation_type", {"type": 'T', "value": 'PRESS'}, None), - ("graph.easing_type", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), - ("graph.smooth", {"type": 'O', "value": 'PRESS', "alt": True}, None), - ("graph.sample", {"type": 'O', "value": 'PRESS', "shift": True}, None), - ("graph.bake", {"type": 'C', "value": 'PRESS', "alt": True}, None), - ( - "wm.call_menu", - {"type": 'X', "value": 'PRESS'}, - { - "properties": [ - ("name", 'GRAPH_MT_delete'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("name", 'GRAPH_MT_delete'), - ], - } - ), - ("graph.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("graph.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), - ( - "graph.click_insert", - {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "graph.click_insert", - {"type": 'ACTIONMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ("graph.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("graph.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ( - "graph.paste", - {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("flipped", True), - ], - } - ), - ("graph.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("graph.view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ("graph.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("graph.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ("graph.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), - ( - "graph.fmodifier_add", - {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("only_active", False), - ], - } - ), - ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ( - "transform.transform", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TIME_EXTEND'), - ], - } - ), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ( - "wm.context_toggle", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.use_proportional_fcurve'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'COMMA', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'BOUNDING_BOX_CENTER'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'PERIOD', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'CURSOR'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'INDIVIDUAL_ORIGINS'), - ], - } - ), - ("marker.add", {"type": 'M', "value": 'PRESS'}, None), - ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "Image Generic", - {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("image.new", {"type": 'N', "value": 'PRESS', "alt": True}, None), - ("image.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), - ("image.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), - ("image.read_viewlayers", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), - ("image.save", {"type": 'S', "value": 'PRESS', "alt": True}, None), - ("image.save_as", {"type": 'F3', "value": 'PRESS'}, None), - ("image.properties", {"type": 'N', "value": 'PRESS'}, None), - ("image.toolshelf", {"type": 'T', "value": 'PRESS'}, None), - ("image.cycle_render_slot", {"type": 'J', "value": 'PRESS'}, None), - ( - "image.cycle_render_slot", - {"type": 'J', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("reverse", True), - ], - } - ), - ], - }, - ), - ( - "Image", - {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("image.view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ( - "image.view_all", - {"type": 'HOME', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("fit_view", True), - ], - } - ), - ("image.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), - ("image.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ("image.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("image.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), - ("image.view_zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), - ("image.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), - ("image.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), - ("image.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), - ("image.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("image.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), - ("image.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), - ("image.view_zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("ratio", 8.0), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("ratio", 4.0), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("ratio", 2.0), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_8', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("ratio", 8.0), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("ratio", 4.0), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_2', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("ratio", 2.0), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_1', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 1.0), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_2', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 0.5), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_4', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 0.25), - ], - } - ), - ( - "image.view_zoom_ratio", - {"type": 'NUMPAD_8', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 0.125), - ], - } - ), - ("image.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("image.sample", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ( - "image.curves_point_set", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("point", 'BLACK_POINT'), - ], - } - ), - ( - "image.curves_point_set", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("point", 'WHITE_POINT'), - ], - } - ), - ( - "object.mode_set", - {"type": 'TAB', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'EDIT'), - ("toggle", True), - ], - } - ), - ( - "wm.context_set_int", - {"type": 'ONE', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.image.render_slots.active_index'), - ("value", 0), - ], - } - ), - ( - "wm.context_set_int", - {"type": 'TWO', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.image.render_slots.active_index'), - ("value", 1), - ], - } - ), - ( - "wm.context_set_int", - {"type": 'THREE', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.image.render_slots.active_index'), - ("value", 2), - ], - } - ), - ( - "wm.context_set_int", - {"type": 'FOUR', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.image.render_slots.active_index'), - ("value", 3), - ], - } - ), - ( - "wm.context_set_int", - {"type": 'FIVE', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.image.render_slots.active_index'), - ("value", 4), - ], - } - ), - ( - "wm.context_set_int", - {"type": 'SIX', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.image.render_slots.active_index'), - ("value", 5), - ], - } - ), - ( - "wm.context_set_int", - {"type": 'SEVEN', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.image.render_slots.active_index'), - ("value", 6), - ], - } - ), - ( - "wm.context_set_int", - {"type": 'EIGHT', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.image.render_slots.active_index'), - ("value", 7), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'COMMA', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'CENTER'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'MEDIAN'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'PERIOD', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'CURSOR'), - ], - } - ), - ("image.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), - ("image.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ], - }, - ), - ( - "Node Generic", - {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("node.properties", {"type": 'N', "value": 'PRESS'}, None), - ("node.toolbar", {"type": 'T', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Node Editor", - {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ( - "node.select", - {"type": 'ACTIONMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select", - {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select_border", - {"type": 'EVT_TWEAK_S', "value": 'ANY'}, - { - "properties": [ - ("tweak", True), - ], - } - ), - ( - "node.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "node.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("node.select_circle", {"type": 'C', "value": 'PRESS'}, None), - ( - "node.link", - {"type": 'LEFTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("detach", False), - ], - } - ), - ( - "node.link", - {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("detach", True), - ], - } - ), - ("node.resize", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("node.add_reroute", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), - ("node.links_cut", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("node.select_link_viewer", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("node.backimage_move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "alt": True}, None), - ( - "node.backimage_zoom", - {"type": 'V', "value": 'PRESS'}, - { - "properties": [ - ("factor", 0.8333333), - ], - } - ), - ( - "node.backimage_zoom", - {"type": 'V', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("factor", 1.2), - ], - } - ), - ("node.backimage_fit", {"type": 'HOME', "value": 'PRESS', "alt": True}, None), - ("node.backimage_sample", {"type": 'ACTIONMOUSE', "value": 'PRESS', "alt": True}, None), - ( - "node.link_make", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("replace", False), - ], - } - ), - ( - "node.link_make", - {"type": 'F', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("replace", True), - ], - } - ), - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'NODE_MT_add'), - ], - } - ), - ("node.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("node.duplicate_move_keep_inputs", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("node.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), - ("node.detach", {"type": 'P', "value": 'PRESS', "alt": True}, None), - ("node.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), - ("node.hide_toggle", {"type": 'H', "value": 'PRESS'}, None), - ("node.mute_toggle", {"type": 'M', "value": 'PRESS'}, None), - ("node.preview_toggle", {"type": 'H', "value": 'PRESS', "shift": True}, None), - ("node.hide_socket_toggle", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), - ("node.view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ("node.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("node.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ( - "node.select_border", - {"type": 'B', "value": 'PRESS'}, - { - "properties": [ - ("tweak", False), - ], - } - ), - ("node.delete", {"type": 'X', "value": 'PRESS'}, None), - ("node.delete", {"type": 'DEL', "value": 'PRESS'}, None), - ("node.delete_reconnect", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), - ( - "node.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "node.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("node.select_linked_to", {"type": 'L', "value": 'PRESS', "shift": True}, None), - ("node.select_linked_from", {"type": 'L', "value": 'PRESS'}, None), - ( - "node.select_grouped", - {"type": 'G', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "node.select_grouped", - {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "node.select_same_type_step", - {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("prev", False), - ], - } - ), - ( - "node.select_same_type_step", - {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("prev", True), - ], - } - ), - ("node.find_node", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), - ("node.group_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), - ("node.group_ungroup", {"type": 'G', "value": 'PRESS', "alt": True}, None), - ("node.group_separate", {"type": 'P', "value": 'PRESS'}, None), - ( - "node.group_edit", - {"type": 'TAB', "value": 'PRESS'}, - { - "properties": [ - ("exit", False), - ], - } - ), - ( - "node.group_edit", - {"type": 'TAB', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("exit", True), - ], - } - ), - ("node.read_viewlayers", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), - ("node.render_changed", {"type": 'Z', "value": 'PRESS'}, None), - ("node.clipboard_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("node.clipboard_paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ("node.viewer_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), - ("node.clear_viewer_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("node.translate_attach", {"type": 'G', "value": 'PRESS'}, None), - ("node.translate_attach", {"type": 'EVT_TWEAK_A', "value": 'ANY'}, None), - ("node.translate_attach", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ( - "transform.translate", - {"type": 'G', "value": 'PRESS'}, - { - "properties": [ - ("release_confirm", True), - ], - } - ), - ( - "transform.translate", - {"type": 'EVT_TWEAK_A', "value": 'ANY'}, - { - "properties": [ - ("release_confirm", True), - ], - } - ), - ( - "transform.translate", - {"type": 'EVT_TWEAK_S', "value": 'ANY'}, - { - "properties": [ - ("release_confirm", True), - ], - } - ), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ("node.move_detach_links", {"type": 'D', "value": 'PRESS', "alt": True}, None), - ("node.move_detach_links_release", {"type": 'EVT_TWEAK_A', "value": 'ANY', "alt": True}, None), - ("node.move_detach_links", {"type": 'EVT_TWEAK_S', "value": 'ANY', "alt": True}, None), - ( - "wm.context_toggle", - {"type": 'TAB', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'tool_settings.use_snap'), - ], - } - ), - ( - "wm.context_menu_enum", - {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("data_path", 'tool_settings.snap_node_element'), - ], - } - ), - ], - }, - ), - ( - "File Browser", - {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, - { - "items": [ - ("file.parent", {"type": 'UP_ARROW', "value": 'PRESS', "alt": True}, None), - ("file.previous", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, None), - ("file.next", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, None), - ("file.refresh", {"type": 'R', "value": 'PRESS'}, None), - ("file.parent", {"type": 'P', "value": 'PRESS'}, None), - ("file.previous", {"type": 'BACK_SPACE', "value": 'PRESS'}, None), - ("file.next", {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, None), - ( - "wm.context_toggle", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.params.show_hidden'), - ], - } - ), - ("file.directory_new", {"type": 'I', "value": 'PRESS'}, None), - ("file.delete", {"type": 'X', "value": 'PRESS'}, None), - ("file.delete", {"type": 'DEL', "value": 'PRESS'}, None), - ("file.smoothscroll", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), - ("file.bookmark_toggle", {"type": 'T', "value": 'PRESS'}, None), - ("file.bookmark_add", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "File Browser Main", - {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, - { - "items": [ - ( - "file.execute", - {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, - { - "properties": [ - ("need_active", True), - ], - } - ), - ("file.refresh", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None), - ( - "file.select", - {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "file.select", - {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ("fill", True), - ], - } - ), - ( - "file.select", - {"type": 'RIGHTMOUSE', "value": 'CLICK'}, - { - "properties": [ - ("open", False), - ], - } - ), - ( - "file.select", - {"type": 'RIGHTMOUSE', "value": 'CLICK', "shift": True}, - { - "properties": [ - ("extend", True), - ("open", False), - ], - } - ), - ( - "file.select", - {"type": 'RIGHTMOUSE', "value": 'CLICK', "alt": True}, - { - "properties": [ - ("extend", True), - ("fill", True), - ("open", False), - ], - } - ), - ( - "file.select_walk", - {"type": 'UP_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'UP'), - ], - } - ), - ( - "file.select_walk", - {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'UP'), - ("extend", True), - ], - } - ), - ( - "file.select_walk", - {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("direction", 'UP'), - ("extend", True), - ("fill", True), - ], - } - ), - ( - "file.select_walk", - {"type": 'DOWN_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'DOWN'), - ], - } - ), - ( - "file.select_walk", - {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'DOWN'), - ("extend", True), - ], - } - ), - ( - "file.select_walk", - {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("direction", 'DOWN'), - ("extend", True), - ("fill", True), - ], - } - ), - ( - "file.select_walk", - {"type": 'LEFT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'LEFT'), - ], - } - ), - ( - "file.select_walk", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'LEFT'), - ("extend", True), - ], - } - ), - ( - "file.select_walk", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("direction", 'LEFT'), - ("extend", True), - ("fill", True), - ], - } - ), - ( - "file.select_walk", - {"type": 'RIGHT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("direction", 'RIGHT'), - ], - } - ), - ( - "file.select_walk", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("direction", 'RIGHT'), - ("extend", True), - ], - } - ), - ( - "file.select_walk", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("direction", 'RIGHT'), - ("extend", True), - ("fill", True), - ], - } - ), - ("file.previous", {"type": 'BUTTON4MOUSE', "value": 'CLICK'}, None), - ("file.next", {"type": 'BUTTON5MOUSE', "value": 'CLICK'}, None), - ("file.select_all_toggle", {"type": 'A', "value": 'PRESS'}, None), - ("file.select_border", {"type": 'B', "value": 'PRESS'}, None), - ("file.select_border", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), - ("file.rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("file.highlight", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), - ( - "file.filenum", - {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, - { - "properties": [ - ("increment", 1), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("increment", 10), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("increment", 100), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, - { - "properties": [ - ("increment", -1), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("increment", -10), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("increment", -100), - ], - } - ), - ], - }, - ), - ( - "File Browser Buttons", - {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, - { - "items": [ - ( - "file.filenum", - {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, - { - "properties": [ - ("increment", 1), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("increment", 10), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("increment", 100), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, - { - "properties": [ - ("increment", -1), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("increment", -10), - ], - } - ), - ( - "file.filenum", - {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("increment", -100), - ], - } - ), - ], - }, - ), - ( - "Dopesheet Generic", - {"space_type": 'DOPESHEET_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("action.properties", {"type": 'N', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Dopesheet", - {"space_type": 'DOPESHEET_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ( - "action.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ("column", False), - ("channel", False), - ], - } - ), - ( - "action.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("extend", False), - ("column", True), - ("channel", False), - ], - } - ), - ( - "action.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ("column", False), - ("channel", False), - ], - } - ), - ( - "action.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("extend", True), - ("column", True), - ("channel", False), - ], - } - ), - ( - "action.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", False), - ("column", False), - ("channel", True), - ], - } - ), - ( - "action.clickselect", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("extend", True), - ("column", False), - ("channel", True), - ], - } - ), - ( - "action.select_leftright", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'CHECK'), - ("extend", False), - ], - } - ), - ( - "action.select_leftright", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("mode", 'CHECK'), - ("extend", True), - ], - } - ), - ( - "action.select_leftright", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'LEFT'), - ("extend", False), - ], - } - ), - ( - "action.select_leftright", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'RIGHT'), - ("extend", False), - ], - } - ), - ( - "action.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "action.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ( - "action.select_border", - {"type": 'B', "value": 'PRESS'}, - { - "properties": [ - ("axis_range", False), - ], - } - ), - ( - "action.select_border", - {"type": 'B', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("axis_range", True), - ], - } - ), - ( - "action.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "action.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("action.select_circle", {"type": 'C', "value": 'PRESS'}, None), - ( - "action.select_column", - {"type": 'K', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'KEYS'), - ], - } - ), - ( - "action.select_column", - {"type": 'K', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'CFRA'), - ], - } - ), - ( - "action.select_column", - {"type": 'K', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'MARKERS_COLUMN'), - ], - } - ), - ( - "action.select_column", - {"type": 'K', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("mode", 'MARKERS_BETWEEN'), - ], - } - ), - ("action.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("action.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ("action.select_linked", {"type": 'L', "value": 'PRESS'}, None), - ("action.frame_jump", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), - ("action.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), - ("action.mirror", {"type": 'M', "value": 'PRESS', "shift": True}, None), - ("action.handle_type", {"type": 'V', "value": 'PRESS'}, None), - ("action.interpolation_type", {"type": 'T', "value": 'PRESS'}, None), - ("action.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None), - ("action.keyframe_type", {"type": 'R', "value": 'PRESS'}, None), - ("action.sample", {"type": 'O', "value": 'PRESS', "shift": True}, None), - ( - "wm.call_menu", - {"type": 'X', "value": 'PRESS'}, - { - "properties": [ - ("name", 'DOPESHEET_MT_delete'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("name", 'DOPESHEET_MT_delete'), - ], - } - ), - ("action.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("action.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), - ("action.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("action.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ( - "action.paste", - {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("flipped", True), - ], - } - ), - ("action.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("action.view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ("action.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("action.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ("action.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), - ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), - ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), - ( - "transform.transform", - {"type": 'G', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TIME_TRANSLATE'), - ], - } - ), - ( - "transform.transform", - {"type": 'EVT_TWEAK_S', "value": 'ANY'}, - { - "properties": [ - ("mode", 'TIME_TRANSLATE'), - ], - } - ), - ( - "transform.transform", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TIME_EXTEND'), - ], - } - ), - ( - "transform.transform", - {"type": 'S', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TIME_SCALE'), - ], - } - ), - ( - "transform.transform", - {"type": 'T', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("mode", 'TIME_SLIDE'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'tool_settings.use_proportional_action'), - ], - } - ), - ("marker.add", {"type": 'M', "value": 'PRESS'}, None), - ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "NLA Generic", - {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("nla.properties", {"type": 'N', "value": 'PRESS'}, None), - ("nla.tweakmode_enter", {"type": 'TAB', "value": 'PRESS'}, None), - ("nla.tweakmode_exit", {"type": 'TAB', "value": 'PRESS'}, None), - ( - "nla.tweakmode_enter", - {"type": 'TAB', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("isolate_action", True), - ], - } - ), - ( - "nla.tweakmode_exit", - {"type": 'TAB', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("isolate_action", True), - ], - } - ), - ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "NLA Channels", - {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ( - "nla.channels_click", - {"type": 'LEFTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "nla.channels_click", - {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "nla.tracks_add", - {"type": 'A', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("above_selected", False), - ], - } - ), - ( - "nla.tracks_add", - {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("above_selected", True), - ], - } - ), - ("nla.tracks_delete", {"type": 'X', "value": 'PRESS'}, None), - ("nla.tracks_delete", {"type": 'DEL', "value": 'PRESS'}, None), - ], - }, - ), - ( - "NLA Editor", - {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ( - "nla.click_select", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "nla.click_select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "nla.select_leftright", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("mode", 'CHECK'), - ("extend", False), - ], - } - ), - ( - "nla.select_leftright", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("mode", 'CHECK'), - ("extend", True), - ], - } - ), - ( - "nla.select_leftright", - {"type": 'LEFT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'LEFT'), - ("extend", False), - ], - } - ), - ( - "nla.select_leftright", - {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'RIGHT'), - ("extend", False), - ], - } - ), - ( - "nla.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "nla.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ( - "nla.select_border", - {"type": 'B', "value": 'PRESS'}, - { - "properties": [ - ("axis_range", False), - ], - } - ), - ( - "nla.select_border", - {"type": 'B', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("axis_range", True), - ], - } - ), - ("nla.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), - ("nla.view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ("nla.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("nla.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ("nla.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), - ("nla.actionclip_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), - ("nla.transition_add", {"type": 'T', "value": 'PRESS', "shift": True}, None), - ("nla.soundclip_add", {"type": 'K', "value": 'PRESS', "shift": True}, None), - ("nla.meta_add", {"type": 'G', "value": 'PRESS', "shift": True}, None), - ("nla.meta_remove", {"type": 'G', "value": 'PRESS', "alt": True}, None), - ( - "nla.duplicate", - {"type": 'D', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("linked", False), - ], - } - ), - ( - "nla.duplicate", - {"type": 'D', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("linked", True), - ], - } - ), - ("nla.make_single_user", {"type": 'U', "value": 'PRESS'}, None), - ("nla.delete", {"type": 'X', "value": 'PRESS'}, None), - ("nla.delete", {"type": 'DEL', "value": 'PRESS'}, None), - ("nla.split", {"type": 'Y', "value": 'PRESS'}, None), - ("nla.mute_toggle", {"type": 'H', "value": 'PRESS'}, None), - ("nla.swap", {"type": 'F', "value": 'PRESS', "alt": True}, None), - ("nla.move_up", {"type": 'PAGE_UP', "value": 'PRESS'}, None), - ("nla.move_down", {"type": 'PAGE_DOWN', "value": 'PRESS'}, None), - ("nla.apply_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), - ("nla.clear_scale", {"type": 'S', "value": 'PRESS', "alt": True}, None), - ("nla.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), - ("nla.fmodifier_add", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "transform.transform", - {"type": 'G', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TRANSLATION'), - ], - } - ), - ( - "transform.transform", - {"type": 'EVT_TWEAK_S', "value": 'ANY'}, - { - "properties": [ - ("mode", 'TRANSLATION'), - ], - } - ), - ( - "transform.transform", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TIME_EXTEND'), - ], - } - ), - ( - "transform.transform", - {"type": 'S', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TIME_SCALE'), - ], - } - ), - ("marker.add", {"type": 'M', "value": 'PRESS'}, None), - ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "Text Generic", - {"space_type": 'TEXT_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("text.start_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), - ("text.jump", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), - ("text.find", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), - ("text.replace", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), - ("text.properties", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "Text", - {"space_type": 'TEXT_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ( - "wm.context_cycle_int", - {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.font_size'), - ("reverse", False), - ], - } - ), - ( - "wm.context_cycle_int", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.font_size'), - ("reverse", True), - ], - } - ), - ( - "wm.context_cycle_int", - {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.font_size'), - ("reverse", False), - ], - } - ), - ( - "wm.context_cycle_int", - {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.font_size'), - ("reverse", True), - ], - } - ), - ("text.new", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), - ("text.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), - ("text.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), - ("text.save", {"type": 'S', "value": 'PRESS', "alt": True}, None), - ("text.save_as", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), - ("text.run_script", {"type": 'P', "value": 'PRESS', "alt": True}, None), - ("text.cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), - ("text.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("text.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ("text.cut", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), - ("text.copy", {"type": 'INSERT', "value": 'PRESS', "ctrl": True}, None), - ("text.paste", {"type": 'INSERT', "value": 'PRESS', "shift": True}, None), - ("text.duplicate_line", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), - ("text.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), - ("text.select_line", {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("text.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), - ( - "text.move_lines", - {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("direction", 'UP'), - ], - } - ), - ( - "text.move_lines", - {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("direction", 'DOWN'), - ], - } - ), - ("text.indent", {"type": 'TAB', "value": 'PRESS'}, None), - ("text.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), - ("text.uncomment", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ( - "text.move", - {"type": 'HOME', "value": 'PRESS'}, - { - "properties": [ - ("type", 'LINE_BEGIN'), - ], - } - ), - ( - "text.move", - {"type": 'END', "value": 'PRESS'}, - { - "properties": [ - ("type", 'LINE_END'), - ], - } - ), - ( - "text.move", - {"type": 'E', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'LINE_END'), - ], - } - ), - ( - "text.move", - {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'LINE_END'), - ], - } - ), - ( - "text.move", - {"type": 'LEFT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "text.move", - {"type": 'RIGHT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_CHARACTER'), - ], - } - ), - ( - "text.move", - {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PREVIOUS_WORD'), - ], - } - ), - ( - "text.move", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'NEXT_WORD'), - ], - } - ), - ( - "text.move", - {"type": 'UP_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_LINE'), - ], - } - ), - ( - "text.move", - {"type": 'DOWN_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_LINE'), - ], - } - ), - ( - "text.move", - {"type": 'PAGE_UP', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_PAGE'), - ], - } - ), - ( - "text.move", - {"type": 'PAGE_DOWN', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_PAGE'), - ], - } - ), - ( - "text.move", - {"type": 'HOME', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'FILE_TOP'), - ], - } - ), - ( - "text.move", - {"type": 'END', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'FILE_BOTTOM'), - ], - } - ), - ( - "text.move_select", - {"type": 'HOME', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'LINE_BEGIN'), - ], - } - ), - ( - "text.move_select", - {"type": 'END', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'LINE_END'), - ], - } - ), - ( - "text.move_select", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "text.move_select", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'NEXT_CHARACTER'), - ], - } - ), - ( - "text.move_select", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'PREVIOUS_WORD'), - ], - } - ), - ( - "text.move_select", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'NEXT_WORD'), - ], - } - ), - ( - "text.move_select", - {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_LINE'), - ], - } - ), - ( - "text.move_select", - {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'NEXT_LINE'), - ], - } - ), - ( - "text.move_select", - {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_PAGE'), - ], - } - ), - ( - "text.move_select", - {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'NEXT_PAGE'), - ], - } - ), - ( - "text.move_select", - {"type": 'HOME', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'FILE_TOP'), - ], - } - ), - ( - "text.move_select", - {"type": 'END', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("type", 'FILE_BOTTOM'), - ], - } - ), - ( - "text.delete", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_CHARACTER'), - ], - } - ), - ( - "text.delete", - {"type": 'BACK_SPACE', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "text.delete", - {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "text.delete", - {"type": 'DEL', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'NEXT_WORD'), - ], - } - ), - ( - "text.delete", - {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PREVIOUS_WORD'), - ], - } - ), - ("text.overwrite_toggle", {"type": 'INSERT', "value": 'PRESS'}, None), - ("text.scroll_bar", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("text.scroll_bar", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("text.scroll", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("text.scroll", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ("text.selection_set", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), - ("text.cursor_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ( - "text.selection_set", - {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("select", True), - ], - } - ), - ( - "text.scroll", - {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("lines", -1), - ], - } - ), - ( - "text.scroll", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("lines", 1), - ], - } - ), - ("text.line_break", {"type": 'RET', "value": 'PRESS'}, None), - ("text.line_break", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), - ( - "wm.call_menu", - {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, - { - "properties": [ - ("name", 'TEXT_MT_toolbox'), - ], - } - ), - ("text.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None), - ("text.line_number", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), - ("text.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), - ], - }, - ), - ( - "SequencerCommon", - {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("sequencer.properties", {"type": 'N', "value": 'PRESS'}, None), - ( - "wm.context_toggle", - {"type": 'O', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("data_path", 'scene.sequence_editor.show_overlay'), - ], - } - ), - ("sequencer.view_toggle", {"type": 'TAB', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "Sequencer", - {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ( - "sequencer.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "sequencer.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ( - "sequencer.cut", - {"type": 'K', "value": 'PRESS'}, - { - "properties": [ - ("type", 'SOFT'), - ], - } - ), - ( - "sequencer.cut", - {"type": 'K', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'HARD'), - ], - } - ), - ( - "sequencer.mute", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "sequencer.mute", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ( - "sequencer.unmute", - {"type": 'H', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "sequencer.unmute", - {"type": 'H', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("sequencer.lock", {"type": 'L', "value": 'PRESS', "shift": True}, None), - ("sequencer.unlock", {"type": 'L', "value": 'PRESS', "shift": True, "alt": True}, None), - ("sequencer.reassign_inputs", {"type": 'R', "value": 'PRESS'}, None), - ("sequencer.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), - ( - "sequencer.reload", - {"type": 'R', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("adjust_length", True), - ], - } - ), - ("sequencer.offset_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None), - ("sequencer.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), - ("sequencer.delete", {"type": 'X', "value": 'PRESS'}, None), - ("sequencer.delete", {"type": 'DEL', "value": 'PRESS'}, None), - ("sequencer.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("sequencer.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ("sequencer.images_separate", {"type": 'Y', "value": 'PRESS'}, None), - ("sequencer.meta_toggle", {"type": 'TAB', "value": 'PRESS'}, None), - ("sequencer.meta_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), - ("sequencer.meta_separate", {"type": 'G', "value": 'PRESS', "alt": True}, None), - ("sequencer.view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ("sequencer.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("sequencer.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ("sequencer.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), - ( - "sequencer.strip_jump", - {"type": 'PAGE_UP', "value": 'PRESS'}, - { - "properties": [ - ("next", True), - ("center", False), - ], - } - ), - ( - "sequencer.strip_jump", - {"type": 'PAGE_DOWN', "value": 'PRESS'}, - { - "properties": [ - ("next", False), - ("center", False), - ], - } - ), - ( - "sequencer.strip_jump", - {"type": 'PAGE_UP', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("next", True), - ("center", True), - ], - } - ), - ( - "sequencer.strip_jump", - {"type": 'PAGE_DOWN', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("next", False), - ("center", True), - ], - } - ), - ( - "sequencer.swap", - {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("side", 'LEFT'), - ], - } - ), - ( - "sequencer.swap", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("side", 'RIGHT'), - ], - } - ), - ( - "sequencer.gap_remove", - {"type": 'BACK_SPACE', "value": 'PRESS'}, - { - "properties": [ - ("all", False), - ], - } - ), - ( - "sequencer.gap_remove", - {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("all", True), - ], - } - ), - ("sequencer.gap_insert", {"type": 'EQUAL', "value": 'PRESS', "shift": True}, None), - ("sequencer.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), - ("sequencer.swap_inputs", {"type": 'S', "value": 'PRESS', "alt": True}, None), - ( - "sequencer.cut_multicam", - {"type": 'ONE', "value": 'PRESS'}, - { - "properties": [ - ("camera", 1), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'TWO', "value": 'PRESS'}, - { - "properties": [ - ("camera", 2), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'THREE', "value": 'PRESS'}, - { - "properties": [ - ("camera", 3), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'FOUR', "value": 'PRESS'}, - { - "properties": [ - ("camera", 4), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'FIVE', "value": 'PRESS'}, - { - "properties": [ - ("camera", 5), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'SIX', "value": 'PRESS'}, - { - "properties": [ - ("camera", 6), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'SEVEN', "value": 'PRESS'}, - { - "properties": [ - ("camera", 7), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'EIGHT', "value": 'PRESS'}, - { - "properties": [ - ("camera", 8), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'NINE', "value": 'PRESS'}, - { - "properties": [ - ("camera", 9), - ], - } - ), - ( - "sequencer.cut_multicam", - {"type": 'ZERO', "value": 'PRESS'}, - { - "properties": [ - ("camera", 10), - ], - } - ), - ( - "sequencer.select", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ("linked_handle", False), - ("left_right", 'NONE'), - ("linked_time", False), - ], - } - ), - ( - "sequencer.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ("linked_handle", False), - ("left_right", 'NONE'), - ("linked_time", False), - ], - } - ), - ( - "sequencer.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("extend", False), - ("linked_handle", True), - ("left_right", 'NONE'), - ("linked_time", False), - ], - } - ), - ( - "sequencer.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("extend", True), - ("linked_handle", True), - ("left_right", 'NONE'), - ("linked_time", False), - ], - } - ), - ( - "sequencer.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("extend", False), - ("linked_handle", False), - ("left_right", 'MOUSE'), - ("linked_time", True), - ], - } - ), - ( - "sequencer.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("extend", True), - ("linked_handle", False), - ("left_right", 'NONE'), - ("linked_time", True), - ], - } - ), - ("sequencer.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), - ("sequencer.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), - ( - "sequencer.select_linked_pick", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "sequencer.select_linked_pick", - {"type": 'L', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ("sequencer.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), - ("sequencer.select_border", {"type": 'B', "value": 'PRESS'}, None), - ("sequencer.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), - ( - "wm.call_menu", - {"type": 'A', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'SEQUENCER_MT_add'), - ], - } - ), - ( - "wm.call_menu", - {"type": 'C', "value": 'PRESS'}, - { - "properties": [ - ("name", 'SEQUENCER_MT_change'), - ], - } - ), - ("sequencer.slip", {"type": 'S', "value": 'PRESS'}, None), - ( - "wm.context_set_int", - {"type": 'O', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'scene.sequence_editor.overlay_frame'), - ("value", 0), - ], - } - ), - ("transform.seq_slide", {"type": 'G', "value": 'PRESS'}, None), - ("transform.seq_slide", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ( - "transform.transform", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("mode", 'TIME_EXTEND'), - ], - } - ), - ("marker.add", {"type": 'M', "value": 'PRESS'}, None), - ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "SequencerPreview", - {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("sequencer.view_all_preview", {"type": 'HOME', "value": 'PRESS'}, None), - ("sequencer.view_all_preview", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("sequencer.view_ghost_border", {"type": 'O', "value": 'PRESS'}, None), - ( - "sequencer.view_zoom_ratio", - {"type": 'NUMPAD_1', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 1.0), - ], - } - ), - ("sequencer.sample", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Console", - {"space_type": 'CONSOLE', "region_type": 'WINDOW'}, - { - "items": [ - ( - "console.move", - {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PREVIOUS_WORD'), - ], - } - ), - ( - "console.move", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'NEXT_WORD'), - ], - } - ), - ( - "console.move", - {"type": 'HOME', "value": 'PRESS'}, - { - "properties": [ - ("type", 'LINE_BEGIN'), - ], - } - ), - ( - "console.move", - {"type": 'END', "value": 'PRESS'}, - { - "properties": [ - ("type", 'LINE_END'), - ], - } - ), - ( - "wm.context_cycle_int", - {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.font_size'), - ("reverse", False), - ], - } - ), - ( - "wm.context_cycle_int", - {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.font_size'), - ("reverse", True), - ], - } - ), - ( - "wm.context_cycle_int", - {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.font_size'), - ("reverse", False), - ], - } - ), - ( - "wm.context_cycle_int", - {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.font_size'), - ("reverse", True), - ], - } - ), - ( - "console.move", - {"type": 'LEFT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "console.move", - {"type": 'RIGHT_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_CHARACTER'), - ], - } - ), - ( - "console.history_cycle", - {"type": 'UP_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("reverse", True), - ], - } - ), - ( - "console.history_cycle", - {"type": 'DOWN_ARROW', "value": 'PRESS'}, - { - "properties": [ - ("reverse", False), - ], - } - ), - ( - "console.delete", - {"type": 'DEL', "value": 'PRESS'}, - { - "properties": [ - ("type", 'NEXT_CHARACTER'), - ], - } - ), - ( - "console.delete", - {"type": 'BACK_SPACE', "value": 'PRESS'}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "console.delete", - {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("type", 'PREVIOUS_CHARACTER'), - ], - } - ), - ( - "console.delete", - {"type": 'DEL', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'NEXT_WORD'), - ], - } - ), - ( - "console.delete", - {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("type", 'PREVIOUS_WORD'), - ], - } - ), - ("console.clear_line", {"type": 'RET', "value": 'PRESS', "shift": True}, None), - ("console.clear_line", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None), - ( - "console.execute", - {"type": 'RET', "value": 'PRESS'}, - { - "properties": [ - ("interactive", True), - ], - } - ), - ( - "console.execute", - {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, - { - "properties": [ - ("interactive", True), - ], - } - ), - ("console.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None), - ("console.copy_as_script", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), - ("console.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("console.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ("console.select_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ("console.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), - ( - "console.insert", - {"type": 'TAB', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("text", '\t'), - ], - } - ), - ("console.indent", {"type": 'TAB', "value": 'PRESS'}, None), - ("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), - ("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), - ], - }, - ), - ( - "Clip", - {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("clip.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), - ("clip.tools", {"type": 'T', "value": 'PRESS'}, None), - ("clip.properties", {"type": 'N', "value": 'PRESS'}, None), - ( - "clip.track_markers", - {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("backwards", True), - ("sequence", False), - ], - } - ), - ( - "clip.track_markers", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("backwards", False), - ("sequence", False), - ], - } - ), - ( - "clip.track_markers", - {"type": 'T', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("backwards", False), - ("sequence", True), - ], - } - ), - ( - "clip.track_markers", - {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("backwards", True), - ("sequence", True), - ], - } - ), - ( - "wm.context_toggle_enum", - {"type": 'TAB', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.mode'), - ("value_1", 'TRACKING'), - ("value_2", 'MASK'), - ], - } - ), - ("clip.solve_camera", {"type": 'S', "value": 'PRESS', "shift": True}, None), - ( - "clip.set_solver_keyframe", - {"type": 'Q', "value": 'PRESS'}, - { - "properties": [ - ("keyframe", 'KEYFRAME_A'), - ], - } - ), - ( - "clip.set_solver_keyframe", - {"type": 'E', "value": 'PRESS'}, - { - "properties": [ - ("keyframe", 'KEYFRAME_B'), - ], - } - ), - ("clip.prefetch", {"type": 'P', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Clip Editor", - {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), - ("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), - ("clip.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), - ("clip.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("clip.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), - ("clip.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), - ("clip.view_zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), - ("clip.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), - ("clip.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), - ("clip.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("ratio", 8.0), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("ratio", 4.0), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("ratio", 2.0), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_8', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("ratio", 8.0), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("ratio", 4.0), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_2', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("ratio", 2.0), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_1', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 1.0), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_2', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 0.5), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_4', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 0.25), - ], - } - ), - ( - "clip.view_zoom_ratio", - {"type": 'NUMPAD_8', "value": 'PRESS'}, - { - "properties": [ - ("ratio", 0.125), - ], - } - ), - ("clip.view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ( - "clip.view_all", - {"type": 'F', "value": 'PRESS'}, - { - "properties": [ - ("fit_view", True), - ], - } - ), - ("clip.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ("clip.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("clip.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), - ( - "clip.frame_jump", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("position", 'PATHSTART'), - ], - } - ), - ( - "clip.frame_jump", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, - { - "properties": [ - ("position", 'PATHEND'), - ], - } - ), - ( - "clip.frame_jump", - {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("position", 'FAILEDPREV'), - ], - } - ), - ( - "clip.frame_jump", - {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("position", 'PATHSTART'), - ], - } - ), - ("clip.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ( - "clip.select", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "clip.select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "clip.select_all", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "clip.select_all", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("clip.select_border", {"type": 'B', "value": 'PRESS'}, None), - ("clip.select_circle", {"type": 'C', "value": 'PRESS'}, None), - ( - "wm.call_menu", - {"type": 'G', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("name", 'CLIP_MT_select_grouped'), - ], - } - ), - ( - "clip.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, - { - "properties": [ - ("deselect", False), - ], - } - ), - ( - "clip.select_lasso", - {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, - { - "properties": [ - ("deselect", True), - ], - } - ), - ("clip.add_marker_slide", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), - ("clip.delete_marker", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), - ("clip.delete_marker", {"type": 'X', "value": 'PRESS', "shift": True}, None), - ("clip.slide_marker", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), - ( - "clip.disable_markers", - {"type": 'D', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ("clip.delete_track", {"type": 'DEL', "value": 'PRESS'}, None), - ("clip.delete_track", {"type": 'X', "value": 'PRESS'}, None), - ( - "clip.lock_tracks", - {"type": 'L', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'LOCK'), - ], - } - ), - ( - "clip.lock_tracks", - {"type": 'L', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("action", 'UNLOCK'), - ], - } - ), - ( - "clip.hide_tracks", - {"type": 'H', "value": 'PRESS'}, - { - "properties": [ - ("unselected", False), - ], - } - ), - ( - "clip.hide_tracks", - {"type": 'H', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("unselected", True), - ], - } - ), - ("clip.hide_tracks_clear", {"type": 'H', "value": 'PRESS', "alt": True}, None), - ("clip.slide_plane_marker", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ("clip.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), - ("clip.keyframe_delete", {"type": 'I', "value": 'PRESS', "alt": True}, None), - ("clip.join_tracks", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), - ( - "wm.call_menu", - {"type": 'W', "value": 'PRESS'}, - { - "properties": [ - ("name", 'CLIP_MT_tracking_specials'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.lock_selection'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'D', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'space_data.show_disabled'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'S', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("data_path", 'space_data.show_marker_search'), - ], - } - ), - ( - "wm.context_toggle", - {"type": 'M', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.use_mute_footage'), - ], - } - ), - ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ( - "clip.clear_track_path", - {"type": 'T', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("action", 'REMAINED'), - ("clear_active", False), - ], - } - ), - ( - "clip.clear_track_path", - {"type": 'T', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("action", 'UPTO'), - ("clear_active", False), - ], - } - ), - ( - "clip.clear_track_path", - {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("action", 'ALL'), - ("clear_active", False), - ], - } - ), - ("clip.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ( - "wm.context_set_enum", - {"type": 'COMMA', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'BOUNDING_BOX_CENTER'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'MEDIAN_POINT'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'PERIOD', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'CURSOR'), - ], - } - ), - ( - "wm.context_set_enum", - {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("data_path", 'space_data.pivot_point'), - ("value", 'INDIVIDUAL_ORIGINS'), - ], - } - ), - ("clip.copy_tracks", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), - ("clip.paste_tracks", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), - ], - }, - ), - ( - "Clip Graph Editor", - {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ("clip.change_frame", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), - ( - "clip.graph_select", - {"type": 'SELECTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", False), - ], - } - ), - ( - "clip.graph_select", - {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("extend", True), - ], - } - ), - ( - "clip.graph_select_all_markers", - {"type": 'A', "value": 'PRESS'}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ( - "clip.graph_select_all_markers", - {"type": 'I', "value": 'PRESS', "ctrl": True}, - { - "properties": [ - ("action", 'INVERT'), - ], - } - ), - ("clip.graph_select_border", {"type": 'B', "value": 'PRESS'}, None), - ("clip.graph_delete_curve", {"type": 'DEL', "value": 'PRESS'}, None), - ("clip.graph_delete_curve", {"type": 'X', "value": 'PRESS'}, None), - ("clip.graph_delete_knot", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), - ("clip.graph_delete_knot", {"type": 'X', "value": 'PRESS', "shift": True}, None), - ("clip.graph_view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ("clip.graph_view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ("clip.graph_center_current_frame", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), - ( - "wm.context_toggle", - {"type": 'L', "value": 'PRESS'}, - { - "properties": [ - ("data_path", 'space_data.lock_time_cursor'), - ], - } - ), - ( - "clip.clear_track_path", - {"type": 'T', "value": 'PRESS', "alt": True}, - { - "properties": [ - ("action", 'REMAINED'), - ("clear_active", True), - ], - } - ), - ( - "clip.clear_track_path", - {"type": 'T', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("action", 'UPTO'), - ("clear_active", True), - ], - } - ), - ( - "clip.clear_track_path", - {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, - { - "properties": [ - ("action", 'ALL'), - ("clear_active", True), - ], - } - ), - ( - "clip.graph_disable_markers", - {"type": 'D', "value": 'PRESS', "shift": True}, - { - "properties": [ - ("action", 'TOGGLE'), - ], - } - ), - ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), - ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), - ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), - ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), - ], - }, - ), - ( - "Clip Dopesheet Editor", - {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, - { - "items": [ - ( - "clip.dopesheet_select_channel", - {"type": 'LEFTMOUSE', "value": 'PRESS'}, - { - "properties": [ - ("extend", True), - ], - } - ), - ("clip.dopesheet_view_all", {"type": 'HOME', "value": 'PRESS'}, None), - ("clip.dopesheet_view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), - ], - }, - ), - ( - "3D View Tool: OBJECT, Move", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ( - "transform.translate", - {"type": 'EVT_TWEAK_A', "value": 'ANY'}, - { - "properties": [ - ("release_confirm", True), - ], - } - ), - ], - }, - ), - ( - "3D View Tool: OBJECT, Rotate", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ( - "transform.rotate", - {"type": 'EVT_TWEAK_A', "value": 'ANY'}, - { - "properties": [ - ("release_confirm", True), - ], - } - ), - ], - }, - ), - ( - "3D View Tool: OBJECT, Scale", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ( - "transform.resize", - {"type": 'EVT_TWEAK_A', "value": 'ANY'}, - { - "properties": [ - ("release_confirm", True), - ], - } - ), - ], - }, - ), - ( - "3D View Tool: OBJECT, Ruler/Protractor", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("view3d.ruler_add", {"type": 'EVT_TWEAK_A', "value": 'ANY'}, None), - ], - }, - ), - ( - "3D View Tool: PARTICLE, Cursor Click", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("view3d.cursor3d", {"type": 'ACTIONMOUSE', "value": 'CLICK'}, None), - ], - }, - ), - ( - "Spot Lamp Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Area Lamp Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), - ( - "Target Lamp Widgets", - {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - { - "items": [ - ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), - ], - }, - ), -] +keyconfig_data = \ +[("Window", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("wm.window_new", {"type": 'W', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("wm.read_homefile", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("wm.save_homefile", {"type": 'U', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'O', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("name", 'INFO_MT_file_open_recent'), + ], + }, + ), + ("wm.open_mainfile", {"type": 'O', "value": 'PRESS', "ctrl": True}, None), + ("wm.open_mainfile", {"type": 'F1', "value": 'PRESS'}, None), + ("wm.link", {"type": 'O', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("wm.append", {"type": 'F1', "value": 'PRESS', "shift": True}, None), + ("wm.save_mainfile", {"type": 'S', "value": 'PRESS', "ctrl": True}, None), + ("wm.save_mainfile", {"type": 'W', "value": 'PRESS', "ctrl": True}, None), + ("wm.save_as_mainfile", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("wm.save_as_mainfile", {"type": 'F2', "value": 'PRESS'}, None), + ("wm.save_as_mainfile", + {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("copy", True), + ], + }, + ), + ("wm.window_fullscreen_toggle", {"type": 'F11', "value": 'PRESS', "alt": True}, None), + ("wm.quit_blender", {"type": 'Q', "value": 'PRESS', "ctrl": True}, None), + ("wm.doc_view_manual_ui_context", {"type": 'F1', "value": 'PRESS', "alt": True}, None), + ("wm.redraw_timer", {"type": 'T', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("wm.debug_menu", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("wm.call_menu", + {"type": 'NDOF_BUTTON_MENU', "value": 'PRESS'}, + {"properties": + [("name", 'USERPREF_MT_ndof_settings'), + ], + }, + ), + ("wm.search_menu", {"type": 'SPACE', "value": 'PRESS'}, None), + ("wm.context_set_enum", + {"type": 'F3', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'NODE_EDITOR'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F4', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'CONSOLE'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F5', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'VIEW_3D'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F6', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'GRAPH_EDITOR'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F7', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'PROPERTIES'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F8', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'SEQUENCE_EDITOR'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F9', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'OUTLINER'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F10', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'IMAGE_EDITOR'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F11', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'TEXT_EDITOR'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'F12', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'area.type'), + ("value", 'DOPESHEET_EDITOR'), + ], + }, + ), + ("wm.context_scale_float", + {"type": 'NDOF_BUTTON_PLUS', "value": 'PRESS'}, + {"properties": + [("data_path", 'user_preferences.inputs.ndof_sensitivity'), + ("value", 1.1), + ], + }, + ), + ("wm.context_scale_float", + {"type": 'NDOF_BUTTON_MINUS', "value": 'PRESS'}, + {"properties": + [("data_path", 'user_preferences.inputs.ndof_sensitivity'), + ("value", 1.0), + ], + }, + ), + ("wm.context_scale_float", + {"type": 'NDOF_BUTTON_PLUS', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'user_preferences.inputs.ndof_sensitivity'), + ("value", 1.5), + ], + }, + ), + ("wm.context_scale_float", + {"type": 'NDOF_BUTTON_MINUS', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'user_preferences.inputs.ndof_sensitivity'), + ("value", 0.6666667), + ], + }, + ), + ("info.reports_display_update", {"type": 'TIMER_REPORT', "value": 'ANY', "any": True}, None), + ], + }, + ), + ("Screen", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("screen.animation_step", {"type": 'TIMER0', "value": 'ANY', "any": True}, None), + ("screen.region_blend", {"type": 'TIMERREGION', "value": 'ANY', "any": True}, None), + ("screen.screen_set", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, + {"properties": + [("delta", 1), + ], + }, + ), + ("screen.screen_set", + {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, + {"properties": + [("delta", -1), + ], + }, + ), + ("screen.screen_full_area", {"type": 'SPACE', "value": 'PRESS', "shift": True}, None), + ("screen.screen_full_area", + {"type": 'SPACE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("use_hide_panels", True), + ], + }, + ), + ("screen.screenshot", {"type": 'F3', "value": 'PRESS', "ctrl": True}, None), + ("screen.screencast", {"type": 'F3', "value": 'PRESS', "alt": True}, None), + ("screen.space_context_cycle", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + {"properties": + [("direction", 'NEXT'), + ], + }, + ), + ("screen.space_context_cycle", + {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("direction", 'PREV'), + ], + }, + ), + ("screen.region_quadview", {"type": 'Q', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("screen.repeat_history", {"type": 'F3', "value": 'PRESS'}, None), + ("screen.repeat_last", {"type": 'R', "value": 'PRESS', "shift": True}, None), + ("screen.region_flip", {"type": 'F5', "value": 'PRESS'}, None), + ("screen.redo_last", {"type": 'F6', "value": 'PRESS'}, None), + ("script.reload", {"type": 'F8', "value": 'PRESS'}, None), + ("file.execute", {"type": 'RET', "value": 'PRESS'}, None), + ("file.execute", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), + ("file.cancel", {"type": 'ESC', "value": 'PRESS'}, None), + ("ed.undo", {"type": 'Z', "value": 'PRESS', "ctrl": True}, None), + ("ed.redo", {"type": 'Z', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("ed.undo_history", {"type": 'Z', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("render.render", + {"type": 'F12', "value": 'PRESS'}, + {"properties": + [("use_viewport", True), + ], + }, + ), + ("render.render", + {"type": 'F12', "value": 'PRESS', "ctrl": True}, + {"properties": + [("animation", True), + ("use_viewport", True), + ], + }, + ), + ("render.view_cancel", {"type": 'ESC', "value": 'PRESS'}, None), + ("render.view_show", {"type": 'F11', "value": 'PRESS'}, None), + ("render.play_rendered_anim", {"type": 'F11', "value": 'PRESS', "ctrl": True}, None), + ("screen.userpref_show", {"type": 'U', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ], + }, + ), + ("User Interface", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("ui.eyedropper_color", {"type": 'E', "value": 'PRESS'}, None), + ("ui.eyedropper_colorband", {"type": 'E', "value": 'PRESS'}, None), + ("ui.eyedropper_colorband_point", {"type": 'E', "value": 'PRESS', "alt": True}, None), + ("ui.eyedropper_id", {"type": 'E', "value": 'PRESS'}, None), + ("ui.eyedropper_depth", {"type": 'E', "value": 'PRESS'}, None), + ("ui.copy_data_path_button", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("ui.copy_data_path_button", + {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("full_path", True), + ], + }, + ), + ("anim.keyframe_insert_button", {"type": 'I', "value": 'PRESS'}, None), + ("anim.keyframe_delete_button", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("anim.keyframe_clear_button", {"type": 'I', "value": 'PRESS', "shift": True, "alt": True}, None), + ("anim.driver_button_add", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), + ("anim.driver_button_remove", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("anim.keyingset_button_add", {"type": 'K', "value": 'PRESS'}, None), + ("anim.keyingset_button_remove", {"type": 'K', "value": 'PRESS', "alt": True}, None), + ], + }, + ), + ("View2D", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("view2d.scroller_activate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("view2d.scroller_activate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), + ("view2d.pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("view2d.scroll_right", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view2d.scroll_left", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None), + ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None), + ("view2d.ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), + ("view2d.zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), + ("view2d.zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), + ("view2d.zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("view2d.zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("view2d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("view2d.smoothview", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), + ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_right", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_left", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), + ("view2d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view2d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("view2d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), + ], + }, + ), + ("Header", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("screen.header_toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ], + }, + ), + ("View2D Buttons List", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("view2d.scroller_activate", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("view2d.scroller_activate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view2d.pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view2d.pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("view2d.scroll_down", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_up", {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, None), + ("view2d.scroll_down", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + {"properties": + [("page", True), + ], + }, + ), + ("view2d.scroll_up", + {"type": 'PAGE_UP', "value": 'PRESS'}, + {"properties": + [("page", True), + ], + }, + ), + ("view2d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view2d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("view2d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("view2d.zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("view2d.zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("view2d.reset", {"type": 'HOME', "value": 'PRESS'}, None), + ], + }, + ), + ("Frames", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("screen.frame_offset", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("delta", 10), + ], + }, + ), + ("screen.frame_offset", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("delta", -10), + ], + }, + ), + ("screen.frame_offset", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + {"properties": + [("delta", -1), + ], + }, + ), + ("screen.frame_offset", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + {"properties": + [("delta", 1), + ], + }, + ), + ("screen.frame_offset", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("delta", 1), + ], + }, + ), + ("screen.frame_offset", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("delta", -1), + ], + }, + ), + ("screen.frame_jump", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("end", True), + ], + }, + ), + ("screen.frame_jump", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("end", False), + ], + }, + ), + ("screen.frame_jump", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("end", True), + ], + }, + ), + ("screen.frame_jump", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("end", False), + ], + }, + ), + ("screen.keyframe_jump", + {"type": 'UP_ARROW', "value": 'PRESS'}, + {"properties": + [("next", True), + ], + }, + ), + ("screen.keyframe_jump", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + {"properties": + [("next", False), + ], + }, + ), + ("screen.keyframe_jump", + {"type": 'MEDIA_LAST', "value": 'PRESS'}, + {"properties": + [("next", True), + ], + }, + ), + ("screen.keyframe_jump", + {"type": 'MEDIA_FIRST', "value": 'PRESS'}, + {"properties": + [("next", False), + ], + }, + ), + ("screen.animation_play", {"type": 'A', "value": 'PRESS', "alt": True}, None), + ("screen.animation_play", + {"type": 'A', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("reverse", True), + ], + }, + ), + ("screen.animation_cancel", {"type": 'ESC', "value": 'PRESS'}, None), + ("screen.animation_play", {"type": 'MEDIA_PLAY', "value": 'PRESS'}, None), + ("screen.animation_cancel", {"type": 'MEDIA_STOP', "value": 'PRESS'}, None), + ], + }, + ), + ("Property Editor", + {"space_type": 'PROPERTIES', "region_type": 'WINDOW'}, + {"items": + [("buttons.toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ], + }, + ), + ("Info", + {"space_type": 'INFO', "region_type": 'WINDOW'}, + {"items": + [("info.select_pick", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), + ("info.select_all_toggle", {"type": 'A', "value": 'PRESS'}, None), + ("info.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("info.report_replay", {"type": 'R', "value": 'PRESS'}, None), + ("info.report_delete", {"type": 'X', "value": 'PRESS'}, None), + ("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("Outliner", + {"space_type": 'OUTLINER', "region_type": 'WINDOW'}, + {"items": + [("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), + ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ("outliner.item_activate", + {"type": 'LEFTMOUSE', "value": 'CLICK'}, + {"properties": + [("extend", False), + ("recursive", False), + ], + }, + ), + ("outliner.item_activate", + {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, + {"properties": + [("extend", True), + ("recursive", False), + ], + }, + ), + ("outliner.item_activate", + {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True}, + {"properties": + [("extend", False), + ("recursive", True), + ], + }, + ), + ("outliner.item_activate", + {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ("recursive", True), + ], + }, + ), + ("outliner.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("outliner.item_openclose", + {"type": 'RET', "value": 'PRESS'}, + {"properties": + [("all", False), + ], + }, + ), + ("outliner.item_openclose", + {"type": 'RET', "value": 'PRESS', "shift": True}, + {"properties": + [("all", True), + ], + }, + ), + ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("outliner.operation", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), + ("outliner.show_hierarchy", {"type": 'HOME', "value": 'PRESS'}, None), + ("outliner.show_active", {"type": 'PERIOD', "value": 'PRESS'}, None), + ("outliner.show_active", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("outliner.scroll_page", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + {"properties": + [("up", False), + ], + }, + ), + ("outliner.scroll_page", + {"type": 'PAGE_UP', "value": 'PRESS'}, + {"properties": + [("up", True), + ], + }, + ), + ("outliner.show_one_level", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("outliner.show_one_level", + {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, + {"properties": + [("open", False), + ], + }, + ), + ("outliner.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("outliner.expanded_toggle", {"type": 'A', "value": 'PRESS', "shift": True}, None), + ("outliner.keyingset_add_selected", {"type": 'K', "value": 'PRESS'}, None), + ("outliner.keyingset_remove_selected", {"type": 'K', "value": 'PRESS', "alt": True}, None), + ("anim.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), + ("anim.keyframe_delete", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("outliner.drivers_add_selected", {"type": 'D', "value": 'PRESS'}, None), + ("outliner.drivers_delete_selected", {"type": 'D', "value": 'PRESS', "alt": True}, None), + ("outliner.collection_new", {"type": 'C', "value": 'PRESS'}, None), + ("outliner.collection_delete", {"type": 'X', "value": 'PRESS'}, None), + ], + }, + ), + ("3D View Generic", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("view3d.properties", {"type": 'N', "value": 'PRESS'}, None), + ("view3d.toolshelf", {"type": 'T', "value": 'PRESS'}, None), + ], + }, + ), + ("Grease Pencil", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("gpencil.draw", + {"type": 'LEFTMOUSE', "value": 'PRESS', "key_modifier": 'D'}, + {"properties": + [("mode", 'DRAW'), + ("wait_for_input", False), + ], + }, + ), + ("gpencil.draw", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'D'}, + {"properties": + [("mode", 'DRAW_STRAIGHT'), + ("wait_for_input", False), + ], + }, + ), + ("gpencil.draw", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'D'}, + {"properties": + [("mode", 'DRAW_POLY'), + ("wait_for_input", False), + ], + }, + ), + ("gpencil.draw", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "key_modifier": 'D'}, + {"properties": + [("mode", 'ERASER'), + ("wait_for_input", False), + ], + }, + ), + ("gpencil.draw", + {"type": 'ERASER', "value": 'PRESS'}, + {"properties": + [("mode", 'ERASER'), + ("wait_for_input", False), + ], + }, + ), + ("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS', "key_modifier": 'D'}, None), + ("wm.call_menu_pie", + {"type": 'Q', "value": 'PRESS', "key_modifier": 'D'}, + {"properties": + [("name", 'GPENCIL_MT_pie_tool_palette'), + ], + }, + ), + ("wm.call_menu_pie", + {"type": 'W', "value": 'PRESS', "key_modifier": 'D'}, + {"properties": + [("name", 'GPENCIL_MT_pie_settings_palette'), + ], + }, + ), + ("gpencil.blank_frame_add", {"type": 'B', "value": 'PRESS', "key_modifier": 'D'}, None), + ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "key_modifier": 'D'}, None), + ], + }, + ), + ("Grease Pencil Stroke Edit Mode", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("wm.call_menu_pie", + {"type": 'E', "value": 'PRESS', "key_modifier": 'D'}, + {"properties": + [("name", 'GPENCIL_MT_pie_sculpt'), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path_primary", 'user_preferences.edit.grease_pencil_eraser_radius'), + ], + }, + ), + ("gpencil.interpolate", {"type": 'E', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("gpencil.interpolate_sequence", {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("gpencil.brush_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS', "key_modifier": 'E'}, + {"properties": + [("wait_for_input", False), + ], + }, + ), + ("gpencil.brush_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "key_modifier": 'E'}, + {"properties": + [("wait_for_input", False), + ], + }, + ), + ("gpencil.brush_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "key_modifier": 'E'}, + {"properties": + [("wait_for_input", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.strength'), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.size'), + ], + }, + ), + ("gpencil.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("gpencil.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("gpencil.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("gpencil.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("gpencil.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("gpencil.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("gpencil.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("gpencil.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("gpencil.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), + ("gpencil.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ("toggle", True), + ], + }, + ), + ("gpencil.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("entire_strokes", True), + ], + }, + ), + ("gpencil.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("gpencil.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("gpencil.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_gpencil_delete'), + ], + }, + ), + ("wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_gpencil_delete'), + ], + }, + ), + ("gpencil.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.dissolve", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "shift": True}, None), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'GPENCIL_MT_gpencil_edit_specials'), + ], + }, + ), + ("gpencil.stroke_join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.stroke_join", + {"type": 'J', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'JOINCOPY'), + ], + }, + ), + ("gpencil.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'S', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'GPENCIL_MT_snap'), + ], + }, + ), + ("gpencil.convert", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ("gpencil.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("gpencil.hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("gpencil.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("gpencil.selection_opacity_toggle", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), + ("gpencil.layer_isolate", {"type": 'NUMPAD_ASTERIX', "value": 'PRESS'}, None), + ("gpencil.move_to_layer", {"type": 'M', "value": 'PRESS'}, None), + ("gpencil.brush_select", + {"type": 'ONE', "value": 'PRESS'}, + {"properties": + [("index", 0), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'TWO', "value": 'PRESS'}, + {"properties": + [("index", 1), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'THREE', "value": 'PRESS'}, + {"properties": + [("index", 2), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'FOUR', "value": 'PRESS'}, + {"properties": + [("index", 3), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'FIVE', "value": 'PRESS'}, + {"properties": + [("index", 4), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'SIX', "value": 'PRESS'}, + {"properties": + [("index", 5), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'SEVEN', "value": 'PRESS'}, + {"properties": + [("index", 6), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'EIGHT', "value": 'PRESS'}, + {"properties": + [("index", 7), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'NINE', "value": 'PRESS'}, + {"properties": + [("index", 8), + ], + }, + ), + ("gpencil.brush_select", + {"type": 'ZERO', "value": 'PRESS'}, + {"properties": + [("index", 9), + ], + }, + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ("transform.bend", {"type": 'W', "value": 'PRESS', "shift": True}, None), + ("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None), + ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("transform.transform", + {"type": 'S', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'GPENCIL_SHRINKFATTEN'), + ], + }, + ), + ("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'CONNECTED'), + ], + }, + ), + ], + }, + ), + ("Face Mask", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("paint.face_select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("paint.face_select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("paint.face_select_hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("paint.face_select_hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("paint.face_select_reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("paint.face_select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("paint.face_select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("deselect", False), + ], + }, + ), + ("paint.face_select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ], + }, + ), + ("Weight Paint Vertex Selection", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("paint.vert_select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("paint.vert_select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("view3d.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("view3d.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("view3d.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ], + }, + ), + ("Pose", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'INFO_MT_add'), + ], + }, + ), + ("pose.hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("pose.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("pose.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("wm.call_menu", + {"type": 'A', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_pose_apply'), + ], + }, + ), + ("pose.rot_clear", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("pose.loc_clear", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ("pose.scale_clear", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("pose.quaternions_flip", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("pose.rotation_mode_set", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("pose.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("pose.paste", + {"type": 'V', "value": 'PRESS', "ctrl": True}, + {"properties": + [("flipped", False), + ], + }, + ), + ("pose.paste", + {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("flipped", True), + ], + }, + ), + ("pose.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("pose.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("pose.select_parent", {"type": 'P', "value": 'PRESS', "shift": True}, None), + ("pose.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("direction", 'PARENT'), + ("extend", False), + ], + }, + ), + ("pose.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'PARENT'), + ("extend", True), + ], + }, + ), + ("pose.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("direction", 'CHILD'), + ("extend", False), + ], + }, + ), + ("pose.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'CHILD'), + ("extend", True), + ], + }, + ), + ("pose.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("pose.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("pose.select_mirror", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("pose.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("pose.constraints_clear", {"type": 'C', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("pose.ik_add", {"type": 'I', "value": 'PRESS', "shift": True}, None), + ("pose.ik_clear", {"type": 'I', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("wm.call_menu", + {"type": 'G', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_pose_group'), + ], + }, + ), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'VIEW3D_MT_bone_options_toggle'), + ], + }, + ), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_bone_options_enable'), + ], + }, + ), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS', "alt": True}, + {"properties": + [("name", 'VIEW3D_MT_bone_options_disable'), + ], + }, + ), + ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None), + ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None), + ("pose.bone_layers", {"type": 'M', "value": 'PRESS'}, None), + ("wm.context_toggle", + {"type": 'Z', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.overlay.show_bone_select'), + ], + }, + ), + ("transform.transform", + {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("mode", 'BONE_SIZE'), + ], + }, + ), + ("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None), + ("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("anim.keying_set_active_set", {"type": 'I', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("poselib.browse_interactive", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("poselib.pose_add", {"type": 'L', "value": 'PRESS', "shift": True}, None), + ("poselib.pose_remove", {"type": 'L', "value": 'PRESS', "alt": True}, None), + ("poselib.pose_rename", {"type": 'L', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("pose.push", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), + ("pose.relax", {"type": 'E', "value": 'PRESS', "alt": True}, None), + ("pose.breakdown", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_pose_specials'), + ], + }, + ), + ("wm.call_menu", + {"type": 'P', "value": 'PRESS', "alt": True}, + {"properties": + [("name", 'VIEW3D_MT_pose_propagate'), + ], + }, + ), + ], + }, + ), + ("Object Mode", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.use_proportional_edit_objects'), + ], + }, + ), + ("object.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("object.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("object.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("object.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("object.select_linked", {"type": 'L', "value": 'PRESS', "shift": True}, None), + ("object.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("object.select_mirror", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("object.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("direction", 'PARENT'), + ("extend", False), + ], + }, + ), + ("object.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'PARENT'), + ("extend", True), + ], + }, + ), + ("object.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("direction", 'CHILD'), + ("extend", False), + ], + }, + ), + ("object.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'CHILD'), + ("extend", True), + ], + }, + ), + ("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("object.parent_no_inverse_set", {"type": 'P', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("object.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("object.track_set", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), + ("object.track_clear", {"type": 'T', "value": 'PRESS', "alt": True}, None), + ("object.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("object.constraints_clear", {"type": 'C', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("object.location_clear", + {"type": 'G', "value": 'PRESS', "alt": True}, + {"properties": + [("clear_delta", False), + ], + }, + ), + ("object.rotation_clear", + {"type": 'R', "value": 'PRESS', "alt": True}, + {"properties": + [("clear_delta", False), + ], + }, + ), + ("object.scale_clear", + {"type": 'S', "value": 'PRESS', "alt": True}, + {"properties": + [("clear_delta", False), + ], + }, + ), + ("object.origin_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("object.delete", + {"type": 'X', "value": 'PRESS'}, + {"properties": + [("use_global", False), + ], + }, + ), + ("object.delete", + {"type": 'X', "value": 'PRESS', "shift": True}, + {"properties": + [("use_global", True), + ], + }, + ), + ("object.delete", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("use_global", False), + ], + }, + ), + ("object.delete", + {"type": 'DEL', "value": 'PRESS', "shift": True}, + {"properties": + [("use_global", True), + ], + }, + ), + ("wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'INFO_MT_add'), + ], + }, + ), + ("object.duplicates_make_real", {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("wm.call_menu", + {"type": 'A', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_object_apply'), + ], + }, + ), + ("wm.call_menu", + {"type": 'U', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_make_single_user'), + ], + }, + ), + ("wm.call_menu", + {"type": 'L', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_make_links'), + ], + }, + ), + ("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True}, None), + ("object.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ("object.convert", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ("object.proxy_make", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("object.make_local", {"type": 'L', "value": 'PRESS'}, None), + ("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None), + ("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("anim.keying_set_active_set", {"type": 'I', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("collection.create", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("collection.objects_remove", {"type": 'G', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("collection.objects_remove_all", {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("collection.objects_add_active", {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("collection.objects_remove_active", {"type": 'G', "value": 'PRESS', "shift": True, "alt": True}, None), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_object_specials'), + ], + }, + ), + ("object.data_transfer", {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("object.subdivision_set", + {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 0), + ], + }, + ), + ("object.subdivision_set", + {"type": 'ONE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 1), + ], + }, + ), + ("object.subdivision_set", + {"type": 'TWO', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 2), + ], + }, + ), + ("object.subdivision_set", + {"type": 'THREE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 3), + ], + }, + ), + ("object.subdivision_set", + {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 4), + ], + }, + ), + ("object.subdivision_set", + {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 5), + ], + }, + ), + ("object.move_to_collection", {"type": 'M', "value": 'PRESS'}, None), + ], + }, + ), + ("Paint Curve", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("paintcurve.add_point_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("paintcurve.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), + ("paintcurve.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("paintcurve.slide", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("paintcurve.slide", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("align", True), + ], + }, + ), + ("paintcurve.select", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("toggle", True), + ], + }, + ), + ("paintcurve.cursor", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("paintcurve.delete_point", {"type": 'X', "value": 'PRESS'}, None), + ("paintcurve.delete_point", {"type": 'DEL', "value": 'PRESS'}, None), + ("paintcurve.draw", {"type": 'RET', "value": 'PRESS'}, None), + ("paintcurve.draw", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ], + }, + ), + ("Curve", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'INFO_MT_edit_curve_add'), + ], + }, + ), + ("curve.handle_type_set", {"type": 'V', "value": 'PRESS'}, None), + ("curve.vertex_add", {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, None), + ("curve.draw", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("wait_for_input", False), + ], + }, + ), + ("curve.draw", + {"type": 'PEN', "value": 'PRESS', "shift": True}, + {"properties": + [("wait_for_input", False), + ], + }, + ), + ("curve.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("curve.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("curve.select_row", {"type": 'R', "value": 'PRESS', "shift": True}, None), + ("curve.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("curve.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("curve.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("curve.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("curve.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("deselect", False), + ], + }, + ), + ("curve.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("curve.shortest_path_pick", {"type": 'SELECTMOUSE', "value": 'CLICK', "ctrl": True}, None), + ("curve.separate", {"type": 'P', "value": 'PRESS'}, None), + ("curve.split", {"type": 'Y', "value": 'PRESS'}, None), + ("curve.extrude_move", {"type": 'E', "value": 'PRESS'}, None), + ("curve.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("curve.make_segment", {"type": 'F', "value": 'PRESS'}, None), + ("curve.cyclic_toggle", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ("wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_curve_delete'), + ], + }, + ), + ("wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_curve_delete'), + ], + }, + ), + ("curve.dissolve_verts", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("curve.dissolve_verts", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), + ("curve.tilt_clear", {"type": 'T', "value": 'PRESS', "alt": True}, None), + ("transform.tilt", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), + ("transform.transform", + {"type": 'S', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'CURVE_SHRINKFATTEN'), + ], + }, + ), + ("curve.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("curve.hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("curve.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("curve.normals_make_consistent", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_curve_specials'), + ], + }, + ), + ("wm.call_menu", + {"type": 'H', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_hook'), + ], + }, + ), + ("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'CONNECTED'), + ], + }, + ), + ], + }, + ), + ("Image Paint", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("paint.image_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + {"properties": + [("mode", 'NORMAL'), + ], + }, + ), + ("paint.image_paint", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'INVERT'), + ], + }, + ), + ("paint.brush_colors_flip", {"type": 'X', "value": 'PRESS'}, None), + ("paint.grab_clone", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ("paint.sample_color", {"type": 'S', "value": 'PRESS'}, None), + ("brush.active_index_set", + {"type": 'ONE', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 0), + ], + }, + ), + ("brush.active_index_set", + {"type": 'TWO', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 1), + ], + }, + ), + ("brush.active_index_set", + {"type": 'THREE', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 2), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 3), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 4), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SIX', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 5), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 6), + ], + }, + ), + ("brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 7), + ], + }, + ), + ("brush.active_index_set", + {"type": 'NINE', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 8), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS'}, + {"properties": + [("mode", 'image_paint'), + ("index", 9), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ONE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 10), + ], + }, + ), + ("brush.active_index_set", + {"type": 'TWO', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 11), + ], + }, + ), + ("brush.active_index_set", + {"type": 'THREE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 12), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 13), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 14), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SIX', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 15), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 16), + ], + }, + ), + ("brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 17), + ], + }, + ), + ("brush.active_index_set", + {"type": 'NINE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 18), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'image_paint'), + ("index", 19), + ], + }, + ), + ("brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 0.9), + ], + }, + ), + ("brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 1.1111112), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("data_path_primary", 'tool_settings.image_paint.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), + ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.image_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", 'space_data.zoom'), + ("image_id", 'tool_settings.image_paint.brush'), + ("secondary_tex", True), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path_primary", 'tool_settings.image_paint.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), + ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.image_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.image_paint.brush'), + ("secondary_tex", True), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path_primary", 'tool_settings.image_paint.brush.texture_slot.angle'), + ("data_path_secondary", ''), + ("use_secondary", ''), + ("rotation_path", 'tool_settings.image_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.image_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.image_paint.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("data_path_primary", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), + ("data_path_secondary", ''), + ("use_secondary", ''), + ("rotation_path", 'tool_settings.image_paint.brush.mask_texture_slot.angle'), + ("color_path", 'tool_settings.image_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.image_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.image_paint.brush'), + ("secondary_tex", True), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS'}, + {"properties": + [("mode", 'TRANSLATION'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'SCALE'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'ROTATION'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'TRANSLATION'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("mode", 'SCALE'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("mode", 'ROTATION'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'M', "value": 'PRESS'}, + {"properties": + [("data_path", 'image_paint_object.data.use_paint_mask'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'S', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.image_paint.brush.use_smooth_stroke'), + ], + }, + ), + ("wm.call_menu", + {"type": 'R', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_angle_control'), + ], + }, + ), + ("wm.context_menu_enum", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.image_paint.brush.stroke_method'), + ], + }, + ), + ], + }, + ), + ("Vertex Paint", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("paint.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("paint.brush_colors_flip", {"type": 'X', "value": 'PRESS'}, None), + ("paint.sample_color", {"type": 'S', "value": 'PRESS'}, None), + ("paint.vertex_color_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), + ("brush.active_index_set", + {"type": 'ONE', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 0), + ], + }, + ), + ("brush.active_index_set", + {"type": 'TWO', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 1), + ], + }, + ), + ("brush.active_index_set", + {"type": 'THREE', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 2), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 3), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 4), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SIX', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 5), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 6), + ], + }, + ), + ("brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 7), + ], + }, + ), + ("brush.active_index_set", + {"type": 'NINE', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 8), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS'}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 9), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ONE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 10), + ], + }, + ), + ("brush.active_index_set", + {"type": 'TWO', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 11), + ], + }, + ), + ("brush.active_index_set", + {"type": 'THREE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 12), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 13), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 14), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SIX', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 15), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 16), + ], + }, + ), + ("brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 17), + ], + }, + ), + ("brush.active_index_set", + {"type": 'NINE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 18), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'vertex_paint'), + ("index", 19), + ], + }, + ), + ("brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 0.9), + ], + }, + ), + ("brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 1.1111112), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("data_path_primary", 'tool_settings.vertex_paint.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.vertex_paint.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path_primary", 'tool_settings.vertex_paint.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.vertex_paint.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path_primary", 'tool_settings.vertex_paint.brush.texture_slot.angle'), + ("data_path_secondary", ''), + ("use_secondary", ''), + ("rotation_path", 'tool_settings.vertex_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.vertex_paint.brush.cursor_color_add'), + ("fill_color_path", 'tool_settings.vertex_paint.brush.color'), + ("fill_color_override_path", 'tool_settings.unified_paint_settings.color'), + ("fill_color_override_test_path", 'tool_settings.unified_paint_settings.use_unified_color'), + ("zoom_path", ''), + ("image_id", 'tool_settings.vertex_paint.brush'), + ("secondary_tex", False), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS'}, + {"properties": + [("mode", 'TRANSLATION'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'SCALE'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'ROTATION'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'TRANSLATION'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("mode", 'SCALE'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("mode", 'ROTATION'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'M', "value": 'PRESS'}, + {"properties": + [("data_path", 'vertex_paint_object.data.use_paint_mask'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'S', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.vertex_paint.brush.use_smooth_stroke'), + ], + }, + ), + ("wm.call_menu", + {"type": 'R', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_angle_control'), + ], + }, + ), + ("wm.context_menu_enum", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.vertex_paint.brush.stroke_method'), + ], + }, + ), + ], + }, + ), + ("Weight Paint", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("paint.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("paint.weight_sample", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("paint.weight_sample_group", {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, None), + ("paint.weight_gradient", + {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("type", 'LINEAR'), + ], + }, + ), + ("paint.weight_gradient", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("type", 'RADIAL'), + ], + }, + ), + ("paint.weight_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), + ("brush.active_index_set", + {"type": 'ONE', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 0), + ], + }, + ), + ("brush.active_index_set", + {"type": 'TWO', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 1), + ], + }, + ), + ("brush.active_index_set", + {"type": 'THREE', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 2), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 3), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 4), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SIX', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 5), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 6), + ], + }, + ), + ("brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 7), + ], + }, + ), + ("brush.active_index_set", + {"type": 'NINE', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 8), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS'}, + {"properties": + [("mode", 'weight_paint'), + ("index", 9), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ONE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 10), + ], + }, + ), + ("brush.active_index_set", + {"type": 'TWO', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 11), + ], + }, + ), + ("brush.active_index_set", + {"type": 'THREE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 12), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 13), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 14), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SIX', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 15), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 16), + ], + }, + ), + ("brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 17), + ], + }, + ), + ("brush.active_index_set", + {"type": 'NINE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 18), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'weight_paint'), + ("index", 19), + ], + }, + ), + ("brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 0.9), + ], + }, + ), + ("brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 1.1111112), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("data_path_primary", 'tool_settings.weight_paint.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.weight_paint.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path_primary", 'tool_settings.weight_paint.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.weight_paint.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("data_path_primary", 'tool_settings.weight_paint.brush.weight'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.weight'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_weight'), + ("rotation_path", 'tool_settings.weight_paint.brush.texture_slot.angle'), + ("color_path", 'tool_settings.weight_paint.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.weight_paint.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.context_menu_enum", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.vertex_paint.brush.stroke_method'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'M', "value": 'PRESS'}, + {"properties": + [("data_path", 'weight_paint_object.data.use_paint_mask'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'V', "value": 'PRESS'}, + {"properties": + [("data_path", 'weight_paint_object.data.use_paint_mask_vertex'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'S', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.weight_paint.brush.use_smooth_stroke'), + ], + }, + ), + ], + }, + ), + ("Sculpt", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("sculpt.brush_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + {"properties": + [("mode", 'NORMAL'), + ], + }, + ), + ("sculpt.brush_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'INVERT'), + ], + }, + ), + ("sculpt.brush_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'SMOOTH'), + ], + }, + ), + ("paint.hide_show", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("action", 'SHOW'), + ("area", 'INSIDE'), + ], + }, + ), + ("paint.hide_show", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("action", 'HIDE'), + ("area", 'INSIDE'), + ], + }, + ), + ("paint.hide_show", + {"type": 'H', "value": 'PRESS', "alt": True}, + {"properties": + [("action", 'SHOW'), + ("area", 'ALL'), + ], + }, + ), + ("object.subdivision_set", + {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 0), + ], + }, + ), + ("object.subdivision_set", + {"type": 'ONE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 1), + ], + }, + ), + ("object.subdivision_set", + {"type": 'TWO', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 2), + ], + }, + ), + ("object.subdivision_set", + {"type": 'THREE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 3), + ], + }, + ), + ("object.subdivision_set", + {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 4), + ], + }, + ), + ("object.subdivision_set", + {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 5), + ], + }, + ), + ("paint.mask_flood_fill", + {"type": 'M', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'VALUE'), + ("value", 0.0), + ], + }, + ), + ("paint.mask_flood_fill", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'INVERT'), + ], + }, + ), + ("paint.mask_lasso_gesture", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("wm.context_toggle", + {"type": 'M', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'scene.tool_settings.sculpt.show_mask'), + ], + }, + ), + ("sculpt.dynamic_topology_toggle", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), + ("sculpt.set_detail_size", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("object.subdivision_set", + {"type": 'PAGE_UP', "value": 'PRESS'}, + {"properties": + [("level", 1), + ("relative", True), + ], + }, + ), + ("object.subdivision_set", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + {"properties": + [("level", -1), + ("relative", True), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ONE', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 0), + ], + }, + ), + ("brush.active_index_set", + {"type": 'TWO', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 1), + ], + }, + ), + ("brush.active_index_set", + {"type": 'THREE', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 2), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 3), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 4), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SIX', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 5), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 6), + ], + }, + ), + ("brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 7), + ], + }, + ), + ("brush.active_index_set", + {"type": 'NINE', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 8), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS'}, + {"properties": + [("mode", 'sculpt'), + ("index", 9), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ONE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 10), + ], + }, + ), + ("brush.active_index_set", + {"type": 'TWO', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 11), + ], + }, + ), + ("brush.active_index_set", + {"type": 'THREE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 12), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FOUR', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 13), + ], + }, + ), + ("brush.active_index_set", + {"type": 'FIVE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 14), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SIX', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 15), + ], + }, + ), + ("brush.active_index_set", + {"type": 'SEVEN', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 16), + ], + }, + ), + ("brush.active_index_set", + {"type": 'EIGHT', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 17), + ], + }, + ), + ("brush.active_index_set", + {"type": 'NINE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 18), + ], + }, + ), + ("brush.active_index_set", + {"type": 'ZERO', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'sculpt'), + ("index", 19), + ], + }, + ), + ("brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 0.9), + ], + }, + ), + ("brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 1.1111112), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("data_path_primary", 'tool_settings.sculpt.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.sculpt.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path_primary", 'tool_settings.sculpt.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.sculpt.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path_primary", 'tool_settings.sculpt.brush.texture_slot.angle'), + ("data_path_secondary", ''), + ("use_secondary", ''), + ("rotation_path", 'tool_settings.sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.sculpt.brush'), + ("secondary_tex", False), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS'}, + {"properties": + [("mode", 'TRANSLATION'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'SCALE'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'ROTATION'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'TRANSLATION'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("mode", 'SCALE'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("brush.stencil_control", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("mode", 'ROTATION'), + ("texmode", 'SECONDARY'), + ], + }, + ), + ("paint.brush_select", + {"type": 'X', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'DRAW'), + ], + }, + ), + ("paint.brush_select", + {"type": 'S', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'SMOOTH'), + ], + }, + ), + ("paint.brush_select", + {"type": 'P', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'PINCH'), + ], + }, + ), + ("paint.brush_select", + {"type": 'I', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'INFLATE'), + ], + }, + ), + ("paint.brush_select", + {"type": 'G', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'GRAB'), + ], + }, + ), + ("paint.brush_select", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'LAYER'), + ], + }, + ), + ("paint.brush_select", + {"type": 'T', "value": 'PRESS', "shift": True}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'FLATTEN'), + ], + }, + ), + ("paint.brush_select", + {"type": 'C', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'CLAY'), + ], + }, + ), + ("paint.brush_select", + {"type": 'C', "value": 'PRESS', "shift": True}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'CREASE'), + ], + }, + ), + ("paint.brush_select", + {"type": 'K', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'SNAKE_HOOK'), + ], + }, + ), + ("paint.brush_select", + {"type": 'M', "value": 'PRESS'}, + {"properties": + [("paint_mode", 'SCULPT'), + ("sculpt_tool", 'MASK'), + ("toggle", True), + ("create_missing", True), + ], + }, + ), + ("wm.context_menu_enum", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.sculpt.brush.stroke_method'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'S', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.sculpt.brush.use_smooth_stroke'), + ], + }, + ), + ("wm.call_menu", + {"type": 'R', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_angle_control'), + ], + }, + ), + ], + }, + ), + ("Mesh", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("mesh.loopcut_slide", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("mesh.offset_edge_loops_slide", {"type": 'R', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("mesh.inset", {"type": 'I', "value": 'PRESS'}, None), + ("mesh.poke", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("mesh.bevel", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + {"properties": + [("vertex_only", False), + ], + }, + ), + ("mesh.bevel", + {"type": 'B', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("vertex_only", True), + ], + }, + ), + ("mesh.loop_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", False), + ], + }, + ), + ("mesh.loop_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", True), + ], + }, + ), + ("mesh.edgering_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", False), + ], + }, + ), + ("mesh.edgering_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", True), + ], + }, + ), + ("mesh.shortest_path_pick", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("use_fill", False), + ], + }, + ), + ("mesh.shortest_path_pick", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("use_fill", True), + ], + }, + ), + ("mesh.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("mesh.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("mesh.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("mesh.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("mesh.select_next_item", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("mesh.select_prev_item", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("mesh.select_non_manifold", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("mesh.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("mesh.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("deselect", False), + ], + }, + ), + ("mesh.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("mesh.faces_select_linked_flat", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("wm.call_menu", + {"type": 'G', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_select_similar'), + ], + }, + ), + ("wm.call_menu", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_select_mode'), + ], + }, + ), + ("mesh.hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("mesh.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("mesh.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("mesh.normals_make_consistent", + {"type": 'N', "value": 'PRESS', "ctrl": True}, + {"properties": + [("inside", False), + ], + }, + ), + ("mesh.normals_make_consistent", + {"type": 'N', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("inside", True), + ], + }, + ), + ("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'}, None), + ("wm.call_menu", + {"type": 'E', "value": 'PRESS', "alt": True}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_extrude'), + ], + }, + ), + ("transform.edge_crease", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("mesh.spin", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("mesh.fill", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("mesh.beautify_fill", {"type": 'F', "value": 'PRESS', "shift": True, "alt": True}, None), + ("mesh.quads_convert_to_tris", + {"type": 'T', "value": 'PRESS', "ctrl": True}, + {"properties": + [("quad_method", 'BEAUTY'), + ("ngon_method", 'BEAUTY'), + ], + }, + ), + ("mesh.quads_convert_to_tris", + {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("quad_method", 'FIXED'), + ("ngon_method", 'CLIP'), + ], + }, + ), + ("mesh.tris_convert_to_quads", {"type": 'J', "value": 'PRESS', "alt": True}, None), + ("mesh.rip_move", + {"type": 'V', "value": 'PRESS'}, + {"properties": + [("MESH_OT_rip", + [("use_fill", False), + ], + ), + ], + }, + ), + ("mesh.rip_move", + {"type": 'V', "value": 'PRESS', "alt": True}, + {"properties": + [("MESH_OT_rip", + [("use_fill", True), + ], + ), + ], + }, + ), + ("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True}, None), + ("mesh.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None), + ("transform.shrink_fatten", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("mesh.edge_face_add", {"type": 'F', "value": 'PRESS'}, None), + ("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'INFO_MT_mesh_add'), + ], + }, + ), + ("mesh.separate", {"type": 'P', "value": 'PRESS'}, None), + ("mesh.split", {"type": 'Y', "value": 'PRESS'}, None), + ("mesh.vert_connect_path", {"type": 'J', "value": 'PRESS'}, None), + ("transform.vert_slide", {"type": 'V', "value": 'PRESS', "shift": True}, None), + ("mesh.dupli_extrude_cursor", + {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, + {"properties": + [("rotate_source", True), + ], + }, + ), + ("mesh.dupli_extrude_cursor", + {"type": 'ACTIONMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, + {"properties": + [("rotate_source", False), + ], + }, + ), + ("wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_delete'), + ], + }, + ), + ("wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_delete'), + ], + }, + ), + ("mesh.dissolve_mode", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("mesh.dissolve_mode", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None), + ("mesh.knife_tool", + {"type": 'K', "value": 'PRESS'}, + {"properties": + [("use_occlude_geometry", True), + ("only_selected", False), + ], + }, + ), + ("mesh.knife_tool", + {"type": 'K', "value": 'PRESS', "shift": True}, + {"properties": + [("use_occlude_geometry", False), + ("only_selected", True), + ], + }, + ), + ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_specials'), + ], + }, + ), + ("wm.call_menu", + {"type": 'F', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_faces'), + ], + }, + ), + ("wm.call_menu", + {"type": 'E', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_edges'), + ], + }, + ), + ("wm.call_menu", + {"type": 'V', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_edit_mesh_vertices'), + ], + }, + ), + ("wm.call_menu", + {"type": 'H', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_hook'), + ], + }, + ), + ("wm.call_menu", + {"type": 'U', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_uv_map'), + ], + }, + ), + ("wm.call_menu", + {"type": 'G', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_vertex_group'), + ], + }, + ), + ("object.subdivision_set", + {"type": 'ZERO', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 0), + ], + }, + ), + ("object.subdivision_set", + {"type": 'ONE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 1), + ], + }, + ), + ("object.subdivision_set", + {"type": 'TWO', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 2), + ], + }, + ), + ("object.subdivision_set", + {"type": 'THREE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 3), + ], + }, + ), + ("object.subdivision_set", + {"type": 'FOUR', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 4), + ], + }, + ), + ("object.subdivision_set", + {"type": 'FIVE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("level", 5), + ], + }, + ), + ("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'CONNECTED'), + ], + }, + ), + ], + }, + ), + ("Armature", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("armature.hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("armature.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("armature.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("armature.align", {"type": 'A', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("armature.calculate_roll", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("armature.roll_clear", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("armature.switch_direction", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("armature.bone_primitive_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), + ("armature.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("armature.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("armature.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("armature.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("armature.select_mirror", + {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("armature.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("direction", 'PARENT'), + ("extend", False), + ], + }, + ), + ("armature.select_hierarchy", + {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'PARENT'), + ("extend", True), + ], + }, + ), + ("armature.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("direction", 'CHILD'), + ("extend", False), + ], + }, + ), + ("armature.select_hierarchy", + {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'CHILD'), + ("extend", True), + ], + }, + ), + ("armature.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("armature.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("armature.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("armature.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("armature.shortest_path_pick", {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_armature_delete'), + ], + }, + ), + ("wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_edit_armature_delete'), + ], + }, + ), + ("armature.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("armature.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("armature.extrude_move", {"type": 'E', "value": 'PRESS'}, None), + ("armature.extrude_forked", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("armature.click_extrude", {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, None), + ("armature.fill", {"type": 'F', "value": 'PRESS'}, None), + ("armature.merge", {"type": 'M', "value": 'PRESS', "alt": True}, None), + ("armature.split", {"type": 'Y', "value": 'PRESS'}, None), + ("armature.separate", {"type": 'P', "value": 'PRESS'}, None), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'VIEW3D_MT_bone_options_toggle'), + ], + }, + ), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_bone_options_enable'), + ], + }, + ), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS', "alt": True}, + {"properties": + [("name", 'VIEW3D_MT_bone_options_disable'), + ], + }, + ), + ("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None), + ("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None), + ("armature.bone_layers", {"type": 'M', "value": 'PRESS'}, None), + ("transform.transform", + {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("mode", 'BONE_SIZE'), + ], + }, + ), + ("transform.transform", + {"type": 'S', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'BONE_ENVELOPE'), + ], + }, + ), + ("transform.transform", + {"type": 'R', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'BONE_ROLL'), + ], + }, + ), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_armature_specials'), + ], + }, + ), + ], + }, + ), + ("Metaball", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("object.metaball_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), + ("mball.reveal_metaelems", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("mball.hide_metaelems", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("mball.hide_metaelems", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("mball.delete_metaelems", {"type": 'X', "value": 'PRESS'}, None), + ("mball.delete_metaelems", {"type": 'DEL', "value": 'PRESS'}, None), + ("mball.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("mball.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("mball.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("mball.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'CONNECTED'), + ], + }, + ), + ], + }, + ), + ("Lattice", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("lattice.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("lattice.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("lattice.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("lattice.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("lattice.flip", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'H', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'VIEW3D_MT_hook'), + ], + }, + ), + ("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + }, + ), + ], + }, + ), + ("Particle", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("particle.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("particle.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("particle.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("particle.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("particle.select_linked", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("deselect", False), + ], + }, + ), + ("particle.select_linked", + {"type": 'L', "value": 'PRESS', "shift": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("particle.delete", {"type": 'X', "value": 'PRESS'}, None), + ("particle.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("particle.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("particle.hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("particle.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("particle.brush_edit", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("particle.brush_edit", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("data_path_primary", 'tool_settings.particle_edit.brush.size'), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path_primary", 'tool_settings.particle_edit.brush.strength'), + ], + }, + ), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'VIEW3D_MT_particle_specials'), + ], + }, + ), + ("particle.weight_set", {"type": 'K', "value": 'PRESS', "shift": True}, None), + ("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + }, + ), + ], + }, + ), + ("Font", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("font.style_toggle", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + {"properties": + [("style", 'BOLD'), + ], + }, + ), + ("font.style_toggle", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("style", 'ITALIC'), + ], + }, + ), + ("font.style_toggle", + {"type": 'U', "value": 'PRESS', "ctrl": True}, + {"properties": + [("style", 'UNDERLINE'), + ], + }, + ), + ("font.style_toggle", + {"type": 'P', "value": 'PRESS', "ctrl": True}, + {"properties": + [("style", 'SMALL_CAPS'), + ], + }, + ), + ("font.delete", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_OR_SELECTION'), + ], + }, + ), + ("font.delete", + {"type": 'DEL', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'NEXT_WORD'), + ], + }, + ), + ("font.delete", + {"type": 'BACK_SPACE', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_OR_SELECTION'), + ], + }, + ), + ("font.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_OR_SELECTION'), + ], + }, + ), + ("font.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PREVIOUS_WORD'), + ], + }, + ), + ("font.move", + {"type": 'HOME', "value": 'PRESS'}, + {"properties": + [("type", 'LINE_BEGIN'), + ], + }, + ), + ("font.move", + {"type": 'END', "value": 'PRESS'}, + {"properties": + [("type", 'LINE_END'), + ], + }, + ), + ("font.move", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("font.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_CHARACTER'), + ], + }, + ), + ("font.move", + {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PREVIOUS_WORD'), + ], + }, + ), + ("font.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'NEXT_WORD'), + ], + }, + ), + ("font.move", + {"type": 'UP_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_LINE'), + ], + }, + ), + ("font.move", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_LINE'), + ], + }, + ), + ("font.move", + {"type": 'PAGE_UP', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_PAGE'), + ], + }, + ), + ("font.move", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_PAGE'), + ], + }, + ), + ("font.move_select", + {"type": 'HOME', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'LINE_BEGIN'), + ], + }, + ), + ("font.move_select", + {"type": 'END', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'LINE_END'), + ], + }, + ), + ("font.move_select", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("font.move_select", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'NEXT_CHARACTER'), + ], + }, + ), + ("font.move_select", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'PREVIOUS_WORD'), + ], + }, + ), + ("font.move_select", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'NEXT_WORD'), + ], + }, + ), + ("font.move_select", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_LINE'), + ], + }, + ), + ("font.move_select", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'NEXT_LINE'), + ], + }, + ), + ("font.move_select", + {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_PAGE'), + ], + }, + ), + ("font.move_select", + {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'NEXT_PAGE'), + ], + }, + ), + ("font.change_spacing", + {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, + {"properties": + [("delta", -1), + ], + }, + ), + ("font.change_spacing", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, + {"properties": + [("delta", 1), + ], + }, + ), + ("font.change_character", + {"type": 'UP_ARROW', "value": 'PRESS', "alt": True}, + {"properties": + [("delta", 1), + ], + }, + ), + ("font.change_character", + {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True}, + {"properties": + [("delta", -1), + ], + }, + ), + ("font.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ("font.text_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("font.text_cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("font.text_paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("font.line_break", {"type": 'RET', "value": 'PRESS'}, None), + ("font.text_insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + ("font.text_insert", + {"type": 'BACK_SPACE', "value": 'PRESS', "alt": True}, + {"properties": + [("accent", True), + ], + }, + ), + ], + }, + ), + ("Object Non-modal", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("object.mode_set", + {"type": 'TAB', "value": 'PRESS'}, + {"properties": + [("mode", 'EDIT'), + ("toggle", True), + ], + }, + ), + ("object.mode_set", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'POSE'), + ("toggle", True), + ], + }, + ), + ("object.mode_set", + {"type": 'V', "value": 'PRESS'}, + {"properties": + [("mode", 'VERTEX_PAINT'), + ("toggle", True), + ], + }, + ), + ("object.mode_set", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'WEIGHT_PAINT'), + ("toggle", True), + ], + }, + ), + ("object.origin_set", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ], + }, + ), + ("3D View", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("view3d.cursor3d", {"type": 'ACTIONMOUSE', "value": 'CLICK'}, None), + ("view3d.rotate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("view3d.move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), + ("view3d.zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("view3d.dolly", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("view3d.view_selected", + {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "ctrl": True}, + {"properties": + [("use_all_regions", True), + ], + }, + ), + ("view3d.view_selected", + {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, + {"properties": + [("use_all_regions", False), + ], + }, + ), + ("view3d.view_lock_to_active", {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "shift": True}, None), + ("view3d.view_lock_clear", {"type": 'NUMPAD_PERIOD', "value": 'PRESS', "alt": True}, None), + ("view3d.navigate", {"type": 'F', "value": 'PRESS', "shift": True}, None), + ("view3d.smoothview", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), + ("view3d.rotate", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("view3d.rotate", {"type": 'MOUSEROTATE', "value": 'ANY'}, None), + ("view3d.move", {"type": 'TRACKPADPAN', "value": 'ANY', "shift": True}, None), + ("view3d.zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("view3d.zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("view3d.zoom", + {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, + {"properties": + [("delta", 1), + ], + }, + ), + ("view3d.zoom", + {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, + {"properties": + [("delta", -1), + ], + }, + ), + ("view3d.zoom", + {"type": 'EQUAL', "value": 'PRESS', "ctrl": True}, + {"properties": + [("delta", 1), + ], + }, + ), + ("view3d.zoom", + {"type": 'MINUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("delta", -1), + ], + }, + ), + ("view3d.zoom", + {"type": 'WHEELINMOUSE', "value": 'PRESS'}, + {"properties": + [("delta", 1), + ], + }, + ), + ("view3d.zoom", + {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, + {"properties": + [("delta", -1), + ], + }, + ), + ("view3d.dolly", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, + {"properties": + [("delta", 1), + ], + }, + ), + ("view3d.dolly", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, + {"properties": + [("delta", -1), + ], + }, + ), + ("view3d.dolly", + {"type": 'EQUAL', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("delta", 1), + ], + }, + ), + ("view3d.dolly", + {"type": 'MINUS', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("delta", -1), + ], + }, + ), + ("view3d.zoom_camera_1_to_1", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None), + ("view3d.view_center_camera", {"type": 'HOME', "value": 'PRESS'}, None), + ("view3d.view_center_lock", {"type": 'HOME', "value": 'PRESS'}, None), + ("view3d.view_center_cursor", {"type": 'HOME', "value": 'PRESS', "alt": True}, None), + ("view3d.view_center_pick", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("view3d.view_all", + {"type": 'HOME', "value": 'PRESS'}, + {"properties": + [("center", False), + ], + }, + ), + ("view3d.view_all", + {"type": 'HOME', "value": 'PRESS', "ctrl": True}, + {"properties": + [("use_all_regions", True), + ("center", False), + ], + }, + ), + ("view3d.view_all", + {"type": 'C', "value": 'PRESS', "shift": True}, + {"properties": + [("center", True), + ], + }, + ), + ("view3d.view_camera", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ("view3d.view_axis", + {"type": 'NUMPAD_1', "value": 'PRESS'}, + {"properties": + [("type", 'FRONT'), + ], + }, + ), + ("view3d.view_orbit", + {"type": 'NUMPAD_2', "value": 'PRESS'}, + {"properties": + [("type", 'ORBITDOWN'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_3', "value": 'PRESS'}, + {"properties": + [("type", 'RIGHT'), + ], + }, + ), + ("view3d.view_orbit", + {"type": 'NUMPAD_4', "value": 'PRESS'}, + {"properties": + [("type", 'ORBITLEFT'), + ], + }, + ), + ("view3d.view_persportho", {"type": 'NUMPAD_5', "value": 'PRESS'}, None), + ("view3d.view_orbit", + {"type": 'NUMPAD_6', "value": 'PRESS'}, + {"properties": + [("type", 'ORBITRIGHT'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_7', "value": 'PRESS'}, + {"properties": + [("type", 'TOP'), + ], + }, + ), + ("view3d.view_orbit", + {"type": 'NUMPAD_8', "value": 'PRESS'}, + {"properties": + [("type", 'ORBITUP'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_1', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'BACK'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_3', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'LEFT'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_7', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'BOTTOM'), + ], + }, + ), + ("view3d.view_pan", + {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PANDOWN'), + ], + }, + ), + ("view3d.view_pan", + {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PANLEFT'), + ], + }, + ), + ("view3d.view_pan", + {"type": 'NUMPAD_6', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PANRIGHT'), + ], + }, + ), + ("view3d.view_pan", + {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PANUP'), + ], + }, + ), + ("view3d.view_roll", + {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'LEFT'), + ], + }, + ), + ("view3d.view_roll", + {"type": 'NUMPAD_6', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'RIGHT'), + ], + }, + ), + ("view3d.view_orbit", + {"type": 'NUMPAD_9', "value": 'PRESS'}, + {"properties": + [("angle", 3.1415927), + ("type", 'ORBITRIGHT'), + ], + }, + ), + ("view3d.view_pan", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PANRIGHT'), + ], + }, + ), + ("view3d.view_pan", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PANLEFT'), + ], + }, + ), + ("view3d.view_pan", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PANUP'), + ], + }, + ), + ("view3d.view_pan", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PANDOWN'), + ], + }, + ), + ("view3d.view_orbit", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("type", 'ORBITLEFT'), + ], + }, + ), + ("view3d.view_orbit", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("type", 'ORBITRIGHT'), + ], + }, + ), + ("view3d.view_orbit", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("type", 'ORBITUP'), + ], + }, + ), + ("view3d.view_orbit", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("type", 'ORBITDOWN'), + ], + }, + ), + ("view3d.view_roll", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'LEFT'), + ], + }, + ), + ("view3d.view_roll", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'RIGHT'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_1', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'FRONT'), + ("align_active", True), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_3', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'RIGHT'), + ("align_active", True), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_7', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'TOP'), + ("align_active", True), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_1', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'BACK'), + ("align_active", True), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_3', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'LEFT'), + ("align_active", True), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NUMPAD_7', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'BOTTOM'), + ("align_active", True), + ], + }, + ), + ("view3d.ndof_orbit_zoom", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), + ("view3d.ndof_orbit", {"type": 'NDOF_MOTION', "value": 'ANY', "ctrl": True}, None), + ("view3d.ndof_pan", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True}, None), + ("view3d.ndof_all", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True, "ctrl": True}, None), + ("view3d.view_selected", + {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, + {"properties": + [("use_all_regions", False), + ], + }, + ), + ("view3d.view_roll", + {"type": 'NDOF_BUTTON_ROLL_CCW', "value": 'PRESS'}, + {"properties": + [("type", 'LEFT'), + ], + }, + ), + ("view3d.view_roll", + {"type": 'NDOF_BUTTON_ROLL_CCW', "value": 'PRESS'}, + {"properties": + [("type", 'RIGHT'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_FRONT', "value": 'PRESS'}, + {"properties": + [("type", 'FRONT'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_BACK', "value": 'PRESS'}, + {"properties": + [("type", 'BACK'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_LEFT', "value": 'PRESS'}, + {"properties": + [("type", 'LEFT'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_RIGHT', "value": 'PRESS'}, + {"properties": + [("type", 'RIGHT'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS'}, + {"properties": + [("type", 'TOP'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_BOTTOM', "value": 'PRESS'}, + {"properties": + [("type", 'BOTTOM'), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_FRONT', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'FRONT'), + ("align_active", True), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_RIGHT', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'RIGHT'), + ("align_active", True), + ], + }, + ), + ("view3d.view_axis", + {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'TOP'), + ("align_active", True), + ], + }, + ), + ("view3d.layers", + {"type": 'ACCENT_GRAVE', "value": 'PRESS'}, + {"properties": + [("nr", 0), + ], + }, + ), + ("view3d.layers", + {"type": 'ONE', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 1), + ], + }, + ), + ("view3d.layers", + {"type": 'TWO', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 2), + ], + }, + ), + ("view3d.layers", + {"type": 'THREE', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 3), + ], + }, + ), + ("view3d.layers", + {"type": 'FOUR', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 4), + ], + }, + ), + ("view3d.layers", + {"type": 'FIVE', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 5), + ], + }, + ), + ("view3d.layers", + {"type": 'SIX', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 6), + ], + }, + ), + ("view3d.layers", + {"type": 'SEVEN', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 7), + ], + }, + ), + ("view3d.layers", + {"type": 'EIGHT', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 8), + ], + }, + ), + ("view3d.layers", + {"type": 'NINE', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 9), + ], + }, + ), + ("view3d.layers", + {"type": 'ZERO', "value": 'PRESS', "any": True}, + {"properties": + [("nr", 10), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'Z', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'space_data.shading.type'), + ("value_1", 'SOLID'), + ("value_2", 'TEXTURED'), + ], + }, + ), + ("view3d.toggle_render", {"type": 'Z', "value": 'PRESS', "shift": True}, None), + ("view3d.toggle_xray_draw_option", {"type": 'Z', "value": 'PRESS'}, None), + ("wm.context_toggle", + {"type": 'Z', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.use_occlude_geometry'), + ], + }, + ), + ("view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", False), + ("center", False), + ("enumerate", False), + ("object", False), + ], + }, + ), + ("view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", True), + ("center", False), + ("enumerate", False), + ("object", False), + ], + }, + ), + ("view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", False), + ("center", True), + ("enumerate", False), + ("object", True), + ], + }, + ), + ("view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", False), + ("center", False), + ("enumerate", True), + ("object", False), + ], + }, + ), + ("view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ("deselect", False), + ("toggle", True), + ("center", True), + ("enumerate", False), + ("object", False), + ], + }, + ), + ("view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", False), + ("center", True), + ("enumerate", True), + ("object", False), + ], + }, + ), + ("view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", True), + ("center", False), + ("enumerate", True), + ("object", False), + ], + }, + ), + ("view3d.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", True), + ("center", True), + ("enumerate", True), + ("object", False), + ], + }, + ), + ("view3d.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("view3d.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("view3d.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("view3d.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("view3d.clip_border", {"type": 'B', "value": 'PRESS', "alt": True}, None), + ("view3d.zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), + ("view3d.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ("view3d.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("view3d.camera_to_view", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("view3d.object_as_camera", {"type": 'NUMPAD_0', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'S', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'VIEW3D_MT_snap'), + ], + }, + ), + ("view3d.copybuffer", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("view3d.pastebuffer", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'BOUNDING_BOX_CENTER'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'MEDIAN_POINT'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'COMMA', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'tool_settings.use_transform_pivot_point_align'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'CURSOR'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'INDIVIDUAL_ORIGINS'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'tool_settings.transform_pivot_point'), + ("value", 'ACTIVE_ELEMENT'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.show_manipulator'), + ], + }, + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.bend", {"type": 'W', "value": 'PRESS', "shift": True}, None), + ("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None), + ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("transform.select_orientation", {"type": 'SPACE', "value": 'PRESS', "alt": True}, None), + ("transform.create_orientation", + {"type": 'SPACE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("use", True), + ], + }, + ), + ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ("wm.context_toggle", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.use_snap'), + ], + }, + ), + ("wm.context_menu_enum", + {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("data_path", 'tool_settings.snap_element'), + ], + }, + ), + ("object.transform_axis_target", {"type": 'T', "value": 'PRESS', "shift": True}, None), + ("transform.translate", + {"type": 'T', "value": 'PRESS', "shift": True}, + {"properties": + [("texture_space", True), + ], + }, + ), + ("transform.resize", + {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("texture_space", True), + ], + }, + ), + ("transform.skin_resize", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("Manipulators", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [], + }, + ), + ("Backdrop Transform Widget", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Backdrop Crop Widget", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Sun Beams Widget", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Corner Pin Widget", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("UV Transform Manipulator", + {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Spot Light Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Area Light Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Target Light Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Force Field Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Camera Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Camera View Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Armature Spline Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("View3D Navigate", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Animation", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("anim.change_frame", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("wm.context_toggle", + {"type": 'T', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.show_seconds'), + ], + }, + ), + ("anim.previewrange_set", {"type": 'P', "value": 'PRESS'}, None), + ("anim.previewrange_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ], + }, + ), + ("Animation Channels", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("anim.channels_click", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("anim.channels_click", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("anim.channels_click", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("children_only", True), + ], + }, + ), + ("anim.channels_rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("anim.channels_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ("anim.channel_select_keys", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ("anim.channel_select_keys", + {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ("anim.channels_select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("anim.channels_select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("anim.channels_select_border", {"type": 'B', "value": 'PRESS'}, None), + ("anim.channels_select_border", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), + ("anim.channels_delete", {"type": 'X', "value": 'PRESS'}, None), + ("anim.channels_delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("anim.channels_setting_toggle", {"type": 'W', "value": 'PRESS', "shift": True}, None), + ("anim.channels_setting_enable", {"type": 'W', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("anim.channels_setting_disable", {"type": 'W', "value": 'PRESS', "alt": True}, None), + ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("anim.channels_expand", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("anim.channels_collapse", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("anim.channels_expand", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("all", False), + ], + }, + ), + ("anim.channels_collapse", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("all", False), + ], + }, + ), + ("anim.channels_move", + {"type": 'PAGE_UP', "value": 'PRESS'}, + {"properties": + [("direction", 'UP'), + ], + }, + ), + ("anim.channels_move", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + {"properties": + [("direction", 'DOWN'), + ], + }, + ), + ("anim.channels_move", + {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'TOP'), + ], + }, + ), + ("anim.channels_move", + {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'BOTTOM'), + ], + }, + ), + ("anim.channels_group", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("anim.channels_ungroup", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ], + }, + ), + ("UV Editor", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("wm.context_toggle", + {"type": 'Q', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.use_uv_sculpt'), + ], + }, + ), + ("uv.mark_seam", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), + ("uv.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ], + }, + ), + ("uv.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("uv.select_loop", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("uv.select_loop", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("uv.select_split", {"type": 'Y', "value": 'PRESS'}, None), + ("uv.select_border", + {"type": 'B', "value": 'PRESS'}, + {"properties": + [("pinned", False), + ], + }, + ), + ("uv.select_border", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + {"properties": + [("pinned", True), + ], + }, + ), + ("uv.circle_select", {"type": 'C', "value": 'PRESS'}, None), + ("uv.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("uv.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("uv.select_linked", + {"type": 'L', "value": 'PRESS', "ctrl": True}, + {"properties": + [("extend", True), + ("deselect", False), + ], + }, + ), + ("uv.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("extend", True), + ("deselect", False), + ], + }, + ), + ("uv.select_linked", + {"type": 'L', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("extend", False), + ("deselect", True), + ], + }, + ), + ("uv.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", False), + ("deselect", True), + ], + }, + ), + ("uv.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("uv.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("uv.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("uv.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("uv.select_pinned", {"type": 'P', "value": 'PRESS', "shift": True}, None), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'IMAGE_MT_uvs_weldalign'), + ], + }, + ), + ("uv.stitch", {"type": 'V', "value": 'PRESS'}, None), + ("uv.pin", + {"type": 'P', "value": 'PRESS'}, + {"properties": + [("clear", False), + ], + }, + ), + ("uv.pin", + {"type": 'P', "value": 'PRESS', "alt": True}, + {"properties": + [("clear", True), + ], + }, + ), + ("uv.unwrap", {"type": 'E', "value": 'PRESS'}, None), + ("uv.minimize_stretch", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("uv.pack_islands", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("uv.average_islands_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ("uv.hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("uv.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("uv.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("uv.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("wm.call_menu", + {"type": 'S', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'IMAGE_MT_uvs_snap'), + ], + }, + ), + ("wm.call_menu", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + {"properties": + [("name", 'IMAGE_MT_uvs_select_mode'), + ], + }, + ), + ("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.proportional_edit'), + ("value_1", 'DISABLED'), + ("value_2", 'ENABLED'), + ], + }, + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.shear", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("transform.mirror", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ("wm.context_toggle", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.use_snap'), + ], + }, + ), + ("wm.context_menu_enum", + {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("data_path", 'tool_settings.snap_uv_element'), + ], + }, + ), + ], + }, + ), + ("UV Sculpt", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("wm.context_toggle", + {"type": 'Q', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.use_uv_sculpt'), + ], + }, + ), + ("sculpt.uv_sculpt_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + {"properties": + [("mode", 'NORMAL'), + ], + }, + ), + ("sculpt.uv_sculpt_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'INVERT'), + ], + }, + ), + ("sculpt.uv_sculpt_stroke", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'RELAX'), + ], + }, + ), + ("brush.scale_size", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 0.9), + ], + }, + ), + ("brush.scale_size", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("scalar", 1.1111112), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("data_path_primary", 'tool_settings.uv_sculpt.brush.size'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.size'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_size'), + ("rotation_path", 'tool_settings.uv_sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.uv_sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.uv_sculpt.brush'), + ("secondary_tex", False), + ], + }, + ), + ("wm.radial_control", + {"type": 'F', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path_primary", 'tool_settings.uv_sculpt.brush.strength'), + ("data_path_secondary", 'tool_settings.unified_paint_settings.strength'), + ("use_secondary", 'tool_settings.unified_paint_settings.use_unified_strength'), + ("rotation_path", 'tool_settings.uv_sculpt.brush.texture_slot.angle'), + ("color_path", 'tool_settings.uv_sculpt.brush.cursor_color_add'), + ("fill_color_path", ''), + ("fill_color_override_path", ''), + ("fill_color_override_test_path", ''), + ("zoom_path", ''), + ("image_id", 'tool_settings.uv_sculpt.brush'), + ("secondary_tex", False), + ], + }, + ), + ("brush.uv_sculpt_tool_set", + {"type": 'S', "value": 'PRESS'}, + {"properties": + [("tool", 'RELAX'), + ], + }, + ), + ("brush.uv_sculpt_tool_set", + {"type": 'P', "value": 'PRESS'}, + {"properties": + [("tool", 'PINCH'), + ], + }, + ), + ("brush.uv_sculpt_tool_set", + {"type": 'G', "value": 'PRESS'}, + {"properties": + [("tool", 'GRAB'), + ], + }, + ), + ], + }, + ), + ("Mask Editing", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("mask.new", {"type": 'N', "value": 'PRESS', "alt": True}, None), + ("wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'MASK_MT_add'), + ], + }, + ), + ("wm.context_cycle_enum", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.proportional_edit_falloff'), + ("wrap", True), + ], + }, + ), + ("wm.context_toggle", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.use_proportional_edit_mask'), + ], + }, + ), + ("mask.add_vertex_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("mask.add_feather_vertex_slide", {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, None), + ("mask.delete", {"type": 'X', "value": 'PRESS'}, None), + ("mask.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("mask.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", False), + ], + }, + ), + ("mask.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", False), + ("deselect", False), + ("toggle", True), + ], + }, + ), + ("mask.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("mask.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("mask.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("mask.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("deselect", False), + ], + }, + ), + ("mask.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("mask.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("mask.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("mask.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("mask.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("mask.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("mask.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("mask.hide_view_clear", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("mask.hide_view_set", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("mask.hide_view_set", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("clip.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("mask.cyclic_toggle", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ("mask.slide_point", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("mask.slide_spline_curvature", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("mask.handle_type_set", {"type": 'V', "value": 'PRESS'}, None), + ("mask.normals_make_consistent", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("mask.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("mask.parent_clear", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("mask.shape_key_insert", {"type": 'I', "value": 'PRESS'}, None), + ("mask.shape_key_clear", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("mask.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("mask.copy_splines", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("mask.paste_splines", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("uv.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.transform", + {"type": 'S', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'MASK_SHRINKFATTEN'), + ], + }, + ), + ], + }, + ), + ("Markers", + {"space_type": 'EMPTY', "region_type": 'WINDOW'}, + {"items": + [("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.move", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("marker.duplicate", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("marker.select", {"type": 'SELECTMOUSE', "value": 'PRESS'}, None), + ("marker.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("marker.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("extend", False), + ("camera", True), + ], + }, + ), + ("marker.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ("camera", True), + ], + }, + ), + ("marker.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("marker.select_all", {"type": 'A', "value": 'PRESS'}, None), + ("marker.delete", {"type": 'X', "value": 'PRESS'}, None), + ("marker.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ("marker.move", {"type": 'G', "value": 'PRESS'}, None), + ("marker.camera_bind", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("Graph Editor Generic", + {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("graph.properties", {"type": 'N', "value": 'PRESS'}, None), + ("graph.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ("graph.hide", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("graph.hide", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("graph.reveal", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ], + }, + ), + ("Graph Editor", + {"space_type": 'GRAPH_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("wm.context_toggle", + {"type": 'H', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.show_handles'), + ], + }, + ), + ("graph.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ("column", False), + ("curves", False), + ], + }, + ), + ("graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("extend", False), + ("column", True), + ("curves", False), + ], + }, + ), + ("graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ("column", False), + ("curves", False), + ], + }, + ), + ("graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("extend", True), + ("column", True), + ("curves", False), + ], + }, + ), + ("graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("extend", False), + ("column", False), + ("curves", True), + ], + }, + ), + ("graph.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("extend", True), + ("column", False), + ("curves", True), + ], + }, + ), + ("graph.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'CHECK'), + ("extend", False), + ], + }, + ), + ("graph.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("mode", 'CHECK'), + ("extend", True), + ], + }, + ), + ("graph.select_leftright", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("mode", 'LEFT'), + ("extend", False), + ], + }, + ), + ("graph.select_leftright", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("mode", 'RIGHT'), + ("extend", False), + ], + }, + ), + ("graph.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("graph.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("graph.select_border", + {"type": 'B', "value": 'PRESS'}, + {"properties": + [("axis_range", False), + ("include_handles", False), + ], + }, + ), + ("graph.select_border", + {"type": 'B', "value": 'PRESS', "alt": True}, + {"properties": + [("axis_range", True), + ("include_handles", False), + ], + }, + ), + ("graph.select_border", + {"type": 'B', "value": 'PRESS', "ctrl": True}, + {"properties": + [("axis_range", False), + ("include_handles", True), + ], + }, + ), + ("graph.select_border", + {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("axis_range", True), + ("include_handles", True), + ], + }, + ), + ("graph.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("graph.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("graph.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("graph.select_column", + {"type": 'K', "value": 'PRESS'}, + {"properties": + [("mode", 'KEYS'), + ], + }, + ), + ("graph.select_column", + {"type": 'K', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'CFRA'), + ], + }, + ), + ("graph.select_column", + {"type": 'K', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'MARKERS_COLUMN'), + ], + }, + ), + ("graph.select_column", + {"type": 'K', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'MARKERS_BETWEEN'), + ], + }, + ), + ("graph.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("graph.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("graph.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("graph.frame_jump", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("graph.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("graph.mirror", {"type": 'M', "value": 'PRESS', "shift": True}, None), + ("graph.handle_type", {"type": 'V', "value": 'PRESS'}, None), + ("graph.interpolation_type", {"type": 'T', "value": 'PRESS'}, None), + ("graph.easing_type", {"type": 'E', "value": 'PRESS', "ctrl": True}, None), + ("graph.smooth", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("graph.sample", {"type": 'O', "value": 'PRESS', "shift": True}, None), + ("graph.bake", {"type": 'C', "value": 'PRESS', "alt": True}, None), + ("wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + {"properties": + [("name", 'GRAPH_MT_delete'), + ], + }, + ), + ("wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("name", 'GRAPH_MT_delete'), + ], + }, + ), + ("graph.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("graph.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), + ("graph.click_insert", + {"type": 'ACTIONMOUSE', "value": 'CLICK', "ctrl": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("graph.click_insert", + {"type": 'ACTIONMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("graph.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("graph.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("graph.paste", + {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("flipped", True), + ], + }, + ), + ("graph.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("graph.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("graph.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("graph.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("graph.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ("graph.fmodifier_add", + {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("only_active", False), + ], + }, + ), + ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.transform", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("mode", 'TIME_EXTEND'), + ], + }, + ), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("wm.context_toggle", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.use_proportional_fcurve'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'BOUNDING_BOX_CENTER'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'CURSOR'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'INDIVIDUAL_ORIGINS'), + ], + }, + ), + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("Image Generic", + {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("image.new", {"type": 'N', "value": 'PRESS', "alt": True}, None), + ("image.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("image.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("image.read_viewlayers", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("image.save", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("image.save_as", {"type": 'F3', "value": 'PRESS'}, None), + ("image.properties", {"type": 'N', "value": 'PRESS'}, None), + ("image.toolshelf", {"type": 'T', "value": 'PRESS'}, None), + ("image.cycle_render_slot", {"type": 'J', "value": 'PRESS'}, None), + ("image.cycle_render_slot", + {"type": 'J', "value": 'PRESS', "alt": True}, + {"properties": + [("reverse", True), + ], + }, + ), + ], + }, + ), + ("Image", + {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("image.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("image.view_all", + {"type": 'HOME', "value": 'PRESS', "shift": True}, + {"properties": + [("fit_view", True), + ], + }, + ), + ("image.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("image.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), + ("image.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("image.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("image.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), + ("image.view_zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), + ("image.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), + ("image.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("image.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("image.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("image.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("image.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("image.view_zoom_border", {"type": 'B', "value": 'PRESS', "shift": True}, None), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, + {"properties": + [("ratio", 8.0), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, + {"properties": + [("ratio", 4.0), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, + {"properties": + [("ratio", 2.0), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS', "shift": True}, + {"properties": + [("ratio", 8.0), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, + {"properties": + [("ratio", 4.0), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS', "shift": True}, + {"properties": + [("ratio", 2.0), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_1', "value": 'PRESS'}, + {"properties": + [("ratio", 1.0), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS'}, + {"properties": + [("ratio", 0.5), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS'}, + {"properties": + [("ratio", 0.25), + ], + }, + ), + ("image.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS'}, + {"properties": + [("ratio", 0.125), + ], + }, + ), + ("image.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("image.sample", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("image.curves_point_set", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("point", 'BLACK_POINT'), + ], + }, + ), + ("image.curves_point_set", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("point", 'WHITE_POINT'), + ], + }, + ), + ("object.mode_set", + {"type": 'TAB', "value": 'PRESS'}, + {"properties": + [("mode", 'EDIT'), + ("toggle", True), + ], + }, + ), + ("wm.context_set_int", + {"type": 'ONE', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.image.render_slots.active_index'), + ("value", 0), + ], + }, + ), + ("wm.context_set_int", + {"type": 'TWO', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.image.render_slots.active_index'), + ("value", 1), + ], + }, + ), + ("wm.context_set_int", + {"type": 'THREE', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.image.render_slots.active_index'), + ("value", 2), + ], + }, + ), + ("wm.context_set_int", + {"type": 'FOUR', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.image.render_slots.active_index'), + ("value", 3), + ], + }, + ), + ("wm.context_set_int", + {"type": 'FIVE', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.image.render_slots.active_index'), + ("value", 4), + ], + }, + ), + ("wm.context_set_int", + {"type": 'SIX', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.image.render_slots.active_index'), + ("value", 5), + ], + }, + ), + ("wm.context_set_int", + {"type": 'SEVEN', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.image.render_slots.active_index'), + ("value", 6), + ], + }, + ), + ("wm.context_set_int", + {"type": 'EIGHT', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.image.render_slots.active_index'), + ("value", 7), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'CENTER'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'MEDIAN'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'CURSOR'), + ], + }, + ), + ("image.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ("image.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ], + }, + ), + ("Node Generic", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("node.properties", {"type": 'N', "value": 'PRESS'}, None), + ("node.toolbar", {"type": 'T', "value": 'PRESS'}, None), + ], + }, + ), + ("Node Editor", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select", + {"type": 'ACTIONMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select_border", + {"type": 'EVT_TWEAK_S', "value": 'ANY'}, + {"properties": + [("tweak", True), + ], + }, + ), + ("node.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("node.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("node.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("node.link", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + {"properties": + [("detach", False), + ], + }, + ), + ("node.link", + {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("detach", True), + ], + }, + ), + ("node.resize", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("node.add_reroute", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, None), + ("node.links_cut", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("node.select_link_viewer", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("node.backimage_move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "alt": True}, None), + ("node.backimage_zoom", + {"type": 'V', "value": 'PRESS'}, + {"properties": + [("factor", 0.8333333), + ], + }, + ), + ("node.backimage_zoom", + {"type": 'V', "value": 'PRESS', "alt": True}, + {"properties": + [("factor", 1.2), + ], + }, + ), + ("node.backimage_fit", {"type": 'HOME', "value": 'PRESS', "alt": True}, None), + ("node.backimage_sample", {"type": 'ACTIONMOUSE', "value": 'PRESS', "alt": True}, None), + ("node.link_make", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("replace", False), + ], + }, + ), + ("node.link_make", + {"type": 'F', "value": 'PRESS', "shift": True}, + {"properties": + [("replace", True), + ], + }, + ), + ("wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'NODE_MT_add'), + ], + }, + ), + ("node.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("node.duplicate_move_keep_inputs", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("node.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None), + ("node.detach", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("node.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ("node.hide_toggle", {"type": 'H', "value": 'PRESS'}, None), + ("node.mute_toggle", {"type": 'M', "value": 'PRESS'}, None), + ("node.preview_toggle", {"type": 'H', "value": 'PRESS', "shift": True}, None), + ("node.hide_socket_toggle", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), + ("node.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("node.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("node.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("node.select_border", + {"type": 'B', "value": 'PRESS'}, + {"properties": + [("tweak", False), + ], + }, + ), + ("node.delete", {"type": 'X', "value": 'PRESS'}, None), + ("node.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("node.delete_reconnect", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("node.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("node.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("node.select_linked_to", {"type": 'L', "value": 'PRESS', "shift": True}, None), + ("node.select_linked_from", {"type": 'L', "value": 'PRESS'}, None), + ("node.select_grouped", + {"type": 'G', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", False), + ], + }, + ), + ("node.select_grouped", + {"type": 'G', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("node.select_same_type_step", + {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True}, + {"properties": + [("prev", False), + ], + }, + ), + ("node.select_same_type_step", + {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True}, + {"properties": + [("prev", True), + ], + }, + ), + ("node.find_node", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ("node.group_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("node.group_ungroup", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ("node.group_separate", {"type": 'P', "value": 'PRESS'}, None), + ("node.group_edit", + {"type": 'TAB', "value": 'PRESS'}, + {"properties": + [("exit", False), + ], + }, + ), + ("node.group_edit", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + {"properties": + [("exit", True), + ], + }, + ), + ("node.read_viewlayers", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("node.render_changed", {"type": 'Z', "value": 'PRESS'}, None), + ("node.clipboard_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("node.clipboard_paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("node.viewer_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ("node.clear_viewer_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("node.translate_attach", {"type": 'G', "value": 'PRESS'}, None), + ("node.translate_attach", {"type": 'EVT_TWEAK_A', "value": 'ANY'}, None), + ("node.translate_attach", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.translate", + {"type": 'G', "value": 'PRESS'}, + {"properties": + [("release_confirm", True), + ], + }, + ), + ("transform.translate", + {"type": 'EVT_TWEAK_A', "value": 'ANY'}, + {"properties": + [("release_confirm", True), + ], + }, + ), + ("transform.translate", + {"type": 'EVT_TWEAK_S', "value": 'ANY'}, + {"properties": + [("release_confirm", True), + ], + }, + ), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("node.move_detach_links", {"type": 'D', "value": 'PRESS', "alt": True}, None), + ("node.move_detach_links_release", {"type": 'EVT_TWEAK_A', "value": 'ANY', "alt": True}, None), + ("node.move_detach_links", {"type": 'EVT_TWEAK_S', "value": 'ANY', "alt": True}, None), + ("wm.context_toggle", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'tool_settings.use_snap'), + ], + }, + ), + ("wm.context_menu_enum", + {"type": 'TAB', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("data_path", 'tool_settings.snap_node_element'), + ], + }, + ), + ], + }, + ), + ("File Browser", + {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, + {"items": + [("file.parent", {"type": 'UP_ARROW', "value": 'PRESS', "alt": True}, None), + ("file.previous", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, None), + ("file.next", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, None), + ("file.refresh", {"type": 'R', "value": 'PRESS'}, None), + ("file.parent", {"type": 'P', "value": 'PRESS'}, None), + ("file.previous", {"type": 'BACK_SPACE', "value": 'PRESS'}, None), + ("file.next", {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, None), + ("wm.context_toggle", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.params.show_hidden'), + ], + }, + ), + ("file.directory_new", {"type": 'I', "value": 'PRESS'}, None), + ("file.delete", {"type": 'X', "value": 'PRESS'}, None), + ("file.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("file.smoothscroll", {"type": 'TIMER1', "value": 'ANY', "any": True}, None), + ("file.bookmark_toggle", {"type": 'T', "value": 'PRESS'}, None), + ("file.bookmark_add", {"type": 'B', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("File Browser Main", + {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, + {"items": + [("file.execute", + {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, + {"properties": + [("need_active", True), + ], + }, + ), + ("file.refresh", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None), + ("file.select", + {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("file.select", + {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ("fill", True), + ], + }, + ), + ("file.select", + {"type": 'RIGHTMOUSE', "value": 'CLICK'}, + {"properties": + [("open", False), + ], + }, + ), + ("file.select", + {"type": 'RIGHTMOUSE', "value": 'CLICK', "shift": True}, + {"properties": + [("extend", True), + ("open", False), + ], + }, + ), + ("file.select", + {"type": 'RIGHTMOUSE', "value": 'CLICK', "alt": True}, + {"properties": + [("extend", True), + ("fill", True), + ("open", False), + ], + }, + ), + ("file.select_walk", + {"type": 'UP_ARROW', "value": 'PRESS'}, + {"properties": + [("direction", 'UP'), + ], + }, + ), + ("file.select_walk", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'UP'), + ("extend", True), + ], + }, + ), + ("file.select_walk", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("direction", 'UP'), + ("extend", True), + ("fill", True), + ], + }, + ), + ("file.select_walk", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + {"properties": + [("direction", 'DOWN'), + ], + }, + ), + ("file.select_walk", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'DOWN'), + ("extend", True), + ], + }, + ), + ("file.select_walk", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("direction", 'DOWN'), + ("extend", True), + ("fill", True), + ], + }, + ), + ("file.select_walk", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + {"properties": + [("direction", 'LEFT'), + ], + }, + ), + ("file.select_walk", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'LEFT'), + ("extend", True), + ], + }, + ), + ("file.select_walk", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("direction", 'LEFT'), + ("extend", True), + ("fill", True), + ], + }, + ), + ("file.select_walk", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + {"properties": + [("direction", 'RIGHT'), + ], + }, + ), + ("file.select_walk", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("direction", 'RIGHT'), + ("extend", True), + ], + }, + ), + ("file.select_walk", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("direction", 'RIGHT'), + ("extend", True), + ("fill", True), + ], + }, + ), + ("file.previous", {"type": 'BUTTON4MOUSE', "value": 'CLICK'}, None), + ("file.next", {"type": 'BUTTON5MOUSE', "value": 'CLICK'}, None), + ("file.select_all_toggle", {"type": 'A', "value": 'PRESS'}, None), + ("file.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("file.select_border", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), + ("file.rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("file.highlight", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), + ("file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, + {"properties": + [("increment", 1), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, + {"properties": + [("increment", 10), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("increment", 100), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, + {"properties": + [("increment", -1), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, + {"properties": + [("increment", -10), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("increment", -100), + ], + }, + ), + ], + }, + ), + ("File Browser Buttons", + {"space_type": 'FILE_BROWSER', "region_type": 'WINDOW'}, + {"items": + [("file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, + {"properties": + [("increment", 1), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, + {"properties": + [("increment", 10), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("increment", 100), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, + {"properties": + [("increment", -1), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "shift": True}, + {"properties": + [("increment", -10), + ], + }, + ), + ("file.filenum", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("increment", -100), + ], + }, + ), + ], + }, + ), + ("Dopesheet Generic", + {"space_type": 'DOPESHEET_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("action.properties", {"type": 'N', "value": 'PRESS'}, None), + ], + }, + ), + ("Dopesheet", + {"space_type": 'DOPESHEET_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ("column", False), + ("channel", False), + ], + }, + ), + ("action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("extend", False), + ("column", True), + ("channel", False), + ], + }, + ), + ("action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ("column", False), + ("channel", False), + ], + }, + ), + ("action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("extend", True), + ("column", True), + ("channel", False), + ], + }, + ), + ("action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True, "alt": True}, + {"properties": + [("extend", False), + ("column", False), + ("channel", True), + ], + }, + ), + ("action.clickselect", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("extend", True), + ("column", False), + ("channel", True), + ], + }, + ), + ("action.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'CHECK'), + ("extend", False), + ], + }, + ), + ("action.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("mode", 'CHECK'), + ("extend", True), + ], + }, + ), + ("action.select_leftright", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("mode", 'LEFT'), + ("extend", False), + ], + }, + ), + ("action.select_leftright", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("mode", 'RIGHT'), + ("extend", False), + ], + }, + ), + ("action.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("action.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("action.select_border", + {"type": 'B', "value": 'PRESS'}, + {"properties": + [("axis_range", False), + ], + }, + ), + ("action.select_border", + {"type": 'B', "value": 'PRESS', "alt": True}, + {"properties": + [("axis_range", True), + ], + }, + ), + ("action.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("action.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("action.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("action.select_column", + {"type": 'K', "value": 'PRESS'}, + {"properties": + [("mode", 'KEYS'), + ], + }, + ), + ("action.select_column", + {"type": 'K', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'CFRA'), + ], + }, + ), + ("action.select_column", + {"type": 'K', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'MARKERS_COLUMN'), + ], + }, + ), + ("action.select_column", + {"type": 'K', "value": 'PRESS', "alt": True}, + {"properties": + [("mode", 'MARKERS_BETWEEN'), + ], + }, + ), + ("action.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("action.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("action.select_linked", {"type": 'L', "value": 'PRESS'}, None), + ("action.frame_jump", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("action.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("action.mirror", {"type": 'M', "value": 'PRESS', "shift": True}, None), + ("action.handle_type", {"type": 'V', "value": 'PRESS'}, None), + ("action.interpolation_type", {"type": 'T', "value": 'PRESS'}, None), + ("action.extrapolation_type", {"type": 'E', "value": 'PRESS', "shift": True}, None), + ("action.keyframe_type", {"type": 'R', "value": 'PRESS'}, None), + ("action.sample", {"type": 'O', "value": 'PRESS', "shift": True}, None), + ("wm.call_menu", + {"type": 'X', "value": 'PRESS'}, + {"properties": + [("name", 'DOPESHEET_MT_delete'), + ], + }, + ), + ("wm.call_menu", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("name", 'DOPESHEET_MT_delete'), + ], + }, + ), + ("action.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("action.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), + ("action.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("action.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("action.paste", + {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("flipped", True), + ], + }, + ), + ("action.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("action.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("action.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("action.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("action.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ("anim.channels_editable_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ("transform.transform", + {"type": 'G', "value": 'PRESS'}, + {"properties": + [("mode", 'TIME_TRANSLATE'), + ], + }, + ), + ("transform.transform", + {"type": 'EVT_TWEAK_S', "value": 'ANY'}, + {"properties": + [("mode", 'TIME_TRANSLATE'), + ], + }, + ), + ("transform.transform", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("mode", 'TIME_EXTEND'), + ], + }, + ), + ("transform.transform", + {"type": 'S', "value": 'PRESS'}, + {"properties": + [("mode", 'TIME_SCALE'), + ], + }, + ), + ("transform.transform", + {"type": 'T', "value": 'PRESS', "shift": True}, + {"properties": + [("mode", 'TIME_SLIDE'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'tool_settings.use_proportional_action'), + ], + }, + ), + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("NLA Generic", + {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("nla.properties", {"type": 'N', "value": 'PRESS'}, None), + ("nla.tweakmode_enter", {"type": 'TAB', "value": 'PRESS'}, None), + ("nla.tweakmode_exit", {"type": 'TAB', "value": 'PRESS'}, None), + ("nla.tweakmode_enter", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + {"properties": + [("isolate_action", True), + ], + }, + ), + ("nla.tweakmode_exit", + {"type": 'TAB', "value": 'PRESS', "shift": True}, + {"properties": + [("isolate_action", True), + ], + }, + ), + ("anim.channels_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("NLA Channels", + {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("nla.channels_click", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ], + }, + ), + ("nla.channels_click", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("nla.tracks_add", + {"type": 'A', "value": 'PRESS', "shift": True}, + {"properties": + [("above_selected", False), + ], + }, + ), + ("nla.tracks_add", + {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("above_selected", True), + ], + }, + ), + ("nla.tracks_delete", {"type": 'X', "value": 'PRESS'}, None), + ("nla.tracks_delete", {"type": 'DEL', "value": 'PRESS'}, None), + ], + }, + ), + ("NLA Editor", + {"space_type": 'NLA_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("nla.click_select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ], + }, + ), + ("nla.click_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("nla.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("mode", 'CHECK'), + ("extend", False), + ], + }, + ), + ("nla.select_leftright", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("mode", 'CHECK'), + ("extend", True), + ], + }, + ), + ("nla.select_leftright", + {"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": + [("mode", 'LEFT'), + ("extend", False), + ], + }, + ), + ("nla.select_leftright", + {"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": + [("mode", 'RIGHT'), + ("extend", False), + ], + }, + ), + ("nla.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("nla.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("nla.select_border", + {"type": 'B', "value": 'PRESS'}, + {"properties": + [("axis_range", False), + ], + }, + ), + ("nla.select_border", + {"type": 'B', "value": 'PRESS', "alt": True}, + {"properties": + [("axis_range", True), + ], + }, + ), + ("nla.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), + ("nla.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("nla.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("nla.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("nla.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ("nla.actionclip_add", {"type": 'A', "value": 'PRESS', "shift": True}, None), + ("nla.transition_add", {"type": 'T', "value": 'PRESS', "shift": True}, None), + ("nla.soundclip_add", {"type": 'K', "value": 'PRESS', "shift": True}, None), + ("nla.meta_add", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("nla.meta_remove", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ("nla.duplicate", + {"type": 'D', "value": 'PRESS', "shift": True}, + {"properties": + [("linked", False), + ], + }, + ), + ("nla.duplicate", + {"type": 'D', "value": 'PRESS', "alt": True}, + {"properties": + [("linked", True), + ], + }, + ), + ("nla.make_single_user", {"type": 'U', "value": 'PRESS'}, None), + ("nla.delete", {"type": 'X', "value": 'PRESS'}, None), + ("nla.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("nla.split", {"type": 'Y', "value": 'PRESS'}, None), + ("nla.mute_toggle", {"type": 'H', "value": 'PRESS'}, None), + ("nla.swap", {"type": 'F', "value": 'PRESS', "alt": True}, None), + ("nla.move_up", {"type": 'PAGE_UP', "value": 'PRESS'}, None), + ("nla.move_down", {"type": 'PAGE_DOWN', "value": 'PRESS'}, None), + ("nla.apply_scale", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ("nla.clear_scale", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("nla.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("nla.fmodifier_add", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("transform.transform", + {"type": 'G', "value": 'PRESS'}, + {"properties": + [("mode", 'TRANSLATION'), + ], + }, + ), + ("transform.transform", + {"type": 'EVT_TWEAK_S', "value": 'ANY'}, + {"properties": + [("mode", 'TRANSLATION'), + ], + }, + ), + ("transform.transform", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("mode", 'TIME_EXTEND'), + ], + }, + ), + ("transform.transform", + {"type": 'S', "value": 'PRESS'}, + {"properties": + [("mode", 'TIME_SCALE'), + ], + }, + ), + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("Text Generic", + {"space_type": 'TEXT_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("text.start_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), + ("text.jump", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ("text.find", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("text.replace", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), + ("text.properties", {"type": 'T', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("Text", + {"space_type": 'TEXT_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("wm.context_cycle_int", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.font_size'), + ("reverse", False), + ], + }, + ), + ("wm.context_cycle_int", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.font_size'), + ("reverse", True), + ], + }, + ), + ("wm.context_cycle_int", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.font_size'), + ("reverse", False), + ], + }, + ), + ("wm.context_cycle_int", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.font_size'), + ("reverse", True), + ], + }, + ), + ("text.new", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + ("text.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("text.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("text.save", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("text.save_as", {"type": 'S', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None), + ("text.run_script", {"type": 'P', "value": 'PRESS', "alt": True}, None), + ("text.cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None), + ("text.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("text.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("text.cut", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), + ("text.copy", {"type": 'INSERT', "value": 'PRESS', "ctrl": True}, None), + ("text.paste", {"type": 'INSERT', "value": 'PRESS', "shift": True}, None), + ("text.duplicate_line", {"type": 'D', "value": 'PRESS', "ctrl": True}, None), + ("text.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None), + ("text.select_line", {"type": 'A', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("text.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ("text.move_lines", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("direction", 'UP'), + ], + }, + ), + ("text.move_lines", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("direction", 'DOWN'), + ], + }, + ), + ("text.indent", {"type": 'TAB', "value": 'PRESS'}, None), + ("text.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), + ("text.uncomment", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("text.move", + {"type": 'HOME', "value": 'PRESS'}, + {"properties": + [("type", 'LINE_BEGIN'), + ], + }, + ), + ("text.move", + {"type": 'END', "value": 'PRESS'}, + {"properties": + [("type", 'LINE_END'), + ], + }, + ), + ("text.move", + {"type": 'E', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'LINE_END'), + ], + }, + ), + ("text.move", + {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'LINE_END'), + ], + }, + ), + ("text.move", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("text.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_CHARACTER'), + ], + }, + ), + ("text.move", + {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PREVIOUS_WORD'), + ], + }, + ), + ("text.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'NEXT_WORD'), + ], + }, + ), + ("text.move", + {"type": 'UP_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_LINE'), + ], + }, + ), + ("text.move", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_LINE'), + ], + }, + ), + ("text.move", + {"type": 'PAGE_UP', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_PAGE'), + ], + }, + ), + ("text.move", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_PAGE'), + ], + }, + ), + ("text.move", + {"type": 'HOME', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'FILE_TOP'), + ], + }, + ), + ("text.move", + {"type": 'END', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'FILE_BOTTOM'), + ], + }, + ), + ("text.move_select", + {"type": 'HOME', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'LINE_BEGIN'), + ], + }, + ), + ("text.move_select", + {"type": 'END', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'LINE_END'), + ], + }, + ), + ("text.move_select", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("text.move_select", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'NEXT_CHARACTER'), + ], + }, + ), + ("text.move_select", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'PREVIOUS_WORD'), + ], + }, + ), + ("text.move_select", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'NEXT_WORD'), + ], + }, + ), + ("text.move_select", + {"type": 'UP_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_LINE'), + ], + }, + ), + ("text.move_select", + {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'NEXT_LINE'), + ], + }, + ), + ("text.move_select", + {"type": 'PAGE_UP', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_PAGE'), + ], + }, + ), + ("text.move_select", + {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'NEXT_PAGE'), + ], + }, + ), + ("text.move_select", + {"type": 'HOME', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'FILE_TOP'), + ], + }, + ), + ("text.move_select", + {"type": 'END', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("type", 'FILE_BOTTOM'), + ], + }, + ), + ("text.delete", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_CHARACTER'), + ], + }, + ), + ("text.delete", + {"type": 'BACK_SPACE', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("text.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("text.delete", + {"type": 'DEL', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'NEXT_WORD'), + ], + }, + ), + ("text.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PREVIOUS_WORD'), + ], + }, + ), + ("text.overwrite_toggle", {"type": 'INSERT', "value": 'PRESS'}, None), + ("text.scroll_bar", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("text.scroll_bar", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("text.scroll", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("text.scroll", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("text.selection_set", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), + ("text.cursor_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("text.selection_set", + {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("select", True), + ], + }, + ), + ("text.scroll", + {"type": 'WHEELUPMOUSE', "value": 'PRESS'}, + {"properties": + [("lines", -1), + ], + }, + ), + ("text.scroll", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS'}, + {"properties": + [("lines", 1), + ], + }, + ), + ("text.line_break", {"type": 'RET', "value": 'PRESS'}, None), + ("text.line_break", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), + ("wm.call_menu", + {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, + {"properties": + [("name", 'TEXT_MT_toolbox'), + ], + }, + ), + ("text.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None), + ("text.line_number", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + ("text.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + ], + }, + ), + ("SequencerCommon", + {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("sequencer.properties", {"type": 'N', "value": 'PRESS'}, None), + ("wm.context_toggle", + {"type": 'O', "value": 'PRESS', "shift": True}, + {"properties": + [("data_path", 'scene.sequence_editor.show_overlay'), + ], + }, + ), + ("sequencer.view_toggle", {"type": 'TAB', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("Sequencer", + {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("sequencer.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("sequencer.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("sequencer.cut", + {"type": 'K', "value": 'PRESS'}, + {"properties": + [("type", 'SOFT'), + ], + }, + ), + ("sequencer.cut", + {"type": 'K', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'HARD'), + ], + }, + ), + ("sequencer.mute", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("sequencer.mute", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("sequencer.unmute", + {"type": 'H', "value": 'PRESS', "alt": True}, + {"properties": + [("unselected", False), + ], + }, + ), + ("sequencer.unmute", + {"type": 'H', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("sequencer.lock", {"type": 'L', "value": 'PRESS', "shift": True}, None), + ("sequencer.unlock", {"type": 'L', "value": 'PRESS', "shift": True, "alt": True}, None), + ("sequencer.reassign_inputs", {"type": 'R', "value": 'PRESS'}, None), + ("sequencer.reload", {"type": 'R', "value": 'PRESS', "alt": True}, None), + ("sequencer.reload", + {"type": 'R', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("adjust_length", True), + ], + }, + ), + ("sequencer.offset_clear", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("sequencer.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None), + ("sequencer.delete", {"type": 'X', "value": 'PRESS'}, None), + ("sequencer.delete", {"type": 'DEL', "value": 'PRESS'}, None), + ("sequencer.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.images_separate", {"type": 'Y', "value": 'PRESS'}, None), + ("sequencer.meta_toggle", {"type": 'TAB', "value": 'PRESS'}, None), + ("sequencer.meta_make", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.meta_separate", {"type": 'G', "value": 'PRESS', "alt": True}, None), + ("sequencer.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("sequencer.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("sequencer.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("sequencer.view_frame", {"type": 'NUMPAD_0', "value": 'PRESS'}, None), + ("sequencer.strip_jump", + {"type": 'PAGE_UP', "value": 'PRESS'}, + {"properties": + [("next", True), + ("center", False), + ], + }, + ), + ("sequencer.strip_jump", + {"type": 'PAGE_DOWN', "value": 'PRESS'}, + {"properties": + [("next", False), + ("center", False), + ], + }, + ), + ("sequencer.strip_jump", + {"type": 'PAGE_UP', "value": 'PRESS', "alt": True}, + {"properties": + [("next", True), + ("center", True), + ], + }, + ), + ("sequencer.strip_jump", + {"type": 'PAGE_DOWN', "value": 'PRESS', "alt": True}, + {"properties": + [("next", False), + ("center", True), + ], + }, + ), + ("sequencer.swap", + {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, + {"properties": + [("side", 'LEFT'), + ], + }, + ), + ("sequencer.swap", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, + {"properties": + [("side", 'RIGHT'), + ], + }, + ), + ("sequencer.gap_remove", + {"type": 'BACK_SPACE', "value": 'PRESS'}, + {"properties": + [("all", False), + ], + }, + ), + ("sequencer.gap_remove", + {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, + {"properties": + [("all", True), + ], + }, + ), + ("sequencer.gap_insert", {"type": 'EQUAL', "value": 'PRESS', "shift": True}, None), + ("sequencer.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("sequencer.swap_inputs", {"type": 'S', "value": 'PRESS', "alt": True}, None), + ("sequencer.cut_multicam", + {"type": 'ONE', "value": 'PRESS'}, + {"properties": + [("camera", 1), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'TWO', "value": 'PRESS'}, + {"properties": + [("camera", 2), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'THREE', "value": 'PRESS'}, + {"properties": + [("camera", 3), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'FOUR', "value": 'PRESS'}, + {"properties": + [("camera", 4), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'FIVE', "value": 'PRESS'}, + {"properties": + [("camera", 5), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'SIX', "value": 'PRESS'}, + {"properties": + [("camera", 6), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'SEVEN', "value": 'PRESS'}, + {"properties": + [("camera", 7), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'EIGHT', "value": 'PRESS'}, + {"properties": + [("camera", 8), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'NINE', "value": 'PRESS'}, + {"properties": + [("camera", 9), + ], + }, + ), + ("sequencer.cut_multicam", + {"type": 'ZERO', "value": 'PRESS'}, + {"properties": + [("camera", 10), + ], + }, + ), + ("sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ("linked_handle", False), + ("left_right", 'NONE'), + ("linked_time", False), + ], + }, + ), + ("sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ("linked_handle", False), + ("left_right", 'NONE'), + ("linked_time", False), + ], + }, + ), + ("sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "alt": True}, + {"properties": + [("extend", False), + ("linked_handle", True), + ("left_right", 'NONE'), + ("linked_time", False), + ], + }, + ), + ("sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("extend", True), + ("linked_handle", True), + ("left_right", 'NONE'), + ("linked_time", False), + ], + }, + ), + ("sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("extend", False), + ("linked_handle", False), + ("left_right", 'MOUSE'), + ("linked_time", True), + ], + }, + ), + ("sequencer.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("extend", True), + ("linked_handle", False), + ("left_right", 'NONE'), + ("linked_time", True), + ], + }, + ), + ("sequencer.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.select_linked_pick", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("extend", False), + ], + }, + ), + ("sequencer.select_linked_pick", + {"type": 'L', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("sequencer.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("sequencer.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None), + ("wm.call_menu", + {"type": 'A', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'SEQUENCER_MT_add'), + ], + }, + ), + ("wm.call_menu", + {"type": 'C', "value": 'PRESS'}, + {"properties": + [("name", 'SEQUENCER_MT_change'), + ], + }, + ), + ("sequencer.slip", {"type": 'S', "value": 'PRESS'}, None), + ("wm.context_set_int", + {"type": 'O', "value": 'PRESS'}, + {"properties": + [("data_path", 'scene.sequence_editor.overlay_frame'), + ("value", 0), + ], + }, + ), + ("transform.seq_slide", {"type": 'G', "value": 'PRESS'}, None), + ("transform.seq_slide", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.transform", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("mode", 'TIME_EXTEND'), + ], + }, + ), + ("marker.add", {"type": 'M', "value": 'PRESS'}, None), + ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("SequencerPreview", + {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("sequencer.view_all_preview", {"type": 'HOME', "value": 'PRESS'}, None), + ("sequencer.view_all_preview", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("sequencer.view_ghost_border", {"type": 'O', "value": 'PRESS'}, None), + ("sequencer.view_zoom_ratio", + {"type": 'NUMPAD_1', "value": 'PRESS'}, + {"properties": + [("ratio", 1.0), + ], + }, + ), + ("sequencer.sample", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ], + }, + ), + ("Console", + {"space_type": 'CONSOLE', "region_type": 'WINDOW'}, + {"items": + [("console.move", + {"type": 'LEFT_ARROW', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PREVIOUS_WORD'), + ], + }, + ), + ("console.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'NEXT_WORD'), + ], + }, + ), + ("console.move", + {"type": 'HOME', "value": 'PRESS'}, + {"properties": + [("type", 'LINE_BEGIN'), + ], + }, + ), + ("console.move", + {"type": 'END', "value": 'PRESS'}, + {"properties": + [("type", 'LINE_END'), + ], + }, + ), + ("wm.context_cycle_int", + {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.font_size'), + ("reverse", False), + ], + }, + ), + ("wm.context_cycle_int", + {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.font_size'), + ("reverse", True), + ], + }, + ), + ("wm.context_cycle_int", + {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.font_size'), + ("reverse", False), + ], + }, + ), + ("wm.context_cycle_int", + {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.font_size'), + ("reverse", True), + ], + }, + ), + ("console.move", + {"type": 'LEFT_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("console.move", + {"type": 'RIGHT_ARROW', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_CHARACTER'), + ], + }, + ), + ("console.history_cycle", + {"type": 'UP_ARROW', "value": 'PRESS'}, + {"properties": + [("reverse", True), + ], + }, + ), + ("console.history_cycle", + {"type": 'DOWN_ARROW', "value": 'PRESS'}, + {"properties": + [("reverse", False), + ], + }, + ), + ("console.delete", + {"type": 'DEL', "value": 'PRESS'}, + {"properties": + [("type", 'NEXT_CHARACTER'), + ], + }, + ), + ("console.delete", + {"type": 'BACK_SPACE', "value": 'PRESS'}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("console.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True}, + {"properties": + [("type", 'PREVIOUS_CHARACTER'), + ], + }, + ), + ("console.delete", + {"type": 'DEL', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'NEXT_WORD'), + ], + }, + ), + ("console.delete", + {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, + {"properties": + [("type", 'PREVIOUS_WORD'), + ], + }, + ), + ("console.clear_line", {"type": 'RET', "value": 'PRESS', "shift": True}, None), + ("console.clear_line", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None), + ("console.execute", + {"type": 'RET', "value": 'PRESS'}, + {"properties": + [("interactive", True), + ], + }, + ), + ("console.execute", + {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, + {"properties": + [("interactive", True), + ], + }, + ), + ("console.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None), + ("console.copy_as_script", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None), + ("console.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("console.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ("console.select_set", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("console.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), + ("console.insert", + {"type": 'TAB', "value": 'PRESS', "ctrl": True}, + {"properties": + [("text", '\t'), + ], + }, + ), + ("console.indent", {"type": 'TAB', "value": 'PRESS'}, None), + ("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), + ("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + ], + }, + ), + ("Clip", + {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("clip.open", {"type": 'O', "value": 'PRESS', "alt": True}, None), + ("clip.tools", {"type": 'T', "value": 'PRESS'}, None), + ("clip.properties", {"type": 'N', "value": 'PRESS'}, None), + ("clip.track_markers", + {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, + {"properties": + [("backwards", True), + ("sequence", False), + ], + }, + ), + ("clip.track_markers", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, + {"properties": + [("backwards", False), + ("sequence", False), + ], + }, + ), + ("clip.track_markers", + {"type": 'T', "value": 'PRESS', "ctrl": True}, + {"properties": + [("backwards", False), + ("sequence", True), + ], + }, + ), + ("clip.track_markers", + {"type": 'T', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("backwards", True), + ("sequence", True), + ], + }, + ), + ("wm.context_toggle_enum", + {"type": 'TAB', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.mode'), + ("value_1", 'TRACKING'), + ("value_2", 'MASK'), + ], + }, + ), + ("clip.solve_camera", {"type": 'S', "value": 'PRESS', "shift": True}, None), + ("clip.set_solver_keyframe", + {"type": 'Q', "value": 'PRESS'}, + {"properties": + [("keyframe", 'KEYFRAME_A'), + ], + }, + ), + ("clip.set_solver_keyframe", + {"type": 'E', "value": 'PRESS'}, + {"properties": + [("keyframe", 'KEYFRAME_B'), + ], + }, + ), + ("clip.prefetch", {"type": 'P', "value": 'PRESS'}, None), + ], + }, + ), + ("Clip Editor", + {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None), + ("clip.view_pan", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None), + ("clip.view_pan", {"type": 'TRACKPADPAN', "value": 'ANY'}, None), + ("clip.view_zoom", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("clip.view_zoom", {"type": 'TRACKPADZOOM', "value": 'ANY'}, None), + ("clip.view_zoom", {"type": 'TRACKPADPAN', "value": 'ANY', "ctrl": True}, None), + ("clip.view_zoom_in", {"type": 'WHEELINMOUSE', "value": 'PRESS'}, None), + ("clip.view_zoom_out", {"type": 'WHEELOUTMOUSE', "value": 'PRESS'}, None), + ("clip.view_zoom_in", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, None), + ("clip.view_zoom_out", {"type": 'NUMPAD_MINUS', "value": 'PRESS'}, None), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS', "ctrl": True}, + {"properties": + [("ratio", 8.0), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS', "ctrl": True}, + {"properties": + [("ratio", 4.0), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS', "ctrl": True}, + {"properties": + [("ratio", 2.0), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS', "shift": True}, + {"properties": + [("ratio", 8.0), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS', "shift": True}, + {"properties": + [("ratio", 4.0), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS', "shift": True}, + {"properties": + [("ratio", 2.0), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_1', "value": 'PRESS'}, + {"properties": + [("ratio", 1.0), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_2', "value": 'PRESS'}, + {"properties": + [("ratio", 0.5), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_4', "value": 'PRESS'}, + {"properties": + [("ratio", 0.25), + ], + }, + ), + ("clip.view_zoom_ratio", + {"type": 'NUMPAD_8', "value": 'PRESS'}, + {"properties": + [("ratio", 0.125), + ], + }, + ), + ("clip.view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("clip.view_all", + {"type": 'F', "value": 'PRESS'}, + {"properties": + [("fit_view", True), + ], + }, + ), + ("clip.view_selected", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("clip.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("clip.view_ndof", {"type": 'NDOF_MOTION', "value": 'ANY'}, None), + ("clip.frame_jump", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("position", 'PATHSTART'), + ], + }, + ), + ("clip.frame_jump", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "ctrl": True}, + {"properties": + [("position", 'PATHEND'), + ], + }, + ), + ("clip.frame_jump", + {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("position", 'FAILEDPREV'), + ], + }, + ), + ("clip.frame_jump", + {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("position", 'PATHSTART'), + ], + }, + ), + ("clip.change_frame", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("clip.select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ], + }, + ), + ("clip.select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("clip.select_all", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("clip.select_all", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("clip.select_border", {"type": 'B', "value": 'PRESS'}, None), + ("clip.select_circle", {"type": 'C', "value": 'PRESS'}, None), + ("wm.call_menu", + {"type": 'G', "value": 'PRESS', "shift": True}, + {"properties": + [("name", 'CLIP_MT_select_grouped'), + ], + }, + ), + ("clip.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "ctrl": True, "alt": True}, + {"properties": + [("deselect", False), + ], + }, + ), + ("clip.select_lasso", + {"type": 'EVT_TWEAK_A', "value": 'ANY', "shift": True, "ctrl": True, "alt": True}, + {"properties": + [("deselect", True), + ], + }, + ), + ("clip.add_marker_slide", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), + ("clip.delete_marker", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), + ("clip.delete_marker", {"type": 'X', "value": 'PRESS', "shift": True}, None), + ("clip.slide_marker", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("clip.disable_markers", + {"type": 'D', "value": 'PRESS', "shift": True}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("clip.delete_track", {"type": 'DEL', "value": 'PRESS'}, None), + ("clip.delete_track", {"type": 'X', "value": 'PRESS'}, None), + ("clip.lock_tracks", + {"type": 'L', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'LOCK'), + ], + }, + ), + ("clip.lock_tracks", + {"type": 'L', "value": 'PRESS', "alt": True}, + {"properties": + [("action", 'UNLOCK'), + ], + }, + ), + ("clip.hide_tracks", + {"type": 'H', "value": 'PRESS'}, + {"properties": + [("unselected", False), + ], + }, + ), + ("clip.hide_tracks", + {"type": 'H', "value": 'PRESS', "shift": True}, + {"properties": + [("unselected", True), + ], + }, + ), + ("clip.hide_tracks_clear", {"type": 'H', "value": 'PRESS', "alt": True}, None), + ("clip.slide_plane_marker", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("clip.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None), + ("clip.keyframe_delete", {"type": 'I', "value": 'PRESS', "alt": True}, None), + ("clip.join_tracks", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), + ("wm.call_menu", + {"type": 'W', "value": 'PRESS'}, + {"properties": + [("name", 'CLIP_MT_tracking_specials'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.lock_selection'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'D', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'space_data.show_disabled'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'S', "value": 'PRESS', "alt": True}, + {"properties": + [("data_path", 'space_data.show_marker_search'), + ], + }, + ), + ("wm.context_toggle", + {"type": 'M', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.use_mute_footage'), + ], + }, + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ("clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "alt": True}, + {"properties": + [("action", 'REMAINED'), + ("clear_active", False), + ], + }, + ), + ("clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "shift": True}, + {"properties": + [("action", 'UPTO'), + ("clear_active", False), + ], + }, + ), + ("clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("action", 'ALL'), + ("clear_active", False), + ], + }, + ), + ("clip.cursor_set", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'BOUNDING_BOX_CENTER'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'COMMA', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'MEDIAN_POINT'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'CURSOR'), + ], + }, + ), + ("wm.context_set_enum", + {"type": 'PERIOD', "value": 'PRESS', "ctrl": True}, + {"properties": + [("data_path", 'space_data.pivot_point'), + ("value", 'INDIVIDUAL_ORIGINS'), + ], + }, + ), + ("clip.copy_tracks", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + ("clip.paste_tracks", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), + ], + }, + ), + ("Clip Graph Editor", + {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("clip.change_frame", {"type": 'ACTIONMOUSE', "value": 'PRESS'}, None), + ("clip.graph_select", + {"type": 'SELECTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", False), + ], + }, + ), + ("clip.graph_select", + {"type": 'SELECTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": + [("extend", True), + ], + }, + ), + ("clip.graph_select_all_markers", + {"type": 'A', "value": 'PRESS'}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("clip.graph_select_all_markers", + {"type": 'I', "value": 'PRESS', "ctrl": True}, + {"properties": + [("action", 'INVERT'), + ], + }, + ), + ("clip.graph_select_border", {"type": 'B', "value": 'PRESS'}, None), + ("clip.graph_delete_curve", {"type": 'DEL', "value": 'PRESS'}, None), + ("clip.graph_delete_curve", {"type": 'X', "value": 'PRESS'}, None), + ("clip.graph_delete_knot", {"type": 'DEL', "value": 'PRESS', "shift": True}, None), + ("clip.graph_delete_knot", {"type": 'X', "value": 'PRESS', "shift": True}, None), + ("clip.graph_view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("clip.graph_view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ("clip.graph_center_current_frame", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None), + ("wm.context_toggle", + {"type": 'L', "value": 'PRESS'}, + {"properties": + [("data_path", 'space_data.lock_time_cursor'), + ], + }, + ), + ("clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "alt": True}, + {"properties": + [("action", 'REMAINED'), + ("clear_active", True), + ], + }, + ), + ("clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "shift": True}, + {"properties": + [("action", 'UPTO'), + ("clear_active", True), + ], + }, + ), + ("clip.clear_track_path", + {"type": 'T', "value": 'PRESS', "shift": True, "alt": True}, + {"properties": + [("action", 'ALL'), + ("clear_active", True), + ], + }, + ), + ("clip.graph_disable_markers", + {"type": 'D', "value": 'PRESS', "shift": True}, + {"properties": + [("action", 'TOGGLE'), + ], + }, + ), + ("transform.translate", {"type": 'G', "value": 'PRESS'}, None), + ("transform.translate", {"type": 'EVT_TWEAK_S', "value": 'ANY'}, None), + ("transform.resize", {"type": 'S', "value": 'PRESS'}, None), + ("transform.rotate", {"type": 'R', "value": 'PRESS'}, None), + ], + }, + ), + ("Clip Dopesheet Editor", + {"space_type": 'CLIP_EDITOR', "region_type": 'WINDOW'}, + {"items": + [("clip.dopesheet_select_channel", + {"type": 'LEFTMOUSE', "value": 'PRESS'}, + {"properties": + [("extend", True), + ], + }, + ), + ("clip.dopesheet_view_all", {"type": 'HOME', "value": 'PRESS'}, None), + ("clip.dopesheet_view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), + ], + }, + ), + ("3D View Tool: OBJECT, Move", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("transform.translate", + {"type": 'EVT_TWEAK_A', "value": 'ANY'}, + {"properties": + [("release_confirm", True), + ], + }, + ), + ], + }, + ), + ("3D View Tool: OBJECT, Rotate", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("transform.rotate", + {"type": 'EVT_TWEAK_A', "value": 'ANY'}, + {"properties": + [("release_confirm", True), + ], + }, + ), + ], + }, + ), + ("3D View Tool: OBJECT, Scale", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("transform.resize", + {"type": 'EVT_TWEAK_A', "value": 'ANY'}, + {"properties": + [("release_confirm", True), + ], + }, + ), + ], + }, + ), + ("3D View Tool: OBJECT, Ruler/Protractor", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("view3d.ruler_add", {"type": 'EVT_TWEAK_A', "value": 'ANY'}, None), + ], + }, + ), + ("3D View Tool: PARTICLE, Cursor Click", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("view3d.cursor3d", {"type": 'ACTIONMOUSE', "value": 'CLICK'}, None), + ], + }, + ), + ("Spot Lamp Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Area Lamp Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ("Target Lamp Widgets", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": + [("manipulatorgroup.manipulator_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), + ], + }, + ), + ] if __name__ == "__main__": -- cgit v1.2.3 From 5a716701e8c769a9d24c5c0ff5056bf9f5dc3917 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 15:59:47 +0200 Subject: GPU_batch: fix error w/ interior line removal Caused glitch w/ navigation icons showing inner lines. --- source/blender/gpu/intern/gpu_batch.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 6194e720156..391a3812073 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -215,13 +215,12 @@ Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( { qsort(lines, lines_len, sizeof(int32_t), BLI_sortutil_cmp_int); lines_step = lines; - - if (lines[0] != lines[1]) { - *lines_step++ = lines[0]; - } for (uint i_prev = 0, i = 1; i < lines_len; i_prev = i++) { if (lines[i] != lines[i_prev]) { - *lines_step++ = lines[i]; + *lines_step++ = lines[i_prev]; + } + else { + i++; } } lines_len = lines_step - lines; -- cgit v1.2.3 From fc7c934cfc00bd58f5cb6114bc9ca1e2e07564e1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 22:29:35 +0200 Subject: UI: rename manipulator to gizmo This is a common, short, distinctive term often used for this purpose. Changes to internal API's still needed. --- release/scripts/startup/bl_ui/space_userpref.py | 6 +++--- release/scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/makesrna/intern/rna_scene.c | 2 +- source/blender/makesrna/intern/rna_space.c | 8 ++++---- source/blender/makesrna/intern/rna_userdef.c | 10 +++++----- .../windowmanager/manipulators/intern/wm_manipulator_group.c | 8 ++++---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 806b57e0297..0c717aa21d5 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -258,7 +258,7 @@ class USERPREF_PT_interface(Panel): #col.label(text="Open Toolbox Delay:") #col.prop(view, "open_left_mouse_delay", text="Hold LMB") #col.prop(view, "open_right_mouse_delay", text="Hold RMB") - col.prop(view, "show_manipulator", text="Manipulators") + col.prop(view, "show_manipulator", text="Gizmos") sub = col.column() sub.active = view.show_manipulator sub.prop(view, "manipulator_size", text="Size") @@ -273,7 +273,7 @@ class USERPREF_PT_interface(Panel): row.separator() col = row.column() - col.label(text="View Manipulation:") + col.label(text="View Gizmos:") col.prop(view, "use_mouse_depth_cursor") col.prop(view, "use_cursor_lock_adjust") col.prop(view, "use_mouse_depth_navigate") @@ -916,7 +916,7 @@ class USERPREF_PT_theme(Panel): col.separator() col.separator() - col.label("Axis & Manipulator Colors:") + col.label("Axis & Gizmo Colors:") row = col.row() diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index f9b69b8de66..3f711ace97e 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3958,7 +3958,7 @@ class VIEW3D_PT_overlay_manipulators(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_parent_id = 'VIEW3D_PT_overlay' - bl_label = "Manipulators" + bl_label = "Gizmo" def draw_header(self, context): view = context.space_data diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 0c734a8e7c7..690c6d8e4c1 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2694,7 +2694,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "manipulator_flag"); RNA_def_property_enum_items(prop, rna_enum_manipulator_items); RNA_def_property_flag(prop, PROP_ENUM_FLAG); - RNA_def_property_ui_text(prop, "Manipulator", ""); + RNA_def_property_ui_text(prop, "Gizmo Mode", ""); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_manipulator_flag_update"); /* Grease Pencil */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index b89a4f09d9f..4bdf7a09585 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2941,22 +2941,22 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE); - RNA_def_property_ui_text(prop, "Manipulator", "Show manipulators of all types"); + RNA_def_property_ui_text(prop, "Show Gizmo", "Show gizmos of all types"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_manipulator_navigate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_NAVIGATE); - RNA_def_property_ui_text(prop, "Navigate Manipulator", ""); + RNA_def_property_ui_text(prop, "Navigate Gizmo", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_manipulator_context", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_CONTEXT); - RNA_def_property_ui_text(prop, "Context Manipulator", "Context sensitive manipulators for the active item"); + RNA_def_property_ui_text(prop, "Context Gizmo", "Context sensitive manipulators for the active item"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_manipulator_tool", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_TOOL); - RNA_def_property_ui_text(prop, "Tool Manipulator", "Active tool manipulator"); + RNA_def_property_ui_text(prop, "Tool Gizmo", "Active tool manipulator"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 3d116482656..d8941e303d9 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1205,31 +1205,31 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) prop = RNA_def_property(srna, "manipulator_hi", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "manipulator_hi"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Manipulator Highlight", ""); + RNA_def_property_ui_text(prop, "Gizmo Highlight", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "manipulator_primary", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "manipulator_primary"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Manipulator Primary", ""); + RNA_def_property_ui_text(prop, "Gizmo Primary", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "manipulator_secondary", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "manipulator_secondary"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Manipulator Secondary", ""); + RNA_def_property_ui_text(prop, "Gizmo Secondary", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "manipulator_a", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "manipulator_a"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Manipulator A", ""); + RNA_def_property_ui_text(prop, "Gizmo A", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "manipulator_b", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "manipulator_b"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Manipulator B", ""); + RNA_def_property_ui_text(prop, "Gizmo B", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); } diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c index f9b55865bf0..8bda9e91db7 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c @@ -303,7 +303,7 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent void MANIPULATORGROUP_OT_manipulator_select(wmOperatorType *ot) { /* identifiers */ - ot->name = "Manipulator Select"; + ot->name = "Gizmo Select"; ot->description = "Select the currently highlighted manipulator"; ot->idname = "MANIPULATORGROUP_OT_manipulator_select"; @@ -585,8 +585,8 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) { /* identifiers */ - ot->name = "Manipulator Tweak"; - ot->description = "Tweak the active manipulator"; + ot->name = "Gizmo Tweak"; + ot->description = "Tweak the active gizmo"; ot->idname = "MANIPULATORGROUP_OT_manipulator_tweak"; /* api callbacks */ @@ -600,7 +600,7 @@ void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) #endif } -/** \} */ // Manipulator operators +/** \} */ static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname) -- cgit v1.2.3 From cd1600413246a62156441f6e7910489b19ae5a28 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 23:16:34 +0200 Subject: WM: rename files, manipulator -> gizmo Edit doxy files and header guards only. --- build_files/cmake/macros.cmake | 4 +- .../scripts/templates_py/gizmo_custom_geometry.py | 158 ++ release/scripts/templates_py/gizmo_operator.py | 234 +++ .../scripts/templates_py/gizmo_operator_target.py | 50 + release/scripts/templates_py/gizmo_simple.py | 47 + .../templates_py/manipulator_custom_geometry.py | 158 -- .../scripts/templates_py/manipulator_operator.py | 234 --- .../templates_py/manipulator_operator_target.py | 50 - release/scripts/templates_py/manipulator_simple.py | 47 - source/blender/editors/CMakeLists.txt | 2 +- .../blender/editors/gizmo_library/CMakeLists.txt | 60 + .../gizmo_library/geometry/geom_arrow_gizmo.c | 141 ++ .../gizmo_library/geometry/geom_cube_gizmo.c | 75 + .../gizmo_library/geometry/geom_dial_gizmo.c | 813 +++++++++ .../editors/gizmo_library/gizmo_draw_utils.c | 121 ++ .../blender/editors/gizmo_library/gizmo_geometry.h | 54 + .../editors/gizmo_library/gizmo_library_intern.h | 111 ++ .../editors/gizmo_library/gizmo_library_presets.c | 150 ++ .../editors/gizmo_library/gizmo_library_utils.c | 256 +++ .../gizmo_library/gizmo_types/arrow2d_gizmo.c | 225 +++ .../gizmo_library/gizmo_types/arrow3d_gizmo.c | 492 ++++++ .../gizmo_library/gizmo_types/button2d_gizmo.c | 322 ++++ .../gizmo_library/gizmo_types/cage2d_gizmo.c | 1100 ++++++++++++ .../gizmo_library/gizmo_types/cage3d_gizmo.c | 692 ++++++++ .../gizmo_library/gizmo_types/dial3d_gizmo.c | 487 ++++++ .../gizmo_library/gizmo_types/grab3d_gizmo.c | 375 ++++ .../gizmo_library/gizmo_types/primitive3d_gizmo.c | 191 +++ source/blender/editors/include/ED_gizmo_library.h | 222 +++ .../editors/include/ED_manipulator_library.h | 222 --- .../editors/manipulator_library/CMakeLists.txt | 60 - .../geometry/geom_arrow_manipulator.c | 141 -- .../geometry/geom_cube_manipulator.c | 75 - .../geometry/geom_dial_manipulator.c | 813 --------- .../manipulator_library/manipulator_draw_utils.c | 121 -- .../manipulator_library/manipulator_geometry.h | 54 - .../manipulator_library_intern.h | 111 -- .../manipulator_library_presets.c | 150 -- .../manipulator_library_utils.c | 256 --- .../manipulator_types/arrow2d_manipulator.c | 225 --- .../manipulator_types/arrow3d_manipulator.c | 492 ------ .../manipulator_types/button2d_manipulator.c | 322 ---- .../manipulator_types/cage2d_manipulator.c | 1100 ------------ .../manipulator_types/cage3d_manipulator.c | 692 -------- .../manipulator_types/dial3d_manipulator.c | 487 ------ .../manipulator_types/grab3d_manipulator.c | 375 ---- .../manipulator_types/primitive3d_manipulator.c | 191 --- source/blender/editors/mesh/CMakeLists.txt | 2 +- source/blender/editors/mesh/editmesh_add_gizmo.c | 426 +++++ .../editors/mesh/editmesh_add_manipulator.c | 426 ----- source/blender/editors/mesh/editmesh_bisect.c | 2 +- source/blender/editors/mesh/editmesh_extrude.c | 2 +- .../blender/editors/mesh/editmesh_extrude_spin.c | 2 +- source/blender/editors/space_api/spacetypes.c | 2 +- source/blender/editors/space_node/CMakeLists.txt | 2 +- source/blender/editors/space_node/node_gizmo.c | 621 +++++++ .../blender/editors/space_node/node_manipulators.c | 621 ------- source/blender/editors/space_view3d/CMakeLists.txt | 16 +- .../editors/space_view3d/view3d_gizmo_armature.c | 228 +++ .../editors/space_view3d/view3d_gizmo_camera.c | 473 ++++++ .../editors/space_view3d/view3d_gizmo_empty.c | 204 +++ .../editors/space_view3d/view3d_gizmo_forcefield.c | 125 ++ .../editors/space_view3d/view3d_gizmo_lamp.c | 307 ++++ .../editors/space_view3d/view3d_gizmo_navigate.c | 371 ++++ .../space_view3d/view3d_gizmo_navigate_type.c | 310 ++++ .../editors/space_view3d/view3d_gizmo_ruler.c | 1101 ++++++++++++ .../space_view3d/view3d_manipulator_armature.c | 228 --- .../space_view3d/view3d_manipulator_camera.c | 473 ------ .../space_view3d/view3d_manipulator_empty.c | 204 --- .../space_view3d/view3d_manipulator_forcefield.c | 125 -- .../editors/space_view3d/view3d_manipulator_lamp.c | 307 ---- .../space_view3d/view3d_manipulator_navigate.c | 371 ---- .../view3d_manipulator_navigate_type.c | 310 ---- .../space_view3d/view3d_manipulator_ruler.c | 1101 ------------ source/blender/editors/transform/CMakeLists.txt | 4 +- .../blender/editors/transform/transform_gizmo_2d.c | 382 +++++ .../blender/editors/transform/transform_gizmo_3d.c | 1790 ++++++++++++++++++++ .../editors/transform/transform_manipulator_2d.c | 382 ----- .../editors/transform/transform_manipulator_3d.c | 1790 -------------------- source/blender/editors/util/CMakeLists.txt | 2 +- source/blender/makesrna/intern/CMakeLists.txt | 4 +- source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/makesrna/intern/rna_wm_gizmo.c | 1335 +++++++++++++++ source/blender/makesrna/intern/rna_wm_gizmo_api.c | 290 ++++ .../blender/makesrna/intern/rna_wm_manipulator.c | 1335 --------------- .../makesrna/intern/rna_wm_manipulator_api.c | 290 ---- source/blender/python/intern/CMakeLists.txt | 8 +- source/blender/python/intern/bpy.c | 2 +- source/blender/python/intern/bpy_gizmo_wrap.c | 235 +++ source/blender/python/intern/bpy_gizmo_wrap.h | 35 + .../blender/python/intern/bpy_manipulator_wrap.c | 235 --- .../blender/python/intern/bpy_manipulator_wrap.h | 35 - source/blender/python/intern/bpy_msgbus.c | 2 +- source/blender/python/intern/bpy_rna_gizmo.c | 565 ++++++ source/blender/python/intern/bpy_rna_gizmo.h | 32 + source/blender/python/intern/bpy_rna_manipulator.c | 565 ------ source/blender/python/intern/bpy_rna_manipulator.h | 32 - source/blender/windowmanager/CMakeLists.txt | 26 +- source/blender/windowmanager/WM_types.h | 4 +- source/blender/windowmanager/gizmo/WM_gizmo_api.h | 343 ++++ .../blender/windowmanager/gizmo/WM_gizmo_types.h | 422 +++++ .../blender/windowmanager/gizmo/intern/wm_gizmo.c | 800 +++++++++ .../windowmanager/gizmo/intern/wm_gizmo_group.c | 949 +++++++++++ .../gizmo/intern/wm_gizmo_group_type.c | 197 +++ .../windowmanager/gizmo/intern/wm_gizmo_intern.h | 144 ++ .../windowmanager/gizmo/intern/wm_gizmo_map.c | 1209 +++++++++++++ .../gizmo/intern/wm_gizmo_target_props.c | 364 ++++ .../windowmanager/gizmo/intern/wm_gizmo_type.c | 212 +++ source/blender/windowmanager/gizmo/wm_gizmo_fn.h | 88 + .../blender/windowmanager/gizmo/wm_gizmo_wmapi.h | 97 ++ .../manipulators/WM_manipulator_api.h | 343 ---- .../manipulators/WM_manipulator_types.h | 422 ----- .../manipulators/intern/wm_manipulator.c | 800 --------- .../manipulators/intern/wm_manipulator_group.c | 949 ----------- .../intern/wm_manipulator_group_type.c | 197 --- .../manipulators/intern/wm_manipulator_intern.h | 144 -- .../manipulators/intern/wm_manipulator_map.c | 1209 ------------- .../intern/wm_manipulator_target_props.c | 364 ---- .../manipulators/intern/wm_manipulator_type.c | 212 --- .../windowmanager/manipulators/wm_manipulator_fn.h | 88 - .../manipulators/wm_manipulator_wmapi.h | 97 -- source/blender/windowmanager/wm.h | 2 +- 121 files changed, 20076 insertions(+), 20076 deletions(-) create mode 100644 release/scripts/templates_py/gizmo_custom_geometry.py create mode 100644 release/scripts/templates_py/gizmo_operator.py create mode 100644 release/scripts/templates_py/gizmo_operator_target.py create mode 100644 release/scripts/templates_py/gizmo_simple.py delete mode 100644 release/scripts/templates_py/manipulator_custom_geometry.py delete mode 100644 release/scripts/templates_py/manipulator_operator.py delete mode 100644 release/scripts/templates_py/manipulator_operator_target.py delete mode 100644 release/scripts/templates_py/manipulator_simple.py create mode 100644 source/blender/editors/gizmo_library/CMakeLists.txt create mode 100644 source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c create mode 100644 source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c create mode 100644 source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c create mode 100644 source/blender/editors/gizmo_library/gizmo_draw_utils.c create mode 100644 source/blender/editors/gizmo_library/gizmo_geometry.h create mode 100644 source/blender/editors/gizmo_library/gizmo_library_intern.h create mode 100644 source/blender/editors/gizmo_library/gizmo_library_presets.c create mode 100644 source/blender/editors/gizmo_library/gizmo_library_utils.c create mode 100644 source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c create mode 100644 source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c create mode 100644 source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c create mode 100644 source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c create mode 100644 source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c create mode 100644 source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c create mode 100644 source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c create mode 100644 source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c create mode 100644 source/blender/editors/include/ED_gizmo_library.h delete mode 100644 source/blender/editors/include/ED_manipulator_library.h delete mode 100644 source/blender/editors/manipulator_library/CMakeLists.txt delete mode 100644 source/blender/editors/manipulator_library/geometry/geom_arrow_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/geometry/geom_cube_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/geometry/geom_dial_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_draw_utils.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_geometry.h delete mode 100644 source/blender/editors/manipulator_library/manipulator_library_intern.h delete mode 100644 source/blender/editors/manipulator_library/manipulator_library_presets.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_library_utils.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c delete mode 100644 source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c create mode 100644 source/blender/editors/mesh/editmesh_add_gizmo.c delete mode 100644 source/blender/editors/mesh/editmesh_add_manipulator.c create mode 100644 source/blender/editors/space_node/node_gizmo.c delete mode 100644 source/blender/editors/space_node/node_manipulators.c create mode 100644 source/blender/editors/space_view3d/view3d_gizmo_armature.c create mode 100644 source/blender/editors/space_view3d/view3d_gizmo_camera.c create mode 100644 source/blender/editors/space_view3d/view3d_gizmo_empty.c create mode 100644 source/blender/editors/space_view3d/view3d_gizmo_forcefield.c create mode 100644 source/blender/editors/space_view3d/view3d_gizmo_lamp.c create mode 100644 source/blender/editors/space_view3d/view3d_gizmo_navigate.c create mode 100644 source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c create mode 100644 source/blender/editors/space_view3d/view3d_gizmo_ruler.c delete mode 100644 source/blender/editors/space_view3d/view3d_manipulator_armature.c delete mode 100644 source/blender/editors/space_view3d/view3d_manipulator_camera.c delete mode 100644 source/blender/editors/space_view3d/view3d_manipulator_empty.c delete mode 100644 source/blender/editors/space_view3d/view3d_manipulator_forcefield.c delete mode 100644 source/blender/editors/space_view3d/view3d_manipulator_lamp.c delete mode 100644 source/blender/editors/space_view3d/view3d_manipulator_navigate.c delete mode 100644 source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c delete mode 100644 source/blender/editors/space_view3d/view3d_manipulator_ruler.c create mode 100644 source/blender/editors/transform/transform_gizmo_2d.c create mode 100644 source/blender/editors/transform/transform_gizmo_3d.c delete mode 100644 source/blender/editors/transform/transform_manipulator_2d.c delete mode 100644 source/blender/editors/transform/transform_manipulator_3d.c create mode 100644 source/blender/makesrna/intern/rna_wm_gizmo.c create mode 100644 source/blender/makesrna/intern/rna_wm_gizmo_api.c delete mode 100644 source/blender/makesrna/intern/rna_wm_manipulator.c delete mode 100644 source/blender/makesrna/intern/rna_wm_manipulator_api.c create mode 100644 source/blender/python/intern/bpy_gizmo_wrap.c create mode 100644 source/blender/python/intern/bpy_gizmo_wrap.h delete mode 100644 source/blender/python/intern/bpy_manipulator_wrap.c delete mode 100644 source/blender/python/intern/bpy_manipulator_wrap.h create mode 100644 source/blender/python/intern/bpy_rna_gizmo.c create mode 100644 source/blender/python/intern/bpy_rna_gizmo.h delete mode 100644 source/blender/python/intern/bpy_rna_manipulator.c delete mode 100644 source/blender/python/intern/bpy_rna_manipulator.h create mode 100644 source/blender/windowmanager/gizmo/WM_gizmo_api.h create mode 100644 source/blender/windowmanager/gizmo/WM_gizmo_types.h create mode 100644 source/blender/windowmanager/gizmo/intern/wm_gizmo.c create mode 100644 source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c create mode 100644 source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c create mode 100644 source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h create mode 100644 source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c create mode 100644 source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c create mode 100644 source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c create mode 100644 source/blender/windowmanager/gizmo/wm_gizmo_fn.h create mode 100644 source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h delete mode 100644 source/blender/windowmanager/manipulators/WM_manipulator_api.h delete mode 100644 source/blender/windowmanager/manipulators/WM_manipulator_types.h delete mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator.c delete mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c delete mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c delete mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h delete mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c delete mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c delete mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c delete mode 100644 source/blender/windowmanager/manipulators/wm_manipulator_fn.h delete mode 100644 source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 545b0e8ce5d..b2ec8f6e7a9 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -600,7 +600,7 @@ function(SETUP_BLENDER_SORTED_LIBS) bf_editor_curve bf_editor_gpencil bf_editor_interface - bf_editor_manipulator_library + bf_editor_gizmo_library bf_editor_mesh bf_editor_metaball bf_editor_object @@ -635,7 +635,7 @@ function(SETUP_BLENDER_SORTED_LIBS) bf_physics bf_nodes bf_rna - bf_editor_manipulator_library # rna -> manipulator bad-level calls + bf_editor_gizmo_library # rna -> gizmo bad-level calls bf_python bf_imbuf bf_blenlib diff --git a/release/scripts/templates_py/gizmo_custom_geometry.py b/release/scripts/templates_py/gizmo_custom_geometry.py new file mode 100644 index 00000000000..de324a909db --- /dev/null +++ b/release/scripts/templates_py/gizmo_custom_geometry.py @@ -0,0 +1,158 @@ +# Example of a custom widget that defines it's own geometry. +# +# Usage: Select a light in the 3D view and drag the arrow at it's rear +# to change it's energy value. +# +import bpy +from bpy.types import ( + Manipulator, + ManipulatorGroup, +) + +# Coordinates (each one is a triangle). +custom_shape_verts = ( + (3.0, 1.0, -1.0), (2.0, 2.0, -1.0), (3.0, 3.0, -1.0), + (1.0, 3.0, 1.0), (3.0, 3.0, -1.0), (1.0, 3.0, -1.0), + (3.0, 3.0, 1.0), (3.0, 1.0, -1.0), (3.0, 3.0, -1.0), + (2.0, 0.0, 1.0), (3.0, 1.0, -1.0), (3.0, 1.0, 1.0), + (2.0, 0.0, -1.0), (2.0, 2.0, 1.0), (2.0, 2.0, -1.0), + (2.0, 2.0, -1.0), (0.0, 2.0, 1.0), (0.0, 2.0, -1.0), + (1.0, 3.0, 1.0), (2.0, 2.0, 1.0), (3.0, 3.0, 1.0), + (0.0, 2.0, -1.0), (1.0, 3.0, 1.0), (1.0, 3.0, -1.0), + (2.0, 2.0, 1.0), (3.0, 1.0, 1.0), (3.0, 3.0, 1.0), + (2.0, 2.0, -1.0), (1.0, 3.0, -1.0), (3.0, 3.0, -1.0), + (-3.0, -1.0, -1.0), (-2.0, -2.0, -1.0), (-3.0, -3.0, -1.0), + (-1.0, -3.0, 1.0), (-3.0, -3.0, -1.0), (-1.0, -3.0, -1.0), + (-3.0, -3.0, 1.0), (-3.0, -1.0, -1.0), (-3.0, -3.0, -1.0), + (-2.0, 0.0, 1.0), (-3.0, -1.0, -1.0), (-3.0, -1.0, 1.0), + (-2.0, 0.0, -1.0), (-2.0, -2.0, 1.0), (-2.0, -2.0, -1.0), + (-2.0, -2.0, -1.0), (0.0, -2.0, 1.0), (0.0, -2.0, -1.0), + (-1.0, -3.0, 1.0), (-2.0, -2.0, 1.0), (-3.0, -3.0, 1.0), + (0.0, -2.0, -1.0), (-1.0, -3.0, 1.0), (-1.0, -3.0, -1.0), + (-2.0, -2.0, 1.0), (-3.0, -1.0, 1.0), (-3.0, -3.0, 1.0), + (-2.0, -2.0, -1.0), (-1.0, -3.0, -1.0), (-3.0, -3.0, -1.0), + (1.0, -1.0, 0.0), (-1.0, -1.0, 0.0), (0.0, 0.0, -5.0), + (-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 0.0, 5.0), + (1.0, -1.0, 0.0), (1.0, 1.0, 0.0), (0.0, 0.0, 5.0), + (1.0, 1.0, 0.0), (-1.0, 1.0, 0.0), (0.0, 0.0, 5.0), + (-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0), (0.0, 0.0, 5.0), + (-1.0, -1.0, 0.0), (-1.0, 1.0, 0.0), (0.0, 0.0, -5.0), + (-1.0, 1.0, 0.0), (1.0, 1.0, 0.0), (0.0, 0.0, -5.0), + (1.0, 1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 0.0, -5.0), + (3.0, 1.0, -1.0), (2.0, 0.0, -1.0), (2.0, 2.0, -1.0), + (1.0, 3.0, 1.0), (3.0, 3.0, 1.0), (3.0, 3.0, -1.0), + (3.0, 3.0, 1.0), (3.0, 1.0, 1.0), (3.0, 1.0, -1.0), + (2.0, 0.0, 1.0), (2.0, 0.0, -1.0), (3.0, 1.0, -1.0), + (2.0, 0.0, -1.0), (2.0, 0.0, 1.0), (2.0, 2.0, 1.0), + (2.0, 2.0, -1.0), (2.0, 2.0, 1.0), (0.0, 2.0, 1.0), + (1.0, 3.0, 1.0), (0.0, 2.0, 1.0), (2.0, 2.0, 1.0), + (0.0, 2.0, -1.0), (0.0, 2.0, 1.0), (1.0, 3.0, 1.0), + (2.0, 2.0, 1.0), (2.0, 0.0, 1.0), (3.0, 1.0, 1.0), + (2.0, 2.0, -1.0), (0.0, 2.0, -1.0), (1.0, 3.0, -1.0), + (-3.0, -1.0, -1.0), (-2.0, 0.0, -1.0), (-2.0, -2.0, -1.0), + (-1.0, -3.0, 1.0), (-3.0, -3.0, 1.0), (-3.0, -3.0, -1.0), + (-3.0, -3.0, 1.0), (-3.0, -1.0, 1.0), (-3.0, -1.0, -1.0), + (-2.0, 0.0, 1.0), (-2.0, 0.0, -1.0), (-3.0, -1.0, -1.0), + (-2.0, 0.0, -1.0), (-2.0, 0.0, 1.0), (-2.0, -2.0, 1.0), + (-2.0, -2.0, -1.0), (-2.0, -2.0, 1.0), (0.0, -2.0, 1.0), + (-1.0, -3.0, 1.0), (0.0, -2.0, 1.0), (-2.0, -2.0, 1.0), + (0.0, -2.0, -1.0), (0.0, -2.0, 1.0), (-1.0, -3.0, 1.0), + (-2.0, -2.0, 1.0), (-2.0, 0.0, 1.0), (-3.0, -1.0, 1.0), + (-2.0, -2.0, -1.0), (0.0, -2.0, -1.0), (-1.0, -3.0, -1.0), +) + + +class MyCustomShapeWidget(Manipulator): + bl_idname = "VIEW3D_WT_auto_facemap" + bl_target_properties = ( + {"id": "offset", "type": 'FLOAT', "array_length": 1}, + ) + + __slots__ = ( + "custom_shape", + "init_mouse_y", + "init_value", + ) + + def _update_offset_matrix(self): + # offset behind the light + self.matrix_offset.col[3][2] = self.target_get_value("offset") / -10.0 + + def draw(self, context): + self._update_offset_matrix() + self.draw_custom_shape(self.custom_shape) + + def draw_select(self, context, select_id): + self._update_offset_matrix() + self.draw_custom_shape(self.custom_shape, select_id=select_id) + + def setup(self): + if not hasattr(self, "custom_shape"): + self.custom_shape = self.new_custom_shape('TRIS', custom_shape_verts) + + def invoke(self, context, event): + self.init_mouse_y = event.mouse_y + self.init_value = self.target_get_value("offset") + return {'RUNNING_MODAL'} + + def exit(self, context, cancel): + context.area.header_text_set() + if cancel: + self.target_set_value("offset", self.init_value) + + def modal(self, context, event, tweak): + delta = (event.mouse_y - self.init_mouse_y) / 10.0 + if 'SNAP' in tweak: + delta = round(delta) + if 'PRECISE' in tweak: + delta /= 10.0 + value = self.init_value + delta + self.target_set_value("offset", value) + context.area.header_text_set("My Manipulator: %.4f" % value) + return {'RUNNING_MODAL'} + + +class MyCustomShapeWidgetGroup(ManipulatorGroup): + bl_idname = "OBJECT_WGT_light_test" + bl_label = "Test Light Widget" + bl_space_type = 'VIEW_3D' + bl_region_type = 'WINDOW' + bl_options = {'3D', 'PERSISTENT'} + + @classmethod + def poll(cls, context): + ob = context.object + return (ob and ob.type == 'LIGHT') + + def setup(self, context): + # Assign the 'offset' target property to the light energy. + ob = context.object + mpr = self.manipulators.new(MyCustomShapeWidget.bl_idname) + mpr.target_set_prop("offset", ob.data, "energy") + mpr.matrix_basis = ob.matrix_world.normalized() + + mpr.color = 1.0, 0.5, 1.0 + mpr.alpha = 0.5 + + mpr.color_highlight = 1.0, 1.0, 1.0 + mpr.alpha_highlight = 0.5 + + # units are large, so shrink to something more reasonable. + mpr.scale_basis = 0.1 + mpr.use_draw_modal = True + + self.energy_widget = mpr + + def refresh(self, context): + ob = context.object + mpr = self.energy_widget + mpr.matrix_basis = ob.matrix_world.normalized() + + +classes = ( + MyCustomShapeWidget, + MyCustomShapeWidgetGroup, +) + +for cls in classes: + bpy.utils.register_class(cls) diff --git a/release/scripts/templates_py/gizmo_operator.py b/release/scripts/templates_py/gizmo_operator.py new file mode 100644 index 00000000000..61796489a95 --- /dev/null +++ b/release/scripts/templates_py/gizmo_operator.py @@ -0,0 +1,234 @@ +# Example of an operator which uses manipulators to control its properties. +# +# Usage: Run this script, then in mesh edit-mode press Spacebar +# to activate the operator "Select Side of Plane" +# The manipulators can then be used to adjust the plane in the 3D view. +# +import bpy +import bmesh + +from bpy.types import ( + Operator, + ManipulatorGroup, +) + +from bpy.props import ( + FloatVectorProperty, +) + + +def main(context, plane_co, plane_no): + obj = context.active_object + matrix = obj.matrix_world.copy() + me = obj.data + bm = bmesh.from_edit_mesh(me) + + plane_dot = plane_no.dot(plane_co) + + for v in bm.verts: + co = matrix * v.co + v.select = (plane_no.dot(co) > plane_dot) + bm.select_flush_mode() + + bmesh.update_edit_mesh(me) + + +class SelectSideOfPlane(Operator): + """UV Operator description""" + bl_idname = "mesh.select_side_of_plane" + bl_label = "Select Side of Plane" + bl_options = {'REGISTER', 'UNDO'} + + plane_co: FloatVectorProperty( + size=3, + default=(0, 0, 0), + ) + plane_no: FloatVectorProperty( + size=3, + default=(0, 0, 1), + ) + + @classmethod + def poll(cls, context): + return (context.mode == 'EDIT_MESH') + + def invoke(self, context, event): + + if not self.properties.is_property_set("plane_co"): + self.plane_co = context.scene.cursor_location + + if not self.properties.is_property_set("plane_no"): + if context.space_data.type == 'VIEW_3D': + rv3d = context.space_data.region_3d + view_inv = rv3d.view_matrix.to_3x3() + # view y axis + self.plane_no = view_inv[1].normalized() + + self.execute(context) + + if context.space_data.type == 'VIEW_3D': + wm = context.window_manager + wm.manipulator_group_type_add(SelectSideOfPlaneManipulatorGroup.bl_idname) + + return {'FINISHED'} + + def execute(self, context): + from mathutils import Vector + main(context, Vector(self.plane_co), Vector(self.plane_no)) + return {'FINISHED'} + + +# Manipulators for plane_co, plane_no +class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): + bl_idname = "MESH_WGT_select_side_of_plane" + bl_label = "Side of Plane Manipulator" + bl_space_type = 'VIEW_3D' + bl_region_type = 'WINDOW' + bl_options = {'3D'} + + # Helper functions + @staticmethod + def my_target_operator(context): + wm = context.window_manager + op = wm.operators[-1] if wm.operators else None + if isinstance(op, SelectSideOfPlane): + return op + return None + + @staticmethod + def my_view_orientation(context): + rv3d = context.space_data.region_3d + view_inv = rv3d.view_matrix.to_3x3() + return view_inv.normalized() + + @classmethod + def poll(cls, context): + op = cls.my_target_operator(context) + if op is None: + wm = context.window_manager + wm.manipulator_group_type_remove(SelectSideOfPlaneManipulatorGroup.bl_idname) + return False + return True + + def setup(self, context): + from mathutils import Matrix, Vector + + # ---- + # Grab + + def grab_get_cb(): + op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) + return op.plane_co + + def grab_set_cb(value): + op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) + op.plane_co = value + # XXX, this may change! + op.execute(context) + + mpr = self.manipulators.new("MANIPULATOR_WT_grab_3d") + mpr.target_set_handler("offset", get=grab_get_cb, set=grab_set_cb) + + mpr.use_draw_value = True + + mpr.color = 0.8, 0.8, 0.8 + mpr.alpha = 0.5 + + mpr.color_highlight = 1.0, 1.0, 1.0 + mpr.alpha_highlight = 1.0 + + mpr.scale_basis = 0.2 + + self.widget_grab = mpr + + # ---- + # Dial + + def direction_get_cb(): + op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) + + no_a = self.widget_dial.matrix_basis.col[1].xyz + no_b = Vector(op.plane_no) + + no_a = (no_a * self.view_inv).xy.normalized() + no_b = (no_b * self.view_inv).xy.normalized() + return no_a.angle_signed(no_b) + + def direction_set_cb(value): + op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) + matrix_rotate = Matrix.Rotation(-value, 3, self.rotate_axis) + no = matrix_rotate * self.widget_dial.matrix_basis.col[1].xyz + op.plane_no = no + op.execute(context) + + mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d") + mpr.target_set_handler("offset", get=direction_get_cb, set=direction_set_cb) + mpr.draw_options = {'ANGLE_START_Y'} + + mpr.use_draw_value = True + + mpr.color = 0.8, 0.8, 0.8 + mpr.alpha = 0.5 + + mpr.color_highlight = 1.0, 1.0, 1.0 + mpr.alpha_highlight = 1.0 + + self.widget_dial = mpr + + def draw_prepare(self, context): + from mathutils import Vector + + view_inv = self.my_view_orientation(context) + + self.view_inv = view_inv + self.rotate_axis = view_inv[2].xyz + self.rotate_up = view_inv[1].xyz + + op = self.my_target_operator(context) + + co = Vector(op.plane_co) + no = Vector(op.plane_no).normalized() + + # Grab + no_z = no + no_y = no_z.orthogonal() + no_x = no_z.cross(no_y) + + matrix = self.widget_grab.matrix_basis + matrix.identity() + matrix.col[0].xyz = no_x + matrix.col[1].xyz = no_y + matrix.col[2].xyz = no_z + matrix.col[3].xyz = co + + # Dial + no_z = self.rotate_axis + no_y = (no - (no.project(no_z))).normalized() + no_x = self.rotate_axis.cross(no_y) + + matrix = self.widget_dial.matrix_basis + matrix.identity() + matrix.col[0].xyz = no_x + matrix.col[1].xyz = no_y + matrix.col[2].xyz = no_z + matrix.col[3].xyz = co + + +classes = ( + SelectSideOfPlane, + SelectSideOfPlaneManipulatorGroup, +) + + +def register(): + for cls in classes: + bpy.utils.register_class(cls) + + +def unregister(): + for cls in reversed(classes): + bpy.utils.unregister_class(cls) + + +if __name__ == "__main__": + register() diff --git a/release/scripts/templates_py/gizmo_operator_target.py b/release/scripts/templates_py/gizmo_operator_target.py new file mode 100644 index 00000000000..ba53b5e10ff --- /dev/null +++ b/release/scripts/templates_py/gizmo_operator_target.py @@ -0,0 +1,50 @@ +# Example of a manipulator that activates an operator +# using the predefined dial manipulator to change the camera roll. +# +# Usage: Run this script and select a camera in the 3D view. +# +import bpy +from bpy.types import ( + ManipulatorGroup, +) + + +class MyCameraWidgetGroup(ManipulatorGroup): + bl_idname = "OBJECT_WGT_test_camera" + bl_label = "Object Camera Test Widget" + bl_space_type = 'VIEW_3D' + bl_region_type = 'WINDOW' + bl_options = {'3D', 'PERSISTENT'} + + @classmethod + def poll(cls, context): + ob = context.object + return (ob and ob.type == 'CAMERA') + + def setup(self, context): + # Run an operator using the dial manipulator + ob = context.object + mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d") + props = mpr.target_set_operator("transform.rotate") + props.constraint_axis = False, False, True + props.constraint_orientation = 'LOCAL' + props.release_confirm = True + + mpr.matrix_basis = ob.matrix_world.normalized() + mpr.line_width = 3 + + mpr.color = 0.8, 0.8, 0.8 + mpr.alpha = 0.5 + + mpr.color_highlight = 1.0, 1.0, 1.0 + mpr.alpha_highlight = 1.0 + + self.roll_widget = mpr + + def refresh(self, context): + ob = context.object + mpr = self.roll_widget + mpr.matrix_basis = ob.matrix_world.normalized() + + +bpy.utils.register_class(MyCameraWidgetGroup) diff --git a/release/scripts/templates_py/gizmo_simple.py b/release/scripts/templates_py/gizmo_simple.py new file mode 100644 index 00000000000..cb10a8b94bb --- /dev/null +++ b/release/scripts/templates_py/gizmo_simple.py @@ -0,0 +1,47 @@ +# Example of a group that edits a single property +# using the predefined manipulator arrow. +# +# Usage: Select a light in the 3D view and drag the arrow at it's rear +# to change it's energy value. +# +import bpy +from bpy.types import ( + ManipulatorGroup, +) + + +class MyLightWidgetGroup(ManipulatorGroup): + bl_idname = "OBJECT_WGT_light_test" + bl_label = "Test Light Widget" + bl_space_type = 'VIEW_3D' + bl_region_type = 'WINDOW' + bl_options = {'3D', 'PERSISTENT'} + + @classmethod + def poll(cls, context): + ob = context.object + return (ob and ob.type == 'LIGHT') + + def setup(self, context): + # Arrow manipulator has one 'offset' property we can assign to the light energy. + ob = context.object + mpr = self.manipulators.new("MANIPULATOR_WT_arrow_3d") + mpr.target_set_prop("offset", ob.data, "energy") + mpr.matrix_basis = ob.matrix_world.normalized() + mpr.draw_style = 'BOX' + + mpr.color = 1.0, 0.5, 0.0 + mpr.alpha = 0.5 + + mpr.color_highlight = 1.0, 0.5, 1.0 + mpr.alpha_highlight = 0.5 + + self.energy_widget = mpr + + def refresh(self, context): + ob = context.object + mpr = self.energy_widget + mpr.matrix_basis = ob.matrix_world.normalized() + + +bpy.utils.register_class(MyLightWidgetGroup) diff --git a/release/scripts/templates_py/manipulator_custom_geometry.py b/release/scripts/templates_py/manipulator_custom_geometry.py deleted file mode 100644 index de324a909db..00000000000 --- a/release/scripts/templates_py/manipulator_custom_geometry.py +++ /dev/null @@ -1,158 +0,0 @@ -# Example of a custom widget that defines it's own geometry. -# -# Usage: Select a light in the 3D view and drag the arrow at it's rear -# to change it's energy value. -# -import bpy -from bpy.types import ( - Manipulator, - ManipulatorGroup, -) - -# Coordinates (each one is a triangle). -custom_shape_verts = ( - (3.0, 1.0, -1.0), (2.0, 2.0, -1.0), (3.0, 3.0, -1.0), - (1.0, 3.0, 1.0), (3.0, 3.0, -1.0), (1.0, 3.0, -1.0), - (3.0, 3.0, 1.0), (3.0, 1.0, -1.0), (3.0, 3.0, -1.0), - (2.0, 0.0, 1.0), (3.0, 1.0, -1.0), (3.0, 1.0, 1.0), - (2.0, 0.0, -1.0), (2.0, 2.0, 1.0), (2.0, 2.0, -1.0), - (2.0, 2.0, -1.0), (0.0, 2.0, 1.0), (0.0, 2.0, -1.0), - (1.0, 3.0, 1.0), (2.0, 2.0, 1.0), (3.0, 3.0, 1.0), - (0.0, 2.0, -1.0), (1.0, 3.0, 1.0), (1.0, 3.0, -1.0), - (2.0, 2.0, 1.0), (3.0, 1.0, 1.0), (3.0, 3.0, 1.0), - (2.0, 2.0, -1.0), (1.0, 3.0, -1.0), (3.0, 3.0, -1.0), - (-3.0, -1.0, -1.0), (-2.0, -2.0, -1.0), (-3.0, -3.0, -1.0), - (-1.0, -3.0, 1.0), (-3.0, -3.0, -1.0), (-1.0, -3.0, -1.0), - (-3.0, -3.0, 1.0), (-3.0, -1.0, -1.0), (-3.0, -3.0, -1.0), - (-2.0, 0.0, 1.0), (-3.0, -1.0, -1.0), (-3.0, -1.0, 1.0), - (-2.0, 0.0, -1.0), (-2.0, -2.0, 1.0), (-2.0, -2.0, -1.0), - (-2.0, -2.0, -1.0), (0.0, -2.0, 1.0), (0.0, -2.0, -1.0), - (-1.0, -3.0, 1.0), (-2.0, -2.0, 1.0), (-3.0, -3.0, 1.0), - (0.0, -2.0, -1.0), (-1.0, -3.0, 1.0), (-1.0, -3.0, -1.0), - (-2.0, -2.0, 1.0), (-3.0, -1.0, 1.0), (-3.0, -3.0, 1.0), - (-2.0, -2.0, -1.0), (-1.0, -3.0, -1.0), (-3.0, -3.0, -1.0), - (1.0, -1.0, 0.0), (-1.0, -1.0, 0.0), (0.0, 0.0, -5.0), - (-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 0.0, 5.0), - (1.0, -1.0, 0.0), (1.0, 1.0, 0.0), (0.0, 0.0, 5.0), - (1.0, 1.0, 0.0), (-1.0, 1.0, 0.0), (0.0, 0.0, 5.0), - (-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0), (0.0, 0.0, 5.0), - (-1.0, -1.0, 0.0), (-1.0, 1.0, 0.0), (0.0, 0.0, -5.0), - (-1.0, 1.0, 0.0), (1.0, 1.0, 0.0), (0.0, 0.0, -5.0), - (1.0, 1.0, 0.0), (1.0, -1.0, 0.0), (0.0, 0.0, -5.0), - (3.0, 1.0, -1.0), (2.0, 0.0, -1.0), (2.0, 2.0, -1.0), - (1.0, 3.0, 1.0), (3.0, 3.0, 1.0), (3.0, 3.0, -1.0), - (3.0, 3.0, 1.0), (3.0, 1.0, 1.0), (3.0, 1.0, -1.0), - (2.0, 0.0, 1.0), (2.0, 0.0, -1.0), (3.0, 1.0, -1.0), - (2.0, 0.0, -1.0), (2.0, 0.0, 1.0), (2.0, 2.0, 1.0), - (2.0, 2.0, -1.0), (2.0, 2.0, 1.0), (0.0, 2.0, 1.0), - (1.0, 3.0, 1.0), (0.0, 2.0, 1.0), (2.0, 2.0, 1.0), - (0.0, 2.0, -1.0), (0.0, 2.0, 1.0), (1.0, 3.0, 1.0), - (2.0, 2.0, 1.0), (2.0, 0.0, 1.0), (3.0, 1.0, 1.0), - (2.0, 2.0, -1.0), (0.0, 2.0, -1.0), (1.0, 3.0, -1.0), - (-3.0, -1.0, -1.0), (-2.0, 0.0, -1.0), (-2.0, -2.0, -1.0), - (-1.0, -3.0, 1.0), (-3.0, -3.0, 1.0), (-3.0, -3.0, -1.0), - (-3.0, -3.0, 1.0), (-3.0, -1.0, 1.0), (-3.0, -1.0, -1.0), - (-2.0, 0.0, 1.0), (-2.0, 0.0, -1.0), (-3.0, -1.0, -1.0), - (-2.0, 0.0, -1.0), (-2.0, 0.0, 1.0), (-2.0, -2.0, 1.0), - (-2.0, -2.0, -1.0), (-2.0, -2.0, 1.0), (0.0, -2.0, 1.0), - (-1.0, -3.0, 1.0), (0.0, -2.0, 1.0), (-2.0, -2.0, 1.0), - (0.0, -2.0, -1.0), (0.0, -2.0, 1.0), (-1.0, -3.0, 1.0), - (-2.0, -2.0, 1.0), (-2.0, 0.0, 1.0), (-3.0, -1.0, 1.0), - (-2.0, -2.0, -1.0), (0.0, -2.0, -1.0), (-1.0, -3.0, -1.0), -) - - -class MyCustomShapeWidget(Manipulator): - bl_idname = "VIEW3D_WT_auto_facemap" - bl_target_properties = ( - {"id": "offset", "type": 'FLOAT', "array_length": 1}, - ) - - __slots__ = ( - "custom_shape", - "init_mouse_y", - "init_value", - ) - - def _update_offset_matrix(self): - # offset behind the light - self.matrix_offset.col[3][2] = self.target_get_value("offset") / -10.0 - - def draw(self, context): - self._update_offset_matrix() - self.draw_custom_shape(self.custom_shape) - - def draw_select(self, context, select_id): - self._update_offset_matrix() - self.draw_custom_shape(self.custom_shape, select_id=select_id) - - def setup(self): - if not hasattr(self, "custom_shape"): - self.custom_shape = self.new_custom_shape('TRIS', custom_shape_verts) - - def invoke(self, context, event): - self.init_mouse_y = event.mouse_y - self.init_value = self.target_get_value("offset") - return {'RUNNING_MODAL'} - - def exit(self, context, cancel): - context.area.header_text_set() - if cancel: - self.target_set_value("offset", self.init_value) - - def modal(self, context, event, tweak): - delta = (event.mouse_y - self.init_mouse_y) / 10.0 - if 'SNAP' in tweak: - delta = round(delta) - if 'PRECISE' in tweak: - delta /= 10.0 - value = self.init_value + delta - self.target_set_value("offset", value) - context.area.header_text_set("My Manipulator: %.4f" % value) - return {'RUNNING_MODAL'} - - -class MyCustomShapeWidgetGroup(ManipulatorGroup): - bl_idname = "OBJECT_WGT_light_test" - bl_label = "Test Light Widget" - bl_space_type = 'VIEW_3D' - bl_region_type = 'WINDOW' - bl_options = {'3D', 'PERSISTENT'} - - @classmethod - def poll(cls, context): - ob = context.object - return (ob and ob.type == 'LIGHT') - - def setup(self, context): - # Assign the 'offset' target property to the light energy. - ob = context.object - mpr = self.manipulators.new(MyCustomShapeWidget.bl_idname) - mpr.target_set_prop("offset", ob.data, "energy") - mpr.matrix_basis = ob.matrix_world.normalized() - - mpr.color = 1.0, 0.5, 1.0 - mpr.alpha = 0.5 - - mpr.color_highlight = 1.0, 1.0, 1.0 - mpr.alpha_highlight = 0.5 - - # units are large, so shrink to something more reasonable. - mpr.scale_basis = 0.1 - mpr.use_draw_modal = True - - self.energy_widget = mpr - - def refresh(self, context): - ob = context.object - mpr = self.energy_widget - mpr.matrix_basis = ob.matrix_world.normalized() - - -classes = ( - MyCustomShapeWidget, - MyCustomShapeWidgetGroup, -) - -for cls in classes: - bpy.utils.register_class(cls) diff --git a/release/scripts/templates_py/manipulator_operator.py b/release/scripts/templates_py/manipulator_operator.py deleted file mode 100644 index 61796489a95..00000000000 --- a/release/scripts/templates_py/manipulator_operator.py +++ /dev/null @@ -1,234 +0,0 @@ -# Example of an operator which uses manipulators to control its properties. -# -# Usage: Run this script, then in mesh edit-mode press Spacebar -# to activate the operator "Select Side of Plane" -# The manipulators can then be used to adjust the plane in the 3D view. -# -import bpy -import bmesh - -from bpy.types import ( - Operator, - ManipulatorGroup, -) - -from bpy.props import ( - FloatVectorProperty, -) - - -def main(context, plane_co, plane_no): - obj = context.active_object - matrix = obj.matrix_world.copy() - me = obj.data - bm = bmesh.from_edit_mesh(me) - - plane_dot = plane_no.dot(plane_co) - - for v in bm.verts: - co = matrix * v.co - v.select = (plane_no.dot(co) > plane_dot) - bm.select_flush_mode() - - bmesh.update_edit_mesh(me) - - -class SelectSideOfPlane(Operator): - """UV Operator description""" - bl_idname = "mesh.select_side_of_plane" - bl_label = "Select Side of Plane" - bl_options = {'REGISTER', 'UNDO'} - - plane_co: FloatVectorProperty( - size=3, - default=(0, 0, 0), - ) - plane_no: FloatVectorProperty( - size=3, - default=(0, 0, 1), - ) - - @classmethod - def poll(cls, context): - return (context.mode == 'EDIT_MESH') - - def invoke(self, context, event): - - if not self.properties.is_property_set("plane_co"): - self.plane_co = context.scene.cursor_location - - if not self.properties.is_property_set("plane_no"): - if context.space_data.type == 'VIEW_3D': - rv3d = context.space_data.region_3d - view_inv = rv3d.view_matrix.to_3x3() - # view y axis - self.plane_no = view_inv[1].normalized() - - self.execute(context) - - if context.space_data.type == 'VIEW_3D': - wm = context.window_manager - wm.manipulator_group_type_add(SelectSideOfPlaneManipulatorGroup.bl_idname) - - return {'FINISHED'} - - def execute(self, context): - from mathutils import Vector - main(context, Vector(self.plane_co), Vector(self.plane_no)) - return {'FINISHED'} - - -# Manipulators for plane_co, plane_no -class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): - bl_idname = "MESH_WGT_select_side_of_plane" - bl_label = "Side of Plane Manipulator" - bl_space_type = 'VIEW_3D' - bl_region_type = 'WINDOW' - bl_options = {'3D'} - - # Helper functions - @staticmethod - def my_target_operator(context): - wm = context.window_manager - op = wm.operators[-1] if wm.operators else None - if isinstance(op, SelectSideOfPlane): - return op - return None - - @staticmethod - def my_view_orientation(context): - rv3d = context.space_data.region_3d - view_inv = rv3d.view_matrix.to_3x3() - return view_inv.normalized() - - @classmethod - def poll(cls, context): - op = cls.my_target_operator(context) - if op is None: - wm = context.window_manager - wm.manipulator_group_type_remove(SelectSideOfPlaneManipulatorGroup.bl_idname) - return False - return True - - def setup(self, context): - from mathutils import Matrix, Vector - - # ---- - # Grab - - def grab_get_cb(): - op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) - return op.plane_co - - def grab_set_cb(value): - op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) - op.plane_co = value - # XXX, this may change! - op.execute(context) - - mpr = self.manipulators.new("MANIPULATOR_WT_grab_3d") - mpr.target_set_handler("offset", get=grab_get_cb, set=grab_set_cb) - - mpr.use_draw_value = True - - mpr.color = 0.8, 0.8, 0.8 - mpr.alpha = 0.5 - - mpr.color_highlight = 1.0, 1.0, 1.0 - mpr.alpha_highlight = 1.0 - - mpr.scale_basis = 0.2 - - self.widget_grab = mpr - - # ---- - # Dial - - def direction_get_cb(): - op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) - - no_a = self.widget_dial.matrix_basis.col[1].xyz - no_b = Vector(op.plane_no) - - no_a = (no_a * self.view_inv).xy.normalized() - no_b = (no_b * self.view_inv).xy.normalized() - return no_a.angle_signed(no_b) - - def direction_set_cb(value): - op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) - matrix_rotate = Matrix.Rotation(-value, 3, self.rotate_axis) - no = matrix_rotate * self.widget_dial.matrix_basis.col[1].xyz - op.plane_no = no - op.execute(context) - - mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d") - mpr.target_set_handler("offset", get=direction_get_cb, set=direction_set_cb) - mpr.draw_options = {'ANGLE_START_Y'} - - mpr.use_draw_value = True - - mpr.color = 0.8, 0.8, 0.8 - mpr.alpha = 0.5 - - mpr.color_highlight = 1.0, 1.0, 1.0 - mpr.alpha_highlight = 1.0 - - self.widget_dial = mpr - - def draw_prepare(self, context): - from mathutils import Vector - - view_inv = self.my_view_orientation(context) - - self.view_inv = view_inv - self.rotate_axis = view_inv[2].xyz - self.rotate_up = view_inv[1].xyz - - op = self.my_target_operator(context) - - co = Vector(op.plane_co) - no = Vector(op.plane_no).normalized() - - # Grab - no_z = no - no_y = no_z.orthogonal() - no_x = no_z.cross(no_y) - - matrix = self.widget_grab.matrix_basis - matrix.identity() - matrix.col[0].xyz = no_x - matrix.col[1].xyz = no_y - matrix.col[2].xyz = no_z - matrix.col[3].xyz = co - - # Dial - no_z = self.rotate_axis - no_y = (no - (no.project(no_z))).normalized() - no_x = self.rotate_axis.cross(no_y) - - matrix = self.widget_dial.matrix_basis - matrix.identity() - matrix.col[0].xyz = no_x - matrix.col[1].xyz = no_y - matrix.col[2].xyz = no_z - matrix.col[3].xyz = co - - -classes = ( - SelectSideOfPlane, - SelectSideOfPlaneManipulatorGroup, -) - - -def register(): - for cls in classes: - bpy.utils.register_class(cls) - - -def unregister(): - for cls in reversed(classes): - bpy.utils.unregister_class(cls) - - -if __name__ == "__main__": - register() diff --git a/release/scripts/templates_py/manipulator_operator_target.py b/release/scripts/templates_py/manipulator_operator_target.py deleted file mode 100644 index ba53b5e10ff..00000000000 --- a/release/scripts/templates_py/manipulator_operator_target.py +++ /dev/null @@ -1,50 +0,0 @@ -# Example of a manipulator that activates an operator -# using the predefined dial manipulator to change the camera roll. -# -# Usage: Run this script and select a camera in the 3D view. -# -import bpy -from bpy.types import ( - ManipulatorGroup, -) - - -class MyCameraWidgetGroup(ManipulatorGroup): - bl_idname = "OBJECT_WGT_test_camera" - bl_label = "Object Camera Test Widget" - bl_space_type = 'VIEW_3D' - bl_region_type = 'WINDOW' - bl_options = {'3D', 'PERSISTENT'} - - @classmethod - def poll(cls, context): - ob = context.object - return (ob and ob.type == 'CAMERA') - - def setup(self, context): - # Run an operator using the dial manipulator - ob = context.object - mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d") - props = mpr.target_set_operator("transform.rotate") - props.constraint_axis = False, False, True - props.constraint_orientation = 'LOCAL' - props.release_confirm = True - - mpr.matrix_basis = ob.matrix_world.normalized() - mpr.line_width = 3 - - mpr.color = 0.8, 0.8, 0.8 - mpr.alpha = 0.5 - - mpr.color_highlight = 1.0, 1.0, 1.0 - mpr.alpha_highlight = 1.0 - - self.roll_widget = mpr - - def refresh(self, context): - ob = context.object - mpr = self.roll_widget - mpr.matrix_basis = ob.matrix_world.normalized() - - -bpy.utils.register_class(MyCameraWidgetGroup) diff --git a/release/scripts/templates_py/manipulator_simple.py b/release/scripts/templates_py/manipulator_simple.py deleted file mode 100644 index cb10a8b94bb..00000000000 --- a/release/scripts/templates_py/manipulator_simple.py +++ /dev/null @@ -1,47 +0,0 @@ -# Example of a group that edits a single property -# using the predefined manipulator arrow. -# -# Usage: Select a light in the 3D view and drag the arrow at it's rear -# to change it's energy value. -# -import bpy -from bpy.types import ( - ManipulatorGroup, -) - - -class MyLightWidgetGroup(ManipulatorGroup): - bl_idname = "OBJECT_WGT_light_test" - bl_label = "Test Light Widget" - bl_space_type = 'VIEW_3D' - bl_region_type = 'WINDOW' - bl_options = {'3D', 'PERSISTENT'} - - @classmethod - def poll(cls, context): - ob = context.object - return (ob and ob.type == 'LIGHT') - - def setup(self, context): - # Arrow manipulator has one 'offset' property we can assign to the light energy. - ob = context.object - mpr = self.manipulators.new("MANIPULATOR_WT_arrow_3d") - mpr.target_set_prop("offset", ob.data, "energy") - mpr.matrix_basis = ob.matrix_world.normalized() - mpr.draw_style = 'BOX' - - mpr.color = 1.0, 0.5, 0.0 - mpr.alpha = 0.5 - - mpr.color_highlight = 1.0, 0.5, 1.0 - mpr.alpha_highlight = 0.5 - - self.energy_widget = mpr - - def refresh(self, context): - ob = context.object - mpr = self.energy_widget - mpr.matrix_basis = ob.matrix_world.normalized() - - -bpy.utils.register_class(MyLightWidgetGroup) diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 2b30382f4a4..cf1db751c85 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -30,7 +30,7 @@ if(WITH_BLENDER) add_subdirectory(interface) add_subdirectory(io) add_subdirectory(lattice) - add_subdirectory(manipulator_library) + add_subdirectory(gizmo_library) add_subdirectory(mask) add_subdirectory(mesh) add_subdirectory(metaball) diff --git a/source/blender/editors/gizmo_library/CMakeLists.txt b/source/blender/editors/gizmo_library/CMakeLists.txt new file mode 100644 index 00000000000..389820240e2 --- /dev/null +++ b/source/blender/editors/gizmo_library/CMakeLists.txt @@ -0,0 +1,60 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + ../include + ../../blenkernel + ../../blenlib + ../../blentranslation + ../../bmesh + ../../depsgraph + ../../gpu + ../../makesdna + ../../makesrna + ../../windowmanager + ../../../../intern/guardedalloc + ../../../../intern/eigen + ../../../../intern/glew-mx +) + +set(INC_SYS + ${GLEW_INCLUDE_PATH} +) + +set(SRC + gizmo_draw_utils.c + gizmo_geometry.h + gizmo_library_intern.h + gizmo_library_presets.c + gizmo_library_utils.c + geometry/geom_arrow_gizmo.c + geometry/geom_cube_gizmo.c + geometry/geom_dial_gizmo.c + gizmo_types/arrow2d_gizmo.c + gizmo_types/arrow3d_gizmo.c + gizmo_types/button2d_gizmo.c + gizmo_types/cage2d_gizmo.c + gizmo_types/cage3d_gizmo.c + gizmo_types/dial3d_gizmo.c + gizmo_types/grab3d_gizmo.c + gizmo_types/primitive3d_gizmo.c +) + +add_definitions(${GL_DEFINITIONS}) + +blender_add_lib(bf_editor_gizmo_library "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c new file mode 100644 index 00000000000..e8804238590 --- /dev/null +++ b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c @@ -0,0 +1,141 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file geom_arrow_gizmo.c + * \ingroup wm + */ + +#include "../gizmo_geometry.h" + +static float verts[][3] = { + {-0.000000, 0.012320, 0.000000}, + {-0.000000, 0.012320, 0.974306}, + {0.008711, 0.008711, 0.000000}, + {0.008711, 0.008711, 0.974306}, + {0.012320, -0.000000, 0.000000}, + {0.012320, -0.000000, 0.974306}, + {0.008711, -0.008711, 0.000000}, + {0.008711, -0.008711, 0.974306}, + {-0.000000, -0.012320, 0.000000}, + {-0.000000, -0.012320, 0.974306}, + {-0.008711, -0.008711, 0.000000}, + {-0.008711, -0.008711, 0.974306}, + {-0.012320, 0.000000, 0.000000}, + {-0.012320, 0.000000, 0.974306}, + {-0.008711, 0.008711, 0.000000}, + {-0.008711, 0.008711, 0.974306}, + {0.000000, 0.072555, 0.974306}, + {0.051304, 0.051304, 0.974306}, + {0.072555, -0.000000, 0.974306}, + {0.051304, -0.051304, 0.974306}, + {-0.000000, -0.072555, 0.974306}, + {-0.051304, -0.051304, 0.974306}, + {-0.072555, 0.000000, 0.974306}, + {-0.051304, 0.051304, 0.974306}, + {0.000000, -0.000000, 1.268098}, +}; + +static float normals[][3] = { + {0.000000, 0.776360, -0.630238}, + {0.000000, 0.594348, -0.804163}, + {0.548967, 0.548967, -0.630238}, + {0.420270, 0.420270, -0.804163}, + {0.776360, 0.000000, -0.630238}, + {0.594378, 0.000000, -0.804163}, + {0.548967, -0.548967, -0.630238}, + {0.420270, -0.420270, -0.804163}, + {0.000000, -0.776360, -0.630238}, + {0.000000, -0.594378, -0.804163}, + {-0.548967, -0.548967, -0.630238}, + {-0.420270, -0.420270, -0.804163}, + {-0.776360, 0.000000, -0.630238}, + {-0.594378, 0.000000, -0.804163}, + {-0.548967, 0.548967, -0.630238}, + {-0.420270, 0.420270, -0.804163}, + {0.000000, 0.843226, -0.537492}, + {0.596271, 0.596271, -0.537492}, + {0.843226, 0.000000, -0.537492}, + {0.596271, -0.596271, -0.537492}, + {0.000000, -0.843226, -0.537492}, + {-0.596271, -0.596271, -0.537492}, + {-0.843226, 0.000000, -0.537492}, + {-0.596271, 0.596271, -0.537492}, + {0.000000, 0.000000, 1.000000}, +}; + +static unsigned short indices[] = { + 1, 3, 2, + 3, 5, 4, + 5, 7, 6, + 7, 9, 8, + 9, 11, 10, + 11, 13, 12, + 5, 18, 19, + 15, 1, 0, + 13, 15, 14, + 6, 10, 14, + 11, 21, 22, + 7, 19, 20, + 13, 22, 23, + 3, 17, 18, + 9, 20, 21, + 15, 23, 16, + 1, 16, 17, + 23, 22, 24, + 21, 20, 24, + 19, 18, 24, + 17, 16, 24, + 16, 23, 24, + 22, 21, 24, + 20, 19, 24, + 18, 17, 24, + 0, 1, 2, + 2, 3, 4, + 4, 5, 6, + 6, 7, 8, + 8, 9, 10, + 10, 11, 12, + 7, 5, 19, + 14, 15, 0, + 12, 13, 14, + 14, 0, 2, + 2, 4, 6, + 6, 8, 10, + 10, 12, 14, + 14, 2, 6, + 13, 11, 22, + 9, 7, 20, + 15, 13, 23, + 5, 3, 18, + 11, 9, 21, + 1, 15, 16, + 3, 1, 17, +}; + +ManipulatorGeomInfo wm_manipulator_geom_data_arrow = { + .nverts = 25, + .ntris = 46, + .verts = verts, + .normals = normals, + .indices = indices, +}; diff --git a/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c new file mode 100644 index 00000000000..f2d03821302 --- /dev/null +++ b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c @@ -0,0 +1,75 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file geom_cube_gizmo.c + * \ingroup wm + */ + +#include "../gizmo_geometry.h" + +static const float verts[][3] = { + {1.000000, 1.000000, -1.000000}, + {1.000000, -1.000000, -1.000000}, + {-1.000000, -1.000000, -1.000000}, + {-1.000000, 1.000000, -1.000000}, + {1.000000, 1.000000, 1.000000}, + {0.999999, -1.000001, 1.000000}, + {-1.000000, -1.000000, 1.000000}, + {-1.000000, 1.000000, 1.000000}, +}; + +static const float normals[][3] = { + {0.577349, 0.577349, -0.577349}, + {0.577349, -0.577349, -0.577349}, + {-0.577349, -0.577349, -0.577349}, + {-0.577349, 0.577349, -0.577349}, + {0.577349, 0.577349, 0.577349}, + {0.577349, -0.577349, 0.577349}, + {-0.577349, -0.577349, 0.577349}, + {-0.577349, 0.577349, 0.577349}, +}; + +static const unsigned short indices[] = { + 1, 2, 3, + 7, 6, 5, + 4, 5, 1, + 5, 6, 2, + 2, 6, 7, + 0, 3, 7, + 0, 1, 3, + 4, 7, 5, + 0, 4, 1, + 1, 5, 2, + 3, 2, 7, + 4, 0, 7, +}; + +ManipulatorGeomInfo wm_manipulator_geom_data_cube = { + .nverts = 8, + .ntris = 12, + .verts = verts, + .normals = normals, + .indices = indices, +}; diff --git a/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c new file mode 100644 index 00000000000..bc3fb6fcaff --- /dev/null +++ b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c @@ -0,0 +1,813 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file geom_dial_gizmo.c + * \ingroup wm + */ + +#include "../gizmo_geometry.h" + +static const float verts[][3] = { + {1.034000, 0.000000, 0.000000}, + {1.017000, 0.000000, 0.029445}, + {0.983000, 0.000000, 0.029445}, + {0.966000, 0.000000, 0.000000}, + {0.983000, 0.000000, -0.029445}, + {1.017000, 0.000000, -0.029445}, + {1.014132, 0.201723, 0.000000}, + {0.997459, 0.198407, 0.029445}, + {0.964112, 0.191774, 0.029445}, + {0.947439, 0.188457, 0.000000}, + {0.964112, 0.191774, -0.029445}, + {0.997459, 0.198407, -0.029445}, + {0.955292, 0.395695, 0.000000}, + {0.939586, 0.389189, 0.029445}, + {0.908174, 0.376178, 0.029445}, + {0.892468, 0.369672, 0.000000}, + {0.908174, 0.376178, -0.029445}, + {0.939586, 0.389189, -0.029445}, + {0.859740, 0.574460, 0.000000}, + {0.845605, 0.565015, 0.029445}, + {0.817335, 0.546126, 0.029445}, + {0.803200, 0.536681, 0.000000}, + {0.817335, 0.546126, -0.029445}, + {0.845605, 0.565015, -0.029445}, + {0.731148, 0.731148, 0.000000}, + {0.719128, 0.719128, 0.029445}, + {0.695086, 0.695086, 0.029445}, + {0.683065, 0.683065, 0.000000}, + {0.695086, 0.695086, -0.029445}, + {0.719128, 0.719128, -0.029445}, + {0.574460, 0.859740, 0.000000}, + {0.565015, 0.845605, 0.029445}, + {0.546125, 0.817335, 0.029445}, + {0.536681, 0.803200, 0.000000}, + {0.546125, 0.817335, -0.029445}, + {0.565015, 0.845605, -0.029445}, + {0.395695, 0.955291, 0.000000}, + {0.389189, 0.939585, 0.029445}, + {0.376178, 0.908173, 0.029445}, + {0.369672, 0.892467, 0.000000}, + {0.376178, 0.908173, -0.029445}, + {0.389189, 0.939585, -0.029445}, + {0.201724, 1.014132, 0.000000}, + {0.198407, 0.997459, 0.029445}, + {0.191774, 0.964112, 0.029445}, + {0.188457, 0.947439, 0.000000}, + {0.191774, 0.964112, -0.029445}, + {0.198407, 0.997459, -0.029445}, + {0.000000, 1.034000, 0.000000}, + {0.000000, 1.017000, 0.029445}, + {0.000000, 0.983000, 0.029445}, + {0.000000, 0.966000, 0.000000}, + {0.000000, 0.983000, -0.029445}, + {0.000000, 1.017000, -0.029445}, + {-0.201723, 1.014132, 0.000000}, + {-0.198407, 0.997459, 0.029445}, + {-0.191774, 0.964112, 0.029445}, + {-0.188457, 0.947439, 0.000000}, + {-0.191774, 0.964112, -0.029445}, + {-0.198407, 0.997459, -0.029445}, + {-0.395695, 0.955291, 0.000000}, + {-0.389189, 0.939585, 0.029445}, + {-0.376178, 0.908174, 0.029445}, + {-0.369672, 0.892468, 0.000000}, + {-0.376178, 0.908174, -0.029445}, + {-0.389189, 0.939585, -0.029445}, + {-0.574459, 0.859740, 0.000000}, + {-0.565015, 0.845605, 0.029445}, + {-0.546125, 0.817335, 0.029445}, + {-0.536681, 0.803200, 0.000000}, + {-0.546125, 0.817335, -0.029445}, + {-0.565015, 0.845605, -0.029445}, + {-0.731149, 0.731148, 0.000000}, + {-0.719128, 0.719127, 0.029445}, + {-0.695086, 0.695086, 0.029445}, + {-0.683065, 0.683065, 0.000000}, + {-0.695086, 0.695086, -0.029445}, + {-0.719128, 0.719127, -0.029445}, + {-0.859740, 0.574460, 0.000000}, + {-0.845604, 0.565015, 0.029445}, + {-0.817335, 0.546126, 0.029445}, + {-0.803200, 0.536681, 0.000000}, + {-0.817335, 0.546126, -0.029445}, + {-0.845604, 0.565015, -0.029445}, + {-0.955291, 0.395695, 0.000000}, + {-0.939585, 0.389189, 0.029445}, + {-0.908173, 0.376178, 0.029445}, + {-0.892468, 0.369672, 0.000000}, + {-0.908173, 0.376178, -0.029445}, + {-0.939585, 0.389189, -0.029445}, + {-1.014132, 0.201723, 0.000000}, + {-0.997459, 0.198407, 0.029445}, + {-0.964112, 0.191774, 0.029445}, + {-0.947439, 0.188457, 0.000000}, + {-0.964112, 0.191774, -0.029445}, + {-0.997459, 0.198407, -0.029445}, + {-1.034000, 0.000000, 0.000000}, + {-1.017000, 0.000000, 0.029445}, + {-0.983000, 0.000000, 0.029445}, + {-0.966000, 0.000000, 0.000000}, + {-0.983000, 0.000000, -0.029445}, + {-1.017000, 0.000000, -0.029445}, + {-1.014132, -0.201723, 0.000000}, + {-0.997459, -0.198407, 0.029445}, + {-0.964112, -0.191774, 0.029445}, + {-0.947439, -0.188457, 0.000000}, + {-0.964112, -0.191774, -0.029445}, + {-0.997459, -0.198407, -0.029445}, + {-0.955292, -0.395694, 0.000000}, + {-0.939586, -0.389189, 0.029445}, + {-0.908174, -0.376177, 0.029445}, + {-0.892468, -0.369672, 0.000000}, + {-0.908174, -0.376177, -0.029445}, + {-0.939586, -0.389189, -0.029445}, + {-0.859740, -0.574460, 0.000000}, + {-0.845604, -0.565015, 0.029445}, + {-0.817335, -0.546126, 0.029445}, + {-0.803200, -0.536681, 0.000000}, + {-0.817335, -0.546126, -0.029445}, + {-0.845604, -0.565015, -0.029445}, + {-0.731149, -0.731148, 0.000000}, + {-0.719128, -0.719127, 0.029445}, + {-0.695086, -0.695086, 0.029445}, + {-0.683065, -0.683065, 0.000000}, + {-0.695086, -0.695086, -0.029445}, + {-0.719128, -0.719127, -0.029445}, + {-0.574460, -0.859739, 0.000000}, + {-0.565015, -0.845604, 0.029445}, + {-0.546126, -0.817334, 0.029445}, + {-0.536681, -0.803199, 0.000000}, + {-0.546126, -0.817334, -0.029445}, + {-0.565015, -0.845604, -0.029445}, + {-0.395695, -0.955291, 0.000000}, + {-0.389189, -0.939585, 0.029445}, + {-0.376178, -0.908174, 0.029445}, + {-0.369672, -0.892468, 0.000000}, + {-0.376178, -0.908174, -0.029445}, + {-0.389189, -0.939585, -0.029445}, + {-0.201724, -1.014132, 0.000000}, + {-0.198407, -0.997459, 0.029445}, + {-0.191774, -0.964112, 0.029445}, + {-0.188458, -0.947438, 0.000000}, + {-0.191774, -0.964112, -0.029445}, + {-0.198407, -0.997459, -0.029445}, + {0.000000, -1.034000, 0.000000}, + {0.000000, -1.017000, 0.029445}, + {0.000000, -0.983000, 0.029445}, + {0.000000, -0.966000, 0.000000}, + {0.000000, -0.983000, -0.029445}, + {0.000000, -1.017000, -0.029445}, + {0.201723, -1.014132, 0.000000}, + {0.198407, -0.997459, 0.029445}, + {0.191773, -0.964112, 0.029445}, + {0.188457, -0.947439, 0.000000}, + {0.191773, -0.964112, -0.029445}, + {0.198407, -0.997459, -0.029445}, + {0.395695, -0.955291, 0.000000}, + {0.389189, -0.939585, 0.029445}, + {0.376178, -0.908173, 0.029445}, + {0.369672, -0.892467, 0.000000}, + {0.376178, -0.908173, -0.029445}, + {0.389189, -0.939585, -0.029445}, + {0.574460, -0.859740, 0.000000}, + {0.565015, -0.845605, 0.029445}, + {0.546125, -0.817335, 0.029445}, + {0.536681, -0.803200, 0.000000}, + {0.546125, -0.817335, -0.029445}, + {0.565015, -0.845605, -0.029445}, + {0.731148, -0.731149, 0.000000}, + {0.719127, -0.719128, 0.029445}, + {0.695086, -0.695086, 0.029445}, + {0.683065, -0.683066, 0.000000}, + {0.695086, -0.695086, -0.029445}, + {0.719127, -0.719128, -0.029445}, + {0.859740, -0.574460, 0.000000}, + {0.845605, -0.565015, 0.029445}, + {0.817335, -0.546126, 0.029445}, + {0.803200, -0.536681, 0.000000}, + {0.817335, -0.546126, -0.029445}, + {0.845605, -0.565015, -0.029445}, + {0.955291, -0.395695, 0.000000}, + {0.939585, -0.389189, 0.029445}, + {0.908173, -0.376178, 0.029445}, + {0.892467, -0.369673, 0.000000}, + {0.908173, -0.376178, -0.029445}, + {0.939585, -0.389189, -0.029445}, + {1.014132, -0.201723, 0.000000}, + {0.997459, -0.198407, 0.029445}, + {0.964112, -0.191774, 0.029445}, + {0.947439, -0.188457, 0.000000}, + {0.964112, -0.191774, -0.029445}, + {0.997459, -0.198407, -0.029445}, +}; + +static const float normals[][3] = { + {1.000000, 0.000000, 0.000000}, + {0.522691, 0.000000, 0.852504}, + {-0.475845, 0.000000, 0.879513}, + {-1.000000, 0.000000, 0.000000}, + {-0.475845, 0.000000, -0.879513}, + {0.522691, 0.000000, -0.852504}, + {0.980773, 0.195074, 0.000000}, + {0.512650, 0.101962, 0.852504}, + {-0.466689, -0.092807, 0.879513}, + {-0.980773, -0.195074, 0.000000}, + {-0.466689, -0.092807, -0.879513}, + {0.512650, 0.101962, -0.852504}, + {0.923856, 0.382672, 0.000000}, + {0.482894, 0.200018, 0.852504}, + {-0.439619, -0.182073, 0.879513}, + {-0.923856, -0.382672, 0.000000}, + {-0.439619, -0.182073, -0.879513}, + {0.482894, 0.200018, -0.852504}, + {0.831446, 0.555559, 0.000000}, + {0.434614, 0.290384, 0.852504}, + {-0.395642, -0.264351, 0.879513}, + {-0.831446, -0.555559, 0.000000}, + {-0.395642, -0.264351, -0.879513}, + {0.434614, 0.290384, -0.852504}, + {0.707083, 0.707083, 0.000000}, + {0.369610, 0.369610, 0.852504}, + {-0.336467, -0.336467, 0.879513}, + {-0.707083, -0.707083, 0.000000}, + {-0.336467, -0.336467, -0.879513}, + {0.369610, 0.369610, -0.852504}, + {0.555559, 0.831446, 0.000000}, + {0.290384, 0.434614, 0.852504}, + {-0.264351, -0.395642, 0.879513}, + {-0.555559, -0.831446, 0.000000}, + {-0.264351, -0.395642, -0.879513}, + {0.290384, 0.434614, -0.852504}, + {0.382672, 0.923856, 0.000000}, + {0.200018, 0.482894, 0.852504}, + {-0.182073, -0.439619, 0.879513}, + {-0.382672, -0.923856, 0.000000}, + {-0.182073, -0.439619, -0.879513}, + {0.200018, 0.482894, -0.852504}, + {0.195074, 0.980773, 0.000000}, + {0.101962, 0.512650, 0.852504}, + {-0.092807, -0.466689, 0.879513}, + {-0.195074, -0.980773, 0.000000}, + {-0.092807, -0.466689, -0.879513}, + {0.101962, 0.512650, -0.852504}, + {0.000000, 1.000000, 0.000000}, + {0.000000, 0.522691, 0.852504}, + {0.000000, -0.475845, 0.879513}, + {0.000000, -1.000000, 0.000000}, + {0.000000, -0.475845, -0.879513}, + {0.000000, 0.522691, -0.852504}, + {-0.195074, 0.980773, 0.000000}, + {-0.101962, 0.512650, 0.852504}, + {0.092807, -0.466689, 0.879513}, + {0.195074, -0.980773, 0.000000}, + {0.092807, -0.466689, -0.879513}, + {-0.101962, 0.512650, -0.852504}, + {-0.382672, 0.923856, 0.000000}, + {-0.200018, 0.482894, 0.852504}, + {0.182073, -0.439619, 0.879513}, + {0.382672, -0.923856, 0.000000}, + {0.182073, -0.439619, -0.879513}, + {-0.200018, 0.482894, -0.852504}, + {-0.555559, 0.831446, 0.000000}, + {-0.290384, 0.434614, 0.852504}, + {0.264351, -0.395642, 0.879513}, + {0.555559, -0.831446, 0.000000}, + {0.264351, -0.395642, -0.879513}, + {-0.290384, 0.434614, -0.852504}, + {-0.707083, 0.707083, 0.000000}, + {-0.369610, 0.369610, 0.852504}, + {0.336467, -0.336467, 0.879513}, + {0.707083, -0.707083, 0.000000}, + {0.336467, -0.336467, -0.879513}, + {-0.369610, 0.369610, -0.852504}, + {-0.831446, 0.555559, 0.000000}, + {-0.434614, 0.290384, 0.852504}, + {0.395642, -0.264351, 0.879513}, + {0.831446, -0.555559, 0.000000}, + {0.395642, -0.264351, -0.879513}, + {-0.434614, 0.290384, -0.852504}, + {-0.923856, 0.382672, 0.000000}, + {-0.482894, 0.200018, 0.852504}, + {0.439619, -0.182073, 0.879513}, + {0.923856, -0.382672, 0.000000}, + {0.439619, -0.182073, -0.879513}, + {-0.482894, 0.200018, -0.852504}, + {-0.980773, 0.195074, 0.000000}, + {-0.512650, 0.101962, 0.852504}, + {0.466689, -0.092807, 0.879513}, + {0.980773, -0.195074, 0.000000}, + {0.466689, -0.092807, -0.879513}, + {-0.512650, 0.101962, -0.852504}, + {-1.000000, 0.000000, 0.000000}, + {-0.522691, 0.000000, 0.852504}, + {0.475845, 0.000000, 0.879513}, + {1.000000, 0.000000, 0.000000}, + {0.475845, 0.000000, -0.879513}, + {-0.522691, 0.000000, -0.852504}, + {-0.980773, -0.195074, 0.000000}, + {-0.512650, -0.101962, 0.852504}, + {0.466689, 0.092807, 0.879513}, + {0.980773, 0.195074, 0.000000}, + {0.466689, 0.092807, -0.879513}, + {-0.512650, -0.101962, -0.852504}, + {-0.923856, -0.382672, 0.000000}, + {-0.482894, -0.200018, 0.852504}, + {0.439619, 0.182073, 0.879513}, + {0.923856, 0.382672, 0.000000}, + {0.439619, 0.182073, -0.879513}, + {-0.482894, -0.200018, -0.852504}, + {-0.831446, -0.555559, 0.000000}, + {-0.434614, -0.290384, 0.852504}, + {0.395642, 0.264351, 0.879513}, + {0.831446, 0.555559, 0.000000}, + {0.395642, 0.264351, -0.879513}, + {-0.434614, -0.290384, -0.852504}, + {-0.707083, -0.707083, 0.000000}, + {-0.369610, -0.369610, 0.852504}, + {0.336467, 0.336467, 0.879513}, + {0.707083, 0.707083, 0.000000}, + {0.336467, 0.336467, -0.879513}, + {-0.369610, -0.369610, -0.852504}, + {-0.555559, -0.831446, 0.000000}, + {-0.290384, -0.434614, 0.852504}, + {0.264351, 0.395642, 0.879513}, + {0.555559, 0.831446, 0.000000}, + {0.264351, 0.395642, -0.879513}, + {-0.290384, -0.434614, -0.852504}, + {-0.382672, -0.923856, 0.000000}, + {-0.200018, -0.482894, 0.852504}, + {0.182073, 0.439619, 0.879513}, + {0.382672, 0.923856, 0.000000}, + {0.182073, 0.439619, -0.879513}, + {-0.200018, -0.482894, -0.852504}, + {-0.195074, -0.980773, 0.000000}, + {-0.101962, -0.512650, 0.852504}, + {0.092807, 0.466689, 0.879513}, + {0.195074, 0.980773, 0.000000}, + {0.092807, 0.466689, -0.879513}, + {-0.101962, -0.512650, -0.852504}, + {0.000000, -1.000000, 0.000000}, + {0.000000, -0.522691, 0.852504}, + {0.000000, 0.475845, 0.879513}, + {0.000000, 1.000000, 0.000000}, + {0.000000, 0.475845, -0.879513}, + {0.000000, -0.522691, -0.852504}, + {0.195074, -0.980773, 0.000000}, + {0.101962, -0.512650, 0.852504}, + {-0.092807, 0.466689, 0.879513}, + {-0.195074, 0.980773, 0.000000}, + {-0.092807, 0.466689, -0.879513}, + {0.101962, -0.512650, -0.852504}, + {0.382672, -0.923856, 0.000000}, + {0.200018, -0.482894, 0.852504}, + {-0.182073, 0.439619, 0.879513}, + {-0.382672, 0.923856, 0.000000}, + {-0.182073, 0.439619, -0.879513}, + {0.200018, -0.482894, -0.852504}, + {0.555559, -0.831446, 0.000000}, + {0.290384, -0.434614, 0.852504}, + {-0.264351, 0.395642, 0.879513}, + {-0.555559, 0.831446, 0.000000}, + {-0.264351, 0.395642, -0.879513}, + {0.290384, -0.434614, -0.852504}, + {0.707083, -0.707083, 0.000000}, + {0.369610, -0.369610, 0.852504}, + {-0.336467, 0.336467, 0.879513}, + {-0.707083, 0.707083, 0.000000}, + {-0.336467, 0.336467, -0.879513}, + {0.369610, -0.369610, -0.852504}, + {0.831446, -0.555559, 0.000000}, + {0.434614, -0.290384, 0.852504}, + {-0.395642, 0.264351, 0.879513}, + {-0.831446, 0.555559, 0.000000}, + {-0.395642, 0.264351, -0.879513}, + {0.434614, -0.290384, -0.852504}, + {0.923856, -0.382672, 0.000000}, + {0.482894, -0.200018, 0.852504}, + {-0.439619, 0.182073, 0.879513}, + {-0.923856, 0.382672, 0.000000}, + {-0.439619, 0.182073, -0.879513}, + {0.482894, -0.200018, -0.852504}, + {0.980773, -0.195074, 0.000000}, + {0.512650, -0.101962, 0.852504}, + {-0.466689, 0.092807, 0.879513}, + {-0.980773, 0.195074, 0.000000}, + {-0.466689, 0.092807, -0.879513}, + {0.512650, -0.101962, -0.852504}, +}; + +static const unsigned short indices[] = { + 6, 7, 1, + 7, 8, 2, + 8, 9, 3, + 9, 10, 4, + 10, 11, 5, + 5, 11, 6, + 12, 13, 7, + 13, 14, 8, + 14, 15, 9, + 15, 16, 10, + 16, 17, 11, + 11, 17, 12, + 18, 19, 13, + 13, 19, 20, + 20, 21, 15, + 15, 21, 22, + 22, 23, 17, + 17, 23, 18, + 24, 25, 19, + 19, 25, 26, + 26, 27, 21, + 21, 27, 28, + 28, 29, 23, + 23, 29, 24, + 30, 31, 25, + 25, 31, 32, + 26, 32, 33, + 27, 33, 34, + 34, 35, 29, + 29, 35, 30, + 36, 37, 31, + 31, 37, 38, + 38, 39, 33, + 39, 40, 34, + 40, 41, 35, + 35, 41, 36, + 36, 42, 43, + 43, 44, 38, + 44, 45, 39, + 45, 46, 40, + 46, 47, 41, + 47, 42, 36, + 48, 49, 43, + 49, 50, 44, + 50, 51, 45, + 51, 52, 46, + 52, 53, 47, + 47, 53, 48, + 54, 55, 49, + 49, 55, 56, + 50, 56, 57, + 57, 58, 52, + 58, 59, 53, + 53, 59, 54, + 60, 61, 55, + 55, 61, 62, + 56, 62, 63, + 63, 64, 58, + 64, 65, 59, + 59, 65, 60, + 66, 67, 61, + 61, 67, 68, + 68, 69, 63, + 69, 70, 64, + 70, 71, 65, + 71, 66, 60, + 72, 73, 67, + 73, 74, 68, + 68, 74, 75, + 75, 76, 70, + 76, 77, 71, + 71, 77, 72, + 78, 79, 73, + 79, 80, 74, + 74, 80, 81, + 81, 82, 76, + 82, 83, 77, + 83, 78, 72, + 78, 84, 85, + 85, 86, 80, + 80, 86, 87, + 87, 88, 82, + 82, 88, 89, + 89, 84, 78, + 90, 91, 85, + 91, 92, 86, + 86, 92, 93, + 93, 94, 88, + 88, 94, 95, + 95, 90, 84, + 96, 97, 91, + 97, 98, 92, + 98, 99, 93, + 99, 100, 94, + 100, 101, 95, + 101, 96, 90, + 102, 103, 97, + 103, 104, 98, + 104, 105, 99, + 99, 105, 106, + 106, 107, 101, + 101, 107, 102, + 108, 109, 103, + 103, 109, 110, + 110, 111, 105, + 105, 111, 112, + 112, 113, 107, + 107, 113, 108, + 114, 115, 109, + 115, 116, 110, + 116, 117, 111, + 111, 117, 118, + 112, 118, 119, + 113, 119, 114, + 114, 120, 121, + 121, 122, 116, + 122, 123, 117, + 117, 123, 124, + 124, 125, 119, + 125, 120, 114, + 126, 127, 121, + 121, 127, 128, + 128, 129, 123, + 123, 129, 130, + 130, 131, 125, + 125, 131, 126, + 132, 133, 127, + 133, 134, 128, + 128, 134, 135, + 135, 136, 130, + 136, 137, 131, + 131, 137, 132, + 132, 138, 139, + 133, 139, 140, + 134, 140, 141, + 141, 142, 136, + 142, 143, 137, + 143, 138, 132, + 138, 144, 145, + 139, 145, 146, + 146, 147, 141, + 141, 147, 148, + 148, 149, 143, + 149, 144, 138, + 144, 150, 151, + 151, 152, 146, + 146, 152, 153, + 153, 154, 148, + 154, 155, 149, + 155, 150, 144, + 156, 157, 151, + 151, 157, 158, + 158, 159, 153, + 159, 160, 154, + 160, 161, 155, + 155, 161, 156, + 156, 162, 163, + 163, 164, 158, + 158, 164, 165, + 165, 166, 160, + 160, 166, 167, + 167, 162, 156, + 162, 168, 169, + 169, 170, 164, + 164, 170, 171, + 165, 171, 172, + 166, 172, 173, + 173, 168, 162, + 174, 175, 169, + 175, 176, 170, + 170, 176, 177, + 177, 178, 172, + 172, 178, 179, + 173, 179, 174, + 174, 180, 181, + 181, 182, 176, + 176, 182, 183, + 183, 184, 178, + 178, 184, 185, + 179, 185, 180, + 186, 187, 181, + 187, 188, 182, + 188, 189, 183, + 183, 189, 190, + 190, 191, 185, + 191, 186, 180, + 0, 1, 187, + 1, 2, 188, + 2, 3, 189, + 3, 4, 190, + 190, 4, 5, + 191, 5, 0, + 0, 6, 1, + 1, 7, 2, + 2, 8, 3, + 3, 9, 4, + 4, 10, 5, + 0, 5, 6, + 6, 12, 7, + 7, 13, 8, + 8, 14, 9, + 9, 15, 10, + 10, 16, 11, + 6, 11, 12, + 12, 18, 13, + 14, 13, 20, + 14, 20, 15, + 16, 15, 22, + 16, 22, 17, + 12, 17, 18, + 18, 24, 19, + 20, 19, 26, + 20, 26, 21, + 22, 21, 28, + 22, 28, 23, + 18, 23, 24, + 24, 30, 25, + 26, 25, 32, + 27, 26, 33, + 28, 27, 34, + 28, 34, 29, + 24, 29, 30, + 30, 36, 31, + 32, 31, 38, + 32, 38, 33, + 33, 39, 34, + 34, 40, 35, + 30, 35, 36, + 37, 36, 43, + 37, 43, 38, + 38, 44, 39, + 39, 45, 40, + 40, 46, 41, + 41, 47, 36, + 42, 48, 43, + 43, 49, 44, + 44, 50, 45, + 45, 51, 46, + 46, 52, 47, + 42, 47, 48, + 48, 54, 49, + 50, 49, 56, + 51, 50, 57, + 51, 57, 52, + 52, 58, 53, + 48, 53, 54, + 54, 60, 55, + 56, 55, 62, + 57, 56, 63, + 57, 63, 58, + 58, 64, 59, + 54, 59, 60, + 60, 66, 61, + 62, 61, 68, + 62, 68, 63, + 63, 69, 64, + 64, 70, 65, + 65, 71, 60, + 66, 72, 67, + 67, 73, 68, + 69, 68, 75, + 69, 75, 70, + 70, 76, 71, + 66, 71, 72, + 72, 78, 73, + 73, 79, 74, + 75, 74, 81, + 75, 81, 76, + 76, 82, 77, + 77, 83, 72, + 79, 78, 85, + 79, 85, 80, + 81, 80, 87, + 81, 87, 82, + 83, 82, 89, + 83, 89, 78, + 84, 90, 85, + 85, 91, 86, + 87, 86, 93, + 87, 93, 88, + 89, 88, 95, + 89, 95, 84, + 90, 96, 91, + 91, 97, 92, + 92, 98, 93, + 93, 99, 94, + 94, 100, 95, + 95, 101, 90, + 96, 102, 97, + 97, 103, 98, + 98, 104, 99, + 100, 99, 106, + 100, 106, 101, + 96, 101, 102, + 102, 108, 103, + 104, 103, 110, + 104, 110, 105, + 106, 105, 112, + 106, 112, 107, + 102, 107, 108, + 108, 114, 109, + 109, 115, 110, + 110, 116, 111, + 112, 111, 118, + 113, 112, 119, + 108, 113, 114, + 115, 114, 121, + 115, 121, 116, + 116, 122, 117, + 118, 117, 124, + 118, 124, 119, + 119, 125, 114, + 120, 126, 121, + 122, 121, 128, + 122, 128, 123, + 124, 123, 130, + 124, 130, 125, + 120, 125, 126, + 126, 132, 127, + 127, 133, 128, + 129, 128, 135, + 129, 135, 130, + 130, 136, 131, + 126, 131, 132, + 133, 132, 139, + 134, 133, 140, + 135, 134, 141, + 135, 141, 136, + 136, 142, 137, + 137, 143, 132, + 139, 138, 145, + 140, 139, 146, + 140, 146, 141, + 142, 141, 148, + 142, 148, 143, + 143, 149, 138, + 145, 144, 151, + 145, 151, 146, + 147, 146, 153, + 147, 153, 148, + 148, 154, 149, + 149, 155, 144, + 150, 156, 151, + 152, 151, 158, + 152, 158, 153, + 153, 159, 154, + 154, 160, 155, + 150, 155, 156, + 157, 156, 163, + 157, 163, 158, + 159, 158, 165, + 159, 165, 160, + 161, 160, 167, + 161, 167, 156, + 163, 162, 169, + 163, 169, 164, + 165, 164, 171, + 166, 165, 172, + 167, 166, 173, + 167, 173, 162, + 168, 174, 169, + 169, 175, 170, + 171, 170, 177, + 171, 177, 172, + 173, 172, 179, + 168, 173, 174, + 175, 174, 181, + 175, 181, 176, + 177, 176, 183, + 177, 183, 178, + 179, 178, 185, + 174, 179, 180, + 180, 186, 181, + 181, 187, 182, + 182, 188, 183, + 184, 183, 190, + 184, 190, 185, + 185, 191, 180, + 186, 0, 187, + 187, 1, 188, + 188, 2, 189, + 189, 3, 190, + 191, 190, 5, + 186, 191, 0, +}; + +ManipulatorGeomInfo wm_manipulator_geom_data_dial = { + .nverts = 192, + .ntris = 384, + .verts = verts, + .normals = normals, + .indices = indices, +}; diff --git a/source/blender/editors/gizmo_library/gizmo_draw_utils.c b/source/blender/editors/gizmo_library/gizmo_draw_utils.c new file mode 100644 index 00000000000..8ae21f61758 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_draw_utils.c @@ -0,0 +1,121 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file gizmo_draw_utils.c + * \ingroup wm + */ + +#include "BLI_listbase.h" +#include "BLI_ghash.h" +#include "BLI_math.h" +#include "BLI_string.h" +#include "BLI_string_utils.h" + +#include "BKE_context.h" + +#include "ED_screen.h" +#include "ED_view3d.h" + +#include "GPU_batch.h" +#include "GPU_glew.h" +#include "GPU_immediate.h" +#include "GPU_state.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +#include "wm.h" + +/* own includes */ +#include "gizmo_library_intern.h" + +/** + * Main draw call for ManipulatorGeomInfo data + */ +void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const bool UNUSED(select), const float color[4]) +{ + /* TODO store the Batches inside the ManipulatorGeomInfo and updated it when geom changes + * So we don't need to re-created and discard it every time */ + + Gwn_VertBuf *vbo; + Gwn_IndexBuf *el; + Gwn_Batch *batch; + Gwn_IndexBufBuilder elb = {0}; + + Gwn_VertFormat format = {0}; + uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + + /* Elements */ + GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, info->ntris, info->nverts); + for (int i = 0; i < info->ntris; ++i) { + const unsigned short *idx = &info->indices[i * 3]; + GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]); + } + el = GWN_indexbuf_build(&elb); + + vbo = GWN_vertbuf_create_with_format(&format); + GWN_vertbuf_data_alloc(vbo, info->nverts); + + GWN_vertbuf_attr_fill(vbo, pos_id, info->verts); + + batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, el, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); + + GWN_batch_uniform_4fv(batch, "color", color); + + /* We may want to re-visit this, for now disable + * since it causes issues leaving the GL state modified. */ +#if 0 + glEnable(GL_CULL_FACE); + GPU_depth_test(true); +#endif + + GWN_batch_draw(batch); + +#if 0 + GPU_depth_test(false); + glDisable(GL_CULL_FACE); +#endif + + + GWN_batch_discard(batch); +} + +void wm_manipulator_vec_draw( + const float color[4], const float (*verts)[3], uint vert_count, + uint pos, uint primitive_type) +{ + immUniformColor4fv(color); + immBegin(primitive_type, vert_count); + for (int i = 0; i < vert_count; i++) { + immVertex3fv(pos, verts[i]); + } + immEnd(); +} diff --git a/source/blender/editors/gizmo_library/gizmo_geometry.h b/source/blender/editors/gizmo_library/gizmo_geometry.h new file mode 100644 index 00000000000..de976bbad48 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_geometry.h @@ -0,0 +1,54 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file gizmo_geometry.h + * \ingroup wm + * + * \name Manipulator Geometry + * + * \brief Prototypes for arrays defining the manipulator geometry. The actual definitions can be found in files usually + * called geom_xxx_manipulator.c + */ + + +#ifndef __GIZMO_GEOMETRY_H__ +#define __GIZMO_GEOMETRY_H__ + +typedef struct ManipulatorGeomInfo { + int nverts; + int ntris; + const float (*verts)[3]; + const float (*normals)[3]; + const unsigned short *indices; +} ManipulatorGeomInfo; + +/* arrow manipulator */ +extern ManipulatorGeomInfo wm_manipulator_geom_data_arrow; + +/* cube manipulator */ +extern ManipulatorGeomInfo wm_manipulator_geom_data_cube; + +/* dial manipulator */ +extern ManipulatorGeomInfo wm_manipulator_geom_data_dial; + +#endif /* __GIZMO_GEOMETRY_H__ */ diff --git a/source/blender/editors/gizmo_library/gizmo_library_intern.h b/source/blender/editors/gizmo_library/gizmo_library_intern.h new file mode 100644 index 00000000000..17121d3752e --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_library_intern.h @@ -0,0 +1,111 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file gizmo_library_intern.h + * \ingroup wm + */ + +#ifndef __GIZMO_LIBRARY_INTERN_H__ +#define __GIZMO_LIBRARY_INTERN_H__ + +/* distance around which manipulators respond to input (and get highlighted) */ +#define MANIPULATOR_HOTSPOT 14.0f + +/** + * Data for common interactions. Used in manipulator_library_utils.c functions. + */ +typedef struct ManipulatorCommonData { + int flag; + + float range_fac; /* factor for arrow min/max distance */ + float offset; + + /* property range for constrained manipulators */ + float range; + /* min/max value for constrained manipulators */ + float min, max; +} ManipulatorCommonData; + +typedef struct ManipulatorInteraction { + float init_value; /* initial property value */ + float init_mval[2]; + float init_offset; + float init_matrix_final[4][4]; + float init_matrix_basis[4][4]; + + /* offset of last handling step */ + float prev_offset; + /* Total offset added by precision tweaking. + * Needed to allow toggling precision on/off without causing jumps */ + float precision_offset; +} ManipulatorInteraction; + +/* ManipulatorCommonData->flag */ +enum { + MANIPULATOR_CUSTOM_RANGE_SET = (1 << 0), +}; + + +float manipulator_offset_from_value( + ManipulatorCommonData *data, const float value, + const bool constrained, const bool inverted); +float manipulator_value_from_offset( + ManipulatorCommonData *data, ManipulatorInteraction *inter, const float offset, + const bool constrained, const bool inverted, const bool use_precision); + +void manipulator_property_data_update( + struct wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, + const bool constrained, const bool inverted); + +void manipulator_property_value_reset( + bContext *C, const struct wmManipulator *mpr, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop); + + +/* -------------------------------------------------------------------- */ + +void manipulator_color_get( + const struct wmManipulator *mpr, const bool highlight, + float r_color[4]); + +bool manipulator_window_project_2d( + bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset, + float r_co[2]); + +bool manipulator_window_project_3d( + bContext *C, const struct wmManipulator *mpr, const float mval[2], bool use_offset, + float r_co[3]); + +/* -------------------------------------------------------------------- */ +/* Manipulator drawing */ + +#include "gizmo_geometry.h" + +void wm_manipulator_geometryinfo_draw(const struct ManipulatorGeomInfo *info, const bool select, const float color[4]); +void wm_manipulator_vec_draw( + const float color[4], const float (*verts)[3], uint vert_count, + uint pos, uint primitive_type); + + +#endif /* __GIZMO_LIBRARY_INTERN_H__ */ diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c new file mode 100644 index 00000000000..d58e0c9dc85 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c @@ -0,0 +1,150 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/gizmo_library/gizmo_library_presets.c + * \ingroup wm + * + * \name Manipulator Lib Presets + * + * \brief Preset shapes that can be drawn from any manipulator type. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "DNA_view3d_types.h" +#include "DNA_object_types.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" + +#include "GPU_draw.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_select.h" + +#include "DEG_depsgraph.h" + +#include "RNA_access.h" + +#include "WM_types.h" +#include "WM_api.h" + +#include "ED_view3d.h" +#include "ED_screen.h" + +/* own includes */ +#include "ED_gizmo_library.h" /* own include */ +#include "gizmo_library_intern.h" /* own include */ + +/* TODO, this is to be used by RNA. might move to ED_manipulator_library */ + +/** + * Given a single axis, orient the matrix to a different direction. + */ +static void single_axis_convert( + int src_axis, float src_mat[4][4], + int dst_axis, float dst_mat[4][4]) +{ + copy_m4_m4(dst_mat, src_mat); + if (src_axis == dst_axis) { + return; + } + + float rotmat[3][3]; + mat3_from_axis_conversion_single(src_axis, dst_axis, rotmat); + transpose_m3(rotmat); + mul_m4_m4m3(dst_mat, src_mat, rotmat); +} + +/** + * Use for all geometry. + */ +static void ed_manipulator_draw_preset_geometry( + const struct wmManipulator *mpr, float mat[4][4], int select_id, + const ManipulatorGeomInfo *info) +{ + const bool is_select = (select_id != -1); + const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + + float color[4]; + manipulator_color_get(mpr, is_highlight, color); + + if (is_select) { + GPU_select_load_id(select_id); + } + + gpuPushMatrix(); + gpuMultMatrix(mat); + wm_manipulator_geometryinfo_draw(info, is_select, color); + gpuPopMatrix(); + + if (is_select) { + GPU_select_load_id(-1); + } +} + +void ED_manipulator_draw_preset_box( + const struct wmManipulator *mpr, float mat[4][4], int select_id) +{ + ed_manipulator_draw_preset_geometry(mpr, mat, select_id, &wm_manipulator_geom_data_cube); +} + +void ED_manipulator_draw_preset_arrow( + const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) +{ + float mat_rotate[4][4]; + single_axis_convert(OB_POSZ, mat, axis, mat_rotate); + ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_manipulator_geom_data_arrow); +} + +void ED_manipulator_draw_preset_circle( + const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) +{ + float mat_rotate[4][4]; + single_axis_convert(OB_POSZ, mat, axis, mat_rotate); + ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_manipulator_geom_data_dial); +} + +void ED_manipulator_draw_preset_facemap( + const bContext *C, const struct wmManipulator *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id) +{ + const bool is_select = (select_id != -1); + const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + + float color[4]; + manipulator_color_get(mpr, is_highlight, color); + + if (is_select) { + GPU_select_load_id(select_id); + } + + gpuPushMatrix(); + gpuMultMatrix(ob->obmat); + ED_draw_object_facemap(CTX_data_depsgraph(C), scene, ob, color, facemap); + gpuPopMatrix(); + + if (is_select) { + GPU_select_load_id(-1); + } +} diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c new file mode 100644 index 00000000000..794728dd03c --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c @@ -0,0 +1,256 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2015 Blender Foundation. + * All rights reserved. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file gizmo_library_utils.c + * \ingroup wm + * + * \name Manipulator Library Utilities + * + * \brief This file contains functions for common behaviors of manipulators. + */ + +#include "BLI_math.h" +#include "BLI_listbase.h" + +#include "DNA_view3d_types.h" +#include "DNA_screen_types.h" + +#include "BKE_context.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_view3d.h" + +/* own includes */ +#include "gizmo_library_intern.h" + +/* factor for precision tweaking */ +#define MANIPULATOR_PRECISION_FAC 0.05f + + +BLI_INLINE float manipulator_offset_from_value_constr( + const float range_fac, const float min, const float range, const float value, + const bool inverted) +{ + return inverted ? (range_fac * (min + range - value) / range) : (range_fac * (value / range)); +} + +BLI_INLINE float manipulator_value_from_offset_constr( + const float range_fac, const float min, const float range, const float value, + const bool inverted) +{ + return inverted ? (min + range - (value * range / range_fac)) : (value * range / range_fac); +} + +float manipulator_offset_from_value( + ManipulatorCommonData *data, const float value, const bool constrained, const bool inverted) +{ + if (constrained) + return manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); + + return value; +} + +float manipulator_value_from_offset( + ManipulatorCommonData *data, ManipulatorInteraction *inter, const float offset, + const bool constrained, const bool inverted, const bool use_precision) +{ + const float max = data->min + data->range; + + if (use_precision) { + /* add delta offset of this step to total precision_offset */ + inter->precision_offset += offset - inter->prev_offset; + } + inter->prev_offset = offset; + + float ofs_new = inter->init_offset + offset - inter->precision_offset * (1.0f - MANIPULATOR_PRECISION_FAC); + float value; + + if (constrained) { + value = manipulator_value_from_offset_constr(data->range_fac, data->min, data->range, ofs_new, inverted); + } + else { + value = ofs_new; + } + + /* clamp to custom range */ + if (data->flag & MANIPULATOR_CUSTOM_RANGE_SET) { + CLAMP(value, data->min, max); + } + + return value; +} + +void manipulator_property_data_update( + wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, + const bool constrained, const bool inverted) +{ + if (mpr_prop->custom_func.value_get_fn != NULL) { + /* pass */ + } + else if (mpr_prop->prop != NULL) { + /* pass */ + } + else { + data->offset = 0.0f; + return; + } + + float value = WM_manipulator_target_property_value_get(mpr, mpr_prop); + + if (constrained) { + if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) { + float range[2]; + if (WM_manipulator_target_property_range_get(mpr, mpr_prop, range)) { + data->range = range[1] - range[0]; + data->min = range[0]; + } + else { + BLI_assert(0); + } + } + data->offset = manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); + } + else { + data->offset = value; + } +} + +void manipulator_property_value_reset( + bContext *C, const wmManipulator *mpr, ManipulatorInteraction *inter, + wmManipulatorProperty *mpr_prop) +{ + WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_value); +} + +/* -------------------------------------------------------------------- */ + +void manipulator_color_get( + const wmManipulator *mpr, const bool highlight, + float r_col[4]) +{ + if (highlight && !(mpr->flag & WM_MANIPULATOR_DRAW_HOVER)) { + copy_v4_v4(r_col, mpr->color_hi); + } + else { + copy_v4_v4(r_col, mpr->color); + } +} + +/* -------------------------------------------------------------------- */ + +/** + * Takes mouse coordinates and returns them in relation to the manipulator. + * Both 2D & 3D supported, use so we can use 2D manipulators in the 3D view. + */ +bool manipulator_window_project_2d( + bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset, + float r_co[2]) +{ + float mat[4][4]; + { + float mat_identity[4][4]; + struct WM_ManipulatorMatrixParams params = {NULL}; + if (use_offset == false) { + unit_m4(mat_identity); + params.matrix_offset = mat_identity; + } + WM_manipulator_calc_matrix_final_params(mpr, ¶ms, mat); + } + + /* rotate mouse in relation to the center and relocate it */ + if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + /* For 3d views, transform 2D mouse pos onto plane. */ + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); + + float plane[4]; + + plane_from_point_normal_v3(plane, mat[3], mat[2]); + + float ray_origin[3], ray_direction[3]; + + if (ED_view3d_win_to_ray(CTX_data_depsgraph(C), ar, v3d, mval, ray_origin, ray_direction, false)) { + float lambda; + if (isect_ray_plane_v3(ray_origin, ray_direction, plane, &lambda, true)) { + float co[3]; + madd_v3_v3v3fl(co, ray_origin, ray_direction, lambda); + float imat[4][4]; + invert_m4_m4(imat, mat); + mul_m4_v3(imat, co); + r_co[0] = co[(axis + 1) % 3]; + r_co[1] = co[(axis + 2) % 3]; + return true; + } + } + return false; + } + else { + float co[3] = {mval[0], mval[1], 0.0f}; + float imat[4][4]; + invert_m4_m4(imat, mat); + mul_mat3_m4_v3(imat, co); + copy_v2_v2(r_co, co); + return true; + } +} + +bool manipulator_window_project_3d( + bContext *C, const struct wmManipulator *mpr, const float mval[2], bool use_offset, + float r_co[3]) +{ + float mat[4][4]; + { + float mat_identity[4][4]; + struct WM_ManipulatorMatrixParams params = {NULL}; + if (use_offset == false) { + unit_m4(mat_identity); + params.matrix_offset = mat_identity; + } + WM_manipulator_calc_matrix_final_params(mpr, ¶ms, mat); + } + + if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); + /* Note: we might want a custom reference point passed in, + * instead of the manipulator center. */ + ED_view3d_win_to_3d(v3d, ar, mat[3], mval, r_co); + invert_m4(mat); + mul_m4_v3(mat, r_co); + return true; + } + else { + float co[3] = {mval[0], mval[1], 0.0f}; + float imat[4][4]; + invert_m4_m4(imat, mat); + mul_m4_v3(imat, co); + copy_v2_v2(r_co, co); + return true; + } +} diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c new file mode 100644 index 00000000000..fbb30b95562 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c @@ -0,0 +1,225 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file arrow2d_gizmo.c + * \ingroup wm + * + * \name 2D Arrow Manipulator + * + * \brief Simple arrow manipulator which is dragged into a certain direction. + */ + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_rect.h" + +#include "DNA_windowmanager_types.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" + +#include "GPU_draw.h" +#include "GPU_immediate.h" +#include "GPU_matrix.h" +#include "GPU_state.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_types.h" + +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +/* own includes */ +#include "WM_api.h" + +#include "../gizmo_library_intern.h" + +static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], const float color[4]) +{ + const float size = 0.11f; + const float size_breadth = size / 2.0f; + const float size_length = size * 1.7f; + /* Subtract the length so the arrow fits in the hotspot. */ + const float arrow_length = RNA_float_get(mpr->ptr, "length") - size_length; + const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); + + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + + gpuPushMatrix(); + gpuMultMatrix(matrix); + gpuRotate2D(RAD2DEGF(arrow_angle)); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + immUniformColor4fv(color); + + immBegin(GWN_PRIM_LINES, 2); + immVertex2f(pos, 0.0f, 0.0f); + immVertex2f(pos, 0.0f, arrow_length); + immEnd(); + + immBegin(GWN_PRIM_TRIS, 3); + immVertex2f(pos, size_breadth, arrow_length); + immVertex2f(pos, -size_breadth, arrow_length); + immVertex2f(pos, 0.0f, arrow_length + size_length); + immEnd(); + + immUnbindProgram(); + + gpuPopMatrix(); +} + +static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *mpr) +{ + float color[4]; + + float matrix_final[4][4]; + + manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, color); + + GPU_line_width(mpr->line_width); + + WM_manipulator_calc_matrix_final(mpr, matrix_final); + + GPU_blend(true); + arrow2d_draw_geom(mpr, matrix_final, color); + GPU_blend(false); + + if (mpr->interaction_data) { + ManipulatorInteraction *inter = mpr->interaction_data; + + GPU_blend(true); + arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); + GPU_blend(false); + } +} + +static void manipulator_arrow2d_setup(wmManipulator *mpr) +{ + mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; +} + +static int manipulator_arrow2d_invoke( + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) +{ + ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); + + copy_m4_m4(inter->init_matrix_basis, mpr->matrix_basis); + WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); + + mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; +} + +static int manipulator_arrow2d_test_select( + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +{ + const float mval[2] = {event->mval[0], event->mval[1]}; + const float arrow_length = RNA_float_get(mpr->ptr, "length"); + const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); + const float line_len = arrow_length * mpr->scale_final; + float mval_local[2]; + + copy_v2_v2(mval_local, mval); + sub_v2_v2(mval_local, mpr->matrix_basis[3]); + + float line[2][2]; + line[0][0] = line[0][1] = line[1][0] = 0.0f; + line[1][1] = line_len; + + /* rotate only if needed */ + if (arrow_angle != 0.0f) { + float rot_point[2]; + copy_v2_v2(rot_point, line[1]); + rotate_v2_v2fl(line[1], rot_point, arrow_angle); + } + + /* arrow line intersection check */ + float isect_1[2], isect_2[2]; + const int isect = isect_line_sphere_v2( + line[0], line[1], mval_local, MANIPULATOR_HOTSPOT + mpr->line_width * 0.5f, + isect_1, isect_2); + + if (isect > 0) { + float line_ext[2][2]; /* extended line for segment check including hotspot */ + copy_v2_v2(line_ext[0], line[0]); + line_ext[1][0] = line[1][0] + MANIPULATOR_HOTSPOT * ((line[1][0] - line[0][0]) / line_len); + line_ext[1][1] = line[1][1] + MANIPULATOR_HOTSPOT * ((line[1][1] - line[0][1]) / line_len); + + const float lambda_1 = line_point_factor_v2(isect_1, line_ext[0], line_ext[1]); + if (isect == 1) { + if (IN_RANGE_INCL(lambda_1, 0.0f, 1.0f)) { + return 0; + } + } + else { + BLI_assert(isect == 2); + const float lambda_2 = line_point_factor_v2(isect_2, line_ext[0], line_ext[1]); + if (IN_RANGE_INCL(lambda_1, 0.0f, 1.0f) && IN_RANGE_INCL(lambda_2, 0.0f, 1.0f)) { + return 0; + } + } + } + + return -1; +} + +/* -------------------------------------------------------------------- */ +/** \name 2D Arrow Manipulator API + * + * \{ */ + +static void MANIPULATOR_WT_arrow_2d(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "MANIPULATOR_WT_arrow_2d"; + + /* api callbacks */ + wt->draw = manipulator_arrow2d_draw; + wt->setup = manipulator_arrow2d_setup; + wt->invoke = manipulator_arrow2d_invoke; + wt->test_select = manipulator_arrow2d_test_select; + + wt->struct_size = sizeof(wmManipulator); + + /* rna */ + RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); + RNA_def_float_rotation( + wt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f), + "Roll", "", DEG2RADF(-360.0f), DEG2RADF(360.0f)); +} + +void ED_manipulatortypes_arrow_2d(void) +{ + WM_manipulatortype_append(MANIPULATOR_WT_arrow_2d); +} + +/** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c new file mode 100644 index 00000000000..72b24e03c00 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -0,0 +1,492 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file arrow3d_gizmo.c + * \ingroup wm + * + * \name Arrow Manipulator + * + * 3D Manipulator + * + * \brief Simple arrow manipulator which is dragged into a certain direction. + * The arrow head can have varying shapes, e.g. cone, box, etc. + * + * - `matrix[0]` is derived from Y and Z. + * - `matrix[1]` is 'up' for manipulator types that have an up. + * - `matrix[2]` is the arrow direction (for all arrowes). + */ + +#include "BIF_gl.h" + +#include "BLI_math.h" + +#include "DNA_view3d_types.h" + +#include "BKE_context.h" + +#include "GPU_draw.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_select.h" +#include "GPU_state.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_types.h" +#include "WM_api.h" + +#include "ED_view3d.h" +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +/* own includes */ +#include "../gizmo_geometry.h" +#include "../gizmo_library_intern.h" + +/* to use custom arrows exported to geom_arrow_manipulator.c */ +//#define USE_MANIPULATOR_CUSTOM_ARROWS + +typedef struct ArrowManipulator3D { + wmManipulator manipulator; + ManipulatorCommonData data; +} ArrowManipulator3D; + + +/* -------------------------------------------------------------------- */ + +static void manipulator_arrow_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4]) +{ + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + + copy_m4_m4(r_matrix, arrow->manipulator.matrix_basis); + madd_v3_v3fl(r_matrix[3], arrow->manipulator.matrix_basis[2], arrow->data.offset); +} + +static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float color[4]) +{ + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + bool unbind_shader = true; + const int draw_style = RNA_enum_get(arrow->manipulator.ptr, "draw_style"); + const int draw_options = RNA_enum_get(arrow->manipulator.ptr, "draw_options"); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + + if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CROSS) { + immUniformColor4fv(color); + + immBegin(GWN_PRIM_LINES, 4); + immVertex3f(pos, -1.0f, 0.0f, 0.0f); + immVertex3f(pos, 1.0f, 0.0f, 0.0f); + immVertex3f(pos, 0.0f, -1.0f, 0.0f); + immVertex3f(pos, 0.0f, 1.0f, 0.0f); + immEnd(); + } + else if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CONE) { + float aspect[2]; + RNA_float_get_array(arrow->manipulator.ptr, "aspect", aspect); + const float unitx = aspect[0]; + const float unity = aspect[1]; + const float vec[4][3] = { + {-unitx, -unity, 0}, + { unitx, -unity, 0}, + { unitx, unity, 0}, + {-unitx, unity, 0}, + }; + + GPU_line_width(arrow->manipulator.line_width); + wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP); + } + else { +#ifdef USE_MANIPULATOR_CUSTOM_ARROWS + wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_arrow, select, color); +#else + const float arrow_length = RNA_float_get(arrow->manipulator.ptr, "length"); + + const float vec[2][3] = { + {0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, arrow_length}, + }; + + if (draw_options & ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM) { + GPU_line_width(arrow->manipulator.line_width); + wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP); + } + else { + immUniformColor4fv(color); + } + + /* *** draw arrow head *** */ + + gpuPushMatrix(); + + if (draw_style == ED_MANIPULATOR_ARROW_STYLE_BOX) { + const float size = 0.05f; + + /* translate to line end with some extra offset so box starts exactly where line ends */ + gpuTranslate3f(0.0f, 0.0f, arrow_length + size); + /* scale down to box size */ + gpuScale3f(size, size, size); + + /* draw cube */ + immUnbindProgram(); + unbind_shader = false; + wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_cube, select, color); + } + else { + BLI_assert(draw_style == ED_MANIPULATOR_ARROW_STYLE_NORMAL); + + const float len = 0.25f; + const float width = 0.06f; + + /* translate to line end */ + gpuTranslate3f(0.0f, 0.0f, arrow_length); + + imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8); + imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1); + } + + gpuPopMatrix(); +#endif /* USE_MANIPULATOR_CUSTOM_ARROWS */ + } + + if (unbind_shader) { + immUnbindProgram(); + } +} + +static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, const bool highlight) +{ + wmManipulator *mpr = &arrow->manipulator; + float color[4]; + float matrix_final[4][4]; + + manipulator_color_get(mpr, highlight, color); + + WM_manipulator_calc_matrix_final(mpr, matrix_final); + + gpuPushMatrix(); + gpuMultMatrix(matrix_final); + GPU_blend(true); + arrow_draw_geom(arrow, select, color); + GPU_blend(false); + + gpuPopMatrix(); + + if (mpr->interaction_data) { + ManipulatorInteraction *inter = mpr->interaction_data; + + gpuPushMatrix(); + gpuMultMatrix(inter->init_matrix_final); + + + GPU_blend(true); + arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); + GPU_blend(false); + + gpuPopMatrix(); + } +} + +static void manipulator_arrow_draw_select( + const bContext *UNUSED(C), wmManipulator *mpr, + int select_id) +{ + GPU_select_load_id(select_id); + arrow_draw_intern((ArrowManipulator3D *)mpr, true, false); +} + +static void manipulator_arrow_draw(const bContext *UNUSED(C), wmManipulator *mpr) +{ + arrow_draw_intern((ArrowManipulator3D *)mpr, false, (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0); +} + +/** + * Calculate arrow offset independent from prop min value, + * meaning the range will not be offset by min value first. + */ +static int manipulator_arrow_modal( + bContext *C, wmManipulator *mpr, const wmEvent *event, + eWM_ManipulatorTweak tweak_flag) +{ + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + ManipulatorInteraction *inter = mpr->interaction_data; + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + + float offset[3]; + float facdir = 1.0f; + + /* (src, dst) */ + struct { + float mval[2]; + float ray_origin[3], ray_direction[3]; + float location[3]; + } proj[2] = { + {.mval = {UNPACK2(inter->init_mval)}}, + {.mval = {UNPACK2(event->mval)}}, + }; + + float arrow_co[3]; + float arrow_no[3]; + copy_v3_v3(arrow_co, inter->init_matrix_basis[3]); + normalize_v3_v3(arrow_no, arrow->manipulator.matrix_basis[2]); + + int ok = 0; + + for (int j = 0; j < 2; j++) { + if (ED_view3d_win_to_ray( + CTX_data_depsgraph(C), + ar, v3d, proj[j].mval, + proj[j].ray_origin, proj[j].ray_direction, false)) + { + /* Force Y axis if we're view aligned */ + if (j == 0) { + if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->manipulator.matrix_basis[2]))) < 5.0f) { + normalize_v3_v3(arrow_no, rv3d->viewinv[1]); + } + } + + float arrow_no_proj[3]; + project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction); + + normalize_v3(arrow_no_proj); + + float plane[4]; + plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj); + + float lambda; + if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) { + madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda); + ok++; + } + } + } + + if (ok != 2) { + return OPERATOR_RUNNING_MODAL; + } + + sub_v3_v3v3(offset, proj[1].location, proj[0].location); + facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1; + + ManipulatorCommonData *data = &arrow->data; + const float ofs_new = facdir * len_v3(offset); + + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + + /* set the property for the operator and call its modal function */ + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + const int transform_flag = RNA_enum_get(arrow->manipulator.ptr, "transform"); + const bool constrained = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED) != 0; + const bool inverted = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED) != 0; + const bool use_precision = (tweak_flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0; + float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); + + WM_manipulator_target_property_value_set(C, mpr, mpr_prop, value); + /* get clamped value */ + value = WM_manipulator_target_property_value_get(mpr, mpr_prop); + + data->offset = manipulator_offset_from_value(data, value, constrained, inverted); + } + else { + data->offset = ofs_new; + } + + /* tag the region for redraw */ + ED_region_tag_redraw(ar); + WM_event_add_mousemove(C); + + return OPERATOR_RUNNING_MODAL; +} + +static void manipulator_arrow_setup(wmManipulator *mpr) +{ + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + + arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_MODAL; + + arrow->data.range_fac = 1.0f; +} + +static int manipulator_arrow_invoke( + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +{ + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + + /* Some manipulators don't use properties. */ + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + inter->init_value = WM_manipulator_target_property_value_get(mpr, mpr_prop); + } + + inter->init_offset = arrow->data.offset; + + inter->init_mval[0] = event->mval[0]; + inter->init_mval[1] = event->mval[1]; + + manipulator_arrow_matrix_basis_get(mpr, inter->init_matrix_basis); + WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); + + mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; +} + +static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +{ + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + const int transform_flag = RNA_enum_get(arrow->manipulator.ptr, "transform"); + const bool constrained = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED) != 0; + const bool inverted = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED) != 0; + manipulator_property_data_update(mpr, &arrow->data, mpr_prop, constrained, inverted); +} + +static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool cancel) +{ + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + ManipulatorCommonData *data = &arrow->data; + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + const bool is_prop_valid = WM_manipulator_target_property_is_valid(mpr_prop); + + if (!cancel) { + /* Assign incase applying the opetration needs an updated offset + * editmesh bisect needs this. */ + if (is_prop_valid) { + data->offset = WM_manipulator_target_property_value_get(mpr, mpr_prop); + } + return; + } + + ManipulatorInteraction *inter = mpr->interaction_data; + if (is_prop_valid) { + manipulator_property_value_reset(C, mpr, inter, mpr_prop); + } + data->offset = inter->init_offset; +} + + +/* -------------------------------------------------------------------- */ +/** \name Arrow Manipulator API + * + * \{ */ + +/** + * Define a custom property UI range + * + * \note Needs to be called before WM_manipulator_target_property_def_rna! + */ +void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, const float max) +{ + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + + BLI_assert(min < max); + BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr, "offset")) && + "Make sure this function is called before WM_manipulator_target_property_def_rna")); + + arrow->data.range = max - min; + arrow->data.min = min; + arrow->data.flag |= MANIPULATOR_CUSTOM_RANGE_SET; +} + +/** + * Define a custom factor for arrow min/max distance + * + * \note Needs to be called before WM_manipulator_target_property_def_rna! + */ +void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac) +{ + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr, "offset")) && + "Make sure this function is called before WM_manipulator_target_property_def_rna")); + + arrow->data.range_fac = range_fac; +} + +static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "MANIPULATOR_WT_arrow_3d"; + + /* api callbacks */ + wt->draw = manipulator_arrow_draw; + wt->draw_select = manipulator_arrow_draw_select; + wt->matrix_basis_get = manipulator_arrow_matrix_basis_get; + wt->modal = manipulator_arrow_modal; + wt->setup = manipulator_arrow_setup; + wt->invoke = manipulator_arrow_invoke; + wt->property_update = manipulator_arrow_property_update; + wt->exit = manipulator_arrow_exit; + + wt->struct_size = sizeof(ArrowManipulator3D); + + /* rna */ + static EnumPropertyItem rna_enum_draw_style_items[] = { + {ED_MANIPULATOR_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""}, + {ED_MANIPULATOR_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""}, + {ED_MANIPULATOR_ARROW_STYLE_BOX, "BOX", 0, "Box", ""}, + {ED_MANIPULATOR_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_draw_options_items[] = { + {ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_transform_items[] = { + {ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""}, + {ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""}, + {0, NULL, 0, NULL, NULL} + }; + + RNA_def_enum( + wt->srna, "draw_style", rna_enum_draw_style_items, + ED_MANIPULATOR_ARROW_STYLE_NORMAL, + "Draw Style", ""); + RNA_def_enum_flag( + wt->srna, "draw_options", rna_enum_draw_options_items, + ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM, + "Draw Options", ""); + RNA_def_enum_flag( + wt->srna, "transform", rna_enum_transform_items, + 0, + "Transform", ""); + + RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); + RNA_def_float_vector(wt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX); + + WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1); +} + +void ED_manipulatortypes_arrow_3d(void) +{ + WM_manipulatortype_append(MANIPULATOR_WT_arrow_3d); +} + +/** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c new file mode 100644 index 00000000000..78f374064e6 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -0,0 +1,322 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file button2d_gizmo.c + * \ingroup wm + * + * \name Button Manipulator + * + * 2D Manipulator, also works in 3D views. + * + * \brief Single click button action for use in manipulator groups. + * + * \note Currently only basic icon & vector-shape buttons are supported. + * + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_select.h" +#include "GPU_batch.h" +#include "GPU_state.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" +#include "ED_view3d.h" +#include "ED_gizmo_library.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" + +/* own includes */ +#include "../gizmo_geometry.h" +#include "../gizmo_library_intern.h" + +typedef struct ButtonManipulator2D { + wmManipulator manipulator; + bool is_init; + /* Use an icon or shape */ + int icon; + Gwn_Batch *shape_batch[2]; +} ButtonManipulator2D; + +#define CIRCLE_RESOLUTION 32 + +/* -------------------------------------------------------------------- */ + +static void button2d_geom_draw_backdrop( + const wmManipulator *mpr, const float color[4], const bool select) +{ + GPU_line_width(mpr->line_width); + + Gwn_VertFormat *format = immVertexFormat(); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + + immUniformColor4fv(color); + + /* TODO, other draw styles */ + imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, CIRCLE_RESOLUTION); + + immUnbindProgram(); + + UNUSED_VARS(select); +} + +static void button2d_draw_intern( + const bContext *C, wmManipulator *mpr, + const bool select, const bool highlight) +{ + ButtonManipulator2D *button = (ButtonManipulator2D *)mpr; + + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + if (button->is_init == false) { + button->is_init = true; + PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "icon"); + if (RNA_property_is_set(mpr->ptr, prop)) { + button->icon = RNA_property_enum_get(mpr->ptr, prop); + } + else { + prop = RNA_struct_find_property(mpr->ptr, "shape"); + const uint polys_len = RNA_property_string_length(mpr->ptr, prop); + /* We shouldn't need the +1, but a NULL char is set. */ + char *polys = MEM_mallocN(polys_len + 1, __func__); + RNA_property_string_get(mpr->ptr, prop, polys); + button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded((uchar *)polys, polys_len, NULL); + button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded((uchar *)polys, polys_len, NULL); + MEM_freeN(polys); + } + } + + float color[4]; + float matrix_final[4][4]; + + manipulator_color_get(mpr, highlight, color); + WM_manipulator_calc_matrix_final(mpr, matrix_final); + + + bool is_3d = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) != 0; + + + if (draw_options & ED_MANIPULATOR_BUTTON_SHOW_HELPLINE) { + float matrix_final_no_offset[4][4]; + WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformColor4fv(color); + GPU_line_width(mpr->line_width); + immUniformColor4fv(color); + immBegin(GWN_PRIM_LINE_STRIP, 2); + immVertex3fv(pos, matrix_final[3]); + immVertex3fv(pos, matrix_final_no_offset[3]); + immEnd(); + immUnbindProgram(); + } + + bool need_to_pop = true; + gpuPushMatrix(); + gpuMultMatrix(matrix_final); + + if (is_3d) { + RegionView3D *rv3d = CTX_wm_region_view3d(C); + float matrix_align[4][4]; + float matrix_final_unit[4][4]; + normalize_m4_m4(matrix_final_unit, matrix_final); + mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); + zero_v3(matrix_align[3]); + transpose_m4(matrix_align); + gpuMultMatrix(matrix_align); + } + + if (select) { + BLI_assert(is_3d); + button2d_geom_draw_backdrop(mpr, color, select); + } + else { + + GPU_blend(true); + if (button->shape_batch[0] != NULL) { + GPU_line_smooth(true); + GPU_polygon_smooth(false); + GPU_line_width(1.0f); + for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) { + /* Invert line color for wire. */ + GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR); + GWN_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color)); + GWN_batch_draw(button->shape_batch[i]); + + if (draw_options & ED_MANIPULATOR_BUTTON_SHOW_OUTLINE) { + color[0] = 1.0f - color[0]; + color[1] = 1.0f - color[1]; + color[2] = 1.0f - color[2]; + } + } + GPU_line_smooth(false); + GPU_polygon_smooth(true); + } + else if (button->icon != ICON_NONE) { + button2d_geom_draw_backdrop(mpr, color, select); + float size[2]; + if (is_3d) { + const float fac = 2.0f; + gpuTranslate2f(-(fac / 2), -(fac / 2)); + gpuScale2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC)); + size[0] = 1.0f; + size[1] = 1.0f; + } + else { + size[0] = mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; + size[1] = mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; + gpuPopMatrix(); + need_to_pop = false; + } + UI_icon_draw(size[0], size[1], button->icon); + } + GPU_blend(false); + } + + if (need_to_pop) { + gpuPopMatrix(); + } +} + +static void manipulator_button2d_draw_select(const bContext *C, wmManipulator *mpr, int select_id) +{ + GPU_select_load_id(select_id); + button2d_draw_intern(C, mpr, true, false); +} + +static void manipulator_button2d_draw(const bContext *C, wmManipulator *mpr) +{ + const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + + GPU_blend(true); + button2d_draw_intern(C, mpr, false, is_highlight); + GPU_blend(false); +} + +static int manipulator_button2d_test_select( + bContext *C, wmManipulator *mpr, const wmEvent *event) +{ + float point_local[2]; + + if (0) { + /* correct, but unnecessarily slow. */ + if (manipulator_window_project_2d( + C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + { + return -1; + } + } + else { + copy_v2_v2(point_local, (float[2]){UNPACK2(event->mval)}); + sub_v2_v2(point_local, mpr->matrix_basis[3]); + mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC)); + } + /* The 'mpr->scale_final' is already applied when projecting. */ + if (len_squared_v2(point_local) < 1.0f) { + return 0; + } + + return -1; +} + +static int manipulator_button2d_cursor_get(wmManipulator *mpr) +{ + if (RNA_boolean_get(mpr->ptr, "show_drag")) { + return BC_NSEW_SCROLLCURSOR; + } + return CURSOR_STD; +} + +static void manipulator_button2d_free(wmManipulator *mpr) +{ + ButtonManipulator2D *shape = (ButtonManipulator2D *)mpr; + + for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) { + GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]); + } +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Button Manipulator API + * + * \{ */ + +static void MANIPULATOR_WT_button_2d(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "MANIPULATOR_WT_button_2d"; + + /* api callbacks */ + wt->draw = manipulator_button2d_draw; + wt->draw_select = manipulator_button2d_draw_select; + wt->test_select = manipulator_button2d_test_select; + wt->cursor_get = manipulator_button2d_cursor_get; + wt->free = manipulator_button2d_free; + + wt->struct_size = sizeof(ButtonManipulator2D); + + /* rna */ + static EnumPropertyItem rna_enum_draw_options[] = { + {ED_MANIPULATOR_BUTTON_SHOW_OUTLINE, "OUTLINE", 0, "Outline", ""}, + {ED_MANIPULATOR_BUTTON_SHOW_HELPLINE, "HELPLINE", 0, "Help Line", ""}, + {0, NULL, 0, NULL, NULL} + }; + PropertyRNA *prop; + + RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + + prop = RNA_def_property(wt->srna, "icon", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_icon_items); + + /* Passed to 'GPU_batch_tris_from_poly_2d_encoded' */ + RNA_def_property(wt->srna, "shape", PROP_STRING, PROP_BYTESTRING); + + /* Currently only used for cursor display. */ + RNA_def_boolean(wt->srna, "show_drag", true, "Show Drag", ""); +} + +void ED_manipulatortypes_button_2d(void) +{ + WM_manipulatortype_append(MANIPULATOR_WT_button_2d); +} + +/** \} */ // Button Manipulator API diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c new file mode 100644 index 00000000000..382733d298f --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -0,0 +1,1100 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file cage2d_gizmo.c + * \ingroup wm + * + * \name Cage Manipulator + * + * 2D Manipulator + * + * \brief Rectangular manipulator acting as a 'cage' around its content. + * Interacting scales or translates the manipulator. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" +#include "BLI_dial_2d.h" +#include "BLI_rect.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" + +#include "GPU_matrix.h" +#include "GPU_shader.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_select.h" +#include "GPU_state.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" +#include "ED_view3d.h" +#include "ED_gizmo_library.h" + +/* own includes */ +#include "../gizmo_library_intern.h" + +#define MANIPULATOR_RESIZER_SIZE 10.0f +#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f + +static void manipulator_calc_rect_view_scale( + const wmManipulator *mpr, const float dims[2], float scale[2]) +{ + float matrix_final_no_offset[4][4]; + float asp[2] = {1.0f, 1.0f}; + if (dims[0] > dims[1]) { + asp[0] = dims[1] / dims[0]; + } + else { + asp[1] = dims[0] / dims[1]; + } + float x_axis[3], y_axis[3]; + WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); + mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); + mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); + + mul_v2_v2(x_axis, asp); + mul_v2_v2(y_axis, asp); + + scale[0] = 1.0f / len_v3(x_axis); + scale[1] = 1.0f / len_v3(y_axis); +} + +static void manipulator_calc_rect_view_margin( + const wmManipulator *mpr, const float dims[2], float margin[2]) +{ + float handle_size; + if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + handle_size = 0.15f; + } + else { + handle_size = MANIPULATOR_RESIZER_SIZE; + } + handle_size *= mpr->scale_final; + float scale_xy[2]; + manipulator_calc_rect_view_scale(mpr, dims, scale_xy); + margin[0] = ((handle_size * scale_xy[0])); + margin[1] = ((handle_size * scale_xy[1])); +} + +/* -------------------------------------------------------------------- */ + +static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_constrain_axis[2]) +{ + bool x = true, y = true; + switch (part) { + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.0); x = false; break; } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.0); x = false; break; } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, 0.5); y = false; break; } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, -0.5); y = false; break; } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.5); x = y = false; break; } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, -0.5); x = y = false; break; } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.5); x = y = false; break; } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, -0.5); x = y = false; break; } + default: BLI_assert(0); + } + r_constrain_axis[0] = x; + r_constrain_axis[1] = y; +} + +/* -------------------------------------------------------------------- */ +/** \name Box Draw Style + * + * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX + * \{ */ + +static void cage2d_draw_box_corners( + const rctf *r, const float margin[2], const float color[3]) +{ + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor3fv(color); + + immBegin(GWN_PRIM_LINES, 16); + + immVertex2f(pos, r->xmin, r->ymin + margin[1]); + immVertex2f(pos, r->xmin, r->ymin); + immVertex2f(pos, r->xmin, r->ymin); + immVertex2f(pos, r->xmin + margin[0], r->ymin); + + immVertex2f(pos, r->xmax, r->ymin + margin[1]); + immVertex2f(pos, r->xmax, r->ymin); + immVertex2f(pos, r->xmax, r->ymin); + immVertex2f(pos, r->xmax - margin[0], r->ymin); + + immVertex2f(pos, r->xmax, r->ymax - margin[1]); + immVertex2f(pos, r->xmax, r->ymax); + immVertex2f(pos, r->xmax, r->ymax); + immVertex2f(pos, r->xmax - margin[0], r->ymax); + + immVertex2f(pos, r->xmin, r->ymax - margin[1]); + immVertex2f(pos, r->xmin, r->ymax); + immVertex2f(pos, r->xmin, r->ymax); + immVertex2f(pos, r->xmin + margin[0], r->ymax); + + immEnd(); + + immUnbindProgram(); +} + +static void cage2d_draw_box_interaction( + const float color[4], const int highlighted, + const float size[2], const float margin[2], + const float line_width, const bool is_solid, const int draw_options) +{ + /* 4 verts for translate, otherwise only 3 are used. */ + float verts[4][2]; + uint verts_len = 0; + Gwn_PrimType prim_type = GWN_PRIM_NONE; + + switch (highlighted) { + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: + { + rctf r = { + .xmin = -size[0], .xmax = -size[0] + margin[0], + .ymin = -size[1] + margin[1], .ymax = size[1] - margin[1], + }; + ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin); + ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymax); + verts_len = 2; + if (is_solid) { + ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); + ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin); + verts_len += 2; + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: + { + rctf r = { + .xmin = size[0] - margin[0], .xmax = size[0], + .ymin = -size[1] + margin[1], .ymax = size[1] - margin[1], + }; + ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymin); + ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax); + verts_len = 2; + if (is_solid) { + ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax); + ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); + verts_len += 2; + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: + { + rctf r = { + .xmin = -size[0] + margin[0], .xmax = size[0] - margin[0], + .ymin = -size[1], .ymax = -size[1] + margin[1], + }; + ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin); + ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymin); + verts_len = 2; + if (is_solid) { + ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); + ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax); + verts_len += 2; + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: + { + rctf r = { + .xmin = -size[0] + margin[0], .xmax = size[0] - margin[0], + .ymin = size[1] - margin[1], .ymax = size[1], + }; + ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymax); + ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax); + verts_len = 2; + if (is_solid) { + ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin); + ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); + verts_len += 2; + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: + { + rctf r = { + .xmin = -size[0], .xmax = -size[0] + margin[0], + .ymin = -size[1], .ymax = -size[1] + margin[1], + }; + ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymin); + ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax); + ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax); + verts_len = 3; + if (is_solid) { + ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); + verts_len += 1; + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: + { + rctf r = { + .xmin = -size[0], .xmax = -size[0] + margin[0], + .ymin = size[1] - margin[1], .ymax = size[1], + }; + ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymax); + ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymin); + ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymin); + verts_len = 3; + if (is_solid) { + ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax); + verts_len += 1; + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: + { + rctf r = { + .xmin = size[0] - margin[0], .xmax = size[0], + .ymin = -size[1], .ymax = -size[1] + margin[1], + }; + ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin); + ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymax); + ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); + verts_len = 3; + if (is_solid) { + ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin); + verts_len += 1; + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: + { + rctf r = { + .xmin = size[0] - margin[0], .xmax = size[0], + .ymin = size[1] - margin[1], .ymax = size[1], + }; + ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymax); + ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymin); + ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin); + verts_len = 3; + if (is_solid) { + ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymax); + verts_len += 1; + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + case ED_MANIPULATOR_CAGE2D_PART_ROTATE: + { + const float rotate_pt[2] = {0.0f, size[1] + margin[1]}; + const rctf r_rotate = { + .xmin = rotate_pt[0] - margin[0] / 2.0f, + .xmax = rotate_pt[0] + margin[0] / 2.0f, + .ymin = rotate_pt[1] - margin[1] / 2.0f, + .ymax = rotate_pt[1] + margin[1] / 2.0f, + }; + + ARRAY_SET_ITEMS(verts[0], r_rotate.xmin, r_rotate.ymin); + ARRAY_SET_ITEMS(verts[1], r_rotate.xmin, r_rotate.ymax); + ARRAY_SET_ITEMS(verts[2], r_rotate.xmax, r_rotate.ymax); + ARRAY_SET_ITEMS(verts[3], r_rotate.xmax, r_rotate.ymin); + verts_len = 4; + if (is_solid) { + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINE_STRIP; + } + break; + } + + case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE: + if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + ARRAY_SET_ITEMS(verts[0], -margin[0] / 2, -margin[1] / 2); + ARRAY_SET_ITEMS(verts[1], margin[0] / 2, margin[1] / 2); + ARRAY_SET_ITEMS(verts[2], -margin[0] / 2, margin[1] / 2); + ARRAY_SET_ITEMS(verts[3], margin[0] / 2, -margin[1] / 2); + verts_len = 4; + if (is_solid) { + prim_type = GWN_PRIM_TRI_FAN; + } + else { + prim_type = GWN_PRIM_LINES; + } + } + else { + /* Only used for 3D view selection, never displayed to the user. */ + ARRAY_SET_ITEMS(verts[0], -size[0], -size[1]); + ARRAY_SET_ITEMS(verts[1], -size[0], size[1]); + ARRAY_SET_ITEMS(verts[2], size[0], size[1]); + ARRAY_SET_ITEMS(verts[3], size[0], -size[1]); + verts_len = 4; + if (is_solid) { + prim_type = GWN_PRIM_TRI_FAN; + } + else { + /* unreachable */ + BLI_assert(0); + prim_type = GWN_PRIM_LINE_STRIP; + } + } + break; + default: + return; + } + + BLI_assert(prim_type != GWN_PRIM_NONE); + + Gwn_VertFormat *format = immVertexFormat(); + struct { + uint pos, col; + } attr_id = { + .pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT), + .col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT), + }; + immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + + { + if (is_solid) { + BLI_assert(ELEM(prim_type, GWN_PRIM_TRI_FAN)); + immBegin(prim_type, verts_len); + immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f); + for (uint i = 0; i < verts_len; i++) { + immVertex2fv(attr_id.pos, verts[i]); + } + immEnd(); + } + else { + BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES)); + GPU_line_width(line_width + 3.0f); + + immBegin(prim_type, verts_len); + immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f); + for (uint i = 0; i < verts_len; i++) { + immVertex2fv(attr_id.pos, verts[i]); + } + immEnd(); + + GPU_line_width(line_width); + + immBegin(prim_type, verts_len); + immAttrib3fv(attr_id.col, color); + for (uint i = 0; i < verts_len; i++) { + immVertex2fv(attr_id.pos, verts[i]); + } + immEnd(); + } + } + + immUnbindProgram(); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Circle Draw Style + * + * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE + * \{ */ + +static void imm_draw_point_aspect_2d( + uint pos, float x, float y, float rad_x, float rad_y, bool solid) +{ + immBegin(solid ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4); + immVertex2f(pos, x - rad_x, y - rad_y); + immVertex2f(pos, x - rad_x, y + rad_y); + immVertex2f(pos, x + rad_x, y + rad_y); + immVertex2f(pos, x + rad_x, y - rad_y); + immEnd(); +} + +static void cage2d_draw_circle_wire( + const rctf *r, const float margin[2], const float color[3], + const int transform_flag, const int draw_options) +{ + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor3fv(color); + + immBegin(GWN_PRIM_LINE_LOOP, 4); + immVertex2f(pos, r->xmin, r->ymin); + immVertex2f(pos, r->xmax, r->ymin); + immVertex2f(pos, r->xmax, r->ymax); + immVertex2f(pos, r->xmin, r->ymax); + immEnd(); + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + immBegin(GWN_PRIM_LINE_LOOP, 2); + immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax); + immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax + margin[1]); + immEnd(); + } + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { + if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + const float rad[2] = {margin[0] / 2, margin[1] / 2}; + const float center[2] = {BLI_rctf_cent_x(r), BLI_rctf_cent_y(r)}; + + immBegin(GWN_PRIM_LINES, 4); + immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]); + immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]); + immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]); + immVertex2f(pos, center[0] - rad[0], center[1] + rad[1]); + immEnd(); + } + } + + immUnbindProgram(); +} + +static void cage2d_draw_circle_handles( + const rctf *r, const float margin[2], const float color[3], + const int transform_flag, + bool solid) +{ + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + void (*circle_fn)(uint, float, float, float, float, int) = + (solid) ? imm_draw_circle_fill_aspect_2d : imm_draw_circle_wire_aspect_2d; + const int resolu = 12; + const float rad[2] = {margin[0] / 3, margin[1] / 3}; + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor3fv(color); + + /* should really divide by two, but looks too bulky. */ + { + imm_draw_point_aspect_2d(pos, r->xmin, r->ymin, rad[0], rad[1], solid); + imm_draw_point_aspect_2d(pos, r->xmax, r->ymin, rad[0], rad[1], solid); + imm_draw_point_aspect_2d(pos, r->xmax, r->ymax, rad[0], rad[1], solid); + imm_draw_point_aspect_2d(pos, r->xmin, r->ymax, rad[0], rad[1], solid); + } + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + const float handle[2] = {BLI_rctf_cent_x(r), r->ymax + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)}; + circle_fn(pos, handle[0], handle[1], rad[0], rad[1], resolu); + } + + immUnbindProgram(); +} + +/** \} */ + +static void manipulator_cage2d_draw_intern( + wmManipulator *mpr, const bool select, const bool highlight, const int select_id) +{ + // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; + float dims[2]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + float matrix_final[4][4]; + + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + + const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; + + WM_manipulator_calc_matrix_final(mpr, matrix_final); + + gpuPushMatrix(); + gpuMultMatrix(matrix_final); + + float margin[2]; + manipulator_calc_rect_view_margin(mpr, dims, margin); + + /* Handy for quick testing draw (if it's outside bounds). */ + if (false) { + GPU_blend(true); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); + float s = 0.5f; + immRectf(pos, -s, -s, s, s); + immUnbindProgram(); + GPU_blend(false); + } + + if (select) { + /* expand for hotspot */ + const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) { + int scale_parts[] = { + ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, + + ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, + }; + for (int i = 0; i < ARRAY_SIZE(scale_parts); i++) { + GPU_select_load_id(select_id | scale_parts[i]); + cage2d_draw_box_interaction( + mpr->color, scale_parts[i], size, margin, mpr->line_width, true, draw_options); + } + } + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { + const int transform_part = ED_MANIPULATOR_CAGE2D_PART_TRANSLATE; + GPU_select_load_id(select_id | transform_part); + cage2d_draw_box_interaction( + mpr->color, transform_part, size, margin, mpr->line_width, true, draw_options); + } + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + cage2d_draw_box_interaction( + mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, true, draw_options); + } + } + else { + const rctf r = { + .xmin = -size_real[0], + .ymin = -size_real[1], + .xmax = size_real[0], + .ymax = size_real[1], + }; + if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { + /* corner manipulators */ + GPU_line_width(mpr->line_width + 3.0f); + cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0}); + + /* corner manipulators */ + float color[4]; + manipulator_color_get(mpr, highlight, color); + GPU_line_width(mpr->line_width); + cage2d_draw_box_corners(&r, margin, color); + + bool show = false; + if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) { + /* Only show if we're drawing the center handle + * otherwise the entire rectangle is the hotspot. */ + if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + show = true; + } + } + else { + show = true; + } + + if (show) { + cage2d_draw_box_interaction( + mpr->color, mpr->highlight_part, size_real, margin, mpr->line_width, false, draw_options); + } + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + cage2d_draw_box_interaction( + mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, false, draw_options); + } + } + else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) { + float color[4]; + manipulator_color_get(mpr, highlight, color); + + GPU_line_smooth(true); + GPU_blend(true); + + GPU_line_width(mpr->line_width + 3.0f); + cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); + GPU_line_width(mpr->line_width); + cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options); + + + /* corner manipulators */ + cage2d_draw_circle_handles(&r, margin, color, transform_flag, true); + cage2d_draw_circle_handles(&r, margin, (const float[3]){0, 0, 0}, transform_flag, false); + + GPU_blend(false); + GPU_line_smooth(false); + } + else { + BLI_assert(0); + } + } + + GPU_line_width(1.0); + gpuPopMatrix(); +} + +/** + * For when we want to draw 2d cage in 3d views. + */ +static void manipulator_cage2d_draw_select(const bContext *UNUSED(C), wmManipulator *mpr, int select_id) +{ + manipulator_cage2d_draw_intern(mpr, true, false, select_id); +} + +static void manipulator_cage2d_draw(const bContext *UNUSED(C), wmManipulator *mpr) +{ + const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + manipulator_cage2d_draw_intern(mpr, false, is_highlight, -1); +} + +static int manipulator_cage2d_get_cursor(wmManipulator *mpr) +{ + int highlight_part = mpr->highlight_part; + + if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + return BC_NSEW_SCROLLCURSOR; + } + + switch (highlight_part) { + case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE: + return BC_NSEW_SCROLLCURSOR; + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: + return CURSOR_X_MOVE; + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: + return CURSOR_Y_MOVE; + + /* TODO diagonal cursor */ + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: + return BC_NSEW_SCROLLCURSOR; + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: + case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: + return BC_NSEW_SCROLLCURSOR; + case ED_MANIPULATOR_CAGE2D_PART_ROTATE: + return BC_CROSSCURSOR; + default: + return CURSOR_STD; + } +} + +static int manipulator_cage2d_test_select( + bContext *C, wmManipulator *mpr, const wmEvent *event) +{ + float point_local[2]; + float dims[2]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; + + if (manipulator_window_project_2d( + C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + { + return -1; + } + + float margin[2]; + manipulator_calc_rect_view_margin(mpr, dims, margin); + /* expand for hotspot */ + const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; + + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { + rctf r; + if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + r.xmin = -margin[0] / 2; + r.ymin = -margin[1] / 2; + r.xmax = margin[0] / 2; + r.ymax = margin[1] / 2; + } + else { + r.xmin = -size[0] + margin[0]; + r.ymin = -size[1] + margin[1]; + r.xmax = size[0] - margin[0]; + r.ymax = size[1] - margin[1]; + }; + bool isect = BLI_rctf_isect_pt_v(&r, point_local); + if (isect) { + return ED_MANIPULATOR_CAGE2D_PART_TRANSLATE; + } + } + + /* if manipulator does not have a scale intersection, don't do it */ + if (transform_flag & (ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM)) { + const rctf r_xmin = {.xmin = -size[0], .ymin = -size[1], .xmax = -size[0] + margin[0], .ymax = size[1]}; + const rctf r_xmax = {.xmin = size[0] - margin[0], .ymin = -size[1], .xmax = size[0], .ymax = size[1]}; + const rctf r_ymin = {.xmin = -size[0], .ymin = -size[1], .xmax = size[0], .ymax = -size[1] + margin[1]}; + const rctf r_ymax = {.xmin = -size[0], .ymin = size[1] - margin[1], .xmax = size[0], .ymax = size[1]}; + + if (BLI_rctf_isect_pt_v(&r_xmin, point_local)) { + if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { + return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y; + } + if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { + return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y; + } + return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X; + } + if (BLI_rctf_isect_pt_v(&r_xmax, point_local)) { + if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { + return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y; + } + if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { + return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y; + } + return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X; + } + if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { + return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y; + } + if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { + return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y; + } + } + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + /* Rotate: + * (*) <-- hot spot is here! + * +---+ + * | | + * +---+ */ + const float r_rotate_pt[2] = {0.0f, size_real[1] + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)}; + const rctf r_rotate = { + .xmin = r_rotate_pt[0] - margin[0] / 2.0f, + .xmax = r_rotate_pt[0] + margin[0] / 2.0f, + .ymin = r_rotate_pt[1] - margin[1] / 2.0f, + .ymax = r_rotate_pt[1] + margin[1] / 2.0f, + }; + + if (BLI_rctf_isect_pt_v(&r_rotate, point_local)) { + return ED_MANIPULATOR_CAGE2D_PART_ROTATE; + } + } + + return -1; +} + +typedef struct RectTransformInteraction { + float orig_mouse[2]; + float orig_matrix_offset[4][4]; + float orig_matrix_final_no_offset[4][4]; + Dial *dial; +} RectTransformInteraction; + +static void manipulator_cage2d_setup(wmManipulator *mpr) +{ + mpr->flag |= WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_NO_SCALE; +} + +static int manipulator_cage2d_invoke( + bContext *C, wmManipulator *mpr, const wmEvent *event) +{ + RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); + + copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); + WM_manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset); + + if (manipulator_window_project_2d( + C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) + { + zero_v2(data->orig_mouse); + } + + mpr->interaction_data = data; + + return OPERATOR_RUNNING_MODAL; +} + +static int manipulator_cage2d_modal( + bContext *C, wmManipulator *mpr, const wmEvent *event, + eWM_ManipulatorTweak UNUSED(tweak_flag)) +{ + /* For transform logic to be managable we operate in -0.5..0.5 2D space, + * no matter the size of the rectangle, mouse coorts are scaled to unit space. + * The mouse coords have been projected into the matrix so we don't need to worry about axis alignment. + * + * - The cursor offset are multiplied by 'dims'. + * - Matrix translation is also multiplied by 'dims'. + */ + RectTransformInteraction *data = mpr->interaction_data; + float point_local[2]; + + float dims[2]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + + { + float matrix_back[4][4]; + copy_m4_m4(matrix_back, mpr->matrix_offset); + copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + + bool ok = manipulator_window_project_2d( + C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local); + copy_m4_m4(mpr->matrix_offset, matrix_back); + if (!ok) { + return OPERATOR_RUNNING_MODAL; + } + } + + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + wmManipulatorProperty *mpr_prop; + + mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); + if (mpr_prop->type != NULL) { + WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + } + + if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) { + /* do this to prevent clamping from changing size */ + copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); + mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); + } + else if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_ROTATE) { + +#define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \ + mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0})) + + float test_co[3]; + + if (data->dial == NULL) { + MUL_V2_V3_M4_FINAL(test_co, data->orig_matrix_offset[3]); + + data->dial = BLI_dial_initialize(test_co, FLT_EPSILON); + + MUL_V2_V3_M4_FINAL(test_co, data->orig_mouse); + BLI_dial_angle(data->dial, test_co); + } + + /* rotate */ + MUL_V2_V3_M4_FINAL(test_co, point_local); + const float angle = BLI_dial_angle(data->dial, test_co); + + float matrix_space_inv[4][4]; + float matrix_rotate[4][4]; + float pivot[3]; + + copy_v3_v3(pivot, data->orig_matrix_offset[3]); + + invert_m4_m4(matrix_space_inv, mpr->matrix_space); + + unit_m4(matrix_rotate); + mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv); + rotate_m4(matrix_rotate, 'Z', -angle); + mul_m4_m4m4(matrix_rotate, matrix_rotate, mpr->matrix_space); + + zero_v3(matrix_rotate[3]); + transform_pivot_set_m4(matrix_rotate, pivot); + + mul_m4_m4m4(mpr->matrix_offset, matrix_rotate, data->orig_matrix_offset); + +#undef MUL_V2_V3_M4_FINAL + } + else { + /* scale */ + copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + float pivot[2]; + bool constrain_axis[2] = {false}; + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { + manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); + } + else { + zero_v2(pivot); + } + + /* Cursor deltas scaled to (-0.5..0.5). */ + float delta_orig[2], delta_curr[2]; + for (int i = 0; i < 2; i++) { + delta_orig[i] = ((data->orig_mouse[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i]; + delta_curr[i] = ((point_local[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i]; + } + + float scale[2] = {1.0f, 1.0f}; + for (int i = 0; i < 2; i++) { + if (constrain_axis[i] == false) { + if (delta_orig[i] < 0.0f) { + delta_orig[i] *= -1.0f; + delta_curr[i] *= -1.0f; + } + const int sign = signum_i(scale[i]); + + scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i])); + + if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) { + if (sign != signum_i(scale[i])) { + scale[i] = 0.0f; + } + } + } + } + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) { + if (constrain_axis[0] == false && constrain_axis[1] == false) { + scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f; + } + else if (constrain_axis[0] == false) { + scale[1] = scale[0]; + } + else if (constrain_axis[1] == false) { + scale[0] = scale[1]; + } + else { + BLI_assert(0); + } + } + + /* scale around pivot */ + float matrix_scale[4][4]; + unit_m4(matrix_scale); + + mul_v3_fl(matrix_scale[0], scale[0]); + mul_v3_fl(matrix_scale[1], scale[1]); + + transform_pivot_set_m4(matrix_scale, (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], 0.0f}); + mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale); + } + + if (mpr_prop->type != NULL) { + WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); + } + + /* tag the region for redraw */ + ED_region_tag_redraw(CTX_wm_region(C)); + WM_event_add_mousemove(C); + + return OPERATOR_RUNNING_MODAL; +} + +static void manipulator_cage2d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +{ + if (STREQ(mpr_prop->type->idname, "matrix")) { + if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) { + WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + } + else { + BLI_assert(0); + } + } + else { + BLI_assert(0); + } +} + +static void manipulator_cage2d_exit(bContext *C, wmManipulator *mpr, const bool cancel) +{ + RectTransformInteraction *data = mpr->interaction_data; + + MEM_SAFE_FREE(data->dial); + + if (!cancel) + return; + + wmManipulatorProperty *mpr_prop; + + /* reset properties */ + mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); + if (mpr_prop->type != NULL) { + WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); + } + + copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); +} + + +/* -------------------------------------------------------------------- */ +/** \name Cage Manipulator API + * + * \{ */ + +static void MANIPULATOR_WT_cage_2d(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "MANIPULATOR_WT_cage_2d"; + + /* api callbacks */ + wt->draw = manipulator_cage2d_draw; + wt->draw_select = manipulator_cage2d_draw_select; + wt->test_select = manipulator_cage2d_test_select; + wt->setup = manipulator_cage2d_setup; + wt->invoke = manipulator_cage2d_invoke; + wt->property_update = manipulator_cage2d_property_update; + wt->modal = manipulator_cage2d_modal; + wt->exit = manipulator_cage2d_exit; + wt->cursor_get = manipulator_cage2d_get_cursor; + + wt->struct_size = sizeof(wmManipulator); + + /* rna */ + static EnumPropertyItem rna_enum_draw_style[] = { + {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""}, + {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_transform[] = { + {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""}, + {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, + {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_draw_options[] = { + {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""}, + {0, NULL, 0, NULL, NULL} + }; + static float unit_v2[2] = {1.0f, 1.0f}; + RNA_def_float_vector(wt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); + RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); + RNA_def_enum_flag( + wt->srna, "draw_options", rna_enum_draw_options, + ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); + + WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16); +} + +void ED_manipulatortypes_cage_2d(void) +{ + WM_manipulatortype_append(MANIPULATOR_WT_cage_2d); +} + +/** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c new file mode 100644 index 00000000000..0f3e67d7585 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -0,0 +1,692 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file cage3d_gizmo.c + * \ingroup wm + * + * \name Cage Manipulator + * + * 2D Manipulator + * + * \brief Rectangular manipulator acting as a 'cage' around its content. + * Interacting scales or translates the manipulator. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" +#include "BLI_rect.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" + +#include "GPU_matrix.h" +#include "GPU_shader.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_select.h" +#include "GPU_state.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" +#include "ED_view3d.h" +#include "ED_gizmo_library.h" + +/* own includes */ +#include "../gizmo_library_intern.h" + +#define MANIPULATOR_RESIZER_SIZE 10.0f +#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f + +static void manipulator_calc_matrix_final_no_offset( + const wmManipulator *mpr, float orig_matrix_final_no_offset[4][4], bool use_space) +{ + float mat_identity[4][4]; + struct WM_ManipulatorMatrixParams params = {NULL}; + unit_m4(mat_identity); + if (use_space == false) { + params.matrix_basis = mat_identity; + } + params.matrix_offset = mat_identity; + WM_manipulator_calc_matrix_final_params(mpr, ¶ms, orig_matrix_final_no_offset); +} + +static void manipulator_calc_rect_view_scale( + const wmManipulator *mpr, const float dims[3], float scale[3]) +{ + UNUSED_VARS(dims); + + /* Unlike cage2d, no need to correct for aspect. */ + float matrix_final_no_offset[4][4]; + + float x_axis[3], y_axis[3], z_axis[3]; + manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset, false); + mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); + mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); + mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, mpr->matrix_offset[2]); + + scale[0] = 1.0f / len_v3(x_axis); + scale[1] = 1.0f / len_v3(y_axis); + scale[2] = 1.0f / len_v3(z_axis); +} + +static void manipulator_calc_rect_view_margin( + const wmManipulator *mpr, const float dims[3], float margin[3]) +{ + float handle_size; + if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + handle_size = 0.15f; + } + else { + handle_size = MANIPULATOR_RESIZER_SIZE; + } + // XXX, the scale isn't taking offset into account, we need to calculate scale per handle! + // handle_size *= mpr->scale_final; + + float scale_xyz[3]; + manipulator_calc_rect_view_scale(mpr, dims, scale_xyz); + margin[0] = ((handle_size * scale_xyz[0])); + margin[1] = ((handle_size * scale_xyz[1])); + margin[2] = ((handle_size * scale_xyz[2])); +} + +/* -------------------------------------------------------------------- */ + +static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3]) +{ + if (part >= ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && + part <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) + { + int index = (part - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); + int range[3]; + range[2] = index % 3; + index = index / 3; + range[1] = index % 3; + index = index / 3; + range[0] = index % 3; + + const float sign[3] = {0.5f, 0.0f, -0.5f}; + for (int i = 0; i < 3; i++) { + r_pt[i] = sign[range[i]]; + r_constrain_axis[i] = (range[i] == 1); + } + } +} + +/* -------------------------------------------------------------------- */ +/** \name Box Draw Style + * + * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX + * \{ */ + +static void cage3d_draw_box_corners( + const float r[3], const float margin[3], const float color[3]) +{ + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + UNUSED_VARS(margin); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformColor3fv(color); + + imm_draw_cube_wire_3d(pos, (float[3]){0}, r); + + immUnbindProgram(); +} + +static void cage3d_draw_box_interaction( + const float color[4], const int highlighted, + const float size[3], const float margin[3]) +{ + if (highlighted >= ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && + highlighted <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) + { + int index = (highlighted - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); + int range[3]; + range[2] = index % 3; + index = index / 3; + range[1] = index % 3; + index = index / 3; + range[0] = index % 3; + + const float sign[3] = {-1.0f, 0.0f, 1.0f}; + float co[3]; + + for (int i = 0; i < 3; i++) { + co[i] = size[i] * sign[range[i]]; + } + const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3}; + + { + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformColor3fv(color); + imm_draw_cube_fill_3d(pos, co, rad); + immUnbindProgram(); + } + } +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Circle Draw Style + * + * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE + * \{ */ + +static void imm_draw_point_aspect_3d( + uint pos, const float co[3], const float rad[3], bool solid) +{ + if (solid) { + imm_draw_cube_fill_3d(pos, co, rad); + } + else { + imm_draw_cube_wire_3d(pos, co, rad); + } +} + +static void cage3d_draw_circle_wire( + const float r[3], const float margin[3], const float color[3], + const int transform_flag, const int draw_options) +{ + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformColor3fv(color); + + imm_draw_cube_wire_3d(pos, (float[3]){0}, r); + +#if 0 + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { + if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + const float rad[2] = {margin[0] / 2, margin[1] / 2}; + const float center[2] = {0.0f, 0.0f}; + + immBegin(GWN_PRIM_LINES, 4); + immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]); + immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]); + immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]); + immVertex2f(pos, center[0] - rad[0], center[1] + rad[1]); + immEnd(); + } + } +#else + UNUSED_VARS(margin, transform_flag, draw_options); +#endif + + + immUnbindProgram(); +} + +static void cage3d_draw_circle_handles( + const RegionView3D *rv3d, const float matrix_final[4][4], + const float r[3], const float margin[3], const float color[3], + bool solid, float scale) +{ + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3}; + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformColor3fv(color); + + float sign[3] = {-1.0f, 0.0f, 1.0f}; + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + for (int z = 0; z < 3; z++) { + if (x == 1 && y == 1 && z == 1) { + continue; + } + const float co[3] = {r[0] * sign[x], r[1] * sign[y], r[2] * sign[z]}; + float co_test[3]; + mul_v3_m4v3(co_test, matrix_final, co); + float rad_scale[3]; + mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test) * scale); + imm_draw_point_aspect_3d(pos, co, rad_scale, solid); + } + } + } + + immUnbindProgram(); +} + +/** \} */ + +static void manipulator_cage3d_draw_intern( + RegionView3D *rv3d, + wmManipulator *mpr, const bool select, const bool highlight, const int select_id) +{ + // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; + float dims[3]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + float matrix_final[4][4]; + + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + + const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f}; + + WM_manipulator_calc_matrix_final(mpr, matrix_final); + + gpuPushMatrix(); + gpuMultMatrix(matrix_final); + + float margin[3]; + manipulator_calc_rect_view_margin(mpr, dims, margin); + + /* Handy for quick testing draw (if it's outside bounds). */ + if (false) { + GPU_blend(true); + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); + float s = 0.5f; + immRectf(pos, -s, -s, s, s); + immUnbindProgram(); + GPU_blend(false); + } + + if (select) { + /* expand for hotspot */ +#if 0 + const float size[3] = { + size_real[0] + margin[0] / 2, + size_real[1] + margin[1] / 2, + size_real[2] + margin[2] / 2, + }; +#else + /* just use same value for now. */ + const float size[3] = {UNPACK3(size_real)}; +#endif + + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) { + for (int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; + i <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z; + i++) + { + if (i == ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z) { + continue; + } + GPU_select_load_id(select_id | i); + cage3d_draw_box_interaction( + mpr->color, i, size, margin); + } + } + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { + const int transform_part = ED_MANIPULATOR_CAGE3D_PART_TRANSLATE; + GPU_select_load_id(select_id | transform_part); + cage3d_draw_box_interaction( + mpr->color, transform_part, size, margin); + } + } + else { +#if 0 + const rctf _r = { + .xmin = -size_real[0], + .ymin = -size_real[1], + .xmax = size_real[0], + .ymax = size_real[1], + }; +#endif + if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { + /* corner manipulators */ + GPU_line_width(mpr->line_width + 3.0f); + cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0}); + + /* corner manipulators */ + float color[4]; + manipulator_color_get(mpr, highlight, color); + GPU_line_width(mpr->line_width); + cage3d_draw_box_corners(size_real, margin, color); + + bool show = false; + if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_TRANSLATE) { + /* Only show if we're drawing the center handle + * otherwise the entire rectangle is the hotspot. */ + if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + show = true; + } + } + else { + show = true; + } + + if (show) { + cage3d_draw_box_interaction( + mpr->color, mpr->highlight_part, size_real, margin); + } + } + else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) { + float color[4]; + manipulator_color_get(mpr, highlight, color); + + GPU_line_smooth(true); + GPU_polygon_smooth(true); + GPU_blend(true); + + GPU_line_width(mpr->line_width + 3.0f); + cage3d_draw_circle_wire(size_real, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); + GPU_line_width(mpr->line_width); + cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options); + + /* corner manipulators */ + cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, (const float[3]){0, 0, 0}, true, 60); + cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 40); + + GPU_blend(false); + GPU_polygon_smooth(false); + GPU_line_smooth(false); + } + else { + BLI_assert(0); + } + } + + GPU_line_width(1.0); + gpuPopMatrix(); +} + +/** + * For when we want to draw 3d cage in 3d views. + */ +static void manipulator_cage3d_draw_select(const bContext *C, wmManipulator *mpr, int select_id) +{ + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + manipulator_cage3d_draw_intern(rv3d, mpr, true, false, select_id); +} + +static void manipulator_cage3d_draw(const bContext *C, wmManipulator *mpr) +{ + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + manipulator_cage3d_draw_intern(rv3d, mpr, false, is_highlight, -1); +} + +static int manipulator_cage3d_get_cursor(wmManipulator *mpr) +{ + if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + return BC_NSEW_SCROLLCURSOR; + } + + return CURSOR_STD; +} + +typedef struct RectTransformInteraction { + float orig_mouse[3]; + float orig_matrix_offset[4][4]; + float orig_matrix_final_no_offset[4][4]; +} RectTransformInteraction; + +static void manipulator_cage3d_setup(wmManipulator *mpr) +{ + mpr->flag |= /* WM_MANIPULATOR_DRAW_MODAL | */ /* TODO */ + WM_MANIPULATOR_DRAW_NO_SCALE; +} + +static int manipulator_cage3d_invoke( + bContext *C, wmManipulator *mpr, const wmEvent *event) +{ + RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); + + copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); + manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset, true); + + if (manipulator_window_project_3d( + C, mpr, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) + { + zero_v3(data->orig_mouse); + } + + mpr->interaction_data = data; + + return OPERATOR_RUNNING_MODAL; +} + +static int manipulator_cage3d_modal( + bContext *C, wmManipulator *mpr, const wmEvent *event, + eWM_ManipulatorTweak UNUSED(tweak_flag)) +{ + /* For transform logic to be managable we operate in -0.5..0.5 2D space, + * no matter the size of the rectangle, mouse coorts are scaled to unit space. + * The mouse coords have been projected into the matrix so we don't need to worry about axis alignment. + * + * - The cursor offset are multiplied by 'dims'. + * - Matrix translation is also multiplied by 'dims'. + */ + RectTransformInteraction *data = mpr->interaction_data; + float point_local[3]; + + float dims[3]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + + { + float matrix_back[4][4]; + copy_m4_m4(matrix_back, mpr->matrix_offset); + copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + + bool ok = manipulator_window_project_3d( + C, mpr, (const float[2]){UNPACK2(event->mval)}, false, point_local); + copy_m4_m4(mpr->matrix_offset, matrix_back); + if (!ok) { + return OPERATOR_RUNNING_MODAL; + } + } + + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + wmManipulatorProperty *mpr_prop; + + mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); + if (mpr_prop->type != NULL) { + WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + } + + if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_TRANSLATE) { + /* do this to prevent clamping from changing size */ + copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); + mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); + mpr->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]); + } + else if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_ROTATE) { + /* TODO (if needed) */ + } + else { + /* scale */ + copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + float pivot[3]; + bool constrain_axis[3] = {false}; + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { + manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); + } + else { + zero_v3(pivot); + } + + /* Cursor deltas scaled to (-0.5..0.5). */ + float delta_orig[3], delta_curr[3]; + + for (int i = 0; i < 3; i++) { + delta_orig[i] = ((data->orig_mouse[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i]; + delta_curr[i] = ((point_local[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i]; + } + + float scale[3] = {1.0f, 1.0f, 1.0f}; + for (int i = 0; i < 3; i++) { + if (constrain_axis[i] == false) { + if (delta_orig[i] < 0.0f) { + delta_orig[i] *= -1.0f; + delta_curr[i] *= -1.0f; + } + const int sign = signum_i(scale[i]); + + scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i])); + + if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) { + if (sign != signum_i(scale[i])) { + scale[i] = 0.0f; + } + } + } + } + + if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) { + if (constrain_axis[0] == false && constrain_axis[1] == false) { + scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f; + } + else if (constrain_axis[0] == false) { + scale[1] = scale[0]; + } + else if (constrain_axis[1] == false) { + scale[0] = scale[1]; + } + else { + BLI_assert(0); + } + } + + /* scale around pivot */ + float matrix_scale[4][4]; + unit_m4(matrix_scale); + + mul_v3_fl(matrix_scale[0], scale[0]); + mul_v3_fl(matrix_scale[1], scale[1]); + mul_v3_fl(matrix_scale[2], scale[2]); + + transform_pivot_set_m4( + matrix_scale, + (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]}); + mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale); + } + + if (mpr_prop->type != NULL) { + WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); + } + + /* tag the region for redraw */ + ED_region_tag_redraw(CTX_wm_region(C)); + WM_event_add_mousemove(C); + + return OPERATOR_RUNNING_MODAL; +} + +static void manipulator_cage3d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +{ + if (STREQ(mpr_prop->type->idname, "matrix")) { + if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) { + WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + } + else { + BLI_assert(0); + } + } + else { + BLI_assert(0); + } +} + +static void manipulator_cage3d_exit(bContext *C, wmManipulator *mpr, const bool cancel) +{ + RectTransformInteraction *data = mpr->interaction_data; + + if (!cancel) + return; + + wmManipulatorProperty *mpr_prop; + + /* reset properties */ + mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); + if (mpr_prop->type != NULL) { + WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); + } + + copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); +} + + +/* -------------------------------------------------------------------- */ +/** \name Cage Manipulator API + * + * \{ */ + +static void MANIPULATOR_WT_cage_3d(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "MANIPULATOR_WT_cage_3d"; + + /* api callbacks */ + wt->draw = manipulator_cage3d_draw; + wt->draw_select = manipulator_cage3d_draw_select; + wt->setup = manipulator_cage3d_setup; + wt->invoke = manipulator_cage3d_invoke; + wt->property_update = manipulator_cage3d_property_update; + wt->modal = manipulator_cage3d_modal; + wt->exit = manipulator_cage3d_exit; + wt->cursor_get = manipulator_cage3d_get_cursor; + + wt->struct_size = sizeof(wmManipulator); + + /* rna */ + static EnumPropertyItem rna_enum_draw_style[] = { + {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""}, + {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_transform[] = { + {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, + {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_draw_options[] = { + {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""}, + {0, NULL, 0, NULL, NULL} + }; + static float unit_v3[3] = {1.0f, 1.0f, 1.0f}; + RNA_def_float_vector(wt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); + RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); + RNA_def_enum_flag( + wt->srna, "draw_options", rna_enum_draw_options, + ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); + + WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16); +} + +void ED_manipulatortypes_cage_3d(void) +{ + WM_manipulatortype_append(MANIPULATOR_WT_cage_3d); +} + +/** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c new file mode 100644 index 00000000000..8d0061f66c8 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -0,0 +1,487 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file dial3d_gizmo.c + * \ingroup wm + * + * \name Dial Manipulator + * + * 3D Manipulator + * + * \brief Circle shaped manipulator for circular interaction. + * Currently no own handling, use with operator only. + * + * - `matrix[0]` is derived from Y and Z. + * - `matrix[1]` is 'up' when DialManipulator.use_start_y_axis is set. + * - `matrix[2]` is the axis the dial rotates around (all dials). + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_select.h" +#include "GPU_state.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" +#include "ED_view3d.h" +#include "ED_gizmo_library.h" + +/* own includes */ +#include "../gizmo_geometry.h" +#include "../gizmo_library_intern.h" + +/* to use custom dials exported to geom_dial_manipulator.c */ +// #define USE_MANIPULATOR_CUSTOM_DIAL + +static int manipulator_dial_modal( + bContext *C, wmManipulator *mpr, const wmEvent *event, + eWM_ManipulatorTweak tweak_flag); + +typedef struct DialInteraction { + float init_mval[2]; + + /* only for when using properties */ + float init_prop_angle; + + /* cache the last angle to detect rotations bigger than -/+ PI */ + float last_angle; + /* number of full rotations */ + int rotations; + + /* final output values, used for drawing */ + struct { + float angle_ofs; + float angle_delta; + } output; +} DialInteraction; + +#define DIAL_WIDTH 1.0f +#define DIAL_RESOLUTION 48 + +/* Could make option, negative to clip more (don't show when view aligned). */ +#define DIAL_CLIP_BIAS 0.02 + +/** + * We can't use this for the #wmManipulatorType.matrix_basis_get callback, it conflicts with depth picking. + */ +static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4]) +{ + float rot[3][3]; + const float up[3] = {0.0f, 0.0f, 1.0f}; + + rotation_between_vecs_to_mat3(rot, up, mpr->matrix_basis[2]); + copy_m4_m3(mat, rot); + copy_v3_v3(mat[3], mpr->matrix_basis[3]); +} + +/* -------------------------------------------------------------------- */ + +static void dial_geom_draw( + const wmManipulator *mpr, const float color[4], const bool select, + float axis_modal_mat[4][4], float clip_plane[4]) +{ +#ifdef USE_MANIPULATOR_CUSTOM_DIAL + UNUSED_VARS(dial, col, axis_modal_mat, clip_plane); + wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_dial, select); +#else + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const bool filled = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL) != 0; + + GPU_line_width(mpr->line_width); + + Gwn_VertFormat *format = immVertexFormat(); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + + if (clip_plane) { + immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR); + float clip_plane_f[4] = {clip_plane[0], clip_plane[1], clip_plane[2], clip_plane[3]}; + immUniform4fv("ClipPlane", clip_plane_f); + immUniformMatrix4fv("ModelMatrix", axis_modal_mat); + } + else { + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + } + + immUniformColor4fv(color); + + if (filled) { + imm_draw_circle_fill_2d(pos, 0, 0, 1.0, DIAL_RESOLUTION); + } + else { + imm_draw_circle_wire_2d(pos, 0, 0, 1.0, DIAL_RESOLUTION); + } + + immUnbindProgram(); + + UNUSED_VARS(select); +#endif +} + +/** + * Draws a line from (0, 0, 0) to \a co_outer, at \a angle. + */ +static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4]) +{ + GPU_line_width(1.0f); + + gpuPushMatrix(); + gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); + + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + + immUniformColor4fv(color); + + immBegin(GWN_PRIM_LINE_STRIP, 2); + immVertex3f(pos, 0.0f, 0.0f, 0.0f); + immVertex3fv(pos, co_outer); + immEnd(); + + immUnbindProgram(); + + gpuPopMatrix(); +} + +static void dial_ghostarc_draw( + const wmManipulator *mpr, const float angle_ofs, const float angle_delta, const float color[4]) +{ + const float width_inner = DIAL_WIDTH - mpr->line_width * 0.5f / U.manipulator_size; + + Gwn_VertFormat *format = immVertexFormat(); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformColor4fv(color); + imm_draw_disk_partial_fill_2d( + pos, 0, 0, 0.0, width_inner, DIAL_RESOLUTION, RAD2DEGF(angle_ofs), RAD2DEGF(angle_delta)); + immUnbindProgram(); +} + +static void dial_ghostarc_get_angles( + struct Depsgraph *depsgraph, + const wmManipulator *mpr, + const wmEvent *event, + const ARegion *ar, const View3D *v3d, + float mat[4][4], const float co_outer[3], + float *r_start, float *r_delta) +{ + DialInteraction *inter = mpr->interaction_data; + const RegionView3D *rv3d = ar->regiondata; + const float mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; + + /* we might need to invert the direction of the angles */ + float view_vec[3], axis_vec[3]; + ED_view3d_global_to_vector(rv3d, mpr->matrix_basis[3], view_vec); + normalize_v3_v3(axis_vec, mpr->matrix_basis[2]); + + float proj_outer_rel[3]; + mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer); + sub_v3_v3(proj_outer_rel, mpr->matrix_basis[3]); + + float proj_mval_new_rel[3]; + float proj_mval_init_rel[3]; + float dial_plane[4]; + float ray_co[3], ray_no[3]; + float ray_lambda; + + plane_from_point_normal_v3(dial_plane, mpr->matrix_basis[3], axis_vec); + + if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, inter->init_mval, ray_co, ray_no, false) || + !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) + { + goto fail; + } + madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda); + sub_v3_v3(proj_mval_init_rel, mpr->matrix_basis[3]); + + if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, mval, ray_co, ray_no, false) || + !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) + { + goto fail; + } + madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda); + sub_v3_v3(proj_mval_new_rel, mpr->matrix_basis[3]); + + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + + /* Start direction from mouse or set by user */ + const float *proj_init_rel = + (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y) ? + mpr->matrix_basis[1] : proj_mval_init_rel; + + /* return angles */ + const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec)); + const float delta = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_mval_init_rel, proj_mval_new_rel, axis_vec)); + + /* Change of sign, we passed the 180 degree threshold. This means we need to add a turn + * to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2. + * Logic taken from BLI_dial_angle */ + if ((delta * inter->last_angle < 0.0f) && + (fabsf(inter->last_angle) > (float)M_PI_2)) + { + if (inter->last_angle < 0.0f) + inter->rotations--; + else + inter->rotations++; + } + inter->last_angle = delta; + + *r_start = start; + *r_delta = fmod(delta + 2.0f * (float)M_PI * inter->rotations, 2 * (float)M_PI); + return; + + /* If we can't project (unlikely). */ +fail: + *r_start = 0.0; + *r_delta = 0.0; +} + +static void dial_draw_intern( + const bContext *C, wmManipulator *mpr, + const bool select, const bool highlight, float clip_plane[4]) +{ + float matrix_basis_adjust[4][4]; + float matrix_final[4][4]; + float color[4]; + + BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D); + + manipulator_color_get(mpr, highlight, color); + + dial_calc_matrix(mpr, matrix_basis_adjust); + + WM_manipulator_calc_matrix_final_params( + mpr, &((struct WM_ManipulatorMatrixParams) { + .matrix_basis = (void *)matrix_basis_adjust, + }), matrix_final); + + gpuPushMatrix(); + gpuMultMatrix(matrix_final); + + /* draw rotation indicator arc first */ + if ((mpr->flag & WM_MANIPULATOR_DRAW_VALUE) && + (mpr->state & WM_MANIPULATOR_STATE_MODAL)) + { + const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ + + DialInteraction *inter = mpr->interaction_data; + + /* XXX, View3D rotation manipulator doesn't call modal. */ + if (!WM_manipulator_target_property_is_valid_any(mpr)) { + wmWindow *win = CTX_wm_window(C); + manipulator_dial_modal((bContext *)C, mpr, win->eventstate, 0); + } + + float angle_ofs = inter->output.angle_ofs; + float angle_delta = inter->output.angle_delta; + + /* draw! */ + for (int i = 0; i < 2; i++) { + GPU_polygon_smooth(false); + dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f}); + GPU_polygon_smooth(true); + + dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */ + dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */ + + if (i == 0) { + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + if ((draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) { + break; + } + } + + angle_ofs += (float)M_PI; + } + } + + /* draw actual dial manipulator */ + dial_geom_draw(mpr, color, select, matrix_basis_adjust, clip_plane); + + gpuPopMatrix(); +} + +static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int select_id) +{ + float clip_plane_buf[4]; + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + float *clip_plane = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL; + + /* enable clipping if needed */ + if (clip_plane) { + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + + copy_v3_v3(clip_plane, rv3d->viewinv[2]); + clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]); + clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final; + glEnable(GL_CLIP_DISTANCE0); + } + + GPU_select_load_id(select_id); + dial_draw_intern(C, mpr, true, false, clip_plane); + + if (clip_plane) { + glDisable(GL_CLIP_DISTANCE0); + } +} + +static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) +{ + const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; + const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + float clip_plane_buf[4]; + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + float *clip_plane = (!is_modal && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL; + + /* enable clipping if needed */ + if (clip_plane) { + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + + copy_v3_v3(clip_plane, rv3d->viewinv[2]); + clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]); + clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final; + + glEnable(GL_CLIP_DISTANCE0); + } + + GPU_blend(true); + dial_draw_intern(C, mpr, false, is_highlight, clip_plane); + GPU_blend(false); + + if (clip_plane) { + glDisable(GL_CLIP_DISTANCE0); + } +} + +static int manipulator_dial_modal( + bContext *C, wmManipulator *mpr, const wmEvent *event, + eWM_ManipulatorTweak UNUSED(tweak_flag)) +{ + const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ + float angle_ofs, angle_delta; + + float matrix[4][4]; + + dial_calc_matrix(mpr, matrix); + + dial_ghostarc_get_angles( + CTX_data_depsgraph(C), + mpr, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta); + + DialInteraction *inter = mpr->interaction_data; + + inter->output.angle_delta = angle_delta; + inter->output.angle_ofs = angle_ofs; + + /* set the property for the operator and call its modal function */ + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); + } + return OPERATOR_RUNNING_MODAL; +} + + +static void manipulator_dial_setup(wmManipulator *mpr) +{ + const float dir_default[3] = {0.0f, 0.0f, 1.0f}; + + /* defaults */ + copy_v3_v3(mpr->matrix_basis[2], dir_default); +} + +static int manipulator_dial_invoke( + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +{ + DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__); + + inter->init_mval[0] = event->mval[0]; + inter->init_mval[1] = event->mval[1]; + + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + inter->init_prop_angle = WM_manipulator_target_property_value_get(mpr, mpr_prop); + } + + mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; +} + +/* -------------------------------------------------------------------- */ +/** \name Dial Manipulator API + * + * \{ */ + +static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "MANIPULATOR_WT_dial_3d"; + + /* api callbacks */ + wt->draw = manipulator_dial_draw; + wt->draw_select = manipulator_dial_draw_select; + wt->setup = manipulator_dial_setup; + wt->invoke = manipulator_dial_invoke; + wt->modal = manipulator_dial_modal; + + wt->struct_size = sizeof(wmManipulator); + + /* rna */ + static EnumPropertyItem rna_enum_draw_options[] = { + {ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""}, + {0, NULL, 0, NULL, NULL} + }; + RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + + WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1); +} + +void ED_manipulatortypes_dial_3d(void) +{ + WM_manipulatortype_append(MANIPULATOR_WT_dial_3d); +} + +/** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c new file mode 100644 index 00000000000..e55b57327b6 --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c @@ -0,0 +1,375 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file grab3d_gizmo.c + * \ingroup wm + * + * \name Grab Manipulator + * + * 3D Manipulator, also works in 2D views. + * + * \brief Simple manipulator to grab and translate. + * + * - `matrix[0]` is derived from Y and Z. + * - `matrix[1]` currently not used. + * - `matrix[2]` is the widget direction (for all manipulators). + * + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_select.h" +#include "GPU_state.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" +#include "ED_view3d.h" +#include "ED_gizmo_library.h" + +/* own includes */ +#include "../gizmo_geometry.h" +#include "../gizmo_library_intern.h" + +typedef struct GrabManipulator3D { + wmManipulator manipulator; + /* Added to 'matrix_basis' when calculating the matrix. */ + float prop_co[3]; +} GrabManipulator3D; + +static void manipulator_grab_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4]) +{ + GrabManipulator3D *grab = (GrabManipulator3D *)mpr; + + copy_m4_m4(r_matrix, grab->manipulator.matrix_basis); + add_v3_v3(r_matrix[3], grab->prop_co); +} + +static int manipulator_grab_modal( + bContext *C, wmManipulator *mpr, const wmEvent *event, + eWM_ManipulatorTweak tweak_flag); + +typedef struct GrabInteraction { + float init_mval[2]; + + /* only for when using properties */ + float init_prop_co[3]; + + float init_matrix_final[4][4]; +} GrabInteraction; + +#define DIAL_RESOLUTION 32 + +/* -------------------------------------------------------------------- */ + +static void grab_geom_draw( + const wmManipulator *mpr, const float color[4], const bool select, const int draw_options) +{ +#ifdef USE_MANIPULATOR_CUSTOM_DIAL + UNUSED_VARS(grab3d, col, axis_modal_mat); + wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_grab3d, select); +#else + const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); + const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0; + + GPU_line_width(mpr->line_width); + + Gwn_VertFormat *format = immVertexFormat(); + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + + immUniformColor4fv(color); + + if (draw_style == ED_MANIPULATOR_GRAB_STYLE_RING_2D) { + if (filled) { + imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION); + } + else { + imm_draw_circle_wire_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION); + } + } + else if (draw_style == ED_MANIPULATOR_GRAB_STYLE_CROSS_2D) { + immBegin(GWN_PRIM_LINES, 4); + immVertex2f(pos, 1.0f, 1.0f); + immVertex2f(pos, -1.0f, -1.0f); + + immVertex2f(pos, -1.0f, 1.0f); + immVertex2f(pos, 1.0f, -1.0f); + immEnd(); + } + else { + BLI_assert(0); + } + + immUnbindProgram(); + + UNUSED_VARS(select); +#endif +} + +static void grab3d_get_translate( + const wmManipulator *mpr, const wmEvent *event, const ARegion *ar, + float co_delta[3]) +{ + GrabInteraction *inter = mpr->interaction_data; + const float mval_delta[2] = { + event->mval[0] - inter->init_mval[0], + event->mval[1] - inter->init_mval[1], + }; + + RegionView3D *rv3d = ar->regiondata; + float co_ref[3]; + mul_v3_mat3_m4v3(co_ref, mpr->matrix_space, inter->init_prop_co); + const float zfac = ED_view3d_calc_zfac(rv3d, co_ref, NULL); + + ED_view3d_win_to_delta(ar, mval_delta, co_delta, zfac); + + float matrix_space_inv[3][3]; + copy_m3_m4(matrix_space_inv, mpr->matrix_space); + invert_m3(matrix_space_inv); + mul_m3_v3(matrix_space_inv, co_delta); +} + +static void grab3d_draw_intern( + const bContext *C, wmManipulator *mpr, + const bool select, const bool highlight) +{ + GrabInteraction *inter = mpr->interaction_data; + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const bool align_view = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0; + float color[4]; + float matrix_final[4][4]; + float matrix_align[4][4]; + + manipulator_color_get(mpr, highlight, color); + WM_manipulator_calc_matrix_final(mpr, matrix_final); + + gpuPushMatrix(); + gpuMultMatrix(matrix_final); + + if (align_view) { + float matrix_final_unit[4][4]; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + normalize_m4_m4(matrix_final_unit, matrix_final); + mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); + zero_v3(matrix_align[3]); + transpose_m4(matrix_align); + gpuMultMatrix(matrix_align); + } + + GPU_blend(true); + grab_geom_draw(mpr, color, select, draw_options); + GPU_blend(false); + gpuPopMatrix(); + + if (mpr->interaction_data) { + gpuPushMatrix(); + gpuMultMatrix(inter->init_matrix_final); + + if (align_view) { + gpuMultMatrix(matrix_align); + } + + GPU_blend(true); + grab_geom_draw(mpr, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); + GPU_blend(false); + gpuPopMatrix(); + } +} + +static void manipulator_grab_draw_select(const bContext *C, wmManipulator *mpr, int select_id) +{ + GPU_select_load_id(select_id); + grab3d_draw_intern(C, mpr, true, false); +} + +static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr) +{ + const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; + const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + + (void)is_modal; + + GPU_blend(true); + grab3d_draw_intern(C, mpr, false, is_highlight); + GPU_blend(false); +} + +static int manipulator_grab_modal( + bContext *C, wmManipulator *mpr, const wmEvent *event, + eWM_ManipulatorTweak UNUSED(tweak_flag)) +{ + GrabManipulator3D *grab = (GrabManipulator3D *)mpr; + GrabInteraction *inter = mpr->interaction_data; + ARegion *ar = CTX_wm_region(C); + + float prop_delta[3]; + if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) { + grab3d_get_translate(mpr, event, ar, prop_delta); + } + else { + float mval_proj_init[2], mval_proj_curr[2]; + if ((manipulator_window_project_2d( + C, mpr, inter->init_mval, 2, false, mval_proj_init) == false) || + (manipulator_window_project_2d( + C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) + { + return OPERATOR_RUNNING_MODAL; + } + sub_v2_v2v2(prop_delta, mval_proj_curr, mval_proj_init); + prop_delta[2] = 0.0f; + } + add_v3_v3v3(grab->prop_co, inter->init_prop_co, prop_delta); + + /* set the property for the operator and call its modal function */ + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, grab->prop_co); + } + else { + zero_v3(grab->prop_co); + } + + ED_region_tag_redraw(ar); + + return OPERATOR_RUNNING_MODAL; +} + +static int manipulator_grab_invoke( + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +{ + GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__); + + inter->init_mval[0] = event->mval[0]; + inter->init_mval[1] = event->mval[1]; + +#if 0 + copy_v3_v3(inter->init_prop_co, grab->prop_co); +#else + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + WM_manipulator_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co); + } +#endif + + WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); + + mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; +} + + +static int manipulator_grab_test_select( + bContext *C, wmManipulator *mpr, const wmEvent *event) +{ + float point_local[2]; + + if (manipulator_window_project_2d( + C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + { + return -1; + } + + /* The 'mpr->scale_final' is already applied when projecting. */ + if (len_squared_v2(point_local) < 1.0f) { + return 0; + } + + return -1; +} + +static void manipulator_grab_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +{ + GrabManipulator3D *grab = (GrabManipulator3D *)mpr; + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + WM_manipulator_target_property_value_get_array(mpr, mpr_prop, grab->prop_co); + } + else { + zero_v3(grab->prop_co); + } +} + +static int manipulator_grab_cursor_get(wmManipulator *UNUSED(mpr)) +{ + return BC_NSEW_SCROLLCURSOR; +} + +/* -------------------------------------------------------------------- */ +/** \name Grab Manipulator API + * + * \{ */ + +static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "MANIPULATOR_WT_grab_3d"; + + /* api callbacks */ + wt->draw = manipulator_grab_draw; + wt->draw_select = manipulator_grab_draw_select; + wt->test_select = manipulator_grab_test_select; + wt->matrix_basis_get = manipulator_grab_matrix_basis_get; + wt->invoke = manipulator_grab_invoke; + wt->property_update = manipulator_grab_property_update; + wt->modal = manipulator_grab_modal; + wt->cursor_get = manipulator_grab_cursor_get; + + wt->struct_size = sizeof(GrabManipulator3D); + + /* rna */ + static EnumPropertyItem rna_enum_draw_style[] = { + {ED_MANIPULATOR_GRAB_STYLE_RING_2D, "RING_2D", 0, "Ring", ""}, + {ED_MANIPULATOR_GRAB_STYLE_CROSS_2D, "CROSS_2D", 0, "Ring", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_draw_options[] = { + {ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, + {ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""}, + {0, NULL, 0, NULL, NULL} + }; + + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_GRAB_STYLE_RING_2D, "Draw Style", ""); + RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + + WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 3); +} + +void ED_manipulatortypes_grab_3d(void) +{ + WM_manipulatortype_append(MANIPULATOR_WT_grab_3d); +} + +/** \} */ // Grab Manipulator API diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c new file mode 100644 index 00000000000..1331a4e983f --- /dev/null +++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c @@ -0,0 +1,191 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file primitive3d_gizmo.c + * \ingroup wm + * + * \name Primitive Manipulator + * + * 3D Manipulator + * + * \brief Manipulator with primitive drawing type (plane, cube, etc.). + * Currently only plane primitive supported without own handling, use with operator only. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "DNA_view3d_types.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" + +#include "GPU_immediate.h" +#include "GPU_matrix.h" +#include "GPU_select.h" +#include "GPU_state.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_gizmo_library.h" + +/* own includes */ +#include "../gizmo_library_intern.h" + +static float verts_plane[4][3] = { + {-1, -1, 0}, + { 1, -1, 0}, + { 1, 1, 0}, + {-1, 1, 0}, +}; + + +/* -------------------------------------------------------------------- */ + +static void manipulator_primitive_draw_geom( + const float col_inner[4], const float col_outer[4], const int draw_style) +{ + float (*verts)[3]; + uint vert_count = 0; + + if (draw_style == ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE) { + verts = verts_plane; + vert_count = ARRAY_SIZE(verts_plane); + } + + if (vert_count > 0) { + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, GWN_PRIM_TRI_FAN); + wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, GWN_PRIM_LINE_LOOP); + immUnbindProgram(); + } +} + +static void manipulator_primitive_draw_intern( + wmManipulator *mpr, const bool UNUSED(select), + const bool highlight) +{ + float color_inner[4], color_outer[4]; + float matrix_final[4][4]; + const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); + + manipulator_color_get(mpr, highlight, color_outer); + copy_v4_v4(color_inner, color_outer); + color_inner[3] *= 0.5f; + + WM_manipulator_calc_matrix_final(mpr, matrix_final); + + gpuPushMatrix(); + gpuMultMatrix(matrix_final); + + GPU_blend(true); + manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); + GPU_blend(false); + + gpuPopMatrix(); + + if (mpr->interaction_data) { + ManipulatorInteraction *inter = mpr->interaction_data; + + copy_v4_fl(color_inner, 0.5f); + copy_v3_fl(color_outer, 0.5f); + color_outer[3] = 0.8f; + + gpuPushMatrix(); + gpuMultMatrix(inter->init_matrix_final); + + GPU_blend(true); + manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); + GPU_blend(false); + + gpuPopMatrix(); + } +} + +static void manipulator_primitive_draw_select( + const bContext *UNUSED(C), wmManipulator *mpr, + int select_id) +{ + GPU_select_load_id(select_id); + manipulator_primitive_draw_intern(mpr, true, false); +} + +static void manipulator_primitive_draw(const bContext *UNUSED(C), wmManipulator *mpr) +{ + manipulator_primitive_draw_intern( + mpr, false, + (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)); +} + +static void manipulator_primitive_setup(wmManipulator *mpr) +{ + mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; +} + +static int manipulator_primitive_invoke( + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) +{ + ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); + + WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); + + mpr->interaction_data = inter; + + return OPERATOR_RUNNING_MODAL; +} + +/* -------------------------------------------------------------------- */ +/** \name Primitive Manipulator API + * + * \{ */ + +static void MANIPULATOR_WT_primitive_3d(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "MANIPULATOR_WT_primitive_3d"; + + /* api callbacks */ + wt->draw = manipulator_primitive_draw; + wt->draw_select = manipulator_primitive_draw_select; + wt->setup = manipulator_primitive_setup; + wt->invoke = manipulator_primitive_invoke; + + wt->struct_size = sizeof(wmManipulator); + + static EnumPropertyItem rna_enum_draw_style[] = { + {ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""}, + {0, NULL, 0, NULL, NULL} + }; + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); +} + +void ED_manipulatortypes_primitive_3d(void) +{ + WM_manipulatortype_append(MANIPULATOR_WT_primitive_3d); +} + +/** \} */ diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h new file mode 100644 index 00000000000..b33fbf47630 --- /dev/null +++ b/source/blender/editors/include/ED_gizmo_library.h @@ -0,0 +1,222 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ED_gizmo_library.h + * \ingroup wm + * + * \name Generic Manipulators. + * + * This is exposes pre-defined manipulators for re-use. + */ + + +#ifndef __ED_GIZMO_LIBRARY_H__ +#define __ED_GIZMO_LIBRARY_H__ + +/* initialize manipulators */ +void ED_manipulatortypes_arrow_2d(void); +void ED_manipulatortypes_arrow_3d(void); +void ED_manipulatortypes_button_2d(void); +void ED_manipulatortypes_cage_2d(void); +void ED_manipulatortypes_cage_3d(void); +void ED_manipulatortypes_dial_3d(void); +void ED_manipulatortypes_grab_3d(void); +void ED_manipulatortypes_facemap_3d(void); +void ED_manipulatortypes_primitive_3d(void); + +struct wmManipulator; +struct wmManipulatorGroup; + + +/* -------------------------------------------------------------------- */ +/* Shape Presets + * + * Intended to be called by custom draw functions. + */ + +/* manipulator_library_presets.c */ +void ED_manipulator_draw_preset_box( + const struct wmManipulator *mpr, float mat[4][4], int select_id); +void ED_manipulator_draw_preset_arrow( + const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id); +void ED_manipulator_draw_preset_circle( + const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id); +void ED_manipulator_draw_preset_facemap( + const struct bContext *C, const struct wmManipulator *mpr, struct Scene *scene, + struct Object *ob, const int facemap, int select_id); + + +/* -------------------------------------------------------------------- */ +/* 3D Arrow Manipulator */ + +enum { + ED_MANIPULATOR_ARROW_STYLE_NORMAL = 0, + ED_MANIPULATOR_ARROW_STYLE_CROSS = 1, + ED_MANIPULATOR_ARROW_STYLE_BOX = 2, + ED_MANIPULATOR_ARROW_STYLE_CONE = 3, +}; + +/* transform */ +enum { + /* inverted offset during interaction - if set it also sets constrained below */ + ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED = (1 << 3), + /* clamp arrow interaction to property width */ + ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED = (1 << 4), +}; + +/* draw_options */ +enum { + /* Show arrow stem. */ + ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM = (1 << 0), +}; + +void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *mpr, const float min, const float max); +void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const float range_fac); + +/* -------------------------------------------------------------------- */ +/* 2D Arrow Manipulator */ + +/* none */ + +/* -------------------------------------------------------------------- */ +/* Cage Manipulator */ + +enum { + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE = (1 << 0), /* Translates */ + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE = (1 << 1), /* Rotates */ + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE = (1 << 2), /* Scales */ + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Scales uniformly */ + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED = (1 << 4), /* Negative scale allowed */ +}; + +/* draw_style */ +enum { + ED_MANIPULATOR_CAGE2D_STYLE_BOX = 0, + ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE = 1, +}; + +/* draw_options */ +enum { + /** Draw a central handle (instead of having the entire area selectable) + * Needed for large rectangles that we don't want to swallow all events. */ + ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE = (1 << 0), +}; + +/** #wmManipulator.highlight_part */ +enum { + ED_MANIPULATOR_CAGE2D_PART_TRANSLATE = 0, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X = 1, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X = 2, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y = 3, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y = 4, + /* Corners */ + ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y = 5, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y = 6, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y = 7, + ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y = 8, + + ED_MANIPULATOR_CAGE2D_PART_ROTATE = 9, +}; + +/** #wmManipulator.highlight_part */ +enum { + /* ordered min/mid/max so we can loop over values (MIN/MID/MAX) on each axis. */ + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z = 0, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MAX_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MIN_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MAX_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MIN_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MAX_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MIN_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MAX_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MIN_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MAX_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MIN_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MAX_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MIN_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MAX_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MIN_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MAX_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MIN_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MID_Z, + ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, + + ED_MANIPULATOR_CAGE3D_PART_TRANSLATE, + + ED_MANIPULATOR_CAGE3D_PART_ROTATE, +}; + +/* -------------------------------------------------------------------- */ +/* Dial Manipulator */ + +/* draw_options */ +enum { + ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP = 0, + ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP = (1 << 0), + ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL = (1 << 1), + ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 2), + ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 3), +}; + +/* -------------------------------------------------------------------- */ +/* Grab Manipulator */ + +/* draw_options */ +enum { + ED_MANIPULATOR_GRAB_DRAW_FLAG_NOP = 0, + /* only for solid shapes */ + ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL = (1 << 0), + ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW = (1 << 1), +}; + +enum { + ED_MANIPULATOR_GRAB_STYLE_RING_2D = 0, + ED_MANIPULATOR_GRAB_STYLE_CROSS_2D = 1, +}; + +/* -------------------------------------------------------------------- */ +/* Button Manipulator */ + +enum { + ED_MANIPULATOR_BUTTON_SHOW_OUTLINE = (1 << 0), + /** + * Draw a line from the origin to the offset (similar to an arrow) + * sometimes needed to show what the button edits. + */ + ED_MANIPULATOR_BUTTON_SHOW_HELPLINE = (1 << 1), +}; + + +/* -------------------------------------------------------------------- */ +/* Primitive Manipulator */ + +enum { + ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE = 0, +}; + +#endif /* __ED_GIZMO_LIBRARY_H__ */ diff --git a/source/blender/editors/include/ED_manipulator_library.h b/source/blender/editors/include/ED_manipulator_library.h deleted file mode 100644 index fca0f5c8806..00000000000 --- a/source/blender/editors/include/ED_manipulator_library.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ED_manipulator_library.h - * \ingroup wm - * - * \name Generic Manipulators. - * - * This is exposes pre-defined manipulators for re-use. - */ - - -#ifndef __ED_MANIPULATOR_LIBRARY_H__ -#define __ED_MANIPULATOR_LIBRARY_H__ - -/* initialize manipulators */ -void ED_manipulatortypes_arrow_2d(void); -void ED_manipulatortypes_arrow_3d(void); -void ED_manipulatortypes_button_2d(void); -void ED_manipulatortypes_cage_2d(void); -void ED_manipulatortypes_cage_3d(void); -void ED_manipulatortypes_dial_3d(void); -void ED_manipulatortypes_grab_3d(void); -void ED_manipulatortypes_facemap_3d(void); -void ED_manipulatortypes_primitive_3d(void); - -struct wmManipulator; -struct wmManipulatorGroup; - - -/* -------------------------------------------------------------------- */ -/* Shape Presets - * - * Intended to be called by custom draw functions. - */ - -/* manipulator_library_presets.c */ -void ED_manipulator_draw_preset_box( - const struct wmManipulator *mpr, float mat[4][4], int select_id); -void ED_manipulator_draw_preset_arrow( - const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id); -void ED_manipulator_draw_preset_circle( - const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id); -void ED_manipulator_draw_preset_facemap( - const struct bContext *C, const struct wmManipulator *mpr, struct Scene *scene, - struct Object *ob, const int facemap, int select_id); - - -/* -------------------------------------------------------------------- */ -/* 3D Arrow Manipulator */ - -enum { - ED_MANIPULATOR_ARROW_STYLE_NORMAL = 0, - ED_MANIPULATOR_ARROW_STYLE_CROSS = 1, - ED_MANIPULATOR_ARROW_STYLE_BOX = 2, - ED_MANIPULATOR_ARROW_STYLE_CONE = 3, -}; - -/* transform */ -enum { - /* inverted offset during interaction - if set it also sets constrained below */ - ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED = (1 << 3), - /* clamp arrow interaction to property width */ - ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED = (1 << 4), -}; - -/* draw_options */ -enum { - /* Show arrow stem. */ - ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM = (1 << 0), -}; - -void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *mpr, const float min, const float max); -void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const float range_fac); - -/* -------------------------------------------------------------------- */ -/* 2D Arrow Manipulator */ - -/* none */ - -/* -------------------------------------------------------------------- */ -/* Cage Manipulator */ - -enum { - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE = (1 << 0), /* Translates */ - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE = (1 << 1), /* Rotates */ - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE = (1 << 2), /* Scales */ - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Scales uniformly */ - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED = (1 << 4), /* Negative scale allowed */ -}; - -/* draw_style */ -enum { - ED_MANIPULATOR_CAGE2D_STYLE_BOX = 0, - ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE = 1, -}; - -/* draw_options */ -enum { - /** Draw a central handle (instead of having the entire area selectable) - * Needed for large rectangles that we don't want to swallow all events. */ - ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE = (1 << 0), -}; - -/** #wmManipulator.highlight_part */ -enum { - ED_MANIPULATOR_CAGE2D_PART_TRANSLATE = 0, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X = 1, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X = 2, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y = 3, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y = 4, - /* Corners */ - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y = 5, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y = 6, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y = 7, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y = 8, - - ED_MANIPULATOR_CAGE2D_PART_ROTATE = 9, -}; - -/** #wmManipulator.highlight_part */ -enum { - /* ordered min/mid/max so we can loop over values (MIN/MID/MAX) on each axis. */ - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z = 0, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, - - ED_MANIPULATOR_CAGE3D_PART_TRANSLATE, - - ED_MANIPULATOR_CAGE3D_PART_ROTATE, -}; - -/* -------------------------------------------------------------------- */ -/* Dial Manipulator */ - -/* draw_options */ -enum { - ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP = 0, - ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP = (1 << 0), - ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL = (1 << 1), - ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 2), - ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 3), -}; - -/* -------------------------------------------------------------------- */ -/* Grab Manipulator */ - -/* draw_options */ -enum { - ED_MANIPULATOR_GRAB_DRAW_FLAG_NOP = 0, - /* only for solid shapes */ - ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL = (1 << 0), - ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW = (1 << 1), -}; - -enum { - ED_MANIPULATOR_GRAB_STYLE_RING_2D = 0, - ED_MANIPULATOR_GRAB_STYLE_CROSS_2D = 1, -}; - -/* -------------------------------------------------------------------- */ -/* Button Manipulator */ - -enum { - ED_MANIPULATOR_BUTTON_SHOW_OUTLINE = (1 << 0), - /** - * Draw a line from the origin to the offset (similar to an arrow) - * sometimes needed to show what the button edits. - */ - ED_MANIPULATOR_BUTTON_SHOW_HELPLINE = (1 << 1), -}; - - -/* -------------------------------------------------------------------- */ -/* Primitive Manipulator */ - -enum { - ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE = 0, -}; - -#endif /* __ED_MANIPULATOR_LIBRARY_H__ */ diff --git a/source/blender/editors/manipulator_library/CMakeLists.txt b/source/blender/editors/manipulator_library/CMakeLists.txt deleted file mode 100644 index 86e1bb3b6d7..00000000000 --- a/source/blender/editors/manipulator_library/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ***** END GPL LICENSE BLOCK ***** - -set(INC - ../include - ../../blenkernel - ../../blenlib - ../../blentranslation - ../../bmesh - ../../depsgraph - ../../gpu - ../../makesdna - ../../makesrna - ../../windowmanager - ../../../../intern/guardedalloc - ../../../../intern/eigen - ../../../../intern/glew-mx -) - -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - -set(SRC - manipulator_draw_utils.c - manipulator_geometry.h - manipulator_library_intern.h - manipulator_library_presets.c - manipulator_library_utils.c - geometry/geom_arrow_manipulator.c - geometry/geom_cube_manipulator.c - geometry/geom_dial_manipulator.c - manipulator_types/arrow2d_manipulator.c - manipulator_types/arrow3d_manipulator.c - manipulator_types/button2d_manipulator.c - manipulator_types/cage2d_manipulator.c - manipulator_types/cage3d_manipulator.c - manipulator_types/dial3d_manipulator.c - manipulator_types/grab3d_manipulator.c - manipulator_types/primitive3d_manipulator.c -) - -add_definitions(${GL_DEFINITIONS}) - -blender_add_lib(bf_editor_manipulator_library "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/manipulator_library/geometry/geom_arrow_manipulator.c b/source/blender/editors/manipulator_library/geometry/geom_arrow_manipulator.c deleted file mode 100644 index 34f7d73589c..00000000000 --- a/source/blender/editors/manipulator_library/geometry/geom_arrow_manipulator.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file geom_arrow_manipulator.c - * \ingroup wm - */ - -#include "../manipulator_geometry.h" - -static float verts[][3] = { - {-0.000000, 0.012320, 0.000000}, - {-0.000000, 0.012320, 0.974306}, - {0.008711, 0.008711, 0.000000}, - {0.008711, 0.008711, 0.974306}, - {0.012320, -0.000000, 0.000000}, - {0.012320, -0.000000, 0.974306}, - {0.008711, -0.008711, 0.000000}, - {0.008711, -0.008711, 0.974306}, - {-0.000000, -0.012320, 0.000000}, - {-0.000000, -0.012320, 0.974306}, - {-0.008711, -0.008711, 0.000000}, - {-0.008711, -0.008711, 0.974306}, - {-0.012320, 0.000000, 0.000000}, - {-0.012320, 0.000000, 0.974306}, - {-0.008711, 0.008711, 0.000000}, - {-0.008711, 0.008711, 0.974306}, - {0.000000, 0.072555, 0.974306}, - {0.051304, 0.051304, 0.974306}, - {0.072555, -0.000000, 0.974306}, - {0.051304, -0.051304, 0.974306}, - {-0.000000, -0.072555, 0.974306}, - {-0.051304, -0.051304, 0.974306}, - {-0.072555, 0.000000, 0.974306}, - {-0.051304, 0.051304, 0.974306}, - {0.000000, -0.000000, 1.268098}, -}; - -static float normals[][3] = { - {0.000000, 0.776360, -0.630238}, - {0.000000, 0.594348, -0.804163}, - {0.548967, 0.548967, -0.630238}, - {0.420270, 0.420270, -0.804163}, - {0.776360, 0.000000, -0.630238}, - {0.594378, 0.000000, -0.804163}, - {0.548967, -0.548967, -0.630238}, - {0.420270, -0.420270, -0.804163}, - {0.000000, -0.776360, -0.630238}, - {0.000000, -0.594378, -0.804163}, - {-0.548967, -0.548967, -0.630238}, - {-0.420270, -0.420270, -0.804163}, - {-0.776360, 0.000000, -0.630238}, - {-0.594378, 0.000000, -0.804163}, - {-0.548967, 0.548967, -0.630238}, - {-0.420270, 0.420270, -0.804163}, - {0.000000, 0.843226, -0.537492}, - {0.596271, 0.596271, -0.537492}, - {0.843226, 0.000000, -0.537492}, - {0.596271, -0.596271, -0.537492}, - {0.000000, -0.843226, -0.537492}, - {-0.596271, -0.596271, -0.537492}, - {-0.843226, 0.000000, -0.537492}, - {-0.596271, 0.596271, -0.537492}, - {0.000000, 0.000000, 1.000000}, -}; - -static unsigned short indices[] = { - 1, 3, 2, - 3, 5, 4, - 5, 7, 6, - 7, 9, 8, - 9, 11, 10, - 11, 13, 12, - 5, 18, 19, - 15, 1, 0, - 13, 15, 14, - 6, 10, 14, - 11, 21, 22, - 7, 19, 20, - 13, 22, 23, - 3, 17, 18, - 9, 20, 21, - 15, 23, 16, - 1, 16, 17, - 23, 22, 24, - 21, 20, 24, - 19, 18, 24, - 17, 16, 24, - 16, 23, 24, - 22, 21, 24, - 20, 19, 24, - 18, 17, 24, - 0, 1, 2, - 2, 3, 4, - 4, 5, 6, - 6, 7, 8, - 8, 9, 10, - 10, 11, 12, - 7, 5, 19, - 14, 15, 0, - 12, 13, 14, - 14, 0, 2, - 2, 4, 6, - 6, 8, 10, - 10, 12, 14, - 14, 2, 6, - 13, 11, 22, - 9, 7, 20, - 15, 13, 23, - 5, 3, 18, - 11, 9, 21, - 1, 15, 16, - 3, 1, 17, -}; - -ManipulatorGeomInfo wm_manipulator_geom_data_arrow = { - .nverts = 25, - .ntris = 46, - .verts = verts, - .normals = normals, - .indices = indices, -}; diff --git a/source/blender/editors/manipulator_library/geometry/geom_cube_manipulator.c b/source/blender/editors/manipulator_library/geometry/geom_cube_manipulator.c deleted file mode 100644 index cee8e1e22ee..00000000000 --- a/source/blender/editors/manipulator_library/geometry/geom_cube_manipulator.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file geom_cube_manipulator.c - * \ingroup wm - */ - -#include "../manipulator_geometry.h" - -static const float verts[][3] = { - {1.000000, 1.000000, -1.000000}, - {1.000000, -1.000000, -1.000000}, - {-1.000000, -1.000000, -1.000000}, - {-1.000000, 1.000000, -1.000000}, - {1.000000, 1.000000, 1.000000}, - {0.999999, -1.000001, 1.000000}, - {-1.000000, -1.000000, 1.000000}, - {-1.000000, 1.000000, 1.000000}, -}; - -static const float normals[][3] = { - {0.577349, 0.577349, -0.577349}, - {0.577349, -0.577349, -0.577349}, - {-0.577349, -0.577349, -0.577349}, - {-0.577349, 0.577349, -0.577349}, - {0.577349, 0.577349, 0.577349}, - {0.577349, -0.577349, 0.577349}, - {-0.577349, -0.577349, 0.577349}, - {-0.577349, 0.577349, 0.577349}, -}; - -static const unsigned short indices[] = { - 1, 2, 3, - 7, 6, 5, - 4, 5, 1, - 5, 6, 2, - 2, 6, 7, - 0, 3, 7, - 0, 1, 3, - 4, 7, 5, - 0, 4, 1, - 1, 5, 2, - 3, 2, 7, - 4, 0, 7, -}; - -ManipulatorGeomInfo wm_manipulator_geom_data_cube = { - .nverts = 8, - .ntris = 12, - .verts = verts, - .normals = normals, - .indices = indices, -}; diff --git a/source/blender/editors/manipulator_library/geometry/geom_dial_manipulator.c b/source/blender/editors/manipulator_library/geometry/geom_dial_manipulator.c deleted file mode 100644 index 811fc872a81..00000000000 --- a/source/blender/editors/manipulator_library/geometry/geom_dial_manipulator.c +++ /dev/null @@ -1,813 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file geom_dial_manipulator.c - * \ingroup wm - */ - -#include "../manipulator_geometry.h" - -static const float verts[][3] = { - {1.034000, 0.000000, 0.000000}, - {1.017000, 0.000000, 0.029445}, - {0.983000, 0.000000, 0.029445}, - {0.966000, 0.000000, 0.000000}, - {0.983000, 0.000000, -0.029445}, - {1.017000, 0.000000, -0.029445}, - {1.014132, 0.201723, 0.000000}, - {0.997459, 0.198407, 0.029445}, - {0.964112, 0.191774, 0.029445}, - {0.947439, 0.188457, 0.000000}, - {0.964112, 0.191774, -0.029445}, - {0.997459, 0.198407, -0.029445}, - {0.955292, 0.395695, 0.000000}, - {0.939586, 0.389189, 0.029445}, - {0.908174, 0.376178, 0.029445}, - {0.892468, 0.369672, 0.000000}, - {0.908174, 0.376178, -0.029445}, - {0.939586, 0.389189, -0.029445}, - {0.859740, 0.574460, 0.000000}, - {0.845605, 0.565015, 0.029445}, - {0.817335, 0.546126, 0.029445}, - {0.803200, 0.536681, 0.000000}, - {0.817335, 0.546126, -0.029445}, - {0.845605, 0.565015, -0.029445}, - {0.731148, 0.731148, 0.000000}, - {0.719128, 0.719128, 0.029445}, - {0.695086, 0.695086, 0.029445}, - {0.683065, 0.683065, 0.000000}, - {0.695086, 0.695086, -0.029445}, - {0.719128, 0.719128, -0.029445}, - {0.574460, 0.859740, 0.000000}, - {0.565015, 0.845605, 0.029445}, - {0.546125, 0.817335, 0.029445}, - {0.536681, 0.803200, 0.000000}, - {0.546125, 0.817335, -0.029445}, - {0.565015, 0.845605, -0.029445}, - {0.395695, 0.955291, 0.000000}, - {0.389189, 0.939585, 0.029445}, - {0.376178, 0.908173, 0.029445}, - {0.369672, 0.892467, 0.000000}, - {0.376178, 0.908173, -0.029445}, - {0.389189, 0.939585, -0.029445}, - {0.201724, 1.014132, 0.000000}, - {0.198407, 0.997459, 0.029445}, - {0.191774, 0.964112, 0.029445}, - {0.188457, 0.947439, 0.000000}, - {0.191774, 0.964112, -0.029445}, - {0.198407, 0.997459, -0.029445}, - {0.000000, 1.034000, 0.000000}, - {0.000000, 1.017000, 0.029445}, - {0.000000, 0.983000, 0.029445}, - {0.000000, 0.966000, 0.000000}, - {0.000000, 0.983000, -0.029445}, - {0.000000, 1.017000, -0.029445}, - {-0.201723, 1.014132, 0.000000}, - {-0.198407, 0.997459, 0.029445}, - {-0.191774, 0.964112, 0.029445}, - {-0.188457, 0.947439, 0.000000}, - {-0.191774, 0.964112, -0.029445}, - {-0.198407, 0.997459, -0.029445}, - {-0.395695, 0.955291, 0.000000}, - {-0.389189, 0.939585, 0.029445}, - {-0.376178, 0.908174, 0.029445}, - {-0.369672, 0.892468, 0.000000}, - {-0.376178, 0.908174, -0.029445}, - {-0.389189, 0.939585, -0.029445}, - {-0.574459, 0.859740, 0.000000}, - {-0.565015, 0.845605, 0.029445}, - {-0.546125, 0.817335, 0.029445}, - {-0.536681, 0.803200, 0.000000}, - {-0.546125, 0.817335, -0.029445}, - {-0.565015, 0.845605, -0.029445}, - {-0.731149, 0.731148, 0.000000}, - {-0.719128, 0.719127, 0.029445}, - {-0.695086, 0.695086, 0.029445}, - {-0.683065, 0.683065, 0.000000}, - {-0.695086, 0.695086, -0.029445}, - {-0.719128, 0.719127, -0.029445}, - {-0.859740, 0.574460, 0.000000}, - {-0.845604, 0.565015, 0.029445}, - {-0.817335, 0.546126, 0.029445}, - {-0.803200, 0.536681, 0.000000}, - {-0.817335, 0.546126, -0.029445}, - {-0.845604, 0.565015, -0.029445}, - {-0.955291, 0.395695, 0.000000}, - {-0.939585, 0.389189, 0.029445}, - {-0.908173, 0.376178, 0.029445}, - {-0.892468, 0.369672, 0.000000}, - {-0.908173, 0.376178, -0.029445}, - {-0.939585, 0.389189, -0.029445}, - {-1.014132, 0.201723, 0.000000}, - {-0.997459, 0.198407, 0.029445}, - {-0.964112, 0.191774, 0.029445}, - {-0.947439, 0.188457, 0.000000}, - {-0.964112, 0.191774, -0.029445}, - {-0.997459, 0.198407, -0.029445}, - {-1.034000, 0.000000, 0.000000}, - {-1.017000, 0.000000, 0.029445}, - {-0.983000, 0.000000, 0.029445}, - {-0.966000, 0.000000, 0.000000}, - {-0.983000, 0.000000, -0.029445}, - {-1.017000, 0.000000, -0.029445}, - {-1.014132, -0.201723, 0.000000}, - {-0.997459, -0.198407, 0.029445}, - {-0.964112, -0.191774, 0.029445}, - {-0.947439, -0.188457, 0.000000}, - {-0.964112, -0.191774, -0.029445}, - {-0.997459, -0.198407, -0.029445}, - {-0.955292, -0.395694, 0.000000}, - {-0.939586, -0.389189, 0.029445}, - {-0.908174, -0.376177, 0.029445}, - {-0.892468, -0.369672, 0.000000}, - {-0.908174, -0.376177, -0.029445}, - {-0.939586, -0.389189, -0.029445}, - {-0.859740, -0.574460, 0.000000}, - {-0.845604, -0.565015, 0.029445}, - {-0.817335, -0.546126, 0.029445}, - {-0.803200, -0.536681, 0.000000}, - {-0.817335, -0.546126, -0.029445}, - {-0.845604, -0.565015, -0.029445}, - {-0.731149, -0.731148, 0.000000}, - {-0.719128, -0.719127, 0.029445}, - {-0.695086, -0.695086, 0.029445}, - {-0.683065, -0.683065, 0.000000}, - {-0.695086, -0.695086, -0.029445}, - {-0.719128, -0.719127, -0.029445}, - {-0.574460, -0.859739, 0.000000}, - {-0.565015, -0.845604, 0.029445}, - {-0.546126, -0.817334, 0.029445}, - {-0.536681, -0.803199, 0.000000}, - {-0.546126, -0.817334, -0.029445}, - {-0.565015, -0.845604, -0.029445}, - {-0.395695, -0.955291, 0.000000}, - {-0.389189, -0.939585, 0.029445}, - {-0.376178, -0.908174, 0.029445}, - {-0.369672, -0.892468, 0.000000}, - {-0.376178, -0.908174, -0.029445}, - {-0.389189, -0.939585, -0.029445}, - {-0.201724, -1.014132, 0.000000}, - {-0.198407, -0.997459, 0.029445}, - {-0.191774, -0.964112, 0.029445}, - {-0.188458, -0.947438, 0.000000}, - {-0.191774, -0.964112, -0.029445}, - {-0.198407, -0.997459, -0.029445}, - {0.000000, -1.034000, 0.000000}, - {0.000000, -1.017000, 0.029445}, - {0.000000, -0.983000, 0.029445}, - {0.000000, -0.966000, 0.000000}, - {0.000000, -0.983000, -0.029445}, - {0.000000, -1.017000, -0.029445}, - {0.201723, -1.014132, 0.000000}, - {0.198407, -0.997459, 0.029445}, - {0.191773, -0.964112, 0.029445}, - {0.188457, -0.947439, 0.000000}, - {0.191773, -0.964112, -0.029445}, - {0.198407, -0.997459, -0.029445}, - {0.395695, -0.955291, 0.000000}, - {0.389189, -0.939585, 0.029445}, - {0.376178, -0.908173, 0.029445}, - {0.369672, -0.892467, 0.000000}, - {0.376178, -0.908173, -0.029445}, - {0.389189, -0.939585, -0.029445}, - {0.574460, -0.859740, 0.000000}, - {0.565015, -0.845605, 0.029445}, - {0.546125, -0.817335, 0.029445}, - {0.536681, -0.803200, 0.000000}, - {0.546125, -0.817335, -0.029445}, - {0.565015, -0.845605, -0.029445}, - {0.731148, -0.731149, 0.000000}, - {0.719127, -0.719128, 0.029445}, - {0.695086, -0.695086, 0.029445}, - {0.683065, -0.683066, 0.000000}, - {0.695086, -0.695086, -0.029445}, - {0.719127, -0.719128, -0.029445}, - {0.859740, -0.574460, 0.000000}, - {0.845605, -0.565015, 0.029445}, - {0.817335, -0.546126, 0.029445}, - {0.803200, -0.536681, 0.000000}, - {0.817335, -0.546126, -0.029445}, - {0.845605, -0.565015, -0.029445}, - {0.955291, -0.395695, 0.000000}, - {0.939585, -0.389189, 0.029445}, - {0.908173, -0.376178, 0.029445}, - {0.892467, -0.369673, 0.000000}, - {0.908173, -0.376178, -0.029445}, - {0.939585, -0.389189, -0.029445}, - {1.014132, -0.201723, 0.000000}, - {0.997459, -0.198407, 0.029445}, - {0.964112, -0.191774, 0.029445}, - {0.947439, -0.188457, 0.000000}, - {0.964112, -0.191774, -0.029445}, - {0.997459, -0.198407, -0.029445}, -}; - -static const float normals[][3] = { - {1.000000, 0.000000, 0.000000}, - {0.522691, 0.000000, 0.852504}, - {-0.475845, 0.000000, 0.879513}, - {-1.000000, 0.000000, 0.000000}, - {-0.475845, 0.000000, -0.879513}, - {0.522691, 0.000000, -0.852504}, - {0.980773, 0.195074, 0.000000}, - {0.512650, 0.101962, 0.852504}, - {-0.466689, -0.092807, 0.879513}, - {-0.980773, -0.195074, 0.000000}, - {-0.466689, -0.092807, -0.879513}, - {0.512650, 0.101962, -0.852504}, - {0.923856, 0.382672, 0.000000}, - {0.482894, 0.200018, 0.852504}, - {-0.439619, -0.182073, 0.879513}, - {-0.923856, -0.382672, 0.000000}, - {-0.439619, -0.182073, -0.879513}, - {0.482894, 0.200018, -0.852504}, - {0.831446, 0.555559, 0.000000}, - {0.434614, 0.290384, 0.852504}, - {-0.395642, -0.264351, 0.879513}, - {-0.831446, -0.555559, 0.000000}, - {-0.395642, -0.264351, -0.879513}, - {0.434614, 0.290384, -0.852504}, - {0.707083, 0.707083, 0.000000}, - {0.369610, 0.369610, 0.852504}, - {-0.336467, -0.336467, 0.879513}, - {-0.707083, -0.707083, 0.000000}, - {-0.336467, -0.336467, -0.879513}, - {0.369610, 0.369610, -0.852504}, - {0.555559, 0.831446, 0.000000}, - {0.290384, 0.434614, 0.852504}, - {-0.264351, -0.395642, 0.879513}, - {-0.555559, -0.831446, 0.000000}, - {-0.264351, -0.395642, -0.879513}, - {0.290384, 0.434614, -0.852504}, - {0.382672, 0.923856, 0.000000}, - {0.200018, 0.482894, 0.852504}, - {-0.182073, -0.439619, 0.879513}, - {-0.382672, -0.923856, 0.000000}, - {-0.182073, -0.439619, -0.879513}, - {0.200018, 0.482894, -0.852504}, - {0.195074, 0.980773, 0.000000}, - {0.101962, 0.512650, 0.852504}, - {-0.092807, -0.466689, 0.879513}, - {-0.195074, -0.980773, 0.000000}, - {-0.092807, -0.466689, -0.879513}, - {0.101962, 0.512650, -0.852504}, - {0.000000, 1.000000, 0.000000}, - {0.000000, 0.522691, 0.852504}, - {0.000000, -0.475845, 0.879513}, - {0.000000, -1.000000, 0.000000}, - {0.000000, -0.475845, -0.879513}, - {0.000000, 0.522691, -0.852504}, - {-0.195074, 0.980773, 0.000000}, - {-0.101962, 0.512650, 0.852504}, - {0.092807, -0.466689, 0.879513}, - {0.195074, -0.980773, 0.000000}, - {0.092807, -0.466689, -0.879513}, - {-0.101962, 0.512650, -0.852504}, - {-0.382672, 0.923856, 0.000000}, - {-0.200018, 0.482894, 0.852504}, - {0.182073, -0.439619, 0.879513}, - {0.382672, -0.923856, 0.000000}, - {0.182073, -0.439619, -0.879513}, - {-0.200018, 0.482894, -0.852504}, - {-0.555559, 0.831446, 0.000000}, - {-0.290384, 0.434614, 0.852504}, - {0.264351, -0.395642, 0.879513}, - {0.555559, -0.831446, 0.000000}, - {0.264351, -0.395642, -0.879513}, - {-0.290384, 0.434614, -0.852504}, - {-0.707083, 0.707083, 0.000000}, - {-0.369610, 0.369610, 0.852504}, - {0.336467, -0.336467, 0.879513}, - {0.707083, -0.707083, 0.000000}, - {0.336467, -0.336467, -0.879513}, - {-0.369610, 0.369610, -0.852504}, - {-0.831446, 0.555559, 0.000000}, - {-0.434614, 0.290384, 0.852504}, - {0.395642, -0.264351, 0.879513}, - {0.831446, -0.555559, 0.000000}, - {0.395642, -0.264351, -0.879513}, - {-0.434614, 0.290384, -0.852504}, - {-0.923856, 0.382672, 0.000000}, - {-0.482894, 0.200018, 0.852504}, - {0.439619, -0.182073, 0.879513}, - {0.923856, -0.382672, 0.000000}, - {0.439619, -0.182073, -0.879513}, - {-0.482894, 0.200018, -0.852504}, - {-0.980773, 0.195074, 0.000000}, - {-0.512650, 0.101962, 0.852504}, - {0.466689, -0.092807, 0.879513}, - {0.980773, -0.195074, 0.000000}, - {0.466689, -0.092807, -0.879513}, - {-0.512650, 0.101962, -0.852504}, - {-1.000000, 0.000000, 0.000000}, - {-0.522691, 0.000000, 0.852504}, - {0.475845, 0.000000, 0.879513}, - {1.000000, 0.000000, 0.000000}, - {0.475845, 0.000000, -0.879513}, - {-0.522691, 0.000000, -0.852504}, - {-0.980773, -0.195074, 0.000000}, - {-0.512650, -0.101962, 0.852504}, - {0.466689, 0.092807, 0.879513}, - {0.980773, 0.195074, 0.000000}, - {0.466689, 0.092807, -0.879513}, - {-0.512650, -0.101962, -0.852504}, - {-0.923856, -0.382672, 0.000000}, - {-0.482894, -0.200018, 0.852504}, - {0.439619, 0.182073, 0.879513}, - {0.923856, 0.382672, 0.000000}, - {0.439619, 0.182073, -0.879513}, - {-0.482894, -0.200018, -0.852504}, - {-0.831446, -0.555559, 0.000000}, - {-0.434614, -0.290384, 0.852504}, - {0.395642, 0.264351, 0.879513}, - {0.831446, 0.555559, 0.000000}, - {0.395642, 0.264351, -0.879513}, - {-0.434614, -0.290384, -0.852504}, - {-0.707083, -0.707083, 0.000000}, - {-0.369610, -0.369610, 0.852504}, - {0.336467, 0.336467, 0.879513}, - {0.707083, 0.707083, 0.000000}, - {0.336467, 0.336467, -0.879513}, - {-0.369610, -0.369610, -0.852504}, - {-0.555559, -0.831446, 0.000000}, - {-0.290384, -0.434614, 0.852504}, - {0.264351, 0.395642, 0.879513}, - {0.555559, 0.831446, 0.000000}, - {0.264351, 0.395642, -0.879513}, - {-0.290384, -0.434614, -0.852504}, - {-0.382672, -0.923856, 0.000000}, - {-0.200018, -0.482894, 0.852504}, - {0.182073, 0.439619, 0.879513}, - {0.382672, 0.923856, 0.000000}, - {0.182073, 0.439619, -0.879513}, - {-0.200018, -0.482894, -0.852504}, - {-0.195074, -0.980773, 0.000000}, - {-0.101962, -0.512650, 0.852504}, - {0.092807, 0.466689, 0.879513}, - {0.195074, 0.980773, 0.000000}, - {0.092807, 0.466689, -0.879513}, - {-0.101962, -0.512650, -0.852504}, - {0.000000, -1.000000, 0.000000}, - {0.000000, -0.522691, 0.852504}, - {0.000000, 0.475845, 0.879513}, - {0.000000, 1.000000, 0.000000}, - {0.000000, 0.475845, -0.879513}, - {0.000000, -0.522691, -0.852504}, - {0.195074, -0.980773, 0.000000}, - {0.101962, -0.512650, 0.852504}, - {-0.092807, 0.466689, 0.879513}, - {-0.195074, 0.980773, 0.000000}, - {-0.092807, 0.466689, -0.879513}, - {0.101962, -0.512650, -0.852504}, - {0.382672, -0.923856, 0.000000}, - {0.200018, -0.482894, 0.852504}, - {-0.182073, 0.439619, 0.879513}, - {-0.382672, 0.923856, 0.000000}, - {-0.182073, 0.439619, -0.879513}, - {0.200018, -0.482894, -0.852504}, - {0.555559, -0.831446, 0.000000}, - {0.290384, -0.434614, 0.852504}, - {-0.264351, 0.395642, 0.879513}, - {-0.555559, 0.831446, 0.000000}, - {-0.264351, 0.395642, -0.879513}, - {0.290384, -0.434614, -0.852504}, - {0.707083, -0.707083, 0.000000}, - {0.369610, -0.369610, 0.852504}, - {-0.336467, 0.336467, 0.879513}, - {-0.707083, 0.707083, 0.000000}, - {-0.336467, 0.336467, -0.879513}, - {0.369610, -0.369610, -0.852504}, - {0.831446, -0.555559, 0.000000}, - {0.434614, -0.290384, 0.852504}, - {-0.395642, 0.264351, 0.879513}, - {-0.831446, 0.555559, 0.000000}, - {-0.395642, 0.264351, -0.879513}, - {0.434614, -0.290384, -0.852504}, - {0.923856, -0.382672, 0.000000}, - {0.482894, -0.200018, 0.852504}, - {-0.439619, 0.182073, 0.879513}, - {-0.923856, 0.382672, 0.000000}, - {-0.439619, 0.182073, -0.879513}, - {0.482894, -0.200018, -0.852504}, - {0.980773, -0.195074, 0.000000}, - {0.512650, -0.101962, 0.852504}, - {-0.466689, 0.092807, 0.879513}, - {-0.980773, 0.195074, 0.000000}, - {-0.466689, 0.092807, -0.879513}, - {0.512650, -0.101962, -0.852504}, -}; - -static const unsigned short indices[] = { - 6, 7, 1, - 7, 8, 2, - 8, 9, 3, - 9, 10, 4, - 10, 11, 5, - 5, 11, 6, - 12, 13, 7, - 13, 14, 8, - 14, 15, 9, - 15, 16, 10, - 16, 17, 11, - 11, 17, 12, - 18, 19, 13, - 13, 19, 20, - 20, 21, 15, - 15, 21, 22, - 22, 23, 17, - 17, 23, 18, - 24, 25, 19, - 19, 25, 26, - 26, 27, 21, - 21, 27, 28, - 28, 29, 23, - 23, 29, 24, - 30, 31, 25, - 25, 31, 32, - 26, 32, 33, - 27, 33, 34, - 34, 35, 29, - 29, 35, 30, - 36, 37, 31, - 31, 37, 38, - 38, 39, 33, - 39, 40, 34, - 40, 41, 35, - 35, 41, 36, - 36, 42, 43, - 43, 44, 38, - 44, 45, 39, - 45, 46, 40, - 46, 47, 41, - 47, 42, 36, - 48, 49, 43, - 49, 50, 44, - 50, 51, 45, - 51, 52, 46, - 52, 53, 47, - 47, 53, 48, - 54, 55, 49, - 49, 55, 56, - 50, 56, 57, - 57, 58, 52, - 58, 59, 53, - 53, 59, 54, - 60, 61, 55, - 55, 61, 62, - 56, 62, 63, - 63, 64, 58, - 64, 65, 59, - 59, 65, 60, - 66, 67, 61, - 61, 67, 68, - 68, 69, 63, - 69, 70, 64, - 70, 71, 65, - 71, 66, 60, - 72, 73, 67, - 73, 74, 68, - 68, 74, 75, - 75, 76, 70, - 76, 77, 71, - 71, 77, 72, - 78, 79, 73, - 79, 80, 74, - 74, 80, 81, - 81, 82, 76, - 82, 83, 77, - 83, 78, 72, - 78, 84, 85, - 85, 86, 80, - 80, 86, 87, - 87, 88, 82, - 82, 88, 89, - 89, 84, 78, - 90, 91, 85, - 91, 92, 86, - 86, 92, 93, - 93, 94, 88, - 88, 94, 95, - 95, 90, 84, - 96, 97, 91, - 97, 98, 92, - 98, 99, 93, - 99, 100, 94, - 100, 101, 95, - 101, 96, 90, - 102, 103, 97, - 103, 104, 98, - 104, 105, 99, - 99, 105, 106, - 106, 107, 101, - 101, 107, 102, - 108, 109, 103, - 103, 109, 110, - 110, 111, 105, - 105, 111, 112, - 112, 113, 107, - 107, 113, 108, - 114, 115, 109, - 115, 116, 110, - 116, 117, 111, - 111, 117, 118, - 112, 118, 119, - 113, 119, 114, - 114, 120, 121, - 121, 122, 116, - 122, 123, 117, - 117, 123, 124, - 124, 125, 119, - 125, 120, 114, - 126, 127, 121, - 121, 127, 128, - 128, 129, 123, - 123, 129, 130, - 130, 131, 125, - 125, 131, 126, - 132, 133, 127, - 133, 134, 128, - 128, 134, 135, - 135, 136, 130, - 136, 137, 131, - 131, 137, 132, - 132, 138, 139, - 133, 139, 140, - 134, 140, 141, - 141, 142, 136, - 142, 143, 137, - 143, 138, 132, - 138, 144, 145, - 139, 145, 146, - 146, 147, 141, - 141, 147, 148, - 148, 149, 143, - 149, 144, 138, - 144, 150, 151, - 151, 152, 146, - 146, 152, 153, - 153, 154, 148, - 154, 155, 149, - 155, 150, 144, - 156, 157, 151, - 151, 157, 158, - 158, 159, 153, - 159, 160, 154, - 160, 161, 155, - 155, 161, 156, - 156, 162, 163, - 163, 164, 158, - 158, 164, 165, - 165, 166, 160, - 160, 166, 167, - 167, 162, 156, - 162, 168, 169, - 169, 170, 164, - 164, 170, 171, - 165, 171, 172, - 166, 172, 173, - 173, 168, 162, - 174, 175, 169, - 175, 176, 170, - 170, 176, 177, - 177, 178, 172, - 172, 178, 179, - 173, 179, 174, - 174, 180, 181, - 181, 182, 176, - 176, 182, 183, - 183, 184, 178, - 178, 184, 185, - 179, 185, 180, - 186, 187, 181, - 187, 188, 182, - 188, 189, 183, - 183, 189, 190, - 190, 191, 185, - 191, 186, 180, - 0, 1, 187, - 1, 2, 188, - 2, 3, 189, - 3, 4, 190, - 190, 4, 5, - 191, 5, 0, - 0, 6, 1, - 1, 7, 2, - 2, 8, 3, - 3, 9, 4, - 4, 10, 5, - 0, 5, 6, - 6, 12, 7, - 7, 13, 8, - 8, 14, 9, - 9, 15, 10, - 10, 16, 11, - 6, 11, 12, - 12, 18, 13, - 14, 13, 20, - 14, 20, 15, - 16, 15, 22, - 16, 22, 17, - 12, 17, 18, - 18, 24, 19, - 20, 19, 26, - 20, 26, 21, - 22, 21, 28, - 22, 28, 23, - 18, 23, 24, - 24, 30, 25, - 26, 25, 32, - 27, 26, 33, - 28, 27, 34, - 28, 34, 29, - 24, 29, 30, - 30, 36, 31, - 32, 31, 38, - 32, 38, 33, - 33, 39, 34, - 34, 40, 35, - 30, 35, 36, - 37, 36, 43, - 37, 43, 38, - 38, 44, 39, - 39, 45, 40, - 40, 46, 41, - 41, 47, 36, - 42, 48, 43, - 43, 49, 44, - 44, 50, 45, - 45, 51, 46, - 46, 52, 47, - 42, 47, 48, - 48, 54, 49, - 50, 49, 56, - 51, 50, 57, - 51, 57, 52, - 52, 58, 53, - 48, 53, 54, - 54, 60, 55, - 56, 55, 62, - 57, 56, 63, - 57, 63, 58, - 58, 64, 59, - 54, 59, 60, - 60, 66, 61, - 62, 61, 68, - 62, 68, 63, - 63, 69, 64, - 64, 70, 65, - 65, 71, 60, - 66, 72, 67, - 67, 73, 68, - 69, 68, 75, - 69, 75, 70, - 70, 76, 71, - 66, 71, 72, - 72, 78, 73, - 73, 79, 74, - 75, 74, 81, - 75, 81, 76, - 76, 82, 77, - 77, 83, 72, - 79, 78, 85, - 79, 85, 80, - 81, 80, 87, - 81, 87, 82, - 83, 82, 89, - 83, 89, 78, - 84, 90, 85, - 85, 91, 86, - 87, 86, 93, - 87, 93, 88, - 89, 88, 95, - 89, 95, 84, - 90, 96, 91, - 91, 97, 92, - 92, 98, 93, - 93, 99, 94, - 94, 100, 95, - 95, 101, 90, - 96, 102, 97, - 97, 103, 98, - 98, 104, 99, - 100, 99, 106, - 100, 106, 101, - 96, 101, 102, - 102, 108, 103, - 104, 103, 110, - 104, 110, 105, - 106, 105, 112, - 106, 112, 107, - 102, 107, 108, - 108, 114, 109, - 109, 115, 110, - 110, 116, 111, - 112, 111, 118, - 113, 112, 119, - 108, 113, 114, - 115, 114, 121, - 115, 121, 116, - 116, 122, 117, - 118, 117, 124, - 118, 124, 119, - 119, 125, 114, - 120, 126, 121, - 122, 121, 128, - 122, 128, 123, - 124, 123, 130, - 124, 130, 125, - 120, 125, 126, - 126, 132, 127, - 127, 133, 128, - 129, 128, 135, - 129, 135, 130, - 130, 136, 131, - 126, 131, 132, - 133, 132, 139, - 134, 133, 140, - 135, 134, 141, - 135, 141, 136, - 136, 142, 137, - 137, 143, 132, - 139, 138, 145, - 140, 139, 146, - 140, 146, 141, - 142, 141, 148, - 142, 148, 143, - 143, 149, 138, - 145, 144, 151, - 145, 151, 146, - 147, 146, 153, - 147, 153, 148, - 148, 154, 149, - 149, 155, 144, - 150, 156, 151, - 152, 151, 158, - 152, 158, 153, - 153, 159, 154, - 154, 160, 155, - 150, 155, 156, - 157, 156, 163, - 157, 163, 158, - 159, 158, 165, - 159, 165, 160, - 161, 160, 167, - 161, 167, 156, - 163, 162, 169, - 163, 169, 164, - 165, 164, 171, - 166, 165, 172, - 167, 166, 173, - 167, 173, 162, - 168, 174, 169, - 169, 175, 170, - 171, 170, 177, - 171, 177, 172, - 173, 172, 179, - 168, 173, 174, - 175, 174, 181, - 175, 181, 176, - 177, 176, 183, - 177, 183, 178, - 179, 178, 185, - 174, 179, 180, - 180, 186, 181, - 181, 187, 182, - 182, 188, 183, - 184, 183, 190, - 184, 190, 185, - 185, 191, 180, - 186, 0, 187, - 187, 1, 188, - 188, 2, 189, - 189, 3, 190, - 191, 190, 5, - 186, 191, 0, -}; - -ManipulatorGeomInfo wm_manipulator_geom_data_dial = { - .nverts = 192, - .ntris = 384, - .verts = verts, - .normals = normals, - .indices = indices, -}; diff --git a/source/blender/editors/manipulator_library/manipulator_draw_utils.c b/source/blender/editors/manipulator_library/manipulator_draw_utils.c deleted file mode 100644 index 80181c57115..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_draw_utils.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file manipulator_draw_utils.c - * \ingroup wm - */ - -#include "BLI_listbase.h" -#include "BLI_ghash.h" -#include "BLI_math.h" -#include "BLI_string.h" -#include "BLI_string_utils.h" - -#include "BKE_context.h" - -#include "ED_screen.h" -#include "ED_view3d.h" - -#include "GPU_batch.h" -#include "GPU_glew.h" -#include "GPU_immediate.h" -#include "GPU_state.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ -#include "wm.h" - -/* own includes */ -#include "manipulator_library_intern.h" - -/** - * Main draw call for ManipulatorGeomInfo data - */ -void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const bool UNUSED(select), const float color[4]) -{ - /* TODO store the Batches inside the ManipulatorGeomInfo and updated it when geom changes - * So we don't need to re-created and discard it every time */ - - Gwn_VertBuf *vbo; - Gwn_IndexBuf *el; - Gwn_Batch *batch; - Gwn_IndexBufBuilder elb = {0}; - - Gwn_VertFormat format = {0}; - uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - - /* Elements */ - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, info->ntris, info->nverts); - for (int i = 0; i < info->ntris; ++i) { - const unsigned short *idx = &info->indices[i * 3]; - GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]); - } - el = GWN_indexbuf_build(&elb); - - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, info->nverts); - - GWN_vertbuf_attr_fill(vbo, pos_id, info->verts); - - batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, el, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); - - GWN_batch_uniform_4fv(batch, "color", color); - - /* We may want to re-visit this, for now disable - * since it causes issues leaving the GL state modified. */ -#if 0 - glEnable(GL_CULL_FACE); - GPU_depth_test(true); -#endif - - GWN_batch_draw(batch); - -#if 0 - GPU_depth_test(false); - glDisable(GL_CULL_FACE); -#endif - - - GWN_batch_discard(batch); -} - -void wm_manipulator_vec_draw( - const float color[4], const float (*verts)[3], uint vert_count, - uint pos, uint primitive_type) -{ - immUniformColor4fv(color); - immBegin(primitive_type, vert_count); - for (int i = 0; i < vert_count; i++) { - immVertex3fv(pos, verts[i]); - } - immEnd(); -} diff --git a/source/blender/editors/manipulator_library/manipulator_geometry.h b/source/blender/editors/manipulator_library/manipulator_geometry.h deleted file mode 100644 index 2083f9d4d31..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_geometry.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file manipulator_geometry.h - * \ingroup wm - * - * \name Manipulator Geometry - * - * \brief Prototypes for arrays defining the manipulator geometry. The actual definitions can be found in files usually - * called geom_xxx_manipulator.c - */ - - -#ifndef __MANIPULATOR_GEOMETRY_H__ -#define __MANIPULATOR_GEOMETRY_H__ - -typedef struct ManipulatorGeomInfo { - int nverts; - int ntris; - const float (*verts)[3]; - const float (*normals)[3]; - const unsigned short *indices; -} ManipulatorGeomInfo; - -/* arrow manipulator */ -extern ManipulatorGeomInfo wm_manipulator_geom_data_arrow; - -/* cube manipulator */ -extern ManipulatorGeomInfo wm_manipulator_geom_data_cube; - -/* dial manipulator */ -extern ManipulatorGeomInfo wm_manipulator_geom_data_dial; - -#endif /* __MANIPULATOR_GEOMETRY_H__ */ diff --git a/source/blender/editors/manipulator_library/manipulator_library_intern.h b/source/blender/editors/manipulator_library/manipulator_library_intern.h deleted file mode 100644 index 55db99236e0..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_library_intern.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file manipulator_library_intern.h - * \ingroup wm - */ - -#ifndef __MANIPULATOR_LIBRARY_INTERN_H__ -#define __MANIPULATOR_LIBRARY_INTERN_H__ - -/* distance around which manipulators respond to input (and get highlighted) */ -#define MANIPULATOR_HOTSPOT 14.0f - -/** - * Data for common interactions. Used in manipulator_library_utils.c functions. - */ -typedef struct ManipulatorCommonData { - int flag; - - float range_fac; /* factor for arrow min/max distance */ - float offset; - - /* property range for constrained manipulators */ - float range; - /* min/max value for constrained manipulators */ - float min, max; -} ManipulatorCommonData; - -typedef struct ManipulatorInteraction { - float init_value; /* initial property value */ - float init_mval[2]; - float init_offset; - float init_matrix_final[4][4]; - float init_matrix_basis[4][4]; - - /* offset of last handling step */ - float prev_offset; - /* Total offset added by precision tweaking. - * Needed to allow toggling precision on/off without causing jumps */ - float precision_offset; -} ManipulatorInteraction; - -/* ManipulatorCommonData->flag */ -enum { - MANIPULATOR_CUSTOM_RANGE_SET = (1 << 0), -}; - - -float manipulator_offset_from_value( - ManipulatorCommonData *data, const float value, - const bool constrained, const bool inverted); -float manipulator_value_from_offset( - ManipulatorCommonData *data, ManipulatorInteraction *inter, const float offset, - const bool constrained, const bool inverted, const bool use_precision); - -void manipulator_property_data_update( - struct wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, - const bool constrained, const bool inverted); - -void manipulator_property_value_reset( - bContext *C, const struct wmManipulator *mpr, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop); - - -/* -------------------------------------------------------------------- */ - -void manipulator_color_get( - const struct wmManipulator *mpr, const bool highlight, - float r_color[4]); - -bool manipulator_window_project_2d( - bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset, - float r_co[2]); - -bool manipulator_window_project_3d( - bContext *C, const struct wmManipulator *mpr, const float mval[2], bool use_offset, - float r_co[3]); - -/* -------------------------------------------------------------------- */ -/* Manipulator drawing */ - -#include "manipulator_geometry.h" - -void wm_manipulator_geometryinfo_draw(const struct ManipulatorGeomInfo *info, const bool select, const float color[4]); -void wm_manipulator_vec_draw( - const float color[4], const float (*verts)[3], uint vert_count, - uint pos, uint primitive_type); - - -#endif /* __MANIPULATOR_LIBRARY_INTERN_H__ */ diff --git a/source/blender/editors/manipulator_library/manipulator_library_presets.c b/source/blender/editors/manipulator_library/manipulator_library_presets.c deleted file mode 100644 index 12f07611722..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_library_presets.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/manipulator_library/manipulator_library_presets.c - * \ingroup wm - * - * \name Manipulator Lib Presets - * - * \brief Preset shapes that can be drawn from any manipulator type. - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" - -#include "DNA_view3d_types.h" -#include "DNA_object_types.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" - -#include "GPU_draw.h" -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_matrix.h" -#include "GPU_select.h" - -#include "DEG_depsgraph.h" - -#include "RNA_access.h" - -#include "WM_types.h" -#include "WM_api.h" - -#include "ED_view3d.h" -#include "ED_screen.h" - -/* own includes */ -#include "ED_manipulator_library.h" /* own include */ -#include "manipulator_library_intern.h" /* own include */ - -/* TODO, this is to be used by RNA. might move to ED_manipulator_library */ - -/** - * Given a single axis, orient the matrix to a different direction. - */ -static void single_axis_convert( - int src_axis, float src_mat[4][4], - int dst_axis, float dst_mat[4][4]) -{ - copy_m4_m4(dst_mat, src_mat); - if (src_axis == dst_axis) { - return; - } - - float rotmat[3][3]; - mat3_from_axis_conversion_single(src_axis, dst_axis, rotmat); - transpose_m3(rotmat); - mul_m4_m4m3(dst_mat, src_mat, rotmat); -} - -/** - * Use for all geometry. - */ -static void ed_manipulator_draw_preset_geometry( - const struct wmManipulator *mpr, float mat[4][4], int select_id, - const ManipulatorGeomInfo *info) -{ - const bool is_select = (select_id != -1); - const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - - float color[4]; - manipulator_color_get(mpr, is_highlight, color); - - if (is_select) { - GPU_select_load_id(select_id); - } - - gpuPushMatrix(); - gpuMultMatrix(mat); - wm_manipulator_geometryinfo_draw(info, is_select, color); - gpuPopMatrix(); - - if (is_select) { - GPU_select_load_id(-1); - } -} - -void ED_manipulator_draw_preset_box( - const struct wmManipulator *mpr, float mat[4][4], int select_id) -{ - ed_manipulator_draw_preset_geometry(mpr, mat, select_id, &wm_manipulator_geom_data_cube); -} - -void ED_manipulator_draw_preset_arrow( - const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) -{ - float mat_rotate[4][4]; - single_axis_convert(OB_POSZ, mat, axis, mat_rotate); - ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_manipulator_geom_data_arrow); -} - -void ED_manipulator_draw_preset_circle( - const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) -{ - float mat_rotate[4][4]; - single_axis_convert(OB_POSZ, mat, axis, mat_rotate); - ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_manipulator_geom_data_dial); -} - -void ED_manipulator_draw_preset_facemap( - const bContext *C, const struct wmManipulator *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id) -{ - const bool is_select = (select_id != -1); - const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - - float color[4]; - manipulator_color_get(mpr, is_highlight, color); - - if (is_select) { - GPU_select_load_id(select_id); - } - - gpuPushMatrix(); - gpuMultMatrix(ob->obmat); - ED_draw_object_facemap(CTX_data_depsgraph(C), scene, ob, color, facemap); - gpuPopMatrix(); - - if (is_select) { - GPU_select_load_id(-1); - } -} diff --git a/source/blender/editors/manipulator_library/manipulator_library_utils.c b/source/blender/editors/manipulator_library/manipulator_library_utils.c deleted file mode 100644 index 957f0abdd71..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_library_utils.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2015 Blender Foundation. - * All rights reserved. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file manipulator_library_utils.c - * \ingroup wm - * - * \name Manipulator Library Utilities - * - * \brief This file contains functions for common behaviors of manipulators. - */ - -#include "BLI_math.h" -#include "BLI_listbase.h" - -#include "DNA_view3d_types.h" -#include "DNA_screen_types.h" - -#include "BKE_context.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_view3d.h" - -/* own includes */ -#include "manipulator_library_intern.h" - -/* factor for precision tweaking */ -#define MANIPULATOR_PRECISION_FAC 0.05f - - -BLI_INLINE float manipulator_offset_from_value_constr( - const float range_fac, const float min, const float range, const float value, - const bool inverted) -{ - return inverted ? (range_fac * (min + range - value) / range) : (range_fac * (value / range)); -} - -BLI_INLINE float manipulator_value_from_offset_constr( - const float range_fac, const float min, const float range, const float value, - const bool inverted) -{ - return inverted ? (min + range - (value * range / range_fac)) : (value * range / range_fac); -} - -float manipulator_offset_from_value( - ManipulatorCommonData *data, const float value, const bool constrained, const bool inverted) -{ - if (constrained) - return manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); - - return value; -} - -float manipulator_value_from_offset( - ManipulatorCommonData *data, ManipulatorInteraction *inter, const float offset, - const bool constrained, const bool inverted, const bool use_precision) -{ - const float max = data->min + data->range; - - if (use_precision) { - /* add delta offset of this step to total precision_offset */ - inter->precision_offset += offset - inter->prev_offset; - } - inter->prev_offset = offset; - - float ofs_new = inter->init_offset + offset - inter->precision_offset * (1.0f - MANIPULATOR_PRECISION_FAC); - float value; - - if (constrained) { - value = manipulator_value_from_offset_constr(data->range_fac, data->min, data->range, ofs_new, inverted); - } - else { - value = ofs_new; - } - - /* clamp to custom range */ - if (data->flag & MANIPULATOR_CUSTOM_RANGE_SET) { - CLAMP(value, data->min, max); - } - - return value; -} - -void manipulator_property_data_update( - wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, - const bool constrained, const bool inverted) -{ - if (mpr_prop->custom_func.value_get_fn != NULL) { - /* pass */ - } - else if (mpr_prop->prop != NULL) { - /* pass */ - } - else { - data->offset = 0.0f; - return; - } - - float value = WM_manipulator_target_property_value_get(mpr, mpr_prop); - - if (constrained) { - if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) { - float range[2]; - if (WM_manipulator_target_property_range_get(mpr, mpr_prop, range)) { - data->range = range[1] - range[0]; - data->min = range[0]; - } - else { - BLI_assert(0); - } - } - data->offset = manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); - } - else { - data->offset = value; - } -} - -void manipulator_property_value_reset( - bContext *C, const wmManipulator *mpr, ManipulatorInteraction *inter, - wmManipulatorProperty *mpr_prop) -{ - WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_value); -} - -/* -------------------------------------------------------------------- */ - -void manipulator_color_get( - const wmManipulator *mpr, const bool highlight, - float r_col[4]) -{ - if (highlight && !(mpr->flag & WM_MANIPULATOR_DRAW_HOVER)) { - copy_v4_v4(r_col, mpr->color_hi); - } - else { - copy_v4_v4(r_col, mpr->color); - } -} - -/* -------------------------------------------------------------------- */ - -/** - * Takes mouse coordinates and returns them in relation to the manipulator. - * Both 2D & 3D supported, use so we can use 2D manipulators in the 3D view. - */ -bool manipulator_window_project_2d( - bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset, - float r_co[2]) -{ - float mat[4][4]; - { - float mat_identity[4][4]; - struct WM_ManipulatorMatrixParams params = {NULL}; - if (use_offset == false) { - unit_m4(mat_identity); - params.matrix_offset = mat_identity; - } - WM_manipulator_calc_matrix_final_params(mpr, ¶ms, mat); - } - - /* rotate mouse in relation to the center and relocate it */ - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - /* For 3d views, transform 2D mouse pos onto plane. */ - View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - - float plane[4]; - - plane_from_point_normal_v3(plane, mat[3], mat[2]); - - float ray_origin[3], ray_direction[3]; - - if (ED_view3d_win_to_ray(CTX_data_depsgraph(C), ar, v3d, mval, ray_origin, ray_direction, false)) { - float lambda; - if (isect_ray_plane_v3(ray_origin, ray_direction, plane, &lambda, true)) { - float co[3]; - madd_v3_v3v3fl(co, ray_origin, ray_direction, lambda); - float imat[4][4]; - invert_m4_m4(imat, mat); - mul_m4_v3(imat, co); - r_co[0] = co[(axis + 1) % 3]; - r_co[1] = co[(axis + 2) % 3]; - return true; - } - } - return false; - } - else { - float co[3] = {mval[0], mval[1], 0.0f}; - float imat[4][4]; - invert_m4_m4(imat, mat); - mul_mat3_m4_v3(imat, co); - copy_v2_v2(r_co, co); - return true; - } -} - -bool manipulator_window_project_3d( - bContext *C, const struct wmManipulator *mpr, const float mval[2], bool use_offset, - float r_co[3]) -{ - float mat[4][4]; - { - float mat_identity[4][4]; - struct WM_ManipulatorMatrixParams params = {NULL}; - if (use_offset == false) { - unit_m4(mat_identity); - params.matrix_offset = mat_identity; - } - WM_manipulator_calc_matrix_final_params(mpr, ¶ms, mat); - } - - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - /* Note: we might want a custom reference point passed in, - * instead of the manipulator center. */ - ED_view3d_win_to_3d(v3d, ar, mat[3], mval, r_co); - invert_m4(mat); - mul_m4_v3(mat, r_co); - return true; - } - else { - float co[3] = {mval[0], mval[1], 0.0f}; - float imat[4][4]; - invert_m4_m4(imat, mat); - mul_m4_v3(imat, co); - copy_v2_v2(r_co, co); - return true; - } -} diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c deleted file mode 100644 index 5acf1ab2d64..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file arrow2d_manipulator.c - * \ingroup wm - * - * \name 2D Arrow Manipulator - * - * \brief Simple arrow manipulator which is dragged into a certain direction. - */ - -#include "BLI_listbase.h" -#include "BLI_math.h" -#include "BLI_rect.h" - -#include "DNA_windowmanager_types.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" - -#include "GPU_draw.h" -#include "GPU_immediate.h" -#include "GPU_matrix.h" -#include "GPU_state.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_types.h" - -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -/* own includes */ -#include "WM_api.h" - -#include "../manipulator_library_intern.h" - -static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], const float color[4]) -{ - const float size = 0.11f; - const float size_breadth = size / 2.0f; - const float size_length = size * 1.7f; - /* Subtract the length so the arrow fits in the hotspot. */ - const float arrow_length = RNA_float_get(mpr->ptr, "length") - size_length; - const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); - - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - gpuPushMatrix(); - gpuMultMatrix(matrix); - gpuRotate2D(RAD2DEGF(arrow_angle)); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - - immUniformColor4fv(color); - - immBegin(GWN_PRIM_LINES, 2); - immVertex2f(pos, 0.0f, 0.0f); - immVertex2f(pos, 0.0f, arrow_length); - immEnd(); - - immBegin(GWN_PRIM_TRIS, 3); - immVertex2f(pos, size_breadth, arrow_length); - immVertex2f(pos, -size_breadth, arrow_length); - immVertex2f(pos, 0.0f, arrow_length + size_length); - immEnd(); - - immUnbindProgram(); - - gpuPopMatrix(); -} - -static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *mpr) -{ - float color[4]; - - float matrix_final[4][4]; - - manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, color); - - GPU_line_width(mpr->line_width); - - WM_manipulator_calc_matrix_final(mpr, matrix_final); - - GPU_blend(true); - arrow2d_draw_geom(mpr, matrix_final, color); - GPU_blend(false); - - if (mpr->interaction_data) { - ManipulatorInteraction *inter = mpr->interaction_data; - - GPU_blend(true); - arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); - GPU_blend(false); - } -} - -static void manipulator_arrow2d_setup(wmManipulator *mpr) -{ - mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; -} - -static int manipulator_arrow2d_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) -{ - ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); - - copy_m4_m4(inter->init_matrix_basis, mpr->matrix_basis); - WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); - - mpr->interaction_data = inter; - - return OPERATOR_RUNNING_MODAL; -} - -static int manipulator_arrow2d_test_select( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) -{ - const float mval[2] = {event->mval[0], event->mval[1]}; - const float arrow_length = RNA_float_get(mpr->ptr, "length"); - const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); - const float line_len = arrow_length * mpr->scale_final; - float mval_local[2]; - - copy_v2_v2(mval_local, mval); - sub_v2_v2(mval_local, mpr->matrix_basis[3]); - - float line[2][2]; - line[0][0] = line[0][1] = line[1][0] = 0.0f; - line[1][1] = line_len; - - /* rotate only if needed */ - if (arrow_angle != 0.0f) { - float rot_point[2]; - copy_v2_v2(rot_point, line[1]); - rotate_v2_v2fl(line[1], rot_point, arrow_angle); - } - - /* arrow line intersection check */ - float isect_1[2], isect_2[2]; - const int isect = isect_line_sphere_v2( - line[0], line[1], mval_local, MANIPULATOR_HOTSPOT + mpr->line_width * 0.5f, - isect_1, isect_2); - - if (isect > 0) { - float line_ext[2][2]; /* extended line for segment check including hotspot */ - copy_v2_v2(line_ext[0], line[0]); - line_ext[1][0] = line[1][0] + MANIPULATOR_HOTSPOT * ((line[1][0] - line[0][0]) / line_len); - line_ext[1][1] = line[1][1] + MANIPULATOR_HOTSPOT * ((line[1][1] - line[0][1]) / line_len); - - const float lambda_1 = line_point_factor_v2(isect_1, line_ext[0], line_ext[1]); - if (isect == 1) { - if (IN_RANGE_INCL(lambda_1, 0.0f, 1.0f)) { - return 0; - } - } - else { - BLI_assert(isect == 2); - const float lambda_2 = line_point_factor_v2(isect_2, line_ext[0], line_ext[1]); - if (IN_RANGE_INCL(lambda_1, 0.0f, 1.0f) && IN_RANGE_INCL(lambda_2, 0.0f, 1.0f)) { - return 0; - } - } - } - - return -1; -} - -/* -------------------------------------------------------------------- */ -/** \name 2D Arrow Manipulator API - * - * \{ */ - -static void MANIPULATOR_WT_arrow_2d(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "MANIPULATOR_WT_arrow_2d"; - - /* api callbacks */ - wt->draw = manipulator_arrow2d_draw; - wt->setup = manipulator_arrow2d_setup; - wt->invoke = manipulator_arrow2d_invoke; - wt->test_select = manipulator_arrow2d_test_select; - - wt->struct_size = sizeof(wmManipulator); - - /* rna */ - RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); - RNA_def_float_rotation( - wt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f), - "Roll", "", DEG2RADF(-360.0f), DEG2RADF(360.0f)); -} - -void ED_manipulatortypes_arrow_2d(void) -{ - WM_manipulatortype_append(MANIPULATOR_WT_arrow_2d); -} - -/** \} */ diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c deleted file mode 100644 index 0430a12bc99..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c +++ /dev/null @@ -1,492 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file arrow3d_manipulator.c - * \ingroup wm - * - * \name Arrow Manipulator - * - * 3D Manipulator - * - * \brief Simple arrow manipulator which is dragged into a certain direction. - * The arrow head can have varying shapes, e.g. cone, box, etc. - * - * - `matrix[0]` is derived from Y and Z. - * - `matrix[1]` is 'up' for manipulator types that have an up. - * - `matrix[2]` is the arrow direction (for all arrowes). - */ - -#include "BIF_gl.h" - -#include "BLI_math.h" - -#include "DNA_view3d_types.h" - -#include "BKE_context.h" - -#include "GPU_draw.h" -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_matrix.h" -#include "GPU_select.h" -#include "GPU_state.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_types.h" -#include "WM_api.h" - -#include "ED_view3d.h" -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -/* own includes */ -#include "../manipulator_geometry.h" -#include "../manipulator_library_intern.h" - -/* to use custom arrows exported to geom_arrow_manipulator.c */ -//#define USE_MANIPULATOR_CUSTOM_ARROWS - -typedef struct ArrowManipulator3D { - wmManipulator manipulator; - ManipulatorCommonData data; -} ArrowManipulator3D; - - -/* -------------------------------------------------------------------- */ - -static void manipulator_arrow_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4]) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - - copy_m4_m4(r_matrix, arrow->manipulator.matrix_basis); - madd_v3_v3fl(r_matrix[3], arrow->manipulator.matrix_basis[2], arrow->data.offset); -} - -static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float color[4]) -{ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - bool unbind_shader = true; - const int draw_style = RNA_enum_get(arrow->manipulator.ptr, "draw_style"); - const int draw_options = RNA_enum_get(arrow->manipulator.ptr, "draw_options"); - - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - - if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CROSS) { - immUniformColor4fv(color); - - immBegin(GWN_PRIM_LINES, 4); - immVertex3f(pos, -1.0f, 0.0f, 0.0f); - immVertex3f(pos, 1.0f, 0.0f, 0.0f); - immVertex3f(pos, 0.0f, -1.0f, 0.0f); - immVertex3f(pos, 0.0f, 1.0f, 0.0f); - immEnd(); - } - else if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CONE) { - float aspect[2]; - RNA_float_get_array(arrow->manipulator.ptr, "aspect", aspect); - const float unitx = aspect[0]; - const float unity = aspect[1]; - const float vec[4][3] = { - {-unitx, -unity, 0}, - { unitx, -unity, 0}, - { unitx, unity, 0}, - {-unitx, unity, 0}, - }; - - GPU_line_width(arrow->manipulator.line_width); - wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP); - } - else { -#ifdef USE_MANIPULATOR_CUSTOM_ARROWS - wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_arrow, select, color); -#else - const float arrow_length = RNA_float_get(arrow->manipulator.ptr, "length"); - - const float vec[2][3] = { - {0.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, arrow_length}, - }; - - if (draw_options & ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM) { - GPU_line_width(arrow->manipulator.line_width); - wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP); - } - else { - immUniformColor4fv(color); - } - - /* *** draw arrow head *** */ - - gpuPushMatrix(); - - if (draw_style == ED_MANIPULATOR_ARROW_STYLE_BOX) { - const float size = 0.05f; - - /* translate to line end with some extra offset so box starts exactly where line ends */ - gpuTranslate3f(0.0f, 0.0f, arrow_length + size); - /* scale down to box size */ - gpuScale3f(size, size, size); - - /* draw cube */ - immUnbindProgram(); - unbind_shader = false; - wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_cube, select, color); - } - else { - BLI_assert(draw_style == ED_MANIPULATOR_ARROW_STYLE_NORMAL); - - const float len = 0.25f; - const float width = 0.06f; - - /* translate to line end */ - gpuTranslate3f(0.0f, 0.0f, arrow_length); - - imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8); - imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1); - } - - gpuPopMatrix(); -#endif /* USE_MANIPULATOR_CUSTOM_ARROWS */ - } - - if (unbind_shader) { - immUnbindProgram(); - } -} - -static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, const bool highlight) -{ - wmManipulator *mpr = &arrow->manipulator; - float color[4]; - float matrix_final[4][4]; - - manipulator_color_get(mpr, highlight, color); - - WM_manipulator_calc_matrix_final(mpr, matrix_final); - - gpuPushMatrix(); - gpuMultMatrix(matrix_final); - GPU_blend(true); - arrow_draw_geom(arrow, select, color); - GPU_blend(false); - - gpuPopMatrix(); - - if (mpr->interaction_data) { - ManipulatorInteraction *inter = mpr->interaction_data; - - gpuPushMatrix(); - gpuMultMatrix(inter->init_matrix_final); - - - GPU_blend(true); - arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); - GPU_blend(false); - - gpuPopMatrix(); - } -} - -static void manipulator_arrow_draw_select( - const bContext *UNUSED(C), wmManipulator *mpr, - int select_id) -{ - GPU_select_load_id(select_id); - arrow_draw_intern((ArrowManipulator3D *)mpr, true, false); -} - -static void manipulator_arrow_draw(const bContext *UNUSED(C), wmManipulator *mpr) -{ - arrow_draw_intern((ArrowManipulator3D *)mpr, false, (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0); -} - -/** - * Calculate arrow offset independent from prop min value, - * meaning the range will not be offset by min value first. - */ -static int manipulator_arrow_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak tweak_flag) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - ManipulatorInteraction *inter = mpr->interaction_data; - View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - - float offset[3]; - float facdir = 1.0f; - - /* (src, dst) */ - struct { - float mval[2]; - float ray_origin[3], ray_direction[3]; - float location[3]; - } proj[2] = { - {.mval = {UNPACK2(inter->init_mval)}}, - {.mval = {UNPACK2(event->mval)}}, - }; - - float arrow_co[3]; - float arrow_no[3]; - copy_v3_v3(arrow_co, inter->init_matrix_basis[3]); - normalize_v3_v3(arrow_no, arrow->manipulator.matrix_basis[2]); - - int ok = 0; - - for (int j = 0; j < 2; j++) { - if (ED_view3d_win_to_ray( - CTX_data_depsgraph(C), - ar, v3d, proj[j].mval, - proj[j].ray_origin, proj[j].ray_direction, false)) - { - /* Force Y axis if we're view aligned */ - if (j == 0) { - if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->manipulator.matrix_basis[2]))) < 5.0f) { - normalize_v3_v3(arrow_no, rv3d->viewinv[1]); - } - } - - float arrow_no_proj[3]; - project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction); - - normalize_v3(arrow_no_proj); - - float plane[4]; - plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj); - - float lambda; - if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) { - madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda); - ok++; - } - } - } - - if (ok != 2) { - return OPERATOR_RUNNING_MODAL; - } - - sub_v3_v3v3(offset, proj[1].location, proj[0].location); - facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1; - - ManipulatorCommonData *data = &arrow->data; - const float ofs_new = facdir * len_v3(offset); - - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - - /* set the property for the operator and call its modal function */ - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - const int transform_flag = RNA_enum_get(arrow->manipulator.ptr, "transform"); - const bool constrained = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED) != 0; - const bool inverted = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED) != 0; - const bool use_precision = (tweak_flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0; - float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); - - WM_manipulator_target_property_value_set(C, mpr, mpr_prop, value); - /* get clamped value */ - value = WM_manipulator_target_property_value_get(mpr, mpr_prop); - - data->offset = manipulator_offset_from_value(data, value, constrained, inverted); - } - else { - data->offset = ofs_new; - } - - /* tag the region for redraw */ - ED_region_tag_redraw(ar); - WM_event_add_mousemove(C); - - return OPERATOR_RUNNING_MODAL; -} - -static void manipulator_arrow_setup(wmManipulator *mpr) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - - arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_MODAL; - - arrow->data.range_fac = 1.0f; -} - -static int manipulator_arrow_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - - /* Some manipulators don't use properties. */ - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - inter->init_value = WM_manipulator_target_property_value_get(mpr, mpr_prop); - } - - inter->init_offset = arrow->data.offset; - - inter->init_mval[0] = event->mval[0]; - inter->init_mval[1] = event->mval[1]; - - manipulator_arrow_matrix_basis_get(mpr, inter->init_matrix_basis); - WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); - - mpr->interaction_data = inter; - - return OPERATOR_RUNNING_MODAL; -} - -static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - const int transform_flag = RNA_enum_get(arrow->manipulator.ptr, "transform"); - const bool constrained = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED) != 0; - const bool inverted = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED) != 0; - manipulator_property_data_update(mpr, &arrow->data, mpr_prop, constrained, inverted); -} - -static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool cancel) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - ManipulatorCommonData *data = &arrow->data; - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - const bool is_prop_valid = WM_manipulator_target_property_is_valid(mpr_prop); - - if (!cancel) { - /* Assign incase applying the opetration needs an updated offset - * editmesh bisect needs this. */ - if (is_prop_valid) { - data->offset = WM_manipulator_target_property_value_get(mpr, mpr_prop); - } - return; - } - - ManipulatorInteraction *inter = mpr->interaction_data; - if (is_prop_valid) { - manipulator_property_value_reset(C, mpr, inter, mpr_prop); - } - data->offset = inter->init_offset; -} - - -/* -------------------------------------------------------------------- */ -/** \name Arrow Manipulator API - * - * \{ */ - -/** - * Define a custom property UI range - * - * \note Needs to be called before WM_manipulator_target_property_def_rna! - */ -void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, const float max) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - - BLI_assert(min < max); - BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr, "offset")) && - "Make sure this function is called before WM_manipulator_target_property_def_rna")); - - arrow->data.range = max - min; - arrow->data.min = min; - arrow->data.flag |= MANIPULATOR_CUSTOM_RANGE_SET; -} - -/** - * Define a custom factor for arrow min/max distance - * - * \note Needs to be called before WM_manipulator_target_property_def_rna! - */ -void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr, "offset")) && - "Make sure this function is called before WM_manipulator_target_property_def_rna")); - - arrow->data.range_fac = range_fac; -} - -static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "MANIPULATOR_WT_arrow_3d"; - - /* api callbacks */ - wt->draw = manipulator_arrow_draw; - wt->draw_select = manipulator_arrow_draw_select; - wt->matrix_basis_get = manipulator_arrow_matrix_basis_get; - wt->modal = manipulator_arrow_modal; - wt->setup = manipulator_arrow_setup; - wt->invoke = manipulator_arrow_invoke; - wt->property_update = manipulator_arrow_property_update; - wt->exit = manipulator_arrow_exit; - - wt->struct_size = sizeof(ArrowManipulator3D); - - /* rna */ - static EnumPropertyItem rna_enum_draw_style_items[] = { - {ED_MANIPULATOR_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""}, - {ED_MANIPULATOR_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""}, - {ED_MANIPULATOR_ARROW_STYLE_BOX, "BOX", 0, "Box", ""}, - {ED_MANIPULATOR_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem rna_enum_draw_options_items[] = { - {ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem rna_enum_transform_items[] = { - {ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""}, - {ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""}, - {0, NULL, 0, NULL, NULL} - }; - - RNA_def_enum( - wt->srna, "draw_style", rna_enum_draw_style_items, - ED_MANIPULATOR_ARROW_STYLE_NORMAL, - "Draw Style", ""); - RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options_items, - ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM, - "Draw Options", ""); - RNA_def_enum_flag( - wt->srna, "transform", rna_enum_transform_items, - 0, - "Transform", ""); - - RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); - RNA_def_float_vector(wt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX); - - WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1); -} - -void ED_manipulatortypes_arrow_3d(void) -{ - WM_manipulatortype_append(MANIPULATOR_WT_arrow_3d); -} - -/** \} */ diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c deleted file mode 100644 index db33f457056..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file button2d_manipulator.c - * \ingroup wm - * - * \name Button Manipulator - * - * 2D Manipulator, also works in 3D views. - * - * \brief Single click button action for use in manipulator groups. - * - * \note Currently only basic icon & vector-shape buttons are supported. - * - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_matrix.h" -#include "GPU_select.h" -#include "GPU_batch.h" -#include "GPU_state.h" - -#include "RNA_access.h" -#include "RNA_define.h" -#include "RNA_enum_types.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" -#include "ED_view3d.h" -#include "ED_manipulator_library.h" - -#include "UI_interface.h" -#include "UI_interface_icons.h" -#include "UI_resources.h" - -/* own includes */ -#include "../manipulator_geometry.h" -#include "../manipulator_library_intern.h" - -typedef struct ButtonManipulator2D { - wmManipulator manipulator; - bool is_init; - /* Use an icon or shape */ - int icon; - Gwn_Batch *shape_batch[2]; -} ButtonManipulator2D; - -#define CIRCLE_RESOLUTION 32 - -/* -------------------------------------------------------------------- */ - -static void button2d_geom_draw_backdrop( - const wmManipulator *mpr, const float color[4], const bool select) -{ - GPU_line_width(mpr->line_width); - - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - - immUniformColor4fv(color); - - /* TODO, other draw styles */ - imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, CIRCLE_RESOLUTION); - - immUnbindProgram(); - - UNUSED_VARS(select); -} - -static void button2d_draw_intern( - const bContext *C, wmManipulator *mpr, - const bool select, const bool highlight) -{ - ButtonManipulator2D *button = (ButtonManipulator2D *)mpr; - - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - if (button->is_init == false) { - button->is_init = true; - PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "icon"); - if (RNA_property_is_set(mpr->ptr, prop)) { - button->icon = RNA_property_enum_get(mpr->ptr, prop); - } - else { - prop = RNA_struct_find_property(mpr->ptr, "shape"); - const uint polys_len = RNA_property_string_length(mpr->ptr, prop); - /* We shouldn't need the +1, but a NULL char is set. */ - char *polys = MEM_mallocN(polys_len + 1, __func__); - RNA_property_string_get(mpr->ptr, prop, polys); - button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded((uchar *)polys, polys_len, NULL); - button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded((uchar *)polys, polys_len, NULL); - MEM_freeN(polys); - } - } - - float color[4]; - float matrix_final[4][4]; - - manipulator_color_get(mpr, highlight, color); - WM_manipulator_calc_matrix_final(mpr, matrix_final); - - - bool is_3d = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) != 0; - - - if (draw_options & ED_MANIPULATOR_BUTTON_SHOW_HELPLINE) { - float matrix_final_no_offset[4][4]; - WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor4fv(color); - GPU_line_width(mpr->line_width); - immUniformColor4fv(color); - immBegin(GWN_PRIM_LINE_STRIP, 2); - immVertex3fv(pos, matrix_final[3]); - immVertex3fv(pos, matrix_final_no_offset[3]); - immEnd(); - immUnbindProgram(); - } - - bool need_to_pop = true; - gpuPushMatrix(); - gpuMultMatrix(matrix_final); - - if (is_3d) { - RegionView3D *rv3d = CTX_wm_region_view3d(C); - float matrix_align[4][4]; - float matrix_final_unit[4][4]; - normalize_m4_m4(matrix_final_unit, matrix_final); - mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); - zero_v3(matrix_align[3]); - transpose_m4(matrix_align); - gpuMultMatrix(matrix_align); - } - - if (select) { - BLI_assert(is_3d); - button2d_geom_draw_backdrop(mpr, color, select); - } - else { - - GPU_blend(true); - if (button->shape_batch[0] != NULL) { - GPU_line_smooth(true); - GPU_polygon_smooth(false); - GPU_line_width(1.0f); - for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) { - /* Invert line color for wire. */ - GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR); - GWN_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color)); - GWN_batch_draw(button->shape_batch[i]); - - if (draw_options & ED_MANIPULATOR_BUTTON_SHOW_OUTLINE) { - color[0] = 1.0f - color[0]; - color[1] = 1.0f - color[1]; - color[2] = 1.0f - color[2]; - } - } - GPU_line_smooth(false); - GPU_polygon_smooth(true); - } - else if (button->icon != ICON_NONE) { - button2d_geom_draw_backdrop(mpr, color, select); - float size[2]; - if (is_3d) { - const float fac = 2.0f; - gpuTranslate2f(-(fac / 2), -(fac / 2)); - gpuScale2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC)); - size[0] = 1.0f; - size[1] = 1.0f; - } - else { - size[0] = mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; - size[1] = mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; - gpuPopMatrix(); - need_to_pop = false; - } - UI_icon_draw(size[0], size[1], button->icon); - } - GPU_blend(false); - } - - if (need_to_pop) { - gpuPopMatrix(); - } -} - -static void manipulator_button2d_draw_select(const bContext *C, wmManipulator *mpr, int select_id) -{ - GPU_select_load_id(select_id); - button2d_draw_intern(C, mpr, true, false); -} - -static void manipulator_button2d_draw(const bContext *C, wmManipulator *mpr) -{ - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - - GPU_blend(true); - button2d_draw_intern(C, mpr, false, is_highlight); - GPU_blend(false); -} - -static int manipulator_button2d_test_select( - bContext *C, wmManipulator *mpr, const wmEvent *event) -{ - float point_local[2]; - - if (0) { - /* correct, but unnecessarily slow. */ - if (manipulator_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) - { - return -1; - } - } - else { - copy_v2_v2(point_local, (float[2]){UNPACK2(event->mval)}); - sub_v2_v2(point_local, mpr->matrix_basis[3]); - mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC)); - } - /* The 'mpr->scale_final' is already applied when projecting. */ - if (len_squared_v2(point_local) < 1.0f) { - return 0; - } - - return -1; -} - -static int manipulator_button2d_cursor_get(wmManipulator *mpr) -{ - if (RNA_boolean_get(mpr->ptr, "show_drag")) { - return BC_NSEW_SCROLLCURSOR; - } - return CURSOR_STD; -} - -static void manipulator_button2d_free(wmManipulator *mpr) -{ - ButtonManipulator2D *shape = (ButtonManipulator2D *)mpr; - - for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) { - GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]); - } -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Button Manipulator API - * - * \{ */ - -static void MANIPULATOR_WT_button_2d(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "MANIPULATOR_WT_button_2d"; - - /* api callbacks */ - wt->draw = manipulator_button2d_draw; - wt->draw_select = manipulator_button2d_draw_select; - wt->test_select = manipulator_button2d_test_select; - wt->cursor_get = manipulator_button2d_cursor_get; - wt->free = manipulator_button2d_free; - - wt->struct_size = sizeof(ButtonManipulator2D); - - /* rna */ - static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_BUTTON_SHOW_OUTLINE, "OUTLINE", 0, "Outline", ""}, - {ED_MANIPULATOR_BUTTON_SHOW_HELPLINE, "HELPLINE", 0, "Help Line", ""}, - {0, NULL, 0, NULL, NULL} - }; - PropertyRNA *prop; - - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - - prop = RNA_def_property(wt->srna, "icon", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, rna_enum_icon_items); - - /* Passed to 'GPU_batch_tris_from_poly_2d_encoded' */ - RNA_def_property(wt->srna, "shape", PROP_STRING, PROP_BYTESTRING); - - /* Currently only used for cursor display. */ - RNA_def_boolean(wt->srna, "show_drag", true, "Show Drag", ""); -} - -void ED_manipulatortypes_button_2d(void) -{ - WM_manipulatortype_append(MANIPULATOR_WT_button_2d); -} - -/** \} */ // Button Manipulator API diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c deleted file mode 100644 index b7b19ccd634..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c +++ /dev/null @@ -1,1100 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file cage2d_manipulator.c - * \ingroup wm - * - * \name Cage Manipulator - * - * 2D Manipulator - * - * \brief Rectangular manipulator acting as a 'cage' around its content. - * Interacting scales or translates the manipulator. - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" -#include "BLI_dial_2d.h" -#include "BLI_rect.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" - -#include "GPU_matrix.h" -#include "GPU_shader.h" -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_select.h" -#include "GPU_state.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" -#include "ED_view3d.h" -#include "ED_manipulator_library.h" - -/* own includes */ -#include "../manipulator_library_intern.h" - -#define MANIPULATOR_RESIZER_SIZE 10.0f -#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f - -static void manipulator_calc_rect_view_scale( - const wmManipulator *mpr, const float dims[2], float scale[2]) -{ - float matrix_final_no_offset[4][4]; - float asp[2] = {1.0f, 1.0f}; - if (dims[0] > dims[1]) { - asp[0] = dims[1] / dims[0]; - } - else { - asp[1] = dims[0] / dims[1]; - } - float x_axis[3], y_axis[3]; - WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); - mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); - mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); - - mul_v2_v2(x_axis, asp); - mul_v2_v2(y_axis, asp); - - scale[0] = 1.0f / len_v3(x_axis); - scale[1] = 1.0f / len_v3(y_axis); -} - -static void manipulator_calc_rect_view_margin( - const wmManipulator *mpr, const float dims[2], float margin[2]) -{ - float handle_size; - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - handle_size = 0.15f; - } - else { - handle_size = MANIPULATOR_RESIZER_SIZE; - } - handle_size *= mpr->scale_final; - float scale_xy[2]; - manipulator_calc_rect_view_scale(mpr, dims, scale_xy); - margin[0] = ((handle_size * scale_xy[0])); - margin[1] = ((handle_size * scale_xy[1])); -} - -/* -------------------------------------------------------------------- */ - -static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_constrain_axis[2]) -{ - bool x = true, y = true; - switch (part) { - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.0); x = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.0); x = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, 0.5); y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, -0.5); y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.5); x = y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, -0.5); x = y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.5); x = y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, -0.5); x = y = false; break; } - default: BLI_assert(0); - } - r_constrain_axis[0] = x; - r_constrain_axis[1] = y; -} - -/* -------------------------------------------------------------------- */ -/** \name Box Draw Style - * - * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX - * \{ */ - -static void cage2d_draw_box_corners( - const rctf *r, const float margin[2], const float color[3]) -{ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor3fv(color); - - immBegin(GWN_PRIM_LINES, 16); - - immVertex2f(pos, r->xmin, r->ymin + margin[1]); - immVertex2f(pos, r->xmin, r->ymin); - immVertex2f(pos, r->xmin, r->ymin); - immVertex2f(pos, r->xmin + margin[0], r->ymin); - - immVertex2f(pos, r->xmax, r->ymin + margin[1]); - immVertex2f(pos, r->xmax, r->ymin); - immVertex2f(pos, r->xmax, r->ymin); - immVertex2f(pos, r->xmax - margin[0], r->ymin); - - immVertex2f(pos, r->xmax, r->ymax - margin[1]); - immVertex2f(pos, r->xmax, r->ymax); - immVertex2f(pos, r->xmax, r->ymax); - immVertex2f(pos, r->xmax - margin[0], r->ymax); - - immVertex2f(pos, r->xmin, r->ymax - margin[1]); - immVertex2f(pos, r->xmin, r->ymax); - immVertex2f(pos, r->xmin, r->ymax); - immVertex2f(pos, r->xmin + margin[0], r->ymax); - - immEnd(); - - immUnbindProgram(); -} - -static void cage2d_draw_box_interaction( - const float color[4], const int highlighted, - const float size[2], const float margin[2], - const float line_width, const bool is_solid, const int draw_options) -{ - /* 4 verts for translate, otherwise only 3 are used. */ - float verts[4][2]; - uint verts_len = 0; - Gwn_PrimType prim_type = GWN_PRIM_NONE; - - switch (highlighted) { - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: - { - rctf r = { - .xmin = -size[0], .xmax = -size[0] + margin[0], - .ymin = -size[1] + margin[1], .ymax = size[1] - margin[1], - }; - ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin); - ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymax); - verts_len = 2; - if (is_solid) { - ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); - ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin); - verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: - { - rctf r = { - .xmin = size[0] - margin[0], .xmax = size[0], - .ymin = -size[1] + margin[1], .ymax = size[1] - margin[1], - }; - ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymin); - ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax); - verts_len = 2; - if (is_solid) { - ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax); - ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); - verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: - { - rctf r = { - .xmin = -size[0] + margin[0], .xmax = size[0] - margin[0], - .ymin = -size[1], .ymax = -size[1] + margin[1], - }; - ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin); - ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymin); - verts_len = 2; - if (is_solid) { - ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); - ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax); - verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: - { - rctf r = { - .xmin = -size[0] + margin[0], .xmax = size[0] - margin[0], - .ymin = size[1] - margin[1], .ymax = size[1], - }; - ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymax); - ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax); - verts_len = 2; - if (is_solid) { - ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin); - ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); - verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: - { - rctf r = { - .xmin = -size[0], .xmax = -size[0] + margin[0], - .ymin = -size[1], .ymax = -size[1] + margin[1], - }; - ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymin); - ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax); - ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax); - verts_len = 3; - if (is_solid) { - ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); - verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: - { - rctf r = { - .xmin = -size[0], .xmax = -size[0] + margin[0], - .ymin = size[1] - margin[1], .ymax = size[1], - }; - ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymax); - ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymin); - ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymin); - verts_len = 3; - if (is_solid) { - ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax); - verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: - { - rctf r = { - .xmin = size[0] - margin[0], .xmax = size[0], - .ymin = -size[1], .ymax = -size[1] + margin[1], - }; - ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin); - ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymax); - ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); - verts_len = 3; - if (is_solid) { - ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin); - verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: - { - rctf r = { - .xmin = size[0] - margin[0], .xmax = size[0], - .ymin = size[1] - margin[1], .ymax = size[1], - }; - ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymax); - ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymin); - ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin); - verts_len = 3; - if (is_solid) { - ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymax); - verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - case ED_MANIPULATOR_CAGE2D_PART_ROTATE: - { - const float rotate_pt[2] = {0.0f, size[1] + margin[1]}; - const rctf r_rotate = { - .xmin = rotate_pt[0] - margin[0] / 2.0f, - .xmax = rotate_pt[0] + margin[0] / 2.0f, - .ymin = rotate_pt[1] - margin[1] / 2.0f, - .ymax = rotate_pt[1] + margin[1] / 2.0f, - }; - - ARRAY_SET_ITEMS(verts[0], r_rotate.xmin, r_rotate.ymin); - ARRAY_SET_ITEMS(verts[1], r_rotate.xmin, r_rotate.ymax); - ARRAY_SET_ITEMS(verts[2], r_rotate.xmax, r_rotate.ymax); - ARRAY_SET_ITEMS(verts[3], r_rotate.xmax, r_rotate.ymin); - verts_len = 4; - if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINE_STRIP; - } - break; - } - - case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE: - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { - ARRAY_SET_ITEMS(verts[0], -margin[0] / 2, -margin[1] / 2); - ARRAY_SET_ITEMS(verts[1], margin[0] / 2, margin[1] / 2); - ARRAY_SET_ITEMS(verts[2], -margin[0] / 2, margin[1] / 2); - ARRAY_SET_ITEMS(verts[3], margin[0] / 2, -margin[1] / 2); - verts_len = 4; - if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; - } - else { - prim_type = GWN_PRIM_LINES; - } - } - else { - /* Only used for 3D view selection, never displayed to the user. */ - ARRAY_SET_ITEMS(verts[0], -size[0], -size[1]); - ARRAY_SET_ITEMS(verts[1], -size[0], size[1]); - ARRAY_SET_ITEMS(verts[2], size[0], size[1]); - ARRAY_SET_ITEMS(verts[3], size[0], -size[1]); - verts_len = 4; - if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; - } - else { - /* unreachable */ - BLI_assert(0); - prim_type = GWN_PRIM_LINE_STRIP; - } - } - break; - default: - return; - } - - BLI_assert(prim_type != GWN_PRIM_NONE); - - Gwn_VertFormat *format = immVertexFormat(); - struct { - uint pos, col; - } attr_id = { - .pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT), - .col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT), - }; - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - - { - if (is_solid) { - BLI_assert(ELEM(prim_type, GWN_PRIM_TRI_FAN)); - immBegin(prim_type, verts_len); - immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f); - for (uint i = 0; i < verts_len; i++) { - immVertex2fv(attr_id.pos, verts[i]); - } - immEnd(); - } - else { - BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES)); - GPU_line_width(line_width + 3.0f); - - immBegin(prim_type, verts_len); - immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f); - for (uint i = 0; i < verts_len; i++) { - immVertex2fv(attr_id.pos, verts[i]); - } - immEnd(); - - GPU_line_width(line_width); - - immBegin(prim_type, verts_len); - immAttrib3fv(attr_id.col, color); - for (uint i = 0; i < verts_len; i++) { - immVertex2fv(attr_id.pos, verts[i]); - } - immEnd(); - } - } - - immUnbindProgram(); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Circle Draw Style - * - * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE - * \{ */ - -static void imm_draw_point_aspect_2d( - uint pos, float x, float y, float rad_x, float rad_y, bool solid) -{ - immBegin(solid ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4); - immVertex2f(pos, x - rad_x, y - rad_y); - immVertex2f(pos, x - rad_x, y + rad_y); - immVertex2f(pos, x + rad_x, y + rad_y); - immVertex2f(pos, x + rad_x, y - rad_y); - immEnd(); -} - -static void cage2d_draw_circle_wire( - const rctf *r, const float margin[2], const float color[3], - const int transform_flag, const int draw_options) -{ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor3fv(color); - - immBegin(GWN_PRIM_LINE_LOOP, 4); - immVertex2f(pos, r->xmin, r->ymin); - immVertex2f(pos, r->xmax, r->ymin); - immVertex2f(pos, r->xmax, r->ymax); - immVertex2f(pos, r->xmin, r->ymax); - immEnd(); - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { - immBegin(GWN_PRIM_LINE_LOOP, 2); - immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax); - immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax + margin[1]); - immEnd(); - } - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { - const float rad[2] = {margin[0] / 2, margin[1] / 2}; - const float center[2] = {BLI_rctf_cent_x(r), BLI_rctf_cent_y(r)}; - - immBegin(GWN_PRIM_LINES, 4); - immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]); - immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]); - immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]); - immVertex2f(pos, center[0] - rad[0], center[1] + rad[1]); - immEnd(); - } - } - - immUnbindProgram(); -} - -static void cage2d_draw_circle_handles( - const rctf *r, const float margin[2], const float color[3], - const int transform_flag, - bool solid) -{ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - void (*circle_fn)(uint, float, float, float, float, int) = - (solid) ? imm_draw_circle_fill_aspect_2d : imm_draw_circle_wire_aspect_2d; - const int resolu = 12; - const float rad[2] = {margin[0] / 3, margin[1] / 3}; - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor3fv(color); - - /* should really divide by two, but looks too bulky. */ - { - imm_draw_point_aspect_2d(pos, r->xmin, r->ymin, rad[0], rad[1], solid); - imm_draw_point_aspect_2d(pos, r->xmax, r->ymin, rad[0], rad[1], solid); - imm_draw_point_aspect_2d(pos, r->xmax, r->ymax, rad[0], rad[1], solid); - imm_draw_point_aspect_2d(pos, r->xmin, r->ymax, rad[0], rad[1], solid); - } - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { - const float handle[2] = {BLI_rctf_cent_x(r), r->ymax + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)}; - circle_fn(pos, handle[0], handle[1], rad[0], rad[1], resolu); - } - - immUnbindProgram(); -} - -/** \} */ - -static void manipulator_cage2d_draw_intern( - wmManipulator *mpr, const bool select, const bool highlight, const int select_id) -{ - // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; - float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); - float matrix_final[4][4]; - - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - - const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; - - WM_manipulator_calc_matrix_final(mpr, matrix_final); - - gpuPushMatrix(); - gpuMultMatrix(matrix_final); - - float margin[2]; - manipulator_calc_rect_view_margin(mpr, dims, margin); - - /* Handy for quick testing draw (if it's outside bounds). */ - if (false) { - GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); - float s = 0.5f; - immRectf(pos, -s, -s, s, s); - immUnbindProgram(); - GPU_blend(false); - } - - if (select) { - /* expand for hotspot */ - const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) { - int scale_parts[] = { - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, - - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, - }; - for (int i = 0; i < ARRAY_SIZE(scale_parts); i++) { - GPU_select_load_id(select_id | scale_parts[i]); - cage2d_draw_box_interaction( - mpr->color, scale_parts[i], size, margin, mpr->line_width, true, draw_options); - } - } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - const int transform_part = ED_MANIPULATOR_CAGE2D_PART_TRANSLATE; - GPU_select_load_id(select_id | transform_part); - cage2d_draw_box_interaction( - mpr->color, transform_part, size, margin, mpr->line_width, true, draw_options); - } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { - cage2d_draw_box_interaction( - mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, true, draw_options); - } - } - else { - const rctf r = { - .xmin = -size_real[0], - .ymin = -size_real[1], - .xmax = size_real[0], - .ymax = size_real[1], - }; - if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { - /* corner manipulators */ - GPU_line_width(mpr->line_width + 3.0f); - cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0}); - - /* corner manipulators */ - float color[4]; - manipulator_color_get(mpr, highlight, color); - GPU_line_width(mpr->line_width); - cage2d_draw_box_corners(&r, margin, color); - - bool show = false; - if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) { - /* Only show if we're drawing the center handle - * otherwise the entire rectangle is the hotspot. */ - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { - show = true; - } - } - else { - show = true; - } - - if (show) { - cage2d_draw_box_interaction( - mpr->color, mpr->highlight_part, size_real, margin, mpr->line_width, false, draw_options); - } - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { - cage2d_draw_box_interaction( - mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, false, draw_options); - } - } - else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) { - float color[4]; - manipulator_color_get(mpr, highlight, color); - - GPU_line_smooth(true); - GPU_blend(true); - - GPU_line_width(mpr->line_width + 3.0f); - cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - GPU_line_width(mpr->line_width); - cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options); - - - /* corner manipulators */ - cage2d_draw_circle_handles(&r, margin, color, transform_flag, true); - cage2d_draw_circle_handles(&r, margin, (const float[3]){0, 0, 0}, transform_flag, false); - - GPU_blend(false); - GPU_line_smooth(false); - } - else { - BLI_assert(0); - } - } - - GPU_line_width(1.0); - gpuPopMatrix(); -} - -/** - * For when we want to draw 2d cage in 3d views. - */ -static void manipulator_cage2d_draw_select(const bContext *UNUSED(C), wmManipulator *mpr, int select_id) -{ - manipulator_cage2d_draw_intern(mpr, true, false, select_id); -} - -static void manipulator_cage2d_draw(const bContext *UNUSED(C), wmManipulator *mpr) -{ - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - manipulator_cage2d_draw_intern(mpr, false, is_highlight, -1); -} - -static int manipulator_cage2d_get_cursor(wmManipulator *mpr) -{ - int highlight_part = mpr->highlight_part; - - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - return BC_NSEW_SCROLLCURSOR; - } - - switch (highlight_part) { - case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE: - return BC_NSEW_SCROLLCURSOR; - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: - return CURSOR_X_MOVE; - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: - return CURSOR_Y_MOVE; - - /* TODO diagonal cursor */ - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: - return BC_NSEW_SCROLLCURSOR; - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: - return BC_NSEW_SCROLLCURSOR; - case ED_MANIPULATOR_CAGE2D_PART_ROTATE: - return BC_CROSSCURSOR; - default: - return CURSOR_STD; - } -} - -static int manipulator_cage2d_test_select( - bContext *C, wmManipulator *mpr, const wmEvent *event) -{ - float point_local[2]; - float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); - const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; - - if (manipulator_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) - { - return -1; - } - - float margin[2]; - manipulator_calc_rect_view_margin(mpr, dims, margin); - /* expand for hotspot */ - const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; - - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - rctf r; - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { - r.xmin = -margin[0] / 2; - r.ymin = -margin[1] / 2; - r.xmax = margin[0] / 2; - r.ymax = margin[1] / 2; - } - else { - r.xmin = -size[0] + margin[0]; - r.ymin = -size[1] + margin[1]; - r.xmax = size[0] - margin[0]; - r.ymax = size[1] - margin[1]; - }; - bool isect = BLI_rctf_isect_pt_v(&r, point_local); - if (isect) { - return ED_MANIPULATOR_CAGE2D_PART_TRANSLATE; - } - } - - /* if manipulator does not have a scale intersection, don't do it */ - if (transform_flag & (ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM)) { - const rctf r_xmin = {.xmin = -size[0], .ymin = -size[1], .xmax = -size[0] + margin[0], .ymax = size[1]}; - const rctf r_xmax = {.xmin = size[0] - margin[0], .ymin = -size[1], .xmax = size[0], .ymax = size[1]}; - const rctf r_ymin = {.xmin = -size[0], .ymin = -size[1], .xmax = size[0], .ymax = -size[1] + margin[1]}; - const rctf r_ymax = {.xmin = -size[0], .ymin = size[1] - margin[1], .xmax = size[0], .ymax = size[1]}; - - if (BLI_rctf_isect_pt_v(&r_xmin, point_local)) { - if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y; - } - if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y; - } - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X; - } - if (BLI_rctf_isect_pt_v(&r_xmax, point_local)) { - if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y; - } - if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y; - } - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X; - } - if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y; - } - if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y; - } - } - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { - /* Rotate: - * (*) <-- hot spot is here! - * +---+ - * | | - * +---+ */ - const float r_rotate_pt[2] = {0.0f, size_real[1] + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)}; - const rctf r_rotate = { - .xmin = r_rotate_pt[0] - margin[0] / 2.0f, - .xmax = r_rotate_pt[0] + margin[0] / 2.0f, - .ymin = r_rotate_pt[1] - margin[1] / 2.0f, - .ymax = r_rotate_pt[1] + margin[1] / 2.0f, - }; - - if (BLI_rctf_isect_pt_v(&r_rotate, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_ROTATE; - } - } - - return -1; -} - -typedef struct RectTransformInteraction { - float orig_mouse[2]; - float orig_matrix_offset[4][4]; - float orig_matrix_final_no_offset[4][4]; - Dial *dial; -} RectTransformInteraction; - -static void manipulator_cage2d_setup(wmManipulator *mpr) -{ - mpr->flag |= WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_NO_SCALE; -} - -static int manipulator_cage2d_invoke( - bContext *C, wmManipulator *mpr, const wmEvent *event) -{ - RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); - - copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); - WM_manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset); - - if (manipulator_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) - { - zero_v2(data->orig_mouse); - } - - mpr->interaction_data = data; - - return OPERATOR_RUNNING_MODAL; -} - -static int manipulator_cage2d_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) -{ - /* For transform logic to be managable we operate in -0.5..0.5 2D space, - * no matter the size of the rectangle, mouse coorts are scaled to unit space. - * The mouse coords have been projected into the matrix so we don't need to worry about axis alignment. - * - * - The cursor offset are multiplied by 'dims'. - * - Matrix translation is also multiplied by 'dims'. - */ - RectTransformInteraction *data = mpr->interaction_data; - float point_local[2]; - - float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); - - { - float matrix_back[4][4]; - copy_m4_m4(matrix_back, mpr->matrix_offset); - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - - bool ok = manipulator_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local); - copy_m4_m4(mpr->matrix_offset, matrix_back); - if (!ok) { - return OPERATOR_RUNNING_MODAL; - } - } - - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - wmManipulatorProperty *mpr_prop; - - mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); - } - - if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) { - /* do this to prevent clamping from changing size */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); - mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); - } - else if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_ROTATE) { - -#define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \ - mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0})) - - float test_co[3]; - - if (data->dial == NULL) { - MUL_V2_V3_M4_FINAL(test_co, data->orig_matrix_offset[3]); - - data->dial = BLI_dial_initialize(test_co, FLT_EPSILON); - - MUL_V2_V3_M4_FINAL(test_co, data->orig_mouse); - BLI_dial_angle(data->dial, test_co); - } - - /* rotate */ - MUL_V2_V3_M4_FINAL(test_co, point_local); - const float angle = BLI_dial_angle(data->dial, test_co); - - float matrix_space_inv[4][4]; - float matrix_rotate[4][4]; - float pivot[3]; - - copy_v3_v3(pivot, data->orig_matrix_offset[3]); - - invert_m4_m4(matrix_space_inv, mpr->matrix_space); - - unit_m4(matrix_rotate); - mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv); - rotate_m4(matrix_rotate, 'Z', -angle); - mul_m4_m4m4(matrix_rotate, matrix_rotate, mpr->matrix_space); - - zero_v3(matrix_rotate[3]); - transform_pivot_set_m4(matrix_rotate, pivot); - - mul_m4_m4m4(mpr->matrix_offset, matrix_rotate, data->orig_matrix_offset); - -#undef MUL_V2_V3_M4_FINAL - } - else { - /* scale */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - float pivot[2]; - bool constrain_axis[2] = {false}; - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); - } - else { - zero_v2(pivot); - } - - /* Cursor deltas scaled to (-0.5..0.5). */ - float delta_orig[2], delta_curr[2]; - for (int i = 0; i < 2; i++) { - delta_orig[i] = ((data->orig_mouse[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i]; - delta_curr[i] = ((point_local[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i]; - } - - float scale[2] = {1.0f, 1.0f}; - for (int i = 0; i < 2; i++) { - if (constrain_axis[i] == false) { - if (delta_orig[i] < 0.0f) { - delta_orig[i] *= -1.0f; - delta_curr[i] *= -1.0f; - } - const int sign = signum_i(scale[i]); - - scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i])); - - if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) { - if (sign != signum_i(scale[i])) { - scale[i] = 0.0f; - } - } - } - } - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) { - if (constrain_axis[0] == false && constrain_axis[1] == false) { - scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f; - } - else if (constrain_axis[0] == false) { - scale[1] = scale[0]; - } - else if (constrain_axis[1] == false) { - scale[0] = scale[1]; - } - else { - BLI_assert(0); - } - } - - /* scale around pivot */ - float matrix_scale[4][4]; - unit_m4(matrix_scale); - - mul_v3_fl(matrix_scale[0], scale[0]); - mul_v3_fl(matrix_scale[1], scale[1]); - - transform_pivot_set_m4(matrix_scale, (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], 0.0f}); - mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale); - } - - if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); - } - - /* tag the region for redraw */ - ED_region_tag_redraw(CTX_wm_region(C)); - WM_event_add_mousemove(C); - - return OPERATOR_RUNNING_MODAL; -} - -static void manipulator_cage2d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) -{ - if (STREQ(mpr_prop->type->idname, "matrix")) { - if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); - } - else { - BLI_assert(0); - } - } - else { - BLI_assert(0); - } -} - -static void manipulator_cage2d_exit(bContext *C, wmManipulator *mpr, const bool cancel) -{ - RectTransformInteraction *data = mpr->interaction_data; - - MEM_SAFE_FREE(data->dial); - - if (!cancel) - return; - - wmManipulatorProperty *mpr_prop; - - /* reset properties */ - mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); - } - - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); -} - - -/* -------------------------------------------------------------------- */ -/** \name Cage Manipulator API - * - * \{ */ - -static void MANIPULATOR_WT_cage_2d(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "MANIPULATOR_WT_cage_2d"; - - /* api callbacks */ - wt->draw = manipulator_cage2d_draw; - wt->draw_select = manipulator_cage2d_draw_select; - wt->test_select = manipulator_cage2d_test_select; - wt->setup = manipulator_cage2d_setup; - wt->invoke = manipulator_cage2d_invoke; - wt->property_update = manipulator_cage2d_property_update; - wt->modal = manipulator_cage2d_modal; - wt->exit = manipulator_cage2d_exit; - wt->cursor_get = manipulator_cage2d_get_cursor; - - wt->struct_size = sizeof(wmManipulator); - - /* rna */ - static EnumPropertyItem rna_enum_draw_style[] = { - {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""}, - {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem rna_enum_transform[] = { - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""}, - {0, NULL, 0, NULL, NULL} - }; - static float unit_v2[2] = {1.0f, 1.0f}; - RNA_def_float_vector(wt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); - RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); - RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options, - ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); - - WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16); -} - -void ED_manipulatortypes_cage_2d(void) -{ - WM_manipulatortype_append(MANIPULATOR_WT_cage_2d); -} - -/** \} */ diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c deleted file mode 100644 index a907816b08f..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c +++ /dev/null @@ -1,692 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file cage3d_manipulator.c - * \ingroup wm - * - * \name Cage Manipulator - * - * 2D Manipulator - * - * \brief Rectangular manipulator acting as a 'cage' around its content. - * Interacting scales or translates the manipulator. - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" -#include "BLI_rect.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" - -#include "GPU_matrix.h" -#include "GPU_shader.h" -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_select.h" -#include "GPU_state.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" -#include "ED_view3d.h" -#include "ED_manipulator_library.h" - -/* own includes */ -#include "../manipulator_library_intern.h" - -#define MANIPULATOR_RESIZER_SIZE 10.0f -#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f - -static void manipulator_calc_matrix_final_no_offset( - const wmManipulator *mpr, float orig_matrix_final_no_offset[4][4], bool use_space) -{ - float mat_identity[4][4]; - struct WM_ManipulatorMatrixParams params = {NULL}; - unit_m4(mat_identity); - if (use_space == false) { - params.matrix_basis = mat_identity; - } - params.matrix_offset = mat_identity; - WM_manipulator_calc_matrix_final_params(mpr, ¶ms, orig_matrix_final_no_offset); -} - -static void manipulator_calc_rect_view_scale( - const wmManipulator *mpr, const float dims[3], float scale[3]) -{ - UNUSED_VARS(dims); - - /* Unlike cage2d, no need to correct for aspect. */ - float matrix_final_no_offset[4][4]; - - float x_axis[3], y_axis[3], z_axis[3]; - manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset, false); - mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); - mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); - mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, mpr->matrix_offset[2]); - - scale[0] = 1.0f / len_v3(x_axis); - scale[1] = 1.0f / len_v3(y_axis); - scale[2] = 1.0f / len_v3(z_axis); -} - -static void manipulator_calc_rect_view_margin( - const wmManipulator *mpr, const float dims[3], float margin[3]) -{ - float handle_size; - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - handle_size = 0.15f; - } - else { - handle_size = MANIPULATOR_RESIZER_SIZE; - } - // XXX, the scale isn't taking offset into account, we need to calculate scale per handle! - // handle_size *= mpr->scale_final; - - float scale_xyz[3]; - manipulator_calc_rect_view_scale(mpr, dims, scale_xyz); - margin[0] = ((handle_size * scale_xyz[0])); - margin[1] = ((handle_size * scale_xyz[1])); - margin[2] = ((handle_size * scale_xyz[2])); -} - -/* -------------------------------------------------------------------- */ - -static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3]) -{ - if (part >= ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && - part <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) - { - int index = (part - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); - int range[3]; - range[2] = index % 3; - index = index / 3; - range[1] = index % 3; - index = index / 3; - range[0] = index % 3; - - const float sign[3] = {0.5f, 0.0f, -0.5f}; - for (int i = 0; i < 3; i++) { - r_pt[i] = sign[range[i]]; - r_constrain_axis[i] = (range[i] == 1); - } - } -} - -/* -------------------------------------------------------------------- */ -/** \name Box Draw Style - * - * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX - * \{ */ - -static void cage3d_draw_box_corners( - const float r[3], const float margin[3], const float color[3]) -{ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - UNUSED_VARS(margin); - - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor3fv(color); - - imm_draw_cube_wire_3d(pos, (float[3]){0}, r); - - immUnbindProgram(); -} - -static void cage3d_draw_box_interaction( - const float color[4], const int highlighted, - const float size[3], const float margin[3]) -{ - if (highlighted >= ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && - highlighted <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) - { - int index = (highlighted - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); - int range[3]; - range[2] = index % 3; - index = index / 3; - range[1] = index % 3; - index = index / 3; - range[0] = index % 3; - - const float sign[3] = {-1.0f, 0.0f, 1.0f}; - float co[3]; - - for (int i = 0; i < 3; i++) { - co[i] = size[i] * sign[range[i]]; - } - const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3}; - - { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor3fv(color); - imm_draw_cube_fill_3d(pos, co, rad); - immUnbindProgram(); - } - } -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Circle Draw Style - * - * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE - * \{ */ - -static void imm_draw_point_aspect_3d( - uint pos, const float co[3], const float rad[3], bool solid) -{ - if (solid) { - imm_draw_cube_fill_3d(pos, co, rad); - } - else { - imm_draw_cube_wire_3d(pos, co, rad); - } -} - -static void cage3d_draw_circle_wire( - const float r[3], const float margin[3], const float color[3], - const int transform_flag, const int draw_options) -{ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor3fv(color); - - imm_draw_cube_wire_3d(pos, (float[3]){0}, r); - -#if 0 - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { - const float rad[2] = {margin[0] / 2, margin[1] / 2}; - const float center[2] = {0.0f, 0.0f}; - - immBegin(GWN_PRIM_LINES, 4); - immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]); - immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]); - immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]); - immVertex2f(pos, center[0] - rad[0], center[1] + rad[1]); - immEnd(); - } - } -#else - UNUSED_VARS(margin, transform_flag, draw_options); -#endif - - - immUnbindProgram(); -} - -static void cage3d_draw_circle_handles( - const RegionView3D *rv3d, const float matrix_final[4][4], - const float r[3], const float margin[3], const float color[3], - bool solid, float scale) -{ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3}; - - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor3fv(color); - - float sign[3] = {-1.0f, 0.0f, 1.0f}; - for (int x = 0; x < 3; x++) { - for (int y = 0; y < 3; y++) { - for (int z = 0; z < 3; z++) { - if (x == 1 && y == 1 && z == 1) { - continue; - } - const float co[3] = {r[0] * sign[x], r[1] * sign[y], r[2] * sign[z]}; - float co_test[3]; - mul_v3_m4v3(co_test, matrix_final, co); - float rad_scale[3]; - mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test) * scale); - imm_draw_point_aspect_3d(pos, co, rad_scale, solid); - } - } - } - - immUnbindProgram(); -} - -/** \} */ - -static void manipulator_cage3d_draw_intern( - RegionView3D *rv3d, - wmManipulator *mpr, const bool select, const bool highlight, const int select_id) -{ - // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; - float dims[3]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); - float matrix_final[4][4]; - - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - - const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f}; - - WM_manipulator_calc_matrix_final(mpr, matrix_final); - - gpuPushMatrix(); - gpuMultMatrix(matrix_final); - - float margin[3]; - manipulator_calc_rect_view_margin(mpr, dims, margin); - - /* Handy for quick testing draw (if it's outside bounds). */ - if (false) { - GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); - float s = 0.5f; - immRectf(pos, -s, -s, s, s); - immUnbindProgram(); - GPU_blend(false); - } - - if (select) { - /* expand for hotspot */ -#if 0 - const float size[3] = { - size_real[0] + margin[0] / 2, - size_real[1] + margin[1] / 2, - size_real[2] + margin[2] / 2, - }; -#else - /* just use same value for now. */ - const float size[3] = {UNPACK3(size_real)}; -#endif - - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) { - for (int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; - i <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z; - i++) - { - if (i == ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z) { - continue; - } - GPU_select_load_id(select_id | i); - cage3d_draw_box_interaction( - mpr->color, i, size, margin); - } - } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - const int transform_part = ED_MANIPULATOR_CAGE3D_PART_TRANSLATE; - GPU_select_load_id(select_id | transform_part); - cage3d_draw_box_interaction( - mpr->color, transform_part, size, margin); - } - } - else { -#if 0 - const rctf _r = { - .xmin = -size_real[0], - .ymin = -size_real[1], - .xmax = size_real[0], - .ymax = size_real[1], - }; -#endif - if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { - /* corner manipulators */ - GPU_line_width(mpr->line_width + 3.0f); - cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0}); - - /* corner manipulators */ - float color[4]; - manipulator_color_get(mpr, highlight, color); - GPU_line_width(mpr->line_width); - cage3d_draw_box_corners(size_real, margin, color); - - bool show = false; - if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_TRANSLATE) { - /* Only show if we're drawing the center handle - * otherwise the entire rectangle is the hotspot. */ - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { - show = true; - } - } - else { - show = true; - } - - if (show) { - cage3d_draw_box_interaction( - mpr->color, mpr->highlight_part, size_real, margin); - } - } - else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) { - float color[4]; - manipulator_color_get(mpr, highlight, color); - - GPU_line_smooth(true); - GPU_polygon_smooth(true); - GPU_blend(true); - - GPU_line_width(mpr->line_width + 3.0f); - cage3d_draw_circle_wire(size_real, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - GPU_line_width(mpr->line_width); - cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options); - - /* corner manipulators */ - cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, (const float[3]){0, 0, 0}, true, 60); - cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 40); - - GPU_blend(false); - GPU_polygon_smooth(false); - GPU_line_smooth(false); - } - else { - BLI_assert(0); - } - } - - GPU_line_width(1.0); - gpuPopMatrix(); -} - -/** - * For when we want to draw 3d cage in 3d views. - */ -static void manipulator_cage3d_draw_select(const bContext *C, wmManipulator *mpr, int select_id) -{ - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - manipulator_cage3d_draw_intern(rv3d, mpr, true, false, select_id); -} - -static void manipulator_cage3d_draw(const bContext *C, wmManipulator *mpr) -{ - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - manipulator_cage3d_draw_intern(rv3d, mpr, false, is_highlight, -1); -} - -static int manipulator_cage3d_get_cursor(wmManipulator *mpr) -{ - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - return BC_NSEW_SCROLLCURSOR; - } - - return CURSOR_STD; -} - -typedef struct RectTransformInteraction { - float orig_mouse[3]; - float orig_matrix_offset[4][4]; - float orig_matrix_final_no_offset[4][4]; -} RectTransformInteraction; - -static void manipulator_cage3d_setup(wmManipulator *mpr) -{ - mpr->flag |= /* WM_MANIPULATOR_DRAW_MODAL | */ /* TODO */ - WM_MANIPULATOR_DRAW_NO_SCALE; -} - -static int manipulator_cage3d_invoke( - bContext *C, wmManipulator *mpr, const wmEvent *event) -{ - RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); - - copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); - manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset, true); - - if (manipulator_window_project_3d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) - { - zero_v3(data->orig_mouse); - } - - mpr->interaction_data = data; - - return OPERATOR_RUNNING_MODAL; -} - -static int manipulator_cage3d_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) -{ - /* For transform logic to be managable we operate in -0.5..0.5 2D space, - * no matter the size of the rectangle, mouse coorts are scaled to unit space. - * The mouse coords have been projected into the matrix so we don't need to worry about axis alignment. - * - * - The cursor offset are multiplied by 'dims'. - * - Matrix translation is also multiplied by 'dims'. - */ - RectTransformInteraction *data = mpr->interaction_data; - float point_local[3]; - - float dims[3]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); - - { - float matrix_back[4][4]; - copy_m4_m4(matrix_back, mpr->matrix_offset); - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - - bool ok = manipulator_window_project_3d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, false, point_local); - copy_m4_m4(mpr->matrix_offset, matrix_back); - if (!ok) { - return OPERATOR_RUNNING_MODAL; - } - } - - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - wmManipulatorProperty *mpr_prop; - - mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); - } - - if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_TRANSLATE) { - /* do this to prevent clamping from changing size */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); - mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); - mpr->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]); - } - else if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_ROTATE) { - /* TODO (if needed) */ - } - else { - /* scale */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - float pivot[3]; - bool constrain_axis[3] = {false}; - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); - } - else { - zero_v3(pivot); - } - - /* Cursor deltas scaled to (-0.5..0.5). */ - float delta_orig[3], delta_curr[3]; - - for (int i = 0; i < 3; i++) { - delta_orig[i] = ((data->orig_mouse[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i]; - delta_curr[i] = ((point_local[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i]; - } - - float scale[3] = {1.0f, 1.0f, 1.0f}; - for (int i = 0; i < 3; i++) { - if (constrain_axis[i] == false) { - if (delta_orig[i] < 0.0f) { - delta_orig[i] *= -1.0f; - delta_curr[i] *= -1.0f; - } - const int sign = signum_i(scale[i]); - - scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i])); - - if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) { - if (sign != signum_i(scale[i])) { - scale[i] = 0.0f; - } - } - } - } - - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) { - if (constrain_axis[0] == false && constrain_axis[1] == false) { - scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f; - } - else if (constrain_axis[0] == false) { - scale[1] = scale[0]; - } - else if (constrain_axis[1] == false) { - scale[0] = scale[1]; - } - else { - BLI_assert(0); - } - } - - /* scale around pivot */ - float matrix_scale[4][4]; - unit_m4(matrix_scale); - - mul_v3_fl(matrix_scale[0], scale[0]); - mul_v3_fl(matrix_scale[1], scale[1]); - mul_v3_fl(matrix_scale[2], scale[2]); - - transform_pivot_set_m4( - matrix_scale, - (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]}); - mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale); - } - - if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); - } - - /* tag the region for redraw */ - ED_region_tag_redraw(CTX_wm_region(C)); - WM_event_add_mousemove(C); - - return OPERATOR_RUNNING_MODAL; -} - -static void manipulator_cage3d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) -{ - if (STREQ(mpr_prop->type->idname, "matrix")) { - if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); - } - else { - BLI_assert(0); - } - } - else { - BLI_assert(0); - } -} - -static void manipulator_cage3d_exit(bContext *C, wmManipulator *mpr, const bool cancel) -{ - RectTransformInteraction *data = mpr->interaction_data; - - if (!cancel) - return; - - wmManipulatorProperty *mpr_prop; - - /* reset properties */ - mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); - } - - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); -} - - -/* -------------------------------------------------------------------- */ -/** \name Cage Manipulator API - * - * \{ */ - -static void MANIPULATOR_WT_cage_3d(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "MANIPULATOR_WT_cage_3d"; - - /* api callbacks */ - wt->draw = manipulator_cage3d_draw; - wt->draw_select = manipulator_cage3d_draw_select; - wt->setup = manipulator_cage3d_setup; - wt->invoke = manipulator_cage3d_invoke; - wt->property_update = manipulator_cage3d_property_update; - wt->modal = manipulator_cage3d_modal; - wt->exit = manipulator_cage3d_exit; - wt->cursor_get = manipulator_cage3d_get_cursor; - - wt->struct_size = sizeof(wmManipulator); - - /* rna */ - static EnumPropertyItem rna_enum_draw_style[] = { - {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""}, - {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem rna_enum_transform[] = { - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""}, - {0, NULL, 0, NULL, NULL} - }; - static float unit_v3[3] = {1.0f, 1.0f, 1.0f}; - RNA_def_float_vector(wt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); - RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); - RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options, - ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); - - WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16); -} - -void ED_manipulatortypes_cage_3d(void) -{ - WM_manipulatortype_append(MANIPULATOR_WT_cage_3d); -} - -/** \} */ diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c deleted file mode 100644 index 74ba8bd77a9..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c +++ /dev/null @@ -1,487 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file dial3d_manipulator.c - * \ingroup wm - * - * \name Dial Manipulator - * - * 3D Manipulator - * - * \brief Circle shaped manipulator for circular interaction. - * Currently no own handling, use with operator only. - * - * - `matrix[0]` is derived from Y and Z. - * - `matrix[1]` is 'up' when DialManipulator.use_start_y_axis is set. - * - `matrix[2]` is the axis the dial rotates around (all dials). - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_matrix.h" -#include "GPU_select.h" -#include "GPU_state.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" -#include "ED_view3d.h" -#include "ED_manipulator_library.h" - -/* own includes */ -#include "../manipulator_geometry.h" -#include "../manipulator_library_intern.h" - -/* to use custom dials exported to geom_dial_manipulator.c */ -// #define USE_MANIPULATOR_CUSTOM_DIAL - -static int manipulator_dial_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak tweak_flag); - -typedef struct DialInteraction { - float init_mval[2]; - - /* only for when using properties */ - float init_prop_angle; - - /* cache the last angle to detect rotations bigger than -/+ PI */ - float last_angle; - /* number of full rotations */ - int rotations; - - /* final output values, used for drawing */ - struct { - float angle_ofs; - float angle_delta; - } output; -} DialInteraction; - -#define DIAL_WIDTH 1.0f -#define DIAL_RESOLUTION 48 - -/* Could make option, negative to clip more (don't show when view aligned). */ -#define DIAL_CLIP_BIAS 0.02 - -/** - * We can't use this for the #wmManipulatorType.matrix_basis_get callback, it conflicts with depth picking. - */ -static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4]) -{ - float rot[3][3]; - const float up[3] = {0.0f, 0.0f, 1.0f}; - - rotation_between_vecs_to_mat3(rot, up, mpr->matrix_basis[2]); - copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], mpr->matrix_basis[3]); -} - -/* -------------------------------------------------------------------- */ - -static void dial_geom_draw( - const wmManipulator *mpr, const float color[4], const bool select, - float axis_modal_mat[4][4], float clip_plane[4]) -{ -#ifdef USE_MANIPULATOR_CUSTOM_DIAL - UNUSED_VARS(dial, col, axis_modal_mat, clip_plane); - wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_dial, select); -#else - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - const bool filled = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL) != 0; - - GPU_line_width(mpr->line_width); - - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - if (clip_plane) { - immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR); - float clip_plane_f[4] = {clip_plane[0], clip_plane[1], clip_plane[2], clip_plane[3]}; - immUniform4fv("ClipPlane", clip_plane_f); - immUniformMatrix4fv("ModelMatrix", axis_modal_mat); - } - else { - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - } - - immUniformColor4fv(color); - - if (filled) { - imm_draw_circle_fill_2d(pos, 0, 0, 1.0, DIAL_RESOLUTION); - } - else { - imm_draw_circle_wire_2d(pos, 0, 0, 1.0, DIAL_RESOLUTION); - } - - immUnbindProgram(); - - UNUSED_VARS(select); -#endif -} - -/** - * Draws a line from (0, 0, 0) to \a co_outer, at \a angle. - */ -static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4]) -{ - GPU_line_width(1.0f); - - gpuPushMatrix(); - gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); - - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - - immUniformColor4fv(color); - - immBegin(GWN_PRIM_LINE_STRIP, 2); - immVertex3f(pos, 0.0f, 0.0f, 0.0f); - immVertex3fv(pos, co_outer); - immEnd(); - - immUnbindProgram(); - - gpuPopMatrix(); -} - -static void dial_ghostarc_draw( - const wmManipulator *mpr, const float angle_ofs, const float angle_delta, const float color[4]) -{ - const float width_inner = DIAL_WIDTH - mpr->line_width * 0.5f / U.manipulator_size; - - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor4fv(color); - imm_draw_disk_partial_fill_2d( - pos, 0, 0, 0.0, width_inner, DIAL_RESOLUTION, RAD2DEGF(angle_ofs), RAD2DEGF(angle_delta)); - immUnbindProgram(); -} - -static void dial_ghostarc_get_angles( - struct Depsgraph *depsgraph, - const wmManipulator *mpr, - const wmEvent *event, - const ARegion *ar, const View3D *v3d, - float mat[4][4], const float co_outer[3], - float *r_start, float *r_delta) -{ - DialInteraction *inter = mpr->interaction_data; - const RegionView3D *rv3d = ar->regiondata; - const float mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; - - /* we might need to invert the direction of the angles */ - float view_vec[3], axis_vec[3]; - ED_view3d_global_to_vector(rv3d, mpr->matrix_basis[3], view_vec); - normalize_v3_v3(axis_vec, mpr->matrix_basis[2]); - - float proj_outer_rel[3]; - mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer); - sub_v3_v3(proj_outer_rel, mpr->matrix_basis[3]); - - float proj_mval_new_rel[3]; - float proj_mval_init_rel[3]; - float dial_plane[4]; - float ray_co[3], ray_no[3]; - float ray_lambda; - - plane_from_point_normal_v3(dial_plane, mpr->matrix_basis[3], axis_vec); - - if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, inter->init_mval, ray_co, ray_no, false) || - !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) - { - goto fail; - } - madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_init_rel, mpr->matrix_basis[3]); - - if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, mval, ray_co, ray_no, false) || - !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) - { - goto fail; - } - madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_new_rel, mpr->matrix_basis[3]); - - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - - /* Start direction from mouse or set by user */ - const float *proj_init_rel = - (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y) ? - mpr->matrix_basis[1] : proj_mval_init_rel; - - /* return angles */ - const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec)); - const float delta = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_mval_init_rel, proj_mval_new_rel, axis_vec)); - - /* Change of sign, we passed the 180 degree threshold. This means we need to add a turn - * to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2. - * Logic taken from BLI_dial_angle */ - if ((delta * inter->last_angle < 0.0f) && - (fabsf(inter->last_angle) > (float)M_PI_2)) - { - if (inter->last_angle < 0.0f) - inter->rotations--; - else - inter->rotations++; - } - inter->last_angle = delta; - - *r_start = start; - *r_delta = fmod(delta + 2.0f * (float)M_PI * inter->rotations, 2 * (float)M_PI); - return; - - /* If we can't project (unlikely). */ -fail: - *r_start = 0.0; - *r_delta = 0.0; -} - -static void dial_draw_intern( - const bContext *C, wmManipulator *mpr, - const bool select, const bool highlight, float clip_plane[4]) -{ - float matrix_basis_adjust[4][4]; - float matrix_final[4][4]; - float color[4]; - - BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D); - - manipulator_color_get(mpr, highlight, color); - - dial_calc_matrix(mpr, matrix_basis_adjust); - - WM_manipulator_calc_matrix_final_params( - mpr, &((struct WM_ManipulatorMatrixParams) { - .matrix_basis = (void *)matrix_basis_adjust, - }), matrix_final); - - gpuPushMatrix(); - gpuMultMatrix(matrix_final); - - /* draw rotation indicator arc first */ - if ((mpr->flag & WM_MANIPULATOR_DRAW_VALUE) && - (mpr->state & WM_MANIPULATOR_STATE_MODAL)) - { - const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ - - DialInteraction *inter = mpr->interaction_data; - - /* XXX, View3D rotation manipulator doesn't call modal. */ - if (!WM_manipulator_target_property_is_valid_any(mpr)) { - wmWindow *win = CTX_wm_window(C); - manipulator_dial_modal((bContext *)C, mpr, win->eventstate, 0); - } - - float angle_ofs = inter->output.angle_ofs; - float angle_delta = inter->output.angle_delta; - - /* draw! */ - for (int i = 0; i < 2; i++) { - GPU_polygon_smooth(false); - dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f}); - GPU_polygon_smooth(true); - - dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */ - dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */ - - if (i == 0) { - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - if ((draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) { - break; - } - } - - angle_ofs += (float)M_PI; - } - } - - /* draw actual dial manipulator */ - dial_geom_draw(mpr, color, select, matrix_basis_adjust, clip_plane); - - gpuPopMatrix(); -} - -static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int select_id) -{ - float clip_plane_buf[4]; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - float *clip_plane = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL; - - /* enable clipping if needed */ - if (clip_plane) { - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - - copy_v3_v3(clip_plane, rv3d->viewinv[2]); - clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]); - clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final; - glEnable(GL_CLIP_DISTANCE0); - } - - GPU_select_load_id(select_id); - dial_draw_intern(C, mpr, true, false, clip_plane); - - if (clip_plane) { - glDisable(GL_CLIP_DISTANCE0); - } -} - -static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) -{ - const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - float clip_plane_buf[4]; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - float *clip_plane = (!is_modal && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL; - - /* enable clipping if needed */ - if (clip_plane) { - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - - copy_v3_v3(clip_plane, rv3d->viewinv[2]); - clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]); - clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final; - - glEnable(GL_CLIP_DISTANCE0); - } - - GPU_blend(true); - dial_draw_intern(C, mpr, false, is_highlight, clip_plane); - GPU_blend(false); - - if (clip_plane) { - glDisable(GL_CLIP_DISTANCE0); - } -} - -static int manipulator_dial_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) -{ - const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ - float angle_ofs, angle_delta; - - float matrix[4][4]; - - dial_calc_matrix(mpr, matrix); - - dial_ghostarc_get_angles( - CTX_data_depsgraph(C), - mpr, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta); - - DialInteraction *inter = mpr->interaction_data; - - inter->output.angle_delta = angle_delta; - inter->output.angle_ofs = angle_ofs; - - /* set the property for the operator and call its modal function */ - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); - } - return OPERATOR_RUNNING_MODAL; -} - - -static void manipulator_dial_setup(wmManipulator *mpr) -{ - const float dir_default[3] = {0.0f, 0.0f, 1.0f}; - - /* defaults */ - copy_v3_v3(mpr->matrix_basis[2], dir_default); -} - -static int manipulator_dial_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) -{ - DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__); - - inter->init_mval[0] = event->mval[0]; - inter->init_mval[1] = event->mval[1]; - - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - inter->init_prop_angle = WM_manipulator_target_property_value_get(mpr, mpr_prop); - } - - mpr->interaction_data = inter; - - return OPERATOR_RUNNING_MODAL; -} - -/* -------------------------------------------------------------------- */ -/** \name Dial Manipulator API - * - * \{ */ - -static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "MANIPULATOR_WT_dial_3d"; - - /* api callbacks */ - wt->draw = manipulator_dial_draw; - wt->draw_select = manipulator_dial_draw_select; - wt->setup = manipulator_dial_setup; - wt->invoke = manipulator_dial_invoke; - wt->modal = manipulator_dial_modal; - - wt->struct_size = sizeof(wmManipulator); - - /* rna */ - static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""}, - {ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, - {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""}, - {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""}, - {0, NULL, 0, NULL, NULL} - }; - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - - WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1); -} - -void ED_manipulatortypes_dial_3d(void) -{ - WM_manipulatortype_append(MANIPULATOR_WT_dial_3d); -} - -/** \} */ diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c deleted file mode 100644 index 458dc2fd1c8..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file grab3d_manipulator.c - * \ingroup wm - * - * \name Grab Manipulator - * - * 3D Manipulator, also works in 2D views. - * - * \brief Simple manipulator to grab and translate. - * - * - `matrix[0]` is derived from Y and Z. - * - `matrix[1]` currently not used. - * - `matrix[2]` is the widget direction (for all manipulators). - * - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_matrix.h" -#include "GPU_select.h" -#include "GPU_state.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" -#include "ED_view3d.h" -#include "ED_manipulator_library.h" - -/* own includes */ -#include "../manipulator_geometry.h" -#include "../manipulator_library_intern.h" - -typedef struct GrabManipulator3D { - wmManipulator manipulator; - /* Added to 'matrix_basis' when calculating the matrix. */ - float prop_co[3]; -} GrabManipulator3D; - -static void manipulator_grab_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4]) -{ - GrabManipulator3D *grab = (GrabManipulator3D *)mpr; - - copy_m4_m4(r_matrix, grab->manipulator.matrix_basis); - add_v3_v3(r_matrix[3], grab->prop_co); -} - -static int manipulator_grab_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak tweak_flag); - -typedef struct GrabInteraction { - float init_mval[2]; - - /* only for when using properties */ - float init_prop_co[3]; - - float init_matrix_final[4][4]; -} GrabInteraction; - -#define DIAL_RESOLUTION 32 - -/* -------------------------------------------------------------------- */ - -static void grab_geom_draw( - const wmManipulator *mpr, const float color[4], const bool select, const int draw_options) -{ -#ifdef USE_MANIPULATOR_CUSTOM_DIAL - UNUSED_VARS(grab3d, col, axis_modal_mat); - wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_grab3d, select); -#else - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0; - - GPU_line_width(mpr->line_width); - - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - - immUniformColor4fv(color); - - if (draw_style == ED_MANIPULATOR_GRAB_STYLE_RING_2D) { - if (filled) { - imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION); - } - else { - imm_draw_circle_wire_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION); - } - } - else if (draw_style == ED_MANIPULATOR_GRAB_STYLE_CROSS_2D) { - immBegin(GWN_PRIM_LINES, 4); - immVertex2f(pos, 1.0f, 1.0f); - immVertex2f(pos, -1.0f, -1.0f); - - immVertex2f(pos, -1.0f, 1.0f); - immVertex2f(pos, 1.0f, -1.0f); - immEnd(); - } - else { - BLI_assert(0); - } - - immUnbindProgram(); - - UNUSED_VARS(select); -#endif -} - -static void grab3d_get_translate( - const wmManipulator *mpr, const wmEvent *event, const ARegion *ar, - float co_delta[3]) -{ - GrabInteraction *inter = mpr->interaction_data; - const float mval_delta[2] = { - event->mval[0] - inter->init_mval[0], - event->mval[1] - inter->init_mval[1], - }; - - RegionView3D *rv3d = ar->regiondata; - float co_ref[3]; - mul_v3_mat3_m4v3(co_ref, mpr->matrix_space, inter->init_prop_co); - const float zfac = ED_view3d_calc_zfac(rv3d, co_ref, NULL); - - ED_view3d_win_to_delta(ar, mval_delta, co_delta, zfac); - - float matrix_space_inv[3][3]; - copy_m3_m4(matrix_space_inv, mpr->matrix_space); - invert_m3(matrix_space_inv); - mul_m3_v3(matrix_space_inv, co_delta); -} - -static void grab3d_draw_intern( - const bContext *C, wmManipulator *mpr, - const bool select, const bool highlight) -{ - GrabInteraction *inter = mpr->interaction_data; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - const bool align_view = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0; - float color[4]; - float matrix_final[4][4]; - float matrix_align[4][4]; - - manipulator_color_get(mpr, highlight, color); - WM_manipulator_calc_matrix_final(mpr, matrix_final); - - gpuPushMatrix(); - gpuMultMatrix(matrix_final); - - if (align_view) { - float matrix_final_unit[4][4]; - RegionView3D *rv3d = CTX_wm_region_view3d(C); - normalize_m4_m4(matrix_final_unit, matrix_final); - mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); - zero_v3(matrix_align[3]); - transpose_m4(matrix_align); - gpuMultMatrix(matrix_align); - } - - GPU_blend(true); - grab_geom_draw(mpr, color, select, draw_options); - GPU_blend(false); - gpuPopMatrix(); - - if (mpr->interaction_data) { - gpuPushMatrix(); - gpuMultMatrix(inter->init_matrix_final); - - if (align_view) { - gpuMultMatrix(matrix_align); - } - - GPU_blend(true); - grab_geom_draw(mpr, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); - GPU_blend(false); - gpuPopMatrix(); - } -} - -static void manipulator_grab_draw_select(const bContext *C, wmManipulator *mpr, int select_id) -{ - GPU_select_load_id(select_id); - grab3d_draw_intern(C, mpr, true, false); -} - -static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr) -{ - const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - - (void)is_modal; - - GPU_blend(true); - grab3d_draw_intern(C, mpr, false, is_highlight); - GPU_blend(false); -} - -static int manipulator_grab_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) -{ - GrabManipulator3D *grab = (GrabManipulator3D *)mpr; - GrabInteraction *inter = mpr->interaction_data; - ARegion *ar = CTX_wm_region(C); - - float prop_delta[3]; - if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) { - grab3d_get_translate(mpr, event, ar, prop_delta); - } - else { - float mval_proj_init[2], mval_proj_curr[2]; - if ((manipulator_window_project_2d( - C, mpr, inter->init_mval, 2, false, mval_proj_init) == false) || - (manipulator_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) - { - return OPERATOR_RUNNING_MODAL; - } - sub_v2_v2v2(prop_delta, mval_proj_curr, mval_proj_init); - prop_delta[2] = 0.0f; - } - add_v3_v3v3(grab->prop_co, inter->init_prop_co, prop_delta); - - /* set the property for the operator and call its modal function */ - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, grab->prop_co); - } - else { - zero_v3(grab->prop_co); - } - - ED_region_tag_redraw(ar); - - return OPERATOR_RUNNING_MODAL; -} - -static int manipulator_grab_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) -{ - GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__); - - inter->init_mval[0] = event->mval[0]; - inter->init_mval[1] = event->mval[1]; - -#if 0 - copy_v3_v3(inter->init_prop_co, grab->prop_co); -#else - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co); - } -#endif - - WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); - - mpr->interaction_data = inter; - - return OPERATOR_RUNNING_MODAL; -} - - -static int manipulator_grab_test_select( - bContext *C, wmManipulator *mpr, const wmEvent *event) -{ - float point_local[2]; - - if (manipulator_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) - { - return -1; - } - - /* The 'mpr->scale_final' is already applied when projecting. */ - if (len_squared_v2(point_local) < 1.0f) { - return 0; - } - - return -1; -} - -static void manipulator_grab_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) -{ - GrabManipulator3D *grab = (GrabManipulator3D *)mpr; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, grab->prop_co); - } - else { - zero_v3(grab->prop_co); - } -} - -static int manipulator_grab_cursor_get(wmManipulator *UNUSED(mpr)) -{ - return BC_NSEW_SCROLLCURSOR; -} - -/* -------------------------------------------------------------------- */ -/** \name Grab Manipulator API - * - * \{ */ - -static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "MANIPULATOR_WT_grab_3d"; - - /* api callbacks */ - wt->draw = manipulator_grab_draw; - wt->draw_select = manipulator_grab_draw_select; - wt->test_select = manipulator_grab_test_select; - wt->matrix_basis_get = manipulator_grab_matrix_basis_get; - wt->invoke = manipulator_grab_invoke; - wt->property_update = manipulator_grab_property_update; - wt->modal = manipulator_grab_modal; - wt->cursor_get = manipulator_grab_cursor_get; - - wt->struct_size = sizeof(GrabManipulator3D); - - /* rna */ - static EnumPropertyItem rna_enum_draw_style[] = { - {ED_MANIPULATOR_GRAB_STYLE_RING_2D, "RING_2D", 0, "Ring", ""}, - {ED_MANIPULATOR_GRAB_STYLE_CROSS_2D, "CROSS_2D", 0, "Ring", ""}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, - {ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""}, - {0, NULL, 0, NULL, NULL} - }; - - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_GRAB_STYLE_RING_2D, "Draw Style", ""); - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - - WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 3); -} - -void ED_manipulatortypes_grab_3d(void) -{ - WM_manipulatortype_append(MANIPULATOR_WT_grab_3d); -} - -/** \} */ // Grab Manipulator API diff --git a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c deleted file mode 100644 index 419873ccfff..00000000000 --- a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file primitive3d_manipulator.c - * \ingroup wm - * - * \name Primitive Manipulator - * - * 3D Manipulator - * - * \brief Manipulator with primitive drawing type (plane, cube, etc.). - * Currently only plane primitive supported without own handling, use with operator only. - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" - -#include "DNA_view3d_types.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" - -#include "GPU_immediate.h" -#include "GPU_matrix.h" -#include "GPU_select.h" -#include "GPU_state.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_manipulator_library.h" - -/* own includes */ -#include "../manipulator_library_intern.h" - -static float verts_plane[4][3] = { - {-1, -1, 0}, - { 1, -1, 0}, - { 1, 1, 0}, - {-1, 1, 0}, -}; - - -/* -------------------------------------------------------------------- */ - -static void manipulator_primitive_draw_geom( - const float col_inner[4], const float col_outer[4], const int draw_style) -{ - float (*verts)[3]; - uint vert_count = 0; - - if (draw_style == ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE) { - verts = verts_plane; - vert_count = ARRAY_SIZE(verts_plane); - } - - if (vert_count > 0) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, GWN_PRIM_TRI_FAN); - wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, GWN_PRIM_LINE_LOOP); - immUnbindProgram(); - } -} - -static void manipulator_primitive_draw_intern( - wmManipulator *mpr, const bool UNUSED(select), - const bool highlight) -{ - float color_inner[4], color_outer[4]; - float matrix_final[4][4]; - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - - manipulator_color_get(mpr, highlight, color_outer); - copy_v4_v4(color_inner, color_outer); - color_inner[3] *= 0.5f; - - WM_manipulator_calc_matrix_final(mpr, matrix_final); - - gpuPushMatrix(); - gpuMultMatrix(matrix_final); - - GPU_blend(true); - manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); - GPU_blend(false); - - gpuPopMatrix(); - - if (mpr->interaction_data) { - ManipulatorInteraction *inter = mpr->interaction_data; - - copy_v4_fl(color_inner, 0.5f); - copy_v3_fl(color_outer, 0.5f); - color_outer[3] = 0.8f; - - gpuPushMatrix(); - gpuMultMatrix(inter->init_matrix_final); - - GPU_blend(true); - manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); - GPU_blend(false); - - gpuPopMatrix(); - } -} - -static void manipulator_primitive_draw_select( - const bContext *UNUSED(C), wmManipulator *mpr, - int select_id) -{ - GPU_select_load_id(select_id); - manipulator_primitive_draw_intern(mpr, true, false); -} - -static void manipulator_primitive_draw(const bContext *UNUSED(C), wmManipulator *mpr) -{ - manipulator_primitive_draw_intern( - mpr, false, - (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)); -} - -static void manipulator_primitive_setup(wmManipulator *mpr) -{ - mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; -} - -static int manipulator_primitive_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) -{ - ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); - - WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); - - mpr->interaction_data = inter; - - return OPERATOR_RUNNING_MODAL; -} - -/* -------------------------------------------------------------------- */ -/** \name Primitive Manipulator API - * - * \{ */ - -static void MANIPULATOR_WT_primitive_3d(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "MANIPULATOR_WT_primitive_3d"; - - /* api callbacks */ - wt->draw = manipulator_primitive_draw; - wt->draw_select = manipulator_primitive_draw_select; - wt->setup = manipulator_primitive_setup; - wt->invoke = manipulator_primitive_invoke; - - wt->struct_size = sizeof(wmManipulator); - - static EnumPropertyItem rna_enum_draw_style[] = { - {ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""}, - {0, NULL, 0, NULL, NULL} - }; - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); -} - -void ED_manipulatortypes_primitive_3d(void) -{ - WM_manipulatortype_append(MANIPULATOR_WT_primitive_3d); -} - -/** \} */ diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 5cd768b4fe3..81ec591fc89 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -44,7 +44,7 @@ set(INC_SYS set(SRC editface.c editmesh_add.c - editmesh_add_manipulator.c + editmesh_add_gizmo.c editmesh_bevel.c editmesh_bisect.c editmesh_extrude.c diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.c new file mode 100644 index 00000000000..3918d8847a6 --- /dev/null +++ b/source/blender/editors/mesh/editmesh_add_gizmo.c @@ -0,0 +1,426 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/mesh/editmesh_add_gizmo.c + * \ingroup edmesh + * + * Creation manipulators. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_context.h" +#include "BKE_editmesh.h" + +#include "ED_gizmo_library.h" +#include "ED_mesh.h" +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_undo.h" +#include "ED_view3d.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "UI_resources.h" + +#include "BLT_translation.h" + +#include "mesh_intern.h" /* own include */ + +/* -------------------------------------------------------------------- */ +/** \name Helper Functions + * \{ */ + +/** + * When we place a shape, pick a plane. + * + * We may base this choice on context, + * for now pick the "ground" based on the 3D cursor's dominant plane pointing down relative to the view. + */ +static void calc_initial_placement_point_from_view( + bContext *C, const float mval[2], + float r_location[3], float r_rotation[3][3]) +{ + + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + + bool use_mouse_project = true; /* TODO: make optional */ + + float cursor_matrix[4][4]; + float orient_matrix[3][3]; + ED_view3d_cursor3d_calc_mat4(scene, v3d, cursor_matrix); + + float dots[3] = { + dot_v3v3(rv3d->viewinv[2], cursor_matrix[0]), + dot_v3v3(rv3d->viewinv[2], cursor_matrix[1]), + dot_v3v3(rv3d->viewinv[2], cursor_matrix[2]), + }; + const int axis = axis_dominant_v3_single(dots); + + copy_v3_v3(orient_matrix[0], cursor_matrix[(axis + 1) % 3]); + copy_v3_v3(orient_matrix[1], cursor_matrix[(axis + 2) % 3]); + copy_v3_v3(orient_matrix[2], cursor_matrix[axis]); + + if (dot_v3v3(rv3d->viewinv[2], orient_matrix[2]) < 0.0f) { + negate_v3(orient_matrix[2]); + } + if (is_negative_m3(orient_matrix)) { + swap_v3_v3(orient_matrix[0], orient_matrix[1]); + } + + if (use_mouse_project) { + float ray_co[3], ray_no[3]; + if (ED_view3d_win_to_ray( + CTX_data_depsgraph(C), + ar, v3d, mval, + ray_co, ray_no, false)) + { + float plane[4]; + plane_from_point_normal_v3(plane, cursor_matrix[3], orient_matrix[2]); + float lambda; + if (isect_ray_plane_v3(ray_co, ray_no, plane, &lambda, true)) { + madd_v3_v3v3fl(r_location, ray_co, ray_no, lambda); + copy_m3_m3(r_rotation, orient_matrix); + return; + } + } + } + + /* fallback */ + copy_v3_v3(r_location, cursor_matrix[3]); + copy_m3_m3(r_rotation, orient_matrix); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Placement Manipulator + * \{ */ + +typedef struct ManipulatorPlacementGroup { + struct wmManipulator *cage; + struct { + bContext *context; + wmOperator *op; + PropertyRNA *prop_matrix; + } data; +} ManipulatorPlacementGroup; + +/** + * \warning Calling redo from property updates is not great. + * This is needed because changing the RNA doesn't cause a redo + * and we're not using operator UI which does just this. + */ +static void manipulator_placement_exec(ManipulatorPlacementGroup *man) +{ + wmOperator *op = man->data.op; + if (op == WM_operator_last_redo((bContext *)man->data.context)) { + ED_undo_operator_repeat((bContext *)man->data.context, op); + } +} + +static void manipulator_mesh_placement_update_from_op(ManipulatorPlacementGroup *man) +{ + wmOperator *op = man->data.op; + UNUSED_VARS(op); + /* For now don't read back from the operator. */ +#if 0 + RNA_property_float_get_array(op->ptr, man->data.prop_matrix, &man->cage->matrix_offset[0][0]); +#endif +} + +/* translate callbacks */ +static void manipulator_placement_prop_matrix_get( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + void *value_p) +{ + ManipulatorPlacementGroup *man = mpr->parent_mgroup->customdata; + wmOperator *op = man->data.op; + float *value = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + UNUSED_VARS_NDEBUG(mpr_prop); + + if (value_p != man->cage->matrix_offset) { + mul_m4_m4m4(value_p, man->cage->matrix_basis, man->cage->matrix_offset); + RNA_property_float_get_array(op->ptr, man->data.prop_matrix, value); + } +} + +static void manipulator_placement_prop_matrix_set( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + const void *value) +{ + ManipulatorPlacementGroup *man = mpr->parent_mgroup->customdata; + wmOperator *op = man->data.op; + + BLI_assert(mpr_prop->type->array_length == 16); + UNUSED_VARS_NDEBUG(mpr_prop); + + float mat[4][4]; + mul_m4_m4m4(mat, man->cage->matrix_basis, value); + + if (is_negative_m4(mat)) { + negate_mat3_m4(mat); + } + + RNA_property_float_set_array(op->ptr, man->data.prop_matrix, &mat[0][0]); + + manipulator_placement_exec(man); +} + +static bool manipulator_mesh_placement_poll(const bContext *C, wmManipulatorGroupType *wgt) +{ + wmOperator *op = WM_operator_last_redo(C); + if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_manipulator")) { + WM_manipulator_group_type_unlink_delayed_ptr(wgt); + return false; + } + return true; +} + +static void manipulator_mesh_placement_modal_from_setup( + const bContext *C, wmManipulatorGroup *mgroup) +{ + ManipulatorPlacementGroup *man = mgroup->customdata; + + /* Initial size. */ + { + wmManipulator *mpr = man->cage; + zero_m4(mpr->matrix_offset); + + /* TODO: support zero scaled matrix in 'MANIPULATOR_WT_cage_3d'. */ + mpr->matrix_offset[0][0] = 0.01; + mpr->matrix_offset[1][1] = 0.01; + mpr->matrix_offset[2][2] = 0.01; + mpr->matrix_offset[3][3] = 1.0f; + } + + /* Start off dragging. */ + { + wmWindow *win = CTX_wm_window(C); + ARegion *ar = CTX_wm_region(C); + wmManipulator *mpr = man->cage; + + { + float mat3[3][3]; + float location[3]; + calc_initial_placement_point_from_view( + (bContext *)C, (float[2]){ + win->eventstate->x - ar->winrct.xmin, + win->eventstate->y - ar->winrct.ymin, + }, + location, mat3); + copy_m4_m3(mpr->matrix_basis, mat3); + copy_v3_v3(mpr->matrix_basis[3], location); + } + + if (1) { + wmManipulatorMap *mmap = mgroup->parent_mmap; + WM_manipulator_modal_set_from_setup( + mmap, (bContext *)C, man->cage, ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, win->eventstate); + } + } +} + +static void manipulator_mesh_placement_setup(const bContext *C, wmManipulatorGroup *mgroup) +{ + wmOperator *op = WM_operator_last_redo(C); + + if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_manipulator")) { + return; + } + + struct ManipulatorPlacementGroup *man = MEM_callocN(sizeof(ManipulatorPlacementGroup), __func__); + mgroup->customdata = man; + + const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true); + + man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->cage->color); + + RNA_enum_set(man->cage->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED); + + WM_manipulator_set_flag(man->cage, WM_MANIPULATOR_DRAW_VALUE, true); + + man->data.context = (bContext *)C; + man->data.op = op; + man->data.prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); + + manipulator_mesh_placement_update_from_op(man); + + /* Setup property callbacks */ + { + WM_manipulator_target_property_def_func( + man->cage, "matrix", + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = manipulator_placement_prop_matrix_get, + .value_set_fn = manipulator_placement_prop_matrix_set, + .range_get_fn = NULL, + .user_data = NULL, + }); + } + + manipulator_mesh_placement_modal_from_setup(C, mgroup); +} + +static void manipulator_mesh_placement_draw_prepare( + const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + ManipulatorPlacementGroup *man = mgroup->customdata; + if (man->data.op->next) { + man->data.op = WM_operator_last_redo((bContext *)man->data.context); + } + manipulator_mesh_placement_update_from_op(man); +} + +static void MESH_WGT_add_bounds(struct wmManipulatorGroupType *wgt) +{ + wgt->name = "Mesh Add Bounds"; + wgt->idname = "MESH_WGT_add_bounds"; + + wgt->flag = WM_MANIPULATORGROUPTYPE_3D; + + wgt->mmap_params.spaceid = SPACE_VIEW3D; + wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + + wgt->poll = manipulator_mesh_placement_poll; + wgt->setup = manipulator_mesh_placement_setup; + wgt->draw_prepare = manipulator_mesh_placement_draw_prepare; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Add Cube Manipulator-Operator + * + * For now we use a separate operator to add a cube, + * we can try to merge then however they are invoked differently + * and share the same BMesh creation code. + * \{ */ + + +static int add_primitive_cube_manipulator_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C);; + BMEditMesh *em = BKE_editmesh_from_object(obedit); + float matrix[4][4]; + + /* Get the matrix that defines the cube bounds (as set by the manipulator cage). */ + { + PropertyRNA *prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); + if (RNA_property_is_set(op->ptr, prop_matrix)) { + RNA_property_float_get_array(op->ptr, prop_matrix, &matrix[0][0]); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_m4m4(matrix, obedit->imat, matrix); + } + else { + /* For the first update the widget may not set the matrix. */ + return OPERATOR_FINISHED; + } + } + + const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs"); + + if (calc_uvs) { + ED_mesh_uv_texture_ensure(obedit->data, NULL); + } + + if (!EDBM_op_call_and_selectf( + em, op, "verts.out", false, + "create_cube matrix=%m4 size=%f calc_uvs=%b", + matrix, 1.0f, calc_uvs)) + { + return OPERATOR_CANCELLED; + } + + EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); + EDBM_update_generic(em, true, true); + + return OPERATOR_FINISHED; +} + +static int add_primitive_cube_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + View3D *v3d = CTX_wm_view3d(C); + + int ret = add_primitive_cube_manipulator_exec(C, op); + if (ret & OPERATOR_FINISHED) { + /* Setup manipulators */ + if (v3d && ((v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0)) { + ARegion *ar = CTX_wm_region(C); + wmManipulatorMap *mmap = ar->manipulator_map; + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find("MESH_WGT_add_bounds", false); + wmManipulatorGroup *mgroup = WM_manipulatormap_group_find_ptr(mmap, wgt); + if (mgroup != NULL) { + ManipulatorPlacementGroup *man = mgroup->customdata; + man->data.op = op; + manipulator_mesh_placement_modal_from_setup(C, mgroup); + } + else { + WM_manipulator_group_type_ensure_ptr(wgt); + } + } + } + + return ret; +} + +void MESH_OT_primitive_cube_add_manipulator(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Cube"; + ot->description = "Construct a cube mesh"; + ot->idname = "MESH_OT_primitive_cube_add_manipulator"; + + /* api callbacks */ + ot->invoke = add_primitive_cube_manipulator_invoke; + ot->exec = add_primitive_cube_manipulator_exec; + ot->poll = ED_operator_editmesh_view3d; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + ED_object_add_mesh_props(ot); + ED_object_add_generic_props(ot, true); + + /* hidden props */ + PropertyRNA *prop = RNA_def_float_matrix(ot->srna, "matrix", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + + WM_manipulatorgrouptype_append(MESH_WGT_add_bounds); +} + +/** \} */ diff --git a/source/blender/editors/mesh/editmesh_add_manipulator.c b/source/blender/editors/mesh/editmesh_add_manipulator.c deleted file mode 100644 index f1704972e81..00000000000 --- a/source/blender/editors/mesh/editmesh_add_manipulator.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/mesh/editmesh_add_manipulator.c - * \ingroup edmesh - * - * Creation manipulators. - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" - -#include "DNA_object_types.h" -#include "DNA_scene_types.h" - -#include "BKE_context.h" -#include "BKE_editmesh.h" - -#include "ED_manipulator_library.h" -#include "ED_mesh.h" -#include "ED_object.h" -#include "ED_screen.h" -#include "ED_undo.h" -#include "ED_view3d.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "UI_resources.h" - -#include "BLT_translation.h" - -#include "mesh_intern.h" /* own include */ - -/* -------------------------------------------------------------------- */ -/** \name Helper Functions - * \{ */ - -/** - * When we place a shape, pick a plane. - * - * We may base this choice on context, - * for now pick the "ground" based on the 3D cursor's dominant plane pointing down relative to the view. - */ -static void calc_initial_placement_point_from_view( - bContext *C, const float mval[2], - float r_location[3], float r_rotation[3][3]) -{ - - Scene *scene = CTX_data_scene(C); - View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - - bool use_mouse_project = true; /* TODO: make optional */ - - float cursor_matrix[4][4]; - float orient_matrix[3][3]; - ED_view3d_cursor3d_calc_mat4(scene, v3d, cursor_matrix); - - float dots[3] = { - dot_v3v3(rv3d->viewinv[2], cursor_matrix[0]), - dot_v3v3(rv3d->viewinv[2], cursor_matrix[1]), - dot_v3v3(rv3d->viewinv[2], cursor_matrix[2]), - }; - const int axis = axis_dominant_v3_single(dots); - - copy_v3_v3(orient_matrix[0], cursor_matrix[(axis + 1) % 3]); - copy_v3_v3(orient_matrix[1], cursor_matrix[(axis + 2) % 3]); - copy_v3_v3(orient_matrix[2], cursor_matrix[axis]); - - if (dot_v3v3(rv3d->viewinv[2], orient_matrix[2]) < 0.0f) { - negate_v3(orient_matrix[2]); - } - if (is_negative_m3(orient_matrix)) { - swap_v3_v3(orient_matrix[0], orient_matrix[1]); - } - - if (use_mouse_project) { - float ray_co[3], ray_no[3]; - if (ED_view3d_win_to_ray( - CTX_data_depsgraph(C), - ar, v3d, mval, - ray_co, ray_no, false)) - { - float plane[4]; - plane_from_point_normal_v3(plane, cursor_matrix[3], orient_matrix[2]); - float lambda; - if (isect_ray_plane_v3(ray_co, ray_no, plane, &lambda, true)) { - madd_v3_v3v3fl(r_location, ray_co, ray_no, lambda); - copy_m3_m3(r_rotation, orient_matrix); - return; - } - } - } - - /* fallback */ - copy_v3_v3(r_location, cursor_matrix[3]); - copy_m3_m3(r_rotation, orient_matrix); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Placement Manipulator - * \{ */ - -typedef struct ManipulatorPlacementGroup { - struct wmManipulator *cage; - struct { - bContext *context; - wmOperator *op; - PropertyRNA *prop_matrix; - } data; -} ManipulatorPlacementGroup; - -/** - * \warning Calling redo from property updates is not great. - * This is needed because changing the RNA doesn't cause a redo - * and we're not using operator UI which does just this. - */ -static void manipulator_placement_exec(ManipulatorPlacementGroup *man) -{ - wmOperator *op = man->data.op; - if (op == WM_operator_last_redo((bContext *)man->data.context)) { - ED_undo_operator_repeat((bContext *)man->data.context, op); - } -} - -static void manipulator_mesh_placement_update_from_op(ManipulatorPlacementGroup *man) -{ - wmOperator *op = man->data.op; - UNUSED_VARS(op); - /* For now don't read back from the operator. */ -#if 0 - RNA_property_float_get_array(op->ptr, man->data.prop_matrix, &man->cage->matrix_offset[0][0]); -#endif -} - -/* translate callbacks */ -static void manipulator_placement_prop_matrix_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - void *value_p) -{ - ManipulatorPlacementGroup *man = mpr->parent_mgroup->customdata; - wmOperator *op = man->data.op; - float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - UNUSED_VARS_NDEBUG(mpr_prop); - - if (value_p != man->cage->matrix_offset) { - mul_m4_m4m4(value_p, man->cage->matrix_basis, man->cage->matrix_offset); - RNA_property_float_get_array(op->ptr, man->data.prop_matrix, value); - } -} - -static void manipulator_placement_prop_matrix_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - const void *value) -{ - ManipulatorPlacementGroup *man = mpr->parent_mgroup->customdata; - wmOperator *op = man->data.op; - - BLI_assert(mpr_prop->type->array_length == 16); - UNUSED_VARS_NDEBUG(mpr_prop); - - float mat[4][4]; - mul_m4_m4m4(mat, man->cage->matrix_basis, value); - - if (is_negative_m4(mat)) { - negate_mat3_m4(mat); - } - - RNA_property_float_set_array(op->ptr, man->data.prop_matrix, &mat[0][0]); - - manipulator_placement_exec(man); -} - -static bool manipulator_mesh_placement_poll(const bContext *C, wmManipulatorGroupType *wgt) -{ - wmOperator *op = WM_operator_last_redo(C); - if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_manipulator")) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); - return false; - } - return true; -} - -static void manipulator_mesh_placement_modal_from_setup( - const bContext *C, wmManipulatorGroup *mgroup) -{ - ManipulatorPlacementGroup *man = mgroup->customdata; - - /* Initial size. */ - { - wmManipulator *mpr = man->cage; - zero_m4(mpr->matrix_offset); - - /* TODO: support zero scaled matrix in 'MANIPULATOR_WT_cage_3d'. */ - mpr->matrix_offset[0][0] = 0.01; - mpr->matrix_offset[1][1] = 0.01; - mpr->matrix_offset[2][2] = 0.01; - mpr->matrix_offset[3][3] = 1.0f; - } - - /* Start off dragging. */ - { - wmWindow *win = CTX_wm_window(C); - ARegion *ar = CTX_wm_region(C); - wmManipulator *mpr = man->cage; - - { - float mat3[3][3]; - float location[3]; - calc_initial_placement_point_from_view( - (bContext *)C, (float[2]){ - win->eventstate->x - ar->winrct.xmin, - win->eventstate->y - ar->winrct.ymin, - }, - location, mat3); - copy_m4_m3(mpr->matrix_basis, mat3); - copy_v3_v3(mpr->matrix_basis[3], location); - } - - if (1) { - wmManipulatorMap *mmap = mgroup->parent_mmap; - WM_manipulator_modal_set_from_setup( - mmap, (bContext *)C, man->cage, ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, win->eventstate); - } - } -} - -static void manipulator_mesh_placement_setup(const bContext *C, wmManipulatorGroup *mgroup) -{ - wmOperator *op = WM_operator_last_redo(C); - - if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_manipulator")) { - return; - } - - struct ManipulatorPlacementGroup *man = MEM_callocN(sizeof(ManipulatorPlacementGroup), __func__); - mgroup->customdata = man; - - const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true); - - man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->cage->color); - - RNA_enum_set(man->cage->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED); - - WM_manipulator_set_flag(man->cage, WM_MANIPULATOR_DRAW_VALUE, true); - - man->data.context = (bContext *)C; - man->data.op = op; - man->data.prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); - - manipulator_mesh_placement_update_from_op(man); - - /* Setup property callbacks */ - { - WM_manipulator_target_property_def_func( - man->cage, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_placement_prop_matrix_get, - .value_set_fn = manipulator_placement_prop_matrix_set, - .range_get_fn = NULL, - .user_data = NULL, - }); - } - - manipulator_mesh_placement_modal_from_setup(C, mgroup); -} - -static void manipulator_mesh_placement_draw_prepare( - const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - ManipulatorPlacementGroup *man = mgroup->customdata; - if (man->data.op->next) { - man->data.op = WM_operator_last_redo((bContext *)man->data.context); - } - manipulator_mesh_placement_update_from_op(man); -} - -static void MESH_WGT_add_bounds(struct wmManipulatorGroupType *wgt) -{ - wgt->name = "Mesh Add Bounds"; - wgt->idname = "MESH_WGT_add_bounds"; - - wgt->flag = WM_MANIPULATORGROUPTYPE_3D; - - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - - wgt->poll = manipulator_mesh_placement_poll; - wgt->setup = manipulator_mesh_placement_setup; - wgt->draw_prepare = manipulator_mesh_placement_draw_prepare; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Add Cube Manipulator-Operator - * - * For now we use a separate operator to add a cube, - * we can try to merge then however they are invoked differently - * and share the same BMesh creation code. - * \{ */ - - -static int add_primitive_cube_manipulator_exec(bContext *C, wmOperator *op) -{ - Object *obedit = CTX_data_edit_object(C);; - BMEditMesh *em = BKE_editmesh_from_object(obedit); - float matrix[4][4]; - - /* Get the matrix that defines the cube bounds (as set by the manipulator cage). */ - { - PropertyRNA *prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); - if (RNA_property_is_set(op->ptr, prop_matrix)) { - RNA_property_float_get_array(op->ptr, prop_matrix, &matrix[0][0]); - invert_m4_m4(obedit->imat, obedit->obmat); - mul_m4_m4m4(matrix, obedit->imat, matrix); - } - else { - /* For the first update the widget may not set the matrix. */ - return OPERATOR_FINISHED; - } - } - - const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs"); - - if (calc_uvs) { - ED_mesh_uv_texture_ensure(obedit->data, NULL); - } - - if (!EDBM_op_call_and_selectf( - em, op, "verts.out", false, - "create_cube matrix=%m4 size=%f calc_uvs=%b", - matrix, 1.0f, calc_uvs)) - { - return OPERATOR_CANCELLED; - } - - EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); - EDBM_update_generic(em, true, true); - - return OPERATOR_FINISHED; -} - -static int add_primitive_cube_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ - View3D *v3d = CTX_wm_view3d(C); - - int ret = add_primitive_cube_manipulator_exec(C, op); - if (ret & OPERATOR_FINISHED) { - /* Setup manipulators */ - if (v3d && ((v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0)) { - ARegion *ar = CTX_wm_region(C); - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find("MESH_WGT_add_bounds", false); - wmManipulatorGroup *mgroup = WM_manipulatormap_group_find_ptr(mmap, wgt); - if (mgroup != NULL) { - ManipulatorPlacementGroup *man = mgroup->customdata; - man->data.op = op; - manipulator_mesh_placement_modal_from_setup(C, mgroup); - } - else { - WM_manipulator_group_type_ensure_ptr(wgt); - } - } - } - - return ret; -} - -void MESH_OT_primitive_cube_add_manipulator(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Add Cube"; - ot->description = "Construct a cube mesh"; - ot->idname = "MESH_OT_primitive_cube_add_manipulator"; - - /* api callbacks */ - ot->invoke = add_primitive_cube_manipulator_invoke; - ot->exec = add_primitive_cube_manipulator_exec; - ot->poll = ED_operator_editmesh_view3d; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - ED_object_add_mesh_props(ot); - ED_object_add_generic_props(ot, true); - - /* hidden props */ - PropertyRNA *prop = RNA_def_float_matrix(ot->srna, "matrix", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - - WM_manipulatorgrouptype_append(MESH_WGT_add_bounds); -} - -/** \} */ diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 579cd5e4e08..87a65924979 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -57,7 +57,7 @@ #define USE_MANIPULATOR #ifdef USE_MANIPULATOR -#include "ED_manipulator_library.h" +#include "ED_gizmo_library.h" #include "ED_undo.h" #endif diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index be68bfda09c..b007bcf04ba 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -53,7 +53,7 @@ #include "ED_screen.h" #include "ED_transform.h" #include "ED_view3d.h" -#include "ED_manipulator_library.h" +#include "ED_gizmo_library.h" #include "UI_resources.h" diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index 5c1b9ccc178..74e2833b2d9 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -57,7 +57,7 @@ #define USE_MANIPULATOR #ifdef USE_MANIPULATOR -#include "ED_manipulator_library.h" +#include "ED_gizmo_library.h" #include "ED_undo.h" #endif diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 2ee791e81d6..37f5ed642fe 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -67,7 +67,7 @@ #include "ED_clip.h" #include "ED_mask.h" #include "ED_sequencer.h" -#include "ED_manipulator_library.h" +#include "ED_gizmo_library.h" #include "io_ops.h" diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index 77b1351435b..06a00945452 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -48,7 +48,7 @@ set(SRC node_draw.c node_edit.c node_group.c - node_manipulators.c + node_gizmo.c node_ops.c node_relationships.c node_select.c diff --git a/source/blender/editors/space_node/node_gizmo.c b/source/blender/editors/space_node/node_gizmo.c new file mode 100644 index 00000000000..62b4a4b6583 --- /dev/null +++ b/source/blender/editors/space_node/node_gizmo.c @@ -0,0 +1,621 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_node/node_gizmo.c + * \ingroup spnode + */ + +#include + +#include "BLI_utildefines.h" +#include "BLI_math_matrix.h" +#include "BLI_math_vector.h" +#include "BLI_rect.h" + +#include "BKE_context.h" +#include "BKE_image.h" +#include "BKE_main.h" + +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +#include "IMB_imbuf_types.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "node_intern.h" + + +/* -------------------------------------------------------------------- */ + +/** \name Local Utilities + * \{ */ + +static void node_manipulator_calc_matrix_space( + const SpaceNode *snode, const ARegion *ar, float matrix_space[4][4]) +{ + unit_m4(matrix_space); + mul_v3_fl(matrix_space[0], snode->zoom); + mul_v3_fl(matrix_space[1], snode->zoom); + matrix_space[3][0] = (ar->winx / 2) + snode->xof; + matrix_space[3][1] = (ar->winy / 2) + snode->yof; +} + +static void node_manipulator_calc_matrix_space_with_image_dims( + const SpaceNode *snode, const ARegion *ar, const float image_dims[2], float matrix_space[4][4]) +{ + unit_m4(matrix_space); + mul_v3_fl(matrix_space[0], snode->zoom * image_dims[0]); + mul_v3_fl(matrix_space[1], snode->zoom * image_dims[1]); + matrix_space[3][0] = ((ar->winx / 2) + snode->xof) - ((image_dims[0] / 2.0f) * snode->zoom); + matrix_space[3][1] = ((ar->winy / 2) + snode->yof) - ((image_dims[1] / 2.0f) * snode->zoom); +} + +/** \} */ + + + +/* -------------------------------------------------------------------- */ + +/** \name Backdrop Manipulator + * \{ */ + +static void manipulator_node_backdrop_prop_matrix_get( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + void *value_p) +{ + float (*matrix)[4] = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + const SpaceNode *snode = mpr_prop->custom_func.user_data; + matrix[0][0] = snode->zoom; + matrix[1][1] = snode->zoom; + matrix[3][0] = snode->xof; + matrix[3][1] = snode->yof; +} + +static void manipulator_node_backdrop_prop_matrix_set( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + const void *value_p) +{ + const float (*matrix)[4] = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + SpaceNode *snode = mpr_prop->custom_func.user_data; + snode->zoom = matrix[0][0]; + snode->zoom = matrix[1][1]; + snode->xof = matrix[3][0]; + snode->yof = matrix[3][1]; +} + +static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + SpaceNode *snode = CTX_wm_space_node(C); + + if ((snode->flag & SNODE_BACKDRAW) == 0) { + return false; + } + + if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) { + bNode *node = nodeGetActive(snode->edittree); + + if (node && ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + return true; + } + } + + return false; +} + +static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); + + wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); + + RNA_enum_set(wwrapper->manipulator->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); + + mgroup->customdata = wwrapper; +} + +static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + Main *bmain = CTX_data_main(C); + wmManipulator *cage = ((wmManipulatorWrapper *)mgroup->customdata)->manipulator; + const ARegion *ar = CTX_wm_region(C); + /* center is always at the origin */ + const float origin[3] = {ar->winx / 2, ar->winy / 2}; + + void *lock; + Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + + if (ibuf) { + const float dims[2] = { + (ibuf->x > 0) ? ibuf->x : 64.0f, + (ibuf->y > 0) ? ibuf->y : 64.0f, + }; + + RNA_float_set_array(cage->ptr, "dimensions", dims); + WM_manipulator_set_matrix_location(cage, origin); + WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, false); + + /* need to set property here for undo. TODO would prefer to do this in _init */ + SpaceNode *snode = CTX_wm_space_node(C); +#if 0 + PointerRNA nodeptr; + RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr); + WM_manipulator_target_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1); + WM_manipulator_target_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1); +#endif + + WM_manipulator_target_property_def_func( + cage, "matrix", + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = manipulator_node_backdrop_prop_matrix_get, + .value_set_fn = manipulator_node_backdrop_prop_matrix_set, + .range_get_fn = NULL, + .user_data = snode, + }); + } + else { + WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true); + } + + BKE_image_release_ibuf(ima, ibuf, lock); +} + +void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt) +{ + wgt->name = "Backdrop Transform Widget"; + wgt->idname = "NODE_WGT_backdrop_transform"; + + wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + + wgt->poll = WIDGETGROUP_node_transform_poll; + wgt->setup = WIDGETGROUP_node_transform_setup; + wgt->refresh = WIDGETGROUP_node_transform_refresh; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ + +/** \name Crop Manipulator + * \{ */ + +struct NodeCropWidgetGroup { + wmManipulator *border; + + struct { + float dims[2]; + } state; + + struct { + PointerRNA ptr; + PropertyRNA *prop; + bContext *context; + } update_data; +}; + +static void manipulator_node_crop_update(struct NodeCropWidgetGroup *crop_group) +{ + RNA_property_update(crop_group->update_data.context, &crop_group->update_data.ptr, crop_group->update_data.prop); +} + +static void two_xy_to_rect(const NodeTwoXYs *nxy, rctf *rect, const float dims[2], bool is_relative) +{ + if (is_relative) { + rect->xmin = nxy->fac_x1; + rect->xmax = nxy->fac_x2; + rect->ymin = nxy->fac_y1; + rect->ymax = nxy->fac_y2; + } + else { + rect->xmin = nxy->x1 / dims[0]; + rect->xmax = nxy->x2 / dims[0]; + rect->ymin = nxy->y1 / dims[1]; + rect->ymax = nxy->y2 / dims[1]; + } +} + +static void two_xy_from_rect(NodeTwoXYs *nxy, const rctf *rect, const float dims[2], bool is_relative) +{ + if (is_relative) { + nxy->fac_x1 = rect->xmin; + nxy->fac_x2 = rect->xmax; + nxy->fac_y1 = rect->ymin; + nxy->fac_y2 = rect->ymax; + } + else { + nxy->x1 = rect->xmin * dims[0]; + nxy->x2 = rect->xmax * dims[0]; + nxy->y1 = rect->ymin * dims[1]; + nxy->y2 = rect->ymax * dims[1]; + } +} + +/* scale callbacks */ +static void manipulator_node_crop_prop_matrix_get( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + void *value_p) +{ + float (*matrix)[4] = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata; + const float *dims = crop_group->state.dims; + const bNode *node = mpr_prop->custom_func.user_data; + const NodeTwoXYs *nxy = node->storage; + bool is_relative = (bool)node->custom2; + rctf rct; + two_xy_to_rect(nxy, &rct, dims, is_relative); + matrix[0][0] = BLI_rctf_size_x(&rct); + matrix[1][1] = BLI_rctf_size_y(&rct); + matrix[3][0] = (BLI_rctf_cent_x(&rct) - 0.5f) * dims[0]; + matrix[3][1] = (BLI_rctf_cent_y(&rct) - 0.5f) * dims[1]; +} + +static void manipulator_node_crop_prop_matrix_set( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + const void *value_p) +{ + const float (*matrix)[4] = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata; + const float *dims = crop_group->state.dims; + bNode *node = mpr_prop->custom_func.user_data; + NodeTwoXYs *nxy = node->storage; + bool is_relative = (bool)node->custom2; + rctf rct; + two_xy_to_rect(nxy, &rct, dims, is_relative); + BLI_rctf_resize(&rct, matrix[0][0], matrix[1][1]); + BLI_rctf_recenter(&rct, (matrix[3][0] / dims[0]) + 0.5f, (matrix[3][1] / dims[1]) + 0.5f); + BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, &rct, &rct); + two_xy_from_rect(nxy, &rct, dims, is_relative); + manipulator_node_crop_update(crop_group); +} + +static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + SpaceNode *snode = CTX_wm_space_node(C); + + if ((snode->flag & SNODE_BACKDRAW) == 0) { + return false; + } + + if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) { + bNode *node = nodeGetActive(snode->edittree); + + if (node && ELEM(node->type, CMP_NODE_CROP)) { + /* ignore 'use_crop_size', we can't usefully edit the crop in this case. */ + if ((node->custom1 & (0 << 1)) == 0) { + return true; + } + } + } + + return false; +} + +static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + struct NodeCropWidgetGroup *crop_group = MEM_mallocN(sizeof(struct NodeCropWidgetGroup), __func__); + + crop_group->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); + + RNA_enum_set(crop_group->border->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + + mgroup->customdata = crop_group; +} + +static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + ARegion *ar = CTX_wm_region(C); + wmManipulator *mpr = mgroup->manipulators.first; + + SpaceNode *snode = CTX_wm_space_node(C); + + node_manipulator_calc_matrix_space(snode, ar, mpr->matrix_space); +} + +static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + Main *bmain = CTX_data_main(C); + struct NodeCropWidgetGroup *crop_group = mgroup->customdata; + wmManipulator *mpr = crop_group->border; + + void *lock; + Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + + if (ibuf) { + crop_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f; + crop_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f; + + RNA_float_set_array(mpr->ptr, "dimensions", crop_group->state.dims); + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + + SpaceNode *snode = CTX_wm_space_node(C); + bNode *node = nodeGetActive(snode->edittree); + + crop_group->update_data.context = (bContext *)C; + RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeCrop, node, &crop_group->update_data.ptr); + crop_group->update_data.prop = RNA_struct_find_property(&crop_group->update_data.ptr, "relative"); + + WM_manipulator_target_property_def_func( + mpr, "matrix", + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = manipulator_node_crop_prop_matrix_get, + .value_set_fn = manipulator_node_crop_prop_matrix_set, + .range_get_fn = NULL, + .user_data = node, + }); + } + else { + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + } + + BKE_image_release_ibuf(ima, ibuf, lock); +} + +void NODE_WGT_backdrop_crop(wmManipulatorGroupType *wgt) +{ + wgt->name = "Backdrop Crop Widget"; + wgt->idname = "NODE_WGT_backdrop_crop"; + + wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + + wgt->poll = WIDGETGROUP_node_crop_poll; + wgt->setup = WIDGETGROUP_node_crop_setup; + wgt->draw_prepare = WIDGETGROUP_node_crop_draw_prepare; + wgt->refresh = WIDGETGROUP_node_crop_refresh; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ + +/** \name Sun Beams + * \{ */ + +struct NodeSunBeamsWidgetGroup { + wmManipulator *manipulator; + + struct { + float dims[2]; + } state; +}; + +static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + SpaceNode *snode = CTX_wm_space_node(C); + + if ((snode->flag & SNODE_BACKDRAW) == 0) { + return false; + } + + if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) { + bNode *node = nodeGetActive(snode->edittree); + + if (node && ELEM(node->type, CMP_NODE_SUNBEAMS)) { + return true; + } + } + + return false; +} + +static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + struct NodeSunBeamsWidgetGroup *sbeam_group = MEM_mallocN(sizeof(struct NodeSunBeamsWidgetGroup), __func__); + + sbeam_group->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL); + wmManipulator *mpr = sbeam_group->manipulator; + + RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D); + + mpr->scale_basis = 0.05f; + + mgroup->customdata = sbeam_group; +} + +static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata; + ARegion *ar = CTX_wm_region(C); + wmManipulator *mpr = mgroup->manipulators.first; + + SpaceNode *snode = CTX_wm_space_node(C); + + node_manipulator_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, mpr->matrix_space); +} + +static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + Main *bmain = CTX_data_main(C); + struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata; + wmManipulator *mpr = sbeam_group->manipulator; + + void *lock; + Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + + if (ibuf) { + sbeam_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f; + sbeam_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f; + + SpaceNode *snode = CTX_wm_space_node(C); + bNode *node = nodeGetActive(snode->edittree); + + /* need to set property here for undo. TODO would prefer to do this in _init */ + PointerRNA nodeptr; + RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeSunBeams, node, &nodeptr); + WM_manipulator_target_property_def_rna(mpr, "offset", &nodeptr, "source", -1); + + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true); + } + else { + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + } + + BKE_image_release_ibuf(ima, ibuf, lock); +} + +void NODE_WGT_backdrop_sun_beams(wmManipulatorGroupType *wgt) +{ + wgt->name = "Sun Beams Widget"; + wgt->idname = "NODE_WGT_sbeam"; + + wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + + wgt->poll = WIDGETGROUP_node_sbeam_poll; + wgt->setup = WIDGETGROUP_node_sbeam_setup; + wgt->draw_prepare = WIDGETGROUP_node_sbeam_draw_prepare; + wgt->refresh = WIDGETGROUP_node_sbeam_refresh; +} + +/** \} */ + + + +/* -------------------------------------------------------------------- */ + +/** \name Corner Pin + * \{ */ + +struct NodeCornerPinWidgetGroup { + wmManipulator *manipulators[4]; + + struct { + float dims[2]; + } state; +}; + +static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + SpaceNode *snode = CTX_wm_space_node(C); + + if ((snode->flag & SNODE_BACKDRAW) == 0) { + return false; + } + + if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) { + bNode *node = nodeGetActive(snode->edittree); + + if (node && ELEM(node->type, CMP_NODE_CORNERPIN)) { + return true; + } + } + + return false; +} + +static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + struct NodeCornerPinWidgetGroup *cpin_group = MEM_mallocN(sizeof(struct NodeCornerPinWidgetGroup), __func__); + const wmManipulatorType *wt_grab_3d = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", false); + + for (int i = 0; i < 4; i++) { + cpin_group->manipulators[i] = WM_manipulator_new_ptr(wt_grab_3d, mgroup, NULL); + wmManipulator *mpr = cpin_group->manipulators[i]; + + RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D); + + mpr->scale_basis = 0.01f; + } + + mgroup->customdata = cpin_group; +} + +static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata; + ARegion *ar = CTX_wm_region(C); + + SpaceNode *snode = CTX_wm_space_node(C); + + float matrix_space[4][4]; + node_manipulator_calc_matrix_space_with_image_dims(snode, ar, cpin_group->state.dims, matrix_space); + + for (int i = 0; i < 4; i++) { + wmManipulator *mpr = cpin_group->manipulators[i]; + copy_m4_m4(mpr->matrix_space, matrix_space); + } +} + +static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + Main *bmain = CTX_data_main(C); + struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata; + + void *lock; + Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + + if (ibuf) { + cpin_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f; + cpin_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f; + + SpaceNode *snode = CTX_wm_space_node(C); + bNode *node = nodeGetActive(snode->edittree); + + /* need to set property here for undo. TODO would prefer to do this in _init */ + int i = 0; + for (bNodeSocket *sock = node->inputs.first; sock && i < 4; sock = sock->next) { + if (sock->type == SOCK_VECTOR) { + wmManipulator *mpr = cpin_group->manipulators[i++]; + + PointerRNA sockptr; + RNA_pointer_create((ID *)snode->edittree, &RNA_NodeSocket, sock, &sockptr); + WM_manipulator_target_property_def_rna(mpr, "offset", &sockptr, "default_value", -1); + + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true); + } + } + } + else { + for (int i = 0; i < 4; i++) { + wmManipulator *mpr = cpin_group->manipulators[i]; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + } + } + + BKE_image_release_ibuf(ima, ibuf, lock); +} + +void NODE_WGT_backdrop_corner_pin(wmManipulatorGroupType *wgt) +{ + wgt->name = "Corner Pin Widget"; + wgt->idname = "NODE_WGT_backdrop_corner_pin"; + + wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + + wgt->poll = WIDGETGROUP_node_corner_pin_poll; + wgt->setup = WIDGETGROUP_node_corner_pin_setup; + wgt->draw_prepare = WIDGETGROUP_node_corner_pin_draw_prepare; + wgt->refresh = WIDGETGROUP_node_corner_pin_refresh; +} + +/** \} */ diff --git a/source/blender/editors/space_node/node_manipulators.c b/source/blender/editors/space_node/node_manipulators.c deleted file mode 100644 index 851e3973288..00000000000 --- a/source/blender/editors/space_node/node_manipulators.c +++ /dev/null @@ -1,621 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_node/node_manipulators.c - * \ingroup spnode - */ - -#include - -#include "BLI_utildefines.h" -#include "BLI_math_matrix.h" -#include "BLI_math_vector.h" -#include "BLI_rect.h" - -#include "BKE_context.h" -#include "BKE_image.h" -#include "BKE_main.h" - -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -#include "IMB_imbuf_types.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "node_intern.h" - - -/* -------------------------------------------------------------------- */ - -/** \name Local Utilities - * \{ */ - -static void node_manipulator_calc_matrix_space( - const SpaceNode *snode, const ARegion *ar, float matrix_space[4][4]) -{ - unit_m4(matrix_space); - mul_v3_fl(matrix_space[0], snode->zoom); - mul_v3_fl(matrix_space[1], snode->zoom); - matrix_space[3][0] = (ar->winx / 2) + snode->xof; - matrix_space[3][1] = (ar->winy / 2) + snode->yof; -} - -static void node_manipulator_calc_matrix_space_with_image_dims( - const SpaceNode *snode, const ARegion *ar, const float image_dims[2], float matrix_space[4][4]) -{ - unit_m4(matrix_space); - mul_v3_fl(matrix_space[0], snode->zoom * image_dims[0]); - mul_v3_fl(matrix_space[1], snode->zoom * image_dims[1]); - matrix_space[3][0] = ((ar->winx / 2) + snode->xof) - ((image_dims[0] / 2.0f) * snode->zoom); - matrix_space[3][1] = ((ar->winy / 2) + snode->yof) - ((image_dims[1] / 2.0f) * snode->zoom); -} - -/** \} */ - - - -/* -------------------------------------------------------------------- */ - -/** \name Backdrop Manipulator - * \{ */ - -static void manipulator_node_backdrop_prop_matrix_get( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - void *value_p) -{ - float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - const SpaceNode *snode = mpr_prop->custom_func.user_data; - matrix[0][0] = snode->zoom; - matrix[1][1] = snode->zoom; - matrix[3][0] = snode->xof; - matrix[3][1] = snode->yof; -} - -static void manipulator_node_backdrop_prop_matrix_set( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - const void *value_p) -{ - const float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - SpaceNode *snode = mpr_prop->custom_func.user_data; - snode->zoom = matrix[0][0]; - snode->zoom = matrix[1][1]; - snode->xof = matrix[3][0]; - snode->yof = matrix[3][1]; -} - -static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - SpaceNode *snode = CTX_wm_space_node(C); - - if ((snode->flag & SNODE_BACKDRAW) == 0) { - return false; - } - - if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) { - bNode *node = nodeGetActive(snode->edittree); - - if (node && ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { - return true; - } - } - - return false; -} - -static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); - - RNA_enum_set(wwrapper->manipulator->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); - - mgroup->customdata = wwrapper; -} - -static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - Main *bmain = CTX_data_main(C); - wmManipulator *cage = ((wmManipulatorWrapper *)mgroup->customdata)->manipulator; - const ARegion *ar = CTX_wm_region(C); - /* center is always at the origin */ - const float origin[3] = {ar->winx / 2, ar->winy / 2}; - - void *lock; - Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); - - if (ibuf) { - const float dims[2] = { - (ibuf->x > 0) ? ibuf->x : 64.0f, - (ibuf->y > 0) ? ibuf->y : 64.0f, - }; - - RNA_float_set_array(cage->ptr, "dimensions", dims); - WM_manipulator_set_matrix_location(cage, origin); - WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, false); - - /* need to set property here for undo. TODO would prefer to do this in _init */ - SpaceNode *snode = CTX_wm_space_node(C); -#if 0 - PointerRNA nodeptr; - RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr); - WM_manipulator_target_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1); - WM_manipulator_target_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1); -#endif - - WM_manipulator_target_property_def_func( - cage, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_node_backdrop_prop_matrix_get, - .value_set_fn = manipulator_node_backdrop_prop_matrix_set, - .range_get_fn = NULL, - .user_data = snode, - }); - } - else { - WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true); - } - - BKE_image_release_ibuf(ima, ibuf, lock); -} - -void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt) -{ - wgt->name = "Backdrop Transform Widget"; - wgt->idname = "NODE_WGT_backdrop_transform"; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; - - wgt->poll = WIDGETGROUP_node_transform_poll; - wgt->setup = WIDGETGROUP_node_transform_setup; - wgt->refresh = WIDGETGROUP_node_transform_refresh; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ - -/** \name Crop Manipulator - * \{ */ - -struct NodeCropWidgetGroup { - wmManipulator *border; - - struct { - float dims[2]; - } state; - - struct { - PointerRNA ptr; - PropertyRNA *prop; - bContext *context; - } update_data; -}; - -static void manipulator_node_crop_update(struct NodeCropWidgetGroup *crop_group) -{ - RNA_property_update(crop_group->update_data.context, &crop_group->update_data.ptr, crop_group->update_data.prop); -} - -static void two_xy_to_rect(const NodeTwoXYs *nxy, rctf *rect, const float dims[2], bool is_relative) -{ - if (is_relative) { - rect->xmin = nxy->fac_x1; - rect->xmax = nxy->fac_x2; - rect->ymin = nxy->fac_y1; - rect->ymax = nxy->fac_y2; - } - else { - rect->xmin = nxy->x1 / dims[0]; - rect->xmax = nxy->x2 / dims[0]; - rect->ymin = nxy->y1 / dims[1]; - rect->ymax = nxy->y2 / dims[1]; - } -} - -static void two_xy_from_rect(NodeTwoXYs *nxy, const rctf *rect, const float dims[2], bool is_relative) -{ - if (is_relative) { - nxy->fac_x1 = rect->xmin; - nxy->fac_x2 = rect->xmax; - nxy->fac_y1 = rect->ymin; - nxy->fac_y2 = rect->ymax; - } - else { - nxy->x1 = rect->xmin * dims[0]; - nxy->x2 = rect->xmax * dims[0]; - nxy->y1 = rect->ymin * dims[1]; - nxy->y2 = rect->ymax * dims[1]; - } -} - -/* scale callbacks */ -static void manipulator_node_crop_prop_matrix_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - void *value_p) -{ - float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata; - const float *dims = crop_group->state.dims; - const bNode *node = mpr_prop->custom_func.user_data; - const NodeTwoXYs *nxy = node->storage; - bool is_relative = (bool)node->custom2; - rctf rct; - two_xy_to_rect(nxy, &rct, dims, is_relative); - matrix[0][0] = BLI_rctf_size_x(&rct); - matrix[1][1] = BLI_rctf_size_y(&rct); - matrix[3][0] = (BLI_rctf_cent_x(&rct) - 0.5f) * dims[0]; - matrix[3][1] = (BLI_rctf_cent_y(&rct) - 0.5f) * dims[1]; -} - -static void manipulator_node_crop_prop_matrix_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - const void *value_p) -{ - const float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata; - const float *dims = crop_group->state.dims; - bNode *node = mpr_prop->custom_func.user_data; - NodeTwoXYs *nxy = node->storage; - bool is_relative = (bool)node->custom2; - rctf rct; - two_xy_to_rect(nxy, &rct, dims, is_relative); - BLI_rctf_resize(&rct, matrix[0][0], matrix[1][1]); - BLI_rctf_recenter(&rct, (matrix[3][0] / dims[0]) + 0.5f, (matrix[3][1] / dims[1]) + 0.5f); - BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, &rct, &rct); - two_xy_from_rect(nxy, &rct, dims, is_relative); - manipulator_node_crop_update(crop_group); -} - -static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - SpaceNode *snode = CTX_wm_space_node(C); - - if ((snode->flag & SNODE_BACKDRAW) == 0) { - return false; - } - - if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) { - bNode *node = nodeGetActive(snode->edittree); - - if (node && ELEM(node->type, CMP_NODE_CROP)) { - /* ignore 'use_crop_size', we can't usefully edit the crop in this case. */ - if ((node->custom1 & (0 << 1)) == 0) { - return true; - } - } - } - - return false; -} - -static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - struct NodeCropWidgetGroup *crop_group = MEM_mallocN(sizeof(struct NodeCropWidgetGroup), __func__); - - crop_group->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); - - RNA_enum_set(crop_group->border->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); - - mgroup->customdata = crop_group; -} - -static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - ARegion *ar = CTX_wm_region(C); - wmManipulator *mpr = mgroup->manipulators.first; - - SpaceNode *snode = CTX_wm_space_node(C); - - node_manipulator_calc_matrix_space(snode, ar, mpr->matrix_space); -} - -static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - Main *bmain = CTX_data_main(C); - struct NodeCropWidgetGroup *crop_group = mgroup->customdata; - wmManipulator *mpr = crop_group->border; - - void *lock; - Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); - - if (ibuf) { - crop_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f; - crop_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f; - - RNA_float_set_array(mpr->ptr, "dimensions", crop_group->state.dims); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - - SpaceNode *snode = CTX_wm_space_node(C); - bNode *node = nodeGetActive(snode->edittree); - - crop_group->update_data.context = (bContext *)C; - RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeCrop, node, &crop_group->update_data.ptr); - crop_group->update_data.prop = RNA_struct_find_property(&crop_group->update_data.ptr, "relative"); - - WM_manipulator_target_property_def_func( - mpr, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_node_crop_prop_matrix_get, - .value_set_fn = manipulator_node_crop_prop_matrix_set, - .range_get_fn = NULL, - .user_data = node, - }); - } - else { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); - } - - BKE_image_release_ibuf(ima, ibuf, lock); -} - -void NODE_WGT_backdrop_crop(wmManipulatorGroupType *wgt) -{ - wgt->name = "Backdrop Crop Widget"; - wgt->idname = "NODE_WGT_backdrop_crop"; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; - - wgt->poll = WIDGETGROUP_node_crop_poll; - wgt->setup = WIDGETGROUP_node_crop_setup; - wgt->draw_prepare = WIDGETGROUP_node_crop_draw_prepare; - wgt->refresh = WIDGETGROUP_node_crop_refresh; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ - -/** \name Sun Beams - * \{ */ - -struct NodeSunBeamsWidgetGroup { - wmManipulator *manipulator; - - struct { - float dims[2]; - } state; -}; - -static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - SpaceNode *snode = CTX_wm_space_node(C); - - if ((snode->flag & SNODE_BACKDRAW) == 0) { - return false; - } - - if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) { - bNode *node = nodeGetActive(snode->edittree); - - if (node && ELEM(node->type, CMP_NODE_SUNBEAMS)) { - return true; - } - } - - return false; -} - -static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - struct NodeSunBeamsWidgetGroup *sbeam_group = MEM_mallocN(sizeof(struct NodeSunBeamsWidgetGroup), __func__); - - sbeam_group->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL); - wmManipulator *mpr = sbeam_group->manipulator; - - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D); - - mpr->scale_basis = 0.05f; - - mgroup->customdata = sbeam_group; -} - -static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata; - ARegion *ar = CTX_wm_region(C); - wmManipulator *mpr = mgroup->manipulators.first; - - SpaceNode *snode = CTX_wm_space_node(C); - - node_manipulator_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, mpr->matrix_space); -} - -static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - Main *bmain = CTX_data_main(C); - struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata; - wmManipulator *mpr = sbeam_group->manipulator; - - void *lock; - Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); - - if (ibuf) { - sbeam_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f; - sbeam_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f; - - SpaceNode *snode = CTX_wm_space_node(C); - bNode *node = nodeGetActive(snode->edittree); - - /* need to set property here for undo. TODO would prefer to do this in _init */ - PointerRNA nodeptr; - RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeSunBeams, node, &nodeptr); - WM_manipulator_target_property_def_rna(mpr, "offset", &nodeptr, "source", -1); - - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true); - } - else { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); - } - - BKE_image_release_ibuf(ima, ibuf, lock); -} - -void NODE_WGT_backdrop_sun_beams(wmManipulatorGroupType *wgt) -{ - wgt->name = "Sun Beams Widget"; - wgt->idname = "NODE_WGT_sbeam"; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; - - wgt->poll = WIDGETGROUP_node_sbeam_poll; - wgt->setup = WIDGETGROUP_node_sbeam_setup; - wgt->draw_prepare = WIDGETGROUP_node_sbeam_draw_prepare; - wgt->refresh = WIDGETGROUP_node_sbeam_refresh; -} - -/** \} */ - - - -/* -------------------------------------------------------------------- */ - -/** \name Corner Pin - * \{ */ - -struct NodeCornerPinWidgetGroup { - wmManipulator *manipulators[4]; - - struct { - float dims[2]; - } state; -}; - -static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - SpaceNode *snode = CTX_wm_space_node(C); - - if ((snode->flag & SNODE_BACKDRAW) == 0) { - return false; - } - - if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) { - bNode *node = nodeGetActive(snode->edittree); - - if (node && ELEM(node->type, CMP_NODE_CORNERPIN)) { - return true; - } - } - - return false; -} - -static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - struct NodeCornerPinWidgetGroup *cpin_group = MEM_mallocN(sizeof(struct NodeCornerPinWidgetGroup), __func__); - const wmManipulatorType *wt_grab_3d = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", false); - - for (int i = 0; i < 4; i++) { - cpin_group->manipulators[i] = WM_manipulator_new_ptr(wt_grab_3d, mgroup, NULL); - wmManipulator *mpr = cpin_group->manipulators[i]; - - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D); - - mpr->scale_basis = 0.01f; - } - - mgroup->customdata = cpin_group; -} - -static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata; - ARegion *ar = CTX_wm_region(C); - - SpaceNode *snode = CTX_wm_space_node(C); - - float matrix_space[4][4]; - node_manipulator_calc_matrix_space_with_image_dims(snode, ar, cpin_group->state.dims, matrix_space); - - for (int i = 0; i < 4; i++) { - wmManipulator *mpr = cpin_group->manipulators[i]; - copy_m4_m4(mpr->matrix_space, matrix_space); - } -} - -static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - Main *bmain = CTX_data_main(C); - struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata; - - void *lock; - Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); - - if (ibuf) { - cpin_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f; - cpin_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f; - - SpaceNode *snode = CTX_wm_space_node(C); - bNode *node = nodeGetActive(snode->edittree); - - /* need to set property here for undo. TODO would prefer to do this in _init */ - int i = 0; - for (bNodeSocket *sock = node->inputs.first; sock && i < 4; sock = sock->next) { - if (sock->type == SOCK_VECTOR) { - wmManipulator *mpr = cpin_group->manipulators[i++]; - - PointerRNA sockptr; - RNA_pointer_create((ID *)snode->edittree, &RNA_NodeSocket, sock, &sockptr); - WM_manipulator_target_property_def_rna(mpr, "offset", &sockptr, "default_value", -1); - - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true); - } - } - } - else { - for (int i = 0; i < 4; i++) { - wmManipulator *mpr = cpin_group->manipulators[i]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); - } - } - - BKE_image_release_ibuf(ima, ibuf, lock); -} - -void NODE_WGT_backdrop_corner_pin(wmManipulatorGroupType *wgt) -{ - wgt->name = "Corner Pin Widget"; - wgt->idname = "NODE_WGT_backdrop_corner_pin"; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; - - wgt->poll = WIDGETGROUP_node_corner_pin_poll; - wgt->setup = WIDGETGROUP_node_corner_pin_setup; - wgt->draw_prepare = WIDGETGROUP_node_corner_pin_draw_prepare; - wgt->refresh = WIDGETGROUP_node_corner_pin_refresh; -} - -/** \} */ diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index f8e38587117..b85525dd2ee 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -55,14 +55,14 @@ set(SRC view3d_walk.c view3d_header.c view3d_iterators.c - view3d_manipulator_armature.c - view3d_manipulator_camera.c - view3d_manipulator_empty.c - view3d_manipulator_forcefield.c - view3d_manipulator_lamp.c - view3d_manipulator_navigate.c - view3d_manipulator_navigate_type.c - view3d_manipulator_ruler.c + view3d_gizmo_armature.c + view3d_gizmo_camera.c + view3d_gizmo_empty.c + view3d_gizmo_forcefield.c + view3d_gizmo_lamp.c + view3d_gizmo_navigate.c + view3d_gizmo_navigate_type.c + view3d_gizmo_ruler.c view3d_ops.c view3d_project.c view3d_ruler.c diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c new file mode 100644 index 00000000000..16c7d574873 --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c @@ -0,0 +1,228 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_view3d/view3d_gizmo_armature.c + * \ingroup spview3d + */ + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_armature.h" +#include "BKE_action.h" +#include "BKE_context.h" +#include "BKE_object.h" + +#include "DNA_object_types.h" +#include "DNA_armature_types.h" + +#include "ED_armature.h" +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +#include "UI_resources.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "view3d_intern.h" /* own include */ + + +/* -------------------------------------------------------------------- */ + +/** \name Armature Spline Manipulator + * + * \{ */ + +/* + * TODO(campbell): Current conversion is a approximation (usable not correct), + * we'll need to take the next/previous bones into account to get the tangent directions. + * First last matrices from 'b_bone_spline_setup' are close but also not quite accurate + * since they're not at either end-points on the curve. + * + * Likely we'll need a function especially to get the first/last orientations. + */ + +#define BBONE_SCALE_Y 3.0f + +struct BoneSplineHandle { + wmManipulator *manipulator; + bPoseChannel *pchan; + /* We could remove, keep since at the moment for checking the conversion. */ + float co[3]; + int index; +}; + +struct BoneSplineWidgetGroup { + struct BoneSplineHandle handles[2]; +}; + +static void manipulator_bbone_offset_get( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + void *value_p) +{ + struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data; + bPoseChannel *pchan = bh->pchan; + + float *value = value_p; + BLI_assert(mpr_prop->type->array_length == 3); + + if (bh->index == 0) { + bh->co[1] = pchan->bone->ease1 / BBONE_SCALE_Y; + bh->co[0] = pchan->curveInX; + bh->co[2] = pchan->curveInY; + } + else { + bh->co[1] = -pchan->bone->ease2 / BBONE_SCALE_Y; + bh->co[0] = pchan->curveOutX; + bh->co[2] = pchan->curveOutY; + } + copy_v3_v3(value, bh->co); +} + +static void manipulator_bbone_offset_set( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + const void *value_p) +{ + struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data; + bPoseChannel *pchan = bh->pchan; + + const float *value = value_p; + + BLI_assert(mpr_prop->type->array_length == 3); + copy_v3_v3(bh->co, value); + + if (bh->index == 0) { + pchan->bone->ease1 = max_ff(0.0f, bh->co[1] * BBONE_SCALE_Y); + pchan->curveInX = bh->co[0]; + pchan->curveInY = bh->co[2]; + } + else { + pchan->bone->ease2 = max_ff(0.0f, -bh->co[1] * BBONE_SCALE_Y); + pchan->curveOutX = bh->co[0]; + pchan->curveOutY = bh->co[2]; + } + +} + +static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + if (ob != NULL) { + const bArmature *arm = ob->data; + if (arm->drawtype == ARM_B_BONE) { + if (arm->act_bone && arm->act_bone->segments > 1) { + View3D *v3d = CTX_wm_view3d(C); + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { + /* pass */ + } + else { + return true; + } + } + } + } + return false; +} + + +static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmManipulatorGroup *mgroup) +{ + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bPoseChannel *pchan = BKE_pose_channel_active(ob); + + const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true); + + struct BoneSplineWidgetGroup *bspline_group = MEM_callocN(sizeof(struct BoneSplineWidgetGroup), __func__); + mgroup->customdata = bspline_group; + + /* Handles */ + for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { + wmManipulator *mpr; + mpr = bspline_group->handles[i].manipulator = WM_manipulator_new_ptr(wt_grab, mgroup, NULL); + RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D); + RNA_enum_set(mpr->ptr, "draw_options", + ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW); + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_VALUE, true); + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + + mpr->scale_basis = 0.06f; + + if (i == 0) { + copy_v3_v3(mpr->matrix_basis[3], pchan->loc); + } + } +} + +static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + + if (!mgroup->customdata) + return; + + struct BoneSplineWidgetGroup *bspline_group = mgroup->customdata; + bPoseChannel *pchan = BKE_pose_channel_active(ob); + + /* Handles */ + for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { + wmManipulator *mpr = bspline_group->handles[i].manipulator; + bspline_group->handles[i].pchan = pchan; + bspline_group->handles[i].index = i; + + float mat[4][4]; + mul_m4_m4m4(mat, ob->obmat, (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat); + copy_m4_m4(mpr->matrix_space, mat); + + /* need to set property here for undo. TODO would prefer to do this in _init */ + WM_manipulator_target_property_def_func( + mpr, "offset", + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = manipulator_bbone_offset_get, + .value_set_fn = manipulator_bbone_offset_set, + .range_get_fn = NULL, + .user_data = &bspline_group->handles[i], + }); + } +} + +void VIEW3D_WGT_armature_spline(wmManipulatorGroupType *wgt) +{ + wgt->name = "Armature Spline Widgets"; + wgt->idname = "VIEW3D_WGT_armature_spline"; + + wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D); + + wgt->poll = WIDGETGROUP_armature_spline_poll; + wgt->setup = WIDGETGROUP_armature_spline_setup; + wgt->refresh = WIDGETGROUP_armature_spline_refresh; +} + +/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c new file mode 100644 index 00000000000..0c97669a9af --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -0,0 +1,473 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_view3d/view3d_gizmo_camera.c + * \ingroup spview3d + */ + + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_camera.h" +#include "BKE_context.h" + +#include "DNA_object_types.h" +#include "DNA_camera_types.h" + +#include "ED_armature.h" +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +#include "UI_resources.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" +#include "WM_message.h" + +#include "view3d_intern.h" /* own include */ + + +/* -------------------------------------------------------------------- */ + +/** \name Camera Manipulators + * \{ */ + +struct CameraWidgetGroup { + wmManipulator *dop_dist; + wmManipulator *focal_len; + wmManipulator *ortho_scale; +}; + +static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + View3D *v3d = CTX_wm_view3d(C); + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { + return false; + } + + Object *ob = CTX_data_active_object(C); + if (ob && ob->type == OB_CAMERA) { + Camera *camera = ob->data; + /* TODO: support overrides. */ + if (camera->id.lib == NULL) { + return true; + } + } + return false; +} + +static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgroup) +{ + Object *ob = CTX_data_active_object(C); + float dir[3]; + + const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); + + struct CameraWidgetGroup *camgroup = MEM_callocN(sizeof(struct CameraWidgetGroup), __func__); + mgroup->customdata = camgroup; + + negate_v3_v3(dir, ob->obmat[2]); + + /* dof distance */ + { + wmManipulator *mpr; + mpr = camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); + RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CROSS); + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); + + UI_GetThemeColor3fv(TH_MANIPULATOR_A, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + } + + /* focal length + * - logic/calculations are similar to BKE_camera_view_frame_ex, better keep in sync */ + { + wmManipulator *mpr; + mpr = camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); + mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE; + RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE); + RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + + mpr = camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); + mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE; + RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE); + RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + } +} + +static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + if (!mgroup->customdata) + return; + + struct CameraWidgetGroup *camgroup = mgroup->customdata; + Object *ob = CTX_data_active_object(C); + Camera *ca = ob->data; + PointerRNA camera_ptr; + float dir[3]; + + const float ob_scale_inv[3] = { + 1.0f / len_v3(ob->obmat[0]), + 1.0f / len_v3(ob->obmat[1]), + 1.0f / len_v3(ob->obmat[2]), + }; + const float ob_scale_uniform_inv = (ob_scale_inv[0] + ob_scale_inv[1] + ob_scale_inv[2]) / 3.0f; + + RNA_pointer_create(&ca->id, &RNA_Camera, ca, &camera_ptr); + + negate_v3_v3(dir, ob->obmat[2]); + + if (ca->flag & CAM_SHOWLIMITS) { + WM_manipulator_set_matrix_location(camgroup->dop_dist, ob->obmat[3]); + WM_manipulator_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob->obmat[1], dir); + WM_manipulator_set_scale(camgroup->dop_dist, ca->drawsize); + WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false); + + /* need to set property here for undo. TODO would prefer to do this in _init */ + WM_manipulator_target_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); + } + else { + WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, true); + } + + /* TODO - make focal length/ortho ob_scale_inv widget optional */ + const Scene *scene = CTX_data_scene(C); + const float aspx = (float)scene->r.xsch * scene->r.xasp; + const float aspy = (float)scene->r.ysch * scene->r.yasp; + const bool is_ortho = (ca->type == CAM_ORTHO); + const int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, aspx, aspy); + wmManipulator *widget = is_ortho ? camgroup->ortho_scale : camgroup->focal_len; + float scale_matrix; + if (true) { + float offset[3]; + float aspect[2]; + + WM_manipulator_set_flag(widget, WM_MANIPULATOR_HIDDEN, false); + WM_manipulator_set_flag(is_ortho ? camgroup->focal_len : camgroup->ortho_scale, WM_MANIPULATOR_HIDDEN, true); + + + /* account for lens shifting */ + offset[0] = ((ob->size[0] > 0.0f) ? -2.0f : 2.0f) * ca->shiftx; + offset[1] = 2.0f * ca->shifty; + offset[2] = 0.0f; + + /* get aspect */ + aspect[0] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? 1.0f : aspx / aspy; + aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f; + + unit_m4(widget->matrix_basis); + WM_manipulator_set_matrix_location(widget, ob->obmat[3]); + WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir); + + if (is_ortho) { + scale_matrix = ca->ortho_scale * 0.5f; + } + else { + scale_matrix = ca->drawsize / ob_scale_uniform_inv; + } + mul_v3_fl(widget->matrix_basis[0], scale_matrix); + mul_v3_fl(widget->matrix_basis[1], scale_matrix); + + RNA_float_set_array(widget->ptr, "aspect", aspect); + + WM_manipulator_set_matrix_offset_location(widget, offset); + } + + /* define & update properties */ + { + const char *propname = is_ortho ? "ortho_scale" : "lens"; + PropertyRNA *prop = RNA_struct_find_property(&camera_ptr, propname); + const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(widget->type, "offset"); + + WM_manipulator_target_property_clear_rna_ptr(widget, mpr_prop_type); + + float min, max, range; + float step, precision; + + /* get property range */ + RNA_property_float_ui_range(&camera_ptr, prop, &min, &max, &step, &precision); + range = max - min; + + ED_manipulator_arrow3d_set_range_fac( + widget, is_ortho ? + (ca->drawsize * range) : + (scale_matrix * range / + /* Half sensor, intentionally use sensor from camera and not calculated above. */ + (0.5f * ((ca->sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_x)))); + + WM_manipulator_target_property_def_rna_ptr(widget, mpr_prop_type, &camera_ptr, prop, -1); + } + +} + +static void WIDGETGROUP_camera_message_subscribe( + const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) +{ + ARegion *ar = CTX_wm_region(C); + Object *ob = CTX_data_active_object(C); + Camera *ca = ob->data; + + wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { + .owner = ar, + .user_data = mgroup->parent_mmap, + .notify = WM_manipulator_do_msg_notify_tag_refresh, + }; + + { + extern PropertyRNA rna_Camera_dof_distance; + extern PropertyRNA rna_Camera_draw_size; + extern PropertyRNA rna_Camera_ortho_scale; + extern PropertyRNA rna_Camera_sensor_fit; + extern PropertyRNA rna_Camera_sensor_width; + extern PropertyRNA rna_Camera_shift_x; + extern PropertyRNA rna_Camera_shift_y; + extern PropertyRNA rna_Camera_type; + extern PropertyRNA rna_Camera_lens; + const PropertyRNA *props[] = { + &rna_Camera_dof_distance, + &rna_Camera_draw_size, + &rna_Camera_ortho_scale, + &rna_Camera_sensor_fit, + &rna_Camera_sensor_width, + &rna_Camera_shift_x, + &rna_Camera_shift_y, + &rna_Camera_type, + &rna_Camera_lens, + }; + + PointerRNA idptr; + RNA_id_pointer_create(&ca->id, &idptr); + + for (int i = 0; i < ARRAY_SIZE(props); i++) { + WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); + } + } + + /* Subscribe to render settings */ + { + WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_x, &msg_sub_value_mpr_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_y, &msg_sub_value_mpr_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_x, &msg_sub_value_mpr_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_y, &msg_sub_value_mpr_tag_refresh); + } +} + +void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt) +{ + wgt->name = "Camera Widgets"; + wgt->idname = "VIEW3D_WGT_camera"; + + wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D | + WM_MANIPULATORGROUPTYPE_DEPTH_3D); + + wgt->poll = WIDGETGROUP_camera_poll; + wgt->setup = WIDGETGROUP_camera_setup; + wgt->refresh = WIDGETGROUP_camera_refresh; + wgt->message_subscribe = WIDGETGROUP_camera_message_subscribe; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ + +/** \name CameraView Manipulators + * \{ */ + +struct CameraViewWidgetGroup { + wmManipulator *border; + + struct { + rctf *edit_border; + rctf view_border; + } state; +}; + +/* scale callbacks */ +static void manipulator_render_border_prop_matrix_get( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + void *value_p) +{ + float (*matrix)[4] = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data; + const rctf *border = viewgroup->state.edit_border; + + unit_m4(matrix); + matrix[0][0] = BLI_rctf_size_x(border); + matrix[1][1] = BLI_rctf_size_y(border); + matrix[3][0] = BLI_rctf_cent_x(border); + matrix[3][1] = BLI_rctf_cent_y(border); +} + +static void manipulator_render_border_prop_matrix_set( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + const void *value_p) +{ + const float (*matrix)[4] = value_p; + struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data; + rctf *border = viewgroup->state.edit_border; + BLI_assert(mpr_prop->type->array_length == 16); + + BLI_rctf_resize(border, len_v3(matrix[0]), len_v3(matrix[1])); + BLI_rctf_recenter(border, matrix[3][0], matrix[3][1]); + BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, border, border); +} + +static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + Scene *scene = CTX_data_scene(C); + + /* This is just so the border isn't always in the way, + * stealing mouse clicks from regular usage. + * We could change the rules for when to show. */ + { + ViewLayer *view_layer = CTX_data_view_layer(C); + if (scene->camera != OBACT(view_layer)) { + return false; + } + } + + View3D *v3d = CTX_wm_view3d(C); + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { + return false; + } + + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + if (rv3d->persp == RV3D_CAMOB) { + if (scene->r.mode & R_BORDER) { + /* TODO: support overrides. */ + if (scene->id.lib == NULL) { + return true; + } + } + } + else if (v3d->flag2 & V3D_RENDER_BORDER) { + return true; + } + return false; +} + +static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + struct CameraViewWidgetGroup *viewgroup = MEM_mallocN(sizeof(struct CameraViewWidgetGroup), __func__); + + viewgroup->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); + + RNA_enum_set(viewgroup->border->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + /* Box style is more subtle in this case. */ + RNA_enum_set(viewgroup->border->ptr, "draw_style", ED_MANIPULATOR_CAGE2D_STYLE_BOX); + + + mgroup->customdata = viewgroup; +} + +static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; + + ARegion *ar = CTX_wm_region(C); + struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + RegionView3D *rv3d = ar->regiondata; + if (rv3d->persp == RV3D_CAMOB) { + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewgroup->state.view_border, false); + } + else { + viewgroup->state.view_border = (rctf){.xmin = 0, .ymin = 0, .xmax = ar->winx, .ymax = ar->winy}; + } + + wmManipulator *mpr = viewgroup->border; + unit_m4(mpr->matrix_space); + mul_v3_fl(mpr->matrix_space[0], BLI_rctf_size_x(&viewgroup->state.view_border)); + mul_v3_fl(mpr->matrix_space[1], BLI_rctf_size_y(&viewgroup->state.view_border)); + mpr->matrix_space[3][0] = viewgroup->state.view_border.xmin; + mpr->matrix_space[3][1] = viewgroup->state.view_border.ymin; +} + +static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; + + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + Scene *scene = CTX_data_scene(C); + + { + wmManipulator *mpr = viewgroup->border; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + + RNA_enum_set(viewgroup->border->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + + if (rv3d->persp == RV3D_CAMOB) { + viewgroup->state.edit_border = &scene->r.border; + } + else { + viewgroup->state.edit_border = &v3d->render_border; + } + + WM_manipulator_target_property_def_func( + mpr, "matrix", + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = manipulator_render_border_prop_matrix_get, + .value_set_fn = manipulator_render_border_prop_matrix_set, + .range_get_fn = NULL, + .user_data = viewgroup, + }); + } + +} + +void VIEW3D_WGT_camera_view(wmManipulatorGroupType *wgt) +{ + wgt->name = "Camera View Widgets"; + wgt->idname = "VIEW3D_WGT_camera_view"; + + wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_SCALE); + + wgt->poll = WIDGETGROUP_camera_view_poll; + wgt->setup = WIDGETGROUP_camera_view_setup; + wgt->draw_prepare = WIDGETGROUP_camera_view_draw_prepare; + wgt->refresh = WIDGETGROUP_camera_view_refresh; +} + +/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.c b/source/blender/editors/space_view3d/view3d_gizmo_empty.c new file mode 100644 index 00000000000..89f55bc1d9a --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.c @@ -0,0 +1,204 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_view3d/view3d_gizmo_empty.c + * \ingroup spview3d + */ + + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" +#include "BKE_object.h" +#include "BKE_image.h" + +#include "DNA_object_types.h" +#include "DNA_lamp_types.h" + +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +#include "UI_resources.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "view3d_intern.h" /* own include */ + +/* -------------------------------------------------------------------- */ + +/** \name Empty Image Manipulators + * \{ */ + +struct EmptyImageWidgetGroup { + wmManipulator *manipulator; + struct { + Object *ob; + float dims[2]; + } state; +}; + +/* translate callbacks */ +static void manipulator_empty_image_prop_matrix_get( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + void *value_p) +{ + float (*matrix)[4] = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data; + const Object *ob = imgroup->state.ob; + + unit_m4(matrix); + matrix[0][0] = ob->empty_drawsize; + matrix[1][1] = ob->empty_drawsize; + + float dims[2] = {0.0f, 0.0f}; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + dims[0] *= ob->empty_drawsize; + dims[1] *= ob->empty_drawsize; + + matrix[3][0] = (ob->ima_ofs[0] * dims[0]) + (0.5f * dims[0]); + matrix[3][1] = (ob->ima_ofs[1] * dims[1]) + (0.5f * dims[1]); +} + +static void manipulator_empty_image_prop_matrix_set( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + const void *value_p) +{ + const float (*matrix)[4] = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data; + Object *ob = imgroup->state.ob; + + ob->empty_drawsize = matrix[0][0]; + + float dims[2]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + dims[0] *= ob->empty_drawsize; + dims[1] *= ob->empty_drawsize; + + ob->ima_ofs[0] = (matrix[3][0] - (0.5f * dims[0])) / dims[0]; + ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1]; +} + +static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + View3D *v3d = CTX_wm_view3d(C); + + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { + return false; + } + + Object *ob = CTX_data_active_object(C); + + if (ob && ob->type == OB_EMPTY) { + return (ob->empty_drawtype == OB_EMPTY_IMAGE); + } + return false; +} + +static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + struct EmptyImageWidgetGroup *imgroup = MEM_mallocN(sizeof(struct EmptyImageWidgetGroup), __func__); + imgroup->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); + wmManipulator *mpr = imgroup->manipulator; + RNA_enum_set(mpr->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + + mgroup->customdata = imgroup; + + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); +} + +static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + struct EmptyImageWidgetGroup *imgroup = mgroup->customdata; + Object *ob = CTX_data_active_object(C); + wmManipulator *mpr = imgroup->manipulator; + + copy_m4_m4(mpr->matrix_basis, ob->obmat); + + RNA_enum_set(mpr->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); + + imgroup->state.ob = ob; + + /* Use dimensions for aspect. */ + if (ob->data != NULL) { + const Image *image = ob->data; + ImageUser iuser = *ob->iuser; + float size[2]; + BKE_image_get_size_fl(ob->data, &iuser, size); + + /* Get the image aspect even if the buffer is invalid */ + if (image->aspx > image->aspy) { + size[1] *= image->aspy / image->aspx; + } + else if (image->aspx < image->aspy) { + size[0] *= image->aspx / image->aspy; + } + + const float dims_max = max_ff(size[0], size[1]); + imgroup->state.dims[0] = size[0] / dims_max; + imgroup->state.dims[1] = size[1] / dims_max; + } + else { + copy_v2_fl(imgroup->state.dims, 1.0f); + } + RNA_float_set_array(mpr->ptr, "dimensions", imgroup->state.dims); + + WM_manipulator_target_property_def_func( + mpr, "matrix", + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = manipulator_empty_image_prop_matrix_get, + .value_set_fn = manipulator_empty_image_prop_matrix_set, + .range_get_fn = NULL, + .user_data = imgroup, + }); +} + +void VIEW3D_WGT_empty_image(wmManipulatorGroupType *wgt) +{ + wgt->name = "Area Light Widgets"; + wgt->idname = "VIEW3D_WGT_empty_image"; + + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D | + WM_MANIPULATORGROUPTYPE_DEPTH_3D); + + wgt->poll = WIDGETGROUP_empty_image_poll; + wgt->setup = WIDGETGROUP_empty_image_setup; + wgt->refresh = WIDGETGROUP_empty_image_refresh; +} + +/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c new file mode 100644 index 00000000000..db985c18c08 --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c @@ -0,0 +1,125 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_view3d/view3d_gizmo_forcefield.c + * \ingroup spview3d + */ + + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" +#include "BKE_object.h" + +#include "DNA_object_types.h" +#include "DNA_object_force_types.h" + +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +#include "UI_resources.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "view3d_intern.h" /* own include */ + +/* -------------------------------------------------------------------- */ + +/** \name Force Field Manipulators + * \{ */ + +static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + View3D *v3d = CTX_wm_view3d(C); + + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { + return false; + } + + Object *ob = CTX_data_active_object(C); + + return (ob && ob->pd && ob->pd->forcefield); +} + +static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + /* only wind effector for now */ + wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); + mgroup->customdata = wwrapper; + + wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL); + wmManipulator *mpr = wwrapper->manipulator; + RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); + ED_manipulator_arrow3d_set_ui_range(mpr, -200.0f, 200.0f); + ED_manipulator_arrow3d_set_range_fac(mpr, 6.0f); + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); +} + +static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + wmManipulatorWrapper *wwrapper = mgroup->customdata; + wmManipulator *mpr = wwrapper->manipulator; + Object *ob = CTX_data_active_object(C); + PartDeflect *pd = ob->pd; + + if (pd->forcefield == PFIELD_WIND) { + const float size = (ob->type == OB_EMPTY) ? ob->empty_drawsize : 1.0f; + const float ofs[3] = {0.0f, -size, 0.0f}; + PointerRNA field_ptr; + + RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd, &field_ptr); + WM_manipulator_set_matrix_location(mpr, ob->obmat[3]); + WM_manipulator_set_matrix_rotation_from_z_axis(mpr, ob->obmat[2]); + WM_manipulator_set_matrix_offset_location(mpr, ofs); + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + WM_manipulator_target_property_def_rna(mpr, "offset", &field_ptr, "strength", -1); + } + else { + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + } +} + +void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt) +{ + wgt->name = "Force Field Widgets"; + wgt->idname = "VIEW3D_WGT_force_field"; + + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D | + WM_MANIPULATORGROUPTYPE_SCALE | + WM_MANIPULATORGROUPTYPE_DEPTH_3D); + + wgt->poll = WIDGETGROUP_forcefield_poll; + wgt->setup = WIDGETGROUP_forcefield_setup; + wgt->refresh = WIDGETGROUP_forcefield_refresh; +} + +/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_lamp.c b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c new file mode 100644 index 00000000000..8087fcbdddd --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c @@ -0,0 +1,307 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_view3d/view3d_gizmo_lamp.c + * \ingroup spview3d + */ + + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" +#include "BKE_object.h" + +#include "DNA_object_types.h" +#include "DNA_lamp_types.h" + +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +#include "UI_resources.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "view3d_intern.h" /* own include */ + +/* -------------------------------------------------------------------- */ + +/** \name Spot Lamp Manipulators + * \{ */ + +static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + View3D *v3d = CTX_wm_view3d(C); + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + { + return false; + } + + Object *ob = CTX_data_active_object(C); + + if (ob && ob->type == OB_LAMP) { + Lamp *la = ob->data; + return (la->type == LA_SPOT); + } + return false; +} + +static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); + + wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL); + wmManipulator *mpr = wwrapper->manipulator; + RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED); + + mgroup->customdata = wwrapper; + + ED_manipulator_arrow3d_set_range_fac(mpr, 4.0f); + + UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, mpr->color); +} + +static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + wmManipulatorWrapper *wwrapper = mgroup->customdata; + wmManipulator *mpr = wwrapper->manipulator; + Object *ob = CTX_data_active_object(C); + Lamp *la = ob->data; + float dir[3]; + + negate_v3_v3(dir, ob->obmat[2]); + + WM_manipulator_set_matrix_rotation_from_z_axis(mpr, dir); + WM_manipulator_set_matrix_location(mpr, ob->obmat[3]); + + /* need to set property here for undo. TODO would prefer to do this in _init */ + PointerRNA lamp_ptr; + const char *propname = "spot_size"; + RNA_pointer_create(&la->id, &RNA_Light, la, &lamp_ptr); + WM_manipulator_target_property_def_rna(mpr, "offset", &lamp_ptr, propname, -1); +} + +void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt) +{ + wgt->name = "Spot Light Widgets"; + wgt->idname = "VIEW3D_WGT_lamp_spot"; + + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D | + WM_MANIPULATORGROUPTYPE_DEPTH_3D); + + wgt->poll = WIDGETGROUP_lamp_spot_poll; + wgt->setup = WIDGETGROUP_lamp_spot_setup; + wgt->refresh = WIDGETGROUP_lamp_spot_refresh; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ + +/** \name Area Lamp Manipulators + * \{ */ + +/* scale callbacks */ +static void manipulator_area_lamp_prop_matrix_get( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + void *value_p) +{ + BLI_assert(mpr_prop->type->array_length == 16); + float (*matrix)[4] = value_p; + const Lamp *la = mpr_prop->custom_func.user_data; + + matrix[0][0] = la->area_size; + matrix[1][1] = ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE) ? la->area_sizey : la->area_size; +} + +static void manipulator_area_lamp_prop_matrix_set( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + const void *value_p) +{ + const float (*matrix)[4] = value_p; + BLI_assert(mpr_prop->type->array_length == 16); + Lamp *la = mpr_prop->custom_func.user_data; + + if (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE)) { + la->area_size = len_v3(matrix[0]); + la->area_sizey = len_v3(matrix[1]); + } + else { + la->area_size = len_v3(matrix[0]); + } +} + +static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + View3D *v3d = CTX_wm_view3d(C); + if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + return false; + } + + Object *ob = CTX_data_active_object(C); + if (ob && ob->type == OB_LAMP) { + Lamp *la = ob->data; + return (la->type == LA_AREA); + } + return false; +} + +static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); + wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); + wmManipulator *mpr = wwrapper->manipulator; + RNA_enum_set(mpr->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + + mgroup->customdata = wwrapper; + + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); +} + +static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + wmManipulatorWrapper *wwrapper = mgroup->customdata; + Object *ob = CTX_data_active_object(C); + Lamp *la = ob->data; + wmManipulator *mpr = wwrapper->manipulator; + + copy_m4_m4(mpr->matrix_basis, ob->obmat); + + int flag = ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE; + if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) { + flag |= ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM; + } + RNA_enum_set(mpr->ptr, "transform", flag); + + /* need to set property here for undo. TODO would prefer to do this in _init */ + WM_manipulator_target_property_def_func( + mpr, "matrix", + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = manipulator_area_lamp_prop_matrix_get, + .value_set_fn = manipulator_area_lamp_prop_matrix_set, + .range_get_fn = NULL, + .user_data = la, + }); +} + +void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt) +{ + wgt->name = "Area Light Widgets"; + wgt->idname = "VIEW3D_WGT_lamp_area"; + + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D | + WM_MANIPULATORGROUPTYPE_DEPTH_3D); + + wgt->poll = WIDGETGROUP_lamp_area_poll; + wgt->setup = WIDGETGROUP_lamp_area_setup; + wgt->refresh = WIDGETGROUP_lamp_area_refresh; +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Lamp Target Manipulator + * \{ */ + +static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + View3D *v3d = CTX_wm_view3d(C); + if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + return false; + } + + Object *ob = CTX_data_active_object(C); + + if (ob != NULL) { + if (ob->type == OB_LAMP) { + Lamp *la = ob->data; + return (ELEM(la->type, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA)); + } +#if 0 + else if (ob->type == OB_CAMERA) { + return true; + } +#endif + } + return false; +} + +static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); + wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL); + wmManipulator *mpr = wwrapper->manipulator; + + mgroup->customdata = wwrapper; + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + + mpr->scale_basis = 0.06f; + + wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_transform_axis_target", true); + + RNA_enum_set(mpr->ptr, "draw_options", + ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW); + + WM_manipulator_operator_set(mpr, 0, ot, NULL); +} + +static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + wmManipulatorWrapper *wwrapper = mgroup->customdata; + Object *ob = CTX_data_active_object(C); + wmManipulator *mpr = wwrapper->manipulator; + + copy_m4_m4(mpr->matrix_basis, ob->obmat); + unit_m4(mpr->matrix_offset); + mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); +} + +void VIEW3D_WGT_lamp_target(wmManipulatorGroupType *wgt) +{ + wgt->name = "Target Light Widgets"; + wgt->idname = "VIEW3D_WGT_lamp_target"; + + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D); + + wgt->poll = WIDGETGROUP_lamp_target_poll; + wgt->setup = WIDGETGROUP_lamp_target_setup; + wgt->draw_prepare = WIDGETGROUP_lamp_target_draw_prepare; +} + +/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c new file mode 100644 index 00000000000..db4eeef18f7 --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -0,0 +1,371 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_view3d/view3d_gizmo_navigate.c + * \ingroup spview3d + */ + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" +#include "BKE_object.h" + +#include "DNA_object_types.h" + +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "view3d_intern.h" /* own include */ + +/* -------------------------------------------------------------------- */ +/** \name View3D Navigation Manipulator Group + * \{ */ + +/* Offset from screen edge. */ +#define MANIPULATOR_OFFSET_FAC 1.5f +/* Size of main icon. */ +#define MANIPULATOR_SIZE 64 +/* Factor for size of smaller button. */ +#define MANIPULATOR_MINI_FAC 0.35f +/* How much mini buttons offset from the primary. */ +#define MANIPULATOR_MINI_OFFSET_FAC 0.42f + + +enum { + MPR_MOVE = 0, + MPR_ROTATE = 1, + MPR_ZOOM = 2, + + /* just buttons */ + /* overlaps MPR_ORTHO (switch between) */ + MPR_PERSP = 3, + MPR_ORTHO = 4, + MPR_CAMERA = 5, + + MPR_TOTAL = 6, +}; + +/* Vector icons compatible with 'GPU_batch_from_poly_2d_encoded' */ +static const uchar shape_camera[] = { + 0xa3, 0x19, 0x78, 0x55, 0x4d, 0x19, 0x4f, 0x0a, 0x7f, 0x00, 0xb0, 0x0a, 0xa9, 0x19, + 0xa9, 0x19, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, + 0x4d, 0x19, 0x47, 0x19, 0x65, 0x55, 0x41, 0x55, 0x41, 0x9e, 0x43, 0xa8, 0x38, 0xb3, + 0x34, 0xc3, 0x38, 0xd2, 0x43, 0xdd, 0x53, 0xe1, 0x62, 0xdd, 0x6d, 0xd2, 0x72, 0xc3, + 0x78, 0xc3, 0x7c, 0xd2, 0x87, 0xdd, 0x96, 0xe1, 0xa6, 0xdd, 0xb1, 0xd2, 0xb5, 0xc3, + 0xb1, 0xb3, 0xa6, 0xa8, 0xa9, 0x9e, 0xa9, 0x8c, 0xbb, 0x8c, 0xbb, 0x86, 0xc7, 0x86, + 0xe0, 0x9e, 0xe0, 0x55, 0xc7, 0x6d, 0xbb, 0x6d, 0xbb, 0x67, 0xa9, 0x67, 0xa9, 0x55, + 0x8a, 0x55, 0xa9, 0x19, 0xb0, 0x0a, 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, + 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, 0x4f, 0xf5, 0x4f, 0xf5, 0x7c, 0xb3, 0x78, 0xc3, + 0x72, 0xc3, 0x6d, 0xb3, 0x62, 0xa8, 0x53, 0xa4, 0x43, 0xa8, 0x41, 0x9e, 0xa9, 0x9e, + 0xa6, 0xa8, 0x96, 0xa4, 0x87, 0xa8, 0x87, 0xa8, +}; +static const uchar shape_ortho[] = { + 0x85, 0x15, 0x85, 0x7c, 0xde, 0xb3, 0xde, 0xb8, 0xd9, 0xba, 0x80, 0x85, 0x27, 0xba, + 0x22, 0xb8, 0x22, 0xb3, 0x7b, 0x7c, 0x7b, 0x15, 0x80, 0x12, 0x80, 0x12, 0x1d, 0xba, + 0x80, 0xf2, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, + 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x80, 0x0d, 0x1d, 0x45, 0x1d, 0x45, 0xb0, 0x0a, + 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, + 0x80, 0xf2, 0xe3, 0xba, 0xe3, 0x45, 0x80, 0x0d, 0x7f, 0x00, 0x7f, 0x00, +}; +static const uchar shape_pan[] = { + 0xbf, 0x4c, 0xbf, 0x66, 0x99, 0x66, 0x99, 0x40, 0xb2, 0x40, 0x7f, 0x0d, 0x7f, 0x00, + 0xb0, 0x0a, 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, + 0x80, 0xff, 0x80, 0xf2, 0xb3, 0xbf, 0x99, 0xbf, 0x99, 0x99, 0xbf, 0x99, 0xbf, 0xb2, + 0xf2, 0x7f, 0xf2, 0x7f, 0x40, 0xb3, 0x40, 0x99, 0x66, 0x99, 0x66, 0xbf, 0x4d, 0xbf, + 0x80, 0xf2, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, + 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x7f, 0x0d, 0x4c, 0x40, 0x66, 0x40, 0x66, 0x66, + 0x40, 0x66, 0x40, 0x4d, 0x0d, 0x80, 0x0d, 0x80, +}; +static const uchar shape_persp[] = { + 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, + 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x80, 0x07, 0x30, 0x50, 0x18, 0xbd, + 0x80, 0xdb, 0xe8, 0xbd, 0xf5, 0xb0, 0xf5, 0xb0, 0x83, 0x0f, 0x87, 0x7b, 0xe2, 0xb7, + 0xe3, 0xba, 0xe0, 0xbb, 0x80, 0x87, 0x20, 0xbb, 0x1d, 0xba, 0x1d, 0xb7, 0x78, 0x7b, + 0x7d, 0x0f, 0x80, 0x0c, 0x80, 0x0c, 0xd0, 0x50, 0x80, 0x07, 0x7f, 0x00, 0xb0, 0x0a, + 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xe8, 0xbd, 0xe8, 0xbd, +}; +static const uchar shape_zoom[] = { + 0xad, 0x7f, 0xf1, 0x7f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, + 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0d, 0x7f, 0x52, 0x7f, 0x69, 0xb7, + 0x48, 0xb7, 0x80, 0xd8, 0xb8, 0xb7, 0x96, 0xb7, 0x96, 0xb7, 0x7f, 0x2f, 0x0d, 0x7f, + 0x00, 0x7f, 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0xb0, 0x0a, 0xda, 0x25, + 0xf5, 0x4f, 0xff, 0x80, 0xf1, 0x7f, 0xf1, 0x7f, +}; + + +struct NavigateManipulatorInfo { + const char *opname; + const char *manipulator; + const unsigned char *shape; + uint shape_size; +}; + +#define SHAPE_VARS(shape_id) shape = shape_id, .shape_size = ARRAY_SIZE(shape_id) + +struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = { + { + .opname = "VIEW3D_OT_move", + .manipulator = "MANIPULATOR_WT_button_2d", + .SHAPE_VARS(shape_pan), + }, { + .opname = "VIEW3D_OT_rotate", + .manipulator = "VIEW3D_WT_navigate_rotate", + .shape = NULL, + .shape_size = 0, + }, { + .opname = "VIEW3D_OT_zoom", + .manipulator = "MANIPULATOR_WT_button_2d", + .SHAPE_VARS(shape_zoom), + }, { + .opname = "VIEW3D_OT_view_persportho", + .manipulator = "MANIPULATOR_WT_button_2d", + .SHAPE_VARS(shape_persp), + }, { + .opname = "VIEW3D_OT_view_persportho", + .manipulator = "MANIPULATOR_WT_button_2d", + .SHAPE_VARS(shape_ortho), + }, { + .opname = "VIEW3D_OT_view_camera", + .manipulator = "MANIPULATOR_WT_button_2d", + .SHAPE_VARS(shape_camera), + }, +}; + +#undef SHAPE_VARS + +struct NavigateWidgetGroup { + wmManipulator *mpr_array[MPR_TOTAL]; + /* Store the view state to check for changes. */ + struct { + rcti rect_visible; + struct { + char is_persp; + char is_camera; + char viewlock; + } rv3d; + } state; + int region_size[2]; +}; + +static bool WIDGETGROUP_navigate_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + View3D *v3d = CTX_wm_view3d(C); + if (((U.uiflag & USER_SHOW_MANIPULATOR_AXIS) == 0) || + (v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_NAVIGATE))) + { + return false; + } + return true; + +} + +static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + struct NavigateWidgetGroup *navgroup = MEM_callocN(sizeof(struct NavigateWidgetGroup), __func__); + + navgroup->region_size[0] = -1; + navgroup->region_size[1] = -1; + + wmOperatorType *ot_view_axis = WM_operatortype_find("VIEW3D_OT_view_axis", true); + wmOperatorType *ot_view_camera = WM_operatortype_find("VIEW3D_OT_view_camera", true); + + for (int i = 0; i < MPR_TOTAL; i++) { + const struct NavigateManipulatorInfo *info = &g_navigate_params[i]; + navgroup->mpr_array[i] = WM_manipulator_new(info->manipulator, mgroup, NULL); + wmManipulator *mpr = navgroup->mpr_array[i]; + mpr->flag |= WM_MANIPULATOR_GRAB_CURSOR | WM_MANIPULATOR_DRAW_MODAL; + mpr->color[3] = 0.2f; + mpr->color_hi[3] = 0.4f; + + /* may be overwritten later */ + mpr->scale_basis = (MANIPULATOR_SIZE * MANIPULATOR_MINI_FAC) / 2; + if (info->shape != NULL) { + PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "shape"); + RNA_property_string_set_bytes( + mpr->ptr, prop, + (const char *)info->shape, info->shape_size); + RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_BUTTON_SHOW_OUTLINE); + } + + wmOperatorType *ot = WM_operatortype_find(info->opname, true); + WM_manipulator_operator_set(mpr, 0, ot, NULL); + } + + { + wmManipulator *mpr = navgroup->mpr_array[MPR_CAMERA]; + WM_manipulator_operator_set(mpr, 0, ot_view_camera, NULL); + } + + /* Click only buttons (not modal). */ + { + int mpr_ids[] = {MPR_PERSP, MPR_ORTHO, MPR_CAMERA}; + for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) { + wmManipulator *mpr = navgroup->mpr_array[mpr_ids[i]]; + RNA_boolean_set(mpr->ptr, "show_drag", false); + } + } + + /* Modal operators, don't use initial mouse location since we're clicking on a button. */ + { + int mpr_ids[] = {MPR_MOVE, MPR_ROTATE, MPR_ZOOM}; + for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) { + wmManipulator *mpr = navgroup->mpr_array[mpr_ids[i]]; + wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, 0); + RNA_boolean_set(&mpop->ptr, "use_mouse_init", false); + } + } + + { + wmManipulator *mpr = navgroup->mpr_array[MPR_ROTATE]; + mpr->scale_basis = MANIPULATOR_SIZE / 2; + char mapping[6] = { + RV3D_VIEW_LEFT, + RV3D_VIEW_RIGHT, + RV3D_VIEW_FRONT, + RV3D_VIEW_BACK, + RV3D_VIEW_BOTTOM, + RV3D_VIEW_TOP, + }; + + for (int part_index = 0; part_index < 6; part_index += 1) { + PointerRNA *ptr = WM_manipulator_operator_set(mpr, part_index + 1, ot_view_axis, NULL); + RNA_enum_set(ptr, "type", mapping[part_index]); + } + + /* When dragging an axis, use this instead. */ + mpr->drag_part = 0; + } + + mgroup->customdata = navgroup; +} + +static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + struct NavigateWidgetGroup *navgroup = mgroup->customdata; + ARegion *ar = CTX_wm_region(C); + const RegionView3D *rv3d = ar->regiondata; + + for (int i = 0; i < 3; i++) { + copy_v3_v3(navgroup->mpr_array[MPR_ROTATE]->matrix_offset[i], rv3d->viewmat[i]); + } + + rcti rect_visible; + ED_region_visible_rect(ar, &rect_visible); + + if ((navgroup->state.rect_visible.xmax == rect_visible.xmax) && + (navgroup->state.rect_visible.ymax == rect_visible.ymax) && + (navgroup->state.rv3d.is_persp == rv3d->is_persp) && + (navgroup->state.rv3d.is_camera == (rv3d->persp == RV3D_CAMOB)) && + (navgroup->state.rv3d.viewlock == rv3d->viewlock)) + { + return; + } + + navgroup->state.rect_visible = rect_visible; + navgroup->state.rv3d.is_persp = rv3d->is_persp; + navgroup->state.rv3d.is_camera = (rv3d->persp == RV3D_CAMOB); + navgroup->state.rv3d.viewlock = rv3d->viewlock; + + const bool show_rotate = ( + ((rv3d->viewlock & RV3D_LOCKED) == 0) && + (navgroup->state.rv3d.is_camera == false)); + const bool show_fixed_offset = navgroup->state.rv3d.is_camera; + const float icon_size = MANIPULATOR_SIZE; + const float icon_offset = (icon_size * 0.52f) * MANIPULATOR_OFFSET_FAC * UI_DPI_FAC; + const float icon_offset_mini = icon_size * MANIPULATOR_MINI_OFFSET_FAC * UI_DPI_FAC; + const float co_rotate[2] = { + rect_visible.xmax - icon_offset, + rect_visible.ymax - icon_offset, + }; + const float co[2] = { + rect_visible.xmax - ((show_rotate || show_fixed_offset) ? (icon_offset * 2.0f) : (icon_offset_mini * 0.75f)), + rect_visible.ymax - icon_offset_mini * 0.75f, + }; + + wmManipulator *mpr; + + for (uint i = 0; i < ARRAY_SIZE(navgroup->mpr_array); i++) { + mpr = navgroup->mpr_array[i]; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + } + + /* RV3D_LOCKED or Camera: only show supported buttons. */ + if (show_rotate) { + mpr = navgroup->mpr_array[MPR_ROTATE]; + mpr->matrix_basis[3][0] = co_rotate[0]; + mpr->matrix_basis[3][1] = co_rotate[1]; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + } + + int icon_mini_slot = 0; + + mpr = navgroup->mpr_array[MPR_ZOOM]; + mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); + mpr->matrix_basis[3][1] = co[1]; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + + mpr = navgroup->mpr_array[MPR_MOVE]; + mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); + mpr->matrix_basis[3][1] = co[1]; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + + if ((rv3d->viewlock & RV3D_LOCKED) == 0) { + mpr = navgroup->mpr_array[MPR_CAMERA]; + mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); + mpr->matrix_basis[3][1] = co[1]; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + + if (navgroup->state.rv3d.is_camera == false) { + mpr = navgroup->mpr_array[rv3d->is_persp ? MPR_PERSP : MPR_ORTHO]; + mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); + mpr->matrix_basis[3][1] = co[1]; + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + } + } +} + +void VIEW3D_WGT_navigate(wmManipulatorGroupType *wgt) +{ + wgt->name = "View3D Navigate"; + wgt->idname = "VIEW3D_WGT_navigate"; + + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_SCALE | + WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL); + + wgt->poll = WIDGETGROUP_navigate_poll; + wgt->setup = WIDGETGROUP_navigate_setup; + wgt->draw_prepare = WIDGETGROUP_navigate_draw_prepare; +} + +/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c new file mode 100644 index 00000000000..072f2ee4583 --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -0,0 +1,310 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file view3d_gizmo_navigate_type.c + * \ingroup wm + * + * \name Custom Orientation/Navigation Manipulator for the 3D View + * + * \brief Simple manipulator to axis and translate. + * + * - scale_basis: used for the size. + * - matrix_basis: used for the location. + * - matrix_offset: used to store the orientation. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" +#include "BLI_sort_utils.h" + +#include "BKE_context.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_state.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" + +#include "view3d_intern.h" + +#define DIAL_RESOLUTION 32 + +#define HANDLE_SIZE 0.33 + +static void axis_geom_draw( + const wmManipulator *mpr, const float color[4], const bool UNUSED(select)) +{ + GPU_line_width(mpr->line_width); + + Gwn_VertFormat *format = immVertexFormat(); + const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + + /* flip z for reverse */ + const float cone_coords[5][3] = { + {-1, -1, 4}, + {-1, +1, 4}, + {+1, +1, 4}, + {+1, -1, 4}, + {0, 0, 2}, + }; + + struct { + float depth; + char index; + char axis; + char is_pos; + } axis_order[6] = { + {-mpr->matrix_offset[0][2], 0, 0, false}, + {+mpr->matrix_offset[0][2], 1, 0, true}, + {-mpr->matrix_offset[1][2], 2, 1, false}, + {+mpr->matrix_offset[1][2], 3, 1, true}, + {-mpr->matrix_offset[2][2], 4, 2, false}, + {+mpr->matrix_offset[2][2], 5, 2, true}, + }; + qsort(&axis_order, ARRAY_SIZE(axis_order), sizeof(axis_order[0]), BLI_sortutil_cmp_float); + + const float scale_axis = 0.25f; + static const float axis_highlight[4] = {1, 1, 1, 1}; + static const float axis_nop[4] = {1, 1, 1, 0}; + static const float axis_black[4] = {0, 0, 0, 1}; + static float axis_color[3][4]; + gpuPushMatrix(); + gpuMultMatrix(mpr->matrix_offset); + + bool draw_center_done = false; + + for (int axis_index = 0; axis_index < ARRAY_SIZE(axis_order); axis_index++) { + const int index = axis_order[axis_index].index; + const int axis = axis_order[axis_index].axis; + const bool is_pos = axis_order[axis_index].is_pos; + + /* Draw slightly before, so axis aligned arrows draw ontop. */ + if ((draw_center_done == false) && (axis_order[axis_index].depth > -0.01f)) { + + /* Circle defining active area (revert back to 2D space). */ + { + gpuPopMatrix(); + immUniformColor4fv(color); + imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION); + gpuPushMatrix(); + gpuMultMatrix(mpr->matrix_offset); + } + + /* Center cube. */ + { + float center[3], size[3]; + + zero_v3(center); + copy_v3_fl(size, HANDLE_SIZE); + + GPU_depth_test(true); + glDepthMask(GL_TRUE); + glDepthFunc(GL_LEQUAL); + GPU_blend_set_func(GPU_ONE, GPU_ZERO); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + + GPU_line_smooth(true); + GPU_blend(true); + GPU_line_width(1.0f); + /* Just draw depth values. */ + immUniformColor4fv(axis_nop); + imm_draw_cube_fill_3d(pos_id, center, size); + immUniformColor4fv(axis_black); + madd_v3_v3fl( + center, + (float[3]){ + mpr->matrix_offset[0][2], + mpr->matrix_offset[1][2], + mpr->matrix_offset[2][2], + }, + 0.08f); + imm_draw_cube_wire_3d(pos_id, center, size); + GPU_blend(false); + GPU_line_smooth(false); + GPU_depth_test(false); + } + + draw_center_done = true; + } + UI_GetThemeColor3fv(TH_AXIS_X + axis, axis_color[axis]); + axis_color[axis][3] = 1.0f; + + const int index_z = axis; + const int index_y = (axis + 1) % 3; + const int index_x = (axis + 2) % 3; + +#define ROTATED_VERT(v_orig) \ + { \ + float v[3]; \ + copy_v3_v3(v, v_orig); \ + if (is_pos == 0) { \ + v[2] *= -1.0f; \ + } \ + immVertex3f(pos_id, v[index_x] * scale_axis, v[index_y] * scale_axis, v[index_z] * scale_axis); \ + } ((void)0) + + bool ok = true; + + /* skip view align axis */ + if (len_squared_v2(mpr->matrix_offset[axis]) < 1e-6f && (mpr->matrix_offset[axis][2] > 0.0f) == is_pos) { + ok = false; + } + if (ok) { + immUniformColor4fv(index + 1 == mpr->highlight_part ? axis_highlight : axis_color[axis]); + immBegin(GWN_PRIM_TRI_FAN, 6); + ROTATED_VERT(cone_coords[4]); + for (int j = 0; j <= 4; j++) { + ROTATED_VERT(cone_coords[j % 4]); + } + immEnd(); + } + +#undef ROTATED_VERT + } + + gpuPopMatrix(); + immUnbindProgram(); +} + +static void axis3d_draw_intern( + const bContext *UNUSED(C), wmManipulator *mpr, + const bool select, const bool highlight) +{ + const float *color = highlight ? mpr->color_hi : mpr->color; + float matrix_final[4][4]; + float matrix_unit[4][4]; + + unit_m4(matrix_unit); + + WM_manipulator_calc_matrix_final_params( + mpr, + &((struct WM_ManipulatorMatrixParams) { + .matrix_offset = matrix_unit, + }), matrix_final); + + gpuPushMatrix(); + gpuMultMatrix(matrix_final); + + GPU_blend(true); + axis_geom_draw(mpr, color, select); + GPU_blend(false); + gpuPopMatrix(); +} + +static void manipulator_axis_draw(const bContext *C, wmManipulator *mpr) +{ + const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; + const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + + (void)is_modal; + + GPU_blend(true); + axis3d_draw_intern(C, mpr, false, is_highlight); + GPU_blend(false); +} + +static int manipulator_axis_test_select( + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +{ + float point_local[2] = {UNPACK2(event->mval)}; + sub_v2_v2(point_local, mpr->matrix_basis[3]); + mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC)); + + const float len_sq = len_squared_v2(point_local); + if (len_sq > 1.0) { + return -1; + } + + int part_best = -1; + int part_index = 1; + /* Use 'SQUARE(HANDLE_SIZE)' if we want to be able to _not_ focus on one of the axis. */ + float i_best_len_sq = FLT_MAX; + for (int i = 0; i < 3; i++) { + for (int is_pos = 0; is_pos < 2; is_pos++) { + float co[2] = { + mpr->matrix_offset[i][0] * (is_pos ? 1 : -1), + mpr->matrix_offset[i][1] * (is_pos ? 1 : -1), + }; + + bool ok = true; + + /* Check if we're viewing on an axis, there is no point to clicking on the current axis so show the reverse. */ + if (len_squared_v2(co) < 1e-6f && (mpr->matrix_offset[i][2] > 0.0f) == is_pos) { + ok = false; + } + + if (ok) { + const float len_axis_sq = len_squared_v2v2(co, point_local); + if (len_axis_sq < i_best_len_sq) { + part_best = part_index; + i_best_len_sq = len_axis_sq; + } + } + part_index += 1; + } + } + + if (part_best != -1) { + return part_best; + } + + /* The 'mpr->scale_final' is already applied when projecting. */ + if (len_sq < 1.0f) { + return 0; + } + + return -1; +} + +static int manipulator_axis_cursor_get(wmManipulator *mpr) +{ + if (mpr->highlight_part > 0) { + return CURSOR_EDIT; + } + return BC_NSEW_SCROLLCURSOR; +} + +void VIEW3D_WT_navigate_rotate(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "VIEW3D_WT_navigate_rotate"; + + /* api callbacks */ + wt->draw = manipulator_axis_draw; + wt->test_select = manipulator_axis_test_select; + wt->cursor_get = manipulator_axis_cursor_get; + + wt->struct_size = sizeof(wmManipulator); +} diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c new file mode 100644 index 00000000000..c29b07e4147 --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -0,0 +1,1101 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_view3d/view3d_gizmo_ruler.c + * \ingroup spview3d + */ + +#include "BLI_listbase.h" +#include "BLI_string.h" +#include "BLI_rect.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BLT_translation.h" + +#include "BKE_context.h" +#include "BKE_gpencil.h" +#include "BKE_main.h" + +#include "BKE_object.h" +#include "BKE_unit.h" + +#include "DNA_object_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_view3d_types.h" + +#include "BIF_gl.h" + +#include "ED_screen.h" +#include "ED_transform_snap_object_context.h" +#include "ED_view3d.h" + +#include "UI_resources.h" +#include "UI_interface.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" +#include "WM_toolsystem.h" + +#include "view3d_intern.h" /* own include */ + +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_select.h" +#include "GPU_state.h" + +#include "BLF_api.h" + + +static const char *view3d_wgt_ruler_id = "VIEW3D_WGT_ruler"; + + +#define MVAL_MAX_PX_DIST 12.0f + +/* -------------------------------------------------------------------- */ +/* Ruler Item (we can have many) */ +enum { + RULERITEM_USE_ANGLE = (1 << 0), /* use protractor */ + RULERITEM_USE_RAYCAST = (1 << 1) +}; + +enum { + RULERITEM_DIRECTION_IN = 0, + RULERITEM_DIRECTION_OUT +}; + +/* keep smaller then selection, since we may want click elsewhere without selecting a ruler */ +#define RULER_PICK_DIST 12.0f +#define RULER_PICK_DIST_SQ (RULER_PICK_DIST * RULER_PICK_DIST) + +/* not clicking on a point */ +#define PART_LINE 0xff + +/* -------------------------------------------------------------------- */ +/* Ruler Info (wmManipulatorGroup customdata) */ + +enum { + RULER_STATE_NORMAL = 0, + RULER_STATE_DRAG +}; + +enum { + RULER_SNAP_OK = (1 << 0), +}; + +typedef struct RulerInfo { + // ListBase items; + int item_active; + int flag; + int snap_flag; + int state; + + struct SnapObjectContext *snap_context; + + /* wm state */ + wmWindow *win; + ScrArea *sa; + ARegion *ar; /* re-assigned every modal update */ +} RulerInfo; + +/* -------------------------------------------------------------------- */ +/* Ruler Item (two or three points) */ + +typedef struct RulerItem { + wmManipulator mpr; + + /* worldspace coords, middle being optional */ + float co[3][3]; + + int flag; + int raycast_dir; /* RULER_DIRECTION_* */ +} RulerItem; + +typedef struct RulerInteraction { + /* selected coord */ + char co_index; /* 0 -> 2 */ + float drag_start_co[3]; + uint inside_region : 1; +} RulerInteraction; + +/* -------------------------------------------------------------------- */ +/** \name Internal Ruler Utilities + * \{ */ + +static RulerItem *ruler_item_add(wmManipulatorGroup *mgroup) +{ + /* could pass this as an arg */ + const wmManipulatorType *wt_ruler = WM_manipulatortype_find("VIEW3D_WT_ruler_item", true); + RulerItem *ruler_item = (RulerItem *)WM_manipulator_new_ptr(wt_ruler, mgroup, NULL); + WM_manipulator_set_flag(&ruler_item->mpr, WM_MANIPULATOR_DRAW_MODAL, true); + return ruler_item; +} + +static void ruler_item_remove(bContext *C, wmManipulatorGroup *mgroup, RulerItem *ruler_item) +{ + WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, &ruler_item->mpr, C); +} + +static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit, + char *numstr, size_t numstr_size, int prec) +{ + const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0; + + if (ruler_item->flag & RULERITEM_USE_ANGLE) { + const float ruler_angle = angle_v3v3v3(ruler_item->co[0], + ruler_item->co[1], + ruler_item->co[2]); + + if (unit->system == USER_UNIT_NONE) { + BLI_snprintf(numstr, numstr_size, "%.*f°", prec, RAD2DEGF(ruler_angle)); + } + else { + bUnit_AsString(numstr, numstr_size, + (double)ruler_angle, + prec, unit->system, B_UNIT_ROTATION, do_split, false); + } + } + else { + const float ruler_len = len_v3v3(ruler_item->co[0], + ruler_item->co[2]); + + if (unit->system == USER_UNIT_NONE) { + BLI_snprintf(numstr, numstr_size, "%.*f", prec, ruler_len); + } + else { + bUnit_AsString(numstr, numstr_size, + (double)(ruler_len * unit->scale_length), + prec, unit->system, B_UNIT_LENGTH, do_split, false); + } + } +} + +static bool view3d_ruler_pick( + wmManipulatorGroup *mgroup, RulerItem *ruler_item, const float mval[2], + int *r_co_index) +{ + RulerInfo *ruler_info = mgroup->customdata; + ARegion *ar = ruler_info->ar; + bool found = false; + + float dist_best = RULER_PICK_DIST_SQ; + int co_index_best = -1; + + { + float co_ss[3][2]; + float dist; + int j; + + /* should these be checked? - ok for now not to */ + for (j = 0; j < 3; j++) { + ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); + } + + if (ruler_item->flag & RULERITEM_USE_ANGLE) { + dist = min_ff(dist_squared_to_line_segment_v2(mval, co_ss[0], co_ss[1]), + dist_squared_to_line_segment_v2(mval, co_ss[1], co_ss[2])); + if (dist < dist_best) { + dist_best = dist; + found = true; + + { + const float dist_points[3] = { + len_squared_v2v2(co_ss[0], mval), + len_squared_v2v2(co_ss[1], mval), + len_squared_v2v2(co_ss[2], mval), + }; + if (min_fff(UNPACK3(dist_points)) < RULER_PICK_DIST_SQ) { + co_index_best = min_axis_v3(dist_points); + } + else { + co_index_best = -1; + } + } + } + } + else { + dist = dist_squared_to_line_segment_v2(mval, co_ss[0], co_ss[2]); + if (dist < dist_best) { + dist_best = dist; + found = true; + + { + const float dist_points[2] = { + len_squared_v2v2(co_ss[0], mval), + len_squared_v2v2(co_ss[2], mval), + }; + if (min_ff(UNPACK2(dist_points)) < RULER_PICK_DIST_SQ) { + co_index_best = (dist_points[0] < dist_points[1]) ? 0 : 2; + } + else { + co_index_best = -1; + } + } + } + } + } + + *r_co_index = co_index_best; + return found; +} + +/** + * Ensure the 'snap_context' is only cached while dragging, + * needed since the user may toggle modes between tool use. + */ +static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) +{ + Main *bmain = CTX_data_main(C); + if (state == ruler_info->state) { + return; + } + + /* always remove */ + if (ruler_info->snap_context) { + ED_transform_snap_object_context_destroy(ruler_info->snap_context); + ruler_info->snap_context = NULL; + } + + if (state == RULER_STATE_NORMAL) { + /* pass */ + } + else if (state == RULER_STATE_DRAG) { + ruler_info->snap_context = ED_transform_snap_object_context_create_view3d( + bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, + ruler_info->ar, CTX_wm_view3d(C)); + } + else { + BLI_assert(0); + } + + ruler_info->state = state; +} + +static void view3d_ruler_item_project( + RulerInfo *ruler_info, float r_co[3], + const int xy[2]) +{ + ED_view3d_win_to_3d_int(ruler_info->sa->spacedata.first, ruler_info->ar, r_co, xy, r_co); +} + +/* use for mousemove events */ +static bool view3d_ruler_item_mousemove( + RulerInfo *ruler_info, RulerItem *ruler_item, const int mval[2], + const bool do_thickness, const bool do_snap) +{ + RulerInteraction *inter = ruler_item->mpr.interaction_data; + const float eps_bias = 0.0002f; + float dist_px = MVAL_MAX_PX_DIST * U.pixelsize; /* snap dist */ + + ruler_info->snap_flag &= ~RULER_SNAP_OK; + + if (ruler_item) { + float *co = ruler_item->co[inter->co_index]; + /* restore the initial depth */ + copy_v3_v3(co, inter->drag_start_co); + view3d_ruler_item_project(ruler_info, co, mval); + if (do_thickness && inter->co_index != 1) { + // Scene *scene = CTX_data_scene(C); + // View3D *v3d = ruler_info->sa->spacedata.first; + const float mval_fl[2] = {UNPACK2(mval)}; + float ray_normal[3]; + float ray_start[3]; + float *co_other; + + co_other = ruler_item->co[inter->co_index == 0 ? 2 : 0]; + + if (ED_transform_snap_object_project_view3d( + ruler_info->snap_context, + SCE_SNAP_MODE_FACE, + &(const struct SnapObjectParams){ + .snap_select = SNAP_ALL, + .use_object_edit_cage = true, + }, + mval_fl, &dist_px, + co, ray_normal)) + { + negate_v3(ray_normal); + /* add some bias */ + madd_v3_v3v3fl(ray_start, co, ray_normal, eps_bias); + ED_transform_snap_object_project_ray( + ruler_info->snap_context, + &(const struct SnapObjectParams){ + .snap_select = SNAP_ALL, + .use_object_edit_cage = true, + }, + ray_start, ray_normal, NULL, + co_other, NULL); + } + } + else if (do_snap) { + const float mval_fl[2] = {UNPACK2(mval)}; + + if (ED_transform_snap_object_project_view3d( + ruler_info->snap_context, + (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE), + &(const struct SnapObjectParams){ + .snap_select = SNAP_ALL, + .use_object_edit_cage = true, + .use_occlusion_test = true, + }, + mval_fl, &dist_px, + co, NULL)) + { + ruler_info->snap_flag |= RULER_SNAP_OK; + } + } + return true; + } + else { + return false; + } +} + + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Ruler/Grease Pencil Conversion + * \{ */ + +#define RULER_ID "RulerData3D" +static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup) +{ + // RulerInfo *ruler_info = mgroup->customdata; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + bGPDlayer *gpl; + bGPDframe *gpf; + bGPDstroke *gps; + bGPDpalette *palette; + bGPDpalettecolor *palcolor; + RulerItem *ruler_item; + const char *ruler_name = RULER_ID; + bool changed = false; + + if (scene->gpd == NULL) { + scene->gpd = BKE_gpencil_data_addnew(bmain, "GPencil"); + } + + gpl = BLI_findstring(&scene->gpd->layers, ruler_name, offsetof(bGPDlayer, info)); + if (gpl == NULL) { + gpl = BKE_gpencil_layer_addnew(scene->gpd, ruler_name, false); + gpl->thickness = 1; + gpl->flag |= GP_LAYER_HIDE; + } + + /* try to get active palette or create a new one */ + palette = BKE_gpencil_palette_getactive(scene->gpd); + if (palette == NULL) { + palette = BKE_gpencil_palette_addnew(scene->gpd, DATA_("GP_Palette"), true); + } + /* try to get color with the ruler name or create a new one */ + palcolor = BKE_gpencil_palettecolor_getbyname(palette, (char *)ruler_name); + if (palcolor == NULL) { + palcolor = BKE_gpencil_palettecolor_addnew(palette, (char *)ruler_name, true); + } + + gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); + BKE_gpencil_free_strokes(gpf); + + for (ruler_item = mgroup->manipulators.first; ruler_item; ruler_item = (RulerItem *)ruler_item->mpr.next) { + bGPDspoint *pt; + int j; + + /* allocate memory for a new stroke */ + gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); + if (ruler_item->flag & RULERITEM_USE_ANGLE) { + gps->totpoints = 3; + pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + for (j = 0; j < 3; j++) { + copy_v3_v3(&pt->x, ruler_item->co[j]); + pt->pressure = 1.0f; + pt->strength = 1.0f; + pt++; + } + } + else { + gps->totpoints = 2; + pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + for (j = 0; j < 3; j += 2) { + copy_v3_v3(&pt->x, ruler_item->co[j]); + pt->pressure = 1.0f; + pt->strength = 1.0f; + pt++; + } + } + gps->flag = GP_STROKE_3DSPACE; + gps->thickness = 3; + /* assign color to stroke */ + BLI_strncpy(gps->colorname, palcolor->info, sizeof(gps->colorname)); + gps->palcolor = palcolor; + BLI_addtail(&gpf->strokes, gps); + changed = true; + } + + return changed; +} + +static bool view3d_ruler_from_gpencil(const bContext *C, wmManipulatorGroup *mgroup) +{ + Scene *scene = CTX_data_scene(C); + bool changed = false; + + if (scene->gpd) { + bGPDlayer *gpl; + const char *ruler_name = RULER_ID; + gpl = BLI_findstring(&scene->gpd->layers, ruler_name, offsetof(bGPDlayer, info)); + if (gpl) { + bGPDframe *gpf; + gpf = BKE_gpencil_layer_getframe(gpl, CFRA, false); + if (gpf) { + bGPDstroke *gps; + for (gps = gpf->strokes.first; gps; gps = gps->next) { + bGPDspoint *pt = gps->points; + int j; + RulerItem *ruler_item = NULL; + if (gps->totpoints == 3) { + ruler_item = ruler_item_add(mgroup); + for (j = 0; j < 3; j++) { + copy_v3_v3(ruler_item->co[j], &pt->x); + pt++; + } + ruler_item->flag |= RULERITEM_USE_ANGLE; + changed = true; + } + else if (gps->totpoints == 2) { + ruler_item = ruler_item_add(mgroup); + for (j = 0; j < 3; j += 2) { + copy_v3_v3(ruler_item->co[j], &pt->x); + pt++; + } + changed = true; + } + } + } + } + } + + return changed; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Ruler Item Manipulator Type + * \{ */ + +static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) +{ + Scene *scene = CTX_data_scene(C); + UnitSettings *unit = &scene->unit; + RulerInfo *ruler_info = mpr->parent_mgroup->customdata; + RulerItem *ruler_item = (RulerItem *)mpr; + ARegion *ar = ruler_info->ar; + RegionView3D *rv3d = ar->regiondata; + const float cap_size = 4.0f; + const float bg_margin = 4.0f * U.pixelsize; + const float bg_radius = 4.0f * U.pixelsize; + const float arc_size = 64.0f * U.pixelsize; +#define ARC_STEPS 24 + const int arc_steps = ARC_STEPS; + const float color_act[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + const float color_base[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + unsigned char color_text[3]; + unsigned char color_wire[3]; + float color_back[4] = {1.0f, 1.0f, 1.0f, 0.5f}; + + /* anti-aliased lines for more consistent appearance */ + GPU_line_smooth(true); + + BLF_enable(blf_mono_font, BLF_ROTATION); + BLF_size(blf_mono_font, 14 * U.pixelsize, U.dpi); + BLF_rotation(blf_mono_font, 0.0f); + + UI_GetThemeColor3ubv(TH_TEXT, color_text); + UI_GetThemeColor3ubv(TH_WIRE, color_wire); + + const bool is_act = (mpr->flag & WM_MANIPULATOR_DRAW_HOVER); + float dir_ruler[2]; + float co_ss[3][2]; + int j; + + /* should these be checked? - ok for now not to */ + for (j = 0; j < 3; j++) { + ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); + } + + GPU_blend(true); + + const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + + if (ruler_item->flag & RULERITEM_USE_ANGLE) { + immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); + + float viewport_size[4]; + GPU_viewport_size_get_f(viewport_size); + immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); + + immUniform1i("colors_len", 2); /* "advanced" mode */ + const float *col = is_act ? color_act : color_base; + immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); + immUniform1f("dash_width", 6.0f); + + immBegin(GWN_PRIM_LINE_STRIP, 3); + + immVertex2fv(shdr_pos, co_ss[0]); + immVertex2fv(shdr_pos, co_ss[1]); + immVertex2fv(shdr_pos, co_ss[2]); + + immEnd(); + + immUnbindProgram(); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + /* arc */ + { + float dir_tmp[3]; + float co_tmp[3]; + float arc_ss_coord[2]; + + float dir_a[3]; + float dir_b[3]; + float quat[4]; + float axis[3]; + float angle; + const float px_scale = (ED_view3d_pixel_size(rv3d, ruler_item->co[1]) * + min_fff(arc_size, + len_v2v2(co_ss[0], co_ss[1]) / 2.0f, + len_v2v2(co_ss[2], co_ss[1]) / 2.0f)); + + sub_v3_v3v3(dir_a, ruler_item->co[0], ruler_item->co[1]); + sub_v3_v3v3(dir_b, ruler_item->co[2], ruler_item->co[1]); + normalize_v3(dir_a); + normalize_v3(dir_b); + + cross_v3_v3v3(axis, dir_a, dir_b); + angle = angle_normalized_v3v3(dir_a, dir_b); + + axis_angle_to_quat(quat, axis, angle / arc_steps); + + copy_v3_v3(dir_tmp, dir_a); + + immUniformColor3ubv(color_wire); + + immBegin(GWN_PRIM_LINE_STRIP, arc_steps + 1); + + for (j = 0; j <= arc_steps; j++) { + madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale); + ED_view3d_project_float_global(ar, co_tmp, arc_ss_coord, V3D_PROJ_TEST_NOP); + mul_qt_v3(quat, dir_tmp); + + immVertex2fv(shdr_pos, arc_ss_coord); + } + + immEnd(); + } + + /* capping */ + { + float rot_90_vec_a[2]; + float rot_90_vec_b[2]; + float cap[2]; + + sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[1]); + rot_90_vec_a[0] = -dir_ruler[1]; + rot_90_vec_a[1] = dir_ruler[0]; + normalize_v2(rot_90_vec_a); + + sub_v2_v2v2(dir_ruler, co_ss[1], co_ss[2]); + rot_90_vec_b[0] = -dir_ruler[1]; + rot_90_vec_b[1] = dir_ruler[0]; + normalize_v2(rot_90_vec_b); + + GPU_blend(true); + + immUniformColor3ubv(color_wire); + + immBegin(GWN_PRIM_LINES, 8); + + madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size); + immVertex2fv(shdr_pos, cap); + madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, -cap_size); + immVertex2fv(shdr_pos, cap); + + madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, cap_size); + immVertex2fv(shdr_pos, cap); + madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, -cap_size); + immVertex2fv(shdr_pos, cap); + + /* angle vertex */ + immVertex2f(shdr_pos, co_ss[1][0] - cap_size, co_ss[1][1] - cap_size); + immVertex2f(shdr_pos, co_ss[1][0] + cap_size, co_ss[1][1] + cap_size); + immVertex2f(shdr_pos, co_ss[1][0] - cap_size, co_ss[1][1] + cap_size); + immVertex2f(shdr_pos, co_ss[1][0] + cap_size, co_ss[1][1] - cap_size); + + immEnd(); + + GPU_blend(false); + } + + immUnbindProgram(); + + /* text */ + { + char numstr[256]; + float numstr_size[2]; + float posit[2]; + const int prec = 2; /* XXX, todo, make optional */ + + ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec); + + BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]); + + posit[0] = co_ss[1][0] + (cap_size * 2.0f); + posit[1] = co_ss[1][1] - (numstr_size[1] / 2.0f); + + /* draw text (bg) */ + UI_draw_roundbox_corner_set(UI_CNR_ALL); + UI_draw_roundbox_aa( + true, + posit[0] - bg_margin, posit[1] - bg_margin, + posit[0] + bg_margin + numstr_size[0], posit[1] + bg_margin + numstr_size[1], + bg_radius, color_back); + /* draw text */ + BLF_color3ubv(blf_mono_font, color_text); + BLF_position(blf_mono_font, posit[0], posit[1], 0.0f); + BLF_rotation(blf_mono_font, 0.0f); + BLF_draw(blf_mono_font, numstr, sizeof(numstr)); + } + } + else { + immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); + + float viewport_size[4]; + GPU_viewport_size_get_f(viewport_size); + immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); + + immUniform1i("colors_len", 2); /* "advanced" mode */ + const float *col = is_act ? color_act : color_base; + immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); + immUniform1f("dash_width", 6.0f); + + immBegin(GWN_PRIM_LINES, 2); + + immVertex2fv(shdr_pos, co_ss[0]); + immVertex2fv(shdr_pos, co_ss[2]); + + immEnd(); + + immUnbindProgram(); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[2]); + + /* capping */ + { + float rot_90_vec[2] = {-dir_ruler[1], dir_ruler[0]}; + float cap[2]; + + normalize_v2(rot_90_vec); + + GPU_blend(true); + + immUniformColor3ubv(color_wire); + + immBegin(GWN_PRIM_LINES, 4); + + madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size); + immVertex2fv(shdr_pos, cap); + madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, -cap_size); + immVertex2fv(shdr_pos, cap); + + madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, cap_size); + immVertex2fv(shdr_pos, cap); + madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, -cap_size); + immVertex2fv(shdr_pos, cap); + + immEnd(); + + GPU_blend(false); + } + + immUnbindProgram(); + + /* text */ + { + char numstr[256]; + float numstr_size[2]; + const int prec = 6; /* XXX, todo, make optional */ + float posit[2]; + + ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec); + + BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]); + + mid_v2_v2v2(posit, co_ss[0], co_ss[2]); + + /* center text */ + posit[0] -= numstr_size[0] / 2.0f; + posit[1] -= numstr_size[1] / 2.0f; + + /* draw text (bg) */ + UI_draw_roundbox_corner_set(UI_CNR_ALL); + UI_draw_roundbox_aa( + true, + posit[0] - bg_margin, posit[1] - bg_margin, + posit[0] + bg_margin + numstr_size[0], posit[1] + bg_margin + numstr_size[1], + bg_radius, color_back); + /* draw text */ + BLF_color3ubv(blf_mono_font, color_text); + BLF_position(blf_mono_font, posit[0], posit[1], 0.0f); + BLF_draw(blf_mono_font, numstr, sizeof(numstr)); + } + } + + GPU_line_smooth(false); + + BLF_disable(blf_mono_font, BLF_ROTATION); + +#undef ARC_STEPS + + /* draw snap */ + if ((ruler_info->snap_flag & RULER_SNAP_OK) && + (ruler_info->state == RULER_STATE_DRAG) && + (ruler_item->mpr.interaction_data != NULL)) + { + RulerInteraction *inter = ruler_item->mpr.interaction_data; + /* size from drawSnapping */ + const float size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); + float co_ss_snap[3]; + ED_view3d_project_float_global(ar, ruler_item->co[inter->co_index], co_ss_snap, V3D_PROJ_TEST_NOP); + + uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor4fv(color_act); + + imm_draw_circle_wire_2d(pos, co_ss_snap[0], co_ss_snap[1], size * U.pixelsize, 32); + + immUnbindProgram(); + } +} + +static int manipulator_ruler_test_select( + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +{ + RulerItem *ruler_item_pick = (RulerItem *)mpr; + float mval_fl[2] = {UNPACK2(event->mval)}; + int co_index; + + /* select and drag */ + if (view3d_ruler_pick(mpr->parent_mgroup, ruler_item_pick, mval_fl, &co_index)) { + if (co_index == -1) { + if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) { + return PART_LINE; + } + } + else { + return co_index; + } + } + return -1; +} + +static int manipulator_ruler_modal( + bContext *C, wmManipulator *mpr, const wmEvent *event, + eWM_ManipulatorTweak UNUSED(tweak_flag)) +{ + bool do_draw = false; + int exit_code = OPERATOR_RUNNING_MODAL; + RulerInfo *ruler_info = mpr->parent_mgroup->customdata; + RulerItem *ruler_item = (RulerItem *)mpr; + RulerInteraction *inter = ruler_item->mpr.interaction_data; + ARegion *ar = CTX_wm_region(C); + + ruler_info->ar = ar; + + switch (event->type) { + case MOUSEMOVE: + { + if (ruler_info->state == RULER_STATE_DRAG) { + if (view3d_ruler_item_mousemove( + ruler_info, ruler_item, event->mval, + event->shift != 0, event->ctrl != 0)) + { + do_draw = true; + } + inter->inside_region = BLI_rcti_isect_pt_v(&ar->winrct, &event->x); + } + break; + } + } + if (do_draw) { + ED_region_tag_redraw(ar); + } + return exit_code; +} + +static int manipulator_ruler_invoke( + bContext *C, wmManipulator *mpr, const wmEvent *event) +{ + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + RulerInfo *ruler_info = mgroup->customdata; + RulerItem *ruler_item_pick = (RulerItem *)mpr; + RulerInteraction *inter = MEM_callocN(sizeof(RulerInteraction), __func__); + mpr->interaction_data = inter; + + ARegion *ar = ruler_info->ar; + + const float mval_fl[2] = {UNPACK2(event->mval)}; + + /* select and drag */ + if (mpr->highlight_part == PART_LINE) { + if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) { + /* Add Center Point */ + ruler_item_pick->flag |= RULERITEM_USE_ANGLE; + inter->co_index = 1; + ruler_state_set(C, ruler_info, RULER_STATE_DRAG); + + /* find the factor */ + { + float co_ss[2][2]; + float fac; + + ED_view3d_project_float_global(ar, ruler_item_pick->co[0], co_ss[0], V3D_PROJ_TEST_NOP); + ED_view3d_project_float_global(ar, ruler_item_pick->co[2], co_ss[1], V3D_PROJ_TEST_NOP); + + fac = line_point_factor_v2(mval_fl, co_ss[0], co_ss[1]); + CLAMP(fac, 0.0f, 1.0f); + + interp_v3_v3v3(ruler_item_pick->co[1], + ruler_item_pick->co[0], + ruler_item_pick->co[2], fac); + } + + /* update the new location */ + view3d_ruler_item_mousemove( + ruler_info, ruler_item_pick, event->mval, + event->shift != 0, event->ctrl != 0); + } + } + else { + inter->co_index = mpr->highlight_part; + ruler_state_set(C, ruler_info, RULER_STATE_DRAG); + + /* store the initial depth */ + copy_v3_v3(inter->drag_start_co, ruler_item_pick->co[inter->co_index]); + } + + return OPERATOR_RUNNING_MODAL; +} + +static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool cancel) +{ + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + RulerInfo *ruler_info = mgroup->customdata; + + if (!cancel) { + if (ruler_info->state == RULER_STATE_DRAG) { + RulerItem *ruler_item = (RulerItem *)mpr; + RulerInteraction *inter = mpr->interaction_data; + /* rubber-band angle removal */ + if (!inter->inside_region) { + if ((inter->co_index == 1) && (ruler_item->flag & RULERITEM_USE_ANGLE)) { + ruler_item->flag &= ~RULERITEM_USE_ANGLE; + } + else { + /* Not ideal, since the ruler isn't a mode and we don't want to override delete key + * use dragging out of the view for removal. */ + ruler_item_remove(C, mgroup, ruler_item); + ruler_item = NULL; + mpr = NULL; + inter = NULL; + } + } + if (ruler_info->snap_flag & RULER_SNAP_OK) { + ruler_info->snap_flag &= ~RULER_SNAP_OK; + } + ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); + } + /* We could convert only the current manipulator, for now just re-generate. */ + view3d_ruler_to_gpencil(C, mgroup); + } + + if (mpr) { + MEM_SAFE_FREE(mpr->interaction_data); + } + + ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); +} + +static int manipulator_ruler_cursor_get(wmManipulator *mpr) +{ + if (mpr->highlight_part == PART_LINE) { + return BC_CROSSCURSOR; + } + return BC_NSEW_SCROLLCURSOR; +} + +void VIEW3D_WT_ruler_item(wmManipulatorType *wt) +{ + /* identifiers */ + wt->idname = "VIEW3D_WT_ruler_item"; + + /* api callbacks */ + wt->draw = manipulator_ruler_draw; + wt->test_select = manipulator_ruler_test_select; + wt->modal = manipulator_ruler_modal; + wt->invoke = manipulator_ruler_invoke; + wt->exit = manipulator_ruler_exit; + wt->cursor_get = manipulator_ruler_cursor_get; + + wt->struct_size = sizeof(RulerItem); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Ruler Manipulator Group + * \{ */ + +static bool WIDGETGROUP_ruler_poll(const bContext *C, wmManipulatorGroupType *wgt) +{ + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); + if ((tref_rt == NULL) || + !STREQ(wgt->idname, tref_rt->manipulator_group)) + { + WM_manipulator_group_type_unlink_delayed_ptr(wgt); + return false; + } + return true; +} + +static void WIDGETGROUP_ruler_setup(const bContext *C, wmManipulatorGroup *mgroup) +{ + RulerInfo *ruler_info = MEM_callocN(sizeof(RulerInfo), __func__); + + if (view3d_ruler_from_gpencil(C, mgroup)) { + /* nop */ + } + + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + ruler_info->win = win; + ruler_info->sa = sa; + ruler_info->ar = ar; + + mgroup->customdata = ruler_info; +} + +void VIEW3D_WGT_ruler(wmManipulatorGroupType *wgt) +{ + wgt->name = "Ruler Widgets"; + wgt->idname = view3d_wgt_ruler_id; + + wgt->flag |= WM_MANIPULATORGROUPTYPE_SCALE | WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL; + + wgt->mmap_params.spaceid = SPACE_VIEW3D; + wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + + wgt->poll = WIDGETGROUP_ruler_poll; + wgt->setup = WIDGETGROUP_ruler_setup; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Add Ruler Operator + * \{ */ + +static bool view3d_ruler_poll(bContext *C) +{ + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); + if ((tref_rt == NULL) || + !STREQ(view3d_wgt_ruler_id, tref_rt->manipulator_group) || + CTX_wm_region_view3d(C) == NULL) + { + return false; + } + return true; +} + +static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = ar->regiondata; + + wmManipulatorMap *mmap = ar->manipulator_map; + wmManipulatorGroup *mgroup = WM_manipulatormap_group_find(mmap, view3d_wgt_ruler_id); + const bool use_depth = (v3d->drawtype >= OB_SOLID); + + /* Create new line */ + RulerItem *ruler_item; + ruler_item = ruler_item_add(mgroup); + + /* This is a little weak, but there is no real good way to tweak directly. */ + WM_manipulator_highlight_set(mmap, &ruler_item->mpr); + if (WM_operator_name_call( + C, "MANIPULATORGROUP_OT_manipulator_tweak", + WM_OP_INVOKE_REGION_WIN, NULL) == OPERATOR_RUNNING_MODAL) + { + RulerInfo *ruler_info = mgroup->customdata; + RulerInteraction *inter = ruler_item->mpr.interaction_data; + if (use_depth) { + /* snap the first point added, not essential but handy */ + inter->co_index = 0; + view3d_ruler_item_mousemove(ruler_info, ruler_item, event->mval, false, true); + copy_v3_v3(inter->drag_start_co, ruler_item->co[inter->co_index]); + } + else { + negate_v3_v3(inter->drag_start_co, rv3d->ofs); + copy_v3_v3(ruler_item->co[0], inter->drag_start_co); + view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval); + } + + copy_v3_v3(ruler_item->co[2], ruler_item->co[0]); + ruler_item->mpr.highlight_part = inter->co_index = 2; + } + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_ruler_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Ruler Add"; + ot->idname = "VIEW3D_OT_ruler_add"; + ot->description = ""; + + ot->invoke = view3d_ruler_add_invoke; + ot->poll = view3d_ruler_poll; + + /* flags */ + ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; +} + +/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_manipulator_armature.c b/source/blender/editors/space_view3d/view3d_manipulator_armature.c deleted file mode 100644 index 17dc4d8eb4a..00000000000 --- a/source/blender/editors/space_view3d/view3d_manipulator_armature.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_view3d/view3d_manipulator_armature.c - * \ingroup spview3d - */ - -#include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "BKE_armature.h" -#include "BKE_action.h" -#include "BKE_context.h" -#include "BKE_object.h" - -#include "DNA_object_types.h" -#include "DNA_armature_types.h" - -#include "ED_armature.h" -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -#include "UI_resources.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "view3d_intern.h" /* own include */ - - -/* -------------------------------------------------------------------- */ - -/** \name Armature Spline Manipulator - * - * \{ */ - -/* - * TODO(campbell): Current conversion is a approximation (usable not correct), - * we'll need to take the next/previous bones into account to get the tangent directions. - * First last matrices from 'b_bone_spline_setup' are close but also not quite accurate - * since they're not at either end-points on the curve. - * - * Likely we'll need a function especially to get the first/last orientations. - */ - -#define BBONE_SCALE_Y 3.0f - -struct BoneSplineHandle { - wmManipulator *manipulator; - bPoseChannel *pchan; - /* We could remove, keep since at the moment for checking the conversion. */ - float co[3]; - int index; -}; - -struct BoneSplineWidgetGroup { - struct BoneSplineHandle handles[2]; -}; - -static void manipulator_bbone_offset_get( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - void *value_p) -{ - struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data; - bPoseChannel *pchan = bh->pchan; - - float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 3); - - if (bh->index == 0) { - bh->co[1] = pchan->bone->ease1 / BBONE_SCALE_Y; - bh->co[0] = pchan->curveInX; - bh->co[2] = pchan->curveInY; - } - else { - bh->co[1] = -pchan->bone->ease2 / BBONE_SCALE_Y; - bh->co[0] = pchan->curveOutX; - bh->co[2] = pchan->curveOutY; - } - copy_v3_v3(value, bh->co); -} - -static void manipulator_bbone_offset_set( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - const void *value_p) -{ - struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data; - bPoseChannel *pchan = bh->pchan; - - const float *value = value_p; - - BLI_assert(mpr_prop->type->array_length == 3); - copy_v3_v3(bh->co, value); - - if (bh->index == 0) { - pchan->bone->ease1 = max_ff(0.0f, bh->co[1] * BBONE_SCALE_Y); - pchan->curveInX = bh->co[0]; - pchan->curveInY = bh->co[2]; - } - else { - pchan->bone->ease2 = max_ff(0.0f, -bh->co[1] * BBONE_SCALE_Y); - pchan->curveOutX = bh->co[0]; - pchan->curveOutY = bh->co[2]; - } - -} - -static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - if (ob != NULL) { - const bArmature *arm = ob->data; - if (arm->drawtype == ARM_B_BONE) { - if (arm->act_bone && arm->act_bone->segments > 1) { - View3D *v3d = CTX_wm_view3d(C); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) - { - /* pass */ - } - else { - return true; - } - } - } - } - return false; -} - - -static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmManipulatorGroup *mgroup) -{ - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - bPoseChannel *pchan = BKE_pose_channel_active(ob); - - const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true); - - struct BoneSplineWidgetGroup *bspline_group = MEM_callocN(sizeof(struct BoneSplineWidgetGroup), __func__); - mgroup->customdata = bspline_group; - - /* Handles */ - for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { - wmManipulator *mpr; - mpr = bspline_group->handles[i].manipulator = WM_manipulator_new_ptr(wt_grab, mgroup, NULL); - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D); - RNA_enum_set(mpr->ptr, "draw_options", - ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_VALUE, true); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); - - mpr->scale_basis = 0.06f; - - if (i == 0) { - copy_v3_v3(mpr->matrix_basis[3], pchan->loc); - } - } -} - -static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - - if (!mgroup->customdata) - return; - - struct BoneSplineWidgetGroup *bspline_group = mgroup->customdata; - bPoseChannel *pchan = BKE_pose_channel_active(ob); - - /* Handles */ - for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { - wmManipulator *mpr = bspline_group->handles[i].manipulator; - bspline_group->handles[i].pchan = pchan; - bspline_group->handles[i].index = i; - - float mat[4][4]; - mul_m4_m4m4(mat, ob->obmat, (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat); - copy_m4_m4(mpr->matrix_space, mat); - - /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_manipulator_target_property_def_func( - mpr, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_bbone_offset_get, - .value_set_fn = manipulator_bbone_offset_set, - .range_get_fn = NULL, - .user_data = &bspline_group->handles[i], - }); - } -} - -void VIEW3D_WGT_armature_spline(wmManipulatorGroupType *wgt) -{ - wgt->name = "Armature Spline Widgets"; - wgt->idname = "VIEW3D_WGT_armature_spline"; - - wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D); - - wgt->poll = WIDGETGROUP_armature_spline_poll; - wgt->setup = WIDGETGROUP_armature_spline_setup; - wgt->refresh = WIDGETGROUP_armature_spline_refresh; -} - -/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c deleted file mode 100644 index 29f380c6334..00000000000 --- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c +++ /dev/null @@ -1,473 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_view3d/view3d_manipulator_camera.c - * \ingroup spview3d - */ - - -#include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "BKE_camera.h" -#include "BKE_context.h" - -#include "DNA_object_types.h" -#include "DNA_camera_types.h" - -#include "ED_armature.h" -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -#include "UI_resources.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" -#include "WM_message.h" - -#include "view3d_intern.h" /* own include */ - - -/* -------------------------------------------------------------------- */ - -/** \name Camera Manipulators - * \{ */ - -struct CameraWidgetGroup { - wmManipulator *dop_dist; - wmManipulator *focal_len; - wmManipulator *ortho_scale; -}; - -static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - View3D *v3d = CTX_wm_view3d(C); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) - { - return false; - } - - Object *ob = CTX_data_active_object(C); - if (ob && ob->type == OB_CAMERA) { - Camera *camera = ob->data; - /* TODO: support overrides. */ - if (camera->id.lib == NULL) { - return true; - } - } - return false; -} - -static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgroup) -{ - Object *ob = CTX_data_active_object(C); - float dir[3]; - - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); - - struct CameraWidgetGroup *camgroup = MEM_callocN(sizeof(struct CameraWidgetGroup), __func__); - mgroup->customdata = camgroup; - - negate_v3_v3(dir, ob->obmat[2]); - - /* dof distance */ - { - wmManipulator *mpr; - mpr = camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CROSS); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); - - UI_GetThemeColor3fv(TH_MANIPULATOR_A, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); - } - - /* focal length - * - logic/calculations are similar to BKE_camera_view_frame_ex, better keep in sync */ - { - wmManipulator *mpr; - mpr = camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE; - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE); - RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); - - mpr = camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE; - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE); - RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); - } -} - -static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - if (!mgroup->customdata) - return; - - struct CameraWidgetGroup *camgroup = mgroup->customdata; - Object *ob = CTX_data_active_object(C); - Camera *ca = ob->data; - PointerRNA camera_ptr; - float dir[3]; - - const float ob_scale_inv[3] = { - 1.0f / len_v3(ob->obmat[0]), - 1.0f / len_v3(ob->obmat[1]), - 1.0f / len_v3(ob->obmat[2]), - }; - const float ob_scale_uniform_inv = (ob_scale_inv[0] + ob_scale_inv[1] + ob_scale_inv[2]) / 3.0f; - - RNA_pointer_create(&ca->id, &RNA_Camera, ca, &camera_ptr); - - negate_v3_v3(dir, ob->obmat[2]); - - if (ca->flag & CAM_SHOWLIMITS) { - WM_manipulator_set_matrix_location(camgroup->dop_dist, ob->obmat[3]); - WM_manipulator_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob->obmat[1], dir); - WM_manipulator_set_scale(camgroup->dop_dist, ca->drawsize); - WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false); - - /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_manipulator_target_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); - } - else { - WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, true); - } - - /* TODO - make focal length/ortho ob_scale_inv widget optional */ - const Scene *scene = CTX_data_scene(C); - const float aspx = (float)scene->r.xsch * scene->r.xasp; - const float aspy = (float)scene->r.ysch * scene->r.yasp; - const bool is_ortho = (ca->type == CAM_ORTHO); - const int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, aspx, aspy); - wmManipulator *widget = is_ortho ? camgroup->ortho_scale : camgroup->focal_len; - float scale_matrix; - if (true) { - float offset[3]; - float aspect[2]; - - WM_manipulator_set_flag(widget, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_set_flag(is_ortho ? camgroup->focal_len : camgroup->ortho_scale, WM_MANIPULATOR_HIDDEN, true); - - - /* account for lens shifting */ - offset[0] = ((ob->size[0] > 0.0f) ? -2.0f : 2.0f) * ca->shiftx; - offset[1] = 2.0f * ca->shifty; - offset[2] = 0.0f; - - /* get aspect */ - aspect[0] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? 1.0f : aspx / aspy; - aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f; - - unit_m4(widget->matrix_basis); - WM_manipulator_set_matrix_location(widget, ob->obmat[3]); - WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir); - - if (is_ortho) { - scale_matrix = ca->ortho_scale * 0.5f; - } - else { - scale_matrix = ca->drawsize / ob_scale_uniform_inv; - } - mul_v3_fl(widget->matrix_basis[0], scale_matrix); - mul_v3_fl(widget->matrix_basis[1], scale_matrix); - - RNA_float_set_array(widget->ptr, "aspect", aspect); - - WM_manipulator_set_matrix_offset_location(widget, offset); - } - - /* define & update properties */ - { - const char *propname = is_ortho ? "ortho_scale" : "lens"; - PropertyRNA *prop = RNA_struct_find_property(&camera_ptr, propname); - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(widget->type, "offset"); - - WM_manipulator_target_property_clear_rna_ptr(widget, mpr_prop_type); - - float min, max, range; - float step, precision; - - /* get property range */ - RNA_property_float_ui_range(&camera_ptr, prop, &min, &max, &step, &precision); - range = max - min; - - ED_manipulator_arrow3d_set_range_fac( - widget, is_ortho ? - (ca->drawsize * range) : - (scale_matrix * range / - /* Half sensor, intentionally use sensor from camera and not calculated above. */ - (0.5f * ((ca->sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_x)))); - - WM_manipulator_target_property_def_rna_ptr(widget, mpr_prop_type, &camera_ptr, prop, -1); - } - -} - -static void WIDGETGROUP_camera_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) -{ - ARegion *ar = CTX_wm_region(C); - Object *ob = CTX_data_active_object(C); - Camera *ca = ob->data; - - wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { - .owner = ar, - .user_data = mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, - }; - - { - extern PropertyRNA rna_Camera_dof_distance; - extern PropertyRNA rna_Camera_draw_size; - extern PropertyRNA rna_Camera_ortho_scale; - extern PropertyRNA rna_Camera_sensor_fit; - extern PropertyRNA rna_Camera_sensor_width; - extern PropertyRNA rna_Camera_shift_x; - extern PropertyRNA rna_Camera_shift_y; - extern PropertyRNA rna_Camera_type; - extern PropertyRNA rna_Camera_lens; - const PropertyRNA *props[] = { - &rna_Camera_dof_distance, - &rna_Camera_draw_size, - &rna_Camera_ortho_scale, - &rna_Camera_sensor_fit, - &rna_Camera_sensor_width, - &rna_Camera_shift_x, - &rna_Camera_shift_y, - &rna_Camera_type, - &rna_Camera_lens, - }; - - PointerRNA idptr; - RNA_id_pointer_create(&ca->id, &idptr); - - for (int i = 0; i < ARRAY_SIZE(props); i++) { - WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); - } - } - - /* Subscribe to render settings */ - { - WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_x, &msg_sub_value_mpr_tag_refresh); - WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_y, &msg_sub_value_mpr_tag_refresh); - WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_x, &msg_sub_value_mpr_tag_refresh); - WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_y, &msg_sub_value_mpr_tag_refresh); - } -} - -void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt) -{ - wgt->name = "Camera Widgets"; - wgt->idname = "VIEW3D_WGT_camera"; - - wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); - - wgt->poll = WIDGETGROUP_camera_poll; - wgt->setup = WIDGETGROUP_camera_setup; - wgt->refresh = WIDGETGROUP_camera_refresh; - wgt->message_subscribe = WIDGETGROUP_camera_message_subscribe; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ - -/** \name CameraView Manipulators - * \{ */ - -struct CameraViewWidgetGroup { - wmManipulator *border; - - struct { - rctf *edit_border; - rctf view_border; - } state; -}; - -/* scale callbacks */ -static void manipulator_render_border_prop_matrix_get( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - void *value_p) -{ - float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data; - const rctf *border = viewgroup->state.edit_border; - - unit_m4(matrix); - matrix[0][0] = BLI_rctf_size_x(border); - matrix[1][1] = BLI_rctf_size_y(border); - matrix[3][0] = BLI_rctf_cent_x(border); - matrix[3][1] = BLI_rctf_cent_y(border); -} - -static void manipulator_render_border_prop_matrix_set( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - const void *value_p) -{ - const float (*matrix)[4] = value_p; - struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data; - rctf *border = viewgroup->state.edit_border; - BLI_assert(mpr_prop->type->array_length == 16); - - BLI_rctf_resize(border, len_v3(matrix[0]), len_v3(matrix[1])); - BLI_rctf_recenter(border, matrix[3][0], matrix[3][1]); - BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, border, border); -} - -static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - Scene *scene = CTX_data_scene(C); - - /* This is just so the border isn't always in the way, - * stealing mouse clicks from regular usage. - * We could change the rules for when to show. */ - { - ViewLayer *view_layer = CTX_data_view_layer(C); - if (scene->camera != OBACT(view_layer)) { - return false; - } - } - - View3D *v3d = CTX_wm_view3d(C); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) - { - return false; - } - - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - if (rv3d->persp == RV3D_CAMOB) { - if (scene->r.mode & R_BORDER) { - /* TODO: support overrides. */ - if (scene->id.lib == NULL) { - return true; - } - } - } - else if (v3d->flag2 & V3D_RENDER_BORDER) { - return true; - } - return false; -} - -static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - struct CameraViewWidgetGroup *viewgroup = MEM_mallocN(sizeof(struct CameraViewWidgetGroup), __func__); - - viewgroup->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); - - RNA_enum_set(viewgroup->border->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); - /* Box style is more subtle in this case. */ - RNA_enum_set(viewgroup->border->ptr, "draw_style", ED_MANIPULATOR_CAGE2D_STYLE_BOX); - - - mgroup->customdata = viewgroup; -} - -static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; - - ARegion *ar = CTX_wm_region(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); - RegionView3D *rv3d = ar->regiondata; - if (rv3d->persp == RV3D_CAMOB) { - Scene *scene = CTX_data_scene(C); - View3D *v3d = CTX_wm_view3d(C); - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewgroup->state.view_border, false); - } - else { - viewgroup->state.view_border = (rctf){.xmin = 0, .ymin = 0, .xmax = ar->winx, .ymax = ar->winy}; - } - - wmManipulator *mpr = viewgroup->border; - unit_m4(mpr->matrix_space); - mul_v3_fl(mpr->matrix_space[0], BLI_rctf_size_x(&viewgroup->state.view_border)); - mul_v3_fl(mpr->matrix_space[1], BLI_rctf_size_y(&viewgroup->state.view_border)); - mpr->matrix_space[3][0] = viewgroup->state.view_border.xmin; - mpr->matrix_space[3][1] = viewgroup->state.view_border.ymin; -} - -static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; - - View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - Scene *scene = CTX_data_scene(C); - - { - wmManipulator *mpr = viewgroup->border; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - - RNA_enum_set(viewgroup->border->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); - - if (rv3d->persp == RV3D_CAMOB) { - viewgroup->state.edit_border = &scene->r.border; - } - else { - viewgroup->state.edit_border = &v3d->render_border; - } - - WM_manipulator_target_property_def_func( - mpr, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_render_border_prop_matrix_get, - .value_set_fn = manipulator_render_border_prop_matrix_set, - .range_get_fn = NULL, - .user_data = viewgroup, - }); - } - -} - -void VIEW3D_WGT_camera_view(wmManipulatorGroupType *wgt) -{ - wgt->name = "Camera View Widgets"; - wgt->idname = "VIEW3D_WGT_camera_view"; - - wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_SCALE); - - wgt->poll = WIDGETGROUP_camera_view_poll; - wgt->setup = WIDGETGROUP_camera_view_setup; - wgt->draw_prepare = WIDGETGROUP_camera_view_draw_prepare; - wgt->refresh = WIDGETGROUP_camera_view_refresh; -} - -/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_manipulator_empty.c b/source/blender/editors/space_view3d/view3d_manipulator_empty.c deleted file mode 100644 index 16424c39bb8..00000000000 --- a/source/blender/editors/space_view3d/view3d_manipulator_empty.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_view3d/view3d_manipulator_empty.c - * \ingroup spview3d - */ - - -#include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "BKE_context.h" -#include "BKE_object.h" -#include "BKE_image.h" - -#include "DNA_object_types.h" -#include "DNA_lamp_types.h" - -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -#include "UI_resources.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "view3d_intern.h" /* own include */ - -/* -------------------------------------------------------------------- */ - -/** \name Empty Image Manipulators - * \{ */ - -struct EmptyImageWidgetGroup { - wmManipulator *manipulator; - struct { - Object *ob; - float dims[2]; - } state; -}; - -/* translate callbacks */ -static void manipulator_empty_image_prop_matrix_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - void *value_p) -{ - float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data; - const Object *ob = imgroup->state.ob; - - unit_m4(matrix); - matrix[0][0] = ob->empty_drawsize; - matrix[1][1] = ob->empty_drawsize; - - float dims[2] = {0.0f, 0.0f}; - RNA_float_get_array(mpr->ptr, "dimensions", dims); - dims[0] *= ob->empty_drawsize; - dims[1] *= ob->empty_drawsize; - - matrix[3][0] = (ob->ima_ofs[0] * dims[0]) + (0.5f * dims[0]); - matrix[3][1] = (ob->ima_ofs[1] * dims[1]) + (0.5f * dims[1]); -} - -static void manipulator_empty_image_prop_matrix_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - const void *value_p) -{ - const float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data; - Object *ob = imgroup->state.ob; - - ob->empty_drawsize = matrix[0][0]; - - float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); - dims[0] *= ob->empty_drawsize; - dims[1] *= ob->empty_drawsize; - - ob->ima_ofs[0] = (matrix[3][0] - (0.5f * dims[0])) / dims[0]; - ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1]; -} - -static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - View3D *v3d = CTX_wm_view3d(C); - - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) - { - return false; - } - - Object *ob = CTX_data_active_object(C); - - if (ob && ob->type == OB_EMPTY) { - return (ob->empty_drawtype == OB_EMPTY_IMAGE); - } - return false; -} - -static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - struct EmptyImageWidgetGroup *imgroup = MEM_mallocN(sizeof(struct EmptyImageWidgetGroup), __func__); - imgroup->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); - wmManipulator *mpr = imgroup->manipulator; - RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); - - mgroup->customdata = imgroup; - - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); -} - -static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - struct EmptyImageWidgetGroup *imgroup = mgroup->customdata; - Object *ob = CTX_data_active_object(C); - wmManipulator *mpr = imgroup->manipulator; - - copy_m4_m4(mpr->matrix_basis, ob->obmat); - - RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); - - imgroup->state.ob = ob; - - /* Use dimensions for aspect. */ - if (ob->data != NULL) { - const Image *image = ob->data; - ImageUser iuser = *ob->iuser; - float size[2]; - BKE_image_get_size_fl(ob->data, &iuser, size); - - /* Get the image aspect even if the buffer is invalid */ - if (image->aspx > image->aspy) { - size[1] *= image->aspy / image->aspx; - } - else if (image->aspx < image->aspy) { - size[0] *= image->aspx / image->aspy; - } - - const float dims_max = max_ff(size[0], size[1]); - imgroup->state.dims[0] = size[0] / dims_max; - imgroup->state.dims[1] = size[1] / dims_max; - } - else { - copy_v2_fl(imgroup->state.dims, 1.0f); - } - RNA_float_set_array(mpr->ptr, "dimensions", imgroup->state.dims); - - WM_manipulator_target_property_def_func( - mpr, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_empty_image_prop_matrix_get, - .value_set_fn = manipulator_empty_image_prop_matrix_set, - .range_get_fn = NULL, - .user_data = imgroup, - }); -} - -void VIEW3D_WGT_empty_image(wmManipulatorGroupType *wgt) -{ - wgt->name = "Area Light Widgets"; - wgt->idname = "VIEW3D_WGT_empty_image"; - - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); - - wgt->poll = WIDGETGROUP_empty_image_poll; - wgt->setup = WIDGETGROUP_empty_image_setup; - wgt->refresh = WIDGETGROUP_empty_image_refresh; -} - -/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c deleted file mode 100644 index e4535004c8f..00000000000 --- a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_view3d/view3d_manipulator_forcefield.c - * \ingroup spview3d - */ - - -#include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "BKE_context.h" -#include "BKE_object.h" - -#include "DNA_object_types.h" -#include "DNA_object_force_types.h" - -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -#include "UI_resources.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "view3d_intern.h" /* own include */ - -/* -------------------------------------------------------------------- */ - -/** \name Force Field Manipulators - * \{ */ - -static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - View3D *v3d = CTX_wm_view3d(C); - - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) - { - return false; - } - - Object *ob = CTX_data_active_object(C); - - return (ob && ob->pd && ob->pd->forcefield); -} - -static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - /* only wind effector for now */ - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - mgroup->customdata = wwrapper; - - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL); - wmManipulator *mpr = wwrapper->manipulator; - RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); - ED_manipulator_arrow3d_set_ui_range(mpr, -200.0f, 200.0f); - ED_manipulator_arrow3d_set_range_fac(mpr, 6.0f); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); -} - -static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - wmManipulatorWrapper *wwrapper = mgroup->customdata; - wmManipulator *mpr = wwrapper->manipulator; - Object *ob = CTX_data_active_object(C); - PartDeflect *pd = ob->pd; - - if (pd->forcefield == PFIELD_WIND) { - const float size = (ob->type == OB_EMPTY) ? ob->empty_drawsize : 1.0f; - const float ofs[3] = {0.0f, -size, 0.0f}; - PointerRNA field_ptr; - - RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd, &field_ptr); - WM_manipulator_set_matrix_location(mpr, ob->obmat[3]); - WM_manipulator_set_matrix_rotation_from_z_axis(mpr, ob->obmat[2]); - WM_manipulator_set_matrix_offset_location(mpr, ofs); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_target_property_def_rna(mpr, "offset", &field_ptr, "strength", -1); - } - else { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); - } -} - -void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt) -{ - wgt->name = "Force Field Widgets"; - wgt->idname = "VIEW3D_WGT_force_field"; - - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_SCALE | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); - - wgt->poll = WIDGETGROUP_forcefield_poll; - wgt->setup = WIDGETGROUP_forcefield_setup; - wgt->refresh = WIDGETGROUP_forcefield_refresh; -} - -/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c deleted file mode 100644 index 39e908ec99d..00000000000 --- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_view3d/view3d_manipulator_lamp.c - * \ingroup spview3d - */ - - -#include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "BKE_context.h" -#include "BKE_object.h" - -#include "DNA_object_types.h" -#include "DNA_lamp_types.h" - -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -#include "UI_resources.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "view3d_intern.h" /* own include */ - -/* -------------------------------------------------------------------- */ - -/** \name Spot Lamp Manipulators - * \{ */ - -static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - View3D *v3d = CTX_wm_view3d(C); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) - { - return false; - } - - Object *ob = CTX_data_active_object(C); - - if (ob && ob->type == OB_LAMP) { - Lamp *la = ob->data; - return (la->type == LA_SPOT); - } - return false; -} - -static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL); - wmManipulator *mpr = wwrapper->manipulator; - RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED); - - mgroup->customdata = wwrapper; - - ED_manipulator_arrow3d_set_range_fac(mpr, 4.0f); - - UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, mpr->color); -} - -static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - wmManipulatorWrapper *wwrapper = mgroup->customdata; - wmManipulator *mpr = wwrapper->manipulator; - Object *ob = CTX_data_active_object(C); - Lamp *la = ob->data; - float dir[3]; - - negate_v3_v3(dir, ob->obmat[2]); - - WM_manipulator_set_matrix_rotation_from_z_axis(mpr, dir); - WM_manipulator_set_matrix_location(mpr, ob->obmat[3]); - - /* need to set property here for undo. TODO would prefer to do this in _init */ - PointerRNA lamp_ptr; - const char *propname = "spot_size"; - RNA_pointer_create(&la->id, &RNA_Light, la, &lamp_ptr); - WM_manipulator_target_property_def_rna(mpr, "offset", &lamp_ptr, propname, -1); -} - -void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt) -{ - wgt->name = "Spot Light Widgets"; - wgt->idname = "VIEW3D_WGT_lamp_spot"; - - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); - - wgt->poll = WIDGETGROUP_lamp_spot_poll; - wgt->setup = WIDGETGROUP_lamp_spot_setup; - wgt->refresh = WIDGETGROUP_lamp_spot_refresh; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ - -/** \name Area Lamp Manipulators - * \{ */ - -/* scale callbacks */ -static void manipulator_area_lamp_prop_matrix_get( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - void *value_p) -{ - BLI_assert(mpr_prop->type->array_length == 16); - float (*matrix)[4] = value_p; - const Lamp *la = mpr_prop->custom_func.user_data; - - matrix[0][0] = la->area_size; - matrix[1][1] = ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE) ? la->area_sizey : la->area_size; -} - -static void manipulator_area_lamp_prop_matrix_set( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - const void *value_p) -{ - const float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - Lamp *la = mpr_prop->custom_func.user_data; - - if (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE)) { - la->area_size = len_v3(matrix[0]); - la->area_sizey = len_v3(matrix[1]); - } - else { - la->area_size = len_v3(matrix[0]); - } -} - -static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - View3D *v3d = CTX_wm_view3d(C); - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { - return false; - } - - Object *ob = CTX_data_active_object(C); - if (ob && ob->type == OB_LAMP) { - Lamp *la = ob->data; - return (la->type == LA_AREA); - } - return false; -} - -static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); - wmManipulator *mpr = wwrapper->manipulator; - RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); - - mgroup->customdata = wwrapper; - - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); -} - -static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - wmManipulatorWrapper *wwrapper = mgroup->customdata; - Object *ob = CTX_data_active_object(C); - Lamp *la = ob->data; - wmManipulator *mpr = wwrapper->manipulator; - - copy_m4_m4(mpr->matrix_basis, ob->obmat); - - int flag = ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE; - if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) { - flag |= ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM; - } - RNA_enum_set(mpr->ptr, "transform", flag); - - /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_manipulator_target_property_def_func( - mpr, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_area_lamp_prop_matrix_get, - .value_set_fn = manipulator_area_lamp_prop_matrix_set, - .range_get_fn = NULL, - .user_data = la, - }); -} - -void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt) -{ - wgt->name = "Area Light Widgets"; - wgt->idname = "VIEW3D_WGT_lamp_area"; - - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); - - wgt->poll = WIDGETGROUP_lamp_area_poll; - wgt->setup = WIDGETGROUP_lamp_area_setup; - wgt->refresh = WIDGETGROUP_lamp_area_refresh; -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Lamp Target Manipulator - * \{ */ - -static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - View3D *v3d = CTX_wm_view3d(C); - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { - return false; - } - - Object *ob = CTX_data_active_object(C); - - if (ob != NULL) { - if (ob->type == OB_LAMP) { - Lamp *la = ob->data; - return (ELEM(la->type, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA)); - } -#if 0 - else if (ob->type == OB_CAMERA) { - return true; - } -#endif - } - return false; -} - -static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL); - wmManipulator *mpr = wwrapper->manipulator; - - mgroup->customdata = wwrapper; - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); - - mpr->scale_basis = 0.06f; - - wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_transform_axis_target", true); - - RNA_enum_set(mpr->ptr, "draw_options", - ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW); - - WM_manipulator_operator_set(mpr, 0, ot, NULL); -} - -static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - wmManipulatorWrapper *wwrapper = mgroup->customdata; - Object *ob = CTX_data_active_object(C); - wmManipulator *mpr = wwrapper->manipulator; - - copy_m4_m4(mpr->matrix_basis, ob->obmat); - unit_m4(mpr->matrix_offset); - mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); -} - -void VIEW3D_WGT_lamp_target(wmManipulatorGroupType *wgt) -{ - wgt->name = "Target Light Widgets"; - wgt->idname = "VIEW3D_WGT_lamp_target"; - - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D); - - wgt->poll = WIDGETGROUP_lamp_target_poll; - wgt->setup = WIDGETGROUP_lamp_target_setup; - wgt->draw_prepare = WIDGETGROUP_lamp_target_draw_prepare; -} - -/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c deleted file mode 100644 index 465faf70fcd..00000000000 --- a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c +++ /dev/null @@ -1,371 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_view3d/view3d_manipulator_navigate.c - * \ingroup spview3d - */ - -#include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "BKE_context.h" -#include "BKE_object.h" - -#include "DNA_object_types.h" - -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -#include "UI_interface.h" -#include "UI_resources.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "view3d_intern.h" /* own include */ - -/* -------------------------------------------------------------------- */ -/** \name View3D Navigation Manipulator Group - * \{ */ - -/* Offset from screen edge. */ -#define MANIPULATOR_OFFSET_FAC 1.5f -/* Size of main icon. */ -#define MANIPULATOR_SIZE 64 -/* Factor for size of smaller button. */ -#define MANIPULATOR_MINI_FAC 0.35f -/* How much mini buttons offset from the primary. */ -#define MANIPULATOR_MINI_OFFSET_FAC 0.42f - - -enum { - MPR_MOVE = 0, - MPR_ROTATE = 1, - MPR_ZOOM = 2, - - /* just buttons */ - /* overlaps MPR_ORTHO (switch between) */ - MPR_PERSP = 3, - MPR_ORTHO = 4, - MPR_CAMERA = 5, - - MPR_TOTAL = 6, -}; - -/* Vector icons compatible with 'GPU_batch_from_poly_2d_encoded' */ -static const uchar shape_camera[] = { - 0xa3, 0x19, 0x78, 0x55, 0x4d, 0x19, 0x4f, 0x0a, 0x7f, 0x00, 0xb0, 0x0a, 0xa9, 0x19, - 0xa9, 0x19, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, - 0x4d, 0x19, 0x47, 0x19, 0x65, 0x55, 0x41, 0x55, 0x41, 0x9e, 0x43, 0xa8, 0x38, 0xb3, - 0x34, 0xc3, 0x38, 0xd2, 0x43, 0xdd, 0x53, 0xe1, 0x62, 0xdd, 0x6d, 0xd2, 0x72, 0xc3, - 0x78, 0xc3, 0x7c, 0xd2, 0x87, 0xdd, 0x96, 0xe1, 0xa6, 0xdd, 0xb1, 0xd2, 0xb5, 0xc3, - 0xb1, 0xb3, 0xa6, 0xa8, 0xa9, 0x9e, 0xa9, 0x8c, 0xbb, 0x8c, 0xbb, 0x86, 0xc7, 0x86, - 0xe0, 0x9e, 0xe0, 0x55, 0xc7, 0x6d, 0xbb, 0x6d, 0xbb, 0x67, 0xa9, 0x67, 0xa9, 0x55, - 0x8a, 0x55, 0xa9, 0x19, 0xb0, 0x0a, 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, - 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, 0x4f, 0xf5, 0x4f, 0xf5, 0x7c, 0xb3, 0x78, 0xc3, - 0x72, 0xc3, 0x6d, 0xb3, 0x62, 0xa8, 0x53, 0xa4, 0x43, 0xa8, 0x41, 0x9e, 0xa9, 0x9e, - 0xa6, 0xa8, 0x96, 0xa4, 0x87, 0xa8, 0x87, 0xa8, -}; -static const uchar shape_ortho[] = { - 0x85, 0x15, 0x85, 0x7c, 0xde, 0xb3, 0xde, 0xb8, 0xd9, 0xba, 0x80, 0x85, 0x27, 0xba, - 0x22, 0xb8, 0x22, 0xb3, 0x7b, 0x7c, 0x7b, 0x15, 0x80, 0x12, 0x80, 0x12, 0x1d, 0xba, - 0x80, 0xf2, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, - 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x80, 0x0d, 0x1d, 0x45, 0x1d, 0x45, 0xb0, 0x0a, - 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, - 0x80, 0xf2, 0xe3, 0xba, 0xe3, 0x45, 0x80, 0x0d, 0x7f, 0x00, 0x7f, 0x00, -}; -static const uchar shape_pan[] = { - 0xbf, 0x4c, 0xbf, 0x66, 0x99, 0x66, 0x99, 0x40, 0xb2, 0x40, 0x7f, 0x0d, 0x7f, 0x00, - 0xb0, 0x0a, 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, - 0x80, 0xff, 0x80, 0xf2, 0xb3, 0xbf, 0x99, 0xbf, 0x99, 0x99, 0xbf, 0x99, 0xbf, 0xb2, - 0xf2, 0x7f, 0xf2, 0x7f, 0x40, 0xb3, 0x40, 0x99, 0x66, 0x99, 0x66, 0xbf, 0x4d, 0xbf, - 0x80, 0xf2, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, - 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x7f, 0x0d, 0x4c, 0x40, 0x66, 0x40, 0x66, 0x66, - 0x40, 0x66, 0x40, 0x4d, 0x0d, 0x80, 0x0d, 0x80, -}; -static const uchar shape_persp[] = { - 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, - 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x80, 0x07, 0x30, 0x50, 0x18, 0xbd, - 0x80, 0xdb, 0xe8, 0xbd, 0xf5, 0xb0, 0xf5, 0xb0, 0x83, 0x0f, 0x87, 0x7b, 0xe2, 0xb7, - 0xe3, 0xba, 0xe0, 0xbb, 0x80, 0x87, 0x20, 0xbb, 0x1d, 0xba, 0x1d, 0xb7, 0x78, 0x7b, - 0x7d, 0x0f, 0x80, 0x0c, 0x80, 0x0c, 0xd0, 0x50, 0x80, 0x07, 0x7f, 0x00, 0xb0, 0x0a, - 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xe8, 0xbd, 0xe8, 0xbd, -}; -static const uchar shape_zoom[] = { - 0xad, 0x7f, 0xf1, 0x7f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, - 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0d, 0x7f, 0x52, 0x7f, 0x69, 0xb7, - 0x48, 0xb7, 0x80, 0xd8, 0xb8, 0xb7, 0x96, 0xb7, 0x96, 0xb7, 0x7f, 0x2f, 0x0d, 0x7f, - 0x00, 0x7f, 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0xb0, 0x0a, 0xda, 0x25, - 0xf5, 0x4f, 0xff, 0x80, 0xf1, 0x7f, 0xf1, 0x7f, -}; - - -struct NavigateManipulatorInfo { - const char *opname; - const char *manipulator; - const unsigned char *shape; - uint shape_size; -}; - -#define SHAPE_VARS(shape_id) shape = shape_id, .shape_size = ARRAY_SIZE(shape_id) - -struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = { - { - .opname = "VIEW3D_OT_move", - .manipulator = "MANIPULATOR_WT_button_2d", - .SHAPE_VARS(shape_pan), - }, { - .opname = "VIEW3D_OT_rotate", - .manipulator = "VIEW3D_WT_navigate_rotate", - .shape = NULL, - .shape_size = 0, - }, { - .opname = "VIEW3D_OT_zoom", - .manipulator = "MANIPULATOR_WT_button_2d", - .SHAPE_VARS(shape_zoom), - }, { - .opname = "VIEW3D_OT_view_persportho", - .manipulator = "MANIPULATOR_WT_button_2d", - .SHAPE_VARS(shape_persp), - }, { - .opname = "VIEW3D_OT_view_persportho", - .manipulator = "MANIPULATOR_WT_button_2d", - .SHAPE_VARS(shape_ortho), - }, { - .opname = "VIEW3D_OT_view_camera", - .manipulator = "MANIPULATOR_WT_button_2d", - .SHAPE_VARS(shape_camera), - }, -}; - -#undef SHAPE_VARS - -struct NavigateWidgetGroup { - wmManipulator *mpr_array[MPR_TOTAL]; - /* Store the view state to check for changes. */ - struct { - rcti rect_visible; - struct { - char is_persp; - char is_camera; - char viewlock; - } rv3d; - } state; - int region_size[2]; -}; - -static bool WIDGETGROUP_navigate_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - View3D *v3d = CTX_wm_view3d(C); - if (((U.uiflag & USER_SHOW_MANIPULATOR_AXIS) == 0) || - (v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_NAVIGATE))) - { - return false; - } - return true; - -} - -static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - struct NavigateWidgetGroup *navgroup = MEM_callocN(sizeof(struct NavigateWidgetGroup), __func__); - - navgroup->region_size[0] = -1; - navgroup->region_size[1] = -1; - - wmOperatorType *ot_view_axis = WM_operatortype_find("VIEW3D_OT_view_axis", true); - wmOperatorType *ot_view_camera = WM_operatortype_find("VIEW3D_OT_view_camera", true); - - for (int i = 0; i < MPR_TOTAL; i++) { - const struct NavigateManipulatorInfo *info = &g_navigate_params[i]; - navgroup->mpr_array[i] = WM_manipulator_new(info->manipulator, mgroup, NULL); - wmManipulator *mpr = navgroup->mpr_array[i]; - mpr->flag |= WM_MANIPULATOR_GRAB_CURSOR | WM_MANIPULATOR_DRAW_MODAL; - mpr->color[3] = 0.2f; - mpr->color_hi[3] = 0.4f; - - /* may be overwritten later */ - mpr->scale_basis = (MANIPULATOR_SIZE * MANIPULATOR_MINI_FAC) / 2; - if (info->shape != NULL) { - PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "shape"); - RNA_property_string_set_bytes( - mpr->ptr, prop, - (const char *)info->shape, info->shape_size); - RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_BUTTON_SHOW_OUTLINE); - } - - wmOperatorType *ot = WM_operatortype_find(info->opname, true); - WM_manipulator_operator_set(mpr, 0, ot, NULL); - } - - { - wmManipulator *mpr = navgroup->mpr_array[MPR_CAMERA]; - WM_manipulator_operator_set(mpr, 0, ot_view_camera, NULL); - } - - /* Click only buttons (not modal). */ - { - int mpr_ids[] = {MPR_PERSP, MPR_ORTHO, MPR_CAMERA}; - for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) { - wmManipulator *mpr = navgroup->mpr_array[mpr_ids[i]]; - RNA_boolean_set(mpr->ptr, "show_drag", false); - } - } - - /* Modal operators, don't use initial mouse location since we're clicking on a button. */ - { - int mpr_ids[] = {MPR_MOVE, MPR_ROTATE, MPR_ZOOM}; - for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) { - wmManipulator *mpr = navgroup->mpr_array[mpr_ids[i]]; - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, 0); - RNA_boolean_set(&mpop->ptr, "use_mouse_init", false); - } - } - - { - wmManipulator *mpr = navgroup->mpr_array[MPR_ROTATE]; - mpr->scale_basis = MANIPULATOR_SIZE / 2; - char mapping[6] = { - RV3D_VIEW_LEFT, - RV3D_VIEW_RIGHT, - RV3D_VIEW_FRONT, - RV3D_VIEW_BACK, - RV3D_VIEW_BOTTOM, - RV3D_VIEW_TOP, - }; - - for (int part_index = 0; part_index < 6; part_index += 1) { - PointerRNA *ptr = WM_manipulator_operator_set(mpr, part_index + 1, ot_view_axis, NULL); - RNA_enum_set(ptr, "type", mapping[part_index]); - } - - /* When dragging an axis, use this instead. */ - mpr->drag_part = 0; - } - - mgroup->customdata = navgroup; -} - -static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - struct NavigateWidgetGroup *navgroup = mgroup->customdata; - ARegion *ar = CTX_wm_region(C); - const RegionView3D *rv3d = ar->regiondata; - - for (int i = 0; i < 3; i++) { - copy_v3_v3(navgroup->mpr_array[MPR_ROTATE]->matrix_offset[i], rv3d->viewmat[i]); - } - - rcti rect_visible; - ED_region_visible_rect(ar, &rect_visible); - - if ((navgroup->state.rect_visible.xmax == rect_visible.xmax) && - (navgroup->state.rect_visible.ymax == rect_visible.ymax) && - (navgroup->state.rv3d.is_persp == rv3d->is_persp) && - (navgroup->state.rv3d.is_camera == (rv3d->persp == RV3D_CAMOB)) && - (navgroup->state.rv3d.viewlock == rv3d->viewlock)) - { - return; - } - - navgroup->state.rect_visible = rect_visible; - navgroup->state.rv3d.is_persp = rv3d->is_persp; - navgroup->state.rv3d.is_camera = (rv3d->persp == RV3D_CAMOB); - navgroup->state.rv3d.viewlock = rv3d->viewlock; - - const bool show_rotate = ( - ((rv3d->viewlock & RV3D_LOCKED) == 0) && - (navgroup->state.rv3d.is_camera == false)); - const bool show_fixed_offset = navgroup->state.rv3d.is_camera; - const float icon_size = MANIPULATOR_SIZE; - const float icon_offset = (icon_size * 0.52f) * MANIPULATOR_OFFSET_FAC * UI_DPI_FAC; - const float icon_offset_mini = icon_size * MANIPULATOR_MINI_OFFSET_FAC * UI_DPI_FAC; - const float co_rotate[2] = { - rect_visible.xmax - icon_offset, - rect_visible.ymax - icon_offset, - }; - const float co[2] = { - rect_visible.xmax - ((show_rotate || show_fixed_offset) ? (icon_offset * 2.0f) : (icon_offset_mini * 0.75f)), - rect_visible.ymax - icon_offset_mini * 0.75f, - }; - - wmManipulator *mpr; - - for (uint i = 0; i < ARRAY_SIZE(navgroup->mpr_array); i++) { - mpr = navgroup->mpr_array[i]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); - } - - /* RV3D_LOCKED or Camera: only show supported buttons. */ - if (show_rotate) { - mpr = navgroup->mpr_array[MPR_ROTATE]; - mpr->matrix_basis[3][0] = co_rotate[0]; - mpr->matrix_basis[3][1] = co_rotate[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - } - - int icon_mini_slot = 0; - - mpr = navgroup->mpr_array[MPR_ZOOM]; - mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); - mpr->matrix_basis[3][1] = co[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - - mpr = navgroup->mpr_array[MPR_MOVE]; - mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); - mpr->matrix_basis[3][1] = co[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - - if ((rv3d->viewlock & RV3D_LOCKED) == 0) { - mpr = navgroup->mpr_array[MPR_CAMERA]; - mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); - mpr->matrix_basis[3][1] = co[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - - if (navgroup->state.rv3d.is_camera == false) { - mpr = navgroup->mpr_array[rv3d->is_persp ? MPR_PERSP : MPR_ORTHO]; - mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); - mpr->matrix_basis[3][1] = co[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - } - } -} - -void VIEW3D_WGT_navigate(wmManipulatorGroupType *wgt) -{ - wgt->name = "View3D Navigate"; - wgt->idname = "VIEW3D_WGT_navigate"; - - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_SCALE | - WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL); - - wgt->poll = WIDGETGROUP_navigate_poll; - wgt->setup = WIDGETGROUP_navigate_setup; - wgt->draw_prepare = WIDGETGROUP_navigate_draw_prepare; -} - -/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c deleted file mode 100644 index 996da2a1475..00000000000 --- a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file view3d_manipulator_navigate_type.c - * \ingroup wm - * - * \name Custom Orientation/Navigation Manipulator for the 3D View - * - * \brief Simple manipulator to axis and translate. - * - * - scale_basis: used for the size. - * - matrix_basis: used for the location. - * - matrix_offset: used to store the orientation. - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" -#include "BLI_sort_utils.h" - -#include "BKE_context.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_matrix.h" -#include "GPU_state.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "UI_interface.h" -#include "UI_resources.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" - -#include "view3d_intern.h" - -#define DIAL_RESOLUTION 32 - -#define HANDLE_SIZE 0.33 - -static void axis_geom_draw( - const wmManipulator *mpr, const float color[4], const bool UNUSED(select)) -{ - GPU_line_width(mpr->line_width); - - Gwn_VertFormat *format = immVertexFormat(); - const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - - /* flip z for reverse */ - const float cone_coords[5][3] = { - {-1, -1, 4}, - {-1, +1, 4}, - {+1, +1, 4}, - {+1, -1, 4}, - {0, 0, 2}, - }; - - struct { - float depth; - char index; - char axis; - char is_pos; - } axis_order[6] = { - {-mpr->matrix_offset[0][2], 0, 0, false}, - {+mpr->matrix_offset[0][2], 1, 0, true}, - {-mpr->matrix_offset[1][2], 2, 1, false}, - {+mpr->matrix_offset[1][2], 3, 1, true}, - {-mpr->matrix_offset[2][2], 4, 2, false}, - {+mpr->matrix_offset[2][2], 5, 2, true}, - }; - qsort(&axis_order, ARRAY_SIZE(axis_order), sizeof(axis_order[0]), BLI_sortutil_cmp_float); - - const float scale_axis = 0.25f; - static const float axis_highlight[4] = {1, 1, 1, 1}; - static const float axis_nop[4] = {1, 1, 1, 0}; - static const float axis_black[4] = {0, 0, 0, 1}; - static float axis_color[3][4]; - gpuPushMatrix(); - gpuMultMatrix(mpr->matrix_offset); - - bool draw_center_done = false; - - for (int axis_index = 0; axis_index < ARRAY_SIZE(axis_order); axis_index++) { - const int index = axis_order[axis_index].index; - const int axis = axis_order[axis_index].axis; - const bool is_pos = axis_order[axis_index].is_pos; - - /* Draw slightly before, so axis aligned arrows draw ontop. */ - if ((draw_center_done == false) && (axis_order[axis_index].depth > -0.01f)) { - - /* Circle defining active area (revert back to 2D space). */ - { - gpuPopMatrix(); - immUniformColor4fv(color); - imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION); - gpuPushMatrix(); - gpuMultMatrix(mpr->matrix_offset); - } - - /* Center cube. */ - { - float center[3], size[3]; - - zero_v3(center); - copy_v3_fl(size, HANDLE_SIZE); - - GPU_depth_test(true); - glDepthMask(GL_TRUE); - glDepthFunc(GL_LEQUAL); - GPU_blend_set_func(GPU_ONE, GPU_ZERO); - GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - - GPU_line_smooth(true); - GPU_blend(true); - GPU_line_width(1.0f); - /* Just draw depth values. */ - immUniformColor4fv(axis_nop); - imm_draw_cube_fill_3d(pos_id, center, size); - immUniformColor4fv(axis_black); - madd_v3_v3fl( - center, - (float[3]){ - mpr->matrix_offset[0][2], - mpr->matrix_offset[1][2], - mpr->matrix_offset[2][2], - }, - 0.08f); - imm_draw_cube_wire_3d(pos_id, center, size); - GPU_blend(false); - GPU_line_smooth(false); - GPU_depth_test(false); - } - - draw_center_done = true; - } - UI_GetThemeColor3fv(TH_AXIS_X + axis, axis_color[axis]); - axis_color[axis][3] = 1.0f; - - const int index_z = axis; - const int index_y = (axis + 1) % 3; - const int index_x = (axis + 2) % 3; - -#define ROTATED_VERT(v_orig) \ - { \ - float v[3]; \ - copy_v3_v3(v, v_orig); \ - if (is_pos == 0) { \ - v[2] *= -1.0f; \ - } \ - immVertex3f(pos_id, v[index_x] * scale_axis, v[index_y] * scale_axis, v[index_z] * scale_axis); \ - } ((void)0) - - bool ok = true; - - /* skip view align axis */ - if (len_squared_v2(mpr->matrix_offset[axis]) < 1e-6f && (mpr->matrix_offset[axis][2] > 0.0f) == is_pos) { - ok = false; - } - if (ok) { - immUniformColor4fv(index + 1 == mpr->highlight_part ? axis_highlight : axis_color[axis]); - immBegin(GWN_PRIM_TRI_FAN, 6); - ROTATED_VERT(cone_coords[4]); - for (int j = 0; j <= 4; j++) { - ROTATED_VERT(cone_coords[j % 4]); - } - immEnd(); - } - -#undef ROTATED_VERT - } - - gpuPopMatrix(); - immUnbindProgram(); -} - -static void axis3d_draw_intern( - const bContext *UNUSED(C), wmManipulator *mpr, - const bool select, const bool highlight) -{ - const float *color = highlight ? mpr->color_hi : mpr->color; - float matrix_final[4][4]; - float matrix_unit[4][4]; - - unit_m4(matrix_unit); - - WM_manipulator_calc_matrix_final_params( - mpr, - &((struct WM_ManipulatorMatrixParams) { - .matrix_offset = matrix_unit, - }), matrix_final); - - gpuPushMatrix(); - gpuMultMatrix(matrix_final); - - GPU_blend(true); - axis_geom_draw(mpr, color, select); - GPU_blend(false); - gpuPopMatrix(); -} - -static void manipulator_axis_draw(const bContext *C, wmManipulator *mpr) -{ - const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - - (void)is_modal; - - GPU_blend(true); - axis3d_draw_intern(C, mpr, false, is_highlight); - GPU_blend(false); -} - -static int manipulator_axis_test_select( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) -{ - float point_local[2] = {UNPACK2(event->mval)}; - sub_v2_v2(point_local, mpr->matrix_basis[3]); - mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC)); - - const float len_sq = len_squared_v2(point_local); - if (len_sq > 1.0) { - return -1; - } - - int part_best = -1; - int part_index = 1; - /* Use 'SQUARE(HANDLE_SIZE)' if we want to be able to _not_ focus on one of the axis. */ - float i_best_len_sq = FLT_MAX; - for (int i = 0; i < 3; i++) { - for (int is_pos = 0; is_pos < 2; is_pos++) { - float co[2] = { - mpr->matrix_offset[i][0] * (is_pos ? 1 : -1), - mpr->matrix_offset[i][1] * (is_pos ? 1 : -1), - }; - - bool ok = true; - - /* Check if we're viewing on an axis, there is no point to clicking on the current axis so show the reverse. */ - if (len_squared_v2(co) < 1e-6f && (mpr->matrix_offset[i][2] > 0.0f) == is_pos) { - ok = false; - } - - if (ok) { - const float len_axis_sq = len_squared_v2v2(co, point_local); - if (len_axis_sq < i_best_len_sq) { - part_best = part_index; - i_best_len_sq = len_axis_sq; - } - } - part_index += 1; - } - } - - if (part_best != -1) { - return part_best; - } - - /* The 'mpr->scale_final' is already applied when projecting. */ - if (len_sq < 1.0f) { - return 0; - } - - return -1; -} - -static int manipulator_axis_cursor_get(wmManipulator *mpr) -{ - if (mpr->highlight_part > 0) { - return CURSOR_EDIT; - } - return BC_NSEW_SCROLLCURSOR; -} - -void VIEW3D_WT_navigate_rotate(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "VIEW3D_WT_navigate_rotate"; - - /* api callbacks */ - wt->draw = manipulator_axis_draw; - wt->test_select = manipulator_axis_test_select; - wt->cursor_get = manipulator_axis_cursor_get; - - wt->struct_size = sizeof(wmManipulator); -} diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c deleted file mode 100644 index d102fdc6e04..00000000000 --- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c +++ /dev/null @@ -1,1101 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_view3d/view3d_manipulator_ruler.c - * \ingroup spview3d - */ - -#include "BLI_listbase.h" -#include "BLI_string.h" -#include "BLI_rect.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "BLT_translation.h" - -#include "BKE_context.h" -#include "BKE_gpencil.h" -#include "BKE_main.h" - -#include "BKE_object.h" -#include "BKE_unit.h" - -#include "DNA_object_types.h" -#include "DNA_gpencil_types.h" -#include "DNA_view3d_types.h" - -#include "BIF_gl.h" - -#include "ED_screen.h" -#include "ED_transform_snap_object_context.h" -#include "ED_view3d.h" - -#include "UI_resources.h" -#include "UI_interface.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" -#include "WM_toolsystem.h" - -#include "view3d_intern.h" /* own include */ - -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" -#include "GPU_select.h" -#include "GPU_state.h" - -#include "BLF_api.h" - - -static const char *view3d_wgt_ruler_id = "VIEW3D_WGT_ruler"; - - -#define MVAL_MAX_PX_DIST 12.0f - -/* -------------------------------------------------------------------- */ -/* Ruler Item (we can have many) */ -enum { - RULERITEM_USE_ANGLE = (1 << 0), /* use protractor */ - RULERITEM_USE_RAYCAST = (1 << 1) -}; - -enum { - RULERITEM_DIRECTION_IN = 0, - RULERITEM_DIRECTION_OUT -}; - -/* keep smaller then selection, since we may want click elsewhere without selecting a ruler */ -#define RULER_PICK_DIST 12.0f -#define RULER_PICK_DIST_SQ (RULER_PICK_DIST * RULER_PICK_DIST) - -/* not clicking on a point */ -#define PART_LINE 0xff - -/* -------------------------------------------------------------------- */ -/* Ruler Info (wmManipulatorGroup customdata) */ - -enum { - RULER_STATE_NORMAL = 0, - RULER_STATE_DRAG -}; - -enum { - RULER_SNAP_OK = (1 << 0), -}; - -typedef struct RulerInfo { - // ListBase items; - int item_active; - int flag; - int snap_flag; - int state; - - struct SnapObjectContext *snap_context; - - /* wm state */ - wmWindow *win; - ScrArea *sa; - ARegion *ar; /* re-assigned every modal update */ -} RulerInfo; - -/* -------------------------------------------------------------------- */ -/* Ruler Item (two or three points) */ - -typedef struct RulerItem { - wmManipulator mpr; - - /* worldspace coords, middle being optional */ - float co[3][3]; - - int flag; - int raycast_dir; /* RULER_DIRECTION_* */ -} RulerItem; - -typedef struct RulerInteraction { - /* selected coord */ - char co_index; /* 0 -> 2 */ - float drag_start_co[3]; - uint inside_region : 1; -} RulerInteraction; - -/* -------------------------------------------------------------------- */ -/** \name Internal Ruler Utilities - * \{ */ - -static RulerItem *ruler_item_add(wmManipulatorGroup *mgroup) -{ - /* could pass this as an arg */ - const wmManipulatorType *wt_ruler = WM_manipulatortype_find("VIEW3D_WT_ruler_item", true); - RulerItem *ruler_item = (RulerItem *)WM_manipulator_new_ptr(wt_ruler, mgroup, NULL); - WM_manipulator_set_flag(&ruler_item->mpr, WM_MANIPULATOR_DRAW_MODAL, true); - return ruler_item; -} - -static void ruler_item_remove(bContext *C, wmManipulatorGroup *mgroup, RulerItem *ruler_item) -{ - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, &ruler_item->mpr, C); -} - -static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit, - char *numstr, size_t numstr_size, int prec) -{ - const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0; - - if (ruler_item->flag & RULERITEM_USE_ANGLE) { - const float ruler_angle = angle_v3v3v3(ruler_item->co[0], - ruler_item->co[1], - ruler_item->co[2]); - - if (unit->system == USER_UNIT_NONE) { - BLI_snprintf(numstr, numstr_size, "%.*f°", prec, RAD2DEGF(ruler_angle)); - } - else { - bUnit_AsString(numstr, numstr_size, - (double)ruler_angle, - prec, unit->system, B_UNIT_ROTATION, do_split, false); - } - } - else { - const float ruler_len = len_v3v3(ruler_item->co[0], - ruler_item->co[2]); - - if (unit->system == USER_UNIT_NONE) { - BLI_snprintf(numstr, numstr_size, "%.*f", prec, ruler_len); - } - else { - bUnit_AsString(numstr, numstr_size, - (double)(ruler_len * unit->scale_length), - prec, unit->system, B_UNIT_LENGTH, do_split, false); - } - } -} - -static bool view3d_ruler_pick( - wmManipulatorGroup *mgroup, RulerItem *ruler_item, const float mval[2], - int *r_co_index) -{ - RulerInfo *ruler_info = mgroup->customdata; - ARegion *ar = ruler_info->ar; - bool found = false; - - float dist_best = RULER_PICK_DIST_SQ; - int co_index_best = -1; - - { - float co_ss[3][2]; - float dist; - int j; - - /* should these be checked? - ok for now not to */ - for (j = 0; j < 3; j++) { - ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); - } - - if (ruler_item->flag & RULERITEM_USE_ANGLE) { - dist = min_ff(dist_squared_to_line_segment_v2(mval, co_ss[0], co_ss[1]), - dist_squared_to_line_segment_v2(mval, co_ss[1], co_ss[2])); - if (dist < dist_best) { - dist_best = dist; - found = true; - - { - const float dist_points[3] = { - len_squared_v2v2(co_ss[0], mval), - len_squared_v2v2(co_ss[1], mval), - len_squared_v2v2(co_ss[2], mval), - }; - if (min_fff(UNPACK3(dist_points)) < RULER_PICK_DIST_SQ) { - co_index_best = min_axis_v3(dist_points); - } - else { - co_index_best = -1; - } - } - } - } - else { - dist = dist_squared_to_line_segment_v2(mval, co_ss[0], co_ss[2]); - if (dist < dist_best) { - dist_best = dist; - found = true; - - { - const float dist_points[2] = { - len_squared_v2v2(co_ss[0], mval), - len_squared_v2v2(co_ss[2], mval), - }; - if (min_ff(UNPACK2(dist_points)) < RULER_PICK_DIST_SQ) { - co_index_best = (dist_points[0] < dist_points[1]) ? 0 : 2; - } - else { - co_index_best = -1; - } - } - } - } - } - - *r_co_index = co_index_best; - return found; -} - -/** - * Ensure the 'snap_context' is only cached while dragging, - * needed since the user may toggle modes between tool use. - */ -static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) -{ - Main *bmain = CTX_data_main(C); - if (state == ruler_info->state) { - return; - } - - /* always remove */ - if (ruler_info->snap_context) { - ED_transform_snap_object_context_destroy(ruler_info->snap_context); - ruler_info->snap_context = NULL; - } - - if (state == RULER_STATE_NORMAL) { - /* pass */ - } - else if (state == RULER_STATE_DRAG) { - ruler_info->snap_context = ED_transform_snap_object_context_create_view3d( - bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, - ruler_info->ar, CTX_wm_view3d(C)); - } - else { - BLI_assert(0); - } - - ruler_info->state = state; -} - -static void view3d_ruler_item_project( - RulerInfo *ruler_info, float r_co[3], - const int xy[2]) -{ - ED_view3d_win_to_3d_int(ruler_info->sa->spacedata.first, ruler_info->ar, r_co, xy, r_co); -} - -/* use for mousemove events */ -static bool view3d_ruler_item_mousemove( - RulerInfo *ruler_info, RulerItem *ruler_item, const int mval[2], - const bool do_thickness, const bool do_snap) -{ - RulerInteraction *inter = ruler_item->mpr.interaction_data; - const float eps_bias = 0.0002f; - float dist_px = MVAL_MAX_PX_DIST * U.pixelsize; /* snap dist */ - - ruler_info->snap_flag &= ~RULER_SNAP_OK; - - if (ruler_item) { - float *co = ruler_item->co[inter->co_index]; - /* restore the initial depth */ - copy_v3_v3(co, inter->drag_start_co); - view3d_ruler_item_project(ruler_info, co, mval); - if (do_thickness && inter->co_index != 1) { - // Scene *scene = CTX_data_scene(C); - // View3D *v3d = ruler_info->sa->spacedata.first; - const float mval_fl[2] = {UNPACK2(mval)}; - float ray_normal[3]; - float ray_start[3]; - float *co_other; - - co_other = ruler_item->co[inter->co_index == 0 ? 2 : 0]; - - if (ED_transform_snap_object_project_view3d( - ruler_info->snap_context, - SCE_SNAP_MODE_FACE, - &(const struct SnapObjectParams){ - .snap_select = SNAP_ALL, - .use_object_edit_cage = true, - }, - mval_fl, &dist_px, - co, ray_normal)) - { - negate_v3(ray_normal); - /* add some bias */ - madd_v3_v3v3fl(ray_start, co, ray_normal, eps_bias); - ED_transform_snap_object_project_ray( - ruler_info->snap_context, - &(const struct SnapObjectParams){ - .snap_select = SNAP_ALL, - .use_object_edit_cage = true, - }, - ray_start, ray_normal, NULL, - co_other, NULL); - } - } - else if (do_snap) { - const float mval_fl[2] = {UNPACK2(mval)}; - - if (ED_transform_snap_object_project_view3d( - ruler_info->snap_context, - (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE), - &(const struct SnapObjectParams){ - .snap_select = SNAP_ALL, - .use_object_edit_cage = true, - .use_occlusion_test = true, - }, - mval_fl, &dist_px, - co, NULL)) - { - ruler_info->snap_flag |= RULER_SNAP_OK; - } - } - return true; - } - else { - return false; - } -} - - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Ruler/Grease Pencil Conversion - * \{ */ - -#define RULER_ID "RulerData3D" -static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup) -{ - // RulerInfo *ruler_info = mgroup->customdata; - Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - bGPDlayer *gpl; - bGPDframe *gpf; - bGPDstroke *gps; - bGPDpalette *palette; - bGPDpalettecolor *palcolor; - RulerItem *ruler_item; - const char *ruler_name = RULER_ID; - bool changed = false; - - if (scene->gpd == NULL) { - scene->gpd = BKE_gpencil_data_addnew(bmain, "GPencil"); - } - - gpl = BLI_findstring(&scene->gpd->layers, ruler_name, offsetof(bGPDlayer, info)); - if (gpl == NULL) { - gpl = BKE_gpencil_layer_addnew(scene->gpd, ruler_name, false); - gpl->thickness = 1; - gpl->flag |= GP_LAYER_HIDE; - } - - /* try to get active palette or create a new one */ - palette = BKE_gpencil_palette_getactive(scene->gpd); - if (palette == NULL) { - palette = BKE_gpencil_palette_addnew(scene->gpd, DATA_("GP_Palette"), true); - } - /* try to get color with the ruler name or create a new one */ - palcolor = BKE_gpencil_palettecolor_getbyname(palette, (char *)ruler_name); - if (palcolor == NULL) { - palcolor = BKE_gpencil_palettecolor_addnew(palette, (char *)ruler_name, true); - } - - gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); - BKE_gpencil_free_strokes(gpf); - - for (ruler_item = mgroup->manipulators.first; ruler_item; ruler_item = (RulerItem *)ruler_item->mpr.next) { - bGPDspoint *pt; - int j; - - /* allocate memory for a new stroke */ - gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); - if (ruler_item->flag & RULERITEM_USE_ANGLE) { - gps->totpoints = 3; - pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - for (j = 0; j < 3; j++) { - copy_v3_v3(&pt->x, ruler_item->co[j]); - pt->pressure = 1.0f; - pt->strength = 1.0f; - pt++; - } - } - else { - gps->totpoints = 2; - pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - for (j = 0; j < 3; j += 2) { - copy_v3_v3(&pt->x, ruler_item->co[j]); - pt->pressure = 1.0f; - pt->strength = 1.0f; - pt++; - } - } - gps->flag = GP_STROKE_3DSPACE; - gps->thickness = 3; - /* assign color to stroke */ - BLI_strncpy(gps->colorname, palcolor->info, sizeof(gps->colorname)); - gps->palcolor = palcolor; - BLI_addtail(&gpf->strokes, gps); - changed = true; - } - - return changed; -} - -static bool view3d_ruler_from_gpencil(const bContext *C, wmManipulatorGroup *mgroup) -{ - Scene *scene = CTX_data_scene(C); - bool changed = false; - - if (scene->gpd) { - bGPDlayer *gpl; - const char *ruler_name = RULER_ID; - gpl = BLI_findstring(&scene->gpd->layers, ruler_name, offsetof(bGPDlayer, info)); - if (gpl) { - bGPDframe *gpf; - gpf = BKE_gpencil_layer_getframe(gpl, CFRA, false); - if (gpf) { - bGPDstroke *gps; - for (gps = gpf->strokes.first; gps; gps = gps->next) { - bGPDspoint *pt = gps->points; - int j; - RulerItem *ruler_item = NULL; - if (gps->totpoints == 3) { - ruler_item = ruler_item_add(mgroup); - for (j = 0; j < 3; j++) { - copy_v3_v3(ruler_item->co[j], &pt->x); - pt++; - } - ruler_item->flag |= RULERITEM_USE_ANGLE; - changed = true; - } - else if (gps->totpoints == 2) { - ruler_item = ruler_item_add(mgroup); - for (j = 0; j < 3; j += 2) { - copy_v3_v3(ruler_item->co[j], &pt->x); - pt++; - } - changed = true; - } - } - } - } - } - - return changed; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Ruler Item Manipulator Type - * \{ */ - -static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) -{ - Scene *scene = CTX_data_scene(C); - UnitSettings *unit = &scene->unit; - RulerInfo *ruler_info = mpr->parent_mgroup->customdata; - RulerItem *ruler_item = (RulerItem *)mpr; - ARegion *ar = ruler_info->ar; - RegionView3D *rv3d = ar->regiondata; - const float cap_size = 4.0f; - const float bg_margin = 4.0f * U.pixelsize; - const float bg_radius = 4.0f * U.pixelsize; - const float arc_size = 64.0f * U.pixelsize; -#define ARC_STEPS 24 - const int arc_steps = ARC_STEPS; - const float color_act[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - const float color_base[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - unsigned char color_text[3]; - unsigned char color_wire[3]; - float color_back[4] = {1.0f, 1.0f, 1.0f, 0.5f}; - - /* anti-aliased lines for more consistent appearance */ - GPU_line_smooth(true); - - BLF_enable(blf_mono_font, BLF_ROTATION); - BLF_size(blf_mono_font, 14 * U.pixelsize, U.dpi); - BLF_rotation(blf_mono_font, 0.0f); - - UI_GetThemeColor3ubv(TH_TEXT, color_text); - UI_GetThemeColor3ubv(TH_WIRE, color_wire); - - const bool is_act = (mpr->flag & WM_MANIPULATOR_DRAW_HOVER); - float dir_ruler[2]; - float co_ss[3][2]; - int j; - - /* should these be checked? - ok for now not to */ - for (j = 0; j < 3; j++) { - ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); - } - - GPU_blend(true); - - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - if (ruler_item->flag & RULERITEM_USE_ANGLE) { - immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); - - float viewport_size[4]; - GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - - immUniform1i("colors_len", 2); /* "advanced" mode */ - const float *col = is_act ? color_act : color_base; - immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); - immUniform1f("dash_width", 6.0f); - - immBegin(GWN_PRIM_LINE_STRIP, 3); - - immVertex2fv(shdr_pos, co_ss[0]); - immVertex2fv(shdr_pos, co_ss[1]); - immVertex2fv(shdr_pos, co_ss[2]); - - immEnd(); - - immUnbindProgram(); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - - /* arc */ - { - float dir_tmp[3]; - float co_tmp[3]; - float arc_ss_coord[2]; - - float dir_a[3]; - float dir_b[3]; - float quat[4]; - float axis[3]; - float angle; - const float px_scale = (ED_view3d_pixel_size(rv3d, ruler_item->co[1]) * - min_fff(arc_size, - len_v2v2(co_ss[0], co_ss[1]) / 2.0f, - len_v2v2(co_ss[2], co_ss[1]) / 2.0f)); - - sub_v3_v3v3(dir_a, ruler_item->co[0], ruler_item->co[1]); - sub_v3_v3v3(dir_b, ruler_item->co[2], ruler_item->co[1]); - normalize_v3(dir_a); - normalize_v3(dir_b); - - cross_v3_v3v3(axis, dir_a, dir_b); - angle = angle_normalized_v3v3(dir_a, dir_b); - - axis_angle_to_quat(quat, axis, angle / arc_steps); - - copy_v3_v3(dir_tmp, dir_a); - - immUniformColor3ubv(color_wire); - - immBegin(GWN_PRIM_LINE_STRIP, arc_steps + 1); - - for (j = 0; j <= arc_steps; j++) { - madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale); - ED_view3d_project_float_global(ar, co_tmp, arc_ss_coord, V3D_PROJ_TEST_NOP); - mul_qt_v3(quat, dir_tmp); - - immVertex2fv(shdr_pos, arc_ss_coord); - } - - immEnd(); - } - - /* capping */ - { - float rot_90_vec_a[2]; - float rot_90_vec_b[2]; - float cap[2]; - - sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[1]); - rot_90_vec_a[0] = -dir_ruler[1]; - rot_90_vec_a[1] = dir_ruler[0]; - normalize_v2(rot_90_vec_a); - - sub_v2_v2v2(dir_ruler, co_ss[1], co_ss[2]); - rot_90_vec_b[0] = -dir_ruler[1]; - rot_90_vec_b[1] = dir_ruler[0]; - normalize_v2(rot_90_vec_b); - - GPU_blend(true); - - immUniformColor3ubv(color_wire); - - immBegin(GWN_PRIM_LINES, 8); - - madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size); - immVertex2fv(shdr_pos, cap); - madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, -cap_size); - immVertex2fv(shdr_pos, cap); - - madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, cap_size); - immVertex2fv(shdr_pos, cap); - madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, -cap_size); - immVertex2fv(shdr_pos, cap); - - /* angle vertex */ - immVertex2f(shdr_pos, co_ss[1][0] - cap_size, co_ss[1][1] - cap_size); - immVertex2f(shdr_pos, co_ss[1][0] + cap_size, co_ss[1][1] + cap_size); - immVertex2f(shdr_pos, co_ss[1][0] - cap_size, co_ss[1][1] + cap_size); - immVertex2f(shdr_pos, co_ss[1][0] + cap_size, co_ss[1][1] - cap_size); - - immEnd(); - - GPU_blend(false); - } - - immUnbindProgram(); - - /* text */ - { - char numstr[256]; - float numstr_size[2]; - float posit[2]; - const int prec = 2; /* XXX, todo, make optional */ - - ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec); - - BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]); - - posit[0] = co_ss[1][0] + (cap_size * 2.0f); - posit[1] = co_ss[1][1] - (numstr_size[1] / 2.0f); - - /* draw text (bg) */ - UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_aa( - true, - posit[0] - bg_margin, posit[1] - bg_margin, - posit[0] + bg_margin + numstr_size[0], posit[1] + bg_margin + numstr_size[1], - bg_radius, color_back); - /* draw text */ - BLF_color3ubv(blf_mono_font, color_text); - BLF_position(blf_mono_font, posit[0], posit[1], 0.0f); - BLF_rotation(blf_mono_font, 0.0f); - BLF_draw(blf_mono_font, numstr, sizeof(numstr)); - } - } - else { - immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); - - float viewport_size[4]; - GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - - immUniform1i("colors_len", 2); /* "advanced" mode */ - const float *col = is_act ? color_act : color_base; - immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); - immUniform1f("dash_width", 6.0f); - - immBegin(GWN_PRIM_LINES, 2); - - immVertex2fv(shdr_pos, co_ss[0]); - immVertex2fv(shdr_pos, co_ss[2]); - - immEnd(); - - immUnbindProgram(); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - - sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[2]); - - /* capping */ - { - float rot_90_vec[2] = {-dir_ruler[1], dir_ruler[0]}; - float cap[2]; - - normalize_v2(rot_90_vec); - - GPU_blend(true); - - immUniformColor3ubv(color_wire); - - immBegin(GWN_PRIM_LINES, 4); - - madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size); - immVertex2fv(shdr_pos, cap); - madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, -cap_size); - immVertex2fv(shdr_pos, cap); - - madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, cap_size); - immVertex2fv(shdr_pos, cap); - madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, -cap_size); - immVertex2fv(shdr_pos, cap); - - immEnd(); - - GPU_blend(false); - } - - immUnbindProgram(); - - /* text */ - { - char numstr[256]; - float numstr_size[2]; - const int prec = 6; /* XXX, todo, make optional */ - float posit[2]; - - ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec); - - BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]); - - mid_v2_v2v2(posit, co_ss[0], co_ss[2]); - - /* center text */ - posit[0] -= numstr_size[0] / 2.0f; - posit[1] -= numstr_size[1] / 2.0f; - - /* draw text (bg) */ - UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_aa( - true, - posit[0] - bg_margin, posit[1] - bg_margin, - posit[0] + bg_margin + numstr_size[0], posit[1] + bg_margin + numstr_size[1], - bg_radius, color_back); - /* draw text */ - BLF_color3ubv(blf_mono_font, color_text); - BLF_position(blf_mono_font, posit[0], posit[1], 0.0f); - BLF_draw(blf_mono_font, numstr, sizeof(numstr)); - } - } - - GPU_line_smooth(false); - - BLF_disable(blf_mono_font, BLF_ROTATION); - -#undef ARC_STEPS - - /* draw snap */ - if ((ruler_info->snap_flag & RULER_SNAP_OK) && - (ruler_info->state == RULER_STATE_DRAG) && - (ruler_item->mpr.interaction_data != NULL)) - { - RulerInteraction *inter = ruler_item->mpr.interaction_data; - /* size from drawSnapping */ - const float size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); - float co_ss_snap[3]; - ED_view3d_project_float_global(ar, ruler_item->co[inter->co_index], co_ss_snap, V3D_PROJ_TEST_NOP); - - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4fv(color_act); - - imm_draw_circle_wire_2d(pos, co_ss_snap[0], co_ss_snap[1], size * U.pixelsize, 32); - - immUnbindProgram(); - } -} - -static int manipulator_ruler_test_select( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) -{ - RulerItem *ruler_item_pick = (RulerItem *)mpr; - float mval_fl[2] = {UNPACK2(event->mval)}; - int co_index; - - /* select and drag */ - if (view3d_ruler_pick(mpr->parent_mgroup, ruler_item_pick, mval_fl, &co_index)) { - if (co_index == -1) { - if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) { - return PART_LINE; - } - } - else { - return co_index; - } - } - return -1; -} - -static int manipulator_ruler_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) -{ - bool do_draw = false; - int exit_code = OPERATOR_RUNNING_MODAL; - RulerInfo *ruler_info = mpr->parent_mgroup->customdata; - RulerItem *ruler_item = (RulerItem *)mpr; - RulerInteraction *inter = ruler_item->mpr.interaction_data; - ARegion *ar = CTX_wm_region(C); - - ruler_info->ar = ar; - - switch (event->type) { - case MOUSEMOVE: - { - if (ruler_info->state == RULER_STATE_DRAG) { - if (view3d_ruler_item_mousemove( - ruler_info, ruler_item, event->mval, - event->shift != 0, event->ctrl != 0)) - { - do_draw = true; - } - inter->inside_region = BLI_rcti_isect_pt_v(&ar->winrct, &event->x); - } - break; - } - } - if (do_draw) { - ED_region_tag_redraw(ar); - } - return exit_code; -} - -static int manipulator_ruler_invoke( - bContext *C, wmManipulator *mpr, const wmEvent *event) -{ - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - RulerInfo *ruler_info = mgroup->customdata; - RulerItem *ruler_item_pick = (RulerItem *)mpr; - RulerInteraction *inter = MEM_callocN(sizeof(RulerInteraction), __func__); - mpr->interaction_data = inter; - - ARegion *ar = ruler_info->ar; - - const float mval_fl[2] = {UNPACK2(event->mval)}; - - /* select and drag */ - if (mpr->highlight_part == PART_LINE) { - if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) { - /* Add Center Point */ - ruler_item_pick->flag |= RULERITEM_USE_ANGLE; - inter->co_index = 1; - ruler_state_set(C, ruler_info, RULER_STATE_DRAG); - - /* find the factor */ - { - float co_ss[2][2]; - float fac; - - ED_view3d_project_float_global(ar, ruler_item_pick->co[0], co_ss[0], V3D_PROJ_TEST_NOP); - ED_view3d_project_float_global(ar, ruler_item_pick->co[2], co_ss[1], V3D_PROJ_TEST_NOP); - - fac = line_point_factor_v2(mval_fl, co_ss[0], co_ss[1]); - CLAMP(fac, 0.0f, 1.0f); - - interp_v3_v3v3(ruler_item_pick->co[1], - ruler_item_pick->co[0], - ruler_item_pick->co[2], fac); - } - - /* update the new location */ - view3d_ruler_item_mousemove( - ruler_info, ruler_item_pick, event->mval, - event->shift != 0, event->ctrl != 0); - } - } - else { - inter->co_index = mpr->highlight_part; - ruler_state_set(C, ruler_info, RULER_STATE_DRAG); - - /* store the initial depth */ - copy_v3_v3(inter->drag_start_co, ruler_item_pick->co[inter->co_index]); - } - - return OPERATOR_RUNNING_MODAL; -} - -static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool cancel) -{ - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - RulerInfo *ruler_info = mgroup->customdata; - - if (!cancel) { - if (ruler_info->state == RULER_STATE_DRAG) { - RulerItem *ruler_item = (RulerItem *)mpr; - RulerInteraction *inter = mpr->interaction_data; - /* rubber-band angle removal */ - if (!inter->inside_region) { - if ((inter->co_index == 1) && (ruler_item->flag & RULERITEM_USE_ANGLE)) { - ruler_item->flag &= ~RULERITEM_USE_ANGLE; - } - else { - /* Not ideal, since the ruler isn't a mode and we don't want to override delete key - * use dragging out of the view for removal. */ - ruler_item_remove(C, mgroup, ruler_item); - ruler_item = NULL; - mpr = NULL; - inter = NULL; - } - } - if (ruler_info->snap_flag & RULER_SNAP_OK) { - ruler_info->snap_flag &= ~RULER_SNAP_OK; - } - ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); - } - /* We could convert only the current manipulator, for now just re-generate. */ - view3d_ruler_to_gpencil(C, mgroup); - } - - if (mpr) { - MEM_SAFE_FREE(mpr->interaction_data); - } - - ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); -} - -static int manipulator_ruler_cursor_get(wmManipulator *mpr) -{ - if (mpr->highlight_part == PART_LINE) { - return BC_CROSSCURSOR; - } - return BC_NSEW_SCROLLCURSOR; -} - -void VIEW3D_WT_ruler_item(wmManipulatorType *wt) -{ - /* identifiers */ - wt->idname = "VIEW3D_WT_ruler_item"; - - /* api callbacks */ - wt->draw = manipulator_ruler_draw; - wt->test_select = manipulator_ruler_test_select; - wt->modal = manipulator_ruler_modal; - wt->invoke = manipulator_ruler_invoke; - wt->exit = manipulator_ruler_exit; - wt->cursor_get = manipulator_ruler_cursor_get; - - wt->struct_size = sizeof(RulerItem); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Ruler Manipulator Group - * \{ */ - -static bool WIDGETGROUP_ruler_poll(const bContext *C, wmManipulatorGroupType *wgt) -{ - bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); - if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->manipulator_group)) - { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); - return false; - } - return true; -} - -static void WIDGETGROUP_ruler_setup(const bContext *C, wmManipulatorGroup *mgroup) -{ - RulerInfo *ruler_info = MEM_callocN(sizeof(RulerInfo), __func__); - - if (view3d_ruler_from_gpencil(C, mgroup)) { - /* nop */ - } - - wmWindow *win = CTX_wm_window(C); - ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); - ruler_info->win = win; - ruler_info->sa = sa; - ruler_info->ar = ar; - - mgroup->customdata = ruler_info; -} - -void VIEW3D_WGT_ruler(wmManipulatorGroupType *wgt) -{ - wgt->name = "Ruler Widgets"; - wgt->idname = view3d_wgt_ruler_id; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_SCALE | WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL; - - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - - wgt->poll = WIDGETGROUP_ruler_poll; - wgt->setup = WIDGETGROUP_ruler_setup; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Add Ruler Operator - * \{ */ - -static bool view3d_ruler_poll(bContext *C) -{ - bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); - if ((tref_rt == NULL) || - !STREQ(view3d_wgt_ruler_id, tref_rt->manipulator_group) || - CTX_wm_region_view3d(C) == NULL) - { - return false; - } - return true; -} - -static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) -{ - ARegion *ar = CTX_wm_region(C); - View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d = ar->regiondata; - - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulatorGroup *mgroup = WM_manipulatormap_group_find(mmap, view3d_wgt_ruler_id); - const bool use_depth = (v3d->drawtype >= OB_SOLID); - - /* Create new line */ - RulerItem *ruler_item; - ruler_item = ruler_item_add(mgroup); - - /* This is a little weak, but there is no real good way to tweak directly. */ - WM_manipulator_highlight_set(mmap, &ruler_item->mpr); - if (WM_operator_name_call( - C, "MANIPULATORGROUP_OT_manipulator_tweak", - WM_OP_INVOKE_REGION_WIN, NULL) == OPERATOR_RUNNING_MODAL) - { - RulerInfo *ruler_info = mgroup->customdata; - RulerInteraction *inter = ruler_item->mpr.interaction_data; - if (use_depth) { - /* snap the first point added, not essential but handy */ - inter->co_index = 0; - view3d_ruler_item_mousemove(ruler_info, ruler_item, event->mval, false, true); - copy_v3_v3(inter->drag_start_co, ruler_item->co[inter->co_index]); - } - else { - negate_v3_v3(inter->drag_start_co, rv3d->ofs); - copy_v3_v3(ruler_item->co[0], inter->drag_start_co); - view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval); - } - - copy_v3_v3(ruler_item->co[2], ruler_item->co[0]); - ruler_item->mpr.highlight_part = inter->co_index = 2; - } - return OPERATOR_FINISHED; -} - -void VIEW3D_OT_ruler_add(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Ruler Add"; - ot->idname = "VIEW3D_OT_ruler_add"; - ot->description = ""; - - ot->invoke = view3d_ruler_add_invoke; - ot->poll = view3d_ruler_poll; - - /* flags */ - ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; -} - -/** \} */ diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index 3e132192875..45055eb1225 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -46,8 +46,8 @@ set(SRC transform_conversions.c transform_generics.c transform_input.c - transform_manipulator_2d.c - transform_manipulator_3d.c + transform_gizmo_2d.c + transform_gizmo_3d.c transform_ops.c transform_orientations.c transform_snap.c diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c new file mode 100644 index 00000000000..5d5d55de848 --- /dev/null +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -0,0 +1,382 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/transform/transform_gizmo_2d.c + * \ingroup edtransform + * + * \name 2D Transform Manipulator + * + * Used for UV/Image Editor + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" + +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_view3d_types.h" + +#include "BKE_context.h" +#include "BKE_editmesh.h" + +#include "RNA_access.h" + +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "WM_api.h" +#include "WM_types.h" +#include "wm.h" /* XXX */ + +#include "ED_image.h" +#include "ED_screen.h" +#include "ED_uvedit.h" +#include "ED_gizmo_library.h" + +#include "transform.h" /* own include */ + +/* axes as index */ +enum { + MAN2D_AXIS_TRANS_X = 0, + MAN2D_AXIS_TRANS_Y, + + MAN2D_AXIS_LAST, +}; + +typedef struct ManipulatorGroup2D { + wmManipulator *translate_x, + *translate_y; + + wmManipulator *cage; + + /* Current origin in view space, used to update widget origin for possible view changes */ + float origin[2]; + float min[2]; + float max[2]; + +} ManipulatorGroup2D; + + +/* **************** Utilities **************** */ + +/* loop over axes */ +#define MAN2D_ITER_AXES_BEGIN(axis, axis_idx) \ + { \ + wmManipulator *axis; \ + int axis_idx; \ + for (axis_idx = 0; axis_idx < MAN2D_AXIS_LAST; axis_idx++) { \ + axis = manipulator2d_get_axis_from_index(man, axis_idx); + +#define MAN2D_ITER_AXES_END \ + } \ + } ((void)0) + +static wmManipulator *manipulator2d_get_axis_from_index(const ManipulatorGroup2D *man, const short axis_idx) +{ + BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN2D_AXIS_TRANS_X, (float)MAN2D_AXIS_TRANS_Y)); + + switch (axis_idx) { + case MAN2D_AXIS_TRANS_X: + return man->translate_x; + case MAN2D_AXIS_TRANS_Y: + return man->translate_y; + } + + return NULL; +} + +static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float *r_col_hi) +{ + const float alpha = 0.6f; + const float alpha_hi = 1.0f; + int col_id; + + switch (axis_idx) { + case MAN2D_AXIS_TRANS_X: + col_id = TH_AXIS_X; + break; + case MAN2D_AXIS_TRANS_Y: + col_id = TH_AXIS_Y; + break; + } + + UI_GetThemeColor4fv(col_id, r_col); + + copy_v4_v4(r_col_hi, r_col); + r_col[3] *= alpha; + r_col_hi[3] *= alpha_hi; +} + +static ManipulatorGroup2D *manipulatorgroup2d_init(wmManipulatorGroup *mgroup) +{ + const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_2d", true); + const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_2d", true); + + ManipulatorGroup2D *man = MEM_callocN(sizeof(ManipulatorGroup2D), __func__); + + man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); + man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); + man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); + + RNA_enum_set(man->cage->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE); + + return man; +} + +/** + * Calculates origin in view space, use with #manipulator2d_origin_to_region. + */ +static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max) +{ + SpaceImage *sima = CTX_wm_space_image(C); + Image *ima = ED_space_image(sima); + + float min_buf[2], max_buf[2]; + if (r_min == NULL) { + r_min = min_buf; + } + if (r_max == NULL) { + r_max = max_buf; + } + + if (!ED_uvedit_minmax(CTX_data_scene(C), ima, CTX_data_edit_object(C), r_min, r_max)) { + zero_v2(r_min); + zero_v2(r_max); + } + mid_v2_v2v2(r_center, r_min, r_max); +} + +/** + * Convert origin (or any other point) from view to region space. + */ +BLI_INLINE void manipulator2d_origin_to_region(ARegion *ar, float *r_origin) +{ + UI_view2d_view_to_region_fl(&ar->v2d, r_origin[0], r_origin[1], &r_origin[0], &r_origin[1]); +} + +/** + * Custom handler for manipulator widgets + */ +static int manipulator2d_modal( + bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), + eWM_ManipulatorTweak UNUSED(tweak_flag)) +{ + ARegion *ar = CTX_wm_region(C); + float origin[3]; + + manipulator2d_calc_bounds(C, origin, NULL, NULL); + manipulator2d_origin_to_region(ar, origin); + WM_manipulator_set_matrix_location(widget, origin); + + ED_region_tag_redraw(ar); + + return OPERATOR_RUNNING_MODAL; +} + +void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + wmOperatorType *ot_translate = WM_operatortype_find("TRANSFORM_OT_translate", true); + ManipulatorGroup2D *man = manipulatorgroup2d_init(mgroup); + mgroup->customdata = man; + + MAN2D_ITER_AXES_BEGIN(axis, axis_idx) + { + const float offset[3] = {0.0f, 0.2f}; + + float color[4], color_hi[4]; + manipulator2d_get_axis_color(axis_idx, color, color_hi); + + /* custom handler! */ + WM_manipulator_set_fn_custom_modal(axis, manipulator2d_modal); + /* set up widget data */ + RNA_float_set(axis->ptr, "angle", -M_PI_2 * axis_idx); + RNA_float_set(axis->ptr, "length", 0.8f); + WM_manipulator_set_matrix_offset_location(axis, offset); + WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); + WM_manipulator_set_scale(axis, U.manipulator_size); + WM_manipulator_set_color(axis, color); + WM_manipulator_set_color_highlight(axis, color_hi); + + /* assign operator */ + PointerRNA *ptr = WM_manipulator_operator_set(axis, 0, ot_translate, NULL); + bool constraint[3] = {0}; + constraint[(axis_idx + 1) % 2] = 1; + if (RNA_struct_find_property(ptr, "constraint_axis")) + RNA_boolean_set_array(ptr, "constraint_axis", constraint); + RNA_boolean_set(ptr, "release_confirm", 1); + } + MAN2D_ITER_AXES_END; + + { + wmOperatorType *ot_resize = WM_operatortype_find("TRANSFORM_OT_resize", true); + wmOperatorType *ot_rotate = WM_operatortype_find("TRANSFORM_OT_rotate", true); + PointerRNA *ptr; + + /* assign operator */ + ptr = WM_manipulator_operator_set(man->cage, 0, ot_translate, NULL); + RNA_boolean_set(ptr, "release_confirm", 1); + + bool constraint_x[3] = {1, 0, 0}; + bool constraint_y[3] = {0, 1, 0}; + + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL); + PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); + PropertyRNA *prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); + RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL); + RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL); + RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL); + RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE, ot_rotate, NULL); + RNA_property_boolean_set(ptr, prop_release_confirm, true); + } +} + +void ED_widgetgroup_manipulator2d_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + ManipulatorGroup2D *man = mgroup->customdata; + float origin[3]; + manipulator2d_calc_bounds(C, origin, man->min, man->max); + copy_v2_v2(man->origin, origin); + bool show_cage = !equals_v2v2(man->min, man->max); + + if (show_cage) { + man->cage->flag &= ~WM_MANIPULATOR_HIDDEN; + man->translate_x->flag |= WM_MANIPULATOR_HIDDEN; + man->translate_y->flag |= WM_MANIPULATOR_HIDDEN; + } + else { + man->cage->flag |= WM_MANIPULATOR_HIDDEN; + man->translate_x->flag &= ~WM_MANIPULATOR_HIDDEN; + man->translate_y->flag &= ~WM_MANIPULATOR_HIDDEN; + } + + if (show_cage) { + wmManipulatorOpElem *mpop; + float mid[2]; + const float *min = man->min; + const float *max = man->max; + mid_v2_v2v2(mid, min, max); + + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X); + PropertyRNA *prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], mid[1], 0.0f}); + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], mid[1], 0.0f}); + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], max[1], 0.0f}); + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], min[1], 0.0f}); + + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], max[1], 0.0f}); + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], min[1], 0.0f}); + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], max[1], 0.0f}); + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], min[1], 0.0f}); + + mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], mid[1], 0.0f}); + } +} + +void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + ARegion *ar = CTX_wm_region(C); + ManipulatorGroup2D *man = mgroup->customdata; + float origin[3] = {UNPACK2(man->origin), 0.0f}; + float origin_aa[3] = {UNPACK2(man->origin), 0.0f}; + + manipulator2d_origin_to_region(ar, origin); + + MAN2D_ITER_AXES_BEGIN(axis, axis_idx) + { + WM_manipulator_set_matrix_location(axis, origin); + } + MAN2D_ITER_AXES_END; + + UI_view2d_view_to_region_m4(&ar->v2d, man->cage->matrix_space); + WM_manipulator_set_matrix_offset_location(man->cage, origin_aa); + man->cage->matrix_offset[0][0] = (man->max[0] - man->min[0]); + man->cage->matrix_offset[1][1] = (man->max[1] - man->min[1]); +} + +/* TODO (Julian) + * - Called on every redraw, better to do a more simple poll and check for selection in _refresh + * - UV editing only, could be expanded for other things. + */ +bool ED_widgetgroup_manipulator2d_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +{ + if ((U.manipulator_flag & USER_MANIPULATOR_DRAW) == 0) { + return false; + } + + SpaceImage *sima = CTX_wm_space_image(C); + Object *obedit = CTX_data_edit_object(C); + + if (ED_space_image_show_uvedit(sima, obedit)) { + Image *ima = ED_space_image(sima); + Scene *scene = CTX_data_scene(C); + BMEditMesh *em = BKE_editmesh_from_object(obedit); + BMFace *efa; + BMLoop *l; + BMIter iter, liter; + + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + + /* check if there's a selected poly */ + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + if (!uvedit_face_visible_test(scene, obedit, ima, efa)) + continue; + + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { + return true; + } + } + } + } + + return false; +} diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c new file mode 100644 index 00000000000..1a30bd1cdcb --- /dev/null +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -0,0 +1,1790 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/transform/transform_gizmo_3d.c + * \ingroup edtransform + * + * \name 3D Transform Manipulator + * + * Used for 3D View + */ + +#include +#include +#include +#include + +#include "DNA_armature_types.h" +#include "DNA_curve_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_lattice_types.h" +#include "DNA_meta_types.h" +#include "DNA_screen_types.h" +#include "DNA_scene_types.h" +#include "DNA_view3d_types.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "RNA_access.h" + +#include "BKE_action.h" +#include "BKE_context.h" +#include "BKE_curve.h" +#include "BKE_global.h" +#include "BKE_particle.h" +#include "BKE_pointcache.h" +#include "BKE_editmesh.h" +#include "BKE_lattice.h" +#include "BKE_gpencil.h" +#include "BKE_scene.h" +#include "BKE_workspace.h" + +#include "BIF_gl.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_types.h" +#include "WM_message.h" +#include "WM_toolsystem.h" + +#include "ED_armature.h" +#include "ED_curve.h" +#include "ED_object.h" +#include "ED_particle.h" +#include "ED_view3d.h" +#include "ED_gpencil.h" +#include "ED_screen.h" +#include "ED_gizmo_library.h" + +#include "UI_resources.h" + +/* local module include */ +#include "transform.h" + +#include "MEM_guardedalloc.h" + +#include "GPU_select.h" +#include "GPU_immediate.h" +#include "GPU_matrix.h" + +#include "DEG_depsgraph_query.h" + +/* return codes for select, and drawing flags */ + +#define MAN_TRANS_X (1 << 0) +#define MAN_TRANS_Y (1 << 1) +#define MAN_TRANS_Z (1 << 2) +#define MAN_TRANS_C (MAN_TRANS_X | MAN_TRANS_Y | MAN_TRANS_Z) + +#define MAN_ROT_X (1 << 3) +#define MAN_ROT_Y (1 << 4) +#define MAN_ROT_Z (1 << 5) +#define MAN_ROT_C (MAN_ROT_X | MAN_ROT_Y | MAN_ROT_Z) + +#define MAN_SCALE_X (1 << 8) +#define MAN_SCALE_Y (1 << 9) +#define MAN_SCALE_Z (1 << 10) +#define MAN_SCALE_C (MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z) + +/* threshold for testing view aligned manipulator axis */ +struct { + float min, max; +} g_tw_axis_range[2] = { + /* Regular range */ + {0.02f, 0.1f}, + /* Use a different range because we flip the dot product, + * also the view aligned planes are harder to see so hiding early is preferred. */ + {0.175f, 0.25f}, +}; + +/* axes as index */ +enum { + MAN_AXIS_TRANS_X = 0, + MAN_AXIS_TRANS_Y, + MAN_AXIS_TRANS_Z, + MAN_AXIS_TRANS_C, + + MAN_AXIS_TRANS_XY, + MAN_AXIS_TRANS_YZ, + MAN_AXIS_TRANS_ZX, +#define MAN_AXIS_RANGE_TRANS_START MAN_AXIS_TRANS_X +#define MAN_AXIS_RANGE_TRANS_END (MAN_AXIS_TRANS_ZX + 1) + + MAN_AXIS_ROT_X, + MAN_AXIS_ROT_Y, + MAN_AXIS_ROT_Z, + MAN_AXIS_ROT_C, + MAN_AXIS_ROT_T, /* trackball rotation */ +#define MAN_AXIS_RANGE_ROT_START MAN_AXIS_ROT_X +#define MAN_AXIS_RANGE_ROT_END (MAN_AXIS_ROT_T + 1) + + MAN_AXIS_SCALE_X, + MAN_AXIS_SCALE_Y, + MAN_AXIS_SCALE_Z, + MAN_AXIS_SCALE_C, + MAN_AXIS_SCALE_XY, + MAN_AXIS_SCALE_YZ, + MAN_AXIS_SCALE_ZX, +#define MAN_AXIS_RANGE_SCALE_START MAN_AXIS_SCALE_X +#define MAN_AXIS_RANGE_SCALE_END (MAN_AXIS_SCALE_ZX + 1) + + MAN_AXIS_LAST = MAN_AXIS_RANGE_SCALE_END, +}; + +/* axis types */ +enum { + MAN_AXES_ALL = 0, + MAN_AXES_TRANSLATE, + MAN_AXES_ROTATE, + MAN_AXES_SCALE, +}; + +typedef struct ManipulatorGroup { + bool all_hidden; + int twtype; + + /* Users may change the twtype, detect changes to re-setup manipulator options. */ + int twtype_init; + int twtype_prev; + int use_twtype_refresh; + + struct wmManipulator *manipulators[MAN_AXIS_LAST]; +} ManipulatorGroup; + +/* -------------------------------------------------------------------- */ +/** \name Utilities + * \{ */ + +/* loop over axes */ +#define MAN_ITER_AXES_BEGIN(axis, axis_idx) \ + { \ + wmManipulator *axis; \ + int axis_idx; \ + for (axis_idx = 0; axis_idx < MAN_AXIS_LAST; axis_idx++) { \ + axis = manipulator_get_axis_from_index(man, axis_idx); + +#define MAN_ITER_AXES_END \ + } \ + } ((void)0) + +static wmManipulator *manipulator_get_axis_from_index(const ManipulatorGroup *man, const short axis_idx) +{ + BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN_AXIS_TRANS_X, (float)MAN_AXIS_LAST)); + return man->manipulators[axis_idx]; +} + +static short manipulator_get_axis_type(const int axis_idx) +{ + if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { + return MAN_AXES_TRANSLATE; + } + if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) { + return MAN_AXES_ROTATE; + } + if (axis_idx >= MAN_AXIS_RANGE_SCALE_START && axis_idx < MAN_AXIS_RANGE_SCALE_END) { + return MAN_AXES_SCALE; + } + BLI_assert(0); + return -1; +} + +static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane) +{ + switch (axis_idx) { + case MAN_AXIS_TRANS_YZ: + case MAN_AXIS_SCALE_YZ: + if (r_is_plane) { + *r_is_plane = true; + } + ATTR_FALLTHROUGH; + case MAN_AXIS_TRANS_X: + case MAN_AXIS_ROT_X: + case MAN_AXIS_SCALE_X: + return 0; + + case MAN_AXIS_TRANS_ZX: + case MAN_AXIS_SCALE_ZX: + if (r_is_plane) { + *r_is_plane = true; + } + ATTR_FALLTHROUGH; + case MAN_AXIS_TRANS_Y: + case MAN_AXIS_ROT_Y: + case MAN_AXIS_SCALE_Y: + return 1; + + case MAN_AXIS_TRANS_XY: + case MAN_AXIS_SCALE_XY: + if (r_is_plane) { + *r_is_plane = true; + } + ATTR_FALLTHROUGH; + case MAN_AXIS_TRANS_Z: + case MAN_AXIS_ROT_Z: + case MAN_AXIS_SCALE_Z: + return 2; + } + return 3; +} + +static bool manipulator_is_axis_visible( + const RegionView3D *rv3d, const int twtype, + const float idot[3], const int axis_type, const int axis_idx) +{ + if ((axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) == 0) { + bool is_plane = false; + const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane); + /* don't draw axis perpendicular to the view */ + if (aidx_norm < 3) { + float idot_axis = idot[aidx_norm]; + if (is_plane) { + idot_axis = 1.0f - idot_axis; + } + if (idot_axis < g_tw_axis_range[is_plane].min) { + return false; + } + } + } + + if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & SCE_MANIP_TRANSLATE)) || + (axis_type == MAN_AXES_ROTATE && !(twtype & SCE_MANIP_ROTATE)) || + (axis_type == MAN_AXES_SCALE && !(twtype & SCE_MANIP_SCALE))) + { + return false; + } + + switch (axis_idx) { + case MAN_AXIS_TRANS_X: + return (rv3d->twdrawflag & MAN_TRANS_X); + case MAN_AXIS_TRANS_Y: + return (rv3d->twdrawflag & MAN_TRANS_Y); + case MAN_AXIS_TRANS_Z: + return (rv3d->twdrawflag & MAN_TRANS_Z); + case MAN_AXIS_TRANS_C: + return (rv3d->twdrawflag & MAN_TRANS_C); + case MAN_AXIS_ROT_X: + return (rv3d->twdrawflag & MAN_ROT_X); + case MAN_AXIS_ROT_Y: + return (rv3d->twdrawflag & MAN_ROT_Y); + case MAN_AXIS_ROT_Z: + return (rv3d->twdrawflag & MAN_ROT_Z); + case MAN_AXIS_ROT_C: + case MAN_AXIS_ROT_T: + return (rv3d->twdrawflag & MAN_ROT_C); + case MAN_AXIS_SCALE_X: + return (rv3d->twdrawflag & MAN_SCALE_X); + case MAN_AXIS_SCALE_Y: + return (rv3d->twdrawflag & MAN_SCALE_Y); + case MAN_AXIS_SCALE_Z: + return (rv3d->twdrawflag & MAN_SCALE_Z); + case MAN_AXIS_SCALE_C: + return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & SCE_MANIP_TRANSLATE) == 0); + case MAN_AXIS_TRANS_XY: + return (rv3d->twdrawflag & MAN_TRANS_X && + rv3d->twdrawflag & MAN_TRANS_Y && + (twtype & SCE_MANIP_ROTATE) == 0); + case MAN_AXIS_TRANS_YZ: + return (rv3d->twdrawflag & MAN_TRANS_Y && + rv3d->twdrawflag & MAN_TRANS_Z && + (twtype & SCE_MANIP_ROTATE) == 0); + case MAN_AXIS_TRANS_ZX: + return (rv3d->twdrawflag & MAN_TRANS_Z && + rv3d->twdrawflag & MAN_TRANS_X && + (twtype & SCE_MANIP_ROTATE) == 0); + case MAN_AXIS_SCALE_XY: + return (rv3d->twdrawflag & MAN_SCALE_X && + rv3d->twdrawflag & MAN_SCALE_Y && + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); + case MAN_AXIS_SCALE_YZ: + return (rv3d->twdrawflag & MAN_SCALE_Y && + rv3d->twdrawflag & MAN_SCALE_Z && + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); + case MAN_AXIS_SCALE_ZX: + return (rv3d->twdrawflag & MAN_SCALE_Z && + rv3d->twdrawflag & MAN_SCALE_X && + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); + } + return false; +} + +static void manipulator_get_axis_color( + const int axis_idx, const float idot[3], + float r_col[4], float r_col_hi[4]) +{ + /* alpha values for normal/highlighted states */ + const float alpha = 0.6f; + const float alpha_hi = 1.0f; + float alpha_fac; + + if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) { + /* Never fade rotation rings. */ + /* trackball rotation axis is a special case, we only draw a slight overlay */ + alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.1f : 1.0f; + } + else { + bool is_plane = false; + const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane); + /* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */ + if (axis_idx_norm < 3) { + const float idot_min = g_tw_axis_range[is_plane].min; + const float idot_max = g_tw_axis_range[is_plane].max; + float idot_axis = idot[axis_idx_norm]; + if (is_plane) { + idot_axis = 1.0f - idot_axis; + } + alpha_fac = ( + (idot_axis > idot_max) ? + 1.0f : (idot_axis < idot_min) ? + 0.0f : ((idot_axis - idot_min) / (idot_max - idot_min))); + } + else { + alpha_fac = 1.0f; + } + } + + switch (axis_idx) { + case MAN_AXIS_TRANS_X: + case MAN_AXIS_ROT_X: + case MAN_AXIS_SCALE_X: + case MAN_AXIS_TRANS_YZ: + case MAN_AXIS_SCALE_YZ: + UI_GetThemeColor4fv(TH_AXIS_X, r_col); + break; + case MAN_AXIS_TRANS_Y: + case MAN_AXIS_ROT_Y: + case MAN_AXIS_SCALE_Y: + case MAN_AXIS_TRANS_ZX: + case MAN_AXIS_SCALE_ZX: + UI_GetThemeColor4fv(TH_AXIS_Y, r_col); + break; + case MAN_AXIS_TRANS_Z: + case MAN_AXIS_ROT_Z: + case MAN_AXIS_SCALE_Z: + case MAN_AXIS_TRANS_XY: + case MAN_AXIS_SCALE_XY: + UI_GetThemeColor4fv(TH_AXIS_Z, r_col); + break; + case MAN_AXIS_TRANS_C: + case MAN_AXIS_ROT_C: + case MAN_AXIS_SCALE_C: + case MAN_AXIS_ROT_T: + copy_v4_fl(r_col, 1.0f); + break; + } + + copy_v4_v4(r_col_hi, r_col); + + r_col[3] = alpha * alpha_fac; + r_col_hi[3] = alpha_hi * alpha_fac; +} + +static void manipulator_get_axis_constraint(const int axis_idx, bool r_axis[3]) +{ + ARRAY_SET_ITEMS(r_axis, 0, 0, 0); + + switch (axis_idx) { + case MAN_AXIS_TRANS_X: + case MAN_AXIS_ROT_X: + case MAN_AXIS_SCALE_X: + r_axis[0] = 1; + break; + case MAN_AXIS_TRANS_Y: + case MAN_AXIS_ROT_Y: + case MAN_AXIS_SCALE_Y: + r_axis[1] = 1; + break; + case MAN_AXIS_TRANS_Z: + case MAN_AXIS_ROT_Z: + case MAN_AXIS_SCALE_Z: + r_axis[2] = 1; + break; + case MAN_AXIS_TRANS_XY: + case MAN_AXIS_SCALE_XY: + r_axis[0] = r_axis[1] = 1; + break; + case MAN_AXIS_TRANS_YZ: + case MAN_AXIS_SCALE_YZ: + r_axis[1] = r_axis[2] = 1; + break; + case MAN_AXIS_TRANS_ZX: + case MAN_AXIS_SCALE_ZX: + r_axis[2] = r_axis[0] = 1; + break; + default: + break; + } +} + + +/* **************** Preparation Stuff **************** */ + +/* transform widget center calc helper for below */ +static void calc_tw_center(struct TransformBounds *tbounds, const float co[3]) +{ + minmax_v3v3_v3(tbounds->min, tbounds->max, co); + add_v3_v3(tbounds->center, co); + + for (int i = 0; i < 3; i++) { + const float d = dot_v3v3(tbounds->axis[i], co); + tbounds->axis_min[i] = min_ff(d, tbounds->axis_min[i]); + tbounds->axis_max[i] = max_ff(d, tbounds->axis_max[i]); + } +} + +static void protectflag_to_drawflags(short protectflag, short *drawflags) +{ + if (protectflag & OB_LOCK_LOCX) + *drawflags &= ~MAN_TRANS_X; + if (protectflag & OB_LOCK_LOCY) + *drawflags &= ~MAN_TRANS_Y; + if (protectflag & OB_LOCK_LOCZ) + *drawflags &= ~MAN_TRANS_Z; + + if (protectflag & OB_LOCK_ROTX) + *drawflags &= ~MAN_ROT_X; + if (protectflag & OB_LOCK_ROTY) + *drawflags &= ~MAN_ROT_Y; + if (protectflag & OB_LOCK_ROTZ) + *drawflags &= ~MAN_ROT_Z; + + if (protectflag & OB_LOCK_SCALEX) + *drawflags &= ~MAN_SCALE_X; + if (protectflag & OB_LOCK_SCALEY) + *drawflags &= ~MAN_SCALE_Y; + if (protectflag & OB_LOCK_SCALEZ) + *drawflags &= ~MAN_SCALE_Z; +} + +/* for pose mode */ +static void protectflag_to_drawflags_pchan(RegionView3D *rv3d, const bPoseChannel *pchan) +{ + protectflag_to_drawflags(pchan->protectflag, &rv3d->twdrawflag); +} + +/* for editmode*/ +static void protectflag_to_drawflags_ebone(RegionView3D *rv3d, const EditBone *ebo) +{ + if (ebo->flag & BONE_EDITMODE_LOCKED) { + protectflag_to_drawflags(OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE, &rv3d->twdrawflag); + } +} + +/* could move into BLI_math however this is only useful for display/editing purposes */ +static void axis_angle_to_gimbal_axis(float gmat[3][3], const float axis[3], const float angle) +{ + /* X/Y are arbitrary axies, most importantly Z is the axis of rotation */ + + float cross_vec[3]; + float quat[4]; + + /* this is an un-scientific method to get a vector to cross with + * XYZ intentionally YZX */ + cross_vec[0] = axis[1]; + cross_vec[1] = axis[2]; + cross_vec[2] = axis[0]; + + /* X-axis */ + cross_v3_v3v3(gmat[0], cross_vec, axis); + normalize_v3(gmat[0]); + axis_angle_to_quat(quat, axis, angle); + mul_qt_v3(quat, gmat[0]); + + /* Y-axis */ + axis_angle_to_quat(quat, axis, M_PI_2); + copy_v3_v3(gmat[1], gmat[0]); + mul_qt_v3(quat, gmat[1]); + + /* Z-axis */ + copy_v3_v3(gmat[2], axis); + + normalize_m3(gmat); +} + + +static bool test_rotmode_euler(short rotmode) +{ + return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1; +} + +bool gimbal_axis(Object *ob, float gmat[3][3]) +{ + if (ob->mode & OB_MODE_POSE) { + bPoseChannel *pchan = BKE_pose_channel_active(ob); + + if (pchan) { + float mat[3][3], tmat[3][3], obmat[3][3]; + if (test_rotmode_euler(pchan->rotmode)) { + eulO_to_gimbal_axis(mat, pchan->eul, pchan->rotmode); + } + else if (pchan->rotmode == ROT_MODE_AXISANGLE) { + axis_angle_to_gimbal_axis(mat, pchan->rotAxis, pchan->rotAngle); + } + else { /* quat */ + return 0; + } + + + /* apply bone transformation */ + mul_m3_m3m3(tmat, pchan->bone->bone_mat, mat); + + if (pchan->parent) { + float parent_mat[3][3]; + + copy_m3_m4(parent_mat, pchan->parent->pose_mat); + mul_m3_m3m3(mat, parent_mat, tmat); + + /* needed if object transformation isn't identity */ + copy_m3_m4(obmat, ob->obmat); + mul_m3_m3m3(gmat, obmat, mat); + } + else { + /* needed if object transformation isn't identity */ + copy_m3_m4(obmat, ob->obmat); + mul_m3_m3m3(gmat, obmat, tmat); + } + + normalize_m3(gmat); + return 1; + } + } + else { + if (test_rotmode_euler(ob->rotmode)) { + eulO_to_gimbal_axis(gmat, ob->rot, ob->rotmode); + } + else if (ob->rotmode == ROT_MODE_AXISANGLE) { + axis_angle_to_gimbal_axis(gmat, ob->rotAxis, ob->rotAngle); + } + else { /* quat */ + return 0; + } + + if (ob->parent) { + float parent_mat[3][3]; + copy_m3_m4(parent_mat, ob->parent->obmat); + normalize_m3(parent_mat); + mul_m3_m3m3(gmat, parent_mat, gmat); + } + return 1; + } + + return 0; +} + + +/* centroid, boundbox, of selection */ +/* returns total items selected */ +int ED_transform_calc_manipulator_stats( + const bContext *C, + const struct TransformCalcParams *params, + struct TransformBounds *tbounds) +{ + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *obedit = CTX_data_edit_object(C); + View3D *v3d = sa->spacedata.first; + RegionView3D *rv3d = ar->regiondata; + Base *base; + Object *ob = OBACT(view_layer); + bGPdata *gpd = CTX_data_gpencil_data(C); + const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); + int a, totsel = 0; + const int pivot_point = scene->toolsettings->transform_pivot_point; + + /* transform widget matrix */ + unit_m4(rv3d->twmat); + + unit_m3(rv3d->tw_axis_matrix); + zero_v3(rv3d->tw_axis_min); + zero_v3(rv3d->tw_axis_max); + + rv3d->twdrawflag = 0xFFFF; + + /* global, local or normal orientation? + * if we could check 'totsel' now, this should be skipped with no selection. */ + if (ob && !is_gp_edit) { + const short orientation_type = params->orientation_type ? (params->orientation_type - 1) : scene->orientation_type; + + switch (orientation_type) { + + case V3D_MANIP_GLOBAL: + { + break; /* nothing to do */ + } + case V3D_MANIP_GIMBAL: + { + float mat[3][3]; + if (gimbal_axis(ob, mat)) { + copy_m4_m3(rv3d->twmat, mat); + break; + } + /* if not gimbal, fall through to normal */ + ATTR_FALLTHROUGH; + } + case V3D_MANIP_NORMAL: + { + if (obedit || ob->mode & OB_MODE_POSE) { + float mat[3][3]; + ED_getTransformOrientationMatrix(C, mat, pivot_point); + copy_m4_m3(rv3d->twmat, mat); + break; + } + /* no break we define 'normal' as 'local' in Object mode */ + ATTR_FALLTHROUGH; + } + case V3D_MANIP_LOCAL: + { + if (ob->mode & OB_MODE_POSE) { + /* each bone moves on its own local axis, but to avoid confusion, + * use the active pones axis for display [#33575], this works as expected on a single bone + * and users who select many bones will understand whats going on and what local means + * when they start transforming */ + float mat[3][3]; + ED_getTransformOrientationMatrix(C, mat, pivot_point); + copy_m4_m3(rv3d->twmat, mat); + break; + } + copy_m4_m4(rv3d->twmat, ob->obmat); + normalize_m4(rv3d->twmat); + break; + } + case V3D_MANIP_VIEW: + { + float mat[3][3]; + copy_m3_m4(mat, rv3d->viewinv); + normalize_m3(mat); + copy_m4_m3(rv3d->twmat, mat); + break; + } + case V3D_MANIP_CURSOR: + { + float mat[3][3]; + ED_view3d_cursor3d_calc_mat3(scene, v3d, mat); + copy_m4_m3(rv3d->twmat, mat); + break; + } + case V3D_MANIP_CUSTOM: + { + TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find( + scene, scene->orientation_index_custom); + float mat[3][3]; + + if (applyTransformOrientation(custom_orientation, mat, NULL)) { + copy_m4_m3(rv3d->twmat, mat); + } + break; + } + } + } + + /* transform widget centroid/center */ + INIT_MINMAX(tbounds->min, tbounds->max); + zero_v3(tbounds->center); + + copy_m3_m4(tbounds->axis, rv3d->twmat); + if (params->use_local_axis && (ob && ob->mode & OB_MODE_EDIT)) { + float diff_mat[3][3]; + copy_m3_m4(diff_mat, ob->obmat); + normalize_m3(diff_mat); + invert_m3(diff_mat); + mul_m3_m3m3(tbounds->axis, tbounds->axis, diff_mat); + normalize_m3(tbounds->axis); + } + + for (int i = 0; i < 3; i++) { + tbounds->axis_min[i] = +FLT_MAX; + tbounds->axis_max[i] = -FLT_MAX; + } + + if (is_gp_edit) { + float diff_mat[4][4]; + float fpt[3]; + + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + /* only editable and visible layers are considered */ + if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { + + /* calculate difference matrix if parent object */ + if (gpl->parent != NULL) { + ED_gpencil_parent_location(gpl, diff_mat); + } + + for (bGPDstroke *gps = gpl->actframe->strokes.first; gps; gps = gps->next) { + /* skip strokes that are invalid for current view */ + if (ED_gpencil_stroke_can_use(C, gps) == false) { + continue; + } + + /* we're only interested in selected points here... */ + if (gps->flag & GP_STROKE_SELECT) { + bGPDspoint *pt; + int i; + + /* Change selection status of all points, then make the stroke match */ + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + if (pt->flag & GP_SPOINT_SELECT) { + if (gpl->parent == NULL) { + calc_tw_center(tbounds, &pt->x); + totsel++; + } + else { + mul_v3_m4v3(fpt, diff_mat, &pt->x); + calc_tw_center(tbounds, fpt); + totsel++; + } + } + } + } + } + } + } + + + /* selection center */ + if (totsel) { + mul_v3_fl(tbounds->center, 1.0f / (float)totsel); /* centroid! */ + } + } + else if (obedit) { + ob = obedit; + if (obedit->type == OB_MESH) { + BMEditMesh *em = BKE_editmesh_from_object(obedit); + BMEditSelection ese; + float vec[3] = {0, 0, 0}; + + /* USE LAST SELECTE WITH ACTIVE */ + if ((pivot_point == V3D_AROUND_ACTIVE) && BM_select_history_active_get(em->bm, &ese)) { + BM_editselection_center(&ese, vec); + calc_tw_center(tbounds, vec); + totsel = 1; + } + else { + BMesh *bm = em->bm; + BMVert *eve; + + BMIter iter; + + BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + totsel++; + calc_tw_center(tbounds, eve->co); + } + } + } + } + } /* end editmesh */ + else if (obedit->type == OB_ARMATURE) { + bArmature *arm = obedit->data; + EditBone *ebo; + + if ((pivot_point == V3D_AROUND_ACTIVE) && (ebo = arm->act_edbone)) { + /* doesn't check selection or visibility intentionally */ + if (ebo->flag & BONE_TIPSEL) { + calc_tw_center(tbounds, ebo->tail); + totsel++; + } + if ((ebo->flag & BONE_ROOTSEL) || + ((ebo->flag & BONE_TIPSEL) == false)) /* ensure we get at least one point */ + { + calc_tw_center(tbounds, ebo->head); + totsel++; + } + protectflag_to_drawflags_ebone(rv3d, ebo); + } + else { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { + if (EBONE_VISIBLE(arm, ebo)) { + if (ebo->flag & BONE_TIPSEL) { + calc_tw_center(tbounds, ebo->tail); + totsel++; + } + if ((ebo->flag & BONE_ROOTSEL) && + /* don't include same point multiple times */ + ((ebo->flag & BONE_CONNECTED) && + (ebo->parent != NULL) && + (ebo->parent->flag & BONE_TIPSEL) && + EBONE_VISIBLE(arm, ebo->parent)) == 0) + { + calc_tw_center(tbounds, ebo->head); + totsel++; + } + if (ebo->flag & BONE_SELECTED) { + protectflag_to_drawflags_ebone(rv3d, ebo); + } + } + } + } + } + else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { + Curve *cu = obedit->data; + float center[3]; + + if ((pivot_point == V3D_AROUND_ACTIVE) && ED_curve_active_center(cu, center)) { + calc_tw_center(tbounds, center); + totsel++; + } + else { + Nurb *nu; + BezTriple *bezt; + BPoint *bp; + ListBase *nurbs = BKE_curve_editNurbs_get(cu); + + nu = nurbs->first; + while (nu) { + if (nu->type == CU_BEZIER) { + bezt = nu->bezt; + a = nu->pntsu; + while (a--) { + /* exceptions + * if handles are hidden then only check the center points. + * If the center knot is selected then only use this as the center point. + */ + if (cu->drawflag & CU_HIDE_HANDLES) { + if (bezt->f2 & SELECT) { + calc_tw_center(tbounds, bezt->vec[1]); + totsel++; + } + } + else if (bezt->f2 & SELECT) { + calc_tw_center(tbounds, bezt->vec[1]); + totsel++; + } + else { + if (bezt->f1 & SELECT) { + calc_tw_center( + tbounds, bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]); + totsel++; + } + if (bezt->f3 & SELECT) { + calc_tw_center( + tbounds, bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]); + totsel++; + } + } + bezt++; + } + } + else { + bp = nu->bp; + a = nu->pntsu * nu->pntsv; + while (a--) { + if (bp->f1 & SELECT) { + calc_tw_center(tbounds, bp->vec); + totsel++; + } + bp++; + } + } + nu = nu->next; + } + } + } + else if (obedit->type == OB_MBALL) { + MetaBall *mb = (MetaBall *)obedit->data; + MetaElem *ml; + + if ((pivot_point == V3D_AROUND_ACTIVE) && (ml = mb->lastelem)) { + calc_tw_center(tbounds, &ml->x); + totsel++; + } + else { + for (ml = mb->editelems->first; ml; ml = ml->next) { + if (ml->flag & SELECT) { + calc_tw_center(tbounds, &ml->x); + totsel++; + } + } + } + } + else if (obedit->type == OB_LATTICE) { + Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; + BPoint *bp; + + if ((pivot_point == V3D_AROUND_ACTIVE) && (bp = BKE_lattice_active_point_get(lt))) { + calc_tw_center(tbounds, bp->vec); + totsel++; + } + else { + bp = lt->def; + a = lt->pntsu * lt->pntsv * lt->pntsw; + while (a--) { + if (bp->f1 & SELECT) { + calc_tw_center(tbounds, bp->vec); + totsel++; + } + bp++; + } + } + } + + /* selection center */ + if (totsel) { + mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! + mul_m4_v3(obedit->obmat, tbounds->center); + mul_m4_v3(obedit->obmat, tbounds->min); + mul_m4_v3(obedit->obmat, tbounds->max); + } + } + else if (ob && (ob->mode & OB_MODE_POSE)) { + bPoseChannel *pchan; + int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed + bool ok = false; + + if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) { + /* doesn't check selection or visibility intentionally */ + Bone *bone = pchan->bone; + if (bone) { + calc_tw_center(tbounds, pchan->pose_head); + protectflag_to_drawflags_pchan(rv3d, pchan); + totsel = 1; + ok = true; + } + } + else { + totsel = count_set_pose_transflags(ob, mode, V3D_AROUND_CENTER_BOUNDS, NULL); + + if (totsel) { + /* use channels to get stats */ + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + Bone *bone = pchan->bone; + if (bone && (bone->flag & BONE_TRANSFORM)) { + calc_tw_center(tbounds, pchan->pose_head); + protectflag_to_drawflags_pchan(rv3d, pchan); + } + } + ok = true; + } + } + + if (ok) { + mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! + mul_m4_v3(ob->obmat, tbounds->center); + mul_m4_v3(ob->obmat, tbounds->min); + mul_m4_v3(ob->obmat, tbounds->max); + } + } + else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { + /* pass */ + } + else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { + PTCacheEdit *edit = PE_get_current(scene, ob); + PTCacheEditPoint *point; + PTCacheEditKey *ek; + int k; + + if (edit) { + point = edit->points; + for (a = 0; a < edit->totpoint; a++, point++) { + if (point->flag & PEP_HIDE) continue; + + for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) { + if (ek->flag & PEK_SELECT) { + calc_tw_center(tbounds, (ek->flag & PEK_USE_WCO) ? ek->world_co : ek->co); + totsel++; + } + } + } + + /* selection center */ + if (totsel) + mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! + } + } + else { + + /* we need the one selected object, if its not active */ + base = BASACT(view_layer); + ob = OBACT(view_layer); + if (base && ((base->flag & BASE_SELECTED) == 0)) ob = NULL; + + for (base = view_layer->object_bases.first; base; base = base->next) { + if (!TESTBASELIB(base)) { + continue; + } + if (ob == NULL) { + ob = base->object; + } + if (params->use_only_center || base->object->bb == NULL) { + calc_tw_center(tbounds, base->object->obmat[3]); + } + else { + for (uint j = 0; j < 8; j++) { + float co[3]; + mul_v3_m4v3(co, base->object->obmat, base->object->bb->vec[j]); + calc_tw_center(tbounds, co); + } + } + protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag); + totsel++; + } + + /* selection center */ + if (totsel) { + mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! + } + } + + if (totsel == 0) { + unit_m4(rv3d->twmat); + } + else { + copy_v3_v3(rv3d->tw_axis_min, tbounds->axis_min); + copy_v3_v3(rv3d->tw_axis_max, tbounds->axis_max); + copy_m3_m3(rv3d->tw_axis_matrix, tbounds->axis); + } + + return totsel; +} + +static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3]) +{ + float view_vec[3], axis_vec[3]; + ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], view_vec); + for (int i = 0; i < 3; i++) { + normalize_v3_v3(axis_vec, rv3d->twmat[i]); + r_idot[i] = 1.0f - fabsf(dot_v3v3(view_vec, axis_vec)); + } +} + +static void manipulator_prepare_mat( + const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds) +{ + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + + switch (scene->toolsettings->transform_pivot_point) { + case V3D_AROUND_CENTER_BOUNDS: + case V3D_AROUND_ACTIVE: + { + bGPdata *gpd = CTX_data_gpencil_data(C); + Object *ob = OBACT(view_layer); + + if (((scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) && + (OBEDIT_FROM_OBACT(ob) == NULL)) && + ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) && + (!(ob->mode & OB_MODE_POSE))) + { + copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); + } + else { + mid_v3_v3v3(rv3d->twmat[3], tbounds->min, tbounds->max); + } + break; + } + case V3D_AROUND_LOCAL_ORIGINS: + case V3D_AROUND_CENTER_MEAN: + copy_v3_v3(rv3d->twmat[3], tbounds->center); + break; + case V3D_AROUND_CURSOR: + copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)->location); + break; + } +} + +/** + * Sets up \a r_start and \a r_len to define arrow line range. + * Needed to adjust line drawing for combined manipulator axis types. + */ +static void manipulator_line_range(const int twtype, const short axis_type, float *r_start, float *r_len) +{ + const float ofs = 0.2f; + + *r_start = 0.2f; + *r_len = 1.0f; + + switch (axis_type) { + case MAN_AXES_TRANSLATE: + if (twtype & SCE_MANIP_SCALE) { + *r_start = *r_len - ofs + 0.075f; + } + if (twtype & SCE_MANIP_ROTATE) { + *r_len += ofs; + } + break; + case MAN_AXES_SCALE: + if (twtype & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE)) { + *r_len -= ofs + 0.025f; + } + break; + } + + *r_len -= *r_start; +} + +static void manipulator_xform_message_subscribe( + wmManipulatorGroup *mgroup, struct wmMsgBus *mbus, + Scene *scene, bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar, const void *type_fn) +{ + /* Subscribe to view properties */ + wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { + .owner = ar, + .user_data = mgroup->parent_mmap, + .notify = WM_manipulator_do_msg_notify_tag_refresh, + }; + + PointerRNA scene_ptr; + RNA_id_pointer_create(&scene->id, &scene_ptr); + + { + extern PropertyRNA rna_Scene_transform_orientation; + extern PropertyRNA rna_Scene_cursor_location; + const PropertyRNA *props[] = { + &rna_Scene_transform_orientation, + (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) ? &rna_Scene_cursor_location : NULL, + }; + for (int i = 0; i < ARRAY_SIZE(props); i++) { + if (props[i]) { + WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); + } + } + } + + PointerRNA toolsettings_ptr; + RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr); + + if (type_fn == TRANSFORM_WGT_manipulator) { + extern PropertyRNA rna_ToolSettings_transform_pivot_point; + extern PropertyRNA rna_ToolSettings_use_manipulator_mode; + const PropertyRNA *props[] = { + &rna_ToolSettings_transform_pivot_point, + &rna_ToolSettings_use_manipulator_mode, + }; + for (int i = 0; i < ARRAY_SIZE(props); i++) { + WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); + } + } + else if (type_fn == VIEW3D_WGT_xform_cage) { + /* pass */ + } + else { + BLI_assert(0); + } + + WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_mpr_tag_refresh); +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ +/** \name Transform Manipulator + * \{ */ + +static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) +{ + ManipulatorGroup *man; + + man = MEM_callocN(sizeof(ManipulatorGroup), "manipulator_data"); + + const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); + const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); + const wmManipulatorType *wt_prim = WM_manipulatortype_find("MANIPULATOR_WT_primitive_3d", true); + +#define MANIPULATOR_NEW_ARROW(v, draw_style) { \ + man->manipulators[v] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); \ + RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \ +} ((void)0) +#define MANIPULATOR_NEW_DIAL(v, draw_options) { \ + man->manipulators[v] = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); \ + RNA_enum_set(man->manipulators[v]->ptr, "draw_options", draw_options); \ +} ((void)0) +#define MANIPULATOR_NEW_PRIM(v, draw_style) { \ + man->manipulators[v] = WM_manipulator_new_ptr(wt_prim, mgroup, NULL); \ + RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \ +} ((void)0) + + /* add/init widgets - order matters! */ + MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_T, ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL); + + MANIPULATOR_NEW_DIAL(MAN_AXIS_SCALE_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + + MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_X, ED_MANIPULATOR_ARROW_STYLE_BOX); + MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_MANIPULATOR_ARROW_STYLE_BOX); + MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_MANIPULATOR_ARROW_STYLE_BOX); + + MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + + MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_X, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); + MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Y, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); + MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Z, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); + + /* init screen aligned widget last here, looks better, behaves better */ + MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + + MANIPULATOR_NEW_DIAL(MAN_AXIS_TRANS_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + + MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_X, ED_MANIPULATOR_ARROW_STYLE_NORMAL); + MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_MANIPULATOR_ARROW_STYLE_NORMAL); + MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_MANIPULATOR_ARROW_STYLE_NORMAL); + + MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + + man->manipulators[MAN_AXIS_ROT_T]->flag |= WM_MANIPULATOR_SELECT_BACKGROUND; + + return man; +} + +/** + * Custom handler for manipulator widgets + */ +static int manipulator_modal( + bContext *C, wmManipulator *widget, const wmEvent *event, + eWM_ManipulatorTweak UNUSED(tweak_flag)) +{ + /* Avoid unnecessary updates, partially address: T55458. */ + if (ELEM(event->type, TIMER, INBETWEEN_MOUSEMOVE)) { + return OPERATOR_RUNNING_MODAL; + } + + const ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + View3D *v3d = sa->spacedata.first; + RegionView3D *rv3d = ar->regiondata; + struct TransformBounds tbounds; + + + if (ED_transform_calc_manipulator_stats( + C, &(struct TransformCalcParams){ + .use_only_center = true, + }, &tbounds)) + { + manipulator_prepare_mat(C, v3d, rv3d, &tbounds); + WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]); + } + + ED_region_tag_redraw(ar); + + return OPERATOR_RUNNING_MODAL; +} + +static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgroup) +{ + struct { + wmOperatorType *translate, *rotate, *trackball, *resize; + } ot_store = {NULL}; + ManipulatorGroup *man = mgroup->customdata; + MAN_ITER_AXES_BEGIN(axis, axis_idx) + { + const short axis_type = manipulator_get_axis_type(axis_idx); + bool constraint_axis[3] = {1, 0, 0}; + PointerRNA *ptr; + + manipulator_get_axis_constraint(axis_idx, constraint_axis); + + /* custom handler! */ + WM_manipulator_set_fn_custom_modal(axis, manipulator_modal); + + switch (axis_idx) { + case MAN_AXIS_TRANS_X: + case MAN_AXIS_TRANS_Y: + case MAN_AXIS_TRANS_Z: + case MAN_AXIS_SCALE_X: + case MAN_AXIS_SCALE_Y: + case MAN_AXIS_SCALE_Z: + if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { + int draw_options = 0; + if ((man->twtype & (SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { + draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM; + } + RNA_enum_set(axis->ptr, "draw_options", draw_options); + } + + WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); + break; + case MAN_AXIS_ROT_X: + case MAN_AXIS_ROT_Y: + case MAN_AXIS_ROT_Z: + /* increased line width for better display */ + WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH + 1.0f); + WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); + break; + case MAN_AXIS_TRANS_XY: + case MAN_AXIS_TRANS_YZ: + case MAN_AXIS_TRANS_ZX: + case MAN_AXIS_SCALE_XY: + case MAN_AXIS_SCALE_YZ: + case MAN_AXIS_SCALE_ZX: + { + const float ofs_ax = 7.0f; + const float ofs[3] = {ofs_ax, ofs_ax, 0.0f}; + WM_manipulator_set_scale(axis, 0.07f); + WM_manipulator_set_matrix_offset_location(axis, ofs); + WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); + break; + } + case MAN_AXIS_TRANS_C: + case MAN_AXIS_ROT_C: + case MAN_AXIS_SCALE_C: + case MAN_AXIS_ROT_T: + WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); + if (axis_idx == MAN_AXIS_ROT_T) { + WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_HOVER, true); + } + else if (axis_idx == MAN_AXIS_ROT_C) { + WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); + WM_manipulator_set_scale(axis, 1.2f); + } + else { + WM_manipulator_set_scale(axis, 0.2f); + } + break; + } + + switch (axis_type) { + case MAN_AXES_TRANSLATE: + if (ot_store.translate == NULL) { + ot_store.translate = WM_operatortype_find("TRANSFORM_OT_translate", true); + } + ptr = WM_manipulator_operator_set(axis, 0, ot_store.translate, NULL); + break; + case MAN_AXES_ROTATE: + { + wmOperatorType *ot_rotate; + if (axis_idx == MAN_AXIS_ROT_T) { + if (ot_store.trackball == NULL) { + ot_store.trackball = WM_operatortype_find("TRANSFORM_OT_trackball", true); + } + ot_rotate = ot_store.trackball; + } + else { + if (ot_store.rotate == NULL) { + ot_store.rotate = WM_operatortype_find("TRANSFORM_OT_rotate", true); + } + ot_rotate = ot_store.rotate; + } + ptr = WM_manipulator_operator_set(axis, 0, ot_rotate, NULL); + break; + } + case MAN_AXES_SCALE: + { + if (ot_store.resize == NULL) { + ot_store.resize = WM_operatortype_find("TRANSFORM_OT_resize", true); + } + ptr = WM_manipulator_operator_set(axis, 0, ot_store.resize, NULL); + break; + } + } + + { + PropertyRNA *prop; + if ((prop = RNA_struct_find_property(ptr, "constraint_axis"))) { + RNA_property_boolean_set_array(ptr, prop, constraint_axis); + } + } + + RNA_boolean_set(ptr, "release_confirm", 1); + } + MAN_ITER_AXES_END; +} + +static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) +{ + ManipulatorGroup *man = manipulatorgroup_init(mgroup); + + mgroup->customdata = man; + + { + man->twtype = 0; + ScrArea *sa = CTX_wm_area(C); + const bToolRef *tref = sa->runtime.tool; + + if (tref == NULL || STREQ(tref->idname, "Transform")) { + /* Setup all manipulators, they can be toggled via 'ToolSettings.manipulator_flag' */ + man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; + man->use_twtype_refresh = true; + } + else if (STREQ(tref->idname, "Grab")) { + man->twtype |= SCE_MANIP_TRANSLATE; + } + else if (STREQ(tref->idname, "Rotate")) { + man->twtype |= SCE_MANIP_ROTATE; + } + else if (STREQ(tref->idname, "Scale")) { + man->twtype |= SCE_MANIP_SCALE; + } + BLI_assert(man->twtype != 0); + man->twtype_init = man->twtype; + } + + /* *** set properties for axes *** */ + manipulatorgroup_init_properties_from_twtype(mgroup); +} + +static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + ManipulatorGroup *man = mgroup->customdata; + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + View3D *v3d = sa->spacedata.first; + RegionView3D *rv3d = ar->regiondata; + struct TransformBounds tbounds; + + if (man->use_twtype_refresh) { + Scene *scene = CTX_data_scene(C); + man->twtype = scene->toolsettings->manipulator_flag & man->twtype_init; + if (man->twtype != man->twtype_prev) { + man->twtype_prev = man->twtype; + manipulatorgroup_init_properties_from_twtype(mgroup); + } + } + + /* skip, we don't draw anything anyway */ + if ((man->all_hidden = + (ED_transform_calc_manipulator_stats( + C, &(struct TransformCalcParams){ + .use_only_center = true, + }, &tbounds) == 0))) + { + return; + } + + manipulator_prepare_mat(C, v3d, rv3d, &tbounds); + + /* *** set properties for axes *** */ + + MAN_ITER_AXES_BEGIN(axis, axis_idx) + { + const short axis_type = manipulator_get_axis_type(axis_idx); + const int aidx_norm = manipulator_orientation_axis(axis_idx, NULL); + + WM_manipulator_set_matrix_location(axis, rv3d->twmat[3]); + + switch (axis_idx) { + case MAN_AXIS_TRANS_X: + case MAN_AXIS_TRANS_Y: + case MAN_AXIS_TRANS_Z: + case MAN_AXIS_SCALE_X: + case MAN_AXIS_SCALE_Y: + case MAN_AXIS_SCALE_Z: + { + float start_co[3] = {0.0f, 0.0f, 0.0f}; + float len; + + manipulator_line_range(man->twtype, axis_type, &start_co[2], &len); + + WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); + RNA_float_set(axis->ptr, "length", len); + + if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { + if (man->twtype & SCE_MANIP_ROTATE) { + /* Avoid rotate and translate arrows overlap. */ + start_co[2] += 0.215f; + } + } + WM_manipulator_set_matrix_offset_location(axis, start_co); + WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); + break; + } + case MAN_AXIS_ROT_X: + case MAN_AXIS_ROT_Y: + case MAN_AXIS_ROT_Z: + WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); + break; + case MAN_AXIS_TRANS_XY: + case MAN_AXIS_TRANS_YZ: + case MAN_AXIS_TRANS_ZX: + case MAN_AXIS_SCALE_XY: + case MAN_AXIS_SCALE_YZ: + case MAN_AXIS_SCALE_ZX: + { + const float *y_axis = rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1]; + const float *z_axis = rv3d->twmat[aidx_norm]; + WM_manipulator_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis); + break; + } + } + } + MAN_ITER_AXES_END; +} + +static void WIDGETGROUP_manipulator_message_subscribe( + const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) +{ + Scene *scene = CTX_data_scene(C); + bScreen *screen = CTX_wm_screen(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, TRANSFORM_WGT_manipulator); +} + +static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + ManipulatorGroup *man = mgroup->customdata; + // ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + // View3D *v3d = sa->spacedata.first; + RegionView3D *rv3d = ar->regiondata; + float idot[3]; + + /* when looking through a selected camera, the manipulator can be at the + * exact same position as the view, skip so we don't break selection */ + if (man->all_hidden || fabsf(ED_view3d_pixel_size(rv3d, rv3d->twmat[3])) < 1e-6f) { + MAN_ITER_AXES_BEGIN(axis, axis_idx) + { + WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true); + } + MAN_ITER_AXES_END; + return; + } + manipulator_get_idot(rv3d, idot); + + /* *** set properties for axes *** */ + + MAN_ITER_AXES_BEGIN(axis, axis_idx) + { + const short axis_type = manipulator_get_axis_type(axis_idx); + /* XXX maybe unset _HIDDEN flag on redraw? */ + if (manipulator_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) { + WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, false); + } + else { + WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true); + continue; + } + + float color[4], color_hi[4]; + manipulator_get_axis_color(axis_idx, idot, color, color_hi); + WM_manipulator_set_color(axis, color); + WM_manipulator_set_color_highlight(axis, color_hi); + + switch (axis_idx) { + case MAN_AXIS_TRANS_C: + case MAN_AXIS_ROT_C: + case MAN_AXIS_SCALE_C: + case MAN_AXIS_ROT_T: + WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]); + break; + } + } + MAN_ITER_AXES_END; +} + +static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt) +{ + /* it's a given we only use this in 3D view */ + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); + if ((tref_rt == NULL) || + !STREQ(wgt->idname, tref_rt->manipulator_group)) + { + WM_manipulator_group_type_unlink_delayed_ptr(wgt); + return false; + } + + View3D *v3d = CTX_wm_view3d(C); + if (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_TOOL)) { + return false; + } + return true; +} + +void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt) +{ + wgt->name = "Transform Manipulator"; + wgt->idname = "TRANSFORM_WGT_manipulator"; + + wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; + + wgt->mmap_params.spaceid = SPACE_VIEW3D; + wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + + wgt->poll = WIDGETGROUP_manipulator_poll; + wgt->setup = WIDGETGROUP_manipulator_setup; + wgt->refresh = WIDGETGROUP_manipulator_refresh; + wgt->message_subscribe = WIDGETGROUP_manipulator_message_subscribe; + wgt->draw_prepare = WIDGETGROUP_manipulator_draw_prepare; +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ +/** \name Scale Cage Manipulator + * \{ */ + +struct XFormCageWidgetGroup { + wmManipulator *manipulator; +}; + +static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupType *wgt) +{ + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); + if (!STREQ(wgt->idname, tref_rt->manipulator_group)) { + WM_manipulator_group_type_unlink_delayed_ptr(wgt); + return false; + } + return true; +} + +static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +{ + struct XFormCageWidgetGroup *xmgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__); + const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true); + xmgroup->manipulator = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); + wmManipulator *mpr = xmgroup->manipulator; + + RNA_enum_set(mpr->ptr, "transform", + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | + ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE); + + mpr->color[0] = 1; + mpr->color_hi[0] = 1; + + mgroup->customdata = xmgroup; + + { + wmOperatorType *ot_resize = WM_operatortype_find("TRANSFORM_OT_resize", true); + PointerRNA *ptr; + + /* assign operator */ + PropertyRNA *prop_release_confirm = NULL; + PropertyRNA *prop_constraint_axis = NULL; + + int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + for (int z = 0; z < 3; z++) { + bool constraint[3] = {x != 1, y != 1, z != 1}; + ptr = WM_manipulator_operator_set(mpr, i, ot_resize, NULL); + if (prop_release_confirm == NULL) { + prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); + prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); + } + RNA_property_boolean_set(ptr, prop_release_confirm, true); + RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint); + i++; + } + } + } + } +} + +static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup *mgroup) +{ + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = sa->spacedata.first; + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + + struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; + wmManipulator *mpr = xmgroup->manipulator; + + struct TransformBounds tbounds; + + if ((ED_transform_calc_manipulator_stats( + C, &(struct TransformCalcParams) { + .use_local_axis = true, + }, &tbounds) == 0) || + equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max)) + { + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + } + else { + manipulator_prepare_mat(C, v3d, rv3d, &tbounds); + + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + WM_manipulator_set_flag(mpr, WM_MANIPULATOR_GRAB_CURSOR, true); + + float dims[3]; + sub_v3_v3v3(dims, rv3d->tw_axis_max, rv3d->tw_axis_min); + RNA_float_set_array(mpr->ptr, "dimensions", dims); + mul_v3_fl(dims, 0.5f); + + copy_m4_m3(mpr->matrix_offset, rv3d->tw_axis_matrix); + mid_v3_v3v3(mpr->matrix_offset[3], rv3d->tw_axis_max, rv3d->tw_axis_min); + mul_m3_v3(rv3d->tw_axis_matrix, mpr->matrix_offset[3]); + + PropertyRNA *prop_center_override = NULL; + float center[3]; + float center_global[3]; + int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; + for (int x = 0; x < 3; x++) { + center[0] = (float)(1 - x) * dims[0]; + for (int y = 0; y < 3; y++) { + center[1] = (float)(1 - y) * dims[1]; + for (int z = 0; z < 3; z++) { + center[2] = (float)(1 - z) * dims[2]; + struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, i); + if (prop_center_override == NULL) { + prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); + } + mul_v3_m4v3(center_global, mpr->matrix_offset, center); + RNA_property_float_set_array(&mpop->ptr, prop_center_override, center_global); + i++; + } + } + } + } +} + +static void WIDGETGROUP_xform_cage_message_subscribe( + const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) +{ + Scene *scene = CTX_data_scene(C); + bScreen *screen = CTX_wm_screen(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, VIEW3D_WGT_xform_cage); +} + +static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +{ + struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; + wmManipulator *mpr = xmgroup->manipulator; + + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + if (ob && ob->mode & OB_MODE_EDIT) { + copy_m4_m4(mpr->matrix_space, ob->obmat); + } + else { + unit_m4(mpr->matrix_space); + } +} + +void VIEW3D_WGT_xform_cage(wmManipulatorGroupType *wgt) +{ + wgt->name = "Transform Cage"; + wgt->idname = "VIEW3D_WGT_xform_cage"; + + wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; + + wgt->mmap_params.spaceid = SPACE_VIEW3D; + wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + + wgt->poll = WIDGETGROUP_xform_cage_poll; + wgt->setup = WIDGETGROUP_xform_cage_setup; + wgt->refresh = WIDGETGROUP_xform_cage_refresh; + wgt->message_subscribe = WIDGETGROUP_xform_cage_message_subscribe; + wgt->draw_prepare = WIDGETGROUP_xform_cage_draw_prepare; +} + +/** \} */ diff --git a/source/blender/editors/transform/transform_manipulator_2d.c b/source/blender/editors/transform/transform_manipulator_2d.c deleted file mode 100644 index fd6e7ed5442..00000000000 --- a/source/blender/editors/transform/transform_manipulator_2d.c +++ /dev/null @@ -1,382 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/transform/transform_manipulator_2d.c - * \ingroup edtransform - * - * \name 2D Transform Manipulator - * - * Used for UV/Image Editor - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_listbase.h" -#include "BLI_math.h" - -#include "DNA_meshdata_types.h" -#include "DNA_object_types.h" -#include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "DNA_view3d_types.h" - -#include "BKE_context.h" -#include "BKE_editmesh.h" - -#include "RNA_access.h" - -#include "UI_resources.h" -#include "UI_view2d.h" - -#include "WM_api.h" -#include "WM_types.h" -#include "wm.h" /* XXX */ - -#include "ED_image.h" -#include "ED_screen.h" -#include "ED_uvedit.h" -#include "ED_manipulator_library.h" - -#include "transform.h" /* own include */ - -/* axes as index */ -enum { - MAN2D_AXIS_TRANS_X = 0, - MAN2D_AXIS_TRANS_Y, - - MAN2D_AXIS_LAST, -}; - -typedef struct ManipulatorGroup2D { - wmManipulator *translate_x, - *translate_y; - - wmManipulator *cage; - - /* Current origin in view space, used to update widget origin for possible view changes */ - float origin[2]; - float min[2]; - float max[2]; - -} ManipulatorGroup2D; - - -/* **************** Utilities **************** */ - -/* loop over axes */ -#define MAN2D_ITER_AXES_BEGIN(axis, axis_idx) \ - { \ - wmManipulator *axis; \ - int axis_idx; \ - for (axis_idx = 0; axis_idx < MAN2D_AXIS_LAST; axis_idx++) { \ - axis = manipulator2d_get_axis_from_index(man, axis_idx); - -#define MAN2D_ITER_AXES_END \ - } \ - } ((void)0) - -static wmManipulator *manipulator2d_get_axis_from_index(const ManipulatorGroup2D *man, const short axis_idx) -{ - BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN2D_AXIS_TRANS_X, (float)MAN2D_AXIS_TRANS_Y)); - - switch (axis_idx) { - case MAN2D_AXIS_TRANS_X: - return man->translate_x; - case MAN2D_AXIS_TRANS_Y: - return man->translate_y; - } - - return NULL; -} - -static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float *r_col_hi) -{ - const float alpha = 0.6f; - const float alpha_hi = 1.0f; - int col_id; - - switch (axis_idx) { - case MAN2D_AXIS_TRANS_X: - col_id = TH_AXIS_X; - break; - case MAN2D_AXIS_TRANS_Y: - col_id = TH_AXIS_Y; - break; - } - - UI_GetThemeColor4fv(col_id, r_col); - - copy_v4_v4(r_col_hi, r_col); - r_col[3] *= alpha; - r_col_hi[3] *= alpha_hi; -} - -static ManipulatorGroup2D *manipulatorgroup2d_init(wmManipulatorGroup *mgroup) -{ - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_2d", true); - const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_2d", true); - - ManipulatorGroup2D *man = MEM_callocN(sizeof(ManipulatorGroup2D), __func__); - - man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); - - RNA_enum_set(man->cage->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE); - - return man; -} - -/** - * Calculates origin in view space, use with #manipulator2d_origin_to_region. - */ -static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max) -{ - SpaceImage *sima = CTX_wm_space_image(C); - Image *ima = ED_space_image(sima); - - float min_buf[2], max_buf[2]; - if (r_min == NULL) { - r_min = min_buf; - } - if (r_max == NULL) { - r_max = max_buf; - } - - if (!ED_uvedit_minmax(CTX_data_scene(C), ima, CTX_data_edit_object(C), r_min, r_max)) { - zero_v2(r_min); - zero_v2(r_max); - } - mid_v2_v2v2(r_center, r_min, r_max); -} - -/** - * Convert origin (or any other point) from view to region space. - */ -BLI_INLINE void manipulator2d_origin_to_region(ARegion *ar, float *r_origin) -{ - UI_view2d_view_to_region_fl(&ar->v2d, r_origin[0], r_origin[1], &r_origin[0], &r_origin[1]); -} - -/** - * Custom handler for manipulator widgets - */ -static int manipulator2d_modal( - bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), - eWM_ManipulatorTweak UNUSED(tweak_flag)) -{ - ARegion *ar = CTX_wm_region(C); - float origin[3]; - - manipulator2d_calc_bounds(C, origin, NULL, NULL); - manipulator2d_origin_to_region(ar, origin); - WM_manipulator_set_matrix_location(widget, origin); - - ED_region_tag_redraw(ar); - - return OPERATOR_RUNNING_MODAL; -} - -void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - wmOperatorType *ot_translate = WM_operatortype_find("TRANSFORM_OT_translate", true); - ManipulatorGroup2D *man = manipulatorgroup2d_init(mgroup); - mgroup->customdata = man; - - MAN2D_ITER_AXES_BEGIN(axis, axis_idx) - { - const float offset[3] = {0.0f, 0.2f}; - - float color[4], color_hi[4]; - manipulator2d_get_axis_color(axis_idx, color, color_hi); - - /* custom handler! */ - WM_manipulator_set_fn_custom_modal(axis, manipulator2d_modal); - /* set up widget data */ - RNA_float_set(axis->ptr, "angle", -M_PI_2 * axis_idx); - RNA_float_set(axis->ptr, "length", 0.8f); - WM_manipulator_set_matrix_offset_location(axis, offset); - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); - WM_manipulator_set_scale(axis, U.manipulator_size); - WM_manipulator_set_color(axis, color); - WM_manipulator_set_color_highlight(axis, color_hi); - - /* assign operator */ - PointerRNA *ptr = WM_manipulator_operator_set(axis, 0, ot_translate, NULL); - bool constraint[3] = {0}; - constraint[(axis_idx + 1) % 2] = 1; - if (RNA_struct_find_property(ptr, "constraint_axis")) - RNA_boolean_set_array(ptr, "constraint_axis", constraint); - RNA_boolean_set(ptr, "release_confirm", 1); - } - MAN2D_ITER_AXES_END; - - { - wmOperatorType *ot_resize = WM_operatortype_find("TRANSFORM_OT_resize", true); - wmOperatorType *ot_rotate = WM_operatortype_find("TRANSFORM_OT_rotate", true); - PointerRNA *ptr; - - /* assign operator */ - ptr = WM_manipulator_operator_set(man->cage, 0, ot_translate, NULL); - RNA_boolean_set(ptr, "release_confirm", 1); - - bool constraint_x[3] = {1, 0, 0}; - bool constraint_y[3] = {0, 1, 0}; - - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL); - PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); - PropertyRNA *prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); - RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL); - RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL); - RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL); - RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE, ot_rotate, NULL); - RNA_property_boolean_set(ptr, prop_release_confirm, true); - } -} - -void ED_widgetgroup_manipulator2d_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - ManipulatorGroup2D *man = mgroup->customdata; - float origin[3]; - manipulator2d_calc_bounds(C, origin, man->min, man->max); - copy_v2_v2(man->origin, origin); - bool show_cage = !equals_v2v2(man->min, man->max); - - if (show_cage) { - man->cage->flag &= ~WM_MANIPULATOR_HIDDEN; - man->translate_x->flag |= WM_MANIPULATOR_HIDDEN; - man->translate_y->flag |= WM_MANIPULATOR_HIDDEN; - } - else { - man->cage->flag |= WM_MANIPULATOR_HIDDEN; - man->translate_x->flag &= ~WM_MANIPULATOR_HIDDEN; - man->translate_y->flag &= ~WM_MANIPULATOR_HIDDEN; - } - - if (show_cage) { - wmManipulatorOpElem *mpop; - float mid[2]; - const float *min = man->min; - const float *max = man->max; - mid_v2_v2v2(mid, min, max); - - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X); - PropertyRNA *prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], mid[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], mid[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], min[1], 0.0f}); - - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], min[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], min[1], 0.0f}); - - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], mid[1], 0.0f}); - } -} - -void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - ARegion *ar = CTX_wm_region(C); - ManipulatorGroup2D *man = mgroup->customdata; - float origin[3] = {UNPACK2(man->origin), 0.0f}; - float origin_aa[3] = {UNPACK2(man->origin), 0.0f}; - - manipulator2d_origin_to_region(ar, origin); - - MAN2D_ITER_AXES_BEGIN(axis, axis_idx) - { - WM_manipulator_set_matrix_location(axis, origin); - } - MAN2D_ITER_AXES_END; - - UI_view2d_view_to_region_m4(&ar->v2d, man->cage->matrix_space); - WM_manipulator_set_matrix_offset_location(man->cage, origin_aa); - man->cage->matrix_offset[0][0] = (man->max[0] - man->min[0]); - man->cage->matrix_offset[1][1] = (man->max[1] - man->min[1]); -} - -/* TODO (Julian) - * - Called on every redraw, better to do a more simple poll and check for selection in _refresh - * - UV editing only, could be expanded for other things. - */ -bool ED_widgetgroup_manipulator2d_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) -{ - if ((U.manipulator_flag & USER_MANIPULATOR_DRAW) == 0) { - return false; - } - - SpaceImage *sima = CTX_wm_space_image(C); - Object *obedit = CTX_data_edit_object(C); - - if (ED_space_image_show_uvedit(sima, obedit)) { - Image *ima = ED_space_image(sima); - Scene *scene = CTX_data_scene(C); - BMEditMesh *em = BKE_editmesh_from_object(obedit); - BMFace *efa; - BMLoop *l; - BMIter iter, liter; - - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - - /* check if there's a selected poly */ - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (!uvedit_face_visible_test(scene, obedit, ima, efa)) - continue; - - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { - return true; - } - } - } - } - - return false; -} diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c deleted file mode 100644 index 7dc72ddff6f..00000000000 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ /dev/null @@ -1,1790 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/transform/transform_manipulator_3d.c - * \ingroup edtransform - * - * \name 3D Transform Manipulator - * - * Used for 3D View - */ - -#include -#include -#include -#include - -#include "DNA_armature_types.h" -#include "DNA_curve_types.h" -#include "DNA_gpencil_types.h" -#include "DNA_lattice_types.h" -#include "DNA_meta_types.h" -#include "DNA_screen_types.h" -#include "DNA_scene_types.h" -#include "DNA_view3d_types.h" - -#include "BLI_listbase.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "RNA_access.h" - -#include "BKE_action.h" -#include "BKE_context.h" -#include "BKE_curve.h" -#include "BKE_global.h" -#include "BKE_particle.h" -#include "BKE_pointcache.h" -#include "BKE_editmesh.h" -#include "BKE_lattice.h" -#include "BKE_gpencil.h" -#include "BKE_scene.h" -#include "BKE_workspace.h" - -#include "BIF_gl.h" - -#include "DEG_depsgraph.h" - -#include "WM_api.h" -#include "WM_types.h" -#include "WM_message.h" -#include "WM_toolsystem.h" - -#include "ED_armature.h" -#include "ED_curve.h" -#include "ED_object.h" -#include "ED_particle.h" -#include "ED_view3d.h" -#include "ED_gpencil.h" -#include "ED_screen.h" -#include "ED_manipulator_library.h" - -#include "UI_resources.h" - -/* local module include */ -#include "transform.h" - -#include "MEM_guardedalloc.h" - -#include "GPU_select.h" -#include "GPU_immediate.h" -#include "GPU_matrix.h" - -#include "DEG_depsgraph_query.h" - -/* return codes for select, and drawing flags */ - -#define MAN_TRANS_X (1 << 0) -#define MAN_TRANS_Y (1 << 1) -#define MAN_TRANS_Z (1 << 2) -#define MAN_TRANS_C (MAN_TRANS_X | MAN_TRANS_Y | MAN_TRANS_Z) - -#define MAN_ROT_X (1 << 3) -#define MAN_ROT_Y (1 << 4) -#define MAN_ROT_Z (1 << 5) -#define MAN_ROT_C (MAN_ROT_X | MAN_ROT_Y | MAN_ROT_Z) - -#define MAN_SCALE_X (1 << 8) -#define MAN_SCALE_Y (1 << 9) -#define MAN_SCALE_Z (1 << 10) -#define MAN_SCALE_C (MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z) - -/* threshold for testing view aligned manipulator axis */ -struct { - float min, max; -} g_tw_axis_range[2] = { - /* Regular range */ - {0.02f, 0.1f}, - /* Use a different range because we flip the dot product, - * also the view aligned planes are harder to see so hiding early is preferred. */ - {0.175f, 0.25f}, -}; - -/* axes as index */ -enum { - MAN_AXIS_TRANS_X = 0, - MAN_AXIS_TRANS_Y, - MAN_AXIS_TRANS_Z, - MAN_AXIS_TRANS_C, - - MAN_AXIS_TRANS_XY, - MAN_AXIS_TRANS_YZ, - MAN_AXIS_TRANS_ZX, -#define MAN_AXIS_RANGE_TRANS_START MAN_AXIS_TRANS_X -#define MAN_AXIS_RANGE_TRANS_END (MAN_AXIS_TRANS_ZX + 1) - - MAN_AXIS_ROT_X, - MAN_AXIS_ROT_Y, - MAN_AXIS_ROT_Z, - MAN_AXIS_ROT_C, - MAN_AXIS_ROT_T, /* trackball rotation */ -#define MAN_AXIS_RANGE_ROT_START MAN_AXIS_ROT_X -#define MAN_AXIS_RANGE_ROT_END (MAN_AXIS_ROT_T + 1) - - MAN_AXIS_SCALE_X, - MAN_AXIS_SCALE_Y, - MAN_AXIS_SCALE_Z, - MAN_AXIS_SCALE_C, - MAN_AXIS_SCALE_XY, - MAN_AXIS_SCALE_YZ, - MAN_AXIS_SCALE_ZX, -#define MAN_AXIS_RANGE_SCALE_START MAN_AXIS_SCALE_X -#define MAN_AXIS_RANGE_SCALE_END (MAN_AXIS_SCALE_ZX + 1) - - MAN_AXIS_LAST = MAN_AXIS_RANGE_SCALE_END, -}; - -/* axis types */ -enum { - MAN_AXES_ALL = 0, - MAN_AXES_TRANSLATE, - MAN_AXES_ROTATE, - MAN_AXES_SCALE, -}; - -typedef struct ManipulatorGroup { - bool all_hidden; - int twtype; - - /* Users may change the twtype, detect changes to re-setup manipulator options. */ - int twtype_init; - int twtype_prev; - int use_twtype_refresh; - - struct wmManipulator *manipulators[MAN_AXIS_LAST]; -} ManipulatorGroup; - -/* -------------------------------------------------------------------- */ -/** \name Utilities - * \{ */ - -/* loop over axes */ -#define MAN_ITER_AXES_BEGIN(axis, axis_idx) \ - { \ - wmManipulator *axis; \ - int axis_idx; \ - for (axis_idx = 0; axis_idx < MAN_AXIS_LAST; axis_idx++) { \ - axis = manipulator_get_axis_from_index(man, axis_idx); - -#define MAN_ITER_AXES_END \ - } \ - } ((void)0) - -static wmManipulator *manipulator_get_axis_from_index(const ManipulatorGroup *man, const short axis_idx) -{ - BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN_AXIS_TRANS_X, (float)MAN_AXIS_LAST)); - return man->manipulators[axis_idx]; -} - -static short manipulator_get_axis_type(const int axis_idx) -{ - if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { - return MAN_AXES_TRANSLATE; - } - if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) { - return MAN_AXES_ROTATE; - } - if (axis_idx >= MAN_AXIS_RANGE_SCALE_START && axis_idx < MAN_AXIS_RANGE_SCALE_END) { - return MAN_AXES_SCALE; - } - BLI_assert(0); - return -1; -} - -static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane) -{ - switch (axis_idx) { - case MAN_AXIS_TRANS_YZ: - case MAN_AXIS_SCALE_YZ: - if (r_is_plane) { - *r_is_plane = true; - } - ATTR_FALLTHROUGH; - case MAN_AXIS_TRANS_X: - case MAN_AXIS_ROT_X: - case MAN_AXIS_SCALE_X: - return 0; - - case MAN_AXIS_TRANS_ZX: - case MAN_AXIS_SCALE_ZX: - if (r_is_plane) { - *r_is_plane = true; - } - ATTR_FALLTHROUGH; - case MAN_AXIS_TRANS_Y: - case MAN_AXIS_ROT_Y: - case MAN_AXIS_SCALE_Y: - return 1; - - case MAN_AXIS_TRANS_XY: - case MAN_AXIS_SCALE_XY: - if (r_is_plane) { - *r_is_plane = true; - } - ATTR_FALLTHROUGH; - case MAN_AXIS_TRANS_Z: - case MAN_AXIS_ROT_Z: - case MAN_AXIS_SCALE_Z: - return 2; - } - return 3; -} - -static bool manipulator_is_axis_visible( - const RegionView3D *rv3d, const int twtype, - const float idot[3], const int axis_type, const int axis_idx) -{ - if ((axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) == 0) { - bool is_plane = false; - const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane); - /* don't draw axis perpendicular to the view */ - if (aidx_norm < 3) { - float idot_axis = idot[aidx_norm]; - if (is_plane) { - idot_axis = 1.0f - idot_axis; - } - if (idot_axis < g_tw_axis_range[is_plane].min) { - return false; - } - } - } - - if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & SCE_MANIP_TRANSLATE)) || - (axis_type == MAN_AXES_ROTATE && !(twtype & SCE_MANIP_ROTATE)) || - (axis_type == MAN_AXES_SCALE && !(twtype & SCE_MANIP_SCALE))) - { - return false; - } - - switch (axis_idx) { - case MAN_AXIS_TRANS_X: - return (rv3d->twdrawflag & MAN_TRANS_X); - case MAN_AXIS_TRANS_Y: - return (rv3d->twdrawflag & MAN_TRANS_Y); - case MAN_AXIS_TRANS_Z: - return (rv3d->twdrawflag & MAN_TRANS_Z); - case MAN_AXIS_TRANS_C: - return (rv3d->twdrawflag & MAN_TRANS_C); - case MAN_AXIS_ROT_X: - return (rv3d->twdrawflag & MAN_ROT_X); - case MAN_AXIS_ROT_Y: - return (rv3d->twdrawflag & MAN_ROT_Y); - case MAN_AXIS_ROT_Z: - return (rv3d->twdrawflag & MAN_ROT_Z); - case MAN_AXIS_ROT_C: - case MAN_AXIS_ROT_T: - return (rv3d->twdrawflag & MAN_ROT_C); - case MAN_AXIS_SCALE_X: - return (rv3d->twdrawflag & MAN_SCALE_X); - case MAN_AXIS_SCALE_Y: - return (rv3d->twdrawflag & MAN_SCALE_Y); - case MAN_AXIS_SCALE_Z: - return (rv3d->twdrawflag & MAN_SCALE_Z); - case MAN_AXIS_SCALE_C: - return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & SCE_MANIP_TRANSLATE) == 0); - case MAN_AXIS_TRANS_XY: - return (rv3d->twdrawflag & MAN_TRANS_X && - rv3d->twdrawflag & MAN_TRANS_Y && - (twtype & SCE_MANIP_ROTATE) == 0); - case MAN_AXIS_TRANS_YZ: - return (rv3d->twdrawflag & MAN_TRANS_Y && - rv3d->twdrawflag & MAN_TRANS_Z && - (twtype & SCE_MANIP_ROTATE) == 0); - case MAN_AXIS_TRANS_ZX: - return (rv3d->twdrawflag & MAN_TRANS_Z && - rv3d->twdrawflag & MAN_TRANS_X && - (twtype & SCE_MANIP_ROTATE) == 0); - case MAN_AXIS_SCALE_XY: - return (rv3d->twdrawflag & MAN_SCALE_X && - rv3d->twdrawflag & MAN_SCALE_Y && - (twtype & SCE_MANIP_TRANSLATE) == 0 && - (twtype & SCE_MANIP_ROTATE) == 0); - case MAN_AXIS_SCALE_YZ: - return (rv3d->twdrawflag & MAN_SCALE_Y && - rv3d->twdrawflag & MAN_SCALE_Z && - (twtype & SCE_MANIP_TRANSLATE) == 0 && - (twtype & SCE_MANIP_ROTATE) == 0); - case MAN_AXIS_SCALE_ZX: - return (rv3d->twdrawflag & MAN_SCALE_Z && - rv3d->twdrawflag & MAN_SCALE_X && - (twtype & SCE_MANIP_TRANSLATE) == 0 && - (twtype & SCE_MANIP_ROTATE) == 0); - } - return false; -} - -static void manipulator_get_axis_color( - const int axis_idx, const float idot[3], - float r_col[4], float r_col_hi[4]) -{ - /* alpha values for normal/highlighted states */ - const float alpha = 0.6f; - const float alpha_hi = 1.0f; - float alpha_fac; - - if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) { - /* Never fade rotation rings. */ - /* trackball rotation axis is a special case, we only draw a slight overlay */ - alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.1f : 1.0f; - } - else { - bool is_plane = false; - const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane); - /* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */ - if (axis_idx_norm < 3) { - const float idot_min = g_tw_axis_range[is_plane].min; - const float idot_max = g_tw_axis_range[is_plane].max; - float idot_axis = idot[axis_idx_norm]; - if (is_plane) { - idot_axis = 1.0f - idot_axis; - } - alpha_fac = ( - (idot_axis > idot_max) ? - 1.0f : (idot_axis < idot_min) ? - 0.0f : ((idot_axis - idot_min) / (idot_max - idot_min))); - } - else { - alpha_fac = 1.0f; - } - } - - switch (axis_idx) { - case MAN_AXIS_TRANS_X: - case MAN_AXIS_ROT_X: - case MAN_AXIS_SCALE_X: - case MAN_AXIS_TRANS_YZ: - case MAN_AXIS_SCALE_YZ: - UI_GetThemeColor4fv(TH_AXIS_X, r_col); - break; - case MAN_AXIS_TRANS_Y: - case MAN_AXIS_ROT_Y: - case MAN_AXIS_SCALE_Y: - case MAN_AXIS_TRANS_ZX: - case MAN_AXIS_SCALE_ZX: - UI_GetThemeColor4fv(TH_AXIS_Y, r_col); - break; - case MAN_AXIS_TRANS_Z: - case MAN_AXIS_ROT_Z: - case MAN_AXIS_SCALE_Z: - case MAN_AXIS_TRANS_XY: - case MAN_AXIS_SCALE_XY: - UI_GetThemeColor4fv(TH_AXIS_Z, r_col); - break; - case MAN_AXIS_TRANS_C: - case MAN_AXIS_ROT_C: - case MAN_AXIS_SCALE_C: - case MAN_AXIS_ROT_T: - copy_v4_fl(r_col, 1.0f); - break; - } - - copy_v4_v4(r_col_hi, r_col); - - r_col[3] = alpha * alpha_fac; - r_col_hi[3] = alpha_hi * alpha_fac; -} - -static void manipulator_get_axis_constraint(const int axis_idx, bool r_axis[3]) -{ - ARRAY_SET_ITEMS(r_axis, 0, 0, 0); - - switch (axis_idx) { - case MAN_AXIS_TRANS_X: - case MAN_AXIS_ROT_X: - case MAN_AXIS_SCALE_X: - r_axis[0] = 1; - break; - case MAN_AXIS_TRANS_Y: - case MAN_AXIS_ROT_Y: - case MAN_AXIS_SCALE_Y: - r_axis[1] = 1; - break; - case MAN_AXIS_TRANS_Z: - case MAN_AXIS_ROT_Z: - case MAN_AXIS_SCALE_Z: - r_axis[2] = 1; - break; - case MAN_AXIS_TRANS_XY: - case MAN_AXIS_SCALE_XY: - r_axis[0] = r_axis[1] = 1; - break; - case MAN_AXIS_TRANS_YZ: - case MAN_AXIS_SCALE_YZ: - r_axis[1] = r_axis[2] = 1; - break; - case MAN_AXIS_TRANS_ZX: - case MAN_AXIS_SCALE_ZX: - r_axis[2] = r_axis[0] = 1; - break; - default: - break; - } -} - - -/* **************** Preparation Stuff **************** */ - -/* transform widget center calc helper for below */ -static void calc_tw_center(struct TransformBounds *tbounds, const float co[3]) -{ - minmax_v3v3_v3(tbounds->min, tbounds->max, co); - add_v3_v3(tbounds->center, co); - - for (int i = 0; i < 3; i++) { - const float d = dot_v3v3(tbounds->axis[i], co); - tbounds->axis_min[i] = min_ff(d, tbounds->axis_min[i]); - tbounds->axis_max[i] = max_ff(d, tbounds->axis_max[i]); - } -} - -static void protectflag_to_drawflags(short protectflag, short *drawflags) -{ - if (protectflag & OB_LOCK_LOCX) - *drawflags &= ~MAN_TRANS_X; - if (protectflag & OB_LOCK_LOCY) - *drawflags &= ~MAN_TRANS_Y; - if (protectflag & OB_LOCK_LOCZ) - *drawflags &= ~MAN_TRANS_Z; - - if (protectflag & OB_LOCK_ROTX) - *drawflags &= ~MAN_ROT_X; - if (protectflag & OB_LOCK_ROTY) - *drawflags &= ~MAN_ROT_Y; - if (protectflag & OB_LOCK_ROTZ) - *drawflags &= ~MAN_ROT_Z; - - if (protectflag & OB_LOCK_SCALEX) - *drawflags &= ~MAN_SCALE_X; - if (protectflag & OB_LOCK_SCALEY) - *drawflags &= ~MAN_SCALE_Y; - if (protectflag & OB_LOCK_SCALEZ) - *drawflags &= ~MAN_SCALE_Z; -} - -/* for pose mode */ -static void protectflag_to_drawflags_pchan(RegionView3D *rv3d, const bPoseChannel *pchan) -{ - protectflag_to_drawflags(pchan->protectflag, &rv3d->twdrawflag); -} - -/* for editmode*/ -static void protectflag_to_drawflags_ebone(RegionView3D *rv3d, const EditBone *ebo) -{ - if (ebo->flag & BONE_EDITMODE_LOCKED) { - protectflag_to_drawflags(OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE, &rv3d->twdrawflag); - } -} - -/* could move into BLI_math however this is only useful for display/editing purposes */ -static void axis_angle_to_gimbal_axis(float gmat[3][3], const float axis[3], const float angle) -{ - /* X/Y are arbitrary axies, most importantly Z is the axis of rotation */ - - float cross_vec[3]; - float quat[4]; - - /* this is an un-scientific method to get a vector to cross with - * XYZ intentionally YZX */ - cross_vec[0] = axis[1]; - cross_vec[1] = axis[2]; - cross_vec[2] = axis[0]; - - /* X-axis */ - cross_v3_v3v3(gmat[0], cross_vec, axis); - normalize_v3(gmat[0]); - axis_angle_to_quat(quat, axis, angle); - mul_qt_v3(quat, gmat[0]); - - /* Y-axis */ - axis_angle_to_quat(quat, axis, M_PI_2); - copy_v3_v3(gmat[1], gmat[0]); - mul_qt_v3(quat, gmat[1]); - - /* Z-axis */ - copy_v3_v3(gmat[2], axis); - - normalize_m3(gmat); -} - - -static bool test_rotmode_euler(short rotmode) -{ - return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1; -} - -bool gimbal_axis(Object *ob, float gmat[3][3]) -{ - if (ob->mode & OB_MODE_POSE) { - bPoseChannel *pchan = BKE_pose_channel_active(ob); - - if (pchan) { - float mat[3][3], tmat[3][3], obmat[3][3]; - if (test_rotmode_euler(pchan->rotmode)) { - eulO_to_gimbal_axis(mat, pchan->eul, pchan->rotmode); - } - else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - axis_angle_to_gimbal_axis(mat, pchan->rotAxis, pchan->rotAngle); - } - else { /* quat */ - return 0; - } - - - /* apply bone transformation */ - mul_m3_m3m3(tmat, pchan->bone->bone_mat, mat); - - if (pchan->parent) { - float parent_mat[3][3]; - - copy_m3_m4(parent_mat, pchan->parent->pose_mat); - mul_m3_m3m3(mat, parent_mat, tmat); - - /* needed if object transformation isn't identity */ - copy_m3_m4(obmat, ob->obmat); - mul_m3_m3m3(gmat, obmat, mat); - } - else { - /* needed if object transformation isn't identity */ - copy_m3_m4(obmat, ob->obmat); - mul_m3_m3m3(gmat, obmat, tmat); - } - - normalize_m3(gmat); - return 1; - } - } - else { - if (test_rotmode_euler(ob->rotmode)) { - eulO_to_gimbal_axis(gmat, ob->rot, ob->rotmode); - } - else if (ob->rotmode == ROT_MODE_AXISANGLE) { - axis_angle_to_gimbal_axis(gmat, ob->rotAxis, ob->rotAngle); - } - else { /* quat */ - return 0; - } - - if (ob->parent) { - float parent_mat[3][3]; - copy_m3_m4(parent_mat, ob->parent->obmat); - normalize_m3(parent_mat); - mul_m3_m3m3(gmat, parent_mat, gmat); - } - return 1; - } - - return 0; -} - - -/* centroid, boundbox, of selection */ -/* returns total items selected */ -int ED_transform_calc_manipulator_stats( - const bContext *C, - const struct TransformCalcParams *params, - struct TransformBounds *tbounds) -{ - ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - Object *obedit = CTX_data_edit_object(C); - View3D *v3d = sa->spacedata.first; - RegionView3D *rv3d = ar->regiondata; - Base *base; - Object *ob = OBACT(view_layer); - bGPdata *gpd = CTX_data_gpencil_data(C); - const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); - int a, totsel = 0; - const int pivot_point = scene->toolsettings->transform_pivot_point; - - /* transform widget matrix */ - unit_m4(rv3d->twmat); - - unit_m3(rv3d->tw_axis_matrix); - zero_v3(rv3d->tw_axis_min); - zero_v3(rv3d->tw_axis_max); - - rv3d->twdrawflag = 0xFFFF; - - /* global, local or normal orientation? - * if we could check 'totsel' now, this should be skipped with no selection. */ - if (ob && !is_gp_edit) { - const short orientation_type = params->orientation_type ? (params->orientation_type - 1) : scene->orientation_type; - - switch (orientation_type) { - - case V3D_MANIP_GLOBAL: - { - break; /* nothing to do */ - } - case V3D_MANIP_GIMBAL: - { - float mat[3][3]; - if (gimbal_axis(ob, mat)) { - copy_m4_m3(rv3d->twmat, mat); - break; - } - /* if not gimbal, fall through to normal */ - ATTR_FALLTHROUGH; - } - case V3D_MANIP_NORMAL: - { - if (obedit || ob->mode & OB_MODE_POSE) { - float mat[3][3]; - ED_getTransformOrientationMatrix(C, mat, pivot_point); - copy_m4_m3(rv3d->twmat, mat); - break; - } - /* no break we define 'normal' as 'local' in Object mode */ - ATTR_FALLTHROUGH; - } - case V3D_MANIP_LOCAL: - { - if (ob->mode & OB_MODE_POSE) { - /* each bone moves on its own local axis, but to avoid confusion, - * use the active pones axis for display [#33575], this works as expected on a single bone - * and users who select many bones will understand whats going on and what local means - * when they start transforming */ - float mat[3][3]; - ED_getTransformOrientationMatrix(C, mat, pivot_point); - copy_m4_m3(rv3d->twmat, mat); - break; - } - copy_m4_m4(rv3d->twmat, ob->obmat); - normalize_m4(rv3d->twmat); - break; - } - case V3D_MANIP_VIEW: - { - float mat[3][3]; - copy_m3_m4(mat, rv3d->viewinv); - normalize_m3(mat); - copy_m4_m3(rv3d->twmat, mat); - break; - } - case V3D_MANIP_CURSOR: - { - float mat[3][3]; - ED_view3d_cursor3d_calc_mat3(scene, v3d, mat); - copy_m4_m3(rv3d->twmat, mat); - break; - } - case V3D_MANIP_CUSTOM: - { - TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find( - scene, scene->orientation_index_custom); - float mat[3][3]; - - if (applyTransformOrientation(custom_orientation, mat, NULL)) { - copy_m4_m3(rv3d->twmat, mat); - } - break; - } - } - } - - /* transform widget centroid/center */ - INIT_MINMAX(tbounds->min, tbounds->max); - zero_v3(tbounds->center); - - copy_m3_m4(tbounds->axis, rv3d->twmat); - if (params->use_local_axis && (ob && ob->mode & OB_MODE_EDIT)) { - float diff_mat[3][3]; - copy_m3_m4(diff_mat, ob->obmat); - normalize_m3(diff_mat); - invert_m3(diff_mat); - mul_m3_m3m3(tbounds->axis, tbounds->axis, diff_mat); - normalize_m3(tbounds->axis); - } - - for (int i = 0; i < 3; i++) { - tbounds->axis_min[i] = +FLT_MAX; - tbounds->axis_max[i] = -FLT_MAX; - } - - if (is_gp_edit) { - float diff_mat[4][4]; - float fpt[3]; - - for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { - /* only editable and visible layers are considered */ - if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { - - /* calculate difference matrix if parent object */ - if (gpl->parent != NULL) { - ED_gpencil_parent_location(gpl, diff_mat); - } - - for (bGPDstroke *gps = gpl->actframe->strokes.first; gps; gps = gps->next) { - /* skip strokes that are invalid for current view */ - if (ED_gpencil_stroke_can_use(C, gps) == false) { - continue; - } - - /* we're only interested in selected points here... */ - if (gps->flag & GP_STROKE_SELECT) { - bGPDspoint *pt; - int i; - - /* Change selection status of all points, then make the stroke match */ - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - if (pt->flag & GP_SPOINT_SELECT) { - if (gpl->parent == NULL) { - calc_tw_center(tbounds, &pt->x); - totsel++; - } - else { - mul_v3_m4v3(fpt, diff_mat, &pt->x); - calc_tw_center(tbounds, fpt); - totsel++; - } - } - } - } - } - } - } - - - /* selection center */ - if (totsel) { - mul_v3_fl(tbounds->center, 1.0f / (float)totsel); /* centroid! */ - } - } - else if (obedit) { - ob = obedit; - if (obedit->type == OB_MESH) { - BMEditMesh *em = BKE_editmesh_from_object(obedit); - BMEditSelection ese; - float vec[3] = {0, 0, 0}; - - /* USE LAST SELECTE WITH ACTIVE */ - if ((pivot_point == V3D_AROUND_ACTIVE) && BM_select_history_active_get(em->bm, &ese)) { - BM_editselection_center(&ese, vec); - calc_tw_center(tbounds, vec); - totsel = 1; - } - else { - BMesh *bm = em->bm; - BMVert *eve; - - BMIter iter; - - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - totsel++; - calc_tw_center(tbounds, eve->co); - } - } - } - } - } /* end editmesh */ - else if (obedit->type == OB_ARMATURE) { - bArmature *arm = obedit->data; - EditBone *ebo; - - if ((pivot_point == V3D_AROUND_ACTIVE) && (ebo = arm->act_edbone)) { - /* doesn't check selection or visibility intentionally */ - if (ebo->flag & BONE_TIPSEL) { - calc_tw_center(tbounds, ebo->tail); - totsel++; - } - if ((ebo->flag & BONE_ROOTSEL) || - ((ebo->flag & BONE_TIPSEL) == false)) /* ensure we get at least one point */ - { - calc_tw_center(tbounds, ebo->head); - totsel++; - } - protectflag_to_drawflags_ebone(rv3d, ebo); - } - else { - for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { - if (EBONE_VISIBLE(arm, ebo)) { - if (ebo->flag & BONE_TIPSEL) { - calc_tw_center(tbounds, ebo->tail); - totsel++; - } - if ((ebo->flag & BONE_ROOTSEL) && - /* don't include same point multiple times */ - ((ebo->flag & BONE_CONNECTED) && - (ebo->parent != NULL) && - (ebo->parent->flag & BONE_TIPSEL) && - EBONE_VISIBLE(arm, ebo->parent)) == 0) - { - calc_tw_center(tbounds, ebo->head); - totsel++; - } - if (ebo->flag & BONE_SELECTED) { - protectflag_to_drawflags_ebone(rv3d, ebo); - } - } - } - } - } - else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu = obedit->data; - float center[3]; - - if ((pivot_point == V3D_AROUND_ACTIVE) && ED_curve_active_center(cu, center)) { - calc_tw_center(tbounds, center); - totsel++; - } - else { - Nurb *nu; - BezTriple *bezt; - BPoint *bp; - ListBase *nurbs = BKE_curve_editNurbs_get(cu); - - nu = nurbs->first; - while (nu) { - if (nu->type == CU_BEZIER) { - bezt = nu->bezt; - a = nu->pntsu; - while (a--) { - /* exceptions - * if handles are hidden then only check the center points. - * If the center knot is selected then only use this as the center point. - */ - if (cu->drawflag & CU_HIDE_HANDLES) { - if (bezt->f2 & SELECT) { - calc_tw_center(tbounds, bezt->vec[1]); - totsel++; - } - } - else if (bezt->f2 & SELECT) { - calc_tw_center(tbounds, bezt->vec[1]); - totsel++; - } - else { - if (bezt->f1 & SELECT) { - calc_tw_center( - tbounds, bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]); - totsel++; - } - if (bezt->f3 & SELECT) { - calc_tw_center( - tbounds, bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]); - totsel++; - } - } - bezt++; - } - } - else { - bp = nu->bp; - a = nu->pntsu * nu->pntsv; - while (a--) { - if (bp->f1 & SELECT) { - calc_tw_center(tbounds, bp->vec); - totsel++; - } - bp++; - } - } - nu = nu->next; - } - } - } - else if (obedit->type == OB_MBALL) { - MetaBall *mb = (MetaBall *)obedit->data; - MetaElem *ml; - - if ((pivot_point == V3D_AROUND_ACTIVE) && (ml = mb->lastelem)) { - calc_tw_center(tbounds, &ml->x); - totsel++; - } - else { - for (ml = mb->editelems->first; ml; ml = ml->next) { - if (ml->flag & SELECT) { - calc_tw_center(tbounds, &ml->x); - totsel++; - } - } - } - } - else if (obedit->type == OB_LATTICE) { - Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; - BPoint *bp; - - if ((pivot_point == V3D_AROUND_ACTIVE) && (bp = BKE_lattice_active_point_get(lt))) { - calc_tw_center(tbounds, bp->vec); - totsel++; - } - else { - bp = lt->def; - a = lt->pntsu * lt->pntsv * lt->pntsw; - while (a--) { - if (bp->f1 & SELECT) { - calc_tw_center(tbounds, bp->vec); - totsel++; - } - bp++; - } - } - } - - /* selection center */ - if (totsel) { - mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! - mul_m4_v3(obedit->obmat, tbounds->center); - mul_m4_v3(obedit->obmat, tbounds->min); - mul_m4_v3(obedit->obmat, tbounds->max); - } - } - else if (ob && (ob->mode & OB_MODE_POSE)) { - bPoseChannel *pchan; - int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed - bool ok = false; - - if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) { - /* doesn't check selection or visibility intentionally */ - Bone *bone = pchan->bone; - if (bone) { - calc_tw_center(tbounds, pchan->pose_head); - protectflag_to_drawflags_pchan(rv3d, pchan); - totsel = 1; - ok = true; - } - } - else { - totsel = count_set_pose_transflags(ob, mode, V3D_AROUND_CENTER_BOUNDS, NULL); - - if (totsel) { - /* use channels to get stats */ - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - Bone *bone = pchan->bone; - if (bone && (bone->flag & BONE_TRANSFORM)) { - calc_tw_center(tbounds, pchan->pose_head); - protectflag_to_drawflags_pchan(rv3d, pchan); - } - } - ok = true; - } - } - - if (ok) { - mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! - mul_m4_v3(ob->obmat, tbounds->center); - mul_m4_v3(ob->obmat, tbounds->min); - mul_m4_v3(ob->obmat, tbounds->max); - } - } - else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { - /* pass */ - } - else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { - PTCacheEdit *edit = PE_get_current(scene, ob); - PTCacheEditPoint *point; - PTCacheEditKey *ek; - int k; - - if (edit) { - point = edit->points; - for (a = 0; a < edit->totpoint; a++, point++) { - if (point->flag & PEP_HIDE) continue; - - for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) { - if (ek->flag & PEK_SELECT) { - calc_tw_center(tbounds, (ek->flag & PEK_USE_WCO) ? ek->world_co : ek->co); - totsel++; - } - } - } - - /* selection center */ - if (totsel) - mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! - } - } - else { - - /* we need the one selected object, if its not active */ - base = BASACT(view_layer); - ob = OBACT(view_layer); - if (base && ((base->flag & BASE_SELECTED) == 0)) ob = NULL; - - for (base = view_layer->object_bases.first; base; base = base->next) { - if (!TESTBASELIB(base)) { - continue; - } - if (ob == NULL) { - ob = base->object; - } - if (params->use_only_center || base->object->bb == NULL) { - calc_tw_center(tbounds, base->object->obmat[3]); - } - else { - for (uint j = 0; j < 8; j++) { - float co[3]; - mul_v3_m4v3(co, base->object->obmat, base->object->bb->vec[j]); - calc_tw_center(tbounds, co); - } - } - protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag); - totsel++; - } - - /* selection center */ - if (totsel) { - mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! - } - } - - if (totsel == 0) { - unit_m4(rv3d->twmat); - } - else { - copy_v3_v3(rv3d->tw_axis_min, tbounds->axis_min); - copy_v3_v3(rv3d->tw_axis_max, tbounds->axis_max); - copy_m3_m3(rv3d->tw_axis_matrix, tbounds->axis); - } - - return totsel; -} - -static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3]) -{ - float view_vec[3], axis_vec[3]; - ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], view_vec); - for (int i = 0; i < 3; i++) { - normalize_v3_v3(axis_vec, rv3d->twmat[i]); - r_idot[i] = 1.0f - fabsf(dot_v3v3(view_vec, axis_vec)); - } -} - -static void manipulator_prepare_mat( - const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds) -{ - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - - switch (scene->toolsettings->transform_pivot_point) { - case V3D_AROUND_CENTER_BOUNDS: - case V3D_AROUND_ACTIVE: - { - bGPdata *gpd = CTX_data_gpencil_data(C); - Object *ob = OBACT(view_layer); - - if (((scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) && - (OBEDIT_FROM_OBACT(ob) == NULL)) && - ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) && - (!(ob->mode & OB_MODE_POSE))) - { - copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); - } - else { - mid_v3_v3v3(rv3d->twmat[3], tbounds->min, tbounds->max); - } - break; - } - case V3D_AROUND_LOCAL_ORIGINS: - case V3D_AROUND_CENTER_MEAN: - copy_v3_v3(rv3d->twmat[3], tbounds->center); - break; - case V3D_AROUND_CURSOR: - copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)->location); - break; - } -} - -/** - * Sets up \a r_start and \a r_len to define arrow line range. - * Needed to adjust line drawing for combined manipulator axis types. - */ -static void manipulator_line_range(const int twtype, const short axis_type, float *r_start, float *r_len) -{ - const float ofs = 0.2f; - - *r_start = 0.2f; - *r_len = 1.0f; - - switch (axis_type) { - case MAN_AXES_TRANSLATE: - if (twtype & SCE_MANIP_SCALE) { - *r_start = *r_len - ofs + 0.075f; - } - if (twtype & SCE_MANIP_ROTATE) { - *r_len += ofs; - } - break; - case MAN_AXES_SCALE: - if (twtype & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE)) { - *r_len -= ofs + 0.025f; - } - break; - } - - *r_len -= *r_start; -} - -static void manipulator_xform_message_subscribe( - wmManipulatorGroup *mgroup, struct wmMsgBus *mbus, - Scene *scene, bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar, const void *type_fn) -{ - /* Subscribe to view properties */ - wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { - .owner = ar, - .user_data = mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, - }; - - PointerRNA scene_ptr; - RNA_id_pointer_create(&scene->id, &scene_ptr); - - { - extern PropertyRNA rna_Scene_transform_orientation; - extern PropertyRNA rna_Scene_cursor_location; - const PropertyRNA *props[] = { - &rna_Scene_transform_orientation, - (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) ? &rna_Scene_cursor_location : NULL, - }; - for (int i = 0; i < ARRAY_SIZE(props); i++) { - if (props[i]) { - WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); - } - } - } - - PointerRNA toolsettings_ptr; - RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr); - - if (type_fn == TRANSFORM_WGT_manipulator) { - extern PropertyRNA rna_ToolSettings_transform_pivot_point; - extern PropertyRNA rna_ToolSettings_use_manipulator_mode; - const PropertyRNA *props[] = { - &rna_ToolSettings_transform_pivot_point, - &rna_ToolSettings_use_manipulator_mode, - }; - for (int i = 0; i < ARRAY_SIZE(props); i++) { - WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); - } - } - else if (type_fn == VIEW3D_WGT_xform_cage) { - /* pass */ - } - else { - BLI_assert(0); - } - - WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_mpr_tag_refresh); -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ -/** \name Transform Manipulator - * \{ */ - -static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) -{ - ManipulatorGroup *man; - - man = MEM_callocN(sizeof(ManipulatorGroup), "manipulator_data"); - - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); - const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); - const wmManipulatorType *wt_prim = WM_manipulatortype_find("MANIPULATOR_WT_primitive_3d", true); - -#define MANIPULATOR_NEW_ARROW(v, draw_style) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \ -} ((void)0) -#define MANIPULATOR_NEW_DIAL(v, draw_options) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_options", draw_options); \ -} ((void)0) -#define MANIPULATOR_NEW_PRIM(v, draw_style) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_prim, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \ -} ((void)0) - - /* add/init widgets - order matters! */ - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_T, ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL); - - MANIPULATOR_NEW_DIAL(MAN_AXIS_SCALE_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); - - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_X, ED_MANIPULATOR_ARROW_STYLE_BOX); - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_MANIPULATOR_ARROW_STYLE_BOX); - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_MANIPULATOR_ARROW_STYLE_BOX); - - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_X, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Y, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Z, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); - - /* init screen aligned widget last here, looks better, behaves better */ - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); - - MANIPULATOR_NEW_DIAL(MAN_AXIS_TRANS_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); - - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_X, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - - man->manipulators[MAN_AXIS_ROT_T]->flag |= WM_MANIPULATOR_SELECT_BACKGROUND; - - return man; -} - -/** - * Custom handler for manipulator widgets - */ -static int manipulator_modal( - bContext *C, wmManipulator *widget, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) -{ - /* Avoid unnecessary updates, partially address: T55458. */ - if (ELEM(event->type, TIMER, INBETWEEN_MOUSEMOVE)) { - return OPERATOR_RUNNING_MODAL; - } - - const ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); - View3D *v3d = sa->spacedata.first; - RegionView3D *rv3d = ar->regiondata; - struct TransformBounds tbounds; - - - if (ED_transform_calc_manipulator_stats( - C, &(struct TransformCalcParams){ - .use_only_center = true, - }, &tbounds)) - { - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); - WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]); - } - - ED_region_tag_redraw(ar); - - return OPERATOR_RUNNING_MODAL; -} - -static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgroup) -{ - struct { - wmOperatorType *translate, *rotate, *trackball, *resize; - } ot_store = {NULL}; - ManipulatorGroup *man = mgroup->customdata; - MAN_ITER_AXES_BEGIN(axis, axis_idx) - { - const short axis_type = manipulator_get_axis_type(axis_idx); - bool constraint_axis[3] = {1, 0, 0}; - PointerRNA *ptr; - - manipulator_get_axis_constraint(axis_idx, constraint_axis); - - /* custom handler! */ - WM_manipulator_set_fn_custom_modal(axis, manipulator_modal); - - switch (axis_idx) { - case MAN_AXIS_TRANS_X: - case MAN_AXIS_TRANS_Y: - case MAN_AXIS_TRANS_Z: - case MAN_AXIS_SCALE_X: - case MAN_AXIS_SCALE_Y: - case MAN_AXIS_SCALE_Z: - if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { - int draw_options = 0; - if ((man->twtype & (SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { - draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM; - } - RNA_enum_set(axis->ptr, "draw_options", draw_options); - } - - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); - break; - case MAN_AXIS_ROT_X: - case MAN_AXIS_ROT_Y: - case MAN_AXIS_ROT_Z: - /* increased line width for better display */ - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH + 1.0f); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); - break; - case MAN_AXIS_TRANS_XY: - case MAN_AXIS_TRANS_YZ: - case MAN_AXIS_TRANS_ZX: - case MAN_AXIS_SCALE_XY: - case MAN_AXIS_SCALE_YZ: - case MAN_AXIS_SCALE_ZX: - { - const float ofs_ax = 7.0f; - const float ofs[3] = {ofs_ax, ofs_ax, 0.0f}; - WM_manipulator_set_scale(axis, 0.07f); - WM_manipulator_set_matrix_offset_location(axis, ofs); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); - break; - } - case MAN_AXIS_TRANS_C: - case MAN_AXIS_ROT_C: - case MAN_AXIS_SCALE_C: - case MAN_AXIS_ROT_T: - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); - if (axis_idx == MAN_AXIS_ROT_T) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_HOVER, true); - } - else if (axis_idx == MAN_AXIS_ROT_C) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); - WM_manipulator_set_scale(axis, 1.2f); - } - else { - WM_manipulator_set_scale(axis, 0.2f); - } - break; - } - - switch (axis_type) { - case MAN_AXES_TRANSLATE: - if (ot_store.translate == NULL) { - ot_store.translate = WM_operatortype_find("TRANSFORM_OT_translate", true); - } - ptr = WM_manipulator_operator_set(axis, 0, ot_store.translate, NULL); - break; - case MAN_AXES_ROTATE: - { - wmOperatorType *ot_rotate; - if (axis_idx == MAN_AXIS_ROT_T) { - if (ot_store.trackball == NULL) { - ot_store.trackball = WM_operatortype_find("TRANSFORM_OT_trackball", true); - } - ot_rotate = ot_store.trackball; - } - else { - if (ot_store.rotate == NULL) { - ot_store.rotate = WM_operatortype_find("TRANSFORM_OT_rotate", true); - } - ot_rotate = ot_store.rotate; - } - ptr = WM_manipulator_operator_set(axis, 0, ot_rotate, NULL); - break; - } - case MAN_AXES_SCALE: - { - if (ot_store.resize == NULL) { - ot_store.resize = WM_operatortype_find("TRANSFORM_OT_resize", true); - } - ptr = WM_manipulator_operator_set(axis, 0, ot_store.resize, NULL); - break; - } - } - - { - PropertyRNA *prop; - if ((prop = RNA_struct_find_property(ptr, "constraint_axis"))) { - RNA_property_boolean_set_array(ptr, prop, constraint_axis); - } - } - - RNA_boolean_set(ptr, "release_confirm", 1); - } - MAN_ITER_AXES_END; -} - -static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) -{ - ManipulatorGroup *man = manipulatorgroup_init(mgroup); - - mgroup->customdata = man; - - { - man->twtype = 0; - ScrArea *sa = CTX_wm_area(C); - const bToolRef *tref = sa->runtime.tool; - - if (tref == NULL || STREQ(tref->idname, "Transform")) { - /* Setup all manipulators, they can be toggled via 'ToolSettings.manipulator_flag' */ - man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; - man->use_twtype_refresh = true; - } - else if (STREQ(tref->idname, "Grab")) { - man->twtype |= SCE_MANIP_TRANSLATE; - } - else if (STREQ(tref->idname, "Rotate")) { - man->twtype |= SCE_MANIP_ROTATE; - } - else if (STREQ(tref->idname, "Scale")) { - man->twtype |= SCE_MANIP_SCALE; - } - BLI_assert(man->twtype != 0); - man->twtype_init = man->twtype; - } - - /* *** set properties for axes *** */ - manipulatorgroup_init_properties_from_twtype(mgroup); -} - -static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - ManipulatorGroup *man = mgroup->customdata; - ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); - View3D *v3d = sa->spacedata.first; - RegionView3D *rv3d = ar->regiondata; - struct TransformBounds tbounds; - - if (man->use_twtype_refresh) { - Scene *scene = CTX_data_scene(C); - man->twtype = scene->toolsettings->manipulator_flag & man->twtype_init; - if (man->twtype != man->twtype_prev) { - man->twtype_prev = man->twtype; - manipulatorgroup_init_properties_from_twtype(mgroup); - } - } - - /* skip, we don't draw anything anyway */ - if ((man->all_hidden = - (ED_transform_calc_manipulator_stats( - C, &(struct TransformCalcParams){ - .use_only_center = true, - }, &tbounds) == 0))) - { - return; - } - - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); - - /* *** set properties for axes *** */ - - MAN_ITER_AXES_BEGIN(axis, axis_idx) - { - const short axis_type = manipulator_get_axis_type(axis_idx); - const int aidx_norm = manipulator_orientation_axis(axis_idx, NULL); - - WM_manipulator_set_matrix_location(axis, rv3d->twmat[3]); - - switch (axis_idx) { - case MAN_AXIS_TRANS_X: - case MAN_AXIS_TRANS_Y: - case MAN_AXIS_TRANS_Z: - case MAN_AXIS_SCALE_X: - case MAN_AXIS_SCALE_Y: - case MAN_AXIS_SCALE_Z: - { - float start_co[3] = {0.0f, 0.0f, 0.0f}; - float len; - - manipulator_line_range(man->twtype, axis_type, &start_co[2], &len); - - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); - RNA_float_set(axis->ptr, "length", len); - - if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { - if (man->twtype & SCE_MANIP_ROTATE) { - /* Avoid rotate and translate arrows overlap. */ - start_co[2] += 0.215f; - } - } - WM_manipulator_set_matrix_offset_location(axis, start_co); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); - break; - } - case MAN_AXIS_ROT_X: - case MAN_AXIS_ROT_Y: - case MAN_AXIS_ROT_Z: - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); - break; - case MAN_AXIS_TRANS_XY: - case MAN_AXIS_TRANS_YZ: - case MAN_AXIS_TRANS_ZX: - case MAN_AXIS_SCALE_XY: - case MAN_AXIS_SCALE_YZ: - case MAN_AXIS_SCALE_ZX: - { - const float *y_axis = rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1]; - const float *z_axis = rv3d->twmat[aidx_norm]; - WM_manipulator_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis); - break; - } - } - } - MAN_ITER_AXES_END; -} - -static void WIDGETGROUP_manipulator_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) -{ - Scene *scene = CTX_data_scene(C); - bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); - manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, TRANSFORM_WGT_manipulator); -} - -static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - ManipulatorGroup *man = mgroup->customdata; - // ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); - // View3D *v3d = sa->spacedata.first; - RegionView3D *rv3d = ar->regiondata; - float idot[3]; - - /* when looking through a selected camera, the manipulator can be at the - * exact same position as the view, skip so we don't break selection */ - if (man->all_hidden || fabsf(ED_view3d_pixel_size(rv3d, rv3d->twmat[3])) < 1e-6f) { - MAN_ITER_AXES_BEGIN(axis, axis_idx) - { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true); - } - MAN_ITER_AXES_END; - return; - } - manipulator_get_idot(rv3d, idot); - - /* *** set properties for axes *** */ - - MAN_ITER_AXES_BEGIN(axis, axis_idx) - { - const short axis_type = manipulator_get_axis_type(axis_idx); - /* XXX maybe unset _HIDDEN flag on redraw? */ - if (manipulator_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, false); - } - else { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true); - continue; - } - - float color[4], color_hi[4]; - manipulator_get_axis_color(axis_idx, idot, color, color_hi); - WM_manipulator_set_color(axis, color); - WM_manipulator_set_color_highlight(axis, color_hi); - - switch (axis_idx) { - case MAN_AXIS_TRANS_C: - case MAN_AXIS_ROT_C: - case MAN_AXIS_SCALE_C: - case MAN_AXIS_ROT_T: - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]); - break; - } - } - MAN_ITER_AXES_END; -} - -static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt) -{ - /* it's a given we only use this in 3D view */ - bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); - if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->manipulator_group)) - { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); - return false; - } - - View3D *v3d = CTX_wm_view3d(C); - if (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_TOOL)) { - return false; - } - return true; -} - -void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt) -{ - wgt->name = "Transform Manipulator"; - wgt->idname = "TRANSFORM_WGT_manipulator"; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; - - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - - wgt->poll = WIDGETGROUP_manipulator_poll; - wgt->setup = WIDGETGROUP_manipulator_setup; - wgt->refresh = WIDGETGROUP_manipulator_refresh; - wgt->message_subscribe = WIDGETGROUP_manipulator_message_subscribe; - wgt->draw_prepare = WIDGETGROUP_manipulator_draw_prepare; -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ -/** \name Scale Cage Manipulator - * \{ */ - -struct XFormCageWidgetGroup { - wmManipulator *manipulator; -}; - -static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupType *wgt) -{ - bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); - if (!STREQ(wgt->idname, tref_rt->manipulator_group)) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); - return false; - } - return true; -} - -static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) -{ - struct XFormCageWidgetGroup *xmgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__); - const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true); - xmgroup->manipulator = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); - wmManipulator *mpr = xmgroup->manipulator; - - RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE); - - mpr->color[0] = 1; - mpr->color_hi[0] = 1; - - mgroup->customdata = xmgroup; - - { - wmOperatorType *ot_resize = WM_operatortype_find("TRANSFORM_OT_resize", true); - PointerRNA *ptr; - - /* assign operator */ - PropertyRNA *prop_release_confirm = NULL; - PropertyRNA *prop_constraint_axis = NULL; - - int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; - for (int x = 0; x < 3; x++) { - for (int y = 0; y < 3; y++) { - for (int z = 0; z < 3; z++) { - bool constraint[3] = {x != 1, y != 1, z != 1}; - ptr = WM_manipulator_operator_set(mpr, i, ot_resize, NULL); - if (prop_release_confirm == NULL) { - prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); - prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); - } - RNA_property_boolean_set(ptr, prop_release_confirm, true); - RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint); - i++; - } - } - } - } -} - -static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup *mgroup) -{ - ScrArea *sa = CTX_wm_area(C); - View3D *v3d = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; - - struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; - wmManipulator *mpr = xmgroup->manipulator; - - struct TransformBounds tbounds; - - if ((ED_transform_calc_manipulator_stats( - C, &(struct TransformCalcParams) { - .use_local_axis = true, - }, &tbounds) == 0) || - equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max)) - { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); - } - else { - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); - - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_GRAB_CURSOR, true); - - float dims[3]; - sub_v3_v3v3(dims, rv3d->tw_axis_max, rv3d->tw_axis_min); - RNA_float_set_array(mpr->ptr, "dimensions", dims); - mul_v3_fl(dims, 0.5f); - - copy_m4_m3(mpr->matrix_offset, rv3d->tw_axis_matrix); - mid_v3_v3v3(mpr->matrix_offset[3], rv3d->tw_axis_max, rv3d->tw_axis_min); - mul_m3_v3(rv3d->tw_axis_matrix, mpr->matrix_offset[3]); - - PropertyRNA *prop_center_override = NULL; - float center[3]; - float center_global[3]; - int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; - for (int x = 0; x < 3; x++) { - center[0] = (float)(1 - x) * dims[0]; - for (int y = 0; y < 3; y++) { - center[1] = (float)(1 - y) * dims[1]; - for (int z = 0; z < 3; z++) { - center[2] = (float)(1 - z) * dims[2]; - struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, i); - if (prop_center_override == NULL) { - prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); - } - mul_v3_m4v3(center_global, mpr->matrix_offset, center); - RNA_property_float_set_array(&mpop->ptr, prop_center_override, center_global); - i++; - } - } - } - } -} - -static void WIDGETGROUP_xform_cage_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) -{ - Scene *scene = CTX_data_scene(C); - bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); - manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, VIEW3D_WGT_xform_cage); -} - -static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) -{ - struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; - wmManipulator *mpr = xmgroup->manipulator; - - ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); - if (ob && ob->mode & OB_MODE_EDIT) { - copy_m4_m4(mpr->matrix_space, ob->obmat); - } - else { - unit_m4(mpr->matrix_space); - } -} - -void VIEW3D_WGT_xform_cage(wmManipulatorGroupType *wgt) -{ - wgt->name = "Transform Cage"; - wgt->idname = "VIEW3D_WGT_xform_cage"; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; - - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - - wgt->poll = WIDGETGROUP_xform_cage_poll; - wgt->setup = WIDGETGROUP_xform_cage_setup; - wgt->refresh = WIDGETGROUP_xform_cage_refresh; - wgt->message_subscribe = WIDGETGROUP_xform_cage_message_subscribe; - wgt->draw_prepare = WIDGETGROUP_xform_cage_draw_prepare; -} - -/** \} */ diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index fa21facefc2..97ea0da6007 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -63,7 +63,7 @@ set(SRC ../include/ED_lattice.h ../include/ED_logic.h ../include/ED_markers.h - ../include/ED_manipulator_library.h + ../include/ED_gizmo_library.h ../include/ED_mask.h ../include/ED_mball.h ../include/ED_mesh.h diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 2288e6c8405..eb32a5fc6cb 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -92,7 +92,7 @@ set(DEFSRC rna_userdef.c rna_vfont.c rna_wm.c - rna_wm_manipulator.c + rna_wm_gizmo.c rna_workspace.c rna_world.c ) @@ -121,7 +121,7 @@ set(APISRC rna_ui_api.c rna_vfont_api.c rna_wm_api.c - rna_wm_manipulator_api.c + rna_wm_gizmo_api.c rna_workspace_api.c ) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 4b06d917ab7..bb24452d67a 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3443,7 +3443,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_userdef.c", NULL, RNA_def_userdef}, {"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont}, {"rna_wm.c", "rna_wm_api.c", RNA_def_wm}, - {"rna_wm_manipulator.c", "rna_wm_manipulator_api.c", RNA_def_wm_manipulator}, + {"rna_wm_gizmo.c", "rna_wm_gizmo_api.c", RNA_def_wm_manipulator}, {"rna_workspace.c", "rna_workspace_api.c", RNA_def_workspace}, {"rna_world.c", NULL, RNA_def_world}, {"rna_movieclip.c", NULL, RNA_def_movieclip}, diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c new file mode 100644 index 00000000000..c2c4c95b83f --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -0,0 +1,1335 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_wm_gizmo.c + * \ingroup RNA + */ + +#include + +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_userdef_types.h" +#include "DNA_view3d_types.h" +#include "DNA_windowmanager_types.h" + +#include "BLI_utildefines.h" +#include "BLI_string_utils.h" + +#include "BLT_translation.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "WM_types.h" + +#ifdef RNA_RUNTIME +/* enum definitions */ +#endif /* RNA_RUNTIME */ + +#ifdef RNA_RUNTIME + +#include + +#include "WM_api.h" + +#include "DNA_workspace_types.h" + +#include "ED_screen.h" + +#include "UI_interface.h" + +#include "BKE_global.h" +#include "BKE_idprop.h" +#include "BKE_workspace.h" + +#include "MEM_guardedalloc.h" + +#ifdef WITH_PYTHON +# include "BPY_extern.h" +#endif + +/* -------------------------------------------------------------------- */ + +/** \name Manipulator API + * \{ */ + +#ifdef WITH_PYTHON +static void rna_manipulator_draw_cb( + const struct bContext *C, struct wmManipulator *mpr) +{ + extern FunctionRNA rna_Manipulator_draw_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "draw"); */ + func = &rna_Manipulator_draw_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static void rna_manipulator_draw_select_cb( + const struct bContext *C, struct wmManipulator *mpr, int select_id) +{ + extern FunctionRNA rna_Manipulator_draw_select_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "draw_select"); */ + func = &rna_Manipulator_draw_select_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "select_id", &select_id); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static int rna_manipulator_test_select_cb( + struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event) +{ + extern FunctionRNA rna_Manipulator_test_select_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "test_select"); */ + func = &rna_Manipulator_test_select_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "event", &event); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + + void *ret; + RNA_parameter_get_lookup(&list, "intersect_id", &ret); + int intersect_id = *(int *)ret; + + RNA_parameter_list_free(&list); + return intersect_id; +} + +static int rna_manipulator_modal_cb( + struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event, + eWM_ManipulatorTweak tweak_flag) +{ + extern FunctionRNA rna_Manipulator_modal_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + const int tweak_flag_int = tweak_flag; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "modal"); */ + func = &rna_Manipulator_modal_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "event", &event); + RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + + void *ret; + RNA_parameter_get_lookup(&list, "result", &ret); + int ret_enum = *(int *)ret; + + RNA_parameter_list_free(&list); + return ret_enum; +} + +static void rna_manipulator_setup_cb( + struct wmManipulator *mpr) +{ + extern FunctionRNA rna_Manipulator_setup_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "setup"); */ + func = &rna_Manipulator_setup_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + + +static int rna_manipulator_invoke_cb( + struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event) +{ + extern FunctionRNA rna_Manipulator_invoke_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "invoke"); */ + func = &rna_Manipulator_invoke_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "event", &event); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + + void *ret; + RNA_parameter_get_lookup(&list, "result", &ret); + int ret_enum = *(int *)ret; + + RNA_parameter_list_free(&list); + return ret_enum; +} + +static void rna_manipulator_exit_cb( + struct bContext *C, struct wmManipulator *mpr, bool cancel) +{ + extern FunctionRNA rna_Manipulator_exit_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "exit"); */ + func = &rna_Manipulator_exit_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + { + int cancel_i = cancel; + RNA_parameter_set_lookup(&list, "cancel", &cancel_i); + } + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static void rna_manipulator_select_refresh_cb( + struct wmManipulator *mpr) +{ + extern FunctionRNA rna_Manipulator_select_refresh_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "select_refresh"); */ + func = &rna_Manipulator_select_refresh_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +#endif /* WITH_PYTHON */ + +/* just to work around 'const char *' warning and to ensure this is a python op */ +static void rna_Manipulator_bl_idname_set(PointerRNA *ptr, const char *value) +{ + wmManipulator *data = ptr->data; + char *str = (char *)data->type->idname; + if (!str[0]) { + BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ + } + else { + assert(!"setting the bl_idname on a non-builtin operator"); + } +} + +static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr) +{ +#if 0 + wmWindowManager *wm = ptr->id.data; +#endif + + /* We could try workaruond this lookup, but not trivial. */ + for (bScreen *screen = G_MAIN->screen.first; screen; screen = screen->id.next) { + IDProperty *properties = ptr->data; + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->manipulator_map) { + wmManipulatorMap *mmap = ar->manipulator_map; + for (wmManipulatorGroup *mgroup = WM_manipulatormap_group_list(mmap)->first; + mgroup; + mgroup = mgroup->next) + { + for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + if (mpr->properties == properties) { + return mpr; + } + } + } + } + } + } + } + return NULL; +} + +static StructRNA *rna_ManipulatorProperties_refine(PointerRNA *ptr) +{ + wmManipulator *mpr = rna_ManipulatorProperties_find_operator(ptr); + + if (mpr) + return mpr->type->srna; + else + return ptr->type; +} + +static IDProperty *rna_ManipulatorProperties_idprops(PointerRNA *ptr, bool create) +{ + if (create && !ptr->data) { + IDPropertyTemplate val = {0}; + ptr->data = IDP_New(IDP_GROUP, &val, "RNA_ManipulatorProperties group"); + } + + return ptr->data; +} + +static PointerRNA rna_Manipulator_properties_get(PointerRNA *ptr) +{ + wmManipulator *mpr = ptr->data; + return rna_pointer_inherit_refine(ptr, mpr->type->srna, mpr->properties); +} + +/* wmManipulator.float */ +#define RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(func_id, member_id) \ +static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return mpr->member_id; \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \ +{ \ + wmManipulator *mpr = ptr->data; \ + mpr->member_id = value; \ +} +#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \ +static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return mpr->member_id[index]; \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \ +{ \ + wmManipulator *mpr = ptr->data; \ + mpr->member_id[index] = value; \ +} +/* wmManipulator.float[len] */ +#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \ +static void rna_Manipulator_##func_id##_get(PointerRNA *ptr, float value[len]) \ +{ \ + wmManipulator *mpr = ptr->data; \ + memcpy(value, mpr->member_id, sizeof(float[len])); \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, const float value[len]) \ +{ \ + wmManipulator *mpr = ptr->data; \ + memcpy(mpr->member_id, value, sizeof(float[len])); \ +} + +/* wmManipulator.flag */ +#define RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \ +static bool rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return (mpr->member_id & flag_value) != 0; \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, bool value) \ +{ \ + wmManipulator *mpr = ptr->data; \ + SET_FLAG_FROM_TEST(mpr->member_id, value, flag_value); \ +} + +/* wmManipulator.flag (negative) */ +#define RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \ +static bool rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return (mpr->member_id & flag_value) == 0; \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, bool value) \ +{ \ + wmManipulator *mpr = ptr->data; \ + SET_FLAG_FROM_TEST(mpr->member_id, !value, flag_value); \ +} + +#define RNA_MANIPULATOR_FLAG_RO_DEF(func_id, member_id, flag_value) \ +static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return (mpr->member_id & flag_value) != 0; \ +} + +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3); +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3); + +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3); +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3); + +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16); +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16); +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16); + +static void rna_Manipulator_matrix_world_get(PointerRNA *ptr, float value[16]) +{ + wmManipulator *mpr = ptr->data; + WM_manipulator_calc_matrix_final(mpr, (float (*)[4])value); +} + +RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis); +RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(line_width, line_width); + +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_MANIPULATOR_DRAW_HOVER); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_MANIPULATOR_DRAW_MODAL); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_MANIPULATOR_DRAW_VALUE); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE); +RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_MANIPULATOR_GRAB_CURSOR); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_MANIPULATOR_SELECT_BACKGROUND); + +/* wmManipulator.state */ +RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT); +RNA_MANIPULATOR_FLAG_RO_DEF(state_is_modal, state, WM_MANIPULATOR_STATE_MODAL); +RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT); + +static void rna_Manipulator_state_select_set(struct PointerRNA *ptr, bool value) +{ + wmManipulator *mpr = ptr->data; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + WM_manipulator_select_set(mgroup->parent_mmap, mpr, value); +} + +static PointerRNA rna_Manipulator_group_get(PointerRNA *ptr) +{ + wmManipulator *mpr = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_ManipulatorGroup, mpr->parent_mgroup); +} + +#ifdef WITH_PYTHON + +static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type); +void BPY_RNA_manipulator_wrapper(wmManipulatorType *wgt, void *userdata); + +static StructRNA *rna_Manipulator_register( + Main *bmain, ReportList *reports, void *data, const char *identifier, + StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + struct { + char idname[MAX_NAME]; + } temp_buffers; + + wmManipulatorType dummywt = {NULL}; + wmManipulator dummymnp = {NULL}; + PointerRNA mnp_ptr; + + /* Two sets of functions. */ + int have_function[8]; + + /* setup dummy manipulator & manipulator type to store static properties in */ + dummymnp.type = &dummywt; + dummywt.idname = temp_buffers.idname; + RNA_pointer_create(NULL, &RNA_Manipulator, &dummymnp, &mnp_ptr); + + /* Clear so we can detect if it's left unset. */ + temp_buffers.idname[0] = '\0'; + + /* validate the python class */ + if (validate(&mnp_ptr, data, have_function) != 0) + return NULL; + + if (strlen(identifier) >= sizeof(temp_buffers.idname)) { + BKE_reportf(reports, RPT_ERROR, "Registering manipulator class: '%s' is too long, maximum length is %d", + identifier, (int)sizeof(temp_buffers.idname)); + return NULL; + } + + /* check if we have registered this manipulator type before, and remove it */ + { + const wmManipulatorType *wt = WM_manipulatortype_find(dummywt.idname, true); + if (wt && wt->ext.srna) { + rna_Manipulator_unregister(bmain, wt->ext.srna); + } + } + if (!RNA_struct_available_or_report(reports, dummywt.idname)) { + return NULL; + } + + { /* allocate the idname */ + /* For multiple strings see ManipulatorGroup. */ + dummywt.idname = BLI_strdup(temp_buffers.idname); + } + + /* create a new manipulator type */ + dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Manipulator); + /* manipulator properties are registered separately */ + RNA_def_struct_flag(dummywt.ext.srna, STRUCT_NO_IDPROPERTIES); + dummywt.ext.data = data; + dummywt.ext.call = call; + dummywt.ext.free = free; + + { + int i = 0; + dummywt.draw = (have_function[i++]) ? rna_manipulator_draw_cb : NULL; + dummywt.draw_select = (have_function[i++]) ? rna_manipulator_draw_select_cb : NULL; + dummywt.test_select = (have_function[i++]) ? rna_manipulator_test_select_cb : NULL; + dummywt.modal = (have_function[i++]) ? rna_manipulator_modal_cb : NULL; +// dummywt.property_update = (have_function[i++]) ? rna_manipulator_property_update : NULL; +// dummywt.position_get = (have_function[i++]) ? rna_manipulator_position_get : NULL; + dummywt.setup = (have_function[i++]) ? rna_manipulator_setup_cb : NULL; + dummywt.invoke = (have_function[i++]) ? rna_manipulator_invoke_cb : NULL; + dummywt.exit = (have_function[i++]) ? rna_manipulator_exit_cb : NULL; + dummywt.select_refresh = (have_function[i++]) ? rna_manipulator_select_refresh_cb : NULL; + + BLI_assert(i == ARRAY_SIZE(have_function)); + } + + WM_manipulatortype_append_ptr(BPY_RNA_manipulator_wrapper, (void *)&dummywt); + + /* update while blender is running */ + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + return dummywt.ext.srna; +} + +static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type) +{ + wmManipulatorType *wt = RNA_struct_blender_type_get(type); + + if (!wt) + return; + + RNA_struct_free_extension(type, &wt->ext); + RNA_struct_free(&BLENDER_RNA, type); + + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + WM_manipulatortype_remove_ptr(NULL, bmain, wt); +} + +static void **rna_Manipulator_instance(PointerRNA *ptr) +{ + wmManipulator *mpr = ptr->data; + return &mpr->py_instance; +} + +#endif /* WITH_PYTHON */ + + +static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr) +{ + wmManipulator *mpr = mnp_ptr->data; + return (mpr->type && mpr->type->ext.srna) ? mpr->type->ext.srna : &RNA_Manipulator; +} + +/** \} */ + +/** \name Manipulator Group API + * \{ */ + +static wmManipulator *rna_ManipulatorGroup_manipulator_new( + wmManipulatorGroup *mgroup, ReportList *reports, const char *idname) +{ + const wmManipulatorType *wt = WM_manipulatortype_find(idname, true); + if (wt == NULL) { + BKE_reportf(reports, RPT_ERROR, "ManipulatorType '%s' not known", idname); + return NULL; + } + wmManipulator *mpr = WM_manipulator_new_ptr(wt, mgroup, NULL); + return mpr; +} + +static void rna_ManipulatorGroup_manipulator_remove( + wmManipulatorGroup *mgroup, bContext *C, wmManipulator *mpr) +{ + WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C); +} + +static void rna_ManipulatorGroup_manipulator_clear( + wmManipulatorGroup *mgroup, bContext *C) +{ + while (mgroup->manipulators.first) { + WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mgroup->manipulators.first, C); + } +} + +static void rna_ManipulatorGroup_name_get(PointerRNA *ptr, char *value) +{ + wmManipulatorGroup *mgroup = ptr->data; + strcpy(value, mgroup->type->name); +} + +static int rna_ManipulatorGroup_name_length(PointerRNA *ptr) +{ + wmManipulatorGroup *mgroup = ptr->data; + return strlen(mgroup->type->name); +} + +/* just to work around 'const char *' warning and to ensure this is a python op */ +static void rna_ManipulatorGroup_bl_idname_set(PointerRNA *ptr, const char *value) +{ + wmManipulatorGroup *data = ptr->data; + char *str = (char *)data->type->idname; + if (!str[0]) + BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ + else + assert(!"setting the bl_idname on a non-builtin operator"); +} + +static void rna_ManipulatorGroup_bl_label_set(PointerRNA *ptr, const char *value) +{ + wmManipulatorGroup *data = ptr->data; + char *str = (char *)data->type->name; + if (!str[0]) + BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ + else + assert(!"setting the bl_label on a non-builtin operator"); +} + +static bool rna_ManipulatorGroup_has_reports_get(PointerRNA *ptr) +{ + wmManipulatorGroup *mgroup = ptr->data; + return (mgroup->reports && mgroup->reports->list.first); +} + +#ifdef WITH_PYTHON + +static bool rna_manipulatorgroup_poll_cb(const bContext *C, wmManipulatorGroupType *wgt) +{ + + extern FunctionRNA rna_ManipulatorGroup_poll_func; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + void *ret; + int visible; + + RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ + func = &rna_ManipulatorGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + wgt->ext.call((bContext *)C, &ptr, func, &list); + + RNA_parameter_get_lookup(&list, "visible", &ret); + visible = *(int *)ret; + + RNA_parameter_list_free(&list); + + return visible; +} + +static void rna_manipulatorgroup_setup_cb(const bContext *C, wmManipulatorGroup *mgroup) +{ + extern FunctionRNA rna_ManipulatorGroup_setup_func; + + PointerRNA mgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + func = &rna_ManipulatorGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */ + + RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupType *wgt, wmKeyConfig *config) +{ + extern FunctionRNA rna_ManipulatorGroup_setup_keymap_func; + void *ret; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ + func = &rna_ManipulatorGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */ + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "keyconfig", &config); + wgt->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_get_lookup(&list, "keymap", &ret); + wmKeyMap *keymap = *(wmKeyMap **)ret; + + RNA_parameter_list_free(&list); + + return keymap; +} + +static void rna_manipulatorgroup_refresh_cb(const bContext *C, wmManipulatorGroup *mgroup) +{ + extern FunctionRNA rna_ManipulatorGroup_refresh_func; + + PointerRNA mgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + func = &rna_ManipulatorGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */ + + RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static void rna_manipulatorgroup_draw_prepare_cb(const bContext *C, wmManipulatorGroup *mgroup) +{ + extern FunctionRNA rna_ManipulatorGroup_draw_prepare_func; + + PointerRNA mgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + func = &rna_ManipulatorGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */ + + RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata); +static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type); + +static StructRNA *rna_ManipulatorGroup_register( + Main *bmain, ReportList *reports, void *data, const char *identifier, + StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + struct { + char name[MAX_NAME]; + char idname[MAX_NAME]; + } temp_buffers; + + wmManipulatorGroupType dummywgt = {NULL}; + wmManipulatorGroup dummywg = {NULL}; + PointerRNA wgptr; + + /* Two sets of functions. */ + int have_function[5]; + + /* setup dummy manipulatorgroup & manipulatorgroup type to store static properties in */ + dummywg.type = &dummywgt; + dummywgt.name = temp_buffers.name; + dummywgt.idname = temp_buffers.idname; + + RNA_pointer_create(NULL, &RNA_ManipulatorGroup, &dummywg, &wgptr); + + /* Clear so we can detect if it's left unset. */ + temp_buffers.idname[0] = temp_buffers.name[0] = '\0'; + + /* validate the python class */ + if (validate(&wgptr, data, have_function) != 0) + return NULL; + + if (strlen(identifier) >= sizeof(temp_buffers.idname)) { + BKE_reportf(reports, RPT_ERROR, "Registering manipulatorgroup class: '%s' is too long, maximum length is %d", + identifier, (int)sizeof(temp_buffers.idname)); + return NULL; + } + + /* check if the area supports widgets */ + const struct wmManipulatorMapType_Params wmap_params = { + .spaceid = dummywgt.mmap_params.spaceid, + .regionid = dummywgt.mmap_params.regionid, + }; + + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wmap_params); + if (mmap_type == NULL) { + BKE_reportf(reports, RPT_ERROR, "Area type does not support manipulators"); + return NULL; + } + + /* check if we have registered this manipulatorgroup type before, and remove it */ + { + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true); + if (wgt && wgt->ext.srna) { + rna_ManipulatorGroup_unregister(bmain, wgt->ext.srna); + } + } + if (!RNA_struct_available_or_report(reports, dummywgt.idname)) { + return NULL; + } + + { /* allocate the idname */ + const char *strings[] = { + temp_buffers.idname, + temp_buffers.name, + }; + char *strings_table[ARRAY_SIZE(strings)]; + BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings)); + + dummywgt.idname = strings_table[0]; /* allocated string stored here */ + dummywgt.name = strings_table[1]; + BLI_assert(ARRAY_SIZE(strings) == 2); + } + + /* create a new manipulatorgroup type */ + dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_ManipulatorGroup); + RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* manipulatorgroup properties are registered separately */ + dummywgt.ext.data = data; + dummywgt.ext.call = call; + dummywgt.ext.free = free; + + /* We used to register widget group types like this, now we do it similar to + * operator types. Thus we should be able to do the same as operator types now. */ + dummywgt.poll = (have_function[0]) ? rna_manipulatorgroup_poll_cb : NULL; + dummywgt.setup_keymap = (have_function[1]) ? rna_manipulatorgroup_setup_keymap_cb : NULL; + dummywgt.setup = (have_function[2]) ? rna_manipulatorgroup_setup_cb : NULL; + dummywgt.refresh = (have_function[3]) ? rna_manipulatorgroup_refresh_cb : NULL; + dummywgt.draw_prepare = (have_function[4]) ? rna_manipulatorgroup_draw_prepare_cb : NULL; + + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr( + BPY_RNA_manipulatorgroup_wrapper, (void *)&dummywgt); + + { + const char *owner_id = RNA_struct_state_owner_get(); + if (owner_id) { + BLI_strncpy(wgt->owner_id, owner_id, sizeof(wgt->owner_id)); + } + } + + if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) { + WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); + + /* update while blender is running */ + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + } + + return dummywgt.ext.srna; +} + +static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type) +{ + wmManipulatorGroupType *wgt = RNA_struct_blender_type_get(type); + + if (!wgt) + return; + + RNA_struct_free_extension(type, &wgt->ext); + RNA_struct_free(&BLENDER_RNA, type); + + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + WM_manipulator_group_type_remove_ptr(bmain, wgt); +} + +static void **rna_ManipulatorGroup_instance(PointerRNA *ptr) +{ + wmManipulatorGroup *mgroup = ptr->data; + return &mgroup->py_instance; +} + +#endif /* WITH_PYTHON */ + +static StructRNA *rna_ManipulatorGroup_refine(PointerRNA *mgroup_ptr) +{ + wmManipulatorGroup *mgroup = mgroup_ptr->data; + return (mgroup->type && mgroup->type->ext.srna) ? mgroup->type->ext.srna : &RNA_ManipulatorGroup; +} + +static void rna_ManipulatorGroup_manipulators_begin(CollectionPropertyIterator *iter, PointerRNA *mgroup_ptr) +{ + wmManipulatorGroup *mgroup = mgroup_ptr->data; + rna_iterator_listbase_begin(iter, &mgroup->manipulators, NULL); +} + +/** \} */ + + +#else /* RNA_RUNTIME */ + + +/* ManipulatorGroup.manipulators */ +static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "Manipulators"); + srna = RNA_def_struct(brna, "Manipulators", NULL); + RNA_def_struct_sdna(srna, "wmManipulatorGroup"); + RNA_def_struct_ui_text(srna, "Manipulators", "Collection of manipulators"); + + func = RNA_def_function(srna, "new", "rna_ManipulatorGroup_manipulator_new"); + RNA_def_function_ui_description(func, "Add manipulator"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_string(func, "type", "Type", 0, "", "Manipulator identifier"); /* optional */ + parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_ManipulatorGroup_manipulator_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Delete manipulator"); + parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + + func = RNA_def_function(srna, "clear", "rna_ManipulatorGroup_manipulator_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Delete all manipulators"); +} + + +static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "Manipulator"); + srna = RNA_def_struct(brna, "Manipulator", NULL); + RNA_def_struct_sdna(srna, "wmManipulator"); + RNA_def_struct_ui_text(srna, "Manipulator", "Collection of manipulators"); + RNA_def_struct_refine_func(srna, "rna_Manipulator_refine"); + +#ifdef WITH_PYTHON + RNA_def_struct_register_funcs( + srna, + "rna_Manipulator_register", + "rna_Manipulator_unregister", + "rna_Manipulator_instance"); +#endif + RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + + prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "ManipulatorProperties"); + RNA_def_property_ui_text(prop, "Properties", ""); + RNA_def_property_pointer_funcs(prop, "rna_Manipulator_properties_get", NULL, NULL, NULL); + + /* -------------------------------------------------------------------- */ + /* Registerable Variables */ + + RNA_define_verify_sdna(0); /* not in sdna */ + + prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->idname"); + RNA_def_property_string_maxlength(prop, MAX_NAME); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Manipulator_bl_idname_set"); + /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ + RNA_def_property_flag(prop, PROP_REGISTER); + + RNA_define_verify_sdna(1); /* not in sdna */ + + /* wmManipulator.draw */ + func = RNA_def_function(srna, "draw", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* wmManipulator.draw_select */ + func = RNA_def_function(srna, "draw_select", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX); + + /* wmManipulator.test_select */ + func = RNA_def_function(srna, "test_select", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "event", "Event", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_int(func, "intersect_id", 0, 0, INT_MAX, "", "", 0, INT_MAX); + RNA_def_function_return(func, parm); + + /* wmManipulator.handler */ + static EnumPropertyItem tweak_actions[] = { + {WM_MANIPULATOR_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""}, + {WM_MANIPULATOR_TWEAK_SNAP, "SNAP", 0, "Snap", ""}, + {0, NULL, 0, NULL, NULL} + }; + func = RNA_def_function(srna, "modal", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "event", "Event", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + /* TODO, shuold be a enum-flag */ + parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", ""); + RNA_def_function_return(func, parm); + /* wmManipulator.property_update */ + /* TODO */ + + /* wmManipulator.setup */ + func = RNA_def_function(srna, "setup", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + + /* wmManipulator.invoke */ + func = RNA_def_function(srna, "invoke", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "event", "Event", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", ""); + RNA_def_function_return(func, parm); + + /* wmManipulator.exit */ + func = RNA_def_function(srna, "exit", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + /* wmManipulator.cursor_get */ + /* TODO */ + + /* wmManipulator.select_refresh */ + func = RNA_def_function(srna, "select_refresh", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + + + /* -------------------------------------------------------------------- */ + /* Instance Variables */ + + prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "ManipulatorGroup"); + RNA_def_property_pointer_funcs(prop, "rna_Manipulator_group_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "", "Manipulator group this manipulator is a member of"); + + /* Color & Alpha */ + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_float_funcs(prop, "rna_Manipulator_color_get", "rna_Manipulator_color_set", NULL); + + prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Alpha", ""); + RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_get", "rna_Manipulator_alpha_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* Color & Alpha (highlight) */ + prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_float_funcs(prop, "rna_Manipulator_color_hi_get", "rna_Manipulator_color_hi_set", NULL); + + prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Alpha", ""); + RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_hi_get", "rna_Manipulator_alpha_hi_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Space Matrix", ""); + RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_space_get", "rna_Manipulator_matrix_space_set", NULL); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Basis Matrix", ""); + RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_basis_get", "rna_Manipulator_matrix_basis_set", NULL); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Offset Matrix", ""); + RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_offset_get", "rna_Manipulator_matrix_offset_set", NULL); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Final World Matrix", ""); + RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_world_get", NULL, NULL); + + prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Scale Basis", ""); + RNA_def_property_float_funcs(prop, "rna_Manipulator_scale_basis_get", "rna_Manipulator_scale_basis_set", NULL); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL); + RNA_def_property_ui_text(prop, "Line Width", ""); + RNA_def_property_float_funcs(prop, "rna_Manipulator_line_width_get", "rna_Manipulator_line_width_set", NULL); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* wmManipulator.flag */ + /* WM_MANIPULATOR_HIDDEN */ + prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_hide_get", "rna_Manipulator_flag_hide_set"); + RNA_def_property_ui_text(prop, "Hide", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_GRAB_CURSOR */ + prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_grab_cursor_get", "rna_Manipulator_flag_use_grab_cursor_set"); + RNA_def_property_ui_text(prop, "Grab Cursor", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* WM_MANIPULATOR_DRAW_HOVER */ + prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_draw_hover_get", "rna_Manipulator_flag_use_draw_hover_set"); + RNA_def_property_ui_text(prop, "Draw Hover", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_DRAW_MODAL */ + prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_draw_modal_get", "rna_Manipulator_flag_use_draw_modal_set"); + RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_DRAW_VALUE */ + prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_draw_value_get", "rna_Manipulator_flag_use_draw_value_set"); + RNA_def_property_ui_text(prop, "Draw Value", "Show an indicator for the current value while dragging"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_DRAW_OFFSET_SCALE */ + prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_draw_offset_scale_get", "rna_Manipulator_flag_use_draw_offset_scale_set"); + RNA_def_property_ui_text(prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_DRAW_NO_SCALE (negated) */ + prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_draw_scale_get", "rna_Manipulator_flag_use_draw_scale_set"); + RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_SELECT_BACKGROUND */ + prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_select_background_get", "rna_Manipulator_flag_use_select_background_set"); + RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* wmManipulator.state (readonly) */ + /* WM_MANIPULATOR_STATE_HIGHLIGHT */ + prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_highlight_get", NULL); + RNA_def_property_ui_text(prop, "Highlight", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + /* WM_MANIPULATOR_STATE_MODAL */ + prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_modal_get", NULL); + RNA_def_property_ui_text(prop, "Highlight", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + /* WM_MANIPULATOR_STATE_SELECT */ + /* (note that setting is involved, needs to handle array) */ + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_select_get", "rna_Manipulator_state_select_set"); + RNA_def_property_ui_text(prop, "Select", ""); + + RNA_api_manipulator(srna); + + srna = RNA_def_struct(brna, "ManipulatorProperties", NULL); + RNA_def_struct_ui_text(srna, "Manipulator Properties", "Input properties of an Manipulator"); + RNA_def_struct_refine_func(srna, "rna_ManipulatorProperties_refine"); + RNA_def_struct_idprops_func(srna, "rna_ManipulatorProperties_idprops"); + RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); +} + +static void rna_def_manipulatorgroup(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "ManipulatorGroup", NULL); + RNA_def_struct_ui_text(srna, "ManipulatorGroup", "Storage of an operator being executed, or registered after execution"); + RNA_def_struct_sdna(srna, "wmManipulatorGroup"); + RNA_def_struct_refine_func(srna, "rna_ManipulatorGroup_refine"); +#ifdef WITH_PYTHON + RNA_def_struct_register_funcs( + srna, + "rna_ManipulatorGroup_register", + "rna_ManipulatorGroup_unregister", + "rna_ManipulatorGroup_instance"); +#endif + RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + + /* -------------------------------------------------------------------- */ + /* Registration */ + + RNA_define_verify_sdna(0); /* not in sdna */ + + prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->idname"); + RNA_def_property_string_maxlength(prop, MAX_NAME); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_idname_set"); + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->name"); + RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */ + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_label_set"); + /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ + RNA_def_property_flag(prop, PROP_REGISTER); + + prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.spaceid"); + RNA_def_property_enum_items(prop, rna_enum_space_type_items); + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in"); + + prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.regionid"); + RNA_def_property_enum_items(prop, rna_enum_region_type_items); + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in"); + + prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->owner_id"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + + /* bl_options */ + static EnumPropertyItem manipulatorgroup_flag_items[] = { + {WM_MANIPULATORGROUPTYPE_3D, "3D", 0, "3D", + "Use in 3D viewport"}, + {WM_MANIPULATORGROUPTYPE_SCALE, "SCALE", 0, "Scale", + "Scale to respect zoom (otherwise zoom independent draw size)"}, + {WM_MANIPULATORGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D", + "Supports culled depth by other objects in the view"}, + {WM_MANIPULATORGROUPTYPE_SELECT, "SELECT", 0, "Select", + "Supports selection"}, + {WM_MANIPULATORGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", + ""}, + {WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All", + "Show all while interacting"}, + {0, NULL, 0, NULL, NULL} + }; + prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->flag"); + RNA_def_property_enum_items(prop, manipulatorgroup_flag_items); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Options", "Options for this operator type"); + + RNA_define_verify_sdna(1); /* not in sdna */ + + + /* Functions */ + + /* poll */ + func = RNA_def_function(srna, "poll", NULL); + RNA_def_function_ui_description(func, "Test if the manipulator group can be called or not"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); + RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* setup_keymap */ + func = RNA_def_function(srna, "setup_keymap", NULL); + RNA_def_function_ui_description( + func, + "Initialize keymaps for this manipulator group, use fallback keymap when not present"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + /* return */ + parm = RNA_def_pointer(func, "keymap", "KeyMap", "", ""); + RNA_def_property_flag(parm, PROP_NEVER_NULL); + RNA_def_function_return(func, parm); + + /* setup */ + func = RNA_def_function(srna, "setup", NULL); + RNA_def_function_ui_description(func, "Create manipulators function for the manipulator group"); + RNA_def_function_flag(func, FUNC_REGISTER); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* refresh */ + func = RNA_def_function(srna, "refresh", NULL); + RNA_def_function_ui_description(func, "Refresh data (called on common state changes such as selection)"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + func = RNA_def_function(srna, "draw_prepare", NULL); + RNA_def_function_ui_description(func, "Run before each redraw"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* -------------------------------------------------------------------- */ + /* Instance Variables */ + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_ManipulatorGroup_name_get", "rna_ManipulatorGroup_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", ""); + + prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */ + RNA_def_property_boolean_funcs(prop, "rna_ManipulatorGroup_has_reports_get", NULL); + RNA_def_property_ui_text(prop, "Has Reports", + "ManipulatorGroup has a set of reports (warnings and errors) from last execution"); + + + RNA_define_verify_sdna(0); /* not in sdna */ + + prop = RNA_def_property(srna, "manipulators", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "manipulators", NULL); + RNA_def_property_struct_type(prop, "Manipulator"); + RNA_def_property_collection_funcs( + prop, "rna_ManipulatorGroup_manipulators_begin", "rna_iterator_listbase_next", + "rna_iterator_listbase_end", "rna_iterator_listbase_get", + NULL, NULL, NULL, NULL); + + RNA_def_property_ui_text(prop, "Manipulators", "List of manipulators in the Manipulator Map"); + rna_def_manipulator(brna, prop); + rna_def_manipulators(brna, prop); + + RNA_define_verify_sdna(1); /* not in sdna */ + + RNA_api_manipulatorgroup(srna); +} + +void RNA_def_wm_manipulator(BlenderRNA *brna) +{ + rna_def_manipulatorgroup(brna); +} + +#endif /* RNA_RUNTIME */ diff --git a/source/blender/makesrna/intern/rna_wm_gizmo_api.c b/source/blender/makesrna/intern/rna_wm_gizmo_api.c new file mode 100644 index 00000000000..b06ba4d3dac --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_gizmo_api.c @@ -0,0 +1,290 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_wm_gizmo_api.c + * \ingroup RNA + */ + + +#include +#include + +#include "BLI_utildefines.h" + +#include "BKE_report.h" + +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "DNA_windowmanager_types.h" + +#include "WM_api.h" + +#include "rna_internal.h" /* own include */ + +#ifdef RNA_RUNTIME + +#include "UI_interface.h" +#include "BKE_context.h" + +#include "ED_gizmo_library.h" + +static void rna_manipulator_draw_preset_box( + wmManipulator *mpr, float matrix[16], int select_id) +{ + ED_manipulator_draw_preset_box(mpr, (float (*)[4])matrix, select_id); +} + +static void rna_manipulator_draw_preset_arrow( + wmManipulator *mpr, float matrix[16], int axis, int select_id) +{ + ED_manipulator_draw_preset_arrow(mpr, (float (*)[4])matrix, axis, select_id); +} + +static void rna_manipulator_draw_preset_circle( + wmManipulator *mpr, float matrix[16], int axis, int select_id) +{ + ED_manipulator_draw_preset_circle(mpr, (float (*)[4])matrix, axis, select_id); +} + +static void rna_manipulator_draw_preset_facemap( + wmManipulator *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id) +{ + struct Scene *scene = CTX_data_scene(C); + ED_manipulator_draw_preset_facemap(C, mpr, scene, ob, facemap, select_id); +} + +/* -------------------------------------------------------------------- */ +/** \name Manipulator Property Define + * \{ */ + +static void rna_manipulator_target_set_prop( + wmManipulator *mpr, ReportList *reports, const char *target_propname, + PointerRNA *ptr, const char *propname, int index) +{ + const wmManipulatorPropertyType *mpr_prop_type = + WM_manipulatortype_target_property_find(mpr->type, target_propname); + if (mpr_prop_type == NULL) { + BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found", + mpr->type->idname, target_propname); + return; + } + + PropertyRNA *prop = RNA_struct_find_property(ptr, propname); + if (prop == NULL) { + BKE_reportf(reports, RPT_ERROR, "Property '%s.%s' not found", + RNA_struct_identifier(ptr->type), target_propname); + return; + } + + if (mpr_prop_type->data_type != RNA_property_type(prop)) { + const int manipulator_type_index = RNA_enum_from_value(rna_enum_property_type_items, mpr_prop_type->data_type); + const int prop_type_index = RNA_enum_from_value(rna_enum_property_type_items, RNA_property_type(prop)); + BLI_assert((manipulator_type_index != -1) && (prop_type_index == -1)); + + BKE_reportf(reports, RPT_ERROR, "Manipulator target '%s.%s' expects '%s', '%s.%s' is '%s'", + mpr->type->idname, target_propname, + rna_enum_property_type_items[manipulator_type_index].identifier, + RNA_struct_identifier(ptr->type), propname, + rna_enum_property_type_items[prop_type_index].identifier); + return; + } + + if (RNA_property_array_check(prop)) { + if (index == -1) { + const int prop_array_length = RNA_property_array_length(ptr, prop); + if (mpr_prop_type->array_length != prop_array_length) { + BKE_reportf(reports, RPT_ERROR, + "Manipulator target property '%s.%s' expects an array of length %d, found %d", + mpr->type->idname, target_propname, + mpr_prop_type->array_length, + prop_array_length); + return; + } + } + } + else { + if (mpr_prop_type->array_length != 1) { + BKE_reportf(reports, RPT_ERROR, + "Manipulator target property '%s.%s' expects an array of length %d", + mpr->type->idname, target_propname, + mpr_prop_type->array_length); + return; + } + } + + if (index >= mpr_prop_type->array_length) { + BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s', index %d must be below %d", + mpr->type->idname, target_propname, index, mpr_prop_type->array_length); + return; + } + + WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); +} + +static PointerRNA rna_manipulator_target_set_operator( + wmManipulator *mpr, ReportList *reports, const char *opname, int part_index) +{ + wmOperatorType *ot; + + ot = WM_operatortype_find(opname, 0); /* print error next */ + if (!ot || !ot->srna) { + BKE_reportf(reports, RPT_ERROR, "%s '%s'", ot ? "unknown operator" : "operator missing srna", opname); + return PointerRNA_NULL; + } + + /* For the return value to be usable, we need 'PointerRNA.data' to be set. */ + IDProperty *properties; + { + IDPropertyTemplate val = {0}; + properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties"); + } + + return *WM_manipulator_operator_set(mpr, part_index, ot, properties); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Manipulator Property Access + * \{ */ + +static bool rna_manipulator_target_is_valid( + wmManipulator *mpr, ReportList *reports, const char *target_propname) +{ + wmManipulatorProperty *mpr_prop = + WM_manipulator_target_property_find(mpr, target_propname); + if (mpr_prop == NULL) { + BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found", + mpr->type->idname, target_propname); + return false; + } + return WM_manipulator_target_property_is_valid(mpr_prop); +} + +/** \} */ + +#else + +void RNA_api_manipulator(StructRNA *srna) +{ + /* Utility draw functions, since we don't expose new OpenGL drawing wrappers via Python yet. + * exactly how these should be exposed isn't totally clear. + * However it's probably good to have some high level API's for this anyway. + * Just note that this could be re-worked once tests are done. + */ + + FunctionRNA *func; + PropertyRNA *parm; + + /* -------------------------------------------------------------------- */ + /* Primitive Shapes */ + + /* draw_preset_box */ + func = RNA_def_function(srna, "draw_preset_box", "rna_manipulator_draw_preset_box"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(parm, "", "The matrix to transform"); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + /* draw_preset_box */ + func = RNA_def_function(srna, "draw_preset_arrow", "rna_manipulator_draw_preset_arrow"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(parm, "", "The matrix to transform"); + RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation"); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + func = RNA_def_function(srna, "draw_preset_circle", "rna_manipulator_draw_preset_circle"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(parm, "", "The matrix to transform"); + RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation"); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + /* -------------------------------------------------------------------- */ + /* Other Shapes */ + + /* draw_preset_facemap */ + func = RNA_def_function(srna, "draw_preset_facemap", "rna_manipulator_draw_preset_facemap"); + RNA_def_function_ui_description(func, "Draw the face-map of a mesh object"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + parm = RNA_def_pointer(func, "object", "Object", "", "Object"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + RNA_def_int(func, "facemap", 0, 0, INT_MAX, "Face map index", "", 0, INT_MAX); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + + /* -------------------------------------------------------------------- */ + /* Property API */ + + /* Define Properties */ + /* note, 'target_set_handler' is defined in 'bpy_rna_gizmo.c' */ + func = RNA_def_function(srna, "target_set_prop", "rna_manipulator_target_set_prop"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, ""); + parm = RNA_def_string(func, "target", NULL, 0, "", "Target property"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* similar to UILayout.prop */ + parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in data"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_int(func, "index", -1, -1, INT_MAX, "", "", -1, INT_MAX); /* RNA_NO_INDEX == -1 */ + + func = RNA_def_function(srna, "target_set_operator", "rna_manipulator_target_set_operator"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description( + func, "Operator to run when activating the manipulator " + "(overrides property targets)"); + parm = RNA_def_string(func, "operator", NULL, 0, "", "Target operator"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_int(func, "index", 0, 0, 255, "Part index", "", 0, 255); + + /* similar to UILayout.operator */ + parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "Operator properties to fill in"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_function_return(func, parm); + + /* Access Properties */ + /* note, 'target_get', 'target_set' is defined in 'bpy_rna_gizmo.c' */ + func = RNA_def_function(srna, "target_is_valid", "rna_manipulator_target_is_valid"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_string(func, "property", NULL, 0, "", "Property identifier"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_function_ui_description(func, ""); + parm = RNA_def_boolean(func, "result", 0, "", ""); + RNA_def_function_return(func, parm); + +} + + +void RNA_api_manipulatorgroup(StructRNA *UNUSED(srna)) +{ + /* nothing yet */ +} + +#endif diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c deleted file mode 100644 index f1abaa73e70..00000000000 --- a/source/blender/makesrna/intern/rna_wm_manipulator.c +++ /dev/null @@ -1,1335 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_wm_manipulator.c - * \ingroup RNA - */ - -#include - -#include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "DNA_userdef_types.h" -#include "DNA_view3d_types.h" -#include "DNA_windowmanager_types.h" - -#include "BLI_utildefines.h" -#include "BLI_string_utils.h" - -#include "BLT_translation.h" - -#include "RNA_access.h" -#include "RNA_define.h" -#include "RNA_enum_types.h" - -#include "rna_internal.h" - -#include "WM_types.h" - -#ifdef RNA_RUNTIME -/* enum definitions */ -#endif /* RNA_RUNTIME */ - -#ifdef RNA_RUNTIME - -#include - -#include "WM_api.h" - -#include "DNA_workspace_types.h" - -#include "ED_screen.h" - -#include "UI_interface.h" - -#include "BKE_global.h" -#include "BKE_idprop.h" -#include "BKE_workspace.h" - -#include "MEM_guardedalloc.h" - -#ifdef WITH_PYTHON -# include "BPY_extern.h" -#endif - -/* -------------------------------------------------------------------- */ - -/** \name Manipulator API - * \{ */ - -#ifdef WITH_PYTHON -static void rna_manipulator_draw_cb( - const struct bContext *C, struct wmManipulator *mpr) -{ - extern FunctionRNA rna_Manipulator_draw_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; - ParameterList list; - FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "draw"); */ - func = &rna_Manipulator_draw_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); - RNA_parameter_list_free(&list); -} - -static void rna_manipulator_draw_select_cb( - const struct bContext *C, struct wmManipulator *mpr, int select_id) -{ - extern FunctionRNA rna_Manipulator_draw_select_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; - ParameterList list; - FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "draw_select"); */ - func = &rna_Manipulator_draw_select_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - RNA_parameter_set_lookup(&list, "select_id", &select_id); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); - RNA_parameter_list_free(&list); -} - -static int rna_manipulator_test_select_cb( - struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event) -{ - extern FunctionRNA rna_Manipulator_test_select_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; - ParameterList list; - FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "test_select"); */ - func = &rna_Manipulator_test_select_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - RNA_parameter_set_lookup(&list, "event", &event); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); - - void *ret; - RNA_parameter_get_lookup(&list, "intersect_id", &ret); - int intersect_id = *(int *)ret; - - RNA_parameter_list_free(&list); - return intersect_id; -} - -static int rna_manipulator_modal_cb( - struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event, - eWM_ManipulatorTweak tweak_flag) -{ - extern FunctionRNA rna_Manipulator_modal_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; - ParameterList list; - FunctionRNA *func; - const int tweak_flag_int = tweak_flag; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "modal"); */ - func = &rna_Manipulator_modal_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - RNA_parameter_set_lookup(&list, "event", &event); - RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); - - void *ret; - RNA_parameter_get_lookup(&list, "result", &ret); - int ret_enum = *(int *)ret; - - RNA_parameter_list_free(&list); - return ret_enum; -} - -static void rna_manipulator_setup_cb( - struct wmManipulator *mpr) -{ - extern FunctionRNA rna_Manipulator_setup_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; - ParameterList list; - FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "setup"); */ - func = &rna_Manipulator_setup_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); - RNA_parameter_list_free(&list); -} - - -static int rna_manipulator_invoke_cb( - struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event) -{ - extern FunctionRNA rna_Manipulator_invoke_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; - ParameterList list; - FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "invoke"); */ - func = &rna_Manipulator_invoke_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - RNA_parameter_set_lookup(&list, "event", &event); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); - - void *ret; - RNA_parameter_get_lookup(&list, "result", &ret); - int ret_enum = *(int *)ret; - - RNA_parameter_list_free(&list); - return ret_enum; -} - -static void rna_manipulator_exit_cb( - struct bContext *C, struct wmManipulator *mpr, bool cancel) -{ - extern FunctionRNA rna_Manipulator_exit_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; - ParameterList list; - FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "exit"); */ - func = &rna_Manipulator_exit_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - { - int cancel_i = cancel; - RNA_parameter_set_lookup(&list, "cancel", &cancel_i); - } - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); - RNA_parameter_list_free(&list); -} - -static void rna_manipulator_select_refresh_cb( - struct wmManipulator *mpr) -{ - extern FunctionRNA rna_Manipulator_select_refresh_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; - ParameterList list; - FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "select_refresh"); */ - func = &rna_Manipulator_select_refresh_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); - RNA_parameter_list_free(&list); -} - -#endif /* WITH_PYTHON */ - -/* just to work around 'const char *' warning and to ensure this is a python op */ -static void rna_Manipulator_bl_idname_set(PointerRNA *ptr, const char *value) -{ - wmManipulator *data = ptr->data; - char *str = (char *)data->type->idname; - if (!str[0]) { - BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ - } - else { - assert(!"setting the bl_idname on a non-builtin operator"); - } -} - -static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr) -{ -#if 0 - wmWindowManager *wm = ptr->id.data; -#endif - - /* We could try workaruond this lookup, but not trivial. */ - for (bScreen *screen = G_MAIN->screen.first; screen; screen = screen->id.next) { - IDProperty *properties = ptr->data; - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->manipulator_map) { - wmManipulatorMap *mmap = ar->manipulator_map; - for (wmManipulatorGroup *mgroup = WM_manipulatormap_group_list(mmap)->first; - mgroup; - mgroup = mgroup->next) - { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->properties == properties) { - return mpr; - } - } - } - } - } - } - } - return NULL; -} - -static StructRNA *rna_ManipulatorProperties_refine(PointerRNA *ptr) -{ - wmManipulator *mpr = rna_ManipulatorProperties_find_operator(ptr); - - if (mpr) - return mpr->type->srna; - else - return ptr->type; -} - -static IDProperty *rna_ManipulatorProperties_idprops(PointerRNA *ptr, bool create) -{ - if (create && !ptr->data) { - IDPropertyTemplate val = {0}; - ptr->data = IDP_New(IDP_GROUP, &val, "RNA_ManipulatorProperties group"); - } - - return ptr->data; -} - -static PointerRNA rna_Manipulator_properties_get(PointerRNA *ptr) -{ - wmManipulator *mpr = ptr->data; - return rna_pointer_inherit_refine(ptr, mpr->type->srna, mpr->properties); -} - -/* wmManipulator.float */ -#define RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(func_id, member_id) \ -static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ -{ \ - wmManipulator *mpr = ptr->data; \ - return mpr->member_id; \ -} \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \ -{ \ - wmManipulator *mpr = ptr->data; \ - mpr->member_id = value; \ -} -#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \ -static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ -{ \ - wmManipulator *mpr = ptr->data; \ - return mpr->member_id[index]; \ -} \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \ -{ \ - wmManipulator *mpr = ptr->data; \ - mpr->member_id[index] = value; \ -} -/* wmManipulator.float[len] */ -#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \ -static void rna_Manipulator_##func_id##_get(PointerRNA *ptr, float value[len]) \ -{ \ - wmManipulator *mpr = ptr->data; \ - memcpy(value, mpr->member_id, sizeof(float[len])); \ -} \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, const float value[len]) \ -{ \ - wmManipulator *mpr = ptr->data; \ - memcpy(mpr->member_id, value, sizeof(float[len])); \ -} - -/* wmManipulator.flag */ -#define RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \ -static bool rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ -{ \ - wmManipulator *mpr = ptr->data; \ - return (mpr->member_id & flag_value) != 0; \ -} \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, bool value) \ -{ \ - wmManipulator *mpr = ptr->data; \ - SET_FLAG_FROM_TEST(mpr->member_id, value, flag_value); \ -} - -/* wmManipulator.flag (negative) */ -#define RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \ -static bool rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ -{ \ - wmManipulator *mpr = ptr->data; \ - return (mpr->member_id & flag_value) == 0; \ -} \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, bool value) \ -{ \ - wmManipulator *mpr = ptr->data; \ - SET_FLAG_FROM_TEST(mpr->member_id, !value, flag_value); \ -} - -#define RNA_MANIPULATOR_FLAG_RO_DEF(func_id, member_id, flag_value) \ -static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ -{ \ - wmManipulator *mpr = ptr->data; \ - return (mpr->member_id & flag_value) != 0; \ -} - -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3); - -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3); - -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16); - -static void rna_Manipulator_matrix_world_get(PointerRNA *ptr, float value[16]) -{ - wmManipulator *mpr = ptr->data; - WM_manipulator_calc_matrix_final(mpr, (float (*)[4])value); -} - -RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis); -RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(line_width, line_width); - -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_MANIPULATOR_DRAW_HOVER); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_MANIPULATOR_DRAW_MODAL); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_MANIPULATOR_DRAW_VALUE); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE); -RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_MANIPULATOR_GRAB_CURSOR); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_MANIPULATOR_SELECT_BACKGROUND); - -/* wmManipulator.state */ -RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT); -RNA_MANIPULATOR_FLAG_RO_DEF(state_is_modal, state, WM_MANIPULATOR_STATE_MODAL); -RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT); - -static void rna_Manipulator_state_select_set(struct PointerRNA *ptr, bool value) -{ - wmManipulator *mpr = ptr->data; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - WM_manipulator_select_set(mgroup->parent_mmap, mpr, value); -} - -static PointerRNA rna_Manipulator_group_get(PointerRNA *ptr) -{ - wmManipulator *mpr = ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_ManipulatorGroup, mpr->parent_mgroup); -} - -#ifdef WITH_PYTHON - -static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type); -void BPY_RNA_manipulator_wrapper(wmManipulatorType *wgt, void *userdata); - -static StructRNA *rna_Manipulator_register( - Main *bmain, ReportList *reports, void *data, const char *identifier, - StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) -{ - struct { - char idname[MAX_NAME]; - } temp_buffers; - - wmManipulatorType dummywt = {NULL}; - wmManipulator dummymnp = {NULL}; - PointerRNA mnp_ptr; - - /* Two sets of functions. */ - int have_function[8]; - - /* setup dummy manipulator & manipulator type to store static properties in */ - dummymnp.type = &dummywt; - dummywt.idname = temp_buffers.idname; - RNA_pointer_create(NULL, &RNA_Manipulator, &dummymnp, &mnp_ptr); - - /* Clear so we can detect if it's left unset. */ - temp_buffers.idname[0] = '\0'; - - /* validate the python class */ - if (validate(&mnp_ptr, data, have_function) != 0) - return NULL; - - if (strlen(identifier) >= sizeof(temp_buffers.idname)) { - BKE_reportf(reports, RPT_ERROR, "Registering manipulator class: '%s' is too long, maximum length is %d", - identifier, (int)sizeof(temp_buffers.idname)); - return NULL; - } - - /* check if we have registered this manipulator type before, and remove it */ - { - const wmManipulatorType *wt = WM_manipulatortype_find(dummywt.idname, true); - if (wt && wt->ext.srna) { - rna_Manipulator_unregister(bmain, wt->ext.srna); - } - } - if (!RNA_struct_available_or_report(reports, dummywt.idname)) { - return NULL; - } - - { /* allocate the idname */ - /* For multiple strings see ManipulatorGroup. */ - dummywt.idname = BLI_strdup(temp_buffers.idname); - } - - /* create a new manipulator type */ - dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Manipulator); - /* manipulator properties are registered separately */ - RNA_def_struct_flag(dummywt.ext.srna, STRUCT_NO_IDPROPERTIES); - dummywt.ext.data = data; - dummywt.ext.call = call; - dummywt.ext.free = free; - - { - int i = 0; - dummywt.draw = (have_function[i++]) ? rna_manipulator_draw_cb : NULL; - dummywt.draw_select = (have_function[i++]) ? rna_manipulator_draw_select_cb : NULL; - dummywt.test_select = (have_function[i++]) ? rna_manipulator_test_select_cb : NULL; - dummywt.modal = (have_function[i++]) ? rna_manipulator_modal_cb : NULL; -// dummywt.property_update = (have_function[i++]) ? rna_manipulator_property_update : NULL; -// dummywt.position_get = (have_function[i++]) ? rna_manipulator_position_get : NULL; - dummywt.setup = (have_function[i++]) ? rna_manipulator_setup_cb : NULL; - dummywt.invoke = (have_function[i++]) ? rna_manipulator_invoke_cb : NULL; - dummywt.exit = (have_function[i++]) ? rna_manipulator_exit_cb : NULL; - dummywt.select_refresh = (have_function[i++]) ? rna_manipulator_select_refresh_cb : NULL; - - BLI_assert(i == ARRAY_SIZE(have_function)); - } - - WM_manipulatortype_append_ptr(BPY_RNA_manipulator_wrapper, (void *)&dummywt); - - /* update while blender is running */ - WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - - return dummywt.ext.srna; -} - -static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type) -{ - wmManipulatorType *wt = RNA_struct_blender_type_get(type); - - if (!wt) - return; - - RNA_struct_free_extension(type, &wt->ext); - RNA_struct_free(&BLENDER_RNA, type); - - WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - - WM_manipulatortype_remove_ptr(NULL, bmain, wt); -} - -static void **rna_Manipulator_instance(PointerRNA *ptr) -{ - wmManipulator *mpr = ptr->data; - return &mpr->py_instance; -} - -#endif /* WITH_PYTHON */ - - -static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr) -{ - wmManipulator *mpr = mnp_ptr->data; - return (mpr->type && mpr->type->ext.srna) ? mpr->type->ext.srna : &RNA_Manipulator; -} - -/** \} */ - -/** \name Manipulator Group API - * \{ */ - -static wmManipulator *rna_ManipulatorGroup_manipulator_new( - wmManipulatorGroup *mgroup, ReportList *reports, const char *idname) -{ - const wmManipulatorType *wt = WM_manipulatortype_find(idname, true); - if (wt == NULL) { - BKE_reportf(reports, RPT_ERROR, "ManipulatorType '%s' not known", idname); - return NULL; - } - wmManipulator *mpr = WM_manipulator_new_ptr(wt, mgroup, NULL); - return mpr; -} - -static void rna_ManipulatorGroup_manipulator_remove( - wmManipulatorGroup *mgroup, bContext *C, wmManipulator *mpr) -{ - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C); -} - -static void rna_ManipulatorGroup_manipulator_clear( - wmManipulatorGroup *mgroup, bContext *C) -{ - while (mgroup->manipulators.first) { - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mgroup->manipulators.first, C); - } -} - -static void rna_ManipulatorGroup_name_get(PointerRNA *ptr, char *value) -{ - wmManipulatorGroup *mgroup = ptr->data; - strcpy(value, mgroup->type->name); -} - -static int rna_ManipulatorGroup_name_length(PointerRNA *ptr) -{ - wmManipulatorGroup *mgroup = ptr->data; - return strlen(mgroup->type->name); -} - -/* just to work around 'const char *' warning and to ensure this is a python op */ -static void rna_ManipulatorGroup_bl_idname_set(PointerRNA *ptr, const char *value) -{ - wmManipulatorGroup *data = ptr->data; - char *str = (char *)data->type->idname; - if (!str[0]) - BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ - else - assert(!"setting the bl_idname on a non-builtin operator"); -} - -static void rna_ManipulatorGroup_bl_label_set(PointerRNA *ptr, const char *value) -{ - wmManipulatorGroup *data = ptr->data; - char *str = (char *)data->type->name; - if (!str[0]) - BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ - else - assert(!"setting the bl_label on a non-builtin operator"); -} - -static bool rna_ManipulatorGroup_has_reports_get(PointerRNA *ptr) -{ - wmManipulatorGroup *mgroup = ptr->data; - return (mgroup->reports && mgroup->reports->list.first); -} - -#ifdef WITH_PYTHON - -static bool rna_manipulatorgroup_poll_cb(const bContext *C, wmManipulatorGroupType *wgt) -{ - - extern FunctionRNA rna_ManipulatorGroup_poll_func; - - PointerRNA ptr; - ParameterList list; - FunctionRNA *func; - void *ret; - int visible; - - RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ - func = &rna_ManipulatorGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ - - RNA_parameter_list_create(&list, &ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - wgt->ext.call((bContext *)C, &ptr, func, &list); - - RNA_parameter_get_lookup(&list, "visible", &ret); - visible = *(int *)ret; - - RNA_parameter_list_free(&list); - - return visible; -} - -static void rna_manipulatorgroup_setup_cb(const bContext *C, wmManipulatorGroup *mgroup) -{ - extern FunctionRNA rna_ManipulatorGroup_setup_func; - - PointerRNA mgroup_ptr; - ParameterList list; - FunctionRNA *func; - - RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); - func = &rna_ManipulatorGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */ - - RNA_parameter_list_create(&list, &mgroup_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); - - RNA_parameter_list_free(&list); -} - -static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupType *wgt, wmKeyConfig *config) -{ - extern FunctionRNA rna_ManipulatorGroup_setup_keymap_func; - void *ret; - - PointerRNA ptr; - ParameterList list; - FunctionRNA *func; - - RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ - func = &rna_ManipulatorGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */ - - RNA_parameter_list_create(&list, &ptr, func); - RNA_parameter_set_lookup(&list, "keyconfig", &config); - wgt->ext.call(NULL, &ptr, func, &list); - - RNA_parameter_get_lookup(&list, "keymap", &ret); - wmKeyMap *keymap = *(wmKeyMap **)ret; - - RNA_parameter_list_free(&list); - - return keymap; -} - -static void rna_manipulatorgroup_refresh_cb(const bContext *C, wmManipulatorGroup *mgroup) -{ - extern FunctionRNA rna_ManipulatorGroup_refresh_func; - - PointerRNA mgroup_ptr; - ParameterList list; - FunctionRNA *func; - - RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); - func = &rna_ManipulatorGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */ - - RNA_parameter_list_create(&list, &mgroup_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); - - RNA_parameter_list_free(&list); -} - -static void rna_manipulatorgroup_draw_prepare_cb(const bContext *C, wmManipulatorGroup *mgroup) -{ - extern FunctionRNA rna_ManipulatorGroup_draw_prepare_func; - - PointerRNA mgroup_ptr; - ParameterList list; - FunctionRNA *func; - - RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); - func = &rna_ManipulatorGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */ - - RNA_parameter_list_create(&list, &mgroup_ptr, func); - RNA_parameter_set_lookup(&list, "context", &C); - mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); - - RNA_parameter_list_free(&list); -} - -void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata); -static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type); - -static StructRNA *rna_ManipulatorGroup_register( - Main *bmain, ReportList *reports, void *data, const char *identifier, - StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) -{ - struct { - char name[MAX_NAME]; - char idname[MAX_NAME]; - } temp_buffers; - - wmManipulatorGroupType dummywgt = {NULL}; - wmManipulatorGroup dummywg = {NULL}; - PointerRNA wgptr; - - /* Two sets of functions. */ - int have_function[5]; - - /* setup dummy manipulatorgroup & manipulatorgroup type to store static properties in */ - dummywg.type = &dummywgt; - dummywgt.name = temp_buffers.name; - dummywgt.idname = temp_buffers.idname; - - RNA_pointer_create(NULL, &RNA_ManipulatorGroup, &dummywg, &wgptr); - - /* Clear so we can detect if it's left unset. */ - temp_buffers.idname[0] = temp_buffers.name[0] = '\0'; - - /* validate the python class */ - if (validate(&wgptr, data, have_function) != 0) - return NULL; - - if (strlen(identifier) >= sizeof(temp_buffers.idname)) { - BKE_reportf(reports, RPT_ERROR, "Registering manipulatorgroup class: '%s' is too long, maximum length is %d", - identifier, (int)sizeof(temp_buffers.idname)); - return NULL; - } - - /* check if the area supports widgets */ - const struct wmManipulatorMapType_Params wmap_params = { - .spaceid = dummywgt.mmap_params.spaceid, - .regionid = dummywgt.mmap_params.regionid, - }; - - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wmap_params); - if (mmap_type == NULL) { - BKE_reportf(reports, RPT_ERROR, "Area type does not support manipulators"); - return NULL; - } - - /* check if we have registered this manipulatorgroup type before, and remove it */ - { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true); - if (wgt && wgt->ext.srna) { - rna_ManipulatorGroup_unregister(bmain, wgt->ext.srna); - } - } - if (!RNA_struct_available_or_report(reports, dummywgt.idname)) { - return NULL; - } - - { /* allocate the idname */ - const char *strings[] = { - temp_buffers.idname, - temp_buffers.name, - }; - char *strings_table[ARRAY_SIZE(strings)]; - BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings)); - - dummywgt.idname = strings_table[0]; /* allocated string stored here */ - dummywgt.name = strings_table[1]; - BLI_assert(ARRAY_SIZE(strings) == 2); - } - - /* create a new manipulatorgroup type */ - dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_ManipulatorGroup); - RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* manipulatorgroup properties are registered separately */ - dummywgt.ext.data = data; - dummywgt.ext.call = call; - dummywgt.ext.free = free; - - /* We used to register widget group types like this, now we do it similar to - * operator types. Thus we should be able to do the same as operator types now. */ - dummywgt.poll = (have_function[0]) ? rna_manipulatorgroup_poll_cb : NULL; - dummywgt.setup_keymap = (have_function[1]) ? rna_manipulatorgroup_setup_keymap_cb : NULL; - dummywgt.setup = (have_function[2]) ? rna_manipulatorgroup_setup_cb : NULL; - dummywgt.refresh = (have_function[3]) ? rna_manipulatorgroup_refresh_cb : NULL; - dummywgt.draw_prepare = (have_function[4]) ? rna_manipulatorgroup_draw_prepare_cb : NULL; - - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr( - BPY_RNA_manipulatorgroup_wrapper, (void *)&dummywgt); - - { - const char *owner_id = RNA_struct_state_owner_get(); - if (owner_id) { - BLI_strncpy(wgt->owner_id, owner_id, sizeof(wgt->owner_id)); - } - } - - if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) { - WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); - - /* update while blender is running */ - WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - } - - return dummywgt.ext.srna; -} - -static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type) -{ - wmManipulatorGroupType *wgt = RNA_struct_blender_type_get(type); - - if (!wgt) - return; - - RNA_struct_free_extension(type, &wgt->ext); - RNA_struct_free(&BLENDER_RNA, type); - - WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - - WM_manipulator_group_type_remove_ptr(bmain, wgt); -} - -static void **rna_ManipulatorGroup_instance(PointerRNA *ptr) -{ - wmManipulatorGroup *mgroup = ptr->data; - return &mgroup->py_instance; -} - -#endif /* WITH_PYTHON */ - -static StructRNA *rna_ManipulatorGroup_refine(PointerRNA *mgroup_ptr) -{ - wmManipulatorGroup *mgroup = mgroup_ptr->data; - return (mgroup->type && mgroup->type->ext.srna) ? mgroup->type->ext.srna : &RNA_ManipulatorGroup; -} - -static void rna_ManipulatorGroup_manipulators_begin(CollectionPropertyIterator *iter, PointerRNA *mgroup_ptr) -{ - wmManipulatorGroup *mgroup = mgroup_ptr->data; - rna_iterator_listbase_begin(iter, &mgroup->manipulators, NULL); -} - -/** \} */ - - -#else /* RNA_RUNTIME */ - - -/* ManipulatorGroup.manipulators */ -static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "Manipulators"); - srna = RNA_def_struct(brna, "Manipulators", NULL); - RNA_def_struct_sdna(srna, "wmManipulatorGroup"); - RNA_def_struct_ui_text(srna, "Manipulators", "Collection of manipulators"); - - func = RNA_def_function(srna, "new", "rna_ManipulatorGroup_manipulator_new"); - RNA_def_function_ui_description(func, "Add manipulator"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_string(func, "type", "Type", 0, "", "Manipulator identifier"); /* optional */ - parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator"); - RNA_def_function_return(func, parm); - - func = RNA_def_function(srna, "remove", "rna_ManipulatorGroup_manipulator_remove"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT); - RNA_def_function_ui_description(func, "Delete manipulator"); - parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); - - func = RNA_def_function(srna, "clear", "rna_ManipulatorGroup_manipulator_clear"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT); - RNA_def_function_ui_description(func, "Delete all manipulators"); -} - - -static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "Manipulator"); - srna = RNA_def_struct(brna, "Manipulator", NULL); - RNA_def_struct_sdna(srna, "wmManipulator"); - RNA_def_struct_ui_text(srna, "Manipulator", "Collection of manipulators"); - RNA_def_struct_refine_func(srna, "rna_Manipulator_refine"); - -#ifdef WITH_PYTHON - RNA_def_struct_register_funcs( - srna, - "rna_Manipulator_register", - "rna_Manipulator_unregister", - "rna_Manipulator_instance"); -#endif - RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); - - prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "ManipulatorProperties"); - RNA_def_property_ui_text(prop, "Properties", ""); - RNA_def_property_pointer_funcs(prop, "rna_Manipulator_properties_get", NULL, NULL, NULL); - - /* -------------------------------------------------------------------- */ - /* Registerable Variables */ - - RNA_define_verify_sdna(0); /* not in sdna */ - - prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "type->idname"); - RNA_def_property_string_maxlength(prop, MAX_NAME); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Manipulator_bl_idname_set"); - /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ - RNA_def_property_flag(prop, PROP_REGISTER); - - RNA_define_verify_sdna(1); /* not in sdna */ - - /* wmManipulator.draw */ - func = RNA_def_function(srna, "draw", NULL); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_REGISTER); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - - /* wmManipulator.draw_select */ - func = RNA_def_function(srna, "draw_select", NULL); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX); - - /* wmManipulator.test_select */ - func = RNA_def_function(srna, "test_select", NULL); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_pointer(func, "event", "Event", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_int(func, "intersect_id", 0, 0, INT_MAX, "", "", 0, INT_MAX); - RNA_def_function_return(func, parm); - - /* wmManipulator.handler */ - static EnumPropertyItem tweak_actions[] = { - {WM_MANIPULATOR_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""}, - {WM_MANIPULATOR_TWEAK_SNAP, "SNAP", 0, "Snap", ""}, - {0, NULL, 0, NULL, NULL} - }; - func = RNA_def_function(srna, "modal", NULL); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_pointer(func, "event", "Event", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - /* TODO, shuold be a enum-flag */ - parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", ""); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", ""); - RNA_def_function_return(func, parm); - /* wmManipulator.property_update */ - /* TODO */ - - /* wmManipulator.setup */ - func = RNA_def_function(srna, "setup", NULL); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - - /* wmManipulator.invoke */ - func = RNA_def_function(srna, "invoke", NULL); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_pointer(func, "event", "Event", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", ""); - RNA_def_function_return(func, parm); - - /* wmManipulator.exit */ - func = RNA_def_function(srna, "exit", NULL); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", ""); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - /* wmManipulator.cursor_get */ - /* TODO */ - - /* wmManipulator.select_refresh */ - func = RNA_def_function(srna, "select_refresh", NULL); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - - - /* -------------------------------------------------------------------- */ - /* Instance Variables */ - - prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_struct_type(prop, "ManipulatorGroup"); - RNA_def_property_pointer_funcs(prop, "rna_Manipulator_group_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "", "Manipulator group this manipulator is a member of"); - - /* Color & Alpha */ - prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 3); - RNA_def_property_float_funcs(prop, "rna_Manipulator_color_get", "rna_Manipulator_color_set", NULL); - - prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_text(prop, "Alpha", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_get", "rna_Manipulator_alpha_set", NULL); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - /* Color & Alpha (highlight) */ - prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 3); - RNA_def_property_float_funcs(prop, "rna_Manipulator_color_hi_get", "rna_Manipulator_color_hi_set", NULL); - - prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_text(prop, "Alpha", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_hi_get", "rna_Manipulator_alpha_hi_set", NULL); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_ui_text(prop, "Space Matrix", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_space_get", "rna_Manipulator_matrix_space_set", NULL); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_ui_text(prop, "Basis Matrix", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_basis_get", "rna_Manipulator_matrix_basis_set", NULL); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_ui_text(prop, "Offset Matrix", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_offset_get", "rna_Manipulator_matrix_offset_set", NULL); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_ui_text(prop, "Final World Matrix", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_world_get", NULL, NULL); - - prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_text(prop, "Scale Basis", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_scale_basis_get", "rna_Manipulator_scale_basis_set", NULL); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL); - RNA_def_property_ui_text(prop, "Line Width", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_line_width_get", "rna_Manipulator_line_width_set", NULL); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - /* wmManipulator.flag */ - /* WM_MANIPULATOR_HIDDEN */ - prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_hide_get", "rna_Manipulator_flag_hide_set"); - RNA_def_property_ui_text(prop, "Hide", ""); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_GRAB_CURSOR */ - prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_grab_cursor_get", "rna_Manipulator_flag_use_grab_cursor_set"); - RNA_def_property_ui_text(prop, "Grab Cursor", ""); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - /* WM_MANIPULATOR_DRAW_HOVER */ - prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_hover_get", "rna_Manipulator_flag_use_draw_hover_set"); - RNA_def_property_ui_text(prop, "Draw Hover", ""); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_MODAL */ - prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_modal_get", "rna_Manipulator_flag_use_draw_modal_set"); - RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_VALUE */ - prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_value_get", "rna_Manipulator_flag_use_draw_value_set"); - RNA_def_property_ui_text(prop, "Draw Value", "Show an indicator for the current value while dragging"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_OFFSET_SCALE */ - prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_offset_scale_get", "rna_Manipulator_flag_use_draw_offset_scale_set"); - RNA_def_property_ui_text(prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_NO_SCALE (negated) */ - prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_scale_get", "rna_Manipulator_flag_use_draw_scale_set"); - RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_SELECT_BACKGROUND */ - prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_select_background_get", "rna_Manipulator_flag_use_select_background_set"); - RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - - /* wmManipulator.state (readonly) */ - /* WM_MANIPULATOR_STATE_HIGHLIGHT */ - prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_highlight_get", NULL); - RNA_def_property_ui_text(prop, "Highlight", ""); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - /* WM_MANIPULATOR_STATE_MODAL */ - prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_modal_get", NULL); - RNA_def_property_ui_text(prop, "Highlight", ""); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - /* WM_MANIPULATOR_STATE_SELECT */ - /* (note that setting is involved, needs to handle array) */ - prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_select_get", "rna_Manipulator_state_select_set"); - RNA_def_property_ui_text(prop, "Select", ""); - - RNA_api_manipulator(srna); - - srna = RNA_def_struct(brna, "ManipulatorProperties", NULL); - RNA_def_struct_ui_text(srna, "Manipulator Properties", "Input properties of an Manipulator"); - RNA_def_struct_refine_func(srna, "rna_ManipulatorProperties_refine"); - RNA_def_struct_idprops_func(srna, "rna_ManipulatorProperties_idprops"); - RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); -} - -static void rna_def_manipulatorgroup(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - srna = RNA_def_struct(brna, "ManipulatorGroup", NULL); - RNA_def_struct_ui_text(srna, "ManipulatorGroup", "Storage of an operator being executed, or registered after execution"); - RNA_def_struct_sdna(srna, "wmManipulatorGroup"); - RNA_def_struct_refine_func(srna, "rna_ManipulatorGroup_refine"); -#ifdef WITH_PYTHON - RNA_def_struct_register_funcs( - srna, - "rna_ManipulatorGroup_register", - "rna_ManipulatorGroup_unregister", - "rna_ManipulatorGroup_instance"); -#endif - RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); - - /* -------------------------------------------------------------------- */ - /* Registration */ - - RNA_define_verify_sdna(0); /* not in sdna */ - - prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "type->idname"); - RNA_def_property_string_maxlength(prop, MAX_NAME); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_idname_set"); - RNA_def_property_flag(prop, PROP_REGISTER); - RNA_def_struct_name_property(srna, prop); - - prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "type->name"); - RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */ - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_label_set"); - /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ - RNA_def_property_flag(prop, PROP_REGISTER); - - prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.spaceid"); - RNA_def_property_enum_items(prop, rna_enum_space_type_items); - RNA_def_property_flag(prop, PROP_REGISTER); - RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in"); - - prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.regionid"); - RNA_def_property_enum_items(prop, rna_enum_region_type_items); - RNA_def_property_flag(prop, PROP_REGISTER); - RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in"); - - prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "type->owner_id"); - RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); - - /* bl_options */ - static EnumPropertyItem manipulatorgroup_flag_items[] = { - {WM_MANIPULATORGROUPTYPE_3D, "3D", 0, "3D", - "Use in 3D viewport"}, - {WM_MANIPULATORGROUPTYPE_SCALE, "SCALE", 0, "Scale", - "Scale to respect zoom (otherwise zoom independent draw size)"}, - {WM_MANIPULATORGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D", - "Supports culled depth by other objects in the view"}, - {WM_MANIPULATORGROUPTYPE_SELECT, "SELECT", 0, "Select", - "Supports selection"}, - {WM_MANIPULATORGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", - ""}, - {WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All", - "Show all while interacting"}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type->flag"); - RNA_def_property_enum_items(prop, manipulatorgroup_flag_items); - RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG); - RNA_def_property_ui_text(prop, "Options", "Options for this operator type"); - - RNA_define_verify_sdna(1); /* not in sdna */ - - - /* Functions */ - - /* poll */ - func = RNA_def_function(srna, "poll", NULL); - RNA_def_function_ui_description(func, "Test if the manipulator group can be called or not"); - RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); - RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - - /* setup_keymap */ - func = RNA_def_function(srna, "setup_keymap", NULL); - RNA_def_function_ui_description( - func, - "Initialize keymaps for this manipulator group, use fallback keymap when not present"); - RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); - parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - /* return */ - parm = RNA_def_pointer(func, "keymap", "KeyMap", "", ""); - RNA_def_property_flag(parm, PROP_NEVER_NULL); - RNA_def_function_return(func, parm); - - /* setup */ - func = RNA_def_function(srna, "setup", NULL); - RNA_def_function_ui_description(func, "Create manipulators function for the manipulator group"); - RNA_def_function_flag(func, FUNC_REGISTER); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - - /* refresh */ - func = RNA_def_function(srna, "refresh", NULL); - RNA_def_function_ui_description(func, "Refresh data (called on common state changes such as selection)"); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - - func = RNA_def_function(srna, "draw_prepare", NULL); - RNA_def_function_ui_description(func, "Run before each redraw"); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); - parm = RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - - /* -------------------------------------------------------------------- */ - /* Instance Variables */ - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_string_funcs(prop, "rna_ManipulatorGroup_name_get", "rna_ManipulatorGroup_name_length", NULL); - RNA_def_property_ui_text(prop, "Name", ""); - - prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */ - RNA_def_property_boolean_funcs(prop, "rna_ManipulatorGroup_has_reports_get", NULL); - RNA_def_property_ui_text(prop, "Has Reports", - "ManipulatorGroup has a set of reports (warnings and errors) from last execution"); - - - RNA_define_verify_sdna(0); /* not in sdna */ - - prop = RNA_def_property(srna, "manipulators", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "manipulators", NULL); - RNA_def_property_struct_type(prop, "Manipulator"); - RNA_def_property_collection_funcs( - prop, "rna_ManipulatorGroup_manipulators_begin", "rna_iterator_listbase_next", - "rna_iterator_listbase_end", "rna_iterator_listbase_get", - NULL, NULL, NULL, NULL); - - RNA_def_property_ui_text(prop, "Manipulators", "List of manipulators in the Manipulator Map"); - rna_def_manipulator(brna, prop); - rna_def_manipulators(brna, prop); - - RNA_define_verify_sdna(1); /* not in sdna */ - - RNA_api_manipulatorgroup(srna); -} - -void RNA_def_wm_manipulator(BlenderRNA *brna) -{ - rna_def_manipulatorgroup(brna); -} - -#endif /* RNA_RUNTIME */ diff --git a/source/blender/makesrna/intern/rna_wm_manipulator_api.c b/source/blender/makesrna/intern/rna_wm_manipulator_api.c deleted file mode 100644 index 16804042608..00000000000 --- a/source/blender/makesrna/intern/rna_wm_manipulator_api.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_wm_manipulator_api.c - * \ingroup RNA - */ - - -#include -#include - -#include "BLI_utildefines.h" - -#include "BKE_report.h" - -#include "RNA_define.h" -#include "RNA_enum_types.h" - -#include "DNA_windowmanager_types.h" - -#include "WM_api.h" - -#include "rna_internal.h" /* own include */ - -#ifdef RNA_RUNTIME - -#include "UI_interface.h" -#include "BKE_context.h" - -#include "ED_manipulator_library.h" - -static void rna_manipulator_draw_preset_box( - wmManipulator *mpr, float matrix[16], int select_id) -{ - ED_manipulator_draw_preset_box(mpr, (float (*)[4])matrix, select_id); -} - -static void rna_manipulator_draw_preset_arrow( - wmManipulator *mpr, float matrix[16], int axis, int select_id) -{ - ED_manipulator_draw_preset_arrow(mpr, (float (*)[4])matrix, axis, select_id); -} - -static void rna_manipulator_draw_preset_circle( - wmManipulator *mpr, float matrix[16], int axis, int select_id) -{ - ED_manipulator_draw_preset_circle(mpr, (float (*)[4])matrix, axis, select_id); -} - -static void rna_manipulator_draw_preset_facemap( - wmManipulator *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id) -{ - struct Scene *scene = CTX_data_scene(C); - ED_manipulator_draw_preset_facemap(C, mpr, scene, ob, facemap, select_id); -} - -/* -------------------------------------------------------------------- */ -/** \name Manipulator Property Define - * \{ */ - -static void rna_manipulator_target_set_prop( - wmManipulator *mpr, ReportList *reports, const char *target_propname, - PointerRNA *ptr, const char *propname, int index) -{ - const wmManipulatorPropertyType *mpr_prop_type = - WM_manipulatortype_target_property_find(mpr->type, target_propname); - if (mpr_prop_type == NULL) { - BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found", - mpr->type->idname, target_propname); - return; - } - - PropertyRNA *prop = RNA_struct_find_property(ptr, propname); - if (prop == NULL) { - BKE_reportf(reports, RPT_ERROR, "Property '%s.%s' not found", - RNA_struct_identifier(ptr->type), target_propname); - return; - } - - if (mpr_prop_type->data_type != RNA_property_type(prop)) { - const int manipulator_type_index = RNA_enum_from_value(rna_enum_property_type_items, mpr_prop_type->data_type); - const int prop_type_index = RNA_enum_from_value(rna_enum_property_type_items, RNA_property_type(prop)); - BLI_assert((manipulator_type_index != -1) && (prop_type_index == -1)); - - BKE_reportf(reports, RPT_ERROR, "Manipulator target '%s.%s' expects '%s', '%s.%s' is '%s'", - mpr->type->idname, target_propname, - rna_enum_property_type_items[manipulator_type_index].identifier, - RNA_struct_identifier(ptr->type), propname, - rna_enum_property_type_items[prop_type_index].identifier); - return; - } - - if (RNA_property_array_check(prop)) { - if (index == -1) { - const int prop_array_length = RNA_property_array_length(ptr, prop); - if (mpr_prop_type->array_length != prop_array_length) { - BKE_reportf(reports, RPT_ERROR, - "Manipulator target property '%s.%s' expects an array of length %d, found %d", - mpr->type->idname, target_propname, - mpr_prop_type->array_length, - prop_array_length); - return; - } - } - } - else { - if (mpr_prop_type->array_length != 1) { - BKE_reportf(reports, RPT_ERROR, - "Manipulator target property '%s.%s' expects an array of length %d", - mpr->type->idname, target_propname, - mpr_prop_type->array_length); - return; - } - } - - if (index >= mpr_prop_type->array_length) { - BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s', index %d must be below %d", - mpr->type->idname, target_propname, index, mpr_prop_type->array_length); - return; - } - - WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); -} - -static PointerRNA rna_manipulator_target_set_operator( - wmManipulator *mpr, ReportList *reports, const char *opname, int part_index) -{ - wmOperatorType *ot; - - ot = WM_operatortype_find(opname, 0); /* print error next */ - if (!ot || !ot->srna) { - BKE_reportf(reports, RPT_ERROR, "%s '%s'", ot ? "unknown operator" : "operator missing srna", opname); - return PointerRNA_NULL; - } - - /* For the return value to be usable, we need 'PointerRNA.data' to be set. */ - IDProperty *properties; - { - IDPropertyTemplate val = {0}; - properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties"); - } - - return *WM_manipulator_operator_set(mpr, part_index, ot, properties); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Manipulator Property Access - * \{ */ - -static bool rna_manipulator_target_is_valid( - wmManipulator *mpr, ReportList *reports, const char *target_propname) -{ - wmManipulatorProperty *mpr_prop = - WM_manipulator_target_property_find(mpr, target_propname); - if (mpr_prop == NULL) { - BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found", - mpr->type->idname, target_propname); - return false; - } - return WM_manipulator_target_property_is_valid(mpr_prop); -} - -/** \} */ - -#else - -void RNA_api_manipulator(StructRNA *srna) -{ - /* Utility draw functions, since we don't expose new OpenGL drawing wrappers via Python yet. - * exactly how these should be exposed isn't totally clear. - * However it's probably good to have some high level API's for this anyway. - * Just note that this could be re-worked once tests are done. - */ - - FunctionRNA *func; - PropertyRNA *parm; - - /* -------------------------------------------------------------------- */ - /* Primitive Shapes */ - - /* draw_preset_box */ - func = RNA_def_function(srna, "draw_preset_box", "rna_manipulator_draw_preset_box"); - RNA_def_function_ui_description(func, "Draw a box"); - parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); - RNA_def_property_ui_text(parm, "", "The matrix to transform"); - RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); - - /* draw_preset_box */ - func = RNA_def_function(srna, "draw_preset_arrow", "rna_manipulator_draw_preset_arrow"); - RNA_def_function_ui_description(func, "Draw a box"); - parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); - RNA_def_property_ui_text(parm, "", "The matrix to transform"); - RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation"); - RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); - - func = RNA_def_function(srna, "draw_preset_circle", "rna_manipulator_draw_preset_circle"); - RNA_def_function_ui_description(func, "Draw a box"); - parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); - RNA_def_property_ui_text(parm, "", "The matrix to transform"); - RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation"); - RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); - - /* -------------------------------------------------------------------- */ - /* Other Shapes */ - - /* draw_preset_facemap */ - func = RNA_def_function(srna, "draw_preset_facemap", "rna_manipulator_draw_preset_facemap"); - RNA_def_function_ui_description(func, "Draw the face-map of a mesh object"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT); - parm = RNA_def_pointer(func, "object", "Object", "", "Object"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - RNA_def_int(func, "facemap", 0, 0, INT_MAX, "Face map index", "", 0, INT_MAX); - RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); - - - /* -------------------------------------------------------------------- */ - /* Property API */ - - /* Define Properties */ - /* note, 'target_set_handler' is defined in 'bpy_rna_manipulator.c' */ - func = RNA_def_function(srna, "target_set_prop", "rna_manipulator_target_set_prop"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, ""); - parm = RNA_def_string(func, "target", NULL, 0, "", "Target property"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - /* similar to UILayout.prop */ - parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); - parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in data"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_int(func, "index", -1, -1, INT_MAX, "", "", -1, INT_MAX); /* RNA_NO_INDEX == -1 */ - - func = RNA_def_function(srna, "target_set_operator", "rna_manipulator_target_set_operator"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description( - func, "Operator to run when activating the manipulator " - "(overrides property targets)"); - parm = RNA_def_string(func, "operator", NULL, 0, "", "Target operator"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_int(func, "index", 0, 0, 255, "Part index", "", 0, 255); - - /* similar to UILayout.operator */ - parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "Operator properties to fill in"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR); - RNA_def_function_return(func, parm); - - /* Access Properties */ - /* note, 'target_get', 'target_set' is defined in 'bpy_rna_manipulator.c' */ - func = RNA_def_function(srna, "target_is_valid", "rna_manipulator_target_is_valid"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_string(func, "property", NULL, 0, "", "Property identifier"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_function_ui_description(func, ""); - parm = RNA_def_boolean(func, "result", 0, "", ""); - RNA_def_function_return(func, parm); - -} - - -void RNA_api_manipulatorgroup(StructRNA *UNUSED(srna)) -{ - /* nothing yet */ -} - -#endif diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index b3f4b4977bf..3255fb49667 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -66,7 +66,7 @@ set(SRC bpy_intern_string.c bpy_library_load.c bpy_library_write.c - bpy_manipulator_wrap.c + bpy_gizmo_wrap.c bpy_msgbus.c bpy_operator.c bpy_operator_wrap.c @@ -78,7 +78,7 @@ set(SRC bpy_rna_callback.c bpy_rna_driver.c bpy_rna_id_collection.c - bpy_rna_manipulator.c + bpy_rna_gizmo.c bpy_traceback.c bpy_utils_previews.c bpy_utils_units.c @@ -105,7 +105,7 @@ set(SRC bpy_driver.h bpy_intern_string.h bpy_library.h - bpy_manipulator_wrap.h + bpy_gizmo_wrap.h bpy_msgbus.h bpy_operator.h bpy_operator_wrap.h @@ -116,7 +116,7 @@ set(SRC bpy_rna_callback.h bpy_rna_driver.h bpy_rna_id_collection.h - bpy_rna_manipulator.h + bpy_rna_gizmo.h bpy_traceback.h bpy_utils_previews.h bpy_utils_units.h diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 751625e378b..3083322d496 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -46,7 +46,7 @@ #include "bpy_rna.h" #include "bpy_app.h" #include "bpy_rna_id_collection.h" -#include "bpy_rna_manipulator.h" +#include "bpy_rna_gizmo.h" #include "bpy_props.h" #include "bpy_library.h" #include "bpy_operator.h" diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c new file mode 100644 index 00000000000..eda1f58a4cc --- /dev/null +++ b/source/blender/python/intern/bpy_gizmo_wrap.c @@ -0,0 +1,235 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_gizmo_wrap.c + * \ingroup pythonintern + * + * This file is so Python can define widget-group's that C can call into. + * The generic callback functions for Python widget-group are defines in + * 'rna_wm.c', some calling into functions here to do python specific + * functionality. + * + * \note This follows 'bpy_operator_wrap.c' very closely. + * Keep in sync unless there is good reason not to! + */ + +#include + +#include "BLI_utildefines.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "bpy_rna.h" +#include "bpy_intern_string.h" +#include "bpy_gizmo_wrap.h" /* own include */ + +/* we may want to add, but not now */ + +/* -------------------------------------------------------------------- */ + +/** \name Manipulator + * \{ */ + + +static bool bpy_manipulatortype_target_property_def( + wmManipulatorType *wt, PyObject *item) +{ + /* Note: names based on 'rna_rna.c' */ + PyObject *empty_tuple = PyTuple_New(0); + + struct { + char *id; + char *type_id; int type; + int array_length; + } params = { + .id = NULL, /* not optional */ + .type = PROP_FLOAT, + .type_id = NULL, + .array_length = 1, + }; + + static const char * const _keywords[] = {"id", "type", "array_length", NULL}; + static _PyArg_Parser _parser = {"|$ssi:register_class", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast( + empty_tuple, item, + &_parser, + ¶ms.id, + ¶ms.type_id, + ¶ms.array_length)) + { + goto fail; + } + + if (params.id == NULL) { + PyErr_SetString(PyExc_ValueError, "'id' argument not given"); + goto fail; + } + + if ((params.type_id != NULL) && + pyrna_enum_value_from_id( + rna_enum_property_type_items, params.type_id, ¶ms.type, "'type' enum value") == -1) + { + goto fail; + } + else { + params.type = rna_enum_property_type_items[params.type].value; + } + + if ((params.array_length < 1 || params.array_length > RNA_MAX_ARRAY_LENGTH)) { + PyErr_SetString(PyExc_ValueError, "'array_length' out of range"); + goto fail; + } + + WM_manipulatortype_target_property_def(wt, params.id, params.type, params.array_length); + Py_DECREF(empty_tuple); + return true; + +fail: + Py_DECREF(empty_tuple); + return false; +} + +static void manipulator_properties_init(wmManipulatorType *wt) +{ + PyTypeObject *py_class = wt->ext.data; + RNA_struct_blender_type_set(wt->ext.srna, wt); + + /* only call this so pyrna_deferred_register_class gives a useful error + * WM_operatortype_append_ptr will call RNA_def_struct_identifier + * later */ + RNA_def_struct_identifier_no_struct_map(wt->srna, wt->idname); + + if (pyrna_deferred_register_class(wt->srna, py_class) != 0) { + PyErr_Print(); /* failed to register operator props */ + PyErr_Clear(); + } + + /* Extract target property definitions from 'bl_target_properties' */ + { + /* picky developers will notice that 'bl_targets' won't work with inheritance + * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */ + PyObject *py_class_dict = py_class->tp_dict; + PyObject *bl_target_properties = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_target_properties); + + /* Some widgets may only exist to activate operators. */ + if (bl_target_properties != NULL) { + PyObject *bl_target_properties_fast; + if (!(bl_target_properties_fast = PySequence_Fast( + bl_target_properties, "bl_target_properties sequence"))) + { + /* PySequence_Fast sets the error */ + PyErr_Print(); + PyErr_Clear(); + return; + } + + const uint items_len = PySequence_Fast_GET_SIZE(bl_target_properties_fast); + PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast); + + for (uint i = 0; i < items_len; i++) { + if (!bpy_manipulatortype_target_property_def(wt, items[i])) { + PyErr_Print(); + PyErr_Clear(); + break; + } + } + + Py_DECREF(bl_target_properties_fast); + } + } +} + +void BPY_RNA_manipulator_wrapper(wmManipulatorType *wt, void *userdata) +{ + /* take care not to overwrite anything set in + * WM_manipulatormaptype_group_link_ptr before opfunc() is called */ + StructRNA *srna = wt->srna; + *wt = *((wmManipulatorType *)userdata); + wt->srna = srna; /* restore */ + + /* don't do translations here yet */ +#if 0 + /* Use i18n context from ext.srna if possible (py manipulatorgroups). */ + if (wt->ext.srna) { + RNA_def_struct_translation_context(wt->srna, RNA_struct_translation_context(wt->ext.srna)); + } +#endif + + wt->struct_size = sizeof(wmManipulator); + + manipulator_properties_init(wt); +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Manipulator Group + * \{ */ + +static void manipulatorgroup_properties_init(wmManipulatorGroupType *wgt) +{ +#ifdef USE_SRNA + PyTypeObject *py_class = wgt->ext.data; +#endif + RNA_struct_blender_type_set(wgt->ext.srna, wgt); + +#ifdef USE_SRNA + /* only call this so pyrna_deferred_register_class gives a useful error + * WM_operatortype_append_ptr will call RNA_def_struct_identifier + * later */ + RNA_def_struct_identifier(wgt->srna, wgt->idname); + + if (pyrna_deferred_register_class(wgt->srna, py_class) != 0) { + PyErr_Print(); /* failed to register operator props */ + PyErr_Clear(); + } +#endif +} + +void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata) +{ + /* take care not to overwrite anything set in + * WM_manipulatormaptype_group_link_ptr before opfunc() is called */ +#ifdef USE_SRNA + StructRNA *srna = wgt->srna; +#endif + *wgt = *((wmManipulatorGroupType *)userdata); +#ifdef USE_SRNA + wgt->srna = srna; /* restore */ +#endif + +#ifdef USE_SRNA + /* Use i18n context from ext.srna if possible (py manipulatorgroups). */ + if (wgt->ext.srna) { + RNA_def_struct_translation_context(wgt->srna, RNA_struct_translation_context(wgt->ext.srna)); + } +#endif + + manipulatorgroup_properties_init(wgt); +} + +/** \} */ diff --git a/source/blender/python/intern/bpy_gizmo_wrap.h b/source/blender/python/intern/bpy_gizmo_wrap.h new file mode 100644 index 00000000000..71fa123d6ce --- /dev/null +++ b/source/blender/python/intern/bpy_gizmo_wrap.h @@ -0,0 +1,35 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_gizmo_wrap.h + * \ingroup pythonintern + */ + +#ifndef __BPY_GIZMO_WRAP_H__ +#define __BPY_GIZMO_WRAP_H__ + +struct wmManipulatorType; +struct wmManipulatorGroupType; + +/* exposed to rna/wm api */ +void BPY_RNA_manipulator_wrapper(struct wmManipulatorType *wt, void *userdata); +void BPY_RNA_manipulatorgroup_wrapper(struct wmManipulatorGroupType *wgt, void *userdata); + +#endif /* __BPY_GIZMO_WRAP_H__ */ diff --git a/source/blender/python/intern/bpy_manipulator_wrap.c b/source/blender/python/intern/bpy_manipulator_wrap.c deleted file mode 100644 index 3703ea92fa7..00000000000 --- a/source/blender/python/intern/bpy_manipulator_wrap.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/intern/bpy_manipulator_wrap.c - * \ingroup pythonintern - * - * This file is so Python can define widget-group's that C can call into. - * The generic callback functions for Python widget-group are defines in - * 'rna_wm.c', some calling into functions here to do python specific - * functionality. - * - * \note This follows 'bpy_operator_wrap.c' very closely. - * Keep in sync unless there is good reason not to! - */ - -#include - -#include "BLI_utildefines.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "RNA_access.h" -#include "RNA_define.h" -#include "RNA_enum_types.h" - -#include "bpy_rna.h" -#include "bpy_intern_string.h" -#include "bpy_manipulator_wrap.h" /* own include */ - -/* we may want to add, but not now */ - -/* -------------------------------------------------------------------- */ - -/** \name Manipulator - * \{ */ - - -static bool bpy_manipulatortype_target_property_def( - wmManipulatorType *wt, PyObject *item) -{ - /* Note: names based on 'rna_rna.c' */ - PyObject *empty_tuple = PyTuple_New(0); - - struct { - char *id; - char *type_id; int type; - int array_length; - } params = { - .id = NULL, /* not optional */ - .type = PROP_FLOAT, - .type_id = NULL, - .array_length = 1, - }; - - static const char * const _keywords[] = {"id", "type", "array_length", NULL}; - static _PyArg_Parser _parser = {"|$ssi:register_class", _keywords, 0}; - if (!_PyArg_ParseTupleAndKeywordsFast( - empty_tuple, item, - &_parser, - ¶ms.id, - ¶ms.type_id, - ¶ms.array_length)) - { - goto fail; - } - - if (params.id == NULL) { - PyErr_SetString(PyExc_ValueError, "'id' argument not given"); - goto fail; - } - - if ((params.type_id != NULL) && - pyrna_enum_value_from_id( - rna_enum_property_type_items, params.type_id, ¶ms.type, "'type' enum value") == -1) - { - goto fail; - } - else { - params.type = rna_enum_property_type_items[params.type].value; - } - - if ((params.array_length < 1 || params.array_length > RNA_MAX_ARRAY_LENGTH)) { - PyErr_SetString(PyExc_ValueError, "'array_length' out of range"); - goto fail; - } - - WM_manipulatortype_target_property_def(wt, params.id, params.type, params.array_length); - Py_DECREF(empty_tuple); - return true; - -fail: - Py_DECREF(empty_tuple); - return false; -} - -static void manipulator_properties_init(wmManipulatorType *wt) -{ - PyTypeObject *py_class = wt->ext.data; - RNA_struct_blender_type_set(wt->ext.srna, wt); - - /* only call this so pyrna_deferred_register_class gives a useful error - * WM_operatortype_append_ptr will call RNA_def_struct_identifier - * later */ - RNA_def_struct_identifier_no_struct_map(wt->srna, wt->idname); - - if (pyrna_deferred_register_class(wt->srna, py_class) != 0) { - PyErr_Print(); /* failed to register operator props */ - PyErr_Clear(); - } - - /* Extract target property definitions from 'bl_target_properties' */ - { - /* picky developers will notice that 'bl_targets' won't work with inheritance - * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */ - PyObject *py_class_dict = py_class->tp_dict; - PyObject *bl_target_properties = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_target_properties); - - /* Some widgets may only exist to activate operators. */ - if (bl_target_properties != NULL) { - PyObject *bl_target_properties_fast; - if (!(bl_target_properties_fast = PySequence_Fast( - bl_target_properties, "bl_target_properties sequence"))) - { - /* PySequence_Fast sets the error */ - PyErr_Print(); - PyErr_Clear(); - return; - } - - const uint items_len = PySequence_Fast_GET_SIZE(bl_target_properties_fast); - PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast); - - for (uint i = 0; i < items_len; i++) { - if (!bpy_manipulatortype_target_property_def(wt, items[i])) { - PyErr_Print(); - PyErr_Clear(); - break; - } - } - - Py_DECREF(bl_target_properties_fast); - } - } -} - -void BPY_RNA_manipulator_wrapper(wmManipulatorType *wt, void *userdata) -{ - /* take care not to overwrite anything set in - * WM_manipulatormaptype_group_link_ptr before opfunc() is called */ - StructRNA *srna = wt->srna; - *wt = *((wmManipulatorType *)userdata); - wt->srna = srna; /* restore */ - - /* don't do translations here yet */ -#if 0 - /* Use i18n context from ext.srna if possible (py manipulatorgroups). */ - if (wt->ext.srna) { - RNA_def_struct_translation_context(wt->srna, RNA_struct_translation_context(wt->ext.srna)); - } -#endif - - wt->struct_size = sizeof(wmManipulator); - - manipulator_properties_init(wt); -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Manipulator Group - * \{ */ - -static void manipulatorgroup_properties_init(wmManipulatorGroupType *wgt) -{ -#ifdef USE_SRNA - PyTypeObject *py_class = wgt->ext.data; -#endif - RNA_struct_blender_type_set(wgt->ext.srna, wgt); - -#ifdef USE_SRNA - /* only call this so pyrna_deferred_register_class gives a useful error - * WM_operatortype_append_ptr will call RNA_def_struct_identifier - * later */ - RNA_def_struct_identifier(wgt->srna, wgt->idname); - - if (pyrna_deferred_register_class(wgt->srna, py_class) != 0) { - PyErr_Print(); /* failed to register operator props */ - PyErr_Clear(); - } -#endif -} - -void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata) -{ - /* take care not to overwrite anything set in - * WM_manipulatormaptype_group_link_ptr before opfunc() is called */ -#ifdef USE_SRNA - StructRNA *srna = wgt->srna; -#endif - *wgt = *((wmManipulatorGroupType *)userdata); -#ifdef USE_SRNA - wgt->srna = srna; /* restore */ -#endif - -#ifdef USE_SRNA - /* Use i18n context from ext.srna if possible (py manipulatorgroups). */ - if (wgt->ext.srna) { - RNA_def_struct_translation_context(wgt->srna, RNA_struct_translation_context(wgt->ext.srna)); - } -#endif - - manipulatorgroup_properties_init(wgt); -} - -/** \} */ diff --git a/source/blender/python/intern/bpy_manipulator_wrap.h b/source/blender/python/intern/bpy_manipulator_wrap.h deleted file mode 100644 index 3e415350228..00000000000 --- a/source/blender/python/intern/bpy_manipulator_wrap.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/intern/bpy_manipulator_wrap.h - * \ingroup pythonintern - */ - -#ifndef __BPY_MANIPULATOR_WRAP_H__ -#define __BPY_MANIPULATOR_WRAP_H__ - -struct wmManipulatorType; -struct wmManipulatorGroupType; - -/* exposed to rna/wm api */ -void BPY_RNA_manipulator_wrapper(struct wmManipulatorType *wt, void *userdata); -void BPY_RNA_manipulatorgroup_wrapper(struct wmManipulatorGroupType *wgt, void *userdata); - -#endif /* __BPY_MANIPULATOR_WRAP_H__ */ diff --git a/source/blender/python/intern/bpy_msgbus.c b/source/blender/python/intern/bpy_msgbus.c index b76ecafe6f0..101cc8b41a3 100644 --- a/source/blender/python/intern/bpy_msgbus.c +++ b/source/blender/python/intern/bpy_msgbus.c @@ -44,7 +44,7 @@ #include "bpy_capi_utils.h" #include "bpy_rna.h" #include "bpy_intern_string.h" -#include "bpy_manipulator_wrap.h" /* own include */ +#include "bpy_gizmo_wrap.h" /* own include */ #include "bpy_msgbus.h" /* own include */ diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.c new file mode 100644 index 00000000000..34a4594bdae --- /dev/null +++ b/source/blender/python/intern/bpy_rna_gizmo.c @@ -0,0 +1,565 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_rna_gizmo.c + * \ingroup pythonintern + * + * . + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_alloca.h" + +#include "BKE_main.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "bpy_capi_utils.h" +#include "bpy_rna_gizmo.h" + +#include "../generic/py_capi_utils.h" +#include "../generic/python_utildefines.h" + +#include "RNA_access.h" +#include "RNA_types.h" +#include "RNA_enum_types.h" + +#include "bpy_rna.h" + + +/* -------------------------------------------------------------------- */ +/** \name Manipulator Target Property Define API + * \{ */ + +enum { + BPY_MANIPULATOR_FN_SLOT_GET = 0, + BPY_MANIPULATOR_FN_SLOT_SET, + BPY_MANIPULATOR_FN_SLOT_RANGE_GET, +}; +#define BPY_MANIPULATOR_FN_SLOT_LEN (BPY_MANIPULATOR_FN_SLOT_RANGE_GET + 1) + +struct BPyManipulatorHandlerUserData { + + PyObject *fn_slots[BPY_MANIPULATOR_FN_SLOT_LEN]; +}; + +static void py_rna_manipulator_handler_get_cb( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + void *value_p) +{ + PyGILState_STATE gilstate = PyGILState_Ensure(); + + struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; + PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_GET], NULL); + if (ret == NULL) { + goto fail; + } + + if (mpr_prop->type->data_type == PROP_FLOAT) { + float *value = value_p; + if (mpr_prop->type->array_length == 1) { + if ((*value = PyFloat_AsDouble(ret)) == -1.0f && PyErr_Occurred()) { + goto fail; + } + } + else { + if (PyC_AsArray(value, ret, mpr_prop->type->array_length, &PyFloat_Type, false, + "Manipulator get callback: ") == -1) + { + goto fail; + } + } + } + else { + PyErr_SetString(PyExc_AttributeError, "internal error, unsupported type"); + goto fail; + } + + Py_DECREF(ret); + + PyGILState_Release(gilstate); + return; + +fail: + PyErr_Print(); + PyErr_Clear(); + + PyGILState_Release(gilstate); +} + +static void py_rna_manipulator_handler_set_cb( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + const void *value_p) +{ + PyGILState_STATE gilstate = PyGILState_Ensure(); + + struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; + + PyObject *args = PyTuple_New(1); + + if (mpr_prop->type->data_type == PROP_FLOAT) { + const float *value = value_p; + PyObject *py_value; + if (mpr_prop->type->array_length == 1) { + py_value = PyFloat_FromDouble(*value); + } + else { + py_value = PyC_Tuple_PackArray_F32(value, mpr_prop->type->array_length); + } + if (py_value == NULL) { + goto fail; + } + PyTuple_SET_ITEM(args, 0, py_value); + } + else { + PyErr_SetString(PyExc_AttributeError, "internal error, unsupported type"); + goto fail; + } + + PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_SET], args); + if (ret == NULL) { + goto fail; + } + Py_DECREF(ret); + + PyGILState_Release(gilstate); + return; + +fail: + PyErr_Print(); + PyErr_Clear(); + + Py_DECREF(args); + + PyGILState_Release(gilstate); +} + +static void py_rna_manipulator_handler_range_get_cb( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, + void *value_p) +{ + struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; + + PyGILState_STATE gilstate = PyGILState_Ensure(); + + PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET], NULL); + if (ret == NULL) { + goto fail; + } + + if (!PyTuple_Check(ret)) { + PyErr_Format(PyExc_TypeError, + "Expected a tuple, not %.200s", + Py_TYPE(ret)->tp_name); + goto fail; + } + + if (PyTuple_GET_SIZE(ret) != 2) { + PyErr_Format(PyExc_TypeError, + "Expected a tuple of size 2, not %d", + PyTuple_GET_SIZE(ret)); + goto fail; + } + + if (mpr_prop->type->data_type == PROP_FLOAT) { + float range[2]; + for (int i = 0; i < 2; i++) { + if (((range[i] = PyFloat_AsDouble(PyTuple_GET_ITEM(ret, i))) == -1.0f && PyErr_Occurred()) == 0) { + /* pass */ + } + else { + goto fail; + } + } + memcpy(value_p, range, sizeof(range)); + } + else { + PyErr_SetString(PyExc_AttributeError, "internal error, unsupported type"); + goto fail; + } + + Py_DECREF(ret); + PyGILState_Release(gilstate); + return; + +fail: + Py_XDECREF(ret); + + PyErr_Print(); + PyErr_Clear(); + + PyGILState_Release(gilstate); +} + +static void py_rna_manipulator_handler_free_cb( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop) +{ + struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; + + PyGILState_STATE gilstate = PyGILState_Ensure(); + for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { + Py_XDECREF(data->fn_slots[i]); + } + PyGILState_Release(gilstate); + + MEM_freeN(data); + +} + +PyDoc_STRVAR(bpy_manipulator_target_set_handler_doc, +".. method:: target_set_handler(target, get, set, range=None):\n" +"\n" +" Assigns callbacks to a manipulators property.\n" +"\n" +" :arg get: Function that returns the value for this property (single value or sequence).\n" +" :type get: callable\n" +" :arg set: Function that takes a single value argument and applies it.\n" +" :type set: callable\n" +" :arg range: Function that returns a (min, max) tuple for manipulators that use a range.\n" +" :type range: callable\n" +); +static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +{ + PyGILState_STATE gilstate = PyGILState_Ensure(); + + struct { + PyObject *self; + char *target; + PyObject *py_fn_slots[BPY_MANIPULATOR_FN_SLOT_LEN]; + } params = { + .self = NULL, + .target = NULL, + .py_fn_slots = {NULL}, + }; + + /* Note: this is a counter-part to functions: + * 'Manipulator.target_set_prop & target_set_operator' + * (see: rna_wm_manipulator_api.c). conventions should match. */ + static const char * const _keywords[] = {"self", "target", "get", "set", "range", NULL}; + static _PyArg_Parser _parser = {"Os|$OOO:target_set_handler", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast( + args, kw, &_parser, + ¶ms.self, + ¶ms.target, + ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_GET], + ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_SET], + ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET])) + { + goto fail; + } + + wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + + const wmManipulatorPropertyType *mpr_prop_type = + WM_manipulatortype_target_property_find(mpr->type, params.target); + if (mpr_prop_type == NULL) { + PyErr_Format(PyExc_ValueError, + "Manipulator target property '%s.%s' not found", + mpr->type->idname, params.target); + goto fail; + } + + { + const int slots_required = 2; + const int slots_start = 2; + for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { + if (params.py_fn_slots[i] == NULL) { + if (i < slots_required) { + PyErr_Format(PyExc_ValueError, "Argument '%s' not given", _keywords[slots_start + i]); + goto fail; + } + } + else if (!PyCallable_Check(params.py_fn_slots[i])) { + PyErr_Format(PyExc_ValueError, "Argument '%s' not callable", _keywords[slots_start + i]); + goto fail; + } + } + } + + struct BPyManipulatorHandlerUserData *data = MEM_callocN(sizeof(*data), __func__); + + for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { + data->fn_slots[i] = params.py_fn_slots[i]; + Py_XINCREF(params.py_fn_slots[i]); + } + + WM_manipulator_target_property_def_func_ptr( + mpr, mpr_prop_type, + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = py_rna_manipulator_handler_get_cb, + .value_set_fn = py_rna_manipulator_handler_set_cb, + .range_get_fn = py_rna_manipulator_handler_range_get_cb, + .free_fn = py_rna_manipulator_handler_free_cb, + .user_data = data, + }); + + PyGILState_Release(gilstate); + + Py_RETURN_NONE; + +fail: + PyGILState_Release(gilstate); + return NULL; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Manipulator Target Property Access API + * \{ */ + +PyDoc_STRVAR(bpy_manipulator_target_get_value_doc, +".. method:: target_get_value(target):\n" +"\n" +" Get the value of this target property.\n" +"\n" +" :arg target: Target property name.\n" +" :type target: string\n" +" :return: The value of the target property.\n" +" :rtype: Single value or array based on the target type\n" +); +static PyObject *bpy_manipulator_target_get_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +{ + struct { + PyObject *self; + char *target; + } params = { + .self = NULL, + .target = NULL, + }; + + static const char * const _keywords[] = {"self", "target", NULL}; + static _PyArg_Parser _parser = {"Os:target_get_value", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast( + args, kw, &_parser, + ¶ms.self, + ¶ms.target)) + { + goto fail; + } + + wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + + wmManipulatorProperty *mpr_prop = + WM_manipulator_target_property_find(mpr, params.target); + if (mpr_prop == NULL) { + PyErr_Format(PyExc_ValueError, + "Manipulator target property '%s.%s' not found", + mpr->type->idname, params.target); + goto fail; + } + + const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop); + switch (mpr_prop->type->data_type) { + case PROP_FLOAT: + { + if (array_len != 0) { + float *value = BLI_array_alloca(value, array_len); + WM_manipulator_target_property_value_get_array(mpr, mpr_prop, value); + return PyC_Tuple_PackArray_F32(value, array_len); + } + else { + float value = WM_manipulator_target_property_value_get(mpr, mpr_prop); + return PyFloat_FromDouble(value); + } + break; + } + default: + { + PyErr_SetString(PyExc_RuntimeError, "Not yet supported type"); + goto fail; + } + } + +fail: + return NULL; +} + +PyDoc_STRVAR(bpy_manipulator_target_set_value_doc, +".. method:: target_set_value(target):\n" +"\n" +" Set the value of this target property.\n" +"\n" +" :arg target: Target property name.\n" +" :type target: string\n" +); +static PyObject *bpy_manipulator_target_set_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +{ + struct { + PyObject *self; + char *target; + PyObject *value; + } params = { + .self = NULL, + .target = NULL, + .value = NULL, + }; + + static const char * const _keywords[] = {"self", "target", "value", NULL}; + static _PyArg_Parser _parser = {"OsO:target_set_value", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast( + args, kw, &_parser, + ¶ms.self, + ¶ms.target, + ¶ms.value)) + { + goto fail; + } + + wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + + wmManipulatorProperty *mpr_prop = + WM_manipulator_target_property_find(mpr, params.target); + if (mpr_prop == NULL) { + PyErr_Format(PyExc_ValueError, + "Manipulator target property '%s.%s' not found", + mpr->type->idname, params.target); + goto fail; + } + + const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop); + switch (mpr_prop->type->data_type) { + case PROP_FLOAT: + { + if (array_len != 0) { + float *value = BLI_array_alloca(value, array_len); + if (PyC_AsArray(value, params.value, mpr_prop->type->array_length, &PyFloat_Type, false, + "Manipulator target property array") == -1) + { + goto fail; + } + WM_manipulator_target_property_value_set_array(BPy_GetContext(), mpr, mpr_prop, value); + } + else { + float value; + if ((value = PyFloat_AsDouble(params.value)) == -1.0f && PyErr_Occurred()) { + goto fail; + } + WM_manipulator_target_property_value_set(BPy_GetContext(), mpr, mpr_prop, value); + } + Py_RETURN_NONE; + } + default: + { + PyErr_SetString(PyExc_RuntimeError, "Not yet supported type"); + goto fail; + } + } + +fail: + return NULL; +} + + +PyDoc_STRVAR(bpy_manipulator_target_get_range_doc, +".. method:: target_get_range(target):\n" +"\n" +" Get the range for this target property.\n" +"\n" +" :arg target: Target property name.\n" +" :Get the range for this target property" +" :return: The range of this property (min, max).\n" +" :rtype: tuple pair.\n" +); +static PyObject *bpy_manipulator_target_get_range(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +{ + struct { + PyObject *self; + char *target; + } params = { + .self = NULL, + .target = NULL, + }; + + static const char * const _keywords[] = {"self", "target", NULL}; + static _PyArg_Parser _parser = {"Os:target_get_range", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast( + args, kw, &_parser, + ¶ms.self, + ¶ms.target)) + { + goto fail; + } + + wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + + wmManipulatorProperty *mpr_prop = + WM_manipulator_target_property_find(mpr, params.target); + if (mpr_prop == NULL) { + PyErr_Format(PyExc_ValueError, + "Manipulator target property '%s.%s' not found", + mpr->type->idname, params.target); + goto fail; + } + + switch (mpr_prop->type->data_type) { + case PROP_FLOAT: + { + float range[2]; + WM_manipulator_target_property_range_get(mpr, mpr_prop, range); + return PyC_Tuple_PackArray_F32(range, 2); + } + default: + { + PyErr_SetString(PyExc_RuntimeError, "Not yet supported type"); + goto fail; + } + } + +fail: + return NULL; +} + +/** \} */ + +int BPY_rna_manipulator_module(PyObject *mod_par) +{ + static PyMethodDef method_def_array[] = { + /* Manipulator Target Property Define API */ + {"target_set_handler", (PyCFunction)bpy_manipulator_target_set_handler, + METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_handler_doc}, + /* Manipulator Target Property Access API */ + {"target_get_value", (PyCFunction)bpy_manipulator_target_get_value, + METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_value_doc}, + {"target_set_value", (PyCFunction)bpy_manipulator_target_set_value, + METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_value_doc}, + {"target_get_range", (PyCFunction)bpy_manipulator_target_get_range, + METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_range_doc}, + /* no sentinel needed. */ + }; + + for (int i = 0; i < ARRAY_SIZE(method_def_array); i++) { + PyMethodDef *m = &method_def_array[i]; + PyObject *func = PyCFunction_New(m, NULL); + PyObject *func_inst = PyInstanceMethod_New(func); + char name_prefix[128]; + PyOS_snprintf(name_prefix, sizeof(name_prefix), "_rna_manipulator_%s", m->ml_name); + /* TODO, return a type that binds nearly to a method. */ + PyModule_AddObject(mod_par, name_prefix, func_inst); + } + + return 0; +} diff --git a/source/blender/python/intern/bpy_rna_gizmo.h b/source/blender/python/intern/bpy_rna_gizmo.h new file mode 100644 index 00000000000..e848fd9800f --- /dev/null +++ b/source/blender/python/intern/bpy_rna_gizmo.h @@ -0,0 +1,32 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Bastien Montagne + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/intern/bpy_rna_gizmo.h + * \ingroup pythonintern + */ + +#ifndef __BPY_RNA_GIZMO_H__ +#define __BPY_RNA_GIZMO_H__ + +int BPY_rna_manipulator_module(PyObject *); + +#endif /* __BPY_RNA_GIZMO_H__ */ diff --git a/source/blender/python/intern/bpy_rna_manipulator.c b/source/blender/python/intern/bpy_rna_manipulator.c deleted file mode 100644 index 950f7f98be0..00000000000 --- a/source/blender/python/intern/bpy_rna_manipulator.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/intern/bpy_rna_manipulator.c - * \ingroup pythonintern - * - * . - */ - -#include -#include - -#include "MEM_guardedalloc.h" - -#include "BLI_utildefines.h" -#include "BLI_alloca.h" - -#include "BKE_main.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "bpy_capi_utils.h" -#include "bpy_rna_manipulator.h" - -#include "../generic/py_capi_utils.h" -#include "../generic/python_utildefines.h" - -#include "RNA_access.h" -#include "RNA_types.h" -#include "RNA_enum_types.h" - -#include "bpy_rna.h" - - -/* -------------------------------------------------------------------- */ -/** \name Manipulator Target Property Define API - * \{ */ - -enum { - BPY_MANIPULATOR_FN_SLOT_GET = 0, - BPY_MANIPULATOR_FN_SLOT_SET, - BPY_MANIPULATOR_FN_SLOT_RANGE_GET, -}; -#define BPY_MANIPULATOR_FN_SLOT_LEN (BPY_MANIPULATOR_FN_SLOT_RANGE_GET + 1) - -struct BPyManipulatorHandlerUserData { - - PyObject *fn_slots[BPY_MANIPULATOR_FN_SLOT_LEN]; -}; - -static void py_rna_manipulator_handler_get_cb( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - void *value_p) -{ - PyGILState_STATE gilstate = PyGILState_Ensure(); - - struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_GET], NULL); - if (ret == NULL) { - goto fail; - } - - if (mpr_prop->type->data_type == PROP_FLOAT) { - float *value = value_p; - if (mpr_prop->type->array_length == 1) { - if ((*value = PyFloat_AsDouble(ret)) == -1.0f && PyErr_Occurred()) { - goto fail; - } - } - else { - if (PyC_AsArray(value, ret, mpr_prop->type->array_length, &PyFloat_Type, false, - "Manipulator get callback: ") == -1) - { - goto fail; - } - } - } - else { - PyErr_SetString(PyExc_AttributeError, "internal error, unsupported type"); - goto fail; - } - - Py_DECREF(ret); - - PyGILState_Release(gilstate); - return; - -fail: - PyErr_Print(); - PyErr_Clear(); - - PyGILState_Release(gilstate); -} - -static void py_rna_manipulator_handler_set_cb( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - const void *value_p) -{ - PyGILState_STATE gilstate = PyGILState_Ensure(); - - struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; - - PyObject *args = PyTuple_New(1); - - if (mpr_prop->type->data_type == PROP_FLOAT) { - const float *value = value_p; - PyObject *py_value; - if (mpr_prop->type->array_length == 1) { - py_value = PyFloat_FromDouble(*value); - } - else { - py_value = PyC_Tuple_PackArray_F32(value, mpr_prop->type->array_length); - } - if (py_value == NULL) { - goto fail; - } - PyTuple_SET_ITEM(args, 0, py_value); - } - else { - PyErr_SetString(PyExc_AttributeError, "internal error, unsupported type"); - goto fail; - } - - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_SET], args); - if (ret == NULL) { - goto fail; - } - Py_DECREF(ret); - - PyGILState_Release(gilstate); - return; - -fail: - PyErr_Print(); - PyErr_Clear(); - - Py_DECREF(args); - - PyGILState_Release(gilstate); -} - -static void py_rna_manipulator_handler_range_get_cb( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, - void *value_p) -{ - struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; - - PyGILState_STATE gilstate = PyGILState_Ensure(); - - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET], NULL); - if (ret == NULL) { - goto fail; - } - - if (!PyTuple_Check(ret)) { - PyErr_Format(PyExc_TypeError, - "Expected a tuple, not %.200s", - Py_TYPE(ret)->tp_name); - goto fail; - } - - if (PyTuple_GET_SIZE(ret) != 2) { - PyErr_Format(PyExc_TypeError, - "Expected a tuple of size 2, not %d", - PyTuple_GET_SIZE(ret)); - goto fail; - } - - if (mpr_prop->type->data_type == PROP_FLOAT) { - float range[2]; - for (int i = 0; i < 2; i++) { - if (((range[i] = PyFloat_AsDouble(PyTuple_GET_ITEM(ret, i))) == -1.0f && PyErr_Occurred()) == 0) { - /* pass */ - } - else { - goto fail; - } - } - memcpy(value_p, range, sizeof(range)); - } - else { - PyErr_SetString(PyExc_AttributeError, "internal error, unsupported type"); - goto fail; - } - - Py_DECREF(ret); - PyGILState_Release(gilstate); - return; - -fail: - Py_XDECREF(ret); - - PyErr_Print(); - PyErr_Clear(); - - PyGILState_Release(gilstate); -} - -static void py_rna_manipulator_handler_free_cb( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop) -{ - struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; - - PyGILState_STATE gilstate = PyGILState_Ensure(); - for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { - Py_XDECREF(data->fn_slots[i]); - } - PyGILState_Release(gilstate); - - MEM_freeN(data); - -} - -PyDoc_STRVAR(bpy_manipulator_target_set_handler_doc, -".. method:: target_set_handler(target, get, set, range=None):\n" -"\n" -" Assigns callbacks to a manipulators property.\n" -"\n" -" :arg get: Function that returns the value for this property (single value or sequence).\n" -" :type get: callable\n" -" :arg set: Function that takes a single value argument and applies it.\n" -" :type set: callable\n" -" :arg range: Function that returns a (min, max) tuple for manipulators that use a range.\n" -" :type range: callable\n" -); -static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kw) -{ - PyGILState_STATE gilstate = PyGILState_Ensure(); - - struct { - PyObject *self; - char *target; - PyObject *py_fn_slots[BPY_MANIPULATOR_FN_SLOT_LEN]; - } params = { - .self = NULL, - .target = NULL, - .py_fn_slots = {NULL}, - }; - - /* Note: this is a counter-part to functions: - * 'Manipulator.target_set_prop & target_set_operator' - * (see: rna_wm_manipulator_api.c). conventions should match. */ - static const char * const _keywords[] = {"self", "target", "get", "set", "range", NULL}; - static _PyArg_Parser _parser = {"Os|$OOO:target_set_handler", _keywords, 0}; - if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, - ¶ms.self, - ¶ms.target, - ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_GET], - ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_SET], - ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET])) - { - goto fail; - } - - wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; - - const wmManipulatorPropertyType *mpr_prop_type = - WM_manipulatortype_target_property_find(mpr->type, params.target); - if (mpr_prop_type == NULL) { - PyErr_Format(PyExc_ValueError, - "Manipulator target property '%s.%s' not found", - mpr->type->idname, params.target); - goto fail; - } - - { - const int slots_required = 2; - const int slots_start = 2; - for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { - if (params.py_fn_slots[i] == NULL) { - if (i < slots_required) { - PyErr_Format(PyExc_ValueError, "Argument '%s' not given", _keywords[slots_start + i]); - goto fail; - } - } - else if (!PyCallable_Check(params.py_fn_slots[i])) { - PyErr_Format(PyExc_ValueError, "Argument '%s' not callable", _keywords[slots_start + i]); - goto fail; - } - } - } - - struct BPyManipulatorHandlerUserData *data = MEM_callocN(sizeof(*data), __func__); - - for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { - data->fn_slots[i] = params.py_fn_slots[i]; - Py_XINCREF(params.py_fn_slots[i]); - } - - WM_manipulator_target_property_def_func_ptr( - mpr, mpr_prop_type, - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = py_rna_manipulator_handler_get_cb, - .value_set_fn = py_rna_manipulator_handler_set_cb, - .range_get_fn = py_rna_manipulator_handler_range_get_cb, - .free_fn = py_rna_manipulator_handler_free_cb, - .user_data = data, - }); - - PyGILState_Release(gilstate); - - Py_RETURN_NONE; - -fail: - PyGILState_Release(gilstate); - return NULL; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Manipulator Target Property Access API - * \{ */ - -PyDoc_STRVAR(bpy_manipulator_target_get_value_doc, -".. method:: target_get_value(target):\n" -"\n" -" Get the value of this target property.\n" -"\n" -" :arg target: Target property name.\n" -" :type target: string\n" -" :return: The value of the target property.\n" -" :rtype: Single value or array based on the target type\n" -); -static PyObject *bpy_manipulator_target_get_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) -{ - struct { - PyObject *self; - char *target; - } params = { - .self = NULL, - .target = NULL, - }; - - static const char * const _keywords[] = {"self", "target", NULL}; - static _PyArg_Parser _parser = {"Os:target_get_value", _keywords, 0}; - if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, - ¶ms.self, - ¶ms.target)) - { - goto fail; - } - - wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; - - wmManipulatorProperty *mpr_prop = - WM_manipulator_target_property_find(mpr, params.target); - if (mpr_prop == NULL) { - PyErr_Format(PyExc_ValueError, - "Manipulator target property '%s.%s' not found", - mpr->type->idname, params.target); - goto fail; - } - - const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop); - switch (mpr_prop->type->data_type) { - case PROP_FLOAT: - { - if (array_len != 0) { - float *value = BLI_array_alloca(value, array_len); - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, value); - return PyC_Tuple_PackArray_F32(value, array_len); - } - else { - float value = WM_manipulator_target_property_value_get(mpr, mpr_prop); - return PyFloat_FromDouble(value); - } - break; - } - default: - { - PyErr_SetString(PyExc_RuntimeError, "Not yet supported type"); - goto fail; - } - } - -fail: - return NULL; -} - -PyDoc_STRVAR(bpy_manipulator_target_set_value_doc, -".. method:: target_set_value(target):\n" -"\n" -" Set the value of this target property.\n" -"\n" -" :arg target: Target property name.\n" -" :type target: string\n" -); -static PyObject *bpy_manipulator_target_set_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) -{ - struct { - PyObject *self; - char *target; - PyObject *value; - } params = { - .self = NULL, - .target = NULL, - .value = NULL, - }; - - static const char * const _keywords[] = {"self", "target", "value", NULL}; - static _PyArg_Parser _parser = {"OsO:target_set_value", _keywords, 0}; - if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, - ¶ms.self, - ¶ms.target, - ¶ms.value)) - { - goto fail; - } - - wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; - - wmManipulatorProperty *mpr_prop = - WM_manipulator_target_property_find(mpr, params.target); - if (mpr_prop == NULL) { - PyErr_Format(PyExc_ValueError, - "Manipulator target property '%s.%s' not found", - mpr->type->idname, params.target); - goto fail; - } - - const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop); - switch (mpr_prop->type->data_type) { - case PROP_FLOAT: - { - if (array_len != 0) { - float *value = BLI_array_alloca(value, array_len); - if (PyC_AsArray(value, params.value, mpr_prop->type->array_length, &PyFloat_Type, false, - "Manipulator target property array") == -1) - { - goto fail; - } - WM_manipulator_target_property_value_set_array(BPy_GetContext(), mpr, mpr_prop, value); - } - else { - float value; - if ((value = PyFloat_AsDouble(params.value)) == -1.0f && PyErr_Occurred()) { - goto fail; - } - WM_manipulator_target_property_value_set(BPy_GetContext(), mpr, mpr_prop, value); - } - Py_RETURN_NONE; - } - default: - { - PyErr_SetString(PyExc_RuntimeError, "Not yet supported type"); - goto fail; - } - } - -fail: - return NULL; -} - - -PyDoc_STRVAR(bpy_manipulator_target_get_range_doc, -".. method:: target_get_range(target):\n" -"\n" -" Get the range for this target property.\n" -"\n" -" :arg target: Target property name.\n" -" :Get the range for this target property" -" :return: The range of this property (min, max).\n" -" :rtype: tuple pair.\n" -); -static PyObject *bpy_manipulator_target_get_range(PyObject *UNUSED(self), PyObject *args, PyObject *kw) -{ - struct { - PyObject *self; - char *target; - } params = { - .self = NULL, - .target = NULL, - }; - - static const char * const _keywords[] = {"self", "target", NULL}; - static _PyArg_Parser _parser = {"Os:target_get_range", _keywords, 0}; - if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, - ¶ms.self, - ¶ms.target)) - { - goto fail; - } - - wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; - - wmManipulatorProperty *mpr_prop = - WM_manipulator_target_property_find(mpr, params.target); - if (mpr_prop == NULL) { - PyErr_Format(PyExc_ValueError, - "Manipulator target property '%s.%s' not found", - mpr->type->idname, params.target); - goto fail; - } - - switch (mpr_prop->type->data_type) { - case PROP_FLOAT: - { - float range[2]; - WM_manipulator_target_property_range_get(mpr, mpr_prop, range); - return PyC_Tuple_PackArray_F32(range, 2); - } - default: - { - PyErr_SetString(PyExc_RuntimeError, "Not yet supported type"); - goto fail; - } - } - -fail: - return NULL; -} - -/** \} */ - -int BPY_rna_manipulator_module(PyObject *mod_par) -{ - static PyMethodDef method_def_array[] = { - /* Manipulator Target Property Define API */ - {"target_set_handler", (PyCFunction)bpy_manipulator_target_set_handler, - METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_handler_doc}, - /* Manipulator Target Property Access API */ - {"target_get_value", (PyCFunction)bpy_manipulator_target_get_value, - METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_value_doc}, - {"target_set_value", (PyCFunction)bpy_manipulator_target_set_value, - METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_value_doc}, - {"target_get_range", (PyCFunction)bpy_manipulator_target_get_range, - METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_range_doc}, - /* no sentinel needed. */ - }; - - for (int i = 0; i < ARRAY_SIZE(method_def_array); i++) { - PyMethodDef *m = &method_def_array[i]; - PyObject *func = PyCFunction_New(m, NULL); - PyObject *func_inst = PyInstanceMethod_New(func); - char name_prefix[128]; - PyOS_snprintf(name_prefix, sizeof(name_prefix), "_rna_manipulator_%s", m->ml_name); - /* TODO, return a type that binds nearly to a method. */ - PyModule_AddObject(mod_par, name_prefix, func_inst); - } - - return 0; -} diff --git a/source/blender/python/intern/bpy_rna_manipulator.h b/source/blender/python/intern/bpy_rna_manipulator.h deleted file mode 100644 index b6f3a2e651d..00000000000 --- a/source/blender/python/intern/bpy_rna_manipulator.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Bastien Montagne - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/intern/bpy_rna_manipulator.h - * \ingroup pythonintern - */ - -#ifndef __BPY_RNA_MANIPULATOR_H__ -#define __BPY_RNA_MANIPULATOR_H__ - -int BPY_rna_manipulator_module(PyObject *); - -#endif /* __BPY_RNA_MANIPULATOR_H__ */ diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 67674dae4f3..edf76364503 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -25,8 +25,8 @@ set(INC . - manipulators - manipulators/intern + gizmo + gizmo/intern ../blenfont ../blenkernel ../blenlib @@ -79,12 +79,12 @@ set(SRC intern/wm_tooltip.c intern/wm_uilist_type.c intern/wm_window.c - manipulators/intern/wm_manipulator.c - manipulators/intern/wm_manipulator_group.c - manipulators/intern/wm_manipulator_group_type.c - manipulators/intern/wm_manipulator_map.c - manipulators/intern/wm_manipulator_target_props.c - manipulators/intern/wm_manipulator_type.c + gizmo/intern/wm_gizmo.c + gizmo/intern/wm_gizmo_group.c + gizmo/intern/wm_gizmo_group_type.c + gizmo/intern/wm_gizmo_map.c + gizmo/intern/wm_gizmo_target_props.c + gizmo/intern/wm_gizmo_type.c message_bus/intern/wm_message_bus.c message_bus/intern/wm_message_bus_rna.c message_bus/intern/wm_message_bus_static.c @@ -100,11 +100,11 @@ set(SRC wm_event_types.h wm_files.h wm_window.h - manipulators/WM_manipulator_api.h - manipulators/WM_manipulator_types.h - manipulators/wm_manipulator_fn.h - manipulators/wm_manipulator_wmapi.h - manipulators/intern/wm_manipulator_intern.h + gizmo/WM_gizmo_api.h + gizmo/WM_gizmo_types.h + gizmo/wm_gizmo_fn.h + gizmo/wm_gizmo_wmapi.h + gizmo/intern/wm_gizmo_intern.h message_bus/intern/wm_message_bus_intern.h message_bus/wm_message_bus.h ) diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 8b7633b635b..486eae0a0ed 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -121,10 +121,10 @@ struct ImBuf; /* exported types for WM */ #include "wm_cursors.h" #include "wm_event_types.h" -#include "manipulators/WM_manipulator_types.h" +#include "gizmo/WM_gizmo_types.h" /* Include external manipulator API's */ -#include "manipulators/WM_manipulator_api.h" +#include "gizmo/WM_gizmo_api.h" /* ************** wmOperatorType ************************ */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h new file mode 100644 index 00000000000..ffd18af496e --- /dev/null +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -0,0 +1,343 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmos/WM_gizmo_api.h + * \ingroup wm + * + * \name Manipulator API + * \brief API for external use of wmManipulator types. + * + * Only included in WM_api.h + */ + + +#ifndef __WM_GIZMO_API_H__ +#define __WM_GIZMO_API_H__ + +struct ARegion; +struct GHashIterator; +struct IDProperty; +struct Main; +struct PropertyRNA; +struct wmKeyConfig; +struct wmManipulator; +struct wmManipulatorProperty; +struct wmManipulatorPropertyType; +struct wmManipulatorType; +struct wmManipulatorGroup; +struct wmManipulatorGroupType; +struct wmManipulatorMap; +struct wmManipulatorMapType; +struct wmManipulatorMapType_Params; +struct wmMsgSubscribeKey; +struct wmMsgSubscribeValue; + +#include "wm_gizmo_fn.h" + +/* -------------------------------------------------------------------- */ +/* wmManipulator */ + +struct wmManipulator *WM_manipulator_new_ptr( + const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup, + struct PointerRNA *properties); +struct wmManipulator *WM_manipulator_new( + const char *idname, struct wmManipulatorGroup *mgroup, + struct PointerRNA *properties); +void WM_manipulator_free(struct wmManipulator *mpr); +void WM_manipulator_unlink( + ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr, + struct bContext *C); + +void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name); + +bool WM_manipulator_select_unlink(struct wmManipulatorMap *mmap, struct wmManipulator *mpr); +bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select); +void WM_manipulator_highlight_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr); + +void WM_manipulator_modal_set_from_setup( + struct wmManipulatorMap *mmap, struct bContext *C, + struct wmManipulator *mpr, int part_index, const struct wmEvent *event); + +struct wmManipulatorOpElem *WM_manipulator_operator_get( + struct wmManipulator *mpr, int part_index); +struct PointerRNA *WM_manipulator_operator_set( + struct wmManipulator *mpr, int part_index, + struct wmOperatorType *ot, struct IDProperty *properties); + +/* callbacks */ +void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn); + +void WM_manipulator_set_matrix_location( + struct wmManipulator *mpr, const float origin[3]); +void WM_manipulator_set_matrix_rotation_from_z_axis( + struct wmManipulator *mpr, const float z_axis[3]); +void WM_manipulator_set_matrix_rotation_from_yz_axis( + struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]); + +void WM_manipulator_set_matrix_offset_location( + struct wmManipulator *mpr, const float origin[3]); +void WM_manipulator_set_matrix_offset_rotation_from_z_axis( + struct wmManipulator *mpr, const float z_axis[3]); +void WM_manipulator_set_matrix_offset_rotation_from_yz_axis( + struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]); + +void WM_manipulator_set_flag(struct wmManipulator *mpr, const int flag, const bool enable); +void WM_manipulator_set_scale(struct wmManipulator *mpr, float scale); +void WM_manipulator_set_line_width(struct wmManipulator *mpr, const float line_width); + +void WM_manipulator_get_color(const struct wmManipulator *mpr, float color[4]); +void WM_manipulator_set_color(struct wmManipulator *mpr, const float color[4]); +void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float color_hi[4]); +void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float color[4]); + +/** + * Leaving values NULL use values from #wmManipulator. + */ +struct WM_ManipulatorMatrixParams { + const float(*matrix_space)[4]; + const float(*matrix_basis)[4]; + const float(*matrix_offset)[4]; + const float *scale_final; +}; + +void WM_manipulator_calc_matrix_final_params( + const struct wmManipulator *mpr, const struct WM_ManipulatorMatrixParams *params, + float r_mat[4][4]); +void WM_manipulator_calc_matrix_final_no_offset( + const struct wmManipulator *mpr, float r_mat[4][4]); + +void WM_manipulator_calc_matrix_final( + const struct wmManipulator *mpr, float r_mat[4][4]); + +/* properties */ +void WM_manipulator_properties_create_ptr(struct PointerRNA *ptr, struct wmManipulatorType *wt); +void WM_manipulator_properties_create(struct PointerRNA *ptr, const char *opstring); +void WM_manipulator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring); +void WM_manipulator_properties_sanitize(struct PointerRNA *ptr, const bool no_context); +bool WM_manipulator_properties_default(struct PointerRNA *ptr, const bool do_update); +void WM_manipulator_properties_reset(struct wmManipulator *op); +void WM_manipulator_properties_clear(struct PointerRNA *ptr); +void WM_manipulator_properties_free(struct PointerRNA *ptr); + + +/* wm_manipulator_type.c */ +const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet); +void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)); +void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata); +bool WM_manipulatortype_remove(struct bContext *C, struct Main *bmain, const char *idname); +void WM_manipulatortype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmManipulatorType *wt); +void WM_manipulatortype_iter(struct GHashIterator *ghi); + +/* wm_manipulator_group_type.c */ +struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet); +struct wmManipulatorGroupType *WM_manipulatorgrouptype_append(void (*wtfunc)(struct wmManipulatorGroupType *)); +struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata); +bool WM_manipulatorgrouptype_free(const char *idname); +void WM_manipulatorgrouptype_free_ptr(struct wmManipulatorGroupType *wt); +void WM_manipulatorgrouptype_iter(struct GHashIterator *ghi); + +struct wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( + struct wmManipulatorMapType *mmap_type, + void (*wtfunc)(struct wmManipulatorGroupType *)); + +/* wm_manipulator_map.c */ + +/* Dynamic Updates (for RNA runtime registration) */ +void WM_manipulatorconfig_update_tag_init(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); +void WM_manipulatorconfig_update_tag_remove(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); +void WM_manipulatorconfig_update(struct Main *bmain); + + +/* wm_maniulator_target_props.c */ +struct wmManipulatorProperty *WM_manipulator_target_property_array(struct wmManipulator *mpr); +struct wmManipulatorProperty *WM_manipulator_target_property_at_index( + struct wmManipulator *mpr, int index); +struct wmManipulatorProperty *WM_manipulator_target_property_find( + struct wmManipulator *mpr, const char *idname); + +void WM_manipulator_target_property_def_rna_ptr( + struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, + struct PointerRNA *ptr, struct PropertyRNA *prop, int index); +void WM_manipulator_target_property_def_rna( + struct wmManipulator *mpr, const char *idname, + struct PointerRNA *ptr, const char *propname, int index); + +void WM_manipulator_target_property_def_func_ptr( + struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, + const struct wmManipulatorPropertyFnParams *params); +void WM_manipulator_target_property_def_func( + struct wmManipulator *mpr, const char *idname, + const struct wmManipulatorPropertyFnParams *params); + +void WM_manipulator_target_property_clear_rna_ptr( + struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type); +void WM_manipulator_target_property_clear_rna( + struct wmManipulator *mpr, const char *idname); + +bool WM_manipulator_target_property_is_valid_any(struct wmManipulator *mpr); +bool WM_manipulator_target_property_is_valid( + const struct wmManipulatorProperty *mpr_prop); +float WM_manipulator_target_property_value_get( + const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); +void WM_manipulator_target_property_value_set( + struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, + const float value); + +void WM_manipulator_target_property_value_get_array( + const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, + float *value); +void WM_manipulator_target_property_value_set_array( + struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, + const float *value); + +bool WM_manipulator_target_property_range_get( + const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, + float range[2]); + +int WM_manipulator_target_property_array_length( + const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); + +/* definitions */ +const struct wmManipulatorPropertyType *WM_manipulatortype_target_property_find( + const struct wmManipulatorType *wt, const char *idname); +void WM_manipulatortype_target_property_def( + struct wmManipulatorType *wt, const char *idname, int data_type, int array_length); + +/* utilities */ +void WM_manipulator_do_msg_notify_tag_refresh( + struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val); +void WM_manipulator_target_property_subscribe_all( + struct wmManipulator *mpr, struct wmMsgBus *mbus, struct ARegion *ar); + +/* -------------------------------------------------------------------- */ +/* wmManipulatorGroup */ + +/* Callbacks for 'wmManipulatorGroupType.setup_keymap' */ +struct wmKeyMap *WM_manipulatorgroup_keymap_common( + const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); +struct wmKeyMap *WM_manipulatorgroup_keymap_common_select( + const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); + + +/* -------------------------------------------------------------------- */ +/* wmManipulatorMap */ + +struct wmManipulatorMap *WM_manipulatormap_new_from_type( + const struct wmManipulatorMapType_Params *mmap_params); +const struct ListBase *WM_manipulatormap_group_list(struct wmManipulatorMap *mmap); +struct wmManipulatorGroup *WM_manipulatormap_group_find( + struct wmManipulatorMap *mmap, + const char *idname); +struct wmManipulatorGroup *WM_manipulatormap_group_find_ptr( + struct wmManipulatorMap *mmap, + const struct wmManipulatorGroupType *wgt); +void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap); +void WM_manipulatormap_draw( + struct wmManipulatorMap *mmap, const struct bContext *C, const eWM_ManipulatorMapDrawStep drawstep); +void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap *mmap); +bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action); +bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win); +void WM_manipulatormap_message_subscribe( + struct bContext *C, struct wmManipulatorMap *mmap, struct ARegion *ar, struct wmMsgBus *mbus); +bool WM_manipulatormap_is_any_selected(const struct wmManipulatorMap *mmap); +bool WM_manipulatormap_minmax( + const struct wmManipulatorMap *mmap, bool use_hidden, bool use_select, + float r_min[3], float r_max[3]); + +struct ARegion *WM_manipulatormap_tooltip_init( + struct bContext *C, struct ARegion *ar, bool *r_exit_on_event); + +/* -------------------------------------------------------------------- */ +/* wmManipulatorMapType */ + +struct wmManipulatorMapType *WM_manipulatormaptype_find( + const struct wmManipulatorMapType_Params *mmap_params); +struct wmManipulatorMapType *WM_manipulatormaptype_ensure( + const struct wmManipulatorMapType_Params *mmap_params); + +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( + struct wmManipulatorMapType *mmap_type, + const char *idname); +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( + struct wmManipulatorMapType *mmap_type, + const struct wmManipulatorGroupType *wgt); +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( + struct wmManipulatorMapType *mmap_type, + const char *idname); +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( + struct wmManipulatorMapType *mmap_type, + struct wmManipulatorGroupType *wgt); + +void WM_manipulatormaptype_group_init_runtime_keymap( + const struct Main *bmain, + struct wmManipulatorGroupType *wgt); +void WM_manipulatormaptype_group_init_runtime( + const struct Main *bmain, struct wmManipulatorMapType *mmap_type, + struct wmManipulatorGroupType *wgt); +void WM_manipulatormaptype_group_unlink( + struct bContext *C, struct Main *bmain, struct wmManipulatorMapType *mmap_type, + const struct wmManipulatorGroupType *wgt); + +void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt); + +/* -------------------------------------------------------------------- */ +/* ManipulatorGroup */ + +/* Add/Ensure/Remove (High level API) */ + +void WM_manipulator_group_type_add_ptr_ex( + struct wmManipulatorGroupType *wgt, + struct wmManipulatorMapType *mmap_type); +void WM_manipulator_group_type_add_ptr( + struct wmManipulatorGroupType *wgt); +void WM_manipulator_group_type_add(const char *idname); + +void WM_manipulator_group_type_ensure_ptr_ex( + struct wmManipulatorGroupType *wgt, + struct wmManipulatorMapType *mmap_type); +void WM_manipulator_group_type_ensure_ptr( + struct wmManipulatorGroupType *wgt); +void WM_manipulator_group_type_ensure(const char *idname); + +void WM_manipulator_group_type_remove_ptr_ex( + struct Main *bmain, struct wmManipulatorGroupType *wgt, + struct wmManipulatorMapType *mmap_type); +void WM_manipulator_group_type_remove_ptr( + struct Main *bmain, struct wmManipulatorGroupType *wgt); +void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname); + +void WM_manipulator_group_type_unlink_delayed_ptr_ex( + struct wmManipulatorGroupType *wgt, + struct wmManipulatorMapType *mmap_type); +void WM_manipulator_group_type_unlink_delayed_ptr( + struct wmManipulatorGroupType *wgt); +void WM_manipulator_group_type_unlink_delayed(const char *idname); + +/* Utilities */ +bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step); + +bool WM_manipulator_group_type_poll(const struct bContext *C, const struct wmManipulatorGroupType *wgt); + +#endif /* __WM_GIZMO_API_H__ */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h new file mode 100644 index 00000000000..0f6af6db24c --- /dev/null +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -0,0 +1,422 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/WM_gizmo_types.h + * \ingroup wm + * + * \name Manipulator Types + * \brief Manipulator defines for external use. + * + * Only included in WM_types.h and lower level files. + */ + + +#ifndef __WM_GIZMO_TYPES_H__ +#define __WM_GIZMO_TYPES_H__ + +#include "BLI_compiler_attrs.h" + +struct wmManipulatorMapType; +struct wmManipulatorGroupType; +struct wmManipulatorGroup; +struct wmManipulator; +struct wmManipulatorProperty; +struct wmKeyConfig; + +#include "DNA_listBase.h" + + +/* -------------------------------------------------------------------- */ +/* Enum Typedef's */ + + +/** + * #wmManipulator.state + */ +typedef enum eWM_ManipulatorState { + WM_MANIPULATOR_STATE_HIGHLIGHT = (1 << 0), /* while hovered */ + WM_MANIPULATOR_STATE_MODAL = (1 << 1), /* while dragging */ + WM_MANIPULATOR_STATE_SELECT = (1 << 2), +} eWM_ManipulatorState; + + +/** + * #wmManipulator.flag + * Flags for individual manipulators. + */ +typedef enum eWM_ManipulatorFlag { + WM_MANIPULATOR_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */ + WM_MANIPULATOR_DRAW_MODAL = (1 << 1), /* draw while dragging */ + WM_MANIPULATOR_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */ + WM_MANIPULATOR_HIDDEN = (1 << 3), + /** + * When set 'scale_final' value also scales the offset. + * Use when offset is to avoid screen-space overlap instead of absolute positioning. */ + WM_MANIPULATOR_DRAW_OFFSET_SCALE = (1 << 4), + /** + * User should still use 'scale_final' for any handles and UI elements. + * This simply skips scale when calculating the final matrix. + * Needed when the manipulator needs to align with the interface underneath it. */ + WM_MANIPULATOR_DRAW_NO_SCALE = (1 << 5), + /** + * Hide the cursor and lock it's position while interacting with this manipulator. + */ + WM_MANIPULATOR_GRAB_CURSOR = (1 << 6), + /** Don't write into the depth buffer when selecting. */ + WM_MANIPULATOR_SELECT_BACKGROUND = (1 << 7), +} eWM_ManipulatorFlag; + +/** + * #wmManipulatorGroupType.flag + * Flags that influence the behavior of all manipulators in the group. + */ +typedef enum eWM_ManipulatorGroupTypeFlag { + /* Mark manipulator-group as being 3D */ + WM_MANIPULATORGROUPTYPE_3D = (1 << 0), + /* Scale manipulators as 3D object that respects zoom (otherwise zoom independent draw size). + * note: currently only for 3D views, 2D support needs adding. */ + WM_MANIPULATORGROUPTYPE_SCALE = (1 << 1), + /* Manipulators can be depth culled with scene objects (covered by other geometry - TODO) */ + WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2), + /* Manipulators can be selected */ + WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3), + /* The manipulator group is to be kept (not removed on loading a new file for eg). */ + WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4), + /* Show all other manipulators when interacting. */ + WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL = (1 << 5), +} eWM_ManipulatorGroupTypeFlag; + + +/** + * #wmManipulatorGroup.init_flag + */ +typedef enum eWM_ManipulatorGroupInitFlag { + /* mgroup has been initialized */ + WM_MANIPULATORGROUP_INIT_SETUP = (1 << 0), + WM_MANIPULATORGROUP_INIT_REFRESH = (1 << 1), +} eWM_ManipulatorGroupInitFlag; + +/** + * #wmManipulatorMapType.type_update_flag + * Manipulator-map type update flag + */ +typedef enum eWM_ManipulatorMapTypeUpdateFlag { + /* A new type has been added, needs to be initialized for all views. */ + WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0), + WM_MANIPULATORMAPTYPE_UPDATE_REMOVE = (1 << 1), + + /* Needed because keymap may be registered before and after window initialization. + * So we need to keep track of keymap initialization separately. */ + WM_MANIPULATORMAPTYPE_KEYMAP_INIT = (1 << 2), +} eWM_ManipulatorMapTypeUpdateFlag; + +/* -------------------------------------------------------------------- */ +/* wmManipulator */ + +/** + * \brief Manipulator tweak flag. + * Bitflag passed to manipulator while tweaking. + * + * \note Manipulators are responsible for handling this #wmManipulator.modal callback!. + */ +typedef enum { + /* Drag with extra precision (Shift). */ + WM_MANIPULATOR_TWEAK_PRECISE = (1 << 0), + /* Drag with snap enabled (Ctrl). */ + WM_MANIPULATOR_TWEAK_SNAP = (1 << 1), +} eWM_ManipulatorTweak; + +#include "wm_gizmo_fn.h" + +typedef struct wmManipulatorOpElem { + struct wmOperatorType *type; + /* operator properties if manipulator spawns and controls an operator, + * or owner pointer if manipulator spawns and controls a property */ + PointerRNA ptr; + + bool is_redo; +} wmManipulatorOpElem; + +/* manipulators are set per region by registering them on manipulator-maps */ +struct wmManipulator { + struct wmManipulator *next, *prev; + + /* While we don't have a real type, use this to put type-like vars. */ + const struct wmManipulatorType *type; + + /* Overrides 'type->modal' when set. + * Note that this is a workaround, remove if we can. */ + wmManipulatorFnModal custom_modal; + + /* pointer back to group this manipulator is in (just for quick access) */ + struct wmManipulatorGroup *parent_mgroup; + + void *py_instance; + + /* rna pointer to access properties */ + struct PointerRNA *ptr; + + /* flags that influence the behavior or how the manipulators are drawn */ + eWM_ManipulatorFlag flag; + /* state flags (active, highlighted, selected) */ + eWM_ManipulatorState state; + + /* Optional ID for highlighting different parts of this manipulator. + * -1 when unset, otherwise a valid index. (Used as index to 'op_data'). */ + int highlight_part; + /* For single click button manipulators, use a different part as a fallback, -1 when unused. */ + int drag_part; + + /* Transformation of the manipulator in 2d or 3d space. + * - Matrix axis are expected to be unit length (scale is applied after). + * - Behavior when axis aren't orthogonal depends on each manipulator. + * - Typically the +Z is the primary axis for manipulators to use. + * - 'matrix[3]' must be used for location, + * besides this it's up to the manipulators internal code how the + * rotation components are used for drawing and interaction. + */ + + /* The space this manipulator is being modified in. */ + float matrix_space[4][4]; + /* Transformation of this manipulator. */ + float matrix_basis[4][4]; + /* custom offset from origin */ + float matrix_offset[4][4]; + /* runtime property, set the scale while drawing on the viewport */ + float scale_final; + /* user defined scale, in addition to the original one */ + float scale_basis; + /* user defined width for line drawing */ + float line_width; + /* manipulator colors (uses default fallbacks if not defined) */ + float color[4], color_hi[4]; + + /* data used during interaction */ + void *interaction_data; + + /* Operator to spawn when activating the manipulator (overrides property editing), + * an array of items (aligned with #wmManipulator.highlight_part). */ + wmManipulatorOpElem *op_data; + int op_data_len; + + struct IDProperty *properties; + + /* over alloc target_properties after 'wmManipulatorType.struct_size' */ +}; + +/* Similar to PropertyElemRNA, but has an identifier. */ +typedef struct wmManipulatorProperty { + const struct wmManipulatorPropertyType *type; + + PointerRNA ptr; + PropertyRNA *prop; + int index; + + + /* Optional functions for converting to/from RNA */ + struct { + wmManipulatorPropertyFnGet value_get_fn; + wmManipulatorPropertyFnSet value_set_fn; + wmManipulatorPropertyFnRangeGet range_get_fn; + wmManipulatorPropertyFnFree free_fn; + void *user_data; + } custom_func; +} wmManipulatorProperty; + +typedef struct wmManipulatorPropertyType { + struct wmManipulatorPropertyType *next, *prev; + /* PropertyType, typically 'PROP_FLOAT' */ + int data_type; + int array_length; + + /* index within 'wmManipulatorType' */ + int index_in_type; + + /* over alloc */ + char idname[0]; +} wmManipulatorPropertyType; + + +/** + * Simple utility wrapper for storing a single manipulator as wmManipulatorGroup.customdata (which gets freed). + */ +typedef struct wmManipulatorWrapper { + struct wmManipulator *manipulator; +} wmManipulatorWrapper; + +struct wmManipulatorMapType_Params { + short spaceid; + short regionid; +}; + +typedef struct wmManipulatorType { + + const char *idname; /* MAX_NAME */ + + /* Set to 'sizeof(wmManipulator)' or larger for instances of this type, + * use so we can cant to other types without the hassle of a custom-data pointer. */ + uint struct_size; + + /* Initialize struct (calloc'd 'struct_size' region). */ + wmManipulatorFnSetup setup; + + /* draw manipulator */ + wmManipulatorFnDraw draw; + + /* determines 3d intersection by rendering the manipulator in a selection routine. */ + wmManipulatorFnDrawSelect draw_select; + + /* Determine if the mouse intersects with the manipulator. + * The calculation should be done in the callback itself, -1 for no seleciton. */ + wmManipulatorFnTestSelect test_select; + + /* handler used by the manipulator. Usually handles interaction tied to a manipulator type */ + wmManipulatorFnModal modal; + + /* manipulator-specific handler to update manipulator attributes based on the property value */ + wmManipulatorFnPropertyUpdate property_update; + + /* Returns the final transformation which may be different from the 'matrix', + * depending on the manipulator. + * Notes: + * - Scale isn't applied (wmManipulator.scale/user_scale). + * - Offset isn't applied (wmManipulator.matrix_offset). + */ + wmManipulatorFnMatrixBasisGet matrix_basis_get; + + /* activate a manipulator state when the user clicks on it */ + wmManipulatorFnInvoke invoke; + + /* called when manipulator tweaking is done - used to free data and reset property when cancelling */ + wmManipulatorFnExit exit; + + wmManipulatorFnCursorGet cursor_get; + + /* called when manipulator selection state changes */ + wmManipulatorFnSelectRefresh select_refresh; + + /* Free data (not the manipulator it's self), use when the manipulator allocates it's own members. */ + wmManipulatorFnFree free; + + /* RNA for properties */ + struct StructRNA *srna; + + /* RNA integration */ + ExtensionRNA ext; + + ListBase target_property_defs; + int target_property_defs_len; + +} wmManipulatorType; + + +/* -------------------------------------------------------------------- */ +/* wmManipulatorGroup */ + +/* factory class for a manipulator-group type, gets called every time a new area is spawned */ +typedef struct wmManipulatorGroupTypeRef { + struct wmManipulatorGroupTypeRef *next, *prev; + struct wmManipulatorGroupType *type; +} wmManipulatorGroupTypeRef; + +/* factory class for a manipulator-group type, gets called every time a new area is spawned */ +typedef struct wmManipulatorGroupType { + const char *idname; /* MAX_NAME */ + const char *name; /* manipulator-group name - displayed in UI (keymap editor) */ + char owner_id[64]; /* MAX_NAME */ + + /* poll if manipulator-map should be visible */ + wmManipulatorGroupFnPoll poll; + /* initially create manipulators and set permanent data - stuff you only need to do once */ + wmManipulatorGroupFnInit setup; + /* refresh data, only called if recreate flag is set (WM_manipulatormap_tag_refresh) */ + wmManipulatorGroupFnRefresh refresh; + /* refresh data for drawing, called before each redraw */ + wmManipulatorGroupFnDrawPrepare draw_prepare; + + /* Keymap init callback for this manipulator-group (optional), + * will fall back to default tweak keymap when left NULL. */ + wmManipulatorGroupFnSetupKeymap setup_keymap; + + /* Optionally subscribe to wmMsgBus events, + * these are calculated automatically from RNA properties, + * only needed if manipulators depend indirectly on properties. */ + wmManipulatorGroupFnMsgBusSubscribe message_subscribe; + + /* keymap created with callback from above */ + struct wmKeyMap *keymap; + /* Only for convenient removal. */ + struct wmKeyConfig *keyconf; + + /* Disable for now, maybe some day we want properties. */ +#if 0 + /* rna for properties */ + struct StructRNA *srna; +#endif + + /* RNA integration */ + ExtensionRNA ext; + + eWM_ManipulatorGroupTypeFlag flag; + + /* So we know which group type to update. */ + eWM_ManipulatorMapTypeUpdateFlag type_update_flag; + + /* same as manipulator-maps, so registering/unregistering goes to the correct region */ + struct wmManipulatorMapType_Params mmap_params; + +} wmManipulatorGroupType; + +typedef struct wmManipulatorGroup { + struct wmManipulatorGroup *next, *prev; + + struct wmManipulatorGroupType *type; + ListBase manipulators; + + struct wmManipulatorMap *parent_mmap; + + void *py_instance; /* python stores the class instance here */ + struct ReportList *reports; /* errors and warnings storage */ + + void *customdata; + void (*customdata_free)(void *); /* for freeing customdata from above */ + eWM_ManipulatorGroupInitFlag init_flag; +} wmManipulatorGroup; + +/* -------------------------------------------------------------------- */ +/* wmManipulatorMap */ + +/** + * Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw. + */ +typedef enum eWM_ManipulatorMapDrawStep { + /** Draw 2D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D not set). */ + WM_MANIPULATORMAP_DRAWSTEP_2D = 0, + /** Draw 3D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D set). */ + WM_MANIPULATORMAP_DRAWSTEP_3D, +} eWM_ManipulatorMapDrawStep; +#define WM_MANIPULATORMAP_DRAWSTEP_MAX 2 + +#endif /* __WM_GIZMO_TYPES_H__ */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c new file mode 100644 index 00000000000..bef193f6c56 --- /dev/null +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c @@ -0,0 +1,800 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/intern/wm_gizmo.c + * \ingroup wm + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_string.h" +#include "BLI_string_utils.h" + +#include "BKE_context.h" + +#include "GPU_batch.h" +#include "GPU_glew.h" +#include "GPU_immediate.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_idprop.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" +#include "ED_view3d.h" + +#include "UI_interface.h" + +#ifdef WITH_PYTHON +#include "BPY_extern.h" +#endif + +/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +#include "wm.h" + +/* own includes */ +#include "wm_gizmo_wmapi.h" +#include "wm_gizmo_intern.h" + +static void wm_manipulator_register( + wmManipulatorGroup *mgroup, wmManipulator *mpr); + +/** + * \note Follow #wm_operator_create convention. + */ +static wmManipulator *wm_manipulator_create( + const wmManipulatorType *wt, + PointerRNA *properties) +{ + BLI_assert(wt != NULL); + BLI_assert(wt->struct_size >= sizeof(wmManipulator)); + + wmManipulator *mpr = MEM_callocN( + wt->struct_size + (sizeof(wmManipulatorProperty) * wt->target_property_defs_len), __func__); + mpr->type = wt; + + /* initialize properties, either copy or create */ + mpr->ptr = MEM_callocN(sizeof(PointerRNA), "wmManipulatorPtrRNA"); + if (properties && properties->data) { + mpr->properties = IDP_CopyProperty(properties->data); + } + else { + IDPropertyTemplate val = {0}; + mpr->properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties"); + } + RNA_pointer_create(G_MAIN->wm.first, wt->srna, mpr->properties, mpr->ptr); + + WM_manipulator_properties_sanitize(mpr->ptr, 0); + + unit_m4(mpr->matrix_space); + unit_m4(mpr->matrix_basis); + unit_m4(mpr->matrix_offset); + + mpr->drag_part = -1; + + return mpr; +} + +wmManipulator *WM_manipulator_new_ptr( + const wmManipulatorType *wt, wmManipulatorGroup *mgroup, + PointerRNA *properties) +{ + wmManipulator *mpr = wm_manipulator_create(wt, properties); + + wm_manipulator_register(mgroup, mpr); + + if (mpr->type->setup != NULL) { + mpr->type->setup(mpr); + } + + return mpr; +} + +/** + * \param wt: Must be valid, + * if you need to check it exists use #WM_manipulator_new_ptr + * because callers of this function don't NULL check the return value. + */ +wmManipulator *WM_manipulator_new( + const char *idname, wmManipulatorGroup *mgroup, + PointerRNA *properties) +{ + const wmManipulatorType *wt = WM_manipulatortype_find(idname, false); + return WM_manipulator_new_ptr(wt, mgroup, properties); +} + +/** + * Initialize default values and allocate needed memory for members. + */ +static void manipulator_init(wmManipulator *mpr) +{ + const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + + mpr->scale_basis = 1.0f; + mpr->line_width = 1.0f; + + /* defaults */ + copy_v4_v4(mpr->color, color_default); + copy_v4_v4(mpr->color_hi, color_default); +} + +/** + * Register \a manipulator. + * + * \param name: name used to create a unique idname for \a manipulator in \a mgroup + * + * \note Not to be confused with type registration from RNA. + */ +static void wm_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr) +{ + manipulator_init(mpr); + wm_manipulatorgroup_manipulator_register(mgroup, mpr); +} + +/** + * \warning this doesn't check #wmManipulatorMap (highlight, selection etc). + * Typical use is when freeing the windowing data, + * where caller can manage clearing selection, highlight... etc. + */ +void WM_manipulator_free(wmManipulator *mpr) +{ + if (mpr->type->free != NULL) { + mpr->type->free(mpr); + } + +#ifdef WITH_PYTHON + if (mpr->py_instance) { + /* do this first in case there are any __del__ functions or + * similar that use properties */ + BPY_DECREF_RNA_INVALIDATE(mpr->py_instance); + } +#endif + + if (mpr->op_data) { + for (int i = 0; i < mpr->op_data_len; i++) { + WM_operator_properties_free(&mpr->op_data[i].ptr); + } + MEM_freeN(mpr->op_data); + } + + if (mpr->ptr != NULL) { + WM_manipulator_properties_free(mpr->ptr); + MEM_freeN(mpr->ptr); + } + + if (mpr->type->target_property_defs_len != 0) { + wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + for (int i = 0; i < mpr->type->target_property_defs_len; i++) { + wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; + if (mpr_prop->custom_func.free_fn) { + mpr_prop->custom_func.free_fn(mpr, mpr_prop); + } + } + } + + MEM_freeN(mpr); +} + +/** + * Free \a manipulator and unlink from \a manipulatorlist. + * \a manipulatorlist is allowed to be NULL. + */ +void WM_manipulator_unlink(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmManipulator *mpr, bContext *C) +{ + if (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) { + wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + } + if (mpr->state & WM_MANIPULATOR_STATE_MODAL) { + wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false); + } + /* Unlink instead of setting so we don't run callbacks. */ + if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { + WM_manipulator_select_unlink(mmap, mpr); + } + + if (manipulatorlist) { + BLI_remlink(manipulatorlist, mpr); + } + + BLI_assert(mmap->mmap_context.highlight != mpr); + BLI_assert(mmap->mmap_context.modal != mpr); + + WM_manipulator_free(mpr); +} + +/* -------------------------------------------------------------------- */ +/** \name Manipulator Creation API + * + * API for defining data on manipulator creation. + * + * \{ */ + +struct wmManipulatorOpElem *WM_manipulator_operator_get( + wmManipulator *mpr, int part_index) +{ + if (mpr->op_data && ((part_index >= 0) && (part_index < mpr->op_data_len))) { + return &mpr->op_data[part_index]; + } + return NULL; +} + +PointerRNA *WM_manipulator_operator_set( + wmManipulator *mpr, int part_index, + wmOperatorType *ot, IDProperty *properties) +{ + BLI_assert(part_index < 255); + /* We could pre-allocate these but using multiple is such a rare thing. */ + if (part_index >= mpr->op_data_len) { + mpr->op_data_len = part_index + 1; + mpr->op_data = MEM_recallocN(mpr->op_data, sizeof(*mpr->op_data) * mpr->op_data_len); + } + wmManipulatorOpElem *mpop = &mpr->op_data[part_index]; + mpop->type = ot; + + if (mpop->ptr.data) { + WM_operator_properties_free(&mpop->ptr); + } + WM_operator_properties_create_ptr(&mpop->ptr, ot); + + if (properties) { + mpop->ptr.data = properties; + } + + return &mpop->ptr; +} + +static void wm_manipulator_set_matrix_rotation_from_z_axis__internal( + float matrix[4][4], const float z_axis[3]) +{ + /* old code, seems we can use simpler method */ +#if 0 + const float z_global[3] = {0.0f, 0.0f, 1.0f}; + float rot[3][3]; + + rotation_between_vecs_to_mat3(rot, z_global, z_axis); + copy_v3_v3(matrix[0], rot[0]); + copy_v3_v3(matrix[1], rot[1]); + copy_v3_v3(matrix[2], rot[2]); +#else + normalize_v3_v3(matrix[2], z_axis); + ortho_basis_v3v3_v3(matrix[0], matrix[1], matrix[2]); +#endif + +} + +static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal( + float matrix[4][4], const float y_axis[3], const float z_axis[3]) +{ + normalize_v3_v3(matrix[1], y_axis); + normalize_v3_v3(matrix[2], z_axis); + cross_v3_v3v3(matrix[0], matrix[1], matrix[2]); + normalize_v3(matrix[0]); +} + +/** + * wmManipulator.matrix utils. + */ +void WM_manipulator_set_matrix_rotation_from_z_axis( + wmManipulator *mpr, const float z_axis[3]) +{ + wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis); +} +void WM_manipulator_set_matrix_rotation_from_yz_axis( + wmManipulator *mpr, const float y_axis[3], const float z_axis[3]) +{ + wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis); +} +void WM_manipulator_set_matrix_location(wmManipulator *mpr, const float origin[3]) +{ + copy_v3_v3(mpr->matrix_basis[3], origin); +} + +/** + * wmManipulator.matrix_offset utils. + */ +void WM_manipulator_set_matrix_offset_rotation_from_z_axis( + wmManipulator *mpr, const float z_axis[3]) +{ + wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis); +} +void WM_manipulator_set_matrix_offset_rotation_from_yz_axis( + wmManipulator *mpr, const float y_axis[3], const float z_axis[3]) +{ + wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis); +} +void WM_manipulator_set_matrix_offset_location(wmManipulator *mpr, const float offset[3]) +{ + copy_v3_v3(mpr->matrix_offset[3], offset); +} + +void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enable) +{ + if (enable) { + mpr->flag |= flag; + } + else { + mpr->flag &= ~flag; + } +} + +void WM_manipulator_set_scale(wmManipulator *mpr, const float scale) +{ + mpr->scale_basis = scale; +} + +void WM_manipulator_set_line_width(wmManipulator *mpr, const float line_width) +{ + mpr->line_width = line_width; +} + +/** + * Set manipulator rgba colors. + * + * \param col Normal state color. + * \param col_hi Highlighted state color. + */ +void WM_manipulator_get_color(const wmManipulator *mpr, float color[4]) +{ + copy_v4_v4(color, mpr->color); +} +void WM_manipulator_set_color(wmManipulator *mpr, const float color[4]) +{ + copy_v4_v4(mpr->color, color); +} + +void WM_manipulator_get_color_highlight(const wmManipulator *mpr, float color_hi[4]) +{ + copy_v4_v4(color_hi, mpr->color_hi); +} +void WM_manipulator_set_color_highlight(wmManipulator *mpr, const float color_hi[4]) +{ + copy_v4_v4(mpr->color_hi, color_hi); +} + + +/** \} */ // Manipulator Creation API + + +/* -------------------------------------------------------------------- */ +/** \name Manipulator Callback Assignment + * + * \{ */ + +void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn) +{ + mpr->custom_modal = fn; +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** + * Add/Remove \a manipulator to selection. + * Reallocates memory for selected manipulators so better not call for selecting multiple ones. + * + * \return if the selection has changed. + */ +bool wm_manipulator_select_set_ex( + wmManipulatorMap *mmap, wmManipulator *mpr, bool select, + bool use_array, bool use_callback) +{ + bool changed = false; + + if (select) { + if ((mpr->state & WM_MANIPULATOR_STATE_SELECT) == 0) { + if (use_array) { + wm_manipulatormap_select_array_push_back(mmap, mpr); + } + mpr->state |= WM_MANIPULATOR_STATE_SELECT; + changed = true; + } + } + else { + if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { + if (use_array) { + wm_manipulatormap_select_array_remove(mmap, mpr); + } + mpr->state &= ~WM_MANIPULATOR_STATE_SELECT; + changed = true; + } + } + + /* In the case of unlinking we only want to remove from the array + * and not write to the external state */ + if (use_callback && changed) { + if (mpr->type->select_refresh) { + mpr->type->select_refresh(mpr); + } + } + + return changed; +} + +/* Remove from selection array without running callbacks. */ +bool WM_manipulator_select_unlink(wmManipulatorMap *mmap, wmManipulator *mpr) +{ + return wm_manipulator_select_set_ex(mmap, mpr, false, true, false); +} + +bool WM_manipulator_select_set(wmManipulatorMap *mmap, wmManipulator *mpr, bool select) +{ + return wm_manipulator_select_set_ex(mmap, mpr, select, true, true); +} + +void WM_manipulator_highlight_set(wmManipulatorMap *mmap, wmManipulator *mpr) +{ + wm_manipulatormap_highlight_set(mmap, NULL, mpr, mpr ? mpr->highlight_part : 0); +} + +bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr) +{ + if (WM_manipulator_select_set(mmap, mpr, true)) { + wm_manipulatormap_highlight_set(mmap, C, mpr, mpr->highlight_part); + return true; + } + else { + return false; + } +} + +/** + * Special function to run from setup so manipulators start out interactive. + * + * We could do this when linking them, but this complicates things since the window update code needs to run first. + */ +void WM_manipulator_modal_set_from_setup( + struct wmManipulatorMap *mmap, struct bContext *C, + struct wmManipulator *mpr, int part_index, const wmEvent *event) +{ + mpr->highlight_part = part_index; + WM_manipulator_highlight_set(mmap, mpr); + if (false) { + wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + } + else { + /* WEAK: but it works. */ + WM_operator_name_call(C, "MANIPULATORGROUP_OT_manipulator_tweak", WM_OP_INVOKE_DEFAULT, NULL); + } +} + +void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C) +{ + const RegionView3D *rv3d = CTX_wm_region_view3d(C); + float scale = UI_DPI_FAC; + + if ((mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE) == 0) { + scale *= U.manipulator_size; + if (rv3d) { + /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */ + float matrix_world[4][4]; + if (mpr->type->matrix_basis_get) { + float matrix_basis[4][4]; + mpr->type->matrix_basis_get(mpr, matrix_basis); + mul_m4_m4m4(matrix_world, mpr->matrix_space, matrix_basis); + } + else { + mul_m4_m4m4(matrix_world, mpr->matrix_space, mpr->matrix_basis); + } + + /* Exclude matrix_offset from scale. */ + scale *= ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_world[3]); + } + else { + scale *= 0.02f; + } + } + + mpr->scale_final = mpr->scale_basis * scale; +} + +static void manipulator_update_prop_data(wmManipulator *mpr) +{ + /* manipulator property might have been changed, so update manipulator */ + if (mpr->type->property_update) { + wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + for (int i = 0; i < mpr->type->target_property_defs_len; i++) { + wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + mpr->type->property_update(mpr, mpr_prop); + } + } + } +} + +void wm_manipulator_update(wmManipulator *mpr, const bContext *C, const bool refresh_map) +{ + if (refresh_map) { + manipulator_update_prop_data(mpr); + } + wm_manipulator_calculate_scale(mpr, C); +} + +int wm_manipulator_is_visible(wmManipulator *mpr) +{ + if (mpr->flag & WM_MANIPULATOR_HIDDEN) { + return 0; + } + if ((mpr->state & WM_MANIPULATOR_STATE_MODAL) && + !(mpr->flag & (WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_VALUE))) + { + /* don't draw while modal (dragging) */ + return 0; + } + if ((mpr->flag & WM_MANIPULATOR_DRAW_HOVER) && + !(mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) && + !(mpr->state & WM_MANIPULATOR_STATE_SELECT)) /* still draw selected manipulators */ + { + /* update but don't draw */ + return WM_MANIPULATOR_IS_VISIBLE_UPDATE; + } + + return WM_MANIPULATOR_IS_VISIBLE_UPDATE | WM_MANIPULATOR_IS_VISIBLE_DRAW; +} + +void WM_manipulator_calc_matrix_final_params( + const wmManipulator *mpr, + const struct WM_ManipulatorMatrixParams *params, + float r_mat[4][4]) +{ + const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : mpr->matrix_space; + const float (* const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis : mpr->matrix_basis; + const float (* const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset : mpr->matrix_offset; + const float *scale_final = params->scale_final ? params->scale_final : &mpr->scale_final; + + float final_matrix[4][4]; + if (params->matrix_basis == NULL && mpr->type->matrix_basis_get) { + mpr->type->matrix_basis_get(mpr, final_matrix); + } + else { + copy_m4_m4(final_matrix, matrix_basis); + } + + if (mpr->flag & WM_MANIPULATOR_DRAW_NO_SCALE) { + mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); + } + else { + if (mpr->flag & WM_MANIPULATOR_DRAW_OFFSET_SCALE) { + mul_mat3_m4_fl(final_matrix, *scale_final); + mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); + } + else { + mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); + mul_mat3_m4_fl(final_matrix, *scale_final); + } + } + + mul_m4_m4m4(r_mat, matrix_space, final_matrix); +} + +void WM_manipulator_calc_matrix_final_no_offset(const wmManipulator *mpr, float r_mat[4][4]) +{ + float mat_identity[4][4]; + unit_m4(mat_identity); + + WM_manipulator_calc_matrix_final_params( + mpr, + &((struct WM_ManipulatorMatrixParams) { + .matrix_space = NULL, + .matrix_basis = NULL, + .matrix_offset = mat_identity, + .scale_final = NULL, + }), r_mat + ); +} + +void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4]) +{ + WM_manipulator_calc_matrix_final_params( + mpr, + &((struct WM_ManipulatorMatrixParams) { + .matrix_space = NULL, + .matrix_basis = NULL, + .matrix_offset = NULL, + .scale_final = NULL, + }), r_mat + ); +} + +/** \name Manipulator Propery Access + * + * Matches `WM_operator_properties` conventions. + * + * \{ */ + + +void WM_manipulator_properties_create_ptr(PointerRNA *ptr, wmManipulatorType *wt) +{ + RNA_pointer_create(NULL, wt->srna, NULL, ptr); +} + +void WM_manipulator_properties_create(PointerRNA *ptr, const char *wtstring) +{ + const wmManipulatorType *wt = WM_manipulatortype_find(wtstring, false); + + if (wt) + WM_manipulator_properties_create_ptr(ptr, (wmManipulatorType *)wt); + else + RNA_pointer_create(NULL, &RNA_ManipulatorProperties, NULL, ptr); +} + +/* similar to the function above except its uses ID properties + * used for keymaps and macros */ +void WM_manipulator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *wtstring) +{ + if (*properties == NULL) { + IDPropertyTemplate val = {0}; + *properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp"); + } + + if (*ptr == NULL) { + *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"); + WM_manipulator_properties_create(*ptr, wtstring); + } + + (*ptr)->data = *properties; + +} + +void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context) +{ + RNA_STRUCT_BEGIN (ptr, prop) + { + switch (RNA_property_type(prop)) { + case PROP_ENUM: + if (no_context) + RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); + else + RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); + break; + case PROP_POINTER: + { + StructRNA *ptype = RNA_property_pointer_type(ptr, prop); + + /* recurse into manipulator properties */ + if (RNA_struct_is_a(ptype, &RNA_ManipulatorProperties)) { + PointerRNA opptr = RNA_property_pointer_get(ptr, prop); + WM_manipulator_properties_sanitize(&opptr, no_context); + } + break; + } + default: + break; + } + } + RNA_STRUCT_END; +} + + +/** set all props to their default, + * \param do_update Only update un-initialized props. + * + * \note, theres nothing specific to manipulators here. + * this could be made a general function. + */ +bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update) +{ + bool changed = false; + RNA_STRUCT_BEGIN (ptr, prop) + { + switch (RNA_property_type(prop)) { + case PROP_POINTER: + { + StructRNA *ptype = RNA_property_pointer_type(ptr, prop); + if (ptype != &RNA_Struct) { + PointerRNA opptr = RNA_property_pointer_get(ptr, prop); + changed |= WM_manipulator_properties_default(&opptr, do_update); + } + break; + } + default: + if ((do_update == false) || (RNA_property_is_set(ptr, prop) == false)) { + if (RNA_property_reset(ptr, prop, -1)) { + changed = true; + } + } + break; + } + } + RNA_STRUCT_END; + + return changed; +} + +/* remove all props without PROP_SKIP_SAVE */ +void WM_manipulator_properties_reset(wmManipulator *mpr) +{ + if (mpr->ptr->data) { + PropertyRNA *iterprop; + iterprop = RNA_struct_iterator_property(mpr->type->srna); + + RNA_PROP_BEGIN (mpr->ptr, itemptr, iterprop) + { + PropertyRNA *prop = itemptr.data; + + if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) { + const char *identifier = RNA_property_identifier(prop); + RNA_struct_idprops_unset(mpr->ptr, identifier); + } + } + RNA_PROP_END; + } +} + +void WM_manipulator_properties_clear(PointerRNA *ptr) +{ + IDProperty *properties = ptr->data; + + if (properties) { + IDP_ClearProperty(properties); + } +} + +void WM_manipulator_properties_free(PointerRNA *ptr) +{ + IDProperty *properties = ptr->data; + + if (properties) { + IDP_FreeProperty(properties); + MEM_freeN(properties); + ptr->data = NULL; /* just in case */ + } +} + +/** \} */ + +/** \name General Utilities + * + * \{ */ + +bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step) +{ + switch (step) { + case WM_MANIPULATORMAP_DRAWSTEP_2D: + { + break; + } + case WM_MANIPULATORMAP_DRAWSTEP_3D: + { + wmWindowManager *wm = CTX_wm_manager(C); + if (ED_screen_animation_playing(wm)) { + return false; + } + break; + } + } + return true; +} + +/** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c new file mode 100644 index 00000000000..83af1a71163 --- /dev/null +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -0,0 +1,949 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/intern/wm_gizmo_group.c + * \ingroup wm + * + * \name Manipulator-Group + * + * Manipulator-groups store and manage groups of manipulators. They can be + * attached to modal handlers and have own keymaps. + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_string.h" +#include "BLI_math.h" + +#include "BKE_context.h" +#include "BKE_main.h" +#include "BKE_report.h" +#include "BKE_workspace.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" +#include "wm_event_system.h" + +#include "ED_screen.h" +#include "ED_undo.h" + +/* own includes */ +#include "wm_gizmo_wmapi.h" +#include "wm_gizmo_intern.h" + +#ifdef WITH_PYTHON +# include "BPY_extern.h" +#endif + +/* Allow manipulator part's to be single click only, + * dragging falls back to activating their 'drag_part' action. */ +#define USE_DRAG_DETECT + +/* -------------------------------------------------------------------- */ +/** \name wmManipulatorGroup + * + * \{ */ + +/** + * Create a new manipulator-group from \a wgt. + */ +wmManipulatorGroup *wm_manipulatorgroup_new_from_type( + wmManipulatorMap *mmap, wmManipulatorGroupType *wgt) +{ + wmManipulatorGroup *mgroup = MEM_callocN(sizeof(*mgroup), "manipulator-group"); + mgroup->type = wgt; + + /* keep back-link */ + mgroup->parent_mmap = mmap; + + BLI_addtail(&mmap->groups, mgroup); + + return mgroup; +} + +void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup) +{ + wmManipulatorMap *mmap = mgroup->parent_mmap; + + /* Similar to WM_manipulator_unlink, but only to keep mmap state correct, + * we don't want to run callbacks. */ + if (mmap->mmap_context.highlight && mmap->mmap_context.highlight->parent_mgroup == mgroup) { + wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + } + if (mmap->mmap_context.modal && mmap->mmap_context.modal->parent_mgroup == mgroup) { + wm_manipulatormap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false); + } + + for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) { + mpr_next = mpr->next; + if (mmap->mmap_context.select.len) { + WM_manipulator_select_unlink(mmap, mpr); + } + WM_manipulator_free(mpr); + } + BLI_listbase_clear(&mgroup->manipulators); + +#ifdef WITH_PYTHON + if (mgroup->py_instance) { + /* do this first in case there are any __del__ functions or + * similar that use properties */ + BPY_DECREF_RNA_INVALIDATE(mgroup->py_instance); + } +#endif + + if (mgroup->reports && (mgroup->reports->flag & RPT_FREE)) { + BKE_reports_clear(mgroup->reports); + MEM_freeN(mgroup->reports); + } + + if (mgroup->customdata_free) { + mgroup->customdata_free(mgroup->customdata); + } + else { + MEM_SAFE_FREE(mgroup->customdata); + } + + BLI_remlink(&mmap->groups, mgroup); + + MEM_freeN(mgroup); +} + +/** + * Add \a manipulator to \a mgroup and make sure its name is unique within the group. + */ +void wm_manipulatorgroup_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr) +{ + BLI_assert(BLI_findindex(&mgroup->manipulators, mpr) == -1); + BLI_addtail(&mgroup->manipulators, mpr); + mpr->parent_mgroup = mgroup; +} + +wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( + const wmManipulatorGroup *mgroup, bContext *C, const wmEvent *event, + int *r_part) +{ + for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + if (mpr->type->test_select && (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) { + if ((*r_part = mpr->type->test_select(C, mpr, event)) != -1) { + return mpr; + } + } + } + + return NULL; +} + +/** + * Adds all manipulators of \a mgroup that can be selected to the head of \a listbase. Added items need freeing! + */ +void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorGroup *mgroup, ListBase *listbase) +{ + for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + if ((mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) { + if (((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) && mpr->type->draw_select) || + ((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0 && mpr->type->test_select)) + { + BLI_addhead(listbase, BLI_genericNodeN(mpr)); + } + } + } +} + +void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bContext *C) +{ + /* prepare for first draw */ + if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0)) { + mgroup->type->setup(C, mgroup); + + /* Not ideal, initialize keymap here, needed for RNA runtime generated manipulators. */ + wmManipulatorGroupType *wgt = mgroup->type; + if (wgt->keymap == NULL) { + wmWindowManager *wm = CTX_wm_manager(C); + wm_manipulatorgrouptype_setup_keymap(wgt, wm->defaultconf); + BLI_assert(wgt->keymap != NULL); + } + mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_SETUP; + } + + /* refresh may be called multiple times, this just ensures its called at least once before we draw. */ + if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_REFRESH) == 0)) { + if (mgroup->type->refresh) { + mgroup->type->refresh(C, mgroup); + } + mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_REFRESH; + } +} + +bool WM_manipulator_group_type_poll(const bContext *C, const struct wmManipulatorGroupType *wgt) +{ + /* If we're tagged, only use compatible. */ + if (wgt->owner_id[0] != '\0') { + const WorkSpace *workspace = CTX_wm_workspace(C); + if (BKE_workspace_owner_id_check(workspace, wgt->owner_id) == false) { + return false; + } + } + /* Check for poll function, if manipulator-group belongs to an operator, also check if the operator is running. */ + return (!wgt->poll || wgt->poll(C, (wmManipulatorGroupType *)wgt)); +} + +bool wm_manipulatorgroup_is_visible_in_drawstep( + const wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep) +{ + switch (drawstep) { + case WM_MANIPULATORMAP_DRAWSTEP_2D: + return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; + case WM_MANIPULATORMAP_DRAWSTEP_3D: + return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D); + default: + BLI_assert(0); + return false; + } +} + +bool wm_manipulatorgroup_is_any_selected(const wmManipulatorGroup *mgroup) +{ + if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT) { + for (const wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { + return true; + } + } + } + return false; +} + +/** \} */ + +/** \name Manipulator operators + * + * Basic operators for manipulator interaction with user configurable keymaps. + * + * \{ */ + +static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + ARegion *ar = CTX_wm_region(C); + wmManipulatorMap *mmap = ar->manipulator_map; + wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmManipulator *highlight = mmap->mmap_context.highlight; + + bool extend = RNA_boolean_get(op->ptr, "extend"); + bool deselect = RNA_boolean_get(op->ptr, "deselect"); + bool toggle = RNA_boolean_get(op->ptr, "toggle"); + + /* deselect all first */ + if (extend == false && deselect == false && toggle == false) { + wm_manipulatormap_deselect_all(mmap); + BLI_assert(msel->items == NULL && msel->len == 0); + UNUSED_VARS_NDEBUG(msel); + } + + if (highlight) { + const bool is_selected = (highlight->state & WM_MANIPULATOR_STATE_SELECT); + bool redraw = false; + + if (toggle) { + /* toggle: deselect if already selected, else select */ + deselect = is_selected; + } + + if (deselect) { + if (is_selected && WM_manipulator_select_set(mmap, highlight, false)) { + redraw = true; + } + } + else if (wm_manipulator_select_and_highlight(C, mmap, highlight)) { + redraw = true; + } + + if (redraw) { + ED_region_tag_redraw(ar); + } + + return OPERATOR_FINISHED; + } + else { + BLI_assert(0); + return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); + } + + return OPERATOR_PASS_THROUGH; +} + +void MANIPULATORGROUP_OT_manipulator_select(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Gizmo Select"; + ot->description = "Select the currently highlighted manipulator"; + ot->idname = "MANIPULATORGROUP_OT_manipulator_select"; + + /* api callbacks */ + ot->invoke = manipulator_select_invoke; + + ot->flag = OPTYPE_UNDO; + + WM_operator_properties_mouse_select(ot); +} + +typedef struct ManipulatorTweakData { + wmManipulatorMap *mmap; + wmManipulatorGroup *mgroup; + wmManipulator *mpr_modal; + + int init_event; /* initial event type */ + int flag; /* tweak flags */ + +#ifdef USE_DRAG_DETECT + /* True until the mouse is moved (only use when the operator has no modal). + * this allows some manipulators to be click-only. */ + enum { + /* Don't detect dragging. */ + DRAG_NOP = 0, + /* Detect dragging (wait until a drag or click is detected). */ + DRAG_DETECT, + /* Drag has started, idle until there is no active modal operator. + * This is needed because finishing the modal operator also exits + * the modal manipulator state (un-grabbs the cursor). + * Ideally this workaround could be removed later. */ + DRAG_IDLE, + } drag_state; +#endif + +} ManipulatorTweakData; + +static bool manipulator_tweak_start( + bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event) +{ + /* activate highlighted manipulator */ + wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + + return (mpr->state & WM_MANIPULATOR_STATE_MODAL); +} + +static bool manipulator_tweak_start_and_finish( + bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event, bool *r_is_modal) +{ + wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + if (r_is_modal) { + *r_is_modal = false; + } + if (mpop && mpop->type) { + + /* Undo/Redo */ + if (mpop->is_redo) { + wmWindowManager *wm = CTX_wm_manager(C); + wmOperator *op = WM_operator_last_redo(C); + + /* We may want to enable this, for now the manipulator can manage it's own properties. */ +#if 0 + IDP_MergeGroup(mpop->ptr.data, op->properties, false); +#endif + + WM_operator_free_all_after(wm, op); + ED_undo_pop_op(C, op); + } + + /* XXX temporary workaround for modal manipulator operator + * conflicting with modal operator attached to manipulator */ + if (mpop->type->modal) { + /* activate highlighted manipulator */ + wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + if (r_is_modal) { + *r_is_modal = true; + } + } + else { + /* Allow for 'button' manipulators, single click to run an action. */ + WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); + } + return true; + } + else { + return false; + } +} + +static void manipulator_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal) +{ + ManipulatorTweakData *mtweak = op->customdata; + if (mtweak->mpr_modal->type->exit) { + mtweak->mpr_modal->type->exit(C, mtweak->mpr_modal, cancel); + } + if (clear_modal) { + /* The manipulator may have been removed. */ + if ((BLI_findindex(&mtweak->mmap->groups, mtweak->mgroup) != -1) && + (BLI_findindex(&mtweak->mgroup->manipulators, mtweak->mpr_modal) != -1)) + { + wm_manipulatormap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false); + } + } + MEM_freeN(mtweak); +} + +static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + ManipulatorTweakData *mtweak = op->customdata; + wmManipulator *mpr = mtweak->mpr_modal; + int retval = OPERATOR_PASS_THROUGH; + bool clear_modal = true; + + if (mpr == NULL) { + BLI_assert(0); + return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); + } + +#ifdef USE_DRAG_DETECT + wmManipulatorMap *mmap = mtweak->mmap; + if (mtweak->drag_state == DRAG_DETECT) { + if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { + if (len_manhattan_v2v2_int(&event->x, mmap->mmap_context.event_xy) > 2) { + mtweak->drag_state = DRAG_IDLE; + mpr->highlight_part = mpr->drag_part; + } + } + else if (event->type == mtweak->init_event && event->val == KM_RELEASE) { + mtweak->drag_state = DRAG_NOP; + retval = OPERATOR_FINISHED; + } + + if (mtweak->drag_state != DRAG_DETECT) { + /* Follow logic in 'manipulator_tweak_invoke' */ + bool is_modal = false; + if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, &is_modal)) { + if (is_modal) { + clear_modal = false; + } + } + else { + if (!manipulator_tweak_start(C, mmap, mpr, event)) { + retval = OPERATOR_FINISHED; + } + } + } + } + if (mtweak->drag_state == DRAG_IDLE) { + if (mmap->mmap_context.modal != NULL) { + return OPERATOR_PASS_THROUGH; + } + else { + manipulator_tweak_finish(C, op, false, false); + return OPERATOR_FINISHED; + } + } +#endif /* USE_DRAG_DETECT */ + + if (retval == OPERATOR_FINISHED) { + /* pass */ + } + else if (event->type == mtweak->init_event && event->val == KM_RELEASE) { + retval = OPERATOR_FINISHED; + } + else if (event->type == EVT_MODAL_MAP) { + switch (event->val) { + case TWEAK_MODAL_CANCEL: + retval = OPERATOR_CANCELLED; + break; + case TWEAK_MODAL_CONFIRM: + retval = OPERATOR_FINISHED; + break; + case TWEAK_MODAL_PRECISION_ON: + mtweak->flag |= WM_MANIPULATOR_TWEAK_PRECISE; + break; + case TWEAK_MODAL_PRECISION_OFF: + mtweak->flag &= ~WM_MANIPULATOR_TWEAK_PRECISE; + break; + + case TWEAK_MODAL_SNAP_ON: + mtweak->flag |= WM_MANIPULATOR_TWEAK_SNAP; + break; + case TWEAK_MODAL_SNAP_OFF: + mtweak->flag &= ~WM_MANIPULATOR_TWEAK_SNAP; + break; + } + } + + if (retval != OPERATOR_PASS_THROUGH) { + manipulator_tweak_finish(C, op, retval != OPERATOR_FINISHED, clear_modal); + return retval; + } + + /* handle manipulator */ + wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; + if (modal_fn) { + int modal_retval = modal_fn(C, mpr, event, mtweak->flag); + + if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) { + manipulator_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true); + return OPERATOR_FINISHED; + } + + /* Ugly hack to send manipulator events */ + ((wmEvent *)event)->type = EVT_MANIPULATOR_UPDATE; + } + + /* always return PASS_THROUGH so modal handlers + * with manipulators attached can update */ + BLI_assert(retval == OPERATOR_PASS_THROUGH); + return OPERATOR_PASS_THROUGH; +} + +static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + wmManipulatorMap *mmap = ar->manipulator_map; + wmManipulator *mpr = mmap->mmap_context.highlight; + + /* Needed for single click actions which don't enter modal state. */ + WM_tooltip_clear(C, CTX_wm_window(C)); + + if (!mpr) { + /* wm_handlers_do_intern shouldn't let this happen */ + BLI_assert(0); + return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); + } + + bool use_drag_fallback = false; + +#ifdef USE_DRAG_DETECT + use_drag_fallback = !ELEM(mpr->drag_part, -1, mpr->highlight_part); +#endif + + if (use_drag_fallback == false) { + if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, NULL)) { + return OPERATOR_FINISHED; + } + } + + bool use_drag_detect = false; +#ifdef USE_DRAG_DETECT + if (use_drag_fallback) { + wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + if (mpop && mpop->type) { + if (mpop->type->modal == NULL) { + use_drag_detect = true; + } + } + } +#endif + + if (use_drag_detect == false) { + if (!manipulator_tweak_start(C, mmap, mpr, event)) { + /* failed to start */ + return OPERATOR_PASS_THROUGH; + } + } + + ManipulatorTweakData *mtweak = MEM_mallocN(sizeof(ManipulatorTweakData), __func__); + + mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type); + mtweak->mpr_modal = mmap->mmap_context.highlight; + mtweak->mgroup = mtweak->mpr_modal->parent_mgroup; + mtweak->mmap = mmap; + mtweak->flag = 0; + +#ifdef USE_DRAG_DETECT + mtweak->drag_state = use_drag_detect ? DRAG_DETECT : DRAG_NOP; +#endif + + op->customdata = mtweak; + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Gizmo Tweak"; + ot->description = "Tweak the active gizmo"; + ot->idname = "MANIPULATORGROUP_OT_manipulator_tweak"; + + /* api callbacks */ + ot->invoke = manipulator_tweak_invoke; + ot->modal = manipulator_tweak_modal; + + /* TODO(campbell) This causes problems tweaking settings for operators, + * need to find a way to support this. */ +#if 0 + ot->flag = OPTYPE_UNDO; +#endif +} + +/** \} */ + + +static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname) +{ + wmKeyMap *keymap; + char name[KMAP_MAX_NAME]; + + static EnumPropertyItem modal_items[] = { + {TWEAK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, + {TWEAK_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, + {TWEAK_MODAL_PRECISION_ON, "PRECISION_ON", 0, "Enable Precision", ""}, + {TWEAK_MODAL_PRECISION_OFF, "PRECISION_OFF", 0, "Disable Precision", ""}, + {TWEAK_MODAL_SNAP_ON, "SNAP_ON", 0, "Enable Snap", ""}, + {TWEAK_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Disable Snap", ""}, + {0, NULL, 0, NULL, NULL} + }; + + + BLI_snprintf(name, sizeof(name), "%s Tweak Modal Map", mgroupname); + keymap = WM_modalkeymap_get(keyconf, name); + + /* this function is called for each spacetype, only needs to add map once */ + if (keymap && keymap->modal_items) + return NULL; + + keymap = WM_modalkeymap_add(keyconf, name, modal_items); + + + /* items for modal map */ + WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL); + WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL); + + WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM); + + WM_modalkeymap_add_item(keymap, RIGHTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON); + WM_modalkeymap_add_item(keymap, RIGHTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF); + WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON); + WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF); + + WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON); + WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF); + WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON); + WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF); + + WM_modalkeymap_assign(keymap, "MANIPULATORGROUP_OT_manipulator_tweak"); + + return keymap; +} + +/** + * Common default keymap for manipulator groups + */ +wmKeyMap *WM_manipulatorgroup_keymap_common( + const wmManipulatorGroupType *wgt, wmKeyConfig *config) +{ + /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ + wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); + + WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0); + manipulatorgroup_tweak_modal_keymap(config, wgt->name); + + return km; +} + +/** + * Variation of #WM_manipulatorgroup_keymap_common but with keymap items for selection + */ +wmKeyMap *WM_manipulatorgroup_keymap_common_select( + const wmManipulatorGroupType *wgt, wmKeyConfig *config) +{ + /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ + wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); + + WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); + WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", EVT_TWEAK_S, KM_ANY, 0, 0); + manipulatorgroup_tweak_modal_keymap(config, wgt->name); + + wmKeyMapItem *kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "extend", false); + RNA_boolean_set(kmi->ptr, "deselect", false); + RNA_boolean_set(kmi->ptr, "toggle", false); + kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", false); + RNA_boolean_set(kmi->ptr, "deselect", false); + RNA_boolean_set(kmi->ptr, "toggle", true); + + return km; +} + +/** \} */ /* wmManipulatorGroup */ + +/* -------------------------------------------------------------------- */ +/** \name wmManipulatorGroupType + * + * \{ */ + +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( + struct wmManipulatorMapType *mmap_type, + const wmManipulatorGroupType *wgt) +{ + /* could use hash lookups as operator types do, for now simple search. */ + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + wgt_ref; + wgt_ref = wgt_ref->next) + { + if (wgt_ref->type == wgt) { + return wgt_ref; + } + } + return NULL; +} + +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( + struct wmManipulatorMapType *mmap_type, + const char *idname) +{ + /* could use hash lookups as operator types do, for now simple search. */ + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + wgt_ref; + wgt_ref = wgt_ref->next) + { + if (STREQ(idname, wgt_ref->type->idname)) { + return wgt_ref; + } + } + return NULL; +} + +/** + * Use this for registering manipulators on startup. For runtime, use #WM_manipulatormaptype_group_link_runtime. + */ +wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( + wmManipulatorMapType *mmap_type, const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + BLI_assert(wgt != NULL); + return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); +} + +wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( + wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +{ + wmManipulatorGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmManipulatorGroupTypeRef), "manipulator-group-ref"); + wgt_ref->type = wgt; + BLI_addtail(&mmap_type->grouptype_refs, wgt_ref); + return wgt_ref; +} + +void WM_manipulatormaptype_group_init_runtime_keymap( + const Main *bmain, + wmManipulatorGroupType *wgt) +{ + /* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */ + wm_manipulatorgrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf); +} + +void WM_manipulatormaptype_group_init_runtime( + const Main *bmain, wmManipulatorMapType *mmap_type, + wmManipulatorGroupType *wgt) +{ + /* now create a manipulator for all existing areas */ + for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { + for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ARegion *ar = lb->first; ar; ar = ar->next) { + wmManipulatorMap *mmap = ar->manipulator_map; + if (mmap && mmap->type == mmap_type) { + wm_manipulatorgroup_new_from_type(mmap, wgt); + + /* just add here, drawing will occur on next update */ + wm_manipulatormap_highlight_set(mmap, NULL, NULL, 0); + ED_region_tag_redraw(ar); + } + } + } + } + } +} + + +/** + * Unlike #WM_manipulatormaptype_group_unlink this doesn't maintain correct state, simply free. + */ +void WM_manipulatormaptype_group_free(wmManipulatorGroupTypeRef *wgt_ref) +{ + MEM_freeN(wgt_ref); +} + +void WM_manipulatormaptype_group_unlink( + bContext *C, Main *bmain, wmManipulatorMapType *mmap_type, + const wmManipulatorGroupType *wgt) +{ + /* Free instances. */ + for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { + for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ARegion *ar = lb->first; ar; ar = ar->next) { + wmManipulatorMap *mmap = ar->manipulator_map; + if (mmap && mmap->type == mmap_type) { + wmManipulatorGroup *mgroup, *mgroup_next; + for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup_next) { + mgroup_next = mgroup->next; + if (mgroup->type == wgt) { + BLI_assert(mgroup->parent_mmap == mmap); + wm_manipulatorgroup_free(C, mgroup); + ED_region_tag_redraw(ar); + } + } + } + } + } + } + } + + /* Free types. */ + wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); + if (wgt_ref) { + BLI_remlink(&mmap_type->grouptype_refs, wgt_ref); + WM_manipulatormaptype_group_free(wgt_ref); + } + + /* Note, we may want to keep this keymap for editing */ + WM_keymap_remove(wgt->keyconf, wgt->keymap); + + BLI_assert(WM_manipulatormaptype_group_find_ptr(mmap_type, wgt) == NULL); +} + +void wm_manipulatorgrouptype_setup_keymap( + wmManipulatorGroupType *wgt, wmKeyConfig *keyconf) +{ + /* Use flag since setup_keymap may return NULL, + * in that case we better not keep calling it. */ + if (wgt->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) { + wgt->keymap = wgt->setup_keymap(wgt, keyconf); + wgt->keyconf = keyconf; + wgt->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + } +} + +/** \} */ /* wmManipulatorGroupType */ + +/* -------------------------------------------------------------------- */ +/** \name High Level Add/Remove API + * + * For use directly from operators & RNA registration. + * + * \note In context of manipulator API these names are a bit misleading, + * but for general use terms its OK. + * `WM_manipulator_group_type_add` would be more correctly called: + * `WM_manipulatormaptype_grouptype_reference_link` + * but for general purpose API this is too detailed & annoying. + * + * \note We may want to return a value if there is nothing to remove. + * + * \{ */ + +void WM_manipulator_group_type_add_ptr_ex( + wmManipulatorGroupType *wgt, + wmManipulatorMapType *mmap_type) +{ + WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); + + WM_manipulatorconfig_update_tag_init(mmap_type, wgt); +} +void WM_manipulator_group_type_add_ptr( + wmManipulatorGroupType *wgt) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); + WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); +} +void WM_manipulator_group_type_add(const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + BLI_assert(wgt != NULL); + WM_manipulator_group_type_add_ptr(wgt); +} + +void WM_manipulator_group_type_ensure_ptr_ex( + wmManipulatorGroupType *wgt, + wmManipulatorMapType *mmap_type) +{ + wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); + if (wgt_ref == NULL) { + WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); + } +} +void WM_manipulator_group_type_ensure_ptr( + wmManipulatorGroupType *wgt) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); + WM_manipulator_group_type_ensure_ptr_ex(wgt, mmap_type); +} +void WM_manipulator_group_type_ensure(const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + BLI_assert(wgt != NULL); + WM_manipulator_group_type_ensure_ptr(wgt); +} + +void WM_manipulator_group_type_remove_ptr_ex( + struct Main *bmain, wmManipulatorGroupType *wgt, + wmManipulatorMapType *mmap_type) +{ + WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt); + WM_manipulatorgrouptype_free_ptr(wgt); +} +void WM_manipulator_group_type_remove_ptr( + struct Main *bmain, wmManipulatorGroupType *wgt) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); + WM_manipulator_group_type_remove_ptr_ex(bmain, wgt, mmap_type); +} +void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + BLI_assert(wgt != NULL); + WM_manipulator_group_type_remove_ptr(bmain, wgt); +} + +/* delayed versions */ + +void WM_manipulator_group_type_unlink_delayed_ptr_ex( + wmManipulatorGroupType *wgt, + wmManipulatorMapType *mmap_type) +{ + WM_manipulatorconfig_update_tag_remove(mmap_type, wgt); +} + +void WM_manipulator_group_type_unlink_delayed_ptr( + wmManipulatorGroupType *wgt) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); + WM_manipulator_group_type_unlink_delayed_ptr_ex(wgt, mmap_type); +} + +void WM_manipulator_group_type_unlink_delayed(const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + BLI_assert(wgt != NULL); + WM_manipulator_group_type_unlink_delayed_ptr(wgt); +} + +/** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c new file mode 100644 index 00000000000..f93beb0ac9f --- /dev/null +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c @@ -0,0 +1,197 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c + * \ingroup wm + */ + +#include "BLI_utildefines.h" +#include "BLI_ghash.h" +#include "BLI_string.h" +#include "BLI_string_utils.h" + +#include "BKE_context.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* only for own init/exit calls (wm_manipulatorgrouptype_init/wm_manipulatorgrouptype_free) */ +#include "wm.h" + +/* own includes */ +#include "wm_gizmo_wmapi.h" +#include "wm_gizmo_intern.h" + + +/** \name ManipulatorGroup Type Append + * + * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. + * \{ */ + +static GHash *global_manipulatorgrouptype_hash = NULL; + +wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet) +{ + if (idname[0]) { + wmManipulatorGroupType *wgt; + + wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); + if (wgt) { + return wgt; + } + + if (!quiet) { + printf("search for unknown manipulator group '%s'\n", idname); + } + } + else { + if (!quiet) { + printf("search for empty manipulator group\n"); + } + } + + return NULL; +} + +/* caller must free */ +void WM_manipulatorgrouptype_iter(GHashIterator *ghi) +{ + BLI_ghashIterator_init(ghi, global_manipulatorgrouptype_hash); +} + +static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void) +{ + wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulatorgrouptype"); + + return wgt; +} +static void wm_manipulatorgrouptype_append__end(wmManipulatorGroupType *wgt) +{ + BLI_assert(wgt->name != NULL); + BLI_assert(wgt->idname != NULL); + + wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + + /* if not set, use default */ + if (wgt->setup_keymap == NULL) { + if (wgt->flag & WM_MANIPULATORGROUPTYPE_SELECT) { + wgt->setup_keymap = WM_manipulatorgroup_keymap_common_select; + } + else { + wgt->setup_keymap = WM_manipulatorgroup_keymap_common; + } + } + + BLI_ghash_insert(global_manipulatorgrouptype_hash, (void *)wgt->idname, wgt); +} + +wmManipulatorGroupType *WM_manipulatorgrouptype_append( + void (*wtfunc)(struct wmManipulatorGroupType *)) +{ + wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); + wtfunc(wgt); + wm_manipulatorgrouptype_append__end(wgt); + return wgt; +} + +wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr( + void (*wtfunc)(struct wmManipulatorGroupType *, void *), void *userdata) +{ + wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); + wtfunc(wgt, userdata); + wm_manipulatorgrouptype_append__end(wgt); + return wgt; +} + +/** + * Append and insert into a manipulator typemap. + * This is most common for C manipulators which are enabled by default. + */ +wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( + wmManipulatorMapType *mmap_type, + void (*wtfunc)(struct wmManipulatorGroupType *)) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(wtfunc); + + wgt->mmap_params.spaceid = mmap_type->spaceid; + wgt->mmap_params.regionid = mmap_type->regionid; + + return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); +} + +/** + * Free but don't remove from ghash. + */ +static void manipulatorgrouptype_free(wmManipulatorGroupType *wgt) +{ + if (wgt->ext.srna) { /* python manipulator group, allocs own string */ + MEM_freeN((void *)wgt->idname); + } + + MEM_freeN(wgt); +} + +void WM_manipulatorgrouptype_free_ptr(wmManipulatorGroupType *wgt) +{ + BLI_assert(wgt == WM_manipulatorgrouptype_find(wgt->idname, false)); + + BLI_ghash_remove(global_manipulatorgrouptype_hash, wgt->idname, NULL, NULL); + + manipulatorgrouptype_free(wgt); + + /* XXX, TODO, update the world! */ +} + +bool WM_manipulatorgrouptype_free(const char *idname) +{ + wmManipulatorGroupType *wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); + + if (wgt == NULL) { + return false; + } + + WM_manipulatorgrouptype_free_ptr(wgt); + + return true; +} + +static void wm_manipulatorgrouptype_ghash_free_cb(wmManipulatorGroupType *wgt) +{ + manipulatorgrouptype_free(wgt); +} + +void wm_manipulatorgrouptype_free(void) +{ + BLI_ghash_free(global_manipulatorgrouptype_hash, NULL, (GHashValFreeFP)wm_manipulatorgrouptype_ghash_free_cb); + global_manipulatorgrouptype_hash = NULL; +} + +/* called on initialize WM_init() */ +void wm_manipulatorgrouptype_init(void) +{ + /* reserve size is set based on blender default setup */ + global_manipulatorgrouptype_hash = BLI_ghash_str_new_ex("wm_manipulatorgrouptype_init gh", 128); +} + +/** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h new file mode 100644 index 00000000000..7a007a8a909 --- /dev/null +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h @@ -0,0 +1,144 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/intern/wm_gizmo_intern.h + * \ingroup wm + */ + + +#ifndef __WM_GIZMO_INTERN_H__ +#define __WM_GIZMO_INTERN_H__ + +struct wmKeyConfig; +struct wmManipulatorMap; +struct ManipulatorGeomInfo; +struct GHashIterator; + +#include "wm_gizmo_fn.h" + +/* -------------------------------------------------------------------- */ +/* wmManipulator */ + + +bool wm_manipulator_select_set_ex( + struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select, + bool use_array, bool use_callback); +bool wm_manipulator_select_and_highlight(bContext *C, struct wmManipulatorMap *mmap, struct wmManipulator *mpr); + +void wm_manipulator_calculate_scale(struct wmManipulator *mpr, const bContext *C); +void wm_manipulator_update(struct wmManipulator *mpr, const bContext *C, const bool refresh_map); + +int wm_manipulator_is_visible(struct wmManipulator *mpr); +enum { + WM_MANIPULATOR_IS_VISIBLE_UPDATE = (1 << 0), + WM_MANIPULATOR_IS_VISIBLE_DRAW = (1 << 1), +}; + +/* -------------------------------------------------------------------- */ +/* wmManipulatorGroup */ + +enum { + TWEAK_MODAL_CANCEL = 1, + TWEAK_MODAL_CONFIRM, + TWEAK_MODAL_PRECISION_ON, + TWEAK_MODAL_PRECISION_OFF, + TWEAK_MODAL_SNAP_ON, + TWEAK_MODAL_SNAP_OFF, +}; + +struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type( + struct wmManipulatorMap *mmap, struct wmManipulatorGroupType *wgt); +void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorGroup *mgroup); +void wm_manipulatorgroup_manipulator_register(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr); +struct wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( + const struct wmManipulatorGroup *mgroup, struct bContext *C, const struct wmEvent *event, + int *r_part); +void wm_manipulatorgroup_intersectable_manipulators_to_list( + const struct wmManipulatorGroup *mgroup, struct ListBase *listbase); +void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, const struct bContext *C); +bool wm_manipulatorgroup_is_visible_in_drawstep( + const struct wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep); + +void wm_manipulatorgrouptype_setup_keymap( + struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf); + + +/* -------------------------------------------------------------------- */ +/* wmManipulatorMap */ + +typedef struct wmManipulatorMapSelectState { + struct wmManipulator **items; + int len, len_alloc; +} wmManipulatorMapSelectState; + +struct wmManipulatorMap { + + struct wmManipulatorMapType *type; + ListBase groups; /* wmManipulatorGroup */ + + /* private, update tagging (enum defined in C source). */ + char update_flag[WM_MANIPULATORMAP_DRAWSTEP_MAX]; + + /** + * \brief Manipulator map runtime context + * + * Contains information about this manipulator-map. Currently + * highlighted manipulator, currently selected manipulators, ... + */ + struct { + /* we redraw the manipulator-map when this changes */ + struct wmManipulator *highlight; + /* User has clicked this manipulator and it gets all input. */ + struct wmManipulator *modal; + /* array for all selected manipulators */ + struct wmManipulatorMapSelectState select; + /* cursor location at point of entering modal (see: WM_MANIPULATOR_GRAB_CURSOR) */ + int event_xy[2]; + short event_grabcursor; + /* until we have nice cursor push/pop API. */ + int last_cursor; + } mmap_context; +}; + +/** + * This is a container for all manipulator types that can be instantiated in a region. + * (similar to dropboxes). + * + * \note There is only ever one of these for every (area, region) combination. + */ +struct wmManipulatorMapType { + struct wmManipulatorMapType *next, *prev; + short spaceid, regionid; + /* types of manipulator-groups for this manipulator-map type */ + ListBase grouptype_refs; + + /* eManipulatorMapTypeUpdateFlags */ + eWM_ManipulatorMapTypeUpdateFlag type_update_flag; +}; + +void wm_manipulatormap_select_array_clear(struct wmManipulatorMap *mmap); +bool wm_manipulatormap_deselect_all(struct wmManipulatorMap *mmap); +void wm_manipulatormap_select_array_shrink(struct wmManipulatorMap *mmap, int len_subtract); +void wm_manipulatormap_select_array_push_back(struct wmManipulatorMap *mmap, wmManipulator *mpr); +void wm_manipulatormap_select_array_remove(struct wmManipulatorMap *mmap, wmManipulator *mpr); + +#endif diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c new file mode 100644 index 00000000000..94db6b45887 --- /dev/null +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -0,0 +1,1209 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/intern/wm_gizmo_map.c + * \ingroup wm + */ + +#include + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_rect.h" +#include "BLI_string.h" +#include "BLI_ghash.h" + +#include "BKE_context.h" +#include "BKE_global.h" + +#include "ED_screen.h" +#include "ED_view3d.h" + +#include "GPU_glew.h" +#include "GPU_matrix.h" +#include "GPU_select.h" + +#include "MEM_guardedalloc.h" + +#include "WM_api.h" +#include "WM_types.h" +#include "wm_event_system.h" + +/* for tool-tips */ +#include "UI_interface.h" + +#include "DEG_depsgraph.h" + +/* own includes */ +#include "wm_gizmo_wmapi.h" +#include "wm_gizmo_intern.h" + +/** + * Store all manipulator-maps here. Anyone who wants to register a manipulator for a certain + * area type can query the manipulator-map to do so. + */ +static ListBase manipulatormaptypes = {NULL, NULL}; + +/** + * Update when manipulator-map types change. + */ +/* so operator removal can trigger update */ +typedef enum eWM_ManipulatorGroupTypeGlobalFlag { + WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0), + WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1), +} eWM_ManipulatorGroupTypeGlobalFlag; + +static eWM_ManipulatorGroupTypeGlobalFlag wm_mmap_type_update_flag = 0; + +/** + * Manipulator-map update tagging. + */ +enum { + /** #manipulatormap_prepare_drawing has run */ + MANIPULATORMAP_IS_PREPARE_DRAW = (1 << 0), + MANIPULATORMAP_IS_REFRESH_CALLBACK = (1 << 1), +}; + + +/* -------------------------------------------------------------------- */ +/** \name wmManipulatorMap Selection Array API + * + * Just handle ``wm_manipulatormap_select_array_*``, not flags or callbacks. + * + * \{ */ + +static void wm_manipulatormap_select_array_ensure_len_alloc(wmManipulatorMap *mmap, int len) +{ + wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + if (len <= msel->len_alloc) { + return; + } + msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * len); + msel->len_alloc = len; +} + +void wm_manipulatormap_select_array_clear(wmManipulatorMap *mmap) +{ + wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + MEM_SAFE_FREE(msel->items); + msel->len = 0; + msel->len_alloc = 0; +} + +void wm_manipulatormap_select_array_shrink(wmManipulatorMap *mmap, int len_subtract) +{ + wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + msel->len -= len_subtract; + if (msel->len <= 0) { + wm_manipulatormap_select_array_clear(mmap); + } + else { + if (msel->len < msel->len_alloc / 2) { + msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len); + msel->len_alloc = msel->len; + } + } +} + +void wm_manipulatormap_select_array_push_back(wmManipulatorMap *mmap, wmManipulator *mpr) +{ + wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + BLI_assert(msel->len <= msel->len_alloc); + if (msel->len == msel->len_alloc) { + msel->len_alloc = (msel->len + 1) * 2; + msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len_alloc); + } + msel->items[msel->len++] = mpr; +} + +void wm_manipulatormap_select_array_remove(wmManipulatorMap *mmap, wmManipulator *mpr) +{ + wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + /* remove manipulator from selected_manipulators array */ + for (int i = 0; i < msel->len; i++) { + if (msel->items[i] == mpr) { + for (int j = i; j < (msel->len - 1); j++) { + msel->items[j] = msel->items[j + 1]; + } + wm_manipulatormap_select_array_shrink(mmap, 1); + break; + } + } + +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ +/** \name wmManipulatorMap + * + * \{ */ + +/** + * Creates a manipulator-map with all registered manipulators for that type + */ +wmManipulatorMap *WM_manipulatormap_new_from_type( + const struct wmManipulatorMapType_Params *mmap_params) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(mmap_params); + wmManipulatorMap *mmap; + + mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap"); + mmap->type = mmap_type; + WM_manipulatormap_tag_refresh(mmap); + + /* create all manipulator-groups for this manipulator-map. We may create an empty one + * too in anticipation of manipulators from operators etc */ + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { + wm_manipulatorgroup_new_from_type(mmap, wgt_ref->type); + } + + return mmap; +} + +void wm_manipulatormap_remove(wmManipulatorMap *mmap) +{ + /* Clear first so further calls don't waste time trying to maintain correct array state. */ + wm_manipulatormap_select_array_clear(mmap); + + for (wmManipulatorGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) { + mgroup_next = mgroup->next; + BLI_assert(mgroup->parent_mmap == mmap); + wm_manipulatorgroup_free(NULL, mgroup); + } + BLI_assert(BLI_listbase_is_empty(&mmap->groups)); + + MEM_freeN(mmap); +} + + +wmManipulatorGroup *WM_manipulatormap_group_find( + struct wmManipulatorMap *mmap, + const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + if (wgt) { + return WM_manipulatormap_group_find_ptr(mmap, wgt); + } + return NULL; +} + +wmManipulatorGroup *WM_manipulatormap_group_find_ptr( + struct wmManipulatorMap *mmap, + const struct wmManipulatorGroupType *wgt) +{ + for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + if (mgroup->type == wgt) { + return mgroup; + } + } + return NULL; +} + +const ListBase *WM_manipulatormap_group_list(wmManipulatorMap *mmap) +{ + return &mmap->groups; +} + +bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap) +{ + return mmap->mmap_context.select.len != 0; +} + +/** + * \note We could use a callback to define bounds, for now just use matrix location. + */ +bool WM_manipulatormap_minmax( + const wmManipulatorMap *mmap, bool UNUSED(use_hidden), bool use_select, + float r_min[3], float r_max[3]) +{ + if (use_select) { + int i; + for (i = 0; i < mmap->mmap_context.select.len; i++) { + minmax_v3v3_v3(r_min, r_max, mmap->mmap_context.select.items[i]->matrix_basis[3]); + } + return i != 0; + } + else { + bool ok = false; + BLI_assert(!"TODO"); + return ok; + } +} + +/** + * Creates and returns idname hash table for (visible) manipulators in \a mmap + * + * \param poll Polling function for excluding manipulators. + * \param data Custom data passed to \a poll + * + * TODO(campbell): this uses unreliable order, + * best we use an iterator function instead of a hash. + */ +static GHash *WM_manipulatormap_manipulator_hash_new( + const bContext *C, wmManipulatorMap *mmap, + bool (*poll)(const wmManipulator *, void *), + void *data, const bool include_hidden) +{ + GHash *hash = BLI_ghash_ptr_new(__func__); + + /* collect manipulators */ + for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + if (WM_manipulator_group_type_poll(C, mgroup->type)) { + for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) && + (!poll || poll(mpr, data))) + { + BLI_ghash_insert(hash, mpr, mpr); + } + } + } + } + + return hash; +} + +void WM_manipulatormap_tag_refresh(wmManipulatorMap *mmap) +{ + if (mmap) { + /* We might want only to refresh some, for tag all steps. */ + for (int i = 0; i < WM_MANIPULATORMAP_DRAWSTEP_MAX; i++) { + mmap->update_flag[i] |= ( + MANIPULATORMAP_IS_PREPARE_DRAW | + MANIPULATORMAP_IS_REFRESH_CALLBACK); + } + } +} + +static bool manipulator_prepare_drawing( + wmManipulatorMap *mmap, wmManipulator *mpr, + const bContext *C, ListBase *draw_manipulators, + const eWM_ManipulatorMapDrawStep drawstep) +{ + int do_draw = wm_manipulator_is_visible(mpr); + if (do_draw == 0) { + /* skip */ + } + else { + /* Ensure we get RNA updates */ + if (do_draw & WM_MANIPULATOR_IS_VISIBLE_UPDATE) { + /* hover manipulators need updating, even if we don't draw them */ + wm_manipulator_update(mpr, C, (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_PREPARE_DRAW) != 0); + } + if (do_draw & WM_MANIPULATOR_IS_VISIBLE_DRAW) { + BLI_addhead(draw_manipulators, BLI_genericNodeN(mpr)); + } + return true; + } + + return false; +} + +/** + * Update manipulators of \a mmap to prepare for drawing. Adds all manipulators that + * should be drawn to list \a draw_manipulators, note that added items need freeing. + */ +static void manipulatormap_prepare_drawing( + wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators, + const eWM_ManipulatorMapDrawStep drawstep) +{ + if (!mmap || BLI_listbase_is_empty(&mmap->groups)) + return; + wmManipulator *mpr_modal = mmap->mmap_context.modal; + + /* only active manipulator needs updating */ + if (mpr_modal) { + if ((mpr_modal->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL) == 0) { + if (wm_manipulatorgroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) { + if (manipulator_prepare_drawing(mmap, mpr_modal, C, draw_manipulators, drawstep)) { + mmap->update_flag[drawstep] &= ~MANIPULATORMAP_IS_PREPARE_DRAW; + } + } + /* don't draw any other manipulators */ + return; + } + } + + for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */ + if (!wm_manipulatorgroup_is_visible_in_drawstep(mgroup, drawstep) || + !WM_manipulator_group_type_poll(C, mgroup->type)) + { + continue; + } + + /* needs to be initialized on first draw */ + /* XXX weak: Manipulator-group may skip refreshing if it's invisible (map gets untagged nevertheless) */ + if (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_REFRESH_CALLBACK) { + /* force refresh again. */ + mgroup->init_flag &= ~WM_MANIPULATORGROUP_INIT_REFRESH; + } + /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */ + wm_manipulatorgroup_ensure_initialized(mgroup, C); + + /* prepare drawing */ + if (mgroup->type->draw_prepare) { + mgroup->type->draw_prepare(C, mgroup); + } + + for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + manipulator_prepare_drawing(mmap, mpr, C, draw_manipulators, drawstep); + } + } + + mmap->update_flag[drawstep] &= + ~(MANIPULATORMAP_IS_REFRESH_CALLBACK | + MANIPULATORMAP_IS_PREPARE_DRAW); +} + +/** + * Draw all visible manipulators in \a mmap. + * Uses global draw_manipulators listbase. + */ +static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators) +{ + /* Can be empty if we're dynamically added and removed. */ + if ((mmap == NULL) || BLI_listbase_is_empty(&mmap->groups)) { + return; + } + + /* TODO this will need it own shader probably? don't think it can be handled from that point though. */ +/* const bool use_lighting = (U.manipulator_flag & V3D_MANIPULATOR_SHADED) != 0; */ + + bool is_depth_prev = false; + + /* draw_manipulators contains all visible manipulators - draw them */ + for (LinkData *link = draw_manipulators->first, *link_next; link; link = link_next) { + wmManipulator *mpr = link->data; + link_next = link->next; + + bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0; + + /* Weak! since we don't 100% support depth yet (select ignores depth) always show highlighted */ + if (is_depth && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)) { + is_depth = false; + } + + if (is_depth == is_depth_prev) { + /* pass */ + } + else { + if (is_depth) { + glEnable(GL_DEPTH_TEST); + } + else { + glDisable(GL_DEPTH_TEST); + } + is_depth_prev = is_depth; + } + + /* XXX force AntiAlias Manipulators. */ + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POLYGON_SMOOTH); + + mpr->type->draw(C, mpr); + + glDisable(GL_LINE_SMOOTH); + glDisable(GL_POLYGON_SMOOTH); + + /* free/remove manipulator link after drawing */ + BLI_freelinkN(draw_manipulators, link); + } + + if (is_depth_prev) { + glDisable(GL_DEPTH_TEST); + } +} + +void WM_manipulatormap_draw( + wmManipulatorMap *mmap, const bContext *C, + const eWM_ManipulatorMapDrawStep drawstep) +{ + if (!WM_manipulator_context_check_drawstep(C, drawstep)) { + return; + } + + ListBase draw_manipulators = {NULL}; + + manipulatormap_prepare_drawing(mmap, C, &draw_manipulators, drawstep); + manipulators_draw_list(mmap, C, &draw_manipulators); + BLI_assert(BLI_listbase_is_empty(&draw_manipulators)); +} + +static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible_manipulators) +{ + int select_id = 0; + wmManipulator *mpr; + + /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */ + bool is_depth_prev = false; + bool is_depth_skip_prev = false; + + for (LinkData *link = visible_manipulators->first; link; link = link->next) { + mpr = link->data; + + bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0; + if (is_depth == is_depth_prev) { + /* pass */ + } + else { + if (is_depth) { + glEnable(GL_DEPTH_TEST); + } + else { + glDisable(GL_DEPTH_TEST); + } + is_depth_prev = is_depth; + } + bool is_depth_skip = (mpr->flag & WM_MANIPULATOR_SELECT_BACKGROUND) != 0; + if (is_depth_skip == is_depth_skip_prev) { + /* pass */ + } + else { + glDepthMask(!is_depth_skip); + is_depth_skip_prev = is_depth_skip; + } + + /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected manipulator part id */ + + mpr->type->draw_select(C, mpr, select_id << 8); + + + select_id++; + } + + if (is_depth_prev) { + glDisable(GL_DEPTH_TEST); + } + if (is_depth_skip_prev) { + glDepthMask(true); + } +} + +static int manipulator_find_intersected_3d_intern( + ListBase *visible_manipulators, const bContext *C, const int co[2], + const int hotspot) +{ + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + View3D *v3d = sa->spacedata.first; + rcti rect; + /* Almost certainly overkill, but allow for many custom manipulators. */ + GLuint buffer[MAXPICKBUF]; + short hits; + const bool do_passes = GPU_select_query_check_active(); + + BLI_rcti_init_pt_radius(&rect, co, hotspot); + + ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, &rect); + + if (do_passes) + GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); + else + GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_ALL, 0); + /* do the drawing */ + manipulator_draw_select_3D_loop(C, visible_manipulators); + + hits = GPU_select_end(); + + if (do_passes && (hits > 0)) { + GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); + manipulator_draw_select_3D_loop(C, visible_manipulators); + GPU_select_end(); + } + + ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, NULL); + + const GLuint *hit_near = GPU_select_buffer_near(buffer, hits); + + return hit_near ? hit_near[3] : -1; +} + +/** + * Try to find a 3D manipulator at screen-space coordinate \a co. Uses OpenGL picking. + */ +static wmManipulator *manipulator_find_intersected_3d( + bContext *C, const int co[2], ListBase *visible_manipulators, + int *r_part) +{ + wmManipulator *result = NULL; + int hit = -1; + + int hotspot_radii[] = { + 3 * U.pixelsize, + /* This runs on mouse move, careful doing too many tests! */ + 10 * U.pixelsize, + }; + + *r_part = 0; + + /* set up view matrices */ + view3d_operator_needs_opengl(C); + + hit = -1; + + for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) { + hit = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, hotspot_radii[i]); + if (hit != -1) { + break; + } + } + + if (hit != -1) { + LinkData *link = BLI_findlink(visible_manipulators, hit >> 8); + if (link != NULL) { + *r_part = hit & 255; + result = link->data; + } + else { + /* All manipulators should use selection ID they're given as part of the callback, + * if they don't it will attempt tp lookup non-existing index. */ + BLI_assert(0); + } + } + + return result; +} + +/** + * Try to find a manipulator under the mouse position. 2D intersections have priority over + * 3D ones (could check for smallest screen-space distance but not needed right now). + */ +wmManipulator *wm_manipulatormap_highlight_find( + wmManipulatorMap *mmap, bContext *C, const wmEvent *event, + int *r_part) +{ + wmManipulator *mpr = NULL; + ListBase visible_3d_manipulators = {NULL}; + bool do_step[WM_MANIPULATORMAP_DRAWSTEP_MAX]; + + for (int i = 0; i < ARRAY_SIZE(do_step); i++) { + do_step[i] = WM_manipulator_context_check_drawstep(C, i); + } + + for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + + /* If it were important we could initialize here, + * but this only happens when events are handled before drawing, + * just skip to keep code-path for initializing manipulators simple. */ + if ((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0) { + continue; + } + + if (WM_manipulator_group_type_poll(C, mgroup->type)) { + eWM_ManipulatorMapDrawStep step; + if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + step = WM_MANIPULATORMAP_DRAWSTEP_3D; + } + else { + step = WM_MANIPULATORMAP_DRAWSTEP_2D; + } + + if (do_step[step]) { + if ((mmap->update_flag[step] & MANIPULATORMAP_IS_REFRESH_CALLBACK) && + (mgroup->type->refresh != NULL)) + { + mgroup->type->refresh(C, mgroup); + /* cleared below */ + } + if (step == WM_MANIPULATORMAP_DRAWSTEP_3D) { + wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators); + } + else if (step == WM_MANIPULATORMAP_DRAWSTEP_2D) { + if ((mpr = wm_manipulatorgroup_find_intersected_manipulator(mgroup, C, event, r_part))) { + break; + } + } + } + } + } + + if (!BLI_listbase_is_empty(&visible_3d_manipulators)) { + /* 2D manipulators get priority. */ + if (mpr == NULL) { + mpr = manipulator_find_intersected_3d(C, event->mval, &visible_3d_manipulators, r_part); + } + BLI_freelistN(&visible_3d_manipulators); + } + + mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_3D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK; + mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_2D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK; + + return mpr; +} + +void WM_manipulatormap_add_handlers(ARegion *ar, wmManipulatorMap *mmap) +{ + wmEventHandler *handler; + + for (handler = ar->handlers.first; handler; handler = handler->next) { + if (handler->manipulator_map == mmap) { + return; + } + } + + handler = MEM_callocN(sizeof(wmEventHandler), "manipulator handler"); + + BLI_assert(mmap == ar->manipulator_map); + handler->manipulator_map = mmap; + BLI_addtail(&ar->handlers, handler); +} + +void wm_manipulatormaps_handled_modal_update( + bContext *C, wmEvent *event, wmEventHandler *handler) +{ + const bool modal_running = (handler->op != NULL); + + /* happens on render or when joining areas */ + if (!handler->op_region || !handler->op_region->manipulator_map) { + return; + } + + wmManipulatorMap *mmap = handler->op_region->manipulator_map; + wmManipulator *mpr = wm_manipulatormap_modal_get(mmap); + ScrArea *area = CTX_wm_area(C); + ARegion *region = CTX_wm_region(C); + + wm_manipulatormap_handler_context(C, handler); + + /* regular update for running operator */ + if (modal_running) { + wmManipulatorOpElem *mpop = mpr ? WM_manipulator_operator_get(mpr, mpr->highlight_part) : NULL; + if (mpr && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) { + wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; + if (modal_fn != NULL) { + int retval = modal_fn(C, mpr, event, 0); + /* The manipulator is tried to the operator, we can't choose when to exit. */ + BLI_assert(retval & OPERATOR_RUNNING_MODAL); + UNUSED_VARS_NDEBUG(retval); + } + } + } + /* operator not running anymore */ + else { + wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + if (mpr) { + /* This isn't defined if it ends because of success of cancel, we may want to change. */ + bool cancel = true; + if (mpr->type->exit) { + mpr->type->exit(C, mpr, cancel); + } + wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false); + } + } + + /* restore the area */ + CTX_wm_area_set(C, area); + CTX_wm_region_set(C, region); +} + +/** + * Deselect all selected manipulators in \a mmap. + * \return if selection has changed. + */ +bool wm_manipulatormap_deselect_all(wmManipulatorMap *mmap) +{ + wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + + if (msel->items == NULL || msel->len == 0) { + return false; + } + + for (int i = 0; i < msel->len; i++) { + wm_manipulator_select_set_ex(mmap, msel->items[i], false, false, true); + } + + wm_manipulatormap_select_array_clear(mmap); + + /* always return true, we already checked + * if there's anything to deselect */ + return true; +} + +BLI_INLINE bool manipulator_selectable_poll(const wmManipulator *mpr, void *UNUSED(data)) +{ + return (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT); +} + +/** + * Select all selectable manipulators in \a mmap. + * \return if selection has changed. + */ +static bool wm_manipulatormap_select_all_intern( + bContext *C, wmManipulatorMap *mmap) +{ + wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + /* GHash is used here to avoid having to loop over all manipulators twice (once to + * get tot_sel for allocating, once for actually selecting). Instead we collect + * selectable manipulators in hash table and use this to get tot_sel and do selection */ + + GHash *hash = WM_manipulatormap_manipulator_hash_new(C, mmap, manipulator_selectable_poll, NULL, true); + GHashIterator gh_iter; + int i; + bool changed = false; + + wm_manipulatormap_select_array_ensure_len_alloc(mmap, BLI_ghash_len(hash)); + + GHASH_ITER_INDEX (gh_iter, hash, i) { + wmManipulator *mpr_iter = BLI_ghashIterator_getValue(&gh_iter); + WM_manipulator_select_set(mmap, mpr_iter, true); + } + /* highlight first manipulator */ + wm_manipulatormap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part); + + BLI_assert(BLI_ghash_len(hash) == msel->len); + + BLI_ghash_free(hash, NULL, NULL); + return changed; +} + +/** + * Select/Deselect all selectable manipulators in \a mmap. + * \return if selection has changed. + * + * TODO select all by type + */ +bool WM_manipulatormap_select_all(bContext *C, wmManipulatorMap *mmap, const int action) +{ + bool changed = false; + + switch (action) { + case SEL_SELECT: + changed = wm_manipulatormap_select_all_intern(C, mmap); + break; + case SEL_DESELECT: + changed = wm_manipulatormap_deselect_all(mmap); + break; + default: + BLI_assert(0); + break; + } + + if (changed) + WM_event_add_mousemove(C); + + return changed; +} + +/** + * Prepare context for manipulator handling (but only if area/region is + * part of screen). Version of #wm_handler_op_context for manipulators. + */ +void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler) +{ + bScreen *screen = CTX_wm_screen(C); + + if (screen) { + if (handler->op_area == NULL) { + /* do nothing in this context */ + } + else { + ScrArea *sa; + + for (sa = screen->areabase.first; sa; sa = sa->next) + if (sa == handler->op_area) + break; + if (sa == NULL) { + /* when changing screen layouts with running modal handlers (like render display), this + * is not an error to print */ + if (handler->manipulator_map == NULL) + printf("internal error: modal manipulator-map handler has invalid area\n"); + } + else { + ARegion *ar; + CTX_wm_area_set(C, sa); + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar == handler->op_region) + break; + /* XXX no warning print here, after full-area and back regions are remade */ + if (ar) + CTX_wm_region_set(C, ar); + } + } + } +} + +bool WM_manipulatormap_cursor_set(const wmManipulatorMap *mmap, wmWindow *win) +{ + wmManipulator *mpr = mmap->mmap_context.highlight; + if (mpr && mpr->type->cursor_get) { + WM_cursor_set(win, mpr->type->cursor_get(mpr)); + return true; + } + + return false; +} + +bool wm_manipulatormap_highlight_set( + wmManipulatorMap *mmap, const bContext *C, wmManipulator *mpr, int part) +{ + if ((mpr != mmap->mmap_context.highlight) || + (mpr && part != mpr->highlight_part)) + { + if (mmap->mmap_context.highlight) { + mmap->mmap_context.highlight->state &= ~WM_MANIPULATOR_STATE_HIGHLIGHT; + mmap->mmap_context.highlight->highlight_part = -1; + } + + mmap->mmap_context.highlight = mpr; + + if (mpr) { + mpr->state |= WM_MANIPULATOR_STATE_HIGHLIGHT; + mpr->highlight_part = part; + mmap->mmap_context.last_cursor = -1; + + if (C && mpr->type->cursor_get) { + wmWindow *win = CTX_wm_window(C); + mmap->mmap_context.last_cursor = win->cursor; + WM_cursor_set(win, mpr->type->cursor_get(mpr)); + } + } + else { + if (C && mmap->mmap_context.last_cursor != -1) { + wmWindow *win = CTX_wm_window(C); + WM_cursor_set(win, mmap->mmap_context.last_cursor); + } + } + + /* tag the region for redraw */ + if (C) { + ARegion *ar = CTX_wm_region(C); + ED_region_tag_redraw(ar); + } + + return true; + } + + return false; +} + +wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap) +{ + return mmap->mmap_context.highlight; +} + +/** + * Caller should call exit when (enable == False). + */ +void wm_manipulatormap_modal_set( + wmManipulatorMap *mmap, bContext *C, wmManipulator *mpr, const wmEvent *event, bool enable) +{ + if (enable) { + BLI_assert(mmap->mmap_context.modal == NULL); + wmWindow *win = CTX_wm_window(C); + + WM_tooltip_clear(C, win); + + if (mpr->type->invoke && + (mpr->type->modal || mpr->custom_modal)) + { + const int retval = mpr->type->invoke(C, mpr, event); + if ((retval & OPERATOR_RUNNING_MODAL) == 0) { + return; + } + } + + mpr->state |= WM_MANIPULATOR_STATE_MODAL; + mmap->mmap_context.modal = mpr; + + if ((mpr->flag & WM_MANIPULATOR_GRAB_CURSOR) && + (event->is_motion_absolute == false)) + { + WM_cursor_grab_enable(win, true, true, NULL); + copy_v2_v2_int(mmap->mmap_context.event_xy, &event->x); + mmap->mmap_context.event_grabcursor = win->grabcursor; + } + else { + mmap->mmap_context.event_xy[0] = INT_MAX; + } + + struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + if (mpop && mpop->type) { + const int retval = WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); + if ((retval & OPERATOR_RUNNING_MODAL) == 0) { + wm_manipulatormap_modal_set(mmap, C, mpr, event, false); + } + + /* we failed to hook the manipulator to the operator handler or operator was cancelled, return */ + if (!mmap->mmap_context.modal) { + mpr->state &= ~WM_MANIPULATOR_STATE_MODAL; + MEM_SAFE_FREE(mpr->interaction_data); + } + return; + } + } + else { + BLI_assert(ELEM(mmap->mmap_context.modal, NULL, mpr)); + + /* deactivate, manipulator but first take care of some stuff */ + if (mpr) { + mpr->state &= ~WM_MANIPULATOR_STATE_MODAL; + MEM_SAFE_FREE(mpr->interaction_data); + } + mmap->mmap_context.modal = NULL; + + if (C) { + wmWindow *win = CTX_wm_window(C); + if (mmap->mmap_context.event_xy[0] != INT_MAX) { + /* Check if some other part of Blender (typically operators) + * have adjusted the grab mode since it was set. + * If so: warp, so we have a predictable outcome. */ + if (mmap->mmap_context.event_grabcursor == win->grabcursor) { + WM_cursor_grab_disable(win, mmap->mmap_context.event_xy); + } + else { + WM_cursor_warp(win, UNPACK2(mmap->mmap_context.event_xy)); + } + } + ED_region_tag_redraw(CTX_wm_region(C)); + WM_event_add_mousemove(C); + } + + mmap->mmap_context.event_xy[0] = INT_MAX; + } +} + +wmManipulator *wm_manipulatormap_modal_get(wmManipulatorMap *mmap) +{ + return mmap->mmap_context.modal; +} + +wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len) +{ + *r_selected_len = mmap->mmap_context.select.len; + return mmap->mmap_context.select.items; +} + +ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap) +{ + return &mmap->groups; +} + +void WM_manipulatormap_message_subscribe( + bContext *C, wmManipulatorMap *mmap, ARegion *ar, struct wmMsgBus *mbus) +{ + for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + if (!WM_manipulator_group_type_poll(C, mgroup->type)) { + continue; + } + for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + if (mpr->flag & WM_MANIPULATOR_HIDDEN) { + continue; + } + WM_manipulator_target_property_subscribe_all(mpr, mbus, ar); + } + if (mgroup->type->message_subscribe != NULL) { + mgroup->type->message_subscribe(C, mgroup, mbus); + } + } +} + +/** \} */ /* wmManipulatorMap */ + + +/* -------------------------------------------------------------------- */ +/** \name Tooltip Handling + * + * \{ */ + +struct ARegion *WM_manipulatormap_tooltip_init( + struct bContext *C, struct ARegion *ar, bool *r_exit_on_event) +{ + wmManipulatorMap *mmap = ar->manipulator_map; + *r_exit_on_event = true; + if (mmap) { + wmManipulator *mpr = mmap->mmap_context.highlight; + if (mpr) { + return UI_tooltip_create_from_manipulator(C, mpr); + } + } + return NULL; +} + +/** \} */ /* wmManipulatorMapType */ + +/* -------------------------------------------------------------------- */ +/** \name wmManipulatorMapType + * + * \{ */ + +wmManipulatorMapType *WM_manipulatormaptype_find( + const struct wmManipulatorMapType_Params *mmap_params) +{ + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { + if (mmap_type->spaceid == mmap_params->spaceid && + mmap_type->regionid == mmap_params->regionid) + { + return mmap_type; + } + } + + return NULL; +} + +wmManipulatorMapType *WM_manipulatormaptype_ensure( + const struct wmManipulatorMapType_Params *mmap_params) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_find(mmap_params); + + if (mmap_type) { + return mmap_type; + } + + mmap_type = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list"); + mmap_type->spaceid = mmap_params->spaceid; + mmap_type->regionid = mmap_params->regionid; + BLI_addhead(&manipulatormaptypes, mmap_type); + + return mmap_type; +} + +void wm_manipulatormaptypes_free(void) +{ + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first, *mmap_type_next; + mmap_type; + mmap_type = mmap_type_next) + { + mmap_type_next = mmap_type->next; + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next; + wgt_ref; + wgt_ref = wgt_next) + { + wgt_next = wgt_ref->next; + WM_manipulatormaptype_group_free(wgt_ref); + } + MEM_freeN(mmap_type); + } +} + +/** + * Initialize keymaps for all existing manipulator-groups + */ +void wm_manipulators_keymap(wmKeyConfig *keyconf) +{ + /* we add this item-less keymap once and use it to group manipulator-group keymaps into it */ + WM_keymap_find(keyconf, "Manipulators", 0, 0); + + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { + wm_manipulatorgrouptype_setup_keymap(wgt_ref->type, keyconf); + } + } +} + +/** \} */ /* wmManipulatorMapType */ + +/* -------------------------------------------------------------------- */ +/** \name Updates for Dynamic Type Registraion + * + * \{ */ + + +void WM_manipulatorconfig_update_tag_init( + wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +{ + /* tag for update on next use */ + mmap_type->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT); + wgt->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT); + + wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; +} + +void WM_manipulatorconfig_update_tag_remove( + wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +{ + /* tag for update on next use */ + mmap_type->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; + wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; + + wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE; +} + +/** + * Run incase new types have been added (runs often, early exit where possible). + * Follows #WM_keyconfig_update concentions. + */ +void WM_manipulatorconfig_update(struct Main *bmain) +{ + if (G.background) + return; + + if (wm_mmap_type_update_flag == 0) + return; + + if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) { + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; + mmap_type; + mmap_type = mmap_type->next) + { + if (mmap_type->type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) { + mmap_type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_ref_next; + wgt_ref; + wgt_ref = wgt_ref_next) + { + wgt_ref_next = wgt_ref->next; + if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_REMOVE) { + wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; + WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type); + } + } + } + } + + wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE; + } + + if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT) { + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; + mmap_type; + mmap_type = mmap_type->next) + { + const uchar type_update_all = WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + if (mmap_type->type_update_flag & type_update_all) { + mmap_type->type_update_flag &= ~type_update_all; + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + wgt_ref; + wgt_ref = wgt_ref->next) + { + if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) { + WM_manipulatormaptype_group_init_runtime_keymap(bmain, wgt_ref->type); + wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + } + + if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) { + WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type); + wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT; + } + } + } + } + + wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; + } +} + +/** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c new file mode 100644 index 00000000000..78d12e4e4ba --- /dev/null +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c @@ -0,0 +1,364 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c + * \ingroup wm + */ + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_string.h" +#include "BLI_string_utils.h" + +#include "BKE_context.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" +#include "WM_message.h" + +#include "wm.h" + +#include "ED_screen.h" +#include "ED_view3d.h" + +/* own includes */ +#include "wm_gizmo_wmapi.h" +#include "wm_gizmo_intern.h" + +/* -------------------------------------------------------------------- */ + +/** \name Property Definition + * \{ */ + +BLI_INLINE wmManipulatorProperty *wm_manipulator_target_property_array(wmManipulator *mpr) +{ + return (wmManipulatorProperty *)(POINTER_OFFSET(mpr, mpr->type->struct_size)); +} + +wmManipulatorProperty *WM_manipulator_target_property_array(wmManipulator *mpr) +{ + return wm_manipulator_target_property_array(mpr); +} + +wmManipulatorProperty *WM_manipulator_target_property_at_index(wmManipulator *mpr, int index) +{ + BLI_assert(index < mpr->type->target_property_defs_len); + BLI_assert(index != -1); + wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr); + return &mpr_prop_array[index]; +} + +wmManipulatorProperty *WM_manipulator_target_property_find(wmManipulator *mpr, const char *idname) +{ + int index = BLI_findstringindex( + &mpr->type->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname)); + if (index != -1) { + return WM_manipulator_target_property_at_index(mpr, index); + } + else { + return NULL; + } +} + +void WM_manipulator_target_property_def_rna_ptr( + wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type, + PointerRNA *ptr, PropertyRNA *prop, int index) +{ + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + + /* if manipulator evokes an operator we cannot use it for property manipulation */ + BLI_assert(mpr->op_data == NULL); + + mpr_prop->type = mpr_prop_type; + + mpr_prop->ptr = *ptr; + mpr_prop->prop = prop; + mpr_prop->index = index; + + if (mpr->type->property_update) { + mpr->type->property_update(mpr, mpr_prop); + } +} + +void WM_manipulator_target_property_def_rna( + wmManipulator *mpr, const char *idname, + PointerRNA *ptr, const char *propname, int index) +{ + const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); + PropertyRNA *prop = RNA_struct_find_property(ptr, propname); + WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); +} + +void WM_manipulator_target_property_def_func_ptr( + wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type, + const wmManipulatorPropertyFnParams *params) +{ + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + + /* if manipulator evokes an operator we cannot use it for property manipulation */ + BLI_assert(mpr->op_data == NULL); + + mpr_prop->type = mpr_prop_type; + + mpr_prop->custom_func.value_get_fn = params->value_get_fn; + mpr_prop->custom_func.value_set_fn = params->value_set_fn; + mpr_prop->custom_func.range_get_fn = params->range_get_fn; + mpr_prop->custom_func.free_fn = params->free_fn; + mpr_prop->custom_func.user_data = params->user_data; + + if (mpr->type->property_update) { + mpr->type->property_update(mpr, mpr_prop); + } +} + +void WM_manipulator_target_property_def_func( + wmManipulator *mpr, const char *idname, + const wmManipulatorPropertyFnParams *params) +{ + const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); + WM_manipulator_target_property_def_func_ptr(mpr, mpr_prop_type, params); +} + +void WM_manipulator_target_property_clear_rna_ptr( + wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type) +{ + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + + /* if manipulator evokes an operator we cannot use it for property manipulation */ + BLI_assert(mpr->op_data == NULL); + + mpr_prop->type = NULL; + + mpr_prop->ptr = PointerRNA_NULL; + mpr_prop->prop = NULL; + mpr_prop->index = -1; +} + +void WM_manipulator_target_property_clear_rna( + wmManipulator *mpr, const char *idname) +{ + const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); + WM_manipulator_target_property_clear_rna_ptr(mpr, mpr_prop_type); +} + + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Property Access + * \{ */ + +bool WM_manipulator_target_property_is_valid_any(wmManipulator *mpr) +{ + wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr); + for (int i = 0; i < mpr->type->target_property_defs_len; i++) { + wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + return true; + } + } + return false; +} + +bool WM_manipulator_target_property_is_valid(const wmManipulatorProperty *mpr_prop) +{ + return ((mpr_prop->prop != NULL) || + (mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn)); +} + +float WM_manipulator_target_property_value_get( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +{ + if (mpr_prop->custom_func.value_get_fn) { + float value = 0.0f; + BLI_assert(mpr_prop->type->array_length == 1); + mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, &value); + return value; + } + + if (mpr_prop->index == -1) { + return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop); + } + else { + return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index); + } +} + +void WM_manipulator_target_property_value_set( + bContext *C, const wmManipulator *mpr, + wmManipulatorProperty *mpr_prop, const float value) +{ + if (mpr_prop->custom_func.value_set_fn) { + BLI_assert(mpr_prop->type->array_length == 1); + mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, &value); + return; + } + + /* reset property */ + if (mpr_prop->index == -1) { + RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, value); + } + else { + RNA_property_float_set_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index, value); + } + RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); +} + +void WM_manipulator_target_property_value_get_array( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + float *value) +{ + if (mpr_prop->custom_func.value_get_fn) { + mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, value); + return; + } + RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value); +} + +void WM_manipulator_target_property_value_set_array( + bContext *C, const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + const float *value) +{ + if (mpr_prop->custom_func.value_set_fn) { + mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, value); + return; + } + RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, value); + + RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); +} + +bool WM_manipulator_target_property_range_get( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + float range[2]) +{ + if (mpr_prop->custom_func.value_get_fn) { + if (mpr_prop->custom_func.range_get_fn) { + mpr_prop->custom_func.range_get_fn(mpr, mpr_prop, range); + return true; + } + else { + return false; + + } + } + + float step, precision; + RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &range[0], &range[1], &step, &precision); + return true; +} + +int WM_manipulator_target_property_array_length( + const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop) +{ + if (mpr_prop->custom_func.value_get_fn) { + return mpr_prop->type->array_length; + } + return RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop); +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Property Define + * \{ */ + +const wmManipulatorPropertyType *WM_manipulatortype_target_property_find( + const wmManipulatorType *wt, const char *idname) +{ + return BLI_findstring(&wt->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname)); +} + +void WM_manipulatortype_target_property_def( + wmManipulatorType *wt, const char *idname, int data_type, int array_length) +{ + wmManipulatorPropertyType *mpt; + + BLI_assert(WM_manipulatortype_target_property_find(wt, idname) == NULL); + + const uint idname_size = strlen(idname) + 1; + mpt = MEM_callocN(sizeof(wmManipulatorPropertyType) + idname_size, __func__); + memcpy(mpt->idname, idname, idname_size); + mpt->data_type = data_type; + mpt->array_length = array_length; + mpt->index_in_type = wt->target_property_defs_len; + wt->target_property_defs_len += 1; + BLI_addtail(&wt->target_property_defs, mpt); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ + +/** \name Property Utilities + * \{ */ + +void WM_manipulator_do_msg_notify_tag_refresh( + bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) +{ + ARegion *ar = msg_val->owner; + wmManipulatorMap *mmap = msg_val->user_data; + + ED_region_tag_redraw(ar); + WM_manipulatormap_tag_refresh(mmap); +} + +/** + * Runs on the "prepare draw" pass, + * drawing the region clears. + */ +void WM_manipulator_target_property_subscribe_all( + wmManipulator *mpr, struct wmMsgBus *mbus, ARegion *ar) +{ + if (mpr->type->target_property_defs_len) { + wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + for (int i = 0; i < mpr->type->target_property_defs_len; i++) { + wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_manipulator_target_property_is_valid(mpr_prop)) { + if (mpr_prop->prop) { + WM_msg_subscribe_rna( + mbus, &mpr_prop->ptr, mpr_prop->prop, + &(const wmMsgSubscribeValue){ + .owner = ar, + .user_data = ar, + .notify = ED_region_do_msg_notify_tag_redraw, + }, __func__); + WM_msg_subscribe_rna( + mbus, &mpr_prop->ptr, mpr_prop->prop, + &(const wmMsgSubscribeValue){ + .owner = ar, + .user_data = mpr->parent_mgroup->parent_mmap, + .notify = WM_manipulator_do_msg_notify_tag_refresh, + }, __func__); + } + } + } + } +} + +/** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c new file mode 100644 index 00000000000..4f31afb5b56 --- /dev/null +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -0,0 +1,212 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/intern/wm_gizmo_type.c + * \ingroup wm + */ + +#include "BLI_utildefines.h" +#include "BLI_ghash.h" +#include "BLI_listbase.h" +#include "BLI_string.h" +#include "BLI_string_utils.h" + +#include "BKE_context.h" +#include "BKE_main.h" + +#include "DNA_screen_types.h" +#include "DNA_space_types.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" + +/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +#include "wm.h" + +/* own includes */ +#include "wm_gizmo_wmapi.h" +#include "wm_gizmo_intern.h" + + +/** \name Manipulator Type Append + * + * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. + * \{ */ + +static GHash *global_manipulatortype_hash = NULL; + +const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) +{ + if (idname[0]) { + wmManipulatorType *wt; + + wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); + if (wt) { + return wt; + } + + if (!quiet) { + printf("search for unknown manipulator '%s'\n", idname); + } + } + else { + if (!quiet) { + printf("search for empty manipulator\n"); + } + } + + return NULL; +} + +/* caller must free */ +void WM_manipulatortype_iter(GHashIterator *ghi) +{ + BLI_ghashIterator_init(ghi, global_manipulatortype_hash); +} + +static wmManipulatorType *wm_manipulatortype_append__begin(void) +{ + wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype"); + wt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_ManipulatorProperties); +#if 0 + /* Set the default i18n context now, so that opfunc can redefine it if needed! */ + RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; +#endif + return wt; +} +static void wm_manipulatortype_append__end(wmManipulatorType *wt) +{ + BLI_assert(wt->struct_size >= sizeof(wmManipulator)); + + RNA_def_struct_identifier(&BLENDER_RNA, wt->srna, wt->idname); + + BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt); +} + +void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)) +{ + wmManipulatorType *wt = wm_manipulatortype_append__begin(); + wtfunc(wt); + wm_manipulatortype_append__end(wt); +} + +void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata) +{ + wmManipulatorType *mt = wm_manipulatortype_append__begin(); + wtfunc(mt, userdata); + wm_manipulatortype_append__end(mt); +} + +/** + * Free but don't remove from ghash. + */ +static void manipulatortype_free(wmManipulatorType *wt) +{ + if (wt->ext.srna) { /* python manipulator, allocs own string */ + MEM_freeN((void *)wt->idname); + } + + BLI_freelistN(&wt->target_property_defs); + MEM_freeN(wt); +} + +/** + * \param C: May be NULL. + */ +static void manipulatortype_unlink( + bContext *C, Main *bmain, wmManipulatorType *wt) +{ + /* Free instances. */ + for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { + for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ARegion *ar = lb->first; ar; ar = ar->next) { + wmManipulatorMap *mmap = ar->manipulator_map; + if (mmap) { + wmManipulatorGroup *mgroup; + for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) { + mpr_next = mpr->next; + BLI_assert(mgroup->parent_mmap == mmap); + if (mpr->type == wt) { + WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C); + ED_region_tag_redraw(ar); + } + } + } + } + } + } + } + } +} + +void WM_manipulatortype_remove_ptr(bContext *C, Main *bmain, wmManipulatorType *wt) +{ + BLI_assert(wt == WM_manipulatortype_find(wt->idname, false)); + + BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL); + + manipulatortype_unlink(C, bmain, wt); + + manipulatortype_free(wt); +} + +bool WM_manipulatortype_remove(bContext *C, Main *bmain, const char *idname) +{ + wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); + + if (wt == NULL) { + return false; + } + + WM_manipulatortype_remove_ptr(C, bmain, wt); + + return true; +} + +static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt) +{ + manipulatortype_free(mt); +} + +void wm_manipulatortype_free(void) +{ + BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb); + global_manipulatortype_hash = NULL; +} + +/* called on initialize WM_init() */ +void wm_manipulatortype_init(void) +{ + /* reserve size is set based on blender default setup */ + global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128); +} + +/** \} */ diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h new file mode 100644 index 00000000000..8d28febbd5d --- /dev/null +++ b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h @@ -0,0 +1,88 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/wm_gizmo_fn.h + * \ingroup wm + * + * Callback function definitions, needed for both Types & API headers. + */ + +#ifndef __WM_GIZMO_FN_H__ +#define __WM_GIZMO_FN_H__ + +#include "BLI_compiler_attrs.h" + +/* wmManipulatorGroup */ +typedef bool (*wmManipulatorGroupFnPoll)( + const struct bContext *, struct wmManipulatorGroupType *) + ATTR_WARN_UNUSED_RESULT; +typedef void (*wmManipulatorGroupFnInit)( + const struct bContext *, struct wmManipulatorGroup *); +typedef void (*wmManipulatorGroupFnRefresh)( + const struct bContext *, struct wmManipulatorGroup *); +typedef void (*wmManipulatorGroupFnDrawPrepare)( + const struct bContext *, struct wmManipulatorGroup *); +typedef struct wmKeyMap *(*wmManipulatorGroupFnSetupKeymap)( + const struct wmManipulatorGroupType *, struct wmKeyConfig *) + ATTR_WARN_UNUSED_RESULT; +typedef void (*wmManipulatorGroupFnMsgBusSubscribe)( + const struct bContext *, struct wmManipulatorGroup *, struct wmMsgBus *); + +/* wmManipulator */ +/* See: wmManipulatorType for docs on each type. */ + +typedef void (*wmManipulatorFnSetup)(struct wmManipulator *); +typedef void (*wmManipulatorFnDraw)(const struct bContext *, struct wmManipulator *); +typedef void (*wmManipulatorFnDrawSelect)(const struct bContext *, struct wmManipulator *, int); +typedef int (*wmManipulatorFnTestSelect)(struct bContext *, struct wmManipulator *, const struct wmEvent *); +typedef int (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, eWM_ManipulatorTweak); +typedef void (*wmManipulatorFnPropertyUpdate)(struct wmManipulator *, struct wmManipulatorProperty *); +typedef void (*wmManipulatorFnMatrixBasisGet)(const struct wmManipulator *, float[4][4]); +typedef int (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *); +typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *, const bool); +typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *); +typedef void (*wmManipulatorFnSelectRefresh)(struct wmManipulator *); +typedef void (*wmManipulatorFnFree)(struct wmManipulator *); + +/* wmManipulatorProperty ('value' type defined by 'wmManipulatorProperty.data_type') */ +typedef void (*wmManipulatorPropertyFnGet)( + const struct wmManipulator *, struct wmManipulatorProperty *, + /* typically 'float *' */ + void *value); +typedef void (*wmManipulatorPropertyFnSet)( + const struct wmManipulator *, struct wmManipulatorProperty *, + /* typically 'const float *' */ + const void *value); +typedef void (*wmManipulatorPropertyFnRangeGet)( + const struct wmManipulator *, struct wmManipulatorProperty *, + /* typically 'float[2]' */ + void *range); +typedef void (*wmManipulatorPropertyFnFree)( + const struct wmManipulator *, struct wmManipulatorProperty *); + +typedef struct wmManipulatorPropertyFnParams { + wmManipulatorPropertyFnGet value_get_fn; + wmManipulatorPropertyFnSet value_set_fn; + wmManipulatorPropertyFnRangeGet range_get_fn; + wmManipulatorPropertyFnFree free_fn; + void *user_data; +} wmManipulatorPropertyFnParams; + +#endif /* __WM_GIZMO_FN_H__ */ diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h new file mode 100644 index 00000000000..80418cbfeb3 --- /dev/null +++ b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h @@ -0,0 +1,97 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/gizmo/wm_gizmo_wmapi.h + * \ingroup wm + * + * \name Manipulators Window Manager API + * API for usage in window manager code only. It should contain all functionality + * needed to hook up the manipulator system with Blender's window manager. It's + * mostly the event system that needs to communicate with manipulator code. + * + * Only included in wm.h and lower level files. + */ + + +#ifndef __WM_GIZMO_WMAPI_H__ +#define __WM_GIZMO_WMAPI_H__ + +struct wmEventHandler; +struct wmManipulatorMap; +struct wmOperatorType; +struct wmOperator; + + +/* -------------------------------------------------------------------- */ +/* wmManipulator */ + +/* wm_manipulator_type.c, for init/exit */ +void wm_manipulatortype_free(void); +void wm_manipulatortype_init(void); + +/* wm_manipulatorgroup_type.c, for init/exit */ +void wm_manipulatorgrouptype_free(void); +void wm_manipulatorgrouptype_init(void); + +/* -------------------------------------------------------------------- */ +/* wmManipulatorGroup */ + +void MANIPULATORGROUP_OT_manipulator_select(struct wmOperatorType *ot); +void MANIPULATORGROUP_OT_manipulator_tweak(struct wmOperatorType *ot); + +bool wm_manipulatorgroup_is_any_selected(const struct wmManipulatorGroup *mgroup); + +/* -------------------------------------------------------------------- */ +/* wmManipulatorMap */ + +void wm_manipulatormap_remove(struct wmManipulatorMap *mmap); + +void wm_manipulators_keymap(struct wmKeyConfig *keyconf); + +void wm_manipulatormaps_handled_modal_update( + bContext *C, struct wmEvent *event, struct wmEventHandler *handler); +void wm_manipulatormap_handler_context(bContext *C, struct wmEventHandler *handler); + +struct wmManipulator *wm_manipulatormap_highlight_find( + struct wmManipulatorMap *mmap, bContext *C, const struct wmEvent *event, + int *r_part); +bool wm_manipulatormap_highlight_set( + struct wmManipulatorMap *mmap, const bContext *C, + struct wmManipulator *mpr, int part); +struct wmManipulator *wm_manipulatormap_highlight_get(struct wmManipulatorMap *mmap); +void wm_manipulatormap_modal_set( + struct wmManipulatorMap *mmap, bContext *C, struct wmManipulator *mpr, + const struct wmEvent *event, bool enable); + +struct wmManipulator *wm_manipulatormap_modal_get(struct wmManipulatorMap *mmap); +struct wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len); +struct ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap); + +/* -------------------------------------------------------------------- */ +/* wmManipulatorMapType */ + +void wm_manipulatormaptypes_free(void); + +#endif /* __WM_GIZMO_WMAPI_H__ */ diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h deleted file mode 100644 index b88956ac28d..00000000000 --- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h +++ /dev/null @@ -1,343 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/WM_manipulator_api.h - * \ingroup wm - * - * \name Manipulator API - * \brief API for external use of wmManipulator types. - * - * Only included in WM_api.h - */ - - -#ifndef __WM_MANIPULATOR_API_H__ -#define __WM_MANIPULATOR_API_H__ - -struct ARegion; -struct GHashIterator; -struct IDProperty; -struct Main; -struct PropertyRNA; -struct wmKeyConfig; -struct wmManipulator; -struct wmManipulatorProperty; -struct wmManipulatorPropertyType; -struct wmManipulatorType; -struct wmManipulatorGroup; -struct wmManipulatorGroupType; -struct wmManipulatorMap; -struct wmManipulatorMapType; -struct wmManipulatorMapType_Params; -struct wmMsgSubscribeKey; -struct wmMsgSubscribeValue; - -#include "wm_manipulator_fn.h" - -/* -------------------------------------------------------------------- */ -/* wmManipulator */ - -struct wmManipulator *WM_manipulator_new_ptr( - const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup, - struct PointerRNA *properties); -struct wmManipulator *WM_manipulator_new( - const char *idname, struct wmManipulatorGroup *mgroup, - struct PointerRNA *properties); -void WM_manipulator_free(struct wmManipulator *mpr); -void WM_manipulator_unlink( - ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr, - struct bContext *C); - -void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name); - -bool WM_manipulator_select_unlink(struct wmManipulatorMap *mmap, struct wmManipulator *mpr); -bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select); -void WM_manipulator_highlight_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr); - -void WM_manipulator_modal_set_from_setup( - struct wmManipulatorMap *mmap, struct bContext *C, - struct wmManipulator *mpr, int part_index, const struct wmEvent *event); - -struct wmManipulatorOpElem *WM_manipulator_operator_get( - struct wmManipulator *mpr, int part_index); -struct PointerRNA *WM_manipulator_operator_set( - struct wmManipulator *mpr, int part_index, - struct wmOperatorType *ot, struct IDProperty *properties); - -/* callbacks */ -void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn); - -void WM_manipulator_set_matrix_location( - struct wmManipulator *mpr, const float origin[3]); -void WM_manipulator_set_matrix_rotation_from_z_axis( - struct wmManipulator *mpr, const float z_axis[3]); -void WM_manipulator_set_matrix_rotation_from_yz_axis( - struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]); - -void WM_manipulator_set_matrix_offset_location( - struct wmManipulator *mpr, const float origin[3]); -void WM_manipulator_set_matrix_offset_rotation_from_z_axis( - struct wmManipulator *mpr, const float z_axis[3]); -void WM_manipulator_set_matrix_offset_rotation_from_yz_axis( - struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]); - -void WM_manipulator_set_flag(struct wmManipulator *mpr, const int flag, const bool enable); -void WM_manipulator_set_scale(struct wmManipulator *mpr, float scale); -void WM_manipulator_set_line_width(struct wmManipulator *mpr, const float line_width); - -void WM_manipulator_get_color(const struct wmManipulator *mpr, float color[4]); -void WM_manipulator_set_color(struct wmManipulator *mpr, const float color[4]); -void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float color_hi[4]); -void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float color[4]); - -/** - * Leaving values NULL use values from #wmManipulator. - */ -struct WM_ManipulatorMatrixParams { - const float(*matrix_space)[4]; - const float(*matrix_basis)[4]; - const float(*matrix_offset)[4]; - const float *scale_final; -}; - -void WM_manipulator_calc_matrix_final_params( - const struct wmManipulator *mpr, const struct WM_ManipulatorMatrixParams *params, - float r_mat[4][4]); -void WM_manipulator_calc_matrix_final_no_offset( - const struct wmManipulator *mpr, float r_mat[4][4]); - -void WM_manipulator_calc_matrix_final( - const struct wmManipulator *mpr, float r_mat[4][4]); - -/* properties */ -void WM_manipulator_properties_create_ptr(struct PointerRNA *ptr, struct wmManipulatorType *wt); -void WM_manipulator_properties_create(struct PointerRNA *ptr, const char *opstring); -void WM_manipulator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring); -void WM_manipulator_properties_sanitize(struct PointerRNA *ptr, const bool no_context); -bool WM_manipulator_properties_default(struct PointerRNA *ptr, const bool do_update); -void WM_manipulator_properties_reset(struct wmManipulator *op); -void WM_manipulator_properties_clear(struct PointerRNA *ptr); -void WM_manipulator_properties_free(struct PointerRNA *ptr); - - -/* wm_manipulator_type.c */ -const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet); -void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)); -void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata); -bool WM_manipulatortype_remove(struct bContext *C, struct Main *bmain, const char *idname); -void WM_manipulatortype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmManipulatorType *wt); -void WM_manipulatortype_iter(struct GHashIterator *ghi); - -/* wm_manipulator_group_type.c */ -struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet); -struct wmManipulatorGroupType *WM_manipulatorgrouptype_append(void (*wtfunc)(struct wmManipulatorGroupType *)); -struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata); -bool WM_manipulatorgrouptype_free(const char *idname); -void WM_manipulatorgrouptype_free_ptr(struct wmManipulatorGroupType *wt); -void WM_manipulatorgrouptype_iter(struct GHashIterator *ghi); - -struct wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( - struct wmManipulatorMapType *mmap_type, - void (*wtfunc)(struct wmManipulatorGroupType *)); - -/* wm_manipulator_map.c */ - -/* Dynamic Updates (for RNA runtime registration) */ -void WM_manipulatorconfig_update_tag_init(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); -void WM_manipulatorconfig_update_tag_remove(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); -void WM_manipulatorconfig_update(struct Main *bmain); - - -/* wm_maniulator_target_props.c */ -struct wmManipulatorProperty *WM_manipulator_target_property_array(struct wmManipulator *mpr); -struct wmManipulatorProperty *WM_manipulator_target_property_at_index( - struct wmManipulator *mpr, int index); -struct wmManipulatorProperty *WM_manipulator_target_property_find( - struct wmManipulator *mpr, const char *idname); - -void WM_manipulator_target_property_def_rna_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, - struct PointerRNA *ptr, struct PropertyRNA *prop, int index); -void WM_manipulator_target_property_def_rna( - struct wmManipulator *mpr, const char *idname, - struct PointerRNA *ptr, const char *propname, int index); - -void WM_manipulator_target_property_def_func_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, - const struct wmManipulatorPropertyFnParams *params); -void WM_manipulator_target_property_def_func( - struct wmManipulator *mpr, const char *idname, - const struct wmManipulatorPropertyFnParams *params); - -void WM_manipulator_target_property_clear_rna_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type); -void WM_manipulator_target_property_clear_rna( - struct wmManipulator *mpr, const char *idname); - -bool WM_manipulator_target_property_is_valid_any(struct wmManipulator *mpr); -bool WM_manipulator_target_property_is_valid( - const struct wmManipulatorProperty *mpr_prop); -float WM_manipulator_target_property_value_get( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); -void WM_manipulator_target_property_value_set( - struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, - const float value); - -void WM_manipulator_target_property_value_get_array( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, - float *value); -void WM_manipulator_target_property_value_set_array( - struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, - const float *value); - -bool WM_manipulator_target_property_range_get( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, - float range[2]); - -int WM_manipulator_target_property_array_length( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); - -/* definitions */ -const struct wmManipulatorPropertyType *WM_manipulatortype_target_property_find( - const struct wmManipulatorType *wt, const char *idname); -void WM_manipulatortype_target_property_def( - struct wmManipulatorType *wt, const char *idname, int data_type, int array_length); - -/* utilities */ -void WM_manipulator_do_msg_notify_tag_refresh( - struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val); -void WM_manipulator_target_property_subscribe_all( - struct wmManipulator *mpr, struct wmMsgBus *mbus, struct ARegion *ar); - -/* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ - -/* Callbacks for 'wmManipulatorGroupType.setup_keymap' */ -struct wmKeyMap *WM_manipulatorgroup_keymap_common( - const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); -struct wmKeyMap *WM_manipulatorgroup_keymap_common_select( - const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); - - -/* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ - -struct wmManipulatorMap *WM_manipulatormap_new_from_type( - const struct wmManipulatorMapType_Params *mmap_params); -const struct ListBase *WM_manipulatormap_group_list(struct wmManipulatorMap *mmap); -struct wmManipulatorGroup *WM_manipulatormap_group_find( - struct wmManipulatorMap *mmap, - const char *idname); -struct wmManipulatorGroup *WM_manipulatormap_group_find_ptr( - struct wmManipulatorMap *mmap, - const struct wmManipulatorGroupType *wgt); -void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap); -void WM_manipulatormap_draw( - struct wmManipulatorMap *mmap, const struct bContext *C, const eWM_ManipulatorMapDrawStep drawstep); -void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap *mmap); -bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action); -bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win); -void WM_manipulatormap_message_subscribe( - struct bContext *C, struct wmManipulatorMap *mmap, struct ARegion *ar, struct wmMsgBus *mbus); -bool WM_manipulatormap_is_any_selected(const struct wmManipulatorMap *mmap); -bool WM_manipulatormap_minmax( - const struct wmManipulatorMap *mmap, bool use_hidden, bool use_select, - float r_min[3], float r_max[3]); - -struct ARegion *WM_manipulatormap_tooltip_init( - struct bContext *C, struct ARegion *ar, bool *r_exit_on_event); - -/* -------------------------------------------------------------------- */ -/* wmManipulatorMapType */ - -struct wmManipulatorMapType *WM_manipulatormaptype_find( - const struct wmManipulatorMapType_Params *mmap_params); -struct wmManipulatorMapType *WM_manipulatormaptype_ensure( - const struct wmManipulatorMapType_Params *mmap_params); - -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( - struct wmManipulatorMapType *mmap_type, - const char *idname); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( - struct wmManipulatorMapType *mmap_type, - const struct wmManipulatorGroupType *wgt); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( - struct wmManipulatorMapType *mmap_type, - const char *idname); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( - struct wmManipulatorMapType *mmap_type, - struct wmManipulatorGroupType *wgt); - -void WM_manipulatormaptype_group_init_runtime_keymap( - const struct Main *bmain, - struct wmManipulatorGroupType *wgt); -void WM_manipulatormaptype_group_init_runtime( - const struct Main *bmain, struct wmManipulatorMapType *mmap_type, - struct wmManipulatorGroupType *wgt); -void WM_manipulatormaptype_group_unlink( - struct bContext *C, struct Main *bmain, struct wmManipulatorMapType *mmap_type, - const struct wmManipulatorGroupType *wgt); - -void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt); - -/* -------------------------------------------------------------------- */ -/* ManipulatorGroup */ - -/* Add/Ensure/Remove (High level API) */ - -void WM_manipulator_group_type_add_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_add_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_add(const char *idname); - -void WM_manipulator_group_type_ensure_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_ensure_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_ensure(const char *idname); - -void WM_manipulator_group_type_remove_ptr_ex( - struct Main *bmain, struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_remove_ptr( - struct Main *bmain, struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname); - -void WM_manipulator_group_type_unlink_delayed_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_unlink_delayed_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_unlink_delayed(const char *idname); - -/* Utilities */ -bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step); - -bool WM_manipulator_group_type_poll(const struct bContext *C, const struct wmManipulatorGroupType *wgt); - -#endif /* __WM_MANIPULATOR_API_H__ */ diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h deleted file mode 100644 index ee2f833858a..00000000000 --- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h +++ /dev/null @@ -1,422 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/WM_manipulator_types.h - * \ingroup wm - * - * \name Manipulator Types - * \brief Manipulator defines for external use. - * - * Only included in WM_types.h and lower level files. - */ - - -#ifndef __WM_MANIPULATOR_TYPES_H__ -#define __WM_MANIPULATOR_TYPES_H__ - -#include "BLI_compiler_attrs.h" - -struct wmManipulatorMapType; -struct wmManipulatorGroupType; -struct wmManipulatorGroup; -struct wmManipulator; -struct wmManipulatorProperty; -struct wmKeyConfig; - -#include "DNA_listBase.h" - - -/* -------------------------------------------------------------------- */ -/* Enum Typedef's */ - - -/** - * #wmManipulator.state - */ -typedef enum eWM_ManipulatorState { - WM_MANIPULATOR_STATE_HIGHLIGHT = (1 << 0), /* while hovered */ - WM_MANIPULATOR_STATE_MODAL = (1 << 1), /* while dragging */ - WM_MANIPULATOR_STATE_SELECT = (1 << 2), -} eWM_ManipulatorState; - - -/** - * #wmManipulator.flag - * Flags for individual manipulators. - */ -typedef enum eWM_ManipulatorFlag { - WM_MANIPULATOR_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */ - WM_MANIPULATOR_DRAW_MODAL = (1 << 1), /* draw while dragging */ - WM_MANIPULATOR_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */ - WM_MANIPULATOR_HIDDEN = (1 << 3), - /** - * When set 'scale_final' value also scales the offset. - * Use when offset is to avoid screen-space overlap instead of absolute positioning. */ - WM_MANIPULATOR_DRAW_OFFSET_SCALE = (1 << 4), - /** - * User should still use 'scale_final' for any handles and UI elements. - * This simply skips scale when calculating the final matrix. - * Needed when the manipulator needs to align with the interface underneath it. */ - WM_MANIPULATOR_DRAW_NO_SCALE = (1 << 5), - /** - * Hide the cursor and lock it's position while interacting with this manipulator. - */ - WM_MANIPULATOR_GRAB_CURSOR = (1 << 6), - /** Don't write into the depth buffer when selecting. */ - WM_MANIPULATOR_SELECT_BACKGROUND = (1 << 7), -} eWM_ManipulatorFlag; - -/** - * #wmManipulatorGroupType.flag - * Flags that influence the behavior of all manipulators in the group. - */ -typedef enum eWM_ManipulatorGroupTypeFlag { - /* Mark manipulator-group as being 3D */ - WM_MANIPULATORGROUPTYPE_3D = (1 << 0), - /* Scale manipulators as 3D object that respects zoom (otherwise zoom independent draw size). - * note: currently only for 3D views, 2D support needs adding. */ - WM_MANIPULATORGROUPTYPE_SCALE = (1 << 1), - /* Manipulators can be depth culled with scene objects (covered by other geometry - TODO) */ - WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2), - /* Manipulators can be selected */ - WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3), - /* The manipulator group is to be kept (not removed on loading a new file for eg). */ - WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4), - /* Show all other manipulators when interacting. */ - WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL = (1 << 5), -} eWM_ManipulatorGroupTypeFlag; - - -/** - * #wmManipulatorGroup.init_flag - */ -typedef enum eWM_ManipulatorGroupInitFlag { - /* mgroup has been initialized */ - WM_MANIPULATORGROUP_INIT_SETUP = (1 << 0), - WM_MANIPULATORGROUP_INIT_REFRESH = (1 << 1), -} eWM_ManipulatorGroupInitFlag; - -/** - * #wmManipulatorMapType.type_update_flag - * Manipulator-map type update flag - */ -typedef enum eWM_ManipulatorMapTypeUpdateFlag { - /* A new type has been added, needs to be initialized for all views. */ - WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0), - WM_MANIPULATORMAPTYPE_UPDATE_REMOVE = (1 << 1), - - /* Needed because keymap may be registered before and after window initialization. - * So we need to keep track of keymap initialization separately. */ - WM_MANIPULATORMAPTYPE_KEYMAP_INIT = (1 << 2), -} eWM_ManipulatorMapTypeUpdateFlag; - -/* -------------------------------------------------------------------- */ -/* wmManipulator */ - -/** - * \brief Manipulator tweak flag. - * Bitflag passed to manipulator while tweaking. - * - * \note Manipulators are responsible for handling this #wmManipulator.modal callback!. - */ -typedef enum { - /* Drag with extra precision (Shift). */ - WM_MANIPULATOR_TWEAK_PRECISE = (1 << 0), - /* Drag with snap enabled (Ctrl). */ - WM_MANIPULATOR_TWEAK_SNAP = (1 << 1), -} eWM_ManipulatorTweak; - -#include "wm_manipulator_fn.h" - -typedef struct wmManipulatorOpElem { - struct wmOperatorType *type; - /* operator properties if manipulator spawns and controls an operator, - * or owner pointer if manipulator spawns and controls a property */ - PointerRNA ptr; - - bool is_redo; -} wmManipulatorOpElem; - -/* manipulators are set per region by registering them on manipulator-maps */ -struct wmManipulator { - struct wmManipulator *next, *prev; - - /* While we don't have a real type, use this to put type-like vars. */ - const struct wmManipulatorType *type; - - /* Overrides 'type->modal' when set. - * Note that this is a workaround, remove if we can. */ - wmManipulatorFnModal custom_modal; - - /* pointer back to group this manipulator is in (just for quick access) */ - struct wmManipulatorGroup *parent_mgroup; - - void *py_instance; - - /* rna pointer to access properties */ - struct PointerRNA *ptr; - - /* flags that influence the behavior or how the manipulators are drawn */ - eWM_ManipulatorFlag flag; - /* state flags (active, highlighted, selected) */ - eWM_ManipulatorState state; - - /* Optional ID for highlighting different parts of this manipulator. - * -1 when unset, otherwise a valid index. (Used as index to 'op_data'). */ - int highlight_part; - /* For single click button manipulators, use a different part as a fallback, -1 when unused. */ - int drag_part; - - /* Transformation of the manipulator in 2d or 3d space. - * - Matrix axis are expected to be unit length (scale is applied after). - * - Behavior when axis aren't orthogonal depends on each manipulator. - * - Typically the +Z is the primary axis for manipulators to use. - * - 'matrix[3]' must be used for location, - * besides this it's up to the manipulators internal code how the - * rotation components are used for drawing and interaction. - */ - - /* The space this manipulator is being modified in. */ - float matrix_space[4][4]; - /* Transformation of this manipulator. */ - float matrix_basis[4][4]; - /* custom offset from origin */ - float matrix_offset[4][4]; - /* runtime property, set the scale while drawing on the viewport */ - float scale_final; - /* user defined scale, in addition to the original one */ - float scale_basis; - /* user defined width for line drawing */ - float line_width; - /* manipulator colors (uses default fallbacks if not defined) */ - float color[4], color_hi[4]; - - /* data used during interaction */ - void *interaction_data; - - /* Operator to spawn when activating the manipulator (overrides property editing), - * an array of items (aligned with #wmManipulator.highlight_part). */ - wmManipulatorOpElem *op_data; - int op_data_len; - - struct IDProperty *properties; - - /* over alloc target_properties after 'wmManipulatorType.struct_size' */ -}; - -/* Similar to PropertyElemRNA, but has an identifier. */ -typedef struct wmManipulatorProperty { - const struct wmManipulatorPropertyType *type; - - PointerRNA ptr; - PropertyRNA *prop; - int index; - - - /* Optional functions for converting to/from RNA */ - struct { - wmManipulatorPropertyFnGet value_get_fn; - wmManipulatorPropertyFnSet value_set_fn; - wmManipulatorPropertyFnRangeGet range_get_fn; - wmManipulatorPropertyFnFree free_fn; - void *user_data; - } custom_func; -} wmManipulatorProperty; - -typedef struct wmManipulatorPropertyType { - struct wmManipulatorPropertyType *next, *prev; - /* PropertyType, typically 'PROP_FLOAT' */ - int data_type; - int array_length; - - /* index within 'wmManipulatorType' */ - int index_in_type; - - /* over alloc */ - char idname[0]; -} wmManipulatorPropertyType; - - -/** - * Simple utility wrapper for storing a single manipulator as wmManipulatorGroup.customdata (which gets freed). - */ -typedef struct wmManipulatorWrapper { - struct wmManipulator *manipulator; -} wmManipulatorWrapper; - -struct wmManipulatorMapType_Params { - short spaceid; - short regionid; -}; - -typedef struct wmManipulatorType { - - const char *idname; /* MAX_NAME */ - - /* Set to 'sizeof(wmManipulator)' or larger for instances of this type, - * use so we can cant to other types without the hassle of a custom-data pointer. */ - uint struct_size; - - /* Initialize struct (calloc'd 'struct_size' region). */ - wmManipulatorFnSetup setup; - - /* draw manipulator */ - wmManipulatorFnDraw draw; - - /* determines 3d intersection by rendering the manipulator in a selection routine. */ - wmManipulatorFnDrawSelect draw_select; - - /* Determine if the mouse intersects with the manipulator. - * The calculation should be done in the callback itself, -1 for no seleciton. */ - wmManipulatorFnTestSelect test_select; - - /* handler used by the manipulator. Usually handles interaction tied to a manipulator type */ - wmManipulatorFnModal modal; - - /* manipulator-specific handler to update manipulator attributes based on the property value */ - wmManipulatorFnPropertyUpdate property_update; - - /* Returns the final transformation which may be different from the 'matrix', - * depending on the manipulator. - * Notes: - * - Scale isn't applied (wmManipulator.scale/user_scale). - * - Offset isn't applied (wmManipulator.matrix_offset). - */ - wmManipulatorFnMatrixBasisGet matrix_basis_get; - - /* activate a manipulator state when the user clicks on it */ - wmManipulatorFnInvoke invoke; - - /* called when manipulator tweaking is done - used to free data and reset property when cancelling */ - wmManipulatorFnExit exit; - - wmManipulatorFnCursorGet cursor_get; - - /* called when manipulator selection state changes */ - wmManipulatorFnSelectRefresh select_refresh; - - /* Free data (not the manipulator it's self), use when the manipulator allocates it's own members. */ - wmManipulatorFnFree free; - - /* RNA for properties */ - struct StructRNA *srna; - - /* RNA integration */ - ExtensionRNA ext; - - ListBase target_property_defs; - int target_property_defs_len; - -} wmManipulatorType; - - -/* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ - -/* factory class for a manipulator-group type, gets called every time a new area is spawned */ -typedef struct wmManipulatorGroupTypeRef { - struct wmManipulatorGroupTypeRef *next, *prev; - struct wmManipulatorGroupType *type; -} wmManipulatorGroupTypeRef; - -/* factory class for a manipulator-group type, gets called every time a new area is spawned */ -typedef struct wmManipulatorGroupType { - const char *idname; /* MAX_NAME */ - const char *name; /* manipulator-group name - displayed in UI (keymap editor) */ - char owner_id[64]; /* MAX_NAME */ - - /* poll if manipulator-map should be visible */ - wmManipulatorGroupFnPoll poll; - /* initially create manipulators and set permanent data - stuff you only need to do once */ - wmManipulatorGroupFnInit setup; - /* refresh data, only called if recreate flag is set (WM_manipulatormap_tag_refresh) */ - wmManipulatorGroupFnRefresh refresh; - /* refresh data for drawing, called before each redraw */ - wmManipulatorGroupFnDrawPrepare draw_prepare; - - /* Keymap init callback for this manipulator-group (optional), - * will fall back to default tweak keymap when left NULL. */ - wmManipulatorGroupFnSetupKeymap setup_keymap; - - /* Optionally subscribe to wmMsgBus events, - * these are calculated automatically from RNA properties, - * only needed if manipulators depend indirectly on properties. */ - wmManipulatorGroupFnMsgBusSubscribe message_subscribe; - - /* keymap created with callback from above */ - struct wmKeyMap *keymap; - /* Only for convenient removal. */ - struct wmKeyConfig *keyconf; - - /* Disable for now, maybe some day we want properties. */ -#if 0 - /* rna for properties */ - struct StructRNA *srna; -#endif - - /* RNA integration */ - ExtensionRNA ext; - - eWM_ManipulatorGroupTypeFlag flag; - - /* So we know which group type to update. */ - eWM_ManipulatorMapTypeUpdateFlag type_update_flag; - - /* same as manipulator-maps, so registering/unregistering goes to the correct region */ - struct wmManipulatorMapType_Params mmap_params; - -} wmManipulatorGroupType; - -typedef struct wmManipulatorGroup { - struct wmManipulatorGroup *next, *prev; - - struct wmManipulatorGroupType *type; - ListBase manipulators; - - struct wmManipulatorMap *parent_mmap; - - void *py_instance; /* python stores the class instance here */ - struct ReportList *reports; /* errors and warnings storage */ - - void *customdata; - void (*customdata_free)(void *); /* for freeing customdata from above */ - eWM_ManipulatorGroupInitFlag init_flag; -} wmManipulatorGroup; - -/* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ - -/** - * Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw. - */ -typedef enum eWM_ManipulatorMapDrawStep { - /** Draw 2D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D not set). */ - WM_MANIPULATORMAP_DRAWSTEP_2D = 0, - /** Draw 3D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D set). */ - WM_MANIPULATORMAP_DRAWSTEP_3D, -} eWM_ManipulatorMapDrawStep; -#define WM_MANIPULATORMAP_DRAWSTEP_MAX 2 - -#endif /* __WM_MANIPULATOR_TYPES_H__ */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c deleted file mode 100644 index d6eb110dca0..00000000000 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c +++ /dev/null @@ -1,800 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/intern/wm_manipulator.c - * \ingroup wm - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_listbase.h" -#include "BLI_math.h" -#include "BLI_string.h" -#include "BLI_string_utils.h" - -#include "BKE_context.h" - -#include "GPU_batch.h" -#include "GPU_glew.h" -#include "GPU_immediate.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "BKE_global.h" -#include "BKE_main.h" -#include "BKE_idprop.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" -#include "ED_view3d.h" - -#include "UI_interface.h" - -#ifdef WITH_PYTHON -#include "BPY_extern.h" -#endif - -/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ -#include "wm.h" - -/* own includes */ -#include "wm_manipulator_wmapi.h" -#include "wm_manipulator_intern.h" - -static void wm_manipulator_register( - wmManipulatorGroup *mgroup, wmManipulator *mpr); - -/** - * \note Follow #wm_operator_create convention. - */ -static wmManipulator *wm_manipulator_create( - const wmManipulatorType *wt, - PointerRNA *properties) -{ - BLI_assert(wt != NULL); - BLI_assert(wt->struct_size >= sizeof(wmManipulator)); - - wmManipulator *mpr = MEM_callocN( - wt->struct_size + (sizeof(wmManipulatorProperty) * wt->target_property_defs_len), __func__); - mpr->type = wt; - - /* initialize properties, either copy or create */ - mpr->ptr = MEM_callocN(sizeof(PointerRNA), "wmManipulatorPtrRNA"); - if (properties && properties->data) { - mpr->properties = IDP_CopyProperty(properties->data); - } - else { - IDPropertyTemplate val = {0}; - mpr->properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties"); - } - RNA_pointer_create(G_MAIN->wm.first, wt->srna, mpr->properties, mpr->ptr); - - WM_manipulator_properties_sanitize(mpr->ptr, 0); - - unit_m4(mpr->matrix_space); - unit_m4(mpr->matrix_basis); - unit_m4(mpr->matrix_offset); - - mpr->drag_part = -1; - - return mpr; -} - -wmManipulator *WM_manipulator_new_ptr( - const wmManipulatorType *wt, wmManipulatorGroup *mgroup, - PointerRNA *properties) -{ - wmManipulator *mpr = wm_manipulator_create(wt, properties); - - wm_manipulator_register(mgroup, mpr); - - if (mpr->type->setup != NULL) { - mpr->type->setup(mpr); - } - - return mpr; -} - -/** - * \param wt: Must be valid, - * if you need to check it exists use #WM_manipulator_new_ptr - * because callers of this function don't NULL check the return value. - */ -wmManipulator *WM_manipulator_new( - const char *idname, wmManipulatorGroup *mgroup, - PointerRNA *properties) -{ - const wmManipulatorType *wt = WM_manipulatortype_find(idname, false); - return WM_manipulator_new_ptr(wt, mgroup, properties); -} - -/** - * Initialize default values and allocate needed memory for members. - */ -static void manipulator_init(wmManipulator *mpr) -{ - const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - - mpr->scale_basis = 1.0f; - mpr->line_width = 1.0f; - - /* defaults */ - copy_v4_v4(mpr->color, color_default); - copy_v4_v4(mpr->color_hi, color_default); -} - -/** - * Register \a manipulator. - * - * \param name: name used to create a unique idname for \a manipulator in \a mgroup - * - * \note Not to be confused with type registration from RNA. - */ -static void wm_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr) -{ - manipulator_init(mpr); - wm_manipulatorgroup_manipulator_register(mgroup, mpr); -} - -/** - * \warning this doesn't check #wmManipulatorMap (highlight, selection etc). - * Typical use is when freeing the windowing data, - * where caller can manage clearing selection, highlight... etc. - */ -void WM_manipulator_free(wmManipulator *mpr) -{ - if (mpr->type->free != NULL) { - mpr->type->free(mpr); - } - -#ifdef WITH_PYTHON - if (mpr->py_instance) { - /* do this first in case there are any __del__ functions or - * similar that use properties */ - BPY_DECREF_RNA_INVALIDATE(mpr->py_instance); - } -#endif - - if (mpr->op_data) { - for (int i = 0; i < mpr->op_data_len; i++) { - WM_operator_properties_free(&mpr->op_data[i].ptr); - } - MEM_freeN(mpr->op_data); - } - - if (mpr->ptr != NULL) { - WM_manipulator_properties_free(mpr->ptr); - MEM_freeN(mpr->ptr); - } - - if (mpr->type->target_property_defs_len != 0) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (mpr_prop->custom_func.free_fn) { - mpr_prop->custom_func.free_fn(mpr, mpr_prop); - } - } - } - - MEM_freeN(mpr); -} - -/** - * Free \a manipulator and unlink from \a manipulatorlist. - * \a manipulatorlist is allowed to be NULL. - */ -void WM_manipulator_unlink(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmManipulator *mpr, bContext *C) -{ - if (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); - } - if (mpr->state & WM_MANIPULATOR_STATE_MODAL) { - wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false); - } - /* Unlink instead of setting so we don't run callbacks. */ - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { - WM_manipulator_select_unlink(mmap, mpr); - } - - if (manipulatorlist) { - BLI_remlink(manipulatorlist, mpr); - } - - BLI_assert(mmap->mmap_context.highlight != mpr); - BLI_assert(mmap->mmap_context.modal != mpr); - - WM_manipulator_free(mpr); -} - -/* -------------------------------------------------------------------- */ -/** \name Manipulator Creation API - * - * API for defining data on manipulator creation. - * - * \{ */ - -struct wmManipulatorOpElem *WM_manipulator_operator_get( - wmManipulator *mpr, int part_index) -{ - if (mpr->op_data && ((part_index >= 0) && (part_index < mpr->op_data_len))) { - return &mpr->op_data[part_index]; - } - return NULL; -} - -PointerRNA *WM_manipulator_operator_set( - wmManipulator *mpr, int part_index, - wmOperatorType *ot, IDProperty *properties) -{ - BLI_assert(part_index < 255); - /* We could pre-allocate these but using multiple is such a rare thing. */ - if (part_index >= mpr->op_data_len) { - mpr->op_data_len = part_index + 1; - mpr->op_data = MEM_recallocN(mpr->op_data, sizeof(*mpr->op_data) * mpr->op_data_len); - } - wmManipulatorOpElem *mpop = &mpr->op_data[part_index]; - mpop->type = ot; - - if (mpop->ptr.data) { - WM_operator_properties_free(&mpop->ptr); - } - WM_operator_properties_create_ptr(&mpop->ptr, ot); - - if (properties) { - mpop->ptr.data = properties; - } - - return &mpop->ptr; -} - -static void wm_manipulator_set_matrix_rotation_from_z_axis__internal( - float matrix[4][4], const float z_axis[3]) -{ - /* old code, seems we can use simpler method */ -#if 0 - const float z_global[3] = {0.0f, 0.0f, 1.0f}; - float rot[3][3]; - - rotation_between_vecs_to_mat3(rot, z_global, z_axis); - copy_v3_v3(matrix[0], rot[0]); - copy_v3_v3(matrix[1], rot[1]); - copy_v3_v3(matrix[2], rot[2]); -#else - normalize_v3_v3(matrix[2], z_axis); - ortho_basis_v3v3_v3(matrix[0], matrix[1], matrix[2]); -#endif - -} - -static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal( - float matrix[4][4], const float y_axis[3], const float z_axis[3]) -{ - normalize_v3_v3(matrix[1], y_axis); - normalize_v3_v3(matrix[2], z_axis); - cross_v3_v3v3(matrix[0], matrix[1], matrix[2]); - normalize_v3(matrix[0]); -} - -/** - * wmManipulator.matrix utils. - */ -void WM_manipulator_set_matrix_rotation_from_z_axis( - wmManipulator *mpr, const float z_axis[3]) -{ - wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis); -} -void WM_manipulator_set_matrix_rotation_from_yz_axis( - wmManipulator *mpr, const float y_axis[3], const float z_axis[3]) -{ - wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis); -} -void WM_manipulator_set_matrix_location(wmManipulator *mpr, const float origin[3]) -{ - copy_v3_v3(mpr->matrix_basis[3], origin); -} - -/** - * wmManipulator.matrix_offset utils. - */ -void WM_manipulator_set_matrix_offset_rotation_from_z_axis( - wmManipulator *mpr, const float z_axis[3]) -{ - wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis); -} -void WM_manipulator_set_matrix_offset_rotation_from_yz_axis( - wmManipulator *mpr, const float y_axis[3], const float z_axis[3]) -{ - wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis); -} -void WM_manipulator_set_matrix_offset_location(wmManipulator *mpr, const float offset[3]) -{ - copy_v3_v3(mpr->matrix_offset[3], offset); -} - -void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enable) -{ - if (enable) { - mpr->flag |= flag; - } - else { - mpr->flag &= ~flag; - } -} - -void WM_manipulator_set_scale(wmManipulator *mpr, const float scale) -{ - mpr->scale_basis = scale; -} - -void WM_manipulator_set_line_width(wmManipulator *mpr, const float line_width) -{ - mpr->line_width = line_width; -} - -/** - * Set manipulator rgba colors. - * - * \param col Normal state color. - * \param col_hi Highlighted state color. - */ -void WM_manipulator_get_color(const wmManipulator *mpr, float color[4]) -{ - copy_v4_v4(color, mpr->color); -} -void WM_manipulator_set_color(wmManipulator *mpr, const float color[4]) -{ - copy_v4_v4(mpr->color, color); -} - -void WM_manipulator_get_color_highlight(const wmManipulator *mpr, float color_hi[4]) -{ - copy_v4_v4(color_hi, mpr->color_hi); -} -void WM_manipulator_set_color_highlight(wmManipulator *mpr, const float color_hi[4]) -{ - copy_v4_v4(mpr->color_hi, color_hi); -} - - -/** \} */ // Manipulator Creation API - - -/* -------------------------------------------------------------------- */ -/** \name Manipulator Callback Assignment - * - * \{ */ - -void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn) -{ - mpr->custom_modal = fn; -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** - * Add/Remove \a manipulator to selection. - * Reallocates memory for selected manipulators so better not call for selecting multiple ones. - * - * \return if the selection has changed. - */ -bool wm_manipulator_select_set_ex( - wmManipulatorMap *mmap, wmManipulator *mpr, bool select, - bool use_array, bool use_callback) -{ - bool changed = false; - - if (select) { - if ((mpr->state & WM_MANIPULATOR_STATE_SELECT) == 0) { - if (use_array) { - wm_manipulatormap_select_array_push_back(mmap, mpr); - } - mpr->state |= WM_MANIPULATOR_STATE_SELECT; - changed = true; - } - } - else { - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { - if (use_array) { - wm_manipulatormap_select_array_remove(mmap, mpr); - } - mpr->state &= ~WM_MANIPULATOR_STATE_SELECT; - changed = true; - } - } - - /* In the case of unlinking we only want to remove from the array - * and not write to the external state */ - if (use_callback && changed) { - if (mpr->type->select_refresh) { - mpr->type->select_refresh(mpr); - } - } - - return changed; -} - -/* Remove from selection array without running callbacks. */ -bool WM_manipulator_select_unlink(wmManipulatorMap *mmap, wmManipulator *mpr) -{ - return wm_manipulator_select_set_ex(mmap, mpr, false, true, false); -} - -bool WM_manipulator_select_set(wmManipulatorMap *mmap, wmManipulator *mpr, bool select) -{ - return wm_manipulator_select_set_ex(mmap, mpr, select, true, true); -} - -void WM_manipulator_highlight_set(wmManipulatorMap *mmap, wmManipulator *mpr) -{ - wm_manipulatormap_highlight_set(mmap, NULL, mpr, mpr ? mpr->highlight_part : 0); -} - -bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr) -{ - if (WM_manipulator_select_set(mmap, mpr, true)) { - wm_manipulatormap_highlight_set(mmap, C, mpr, mpr->highlight_part); - return true; - } - else { - return false; - } -} - -/** - * Special function to run from setup so manipulators start out interactive. - * - * We could do this when linking them, but this complicates things since the window update code needs to run first. - */ -void WM_manipulator_modal_set_from_setup( - struct wmManipulatorMap *mmap, struct bContext *C, - struct wmManipulator *mpr, int part_index, const wmEvent *event) -{ - mpr->highlight_part = part_index; - WM_manipulator_highlight_set(mmap, mpr); - if (false) { - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); - } - else { - /* WEAK: but it works. */ - WM_operator_name_call(C, "MANIPULATORGROUP_OT_manipulator_tweak", WM_OP_INVOKE_DEFAULT, NULL); - } -} - -void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C) -{ - const RegionView3D *rv3d = CTX_wm_region_view3d(C); - float scale = UI_DPI_FAC; - - if ((mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE) == 0) { - scale *= U.manipulator_size; - if (rv3d) { - /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */ - float matrix_world[4][4]; - if (mpr->type->matrix_basis_get) { - float matrix_basis[4][4]; - mpr->type->matrix_basis_get(mpr, matrix_basis); - mul_m4_m4m4(matrix_world, mpr->matrix_space, matrix_basis); - } - else { - mul_m4_m4m4(matrix_world, mpr->matrix_space, mpr->matrix_basis); - } - - /* Exclude matrix_offset from scale. */ - scale *= ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_world[3]); - } - else { - scale *= 0.02f; - } - } - - mpr->scale_final = mpr->scale_basis * scale; -} - -static void manipulator_update_prop_data(wmManipulator *mpr) -{ - /* manipulator property might have been changed, so update manipulator */ - if (mpr->type->property_update) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - mpr->type->property_update(mpr, mpr_prop); - } - } - } -} - -void wm_manipulator_update(wmManipulator *mpr, const bContext *C, const bool refresh_map) -{ - if (refresh_map) { - manipulator_update_prop_data(mpr); - } - wm_manipulator_calculate_scale(mpr, C); -} - -int wm_manipulator_is_visible(wmManipulator *mpr) -{ - if (mpr->flag & WM_MANIPULATOR_HIDDEN) { - return 0; - } - if ((mpr->state & WM_MANIPULATOR_STATE_MODAL) && - !(mpr->flag & (WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_VALUE))) - { - /* don't draw while modal (dragging) */ - return 0; - } - if ((mpr->flag & WM_MANIPULATOR_DRAW_HOVER) && - !(mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) && - !(mpr->state & WM_MANIPULATOR_STATE_SELECT)) /* still draw selected manipulators */ - { - /* update but don't draw */ - return WM_MANIPULATOR_IS_VISIBLE_UPDATE; - } - - return WM_MANIPULATOR_IS_VISIBLE_UPDATE | WM_MANIPULATOR_IS_VISIBLE_DRAW; -} - -void WM_manipulator_calc_matrix_final_params( - const wmManipulator *mpr, - const struct WM_ManipulatorMatrixParams *params, - float r_mat[4][4]) -{ - const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : mpr->matrix_space; - const float (* const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis : mpr->matrix_basis; - const float (* const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset : mpr->matrix_offset; - const float *scale_final = params->scale_final ? params->scale_final : &mpr->scale_final; - - float final_matrix[4][4]; - if (params->matrix_basis == NULL && mpr->type->matrix_basis_get) { - mpr->type->matrix_basis_get(mpr, final_matrix); - } - else { - copy_m4_m4(final_matrix, matrix_basis); - } - - if (mpr->flag & WM_MANIPULATOR_DRAW_NO_SCALE) { - mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); - } - else { - if (mpr->flag & WM_MANIPULATOR_DRAW_OFFSET_SCALE) { - mul_mat3_m4_fl(final_matrix, *scale_final); - mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); - } - else { - mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); - mul_mat3_m4_fl(final_matrix, *scale_final); - } - } - - mul_m4_m4m4(r_mat, matrix_space, final_matrix); -} - -void WM_manipulator_calc_matrix_final_no_offset(const wmManipulator *mpr, float r_mat[4][4]) -{ - float mat_identity[4][4]; - unit_m4(mat_identity); - - WM_manipulator_calc_matrix_final_params( - mpr, - &((struct WM_ManipulatorMatrixParams) { - .matrix_space = NULL, - .matrix_basis = NULL, - .matrix_offset = mat_identity, - .scale_final = NULL, - }), r_mat - ); -} - -void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4]) -{ - WM_manipulator_calc_matrix_final_params( - mpr, - &((struct WM_ManipulatorMatrixParams) { - .matrix_space = NULL, - .matrix_basis = NULL, - .matrix_offset = NULL, - .scale_final = NULL, - }), r_mat - ); -} - -/** \name Manipulator Propery Access - * - * Matches `WM_operator_properties` conventions. - * - * \{ */ - - -void WM_manipulator_properties_create_ptr(PointerRNA *ptr, wmManipulatorType *wt) -{ - RNA_pointer_create(NULL, wt->srna, NULL, ptr); -} - -void WM_manipulator_properties_create(PointerRNA *ptr, const char *wtstring) -{ - const wmManipulatorType *wt = WM_manipulatortype_find(wtstring, false); - - if (wt) - WM_manipulator_properties_create_ptr(ptr, (wmManipulatorType *)wt); - else - RNA_pointer_create(NULL, &RNA_ManipulatorProperties, NULL, ptr); -} - -/* similar to the function above except its uses ID properties - * used for keymaps and macros */ -void WM_manipulator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *wtstring) -{ - if (*properties == NULL) { - IDPropertyTemplate val = {0}; - *properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp"); - } - - if (*ptr == NULL) { - *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"); - WM_manipulator_properties_create(*ptr, wtstring); - } - - (*ptr)->data = *properties; - -} - -void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context) -{ - RNA_STRUCT_BEGIN (ptr, prop) - { - switch (RNA_property_type(prop)) { - case PROP_ENUM: - if (no_context) - RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); - else - RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); - break; - case PROP_POINTER: - { - StructRNA *ptype = RNA_property_pointer_type(ptr, prop); - - /* recurse into manipulator properties */ - if (RNA_struct_is_a(ptype, &RNA_ManipulatorProperties)) { - PointerRNA opptr = RNA_property_pointer_get(ptr, prop); - WM_manipulator_properties_sanitize(&opptr, no_context); - } - break; - } - default: - break; - } - } - RNA_STRUCT_END; -} - - -/** set all props to their default, - * \param do_update Only update un-initialized props. - * - * \note, theres nothing specific to manipulators here. - * this could be made a general function. - */ -bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update) -{ - bool changed = false; - RNA_STRUCT_BEGIN (ptr, prop) - { - switch (RNA_property_type(prop)) { - case PROP_POINTER: - { - StructRNA *ptype = RNA_property_pointer_type(ptr, prop); - if (ptype != &RNA_Struct) { - PointerRNA opptr = RNA_property_pointer_get(ptr, prop); - changed |= WM_manipulator_properties_default(&opptr, do_update); - } - break; - } - default: - if ((do_update == false) || (RNA_property_is_set(ptr, prop) == false)) { - if (RNA_property_reset(ptr, prop, -1)) { - changed = true; - } - } - break; - } - } - RNA_STRUCT_END; - - return changed; -} - -/* remove all props without PROP_SKIP_SAVE */ -void WM_manipulator_properties_reset(wmManipulator *mpr) -{ - if (mpr->ptr->data) { - PropertyRNA *iterprop; - iterprop = RNA_struct_iterator_property(mpr->type->srna); - - RNA_PROP_BEGIN (mpr->ptr, itemptr, iterprop) - { - PropertyRNA *prop = itemptr.data; - - if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) { - const char *identifier = RNA_property_identifier(prop); - RNA_struct_idprops_unset(mpr->ptr, identifier); - } - } - RNA_PROP_END; - } -} - -void WM_manipulator_properties_clear(PointerRNA *ptr) -{ - IDProperty *properties = ptr->data; - - if (properties) { - IDP_ClearProperty(properties); - } -} - -void WM_manipulator_properties_free(PointerRNA *ptr) -{ - IDProperty *properties = ptr->data; - - if (properties) { - IDP_FreeProperty(properties); - MEM_freeN(properties); - ptr->data = NULL; /* just in case */ - } -} - -/** \} */ - -/** \name General Utilities - * - * \{ */ - -bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step) -{ - switch (step) { - case WM_MANIPULATORMAP_DRAWSTEP_2D: - { - break; - } - case WM_MANIPULATORMAP_DRAWSTEP_3D: - { - wmWindowManager *wm = CTX_wm_manager(C); - if (ED_screen_animation_playing(wm)) { - return false; - } - break; - } - } - return true; -} - -/** \} */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c deleted file mode 100644 index 8bda9e91db7..00000000000 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c +++ /dev/null @@ -1,949 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/intern/wm_manipulator_group.c - * \ingroup wm - * - * \name Manipulator-Group - * - * Manipulator-groups store and manage groups of manipulators. They can be - * attached to modal handlers and have own keymaps. - */ - -#include -#include - -#include "MEM_guardedalloc.h" - -#include "BLI_listbase.h" -#include "BLI_string.h" -#include "BLI_math.h" - -#include "BKE_context.h" -#include "BKE_main.h" -#include "BKE_report.h" -#include "BKE_workspace.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" -#include "wm_event_system.h" - -#include "ED_screen.h" -#include "ED_undo.h" - -/* own includes */ -#include "wm_manipulator_wmapi.h" -#include "wm_manipulator_intern.h" - -#ifdef WITH_PYTHON -# include "BPY_extern.h" -#endif - -/* Allow manipulator part's to be single click only, - * dragging falls back to activating their 'drag_part' action. */ -#define USE_DRAG_DETECT - -/* -------------------------------------------------------------------- */ -/** \name wmManipulatorGroup - * - * \{ */ - -/** - * Create a new manipulator-group from \a wgt. - */ -wmManipulatorGroup *wm_manipulatorgroup_new_from_type( - wmManipulatorMap *mmap, wmManipulatorGroupType *wgt) -{ - wmManipulatorGroup *mgroup = MEM_callocN(sizeof(*mgroup), "manipulator-group"); - mgroup->type = wgt; - - /* keep back-link */ - mgroup->parent_mmap = mmap; - - BLI_addtail(&mmap->groups, mgroup); - - return mgroup; -} - -void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup) -{ - wmManipulatorMap *mmap = mgroup->parent_mmap; - - /* Similar to WM_manipulator_unlink, but only to keep mmap state correct, - * we don't want to run callbacks. */ - if (mmap->mmap_context.highlight && mmap->mmap_context.highlight->parent_mgroup == mgroup) { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); - } - if (mmap->mmap_context.modal && mmap->mmap_context.modal->parent_mgroup == mgroup) { - wm_manipulatormap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false); - } - - for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) { - mpr_next = mpr->next; - if (mmap->mmap_context.select.len) { - WM_manipulator_select_unlink(mmap, mpr); - } - WM_manipulator_free(mpr); - } - BLI_listbase_clear(&mgroup->manipulators); - -#ifdef WITH_PYTHON - if (mgroup->py_instance) { - /* do this first in case there are any __del__ functions or - * similar that use properties */ - BPY_DECREF_RNA_INVALIDATE(mgroup->py_instance); - } -#endif - - if (mgroup->reports && (mgroup->reports->flag & RPT_FREE)) { - BKE_reports_clear(mgroup->reports); - MEM_freeN(mgroup->reports); - } - - if (mgroup->customdata_free) { - mgroup->customdata_free(mgroup->customdata); - } - else { - MEM_SAFE_FREE(mgroup->customdata); - } - - BLI_remlink(&mmap->groups, mgroup); - - MEM_freeN(mgroup); -} - -/** - * Add \a manipulator to \a mgroup and make sure its name is unique within the group. - */ -void wm_manipulatorgroup_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr) -{ - BLI_assert(BLI_findindex(&mgroup->manipulators, mpr) == -1); - BLI_addtail(&mgroup->manipulators, mpr); - mpr->parent_mgroup = mgroup; -} - -wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( - const wmManipulatorGroup *mgroup, bContext *C, const wmEvent *event, - int *r_part) -{ - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->type->test_select && (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) { - if ((*r_part = mpr->type->test_select(C, mpr, event)) != -1) { - return mpr; - } - } - } - - return NULL; -} - -/** - * Adds all manipulators of \a mgroup that can be selected to the head of \a listbase. Added items need freeing! - */ -void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorGroup *mgroup, ListBase *listbase) -{ - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if ((mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) { - if (((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) && mpr->type->draw_select) || - ((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0 && mpr->type->test_select)) - { - BLI_addhead(listbase, BLI_genericNodeN(mpr)); - } - } - } -} - -void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bContext *C) -{ - /* prepare for first draw */ - if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0)) { - mgroup->type->setup(C, mgroup); - - /* Not ideal, initialize keymap here, needed for RNA runtime generated manipulators. */ - wmManipulatorGroupType *wgt = mgroup->type; - if (wgt->keymap == NULL) { - wmWindowManager *wm = CTX_wm_manager(C); - wm_manipulatorgrouptype_setup_keymap(wgt, wm->defaultconf); - BLI_assert(wgt->keymap != NULL); - } - mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_SETUP; - } - - /* refresh may be called multiple times, this just ensures its called at least once before we draw. */ - if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_REFRESH) == 0)) { - if (mgroup->type->refresh) { - mgroup->type->refresh(C, mgroup); - } - mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_REFRESH; - } -} - -bool WM_manipulator_group_type_poll(const bContext *C, const struct wmManipulatorGroupType *wgt) -{ - /* If we're tagged, only use compatible. */ - if (wgt->owner_id[0] != '\0') { - const WorkSpace *workspace = CTX_wm_workspace(C); - if (BKE_workspace_owner_id_check(workspace, wgt->owner_id) == false) { - return false; - } - } - /* Check for poll function, if manipulator-group belongs to an operator, also check if the operator is running. */ - return (!wgt->poll || wgt->poll(C, (wmManipulatorGroupType *)wgt)); -} - -bool wm_manipulatorgroup_is_visible_in_drawstep( - const wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep) -{ - switch (drawstep) { - case WM_MANIPULATORMAP_DRAWSTEP_2D: - return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; - case WM_MANIPULATORMAP_DRAWSTEP_3D: - return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D); - default: - BLI_assert(0); - return false; - } -} - -bool wm_manipulatorgroup_is_any_selected(const wmManipulatorGroup *mgroup) -{ - if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT) { - for (const wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { - return true; - } - } - } - return false; -} - -/** \} */ - -/** \name Manipulator operators - * - * Basic operators for manipulator interaction with user configurable keymaps. - * - * \{ */ - -static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ - ARegion *ar = CTX_wm_region(C); - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - wmManipulator *highlight = mmap->mmap_context.highlight; - - bool extend = RNA_boolean_get(op->ptr, "extend"); - bool deselect = RNA_boolean_get(op->ptr, "deselect"); - bool toggle = RNA_boolean_get(op->ptr, "toggle"); - - /* deselect all first */ - if (extend == false && deselect == false && toggle == false) { - wm_manipulatormap_deselect_all(mmap); - BLI_assert(msel->items == NULL && msel->len == 0); - UNUSED_VARS_NDEBUG(msel); - } - - if (highlight) { - const bool is_selected = (highlight->state & WM_MANIPULATOR_STATE_SELECT); - bool redraw = false; - - if (toggle) { - /* toggle: deselect if already selected, else select */ - deselect = is_selected; - } - - if (deselect) { - if (is_selected && WM_manipulator_select_set(mmap, highlight, false)) { - redraw = true; - } - } - else if (wm_manipulator_select_and_highlight(C, mmap, highlight)) { - redraw = true; - } - - if (redraw) { - ED_region_tag_redraw(ar); - } - - return OPERATOR_FINISHED; - } - else { - BLI_assert(0); - return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); - } - - return OPERATOR_PASS_THROUGH; -} - -void MANIPULATORGROUP_OT_manipulator_select(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Gizmo Select"; - ot->description = "Select the currently highlighted manipulator"; - ot->idname = "MANIPULATORGROUP_OT_manipulator_select"; - - /* api callbacks */ - ot->invoke = manipulator_select_invoke; - - ot->flag = OPTYPE_UNDO; - - WM_operator_properties_mouse_select(ot); -} - -typedef struct ManipulatorTweakData { - wmManipulatorMap *mmap; - wmManipulatorGroup *mgroup; - wmManipulator *mpr_modal; - - int init_event; /* initial event type */ - int flag; /* tweak flags */ - -#ifdef USE_DRAG_DETECT - /* True until the mouse is moved (only use when the operator has no modal). - * this allows some manipulators to be click-only. */ - enum { - /* Don't detect dragging. */ - DRAG_NOP = 0, - /* Detect dragging (wait until a drag or click is detected). */ - DRAG_DETECT, - /* Drag has started, idle until there is no active modal operator. - * This is needed because finishing the modal operator also exits - * the modal manipulator state (un-grabbs the cursor). - * Ideally this workaround could be removed later. */ - DRAG_IDLE, - } drag_state; -#endif - -} ManipulatorTweakData; - -static bool manipulator_tweak_start( - bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event) -{ - /* activate highlighted manipulator */ - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); - - return (mpr->state & WM_MANIPULATOR_STATE_MODAL); -} - -static bool manipulator_tweak_start_and_finish( - bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event, bool *r_is_modal) -{ - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); - if (r_is_modal) { - *r_is_modal = false; - } - if (mpop && mpop->type) { - - /* Undo/Redo */ - if (mpop->is_redo) { - wmWindowManager *wm = CTX_wm_manager(C); - wmOperator *op = WM_operator_last_redo(C); - - /* We may want to enable this, for now the manipulator can manage it's own properties. */ -#if 0 - IDP_MergeGroup(mpop->ptr.data, op->properties, false); -#endif - - WM_operator_free_all_after(wm, op); - ED_undo_pop_op(C, op); - } - - /* XXX temporary workaround for modal manipulator operator - * conflicting with modal operator attached to manipulator */ - if (mpop->type->modal) { - /* activate highlighted manipulator */ - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); - if (r_is_modal) { - *r_is_modal = true; - } - } - else { - /* Allow for 'button' manipulators, single click to run an action. */ - WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); - } - return true; - } - else { - return false; - } -} - -static void manipulator_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal) -{ - ManipulatorTweakData *mtweak = op->customdata; - if (mtweak->mpr_modal->type->exit) { - mtweak->mpr_modal->type->exit(C, mtweak->mpr_modal, cancel); - } - if (clear_modal) { - /* The manipulator may have been removed. */ - if ((BLI_findindex(&mtweak->mmap->groups, mtweak->mgroup) != -1) && - (BLI_findindex(&mtweak->mgroup->manipulators, mtweak->mpr_modal) != -1)) - { - wm_manipulatormap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false); - } - } - MEM_freeN(mtweak); -} - -static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) -{ - ManipulatorTweakData *mtweak = op->customdata; - wmManipulator *mpr = mtweak->mpr_modal; - int retval = OPERATOR_PASS_THROUGH; - bool clear_modal = true; - - if (mpr == NULL) { - BLI_assert(0); - return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); - } - -#ifdef USE_DRAG_DETECT - wmManipulatorMap *mmap = mtweak->mmap; - if (mtweak->drag_state == DRAG_DETECT) { - if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { - if (len_manhattan_v2v2_int(&event->x, mmap->mmap_context.event_xy) > 2) { - mtweak->drag_state = DRAG_IDLE; - mpr->highlight_part = mpr->drag_part; - } - } - else if (event->type == mtweak->init_event && event->val == KM_RELEASE) { - mtweak->drag_state = DRAG_NOP; - retval = OPERATOR_FINISHED; - } - - if (mtweak->drag_state != DRAG_DETECT) { - /* Follow logic in 'manipulator_tweak_invoke' */ - bool is_modal = false; - if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, &is_modal)) { - if (is_modal) { - clear_modal = false; - } - } - else { - if (!manipulator_tweak_start(C, mmap, mpr, event)) { - retval = OPERATOR_FINISHED; - } - } - } - } - if (mtweak->drag_state == DRAG_IDLE) { - if (mmap->mmap_context.modal != NULL) { - return OPERATOR_PASS_THROUGH; - } - else { - manipulator_tweak_finish(C, op, false, false); - return OPERATOR_FINISHED; - } - } -#endif /* USE_DRAG_DETECT */ - - if (retval == OPERATOR_FINISHED) { - /* pass */ - } - else if (event->type == mtweak->init_event && event->val == KM_RELEASE) { - retval = OPERATOR_FINISHED; - } - else if (event->type == EVT_MODAL_MAP) { - switch (event->val) { - case TWEAK_MODAL_CANCEL: - retval = OPERATOR_CANCELLED; - break; - case TWEAK_MODAL_CONFIRM: - retval = OPERATOR_FINISHED; - break; - case TWEAK_MODAL_PRECISION_ON: - mtweak->flag |= WM_MANIPULATOR_TWEAK_PRECISE; - break; - case TWEAK_MODAL_PRECISION_OFF: - mtweak->flag &= ~WM_MANIPULATOR_TWEAK_PRECISE; - break; - - case TWEAK_MODAL_SNAP_ON: - mtweak->flag |= WM_MANIPULATOR_TWEAK_SNAP; - break; - case TWEAK_MODAL_SNAP_OFF: - mtweak->flag &= ~WM_MANIPULATOR_TWEAK_SNAP; - break; - } - } - - if (retval != OPERATOR_PASS_THROUGH) { - manipulator_tweak_finish(C, op, retval != OPERATOR_FINISHED, clear_modal); - return retval; - } - - /* handle manipulator */ - wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; - if (modal_fn) { - int modal_retval = modal_fn(C, mpr, event, mtweak->flag); - - if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) { - manipulator_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true); - return OPERATOR_FINISHED; - } - - /* Ugly hack to send manipulator events */ - ((wmEvent *)event)->type = EVT_MANIPULATOR_UPDATE; - } - - /* always return PASS_THROUGH so modal handlers - * with manipulators attached can update */ - BLI_assert(retval == OPERATOR_PASS_THROUGH); - return OPERATOR_PASS_THROUGH; -} - -static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) -{ - ARegion *ar = CTX_wm_region(C); - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulator *mpr = mmap->mmap_context.highlight; - - /* Needed for single click actions which don't enter modal state. */ - WM_tooltip_clear(C, CTX_wm_window(C)); - - if (!mpr) { - /* wm_handlers_do_intern shouldn't let this happen */ - BLI_assert(0); - return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); - } - - bool use_drag_fallback = false; - -#ifdef USE_DRAG_DETECT - use_drag_fallback = !ELEM(mpr->drag_part, -1, mpr->highlight_part); -#endif - - if (use_drag_fallback == false) { - if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, NULL)) { - return OPERATOR_FINISHED; - } - } - - bool use_drag_detect = false; -#ifdef USE_DRAG_DETECT - if (use_drag_fallback) { - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); - if (mpop && mpop->type) { - if (mpop->type->modal == NULL) { - use_drag_detect = true; - } - } - } -#endif - - if (use_drag_detect == false) { - if (!manipulator_tweak_start(C, mmap, mpr, event)) { - /* failed to start */ - return OPERATOR_PASS_THROUGH; - } - } - - ManipulatorTweakData *mtweak = MEM_mallocN(sizeof(ManipulatorTweakData), __func__); - - mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type); - mtweak->mpr_modal = mmap->mmap_context.highlight; - mtweak->mgroup = mtweak->mpr_modal->parent_mgroup; - mtweak->mmap = mmap; - mtweak->flag = 0; - -#ifdef USE_DRAG_DETECT - mtweak->drag_state = use_drag_detect ? DRAG_DETECT : DRAG_NOP; -#endif - - op->customdata = mtweak; - - WM_event_add_modal_handler(C, op); - - return OPERATOR_RUNNING_MODAL; -} - -void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Gizmo Tweak"; - ot->description = "Tweak the active gizmo"; - ot->idname = "MANIPULATORGROUP_OT_manipulator_tweak"; - - /* api callbacks */ - ot->invoke = manipulator_tweak_invoke; - ot->modal = manipulator_tweak_modal; - - /* TODO(campbell) This causes problems tweaking settings for operators, - * need to find a way to support this. */ -#if 0 - ot->flag = OPTYPE_UNDO; -#endif -} - -/** \} */ - - -static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname) -{ - wmKeyMap *keymap; - char name[KMAP_MAX_NAME]; - - static EnumPropertyItem modal_items[] = { - {TWEAK_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, - {TWEAK_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {TWEAK_MODAL_PRECISION_ON, "PRECISION_ON", 0, "Enable Precision", ""}, - {TWEAK_MODAL_PRECISION_OFF, "PRECISION_OFF", 0, "Disable Precision", ""}, - {TWEAK_MODAL_SNAP_ON, "SNAP_ON", 0, "Enable Snap", ""}, - {TWEAK_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Disable Snap", ""}, - {0, NULL, 0, NULL, NULL} - }; - - - BLI_snprintf(name, sizeof(name), "%s Tweak Modal Map", mgroupname); - keymap = WM_modalkeymap_get(keyconf, name); - - /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) - return NULL; - - keymap = WM_modalkeymap_add(keyconf, name, modal_items); - - - /* items for modal map */ - WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL); - WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL); - - WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM); - WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM); - - WM_modalkeymap_add_item(keymap, RIGHTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON); - WM_modalkeymap_add_item(keymap, RIGHTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF); - WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON); - WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF); - - WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON); - WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF); - WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON); - WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF); - - WM_modalkeymap_assign(keymap, "MANIPULATORGROUP_OT_manipulator_tweak"); - - return keymap; -} - -/** - * Common default keymap for manipulator groups - */ -wmKeyMap *WM_manipulatorgroup_keymap_common( - const wmManipulatorGroupType *wgt, wmKeyConfig *config) -{ - /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ - wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); - - WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0); - manipulatorgroup_tweak_modal_keymap(config, wgt->name); - - return km; -} - -/** - * Variation of #WM_manipulatorgroup_keymap_common but with keymap items for selection - */ -wmKeyMap *WM_manipulatorgroup_keymap_common_select( - const wmManipulatorGroupType *wgt, wmKeyConfig *config) -{ - /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ - wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); - - WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); - WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", EVT_TWEAK_S, KM_ANY, 0, 0); - manipulatorgroup_tweak_modal_keymap(config, wgt->name); - - wmKeyMapItem *kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", false); - RNA_boolean_set(kmi->ptr, "deselect", false); - RNA_boolean_set(kmi->ptr, "toggle", false); - kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", false); - RNA_boolean_set(kmi->ptr, "deselect", false); - RNA_boolean_set(kmi->ptr, "toggle", true); - - return km; -} - -/** \} */ /* wmManipulatorGroup */ - -/* -------------------------------------------------------------------- */ -/** \name wmManipulatorGroupType - * - * \{ */ - -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( - struct wmManipulatorMapType *mmap_type, - const wmManipulatorGroupType *wgt) -{ - /* could use hash lookups as operator types do, for now simple search. */ - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; - wgt_ref; - wgt_ref = wgt_ref->next) - { - if (wgt_ref->type == wgt) { - return wgt_ref; - } - } - return NULL; -} - -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( - struct wmManipulatorMapType *mmap_type, - const char *idname) -{ - /* could use hash lookups as operator types do, for now simple search. */ - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; - wgt_ref; - wgt_ref = wgt_ref->next) - { - if (STREQ(idname, wgt_ref->type->idname)) { - return wgt_ref; - } - } - return NULL; -} - -/** - * Use this for registering manipulators on startup. For runtime, use #WM_manipulatormaptype_group_link_runtime. - */ -wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( - wmManipulatorMapType *mmap_type, const char *idname) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); - BLI_assert(wgt != NULL); - return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); -} - -wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) -{ - wmManipulatorGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmManipulatorGroupTypeRef), "manipulator-group-ref"); - wgt_ref->type = wgt; - BLI_addtail(&mmap_type->grouptype_refs, wgt_ref); - return wgt_ref; -} - -void WM_manipulatormaptype_group_init_runtime_keymap( - const Main *bmain, - wmManipulatorGroupType *wgt) -{ - /* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */ - wm_manipulatorgrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf); -} - -void WM_manipulatormaptype_group_init_runtime( - const Main *bmain, wmManipulatorMapType *mmap_type, - wmManipulatorGroupType *wgt) -{ - /* now create a manipulator for all existing areas */ - for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmManipulatorMap *mmap = ar->manipulator_map; - if (mmap && mmap->type == mmap_type) { - wm_manipulatorgroup_new_from_type(mmap, wgt); - - /* just add here, drawing will occur on next update */ - wm_manipulatormap_highlight_set(mmap, NULL, NULL, 0); - ED_region_tag_redraw(ar); - } - } - } - } - } -} - - -/** - * Unlike #WM_manipulatormaptype_group_unlink this doesn't maintain correct state, simply free. - */ -void WM_manipulatormaptype_group_free(wmManipulatorGroupTypeRef *wgt_ref) -{ - MEM_freeN(wgt_ref); -} - -void WM_manipulatormaptype_group_unlink( - bContext *C, Main *bmain, wmManipulatorMapType *mmap_type, - const wmManipulatorGroupType *wgt) -{ - /* Free instances. */ - for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmManipulatorMap *mmap = ar->manipulator_map; - if (mmap && mmap->type == mmap_type) { - wmManipulatorGroup *mgroup, *mgroup_next; - for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup_next) { - mgroup_next = mgroup->next; - if (mgroup->type == wgt) { - BLI_assert(mgroup->parent_mmap == mmap); - wm_manipulatorgroup_free(C, mgroup); - ED_region_tag_redraw(ar); - } - } - } - } - } - } - } - - /* Free types. */ - wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); - if (wgt_ref) { - BLI_remlink(&mmap_type->grouptype_refs, wgt_ref); - WM_manipulatormaptype_group_free(wgt_ref); - } - - /* Note, we may want to keep this keymap for editing */ - WM_keymap_remove(wgt->keyconf, wgt->keymap); - - BLI_assert(WM_manipulatormaptype_group_find_ptr(mmap_type, wgt) == NULL); -} - -void wm_manipulatorgrouptype_setup_keymap( - wmManipulatorGroupType *wgt, wmKeyConfig *keyconf) -{ - /* Use flag since setup_keymap may return NULL, - * in that case we better not keep calling it. */ - if (wgt->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) { - wgt->keymap = wgt->setup_keymap(wgt, keyconf); - wgt->keyconf = keyconf; - wgt->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT; - } -} - -/** \} */ /* wmManipulatorGroupType */ - -/* -------------------------------------------------------------------- */ -/** \name High Level Add/Remove API - * - * For use directly from operators & RNA registration. - * - * \note In context of manipulator API these names are a bit misleading, - * but for general use terms its OK. - * `WM_manipulator_group_type_add` would be more correctly called: - * `WM_manipulatormaptype_grouptype_reference_link` - * but for general purpose API this is too detailed & annoying. - * - * \note We may want to return a value if there is nothing to remove. - * - * \{ */ - -void WM_manipulator_group_type_add_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) -{ - WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); - - WM_manipulatorconfig_update_tag_init(mmap_type, wgt); -} -void WM_manipulator_group_type_add_ptr( - wmManipulatorGroupType *wgt) -{ - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); -} -void WM_manipulator_group_type_add(const char *idname) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); - BLI_assert(wgt != NULL); - WM_manipulator_group_type_add_ptr(wgt); -} - -void WM_manipulator_group_type_ensure_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) -{ - wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); - if (wgt_ref == NULL) { - WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); - } -} -void WM_manipulator_group_type_ensure_ptr( - wmManipulatorGroupType *wgt) -{ - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_ensure_ptr_ex(wgt, mmap_type); -} -void WM_manipulator_group_type_ensure(const char *idname) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); - BLI_assert(wgt != NULL); - WM_manipulator_group_type_ensure_ptr(wgt); -} - -void WM_manipulator_group_type_remove_ptr_ex( - struct Main *bmain, wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) -{ - WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt); - WM_manipulatorgrouptype_free_ptr(wgt); -} -void WM_manipulator_group_type_remove_ptr( - struct Main *bmain, wmManipulatorGroupType *wgt) -{ - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_remove_ptr_ex(bmain, wgt, mmap_type); -} -void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); - BLI_assert(wgt != NULL); - WM_manipulator_group_type_remove_ptr(bmain, wgt); -} - -/* delayed versions */ - -void WM_manipulator_group_type_unlink_delayed_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) -{ - WM_manipulatorconfig_update_tag_remove(mmap_type, wgt); -} - -void WM_manipulator_group_type_unlink_delayed_ptr( - wmManipulatorGroupType *wgt) -{ - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_unlink_delayed_ptr_ex(wgt, mmap_type); -} - -void WM_manipulator_group_type_unlink_delayed(const char *idname) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); - BLI_assert(wgt != NULL); - WM_manipulator_group_type_unlink_delayed_ptr(wgt); -} - -/** \} */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c deleted file mode 100644 index b32eb84e289..00000000000 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/intern/wm_manipulator_group_type.c - * \ingroup wm - */ - -#include "BLI_utildefines.h" -#include "BLI_ghash.h" -#include "BLI_string.h" -#include "BLI_string_utils.h" - -#include "BKE_context.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" - -/* only for own init/exit calls (wm_manipulatorgrouptype_init/wm_manipulatorgrouptype_free) */ -#include "wm.h" - -/* own includes */ -#include "wm_manipulator_wmapi.h" -#include "wm_manipulator_intern.h" - - -/** \name ManipulatorGroup Type Append - * - * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. - * \{ */ - -static GHash *global_manipulatorgrouptype_hash = NULL; - -wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet) -{ - if (idname[0]) { - wmManipulatorGroupType *wgt; - - wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); - if (wgt) { - return wgt; - } - - if (!quiet) { - printf("search for unknown manipulator group '%s'\n", idname); - } - } - else { - if (!quiet) { - printf("search for empty manipulator group\n"); - } - } - - return NULL; -} - -/* caller must free */ -void WM_manipulatorgrouptype_iter(GHashIterator *ghi) -{ - BLI_ghashIterator_init(ghi, global_manipulatorgrouptype_hash); -} - -static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void) -{ - wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulatorgrouptype"); - - return wgt; -} -static void wm_manipulatorgrouptype_append__end(wmManipulatorGroupType *wgt) -{ - BLI_assert(wgt->name != NULL); - BLI_assert(wgt->idname != NULL); - - wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_KEYMAP_INIT; - - /* if not set, use default */ - if (wgt->setup_keymap == NULL) { - if (wgt->flag & WM_MANIPULATORGROUPTYPE_SELECT) { - wgt->setup_keymap = WM_manipulatorgroup_keymap_common_select; - } - else { - wgt->setup_keymap = WM_manipulatorgroup_keymap_common; - } - } - - BLI_ghash_insert(global_manipulatorgrouptype_hash, (void *)wgt->idname, wgt); -} - -wmManipulatorGroupType *WM_manipulatorgrouptype_append( - void (*wtfunc)(struct wmManipulatorGroupType *)) -{ - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); - wtfunc(wgt); - wm_manipulatorgrouptype_append__end(wgt); - return wgt; -} - -wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr( - void (*wtfunc)(struct wmManipulatorGroupType *, void *), void *userdata) -{ - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); - wtfunc(wgt, userdata); - wm_manipulatorgrouptype_append__end(wgt); - return wgt; -} - -/** - * Append and insert into a manipulator typemap. - * This is most common for C manipulators which are enabled by default. - */ -wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( - wmManipulatorMapType *mmap_type, - void (*wtfunc)(struct wmManipulatorGroupType *)) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(wtfunc); - - wgt->mmap_params.spaceid = mmap_type->spaceid; - wgt->mmap_params.regionid = mmap_type->regionid; - - return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); -} - -/** - * Free but don't remove from ghash. - */ -static void manipulatorgrouptype_free(wmManipulatorGroupType *wgt) -{ - if (wgt->ext.srna) { /* python manipulator group, allocs own string */ - MEM_freeN((void *)wgt->idname); - } - - MEM_freeN(wgt); -} - -void WM_manipulatorgrouptype_free_ptr(wmManipulatorGroupType *wgt) -{ - BLI_assert(wgt == WM_manipulatorgrouptype_find(wgt->idname, false)); - - BLI_ghash_remove(global_manipulatorgrouptype_hash, wgt->idname, NULL, NULL); - - manipulatorgrouptype_free(wgt); - - /* XXX, TODO, update the world! */ -} - -bool WM_manipulatorgrouptype_free(const char *idname) -{ - wmManipulatorGroupType *wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); - - if (wgt == NULL) { - return false; - } - - WM_manipulatorgrouptype_free_ptr(wgt); - - return true; -} - -static void wm_manipulatorgrouptype_ghash_free_cb(wmManipulatorGroupType *wgt) -{ - manipulatorgrouptype_free(wgt); -} - -void wm_manipulatorgrouptype_free(void) -{ - BLI_ghash_free(global_manipulatorgrouptype_hash, NULL, (GHashValFreeFP)wm_manipulatorgrouptype_ghash_free_cb); - global_manipulatorgrouptype_hash = NULL; -} - -/* called on initialize WM_init() */ -void wm_manipulatorgrouptype_init(void) -{ - /* reserve size is set based on blender default setup */ - global_manipulatorgrouptype_hash = BLI_ghash_str_new_ex("wm_manipulatorgrouptype_init gh", 128); -} - -/** \} */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h deleted file mode 100644 index ecf4ffd2ac4..00000000000 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/intern/wm_manipulator_intern.h - * \ingroup wm - */ - - -#ifndef __WM_MANIPULATOR_INTERN_H__ -#define __WM_MANIPULATOR_INTERN_H__ - -struct wmKeyConfig; -struct wmManipulatorMap; -struct ManipulatorGeomInfo; -struct GHashIterator; - -#include "wm_manipulator_fn.h" - -/* -------------------------------------------------------------------- */ -/* wmManipulator */ - - -bool wm_manipulator_select_set_ex( - struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select, - bool use_array, bool use_callback); -bool wm_manipulator_select_and_highlight(bContext *C, struct wmManipulatorMap *mmap, struct wmManipulator *mpr); - -void wm_manipulator_calculate_scale(struct wmManipulator *mpr, const bContext *C); -void wm_manipulator_update(struct wmManipulator *mpr, const bContext *C, const bool refresh_map); - -int wm_manipulator_is_visible(struct wmManipulator *mpr); -enum { - WM_MANIPULATOR_IS_VISIBLE_UPDATE = (1 << 0), - WM_MANIPULATOR_IS_VISIBLE_DRAW = (1 << 1), -}; - -/* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ - -enum { - TWEAK_MODAL_CANCEL = 1, - TWEAK_MODAL_CONFIRM, - TWEAK_MODAL_PRECISION_ON, - TWEAK_MODAL_PRECISION_OFF, - TWEAK_MODAL_SNAP_ON, - TWEAK_MODAL_SNAP_OFF, -}; - -struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type( - struct wmManipulatorMap *mmap, struct wmManipulatorGroupType *wgt); -void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorGroup *mgroup); -void wm_manipulatorgroup_manipulator_register(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr); -struct wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( - const struct wmManipulatorGroup *mgroup, struct bContext *C, const struct wmEvent *event, - int *r_part); -void wm_manipulatorgroup_intersectable_manipulators_to_list( - const struct wmManipulatorGroup *mgroup, struct ListBase *listbase); -void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, const struct bContext *C); -bool wm_manipulatorgroup_is_visible_in_drawstep( - const struct wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep); - -void wm_manipulatorgrouptype_setup_keymap( - struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf); - - -/* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ - -typedef struct wmManipulatorMapSelectState { - struct wmManipulator **items; - int len, len_alloc; -} wmManipulatorMapSelectState; - -struct wmManipulatorMap { - - struct wmManipulatorMapType *type; - ListBase groups; /* wmManipulatorGroup */ - - /* private, update tagging (enum defined in C source). */ - char update_flag[WM_MANIPULATORMAP_DRAWSTEP_MAX]; - - /** - * \brief Manipulator map runtime context - * - * Contains information about this manipulator-map. Currently - * highlighted manipulator, currently selected manipulators, ... - */ - struct { - /* we redraw the manipulator-map when this changes */ - struct wmManipulator *highlight; - /* User has clicked this manipulator and it gets all input. */ - struct wmManipulator *modal; - /* array for all selected manipulators */ - struct wmManipulatorMapSelectState select; - /* cursor location at point of entering modal (see: WM_MANIPULATOR_GRAB_CURSOR) */ - int event_xy[2]; - short event_grabcursor; - /* until we have nice cursor push/pop API. */ - int last_cursor; - } mmap_context; -}; - -/** - * This is a container for all manipulator types that can be instantiated in a region. - * (similar to dropboxes). - * - * \note There is only ever one of these for every (area, region) combination. - */ -struct wmManipulatorMapType { - struct wmManipulatorMapType *next, *prev; - short spaceid, regionid; - /* types of manipulator-groups for this manipulator-map type */ - ListBase grouptype_refs; - - /* eManipulatorMapTypeUpdateFlags */ - eWM_ManipulatorMapTypeUpdateFlag type_update_flag; -}; - -void wm_manipulatormap_select_array_clear(struct wmManipulatorMap *mmap); -bool wm_manipulatormap_deselect_all(struct wmManipulatorMap *mmap); -void wm_manipulatormap_select_array_shrink(struct wmManipulatorMap *mmap, int len_subtract); -void wm_manipulatormap_select_array_push_back(struct wmManipulatorMap *mmap, wmManipulator *mpr); -void wm_manipulatormap_select_array_remove(struct wmManipulatorMap *mmap, wmManipulator *mpr); - -#endif diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c deleted file mode 100644 index 2a3aa5df197..00000000000 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c +++ /dev/null @@ -1,1209 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/intern/wm_manipulator_map.c - * \ingroup wm - */ - -#include - -#include "BLI_listbase.h" -#include "BLI_math.h" -#include "BLI_rect.h" -#include "BLI_string.h" -#include "BLI_ghash.h" - -#include "BKE_context.h" -#include "BKE_global.h" - -#include "ED_screen.h" -#include "ED_view3d.h" - -#include "GPU_glew.h" -#include "GPU_matrix.h" -#include "GPU_select.h" - -#include "MEM_guardedalloc.h" - -#include "WM_api.h" -#include "WM_types.h" -#include "wm_event_system.h" - -/* for tool-tips */ -#include "UI_interface.h" - -#include "DEG_depsgraph.h" - -/* own includes */ -#include "wm_manipulator_wmapi.h" -#include "wm_manipulator_intern.h" - -/** - * Store all manipulator-maps here. Anyone who wants to register a manipulator for a certain - * area type can query the manipulator-map to do so. - */ -static ListBase manipulatormaptypes = {NULL, NULL}; - -/** - * Update when manipulator-map types change. - */ -/* so operator removal can trigger update */ -typedef enum eWM_ManipulatorGroupTypeGlobalFlag { - WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0), - WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1), -} eWM_ManipulatorGroupTypeGlobalFlag; - -static eWM_ManipulatorGroupTypeGlobalFlag wm_mmap_type_update_flag = 0; - -/** - * Manipulator-map update tagging. - */ -enum { - /** #manipulatormap_prepare_drawing has run */ - MANIPULATORMAP_IS_PREPARE_DRAW = (1 << 0), - MANIPULATORMAP_IS_REFRESH_CALLBACK = (1 << 1), -}; - - -/* -------------------------------------------------------------------- */ -/** \name wmManipulatorMap Selection Array API - * - * Just handle ``wm_manipulatormap_select_array_*``, not flags or callbacks. - * - * \{ */ - -static void wm_manipulatormap_select_array_ensure_len_alloc(wmManipulatorMap *mmap, int len) -{ - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - if (len <= msel->len_alloc) { - return; - } - msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * len); - msel->len_alloc = len; -} - -void wm_manipulatormap_select_array_clear(wmManipulatorMap *mmap) -{ - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - MEM_SAFE_FREE(msel->items); - msel->len = 0; - msel->len_alloc = 0; -} - -void wm_manipulatormap_select_array_shrink(wmManipulatorMap *mmap, int len_subtract) -{ - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - msel->len -= len_subtract; - if (msel->len <= 0) { - wm_manipulatormap_select_array_clear(mmap); - } - else { - if (msel->len < msel->len_alloc / 2) { - msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len); - msel->len_alloc = msel->len; - } - } -} - -void wm_manipulatormap_select_array_push_back(wmManipulatorMap *mmap, wmManipulator *mpr) -{ - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - BLI_assert(msel->len <= msel->len_alloc); - if (msel->len == msel->len_alloc) { - msel->len_alloc = (msel->len + 1) * 2; - msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len_alloc); - } - msel->items[msel->len++] = mpr; -} - -void wm_manipulatormap_select_array_remove(wmManipulatorMap *mmap, wmManipulator *mpr) -{ - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - /* remove manipulator from selected_manipulators array */ - for (int i = 0; i < msel->len; i++) { - if (msel->items[i] == mpr) { - for (int j = i; j < (msel->len - 1); j++) { - msel->items[j] = msel->items[j + 1]; - } - wm_manipulatormap_select_array_shrink(mmap, 1); - break; - } - } - -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ -/** \name wmManipulatorMap - * - * \{ */ - -/** - * Creates a manipulator-map with all registered manipulators for that type - */ -wmManipulatorMap *WM_manipulatormap_new_from_type( - const struct wmManipulatorMapType_Params *mmap_params) -{ - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(mmap_params); - wmManipulatorMap *mmap; - - mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap"); - mmap->type = mmap_type; - WM_manipulatormap_tag_refresh(mmap); - - /* create all manipulator-groups for this manipulator-map. We may create an empty one - * too in anticipation of manipulators from operators etc */ - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { - wm_manipulatorgroup_new_from_type(mmap, wgt_ref->type); - } - - return mmap; -} - -void wm_manipulatormap_remove(wmManipulatorMap *mmap) -{ - /* Clear first so further calls don't waste time trying to maintain correct array state. */ - wm_manipulatormap_select_array_clear(mmap); - - for (wmManipulatorGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) { - mgroup_next = mgroup->next; - BLI_assert(mgroup->parent_mmap == mmap); - wm_manipulatorgroup_free(NULL, mgroup); - } - BLI_assert(BLI_listbase_is_empty(&mmap->groups)); - - MEM_freeN(mmap); -} - - -wmManipulatorGroup *WM_manipulatormap_group_find( - struct wmManipulatorMap *mmap, - const char *idname) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); - if (wgt) { - return WM_manipulatormap_group_find_ptr(mmap, wgt); - } - return NULL; -} - -wmManipulatorGroup *WM_manipulatormap_group_find_ptr( - struct wmManipulatorMap *mmap, - const struct wmManipulatorGroupType *wgt) -{ - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (mgroup->type == wgt) { - return mgroup; - } - } - return NULL; -} - -const ListBase *WM_manipulatormap_group_list(wmManipulatorMap *mmap) -{ - return &mmap->groups; -} - -bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap) -{ - return mmap->mmap_context.select.len != 0; -} - -/** - * \note We could use a callback to define bounds, for now just use matrix location. - */ -bool WM_manipulatormap_minmax( - const wmManipulatorMap *mmap, bool UNUSED(use_hidden), bool use_select, - float r_min[3], float r_max[3]) -{ - if (use_select) { - int i; - for (i = 0; i < mmap->mmap_context.select.len; i++) { - minmax_v3v3_v3(r_min, r_max, mmap->mmap_context.select.items[i]->matrix_basis[3]); - } - return i != 0; - } - else { - bool ok = false; - BLI_assert(!"TODO"); - return ok; - } -} - -/** - * Creates and returns idname hash table for (visible) manipulators in \a mmap - * - * \param poll Polling function for excluding manipulators. - * \param data Custom data passed to \a poll - * - * TODO(campbell): this uses unreliable order, - * best we use an iterator function instead of a hash. - */ -static GHash *WM_manipulatormap_manipulator_hash_new( - const bContext *C, wmManipulatorMap *mmap, - bool (*poll)(const wmManipulator *, void *), - void *data, const bool include_hidden) -{ - GHash *hash = BLI_ghash_ptr_new(__func__); - - /* collect manipulators */ - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (WM_manipulator_group_type_poll(C, mgroup->type)) { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) && - (!poll || poll(mpr, data))) - { - BLI_ghash_insert(hash, mpr, mpr); - } - } - } - } - - return hash; -} - -void WM_manipulatormap_tag_refresh(wmManipulatorMap *mmap) -{ - if (mmap) { - /* We might want only to refresh some, for tag all steps. */ - for (int i = 0; i < WM_MANIPULATORMAP_DRAWSTEP_MAX; i++) { - mmap->update_flag[i] |= ( - MANIPULATORMAP_IS_PREPARE_DRAW | - MANIPULATORMAP_IS_REFRESH_CALLBACK); - } - } -} - -static bool manipulator_prepare_drawing( - wmManipulatorMap *mmap, wmManipulator *mpr, - const bContext *C, ListBase *draw_manipulators, - const eWM_ManipulatorMapDrawStep drawstep) -{ - int do_draw = wm_manipulator_is_visible(mpr); - if (do_draw == 0) { - /* skip */ - } - else { - /* Ensure we get RNA updates */ - if (do_draw & WM_MANIPULATOR_IS_VISIBLE_UPDATE) { - /* hover manipulators need updating, even if we don't draw them */ - wm_manipulator_update(mpr, C, (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_PREPARE_DRAW) != 0); - } - if (do_draw & WM_MANIPULATOR_IS_VISIBLE_DRAW) { - BLI_addhead(draw_manipulators, BLI_genericNodeN(mpr)); - } - return true; - } - - return false; -} - -/** - * Update manipulators of \a mmap to prepare for drawing. Adds all manipulators that - * should be drawn to list \a draw_manipulators, note that added items need freeing. - */ -static void manipulatormap_prepare_drawing( - wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators, - const eWM_ManipulatorMapDrawStep drawstep) -{ - if (!mmap || BLI_listbase_is_empty(&mmap->groups)) - return; - wmManipulator *mpr_modal = mmap->mmap_context.modal; - - /* only active manipulator needs updating */ - if (mpr_modal) { - if ((mpr_modal->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL) == 0) { - if (wm_manipulatorgroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) { - if (manipulator_prepare_drawing(mmap, mpr_modal, C, draw_manipulators, drawstep)) { - mmap->update_flag[drawstep] &= ~MANIPULATORMAP_IS_PREPARE_DRAW; - } - } - /* don't draw any other manipulators */ - return; - } - } - - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */ - if (!wm_manipulatorgroup_is_visible_in_drawstep(mgroup, drawstep) || - !WM_manipulator_group_type_poll(C, mgroup->type)) - { - continue; - } - - /* needs to be initialized on first draw */ - /* XXX weak: Manipulator-group may skip refreshing if it's invisible (map gets untagged nevertheless) */ - if (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_REFRESH_CALLBACK) { - /* force refresh again. */ - mgroup->init_flag &= ~WM_MANIPULATORGROUP_INIT_REFRESH; - } - /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */ - wm_manipulatorgroup_ensure_initialized(mgroup, C); - - /* prepare drawing */ - if (mgroup->type->draw_prepare) { - mgroup->type->draw_prepare(C, mgroup); - } - - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - manipulator_prepare_drawing(mmap, mpr, C, draw_manipulators, drawstep); - } - } - - mmap->update_flag[drawstep] &= - ~(MANIPULATORMAP_IS_REFRESH_CALLBACK | - MANIPULATORMAP_IS_PREPARE_DRAW); -} - -/** - * Draw all visible manipulators in \a mmap. - * Uses global draw_manipulators listbase. - */ -static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators) -{ - /* Can be empty if we're dynamically added and removed. */ - if ((mmap == NULL) || BLI_listbase_is_empty(&mmap->groups)) { - return; - } - - /* TODO this will need it own shader probably? don't think it can be handled from that point though. */ -/* const bool use_lighting = (U.manipulator_flag & V3D_MANIPULATOR_SHADED) != 0; */ - - bool is_depth_prev = false; - - /* draw_manipulators contains all visible manipulators - draw them */ - for (LinkData *link = draw_manipulators->first, *link_next; link; link = link_next) { - wmManipulator *mpr = link->data; - link_next = link->next; - - bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0; - - /* Weak! since we don't 100% support depth yet (select ignores depth) always show highlighted */ - if (is_depth && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)) { - is_depth = false; - } - - if (is_depth == is_depth_prev) { - /* pass */ - } - else { - if (is_depth) { - glEnable(GL_DEPTH_TEST); - } - else { - glDisable(GL_DEPTH_TEST); - } - is_depth_prev = is_depth; - } - - /* XXX force AntiAlias Manipulators. */ - glEnable(GL_LINE_SMOOTH); - glEnable(GL_POLYGON_SMOOTH); - - mpr->type->draw(C, mpr); - - glDisable(GL_LINE_SMOOTH); - glDisable(GL_POLYGON_SMOOTH); - - /* free/remove manipulator link after drawing */ - BLI_freelinkN(draw_manipulators, link); - } - - if (is_depth_prev) { - glDisable(GL_DEPTH_TEST); - } -} - -void WM_manipulatormap_draw( - wmManipulatorMap *mmap, const bContext *C, - const eWM_ManipulatorMapDrawStep drawstep) -{ - if (!WM_manipulator_context_check_drawstep(C, drawstep)) { - return; - } - - ListBase draw_manipulators = {NULL}; - - manipulatormap_prepare_drawing(mmap, C, &draw_manipulators, drawstep); - manipulators_draw_list(mmap, C, &draw_manipulators); - BLI_assert(BLI_listbase_is_empty(&draw_manipulators)); -} - -static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible_manipulators) -{ - int select_id = 0; - wmManipulator *mpr; - - /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */ - bool is_depth_prev = false; - bool is_depth_skip_prev = false; - - for (LinkData *link = visible_manipulators->first; link; link = link->next) { - mpr = link->data; - - bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0; - if (is_depth == is_depth_prev) { - /* pass */ - } - else { - if (is_depth) { - glEnable(GL_DEPTH_TEST); - } - else { - glDisable(GL_DEPTH_TEST); - } - is_depth_prev = is_depth; - } - bool is_depth_skip = (mpr->flag & WM_MANIPULATOR_SELECT_BACKGROUND) != 0; - if (is_depth_skip == is_depth_skip_prev) { - /* pass */ - } - else { - glDepthMask(!is_depth_skip); - is_depth_skip_prev = is_depth_skip; - } - - /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected manipulator part id */ - - mpr->type->draw_select(C, mpr, select_id << 8); - - - select_id++; - } - - if (is_depth_prev) { - glDisable(GL_DEPTH_TEST); - } - if (is_depth_skip_prev) { - glDepthMask(true); - } -} - -static int manipulator_find_intersected_3d_intern( - ListBase *visible_manipulators, const bContext *C, const int co[2], - const int hotspot) -{ - ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); - View3D *v3d = sa->spacedata.first; - rcti rect; - /* Almost certainly overkill, but allow for many custom manipulators. */ - GLuint buffer[MAXPICKBUF]; - short hits; - const bool do_passes = GPU_select_query_check_active(); - - BLI_rcti_init_pt_radius(&rect, co, hotspot); - - ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, &rect); - - if (do_passes) - GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); - else - GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_ALL, 0); - /* do the drawing */ - manipulator_draw_select_3D_loop(C, visible_manipulators); - - hits = GPU_select_end(); - - if (do_passes && (hits > 0)) { - GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); - manipulator_draw_select_3D_loop(C, visible_manipulators); - GPU_select_end(); - } - - ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, NULL); - - const GLuint *hit_near = GPU_select_buffer_near(buffer, hits); - - return hit_near ? hit_near[3] : -1; -} - -/** - * Try to find a 3D manipulator at screen-space coordinate \a co. Uses OpenGL picking. - */ -static wmManipulator *manipulator_find_intersected_3d( - bContext *C, const int co[2], ListBase *visible_manipulators, - int *r_part) -{ - wmManipulator *result = NULL; - int hit = -1; - - int hotspot_radii[] = { - 3 * U.pixelsize, - /* This runs on mouse move, careful doing too many tests! */ - 10 * U.pixelsize, - }; - - *r_part = 0; - - /* set up view matrices */ - view3d_operator_needs_opengl(C); - - hit = -1; - - for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) { - hit = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, hotspot_radii[i]); - if (hit != -1) { - break; - } - } - - if (hit != -1) { - LinkData *link = BLI_findlink(visible_manipulators, hit >> 8); - if (link != NULL) { - *r_part = hit & 255; - result = link->data; - } - else { - /* All manipulators should use selection ID they're given as part of the callback, - * if they don't it will attempt tp lookup non-existing index. */ - BLI_assert(0); - } - } - - return result; -} - -/** - * Try to find a manipulator under the mouse position. 2D intersections have priority over - * 3D ones (could check for smallest screen-space distance but not needed right now). - */ -wmManipulator *wm_manipulatormap_highlight_find( - wmManipulatorMap *mmap, bContext *C, const wmEvent *event, - int *r_part) -{ - wmManipulator *mpr = NULL; - ListBase visible_3d_manipulators = {NULL}; - bool do_step[WM_MANIPULATORMAP_DRAWSTEP_MAX]; - - for (int i = 0; i < ARRAY_SIZE(do_step); i++) { - do_step[i] = WM_manipulator_context_check_drawstep(C, i); - } - - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - - /* If it were important we could initialize here, - * but this only happens when events are handled before drawing, - * just skip to keep code-path for initializing manipulators simple. */ - if ((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0) { - continue; - } - - if (WM_manipulator_group_type_poll(C, mgroup->type)) { - eWM_ManipulatorMapDrawStep step; - if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - step = WM_MANIPULATORMAP_DRAWSTEP_3D; - } - else { - step = WM_MANIPULATORMAP_DRAWSTEP_2D; - } - - if (do_step[step]) { - if ((mmap->update_flag[step] & MANIPULATORMAP_IS_REFRESH_CALLBACK) && - (mgroup->type->refresh != NULL)) - { - mgroup->type->refresh(C, mgroup); - /* cleared below */ - } - if (step == WM_MANIPULATORMAP_DRAWSTEP_3D) { - wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators); - } - else if (step == WM_MANIPULATORMAP_DRAWSTEP_2D) { - if ((mpr = wm_manipulatorgroup_find_intersected_manipulator(mgroup, C, event, r_part))) { - break; - } - } - } - } - } - - if (!BLI_listbase_is_empty(&visible_3d_manipulators)) { - /* 2D manipulators get priority. */ - if (mpr == NULL) { - mpr = manipulator_find_intersected_3d(C, event->mval, &visible_3d_manipulators, r_part); - } - BLI_freelistN(&visible_3d_manipulators); - } - - mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_3D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK; - mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_2D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK; - - return mpr; -} - -void WM_manipulatormap_add_handlers(ARegion *ar, wmManipulatorMap *mmap) -{ - wmEventHandler *handler; - - for (handler = ar->handlers.first; handler; handler = handler->next) { - if (handler->manipulator_map == mmap) { - return; - } - } - - handler = MEM_callocN(sizeof(wmEventHandler), "manipulator handler"); - - BLI_assert(mmap == ar->manipulator_map); - handler->manipulator_map = mmap; - BLI_addtail(&ar->handlers, handler); -} - -void wm_manipulatormaps_handled_modal_update( - bContext *C, wmEvent *event, wmEventHandler *handler) -{ - const bool modal_running = (handler->op != NULL); - - /* happens on render or when joining areas */ - if (!handler->op_region || !handler->op_region->manipulator_map) { - return; - } - - wmManipulatorMap *mmap = handler->op_region->manipulator_map; - wmManipulator *mpr = wm_manipulatormap_modal_get(mmap); - ScrArea *area = CTX_wm_area(C); - ARegion *region = CTX_wm_region(C); - - wm_manipulatormap_handler_context(C, handler); - - /* regular update for running operator */ - if (modal_running) { - wmManipulatorOpElem *mpop = mpr ? WM_manipulator_operator_get(mpr, mpr->highlight_part) : NULL; - if (mpr && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) { - wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; - if (modal_fn != NULL) { - int retval = modal_fn(C, mpr, event, 0); - /* The manipulator is tried to the operator, we can't choose when to exit. */ - BLI_assert(retval & OPERATOR_RUNNING_MODAL); - UNUSED_VARS_NDEBUG(retval); - } - } - } - /* operator not running anymore */ - else { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); - if (mpr) { - /* This isn't defined if it ends because of success of cancel, we may want to change. */ - bool cancel = true; - if (mpr->type->exit) { - mpr->type->exit(C, mpr, cancel); - } - wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false); - } - } - - /* restore the area */ - CTX_wm_area_set(C, area); - CTX_wm_region_set(C, region); -} - -/** - * Deselect all selected manipulators in \a mmap. - * \return if selection has changed. - */ -bool wm_manipulatormap_deselect_all(wmManipulatorMap *mmap) -{ - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - - if (msel->items == NULL || msel->len == 0) { - return false; - } - - for (int i = 0; i < msel->len; i++) { - wm_manipulator_select_set_ex(mmap, msel->items[i], false, false, true); - } - - wm_manipulatormap_select_array_clear(mmap); - - /* always return true, we already checked - * if there's anything to deselect */ - return true; -} - -BLI_INLINE bool manipulator_selectable_poll(const wmManipulator *mpr, void *UNUSED(data)) -{ - return (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT); -} - -/** - * Select all selectable manipulators in \a mmap. - * \return if selection has changed. - */ -static bool wm_manipulatormap_select_all_intern( - bContext *C, wmManipulatorMap *mmap) -{ - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - /* GHash is used here to avoid having to loop over all manipulators twice (once to - * get tot_sel for allocating, once for actually selecting). Instead we collect - * selectable manipulators in hash table and use this to get tot_sel and do selection */ - - GHash *hash = WM_manipulatormap_manipulator_hash_new(C, mmap, manipulator_selectable_poll, NULL, true); - GHashIterator gh_iter; - int i; - bool changed = false; - - wm_manipulatormap_select_array_ensure_len_alloc(mmap, BLI_ghash_len(hash)); - - GHASH_ITER_INDEX (gh_iter, hash, i) { - wmManipulator *mpr_iter = BLI_ghashIterator_getValue(&gh_iter); - WM_manipulator_select_set(mmap, mpr_iter, true); - } - /* highlight first manipulator */ - wm_manipulatormap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part); - - BLI_assert(BLI_ghash_len(hash) == msel->len); - - BLI_ghash_free(hash, NULL, NULL); - return changed; -} - -/** - * Select/Deselect all selectable manipulators in \a mmap. - * \return if selection has changed. - * - * TODO select all by type - */ -bool WM_manipulatormap_select_all(bContext *C, wmManipulatorMap *mmap, const int action) -{ - bool changed = false; - - switch (action) { - case SEL_SELECT: - changed = wm_manipulatormap_select_all_intern(C, mmap); - break; - case SEL_DESELECT: - changed = wm_manipulatormap_deselect_all(mmap); - break; - default: - BLI_assert(0); - break; - } - - if (changed) - WM_event_add_mousemove(C); - - return changed; -} - -/** - * Prepare context for manipulator handling (but only if area/region is - * part of screen). Version of #wm_handler_op_context for manipulators. - */ -void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler) -{ - bScreen *screen = CTX_wm_screen(C); - - if (screen) { - if (handler->op_area == NULL) { - /* do nothing in this context */ - } - else { - ScrArea *sa; - - for (sa = screen->areabase.first; sa; sa = sa->next) - if (sa == handler->op_area) - break; - if (sa == NULL) { - /* when changing screen layouts with running modal handlers (like render display), this - * is not an error to print */ - if (handler->manipulator_map == NULL) - printf("internal error: modal manipulator-map handler has invalid area\n"); - } - else { - ARegion *ar; - CTX_wm_area_set(C, sa); - for (ar = sa->regionbase.first; ar; ar = ar->next) - if (ar == handler->op_region) - break; - /* XXX no warning print here, after full-area and back regions are remade */ - if (ar) - CTX_wm_region_set(C, ar); - } - } - } -} - -bool WM_manipulatormap_cursor_set(const wmManipulatorMap *mmap, wmWindow *win) -{ - wmManipulator *mpr = mmap->mmap_context.highlight; - if (mpr && mpr->type->cursor_get) { - WM_cursor_set(win, mpr->type->cursor_get(mpr)); - return true; - } - - return false; -} - -bool wm_manipulatormap_highlight_set( - wmManipulatorMap *mmap, const bContext *C, wmManipulator *mpr, int part) -{ - if ((mpr != mmap->mmap_context.highlight) || - (mpr && part != mpr->highlight_part)) - { - if (mmap->mmap_context.highlight) { - mmap->mmap_context.highlight->state &= ~WM_MANIPULATOR_STATE_HIGHLIGHT; - mmap->mmap_context.highlight->highlight_part = -1; - } - - mmap->mmap_context.highlight = mpr; - - if (mpr) { - mpr->state |= WM_MANIPULATOR_STATE_HIGHLIGHT; - mpr->highlight_part = part; - mmap->mmap_context.last_cursor = -1; - - if (C && mpr->type->cursor_get) { - wmWindow *win = CTX_wm_window(C); - mmap->mmap_context.last_cursor = win->cursor; - WM_cursor_set(win, mpr->type->cursor_get(mpr)); - } - } - else { - if (C && mmap->mmap_context.last_cursor != -1) { - wmWindow *win = CTX_wm_window(C); - WM_cursor_set(win, mmap->mmap_context.last_cursor); - } - } - - /* tag the region for redraw */ - if (C) { - ARegion *ar = CTX_wm_region(C); - ED_region_tag_redraw(ar); - } - - return true; - } - - return false; -} - -wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap) -{ - return mmap->mmap_context.highlight; -} - -/** - * Caller should call exit when (enable == False). - */ -void wm_manipulatormap_modal_set( - wmManipulatorMap *mmap, bContext *C, wmManipulator *mpr, const wmEvent *event, bool enable) -{ - if (enable) { - BLI_assert(mmap->mmap_context.modal == NULL); - wmWindow *win = CTX_wm_window(C); - - WM_tooltip_clear(C, win); - - if (mpr->type->invoke && - (mpr->type->modal || mpr->custom_modal)) - { - const int retval = mpr->type->invoke(C, mpr, event); - if ((retval & OPERATOR_RUNNING_MODAL) == 0) { - return; - } - } - - mpr->state |= WM_MANIPULATOR_STATE_MODAL; - mmap->mmap_context.modal = mpr; - - if ((mpr->flag & WM_MANIPULATOR_GRAB_CURSOR) && - (event->is_motion_absolute == false)) - { - WM_cursor_grab_enable(win, true, true, NULL); - copy_v2_v2_int(mmap->mmap_context.event_xy, &event->x); - mmap->mmap_context.event_grabcursor = win->grabcursor; - } - else { - mmap->mmap_context.event_xy[0] = INT_MAX; - } - - struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); - if (mpop && mpop->type) { - const int retval = WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); - if ((retval & OPERATOR_RUNNING_MODAL) == 0) { - wm_manipulatormap_modal_set(mmap, C, mpr, event, false); - } - - /* we failed to hook the manipulator to the operator handler or operator was cancelled, return */ - if (!mmap->mmap_context.modal) { - mpr->state &= ~WM_MANIPULATOR_STATE_MODAL; - MEM_SAFE_FREE(mpr->interaction_data); - } - return; - } - } - else { - BLI_assert(ELEM(mmap->mmap_context.modal, NULL, mpr)); - - /* deactivate, manipulator but first take care of some stuff */ - if (mpr) { - mpr->state &= ~WM_MANIPULATOR_STATE_MODAL; - MEM_SAFE_FREE(mpr->interaction_data); - } - mmap->mmap_context.modal = NULL; - - if (C) { - wmWindow *win = CTX_wm_window(C); - if (mmap->mmap_context.event_xy[0] != INT_MAX) { - /* Check if some other part of Blender (typically operators) - * have adjusted the grab mode since it was set. - * If so: warp, so we have a predictable outcome. */ - if (mmap->mmap_context.event_grabcursor == win->grabcursor) { - WM_cursor_grab_disable(win, mmap->mmap_context.event_xy); - } - else { - WM_cursor_warp(win, UNPACK2(mmap->mmap_context.event_xy)); - } - } - ED_region_tag_redraw(CTX_wm_region(C)); - WM_event_add_mousemove(C); - } - - mmap->mmap_context.event_xy[0] = INT_MAX; - } -} - -wmManipulator *wm_manipulatormap_modal_get(wmManipulatorMap *mmap) -{ - return mmap->mmap_context.modal; -} - -wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len) -{ - *r_selected_len = mmap->mmap_context.select.len; - return mmap->mmap_context.select.items; -} - -ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap) -{ - return &mmap->groups; -} - -void WM_manipulatormap_message_subscribe( - bContext *C, wmManipulatorMap *mmap, ARegion *ar, struct wmMsgBus *mbus) -{ - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (!WM_manipulator_group_type_poll(C, mgroup->type)) { - continue; - } - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->flag & WM_MANIPULATOR_HIDDEN) { - continue; - } - WM_manipulator_target_property_subscribe_all(mpr, mbus, ar); - } - if (mgroup->type->message_subscribe != NULL) { - mgroup->type->message_subscribe(C, mgroup, mbus); - } - } -} - -/** \} */ /* wmManipulatorMap */ - - -/* -------------------------------------------------------------------- */ -/** \name Tooltip Handling - * - * \{ */ - -struct ARegion *WM_manipulatormap_tooltip_init( - struct bContext *C, struct ARegion *ar, bool *r_exit_on_event) -{ - wmManipulatorMap *mmap = ar->manipulator_map; - *r_exit_on_event = true; - if (mmap) { - wmManipulator *mpr = mmap->mmap_context.highlight; - if (mpr) { - return UI_tooltip_create_from_manipulator(C, mpr); - } - } - return NULL; -} - -/** \} */ /* wmManipulatorMapType */ - -/* -------------------------------------------------------------------- */ -/** \name wmManipulatorMapType - * - * \{ */ - -wmManipulatorMapType *WM_manipulatormaptype_find( - const struct wmManipulatorMapType_Params *mmap_params) -{ - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { - if (mmap_type->spaceid == mmap_params->spaceid && - mmap_type->regionid == mmap_params->regionid) - { - return mmap_type; - } - } - - return NULL; -} - -wmManipulatorMapType *WM_manipulatormaptype_ensure( - const struct wmManipulatorMapType_Params *mmap_params) -{ - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_find(mmap_params); - - if (mmap_type) { - return mmap_type; - } - - mmap_type = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list"); - mmap_type->spaceid = mmap_params->spaceid; - mmap_type->regionid = mmap_params->regionid; - BLI_addhead(&manipulatormaptypes, mmap_type); - - return mmap_type; -} - -void wm_manipulatormaptypes_free(void) -{ - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first, *mmap_type_next; - mmap_type; - mmap_type = mmap_type_next) - { - mmap_type_next = mmap_type->next; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next; - wgt_ref; - wgt_ref = wgt_next) - { - wgt_next = wgt_ref->next; - WM_manipulatormaptype_group_free(wgt_ref); - } - MEM_freeN(mmap_type); - } -} - -/** - * Initialize keymaps for all existing manipulator-groups - */ -void wm_manipulators_keymap(wmKeyConfig *keyconf) -{ - /* we add this item-less keymap once and use it to group manipulator-group keymaps into it */ - WM_keymap_find(keyconf, "Manipulators", 0, 0); - - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { - wm_manipulatorgrouptype_setup_keymap(wgt_ref->type, keyconf); - } - } -} - -/** \} */ /* wmManipulatorMapType */ - -/* -------------------------------------------------------------------- */ -/** \name Updates for Dynamic Type Registraion - * - * \{ */ - - -void WM_manipulatorconfig_update_tag_init( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) -{ - /* tag for update on next use */ - mmap_type->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT); - wgt->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT); - - wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; -} - -void WM_manipulatorconfig_update_tag_remove( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) -{ - /* tag for update on next use */ - mmap_type->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - - wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE; -} - -/** - * Run incase new types have been added (runs often, early exit where possible). - * Follows #WM_keyconfig_update concentions. - */ -void WM_manipulatorconfig_update(struct Main *bmain) -{ - if (G.background) - return; - - if (wm_mmap_type_update_flag == 0) - return; - - if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; - mmap_type; - mmap_type = mmap_type->next) - { - if (mmap_type->type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) { - mmap_type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_ref_next; - wgt_ref; - wgt_ref = wgt_ref_next) - { - wgt_ref_next = wgt_ref->next; - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_REMOVE) { - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type); - } - } - } - } - - wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE; - } - - if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; - mmap_type; - mmap_type = mmap_type->next) - { - const uchar type_update_all = WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT; - if (mmap_type->type_update_flag & type_update_all) { - mmap_type->type_update_flag &= ~type_update_all; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; - wgt_ref; - wgt_ref = wgt_ref->next) - { - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) { - WM_manipulatormaptype_group_init_runtime_keymap(bmain, wgt_ref->type); - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT; - } - - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) { - WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type); - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT; - } - } - } - } - - wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; - } -} - -/** \} */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c deleted file mode 100644 index 137e8f5639d..00000000000 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c +++ /dev/null @@ -1,364 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c - * \ingroup wm - */ - -#include "BLI_listbase.h" -#include "BLI_math.h" -#include "BLI_string.h" -#include "BLI_string_utils.h" - -#include "BKE_context.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" - -#include "WM_api.h" -#include "WM_types.h" -#include "WM_message.h" - -#include "wm.h" - -#include "ED_screen.h" -#include "ED_view3d.h" - -/* own includes */ -#include "wm_manipulator_wmapi.h" -#include "wm_manipulator_intern.h" - -/* -------------------------------------------------------------------- */ - -/** \name Property Definition - * \{ */ - -BLI_INLINE wmManipulatorProperty *wm_manipulator_target_property_array(wmManipulator *mpr) -{ - return (wmManipulatorProperty *)(POINTER_OFFSET(mpr, mpr->type->struct_size)); -} - -wmManipulatorProperty *WM_manipulator_target_property_array(wmManipulator *mpr) -{ - return wm_manipulator_target_property_array(mpr); -} - -wmManipulatorProperty *WM_manipulator_target_property_at_index(wmManipulator *mpr, int index) -{ - BLI_assert(index < mpr->type->target_property_defs_len); - BLI_assert(index != -1); - wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr); - return &mpr_prop_array[index]; -} - -wmManipulatorProperty *WM_manipulator_target_property_find(wmManipulator *mpr, const char *idname) -{ - int index = BLI_findstringindex( - &mpr->type->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname)); - if (index != -1) { - return WM_manipulator_target_property_at_index(mpr, index); - } - else { - return NULL; - } -} - -void WM_manipulator_target_property_def_rna_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type, - PointerRNA *ptr, PropertyRNA *prop, int index) -{ - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); - - /* if manipulator evokes an operator we cannot use it for property manipulation */ - BLI_assert(mpr->op_data == NULL); - - mpr_prop->type = mpr_prop_type; - - mpr_prop->ptr = *ptr; - mpr_prop->prop = prop; - mpr_prop->index = index; - - if (mpr->type->property_update) { - mpr->type->property_update(mpr, mpr_prop); - } -} - -void WM_manipulator_target_property_def_rna( - wmManipulator *mpr, const char *idname, - PointerRNA *ptr, const char *propname, int index) -{ - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); - PropertyRNA *prop = RNA_struct_find_property(ptr, propname); - WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); -} - -void WM_manipulator_target_property_def_func_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type, - const wmManipulatorPropertyFnParams *params) -{ - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); - - /* if manipulator evokes an operator we cannot use it for property manipulation */ - BLI_assert(mpr->op_data == NULL); - - mpr_prop->type = mpr_prop_type; - - mpr_prop->custom_func.value_get_fn = params->value_get_fn; - mpr_prop->custom_func.value_set_fn = params->value_set_fn; - mpr_prop->custom_func.range_get_fn = params->range_get_fn; - mpr_prop->custom_func.free_fn = params->free_fn; - mpr_prop->custom_func.user_data = params->user_data; - - if (mpr->type->property_update) { - mpr->type->property_update(mpr, mpr_prop); - } -} - -void WM_manipulator_target_property_def_func( - wmManipulator *mpr, const char *idname, - const wmManipulatorPropertyFnParams *params) -{ - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); - WM_manipulator_target_property_def_func_ptr(mpr, mpr_prop_type, params); -} - -void WM_manipulator_target_property_clear_rna_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type) -{ - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); - - /* if manipulator evokes an operator we cannot use it for property manipulation */ - BLI_assert(mpr->op_data == NULL); - - mpr_prop->type = NULL; - - mpr_prop->ptr = PointerRNA_NULL; - mpr_prop->prop = NULL; - mpr_prop->index = -1; -} - -void WM_manipulator_target_property_clear_rna( - wmManipulator *mpr, const char *idname) -{ - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); - WM_manipulator_target_property_clear_rna_ptr(mpr, mpr_prop_type); -} - - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Property Access - * \{ */ - -bool WM_manipulator_target_property_is_valid_any(wmManipulator *mpr) -{ - wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - return true; - } - } - return false; -} - -bool WM_manipulator_target_property_is_valid(const wmManipulatorProperty *mpr_prop) -{ - return ((mpr_prop->prop != NULL) || - (mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn)); -} - -float WM_manipulator_target_property_value_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop) -{ - if (mpr_prop->custom_func.value_get_fn) { - float value = 0.0f; - BLI_assert(mpr_prop->type->array_length == 1); - mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, &value); - return value; - } - - if (mpr_prop->index == -1) { - return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop); - } - else { - return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index); - } -} - -void WM_manipulator_target_property_value_set( - bContext *C, const wmManipulator *mpr, - wmManipulatorProperty *mpr_prop, const float value) -{ - if (mpr_prop->custom_func.value_set_fn) { - BLI_assert(mpr_prop->type->array_length == 1); - mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, &value); - return; - } - - /* reset property */ - if (mpr_prop->index == -1) { - RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, value); - } - else { - RNA_property_float_set_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index, value); - } - RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); -} - -void WM_manipulator_target_property_value_get_array( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - float *value) -{ - if (mpr_prop->custom_func.value_get_fn) { - mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, value); - return; - } - RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value); -} - -void WM_manipulator_target_property_value_set_array( - bContext *C, const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - const float *value) -{ - if (mpr_prop->custom_func.value_set_fn) { - mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, value); - return; - } - RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, value); - - RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); -} - -bool WM_manipulator_target_property_range_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - float range[2]) -{ - if (mpr_prop->custom_func.value_get_fn) { - if (mpr_prop->custom_func.range_get_fn) { - mpr_prop->custom_func.range_get_fn(mpr, mpr_prop, range); - return true; - } - else { - return false; - - } - } - - float step, precision; - RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &range[0], &range[1], &step, &precision); - return true; -} - -int WM_manipulator_target_property_array_length( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop) -{ - if (mpr_prop->custom_func.value_get_fn) { - return mpr_prop->type->array_length; - } - return RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop); -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Property Define - * \{ */ - -const wmManipulatorPropertyType *WM_manipulatortype_target_property_find( - const wmManipulatorType *wt, const char *idname) -{ - return BLI_findstring(&wt->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname)); -} - -void WM_manipulatortype_target_property_def( - wmManipulatorType *wt, const char *idname, int data_type, int array_length) -{ - wmManipulatorPropertyType *mpt; - - BLI_assert(WM_manipulatortype_target_property_find(wt, idname) == NULL); - - const uint idname_size = strlen(idname) + 1; - mpt = MEM_callocN(sizeof(wmManipulatorPropertyType) + idname_size, __func__); - memcpy(mpt->idname, idname, idname_size); - mpt->data_type = data_type; - mpt->array_length = array_length; - mpt->index_in_type = wt->target_property_defs_len; - wt->target_property_defs_len += 1; - BLI_addtail(&wt->target_property_defs, mpt); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ - -/** \name Property Utilities - * \{ */ - -void WM_manipulator_do_msg_notify_tag_refresh( - bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) -{ - ARegion *ar = msg_val->owner; - wmManipulatorMap *mmap = msg_val->user_data; - - ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); -} - -/** - * Runs on the "prepare draw" pass, - * drawing the region clears. - */ -void WM_manipulator_target_property_subscribe_all( - wmManipulator *mpr, struct wmMsgBus *mbus, ARegion *ar) -{ - if (mpr->type->target_property_defs_len) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - if (mpr_prop->prop) { - WM_msg_subscribe_rna( - mbus, &mpr_prop->ptr, mpr_prop->prop, - &(const wmMsgSubscribeValue){ - .owner = ar, - .user_data = ar, - .notify = ED_region_do_msg_notify_tag_redraw, - }, __func__); - WM_msg_subscribe_rna( - mbus, &mpr_prop->ptr, mpr_prop->prop, - &(const wmMsgSubscribeValue){ - .owner = ar, - .user_data = mpr->parent_mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, - }, __func__); - } - } - } - } -} - -/** \} */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c deleted file mode 100644 index fd7f31db903..00000000000 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/intern/wm_manipulator_type.c - * \ingroup wm - */ - -#include "BLI_utildefines.h" -#include "BLI_ghash.h" -#include "BLI_listbase.h" -#include "BLI_string.h" -#include "BLI_string_utils.h" - -#include "BKE_context.h" -#include "BKE_main.h" - -#include "DNA_screen_types.h" -#include "DNA_space_types.h" - -#include "MEM_guardedalloc.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" - -/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ -#include "wm.h" - -/* own includes */ -#include "wm_manipulator_wmapi.h" -#include "wm_manipulator_intern.h" - - -/** \name Manipulator Type Append - * - * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. - * \{ */ - -static GHash *global_manipulatortype_hash = NULL; - -const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) -{ - if (idname[0]) { - wmManipulatorType *wt; - - wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); - if (wt) { - return wt; - } - - if (!quiet) { - printf("search for unknown manipulator '%s'\n", idname); - } - } - else { - if (!quiet) { - printf("search for empty manipulator\n"); - } - } - - return NULL; -} - -/* caller must free */ -void WM_manipulatortype_iter(GHashIterator *ghi) -{ - BLI_ghashIterator_init(ghi, global_manipulatortype_hash); -} - -static wmManipulatorType *wm_manipulatortype_append__begin(void) -{ - wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype"); - wt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_ManipulatorProperties); -#if 0 - /* Set the default i18n context now, so that opfunc can redefine it if needed! */ - RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); - ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; -#endif - return wt; -} -static void wm_manipulatortype_append__end(wmManipulatorType *wt) -{ - BLI_assert(wt->struct_size >= sizeof(wmManipulator)); - - RNA_def_struct_identifier(&BLENDER_RNA, wt->srna, wt->idname); - - BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt); -} - -void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)) -{ - wmManipulatorType *wt = wm_manipulatortype_append__begin(); - wtfunc(wt); - wm_manipulatortype_append__end(wt); -} - -void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata) -{ - wmManipulatorType *mt = wm_manipulatortype_append__begin(); - wtfunc(mt, userdata); - wm_manipulatortype_append__end(mt); -} - -/** - * Free but don't remove from ghash. - */ -static void manipulatortype_free(wmManipulatorType *wt) -{ - if (wt->ext.srna) { /* python manipulator, allocs own string */ - MEM_freeN((void *)wt->idname); - } - - BLI_freelistN(&wt->target_property_defs); - MEM_freeN(wt); -} - -/** - * \param C: May be NULL. - */ -static void manipulatortype_unlink( - bContext *C, Main *bmain, wmManipulatorType *wt) -{ - /* Free instances. */ - for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmManipulatorMap *mmap = ar->manipulator_map; - if (mmap) { - wmManipulatorGroup *mgroup; - for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) { - mpr_next = mpr->next; - BLI_assert(mgroup->parent_mmap == mmap); - if (mpr->type == wt) { - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C); - ED_region_tag_redraw(ar); - } - } - } - } - } - } - } - } -} - -void WM_manipulatortype_remove_ptr(bContext *C, Main *bmain, wmManipulatorType *wt) -{ - BLI_assert(wt == WM_manipulatortype_find(wt->idname, false)); - - BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL); - - manipulatortype_unlink(C, bmain, wt); - - manipulatortype_free(wt); -} - -bool WM_manipulatortype_remove(bContext *C, Main *bmain, const char *idname) -{ - wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); - - if (wt == NULL) { - return false; - } - - WM_manipulatortype_remove_ptr(C, bmain, wt); - - return true; -} - -static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt) -{ - manipulatortype_free(mt); -} - -void wm_manipulatortype_free(void) -{ - BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb); - global_manipulatortype_hash = NULL; -} - -/* called on initialize WM_init() */ -void wm_manipulatortype_init(void) -{ - /* reserve size is set based on blender default setup */ - global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128); -} - -/** \} */ diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h deleted file mode 100644 index 305d04eab68..00000000000 --- a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/wm_manipulator_fn.h - * \ingroup wm - * - * Callback function definitions, needed for both Types & API headers. - */ - -#ifndef __WM_MANIPULATOR_FN_H__ -#define __WM_MANIPULATOR_FN_H__ - -#include "BLI_compiler_attrs.h" - -/* wmManipulatorGroup */ -typedef bool (*wmManipulatorGroupFnPoll)( - const struct bContext *, struct wmManipulatorGroupType *) - ATTR_WARN_UNUSED_RESULT; -typedef void (*wmManipulatorGroupFnInit)( - const struct bContext *, struct wmManipulatorGroup *); -typedef void (*wmManipulatorGroupFnRefresh)( - const struct bContext *, struct wmManipulatorGroup *); -typedef void (*wmManipulatorGroupFnDrawPrepare)( - const struct bContext *, struct wmManipulatorGroup *); -typedef struct wmKeyMap *(*wmManipulatorGroupFnSetupKeymap)( - const struct wmManipulatorGroupType *, struct wmKeyConfig *) - ATTR_WARN_UNUSED_RESULT; -typedef void (*wmManipulatorGroupFnMsgBusSubscribe)( - const struct bContext *, struct wmManipulatorGroup *, struct wmMsgBus *); - -/* wmManipulator */ -/* See: wmManipulatorType for docs on each type. */ - -typedef void (*wmManipulatorFnSetup)(struct wmManipulator *); -typedef void (*wmManipulatorFnDraw)(const struct bContext *, struct wmManipulator *); -typedef void (*wmManipulatorFnDrawSelect)(const struct bContext *, struct wmManipulator *, int); -typedef int (*wmManipulatorFnTestSelect)(struct bContext *, struct wmManipulator *, const struct wmEvent *); -typedef int (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, eWM_ManipulatorTweak); -typedef void (*wmManipulatorFnPropertyUpdate)(struct wmManipulator *, struct wmManipulatorProperty *); -typedef void (*wmManipulatorFnMatrixBasisGet)(const struct wmManipulator *, float[4][4]); -typedef int (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *); -typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *, const bool); -typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *); -typedef void (*wmManipulatorFnSelectRefresh)(struct wmManipulator *); -typedef void (*wmManipulatorFnFree)(struct wmManipulator *); - -/* wmManipulatorProperty ('value' type defined by 'wmManipulatorProperty.data_type') */ -typedef void (*wmManipulatorPropertyFnGet)( - const struct wmManipulator *, struct wmManipulatorProperty *, - /* typically 'float *' */ - void *value); -typedef void (*wmManipulatorPropertyFnSet)( - const struct wmManipulator *, struct wmManipulatorProperty *, - /* typically 'const float *' */ - const void *value); -typedef void (*wmManipulatorPropertyFnRangeGet)( - const struct wmManipulator *, struct wmManipulatorProperty *, - /* typically 'float[2]' */ - void *range); -typedef void (*wmManipulatorPropertyFnFree)( - const struct wmManipulator *, struct wmManipulatorProperty *); - -typedef struct wmManipulatorPropertyFnParams { - wmManipulatorPropertyFnGet value_get_fn; - wmManipulatorPropertyFnSet value_set_fn; - wmManipulatorPropertyFnRangeGet range_get_fn; - wmManipulatorPropertyFnFree free_fn; - void *user_data; -} wmManipulatorPropertyFnParams; - -#endif /* __WM_MANIPULATOR_FN_H__ */ diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h b/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h deleted file mode 100644 index a470c5c28ea..00000000000 --- a/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/manipulators/wm_manipulator_wmapi.h - * \ingroup wm - * - * \name Manipulators Window Manager API - * API for usage in window manager code only. It should contain all functionality - * needed to hook up the manipulator system with Blender's window manager. It's - * mostly the event system that needs to communicate with manipulator code. - * - * Only included in wm.h and lower level files. - */ - - -#ifndef __WM_MANIPULATOR_WMAPI_H__ -#define __WM_MANIPULATOR_WMAPI_H__ - -struct wmEventHandler; -struct wmManipulatorMap; -struct wmOperatorType; -struct wmOperator; - - -/* -------------------------------------------------------------------- */ -/* wmManipulator */ - -/* wm_manipulator_type.c, for init/exit */ -void wm_manipulatortype_free(void); -void wm_manipulatortype_init(void); - -/* wm_manipulatorgroup_type.c, for init/exit */ -void wm_manipulatorgrouptype_free(void); -void wm_manipulatorgrouptype_init(void); - -/* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ - -void MANIPULATORGROUP_OT_manipulator_select(struct wmOperatorType *ot); -void MANIPULATORGROUP_OT_manipulator_tweak(struct wmOperatorType *ot); - -bool wm_manipulatorgroup_is_any_selected(const struct wmManipulatorGroup *mgroup); - -/* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ - -void wm_manipulatormap_remove(struct wmManipulatorMap *mmap); - -void wm_manipulators_keymap(struct wmKeyConfig *keyconf); - -void wm_manipulatormaps_handled_modal_update( - bContext *C, struct wmEvent *event, struct wmEventHandler *handler); -void wm_manipulatormap_handler_context(bContext *C, struct wmEventHandler *handler); - -struct wmManipulator *wm_manipulatormap_highlight_find( - struct wmManipulatorMap *mmap, bContext *C, const struct wmEvent *event, - int *r_part); -bool wm_manipulatormap_highlight_set( - struct wmManipulatorMap *mmap, const bContext *C, - struct wmManipulator *mpr, int part); -struct wmManipulator *wm_manipulatormap_highlight_get(struct wmManipulatorMap *mmap); -void wm_manipulatormap_modal_set( - struct wmManipulatorMap *mmap, bContext *C, struct wmManipulator *mpr, - const struct wmEvent *event, bool enable); - -struct wmManipulator *wm_manipulatormap_modal_get(struct wmManipulatorMap *mmap); -struct wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len); -struct ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap); - -/* -------------------------------------------------------------------- */ -/* wmManipulatorMapType */ - -void wm_manipulatormaptypes_free(void); - -#endif /* __WM_MANIPULATOR_WMAPI_H__ */ diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index d17d5f7d157..04353b55334 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -35,7 +35,7 @@ struct ARegion; struct wmWindow; struct ReportList; -#include "manipulators/wm_manipulator_wmapi.h" +#include "gizmo/wm_gizmo_wmapi.h" typedef struct wmPaintCursor { struct wmPaintCursor *next, *prev; -- cgit v1.2.3 From 5ebebcfbfff4c218ab4101ee7f6a66617ee9b01f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 23:49:00 +0200 Subject: WM: rename manipulator to gizmo internally --- release/datafiles/userdef/userdef_default_theme.c | 10 +- release/scripts/modules/bpy_types.py | 8 +- .../startup/bl_ui/space_toolsystem_common.py | 2 +- release/scripts/startup/bl_ui/space_userpref.py | 16 +- release/scripts/startup/bl_ui/space_view3d.py | 14 +- source/blender/blenkernel/BKE_context.h | 4 +- source/blender/blenkernel/BKE_screen.h | 14 +- source/blender/blenkernel/intern/blender.c | 2 +- source/blender/blenkernel/intern/blendfile.c | 2 +- source/blender/blenkernel/intern/constraint.c | 4 +- source/blender/blenkernel/intern/context.c | 10 +- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/screen.c | 30 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/blenloader/intern/versioning_280.c | 4 +- source/blender/bmesh/intern/bmesh_marking.c | 4 +- source/blender/bmesh/intern/bmesh_polygon.c | 2 +- source/blender/draw/intern/draw_manager.c | 8 +- source/blender/draw/intern/draw_view.c | 22 +- source/blender/draw/intern/draw_view.h | 4 +- source/blender/draw/modes/pose_mode.c | 2 +- .../gizmo_library/geometry/geom_arrow_gizmo.c | 2 +- .../gizmo_library/geometry/geom_cube_gizmo.c | 2 +- .../gizmo_library/geometry/geom_dial_gizmo.c | 2 +- .../editors/gizmo_library/gizmo_draw_utils.c | 10 +- .../blender/editors/gizmo_library/gizmo_geometry.h | 22 +- .../editors/gizmo_library/gizmo_library_intern.h | 56 +- .../editors/gizmo_library/gizmo_library_presets.c | 44 +- .../editors/gizmo_library/gizmo_library_utils.c | 78 +-- .../gizmo_library/gizmo_types/arrow2d_gizmo.c | 56 +- .../gizmo_library/gizmo_types/arrow3d_gizmo.c | 246 ++++---- .../gizmo_library/gizmo_types/button2d_gizmo.c | 76 +-- .../gizmo_library/gizmo_types/cage2d_gizmo.c | 322 +++++----- .../gizmo_library/gizmo_types/cage3d_gizmo.c | 214 +++---- .../gizmo_library/gizmo_types/dial3d_gizmo.c | 128 ++-- .../gizmo_library/gizmo_types/grab3d_gizmo.c | 144 ++--- .../gizmo_library/gizmo_types/primitive3d_gizmo.c | 76 +-- source/blender/editors/include/ED_gizmo_library.h | 206 +++---- source/blender/editors/include/ED_transform.h | 20 +- source/blender/editors/include/UI_interface.h | 4 +- source/blender/editors/include/UI_resources.h | 10 +- .../editors/interface/interface_region_tooltip.c | 14 +- source/blender/editors/interface/resources.c | 28 +- source/blender/editors/mesh/editmesh_add_gizmo.c | 138 ++--- source/blender/editors/mesh/editmesh_bevel.c | 2 +- source/blender/editors/mesh/editmesh_bisect.c | 180 +++--- source/blender/editors/mesh/editmesh_extrude.c | 120 ++-- .../blender/editors/mesh/editmesh_extrude_spin.c | 208 +++---- source/blender/editors/mesh/editmesh_inset.c | 2 +- source/blender/editors/mesh/editmesh_polybuild.c | 2 +- source/blender/editors/mesh/mesh_intern.h | 4 +- source/blender/editors/mesh/mesh_ops.c | 2 +- source/blender/editors/screen/area.c | 4 +- source/blender/editors/screen/screen_edit.c | 4 +- source/blender/editors/space_api/spacetypes.c | 28 +- source/blender/editors/space_image/space_image.c | 40 +- source/blender/editors/space_node/node_draw.c | 2 +- source/blender/editors/space_node/node_gizmo.c | 170 ++--- source/blender/editors/space_node/node_intern.h | 8 +- source/blender/editors/space_node/space_node.c | 34 +- .../editors/space_sequencer/sequencer_select.c | 2 +- source/blender/editors/space_view3d/space_view3d.c | 70 +-- source/blender/editors/space_view3d/view3d_draw.c | 6 +- source/blender/editors/space_view3d/view3d_edit.c | 8 +- .../editors/space_view3d/view3d_gizmo_armature.c | 52 +- .../editors/space_view3d/view3d_gizmo_camera.c | 156 ++--- .../editors/space_view3d/view3d_gizmo_empty.c | 56 +- .../editors/space_view3d/view3d_gizmo_forcefield.c | 52 +- .../editors/space_view3d/view3d_gizmo_lamp.c | 128 ++-- .../editors/space_view3d/view3d_gizmo_navigate.c | 98 +-- .../space_view3d/view3d_gizmo_navigate_type.c | 34 +- .../editors/space_view3d/view3d_gizmo_ruler.c | 92 +-- .../blender/editors/space_view3d/view3d_header.c | 6 +- .../blender/editors/space_view3d/view3d_intern.h | 30 +- source/blender/editors/space_view3d/view3d_ops.c | 2 +- source/blender/editors/transform/transform.c | 12 +- source/blender/editors/transform/transform.h | 6 +- .../editors/transform/transform_conversions.c | 2 +- .../blender/editors/transform/transform_generics.c | 6 +- .../blender/editors/transform/transform_gizmo_2d.c | 150 ++--- .../blender/editors/transform/transform_gizmo_3d.c | 336 +++++----- source/blender/editors/transform/transform_ops.c | 4 +- source/blender/makesdna/DNA_scene_types.h | 4 +- source/blender/makesdna/DNA_screen_types.h | 2 +- source/blender/makesdna/DNA_userdef_types.h | 18 +- source/blender/makesdna/DNA_view3d_types.h | 14 +- source/blender/makesdna/DNA_workspace_types.h | 2 +- source/blender/makesrna/RNA_access.h | 4 +- source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/makesrna/intern/rna_context.c | 10 +- source/blender/makesrna/intern/rna_internal.h | 6 +- source/blender/makesrna/intern/rna_scene.c | 16 +- source/blender/makesrna/intern/rna_space.c | 22 +- source/blender/makesrna/intern/rna_userdef.c | 36 +- source/blender/makesrna/intern/rna_wm_api.c | 30 +- source/blender/makesrna/intern/rna_wm_gizmo.c | 684 ++++++++++----------- source/blender/makesrna/intern/rna_wm_gizmo_api.c | 94 +-- source/blender/makesrna/intern/rna_workspace_api.c | 6 +- source/blender/python/intern/bpy.c | 2 +- source/blender/python/intern/bpy_gizmo_wrap.c | 38 +- source/blender/python/intern/bpy_gizmo_wrap.h | 8 +- source/blender/python/intern/bpy_rna.c | 8 +- source/blender/python/intern/bpy_rna_gizmo.c | 172 +++--- source/blender/python/intern/bpy_rna_gizmo.h | 2 +- source/blender/python/intern/gpu_py_select.c | 2 +- source/blender/windowmanager/WM_api.h | 6 +- source/blender/windowmanager/WM_types.h | 2 +- source/blender/windowmanager/gizmo/WM_gizmo_api.h | 442 ++++++------- .../blender/windowmanager/gizmo/WM_gizmo_types.h | 346 +++++------ .../blender/windowmanager/gizmo/intern/wm_gizmo.c | 314 +++++----- .../windowmanager/gizmo/intern/wm_gizmo_group.c | 466 +++++++------- .../gizmo/intern/wm_gizmo_group_type.c | 98 +-- .../windowmanager/gizmo/intern/wm_gizmo_intern.h | 108 ++-- .../windowmanager/gizmo/intern/wm_gizmo_map.c | 590 +++++++++--------- .../gizmo/intern/wm_gizmo_target_props.c | 140 ++--- .../windowmanager/gizmo/intern/wm_gizmo_type.c | 90 +-- source/blender/windowmanager/gizmo/wm_gizmo_fn.h | 84 +-- .../blender/windowmanager/gizmo/wm_gizmo_wmapi.h | 66 +- .../blender/windowmanager/intern/wm_event_system.c | 64 +- source/blender/windowmanager/intern/wm_init_exit.c | 16 +- source/blender/windowmanager/intern/wm_operators.c | 8 +- .../blender/windowmanager/intern/wm_toolsystem.c | 18 +- source/blender/windowmanager/wm_event_system.h | 4 +- source/blender/windowmanager/wm_event_types.h | 4 +- 124 files changed, 4115 insertions(+), 4115 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 666fb03596c..f77b06b56e2 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -239,11 +239,11 @@ const bTheme U_theme_default = { .xaxis = RGBA(0xff3352ff), .yaxis = RGBA(0x8bdc00ff), .zaxis = RGBA(0x2890ffff), - .manipulator_hi = RGBA(0xffffffff), - .manipulator_primary = RGBA(0xf5f14dff), - .manipulator_secondary = RGBA(0x63ffffff), - .manipulator_a = RGBA(0x4da84dff), - .manipulator_b = RGBA(0xa33535ff), + .gizmo_hi = RGBA(0xffffffff), + .gizmo_primary = RGBA(0xf5f14dff), + .gizmo_secondary = RGBA(0x63ffffff), + .gizmo_a = RGBA(0x4da84dff), + .gizmo_b = RGBA(0xa33535ff), }, .tbuts = { .back = RGBA(0x42424200), diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 3bdf92f8e63..e9f40bd0c3c 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -581,10 +581,10 @@ class Manipulator(StructRNA): return super().__delattr__(attr) from _bpy import ( - _rna_manipulator_target_set_handler as target_set_handler, - _rna_manipulator_target_get_value as target_get_value, - _rna_manipulator_target_set_value as target_set_value, - _rna_manipulator_target_get_range as target_get_range, + _rna_gizmo_target_set_handler as target_set_handler, + _rna_gizmo_target_get_value as target_get_value, + _rna_gizmo_target_set_value as target_set_value, + _rna_gizmo_target_get_range as target_get_range, ) # Convenience wrappers around private `_gawain` module. diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 9cc57bc2c87..4c954874f0d 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -569,7 +569,7 @@ def _activate_by_item(context, space_type, item, index): name=item.text, keymap=item.keymap[0].name if item.keymap is not None else "", cursor=item.cursor or 'DEFAULT', - manipulator_group=item.widget or "", + gizmo_group=item.widget or "", data_block=item.data_block or "", operator=item.operator or "", index=index, diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 0c717aa21d5..e2bca0b6b33 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -238,7 +238,7 @@ class USERPREF_PT_interface(Panel): col.separator() - # col.prop(view, "show_manipulator_navigate") + # col.prop(view, "show_gizmo_navigate") sub = col.column(align=True) @@ -258,10 +258,10 @@ class USERPREF_PT_interface(Panel): #col.label(text="Open Toolbox Delay:") #col.prop(view, "open_left_mouse_delay", text="Hold LMB") #col.prop(view, "open_right_mouse_delay", text="Hold RMB") - col.prop(view, "show_manipulator", text="Gizmos") + col.prop(view, "show_gizmo", text="Gizmos") sub = col.column() - sub.active = view.show_manipulator - sub.prop(view, "manipulator_size", text="Size") + sub.active = view.show_gizmo + sub.prop(view, "gizmo_size", text="Size") col.separator() @@ -934,10 +934,10 @@ class USERPREF_PT_theme(Panel): padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() - colsub.row().prop(ui, "manipulator_primary") - colsub.row().prop(ui, "manipulator_secondary") - colsub.row().prop(ui, "manipulator_a") - colsub.row().prop(ui, "manipulator_b") + colsub.row().prop(ui, "gizmo_primary") + colsub.row().prop(ui, "gizmo_secondary") + colsub.row().prop(ui, "gizmo_a") + colsub.row().prop(ui, "gizmo_b") col.separator() col.separator() diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 3f711ace97e..682af76500b 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3954,7 +3954,7 @@ class VIEW3D_PT_overlay(Panel): pass -class VIEW3D_PT_overlay_manipulators(Panel): +class VIEW3D_PT_overlay_gizmo(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_parent_id = 'VIEW3D_PT_overlay' @@ -3962,7 +3962,7 @@ class VIEW3D_PT_overlay_manipulators(Panel): def draw_header(self, context): view = context.space_data - self.layout.prop(view, "show_manipulator", text="") + self.layout.prop(view, "show_gizmo", text="") def draw(self, context): layout = self.layout @@ -3975,10 +3975,10 @@ class VIEW3D_PT_overlay_manipulators(Panel): col.active = display_all row = col.row(align=True) - row.active = view.show_manipulator - row.prop(view, "show_manipulator_navigate", text="Navigate", toggle=True) - row.prop(view, "show_manipulator_context", text="Active Object", toggle=True) - row.prop(view, "show_manipulator_tool", text="Active Tools", toggle=True) + row.active = view.show_gizmo + row.prop(view, "show_gizmo_navigate", text="Navigate", toggle=True) + row.prop(view, "show_gizmo_context", text="Active Object", toggle=True) + row.prop(view, "show_gizmo_tool", text="Active Tools", toggle=True) class VIEW3D_PT_overlay_guides(Panel): @@ -4818,7 +4818,7 @@ classes = ( VIEW3D_PT_shading_options_shadow, VIEW3D_PT_shading_options_ssao, VIEW3D_PT_overlay, - VIEW3D_PT_overlay_manipulators, + VIEW3D_PT_overlay_gizmo, VIEW3D_PT_overlay_guides, VIEW3D_PT_overlay_object, VIEW3D_PT_overlay_geometry, diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 9fa00e7f63f..6703d828bf0 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -157,7 +157,7 @@ struct SpaceLink *CTX_wm_space_data(const bContext *C); struct ARegion *CTX_wm_region(const bContext *C); void *CTX_wm_region_data(const bContext *C); struct ARegion *CTX_wm_menu(const bContext *C); -struct wmManipulatorGroup *CTX_wm_manipulator_group(const bContext *C); +struct wmGizmoGroup *CTX_wm_gizmo_group(const bContext *C); struct wmMsgBus *CTX_wm_message_bus(const bContext *C); struct ReportList *CTX_wm_reports(const bContext *C); @@ -185,7 +185,7 @@ void CTX_wm_screen_set(bContext *C, struct bScreen *screen); /* to be removed */ void CTX_wm_area_set(bContext *C, struct ScrArea *sa); void CTX_wm_region_set(bContext *C, struct ARegion *region); void CTX_wm_menu_set(bContext *C, struct ARegion *menu); -void CTX_wm_manipulator_group_set(bContext *C, struct wmManipulatorGroup *mgroup); +void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *mgroup); const char *CTX_wm_operator_poll_msg_get(struct bContext *C); void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg); diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 23f57586ed1..60981c6e76e 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -51,7 +51,7 @@ struct bScreen; struct uiLayout; struct uiList; struct wmKeyConfig; -struct wmManipulatorMap; +struct wmGizmoMap; struct wmNotifier; struct wmWindow; struct wmWindowManager; @@ -104,8 +104,8 @@ typedef struct SpaceType { /* on startup, define dropboxes for spacetype+regions */ void (*dropboxes)(void); - /* initialize manipulator-map-types and manipulator-group-types with the region */ - void (*manipulators)(void); + /* initialize gizmo-map-types and gizmo-group-types with the region */ + void (*gizmos)(void); /* return context data */ int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result); @@ -325,9 +325,9 @@ void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar); void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar); void BKE_screen_area_free(struct ScrArea *sa); -/* Manipulator-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */ -void BKE_region_callback_free_manipulatormap_set(void (*callback)(struct wmManipulatorMap *)); -void BKE_region_callback_refresh_tag_manipulatormap_set(void (*callback)(struct wmManipulatorMap *)); +/* Gizmo-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */ +void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *)); +void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *)); struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type); struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa); @@ -344,7 +344,7 @@ unsigned int BKE_screen_view3d_layer_active( unsigned int BKE_screen_view3d_layer_all(const struct bScreen *sc) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); -void BKE_screen_manipulator_tag_refresh(struct bScreen *sc); +void BKE_screen_gizmo_tag_refresh(struct bScreen *sc); void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene); void BKE_screen_view3d_scene_sync(struct bScreen *sc, struct Scene *scene); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 23c2147ff7e..66020679bf7 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -300,7 +300,7 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use DATA_SWAP(font_path_ui_mono); DATA_SWAP(keyconfigstr); - DATA_SWAP(manipulator_flag); + DATA_SWAP(gizmo_flag); DATA_SWAP(app_flag); /* We could add others. */ diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 27b5089b092..b16648fd73f 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -226,7 +226,7 @@ static void setup_app_data( * only the current screen is important because we wont have to handle * events from multiple screens at once.*/ { - BKE_screen_manipulator_tag_refresh(curscreen); + BKE_screen_gizmo_tag_refresh(curscreen); } } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 0cbd77b67d2..4f772673e1d 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -463,8 +463,8 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ } /* derive the rotation from the average normal: - * - code taken from transform_manipulator.c, - * calc_manipulator_stats, V3D_MANIP_NORMAL case + * - code taken from transform_gizmo.c, + * calc_gizmo_stats, V3D_MANIP_NORMAL case */ /* we need the transpose of the inverse for a normal... */ copy_m3_m4(imat, ob->obmat); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 1aaf5e4f485..68a1e607517 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -80,7 +80,7 @@ struct bContext { struct ScrArea *area; struct ARegion *region; struct ARegion *menu; - struct wmManipulatorGroup *manipulator_group; + struct wmGizmoGroup *gizmo_group; struct bContextStore *store; const char *operator_poll_msg; /* reason for poll failing */ } wm; @@ -675,9 +675,9 @@ struct ARegion *CTX_wm_menu(const bContext *C) return C->wm.menu; } -struct wmManipulatorGroup *CTX_wm_manipulator_group(const bContext *C) +struct wmGizmoGroup *CTX_wm_gizmo_group(const bContext *C) { - return C->wm.manipulator_group; + return C->wm.gizmo_group; } struct wmMsgBus *CTX_wm_message_bus(const bContext *C) @@ -876,9 +876,9 @@ void CTX_wm_menu_set(bContext *C, ARegion *menu) C->wm.menu = menu; } -void CTX_wm_manipulator_group_set(bContext *C, struct wmManipulatorGroup *mgroup) +void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *mgroup) { - C->wm.manipulator_group = mgroup; + C->wm.gizmo_group = mgroup; } void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 8299d785cfc..6a8f46badd9 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -645,7 +645,7 @@ void BKE_scene_init(Scene *sce) sce->toolsettings->uvcalc_flag = UVCALC_TRANSFORM_CORRECT; sce->toolsettings->unwrapper = 1; sce->toolsettings->select_thresh = 0.01f; - sce->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; + sce->toolsettings->gizmo_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; sce->toolsettings->selectmode = SCE_SELECT_VERTEX; sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX; diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 1c8a93981c7..448b97c63b3 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -222,7 +222,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar) BLI_listbase_clear(&newar->panels_category_active); BLI_listbase_clear(&newar->ui_lists); newar->visible = 0; - newar->manipulator_map = NULL; + newar->gizmo_map = NULL; newar->regiontimer = NULL; newar->headerstr = NULL; newar->draw_buffer = NULL; @@ -324,18 +324,18 @@ void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID } /** - * Avoid bad-level calls to #WM_manipulatormap_tag_refresh. + * Avoid bad-level calls to #WM_gizmomap_tag_refresh. */ -static void (*region_refresh_tag_manipulatormap_callback)(struct wmManipulatorMap *) = NULL; +static void (*region_refresh_tag_gizmomap_callback)(struct wmGizmoMap *) = NULL; -void BKE_region_callback_refresh_tag_manipulatormap_set(void (*callback)(struct wmManipulatorMap *)) +void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *)) { - region_refresh_tag_manipulatormap_callback = callback; + region_refresh_tag_gizmomap_callback = callback; } -void BKE_screen_manipulator_tag_refresh(struct bScreen *sc) +void BKE_screen_gizmo_tag_refresh(struct bScreen *sc) { - if (region_refresh_tag_manipulatormap_callback == NULL) { + if (region_refresh_tag_gizmomap_callback == NULL) { return; } @@ -343,21 +343,21 @@ void BKE_screen_manipulator_tag_refresh(struct bScreen *sc) ARegion *ar; for (sa = sc->areabase.first; sa; sa = sa->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->manipulator_map != NULL) { - region_refresh_tag_manipulatormap_callback(ar->manipulator_map); + if (ar->gizmo_map != NULL) { + region_refresh_tag_gizmomap_callback(ar->gizmo_map); } } } } /** - * Avoid bad-level calls to #WM_manipulatormap_delete. + * Avoid bad-level calls to #WM_gizmomap_delete. */ -static void (*region_free_manipulatormap_callback)(struct wmManipulatorMap *) = NULL; +static void (*region_free_gizmomap_callback)(struct wmGizmoMap *) = NULL; -void BKE_region_callback_free_manipulatormap_set(void (*callback)(struct wmManipulatorMap *)) +void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *)) { - region_free_manipulatormap_callback = callback; + region_free_gizmomap_callback = callback; } static void panel_list_free(ListBase *lb) @@ -414,8 +414,8 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar) } } - if (ar->manipulator_map != NULL) { - region_free_manipulatormap_callback(ar->manipulator_map); + if (ar->gizmo_map != NULL) { + region_free_gizmomap_callback(ar->gizmo_map); } BLI_freelistN(&ar->ui_lists); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6bc0a634599..6b356ac2e96 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6535,7 +6535,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) ar->visible = 0; ar->type = NULL; ar->do_draw = 0; - ar->manipulator_map = NULL; + ar->gizmo_map = NULL; ar->regiontimer = NULL; ar->draw_buffer = NULL; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index a078b794536..b854438ed47 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1549,8 +1549,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { - if (scene->toolsettings->manipulator_flag == 0) { - scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; + if (scene->toolsettings->gizmo_flag == 0) { + scene->toolsettings->gizmo_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; } } diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 10a03050d4b..1e53180396e 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -863,7 +863,7 @@ void BM_editselection_normal(BMEditSelection *ese, float r_normal[3]) /* Calculate a plane that is rightangles to the edge/vert/faces normal * also make the plane run along an axis that is related to the geometry, - * because this is used for the manipulators Y axis. */ + * because this is used for the gizmos Y axis. */ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]) { if (ese->htype == BM_VERT) { @@ -895,7 +895,7 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]) else { /* the plane is simple, it runs along the edge * however selecting different edges can swap the direction of the y axis. - * this makes it less likely for the y axis of the manipulator + * this makes it less likely for the y axis of the gizmo * (running along the edge).. to flip less often. * at least its more predictable */ if (eed->v2->co[1] > eed->v1->co[1]) { /* check which to do first */ diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 7cbc6461667..421b2adc3a7 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -487,7 +487,7 @@ void BM_face_calc_tangent_vert_diagonal(const BMFace *f, float r_tangent[3]) } /** - * Compute a meaningful direction along the face (use for manipulator axis). + * Compute a meaningful direction along the face (use for gizmo axis). * * \note Callers shouldn't depend on the *exact* method used here. */ diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index d8e1aa2c7a4..98d6f167d30 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1438,12 +1438,12 @@ void DRW_draw_render_loop_ex( glEnable(GL_DEPTH_TEST); if (DST.draw_ctx.evil_C) { - /* needed so manipulator isn't obscured */ + /* needed so gizmo isn't obscured */ if (((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && - ((v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0)) + ((v3d->mpr_flag & V3D_GIZMO_HIDE) == 0)) { glDisable(GL_DEPTH_TEST); - DRW_draw_manipulator_3d(); + DRW_draw_gizmo_3d(); } DRW_draw_region_info(); @@ -1451,7 +1451,7 @@ void DRW_draw_render_loop_ex( if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { /* Draw 2D after region info so we can draw on top of the camera passepartout overlay. * 'DRW_draw_region_info' sets the projection in pixel-space. */ - DRW_draw_manipulator_2d(); + DRW_draw_gizmo_2d(); glEnable(GL_DEPTH_TEST); } } diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 59ae8a918f9..75a7d567d5c 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -739,30 +739,30 @@ void DRW_draw_cursor(void) } } -/* **************************** 3D Manipulator ******************************** */ +/* **************************** 3D Gizmo ******************************** */ -void DRW_draw_manipulator_3d(void) +void DRW_draw_gizmo_3d(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); ARegion *ar = draw_ctx->ar; - /* draw depth culled manipulators - manipulators need to be updated *after* view matrix was set up */ - /* TODO depth culling manipulators is not yet supported, just drawing _3D here, should + /* draw depth culled gizmos - gizmos need to be updated *after* view matrix was set up */ + /* TODO depth culling gizmos is not yet supported, just drawing _3D here, should * later become _IN_SCENE (and draw _3D separate) */ - WM_manipulatormap_draw( - ar->manipulator_map, draw_ctx->evil_C, - WM_MANIPULATORMAP_DRAWSTEP_3D); + WM_gizmomap_draw( + ar->gizmo_map, draw_ctx->evil_C, + WM_GIZMOMAP_DRAWSTEP_3D); } -void DRW_draw_manipulator_2d(void) +void DRW_draw_gizmo_2d(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); ARegion *ar = draw_ctx->ar; - WM_manipulatormap_draw( - ar->manipulator_map, draw_ctx->evil_C, - WM_MANIPULATORMAP_DRAWSTEP_2D); + WM_gizmomap_draw( + ar->gizmo_map, draw_ctx->evil_C, + WM_GIZMOMAP_DRAWSTEP_2D); glDepthMask(GL_TRUE); } diff --git a/source/blender/draw/intern/draw_view.h b/source/blender/draw/intern/draw_view.h index 203420483a7..8f45a5fd786 100644 --- a/source/blender/draw/intern/draw_view.h +++ b/source/blender/draw/intern/draw_view.h @@ -30,7 +30,7 @@ void DRW_draw_grid(void); void DRW_draw_region_info(void); void DRW_draw_background(void); void DRW_draw_cursor(void); -void DRW_draw_manipulator_3d(void); -void DRW_draw_manipulator_2d(void); +void DRW_draw_gizmo_3d(void); +void DRW_draw_gizmo_2d(void); #endif /* __DRAW_VIEW_H__ */ diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index 90bbd3580cb..57efc65542c 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -198,7 +198,7 @@ static void POSE_cache_populate(void *vedata, Object *ob) POSE_StorageList *stl = ((POSE_Data *)vedata)->stl; const DRWContextState *draw_ctx = DRW_context_state_get(); - /* In the future this will allow us to implement face manipulators, + /* In the future this will allow us to implement face gizmos, * and similar functionalities. For now we handle only pose bones. */ if (ob->type == OB_ARMATURE) { diff --git a/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c index e8804238590..11708f5b5ce 100644 --- a/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c +++ b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c @@ -132,7 +132,7 @@ static unsigned short indices[] = { 3, 1, 17, }; -ManipulatorGeomInfo wm_manipulator_geom_data_arrow = { +GizmoGeomInfo wm_gizmo_geom_data_arrow = { .nverts = 25, .ntris = 46, .verts = verts, diff --git a/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c index f2d03821302..28eb772c082 100644 --- a/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c +++ b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c @@ -66,7 +66,7 @@ static const unsigned short indices[] = { 4, 0, 7, }; -ManipulatorGeomInfo wm_manipulator_geom_data_cube = { +GizmoGeomInfo wm_gizmo_geom_data_cube = { .nverts = 8, .ntris = 12, .verts = verts, diff --git a/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c index bc3fb6fcaff..0225a662ff3 100644 --- a/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c +++ b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c @@ -804,7 +804,7 @@ static const unsigned short indices[] = { 186, 191, 0, }; -ManipulatorGeomInfo wm_manipulator_geom_data_dial = { +GizmoGeomInfo wm_gizmo_geom_data_dial = { .nverts = 192, .ntris = 384, .verts = verts, diff --git a/source/blender/editors/gizmo_library/gizmo_draw_utils.c b/source/blender/editors/gizmo_library/gizmo_draw_utils.c index 8ae21f61758..aaaee182c71 100644 --- a/source/blender/editors/gizmo_library/gizmo_draw_utils.c +++ b/source/blender/editors/gizmo_library/gizmo_draw_utils.c @@ -50,18 +50,18 @@ #include "WM_api.h" #include "WM_types.h" -/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */ #include "wm.h" /* own includes */ #include "gizmo_library_intern.h" /** - * Main draw call for ManipulatorGeomInfo data + * Main draw call for GizmoGeomInfo data */ -void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const bool UNUSED(select), const float color[4]) +void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(select), const float color[4]) { - /* TODO store the Batches inside the ManipulatorGeomInfo and updated it when geom changes + /* TODO store the Batches inside the GizmoGeomInfo and updated it when geom changes * So we don't need to re-created and discard it every time */ Gwn_VertBuf *vbo; @@ -108,7 +108,7 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo GWN_batch_discard(batch); } -void wm_manipulator_vec_draw( +void wm_gizmo_vec_draw( const float color[4], const float (*verts)[3], uint vert_count, uint pos, uint primitive_type) { diff --git a/source/blender/editors/gizmo_library/gizmo_geometry.h b/source/blender/editors/gizmo_library/gizmo_geometry.h index de976bbad48..254fb6b0957 100644 --- a/source/blender/editors/gizmo_library/gizmo_geometry.h +++ b/source/blender/editors/gizmo_library/gizmo_geometry.h @@ -24,31 +24,31 @@ /** \file gizmo_geometry.h * \ingroup wm * - * \name Manipulator Geometry + * \name Gizmo Geometry * - * \brief Prototypes for arrays defining the manipulator geometry. The actual definitions can be found in files usually - * called geom_xxx_manipulator.c + * \brief Prototypes for arrays defining the gizmo geometry. The actual definitions can be found in files usually + * called geom_xxx_gizmo.c */ #ifndef __GIZMO_GEOMETRY_H__ #define __GIZMO_GEOMETRY_H__ -typedef struct ManipulatorGeomInfo { +typedef struct GizmoGeomInfo { int nverts; int ntris; const float (*verts)[3]; const float (*normals)[3]; const unsigned short *indices; -} ManipulatorGeomInfo; +} GizmoGeomInfo; -/* arrow manipulator */ -extern ManipulatorGeomInfo wm_manipulator_geom_data_arrow; +/* arrow gizmo */ +extern GizmoGeomInfo wm_gizmo_geom_data_arrow; -/* cube manipulator */ -extern ManipulatorGeomInfo wm_manipulator_geom_data_cube; +/* cube gizmo */ +extern GizmoGeomInfo wm_gizmo_geom_data_cube; -/* dial manipulator */ -extern ManipulatorGeomInfo wm_manipulator_geom_data_dial; +/* dial gizmo */ +extern GizmoGeomInfo wm_gizmo_geom_data_dial; #endif /* __GIZMO_GEOMETRY_H__ */ diff --git a/source/blender/editors/gizmo_library/gizmo_library_intern.h b/source/blender/editors/gizmo_library/gizmo_library_intern.h index 17121d3752e..f1689ee93db 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_intern.h +++ b/source/blender/editors/gizmo_library/gizmo_library_intern.h @@ -30,25 +30,25 @@ #ifndef __GIZMO_LIBRARY_INTERN_H__ #define __GIZMO_LIBRARY_INTERN_H__ -/* distance around which manipulators respond to input (and get highlighted) */ -#define MANIPULATOR_HOTSPOT 14.0f +/* distance around which gizmos respond to input (and get highlighted) */ +#define GIZMO_HOTSPOT 14.0f /** - * Data for common interactions. Used in manipulator_library_utils.c functions. + * Data for common interactions. Used in gizmo_library_utils.c functions. */ -typedef struct ManipulatorCommonData { +typedef struct GizmoCommonData { int flag; float range_fac; /* factor for arrow min/max distance */ float offset; - /* property range for constrained manipulators */ + /* property range for constrained gizmos */ float range; - /* min/max value for constrained manipulators */ + /* min/max value for constrained gizmos */ float min, max; -} ManipulatorCommonData; +} GizmoCommonData; -typedef struct ManipulatorInteraction { +typedef struct GizmoInteraction { float init_value; /* initial property value */ float init_mval[2]; float init_offset; @@ -60,50 +60,50 @@ typedef struct ManipulatorInteraction { /* Total offset added by precision tweaking. * Needed to allow toggling precision on/off without causing jumps */ float precision_offset; -} ManipulatorInteraction; +} GizmoInteraction; -/* ManipulatorCommonData->flag */ +/* GizmoCommonData->flag */ enum { - MANIPULATOR_CUSTOM_RANGE_SET = (1 << 0), + GIZMO_CUSTOM_RANGE_SET = (1 << 0), }; -float manipulator_offset_from_value( - ManipulatorCommonData *data, const float value, +float gizmo_offset_from_value( + GizmoCommonData *data, const float value, const bool constrained, const bool inverted); -float manipulator_value_from_offset( - ManipulatorCommonData *data, ManipulatorInteraction *inter, const float offset, +float gizmo_value_from_offset( + GizmoCommonData *data, GizmoInteraction *inter, const float offset, const bool constrained, const bool inverted, const bool use_precision); -void manipulator_property_data_update( - struct wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, +void gizmo_property_data_update( + struct wmGizmo *mpr, GizmoCommonData *data, wmGizmoProperty *mpr_prop, const bool constrained, const bool inverted); -void manipulator_property_value_reset( - bContext *C, const struct wmManipulator *mpr, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop); +void gizmo_property_value_reset( + bContext *C, const struct wmGizmo *mpr, GizmoInteraction *inter, wmGizmoProperty *mpr_prop); /* -------------------------------------------------------------------- */ -void manipulator_color_get( - const struct wmManipulator *mpr, const bool highlight, +void gizmo_color_get( + const struct wmGizmo *mpr, const bool highlight, float r_color[4]); -bool manipulator_window_project_2d( - bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset, +bool gizmo_window_project_2d( + bContext *C, const struct wmGizmo *mpr, const float mval[2], int axis, bool use_offset, float r_co[2]); -bool manipulator_window_project_3d( - bContext *C, const struct wmManipulator *mpr, const float mval[2], bool use_offset, +bool gizmo_window_project_3d( + bContext *C, const struct wmGizmo *mpr, const float mval[2], bool use_offset, float r_co[3]); /* -------------------------------------------------------------------- */ -/* Manipulator drawing */ +/* Gizmo drawing */ #include "gizmo_geometry.h" -void wm_manipulator_geometryinfo_draw(const struct ManipulatorGeomInfo *info, const bool select, const float color[4]); -void wm_manipulator_vec_draw( +void wm_gizmo_geometryinfo_draw(const struct GizmoGeomInfo *info, const bool select, const float color[4]); +void wm_gizmo_vec_draw( const float color[4], const float (*verts)[3], uint vert_count, uint pos, uint primitive_type); diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c index d58e0c9dc85..8a6b92e48d6 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_presets.c +++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c @@ -21,9 +21,9 @@ /** \file blender/editors/gizmo_library/gizmo_library_presets.c * \ingroup wm * - * \name Manipulator Lib Presets + * \name Gizmo Lib Presets * - * \brief Preset shapes that can be drawn from any manipulator type. + * \brief Preset shapes that can be drawn from any gizmo type. */ #include "MEM_guardedalloc.h" @@ -57,7 +57,7 @@ #include "ED_gizmo_library.h" /* own include */ #include "gizmo_library_intern.h" /* own include */ -/* TODO, this is to be used by RNA. might move to ED_manipulator_library */ +/* TODO, this is to be used by RNA. might move to ED_gizmo_library */ /** * Given a single axis, orient the matrix to a different direction. @@ -80,15 +80,15 @@ static void single_axis_convert( /** * Use for all geometry. */ -static void ed_manipulator_draw_preset_geometry( - const struct wmManipulator *mpr, float mat[4][4], int select_id, - const ManipulatorGeomInfo *info) +static void ed_gizmo_draw_preset_geometry( + const struct wmGizmo *mpr, float mat[4][4], int select_id, + const GizmoGeomInfo *info) { const bool is_select = (select_id != -1); - const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + const bool is_highlight = is_select && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float color[4]; - manipulator_color_get(mpr, is_highlight, color); + gizmo_color_get(mpr, is_highlight, color); if (is_select) { GPU_select_load_id(select_id); @@ -96,7 +96,7 @@ static void ed_manipulator_draw_preset_geometry( gpuPushMatrix(); gpuMultMatrix(mat); - wm_manipulator_geometryinfo_draw(info, is_select, color); + wm_gizmo_geometryinfo_draw(info, is_select, color); gpuPopMatrix(); if (is_select) { @@ -104,36 +104,36 @@ static void ed_manipulator_draw_preset_geometry( } } -void ED_manipulator_draw_preset_box( - const struct wmManipulator *mpr, float mat[4][4], int select_id) +void ED_gizmo_draw_preset_box( + const struct wmGizmo *mpr, float mat[4][4], int select_id) { - ed_manipulator_draw_preset_geometry(mpr, mat, select_id, &wm_manipulator_geom_data_cube); + ed_gizmo_draw_preset_geometry(mpr, mat, select_id, &wm_gizmo_geom_data_cube); } -void ED_manipulator_draw_preset_arrow( - const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) +void ED_gizmo_draw_preset_arrow( + const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id) { float mat_rotate[4][4]; single_axis_convert(OB_POSZ, mat, axis, mat_rotate); - ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_manipulator_geom_data_arrow); + ed_gizmo_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_gizmo_geom_data_arrow); } -void ED_manipulator_draw_preset_circle( - const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) +void ED_gizmo_draw_preset_circle( + const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id) { float mat_rotate[4][4]; single_axis_convert(OB_POSZ, mat, axis, mat_rotate); - ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_manipulator_geom_data_dial); + ed_gizmo_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_gizmo_geom_data_dial); } -void ED_manipulator_draw_preset_facemap( - const bContext *C, const struct wmManipulator *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id) +void ED_gizmo_draw_preset_facemap( + const bContext *C, const struct wmGizmo *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id) { const bool is_select = (select_id != -1); - const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + const bool is_highlight = is_select && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float color[4]; - manipulator_color_get(mpr, is_highlight, color); + gizmo_color_get(mpr, is_highlight, color); if (is_select) { GPU_select_load_id(select_id); diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c index 794728dd03c..6e6bc2ed824 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_utils.c +++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c @@ -26,9 +26,9 @@ /** \file gizmo_library_utils.c * \ingroup wm * - * \name Manipulator Library Utilities + * \name Gizmo Library Utilities * - * \brief This file contains functions for common behaviors of manipulators. + * \brief This file contains functions for common behaviors of gizmos. */ #include "BLI_math.h" @@ -50,34 +50,34 @@ #include "gizmo_library_intern.h" /* factor for precision tweaking */ -#define MANIPULATOR_PRECISION_FAC 0.05f +#define GIZMO_PRECISION_FAC 0.05f -BLI_INLINE float manipulator_offset_from_value_constr( +BLI_INLINE float gizmo_offset_from_value_constr( const float range_fac, const float min, const float range, const float value, const bool inverted) { return inverted ? (range_fac * (min + range - value) / range) : (range_fac * (value / range)); } -BLI_INLINE float manipulator_value_from_offset_constr( +BLI_INLINE float gizmo_value_from_offset_constr( const float range_fac, const float min, const float range, const float value, const bool inverted) { return inverted ? (min + range - (value * range / range_fac)) : (value * range / range_fac); } -float manipulator_offset_from_value( - ManipulatorCommonData *data, const float value, const bool constrained, const bool inverted) +float gizmo_offset_from_value( + GizmoCommonData *data, const float value, const bool constrained, const bool inverted) { if (constrained) - return manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); + return gizmo_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); return value; } -float manipulator_value_from_offset( - ManipulatorCommonData *data, ManipulatorInteraction *inter, const float offset, +float gizmo_value_from_offset( + GizmoCommonData *data, GizmoInteraction *inter, const float offset, const bool constrained, const bool inverted, const bool use_precision) { const float max = data->min + data->range; @@ -88,26 +88,26 @@ float manipulator_value_from_offset( } inter->prev_offset = offset; - float ofs_new = inter->init_offset + offset - inter->precision_offset * (1.0f - MANIPULATOR_PRECISION_FAC); + float ofs_new = inter->init_offset + offset - inter->precision_offset * (1.0f - GIZMO_PRECISION_FAC); float value; if (constrained) { - value = manipulator_value_from_offset_constr(data->range_fac, data->min, data->range, ofs_new, inverted); + value = gizmo_value_from_offset_constr(data->range_fac, data->min, data->range, ofs_new, inverted); } else { value = ofs_new; } /* clamp to custom range */ - if (data->flag & MANIPULATOR_CUSTOM_RANGE_SET) { + if (data->flag & GIZMO_CUSTOM_RANGE_SET) { CLAMP(value, data->min, max); } return value; } -void manipulator_property_data_update( - wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, +void gizmo_property_data_update( + wmGizmo *mpr, GizmoCommonData *data, wmGizmoProperty *mpr_prop, const bool constrained, const bool inverted) { if (mpr_prop->custom_func.value_get_fn != NULL) { @@ -121,12 +121,12 @@ void manipulator_property_data_update( return; } - float value = WM_manipulator_target_property_value_get(mpr, mpr_prop); + float value = WM_gizmo_target_property_value_get(mpr, mpr_prop); if (constrained) { - if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) { + if ((data->flag & GIZMO_CUSTOM_RANGE_SET) == 0) { float range[2]; - if (WM_manipulator_target_property_range_get(mpr, mpr_prop, range)) { + if (WM_gizmo_target_property_range_get(mpr, mpr_prop, range)) { data->range = range[1] - range[0]; data->min = range[0]; } @@ -134,27 +134,27 @@ void manipulator_property_data_update( BLI_assert(0); } } - data->offset = manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); + data->offset = gizmo_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); } else { data->offset = value; } } -void manipulator_property_value_reset( - bContext *C, const wmManipulator *mpr, ManipulatorInteraction *inter, - wmManipulatorProperty *mpr_prop) +void gizmo_property_value_reset( + bContext *C, const wmGizmo *mpr, GizmoInteraction *inter, + wmGizmoProperty *mpr_prop) { - WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_value); + WM_gizmo_target_property_value_set(C, mpr, mpr_prop, inter->init_value); } /* -------------------------------------------------------------------- */ -void manipulator_color_get( - const wmManipulator *mpr, const bool highlight, +void gizmo_color_get( + const wmGizmo *mpr, const bool highlight, float r_col[4]) { - if (highlight && !(mpr->flag & WM_MANIPULATOR_DRAW_HOVER)) { + if (highlight && !(mpr->flag & WM_GIZMO_DRAW_HOVER)) { copy_v4_v4(r_col, mpr->color_hi); } else { @@ -165,26 +165,26 @@ void manipulator_color_get( /* -------------------------------------------------------------------- */ /** - * Takes mouse coordinates and returns them in relation to the manipulator. - * Both 2D & 3D supported, use so we can use 2D manipulators in the 3D view. + * Takes mouse coordinates and returns them in relation to the gizmo. + * Both 2D & 3D supported, use so we can use 2D gizmos in the 3D view. */ -bool manipulator_window_project_2d( - bContext *C, const struct wmManipulator *mpr, const float mval[2], int axis, bool use_offset, +bool gizmo_window_project_2d( + bContext *C, const struct wmGizmo *mpr, const float mval[2], int axis, bool use_offset, float r_co[2]) { float mat[4][4]; { float mat_identity[4][4]; - struct WM_ManipulatorMatrixParams params = {NULL}; + struct WM_GizmoMatrixParams params = {NULL}; if (use_offset == false) { unit_m4(mat_identity); params.matrix_offset = mat_identity; } - WM_manipulator_calc_matrix_final_params(mpr, ¶ms, mat); + WM_gizmo_calc_matrix_final_params(mpr, ¶ms, mat); } /* rotate mouse in relation to the center and relocate it */ - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { /* For 3d views, transform 2D mouse pos onto plane. */ View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); @@ -220,26 +220,26 @@ bool manipulator_window_project_2d( } } -bool manipulator_window_project_3d( - bContext *C, const struct wmManipulator *mpr, const float mval[2], bool use_offset, +bool gizmo_window_project_3d( + bContext *C, const struct wmGizmo *mpr, const float mval[2], bool use_offset, float r_co[3]) { float mat[4][4]; { float mat_identity[4][4]; - struct WM_ManipulatorMatrixParams params = {NULL}; + struct WM_GizmoMatrixParams params = {NULL}; if (use_offset == false) { unit_m4(mat_identity); params.matrix_offset = mat_identity; } - WM_manipulator_calc_matrix_final_params(mpr, ¶ms, mat); + WM_gizmo_calc_matrix_final_params(mpr, ¶ms, mat); } - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); /* Note: we might want a custom reference point passed in, - * instead of the manipulator center. */ + * instead of the gizmo center. */ ED_view3d_win_to_3d(v3d, ar, mat[3], mval, r_co); invert_m4(mat); mul_m4_v3(mat, r_co); diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c index fbb30b95562..dfa2eeeb38b 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c @@ -26,9 +26,9 @@ /** \file arrow2d_gizmo.c * \ingroup wm * - * \name 2D Arrow Manipulator + * \name 2D Arrow Gizmo * - * \brief Simple arrow manipulator which is dragged into a certain direction. + * \brief Simple arrow gizmo which is dragged into a certain direction. */ #include "BLI_listbase.h" @@ -61,7 +61,7 @@ #include "../gizmo_library_intern.h" -static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], const float color[4]) +static void arrow2d_draw_geom(wmGizmo *mpr, const float matrix[4][4], const float color[4]) { const float size = 0.11f; const float size_breadth = size / 2.0f; @@ -96,24 +96,24 @@ static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], cons gpuPopMatrix(); } -static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *mpr) +static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *mpr) { float color[4]; float matrix_final[4][4]; - manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, color); + gizmo_color_get(mpr, mpr->state & WM_GIZMO_STATE_HIGHLIGHT, color); GPU_line_width(mpr->line_width); - WM_manipulator_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(mpr, matrix_final); GPU_blend(true); arrow2d_draw_geom(mpr, matrix_final, color); GPU_blend(false); if (mpr->interaction_data) { - ManipulatorInteraction *inter = mpr->interaction_data; + GizmoInteraction *inter = mpr->interaction_data; GPU_blend(true); arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); @@ -121,26 +121,26 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *m } } -static void manipulator_arrow2d_setup(wmManipulator *mpr) +static void gizmo_arrow2d_setup(wmGizmo *mpr) { - mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; + mpr->flag |= WM_GIZMO_DRAW_MODAL; } -static int manipulator_arrow2d_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) +static int gizmo_arrow2d_invoke( + bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *UNUSED(event)) { - ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); + GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); copy_m4_m4(inter->init_matrix_basis, mpr->matrix_basis); - WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); + WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); mpr->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } -static int manipulator_arrow2d_test_select( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +static int gizmo_arrow2d_test_select( + bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) { const float mval[2] = {event->mval[0], event->mval[1]}; const float arrow_length = RNA_float_get(mpr->ptr, "length"); @@ -165,14 +165,14 @@ static int manipulator_arrow2d_test_select( /* arrow line intersection check */ float isect_1[2], isect_2[2]; const int isect = isect_line_sphere_v2( - line[0], line[1], mval_local, MANIPULATOR_HOTSPOT + mpr->line_width * 0.5f, + line[0], line[1], mval_local, GIZMO_HOTSPOT + mpr->line_width * 0.5f, isect_1, isect_2); if (isect > 0) { float line_ext[2][2]; /* extended line for segment check including hotspot */ copy_v2_v2(line_ext[0], line[0]); - line_ext[1][0] = line[1][0] + MANIPULATOR_HOTSPOT * ((line[1][0] - line[0][0]) / line_len); - line_ext[1][1] = line[1][1] + MANIPULATOR_HOTSPOT * ((line[1][1] - line[0][1]) / line_len); + line_ext[1][0] = line[1][0] + GIZMO_HOTSPOT * ((line[1][0] - line[0][0]) / line_len); + line_ext[1][1] = line[1][1] + GIZMO_HOTSPOT * ((line[1][1] - line[0][1]) / line_len); const float lambda_1 = line_point_factor_v2(isect_1, line_ext[0], line_ext[1]); if (isect == 1) { @@ -193,22 +193,22 @@ static int manipulator_arrow2d_test_select( } /* -------------------------------------------------------------------- */ -/** \name 2D Arrow Manipulator API +/** \name 2D Arrow Gizmo API * * \{ */ -static void MANIPULATOR_WT_arrow_2d(wmManipulatorType *wt) +static void GIZMO_WT_arrow_2d(wmGizmoType *wt) { /* identifiers */ - wt->idname = "MANIPULATOR_WT_arrow_2d"; + wt->idname = "GIZMO_WT_arrow_2d"; /* api callbacks */ - wt->draw = manipulator_arrow2d_draw; - wt->setup = manipulator_arrow2d_setup; - wt->invoke = manipulator_arrow2d_invoke; - wt->test_select = manipulator_arrow2d_test_select; + wt->draw = gizmo_arrow2d_draw; + wt->setup = gizmo_arrow2d_setup; + wt->invoke = gizmo_arrow2d_invoke; + wt->test_select = gizmo_arrow2d_test_select; - wt->struct_size = sizeof(wmManipulator); + wt->struct_size = sizeof(wmGizmo); /* rna */ RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); @@ -217,9 +217,9 @@ static void MANIPULATOR_WT_arrow_2d(wmManipulatorType *wt) "Roll", "", DEG2RADF(-360.0f), DEG2RADF(360.0f)); } -void ED_manipulatortypes_arrow_2d(void) +void ED_gizmotypes_arrow_2d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_arrow_2d); + WM_gizmotype_append(GIZMO_WT_arrow_2d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index 72b24e03c00..9807a111d26 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -26,15 +26,15 @@ /** \file arrow3d_gizmo.c * \ingroup wm * - * \name Arrow Manipulator + * \name Arrow Gizmo * - * 3D Manipulator + * 3D Gizmo * - * \brief Simple arrow manipulator which is dragged into a certain direction. + * \brief Simple arrow gizmo which is dragged into a certain direction. * The arrow head can have varying shapes, e.g. cone, box, etc. * * - `matrix[0]` is derived from Y and Z. - * - `matrix[1]` is 'up' for manipulator types that have an up. + * - `matrix[1]` is 'up' for gizmo types that have an up. * - `matrix[2]` is the arrow direction (for all arrowes). */ @@ -69,35 +69,35 @@ #include "../gizmo_geometry.h" #include "../gizmo_library_intern.h" -/* to use custom arrows exported to geom_arrow_manipulator.c */ -//#define USE_MANIPULATOR_CUSTOM_ARROWS +/* to use custom arrows exported to geom_arrow_gizmo.c */ +//#define USE_GIZMO_CUSTOM_ARROWS -typedef struct ArrowManipulator3D { - wmManipulator manipulator; - ManipulatorCommonData data; -} ArrowManipulator3D; +typedef struct ArrowGizmo3D { + wmGizmo gizmo; + GizmoCommonData data; +} ArrowGizmo3D; /* -------------------------------------------------------------------- */ -static void manipulator_arrow_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4]) +static void gizmo_arrow_matrix_basis_get(const wmGizmo *mpr, float r_matrix[4][4]) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; - copy_m4_m4(r_matrix, arrow->manipulator.matrix_basis); - madd_v3_v3fl(r_matrix[3], arrow->manipulator.matrix_basis[2], arrow->data.offset); + copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis); + madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset); } -static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float color[4]) +static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4]) { uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); bool unbind_shader = true; - const int draw_style = RNA_enum_get(arrow->manipulator.ptr, "draw_style"); - const int draw_options = RNA_enum_get(arrow->manipulator.ptr, "draw_options"); + const int draw_style = RNA_enum_get(arrow->gizmo.ptr, "draw_style"); + const int draw_options = RNA_enum_get(arrow->gizmo.ptr, "draw_options"); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CROSS) { + if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) { immUniformColor4fv(color); immBegin(GWN_PRIM_LINES, 4); @@ -107,9 +107,9 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, immVertex3f(pos, 0.0f, 1.0f, 0.0f); immEnd(); } - else if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CONE) { + else if (draw_style == ED_GIZMO_ARROW_STYLE_CONE) { float aspect[2]; - RNA_float_get_array(arrow->manipulator.ptr, "aspect", aspect); + RNA_float_get_array(arrow->gizmo.ptr, "aspect", aspect); const float unitx = aspect[0]; const float unity = aspect[1]; const float vec[4][3] = { @@ -119,23 +119,23 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, {-unitx, unity, 0}, }; - GPU_line_width(arrow->manipulator.line_width); - wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP); + GPU_line_width(arrow->gizmo.line_width); + wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP); } else { -#ifdef USE_MANIPULATOR_CUSTOM_ARROWS - wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_arrow, select, color); +#ifdef USE_GIZMO_CUSTOM_ARROWS + wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_arrow, select, color); #else - const float arrow_length = RNA_float_get(arrow->manipulator.ptr, "length"); + const float arrow_length = RNA_float_get(arrow->gizmo.ptr, "length"); const float vec[2][3] = { {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, arrow_length}, }; - if (draw_options & ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM) { - GPU_line_width(arrow->manipulator.line_width); - wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP); + if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) { + GPU_line_width(arrow->gizmo.line_width); + wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP); } else { immUniformColor4fv(color); @@ -145,7 +145,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, gpuPushMatrix(); - if (draw_style == ED_MANIPULATOR_ARROW_STYLE_BOX) { + if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) { const float size = 0.05f; /* translate to line end with some extra offset so box starts exactly where line ends */ @@ -156,10 +156,10 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, /* draw cube */ immUnbindProgram(); unbind_shader = false; - wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_cube, select, color); + wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_cube, select, color); } else { - BLI_assert(draw_style == ED_MANIPULATOR_ARROW_STYLE_NORMAL); + BLI_assert(draw_style == ED_GIZMO_ARROW_STYLE_NORMAL); const float len = 0.25f; const float width = 0.06f; @@ -172,7 +172,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, } gpuPopMatrix(); -#endif /* USE_MANIPULATOR_CUSTOM_ARROWS */ +#endif /* USE_GIZMO_CUSTOM_ARROWS */ } if (unbind_shader) { @@ -180,15 +180,15 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, } } -static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, const bool highlight) +static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight) { - wmManipulator *mpr = &arrow->manipulator; + wmGizmo *mpr = &arrow->gizmo; float color[4]; float matrix_final[4][4]; - manipulator_color_get(mpr, highlight, color); + gizmo_color_get(mpr, highlight, color); - WM_manipulator_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(mpr, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); @@ -199,7 +199,7 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons gpuPopMatrix(); if (mpr->interaction_data) { - ManipulatorInteraction *inter = mpr->interaction_data; + GizmoInteraction *inter = mpr->interaction_data; gpuPushMatrix(); gpuMultMatrix(inter->init_matrix_final); @@ -213,29 +213,29 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons } } -static void manipulator_arrow_draw_select( - const bContext *UNUSED(C), wmManipulator *mpr, +static void gizmo_arrow_draw_select( + const bContext *UNUSED(C), wmGizmo *mpr, int select_id) { GPU_select_load_id(select_id); - arrow_draw_intern((ArrowManipulator3D *)mpr, true, false); + arrow_draw_intern((ArrowGizmo3D *)mpr, true, false); } -static void manipulator_arrow_draw(const bContext *UNUSED(C), wmManipulator *mpr) +static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *mpr) { - arrow_draw_intern((ArrowManipulator3D *)mpr, false, (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0); + arrow_draw_intern((ArrowGizmo3D *)mpr, false, (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0); } /** * Calculate arrow offset independent from prop min value, * meaning the range will not be offset by min value first. */ -static int manipulator_arrow_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak tweak_flag) +static int gizmo_arrow_modal( + bContext *C, wmGizmo *mpr, const wmEvent *event, + eWM_GizmoFlagTweak tweak_flag) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - ManipulatorInteraction *inter = mpr->interaction_data; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + GizmoInteraction *inter = mpr->interaction_data; View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; @@ -256,7 +256,7 @@ static int manipulator_arrow_modal( float arrow_co[3]; float arrow_no[3]; copy_v3_v3(arrow_co, inter->init_matrix_basis[3]); - normalize_v3_v3(arrow_no, arrow->manipulator.matrix_basis[2]); + normalize_v3_v3(arrow_no, arrow->gizmo.matrix_basis[2]); int ok = 0; @@ -268,7 +268,7 @@ static int manipulator_arrow_modal( { /* Force Y axis if we're view aligned */ if (j == 0) { - if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->manipulator.matrix_basis[2]))) < 5.0f) { + if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) { normalize_v3_v3(arrow_no, rv3d->viewinv[1]); } } @@ -296,24 +296,24 @@ static int manipulator_arrow_modal( sub_v3_v3v3(offset, proj[1].location, proj[0].location); facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1; - ManipulatorCommonData *data = &arrow->data; + GizmoCommonData *data = &arrow->data; const float ofs_new = facdir * len_v3(offset); - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); /* set the property for the operator and call its modal function */ - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - const int transform_flag = RNA_enum_get(arrow->manipulator.ptr, "transform"); - const bool constrained = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED) != 0; - const bool inverted = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED) != 0; - const bool use_precision = (tweak_flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0; - float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); - - WM_manipulator_target_property_value_set(C, mpr, mpr_prop, value); + if (WM_gizmo_target_property_is_valid(mpr_prop)) { + const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform"); + const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0; + const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0; + const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0; + float value = gizmo_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); + + WM_gizmo_target_property_value_set(C, mpr, mpr_prop, value); /* get clamped value */ - value = WM_manipulator_target_property_value_get(mpr, mpr_prop); + value = WM_gizmo_target_property_value_get(mpr, mpr_prop); - data->offset = manipulator_offset_from_value(data, value, constrained, inverted); + data->offset = gizmo_offset_from_value(data, value, constrained, inverted); } else { data->offset = ofs_new; @@ -326,25 +326,25 @@ static int manipulator_arrow_modal( return OPERATOR_RUNNING_MODAL; } -static void manipulator_arrow_setup(wmManipulator *mpr) +static void gizmo_arrow_setup(wmGizmo *mpr) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; - arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_MODAL; + arrow->gizmo.flag |= WM_GIZMO_DRAW_MODAL; arrow->data.range_fac = 1.0f; } -static int manipulator_arrow_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +static int gizmo_arrow_invoke( + bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - /* Some manipulators don't use properties. */ - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - inter->init_value = WM_manipulator_target_property_value_get(mpr, mpr_prop); + /* Some gizmos don't use properties. */ + if (WM_gizmo_target_property_is_valid(mpr_prop)) { + inter->init_value = WM_gizmo_target_property_value_get(mpr, mpr_prop); } inter->init_offset = arrow->data.offset; @@ -352,126 +352,126 @@ static int manipulator_arrow_invoke( inter->init_mval[0] = event->mval[0]; inter->init_mval[1] = event->mval[1]; - manipulator_arrow_matrix_basis_get(mpr, inter->init_matrix_basis); - WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); + gizmo_arrow_matrix_basis_get(mpr, inter->init_matrix_basis); + WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); mpr->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } -static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +static void gizmo_arrow_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - const int transform_flag = RNA_enum_get(arrow->manipulator.ptr, "transform"); - const bool constrained = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED) != 0; - const bool inverted = (transform_flag & ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED) != 0; - manipulator_property_data_update(mpr, &arrow->data, mpr_prop, constrained, inverted); + ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform"); + const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0; + const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0; + gizmo_property_data_update(mpr, &arrow->data, mpr_prop, constrained, inverted); } -static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool cancel) +static void gizmo_arrow_exit(bContext *C, wmGizmo *mpr, const bool cancel) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - ManipulatorCommonData *data = &arrow->data; - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - const bool is_prop_valid = WM_manipulator_target_property_is_valid(mpr_prop); + ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + GizmoCommonData *data = &arrow->data; + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + const bool is_prop_valid = WM_gizmo_target_property_is_valid(mpr_prop); if (!cancel) { /* Assign incase applying the opetration needs an updated offset * editmesh bisect needs this. */ if (is_prop_valid) { - data->offset = WM_manipulator_target_property_value_get(mpr, mpr_prop); + data->offset = WM_gizmo_target_property_value_get(mpr, mpr_prop); } return; } - ManipulatorInteraction *inter = mpr->interaction_data; + GizmoInteraction *inter = mpr->interaction_data; if (is_prop_valid) { - manipulator_property_value_reset(C, mpr, inter, mpr_prop); + gizmo_property_value_reset(C, mpr, inter, mpr_prop); } data->offset = inter->init_offset; } /* -------------------------------------------------------------------- */ -/** \name Arrow Manipulator API +/** \name Arrow Gizmo API * * \{ */ /** * Define a custom property UI range * - * \note Needs to be called before WM_manipulator_target_property_def_rna! + * \note Needs to be called before WM_gizmo_target_property_def_rna! */ -void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, const float max) +void ED_gizmo_arrow3d_set_ui_range(wmGizmo *mpr, const float min, const float max) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; BLI_assert(min < max); - BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr, "offset")) && - "Make sure this function is called before WM_manipulator_target_property_def_rna")); + BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(mpr, "offset")) && + "Make sure this function is called before WM_gizmo_target_property_def_rna")); arrow->data.range = max - min; arrow->data.min = min; - arrow->data.flag |= MANIPULATOR_CUSTOM_RANGE_SET; + arrow->data.flag |= GIZMO_CUSTOM_RANGE_SET; } /** * Define a custom factor for arrow min/max distance * - * \note Needs to be called before WM_manipulator_target_property_def_rna! + * \note Needs to be called before WM_gizmo_target_property_def_rna! */ -void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac) +void ED_gizmo_arrow3d_set_range_fac(wmGizmo *mpr, const float range_fac) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr, "offset")) && - "Make sure this function is called before WM_manipulator_target_property_def_rna")); + ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(mpr, "offset")) && + "Make sure this function is called before WM_gizmo_target_property_def_rna")); arrow->data.range_fac = range_fac; } -static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt) +static void GIZMO_WT_arrow_3d(wmGizmoType *wt) { /* identifiers */ - wt->idname = "MANIPULATOR_WT_arrow_3d"; + wt->idname = "GIZMO_WT_arrow_3d"; /* api callbacks */ - wt->draw = manipulator_arrow_draw; - wt->draw_select = manipulator_arrow_draw_select; - wt->matrix_basis_get = manipulator_arrow_matrix_basis_get; - wt->modal = manipulator_arrow_modal; - wt->setup = manipulator_arrow_setup; - wt->invoke = manipulator_arrow_invoke; - wt->property_update = manipulator_arrow_property_update; - wt->exit = manipulator_arrow_exit; + wt->draw = gizmo_arrow_draw; + wt->draw_select = gizmo_arrow_draw_select; + wt->matrix_basis_get = gizmo_arrow_matrix_basis_get; + wt->modal = gizmo_arrow_modal; + wt->setup = gizmo_arrow_setup; + wt->invoke = gizmo_arrow_invoke; + wt->property_update = gizmo_arrow_property_update; + wt->exit = gizmo_arrow_exit; - wt->struct_size = sizeof(ArrowManipulator3D); + wt->struct_size = sizeof(ArrowGizmo3D); /* rna */ static EnumPropertyItem rna_enum_draw_style_items[] = { - {ED_MANIPULATOR_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""}, - {ED_MANIPULATOR_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""}, - {ED_MANIPULATOR_ARROW_STYLE_BOX, "BOX", 0, "Box", ""}, - {ED_MANIPULATOR_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""}, + {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""}, + {ED_GIZMO_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""}, + {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""}, + {ED_GIZMO_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""}, {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem rna_enum_draw_options_items[] = { - {ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""}, + {ED_GIZMO_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""}, {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem rna_enum_transform_items[] = { - {ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""}, - {ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""}, + {ED_GIZMO_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""}, + {ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""}, {0, NULL, 0, NULL, NULL} }; RNA_def_enum( wt->srna, "draw_style", rna_enum_draw_style_items, - ED_MANIPULATOR_ARROW_STYLE_NORMAL, + ED_GIZMO_ARROW_STYLE_NORMAL, "Draw Style", ""); RNA_def_enum_flag( wt->srna, "draw_options", rna_enum_draw_options_items, - ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM, + ED_GIZMO_ARROW_DRAW_FLAG_STEM, "Draw Options", ""); RNA_def_enum_flag( wt->srna, "transform", rna_enum_transform_items, @@ -481,12 +481,12 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt) RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); RNA_def_float_vector(wt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX); - WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1); + WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 1); } -void ED_manipulatortypes_arrow_3d(void) +void ED_gizmotypes_arrow_3d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_arrow_3d); + WM_gizmotype_append(GIZMO_WT_arrow_3d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index 78f374064e6..33639dd7ec7 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -21,11 +21,11 @@ /** \file button2d_gizmo.c * \ingroup wm * - * \name Button Manipulator + * \name Button Gizmo * - * 2D Manipulator, also works in 3D views. + * 2D Gizmo, also works in 3D views. * - * \brief Single click button action for use in manipulator groups. + * \brief Single click button action for use in gizmo groups. * * \note Currently only basic icon & vector-shape buttons are supported. * @@ -66,20 +66,20 @@ #include "../gizmo_geometry.h" #include "../gizmo_library_intern.h" -typedef struct ButtonManipulator2D { - wmManipulator manipulator; +typedef struct ButtonGizmo2D { + wmGizmo gizmo; bool is_init; /* Use an icon or shape */ int icon; Gwn_Batch *shape_batch[2]; -} ButtonManipulator2D; +} ButtonGizmo2D; #define CIRCLE_RESOLUTION 32 /* -------------------------------------------------------------------- */ static void button2d_geom_draw_backdrop( - const wmManipulator *mpr, const float color[4], const bool select) + const wmGizmo *mpr, const float color[4], const bool select) { GPU_line_width(mpr->line_width); @@ -99,10 +99,10 @@ static void button2d_geom_draw_backdrop( } static void button2d_draw_intern( - const bContext *C, wmManipulator *mpr, + const bContext *C, wmGizmo *mpr, const bool select, const bool highlight) { - ButtonManipulator2D *button = (ButtonManipulator2D *)mpr; + ButtonGizmo2D *button = (ButtonGizmo2D *)mpr; const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); if (button->is_init == false) { @@ -126,16 +126,16 @@ static void button2d_draw_intern( float color[4]; float matrix_final[4][4]; - manipulator_color_get(mpr, highlight, color); - WM_manipulator_calc_matrix_final(mpr, matrix_final); + gizmo_color_get(mpr, highlight, color); + WM_gizmo_calc_matrix_final(mpr, matrix_final); - bool is_3d = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) != 0; + bool is_3d = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) != 0; - if (draw_options & ED_MANIPULATOR_BUTTON_SHOW_HELPLINE) { + if (draw_options & ED_GIZMO_BUTTON_SHOW_HELPLINE) { float matrix_final_no_offset[4][4]; - WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); + WM_gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); @@ -180,7 +180,7 @@ static void button2d_draw_intern( GWN_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color)); GWN_batch_draw(button->shape_batch[i]); - if (draw_options & ED_MANIPULATOR_BUTTON_SHOW_OUTLINE) { + if (draw_options & ED_GIZMO_BUTTON_SHOW_OUTLINE) { color[0] = 1.0f - color[0]; color[1] = 1.0f - color[1]; color[2] = 1.0f - color[2]; @@ -215,29 +215,29 @@ static void button2d_draw_intern( } } -static void manipulator_button2d_draw_select(const bContext *C, wmManipulator *mpr, int select_id) +static void gizmo_button2d_draw_select(const bContext *C, wmGizmo *mpr, int select_id) { GPU_select_load_id(select_id); button2d_draw_intern(C, mpr, true, false); } -static void manipulator_button2d_draw(const bContext *C, wmManipulator *mpr) +static void gizmo_button2d_draw(const bContext *C, wmGizmo *mpr) { - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; GPU_blend(true); button2d_draw_intern(C, mpr, false, is_highlight); GPU_blend(false); } -static int manipulator_button2d_test_select( - bContext *C, wmManipulator *mpr, const wmEvent *event) +static int gizmo_button2d_test_select( + bContext *C, wmGizmo *mpr, const wmEvent *event) { float point_local[2]; if (0) { /* correct, but unnecessarily slow. */ - if (manipulator_window_project_2d( + if (gizmo_window_project_2d( C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; @@ -256,7 +256,7 @@ static int manipulator_button2d_test_select( return -1; } -static int manipulator_button2d_cursor_get(wmManipulator *mpr) +static int gizmo_button2d_cursor_get(wmGizmo *mpr) { if (RNA_boolean_get(mpr->ptr, "show_drag")) { return BC_NSEW_SCROLLCURSOR; @@ -264,9 +264,9 @@ static int manipulator_button2d_cursor_get(wmManipulator *mpr) return CURSOR_STD; } -static void manipulator_button2d_free(wmManipulator *mpr) +static void gizmo_button2d_free(wmGizmo *mpr) { - ButtonManipulator2D *shape = (ButtonManipulator2D *)mpr; + ButtonGizmo2D *shape = (ButtonGizmo2D *)mpr; for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) { GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]); @@ -276,28 +276,28 @@ static void manipulator_button2d_free(wmManipulator *mpr) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Button Manipulator API +/** \name Button Gizmo API * * \{ */ -static void MANIPULATOR_WT_button_2d(wmManipulatorType *wt) +static void GIZMO_WT_button_2d(wmGizmoType *wt) { /* identifiers */ - wt->idname = "MANIPULATOR_WT_button_2d"; + wt->idname = "GIZMO_WT_button_2d"; /* api callbacks */ - wt->draw = manipulator_button2d_draw; - wt->draw_select = manipulator_button2d_draw_select; - wt->test_select = manipulator_button2d_test_select; - wt->cursor_get = manipulator_button2d_cursor_get; - wt->free = manipulator_button2d_free; + wt->draw = gizmo_button2d_draw; + wt->draw_select = gizmo_button2d_draw_select; + wt->test_select = gizmo_button2d_test_select; + wt->cursor_get = gizmo_button2d_cursor_get; + wt->free = gizmo_button2d_free; - wt->struct_size = sizeof(ButtonManipulator2D); + wt->struct_size = sizeof(ButtonGizmo2D); /* rna */ static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_BUTTON_SHOW_OUTLINE, "OUTLINE", 0, "Outline", ""}, - {ED_MANIPULATOR_BUTTON_SHOW_HELPLINE, "HELPLINE", 0, "Help Line", ""}, + {ED_GIZMO_BUTTON_SHOW_OUTLINE, "OUTLINE", 0, "Outline", ""}, + {ED_GIZMO_BUTTON_SHOW_HELPLINE, "HELPLINE", 0, "Help Line", ""}, {0, NULL, 0, NULL, NULL} }; PropertyRNA *prop; @@ -314,9 +314,9 @@ static void MANIPULATOR_WT_button_2d(wmManipulatorType *wt) RNA_def_boolean(wt->srna, "show_drag", true, "Show Drag", ""); } -void ED_manipulatortypes_button_2d(void) +void ED_gizmotypes_button_2d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_button_2d); + WM_gizmotype_append(GIZMO_WT_button_2d); } -/** \} */ // Button Manipulator API +/** \} */ // Button Gizmo API diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index 382733d298f..a037727de58 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -26,12 +26,12 @@ /** \file cage2d_gizmo.c * \ingroup wm * - * \name Cage Manipulator + * \name Cage Gizmo * - * 2D Manipulator + * 2D Gizmo * - * \brief Rectangular manipulator acting as a 'cage' around its content. - * Interacting scales or translates the manipulator. + * \brief Rectangular gizmo acting as a 'cage' around its content. + * Interacting scales or translates the gizmo. */ #include "MEM_guardedalloc.h" @@ -64,11 +64,11 @@ /* own includes */ #include "../gizmo_library_intern.h" -#define MANIPULATOR_RESIZER_SIZE 10.0f -#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f +#define GIZMO_RESIZER_SIZE 10.0f +#define GIZMO_MARGIN_OFFSET_SCALE 1.5f -static void manipulator_calc_rect_view_scale( - const wmManipulator *mpr, const float dims[2], float scale[2]) +static void gizmo_calc_rect_view_scale( + const wmGizmo *mpr, const float dims[2], float scale[2]) { float matrix_final_no_offset[4][4]; float asp[2] = {1.0f, 1.0f}; @@ -79,7 +79,7 @@ static void manipulator_calc_rect_view_scale( asp[1] = dims[0] / dims[1]; } float x_axis[3], y_axis[3]; - WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); + WM_gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); @@ -90,37 +90,37 @@ static void manipulator_calc_rect_view_scale( scale[1] = 1.0f / len_v3(y_axis); } -static void manipulator_calc_rect_view_margin( - const wmManipulator *mpr, const float dims[2], float margin[2]) +static void gizmo_calc_rect_view_margin( + const wmGizmo *mpr, const float dims[2], float margin[2]) { float handle_size; - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { handle_size = 0.15f; } else { - handle_size = MANIPULATOR_RESIZER_SIZE; + handle_size = GIZMO_RESIZER_SIZE; } handle_size *= mpr->scale_final; float scale_xy[2]; - manipulator_calc_rect_view_scale(mpr, dims, scale_xy); + gizmo_calc_rect_view_scale(mpr, dims, scale_xy); margin[0] = ((handle_size * scale_xy[0])); margin[1] = ((handle_size * scale_xy[1])); } /* -------------------------------------------------------------------- */ -static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_constrain_axis[2]) +static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_constrain_axis[2]) { bool x = true, y = true; switch (part) { - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.0); x = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.0); x = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, 0.5); y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, -0.5); y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.5); x = y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, -0.5); x = y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.5); x = y = false; break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, -0.5); x = y = false; break; } + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.0); x = false; break; } + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.0); x = false; break; } + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, 0.5); y = false; break; } + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.0, -0.5); y = false; break; } + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, 0.5); x = y = false; break; } + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, 0.5, -0.5); x = y = false; break; } + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, 0.5); x = y = false; break; } + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y: { ARRAY_SET_ITEMS(r_pt, -0.5, -0.5); x = y = false; break; } default: BLI_assert(0); } r_constrain_axis[0] = x; @@ -130,7 +130,7 @@ static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[2], bool /* -------------------------------------------------------------------- */ /** \name Box Draw Style * - * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX + * Useful for 3D views, see: #ED_GIZMO_CAGE2D_STYLE_BOX * \{ */ static void cage2d_draw_box_corners( @@ -179,7 +179,7 @@ static void cage2d_draw_box_interaction( Gwn_PrimType prim_type = GWN_PRIM_NONE; switch (highlighted) { - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X: { rctf r = { .xmin = -size[0], .xmax = -size[0] + margin[0], @@ -199,7 +199,7 @@ static void cage2d_draw_box_interaction( } break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X: { rctf r = { .xmin = size[0] - margin[0], .xmax = size[0], @@ -219,7 +219,7 @@ static void cage2d_draw_box_interaction( } break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y: { rctf r = { .xmin = -size[0] + margin[0], .xmax = size[0] - margin[0], @@ -239,7 +239,7 @@ static void cage2d_draw_box_interaction( } break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y: { rctf r = { .xmin = -size[0] + margin[0], .xmax = size[0] - margin[0], @@ -259,7 +259,7 @@ static void cage2d_draw_box_interaction( } break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y: { rctf r = { .xmin = -size[0], .xmax = -size[0] + margin[0], @@ -279,7 +279,7 @@ static void cage2d_draw_box_interaction( } break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y: { rctf r = { .xmin = -size[0], .xmax = -size[0] + margin[0], @@ -299,7 +299,7 @@ static void cage2d_draw_box_interaction( } break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y: { rctf r = { .xmin = size[0] - margin[0], .xmax = size[0], @@ -319,7 +319,7 @@ static void cage2d_draw_box_interaction( } break; } - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y: { rctf r = { .xmin = size[0] - margin[0], .xmax = size[0], @@ -339,7 +339,7 @@ static void cage2d_draw_box_interaction( } break; } - case ED_MANIPULATOR_CAGE2D_PART_ROTATE: + case ED_GIZMO_CAGE2D_PART_ROTATE: { const float rotate_pt[2] = {0.0f, size[1] + margin[1]}; const rctf r_rotate = { @@ -363,8 +363,8 @@ static void cage2d_draw_box_interaction( break; } - case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE: - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + case ED_GIZMO_CAGE2D_PART_TRANSLATE: + if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { ARRAY_SET_ITEMS(verts[0], -margin[0] / 2, -margin[1] / 2); ARRAY_SET_ITEMS(verts[1], margin[0] / 2, margin[1] / 2); ARRAY_SET_ITEMS(verts[2], -margin[0] / 2, margin[1] / 2); @@ -449,7 +449,7 @@ static void cage2d_draw_box_interaction( /* -------------------------------------------------------------------- */ /** \name Circle Draw Style * - * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE + * Useful for 2D views, see: #ED_GIZMO_CAGE2D_STYLE_CIRCLE * \{ */ static void imm_draw_point_aspect_2d( @@ -479,15 +479,15 @@ static void cage2d_draw_circle_wire( immVertex2f(pos, r->xmin, r->ymax); immEnd(); - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { immBegin(GWN_PRIM_LINE_LOOP, 2); immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax); immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax + margin[1]); immEnd(); } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { + if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { const float rad[2] = {margin[0] / 2, margin[1] / 2}; const float center[2] = {BLI_rctf_cent_x(r), BLI_rctf_cent_y(r)}; @@ -525,8 +525,8 @@ static void cage2d_draw_circle_handles( imm_draw_point_aspect_2d(pos, r->xmin, r->ymax, rad[0], rad[1], solid); } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { - const float handle[2] = {BLI_rctf_cent_x(r), r->ymax + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)}; + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { + const float handle[2] = {BLI_rctf_cent_x(r), r->ymax + (margin[1] * GIZMO_MARGIN_OFFSET_SCALE)}; circle_fn(pos, handle[0], handle[1], rad[0], rad[1], resolu); } @@ -535,10 +535,10 @@ static void cage2d_draw_circle_handles( /** \} */ -static void manipulator_cage2d_draw_intern( - wmManipulator *mpr, const bool select, const bool highlight, const int select_id) +static void gizmo_cage2d_draw_intern( + wmGizmo *mpr, const bool select, const bool highlight, const int select_id) { - // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; + // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; float dims[2]; RNA_float_get_array(mpr->ptr, "dimensions", dims); float matrix_final[4][4]; @@ -549,13 +549,13 @@ static void manipulator_cage2d_draw_intern( const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; - WM_manipulator_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(mpr, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); float margin[2]; - manipulator_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(mpr, dims, margin); /* Handy for quick testing draw (if it's outside bounds). */ if (false) { @@ -573,17 +573,17 @@ static void manipulator_cage2d_draw_intern( /* expand for hotspot */ const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE) { int scale_parts[] = { - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, - - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, + ED_GIZMO_CAGE2D_PART_SCALE_MIN_X, + ED_GIZMO_CAGE2D_PART_SCALE_MAX_X, + ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y, + ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y, + + ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y, + ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y, + ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y, + ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y, }; for (int i = 0; i < ARRAY_SIZE(scale_parts); i++) { GPU_select_load_id(select_id | scale_parts[i]); @@ -591,15 +591,15 @@ static void manipulator_cage2d_draw_intern( mpr->color, scale_parts[i], size, margin, mpr->line_width, true, draw_options); } } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - const int transform_part = ED_MANIPULATOR_CAGE2D_PART_TRANSLATE; + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { + const int transform_part = ED_GIZMO_CAGE2D_PART_TRANSLATE; GPU_select_load_id(select_id | transform_part); cage2d_draw_box_interaction( mpr->color, transform_part, size, margin, mpr->line_width, true, draw_options); } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { cage2d_draw_box_interaction( - mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, true, draw_options); + mpr->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, true, draw_options); } } else { @@ -609,22 +609,22 @@ static void manipulator_cage2d_draw_intern( .xmax = size_real[0], .ymax = size_real[1], }; - if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { - /* corner manipulators */ + if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) { + /* corner gizmos */ GPU_line_width(mpr->line_width + 3.0f); cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0}); - /* corner manipulators */ + /* corner gizmos */ float color[4]; - manipulator_color_get(mpr, highlight, color); + gizmo_color_get(mpr, highlight, color); GPU_line_width(mpr->line_width); cage2d_draw_box_corners(&r, margin, color); bool show = false; - if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) { + if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { /* Only show if we're drawing the center handle * otherwise the entire rectangle is the hotspot. */ - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { show = true; } } @@ -637,14 +637,14 @@ static void manipulator_cage2d_draw_intern( mpr->color, mpr->highlight_part, size_real, margin, mpr->line_width, false, draw_options); } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { cage2d_draw_box_interaction( - mpr->color, ED_MANIPULATOR_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, false, draw_options); + mpr->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, false, draw_options); } } - else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) { + else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) { float color[4]; - manipulator_color_get(mpr, highlight, color); + gizmo_color_get(mpr, highlight, color); GPU_line_smooth(true); GPU_blend(true); @@ -655,7 +655,7 @@ static void manipulator_cage2d_draw_intern( cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options); - /* corner manipulators */ + /* corner gizmos */ cage2d_draw_circle_handles(&r, margin, color, transform_flag, true); cage2d_draw_circle_handles(&r, margin, (const float[3]){0, 0, 0}, transform_flag, false); @@ -674,74 +674,74 @@ static void manipulator_cage2d_draw_intern( /** * For when we want to draw 2d cage in 3d views. */ -static void manipulator_cage2d_draw_select(const bContext *UNUSED(C), wmManipulator *mpr, int select_id) +static void gizmo_cage2d_draw_select(const bContext *UNUSED(C), wmGizmo *mpr, int select_id) { - manipulator_cage2d_draw_intern(mpr, true, false, select_id); + gizmo_cage2d_draw_intern(mpr, true, false, select_id); } -static void manipulator_cage2d_draw(const bContext *UNUSED(C), wmManipulator *mpr) +static void gizmo_cage2d_draw(const bContext *UNUSED(C), wmGizmo *mpr) { - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - manipulator_cage2d_draw_intern(mpr, false, is_highlight, -1); + const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + gizmo_cage2d_draw_intern(mpr, false, is_highlight, -1); } -static int manipulator_cage2d_get_cursor(wmManipulator *mpr) +static int gizmo_cage2d_get_cursor(wmGizmo *mpr) { int highlight_part = mpr->highlight_part; - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { return BC_NSEW_SCROLLCURSOR; } switch (highlight_part) { - case ED_MANIPULATOR_CAGE2D_PART_TRANSLATE: + case ED_GIZMO_CAGE2D_PART_TRANSLATE: return BC_NSEW_SCROLLCURSOR; - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X: - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X: + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X: + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X: return CURSOR_X_MOVE; - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y: - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y: return CURSOR_Y_MOVE; /* TODO diagonal cursor */ - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y: - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y: return BC_NSEW_SCROLLCURSOR; - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y: - case ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y: + case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y: return BC_NSEW_SCROLLCURSOR; - case ED_MANIPULATOR_CAGE2D_PART_ROTATE: + case ED_GIZMO_CAGE2D_PART_ROTATE: return BC_CROSSCURSOR; default: return CURSOR_STD; } } -static int manipulator_cage2d_test_select( - bContext *C, wmManipulator *mpr, const wmEvent *event) +static int gizmo_cage2d_test_select( + bContext *C, wmGizmo *mpr, const wmEvent *event) { float point_local[2]; float dims[2]; RNA_float_get_array(mpr->ptr, "dimensions", dims); const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; - if (manipulator_window_project_2d( + if (gizmo_window_project_2d( C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; } float margin[2]; - manipulator_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(mpr, dims, margin); /* expand for hotspot */ const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { rctf r; - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { r.xmin = -margin[0] / 2; r.ymin = -margin[1] / 2; r.xmax = margin[0] / 2; @@ -755,12 +755,12 @@ static int manipulator_cage2d_test_select( }; bool isect = BLI_rctf_isect_pt_v(&r, point_local); if (isect) { - return ED_MANIPULATOR_CAGE2D_PART_TRANSLATE; + return ED_GIZMO_CAGE2D_PART_TRANSLATE; } } - /* if manipulator does not have a scale intersection, don't do it */ - if (transform_flag & (ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM)) { + /* if gizmo does not have a scale intersection, don't do it */ + if (transform_flag & (ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM)) { const rctf r_xmin = {.xmin = -size[0], .ymin = -size[1], .xmax = -size[0] + margin[0], .ymax = size[1]}; const rctf r_xmax = {.xmin = size[0] - margin[0], .ymin = -size[1], .xmax = size[0], .ymax = size[1]}; const rctf r_ymin = {.xmin = -size[0], .ymin = -size[1], .xmax = size[0], .ymax = -size[1] + margin[1]}; @@ -768,37 +768,37 @@ static int manipulator_cage2d_test_select( if (BLI_rctf_isect_pt_v(&r_xmin, point_local)) { if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y; + return ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y; } if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y; + return ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y; } - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X; + return ED_GIZMO_CAGE2D_PART_SCALE_MIN_X; } if (BLI_rctf_isect_pt_v(&r_xmax, point_local)) { if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y; + return ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y; } if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y; + return ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y; } - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X; + return ED_GIZMO_CAGE2D_PART_SCALE_MAX_X; } if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y; + return ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y; } if (BLI_rctf_isect_pt_v(&r_ymax, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y; + return ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y; } } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { /* Rotate: * (*) <-- hot spot is here! * +---+ * | | * +---+ */ - const float r_rotate_pt[2] = {0.0f, size_real[1] + (margin[1] * MANIPULATOR_MARGIN_OFFSET_SCALE)}; + const float r_rotate_pt[2] = {0.0f, size_real[1] + (margin[1] * GIZMO_MARGIN_OFFSET_SCALE)}; const rctf r_rotate = { .xmin = r_rotate_pt[0] - margin[0] / 2.0f, .xmax = r_rotate_pt[0] + margin[0] / 2.0f, @@ -807,7 +807,7 @@ static int manipulator_cage2d_test_select( }; if (BLI_rctf_isect_pt_v(&r_rotate, point_local)) { - return ED_MANIPULATOR_CAGE2D_PART_ROTATE; + return ED_GIZMO_CAGE2D_PART_ROTATE; } } @@ -821,20 +821,20 @@ typedef struct RectTransformInteraction { Dial *dial; } RectTransformInteraction; -static void manipulator_cage2d_setup(wmManipulator *mpr) +static void gizmo_cage2d_setup(wmGizmo *mpr) { - mpr->flag |= WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_NO_SCALE; + mpr->flag |= WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_NO_SCALE; } -static int manipulator_cage2d_invoke( - bContext *C, wmManipulator *mpr, const wmEvent *event) +static int gizmo_cage2d_invoke( + bContext *C, wmGizmo *mpr, const wmEvent *event) { RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); - WM_manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset); + WM_gizmo_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset); - if (manipulator_window_project_2d( + if (gizmo_window_project_2d( C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) { zero_v2(data->orig_mouse); @@ -845,9 +845,9 @@ static int manipulator_cage2d_invoke( return OPERATOR_RUNNING_MODAL; } -static int manipulator_cage2d_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo_cage2d_modal( + bContext *C, wmGizmo *mpr, const wmEvent *event, + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { /* For transform logic to be managable we operate in -0.5..0.5 2D space, * no matter the size of the rectangle, mouse coorts are scaled to unit space. @@ -867,7 +867,7 @@ static int manipulator_cage2d_modal( copy_m4_m4(matrix_back, mpr->matrix_offset); copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - bool ok = manipulator_window_project_2d( + bool ok = gizmo_window_project_2d( C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local); copy_m4_m4(mpr->matrix_offset, matrix_back); if (!ok) { @@ -876,20 +876,20 @@ static int manipulator_cage2d_modal( } const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - wmManipulatorProperty *mpr_prop; + wmGizmoProperty *mpr_prop; - mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); + mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); } - if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_TRANSLATE) { + if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { /* do this to prevent clamping from changing size */ copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); } - else if (mpr->highlight_part == ED_MANIPULATOR_CAGE2D_PART_ROTATE) { + else if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_ROTATE) { #define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \ mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0})) @@ -935,8 +935,8 @@ static int manipulator_cage2d_modal( float pivot[2]; bool constrain_axis[2] = {false}; - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { + gizmo_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); } else { zero_v2(pivot); @@ -960,7 +960,7 @@ static int manipulator_cage2d_modal( scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i])); - if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) { + if ((transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) { if (sign != signum_i(scale[i])) { scale[i] = 0.0f; } @@ -968,7 +968,7 @@ static int manipulator_cage2d_modal( } } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) { if (constrain_axis[0] == false && constrain_axis[1] == false) { scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f; } @@ -995,7 +995,7 @@ static int manipulator_cage2d_modal( } if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); + WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); } /* tag the region for redraw */ @@ -1005,11 +1005,11 @@ static int manipulator_cage2d_modal( return OPERATOR_RUNNING_MODAL; } -static void manipulator_cage2d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +static void gizmo_cage2d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) { if (STREQ(mpr_prop->type->idname, "matrix")) { - if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (WM_gizmo_target_property_array_length(mpr, mpr_prop) == 16) { + WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); } else { BLI_assert(0); @@ -1020,7 +1020,7 @@ static void manipulator_cage2d_property_update(wmManipulator *mpr, wmManipulator } } -static void manipulator_cage2d_exit(bContext *C, wmManipulator *mpr, const bool cancel) +static void gizmo_cage2d_exit(bContext *C, wmGizmo *mpr, const bool cancel) { RectTransformInteraction *data = mpr->interaction_data; @@ -1029,12 +1029,12 @@ static void manipulator_cage2d_exit(bContext *C, wmManipulator *mpr, const bool if (!cancel) return; - wmManipulatorProperty *mpr_prop; + wmGizmoProperty *mpr_prop; /* reset properties */ - mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); + mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); + WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); } copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); @@ -1042,59 +1042,59 @@ static void manipulator_cage2d_exit(bContext *C, wmManipulator *mpr, const bool /* -------------------------------------------------------------------- */ -/** \name Cage Manipulator API +/** \name Cage Gizmo API * * \{ */ -static void MANIPULATOR_WT_cage_2d(wmManipulatorType *wt) +static void GIZMO_WT_cage_2d(wmGizmoType *wt) { /* identifiers */ - wt->idname = "MANIPULATOR_WT_cage_2d"; + wt->idname = "GIZMO_WT_cage_2d"; /* api callbacks */ - wt->draw = manipulator_cage2d_draw; - wt->draw_select = manipulator_cage2d_draw_select; - wt->test_select = manipulator_cage2d_test_select; - wt->setup = manipulator_cage2d_setup; - wt->invoke = manipulator_cage2d_invoke; - wt->property_update = manipulator_cage2d_property_update; - wt->modal = manipulator_cage2d_modal; - wt->exit = manipulator_cage2d_exit; - wt->cursor_get = manipulator_cage2d_get_cursor; - - wt->struct_size = sizeof(wmManipulator); + wt->draw = gizmo_cage2d_draw; + wt->draw_select = gizmo_cage2d_draw_select; + wt->test_select = gizmo_cage2d_test_select; + wt->setup = gizmo_cage2d_setup; + wt->invoke = gizmo_cage2d_invoke; + wt->property_update = gizmo_cage2d_property_update; + wt->modal = gizmo_cage2d_modal; + wt->exit = gizmo_cage2d_exit; + wt->cursor_get = gizmo_cage2d_get_cursor; + + wt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { - {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""}, - {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""}, + {ED_GIZMO_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""}, + {ED_GIZMO_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""}, {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem rna_enum_transform[] = { - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, + {ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""}, + {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, + {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""}, + {ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""}, {0, NULL, 0, NULL, NULL} }; static float unit_v2[2] = {1.0f, 1.0f}; RNA_def_float_vector(wt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); RNA_def_enum_flag( wt->srna, "draw_options", rna_enum_draw_options, - ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); + ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); - WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16); + WM_gizmotype_target_property_def(wt, "matrix", PROP_FLOAT, 16); } -void ED_manipulatortypes_cage_2d(void) +void ED_gizmotypes_cage_2d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_cage_2d); + WM_gizmotype_append(GIZMO_WT_cage_2d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index 0f3e67d7585..e266514855b 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -26,12 +26,12 @@ /** \file cage3d_gizmo.c * \ingroup wm * - * \name Cage Manipulator + * \name Cage Gizmo * - * 2D Manipulator + * 2D Gizmo * - * \brief Rectangular manipulator acting as a 'cage' around its content. - * Interacting scales or translates the manipulator. + * \brief Rectangular gizmo acting as a 'cage' around its content. + * Interacting scales or translates the gizmo. */ #include "MEM_guardedalloc.h" @@ -63,24 +63,24 @@ /* own includes */ #include "../gizmo_library_intern.h" -#define MANIPULATOR_RESIZER_SIZE 10.0f -#define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f +#define GIZMO_RESIZER_SIZE 10.0f +#define GIZMO_MARGIN_OFFSET_SCALE 1.5f -static void manipulator_calc_matrix_final_no_offset( - const wmManipulator *mpr, float orig_matrix_final_no_offset[4][4], bool use_space) +static void gizmo_calc_matrix_final_no_offset( + const wmGizmo *mpr, float orig_matrix_final_no_offset[4][4], bool use_space) { float mat_identity[4][4]; - struct WM_ManipulatorMatrixParams params = {NULL}; + struct WM_GizmoMatrixParams params = {NULL}; unit_m4(mat_identity); if (use_space == false) { params.matrix_basis = mat_identity; } params.matrix_offset = mat_identity; - WM_manipulator_calc_matrix_final_params(mpr, ¶ms, orig_matrix_final_no_offset); + WM_gizmo_calc_matrix_final_params(mpr, ¶ms, orig_matrix_final_no_offset); } -static void manipulator_calc_rect_view_scale( - const wmManipulator *mpr, const float dims[3], float scale[3]) +static void gizmo_calc_rect_view_scale( + const wmGizmo *mpr, const float dims[3], float scale[3]) { UNUSED_VARS(dims); @@ -88,7 +88,7 @@ static void manipulator_calc_rect_view_scale( float matrix_final_no_offset[4][4]; float x_axis[3], y_axis[3], z_axis[3]; - manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset, false); + gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset, false); mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, mpr->matrix_offset[2]); @@ -98,21 +98,21 @@ static void manipulator_calc_rect_view_scale( scale[2] = 1.0f / len_v3(z_axis); } -static void manipulator_calc_rect_view_margin( - const wmManipulator *mpr, const float dims[3], float margin[3]) +static void gizmo_calc_rect_view_margin( + const wmGizmo *mpr, const float dims[3], float margin[3]) { float handle_size; - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { handle_size = 0.15f; } else { - handle_size = MANIPULATOR_RESIZER_SIZE; + handle_size = GIZMO_RESIZER_SIZE; } // XXX, the scale isn't taking offset into account, we need to calculate scale per handle! // handle_size *= mpr->scale_final; float scale_xyz[3]; - manipulator_calc_rect_view_scale(mpr, dims, scale_xyz); + gizmo_calc_rect_view_scale(mpr, dims, scale_xyz); margin[0] = ((handle_size * scale_xyz[0])); margin[1] = ((handle_size * scale_xyz[1])); margin[2] = ((handle_size * scale_xyz[2])); @@ -120,12 +120,12 @@ static void manipulator_calc_rect_view_margin( /* -------------------------------------------------------------------- */ -static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3]) +static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3]) { - if (part >= ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && - part <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) + if (part >= ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && + part <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) { - int index = (part - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); + int index = (part - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); int range[3]; range[2] = index % 3; index = index / 3; @@ -144,7 +144,7 @@ static void manipulator_rect_pivot_from_scale_part(int part, float r_pt[3], bool /* -------------------------------------------------------------------- */ /** \name Box Draw Style * - * Useful for 3D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_BOX + * Useful for 3D views, see: #ED_GIZMO_CAGE2D_STYLE_BOX * \{ */ static void cage3d_draw_box_corners( @@ -165,10 +165,10 @@ static void cage3d_draw_box_interaction( const float color[4], const int highlighted, const float size[3], const float margin[3]) { - if (highlighted >= ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && - highlighted <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) + if (highlighted >= ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && + highlighted <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) { - int index = (highlighted - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); + int index = (highlighted - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); int range[3]; range[2] = index % 3; index = index / 3; @@ -199,7 +199,7 @@ static void cage3d_draw_box_interaction( /* -------------------------------------------------------------------- */ /** \name Circle Draw Style * - * Useful for 2D views, see: #ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE + * Useful for 2D views, see: #ED_GIZMO_CAGE2D_STYLE_CIRCLE * \{ */ static void imm_draw_point_aspect_3d( @@ -225,8 +225,8 @@ static void cage3d_draw_circle_wire( imm_draw_cube_wire_3d(pos, (float[3]){0}, r); #if 0 - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { + if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { const float rad[2] = {margin[0] / 2, margin[1] / 2}; const float center[2] = {0.0f, 0.0f}; @@ -279,11 +279,11 @@ static void cage3d_draw_circle_handles( /** \} */ -static void manipulator_cage3d_draw_intern( +static void gizmo_cage3d_draw_intern( RegionView3D *rv3d, - wmManipulator *mpr, const bool select, const bool highlight, const int select_id) + wmGizmo *mpr, const bool select, const bool highlight, const int select_id) { - // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; + // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; float dims[3]; RNA_float_get_array(mpr->ptr, "dimensions", dims); float matrix_final[4][4]; @@ -294,13 +294,13 @@ static void manipulator_cage3d_draw_intern( const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f}; - WM_manipulator_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(mpr, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); float margin[3]; - manipulator_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(mpr, dims, margin); /* Handy for quick testing draw (if it's outside bounds). */ if (false) { @@ -328,12 +328,12 @@ static void manipulator_cage3d_draw_intern( #endif - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE) { - for (int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; - i <= ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z; + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE) { + for (int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; + i <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z; i++) { - if (i == ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z) { + if (i == ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z) { continue; } GPU_select_load_id(select_id | i); @@ -341,8 +341,8 @@ static void manipulator_cage3d_draw_intern( mpr->color, i, size, margin); } } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - const int transform_part = ED_MANIPULATOR_CAGE3D_PART_TRANSLATE; + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { + const int transform_part = ED_GIZMO_CAGE3D_PART_TRANSLATE; GPU_select_load_id(select_id | transform_part); cage3d_draw_box_interaction( mpr->color, transform_part, size, margin); @@ -357,22 +357,22 @@ static void manipulator_cage3d_draw_intern( .ymax = size_real[1], }; #endif - if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { - /* corner manipulators */ + if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) { + /* corner gizmos */ GPU_line_width(mpr->line_width + 3.0f); cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0}); - /* corner manipulators */ + /* corner gizmos */ float color[4]; - manipulator_color_get(mpr, highlight, color); + gizmo_color_get(mpr, highlight, color); GPU_line_width(mpr->line_width); cage3d_draw_box_corners(size_real, margin, color); bool show = false; - if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_TRANSLATE) { + if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { /* Only show if we're drawing the center handle * otherwise the entire rectangle is the hotspot. */ - if (draw_options & ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { + if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { show = true; } } @@ -385,9 +385,9 @@ static void manipulator_cage3d_draw_intern( mpr->color, mpr->highlight_part, size_real, margin); } } - else if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE) { + else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) { float color[4]; - manipulator_color_get(mpr, highlight, color); + gizmo_color_get(mpr, highlight, color); GPU_line_smooth(true); GPU_polygon_smooth(true); @@ -398,7 +398,7 @@ static void manipulator_cage3d_draw_intern( GPU_line_width(mpr->line_width); cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options); - /* corner manipulators */ + /* corner gizmos */ cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, (const float[3]){0, 0, 0}, true, 60); cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 40); @@ -418,24 +418,24 @@ static void manipulator_cage3d_draw_intern( /** * For when we want to draw 3d cage in 3d views. */ -static void manipulator_cage3d_draw_select(const bContext *C, wmManipulator *mpr, int select_id) +static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *mpr, int select_id) { ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - manipulator_cage3d_draw_intern(rv3d, mpr, true, false, select_id); + gizmo_cage3d_draw_intern(rv3d, mpr, true, false, select_id); } -static void manipulator_cage3d_draw(const bContext *C, wmManipulator *mpr) +static void gizmo_cage3d_draw(const bContext *C, wmGizmo *mpr) { ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - manipulator_cage3d_draw_intern(rv3d, mpr, false, is_highlight, -1); + const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + gizmo_cage3d_draw_intern(rv3d, mpr, false, is_highlight, -1); } -static int manipulator_cage3d_get_cursor(wmManipulator *mpr) +static int gizmo_cage3d_get_cursor(wmGizmo *mpr) { - if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { + if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { return BC_NSEW_SCROLLCURSOR; } @@ -448,21 +448,21 @@ typedef struct RectTransformInteraction { float orig_matrix_final_no_offset[4][4]; } RectTransformInteraction; -static void manipulator_cage3d_setup(wmManipulator *mpr) +static void gizmo_cage3d_setup(wmGizmo *mpr) { - mpr->flag |= /* WM_MANIPULATOR_DRAW_MODAL | */ /* TODO */ - WM_MANIPULATOR_DRAW_NO_SCALE; + mpr->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */ + WM_GIZMO_DRAW_NO_SCALE; } -static int manipulator_cage3d_invoke( - bContext *C, wmManipulator *mpr, const wmEvent *event) +static int gizmo_cage3d_invoke( + bContext *C, wmGizmo *mpr, const wmEvent *event) { RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); - manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset, true); + gizmo_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset, true); - if (manipulator_window_project_3d( + if (gizmo_window_project_3d( C, mpr, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) { zero_v3(data->orig_mouse); @@ -473,9 +473,9 @@ static int manipulator_cage3d_invoke( return OPERATOR_RUNNING_MODAL; } -static int manipulator_cage3d_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo_cage3d_modal( + bContext *C, wmGizmo *mpr, const wmEvent *event, + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { /* For transform logic to be managable we operate in -0.5..0.5 2D space, * no matter the size of the rectangle, mouse coorts are scaled to unit space. @@ -495,7 +495,7 @@ static int manipulator_cage3d_modal( copy_m4_m4(matrix_back, mpr->matrix_offset); copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - bool ok = manipulator_window_project_3d( + bool ok = gizmo_window_project_3d( C, mpr, (const float[2]){UNPACK2(event->mval)}, false, point_local); copy_m4_m4(mpr->matrix_offset, matrix_back); if (!ok) { @@ -504,21 +504,21 @@ static int manipulator_cage3d_modal( } const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - wmManipulatorProperty *mpr_prop; + wmGizmoProperty *mpr_prop; - mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); + mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); } - if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_TRANSLATE) { + if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { /* do this to prevent clamping from changing size */ copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); mpr->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]); } - else if (mpr->highlight_part == ED_MANIPULATOR_CAGE3D_PART_ROTATE) { + else if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_ROTATE) { /* TODO (if needed) */ } else { @@ -527,8 +527,8 @@ static int manipulator_cage3d_modal( float pivot[3]; bool constrain_axis[3] = {false}; - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE) { - manipulator_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { + gizmo_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); } else { zero_v3(pivot); @@ -553,7 +553,7 @@ static int manipulator_cage3d_modal( scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i])); - if ((transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) { + if ((transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) { if (sign != signum_i(scale[i])) { scale[i] = 0.0f; } @@ -561,7 +561,7 @@ static int manipulator_cage3d_modal( } } - if (transform_flag & ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) { + if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) { if (constrain_axis[0] == false && constrain_axis[1] == false) { scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f; } @@ -591,7 +591,7 @@ static int manipulator_cage3d_modal( } if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); + WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); } /* tag the region for redraw */ @@ -601,11 +601,11 @@ static int manipulator_cage3d_modal( return OPERATOR_RUNNING_MODAL; } -static void manipulator_cage3d_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +static void gizmo_cage3d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) { if (STREQ(mpr_prop->type->idname, "matrix")) { - if (WM_manipulator_target_property_array_length(mpr, mpr_prop) == 16) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (WM_gizmo_target_property_array_length(mpr, mpr_prop) == 16) { + WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); } else { BLI_assert(0); @@ -616,19 +616,19 @@ static void manipulator_cage3d_property_update(wmManipulator *mpr, wmManipulator } } -static void manipulator_cage3d_exit(bContext *C, wmManipulator *mpr, const bool cancel) +static void gizmo_cage3d_exit(bContext *C, wmGizmo *mpr, const bool cancel) { RectTransformInteraction *data = mpr->interaction_data; if (!cancel) return; - wmManipulatorProperty *mpr_prop; + wmGizmoProperty *mpr_prop; /* reset properties */ - mpr_prop = WM_manipulator_target_property_find(mpr, "matrix"); + mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); if (mpr_prop->type != NULL) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); + WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); } copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); @@ -636,57 +636,57 @@ static void manipulator_cage3d_exit(bContext *C, wmManipulator *mpr, const bool /* -------------------------------------------------------------------- */ -/** \name Cage Manipulator API +/** \name Cage Gizmo API * * \{ */ -static void MANIPULATOR_WT_cage_3d(wmManipulatorType *wt) +static void GIZMO_WT_cage_3d(wmGizmoType *wt) { /* identifiers */ - wt->idname = "MANIPULATOR_WT_cage_3d"; + wt->idname = "GIZMO_WT_cage_3d"; /* api callbacks */ - wt->draw = manipulator_cage3d_draw; - wt->draw_select = manipulator_cage3d_draw_select; - wt->setup = manipulator_cage3d_setup; - wt->invoke = manipulator_cage3d_invoke; - wt->property_update = manipulator_cage3d_property_update; - wt->modal = manipulator_cage3d_modal; - wt->exit = manipulator_cage3d_exit; - wt->cursor_get = manipulator_cage3d_get_cursor; + wt->draw = gizmo_cage3d_draw; + wt->draw_select = gizmo_cage3d_draw_select; + wt->setup = gizmo_cage3d_setup; + wt->invoke = gizmo_cage3d_invoke; + wt->property_update = gizmo_cage3d_property_update; + wt->modal = gizmo_cage3d_modal; + wt->exit = gizmo_cage3d_exit; + wt->cursor_get = gizmo_cage3d_get_cursor; - wt->struct_size = sizeof(wmManipulator); + wt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { - {ED_MANIPULATOR_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""}, - {ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""}, + {ED_GIZMO_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""}, + {ED_GIZMO_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""}, {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem rna_enum_transform[] = { - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, - {ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, + {ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, + {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""}, + {ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""}, {0, NULL, 0, NULL, NULL} }; static float unit_v3[3] = {1.0f, 1.0f, 1.0f}; RNA_def_float_vector(wt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); RNA_def_enum_flag( wt->srna, "draw_options", rna_enum_draw_options, - ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); + ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); - WM_manipulatortype_target_property_def(wt, "matrix", PROP_FLOAT, 16); + WM_gizmotype_target_property_def(wt, "matrix", PROP_FLOAT, 16); } -void ED_manipulatortypes_cage_3d(void) +void ED_gizmotypes_cage_3d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_cage_3d); + WM_gizmotype_append(GIZMO_WT_cage_3d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c index 8d0061f66c8..b93b87b1efa 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -26,15 +26,15 @@ /** \file dial3d_gizmo.c * \ingroup wm * - * \name Dial Manipulator + * \name Dial Gizmo * - * 3D Manipulator + * 3D Gizmo * - * \brief Circle shaped manipulator for circular interaction. + * \brief Circle shaped gizmo for circular interaction. * Currently no own handling, use with operator only. * * - `matrix[0]` is derived from Y and Z. - * - `matrix[1]` is 'up' when DialManipulator.use_start_y_axis is set. + * - `matrix[1]` is 'up' when DialGizmo.use_start_y_axis is set. * - `matrix[2]` is the axis the dial rotates around (all dials). */ @@ -67,12 +67,12 @@ #include "../gizmo_geometry.h" #include "../gizmo_library_intern.h" -/* to use custom dials exported to geom_dial_manipulator.c */ -// #define USE_MANIPULATOR_CUSTOM_DIAL +/* to use custom dials exported to geom_dial_gizmo.c */ +// #define USE_GIZMO_CUSTOM_DIAL -static int manipulator_dial_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak tweak_flag); +static int gizmo_dial_modal( + bContext *C, wmGizmo *mpr, const wmEvent *event, + eWM_GizmoFlagTweak tweak_flag); typedef struct DialInteraction { float init_mval[2]; @@ -99,9 +99,9 @@ typedef struct DialInteraction { #define DIAL_CLIP_BIAS 0.02 /** - * We can't use this for the #wmManipulatorType.matrix_basis_get callback, it conflicts with depth picking. + * We can't use this for the #wmGizmoType.matrix_basis_get callback, it conflicts with depth picking. */ -static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4]) +static void dial_calc_matrix(const wmGizmo *mpr, float mat[4][4]) { float rot[3][3]; const float up[3] = {0.0f, 0.0f, 1.0f}; @@ -114,15 +114,15 @@ static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4]) /* -------------------------------------------------------------------- */ static void dial_geom_draw( - const wmManipulator *mpr, const float color[4], const bool select, + const wmGizmo *mpr, const float color[4], const bool select, float axis_modal_mat[4][4], float clip_plane[4]) { -#ifdef USE_MANIPULATOR_CUSTOM_DIAL +#ifdef USE_GIZMO_CUSTOM_DIAL UNUSED_VARS(dial, col, axis_modal_mat, clip_plane); - wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_dial, select); + wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_dial, select); #else const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - const bool filled = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL) != 0; + const bool filled = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_FILL) != 0; GPU_line_width(mpr->line_width); @@ -181,9 +181,9 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[ } static void dial_ghostarc_draw( - const wmManipulator *mpr, const float angle_ofs, const float angle_delta, const float color[4]) + const wmGizmo *mpr, const float angle_ofs, const float angle_delta, const float color[4]) { - const float width_inner = DIAL_WIDTH - mpr->line_width * 0.5f / U.manipulator_size; + const float width_inner = DIAL_WIDTH - mpr->line_width * 0.5f / U.gizmo_size; Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -196,7 +196,7 @@ static void dial_ghostarc_draw( static void dial_ghostarc_get_angles( struct Depsgraph *depsgraph, - const wmManipulator *mpr, + const wmGizmo *mpr, const wmEvent *event, const ARegion *ar, const View3D *v3d, float mat[4][4], const float co_outer[3], @@ -243,7 +243,7 @@ static void dial_ghostarc_get_angles( /* Start direction from mouse or set by user */ const float *proj_init_rel = - (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y) ? + (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y) ? mpr->matrix_basis[1] : proj_mval_init_rel; /* return angles */ @@ -274,7 +274,7 @@ fail: } static void dial_draw_intern( - const bContext *C, wmManipulator *mpr, + const bContext *C, wmGizmo *mpr, const bool select, const bool highlight, float clip_plane[4]) { float matrix_basis_adjust[4][4]; @@ -283,12 +283,12 @@ static void dial_draw_intern( BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D); - manipulator_color_get(mpr, highlight, color); + gizmo_color_get(mpr, highlight, color); dial_calc_matrix(mpr, matrix_basis_adjust); - WM_manipulator_calc_matrix_final_params( - mpr, &((struct WM_ManipulatorMatrixParams) { + WM_gizmo_calc_matrix_final_params( + mpr, &((struct WM_GizmoMatrixParams) { .matrix_basis = (void *)matrix_basis_adjust, }), matrix_final); @@ -296,17 +296,17 @@ static void dial_draw_intern( gpuMultMatrix(matrix_final); /* draw rotation indicator arc first */ - if ((mpr->flag & WM_MANIPULATOR_DRAW_VALUE) && - (mpr->state & WM_MANIPULATOR_STATE_MODAL)) + if ((mpr->flag & WM_GIZMO_DRAW_VALUE) && + (mpr->state & WM_GIZMO_STATE_MODAL)) { const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ DialInteraction *inter = mpr->interaction_data; - /* XXX, View3D rotation manipulator doesn't call modal. */ - if (!WM_manipulator_target_property_is_valid_any(mpr)) { + /* XXX, View3D rotation gizmo doesn't call modal. */ + if (!WM_gizmo_target_property_is_valid_any(mpr)) { wmWindow *win = CTX_wm_window(C); - manipulator_dial_modal((bContext *)C, mpr, win->eventstate, 0); + gizmo_dial_modal((bContext *)C, mpr, win->eventstate, 0); } float angle_ofs = inter->output.angle_ofs; @@ -323,7 +323,7 @@ static void dial_draw_intern( if (i == 0) { const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - if ((draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) { + if ((draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) { break; } } @@ -332,17 +332,17 @@ static void dial_draw_intern( } } - /* draw actual dial manipulator */ + /* draw actual dial gizmo */ dial_geom_draw(mpr, color, select, matrix_basis_adjust, clip_plane); gpuPopMatrix(); } -static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int select_id) +static void gizmo_dial_draw_select(const bContext *C, wmGizmo *mpr, int select_id) { float clip_plane_buf[4]; const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - float *clip_plane = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL; + float *clip_plane = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL; /* enable clipping if needed */ if (clip_plane) { @@ -363,13 +363,13 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, } } -static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) +static void gizmo_dial_draw(const bContext *C, wmGizmo *mpr) { - const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL; + const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float clip_plane_buf[4]; const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - float *clip_plane = (!is_modal && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL; + float *clip_plane = (!is_modal && (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL; /* enable clipping if needed */ if (clip_plane) { @@ -392,9 +392,9 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) } } -static int manipulator_dial_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo_dial_modal( + bContext *C, wmGizmo *mpr, const wmEvent *event, + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ float angle_ofs, angle_delta; @@ -413,15 +413,15 @@ static int manipulator_dial_modal( inter->output.angle_ofs = angle_ofs; /* set the property for the operator and call its modal function */ - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + if (WM_gizmo_target_property_is_valid(mpr_prop)) { + WM_gizmo_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); } return OPERATOR_RUNNING_MODAL; } -static void manipulator_dial_setup(wmManipulator *mpr) +static void gizmo_dial_setup(wmGizmo *mpr) { const float dir_default[3] = {0.0f, 0.0f, 1.0f}; @@ -429,17 +429,17 @@ static void manipulator_dial_setup(wmManipulator *mpr) copy_v3_v3(mpr->matrix_basis[2], dir_default); } -static int manipulator_dial_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +static int gizmo_dial_invoke( + bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) { DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__); inter->init_mval[0] = event->mval[0]; inter->init_mval[1] = event->mval[1]; - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - inter->init_prop_angle = WM_manipulator_target_property_value_get(mpr, mpr_prop); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + if (WM_gizmo_target_property_is_valid(mpr_prop)) { + inter->init_prop_angle = WM_gizmo_target_property_value_get(mpr, mpr_prop); } mpr->interaction_data = inter; @@ -448,40 +448,40 @@ static int manipulator_dial_invoke( } /* -------------------------------------------------------------------- */ -/** \name Dial Manipulator API +/** \name Dial Gizmo API * * \{ */ -static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt) +static void GIZMO_WT_dial_3d(wmGizmoType *wt) { /* identifiers */ - wt->idname = "MANIPULATOR_WT_dial_3d"; + wt->idname = "GIZMO_WT_dial_3d"; /* api callbacks */ - wt->draw = manipulator_dial_draw; - wt->draw_select = manipulator_dial_draw_select; - wt->setup = manipulator_dial_setup; - wt->invoke = manipulator_dial_invoke; - wt->modal = manipulator_dial_modal; + wt->draw = gizmo_dial_draw; + wt->draw_select = gizmo_dial_draw_select; + wt->setup = gizmo_dial_setup; + wt->invoke = gizmo_dial_invoke; + wt->modal = gizmo_dial_modal; - wt->struct_size = sizeof(wmManipulator); + wt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""}, - {ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, - {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""}, - {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""}, + {ED_GIZMO_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""}, + {ED_GIZMO_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, + {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""}, + {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""}, {0, NULL, 0, NULL, NULL} }; RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 1); + WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 1); } -void ED_manipulatortypes_dial_3d(void) +void ED_gizmotypes_dial_3d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_dial_3d); + WM_gizmotype_append(GIZMO_WT_dial_3d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c index e55b57327b6..2a89c8cc4ab 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c @@ -21,15 +21,15 @@ /** \file grab3d_gizmo.c * \ingroup wm * - * \name Grab Manipulator + * \name Grab Gizmo * - * 3D Manipulator, also works in 2D views. + * 3D Gizmo, also works in 2D views. * - * \brief Simple manipulator to grab and translate. + * \brief Simple gizmo to grab and translate. * * - `matrix[0]` is derived from Y and Z. * - `matrix[1]` currently not used. - * - `matrix[2]` is the widget direction (for all manipulators). + * - `matrix[2]` is the widget direction (for all gizmos). * */ @@ -62,23 +62,23 @@ #include "../gizmo_geometry.h" #include "../gizmo_library_intern.h" -typedef struct GrabManipulator3D { - wmManipulator manipulator; +typedef struct GrabGizmo3D { + wmGizmo gizmo; /* Added to 'matrix_basis' when calculating the matrix. */ float prop_co[3]; -} GrabManipulator3D; +} GrabGizmo3D; -static void manipulator_grab_matrix_basis_get(const wmManipulator *mpr, float r_matrix[4][4]) +static void gizmo_grab_matrix_basis_get(const wmGizmo *mpr, float r_matrix[4][4]) { - GrabManipulator3D *grab = (GrabManipulator3D *)mpr; + GrabGizmo3D *grab = (GrabGizmo3D *)mpr; - copy_m4_m4(r_matrix, grab->manipulator.matrix_basis); + copy_m4_m4(r_matrix, grab->gizmo.matrix_basis); add_v3_v3(r_matrix[3], grab->prop_co); } -static int manipulator_grab_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak tweak_flag); +static int gizmo_grab_modal( + bContext *C, wmGizmo *mpr, const wmEvent *event, + eWM_GizmoFlagTweak tweak_flag); typedef struct GrabInteraction { float init_mval[2]; @@ -94,14 +94,14 @@ typedef struct GrabInteraction { /* -------------------------------------------------------------------- */ static void grab_geom_draw( - const wmManipulator *mpr, const float color[4], const bool select, const int draw_options) + const wmGizmo *mpr, const float color[4], const bool select, const int draw_options) { -#ifdef USE_MANIPULATOR_CUSTOM_DIAL +#ifdef USE_GIZMO_CUSTOM_DIAL UNUSED_VARS(grab3d, col, axis_modal_mat); - wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_grab3d, select); + wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_grab3d, select); #else const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0; + const bool filled = (draw_options & ED_GIZMO_GRAB_DRAW_FLAG_FILL) != 0; GPU_line_width(mpr->line_width); @@ -112,7 +112,7 @@ static void grab_geom_draw( immUniformColor4fv(color); - if (draw_style == ED_MANIPULATOR_GRAB_STYLE_RING_2D) { + if (draw_style == ED_GIZMO_GRAB_STYLE_RING_2D) { if (filled) { imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION); } @@ -120,7 +120,7 @@ static void grab_geom_draw( imm_draw_circle_wire_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION); } } - else if (draw_style == ED_MANIPULATOR_GRAB_STYLE_CROSS_2D) { + else if (draw_style == ED_GIZMO_GRAB_STYLE_CROSS_2D) { immBegin(GWN_PRIM_LINES, 4); immVertex2f(pos, 1.0f, 1.0f); immVertex2f(pos, -1.0f, -1.0f); @@ -140,7 +140,7 @@ static void grab_geom_draw( } static void grab3d_get_translate( - const wmManipulator *mpr, const wmEvent *event, const ARegion *ar, + const wmGizmo *mpr, const wmEvent *event, const ARegion *ar, float co_delta[3]) { GrabInteraction *inter = mpr->interaction_data; @@ -163,18 +163,18 @@ static void grab3d_get_translate( } static void grab3d_draw_intern( - const bContext *C, wmManipulator *mpr, + const bContext *C, wmGizmo *mpr, const bool select, const bool highlight) { GrabInteraction *inter = mpr->interaction_data; const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); - const bool align_view = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0; + const bool align_view = (draw_options & ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0; float color[4]; float matrix_final[4][4]; float matrix_align[4][4]; - manipulator_color_get(mpr, highlight, color); - WM_manipulator_calc_matrix_final(mpr, matrix_final); + gizmo_color_get(mpr, highlight, color); + WM_gizmo_calc_matrix_final(mpr, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); @@ -209,16 +209,16 @@ static void grab3d_draw_intern( } } -static void manipulator_grab_draw_select(const bContext *C, wmManipulator *mpr, int select_id) +static void gizmo_grab_draw_select(const bContext *C, wmGizmo *mpr, int select_id) { GPU_select_load_id(select_id); grab3d_draw_intern(C, mpr, true, false); } -static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr) +static void gizmo_grab_draw(const bContext *C, wmGizmo *mpr) { - const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL; + const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; (void)is_modal; @@ -227,11 +227,11 @@ static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr) GPU_blend(false); } -static int manipulator_grab_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo_grab_modal( + bContext *C, wmGizmo *mpr, const wmEvent *event, + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { - GrabManipulator3D *grab = (GrabManipulator3D *)mpr; + GrabGizmo3D *grab = (GrabGizmo3D *)mpr; GrabInteraction *inter = mpr->interaction_data; ARegion *ar = CTX_wm_region(C); @@ -241,9 +241,9 @@ static int manipulator_grab_modal( } else { float mval_proj_init[2], mval_proj_curr[2]; - if ((manipulator_window_project_2d( + if ((gizmo_window_project_2d( C, mpr, inter->init_mval, 2, false, mval_proj_init) == false) || - (manipulator_window_project_2d( + (gizmo_window_project_2d( C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) { return OPERATOR_RUNNING_MODAL; @@ -254,9 +254,9 @@ static int manipulator_grab_modal( add_v3_v3v3(grab->prop_co, inter->init_prop_co, prop_delta); /* set the property for the operator and call its modal function */ - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, grab->prop_co); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + if (WM_gizmo_target_property_is_valid(mpr_prop)) { + WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, grab->prop_co); } else { zero_v3(grab->prop_co); @@ -267,8 +267,8 @@ static int manipulator_grab_modal( return OPERATOR_RUNNING_MODAL; } -static int manipulator_grab_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +static int gizmo_grab_invoke( + bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) { GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__); @@ -278,13 +278,13 @@ static int manipulator_grab_invoke( #if 0 copy_v3_v3(inter->init_prop_co, grab->prop_co); #else - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + if (WM_gizmo_target_property_is_valid(mpr_prop)) { + WM_gizmo_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co); } #endif - WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); + WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); mpr->interaction_data = inter; @@ -292,12 +292,12 @@ static int manipulator_grab_invoke( } -static int manipulator_grab_test_select( - bContext *C, wmManipulator *mpr, const wmEvent *event) +static int gizmo_grab_test_select( + bContext *C, wmGizmo *mpr, const wmEvent *event) { float point_local[2]; - if (manipulator_window_project_2d( + if (gizmo_window_project_2d( C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; @@ -311,65 +311,65 @@ static int manipulator_grab_test_select( return -1; } -static void manipulator_grab_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +static void gizmo_grab_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) { - GrabManipulator3D *grab = (GrabManipulator3D *)mpr; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, grab->prop_co); + GrabGizmo3D *grab = (GrabGizmo3D *)mpr; + if (WM_gizmo_target_property_is_valid(mpr_prop)) { + WM_gizmo_target_property_value_get_array(mpr, mpr_prop, grab->prop_co); } else { zero_v3(grab->prop_co); } } -static int manipulator_grab_cursor_get(wmManipulator *UNUSED(mpr)) +static int gizmo_grab_cursor_get(wmGizmo *UNUSED(mpr)) { return BC_NSEW_SCROLLCURSOR; } /* -------------------------------------------------------------------- */ -/** \name Grab Manipulator API +/** \name Grab Gizmo API * * \{ */ -static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt) +static void GIZMO_WT_grab_3d(wmGizmoType *wt) { /* identifiers */ - wt->idname = "MANIPULATOR_WT_grab_3d"; + wt->idname = "GIZMO_WT_grab_3d"; /* api callbacks */ - wt->draw = manipulator_grab_draw; - wt->draw_select = manipulator_grab_draw_select; - wt->test_select = manipulator_grab_test_select; - wt->matrix_basis_get = manipulator_grab_matrix_basis_get; - wt->invoke = manipulator_grab_invoke; - wt->property_update = manipulator_grab_property_update; - wt->modal = manipulator_grab_modal; - wt->cursor_get = manipulator_grab_cursor_get; + wt->draw = gizmo_grab_draw; + wt->draw_select = gizmo_grab_draw_select; + wt->test_select = gizmo_grab_test_select; + wt->matrix_basis_get = gizmo_grab_matrix_basis_get; + wt->invoke = gizmo_grab_invoke; + wt->property_update = gizmo_grab_property_update; + wt->modal = gizmo_grab_modal; + wt->cursor_get = gizmo_grab_cursor_get; - wt->struct_size = sizeof(GrabManipulator3D); + wt->struct_size = sizeof(GrabGizmo3D); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { - {ED_MANIPULATOR_GRAB_STYLE_RING_2D, "RING_2D", 0, "Ring", ""}, - {ED_MANIPULATOR_GRAB_STYLE_CROSS_2D, "CROSS_2D", 0, "Ring", ""}, + {ED_GIZMO_GRAB_STYLE_RING_2D, "RING_2D", 0, "Ring", ""}, + {ED_GIZMO_GRAB_STYLE_CROSS_2D, "CROSS_2D", 0, "Ring", ""}, {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem rna_enum_draw_options[] = { - {ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, - {ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""}, + {ED_GIZMO_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, + {ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""}, {0, NULL, 0, NULL, NULL} }; - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_GRAB_STYLE_RING_2D, "Draw Style", ""); + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_GRAB_STYLE_RING_2D, "Draw Style", ""); RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - WM_manipulatortype_target_property_def(wt, "offset", PROP_FLOAT, 3); + WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 3); } -void ED_manipulatortypes_grab_3d(void) +void ED_gizmotypes_grab_3d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_grab_3d); + WM_gizmotype_append(GIZMO_WT_grab_3d); } -/** \} */ // Grab Manipulator API +/** \} */ // Grab Gizmo API diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c index 1331a4e983f..ff02517dafa 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c @@ -21,11 +21,11 @@ /** \file primitive3d_gizmo.c * \ingroup wm * - * \name Primitive Manipulator + * \name Primitive Gizmo * - * 3D Manipulator + * 3D Gizmo * - * \brief Manipulator with primitive drawing type (plane, cube, etc.). + * \brief Gizmo with primitive drawing type (plane, cube, etc.). * Currently only plane primitive supported without own handling, use with operator only. */ @@ -65,13 +65,13 @@ static float verts_plane[4][3] = { /* -------------------------------------------------------------------- */ -static void manipulator_primitive_draw_geom( +static void gizmo_primitive_draw_geom( const float col_inner[4], const float col_outer[4], const int draw_style) { float (*verts)[3]; uint vert_count = 0; - if (draw_style == ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE) { + if (draw_style == ED_GIZMO_PRIMITIVE_STYLE_PLANE) { verts = verts_plane; vert_count = ARRAY_SIZE(verts_plane); } @@ -79,37 +79,37 @@ static void manipulator_primitive_draw_geom( if (vert_count > 0) { uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, GWN_PRIM_TRI_FAN); - wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, GWN_PRIM_LINE_LOOP); + wm_gizmo_vec_draw(col_inner, verts, vert_count, pos, GWN_PRIM_TRI_FAN); + wm_gizmo_vec_draw(col_outer, verts, vert_count, pos, GWN_PRIM_LINE_LOOP); immUnbindProgram(); } } -static void manipulator_primitive_draw_intern( - wmManipulator *mpr, const bool UNUSED(select), +static void gizmo_primitive_draw_intern( + wmGizmo *mpr, const bool UNUSED(select), const bool highlight) { float color_inner[4], color_outer[4]; float matrix_final[4][4]; const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - manipulator_color_get(mpr, highlight, color_outer); + gizmo_color_get(mpr, highlight, color_outer); copy_v4_v4(color_inner, color_outer); color_inner[3] *= 0.5f; - WM_manipulator_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(mpr, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); GPU_blend(true); - manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); + gizmo_primitive_draw_geom(color_inner, color_outer, draw_style); GPU_blend(false); gpuPopMatrix(); if (mpr->interaction_data) { - ManipulatorInteraction *inter = mpr->interaction_data; + GizmoInteraction *inter = mpr->interaction_data; copy_v4_fl(color_inner, 0.5f); copy_v3_fl(color_outer, 0.5f); @@ -119,39 +119,39 @@ static void manipulator_primitive_draw_intern( gpuMultMatrix(inter->init_matrix_final); GPU_blend(true); - manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); + gizmo_primitive_draw_geom(color_inner, color_outer, draw_style); GPU_blend(false); gpuPopMatrix(); } } -static void manipulator_primitive_draw_select( - const bContext *UNUSED(C), wmManipulator *mpr, +static void gizmo_primitive_draw_select( + const bContext *UNUSED(C), wmGizmo *mpr, int select_id) { GPU_select_load_id(select_id); - manipulator_primitive_draw_intern(mpr, true, false); + gizmo_primitive_draw_intern(mpr, true, false); } -static void manipulator_primitive_draw(const bContext *UNUSED(C), wmManipulator *mpr) +static void gizmo_primitive_draw(const bContext *UNUSED(C), wmGizmo *mpr) { - manipulator_primitive_draw_intern( + gizmo_primitive_draw_intern( mpr, false, - (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)); + (mpr->state & WM_GIZMO_STATE_HIGHLIGHT)); } -static void manipulator_primitive_setup(wmManipulator *mpr) +static void gizmo_primitive_setup(wmGizmo *mpr) { - mpr->flag |= WM_MANIPULATOR_DRAW_MODAL; + mpr->flag |= WM_GIZMO_DRAW_MODAL; } -static int manipulator_primitive_invoke( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) +static int gizmo_primitive_invoke( + bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *UNUSED(event)) { - ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); + GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); - WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final); + WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); mpr->interaction_data = inter; @@ -159,33 +159,33 @@ static int manipulator_primitive_invoke( } /* -------------------------------------------------------------------- */ -/** \name Primitive Manipulator API +/** \name Primitive Gizmo API * * \{ */ -static void MANIPULATOR_WT_primitive_3d(wmManipulatorType *wt) +static void GIZMO_WT_primitive_3d(wmGizmoType *wt) { /* identifiers */ - wt->idname = "MANIPULATOR_WT_primitive_3d"; + wt->idname = "GIZMO_WT_primitive_3d"; /* api callbacks */ - wt->draw = manipulator_primitive_draw; - wt->draw_select = manipulator_primitive_draw_select; - wt->setup = manipulator_primitive_setup; - wt->invoke = manipulator_primitive_invoke; + wt->draw = gizmo_primitive_draw; + wt->draw_select = gizmo_primitive_draw_select; + wt->setup = gizmo_primitive_setup; + wt->invoke = gizmo_primitive_invoke; - wt->struct_size = sizeof(wmManipulator); + wt->struct_size = sizeof(wmGizmo); static EnumPropertyItem rna_enum_draw_style[] = { - {ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""}, + {ED_GIZMO_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""}, {0, NULL, 0, NULL, NULL} }; - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); } -void ED_manipulatortypes_primitive_3d(void) +void ED_gizmotypes_primitive_3d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_primitive_3d); + WM_gizmotype_append(GIZMO_WT_primitive_3d); } /** \} */ diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h index b33fbf47630..39a58929b7c 100644 --- a/source/blender/editors/include/ED_gizmo_library.h +++ b/source/blender/editors/include/ED_gizmo_library.h @@ -21,28 +21,28 @@ /** \file ED_gizmo_library.h * \ingroup wm * - * \name Generic Manipulators. + * \name Generic Gizmos. * - * This is exposes pre-defined manipulators for re-use. + * This is exposes pre-defined gizmos for re-use. */ #ifndef __ED_GIZMO_LIBRARY_H__ #define __ED_GIZMO_LIBRARY_H__ -/* initialize manipulators */ -void ED_manipulatortypes_arrow_2d(void); -void ED_manipulatortypes_arrow_3d(void); -void ED_manipulatortypes_button_2d(void); -void ED_manipulatortypes_cage_2d(void); -void ED_manipulatortypes_cage_3d(void); -void ED_manipulatortypes_dial_3d(void); -void ED_manipulatortypes_grab_3d(void); -void ED_manipulatortypes_facemap_3d(void); -void ED_manipulatortypes_primitive_3d(void); +/* initialize gizmos */ +void ED_gizmotypes_arrow_2d(void); +void ED_gizmotypes_arrow_3d(void); +void ED_gizmotypes_button_2d(void); +void ED_gizmotypes_cage_2d(void); +void ED_gizmotypes_cage_3d(void); +void ED_gizmotypes_dial_3d(void); +void ED_gizmotypes_grab_3d(void); +void ED_gizmotypes_facemap_3d(void); +void ED_gizmotypes_primitive_3d(void); -struct wmManipulator; -struct wmManipulatorGroup; +struct wmGizmo; +struct wmGizmoGroup; /* -------------------------------------------------------------------- */ @@ -51,172 +51,172 @@ struct wmManipulatorGroup; * Intended to be called by custom draw functions. */ -/* manipulator_library_presets.c */ -void ED_manipulator_draw_preset_box( - const struct wmManipulator *mpr, float mat[4][4], int select_id); -void ED_manipulator_draw_preset_arrow( - const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id); -void ED_manipulator_draw_preset_circle( - const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id); -void ED_manipulator_draw_preset_facemap( - const struct bContext *C, const struct wmManipulator *mpr, struct Scene *scene, +/* gizmo_library_presets.c */ +void ED_gizmo_draw_preset_box( + const struct wmGizmo *mpr, float mat[4][4], int select_id); +void ED_gizmo_draw_preset_arrow( + const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id); +void ED_gizmo_draw_preset_circle( + const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id); +void ED_gizmo_draw_preset_facemap( + const struct bContext *C, const struct wmGizmo *mpr, struct Scene *scene, struct Object *ob, const int facemap, int select_id); /* -------------------------------------------------------------------- */ -/* 3D Arrow Manipulator */ +/* 3D Arrow Gizmo */ enum { - ED_MANIPULATOR_ARROW_STYLE_NORMAL = 0, - ED_MANIPULATOR_ARROW_STYLE_CROSS = 1, - ED_MANIPULATOR_ARROW_STYLE_BOX = 2, - ED_MANIPULATOR_ARROW_STYLE_CONE = 3, + ED_GIZMO_ARROW_STYLE_NORMAL = 0, + ED_GIZMO_ARROW_STYLE_CROSS = 1, + ED_GIZMO_ARROW_STYLE_BOX = 2, + ED_GIZMO_ARROW_STYLE_CONE = 3, }; /* transform */ enum { /* inverted offset during interaction - if set it also sets constrained below */ - ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED = (1 << 3), + ED_GIZMO_ARROW_XFORM_FLAG_INVERTED = (1 << 3), /* clamp arrow interaction to property width */ - ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED = (1 << 4), + ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED = (1 << 4), }; /* draw_options */ enum { /* Show arrow stem. */ - ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM = (1 << 0), + ED_GIZMO_ARROW_DRAW_FLAG_STEM = (1 << 0), }; -void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *mpr, const float min, const float max); -void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const float range_fac); +void ED_gizmo_arrow3d_set_ui_range(struct wmGizmo *mpr, const float min, const float max); +void ED_gizmo_arrow3d_set_range_fac(struct wmGizmo *mpr, const float range_fac); /* -------------------------------------------------------------------- */ -/* 2D Arrow Manipulator */ +/* 2D Arrow Gizmo */ /* none */ /* -------------------------------------------------------------------- */ -/* Cage Manipulator */ +/* Cage Gizmo */ enum { - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE = (1 << 0), /* Translates */ - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE = (1 << 1), /* Rotates */ - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE = (1 << 2), /* Scales */ - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Scales uniformly */ - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED = (1 << 4), /* Negative scale allowed */ + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE = (1 << 0), /* Translates */ + ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE = (1 << 1), /* Rotates */ + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE = (1 << 2), /* Scales */ + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Scales uniformly */ + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED = (1 << 4), /* Negative scale allowed */ }; /* draw_style */ enum { - ED_MANIPULATOR_CAGE2D_STYLE_BOX = 0, - ED_MANIPULATOR_CAGE2D_STYLE_CIRCLE = 1, + ED_GIZMO_CAGE2D_STYLE_BOX = 0, + ED_GIZMO_CAGE2D_STYLE_CIRCLE = 1, }; /* draw_options */ enum { /** Draw a central handle (instead of having the entire area selectable) * Needed for large rectangles that we don't want to swallow all events. */ - ED_MANIPULATOR_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE = (1 << 0), + ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE = (1 << 0), }; -/** #wmManipulator.highlight_part */ +/** #wmGizmo.highlight_part */ enum { - ED_MANIPULATOR_CAGE2D_PART_TRANSLATE = 0, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X = 1, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X = 2, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y = 3, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y = 4, + ED_GIZMO_CAGE2D_PART_TRANSLATE = 0, + ED_GIZMO_CAGE2D_PART_SCALE_MIN_X = 1, + ED_GIZMO_CAGE2D_PART_SCALE_MAX_X = 2, + ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y = 3, + ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y = 4, /* Corners */ - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y = 5, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y = 6, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y = 7, - ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y = 8, + ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y = 5, + ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y = 6, + ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y = 7, + ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y = 8, - ED_MANIPULATOR_CAGE2D_PART_ROTATE = 9, + ED_GIZMO_CAGE2D_PART_ROTATE = 9, }; -/** #wmManipulator.highlight_part */ +/** #wmGizmo.highlight_part */ enum { /* ordered min/mid/max so we can loop over values (MIN/MID/MAX) on each axis. */ - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z = 0, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MID_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MIN_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MID_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MID_X_MAX_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MID_Y_MAX_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MIN_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MID_Z, - ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, - - ED_MANIPULATOR_CAGE3D_PART_TRANSLATE, - - ED_MANIPULATOR_CAGE3D_PART_ROTATE, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z = 0, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MAX_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MIN_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MAX_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MIN_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MAX_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MIN_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MAX_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MIN_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MAX_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MIN_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MAX_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MIN_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MAX_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MIN_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MAX_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MIN_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MID_Z, + ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, + + ED_GIZMO_CAGE3D_PART_TRANSLATE, + + ED_GIZMO_CAGE3D_PART_ROTATE, }; /* -------------------------------------------------------------------- */ -/* Dial Manipulator */ +/* Dial Gizmo */ /* draw_options */ enum { - ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP = 0, - ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP = (1 << 0), - ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL = (1 << 1), - ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 2), - ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 3), + ED_GIZMO_DIAL_DRAW_FLAG_NOP = 0, + ED_GIZMO_DIAL_DRAW_FLAG_CLIP = (1 << 0), + ED_GIZMO_DIAL_DRAW_FLAG_FILL = (1 << 1), + ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 2), + ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 3), }; /* -------------------------------------------------------------------- */ -/* Grab Manipulator */ +/* Grab Gizmo */ /* draw_options */ enum { - ED_MANIPULATOR_GRAB_DRAW_FLAG_NOP = 0, + ED_GIZMO_GRAB_DRAW_FLAG_NOP = 0, /* only for solid shapes */ - ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL = (1 << 0), - ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW = (1 << 1), + ED_GIZMO_GRAB_DRAW_FLAG_FILL = (1 << 0), + ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW = (1 << 1), }; enum { - ED_MANIPULATOR_GRAB_STYLE_RING_2D = 0, - ED_MANIPULATOR_GRAB_STYLE_CROSS_2D = 1, + ED_GIZMO_GRAB_STYLE_RING_2D = 0, + ED_GIZMO_GRAB_STYLE_CROSS_2D = 1, }; /* -------------------------------------------------------------------- */ -/* Button Manipulator */ +/* Button Gizmo */ enum { - ED_MANIPULATOR_BUTTON_SHOW_OUTLINE = (1 << 0), + ED_GIZMO_BUTTON_SHOW_OUTLINE = (1 << 0), /** * Draw a line from the origin to the offset (similar to an arrow) * sometimes needed to show what the button edits. */ - ED_MANIPULATOR_BUTTON_SHOW_HELPLINE = (1 << 1), + ED_GIZMO_BUTTON_SHOW_HELPLINE = (1 << 1), }; /* -------------------------------------------------------------------- */ -/* Primitive Manipulator */ +/* Primitive Gizmo */ enum { - ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE = 0, + ED_GIZMO_PRIMITIVE_STYLE_PLANE = 0, }; #endif /* __ED_GIZMO_LIBRARY_H__ */ diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 1e3c8995314..80dea103f8c 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -113,8 +113,8 @@ bool calculateTransformCenter(struct bContext *C, int centerMode, float cent3d[3 struct TransInfo; struct Scene; struct Object; -struct wmManipulatorGroup; -struct wmManipulatorGroupType; +struct wmGizmoGroup; +struct wmGizmoGroupType; struct wmOperator; /* UNUSED */ @@ -157,15 +157,15 @@ int BIF_countTransformOrientation(const struct bContext *C); void Transform_Properties(struct wmOperatorType *ot, int flags); -/* transform manipulators */ +/* transform gizmos */ -void TRANSFORM_WGT_manipulator(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_xform_cage(struct wmManipulatorGroupType *wgt); +void TRANSFORM_WGT_gizmo(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_xform_cage(struct wmGizmoGroupType *wgt); -bool ED_widgetgroup_manipulator2d_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt); -void ED_widgetgroup_manipulator2d_setup(const struct bContext *C, struct wmManipulatorGroup *mgroup); -void ED_widgetgroup_manipulator2d_refresh(const struct bContext *C, struct wmManipulatorGroup *mgroup); -void ED_widgetgroup_manipulator2d_draw_prepare(const struct bContext *C, struct wmManipulatorGroup *mgroup); +bool ED_widgetgroup_gizmo2d_poll(const struct bContext *C, struct wmGizmoGroupType *wgt); +void ED_widgetgroup_gizmo2d_setup(const struct bContext *C, struct wmGizmoGroup *mgroup); +void ED_widgetgroup_gizmo2d_refresh(const struct bContext *C, struct wmGizmoGroup *mgroup); +void ED_widgetgroup_gizmo2d_draw_prepare(const struct bContext *C, struct wmGizmoGroup *mgroup); /* Snapping */ @@ -211,7 +211,7 @@ struct TransformCalcParams { /* Use 'Scene.orientation_type' when zero, otherwise subtract one and use. */ ushort orientation_type; }; -int ED_transform_calc_manipulator_stats( +int ED_transform_calc_gizmo_stats( const struct bContext *C, const struct TransformCalcParams *params, struct TransformBounds *tbounds); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 251f2b92acd..723dde640e4 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -73,7 +73,7 @@ struct bNodeSocket; struct wmDropBox; struct wmDrag; struct wmEvent; -struct wmManipulator; +struct wmGizmo; struct wmMsgBus; struct wmKeyMap; struct wmKeyMapItem; @@ -1265,7 +1265,7 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p); /* ui_interface_region_tooltip.c */ struct ARegion *UI_tooltip_create_from_button(struct bContext *C, struct ARegion *butregion, uiBut *but); -struct ARegion *UI_tooltip_create_from_manipulator(struct bContext *C, struct wmManipulator *mpr); +struct ARegion *UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *mpr); void UI_tooltip_free(struct bContext *C, struct bScreen *sc, struct ARegion *ar); /* How long before a tool-tip shows. */ diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 5e6c346d9cf..d2fbb881a0a 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -280,11 +280,11 @@ typedef enum ThemeColorID { TH_AXIS_Y, TH_AXIS_Z, - TH_MANIPULATOR_HI, - TH_MANIPULATOR_PRIMARY, - TH_MANIPULATOR_SECONDARY, - TH_MANIPULATOR_A, - TH_MANIPULATOR_B, + TH_GIZMO_HI, + TH_GIZMO_PRIMARY, + TH_GIZMO_SECONDARY, + TH_GIZMO_A, + TH_GIZMO_B, TH_LOW_GRAD, TH_HIGH_GRAD, diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index ed83a715c7e..fae547d460c 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -615,11 +615,11 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) } } -static uiTooltipData *ui_tooltip_data_from_manipulator(bContext *C, wmManipulator *mpr) +static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *mpr) { uiTooltipData *data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); - /* TODO(campbell): a way for manipulators to have their own descriptions (low priority). */ + /* TODO(campbell): a way for gizmos to have their own descriptions (low priority). */ /* Operator Actions */ { @@ -639,7 +639,7 @@ static uiTooltipData *ui_tooltip_data_from_manipulator(bContext *C, wmManipulato }; for (int i = 0; i < ARRAY_SIZE(mpop_actions); i++) { - wmManipulatorOpElem *mpop = (mpop_actions[i].part != -1) ? WM_manipulator_operator_get(mpr, mpop_actions[i].part) : NULL; + wmGizmoOpElem *mpop = (mpop_actions[i].part != -1) ? WM_gizmo_operator_get(mpr, mpop_actions[i].part) : NULL; if (mpop != NULL) { /* Description */ const char *info = RNA_struct_ui_description(mpop->type->srna); @@ -692,10 +692,10 @@ static uiTooltipData *ui_tooltip_data_from_manipulator(bContext *C, wmManipulato /* Property Actions */ if (mpr->type->target_property_defs_len) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { /* TODO(campbell): function callback descriptions. */ - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; if (mpr_prop->prop != NULL) { const char *info = RNA_property_ui_description(mpr_prop->prop); if (info && info[0]) { @@ -934,13 +934,13 @@ ARegion *UI_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *b return ui_tooltip_create_with_data(C, data, init_position, aspect); } -ARegion *UI_tooltip_create_from_manipulator(bContext *C, wmManipulator *mpr) +ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *mpr) { wmWindow *win = CTX_wm_window(C); const float aspect = 1.0f; float init_position[2]; - uiTooltipData *data = ui_tooltip_data_from_manipulator(C, mpr); + uiTooltipData *data = ui_tooltip_data_from_gizmo(C, mpr); if (data == NULL) { return NULL; } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index a2b1aa1f251..47d664eaeb2 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -679,16 +679,16 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case TH_AXIS_Z: cp = btheme->tui.zaxis; break; - case TH_MANIPULATOR_HI: - cp = btheme->tui.manipulator_hi; break; - case TH_MANIPULATOR_PRIMARY: - cp = btheme->tui.manipulator_primary; break; - case TH_MANIPULATOR_SECONDARY: - cp = btheme->tui.manipulator_secondary; break; - case TH_MANIPULATOR_A: - cp = btheme->tui.manipulator_a; break; - case TH_MANIPULATOR_B: - cp = btheme->tui.manipulator_b; break; + case TH_GIZMO_HI: + cp = btheme->tui.gizmo_hi; break; + case TH_GIZMO_PRIMARY: + cp = btheme->tui.gizmo_primary; break; + case TH_GIZMO_SECONDARY: + cp = btheme->tui.gizmo_secondary; break; + case TH_GIZMO_A: + cp = btheme->tui.gizmo_a; break; + case TH_GIZMO_B: + cp = btheme->tui.gizmo_b; break; case TH_INFO_SELECTED: cp = ts->info_selected; @@ -1338,9 +1338,9 @@ void init_userdef_do_versions(Main *bmain) U.savetime = 1; // XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n"); } - if (U.manipulator_size == 0) { - U.manipulator_size = 75; - U.manipulator_flag |= USER_MANIPULATOR_DRAW; + if (U.gizmo_size == 0) { + U.gizmo_size = 75; + U.gizmo_flag |= USER_GIZMO_DRAW; } if (U.pad_rot_angle == 0.0f) U.pad_rot_angle = 15.0f; @@ -1383,7 +1383,7 @@ void init_userdef_do_versions(Main *bmain) if (U.rvisize == 0) { U.rvisize = 15; U.rvibright = 8; - U.uiflag |= USER_SHOW_MANIPULATOR_AXIS; + U.uiflag |= USER_SHOW_GIZMO_AXIS; } } diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.c index 3918d8847a6..be5c01e08df 100644 --- a/source/blender/editors/mesh/editmesh_add_gizmo.c +++ b/source/blender/editors/mesh/editmesh_add_gizmo.c @@ -21,7 +21,7 @@ /** \file blender/editors/mesh/editmesh_add_gizmo.c * \ingroup edmesh * - * Creation manipulators. + * Creation gizmos. */ #include "MEM_guardedalloc.h" @@ -123,24 +123,24 @@ static void calc_initial_placement_point_from_view( /** \} */ /* -------------------------------------------------------------------- */ -/** \name Placement Manipulator +/** \name Placement Gizmo * \{ */ -typedef struct ManipulatorPlacementGroup { - struct wmManipulator *cage; +typedef struct GizmoPlacementGroup { + struct wmGizmo *cage; struct { bContext *context; wmOperator *op; PropertyRNA *prop_matrix; } data; -} ManipulatorPlacementGroup; +} GizmoPlacementGroup; /** * \warning Calling redo from property updates is not great. * This is needed because changing the RNA doesn't cause a redo * and we're not using operator UI which does just this. */ -static void manipulator_placement_exec(ManipulatorPlacementGroup *man) +static void gizmo_placement_exec(GizmoPlacementGroup *man) { wmOperator *op = man->data.op; if (op == WM_operator_last_redo((bContext *)man->data.context)) { @@ -148,7 +148,7 @@ static void manipulator_placement_exec(ManipulatorPlacementGroup *man) } } -static void manipulator_mesh_placement_update_from_op(ManipulatorPlacementGroup *man) +static void gizmo_mesh_placement_update_from_op(GizmoPlacementGroup *man) { wmOperator *op = man->data.op; UNUSED_VARS(op); @@ -159,11 +159,11 @@ static void manipulator_mesh_placement_update_from_op(ManipulatorPlacementGroup } /* translate callbacks */ -static void manipulator_placement_prop_matrix_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_placement_prop_matrix_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { - ManipulatorPlacementGroup *man = mpr->parent_mgroup->customdata; + GizmoPlacementGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; BLI_assert(mpr_prop->type->array_length == 16); @@ -175,11 +175,11 @@ static void manipulator_placement_prop_matrix_get( } } -static void manipulator_placement_prop_matrix_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_placement_prop_matrix_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value) { - ManipulatorPlacementGroup *man = mpr->parent_mgroup->customdata; + GizmoPlacementGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; BLI_assert(mpr_prop->type->array_length == 16); @@ -194,30 +194,30 @@ static void manipulator_placement_prop_matrix_set( RNA_property_float_set_array(op->ptr, man->data.prop_matrix, &mat[0][0]); - manipulator_placement_exec(man); + gizmo_placement_exec(man); } -static bool manipulator_mesh_placement_poll(const bContext *C, wmManipulatorGroupType *wgt) +static bool gizmo_mesh_placement_poll(const bContext *C, wmGizmoGroupType *wgt) { wmOperator *op = WM_operator_last_redo(C); - if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_manipulator")) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_gizmo")) { + WM_gizmo_group_type_unlink_delayed_ptr(wgt); return false; } return true; } -static void manipulator_mesh_placement_modal_from_setup( - const bContext *C, wmManipulatorGroup *mgroup) +static void gizmo_mesh_placement_modal_from_setup( + const bContext *C, wmGizmoGroup *mgroup) { - ManipulatorPlacementGroup *man = mgroup->customdata; + GizmoPlacementGroup *man = mgroup->customdata; /* Initial size. */ { - wmManipulator *mpr = man->cage; + wmGizmo *mpr = man->cage; zero_m4(mpr->matrix_offset); - /* TODO: support zero scaled matrix in 'MANIPULATOR_WT_cage_3d'. */ + /* TODO: support zero scaled matrix in 'GIZMO_WT_cage_3d'. */ mpr->matrix_offset[0][0] = 0.01; mpr->matrix_offset[1][1] = 0.01; mpr->matrix_offset[2][2] = 0.01; @@ -228,7 +228,7 @@ static void manipulator_mesh_placement_modal_from_setup( { wmWindow *win = CTX_wm_window(C); ARegion *ar = CTX_wm_region(C); - wmManipulator *mpr = man->cage; + wmGizmo *mpr = man->cage; { float mat3[3][3]; @@ -244,87 +244,87 @@ static void manipulator_mesh_placement_modal_from_setup( } if (1) { - wmManipulatorMap *mmap = mgroup->parent_mmap; - WM_manipulator_modal_set_from_setup( - mmap, (bContext *)C, man->cage, ED_MANIPULATOR_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, win->eventstate); + wmGizmoMap *mmap = mgroup->parent_mmap; + WM_gizmo_modal_set_from_setup( + mmap, (bContext *)C, man->cage, ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, win->eventstate); } } } -static void manipulator_mesh_placement_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void gizmo_mesh_placement_setup(const bContext *C, wmGizmoGroup *mgroup) { wmOperator *op = WM_operator_last_redo(C); - if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_manipulator")) { + if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_gizmo")) { return; } - struct ManipulatorPlacementGroup *man = MEM_callocN(sizeof(ManipulatorPlacementGroup), __func__); + struct GizmoPlacementGroup *man = MEM_callocN(sizeof(GizmoPlacementGroup), __func__); mgroup->customdata = man; - const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true); + const wmGizmoType *wt_cage = WM_gizmotype_find("GIZMO_WT_cage_3d", true); - man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); + man->cage = WM_gizmo_new_ptr(wt_cage, mgroup, NULL); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->cage->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->cage->color); RNA_enum_set(man->cage->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_SIGNED); + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED); - WM_manipulator_set_flag(man->cage, WM_MANIPULATOR_DRAW_VALUE, true); + WM_gizmo_set_flag(man->cage, WM_GIZMO_DRAW_VALUE, true); man->data.context = (bContext *)C; man->data.op = op; man->data.prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); - manipulator_mesh_placement_update_from_op(man); + gizmo_mesh_placement_update_from_op(man); /* Setup property callbacks */ { - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( man->cage, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_placement_prop_matrix_get, - .value_set_fn = manipulator_placement_prop_matrix_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_placement_prop_matrix_get, + .value_set_fn = gizmo_placement_prop_matrix_set, .range_get_fn = NULL, .user_data = NULL, }); } - manipulator_mesh_placement_modal_from_setup(C, mgroup); + gizmo_mesh_placement_modal_from_setup(C, mgroup); } -static void manipulator_mesh_placement_draw_prepare( - const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void gizmo_mesh_placement_draw_prepare( + const bContext *UNUSED(C), wmGizmoGroup *mgroup) { - ManipulatorPlacementGroup *man = mgroup->customdata; + GizmoPlacementGroup *man = mgroup->customdata; if (man->data.op->next) { man->data.op = WM_operator_last_redo((bContext *)man->data.context); } - manipulator_mesh_placement_update_from_op(man); + gizmo_mesh_placement_update_from_op(man); } -static void MESH_WGT_add_bounds(struct wmManipulatorGroupType *wgt) +static void MESH_WGT_add_bounds(struct wmGizmoGroupType *wgt) { wgt->name = "Mesh Add Bounds"; wgt->idname = "MESH_WGT_add_bounds"; - wgt->flag = WM_MANIPULATORGROUPTYPE_3D; + wgt->flag = WM_GIZMOGROUPTYPE_3D; wgt->mmap_params.spaceid = SPACE_VIEW3D; wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = manipulator_mesh_placement_poll; - wgt->setup = manipulator_mesh_placement_setup; - wgt->draw_prepare = manipulator_mesh_placement_draw_prepare; + wgt->poll = gizmo_mesh_placement_poll; + wgt->setup = gizmo_mesh_placement_setup; + wgt->draw_prepare = gizmo_mesh_placement_draw_prepare; } /** \} */ /* -------------------------------------------------------------------- */ -/** \name Add Cube Manipulator-Operator +/** \name Add Cube Gizmo-Operator * * For now we use a separate operator to add a cube, * we can try to merge then however they are invoked differently @@ -332,13 +332,13 @@ static void MESH_WGT_add_bounds(struct wmManipulatorGroupType *wgt) * \{ */ -static int add_primitive_cube_manipulator_exec(bContext *C, wmOperator *op) +static int add_primitive_cube_gizmo_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C);; BMEditMesh *em = BKE_editmesh_from_object(obedit); float matrix[4][4]; - /* Get the matrix that defines the cube bounds (as set by the manipulator cage). */ + /* Get the matrix that defines the cube bounds (as set by the gizmo cage). */ { PropertyRNA *prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); if (RNA_property_is_set(op->ptr, prop_matrix)) { @@ -372,25 +372,25 @@ static int add_primitive_cube_manipulator_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int add_primitive_cube_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int add_primitive_cube_gizmo_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { View3D *v3d = CTX_wm_view3d(C); - int ret = add_primitive_cube_manipulator_exec(C, op); + int ret = add_primitive_cube_gizmo_exec(C, op); if (ret & OPERATOR_FINISHED) { - /* Setup manipulators */ - if (v3d && ((v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0)) { + /* Setup gizmos */ + if (v3d && ((v3d->mpr_flag & V3D_GIZMO_HIDE) == 0)) { ARegion *ar = CTX_wm_region(C); - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find("MESH_WGT_add_bounds", false); - wmManipulatorGroup *mgroup = WM_manipulatormap_group_find_ptr(mmap, wgt); + wmGizmoMap *mmap = ar->gizmo_map; + wmGizmoGroupType *wgt = WM_gizmogrouptype_find("MESH_WGT_add_bounds", false); + wmGizmoGroup *mgroup = WM_gizmomap_group_find_ptr(mmap, wgt); if (mgroup != NULL) { - ManipulatorPlacementGroup *man = mgroup->customdata; + GizmoPlacementGroup *man = mgroup->customdata; man->data.op = op; - manipulator_mesh_placement_modal_from_setup(C, mgroup); + gizmo_mesh_placement_modal_from_setup(C, mgroup); } else { - WM_manipulator_group_type_ensure_ptr(wgt); + WM_gizmo_group_type_ensure_ptr(wgt); } } } @@ -398,16 +398,16 @@ static int add_primitive_cube_manipulator_invoke(bContext *C, wmOperator *op, co return ret; } -void MESH_OT_primitive_cube_add_manipulator(wmOperatorType *ot) +void MESH_OT_primitive_cube_add_gizmo(wmOperatorType *ot) { /* identifiers */ ot->name = "Add Cube"; ot->description = "Construct a cube mesh"; - ot->idname = "MESH_OT_primitive_cube_add_manipulator"; + ot->idname = "MESH_OT_primitive_cube_add_gizmo"; /* api callbacks */ - ot->invoke = add_primitive_cube_manipulator_invoke; - ot->exec = add_primitive_cube_manipulator_exec; + ot->invoke = add_primitive_cube_gizmo_invoke; + ot->exec = add_primitive_cube_gizmo_exec; ot->poll = ED_operator_editmesh_view3d; /* flags */ @@ -420,7 +420,7 @@ void MESH_OT_primitive_cube_add_manipulator(wmOperatorType *ot) PropertyRNA *prop = RNA_def_float_matrix(ot->srna, "matrix", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - WM_manipulatorgrouptype_append(MESH_WGT_add_bounds); + WM_gizmogrouptype_append(MESH_WGT_add_bounds); } /** \} */ diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 58246a60362..b73ce410626 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -202,7 +202,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) if (v3d) { opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = V3D_MANIPULATOR_HIDE; + v3d->mpr_flag = V3D_GIZMO_HIDE; } } diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 87a65924979..a9e11b7b411 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -54,9 +54,9 @@ #include "mesh_intern.h" /* own include */ -#define USE_MANIPULATOR +#define USE_GIZMO -#ifdef USE_MANIPULATOR +#ifdef USE_GIZMO #include "ED_gizmo_library.h" #include "ED_undo.h" #endif @@ -157,7 +157,7 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* misc other vars */ G.moving = G_TRANSFORM_EDIT; opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = V3D_MANIPULATOR_HIDE; + v3d->mpr_flag = V3D_GIZMO_HIDE; /* initialize modal callout */ ED_workspace_status_text(C, IFACE_("LMB: Click and drag to draw cut line")); @@ -195,12 +195,12 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) if (ret & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) { edbm_bisect_exit(C, &opdata_back); -#ifdef USE_MANIPULATOR - /* Setup manipulators */ +#ifdef USE_GIZMO + /* Setup gizmos */ { View3D *v3d = CTX_wm_view3d(C); - if (v3d && (v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0) { - WM_manipulator_group_type_ensure("MESH_WGT_bisect"); + if (v3d && (v3d->mpr_flag & V3D_GIZMO_HIDE) == 0) { + WM_gizmo_group_type_ensure("MESH_WGT_bisect"); } } #endif @@ -333,8 +333,8 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) } } -#ifdef USE_MANIPULATOR -static void MESH_WGT_bisect(struct wmManipulatorGroupType *wgt); +#ifdef USE_GIZMO +static void MESH_WGT_bisect(struct wmGizmoGroupType *wgt); #endif void MESH_OT_bisect(struct wmOperatorType *ot) @@ -373,26 +373,26 @@ void MESH_OT_bisect(struct wmOperatorType *ot) WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); -#ifdef USE_MANIPULATOR - WM_manipulatorgrouptype_append(MESH_WGT_bisect); +#ifdef USE_GIZMO + WM_gizmogrouptype_append(MESH_WGT_bisect); #endif } -#ifdef USE_MANIPULATOR +#ifdef USE_GIZMO /* -------------------------------------------------------------------- */ -/** \name Bisect Manipulator +/** \name Bisect Gizmo * \{ */ -typedef struct ManipulatorGroup { +typedef struct GizmoGroup { /* Arrow to change plane depth. */ - struct wmManipulator *translate_z; + struct wmGizmo *translate_z; /* Translate XYZ */ - struct wmManipulator *translate_c; - /* For grabbing the manipulator and moving freely. */ - struct wmManipulator *rotate_c; + struct wmGizmo *translate_c; + /* For grabbing the gizmo and moving freely. */ + struct wmGizmo *rotate_c; /* We could store more vars here! */ struct { @@ -404,14 +404,14 @@ typedef struct ManipulatorGroup { float rotate_axis[3]; float rotate_up[3]; } data; -} ManipulatorGroup; +} GizmoGroup; /** * XXX. calling redo from property updates is not great. * This is needed because changing the RNA doesn't cause a redo * and we're not using operator UI which does just this. */ -static void manipulator_bisect_exec(ManipulatorGroup *man) +static void gizmo_bisect_exec(GizmoGroup *man) { wmOperator *op = man->data.op; if (op == WM_operator_last_redo((bContext *)man->data.context)) { @@ -419,7 +419,7 @@ static void manipulator_bisect_exec(ManipulatorGroup *man) } } -static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man) +static void gizmo_mesh_bisect_update_from_op(GizmoGroup *man) { wmOperator *op = man->data.op; @@ -428,13 +428,13 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man) RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co); RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); - WM_manipulator_set_matrix_location(man->translate_z, plane_co); - WM_manipulator_set_matrix_location(man->rotate_c, plane_co); + WM_gizmo_set_matrix_location(man->translate_z, plane_co); + WM_gizmo_set_matrix_location(man->rotate_c, plane_co); /* translate_c location comes from the property. */ - WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_z, plane_no); + WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_z, plane_no); - WM_manipulator_set_scale(man->translate_c, 0.2); + WM_gizmo_set_scale(man->translate_c, 0.2); RegionView3D *rv3d = ED_view3d_context_rv3d(man->data.context); if (rv3d) { @@ -445,24 +445,24 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man) project_plane_normalized_v3_v3v3(man->data.rotate_up, man->data.rotate_up, man->data.rotate_axis); normalize_v3(man->data.rotate_up); - WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_c, plane_no); + WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_c, plane_no); float plane_no_cross[3]; cross_v3_v3v3(plane_no_cross, plane_no, man->data.rotate_axis); - WM_manipulator_set_matrix_offset_rotation_from_yz_axis(man->rotate_c, plane_no_cross, man->data.rotate_axis); + WM_gizmo_set_matrix_offset_rotation_from_yz_axis(man->rotate_c, plane_no_cross, man->data.rotate_axis); RNA_enum_set(man->rotate_c->ptr, "draw_options", - ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR | - ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y); + ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR | + ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y); } } /* depth callbacks */ -static void manipulator_bisect_prop_depth_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_bisect_prop_depth_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { - ManipulatorGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; @@ -476,11 +476,11 @@ static void manipulator_bisect_prop_depth_get( value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix_basis[3]); } -static void manipulator_bisect_prop_depth_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_bisect_prop_depth_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value_p) { - ManipulatorGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; const float *value = value_p; @@ -499,15 +499,15 @@ static void manipulator_bisect_prop_depth_set( RNA_property_float_set_array(op->ptr, man->data.prop_plane_co, plane_co); - manipulator_bisect_exec(man); + gizmo_bisect_exec(man); } /* translate callbacks */ -static void manipulator_bisect_prop_translate_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_bisect_prop_translate_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { - ManipulatorGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; BLI_assert(mpr_prop->type->array_length == 3); @@ -516,11 +516,11 @@ static void manipulator_bisect_prop_translate_get( RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, value_p); } -static void manipulator_bisect_prop_translate_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_bisect_prop_translate_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value_p) { - ManipulatorGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; BLI_assert(mpr_prop->type->array_length == 3); @@ -528,15 +528,15 @@ static void manipulator_bisect_prop_translate_set( RNA_property_float_set_array(op->ptr, man->data.prop_plane_co, value_p); - manipulator_bisect_exec(man); + gizmo_bisect_exec(man); } /* angle callbacks */ -static void manipulator_bisect_prop_angle_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_bisect_prop_angle_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { - ManipulatorGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; @@ -559,11 +559,11 @@ static void manipulator_bisect_prop_angle_get( } } -static void manipulator_bisect_prop_angle_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_bisect_prop_angle_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value_p) { - ManipulatorGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; const float *value = value_p; @@ -588,22 +588,22 @@ static void manipulator_bisect_prop_angle_set( /* re-normalize - seems acceptable */ RNA_property_float_set_array(op->ptr, man->data.prop_plane_no, plane_no); - manipulator_bisect_exec(man); + gizmo_bisect_exec(man); } } } -static bool manipulator_mesh_bisect_poll(const bContext *C, wmManipulatorGroupType *wgt) +static bool gizmo_mesh_bisect_poll(const bContext *C, wmGizmoGroupType *wgt) { wmOperator *op = WM_operator_last_redo(C); if (op == NULL || !STREQ(op->type->idname, "MESH_OT_bisect")) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(wgt); return false; } return true; } -static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *mgroup) { wmOperator *op = WM_operator_last_redo(C); @@ -611,26 +611,26 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup return; } - struct ManipulatorGroup *man = MEM_callocN(sizeof(ManipulatorGroup), __func__); + struct GizmoGroup *man = MEM_callocN(sizeof(GizmoGroup), __func__); mgroup->customdata = man; - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); - const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true); - const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); + const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); + const wmGizmoType *wt_grab = WM_gizmotype_find("GIZMO_WT_grab_3d", true); + const wmGizmoType *wt_dial = WM_gizmotype_find("GIZMO_WT_dial_3d", true); - man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, NULL); - man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); + man->translate_z = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); + man->translate_c = WM_gizmo_new_ptr(wt_grab, mgroup, NULL); + man->rotate_c = WM_gizmo_new_ptr(wt_dial, mgroup, NULL); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_z->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_c->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, man->rotate_c->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_z->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_c->color); + UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, man->rotate_c->color); - RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL); - RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D); + RNA_enum_set(man->translate_z->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_NORMAL); + RNA_enum_set(man->translate_c->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_RING_2D); - WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true); - WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true); + WM_gizmo_set_flag(man->translate_c, WM_GIZMO_DRAW_VALUE, true); + WM_gizmo_set_flag(man->rotate_c, WM_GIZMO_DRAW_VALUE, true); { man->data.context = (bContext *)C; @@ -639,64 +639,64 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup man->data.prop_plane_no = RNA_struct_find_property(op->ptr, "plane_no"); } - manipulator_mesh_bisect_update_from_op(man); + gizmo_mesh_bisect_update_from_op(man); /* Setup property callbacks */ { - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( man->translate_z, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_bisect_prop_depth_get, - .value_set_fn = manipulator_bisect_prop_depth_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_bisect_prop_depth_get, + .value_set_fn = gizmo_bisect_prop_depth_set, .range_get_fn = NULL, .user_data = NULL, }); - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( man->translate_c, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_bisect_prop_translate_get, - .value_set_fn = manipulator_bisect_prop_translate_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_bisect_prop_translate_get, + .value_set_fn = gizmo_bisect_prop_translate_set, .range_get_fn = NULL, .user_data = NULL, }); - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( man->rotate_c, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_bisect_prop_angle_get, - .value_set_fn = manipulator_bisect_prop_angle_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_bisect_prop_angle_get, + .value_set_fn = gizmo_bisect_prop_angle_set, .range_get_fn = NULL, .user_data = NULL, }); } } -static void manipulator_mesh_bisect_draw_prepare( - const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void gizmo_mesh_bisect_draw_prepare( + const bContext *UNUSED(C), wmGizmoGroup *mgroup) { - ManipulatorGroup *man = mgroup->customdata; + GizmoGroup *man = mgroup->customdata; if (man->data.op->next) { man->data.op = WM_operator_last_redo((bContext *)man->data.context); } - manipulator_mesh_bisect_update_from_op(man); + gizmo_mesh_bisect_update_from_op(man); } -static void MESH_WGT_bisect(struct wmManipulatorGroupType *wgt) +static void MESH_WGT_bisect(struct wmGizmoGroupType *wgt) { wgt->name = "Mesh Bisect"; wgt->idname = "MESH_WGT_bisect"; - wgt->flag = WM_MANIPULATORGROUPTYPE_3D; + wgt->flag = WM_GIZMOGROUPTYPE_3D; wgt->mmap_params.spaceid = SPACE_VIEW3D; wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = manipulator_mesh_bisect_poll; - wgt->setup = manipulator_mesh_bisect_setup; - wgt->draw_prepare = manipulator_mesh_bisect_draw_prepare; + wgt->poll = gizmo_mesh_bisect_poll; + wgt->setup = gizmo_mesh_bisect_setup; + wgt->draw_prepare = gizmo_mesh_bisect_draw_prepare; } /** \} */ -#endif /* USE_MANIPULATOR */ +#endif /* USE_GIZMO */ diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index b007bcf04ba..dd167c1fc15 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -61,7 +61,7 @@ #include "mesh_intern.h" /* own include */ -#define USE_MANIPULATOR +#define USE_GIZMO /* -------------------------------------------------------------------- */ /** \name Extrude Internal Utilities @@ -360,10 +360,10 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) /* -------------------------------------------------------------------- */ -/** \name Extrude Manipulator +/** \name Extrude Gizmo * \{ */ -#ifdef USE_MANIPULATOR +#ifdef USE_GIZMO const float extrude_button_scale = 0.15f; const float extrude_button_offset_scale = 1.5f; @@ -380,11 +380,11 @@ static const uchar shape_plus[] = { 0x90, 0x6e, 0xd7, 0x80, 0xff, 0x5f, 0xfb, 0x5f, 0xfb, }; -typedef struct ManipulatorExtrudeGroup { +typedef struct GizmoExtrudeGroup { /* XYZ & normal. */ - struct wmManipulator *invoke_xyz_no[4]; - struct wmManipulator *adjust_xyz_no[5]; + struct wmGizmo *invoke_xyz_no[4]; + struct wmGizmo *adjust_xyz_no[5]; struct { float normal_mat3[3][3]; /* use Z axis for normal. */ @@ -392,10 +392,10 @@ typedef struct ManipulatorExtrudeGroup { } data; wmOperatorType *ot_extrude; -} ManipulatorExtrudeGroup; +} GizmoExtrudeGroup; -static void manipulator_mesh_extrude_orientation_matrix_set( - struct ManipulatorExtrudeGroup *man, const float mat[3][3]) +static void gizmo_mesh_extrude_orientation_matrix_set( + struct GizmoExtrudeGroup *man, const float mat[3][3]) { for (int i = 0; i < 3; i++) { /* Set orientation without location. */ @@ -417,32 +417,32 @@ static void manipulator_mesh_extrude_orientation_matrix_set( } } -static bool manipulator_mesh_extrude_poll(const bContext *C, wmManipulatorGroupType *wgt) +static bool gizmo_mesh_extrude_poll(const bContext *C, wmGizmoGroupType *wgt) { ScrArea *sa = CTX_wm_area(C); bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->manipulator_group) || + !STREQ(wgt->idname, tref_rt->gizmo_group) || !ED_operator_editmesh_view3d((bContext *)C)) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(wgt); return false; } return true; } -static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void gizmo_mesh_extrude_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { - struct ManipulatorExtrudeGroup *man = MEM_callocN(sizeof(ManipulatorExtrudeGroup), __func__); + struct GizmoExtrudeGroup *man = MEM_callocN(sizeof(GizmoExtrudeGroup), __func__); mgroup->customdata = man; - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); - const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_button_2d", true); + const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); + const wmGizmoType *wt_grab = WM_gizmotype_find("GIZMO_WT_button_2d", true); for (int i = 0; i < 4; i++) { - man->adjust_xyz_no[i] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->invoke_xyz_no[i] = WM_manipulator_new_ptr(wt_grab, mgroup, NULL); - man->invoke_xyz_no[i]->flag |= WM_MANIPULATOR_DRAW_OFFSET_SCALE; + man->adjust_xyz_no[i] = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); + man->invoke_xyz_no[i] = WM_gizmo_new_ptr(wt_grab, mgroup, NULL); + man->invoke_xyz_no[i]->flag |= WM_GIZMO_DRAW_OFFSET_SCALE; } { @@ -460,25 +460,25 @@ static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipula UI_GetThemeColor3fv(TH_AXIS_X + i, man->invoke_xyz_no[i]->color); UI_GetThemeColor3fv(TH_AXIS_X + i, man->adjust_xyz_no[i]->color); } - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->invoke_xyz_no[3]->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->adjust_xyz_no[3]->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->invoke_xyz_no[3]->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->adjust_xyz_no[3]->color); for (int i = 0; i < 4; i++) { - WM_manipulator_set_scale(man->invoke_xyz_no[i], extrude_button_scale); - WM_manipulator_set_scale(man->adjust_xyz_no[i], extrude_arrow_scale); + WM_gizmo_set_scale(man->invoke_xyz_no[i], extrude_button_scale); + WM_gizmo_set_scale(man->adjust_xyz_no[i], extrude_arrow_scale); } - WM_manipulator_set_scale(man->adjust_xyz_no[3], extrude_arrow_normal_axis_scale); + WM_gizmo_set_scale(man->adjust_xyz_no[3], extrude_arrow_normal_axis_scale); for (int i = 0; i < 4; i++) { } for (int i = 0; i < 4; i++) { - WM_manipulator_set_flag(man->adjust_xyz_no[i], WM_MANIPULATOR_DRAW_VALUE, true); + WM_gizmo_set_flag(man->adjust_xyz_no[i], WM_GIZMO_DRAW_VALUE, true); } /* XYZ & normal axis extrude. */ for (int i = 0; i < 4; i++) { - PointerRNA *ptr = WM_manipulator_operator_set(man->invoke_xyz_no[i], 0, man->ot_extrude, NULL); + PointerRNA *ptr = WM_gizmo_operator_set(man->invoke_xyz_no[i], 0, man->ot_extrude, NULL); { bool constraint[3] = {0, 0, 0}; constraint[MIN2(i, 2)] = 1; @@ -490,7 +490,7 @@ static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipula /* Adjust extrude. */ for (int i = 0; i < 4; i++) { - PointerRNA *ptr = WM_manipulator_operator_set(man->adjust_xyz_no[i], 0, man->ot_extrude, NULL); + PointerRNA *ptr = WM_gizmo_operator_set(man->adjust_xyz_no[i], 0, man->ot_extrude, NULL); { bool constraint[3] = {0, 0, 0}; constraint[MIN2(i, 2)] = 1; @@ -498,18 +498,18 @@ static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipula RNA_boolean_set(¯optr, "release_confirm", true); RNA_boolean_set_array(¯optr, "constraint_axis", constraint); } - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(man->adjust_xyz_no[i], 0); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(man->adjust_xyz_no[i], 0); mpop->is_redo = true; } } -static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void gizmo_mesh_extrude_refresh(const bContext *C, wmGizmoGroup *mgroup) { - ManipulatorExtrudeGroup *man = mgroup->customdata; + GizmoExtrudeGroup *man = mgroup->customdata; for (int i = 0; i < 4; i++) { - WM_manipulator_set_flag(man->invoke_xyz_no[i], WM_MANIPULATOR_HIDDEN, true); - WM_manipulator_set_flag(man->adjust_xyz_no[i], WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(man->invoke_xyz_no[i], WM_GIZMO_HIDDEN, true); + WM_gizmo_set_flag(man->adjust_xyz_no[i], WM_GIZMO_HIDDEN, true); } if (G.moving) { @@ -525,7 +525,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro if (use_normal) { struct TransformBounds tbounds_normal; - if (!ED_transform_calc_manipulator_stats( + if (!ED_transform_calc_gizmo_stats( C, &(struct TransformCalcParams){ .orientation_type = V3D_MANIP_NORMAL + 1, }, &tbounds_normal)) @@ -536,7 +536,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro } /* TODO(campbell): run second since this modifies the 3D view, it should not. */ - if (!ED_transform_calc_manipulator_stats( + if (!ED_transform_calc_gizmo_stats( C, &(struct TransformCalcParams){ .orientation_type = man->data.orientation_type + 1, }, &tbounds)) @@ -556,15 +556,15 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro (extrude_arrow_normal_axis_scale * extrude_button_offset_scale) / extrude_button_scale); /* Needed for normal orientation. */ - manipulator_mesh_extrude_orientation_matrix_set(man, tbounds.axis); + gizmo_mesh_extrude_orientation_matrix_set(man, tbounds.axis); if (use_normal) { copy_m4_m3(man->adjust_xyz_no[3]->matrix_basis, man->data.normal_mat3); } /* Location. */ for (int i = 0; i < axis_len_used; i++) { - WM_manipulator_set_matrix_location(man->invoke_xyz_no[i], tbounds.center); - WM_manipulator_set_matrix_location(man->adjust_xyz_no[i], tbounds.center); + WM_gizmo_set_matrix_location(man->invoke_xyz_no[i], tbounds.center); + WM_gizmo_set_matrix_location(man->adjust_xyz_no[i], tbounds.center); } wmOperator *op = WM_operator_last_redo(C); @@ -572,13 +572,13 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro /* Un-hide. */ for (int i = 0; i < axis_len_used; i++) { - WM_manipulator_set_flag(man->invoke_xyz_no[i], WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_set_flag(man->adjust_xyz_no[i], WM_MANIPULATOR_HIDDEN, !has_redo); + WM_gizmo_set_flag(man->invoke_xyz_no[i], WM_GIZMO_HIDDEN, false); + WM_gizmo_set_flag(man->adjust_xyz_no[i], WM_GIZMO_HIDDEN, !has_redo); } /* Operator properties. */ if (use_normal) { - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(man->invoke_xyz_no[3], 0); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(man->invoke_xyz_no[3], 0); PointerRNA macroptr = RNA_pointer_get(&mpop->ptr, "TRANSFORM_OT_translate"); RNA_enum_set(¯optr, "constraint_orientation", V3D_MANIP_NORMAL); } @@ -598,7 +598,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro (orientation_type == man->data.orientation_type && constraint_axis[i]) : (orientation_type == V3D_MANIP_NORMAL && constraint_axis[2])) { - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(man->adjust_xyz_no[i], 0); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(man->adjust_xyz_no[i], 0); PointerRNA macroptr = RNA_pointer_get(&mpop->ptr, "TRANSFORM_OT_translate"); @@ -609,7 +609,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro else { /* TODO(campbell): ideally we could adjust all, * this is complicated by how operator redo and the transform macro works. */ - WM_manipulator_set_flag(man->adjust_xyz_no[i], WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(man->adjust_xyz_no[i], WM_GIZMO_HIDDEN, true); } } } @@ -618,14 +618,14 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro RNA_enum_set( man->invoke_xyz_no[i]->ptr, "draw_options", - (man->adjust_xyz_no[i]->flag & WM_MANIPULATOR_HIDDEN) ? - ED_MANIPULATOR_BUTTON_SHOW_HELPLINE : 0); + (man->adjust_xyz_no[i]->flag & WM_GIZMO_HIDDEN) ? + ED_GIZMO_BUTTON_SHOW_HELPLINE : 0); } } -static void manipulator_mesh_extrude_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void gizmo_mesh_extrude_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { - ManipulatorExtrudeGroup *man = mgroup->customdata; + GizmoExtrudeGroup *man = mgroup->customdata; switch (man->data.orientation_type) { case V3D_MANIP_VIEW: { @@ -633,14 +633,14 @@ static void manipulator_mesh_extrude_draw_prepare(const bContext *C, wmManipulat float mat[3][3]; copy_m3_m4(mat, rv3d->viewinv); normalize_m3(mat); - manipulator_mesh_extrude_orientation_matrix_set(man, mat); + gizmo_mesh_extrude_orientation_matrix_set(man, mat); break; } } } -static void manipulator_mesh_extrude_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) +static void gizmo_mesh_extrude_message_subscribe( + const bContext *C, wmGizmoGroup *mgroup, struct wmMsgBus *mbus) { ARegion *ar = CTX_wm_region(C); @@ -648,7 +648,7 @@ static void manipulator_mesh_extrude_message_subscribe( wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { .owner = ar, .user_data = mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, + .notify = WM_gizmo_do_msg_notify_tag_refresh, }; { @@ -657,24 +657,24 @@ static void manipulator_mesh_extrude_message_subscribe( } -static void MESH_WGT_extrude(struct wmManipulatorGroupType *wgt) +static void MESH_WGT_extrude(struct wmGizmoGroupType *wgt) { wgt->name = "Mesh Extrude"; wgt->idname = "MESH_WGT_extrude"; - wgt->flag = WM_MANIPULATORGROUPTYPE_3D; + wgt->flag = WM_GIZMOGROUPTYPE_3D; wgt->mmap_params.spaceid = SPACE_VIEW3D; wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = manipulator_mesh_extrude_poll; - wgt->setup = manipulator_mesh_extrude_setup; - wgt->refresh = manipulator_mesh_extrude_refresh; - wgt->draw_prepare = manipulator_mesh_extrude_draw_prepare; - wgt->message_subscribe = manipulator_mesh_extrude_message_subscribe; + wgt->poll = gizmo_mesh_extrude_poll; + wgt->setup = gizmo_mesh_extrude_setup; + wgt->refresh = gizmo_mesh_extrude_refresh; + wgt->draw_prepare = gizmo_mesh_extrude_draw_prepare; + wgt->message_subscribe = gizmo_mesh_extrude_message_subscribe; } -#endif /* USE_MANIPULATOR */ +#endif /* USE_GIZMO */ /** \} */ @@ -825,8 +825,8 @@ void MESH_OT_extrude_context(wmOperatorType *ot) Transform_Properties(ot, P_NO_DEFAULTS | P_MIRROR_DUMMY); -#ifdef USE_MANIPULATOR - WM_manipulatorgrouptype_append(MESH_WGT_extrude); +#ifdef USE_GIZMO + WM_gizmogrouptype_append(MESH_WGT_extrude); #endif } diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index 74e2833b2d9..3864bd63036 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -54,27 +54,27 @@ #include "mesh_intern.h" /* own include */ -#define USE_MANIPULATOR +#define USE_GIZMO -#ifdef USE_MANIPULATOR +#ifdef USE_GIZMO #include "ED_gizmo_library.h" #include "ED_undo.h" #endif /* -------------------------------------------------------------------- */ -/** \name Spin Manipulator +/** \name Spin Gizmo * \{ */ -#ifdef USE_MANIPULATOR -typedef struct ManipulatorSpinGroup { +#ifdef USE_GIZMO +typedef struct GizmoSpinGroup { /* Arrow to change plane depth. */ - struct wmManipulator *translate_z; + struct wmGizmo *translate_z; /* Translate XYZ */ - struct wmManipulator *translate_c; - /* For grabbing the manipulator and moving freely. */ - struct wmManipulator *rotate_c; + struct wmGizmo *translate_c; + /* For grabbing the gizmo and moving freely. */ + struct wmGizmo *rotate_c; /* Spin angle */ - struct wmManipulator *angle_z; + struct wmGizmo *angle_z; /* We could store more vars here! */ struct { @@ -87,14 +87,14 @@ typedef struct ManipulatorSpinGroup { float rotate_axis[3]; float rotate_up[3]; } data; -} ManipulatorSpinGroup; +} GizmoSpinGroup; /** * XXX. calling redo from property updates is not great. * This is needed because changing the RNA doesn't cause a redo * and we're not using operator UI which does just this. */ -static void manipulator_spin_exec(ManipulatorSpinGroup *man) +static void gizmo_spin_exec(GizmoSpinGroup *man) { wmOperator *op = man->data.op; if (op == WM_operator_last_redo((bContext *)man->data.context)) { @@ -102,7 +102,7 @@ static void manipulator_spin_exec(ManipulatorSpinGroup *man) } } -static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man) +static void gizmo_mesh_spin_update_from_op(GizmoSpinGroup *man) { wmOperator *op = man->data.op; @@ -111,15 +111,15 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man) RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co); RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no); - WM_manipulator_set_matrix_location(man->translate_z, plane_co); - WM_manipulator_set_matrix_location(man->rotate_c, plane_co); - WM_manipulator_set_matrix_location(man->angle_z, plane_co); + WM_gizmo_set_matrix_location(man->translate_z, plane_co); + WM_gizmo_set_matrix_location(man->rotate_c, plane_co); + WM_gizmo_set_matrix_location(man->angle_z, plane_co); /* translate_c location comes from the property. */ - WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_z, plane_no); - WM_manipulator_set_matrix_rotation_from_z_axis(man->angle_z, plane_no); + WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_z, plane_no); + WM_gizmo_set_matrix_rotation_from_z_axis(man->angle_z, plane_no); - WM_manipulator_set_scale(man->translate_c, 0.2); + WM_gizmo_set_scale(man->translate_c, 0.2); RegionView3D *rv3d = ED_view3d_context_rv3d(man->data.context); if (rv3d) { @@ -130,23 +130,23 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man) project_plane_normalized_v3_v3v3(man->data.rotate_up, man->data.rotate_up, man->data.rotate_axis); normalize_v3(man->data.rotate_up); - WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_c, plane_no); - WM_manipulator_set_matrix_rotation_from_yz_axis(man->rotate_c, plane_no, man->data.rotate_axis); + WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_c, plane_no); + WM_gizmo_set_matrix_rotation_from_yz_axis(man->rotate_c, plane_no, man->data.rotate_axis); /* show the axis instead of mouse cursor */ RNA_enum_set(man->rotate_c->ptr, "draw_options", - ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR | - ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y); + ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR | + ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y); } } /* depth callbacks */ -static void manipulator_spin_prop_depth_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_spin_prop_depth_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { - ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; @@ -160,11 +160,11 @@ static void manipulator_spin_prop_depth_get( value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix_basis[3]); } -static void manipulator_spin_prop_depth_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_spin_prop_depth_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value_p) { - ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; const float *value = value_p; @@ -183,15 +183,15 @@ static void manipulator_spin_prop_depth_set( RNA_property_float_set_array(op->ptr, man->data.prop_axis_co, plane_co); - manipulator_spin_exec(man); + gizmo_spin_exec(man); } /* translate callbacks */ -static void manipulator_spin_prop_translate_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_spin_prop_translate_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { - ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; @@ -201,11 +201,11 @@ static void manipulator_spin_prop_translate_get( RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, value); } -static void manipulator_spin_prop_translate_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_spin_prop_translate_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value) { - ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; BLI_assert(mpr_prop->type->array_length == 3); @@ -213,15 +213,15 @@ static void manipulator_spin_prop_translate_set( RNA_property_float_set_array(op->ptr, man->data.prop_axis_co, value); - manipulator_spin_exec(man); + gizmo_spin_exec(man); } /* angle callbacks */ -static void manipulator_spin_prop_axis_angle_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_spin_prop_axis_angle_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { - ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; @@ -244,11 +244,11 @@ static void manipulator_spin_prop_axis_angle_get( } } -static void manipulator_spin_prop_axis_angle_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_spin_prop_axis_angle_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value_p) { - ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; const float *value = value_p; @@ -273,17 +273,17 @@ static void manipulator_spin_prop_axis_angle_set( /* re-normalize - seems acceptable */ RNA_property_float_set_array(op->ptr, man->data.prop_axis_no, plane_no); - manipulator_spin_exec(man); + gizmo_spin_exec(man); } } } /* angle callbacks */ -static void manipulator_spin_prop_angle_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_spin_prop_angle_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { - ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; @@ -292,31 +292,31 @@ static void manipulator_spin_prop_angle_get( value[0] = RNA_property_float_get(op->ptr, man->data.prop_angle); } -static void manipulator_spin_prop_angle_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_spin_prop_angle_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value_p) { - ManipulatorSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = mpr->parent_mgroup->customdata; wmOperator *op = man->data.op; BLI_assert(mpr_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(mpr_prop); const float *value = value_p; RNA_property_float_set(op->ptr, man->data.prop_angle, value[0]); - manipulator_spin_exec(man); + gizmo_spin_exec(man); } -static bool manipulator_mesh_spin_poll(const bContext *C, wmManipulatorGroupType *wgt) +static bool gizmo_mesh_spin_poll(const bContext *C, wmGizmoGroupType *wgt) { wmOperator *op = WM_operator_last_redo(C); if (op == NULL || !STREQ(op->type->idname, "MESH_OT_spin")) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(wgt); return false; } return true; } -static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void gizmo_mesh_spin_setup(const bContext *C, wmGizmoGroup *mgroup) { wmOperator *op = WM_operator_last_redo(C); @@ -324,32 +324,32 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m return; } - struct ManipulatorSpinGroup *man = MEM_callocN(sizeof(ManipulatorSpinGroup), __func__); + struct GizmoSpinGroup *man = MEM_callocN(sizeof(GizmoSpinGroup), __func__); mgroup->customdata = man; - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); - const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true); - const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); + const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); + const wmGizmoType *wt_grab = WM_gizmotype_find("GIZMO_WT_grab_3d", true); + const wmGizmoType *wt_dial = WM_gizmotype_find("GIZMO_WT_dial_3d", true); - man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, NULL); - man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); - man->angle_z = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); + man->translate_z = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); + man->translate_c = WM_gizmo_new_ptr(wt_grab, mgroup, NULL); + man->rotate_c = WM_gizmo_new_ptr(wt_dial, mgroup, NULL); + man->angle_z = WM_gizmo_new_ptr(wt_dial, mgroup, NULL); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_z->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_c->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, man->rotate_c->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_z->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_c->color); + UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, man->rotate_c->color); UI_GetThemeColor3fv(TH_AXIS_Z, man->angle_z->color); - RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL); - RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D); + RNA_enum_set(man->translate_z->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_NORMAL); + RNA_enum_set(man->translate_c->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_RING_2D); - WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true); - WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true); - WM_manipulator_set_flag(man->angle_z, WM_MANIPULATOR_DRAW_VALUE, true); + WM_gizmo_set_flag(man->translate_c, WM_GIZMO_DRAW_VALUE, true); + WM_gizmo_set_flag(man->rotate_c, WM_GIZMO_DRAW_VALUE, true); + WM_gizmo_set_flag(man->angle_z, WM_GIZMO_DRAW_VALUE, true); - WM_manipulator_set_scale(man->angle_z, 0.5f); + WM_gizmo_set_scale(man->angle_z, 0.5f); { man->data.context = (bContext *)C; @@ -359,42 +359,42 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m man->data.prop_angle = RNA_struct_find_property(op->ptr, "angle"); } - manipulator_mesh_spin_update_from_op(man); + gizmo_mesh_spin_update_from_op(man); /* Setup property callbacks */ { - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( man->translate_z, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_spin_prop_depth_get, - .value_set_fn = manipulator_spin_prop_depth_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_spin_prop_depth_get, + .value_set_fn = gizmo_spin_prop_depth_set, .range_get_fn = NULL, .user_data = NULL, }); - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( man->translate_c, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_spin_prop_translate_get, - .value_set_fn = manipulator_spin_prop_translate_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_spin_prop_translate_get, + .value_set_fn = gizmo_spin_prop_translate_set, .range_get_fn = NULL, .user_data = NULL, }); - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( man->rotate_c, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_spin_prop_axis_angle_get, - .value_set_fn = manipulator_spin_prop_axis_angle_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_spin_prop_axis_angle_get, + .value_set_fn = gizmo_spin_prop_axis_angle_set, .range_get_fn = NULL, .user_data = NULL, }); - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( man->angle_z, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_spin_prop_angle_get, - .value_set_fn = manipulator_spin_prop_angle_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_spin_prop_angle_get, + .value_set_fn = gizmo_spin_prop_angle_set, .range_get_fn = NULL, .user_data = NULL, }); @@ -402,34 +402,34 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m } } -static void manipulator_mesh_spin_draw_prepare( - const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void gizmo_mesh_spin_draw_prepare( + const bContext *UNUSED(C), wmGizmoGroup *mgroup) { - ManipulatorSpinGroup *man = mgroup->customdata; + GizmoSpinGroup *man = mgroup->customdata; if (man->data.op->next) { man->data.op = WM_operator_last_redo((bContext *)man->data.context); } - manipulator_mesh_spin_update_from_op(man); + gizmo_mesh_spin_update_from_op(man); } -static void MESH_WGT_spin(struct wmManipulatorGroupType *wgt) +static void MESH_WGT_spin(struct wmGizmoGroupType *wgt) { wgt->name = "Mesh Spin"; wgt->idname = "MESH_WGT_spin"; - wgt->flag = WM_MANIPULATORGROUPTYPE_3D; + wgt->flag = WM_GIZMOGROUPTYPE_3D; wgt->mmap_params.spaceid = SPACE_VIEW3D; wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = manipulator_mesh_spin_poll; - wgt->setup = manipulator_mesh_spin_setup; - wgt->draw_prepare = manipulator_mesh_spin_draw_prepare; + wgt->poll = gizmo_mesh_spin_poll; + wgt->setup = gizmo_mesh_spin_setup; + wgt->draw_prepare = gizmo_mesh_spin_draw_prepare; } /** \} */ -#endif /* USE_MANIPULATOR */ +#endif /* USE_GIZMO */ /* -------------------------------------------------------------------- */ /** \name Spin Operator @@ -508,11 +508,11 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e int ret = edbm_spin_exec(C, op); -#ifdef USE_MANIPULATOR +#ifdef USE_GIZMO if (ret & OPERATOR_FINISHED) { - /* Setup manipulators */ - if (v3d && ((v3d->mpr_flag & V3D_MANIPULATOR_HIDE) == 0)) { - WM_manipulator_group_type_ensure("MESH_WGT_spin"); + /* Setup gizmos */ + if (v3d && ((v3d->mpr_flag & V3D_GIZMO_HIDE) == 0)) { + WM_gizmo_group_type_ensure("MESH_WGT_spin"); } } #endif @@ -548,7 +548,7 @@ void MESH_OT_spin(wmOperatorType *ot) "Center", "Center in global view space", -1e4f, 1e4f); RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); -#ifdef USE_MANIPULATOR - WM_manipulatorgrouptype_append(MESH_WGT_spin); +#ifdef USE_GIZMO + WM_gizmogrouptype_append(MESH_WGT_spin); #endif } diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 1f1d2f5a2e1..1be180b852c 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -174,7 +174,7 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) G.moving = G_TRANSFORM_EDIT; if (v3d) { opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = V3D_MANIPULATOR_HIDE; + v3d->mpr_flag = V3D_GIZMO_HIDE; } } diff --git a/source/blender/editors/mesh/editmesh_polybuild.c b/source/blender/editors/mesh/editmesh_polybuild.c index e8bcfb5eb08..86c9fc0243b 100644 --- a/source/blender/editors/mesh/editmesh_polybuild.c +++ b/source/blender/editors/mesh/editmesh_polybuild.c @@ -390,7 +390,7 @@ void MESH_OT_polybuild_dissolve_at_cursor(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Cursor Manipulator +/** \name Cursor Gizmo * * \note This may need its own file, for now not. * \{ */ diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 3800ab9dddd..cc9448e5e06 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -92,8 +92,8 @@ void MESH_OT_primitive_monkey_add(struct wmOperatorType *ot); void MESH_OT_primitive_uv_sphere_add(struct wmOperatorType *ot); void MESH_OT_primitive_ico_sphere_add(struct wmOperatorType *ot); -/* *** editmesh_add_manipulator.c *** */ -void MESH_OT_primitive_cube_add_manipulator(struct wmOperatorType *ot); +/* *** editmesh_add_gizmo.c *** */ +void MESH_OT_primitive_cube_add_gizmo(struct wmOperatorType *ot); /* *** editmesh_bevel.c *** */ void MESH_OT_bevel(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 2bfc0634f1e..0fcc5ada854 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -78,7 +78,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_primitive_uv_sphere_add); WM_operatortype_append(MESH_OT_primitive_ico_sphere_add); - WM_operatortype_append(MESH_OT_primitive_cube_add_manipulator); + WM_operatortype_append(MESH_OT_primitive_cube_add_gizmo); WM_operatortype_append(MESH_OT_duplicate); WM_operatortype_append(MESH_OT_remove_doubles); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 137fd01a146..41c3209dbb1 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2936,8 +2936,8 @@ void ED_region_message_subscribe( struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar, struct wmMsgBus *mbus) { - if (ar->manipulator_map != NULL) { - WM_manipulatormap_message_subscribe(C, ar->manipulator_map, ar, mbus); + if (ar->gizmo_map != NULL) { + WM_gizmomap_message_subscribe(C, ar->gizmo_map, ar, mbus); } if (BLI_listbase_is_empty(&ar->uiblocks)) { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 8fbf74ed800..1d14940085b 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -381,8 +381,8 @@ static void region_cursor_set(wmWindow *win, bool swin_changed) for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { if (ar == screen->active_region) { if (swin_changed || (ar->type && ar->type->event_cursor)) { - if (ar->manipulator_map != NULL) { - if (WM_manipulatormap_cursor_set(ar->manipulator_map, win)) { + if (ar->gizmo_map != NULL) { + if (WM_gizmomap_cursor_set(ar->gizmo_map, win)) { return; } } diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 37f5ed642fe..7246812dc82 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -129,22 +129,22 @@ void ED_spacetypes_init(void) ED_screen_user_menu_register(); - /* manipulator types */ - ED_manipulatortypes_button_2d(); - ED_manipulatortypes_dial_3d(); - ED_manipulatortypes_grab_3d(); - ED_manipulatortypes_arrow_2d(); - ED_manipulatortypes_arrow_3d(); - ED_manipulatortypes_primitive_3d(); - ED_manipulatortypes_cage_2d(); - ED_manipulatortypes_cage_3d(); - - /* register types for operators and manipulators */ + /* gizmo types */ + ED_gizmotypes_button_2d(); + ED_gizmotypes_dial_3d(); + ED_gizmotypes_grab_3d(); + ED_gizmotypes_arrow_2d(); + ED_gizmotypes_arrow_3d(); + ED_gizmotypes_primitive_3d(); + ED_gizmotypes_cage_2d(); + ED_gizmotypes_cage_3d(); + + /* register types for operators and gizmos */ spacetypes = BKE_spacetypes_list(); for (type = spacetypes->first; type; type = type->next) { - /* init manipulator types first, operator-types need them */ - if (type->manipulators) { - type->manipulators(); + /* init gizmo types first, operator-types need them */ + if (type->gizmos) { + type->gizmos(); } if (type->operatortypes) { type->operatortypes(); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 650f377787a..68b0f42768a 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -581,25 +581,25 @@ static int image_context(const bContext *C, const char *member, bContextDataResu return 0; } -static void IMAGE_WGT_manipulator2d(wmManipulatorGroupType *wgt) +static void IMAGE_WGT_gizmo2d(wmGizmoGroupType *wgt) { - wgt->name = "UV Transform Manipulator"; - wgt->idname = "IMAGE_WGT_manipulator2d"; + wgt->name = "UV Transform Gizmo"; + wgt->idname = "IMAGE_WGT_gizmo2d"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; - wgt->poll = ED_widgetgroup_manipulator2d_poll; - wgt->setup = ED_widgetgroup_manipulator2d_setup; - wgt->refresh = ED_widgetgroup_manipulator2d_refresh; - wgt->draw_prepare = ED_widgetgroup_manipulator2d_draw_prepare; + wgt->poll = ED_widgetgroup_gizmo2d_poll; + wgt->setup = ED_widgetgroup_gizmo2d_setup; + wgt->refresh = ED_widgetgroup_gizmo2d_refresh; + wgt->draw_prepare = ED_widgetgroup_gizmo2d_draw_prepare; } static void image_widgets(void) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure( - &(const struct wmManipulatorMapType_Params){SPACE_IMAGE, RGN_TYPE_WINDOW}); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure( + &(const struct wmGizmoMapType_Params){SPACE_IMAGE, RGN_TYPE_WINDOW}); - WM_manipulatorgrouptype_append_and_link(mmap_type, IMAGE_WGT_manipulator2d); + WM_gizmogrouptype_append_and_link(mmap_type, IMAGE_WGT_gizmo2d); } /************************** main region ***************************/ @@ -665,15 +665,15 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar) // image space manages own v2d // UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); - /* manipulators */ - if (ar->manipulator_map == NULL) { - const struct wmManipulatorMapType_Params wmap_params = { + /* gizmos */ + if (ar->gizmo_map == NULL) { + const struct wmGizmoMapType_Params wmap_params = { .spaceid = SPACE_IMAGE, .regionid = RGN_TYPE_WINDOW, }; - ar->manipulator_map = WM_manipulatormap_new_from_type(&wmap_params); + ar->gizmo_map = WM_gizmomap_new_from_type(&wmap_params); } - WM_manipulatormap_add_handlers(ar, ar->manipulator_map); + WM_gizmomap_add_handlers(ar, ar->gizmo_map); /* mask polls mode */ keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); @@ -807,7 +807,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); } - WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_2D); + WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); draw_image_cache(C, ar); @@ -827,7 +827,7 @@ static void image_main_region_listener( switch (wmn->category) { case NC_GEOM: if (ELEM(wmn->data, ND_DATA, ND_SELECT)) - WM_manipulatormap_tag_refresh(ar->manipulator_map); + WM_gizmomap_tag_refresh(ar->gizmo_map); break; case NC_GPENCIL: if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) @@ -838,7 +838,7 @@ static void image_main_region_listener( case NC_IMAGE: if (wmn->action == NA_PAINTING) ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(ar->manipulator_map); + WM_gizmomap_tag_refresh(ar->gizmo_map); break; case NC_MATERIAL: if (wmn->data == ND_SHADING_LINKS) { @@ -1089,7 +1089,7 @@ void ED_spacetype_image(void) st->refresh = image_refresh; st->listener = image_listener; st->context = image_context; - st->manipulators = image_widgets; + st->gizmos = image_widgets; st->id_remap = image_id_remap; /* regions: main window */ diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 5b91796d41c..c632b354440 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1412,7 +1412,7 @@ void drawnodespace(const bContext *C, ARegion *ar) wmOrtho2_pixelspace(ar->winx, ar->winy); - WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_2D); + WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); gpuPopMatrix(); gpuLoadProjectionMatrix(original_proj); diff --git a/source/blender/editors/space_node/node_gizmo.c b/source/blender/editors/space_node/node_gizmo.c index 62b4a4b6583..37ea53aa710 100644 --- a/source/blender/editors/space_node/node_gizmo.c +++ b/source/blender/editors/space_node/node_gizmo.c @@ -53,7 +53,7 @@ /** \name Local Utilities * \{ */ -static void node_manipulator_calc_matrix_space( +static void node_gizmo_calc_matrix_space( const SpaceNode *snode, const ARegion *ar, float matrix_space[4][4]) { unit_m4(matrix_space); @@ -63,7 +63,7 @@ static void node_manipulator_calc_matrix_space( matrix_space[3][1] = (ar->winy / 2) + snode->yof; } -static void node_manipulator_calc_matrix_space_with_image_dims( +static void node_gizmo_calc_matrix_space_with_image_dims( const SpaceNode *snode, const ARegion *ar, const float image_dims[2], float matrix_space[4][4]) { unit_m4(matrix_space); @@ -79,11 +79,11 @@ static void node_manipulator_calc_matrix_space_with_image_dims( /* -------------------------------------------------------------------- */ -/** \name Backdrop Manipulator +/** \name Backdrop Gizmo * \{ */ -static void manipulator_node_backdrop_prop_matrix_get( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void gizmo_node_backdrop_prop_matrix_get( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, void *value_p) { float (*matrix)[4] = value_p; @@ -95,8 +95,8 @@ static void manipulator_node_backdrop_prop_matrix_get( matrix[3][1] = snode->yof; } -static void manipulator_node_backdrop_prop_matrix_set( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void gizmo_node_backdrop_prop_matrix_set( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, const void *value_p) { const float (*matrix)[4] = value_p; @@ -108,7 +108,7 @@ static void manipulator_node_backdrop_prop_matrix_set( snode->yof = matrix[3][1]; } -static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -127,22 +127,22 @@ static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmManipulatorGrou return false; } -static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); + wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); + wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); - RNA_enum_set(wwrapper->manipulator->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); + RNA_enum_set(wwrapper->gizmo->ptr, "transform", + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); mgroup->customdata = wwrapper; } -static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmGizmoGroup *mgroup) { Main *bmain = CTX_data_main(C); - wmManipulator *cage = ((wmManipulatorWrapper *)mgroup->customdata)->manipulator; + wmGizmo *cage = ((wmGizmoWrapper *)mgroup->customdata)->gizmo; const ARegion *ar = CTX_wm_region(C); /* center is always at the origin */ const float origin[3] = {ar->winx / 2, ar->winy / 2}; @@ -158,40 +158,40 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorG }; RNA_float_set_array(cage->ptr, "dimensions", dims); - WM_manipulator_set_matrix_location(cage, origin); - WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, false); + WM_gizmo_set_matrix_location(cage, origin); + WM_gizmo_set_flag(cage, WM_GIZMO_HIDDEN, false); /* need to set property here for undo. TODO would prefer to do this in _init */ SpaceNode *snode = CTX_wm_space_node(C); #if 0 PointerRNA nodeptr; RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr); - WM_manipulator_target_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1); - WM_manipulator_target_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1); + WM_gizmo_target_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1); + WM_gizmo_target_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1); #endif - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( cage, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_node_backdrop_prop_matrix_get, - .value_set_fn = manipulator_node_backdrop_prop_matrix_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_node_backdrop_prop_matrix_get, + .value_set_fn = gizmo_node_backdrop_prop_matrix_set, .range_get_fn = NULL, .user_data = snode, }); } else { - WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(cage, WM_GIZMO_HIDDEN, true); } BKE_image_release_ibuf(ima, ibuf, lock); } -void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt) +void NODE_WGT_backdrop_transform(wmGizmoGroupType *wgt) { wgt->name = "Backdrop Transform Widget"; wgt->idname = "NODE_WGT_backdrop_transform"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; wgt->poll = WIDGETGROUP_node_transform_poll; wgt->setup = WIDGETGROUP_node_transform_setup; @@ -202,11 +202,11 @@ void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt) /* -------------------------------------------------------------------- */ -/** \name Crop Manipulator +/** \name Crop Gizmo * \{ */ struct NodeCropWidgetGroup { - wmManipulator *border; + wmGizmo *border; struct { float dims[2]; @@ -219,7 +219,7 @@ struct NodeCropWidgetGroup { } update_data; }; -static void manipulator_node_crop_update(struct NodeCropWidgetGroup *crop_group) +static void gizmo_node_crop_update(struct NodeCropWidgetGroup *crop_group) { RNA_property_update(crop_group->update_data.context, &crop_group->update_data.ptr, crop_group->update_data.prop); } @@ -257,8 +257,8 @@ static void two_xy_from_rect(NodeTwoXYs *nxy, const rctf *rect, const float dims } /* scale callbacks */ -static void manipulator_node_crop_prop_matrix_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_node_crop_prop_matrix_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { float (*matrix)[4] = value_p; @@ -276,8 +276,8 @@ static void manipulator_node_crop_prop_matrix_get( matrix[3][1] = (BLI_rctf_cent_y(&rct) - 0.5f) * dims[1]; } -static void manipulator_node_crop_prop_matrix_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_node_crop_prop_matrix_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value_p) { const float (*matrix)[4] = value_p; @@ -293,10 +293,10 @@ static void manipulator_node_crop_prop_matrix_set( BLI_rctf_recenter(&rct, (matrix[3][0] / dims[0]) + 0.5f, (matrix[3][1] / dims[1]) + 0.5f); BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, &rct, &rct); two_xy_from_rect(nxy, &rct, dims, is_relative); - manipulator_node_crop_update(crop_group); + gizmo_node_crop_update(crop_group); } -static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -318,33 +318,33 @@ static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmManipulatorGroupType return false; } -static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { struct NodeCropWidgetGroup *crop_group = MEM_mallocN(sizeof(struct NodeCropWidgetGroup), __func__); - crop_group->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); + crop_group->border = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); RNA_enum_set(crop_group->border->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); mgroup->customdata = crop_group; } -static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { ARegion *ar = CTX_wm_region(C); - wmManipulator *mpr = mgroup->manipulators.first; + wmGizmo *mpr = mgroup->gizmos.first; SpaceNode *snode = CTX_wm_space_node(C); - node_manipulator_calc_matrix_space(snode, ar, mpr->matrix_space); + node_gizmo_calc_matrix_space(snode, ar, mpr->matrix_space); } -static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *mgroup) { Main *bmain = CTX_data_main(C); struct NodeCropWidgetGroup *crop_group = mgroup->customdata; - wmManipulator *mpr = crop_group->border; + wmGizmo *mpr = crop_group->border; void *lock; Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); @@ -355,7 +355,7 @@ static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup crop_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f; RNA_float_set_array(mpr->ptr, "dimensions", crop_group->state.dims); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); SpaceNode *snode = CTX_wm_space_node(C); bNode *node = nodeGetActive(snode->edittree); @@ -364,28 +364,28 @@ static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeCrop, node, &crop_group->update_data.ptr); crop_group->update_data.prop = RNA_struct_find_property(&crop_group->update_data.ptr, "relative"); - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( mpr, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_node_crop_prop_matrix_get, - .value_set_fn = manipulator_node_crop_prop_matrix_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_node_crop_prop_matrix_get, + .value_set_fn = gizmo_node_crop_prop_matrix_set, .range_get_fn = NULL, .user_data = node, }); } else { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); } BKE_image_release_ibuf(ima, ibuf, lock); } -void NODE_WGT_backdrop_crop(wmManipulatorGroupType *wgt) +void NODE_WGT_backdrop_crop(wmGizmoGroupType *wgt) { wgt->name = "Backdrop Crop Widget"; wgt->idname = "NODE_WGT_backdrop_crop"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; wgt->poll = WIDGETGROUP_node_crop_poll; wgt->setup = WIDGETGROUP_node_crop_setup; @@ -401,14 +401,14 @@ void NODE_WGT_backdrop_crop(wmManipulatorGroupType *wgt) * \{ */ struct NodeSunBeamsWidgetGroup { - wmManipulator *manipulator; + wmGizmo *gizmo; struct { float dims[2]; } state; }; -static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -427,36 +427,36 @@ static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmManipulatorGroupTyp return false; } -static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { struct NodeSunBeamsWidgetGroup *sbeam_group = MEM_mallocN(sizeof(struct NodeSunBeamsWidgetGroup), __func__); - sbeam_group->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL); - wmManipulator *mpr = sbeam_group->manipulator; + sbeam_group->gizmo = WM_gizmo_new("GIZMO_WT_grab_3d", mgroup, NULL); + wmGizmo *mpr = sbeam_group->gizmo; - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D); + RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_CROSS_2D); mpr->scale_basis = 0.05f; mgroup->customdata = sbeam_group; } -static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata; ARegion *ar = CTX_wm_region(C); - wmManipulator *mpr = mgroup->manipulators.first; + wmGizmo *mpr = mgroup->gizmos.first; SpaceNode *snode = CTX_wm_space_node(C); - node_manipulator_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, mpr->matrix_space); + node_gizmo_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, mpr->matrix_space); } -static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmGizmoGroup *mgroup) { Main *bmain = CTX_data_main(C); struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata; - wmManipulator *mpr = sbeam_group->manipulator; + wmGizmo *mpr = sbeam_group->gizmo; void *lock; Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); @@ -472,23 +472,23 @@ static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup /* need to set property here for undo. TODO would prefer to do this in _init */ PointerRNA nodeptr; RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeSunBeams, node, &nodeptr); - WM_manipulator_target_property_def_rna(mpr, "offset", &nodeptr, "source", -1); + WM_gizmo_target_property_def_rna(mpr, "offset", &nodeptr, "source", -1); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_MODAL, true); } else { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); } BKE_image_release_ibuf(ima, ibuf, lock); } -void NODE_WGT_backdrop_sun_beams(wmManipulatorGroupType *wgt) +void NODE_WGT_backdrop_sun_beams(wmGizmoGroupType *wgt) { wgt->name = "Sun Beams Widget"; wgt->idname = "NODE_WGT_sbeam"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; wgt->poll = WIDGETGROUP_node_sbeam_poll; wgt->setup = WIDGETGROUP_node_sbeam_setup; @@ -506,14 +506,14 @@ void NODE_WGT_backdrop_sun_beams(wmManipulatorGroupType *wgt) * \{ */ struct NodeCornerPinWidgetGroup { - wmManipulator *manipulators[4]; + wmGizmo *gizmos[4]; struct { float dims[2]; } state; }; -static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -532,16 +532,16 @@ static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmManipulatorGro return false; } -static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { struct NodeCornerPinWidgetGroup *cpin_group = MEM_mallocN(sizeof(struct NodeCornerPinWidgetGroup), __func__); - const wmManipulatorType *wt_grab_3d = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", false); + const wmGizmoType *wt_grab_3d = WM_gizmotype_find("GIZMO_WT_grab_3d", false); for (int i = 0; i < 4; i++) { - cpin_group->manipulators[i] = WM_manipulator_new_ptr(wt_grab_3d, mgroup, NULL); - wmManipulator *mpr = cpin_group->manipulators[i]; + cpin_group->gizmos[i] = WM_gizmo_new_ptr(wt_grab_3d, mgroup, NULL); + wmGizmo *mpr = cpin_group->gizmos[i]; - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_CROSS_2D); + RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_CROSS_2D); mpr->scale_basis = 0.01f; } @@ -549,7 +549,7 @@ static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmManip mgroup->customdata = cpin_group; } -static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata; ARegion *ar = CTX_wm_region(C); @@ -557,15 +557,15 @@ static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmManipu SpaceNode *snode = CTX_wm_space_node(C); float matrix_space[4][4]; - node_manipulator_calc_matrix_space_with_image_dims(snode, ar, cpin_group->state.dims, matrix_space); + node_gizmo_calc_matrix_space_with_image_dims(snode, ar, cpin_group->state.dims, matrix_space); for (int i = 0; i < 4; i++) { - wmManipulator *mpr = cpin_group->manipulators[i]; + wmGizmo *mpr = cpin_group->gizmos[i]; copy_m4_m4(mpr->matrix_space, matrix_space); } } -static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmGizmoGroup *mgroup) { Main *bmain = CTX_data_main(C); struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata; @@ -585,32 +585,32 @@ static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulator int i = 0; for (bNodeSocket *sock = node->inputs.first; sock && i < 4; sock = sock->next) { if (sock->type == SOCK_VECTOR) { - wmManipulator *mpr = cpin_group->manipulators[i++]; + wmGizmo *mpr = cpin_group->gizmos[i++]; PointerRNA sockptr; RNA_pointer_create((ID *)snode->edittree, &RNA_NodeSocket, sock, &sockptr); - WM_manipulator_target_property_def_rna(mpr, "offset", &sockptr, "default_value", -1); + WM_gizmo_target_property_def_rna(mpr, "offset", &sockptr, "default_value", -1); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_MODAL, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_MODAL, true); } } } else { for (int i = 0; i < 4; i++) { - wmManipulator *mpr = cpin_group->manipulators[i]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + wmGizmo *mpr = cpin_group->gizmos[i]; + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); } } BKE_image_release_ibuf(ima, ibuf, lock); } -void NODE_WGT_backdrop_corner_pin(wmManipulatorGroupType *wgt) +void NODE_WGT_backdrop_corner_pin(wmGizmoGroupType *wgt) { wgt->name = "Corner Pin Widget"; wgt->idname = "NODE_WGT_backdrop_corner_pin"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; wgt->poll = WIDGETGROUP_node_corner_pin_poll; wgt->setup = WIDGETGROUP_node_corner_pin_setup; diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index d7a43bda461..742c3975c8d 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -224,10 +224,10 @@ void NODE_OT_viewer_border(struct wmOperatorType *ot); void NODE_OT_clear_viewer_border(struct wmOperatorType *ot); /* node_widgets.c */ -void NODE_WGT_backdrop_transform(struct wmManipulatorGroupType *wgt); -void NODE_WGT_backdrop_crop(struct wmManipulatorGroupType *wgt); -void NODE_WGT_backdrop_sun_beams(struct wmManipulatorGroupType *wgt); -void NODE_WGT_backdrop_corner_pin(struct wmManipulatorGroupType *wgt); +void NODE_WGT_backdrop_transform(struct wmGizmoGroupType *wgt); +void NODE_WGT_backdrop_crop(struct wmGizmoGroupType *wgt); +void NODE_WGT_backdrop_sun_beams(struct wmGizmoGroupType *wgt); +void NODE_WGT_backdrop_corner_pin(struct wmGizmoGroupType *wgt); extern const char *node_context_dir[]; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index a87a68392c7..1149b910947 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -646,13 +646,13 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - /* manipulators stay in the background for now - quick patchjob to make sure nodes themselves work */ - if (ar->manipulator_map == NULL) { - ar->manipulator_map = WM_manipulatormap_new_from_type( - &(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW}); + /* gizmos stay in the background for now - quick patchjob to make sure nodes themselves work */ + if (ar->gizmo_map == NULL) { + ar->gizmo_map = WM_gizmomap_new_from_type( + &(const struct wmGizmoMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW}); } - WM_manipulatormap_add_handlers(ar, ar->manipulator_map); + WM_gizmomap_add_handlers(ar, ar->gizmo_map); /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0); @@ -752,7 +752,7 @@ static void node_region_listener( wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { - wmManipulatorMap *mmap = ar->manipulator_map; + wmGizmoMap *mmap = ar->gizmo_map; /* context changes */ switch (wmn->category) { @@ -762,13 +762,13 @@ static void node_region_listener( ED_region_tag_redraw(ar); break; case ND_SPACE_NODE_VIEW: - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); break; } break; case NC_SCREEN: if (wmn->data == ND_LAYOUTSET || wmn->action == NA_EDITED) { - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); } switch (wmn->data) { case ND_ANIMPLAY: @@ -784,13 +784,13 @@ static void node_region_listener( case NC_SCENE: ED_region_tag_redraw(ar); if (wmn->data == ND_RENDER_RESULT) { - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); } break; case NC_NODE: ED_region_tag_redraw(ar); if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); } break; case NC_MATERIAL: @@ -863,12 +863,12 @@ static int node_context(const bContext *C, const char *member, bContextDataResul static void node_widgets(void) { /* create the widgetmap for the area here */ - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure( - &(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW}); - WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_transform); - WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_crop); - WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_sun_beams); - WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_corner_pin); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure( + &(const struct wmGizmoMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW}); + WM_gizmogrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_transform); + WM_gizmogrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_crop); + WM_gizmogrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_sun_beams); + WM_gizmogrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_corner_pin); } static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) @@ -987,7 +987,7 @@ void ED_spacetype_node(void) st->refresh = node_area_refresh; st->context = node_context; st->dropboxes = node_dropboxes; - st->manipulators = node_widgets; + st->gizmos = node_widgets; st->id_remap = node_id_remap; st->space_subtype_item_extend = node_space_subtype_item_extend; st->space_subtype_get = node_space_subtype_get; diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 1ec9ea53e33..c440d12e444 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -829,7 +829,7 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot) /* identifiers */ ot->name = "Select Handles"; ot->idname = "SEQUENCER_OT_select_handles"; - ot->description = "Select manipulator handles on the sides of the selected strip"; + ot->description = "Select gizmo handles on the sides of the selected strip"; /* api callbacks */ ot->exec = sequencer_select_handles_exec; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 691baaf48f7..6d4009e9d2b 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -451,12 +451,12 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) ListBase *lb; wmKeyMap *keymap; - if (ar->manipulator_map == NULL) { - ar->manipulator_map = WM_manipulatormap_new_from_type( - &(const struct wmManipulatorMapType_Params) {SPACE_VIEW3D, RGN_TYPE_WINDOW}); + if (ar->gizmo_map == NULL) { + ar->gizmo_map = WM_gizmomap_new_from_type( + &(const struct wmGizmoMapType_Params) {SPACE_VIEW3D, RGN_TYPE_WINDOW}); } - WM_manipulatormap_add_handlers(ar, ar->manipulator_map); + WM_gizmomap_add_handlers(ar, ar->gizmo_map); /* object ops. */ @@ -716,26 +716,26 @@ static void view3d_dropboxes(void) static void view3d_widgets(void) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure( - &(const struct wmManipulatorMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW}); - - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot); - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area); - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target); - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field); - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera); - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera_view); - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_empty_image); - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_armature_spline); - - WM_manipulatorgrouptype_append(TRANSFORM_WGT_manipulator); - WM_manipulatorgrouptype_append(VIEW3D_WGT_xform_cage); - - WM_manipulatorgrouptype_append(VIEW3D_WGT_ruler); - WM_manipulatortype_append(VIEW3D_WT_ruler_item); - - WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_navigate); - WM_manipulatortype_append(VIEW3D_WT_navigate_rotate); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure( + &(const struct wmGizmoMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW}); + + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot); + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area); + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target); + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field); + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera); + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera_view); + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_empty_image); + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_armature_spline); + + WM_gizmogrouptype_append(TRANSFORM_WGT_gizmo); + WM_gizmogrouptype_append(VIEW3D_WGT_xform_cage); + + WM_gizmogrouptype_append(VIEW3D_WGT_ruler); + WM_gizmotype_append(VIEW3D_WT_ruler_item); + + WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_navigate); + WM_gizmotype_append(VIEW3D_WT_navigate_rotate); } @@ -815,13 +815,13 @@ static void view3d_main_region_listener( { View3D *v3d = sa->spacedata.first; RegionView3D *rv3d = ar->regiondata; - wmManipulatorMap *mmap = ar->manipulator_map; + wmGizmoMap *mmap = ar->gizmo_map; /* context changes */ switch (wmn->category) { case NC_WM: if (ELEM(wmn->data, ND_UNDO)) { - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); } break; case NC_ANIMATION: @@ -848,14 +848,14 @@ static void view3d_main_region_listener( if (wmn->reference) view3d_recalc_used_layers(ar, wmn, wmn->reference); ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); break; case ND_LAYER: if (wmn->reference) { BKE_screen_view3d_sync(v3d, wmn->reference); } ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); break; case ND_OB_ACTIVE: case ND_OB_SELECT: @@ -867,7 +867,7 @@ static void view3d_main_region_listener( case ND_MARKERS: case ND_MODE: ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); break; case ND_WORLD: /* handled by space_view3d_listener() for v3d access */ @@ -899,7 +899,7 @@ static void view3d_main_region_listener( case ND_POINTCACHE: case ND_LOD: ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); break; } switch (wmn->action) { @@ -912,7 +912,7 @@ static void view3d_main_region_listener( switch (wmn->data) { case ND_SELECT: { - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); ATTR_FALLTHROUGH; } case ND_DATA: @@ -993,7 +993,7 @@ static void view3d_main_region_listener( break; case ND_LIGHTING_DRAW: ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); break; } break; @@ -1019,7 +1019,7 @@ static void view3d_main_region_listener( rv3d->rflag |= RV3D_GPULIGHT_UPDATE; } ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); } break; case NC_ID: @@ -1035,7 +1035,7 @@ static void view3d_main_region_listener( case ND_LAYOUTBROWSE: case ND_LAYOUTDELETE: case ND_LAYOUTSET: - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); ED_region_tag_redraw(ar); break; case ND_LAYER: @@ -1545,7 +1545,7 @@ void ED_spacetype_view3d(void) st->operatortypes = view3d_operatortypes; st->keymap = view3d_keymap; st->dropboxes = view3d_dropboxes; - st->manipulators = view3d_widgets; + st->gizmos = view3d_widgets; st->context = view3d_context; st->id_remap = view3d_id_remap; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 62e9d4ee3bf..3b86e574a1a 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1203,10 +1203,10 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(of BLF_batch_draw_begin(); - if ((U.uiflag & USER_SHOW_MANIPULATOR_AXIS) || + if ((U.uiflag & USER_SHOW_GIZMO_AXIS) || (v3d->flag2 & V3D_RENDER_OVERRIDE) || - /* No need to display manipulator and this info. */ - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_NAVIGATE))) + /* No need to display gizmo and this info. */ + (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) { /* pass */ } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index b6e20def432..792a341fba4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2812,8 +2812,8 @@ static int viewselected_exec(bContext *C, wmOperator *op) ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); bGPdata *gpd = CTX_data_gpencil_data(C); const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); - const bool is_face_map = ((is_gp_edit == false) && ar->manipulator_map && - WM_manipulatormap_is_any_selected(ar->manipulator_map)); + const bool is_face_map = ((is_gp_edit == false) && ar->gizmo_map && + WM_gizmomap_is_any_selected(ar->gizmo_map)); Object *ob_eval = OBACT(view_layer_eval); Object *obedit = CTX_data_edit_object(C); float min[3], max[3]; @@ -2858,7 +2858,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) CTX_DATA_END; } else if (is_face_map) { - ok = WM_manipulatormap_minmax(ar->manipulator_map, true, true, min, max); + ok = WM_gizmomap_minmax(ar->gizmo_map, true, true, min, max); } else if (obedit) { /* only selected */ @@ -3705,7 +3705,7 @@ static int view_axis_exec(bContext *C, wmOperator *op) Object *obact = CTX_data_active_object(C); if (obact != NULL) { float twmat[3][3]; - /* same as transform manipulator when normal is set */ + /* same as transform gizmo when normal is set */ ED_getTransformOrientationMatrix(C, twmat, V3D_AROUND_ACTIVE); align_quat = align_quat_buf; mat3_to_quat(align_quat, twmat); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c index 16c7d574873..c7b12529798 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_armature.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c @@ -52,7 +52,7 @@ /* -------------------------------------------------------------------- */ -/** \name Armature Spline Manipulator +/** \name Armature Spline Gizmo * * \{ */ @@ -68,7 +68,7 @@ #define BBONE_SCALE_Y 3.0f struct BoneSplineHandle { - wmManipulator *manipulator; + wmGizmo *gizmo; bPoseChannel *pchan; /* We could remove, keep since at the moment for checking the conversion. */ float co[3]; @@ -79,8 +79,8 @@ struct BoneSplineWidgetGroup { struct BoneSplineHandle handles[2]; }; -static void manipulator_bbone_offset_get( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void gizmo_bbone_offset_get( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, void *value_p) { struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data; @@ -102,8 +102,8 @@ static void manipulator_bbone_offset_get( copy_v3_v3(value, bh->co); } -static void manipulator_bbone_offset_set( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void gizmo_bbone_offset_set( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, const void *value_p) { struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data; @@ -127,7 +127,7 @@ static void manipulator_bbone_offset_set( } -static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); if (ob != NULL) { @@ -136,7 +136,7 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGro if (arm->act_bone && arm->act_bone->segments > 1) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { /* pass */ } @@ -150,27 +150,27 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmManipulatorGro } -static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *mgroup) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan = BKE_pose_channel_active(ob); - const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true); + const wmGizmoType *wt_grab = WM_gizmotype_find("GIZMO_WT_grab_3d", true); struct BoneSplineWidgetGroup *bspline_group = MEM_callocN(sizeof(struct BoneSplineWidgetGroup), __func__); mgroup->customdata = bspline_group; /* Handles */ for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { - wmManipulator *mpr; - mpr = bspline_group->handles[i].manipulator = WM_manipulator_new_ptr(wt_grab, mgroup, NULL); - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING_2D); + wmGizmo *mpr; + mpr = bspline_group->handles[i].gizmo = WM_gizmo_new_ptr(wt_grab, mgroup, NULL); + RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_RING_2D); RNA_enum_set(mpr->ptr, "draw_options", - ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_VALUE, true); + ED_GIZMO_GRAB_DRAW_FLAG_FILL | ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW); + WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_VALUE, true); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); mpr->scale_basis = 0.06f; @@ -180,7 +180,7 @@ static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmManipulatorGr } } -static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup *mgroup) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); @@ -192,7 +192,7 @@ static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmManipulator /* Handles */ for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { - wmManipulator *mpr = bspline_group->handles[i].manipulator; + wmGizmo *mpr = bspline_group->handles[i].gizmo; bspline_group->handles[i].pchan = pchan; bspline_group->handles[i].index = i; @@ -201,24 +201,24 @@ static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmManipulator copy_m4_m4(mpr->matrix_space, mat); /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( mpr, "offset", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_bbone_offset_get, - .value_set_fn = manipulator_bbone_offset_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_bbone_offset_get, + .value_set_fn = gizmo_bbone_offset_set, .range_get_fn = NULL, .user_data = &bspline_group->handles[i], }); } } -void VIEW3D_WGT_armature_spline(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_armature_spline(wmGizmoGroupType *wgt) { wgt->name = "Armature Spline Widgets"; wgt->idname = "VIEW3D_WGT_armature_spline"; - wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D); + wgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_3D); wgt->poll = WIDGETGROUP_armature_spline_poll; wgt->setup = WIDGETGROUP_armature_spline_setup; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index 0c97669a9af..b011e6e2e21 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -52,20 +52,20 @@ /* -------------------------------------------------------------------- */ -/** \name Camera Manipulators +/** \name Camera Gizmos * \{ */ struct CameraWidgetGroup { - wmManipulator *dop_dist; - wmManipulator *focal_len; - wmManipulator *ortho_scale; + wmGizmo *dop_dist; + wmGizmo *focal_len; + wmGizmo *ortho_scale; }; -static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -81,12 +81,12 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmManipulatorGroupType *U return false; } -static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *mgroup) { Object *ob = CTX_data_active_object(C); float dir[3]; - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); + const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); struct CameraWidgetGroup *camgroup = MEM_callocN(sizeof(struct CameraWidgetGroup), __func__); mgroup->customdata = camgroup; @@ -95,38 +95,38 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgro /* dof distance */ { - wmManipulator *mpr; - mpr = camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CROSS); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); + wmGizmo *mpr; + mpr = camgroup->dop_dist = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); + RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CROSS); + WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_HOVER, true); - UI_GetThemeColor3fv(TH_MANIPULATOR_A, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_A, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); } /* focal length * - logic/calculations are similar to BKE_camera_view_frame_ex, better keep in sync */ { - wmManipulator *mpr; - mpr = camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE; - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE); - RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); - - mpr = camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE; - RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE); - RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); - - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + wmGizmo *mpr; + mpr = camgroup->focal_len = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); + mpr->flag |= WM_GIZMO_DRAW_NO_SCALE; + RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CONE); + RNA_enum_set(mpr->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); + + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); + + mpr = camgroup->ortho_scale = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); + mpr->flag |= WM_GIZMO_DRAW_NO_SCALE; + RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CONE); + RNA_enum_set(mpr->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); + + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); } } -static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *mgroup) { if (!mgroup->customdata) return; @@ -149,16 +149,16 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg negate_v3_v3(dir, ob->obmat[2]); if (ca->flag & CAM_SHOWLIMITS) { - WM_manipulator_set_matrix_location(camgroup->dop_dist, ob->obmat[3]); - WM_manipulator_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob->obmat[1], dir); - WM_manipulator_set_scale(camgroup->dop_dist, ca->drawsize); - WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false); + WM_gizmo_set_matrix_location(camgroup->dop_dist, ob->obmat[3]); + WM_gizmo_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob->obmat[1], dir); + WM_gizmo_set_scale(camgroup->dop_dist, ca->drawsize); + WM_gizmo_set_flag(camgroup->dop_dist, WM_GIZMO_HIDDEN, false); /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_manipulator_target_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); + WM_gizmo_target_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); } else { - WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(camgroup->dop_dist, WM_GIZMO_HIDDEN, true); } /* TODO - make focal length/ortho ob_scale_inv widget optional */ @@ -167,14 +167,14 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg const float aspy = (float)scene->r.ysch * scene->r.yasp; const bool is_ortho = (ca->type == CAM_ORTHO); const int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, aspx, aspy); - wmManipulator *widget = is_ortho ? camgroup->ortho_scale : camgroup->focal_len; + wmGizmo *widget = is_ortho ? camgroup->ortho_scale : camgroup->focal_len; float scale_matrix; if (true) { float offset[3]; float aspect[2]; - WM_manipulator_set_flag(widget, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_set_flag(is_ortho ? camgroup->focal_len : camgroup->ortho_scale, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(widget, WM_GIZMO_HIDDEN, false); + WM_gizmo_set_flag(is_ortho ? camgroup->focal_len : camgroup->ortho_scale, WM_GIZMO_HIDDEN, true); /* account for lens shifting */ @@ -187,8 +187,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f; unit_m4(widget->matrix_basis); - WM_manipulator_set_matrix_location(widget, ob->obmat[3]); - WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir); + WM_gizmo_set_matrix_location(widget, ob->obmat[3]); + WM_gizmo_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir); if (is_ortho) { scale_matrix = ca->ortho_scale * 0.5f; @@ -201,16 +201,16 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg RNA_float_set_array(widget->ptr, "aspect", aspect); - WM_manipulator_set_matrix_offset_location(widget, offset); + WM_gizmo_set_matrix_offset_location(widget, offset); } /* define & update properties */ { const char *propname = is_ortho ? "ortho_scale" : "lens"; PropertyRNA *prop = RNA_struct_find_property(&camera_ptr, propname); - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(widget->type, "offset"); + const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(widget->type, "offset"); - WM_manipulator_target_property_clear_rna_ptr(widget, mpr_prop_type); + WM_gizmo_target_property_clear_rna_ptr(widget, mpr_prop_type); float min, max, range; float step, precision; @@ -219,20 +219,20 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg RNA_property_float_ui_range(&camera_ptr, prop, &min, &max, &step, &precision); range = max - min; - ED_manipulator_arrow3d_set_range_fac( + ED_gizmo_arrow3d_set_range_fac( widget, is_ortho ? (ca->drawsize * range) : (scale_matrix * range / /* Half sensor, intentionally use sensor from camera and not calculated above. */ (0.5f * ((ca->sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_x)))); - WM_manipulator_target_property_def_rna_ptr(widget, mpr_prop_type, &camera_ptr, prop, -1); + WM_gizmo_target_property_def_rna_ptr(widget, mpr_prop_type, &camera_ptr, prop, -1); } } static void WIDGETGROUP_camera_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) + const bContext *C, wmGizmoGroup *mgroup, struct wmMsgBus *mbus) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); @@ -241,7 +241,7 @@ static void WIDGETGROUP_camera_message_subscribe( wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { .owner = ar, .user_data = mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, + .notify = WM_gizmo_do_msg_notify_tag_refresh, }; { @@ -283,14 +283,14 @@ static void WIDGETGROUP_camera_message_subscribe( } } -void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_camera(wmGizmoGroupType *wgt) { wgt->name = "Camera Widgets"; wgt->idname = "VIEW3D_WGT_camera"; - wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); + wgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_3D | + WM_GIZMOGROUPTYPE_DEPTH_3D); wgt->poll = WIDGETGROUP_camera_poll; wgt->setup = WIDGETGROUP_camera_setup; @@ -302,11 +302,11 @@ void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt) /* -------------------------------------------------------------------- */ -/** \name CameraView Manipulators +/** \name CameraView Gizmos * \{ */ struct CameraViewWidgetGroup { - wmManipulator *border; + wmGizmo *border; struct { rctf *edit_border; @@ -315,8 +315,8 @@ struct CameraViewWidgetGroup { }; /* scale callbacks */ -static void manipulator_render_border_prop_matrix_get( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void gizmo_render_border_prop_matrix_get( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, void *value_p) { float (*matrix)[4] = value_p; @@ -331,8 +331,8 @@ static void manipulator_render_border_prop_matrix_get( matrix[3][1] = BLI_rctf_cent_y(border); } -static void manipulator_render_border_prop_matrix_set( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void gizmo_render_border_prop_matrix_set( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, const void *value_p) { const float (*matrix)[4] = value_p; @@ -345,7 +345,7 @@ static void manipulator_render_border_prop_matrix_set( BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, border, border); } -static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { Scene *scene = CTX_data_scene(C); @@ -361,7 +361,7 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupTy View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -382,22 +382,22 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmManipulatorGroupTy return false; } -static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { struct CameraViewWidgetGroup *viewgroup = MEM_mallocN(sizeof(struct CameraViewWidgetGroup), __func__); - viewgroup->border = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); + viewgroup->border = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); RNA_enum_set(viewgroup->border->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); /* Box style is more subtle in this case. */ - RNA_enum_set(viewgroup->border->ptr, "draw_style", ED_MANIPULATOR_CAGE2D_STYLE_BOX); + RNA_enum_set(viewgroup->border->ptr, "draw_style", ED_GIZMO_CAGE2D_STYLE_BOX); mgroup->customdata = viewgroup; } -static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; @@ -413,7 +413,7 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulato viewgroup->state.view_border = (rctf){.xmin = 0, .ymin = 0, .xmax = ar->winx, .ymax = ar->winy}; } - wmManipulator *mpr = viewgroup->border; + wmGizmo *mpr = viewgroup->border; unit_m4(mpr->matrix_space); mul_v3_fl(mpr->matrix_space[0], BLI_rctf_size_x(&viewgroup->state.view_border)); mul_v3_fl(mpr->matrix_space[1], BLI_rctf_size_y(&viewgroup->state.view_border)); @@ -421,7 +421,7 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulato mpr->matrix_space[3][1] = viewgroup->state.view_border.ymin; } -static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmGizmoGroup *mgroup) { struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; @@ -431,11 +431,11 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGrou Scene *scene = CTX_data_scene(C); { - wmManipulator *mpr = viewgroup->border; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + wmGizmo *mpr = viewgroup->border; + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); RNA_enum_set(viewgroup->border->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); if (rv3d->persp == RV3D_CAMOB) { viewgroup->state.edit_border = &scene->r.border; @@ -444,11 +444,11 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGrou viewgroup->state.edit_border = &v3d->render_border; } - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( mpr, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_render_border_prop_matrix_get, - .value_set_fn = manipulator_render_border_prop_matrix_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_render_border_prop_matrix_get, + .value_set_fn = gizmo_render_border_prop_matrix_set, .range_get_fn = NULL, .user_data = viewgroup, }); @@ -456,13 +456,13 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGrou } -void VIEW3D_WGT_camera_view(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_camera_view(wmGizmoGroupType *wgt) { wgt->name = "Camera View Widgets"; wgt->idname = "VIEW3D_WGT_camera_view"; - wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_SCALE); + wgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_SCALE); wgt->poll = WIDGETGROUP_camera_view_poll; wgt->setup = WIDGETGROUP_camera_view_setup; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.c b/source/blender/editors/space_view3d/view3d_gizmo_empty.c index 89f55bc1d9a..3b51af5ca15 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_empty.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.c @@ -50,11 +50,11 @@ /* -------------------------------------------------------------------- */ -/** \name Empty Image Manipulators +/** \name Empty Image Gizmos * \{ */ struct EmptyImageWidgetGroup { - wmManipulator *manipulator; + wmGizmo *gizmo; struct { Object *ob; float dims[2]; @@ -62,8 +62,8 @@ struct EmptyImageWidgetGroup { }; /* translate callbacks */ -static void manipulator_empty_image_prop_matrix_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_empty_image_prop_matrix_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, void *value_p) { float (*matrix)[4] = value_p; @@ -84,8 +84,8 @@ static void manipulator_empty_image_prop_matrix_get( matrix[3][1] = (ob->ima_ofs[1] * dims[1]) + (0.5f * dims[1]); } -static void manipulator_empty_image_prop_matrix_set( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +static void gizmo_empty_image_prop_matrix_set( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const void *value_p) { const float (*matrix)[4] = value_p; @@ -104,12 +104,12 @@ static void manipulator_empty_image_prop_matrix_set( ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1]; } -static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -122,34 +122,34 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupTy return false; } -static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { struct EmptyImageWidgetGroup *imgroup = MEM_mallocN(sizeof(struct EmptyImageWidgetGroup), __func__); - imgroup->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); - wmManipulator *mpr = imgroup->manipulator; + imgroup->gizmo = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); + wmGizmo *mpr = imgroup->gizmo; RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); mgroup->customdata = imgroup; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_HOVER, true); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); } -static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *mgroup) { struct EmptyImageWidgetGroup *imgroup = mgroup->customdata; Object *ob = CTX_data_active_object(C); - wmManipulator *mpr = imgroup->manipulator; + wmGizmo *mpr = imgroup->gizmo; copy_m4_m4(mpr->matrix_basis, ob->obmat); RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); imgroup->state.ob = ob; @@ -177,24 +177,24 @@ static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGrou } RNA_float_set_array(mpr->ptr, "dimensions", imgroup->state.dims); - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( mpr, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_empty_image_prop_matrix_get, - .value_set_fn = manipulator_empty_image_prop_matrix_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_empty_image_prop_matrix_get, + .value_set_fn = gizmo_empty_image_prop_matrix_set, .range_get_fn = NULL, .user_data = imgroup, }); } -void VIEW3D_WGT_empty_image(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_empty_image(wmGizmoGroupType *wgt) { wgt->name = "Area Light Widgets"; wgt->idname = "VIEW3D_WGT_empty_image"; - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); + wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_3D | + WM_GIZMOGROUPTYPE_DEPTH_3D); wgt->poll = WIDGETGROUP_empty_image_poll; wgt->setup = WIDGETGROUP_empty_image_setup; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c index db985c18c08..d4605bb0c7d 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c @@ -49,15 +49,15 @@ /* -------------------------------------------------------------------- */ -/** \name Force Field Manipulators +/** \name Force Field Gizmos * \{ */ -static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -67,26 +67,26 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupTyp return (ob && ob->pd && ob->pd->forcefield); } -static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { /* only wind effector for now */ - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); + wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); mgroup->customdata = wwrapper; - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL); - wmManipulator *mpr = wwrapper->manipulator; - RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED); - ED_manipulator_arrow3d_set_ui_range(mpr, -200.0f, 200.0f); - ED_manipulator_arrow3d_set_range_fac(mpr, 6.0f); + wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_arrow_3d", mgroup, NULL); + wmGizmo *mpr = wwrapper->gizmo; + RNA_enum_set(mpr->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); + ED_gizmo_arrow3d_set_ui_range(mpr, -200.0f, 200.0f); + ED_gizmo_arrow3d_set_range_fac(mpr, 6.0f); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); } -static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *mgroup) { - wmManipulatorWrapper *wwrapper = mgroup->customdata; - wmManipulator *mpr = wwrapper->manipulator; + wmGizmoWrapper *wwrapper = mgroup->customdata; + wmGizmo *mpr = wwrapper->gizmo; Object *ob = CTX_data_active_object(C); PartDeflect *pd = ob->pd; @@ -96,26 +96,26 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup PointerRNA field_ptr; RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd, &field_ptr); - WM_manipulator_set_matrix_location(mpr, ob->obmat[3]); - WM_manipulator_set_matrix_rotation_from_z_axis(mpr, ob->obmat[2]); - WM_manipulator_set_matrix_offset_location(mpr, ofs); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_target_property_def_rna(mpr, "offset", &field_ptr, "strength", -1); + WM_gizmo_set_matrix_location(mpr, ob->obmat[3]); + WM_gizmo_set_matrix_rotation_from_z_axis(mpr, ob->obmat[2]); + WM_gizmo_set_matrix_offset_location(mpr, ofs); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + WM_gizmo_target_property_def_rna(mpr, "offset", &field_ptr, "strength", -1); } else { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); } } -void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_force_field(wmGizmoGroupType *wgt) { wgt->name = "Force Field Widgets"; wgt->idname = "VIEW3D_WGT_force_field"; - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_SCALE | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); + wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_3D | + WM_GIZMOGROUPTYPE_SCALE | + WM_GIZMOGROUPTYPE_DEPTH_3D); wgt->poll = WIDGETGROUP_forcefield_poll; wgt->setup = WIDGETGROUP_forcefield_setup; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_lamp.c b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c index 8087fcbdddd..a872cc96172 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_lamp.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c @@ -49,14 +49,14 @@ /* -------------------------------------------------------------------- */ -/** \name Spot Lamp Manipulators +/** \name Spot Lamp Gizmos * \{ */ -static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_CONTEXT))) + (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -70,49 +70,49 @@ static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType return false; } -static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); + wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL); - wmManipulator *mpr = wwrapper->manipulator; - RNA_enum_set(mpr->ptr, "transform", ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED); + wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_arrow_3d", mgroup, NULL); + wmGizmo *mpr = wwrapper->gizmo; + RNA_enum_set(mpr->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_INVERTED); mgroup->customdata = wwrapper; - ED_manipulator_arrow3d_set_range_fac(mpr, 4.0f); + ED_gizmo_arrow3d_set_range_fac(mpr, 4.0f); - UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, mpr->color); } -static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmGizmoGroup *mgroup) { - wmManipulatorWrapper *wwrapper = mgroup->customdata; - wmManipulator *mpr = wwrapper->manipulator; + wmGizmoWrapper *wwrapper = mgroup->customdata; + wmGizmo *mpr = wwrapper->gizmo; Object *ob = CTX_data_active_object(C); Lamp *la = ob->data; float dir[3]; negate_v3_v3(dir, ob->obmat[2]); - WM_manipulator_set_matrix_rotation_from_z_axis(mpr, dir); - WM_manipulator_set_matrix_location(mpr, ob->obmat[3]); + WM_gizmo_set_matrix_rotation_from_z_axis(mpr, dir); + WM_gizmo_set_matrix_location(mpr, ob->obmat[3]); /* need to set property here for undo. TODO would prefer to do this in _init */ PointerRNA lamp_ptr; const char *propname = "spot_size"; RNA_pointer_create(&la->id, &RNA_Light, la, &lamp_ptr); - WM_manipulator_target_property_def_rna(mpr, "offset", &lamp_ptr, propname, -1); + WM_gizmo_target_property_def_rna(mpr, "offset", &lamp_ptr, propname, -1); } -void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_lamp_spot(wmGizmoGroupType *wgt) { wgt->name = "Spot Light Widgets"; wgt->idname = "VIEW3D_WGT_lamp_spot"; - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); + wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_3D | + WM_GIZMOGROUPTYPE_DEPTH_3D); wgt->poll = WIDGETGROUP_lamp_spot_poll; wgt->setup = WIDGETGROUP_lamp_spot_setup; @@ -123,12 +123,12 @@ void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt) /* -------------------------------------------------------------------- */ -/** \name Area Lamp Manipulators +/** \name Area Lamp Gizmos * \{ */ /* scale callbacks */ -static void manipulator_area_lamp_prop_matrix_get( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void gizmo_area_lamp_prop_matrix_get( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, void *value_p) { BLI_assert(mpr_prop->type->array_length == 16); @@ -139,8 +139,8 @@ static void manipulator_area_lamp_prop_matrix_get( matrix[1][1] = ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE) ? la->area_sizey : la->area_size; } -static void manipulator_area_lamp_prop_matrix_set( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void gizmo_area_lamp_prop_matrix_set( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, const void *value_p) { const float (*matrix)[4] = value_p; @@ -156,7 +156,7 @@ static void manipulator_area_lamp_prop_matrix_set( } } -static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); if (v3d->flag2 & V3D_RENDER_OVERRIDE) { @@ -171,56 +171,56 @@ static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType return false; } -static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); - wmManipulator *mpr = wwrapper->manipulator; + wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); + wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); + wmGizmo *mpr = wwrapper->gizmo; RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE); + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); mgroup->customdata = wwrapper; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_HOVER, true); - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); } -static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmGizmoGroup *mgroup) { - wmManipulatorWrapper *wwrapper = mgroup->customdata; + wmGizmoWrapper *wwrapper = mgroup->customdata; Object *ob = CTX_data_active_object(C); Lamp *la = ob->data; - wmManipulator *mpr = wwrapper->manipulator; + wmGizmo *mpr = wwrapper->gizmo; copy_m4_m4(mpr->matrix_basis, ob->obmat); - int flag = ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE; + int flag = ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE; if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) { - flag |= ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM; + flag |= ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM; } RNA_enum_set(mpr->ptr, "transform", flag); /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_manipulator_target_property_def_func( + WM_gizmo_target_property_def_func( mpr, "matrix", - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = manipulator_area_lamp_prop_matrix_get, - .value_set_fn = manipulator_area_lamp_prop_matrix_set, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = gizmo_area_lamp_prop_matrix_get, + .value_set_fn = gizmo_area_lamp_prop_matrix_set, .range_get_fn = NULL, .user_data = la, }); } -void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_lamp_area(wmGizmoGroupType *wgt) { wgt->name = "Area Light Widgets"; wgt->idname = "VIEW3D_WGT_lamp_area"; - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D | - WM_MANIPULATORGROUPTYPE_DEPTH_3D); + wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_3D | + WM_GIZMOGROUPTYPE_DEPTH_3D); wgt->poll = WIDGETGROUP_lamp_area_poll; wgt->setup = WIDGETGROUP_lamp_area_setup; @@ -232,10 +232,10 @@ void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt) /* -------------------------------------------------------------------- */ -/** \name Lamp Target Manipulator +/** \name Lamp Target Gizmo * \{ */ -static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); if (v3d->flag2 & V3D_RENDER_OVERRIDE) { @@ -258,46 +258,46 @@ static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupTy return false; } -static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL); - wmManipulator *mpr = wwrapper->manipulator; + wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); + wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_grab_3d", mgroup, NULL); + wmGizmo *mpr = wwrapper->gizmo; mgroup->customdata = wwrapper; - UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); mpr->scale_basis = 0.06f; wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_transform_axis_target", true); RNA_enum_set(mpr->ptr, "draw_options", - ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL | ED_MANIPULATOR_GRAB_DRAW_FLAG_ALIGN_VIEW); + ED_GIZMO_GRAB_DRAW_FLAG_FILL | ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW); - WM_manipulator_operator_set(mpr, 0, ot, NULL); + WM_gizmo_operator_set(mpr, 0, ot, NULL); } -static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { - wmManipulatorWrapper *wwrapper = mgroup->customdata; + wmGizmoWrapper *wwrapper = mgroup->customdata; Object *ob = CTX_data_active_object(C); - wmManipulator *mpr = wwrapper->manipulator; + wmGizmo *mpr = wwrapper->gizmo; copy_m4_m4(mpr->matrix_basis, ob->obmat); unit_m4(mpr->matrix_offset); mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_OFFSET_SCALE, true); } -void VIEW3D_WGT_lamp_target(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_lamp_target(wmGizmoGroupType *wgt) { wgt->name = "Target Light Widgets"; wgt->idname = "VIEW3D_WGT_lamp_target"; - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D); + wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_3D); wgt->poll = WIDGETGROUP_lamp_target_poll; wgt->setup = WIDGETGROUP_lamp_target_setup; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index db4eeef18f7..98669739745 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -47,17 +47,17 @@ #include "view3d_intern.h" /* own include */ /* -------------------------------------------------------------------- */ -/** \name View3D Navigation Manipulator Group +/** \name View3D Navigation Gizmo Group * \{ */ /* Offset from screen edge. */ -#define MANIPULATOR_OFFSET_FAC 1.5f +#define GIZMO_OFFSET_FAC 1.5f /* Size of main icon. */ -#define MANIPULATOR_SIZE 64 +#define GIZMO_SIZE 64 /* Factor for size of smaller button. */ -#define MANIPULATOR_MINI_FAC 0.35f +#define GIZMO_MINI_FAC 0.35f /* How much mini buttons offset from the primary. */ -#define MANIPULATOR_MINI_OFFSET_FAC 0.42f +#define GIZMO_MINI_OFFSET_FAC 0.42f enum { @@ -122,40 +122,40 @@ static const uchar shape_zoom[] = { }; -struct NavigateManipulatorInfo { +struct NavigateGizmoInfo { const char *opname; - const char *manipulator; + const char *gizmo; const unsigned char *shape; uint shape_size; }; #define SHAPE_VARS(shape_id) shape = shape_id, .shape_size = ARRAY_SIZE(shape_id) -struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = { +struct NavigateGizmoInfo g_navigate_params[MPR_TOTAL] = { { .opname = "VIEW3D_OT_move", - .manipulator = "MANIPULATOR_WT_button_2d", + .gizmo = "GIZMO_WT_button_2d", .SHAPE_VARS(shape_pan), }, { .opname = "VIEW3D_OT_rotate", - .manipulator = "VIEW3D_WT_navigate_rotate", + .gizmo = "VIEW3D_WT_navigate_rotate", .shape = NULL, .shape_size = 0, }, { .opname = "VIEW3D_OT_zoom", - .manipulator = "MANIPULATOR_WT_button_2d", + .gizmo = "GIZMO_WT_button_2d", .SHAPE_VARS(shape_zoom), }, { .opname = "VIEW3D_OT_view_persportho", - .manipulator = "MANIPULATOR_WT_button_2d", + .gizmo = "GIZMO_WT_button_2d", .SHAPE_VARS(shape_persp), }, { .opname = "VIEW3D_OT_view_persportho", - .manipulator = "MANIPULATOR_WT_button_2d", + .gizmo = "GIZMO_WT_button_2d", .SHAPE_VARS(shape_ortho), }, { .opname = "VIEW3D_OT_view_camera", - .manipulator = "MANIPULATOR_WT_button_2d", + .gizmo = "GIZMO_WT_button_2d", .SHAPE_VARS(shape_camera), }, }; @@ -163,7 +163,7 @@ struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = { #undef SHAPE_VARS struct NavigateWidgetGroup { - wmManipulator *mpr_array[MPR_TOTAL]; + wmGizmo *mpr_array[MPR_TOTAL]; /* Store the view state to check for changes. */ struct { rcti rect_visible; @@ -176,12 +176,12 @@ struct NavigateWidgetGroup { int region_size[2]; }; -static bool WIDGETGROUP_navigate_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { View3D *v3d = CTX_wm_view3d(C); - if (((U.uiflag & USER_SHOW_MANIPULATOR_AXIS) == 0) || + if (((U.uiflag & USER_SHOW_GIZMO_AXIS) == 0) || (v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_NAVIGATE))) + (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) { return false; } @@ -189,7 +189,7 @@ static bool WIDGETGROUP_navigate_poll(const bContext *C, wmManipulatorGroupType } -static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { struct NavigateWidgetGroup *navgroup = MEM_callocN(sizeof(struct NavigateWidgetGroup), __func__); @@ -200,37 +200,37 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG wmOperatorType *ot_view_camera = WM_operatortype_find("VIEW3D_OT_view_camera", true); for (int i = 0; i < MPR_TOTAL; i++) { - const struct NavigateManipulatorInfo *info = &g_navigate_params[i]; - navgroup->mpr_array[i] = WM_manipulator_new(info->manipulator, mgroup, NULL); - wmManipulator *mpr = navgroup->mpr_array[i]; - mpr->flag |= WM_MANIPULATOR_GRAB_CURSOR | WM_MANIPULATOR_DRAW_MODAL; + const struct NavigateGizmoInfo *info = &g_navigate_params[i]; + navgroup->mpr_array[i] = WM_gizmo_new(info->gizmo, mgroup, NULL); + wmGizmo *mpr = navgroup->mpr_array[i]; + mpr->flag |= WM_GIZMO_GRAB_CURSOR | WM_GIZMO_DRAW_MODAL; mpr->color[3] = 0.2f; mpr->color_hi[3] = 0.4f; /* may be overwritten later */ - mpr->scale_basis = (MANIPULATOR_SIZE * MANIPULATOR_MINI_FAC) / 2; + mpr->scale_basis = (GIZMO_SIZE * GIZMO_MINI_FAC) / 2; if (info->shape != NULL) { PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "shape"); RNA_property_string_set_bytes( mpr->ptr, prop, (const char *)info->shape, info->shape_size); - RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_BUTTON_SHOW_OUTLINE); + RNA_enum_set(mpr->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_OUTLINE); } wmOperatorType *ot = WM_operatortype_find(info->opname, true); - WM_manipulator_operator_set(mpr, 0, ot, NULL); + WM_gizmo_operator_set(mpr, 0, ot, NULL); } { - wmManipulator *mpr = navgroup->mpr_array[MPR_CAMERA]; - WM_manipulator_operator_set(mpr, 0, ot_view_camera, NULL); + wmGizmo *mpr = navgroup->mpr_array[MPR_CAMERA]; + WM_gizmo_operator_set(mpr, 0, ot_view_camera, NULL); } /* Click only buttons (not modal). */ { int mpr_ids[] = {MPR_PERSP, MPR_ORTHO, MPR_CAMERA}; for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) { - wmManipulator *mpr = navgroup->mpr_array[mpr_ids[i]]; + wmGizmo *mpr = navgroup->mpr_array[mpr_ids[i]]; RNA_boolean_set(mpr->ptr, "show_drag", false); } } @@ -239,15 +239,15 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG { int mpr_ids[] = {MPR_MOVE, MPR_ROTATE, MPR_ZOOM}; for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) { - wmManipulator *mpr = navgroup->mpr_array[mpr_ids[i]]; - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, 0); + wmGizmo *mpr = navgroup->mpr_array[mpr_ids[i]]; + wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, 0); RNA_boolean_set(&mpop->ptr, "use_mouse_init", false); } } { - wmManipulator *mpr = navgroup->mpr_array[MPR_ROTATE]; - mpr->scale_basis = MANIPULATOR_SIZE / 2; + wmGizmo *mpr = navgroup->mpr_array[MPR_ROTATE]; + mpr->scale_basis = GIZMO_SIZE / 2; char mapping[6] = { RV3D_VIEW_LEFT, RV3D_VIEW_RIGHT, @@ -258,7 +258,7 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG }; for (int part_index = 0; part_index < 6; part_index += 1) { - PointerRNA *ptr = WM_manipulator_operator_set(mpr, part_index + 1, ot_view_axis, NULL); + PointerRNA *ptr = WM_gizmo_operator_set(mpr, part_index + 1, ot_view_axis, NULL); RNA_enum_set(ptr, "type", mapping[part_index]); } @@ -269,7 +269,7 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG mgroup->customdata = navgroup; } -static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { struct NavigateWidgetGroup *navgroup = mgroup->customdata; ARegion *ar = CTX_wm_region(C); @@ -300,9 +300,9 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr ((rv3d->viewlock & RV3D_LOCKED) == 0) && (navgroup->state.rv3d.is_camera == false)); const bool show_fixed_offset = navgroup->state.rv3d.is_camera; - const float icon_size = MANIPULATOR_SIZE; - const float icon_offset = (icon_size * 0.52f) * MANIPULATOR_OFFSET_FAC * UI_DPI_FAC; - const float icon_offset_mini = icon_size * MANIPULATOR_MINI_OFFSET_FAC * UI_DPI_FAC; + const float icon_size = GIZMO_SIZE; + const float icon_offset = (icon_size * 0.52f) * GIZMO_OFFSET_FAC * UI_DPI_FAC; + const float icon_offset_mini = icon_size * GIZMO_MINI_OFFSET_FAC * UI_DPI_FAC; const float co_rotate[2] = { rect_visible.xmax - icon_offset, rect_visible.ymax - icon_offset, @@ -312,11 +312,11 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr rect_visible.ymax - icon_offset_mini * 0.75f, }; - wmManipulator *mpr; + wmGizmo *mpr; for (uint i = 0; i < ARRAY_SIZE(navgroup->mpr_array); i++) { mpr = navgroup->mpr_array[i]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); } /* RV3D_LOCKED or Camera: only show supported buttons. */ @@ -324,7 +324,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr mpr = navgroup->mpr_array[MPR_ROTATE]; mpr->matrix_basis[3][0] = co_rotate[0]; mpr->matrix_basis[3][1] = co_rotate[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); } int icon_mini_slot = 0; @@ -332,36 +332,36 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr mpr = navgroup->mpr_array[MPR_ZOOM]; mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); mpr->matrix_basis[3][1] = co[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); mpr = navgroup->mpr_array[MPR_MOVE]; mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); mpr->matrix_basis[3][1] = co[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); if ((rv3d->viewlock & RV3D_LOCKED) == 0) { mpr = navgroup->mpr_array[MPR_CAMERA]; mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); mpr->matrix_basis[3][1] = co[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); if (navgroup->state.rv3d.is_camera == false) { mpr = navgroup->mpr_array[rv3d->is_persp ? MPR_PERSP : MPR_ORTHO]; mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); mpr->matrix_basis[3][1] = co[1]; - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); } } } -void VIEW3D_WGT_navigate(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_navigate(wmGizmoGroupType *wgt) { wgt->name = "View3D Navigate"; wgt->idname = "VIEW3D_WGT_navigate"; - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_SCALE | - WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL); + wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + WM_GIZMOGROUPTYPE_SCALE | + WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL); wgt->poll = WIDGETGROUP_navigate_poll; wgt->setup = WIDGETGROUP_navigate_setup; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 072f2ee4583..0136b235cc0 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -21,9 +21,9 @@ /** \file view3d_gizmo_navigate_type.c * \ingroup wm * - * \name Custom Orientation/Navigation Manipulator for the 3D View + * \name Custom Orientation/Navigation Gizmo for the 3D View * - * \brief Simple manipulator to axis and translate. + * \brief Simple gizmo to axis and translate. * * - scale_basis: used for the size. * - matrix_basis: used for the location. @@ -63,7 +63,7 @@ #define HANDLE_SIZE 0.33 static void axis_geom_draw( - const wmManipulator *mpr, const float color[4], const bool UNUSED(select)) + const wmGizmo *mpr, const float color[4], const bool UNUSED(select)) { GPU_line_width(mpr->line_width); @@ -199,7 +199,7 @@ static void axis_geom_draw( } static void axis3d_draw_intern( - const bContext *UNUSED(C), wmManipulator *mpr, + const bContext *UNUSED(C), wmGizmo *mpr, const bool select, const bool highlight) { const float *color = highlight ? mpr->color_hi : mpr->color; @@ -208,9 +208,9 @@ static void axis3d_draw_intern( unit_m4(matrix_unit); - WM_manipulator_calc_matrix_final_params( + WM_gizmo_calc_matrix_final_params( mpr, - &((struct WM_ManipulatorMatrixParams) { + &((struct WM_GizmoMatrixParams) { .matrix_offset = matrix_unit, }), matrix_final); @@ -223,10 +223,10 @@ static void axis3d_draw_intern( gpuPopMatrix(); } -static void manipulator_axis_draw(const bContext *C, wmManipulator *mpr) +static void gizmo_axis_draw(const bContext *C, wmGizmo *mpr) { - const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; + const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL; + const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; (void)is_modal; @@ -235,8 +235,8 @@ static void manipulator_axis_draw(const bContext *C, wmManipulator *mpr) GPU_blend(false); } -static int manipulator_axis_test_select( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +static int gizmo_axis_test_select( + bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) { float point_local[2] = {UNPACK2(event->mval)}; sub_v2_v2(point_local, mpr->matrix_basis[3]); @@ -288,7 +288,7 @@ static int manipulator_axis_test_select( return -1; } -static int manipulator_axis_cursor_get(wmManipulator *mpr) +static int gizmo_axis_cursor_get(wmGizmo *mpr) { if (mpr->highlight_part > 0) { return CURSOR_EDIT; @@ -296,15 +296,15 @@ static int manipulator_axis_cursor_get(wmManipulator *mpr) return BC_NSEW_SCROLLCURSOR; } -void VIEW3D_WT_navigate_rotate(wmManipulatorType *wt) +void VIEW3D_WT_navigate_rotate(wmGizmoType *wt) { /* identifiers */ wt->idname = "VIEW3D_WT_navigate_rotate"; /* api callbacks */ - wt->draw = manipulator_axis_draw; - wt->test_select = manipulator_axis_test_select; - wt->cursor_get = manipulator_axis_cursor_get; + wt->draw = gizmo_axis_draw; + wt->test_select = gizmo_axis_test_select; + wt->cursor_get = gizmo_axis_cursor_get; - wt->struct_size = sizeof(wmManipulator); + wt->struct_size = sizeof(wmGizmo); } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index c29b07e4147..ac6a984bea5 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -93,7 +93,7 @@ enum { #define PART_LINE 0xff /* -------------------------------------------------------------------- */ -/* Ruler Info (wmManipulatorGroup customdata) */ +/* Ruler Info (wmGizmoGroup customdata) */ enum { RULER_STATE_NORMAL = 0, @@ -123,7 +123,7 @@ typedef struct RulerInfo { /* Ruler Item (two or three points) */ typedef struct RulerItem { - wmManipulator mpr; + wmGizmo mpr; /* worldspace coords, middle being optional */ float co[3][3]; @@ -143,18 +143,18 @@ typedef struct RulerInteraction { /** \name Internal Ruler Utilities * \{ */ -static RulerItem *ruler_item_add(wmManipulatorGroup *mgroup) +static RulerItem *ruler_item_add(wmGizmoGroup *mgroup) { /* could pass this as an arg */ - const wmManipulatorType *wt_ruler = WM_manipulatortype_find("VIEW3D_WT_ruler_item", true); - RulerItem *ruler_item = (RulerItem *)WM_manipulator_new_ptr(wt_ruler, mgroup, NULL); - WM_manipulator_set_flag(&ruler_item->mpr, WM_MANIPULATOR_DRAW_MODAL, true); + const wmGizmoType *wt_ruler = WM_gizmotype_find("VIEW3D_WT_ruler_item", true); + RulerItem *ruler_item = (RulerItem *)WM_gizmo_new_ptr(wt_ruler, mgroup, NULL); + WM_gizmo_set_flag(&ruler_item->mpr, WM_GIZMO_DRAW_MODAL, true); return ruler_item; } -static void ruler_item_remove(bContext *C, wmManipulatorGroup *mgroup, RulerItem *ruler_item) +static void ruler_item_remove(bContext *C, wmGizmoGroup *mgroup, RulerItem *ruler_item) { - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, &ruler_item->mpr, C); + WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, &ruler_item->mpr, C); } static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit, @@ -192,7 +192,7 @@ static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit, } static bool view3d_ruler_pick( - wmManipulatorGroup *mgroup, RulerItem *ruler_item, const float mval[2], + wmGizmoGroup *mgroup, RulerItem *ruler_item, const float mval[2], int *r_co_index) { RulerInfo *ruler_info = mgroup->customdata; @@ -380,7 +380,7 @@ static bool view3d_ruler_item_mousemove( * \{ */ #define RULER_ID "RulerData3D" -static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup) +static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *mgroup) { // RulerInfo *ruler_info = mgroup->customdata; Main *bmain = CTX_data_main(C); @@ -419,7 +419,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup) gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); BKE_gpencil_free_strokes(gpf); - for (ruler_item = mgroup->manipulators.first; ruler_item; ruler_item = (RulerItem *)ruler_item->mpr.next) { + for (ruler_item = mgroup->gizmos.first; ruler_item; ruler_item = (RulerItem *)ruler_item->mpr.next) { bGPDspoint *pt; int j; @@ -457,7 +457,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup) return changed; } -static bool view3d_ruler_from_gpencil(const bContext *C, wmManipulatorGroup *mgroup) +static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *mgroup) { Scene *scene = CTX_data_scene(C); bool changed = false; @@ -503,10 +503,10 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmManipulatorGroup *mgr /** \} */ /* -------------------------------------------------------------------- */ -/** \name Ruler Item Manipulator Type +/** \name Ruler Item Gizmo Type * \{ */ -static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) +static void gizmo_ruler_draw(const bContext *C, wmGizmo *mpr) { Scene *scene = CTX_data_scene(C); UnitSettings *unit = &scene->unit; @@ -536,7 +536,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) UI_GetThemeColor3ubv(TH_TEXT, color_text); UI_GetThemeColor3ubv(TH_WIRE, color_wire); - const bool is_act = (mpr->flag & WM_MANIPULATOR_DRAW_HOVER); + const bool is_act = (mpr->flag & WM_GIZMO_DRAW_HOVER); float dir_ruler[2]; float co_ss[3][2]; int j; @@ -804,8 +804,8 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) } } -static int manipulator_ruler_test_select( - bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) +static int gizmo_ruler_test_select( + bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) { RulerItem *ruler_item_pick = (RulerItem *)mpr; float mval_fl[2] = {UNPACK2(event->mval)}; @@ -825,9 +825,9 @@ static int manipulator_ruler_test_select( return -1; } -static int manipulator_ruler_modal( - bContext *C, wmManipulator *mpr, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo_ruler_modal( + bContext *C, wmGizmo *mpr, const wmEvent *event, + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { bool do_draw = false; int exit_code = OPERATOR_RUNNING_MODAL; @@ -859,10 +859,10 @@ static int manipulator_ruler_modal( return exit_code; } -static int manipulator_ruler_invoke( - bContext *C, wmManipulator *mpr, const wmEvent *event) +static int gizmo_ruler_invoke( + bContext *C, wmGizmo *mpr, const wmEvent *event) { - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + wmGizmoGroup *mgroup = mpr->parent_mgroup; RulerInfo *ruler_info = mgroup->customdata; RulerItem *ruler_item_pick = (RulerItem *)mpr; RulerInteraction *inter = MEM_callocN(sizeof(RulerInteraction), __func__); @@ -913,9 +913,9 @@ static int manipulator_ruler_invoke( return OPERATOR_RUNNING_MODAL; } -static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool cancel) +static void gizmo_ruler_exit(bContext *C, wmGizmo *mpr, const bool cancel) { - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + wmGizmoGroup *mgroup = mpr->parent_mgroup; RulerInfo *ruler_info = mgroup->customdata; if (!cancel) { @@ -941,7 +941,7 @@ static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool c } ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); } - /* We could convert only the current manipulator, for now just re-generate. */ + /* We could convert only the current gizmo, for now just re-generate. */ view3d_ruler_to_gpencil(C, mgroup); } @@ -952,7 +952,7 @@ static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool c ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); } -static int manipulator_ruler_cursor_get(wmManipulator *mpr) +static int gizmo_ruler_cursor_get(wmGizmo *mpr) { if (mpr->highlight_part == PART_LINE) { return BC_CROSSCURSOR; @@ -960,18 +960,18 @@ static int manipulator_ruler_cursor_get(wmManipulator *mpr) return BC_NSEW_SCROLLCURSOR; } -void VIEW3D_WT_ruler_item(wmManipulatorType *wt) +void VIEW3D_WT_ruler_item(wmGizmoType *wt) { /* identifiers */ wt->idname = "VIEW3D_WT_ruler_item"; /* api callbacks */ - wt->draw = manipulator_ruler_draw; - wt->test_select = manipulator_ruler_test_select; - wt->modal = manipulator_ruler_modal; - wt->invoke = manipulator_ruler_invoke; - wt->exit = manipulator_ruler_exit; - wt->cursor_get = manipulator_ruler_cursor_get; + wt->draw = gizmo_ruler_draw; + wt->test_select = gizmo_ruler_test_select; + wt->modal = gizmo_ruler_modal; + wt->invoke = gizmo_ruler_invoke; + wt->exit = gizmo_ruler_exit; + wt->cursor_get = gizmo_ruler_cursor_get; wt->struct_size = sizeof(RulerItem); } @@ -979,22 +979,22 @@ void VIEW3D_WT_ruler_item(wmManipulatorType *wt) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Ruler Manipulator Group +/** \name Ruler Gizmo Group * \{ */ -static bool WIDGETGROUP_ruler_poll(const bContext *C, wmManipulatorGroupType *wgt) +static bool WIDGETGROUP_ruler_poll(const bContext *C, wmGizmoGroupType *wgt) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->manipulator_group)) + !STREQ(wgt->idname, tref_rt->gizmo_group)) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(wgt); return false; } return true; } -static void WIDGETGROUP_ruler_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *mgroup) { RulerInfo *ruler_info = MEM_callocN(sizeof(RulerInfo), __func__); @@ -1012,12 +1012,12 @@ static void WIDGETGROUP_ruler_setup(const bContext *C, wmManipulatorGroup *mgrou mgroup->customdata = ruler_info; } -void VIEW3D_WGT_ruler(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_ruler(wmGizmoGroupType *wgt) { wgt->name = "Ruler Widgets"; wgt->idname = view3d_wgt_ruler_id; - wgt->flag |= WM_MANIPULATORGROUPTYPE_SCALE | WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL; + wgt->flag |= WM_GIZMOGROUPTYPE_SCALE | WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL; wgt->mmap_params.spaceid = SPACE_VIEW3D; wgt->mmap_params.regionid = RGN_TYPE_WINDOW; @@ -1036,7 +1036,7 @@ static bool view3d_ruler_poll(bContext *C) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || - !STREQ(view3d_wgt_ruler_id, tref_rt->manipulator_group) || + !STREQ(view3d_wgt_ruler_id, tref_rt->gizmo_group) || CTX_wm_region_view3d(C) == NULL) { return false; @@ -1050,8 +1050,8 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wm View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ar->regiondata; - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulatorGroup *mgroup = WM_manipulatormap_group_find(mmap, view3d_wgt_ruler_id); + wmGizmoMap *mmap = ar->gizmo_map; + wmGizmoGroup *mgroup = WM_gizmomap_group_find(mmap, view3d_wgt_ruler_id); const bool use_depth = (v3d->drawtype >= OB_SOLID); /* Create new line */ @@ -1059,9 +1059,9 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wm ruler_item = ruler_item_add(mgroup); /* This is a little weak, but there is no real good way to tweak directly. */ - WM_manipulator_highlight_set(mmap, &ruler_item->mpr); + WM_gizmo_highlight_set(mmap, &ruler_item->mpr); if (WM_operator_name_call( - C, "MANIPULATORGROUP_OT_manipulator_tweak", + C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_REGION_WIN, NULL) == OPERATOR_RUNNING_MODAL) { RulerInfo *ruler_info = mgroup->customdata; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index a2dda8d6403..c9277235d50 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -308,7 +308,7 @@ static void uiTemplatePaintModeSelection(uiLayout *layout, struct bContext *C) ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - /* Manipulators aren't used in paint modes */ + /* Gizmos aren't used in paint modes */ if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) { /* masks aren't used for sculpt and particle painting */ PointerRNA meshptr; @@ -391,9 +391,9 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) else { /* Moved to popover and topbar. */ #if 0 - /* Transform widget / manipulators */ + /* Transform widget / gizmos */ row = uiLayoutRow(layout, true); - uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); + uiItemR(row, &v3dptr, "show_gizmo", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiItemR(row, &sceneptr, "transform_orientation", 0, "", ICON_NONE); #endif } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index b74a40969a1..89dd254c130 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -51,8 +51,8 @@ struct Mesh; struct ViewLayer; struct wmOperatorType; struct wmKeyConfig; -struct wmManipulatorGroupType; -struct wmManipulatorType; +struct wmGizmoGroupType; +struct wmGizmoType; struct wmWindowManager; /* drawing flags: */ @@ -254,21 +254,21 @@ ARegion *view3d_has_tools_region(ScrArea *sa); extern const char *view3d_context_dir[]; /* doc access */ /* view3d_widgets.c */ -void VIEW3D_WGT_lamp_spot(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_lamp_area(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_lamp_target(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_camera(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_camera_view(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_force_field(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_empty_image(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_armature_spline(struct wmManipulatorGroupType *wgt); -void VIEW3D_WGT_navigate(struct wmManipulatorGroupType *wgt); - -void VIEW3D_WGT_ruler(struct wmManipulatorGroupType *wgt); -void VIEW3D_WT_ruler_item(struct wmManipulatorType *wt); +void VIEW3D_WGT_lamp_spot(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_lamp_area(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_lamp_target(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_camera(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_camera_view(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_force_field(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_empty_image(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_armature_spline(struct wmGizmoGroupType *wgt); +void VIEW3D_WGT_navigate(struct wmGizmoGroupType *wgt); + +void VIEW3D_WGT_ruler(struct wmGizmoGroupType *wgt); +void VIEW3D_WT_ruler_item(struct wmGizmoType *wt); void VIEW3D_OT_ruler_add(struct wmOperatorType *ot); -void VIEW3D_WT_navigate_rotate(struct wmManipulatorType *wt); +void VIEW3D_WT_navigate_rotate(struct wmGizmoType *wt); /* draw_volume.c */ void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob, diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index fb9cf917701..cf9b8afe8e5 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -541,7 +541,7 @@ void view3d_keymap(wmKeyConfig *keyconf) #else kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); #endif - RNA_string_set(kmi->ptr, "data_path", "space_data.show_manipulator_tool"); + RNA_string_set(kmi->ptr, "data_path", "space_data.show_gizmo_tool"); transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 15c830e45d0..ad7b5d55ba5 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2215,7 +2215,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->launch_event = event ? WM_userdef_event_type_from_keymap_type(event->type) : -1; // XXX Remove this when wm_operator_call_internal doesn't use window->eventstate (which can have type = 0) - // For manipulator only, so assume LEFTMOUSE + // For gizmo only, so assume LEFTMOUSE if (t->launch_event == 0) { t->launch_event = LEFTMOUSE; } @@ -2267,10 +2267,10 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* keymap for shortcut header prints */ t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); - /* Stupid code to have Ctrl-Click on manipulator work ok + /* Stupid code to have Ctrl-Click on gizmo work ok * * do this only for translation/rotation/resize due to only this - * moded are available from manipulator and doing such check could + * moded are available from gizmo and doing such check could * lead to keymap conflicts for other modes (see #31584) */ if (ELEM(mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) { @@ -3590,7 +3590,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2])) t->con.applySize(t, NULL, NULL, mat); } - copy_m3_m3(t->mat, mat); // used in manipulator + copy_m3_m3(t->mat, mat); // used in gizmo headerResize(t, t->values, str); @@ -4302,7 +4302,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) mul_m3_m3m3(mat, smat, totmat); // TRANSFORM_FIX_ME - //copy_m3_m3(t->mat, mat); // used in manipulator + //copy_m3_m3(t->mat, mat); // used in gizmo #endif applyTrackballValue(t, axis1, axis2, phi); @@ -5453,7 +5453,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) t->con.applySize(t, NULL, NULL, mat); } - copy_m3_m3(t->mat, mat); // used in manipulator + copy_m3_m3(t->mat, mat); // used in gizmo headerBoneSize(t, size, str); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b022d5a3058..2006bd830b4 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -491,7 +491,7 @@ typedef struct TransInfo { short persp; short around; char spacetype; /* spacetype where transforming is */ - char helpline; /* Choice of custom cursor with or without a help line from the manipulator to the mouse position. */ + char helpline; /* Choice of custom cursor with or without a help line from the gizmo to the mouse position. */ short obedit_type; /* Avoid looking inside TransDataContainer obedit. */ float vec[3]; /* translation, to show for widget */ @@ -710,9 +710,9 @@ void flushTransMasking(TransInfo *t); void flushTransPaintCurve(TransInfo *t); void restoreBones(TransDataContainer *tc); -/*********************** transform_manipulator.c ********** */ +/*********************** transform_gizmo.c ********** */ -#define MANIPULATOR_AXIS_LINE_WIDTH 2.0f +#define GIZMO_AXIS_LINE_WIDTH 2.0f /* return 0 when no gimbal for selection */ bool gimbal_axis(struct Object *ob, float gmat[3][3]); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 83b568b494c..a5706f4a003 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -6684,7 +6684,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) BKE_pose_where_is(t->depsgraph, t->scene, pose_ob); } - /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */ + /* set BONE_TRANSFORM flags for autokey, gizmo draw might have changed them */ if (!canceled && (t->mode != TFM_DUMMY)) { count_set_pose_transflags(ob, t->mode, t->around, NULL); } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index c79c28a99da..e32bef72cf6 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1348,10 +1348,10 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->view = v3d; t->animtimer = (animscreen) ? animscreen->animtimer : NULL; - /* turn manipulator off during transform */ + /* turn gizmo off during transform */ if (t->flag & T_MODAL) { t->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = V3D_MANIPULATOR_HIDE; + v3d->mpr_flag = V3D_GIZMO_HIDE; } if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) { @@ -1688,7 +1688,7 @@ void postTrans(bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = t->sa->spacedata.first; - /* restore manipulator */ + /* restore gizmo */ if (t->flag & T_MODAL) { v3d->mpr_flag = t->mpr_flag; } diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c index 5d5d55de848..995faae8333 100644 --- a/source/blender/editors/transform/transform_gizmo_2d.c +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -21,7 +21,7 @@ /** \file blender/editors/transform/transform_gizmo_2d.c * \ingroup edtransform * - * \name 2D Transform Manipulator + * \name 2D Transform Gizmo * * Used for UV/Image Editor */ @@ -64,18 +64,18 @@ enum { MAN2D_AXIS_LAST, }; -typedef struct ManipulatorGroup2D { - wmManipulator *translate_x, +typedef struct GizmoGroup2D { + wmGizmo *translate_x, *translate_y; - wmManipulator *cage; + wmGizmo *cage; /* Current origin in view space, used to update widget origin for possible view changes */ float origin[2]; float min[2]; float max[2]; -} ManipulatorGroup2D; +} GizmoGroup2D; /* **************** Utilities **************** */ @@ -83,16 +83,16 @@ typedef struct ManipulatorGroup2D { /* loop over axes */ #define MAN2D_ITER_AXES_BEGIN(axis, axis_idx) \ { \ - wmManipulator *axis; \ + wmGizmo *axis; \ int axis_idx; \ for (axis_idx = 0; axis_idx < MAN2D_AXIS_LAST; axis_idx++) { \ - axis = manipulator2d_get_axis_from_index(man, axis_idx); + axis = gizmo2d_get_axis_from_index(man, axis_idx); #define MAN2D_ITER_AXES_END \ } \ } ((void)0) -static wmManipulator *manipulator2d_get_axis_from_index(const ManipulatorGroup2D *man, const short axis_idx) +static wmGizmo *gizmo2d_get_axis_from_index(const GizmoGroup2D *man, const short axis_idx) { BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN2D_AXIS_TRANS_X, (float)MAN2D_AXIS_TRANS_Y)); @@ -106,7 +106,7 @@ static wmManipulator *manipulator2d_get_axis_from_index(const ManipulatorGroup2D return NULL; } -static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float *r_col_hi) +static void gizmo2d_get_axis_color(const int axis_idx, float *r_col, float *r_col_hi) { const float alpha = 0.6f; const float alpha_hi = 1.0f; @@ -128,29 +128,29 @@ static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float r_col_hi[3] *= alpha_hi; } -static ManipulatorGroup2D *manipulatorgroup2d_init(wmManipulatorGroup *mgroup) +static GizmoGroup2D *gizmogroup2d_init(wmGizmoGroup *mgroup) { - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_2d", true); - const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_2d", true); + const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_2d", true); + const wmGizmoType *wt_cage = WM_gizmotype_find("GIZMO_WT_cage_2d", true); - ManipulatorGroup2D *man = MEM_callocN(sizeof(ManipulatorGroup2D), __func__); + GizmoGroup2D *man = MEM_callocN(sizeof(GizmoGroup2D), __func__); - man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); + man->translate_x = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); + man->translate_y = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); + man->cage = WM_gizmo_new_ptr(wt_cage, mgroup, NULL); RNA_enum_set(man->cage->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE); + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | + ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE); return man; } /** - * Calculates origin in view space, use with #manipulator2d_origin_to_region. + * Calculates origin in view space, use with #gizmo2d_origin_to_region. */ -static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max) +static void gizmo2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max) { SpaceImage *sima = CTX_wm_space_image(C); Image *ima = ED_space_image(sima); @@ -173,34 +173,34 @@ static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float /** * Convert origin (or any other point) from view to region space. */ -BLI_INLINE void manipulator2d_origin_to_region(ARegion *ar, float *r_origin) +BLI_INLINE void gizmo2d_origin_to_region(ARegion *ar, float *r_origin) { UI_view2d_view_to_region_fl(&ar->v2d, r_origin[0], r_origin[1], &r_origin[0], &r_origin[1]); } /** - * Custom handler for manipulator widgets + * Custom handler for gizmo widgets */ -static int manipulator2d_modal( - bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo2d_modal( + bContext *C, wmGizmo *widget, const wmEvent *UNUSED(event), + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { ARegion *ar = CTX_wm_region(C); float origin[3]; - manipulator2d_calc_bounds(C, origin, NULL, NULL); - manipulator2d_origin_to_region(ar, origin); - WM_manipulator_set_matrix_location(widget, origin); + gizmo2d_calc_bounds(C, origin, NULL, NULL); + gizmo2d_origin_to_region(ar, origin); + WM_gizmo_set_matrix_location(widget, origin); ED_region_tag_redraw(ar); return OPERATOR_RUNNING_MODAL; } -void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { wmOperatorType *ot_translate = WM_operatortype_find("TRANSFORM_OT_translate", true); - ManipulatorGroup2D *man = manipulatorgroup2d_init(mgroup); + GizmoGroup2D *man = gizmogroup2d_init(mgroup); mgroup->customdata = man; MAN2D_ITER_AXES_BEGIN(axis, axis_idx) @@ -208,21 +208,21 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator const float offset[3] = {0.0f, 0.2f}; float color[4], color_hi[4]; - manipulator2d_get_axis_color(axis_idx, color, color_hi); + gizmo2d_get_axis_color(axis_idx, color, color_hi); /* custom handler! */ - WM_manipulator_set_fn_custom_modal(axis, manipulator2d_modal); + WM_gizmo_set_fn_custom_modal(axis, gizmo2d_modal); /* set up widget data */ RNA_float_set(axis->ptr, "angle", -M_PI_2 * axis_idx); RNA_float_set(axis->ptr, "length", 0.8f); - WM_manipulator_set_matrix_offset_location(axis, offset); - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); - WM_manipulator_set_scale(axis, U.manipulator_size); - WM_manipulator_set_color(axis, color); - WM_manipulator_set_color_highlight(axis, color_hi); + WM_gizmo_set_matrix_offset_location(axis, offset); + WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH); + WM_gizmo_set_scale(axis, U.gizmo_size); + WM_gizmo_set_color(axis, color); + WM_gizmo_set_color_highlight(axis, color_hi); /* assign operator */ - PointerRNA *ptr = WM_manipulator_operator_set(axis, 0, ot_translate, NULL); + PointerRNA *ptr = WM_gizmo_operator_set(axis, 0, ot_translate, NULL); bool constraint[3] = {0}; constraint[(axis_idx + 1) % 2] = 1; if (RNA_struct_find_property(ptr, "constraint_axis")) @@ -237,107 +237,107 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator PointerRNA *ptr; /* assign operator */ - ptr = WM_manipulator_operator_set(man->cage, 0, ot_translate, NULL); + ptr = WM_gizmo_operator_set(man->cage, 0, ot_translate, NULL); RNA_boolean_set(ptr, "release_confirm", 1); bool constraint_x[3] = {1, 0, 0}; bool constraint_y[3] = {0, 1, 0}; - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL); PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); PropertyRNA *prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL); RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL); RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL); RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE, ot_rotate, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_ROTATE, ot_rotate, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); } } -void ED_widgetgroup_manipulator2d_refresh(const bContext *C, wmManipulatorGroup *mgroup) +void ED_widgetgroup_gizmo2d_refresh(const bContext *C, wmGizmoGroup *mgroup) { - ManipulatorGroup2D *man = mgroup->customdata; + GizmoGroup2D *man = mgroup->customdata; float origin[3]; - manipulator2d_calc_bounds(C, origin, man->min, man->max); + gizmo2d_calc_bounds(C, origin, man->min, man->max); copy_v2_v2(man->origin, origin); bool show_cage = !equals_v2v2(man->min, man->max); if (show_cage) { - man->cage->flag &= ~WM_MANIPULATOR_HIDDEN; - man->translate_x->flag |= WM_MANIPULATOR_HIDDEN; - man->translate_y->flag |= WM_MANIPULATOR_HIDDEN; + man->cage->flag &= ~WM_GIZMO_HIDDEN; + man->translate_x->flag |= WM_GIZMO_HIDDEN; + man->translate_y->flag |= WM_GIZMO_HIDDEN; } else { - man->cage->flag |= WM_MANIPULATOR_HIDDEN; - man->translate_x->flag &= ~WM_MANIPULATOR_HIDDEN; - man->translate_y->flag &= ~WM_MANIPULATOR_HIDDEN; + man->cage->flag |= WM_GIZMO_HIDDEN; + man->translate_x->flag &= ~WM_GIZMO_HIDDEN; + man->translate_y->flag &= ~WM_GIZMO_HIDDEN; } if (show_cage) { - wmManipulatorOpElem *mpop; + wmGizmoOpElem *mpop; float mid[2]; const float *min = man->min; const float *max = man->max; mid_v2_v2v2(mid, min, max); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X); PropertyRNA *prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], mid[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], mid[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], min[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], min[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], min[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_ROTATE); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], mid[1], 0.0f}); } } -void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +void ED_widgetgroup_gizmo2d_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { ARegion *ar = CTX_wm_region(C); - ManipulatorGroup2D *man = mgroup->customdata; + GizmoGroup2D *man = mgroup->customdata; float origin[3] = {UNPACK2(man->origin), 0.0f}; float origin_aa[3] = {UNPACK2(man->origin), 0.0f}; - manipulator2d_origin_to_region(ar, origin); + gizmo2d_origin_to_region(ar, origin); MAN2D_ITER_AXES_BEGIN(axis, axis_idx) { - WM_manipulator_set_matrix_location(axis, origin); + WM_gizmo_set_matrix_location(axis, origin); } MAN2D_ITER_AXES_END; UI_view2d_view_to_region_m4(&ar->v2d, man->cage->matrix_space); - WM_manipulator_set_matrix_offset_location(man->cage, origin_aa); + WM_gizmo_set_matrix_offset_location(man->cage, origin_aa); man->cage->matrix_offset[0][0] = (man->max[0] - man->min[0]); man->cage->matrix_offset[1][1] = (man->max[1] - man->min[1]); } @@ -346,9 +346,9 @@ void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorG * - Called on every redraw, better to do a more simple poll and check for selection in _refresh * - UV editing only, could be expanded for other things. */ -bool ED_widgetgroup_manipulator2d_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +bool ED_widgetgroup_gizmo2d_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) { - if ((U.manipulator_flag & USER_MANIPULATOR_DRAW) == 0) { + if ((U.gizmo_flag & USER_GIZMO_DRAW) == 0) { return false; } diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 1a30bd1cdcb..7d608c433c3 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -21,7 +21,7 @@ /** \file blender/editors/transform/transform_gizmo_3d.c * \ingroup edtransform * - * \name 3D Transform Manipulator + * \name 3D Transform Gizmo * * Used for 3D View */ @@ -106,7 +106,7 @@ #define MAN_SCALE_Z (1 << 10) #define MAN_SCALE_C (MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z) -/* threshold for testing view aligned manipulator axis */ +/* threshold for testing view aligned gizmo axis */ struct { float min, max; } g_tw_axis_range[2] = { @@ -159,17 +159,17 @@ enum { MAN_AXES_SCALE, }; -typedef struct ManipulatorGroup { +typedef struct GizmoGroup { bool all_hidden; int twtype; - /* Users may change the twtype, detect changes to re-setup manipulator options. */ + /* Users may change the twtype, detect changes to re-setup gizmo options. */ int twtype_init; int twtype_prev; int use_twtype_refresh; - struct wmManipulator *manipulators[MAN_AXIS_LAST]; -} ManipulatorGroup; + struct wmGizmo *gizmos[MAN_AXIS_LAST]; +} GizmoGroup; /* -------------------------------------------------------------------- */ /** \name Utilities @@ -178,22 +178,22 @@ typedef struct ManipulatorGroup { /* loop over axes */ #define MAN_ITER_AXES_BEGIN(axis, axis_idx) \ { \ - wmManipulator *axis; \ + wmGizmo *axis; \ int axis_idx; \ for (axis_idx = 0; axis_idx < MAN_AXIS_LAST; axis_idx++) { \ - axis = manipulator_get_axis_from_index(man, axis_idx); + axis = gizmo_get_axis_from_index(man, axis_idx); #define MAN_ITER_AXES_END \ } \ } ((void)0) -static wmManipulator *manipulator_get_axis_from_index(const ManipulatorGroup *man, const short axis_idx) +static wmGizmo *gizmo_get_axis_from_index(const GizmoGroup *man, const short axis_idx) { BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN_AXIS_TRANS_X, (float)MAN_AXIS_LAST)); - return man->manipulators[axis_idx]; + return man->gizmos[axis_idx]; } -static short manipulator_get_axis_type(const int axis_idx) +static short gizmo_get_axis_type(const int axis_idx) { if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { return MAN_AXES_TRANSLATE; @@ -208,7 +208,7 @@ static short manipulator_get_axis_type(const int axis_idx) return -1; } -static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane) +static uint gizmo_orientation_axis(const int axis_idx, bool *r_is_plane) { switch (axis_idx) { case MAN_AXIS_TRANS_YZ: @@ -247,13 +247,13 @@ static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane) return 3; } -static bool manipulator_is_axis_visible( +static bool gizmo_is_axis_visible( const RegionView3D *rv3d, const int twtype, const float idot[3], const int axis_type, const int axis_idx) { if ((axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) == 0) { bool is_plane = false; - const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane); + const uint aidx_norm = gizmo_orientation_axis(axis_idx, &is_plane); /* don't draw axis perpendicular to the view */ if (aidx_norm < 3) { float idot_axis = idot[aidx_norm]; @@ -330,7 +330,7 @@ static bool manipulator_is_axis_visible( return false; } -static void manipulator_get_axis_color( +static void gizmo_get_axis_color( const int axis_idx, const float idot[3], float r_col[4], float r_col_hi[4]) { @@ -346,7 +346,7 @@ static void manipulator_get_axis_color( } else { bool is_plane = false; - const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane); + const int axis_idx_norm = gizmo_orientation_axis(axis_idx, &is_plane); /* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */ if (axis_idx_norm < 3) { const float idot_min = g_tw_axis_range[is_plane].min; @@ -401,7 +401,7 @@ static void manipulator_get_axis_color( r_col_hi[3] = alpha_hi * alpha_fac; } -static void manipulator_get_axis_constraint(const int axis_idx, bool r_axis[3]) +static void gizmo_get_axis_constraint(const int axis_idx, bool r_axis[3]) { ARRAY_SET_ITEMS(r_axis, 0, 0, 0); @@ -596,7 +596,7 @@ bool gimbal_axis(Object *ob, float gmat[3][3]) /* centroid, boundbox, of selection */ /* returns total items selected */ -int ED_transform_calc_manipulator_stats( +int ED_transform_calc_gizmo_stats( const bContext *C, const struct TransformCalcParams *params, struct TransformBounds *tbounds) @@ -952,7 +952,7 @@ int ED_transform_calc_manipulator_stats( } else if (ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; - int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed + int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the gizmo mode, could be mixed bool ok = false; if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) { @@ -1061,7 +1061,7 @@ int ED_transform_calc_manipulator_stats( return totsel; } -static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3]) +static void gizmo_get_idot(RegionView3D *rv3d, float r_idot[3]) { float view_vec[3], axis_vec[3]; ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], view_vec); @@ -1071,7 +1071,7 @@ static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3]) } } -static void manipulator_prepare_mat( +static void gizmo_prepare_mat( const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds) { Scene *scene = CTX_data_scene(C); @@ -1108,9 +1108,9 @@ static void manipulator_prepare_mat( /** * Sets up \a r_start and \a r_len to define arrow line range. - * Needed to adjust line drawing for combined manipulator axis types. + * Needed to adjust line drawing for combined gizmo axis types. */ -static void manipulator_line_range(const int twtype, const short axis_type, float *r_start, float *r_len) +static void gizmo_line_range(const int twtype, const short axis_type, float *r_start, float *r_len) { const float ofs = 0.2f; @@ -1136,15 +1136,15 @@ static void manipulator_line_range(const int twtype, const short axis_type, floa *r_len -= *r_start; } -static void manipulator_xform_message_subscribe( - wmManipulatorGroup *mgroup, struct wmMsgBus *mbus, +static void gizmo_xform_message_subscribe( + wmGizmoGroup *mgroup, struct wmMsgBus *mbus, Scene *scene, bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar, const void *type_fn) { /* Subscribe to view properties */ wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { .owner = ar, .user_data = mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, + .notify = WM_gizmo_do_msg_notify_tag_refresh, }; PointerRNA scene_ptr; @@ -1167,12 +1167,12 @@ static void manipulator_xform_message_subscribe( PointerRNA toolsettings_ptr; RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr); - if (type_fn == TRANSFORM_WGT_manipulator) { + if (type_fn == TRANSFORM_WGT_gizmo) { extern PropertyRNA rna_ToolSettings_transform_pivot_point; - extern PropertyRNA rna_ToolSettings_use_manipulator_mode; + extern PropertyRNA rna_ToolSettings_use_gizmo_mode; const PropertyRNA *props[] = { &rna_ToolSettings_transform_pivot_point, - &rna_ToolSettings_use_manipulator_mode, + &rna_ToolSettings_use_gizmo_mode, }; for (int i = 0; i < ARRAY_SIZE(props); i++) { WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); @@ -1192,73 +1192,73 @@ static void manipulator_xform_message_subscribe( /* -------------------------------------------------------------------- */ -/** \name Transform Manipulator +/** \name Transform Gizmo * \{ */ -static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) +static GizmoGroup *gizmogroup_init(wmGizmoGroup *mgroup) { - ManipulatorGroup *man; + GizmoGroup *man; - man = MEM_callocN(sizeof(ManipulatorGroup), "manipulator_data"); + man = MEM_callocN(sizeof(GizmoGroup), "gizmo_data"); - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); - const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); - const wmManipulatorType *wt_prim = WM_manipulatortype_find("MANIPULATOR_WT_primitive_3d", true); + const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); + const wmGizmoType *wt_dial = WM_gizmotype_find("GIZMO_WT_dial_3d", true); + const wmGizmoType *wt_prim = WM_gizmotype_find("GIZMO_WT_primitive_3d", true); -#define MANIPULATOR_NEW_ARROW(v, draw_style) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \ +#define GIZMO_NEW_ARROW(v, draw_style) { \ + man->gizmos[v] = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); \ + RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \ } ((void)0) -#define MANIPULATOR_NEW_DIAL(v, draw_options) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_options", draw_options); \ +#define GIZMO_NEW_DIAL(v, draw_options) { \ + man->gizmos[v] = WM_gizmo_new_ptr(wt_dial, mgroup, NULL); \ + RNA_enum_set(man->gizmos[v]->ptr, "draw_options", draw_options); \ } ((void)0) -#define MANIPULATOR_NEW_PRIM(v, draw_style) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_prim, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \ +#define GIZMO_NEW_PRIM(v, draw_style) { \ + man->gizmos[v] = WM_gizmo_new_ptr(wt_prim, mgroup, NULL); \ + RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \ } ((void)0) /* add/init widgets - order matters! */ - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_T, ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_T, ED_GIZMO_DIAL_DRAW_FLAG_FILL); - MANIPULATOR_NEW_DIAL(MAN_AXIS_SCALE_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + GIZMO_NEW_DIAL(MAN_AXIS_SCALE_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP); - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_X, ED_MANIPULATOR_ARROW_STYLE_BOX); - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_MANIPULATOR_ARROW_STYLE_BOX); - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_MANIPULATOR_ARROW_STYLE_BOX); + GIZMO_NEW_ARROW(MAN_AXIS_SCALE_X, ED_GIZMO_ARROW_STYLE_BOX); + GIZMO_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_GIZMO_ARROW_STYLE_BOX); + GIZMO_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_GIZMO_ARROW_STYLE_BOX); - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_GIZMO_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_X, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Y, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Z, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_X, ED_GIZMO_DIAL_DRAW_FLAG_CLIP); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_Y, ED_GIZMO_DIAL_DRAW_FLAG_CLIP); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_Z, ED_GIZMO_DIAL_DRAW_FLAG_CLIP); /* init screen aligned widget last here, looks better, behaves better */ - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP); - MANIPULATOR_NEW_DIAL(MAN_AXIS_TRANS_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + GIZMO_NEW_DIAL(MAN_AXIS_TRANS_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP); - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_X, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_MANIPULATOR_ARROW_STYLE_NORMAL); + GIZMO_NEW_ARROW(MAN_AXIS_TRANS_X, ED_GIZMO_ARROW_STYLE_NORMAL); + GIZMO_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_GIZMO_ARROW_STYLE_NORMAL); + GIZMO_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_GIZMO_ARROW_STYLE_NORMAL); - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_GIZMO_PRIMITIVE_STYLE_PLANE); - man->manipulators[MAN_AXIS_ROT_T]->flag |= WM_MANIPULATOR_SELECT_BACKGROUND; + man->gizmos[MAN_AXIS_ROT_T]->flag |= WM_GIZMO_SELECT_BACKGROUND; return man; } /** - * Custom handler for manipulator widgets + * Custom handler for gizmo widgets */ -static int manipulator_modal( - bContext *C, wmManipulator *widget, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo_modal( + bContext *C, wmGizmo *widget, const wmEvent *event, + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { /* Avoid unnecessary updates, partially address: T55458. */ if (ELEM(event->type, TIMER, INBETWEEN_MOUSEMOVE)) { @@ -1272,13 +1272,13 @@ static int manipulator_modal( struct TransformBounds tbounds; - if (ED_transform_calc_manipulator_stats( + if (ED_transform_calc_gizmo_stats( C, &(struct TransformCalcParams){ .use_only_center = true, }, &tbounds)) { - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); - WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]); + gizmo_prepare_mat(C, v3d, rv3d, &tbounds); + WM_gizmo_set_matrix_location(widget, rv3d->twmat[3]); } ED_region_tag_redraw(ar); @@ -1286,22 +1286,22 @@ static int manipulator_modal( return OPERATOR_RUNNING_MODAL; } -static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgroup) +static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *mgroup) { struct { wmOperatorType *translate, *rotate, *trackball, *resize; } ot_store = {NULL}; - ManipulatorGroup *man = mgroup->customdata; + GizmoGroup *man = mgroup->customdata; MAN_ITER_AXES_BEGIN(axis, axis_idx) { - const short axis_type = manipulator_get_axis_type(axis_idx); + const short axis_type = gizmo_get_axis_type(axis_idx); bool constraint_axis[3] = {1, 0, 0}; PointerRNA *ptr; - manipulator_get_axis_constraint(axis_idx, constraint_axis); + gizmo_get_axis_constraint(axis_idx, constraint_axis); /* custom handler! */ - WM_manipulator_set_fn_custom_modal(axis, manipulator_modal); + WM_gizmo_set_fn_custom_modal(axis, gizmo_modal); switch (axis_idx) { case MAN_AXIS_TRANS_X: @@ -1313,19 +1313,19 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { int draw_options = 0; if ((man->twtype & (SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { - draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM; + draw_options |= ED_GIZMO_ARROW_DRAW_FLAG_STEM; } RNA_enum_set(axis->ptr, "draw_options", draw_options); } - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); + WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH); break; case MAN_AXIS_ROT_X: case MAN_AXIS_ROT_Y: case MAN_AXIS_ROT_Z: /* increased line width for better display */ - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH + 1.0f); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); + WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH + 1.0f); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_VALUE, true); break; case MAN_AXIS_TRANS_XY: case MAN_AXIS_TRANS_YZ: @@ -1336,25 +1336,25 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr { const float ofs_ax = 7.0f; const float ofs[3] = {ofs_ax, ofs_ax, 0.0f}; - WM_manipulator_set_scale(axis, 0.07f); - WM_manipulator_set_matrix_offset_location(axis, ofs); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); + WM_gizmo_set_scale(axis, 0.07f); + WM_gizmo_set_matrix_offset_location(axis, ofs); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_OFFSET_SCALE, true); break; } case MAN_AXIS_TRANS_C: case MAN_AXIS_ROT_C: case MAN_AXIS_SCALE_C: case MAN_AXIS_ROT_T: - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); + WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH); if (axis_idx == MAN_AXIS_ROT_T) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_HOVER, true); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_HOVER, true); } else if (axis_idx == MAN_AXIS_ROT_C) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); - WM_manipulator_set_scale(axis, 1.2f); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_VALUE, true); + WM_gizmo_set_scale(axis, 1.2f); } else { - WM_manipulator_set_scale(axis, 0.2f); + WM_gizmo_set_scale(axis, 0.2f); } break; } @@ -1364,7 +1364,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr if (ot_store.translate == NULL) { ot_store.translate = WM_operatortype_find("TRANSFORM_OT_translate", true); } - ptr = WM_manipulator_operator_set(axis, 0, ot_store.translate, NULL); + ptr = WM_gizmo_operator_set(axis, 0, ot_store.translate, NULL); break; case MAN_AXES_ROTATE: { @@ -1381,7 +1381,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr } ot_rotate = ot_store.rotate; } - ptr = WM_manipulator_operator_set(axis, 0, ot_rotate, NULL); + ptr = WM_gizmo_operator_set(axis, 0, ot_rotate, NULL); break; } case MAN_AXES_SCALE: @@ -1389,7 +1389,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr if (ot_store.resize == NULL) { ot_store.resize = WM_operatortype_find("TRANSFORM_OT_resize", true); } - ptr = WM_manipulator_operator_set(axis, 0, ot_store.resize, NULL); + ptr = WM_gizmo_operator_set(axis, 0, ot_store.resize, NULL); break; } } @@ -1406,9 +1406,9 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr MAN_ITER_AXES_END; } -static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *mgroup) { - ManipulatorGroup *man = manipulatorgroup_init(mgroup); + GizmoGroup *man = gizmogroup_init(mgroup); mgroup->customdata = man; @@ -1418,7 +1418,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup const bToolRef *tref = sa->runtime.tool; if (tref == NULL || STREQ(tref->idname, "Transform")) { - /* Setup all manipulators, they can be toggled via 'ToolSettings.manipulator_flag' */ + /* Setup all gizmos, they can be toggled via 'ToolSettings.gizmo_flag' */ man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; man->use_twtype_refresh = true; } @@ -1436,12 +1436,12 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup } /* *** set properties for axes *** */ - manipulatorgroup_init_properties_from_twtype(mgroup); + gizmogroup_init_properties_from_twtype(mgroup); } -static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *mgroup) { - ManipulatorGroup *man = mgroup->customdata; + GizmoGroup *man = mgroup->customdata; ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = sa->spacedata.first; @@ -1450,16 +1450,16 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou if (man->use_twtype_refresh) { Scene *scene = CTX_data_scene(C); - man->twtype = scene->toolsettings->manipulator_flag & man->twtype_init; + man->twtype = scene->toolsettings->gizmo_flag & man->twtype_init; if (man->twtype != man->twtype_prev) { man->twtype_prev = man->twtype; - manipulatorgroup_init_properties_from_twtype(mgroup); + gizmogroup_init_properties_from_twtype(mgroup); } } /* skip, we don't draw anything anyway */ if ((man->all_hidden = - (ED_transform_calc_manipulator_stats( + (ED_transform_calc_gizmo_stats( C, &(struct TransformCalcParams){ .use_only_center = true, }, &tbounds) == 0))) @@ -1467,16 +1467,16 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou return; } - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); + gizmo_prepare_mat(C, v3d, rv3d, &tbounds); /* *** set properties for axes *** */ MAN_ITER_AXES_BEGIN(axis, axis_idx) { - const short axis_type = manipulator_get_axis_type(axis_idx); - const int aidx_norm = manipulator_orientation_axis(axis_idx, NULL); + const short axis_type = gizmo_get_axis_type(axis_idx); + const int aidx_norm = gizmo_orientation_axis(axis_idx, NULL); - WM_manipulator_set_matrix_location(axis, rv3d->twmat[3]); + WM_gizmo_set_matrix_location(axis, rv3d->twmat[3]); switch (axis_idx) { case MAN_AXIS_TRANS_X: @@ -1489,9 +1489,9 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou float start_co[3] = {0.0f, 0.0f, 0.0f}; float len; - manipulator_line_range(man->twtype, axis_type, &start_co[2], &len); + gizmo_line_range(man->twtype, axis_type, &start_co[2], &len); - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); + WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); RNA_float_set(axis->ptr, "length", len); if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { @@ -1500,14 +1500,14 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou start_co[2] += 0.215f; } } - WM_manipulator_set_matrix_offset_location(axis, start_co); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); + WM_gizmo_set_matrix_offset_location(axis, start_co); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_OFFSET_SCALE, true); break; } case MAN_AXIS_ROT_X: case MAN_AXIS_ROT_Y: case MAN_AXIS_ROT_Z: - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); + WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); break; case MAN_AXIS_TRANS_XY: case MAN_AXIS_TRANS_YZ: @@ -1518,7 +1518,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou { const float *y_axis = rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1]; const float *z_axis = rv3d->twmat[aidx_norm]; - WM_manipulator_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis); + WM_gizmo_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis); break; } } @@ -1526,134 +1526,134 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou MAN_ITER_AXES_END; } -static void WIDGETGROUP_manipulator_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) +static void WIDGETGROUP_gizmo_message_subscribe( + const bContext *C, wmGizmoGroup *mgroup, struct wmMsgBus *mbus) { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, TRANSFORM_WGT_manipulator); + gizmo_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, TRANSFORM_WGT_gizmo); } -static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { - ManipulatorGroup *man = mgroup->customdata; + GizmoGroup *man = mgroup->customdata; // ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); // View3D *v3d = sa->spacedata.first; RegionView3D *rv3d = ar->regiondata; float idot[3]; - /* when looking through a selected camera, the manipulator can be at the + /* when looking through a selected camera, the gizmo can be at the * exact same position as the view, skip so we don't break selection */ if (man->all_hidden || fabsf(ED_view3d_pixel_size(rv3d, rv3d->twmat[3])) < 1e-6f) { MAN_ITER_AXES_BEGIN(axis, axis_idx) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, true); } MAN_ITER_AXES_END; return; } - manipulator_get_idot(rv3d, idot); + gizmo_get_idot(rv3d, idot); /* *** set properties for axes *** */ MAN_ITER_AXES_BEGIN(axis, axis_idx) { - const short axis_type = manipulator_get_axis_type(axis_idx); + const short axis_type = gizmo_get_axis_type(axis_idx); /* XXX maybe unset _HIDDEN flag on redraw? */ - if (manipulator_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, false); + if (gizmo_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) { + WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, false); } else { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, true); continue; } float color[4], color_hi[4]; - manipulator_get_axis_color(axis_idx, idot, color, color_hi); - WM_manipulator_set_color(axis, color); - WM_manipulator_set_color_highlight(axis, color_hi); + gizmo_get_axis_color(axis_idx, idot, color, color_hi); + WM_gizmo_set_color(axis, color); + WM_gizmo_set_color_highlight(axis, color_hi); switch (axis_idx) { case MAN_AXIS_TRANS_C: case MAN_AXIS_ROT_C: case MAN_AXIS_SCALE_C: case MAN_AXIS_ROT_T: - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]); + WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]); break; } } MAN_ITER_AXES_END; } -static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt) +static bool WIDGETGROUP_gizmo_poll(const struct bContext *C, struct wmGizmoGroupType *wgt) { /* it's a given we only use this in 3D view */ bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->manipulator_group)) + !STREQ(wgt->idname, tref_rt->gizmo_group)) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(wgt); return false; } View3D *v3d = CTX_wm_view3d(C); - if (v3d->mpr_flag & (V3D_MANIPULATOR_HIDE | V3D_MANIPULATOR_HIDE_TOOL)) { + if (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { return false; } return true; } -void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt) +void TRANSFORM_WGT_gizmo(wmGizmoGroupType *wgt) { - wgt->name = "Transform Manipulator"; - wgt->idname = "TRANSFORM_WGT_manipulator"; + wgt->name = "Transform Gizmo"; + wgt->idname = "TRANSFORM_WGT_gizmo"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; + wgt->flag |= WM_GIZMOGROUPTYPE_3D; wgt->mmap_params.spaceid = SPACE_VIEW3D; wgt->mmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = WIDGETGROUP_manipulator_poll; - wgt->setup = WIDGETGROUP_manipulator_setup; - wgt->refresh = WIDGETGROUP_manipulator_refresh; - wgt->message_subscribe = WIDGETGROUP_manipulator_message_subscribe; - wgt->draw_prepare = WIDGETGROUP_manipulator_draw_prepare; + wgt->poll = WIDGETGROUP_gizmo_poll; + wgt->setup = WIDGETGROUP_gizmo_setup; + wgt->refresh = WIDGETGROUP_gizmo_refresh; + wgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe; + wgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare; } /** \} */ /* -------------------------------------------------------------------- */ -/** \name Scale Cage Manipulator +/** \name Scale Cage Gizmo * \{ */ struct XFormCageWidgetGroup { - wmManipulator *manipulator; + wmGizmo *gizmo; }; -static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupType *wgt) +static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmGizmoGroupType *wgt) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); - if (!STREQ(wgt->idname, tref_rt->manipulator_group)) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + if (!STREQ(wgt->idname, tref_rt->gizmo_group)) { + WM_gizmo_group_type_unlink_delayed_ptr(wgt); return false; } return true; } -static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) { struct XFormCageWidgetGroup *xmgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__); - const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true); - xmgroup->manipulator = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); - wmManipulator *mpr = xmgroup->manipulator; + const wmGizmoType *wt_cage = WM_gizmotype_find("GIZMO_WT_cage_3d", true); + xmgroup->gizmo = WM_gizmo_new_ptr(wt_cage, mgroup, NULL); + wmGizmo *mpr = xmgroup->gizmo; RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE); + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE); mpr->color[0] = 1; mpr->color_hi[0] = 1; @@ -1668,12 +1668,12 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulato PropertyRNA *prop_release_confirm = NULL; PropertyRNA *prop_constraint_axis = NULL; - int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; + int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { bool constraint[3] = {x != 1, y != 1, z != 1}; - ptr = WM_manipulator_operator_set(mpr, i, ot_resize, NULL); + ptr = WM_gizmo_operator_set(mpr, i, ot_resize, NULL); if (prop_release_confirm == NULL) { prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); @@ -1687,7 +1687,7 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulato } } -static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *mgroup) { ScrArea *sa = CTX_wm_area(C); View3D *v3d = sa->spacedata.first; @@ -1695,23 +1695,23 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup RegionView3D *rv3d = ar->regiondata; struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; - wmManipulator *mpr = xmgroup->manipulator; + wmGizmo *mpr = xmgroup->gizmo; struct TransformBounds tbounds; - if ((ED_transform_calc_manipulator_stats( + if ((ED_transform_calc_gizmo_stats( C, &(struct TransformCalcParams) { .use_local_axis = true, }, &tbounds) == 0) || equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max)) { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); } else { - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); + gizmo_prepare_mat(C, v3d, rv3d, &tbounds); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_GRAB_CURSOR, true); + WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + WM_gizmo_set_flag(mpr, WM_GIZMO_GRAB_CURSOR, true); float dims[3]; sub_v3_v3v3(dims, rv3d->tw_axis_max, rv3d->tw_axis_min); @@ -1725,14 +1725,14 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup PropertyRNA *prop_center_override = NULL; float center[3]; float center_global[3]; - int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; + int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; for (int x = 0; x < 3; x++) { center[0] = (float)(1 - x) * dims[0]; for (int y = 0; y < 3; y++) { center[1] = (float)(1 - y) * dims[1]; for (int z = 0; z < 3; z++) { center[2] = (float)(1 - z) * dims[2]; - struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, i); + struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, i); if (prop_center_override == NULL) { prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); } @@ -1746,19 +1746,19 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup } static void WIDGETGROUP_xform_cage_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) + const bContext *C, wmGizmoGroup *mgroup, struct wmMsgBus *mbus) { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, VIEW3D_WGT_xform_cage); + gizmo_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, VIEW3D_WGT_xform_cage); } -static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) { struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; - wmManipulator *mpr = xmgroup->manipulator; + wmGizmo *mpr = xmgroup->gizmo; ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); @@ -1770,12 +1770,12 @@ static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulator } } -void VIEW3D_WGT_xform_cage(wmManipulatorGroupType *wgt) +void VIEW3D_WGT_xform_cage(wmGizmoGroupType *wgt) { wgt->name = "Transform Cage"; wgt->idname = "VIEW3D_WGT_xform_cage"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; + wgt->flag |= WM_GIZMOGROUPTYPE_3D; wgt->mmap_params.spaceid = SPACE_VIEW3D; wgt->mmap_params.regionid = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index eedf6f50a1f..c9a97c8530c 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -493,7 +493,7 @@ static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* add temp handler */ WM_event_add_modal_handler(C, op); - op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the manipulator only? + op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the gizmo only? /* Use when modal input has some transformation to begin with. */ { @@ -585,7 +585,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) } if (flags & P_CENTER) { - /* For manipulators that define their own center. */ + /* For gizmos that define their own center. */ prop = RNA_def_property(ot->srna, "center_override", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 3); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index e6ad7835b24..0c4c0a00f1a 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1237,7 +1237,7 @@ typedef struct ToolSettings { short autoik_chainlen; /* runtime only */ /* SCE_MPR_LOC/SCAL */ - char manipulator_flag; + char gizmo_flag; /* Grease Pencil */ char gpencil_flags; /* flags/options for how the tool works */ @@ -2010,7 +2010,7 @@ typedef enum eImagePaintMode { #define EDGE_MODE_TAG_BEVEL 4 #define EDGE_MODE_TAG_FREESTYLE 5 -/* ToolSettings.manipulator_flag */ +/* ToolSettings.gizmo_flag */ #define SCE_MANIP_TRANSLATE 1 #define SCE_MANIP_ROTATE 2 #define SCE_MANIP_SCALE 4 diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 3ee6bc38644..3815f01abeb 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -347,7 +347,7 @@ typedef struct ARegion { ListBase handlers; /* wmEventHandler */ ListBase panels_category; /* Panel categories runtime */ - struct wmManipulatorMap *manipulator_map; /* manipulator-map of this region */ + struct wmGizmoMap *gizmo_map; /* gizmo-map of this region */ struct wmTimer *regiontimer; /* blend in/out */ struct wmDrawBuffer *draw_buffer; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 5b8f6fcb73f..cdfcf5598e8 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -195,12 +195,12 @@ typedef struct ThemeUI { /* Axis Colors */ char xaxis[4], yaxis[4], zaxis[4]; - /* Manipulator Colors. */ - char manipulator_hi[4]; - char manipulator_primary[4]; - char manipulator_secondary[4]; - char manipulator_a[4]; - char manipulator_b[4]; + /* Gizmo Colors. */ + char gizmo_hi[4]; + char gizmo_primary[4]; + char gizmo_secondary[4]; + char gizmo_a[4]; + char gizmo_b[4]; char pad2[4]; } ThemeUI; @@ -572,7 +572,7 @@ typedef struct UserDef { short gp_settings; /* eGP_UserdefSettings */ short tb_leftmouse, tb_rightmouse; struct SolidLight light[3]; - short manipulator_flag, manipulator_size; + short gizmo_flag, gizmo_size; short pad6[3]; short textimeout, texcollectrate; short dragthreshold; @@ -751,7 +751,7 @@ typedef enum eUserpref_UI_Flag { USER_ORBIT_SELECTION = (1 << 14), USER_DEPTH_NAVIGATE = (1 << 15), USER_HIDE_DOT = (1 << 16), - USER_SHOW_MANIPULATOR_AXIS = (1 << 17), + USER_SHOW_GIZMO_AXIS = (1 << 17), USER_SHOW_VIEWPORTNAME = (1 << 18), USER_CAM_LOCK_NO_PARENT = (1 << 19), USER_ZOOM_TO_MOUSEPOS = (1 << 20), @@ -875,7 +875,7 @@ typedef enum eGP_UserdefSettings { } eGP_UserdefSettings; enum { - USER_MANIPULATOR_DRAW = (1 << 0), + USER_GIZMO_DRAW = (1 << 0), }; /* Color Picker Types. diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index e0ab3a744f1..40551701627 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -90,7 +90,7 @@ typedef struct RegionView3D { struct wmTimer *smooth_timer; - /* transform manipulator matrix */ + /* transform gizmo matrix */ float twmat[4][4]; /* min/max dot product on twmat xyz axis. */ float tw_axis_min[3], tw_axis_max[3]; @@ -236,7 +236,7 @@ typedef struct View3D { short gridsubdiv; /* Number of subdivisions in the grid between each highlighted grid line */ char gridflag; - /* transform manipulator info */ + /* transform gizmo info */ char _pad5[2], mpr_flag; short flag3; @@ -453,11 +453,11 @@ enum { /* View3d.mpr_flag (also) */ enum { - /** All manipulators. */ - V3D_MANIPULATOR_HIDE = (1 << 0), - V3D_MANIPULATOR_HIDE_NAVIGATE = (1 << 1), - V3D_MANIPULATOR_HIDE_CONTEXT = (1 << 2), - V3D_MANIPULATOR_HIDE_TOOL = (1 << 3), + /** All gizmos. */ + V3D_GIZMO_HIDE = (1 << 0), + V3D_GIZMO_HIDE_NAVIGATE = (1 << 1), + V3D_GIZMO_HIDE_CONTEXT = (1 << 2), + V3D_GIZMO_HIDE_TOOL = (1 << 3), }; #define RV3D_CAMZOOM_MIN -30 diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h index 2b0f74a54ee..3eb40bfa523 100644 --- a/source/blender/makesdna/DNA_workspace_types.h +++ b/source/blender/makesdna/DNA_workspace_types.h @@ -60,7 +60,7 @@ typedef struct bToolRef_Runtime { /** One of these 3 must be defined. */ char keymap[64]; - char manipulator_group[64]; + char gizmo_group[64]; char data_block[64]; /** Use to infer primary operator to use when setting accelerator keys. */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index fe8868235c4..f66c80beeab 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -374,8 +374,8 @@ extern StructRNA RNA_LineStyleThicknessModifier_Tangent; extern StructRNA RNA_LockedTrackConstraint; extern StructRNA RNA_Macro; extern StructRNA RNA_MagicTexture; -extern StructRNA RNA_Manipulator; -extern StructRNA RNA_ManipulatorProperties; +extern StructRNA RNA_Gizmo; +extern StructRNA RNA_GizmoProperties; extern StructRNA RNA_MarbleTexture; extern StructRNA RNA_MaskModifier; extern StructRNA RNA_MaskSequence; diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index bb24452d67a..393ebc15d3e 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3443,7 +3443,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_userdef.c", NULL, RNA_def_userdef}, {"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont}, {"rna_wm.c", "rna_wm_api.c", RNA_def_wm}, - {"rna_wm_gizmo.c", "rna_wm_gizmo_api.c", RNA_def_wm_manipulator}, + {"rna_wm_gizmo.c", "rna_wm_gizmo_api.c", RNA_def_wm_gizmo}, {"rna_workspace.c", "rna_workspace_api.c", RNA_def_workspace}, {"rna_world.c", NULL, RNA_def_world}, {"rna_movieclip.c", NULL, RNA_def_movieclip}, diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 6e07976a3c6..7b07faf8ee7 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -121,11 +121,11 @@ static PointerRNA rna_Context_region_data_get(PointerRNA *ptr) return PointerRNA_NULL; } -static PointerRNA rna_Context_manipulator_group_get(PointerRNA *ptr) +static PointerRNA rna_Context_gizmo_group_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; PointerRNA newptr; - RNA_pointer_create(NULL, &RNA_ManipulatorGroup, CTX_wm_manipulator_group(C), &newptr); + RNA_pointer_create(NULL, &RNA_GizmoGroup, CTX_wm_gizmo_group(C), &newptr); return newptr; } @@ -256,10 +256,10 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_struct_type(prop, "RegionView3D"); RNA_def_property_pointer_funcs(prop, "rna_Context_region_data_get", NULL, NULL, NULL); - prop = RNA_def_property(srna, "manipulator_group", PROP_POINTER, PROP_NONE); + prop = RNA_def_property(srna, "gizmo_group", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_struct_type(prop, "ManipulatorGroup"); - RNA_def_property_pointer_funcs(prop, "rna_Context_manipulator_group_get", NULL, NULL, NULL); + RNA_def_property_struct_type(prop, "GizmoGroup"); + RNA_def_property_pointer_funcs(prop, "rna_Context_gizmo_group_get", NULL, NULL, NULL); /* Data */ prop = RNA_def_property(srna, "blend_data", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index a57777f0630..83d173de6c8 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -193,7 +193,7 @@ void RNA_def_ui(struct BlenderRNA *brna); void RNA_def_userdef(struct BlenderRNA *brna); void RNA_def_vfont(struct BlenderRNA *brna); void RNA_def_wm(struct BlenderRNA *brna); -void RNA_def_wm_manipulator(struct BlenderRNA *brna); +void RNA_def_wm_gizmo(struct BlenderRNA *brna); void RNA_def_workspace(struct BlenderRNA *brna); void RNA_def_world(struct BlenderRNA *brna); void RNA_def_movieclip(struct BlenderRNA *brna); @@ -308,8 +308,8 @@ void RNA_api_image(struct StructRNA *srna); void RNA_api_lattice(struct StructRNA *srna); void RNA_api_operator(struct StructRNA *srna); void RNA_api_macro(struct StructRNA *srna); -void RNA_api_manipulator(struct StructRNA *srna); -void RNA_api_manipulatorgroup(struct StructRNA *srna); +void RNA_api_gizmo(struct StructRNA *srna); +void RNA_api_gizmogroup(struct StructRNA *srna); void RNA_api_keyconfig(struct StructRNA *srna); void RNA_api_keyconfigs(struct StructRNA *srna); void RNA_api_keyingset(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 690c6d8e4c1..54b553e94ae 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -413,7 +413,7 @@ const EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = { {0, NULL, 0, NULL, NULL} }; -static const EnumPropertyItem rna_enum_manipulator_items[] = { +static const EnumPropertyItem rna_enum_gizmo_items[] = { {SCE_MANIP_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, {SCE_MANIP_ROTATE, "ROTATE", 0, "Rotate", ""}, {SCE_MANIP_SCALE, "SCALE", 0, "Scale", ""}, @@ -647,11 +647,11 @@ static void rna_GPencilBrush_name_set(PointerRNA *ptr, const char *value) /* ----------------- end of Grease pencil drawing brushes ------------*/ -static void rna_ToolSettings_manipulator_flag_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ToolSettings_gizmo_flag_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { ToolSettings *ts = scene->toolsettings; - if ((ts->manipulator_flag & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { - ts->manipulator_flag |= SCE_MANIP_TRANSLATE; + if ((ts->gizmo_flag & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { + ts->gizmo_flag |= SCE_MANIP_TRANSLATE; } } @@ -2690,12 +2690,12 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ - prop = RNA_def_property(srna, "use_manipulator_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "manipulator_flag"); - RNA_def_property_enum_items(prop, rna_enum_manipulator_items); + prop = RNA_def_property(srna, "use_gizmo_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "gizmo_flag"); + RNA_def_property_enum_items(prop, rna_enum_gizmo_items); RNA_def_property_flag(prop, PROP_ENUM_FLAG); RNA_def_property_ui_text(prop, "Gizmo Mode", ""); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_manipulator_flag_update"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_gizmo_flag_update"); /* Grease Pencil */ prop = RNA_def_property(srna, "use_gpencil_continuous_drawing", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 4bdf7a09585..5c30cdb2b07 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2562,7 +2562,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) prop = RNA_def_property(srna, "show_overlays", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag2", V3D_RENDER_OVERRIDE); - RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like manipulators and outlines"); + RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like gizmos and outlines"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE); @@ -2939,24 +2939,24 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE); + prop = RNA_def_property(srna, "show_gizmo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_GIZMO_HIDE); RNA_def_property_ui_text(prop, "Show Gizmo", "Show gizmos of all types"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_manipulator_navigate", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_NAVIGATE); + prop = RNA_def_property(srna, "show_gizmo_navigate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_GIZMO_HIDE_NAVIGATE); RNA_def_property_ui_text(prop, "Navigate Gizmo", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_manipulator_context", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_CONTEXT); - RNA_def_property_ui_text(prop, "Context Gizmo", "Context sensitive manipulators for the active item"); + prop = RNA_def_property(srna, "show_gizmo_context", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_GIZMO_HIDE_CONTEXT); + RNA_def_property_ui_text(prop, "Context Gizmo", "Context sensitive gizmos for the active item"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_manipulator_tool", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_MANIPULATOR_HIDE_TOOL); - RNA_def_property_ui_text(prop, "Tool Gizmo", "Active tool manipulator"); + prop = RNA_def_property(srna, "show_gizmo_tool", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_GIZMO_HIDE_TOOL); + RNA_def_property_ui_text(prop, "Tool Gizmo", "Active tool gizmo"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index d8941e303d9..5557afdb33f 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1201,33 +1201,33 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Z Axis", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - /* Generic manipulator colors. */ - prop = RNA_def_property(srna, "manipulator_hi", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "manipulator_hi"); + /* Generic gizmo colors. */ + prop = RNA_def_property(srna, "gizmo_hi", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_hi"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Gizmo Highlight", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "manipulator_primary", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "manipulator_primary"); + prop = RNA_def_property(srna, "gizmo_primary", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_primary"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Gizmo Primary", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "manipulator_secondary", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "manipulator_secondary"); + prop = RNA_def_property(srna, "gizmo_secondary", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_secondary"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Gizmo Secondary", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "manipulator_a", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "manipulator_a"); + prop = RNA_def_property(srna, "gizmo_a", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_a"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Gizmo A", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "manipulator_b", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "manipulator_b"); + prop = RNA_def_property(srna, "gizmo_b", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_b"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Gizmo B", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); @@ -3705,7 +3705,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) /* mini axis */ static const EnumPropertyItem mini_axis_type_items[] = { {0, "MINIMAL", 0, "Simple Axis", ""}, - {USER_SHOW_MANIPULATOR_AXIS, "MANIPULATOR", 0, "Interactive Navigation", ""}, + {USER_SHOW_GIZMO_AXIS, "GIZMO", 0, "Interactive Navigation", ""}, {0, NULL, 0, NULL, NULL} }; @@ -3739,16 +3739,16 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Rotation Angle", "Rotation step for numerical pad keys (2 4 6 8)"); /* 3D transform widget */ - prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW); - RNA_def_property_ui_text(prop, "Manipulators", "Use transform manipulators by default"); + prop = RNA_def_property(srna, "show_gizmo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gizmo_flag", USER_GIZMO_DRAW); + RNA_def_property_ui_text(prop, "Gizmos", "Use transform gizmos by default"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "manipulator_size"); + prop = RNA_def_property(srna, "gizmo_size", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "gizmo_size"); RNA_def_property_range(prop, 10, 200); RNA_def_property_int_default(prop, 75); - RNA_def_property_ui_text(prop, "Manipulator Size", "Diameter of the manipulator"); + RNA_def_property_ui_text(prop, "Gizmo Size", "Diameter of the gizmo"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index f398c4143ae..7abcf0f0667 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -118,33 +118,33 @@ static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer) } -static wmManipulatorGroupType *wm_manipulatorgrouptype_find_for_add_remove(ReportList *reports, const char *idname) +static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports, const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, true); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, true); if (wgt == NULL) { - BKE_reportf(reports, RPT_ERROR, "Manipulator group type '%s' not found!", idname); + BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname); return NULL; } - if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) { - BKE_reportf(reports, RPT_ERROR, "Manipulator group '%s' has 'PERSISTENT' option set!", idname); + if (wgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { + BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname); return NULL; } return wgt; } -static void rna_manipulator_group_type_add(ReportList *reports, const char *idname) +static void rna_gizmo_group_type_add(ReportList *reports, const char *idname) { - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname); + wmGizmoGroupType *wgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); if (wgt != NULL) { - WM_manipulator_group_type_add_ptr(wgt); + WM_gizmo_group_type_add_ptr(wgt); } } -static void rna_manipulator_group_type_remove(Main *bmain, ReportList *reports, const char *idname) +static void rna_gizmo_group_type_remove(Main *bmain, ReportList *reports, const char *idname) { - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname); + wmGizmoGroupType *wgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); if (wgt != NULL) { - WM_manipulator_group_type_remove_ptr(bmain, wgt); + WM_gizmo_group_type_remove_ptr(bmain, wgt); } } @@ -516,16 +516,16 @@ void RNA_api_wm(StructRNA *srna) parm = RNA_def_pointer(func, "timer", "Timer", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - func = RNA_def_function(srna, "manipulator_group_type_add", "rna_manipulator_group_type_add"); + func = RNA_def_function(srna, "gizmo_group_type_add", "rna_gizmo_group_type_add"); RNA_def_function_ui_description(func, "Activate an existing widget group (when the persistent option isn't set)"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS); - parm = RNA_def_string(func, "identifier", NULL, 0, "", "Manipulator group type name"); + parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - func = RNA_def_function(srna, "manipulator_group_type_remove", "rna_manipulator_group_type_remove"); + func = RNA_def_function(srna, "gizmo_group_type_remove", "rna_gizmo_group_type_remove"); RNA_def_function_ui_description(func, "De-activate a widget group (when the persistent option isn't set)"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_MAIN | FUNC_USE_REPORTS); - parm = RNA_def_string(func, "identifier", NULL, 0, "", "Manipulator group type name"); + parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* Progress bar interface */ diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index c2c4c95b83f..754ef4575a4 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -71,38 +71,38 @@ /* -------------------------------------------------------------------- */ -/** \name Manipulator API +/** \name Gizmo API * \{ */ #ifdef WITH_PYTHON -static void rna_manipulator_draw_cb( - const struct bContext *C, struct wmManipulator *mpr) +static void rna_gizmo_draw_cb( + const struct bContext *C, struct wmGizmo *mpr) { - extern FunctionRNA rna_Manipulator_draw_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + extern FunctionRNA rna_Gizmo_draw_func; + wmGizmoGroup *mgroup = mpr->parent_mgroup; PointerRNA mpr_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); /* RNA_struct_find_function(&mpr_ptr, "draw"); */ - func = &rna_Manipulator_draw_func; + func = &rna_Gizmo_draw_func; RNA_parameter_list_create(&list, &mpr_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); RNA_parameter_list_free(&list); } -static void rna_manipulator_draw_select_cb( - const struct bContext *C, struct wmManipulator *mpr, int select_id) +static void rna_gizmo_draw_select_cb( + const struct bContext *C, struct wmGizmo *mpr, int select_id) { - extern FunctionRNA rna_Manipulator_draw_select_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + extern FunctionRNA rna_Gizmo_draw_select_func; + wmGizmoGroup *mgroup = mpr->parent_mgroup; PointerRNA mpr_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); /* RNA_struct_find_function(&mpr_ptr, "draw_select"); */ - func = &rna_Manipulator_draw_select_func; + func = &rna_Gizmo_draw_select_func; RNA_parameter_list_create(&list, &mpr_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "select_id", &select_id); @@ -110,17 +110,17 @@ static void rna_manipulator_draw_select_cb( RNA_parameter_list_free(&list); } -static int rna_manipulator_test_select_cb( - struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event) +static int rna_gizmo_test_select_cb( + struct bContext *C, struct wmGizmo *mpr, const struct wmEvent *event) { - extern FunctionRNA rna_Manipulator_test_select_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + extern FunctionRNA rna_Gizmo_test_select_func; + wmGizmoGroup *mgroup = mpr->parent_mgroup; PointerRNA mpr_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); /* RNA_struct_find_function(&mpr_ptr, "test_select"); */ - func = &rna_Manipulator_test_select_func; + func = &rna_Gizmo_test_select_func; RNA_parameter_list_create(&list, &mpr_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); @@ -134,19 +134,19 @@ static int rna_manipulator_test_select_cb( return intersect_id; } -static int rna_manipulator_modal_cb( - struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event, - eWM_ManipulatorTweak tweak_flag) +static int rna_gizmo_modal_cb( + struct bContext *C, struct wmGizmo *mpr, const struct wmEvent *event, + eWM_GizmoFlagTweak tweak_flag) { - extern FunctionRNA rna_Manipulator_modal_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + extern FunctionRNA rna_Gizmo_modal_func; + wmGizmoGroup *mgroup = mpr->parent_mgroup; PointerRNA mpr_ptr; ParameterList list; FunctionRNA *func; const int tweak_flag_int = tweak_flag; RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); /* RNA_struct_find_function(&mpr_ptr, "modal"); */ - func = &rna_Manipulator_modal_func; + func = &rna_Gizmo_modal_func; RNA_parameter_list_create(&list, &mpr_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); @@ -161,34 +161,34 @@ static int rna_manipulator_modal_cb( return ret_enum; } -static void rna_manipulator_setup_cb( - struct wmManipulator *mpr) +static void rna_gizmo_setup_cb( + struct wmGizmo *mpr) { - extern FunctionRNA rna_Manipulator_setup_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + extern FunctionRNA rna_Gizmo_setup_func; + wmGizmoGroup *mgroup = mpr->parent_mgroup; PointerRNA mpr_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); /* RNA_struct_find_function(&mpr_ptr, "setup"); */ - func = &rna_Manipulator_setup_func; + func = &rna_Gizmo_setup_func; RNA_parameter_list_create(&list, &mpr_ptr, func); mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); RNA_parameter_list_free(&list); } -static int rna_manipulator_invoke_cb( - struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event) +static int rna_gizmo_invoke_cb( + struct bContext *C, struct wmGizmo *mpr, const struct wmEvent *event) { - extern FunctionRNA rna_Manipulator_invoke_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + extern FunctionRNA rna_Gizmo_invoke_func; + wmGizmoGroup *mgroup = mpr->parent_mgroup; PointerRNA mpr_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); /* RNA_struct_find_function(&mpr_ptr, "invoke"); */ - func = &rna_Manipulator_invoke_func; + func = &rna_Gizmo_invoke_func; RNA_parameter_list_create(&list, &mpr_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); @@ -202,17 +202,17 @@ static int rna_manipulator_invoke_cb( return ret_enum; } -static void rna_manipulator_exit_cb( - struct bContext *C, struct wmManipulator *mpr, bool cancel) +static void rna_gizmo_exit_cb( + struct bContext *C, struct wmGizmo *mpr, bool cancel) { - extern FunctionRNA rna_Manipulator_exit_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + extern FunctionRNA rna_Gizmo_exit_func; + wmGizmoGroup *mgroup = mpr->parent_mgroup; PointerRNA mpr_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); /* RNA_struct_find_function(&mpr_ptr, "exit"); */ - func = &rna_Manipulator_exit_func; + func = &rna_Gizmo_exit_func; RNA_parameter_list_create(&list, &mpr_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); { @@ -223,17 +223,17 @@ static void rna_manipulator_exit_cb( RNA_parameter_list_free(&list); } -static void rna_manipulator_select_refresh_cb( - struct wmManipulator *mpr) +static void rna_gizmo_select_refresh_cb( + struct wmGizmo *mpr) { - extern FunctionRNA rna_Manipulator_select_refresh_func; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; + extern FunctionRNA rna_Gizmo_select_refresh_func; + wmGizmoGroup *mgroup = mpr->parent_mgroup; PointerRNA mpr_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); /* RNA_struct_find_function(&mpr_ptr, "select_refresh"); */ - func = &rna_Manipulator_select_refresh_func; + func = &rna_Gizmo_select_refresh_func; RNA_parameter_list_create(&list, &mpr_ptr, func); mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); RNA_parameter_list_free(&list); @@ -242,9 +242,9 @@ static void rna_manipulator_select_refresh_cb( #endif /* WITH_PYTHON */ /* just to work around 'const char *' warning and to ensure this is a python op */ -static void rna_Manipulator_bl_idname_set(PointerRNA *ptr, const char *value) +static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value) { - wmManipulator *data = ptr->data; + wmGizmo *data = ptr->data; char *str = (char *)data->type->idname; if (!str[0]) { BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ @@ -254,7 +254,7 @@ static void rna_Manipulator_bl_idname_set(PointerRNA *ptr, const char *value) } } -static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr) +static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr) { #if 0 wmWindowManager *wm = ptr->id.data; @@ -265,13 +265,13 @@ static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr) IDProperty *properties = ptr->data; for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->manipulator_map) { - wmManipulatorMap *mmap = ar->manipulator_map; - for (wmManipulatorGroup *mgroup = WM_manipulatormap_group_list(mmap)->first; + if (ar->gizmo_map) { + wmGizmoMap *mmap = ar->gizmo_map; + for (wmGizmoGroup *mgroup = WM_gizmomap_group_list(mmap)->first; mgroup; mgroup = mgroup->next) { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { if (mpr->properties == properties) { return mpr; } @@ -284,9 +284,9 @@ static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr) return NULL; } -static StructRNA *rna_ManipulatorProperties_refine(PointerRNA *ptr) +static StructRNA *rna_GizmoProperties_refine(PointerRNA *ptr) { - wmManipulator *mpr = rna_ManipulatorProperties_find_operator(ptr); + wmGizmo *mpr = rna_GizmoProperties_find_operator(ptr); if (mpr) return mpr->type->srna; @@ -294,143 +294,143 @@ static StructRNA *rna_ManipulatorProperties_refine(PointerRNA *ptr) return ptr->type; } -static IDProperty *rna_ManipulatorProperties_idprops(PointerRNA *ptr, bool create) +static IDProperty *rna_GizmoProperties_idprops(PointerRNA *ptr, bool create) { if (create && !ptr->data) { IDPropertyTemplate val = {0}; - ptr->data = IDP_New(IDP_GROUP, &val, "RNA_ManipulatorProperties group"); + ptr->data = IDP_New(IDP_GROUP, &val, "RNA_GizmoProperties group"); } return ptr->data; } -static PointerRNA rna_Manipulator_properties_get(PointerRNA *ptr) +static PointerRNA rna_Gizmo_properties_get(PointerRNA *ptr) { - wmManipulator *mpr = ptr->data; + wmGizmo *mpr = ptr->data; return rna_pointer_inherit_refine(ptr, mpr->type->srna, mpr->properties); } -/* wmManipulator.float */ -#define RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(func_id, member_id) \ -static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +/* wmGizmo.float */ +#define RNA_GIZMO_GENERIC_FLOAT_RW_DEF(func_id, member_id) \ +static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ return mpr->member_id; \ } \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ mpr->member_id = value; \ } -#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \ -static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +#define RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \ +static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ return mpr->member_id[index]; \ } \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ mpr->member_id[index] = value; \ } -/* wmManipulator.float[len] */ -#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \ -static void rna_Manipulator_##func_id##_get(PointerRNA *ptr, float value[len]) \ +/* wmGizmo.float[len] */ +#define RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \ +static void rna_Gizmo_##func_id##_get(PointerRNA *ptr, float value[len]) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ memcpy(value, mpr->member_id, sizeof(float[len])); \ } \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, const float value[len]) \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, const float value[len]) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ memcpy(mpr->member_id, value, sizeof(float[len])); \ } -/* wmManipulator.flag */ -#define RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \ -static bool rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +/* wmGizmo.flag */ +#define RNA_GIZMO_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \ +static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ return (mpr->member_id & flag_value) != 0; \ } \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, bool value) \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ SET_FLAG_FROM_TEST(mpr->member_id, value, flag_value); \ } -/* wmManipulator.flag (negative) */ -#define RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \ -static bool rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +/* wmGizmo.flag (negative) */ +#define RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \ +static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ return (mpr->member_id & flag_value) == 0; \ } \ -static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, bool value) \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ SET_FLAG_FROM_TEST(mpr->member_id, !value, flag_value); \ } -#define RNA_MANIPULATOR_FLAG_RO_DEF(func_id, member_id, flag_value) \ -static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +#define RNA_GIZMO_FLAG_RO_DEF(func_id, member_id, flag_value) \ +static int rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmManipulator *mpr = ptr->data; \ + wmGizmo *mpr = ptr->data; \ return (mpr->member_id & flag_value) != 0; \ } -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16); -RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16); -static void rna_Manipulator_matrix_world_get(PointerRNA *ptr, float value[16]) +static void rna_Gizmo_matrix_world_get(PointerRNA *ptr, float value[16]) { - wmManipulator *mpr = ptr->data; - WM_manipulator_calc_matrix_final(mpr, (float (*)[4])value); + wmGizmo *mpr = ptr->data; + WM_gizmo_calc_matrix_final(mpr, (float (*)[4])value); } -RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis); -RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(line_width, line_width); +RNA_GIZMO_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis); +RNA_GIZMO_GENERIC_FLOAT_RW_DEF(line_width, line_width); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_MANIPULATOR_DRAW_HOVER); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_MANIPULATOR_DRAW_MODAL); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_MANIPULATOR_DRAW_VALUE); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE); -RNA_MANIPULATOR_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_MANIPULATOR_DRAW_OFFSET_SCALE); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_MANIPULATOR_GRAB_CURSOR); -RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_MANIPULATOR_SELECT_BACKGROUND); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_GIZMO_DRAW_HOVER); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_GIZMO_DRAW_MODAL); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_GIZMO_DRAW_VALUE); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE); +RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_GRAB_CURSOR); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND); -/* wmManipulator.state */ -RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT); -RNA_MANIPULATOR_FLAG_RO_DEF(state_is_modal, state, WM_MANIPULATOR_STATE_MODAL); -RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT); +/* wmGizmo.state */ +RNA_GIZMO_FLAG_RO_DEF(state_is_highlight, state, WM_GIZMO_STATE_HIGHLIGHT); +RNA_GIZMO_FLAG_RO_DEF(state_is_modal, state, WM_GIZMO_STATE_MODAL); +RNA_GIZMO_FLAG_RO_DEF(state_select, state, WM_GIZMO_STATE_SELECT); -static void rna_Manipulator_state_select_set(struct PointerRNA *ptr, bool value) +static void rna_Gizmo_state_select_set(struct PointerRNA *ptr, bool value) { - wmManipulator *mpr = ptr->data; - wmManipulatorGroup *mgroup = mpr->parent_mgroup; - WM_manipulator_select_set(mgroup->parent_mmap, mpr, value); + wmGizmo *mpr = ptr->data; + wmGizmoGroup *mgroup = mpr->parent_mgroup; + WM_gizmo_select_set(mgroup->parent_mmap, mpr, value); } -static PointerRNA rna_Manipulator_group_get(PointerRNA *ptr) +static PointerRNA rna_Gizmo_group_get(PointerRNA *ptr) { - wmManipulator *mpr = ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_ManipulatorGroup, mpr->parent_mgroup); + wmGizmo *mpr = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_GizmoGroup, mpr->parent_mgroup); } #ifdef WITH_PYTHON -static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type); -void BPY_RNA_manipulator_wrapper(wmManipulatorType *wgt, void *userdata); +static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type); +void BPY_RNA_gizmo_wrapper(wmGizmoType *wgt, void *userdata); -static StructRNA *rna_Manipulator_register( +static StructRNA *rna_Gizmo_register( Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { @@ -438,17 +438,17 @@ static StructRNA *rna_Manipulator_register( char idname[MAX_NAME]; } temp_buffers; - wmManipulatorType dummywt = {NULL}; - wmManipulator dummymnp = {NULL}; + wmGizmoType dummywt = {NULL}; + wmGizmo dummymnp = {NULL}; PointerRNA mnp_ptr; /* Two sets of functions. */ int have_function[8]; - /* setup dummy manipulator & manipulator type to store static properties in */ + /* setup dummy gizmo & gizmo type to store static properties in */ dummymnp.type = &dummywt; dummywt.idname = temp_buffers.idname; - RNA_pointer_create(NULL, &RNA_Manipulator, &dummymnp, &mnp_ptr); + RNA_pointer_create(NULL, &RNA_Gizmo, &dummymnp, &mnp_ptr); /* Clear so we can detect if it's left unset. */ temp_buffers.idname[0] = '\0'; @@ -458,16 +458,16 @@ static StructRNA *rna_Manipulator_register( return NULL; if (strlen(identifier) >= sizeof(temp_buffers.idname)) { - BKE_reportf(reports, RPT_ERROR, "Registering manipulator class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering gizmo class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(temp_buffers.idname)); return NULL; } - /* check if we have registered this manipulator type before, and remove it */ + /* check if we have registered this gizmo type before, and remove it */ { - const wmManipulatorType *wt = WM_manipulatortype_find(dummywt.idname, true); + const wmGizmoType *wt = WM_gizmotype_find(dummywt.idname, true); if (wt && wt->ext.srna) { - rna_Manipulator_unregister(bmain, wt->ext.srna); + rna_Gizmo_unregister(bmain, wt->ext.srna); } } if (!RNA_struct_available_or_report(reports, dummywt.idname)) { @@ -475,13 +475,13 @@ static StructRNA *rna_Manipulator_register( } { /* allocate the idname */ - /* For multiple strings see ManipulatorGroup. */ + /* For multiple strings see GizmoGroup. */ dummywt.idname = BLI_strdup(temp_buffers.idname); } - /* create a new manipulator type */ - dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Manipulator); - /* manipulator properties are registered separately */ + /* create a new gizmo type */ + dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Gizmo); + /* gizmo properties are registered separately */ RNA_def_struct_flag(dummywt.ext.srna, STRUCT_NO_IDPROPERTIES); dummywt.ext.data = data; dummywt.ext.call = call; @@ -489,21 +489,21 @@ static StructRNA *rna_Manipulator_register( { int i = 0; - dummywt.draw = (have_function[i++]) ? rna_manipulator_draw_cb : NULL; - dummywt.draw_select = (have_function[i++]) ? rna_manipulator_draw_select_cb : NULL; - dummywt.test_select = (have_function[i++]) ? rna_manipulator_test_select_cb : NULL; - dummywt.modal = (have_function[i++]) ? rna_manipulator_modal_cb : NULL; -// dummywt.property_update = (have_function[i++]) ? rna_manipulator_property_update : NULL; -// dummywt.position_get = (have_function[i++]) ? rna_manipulator_position_get : NULL; - dummywt.setup = (have_function[i++]) ? rna_manipulator_setup_cb : NULL; - dummywt.invoke = (have_function[i++]) ? rna_manipulator_invoke_cb : NULL; - dummywt.exit = (have_function[i++]) ? rna_manipulator_exit_cb : NULL; - dummywt.select_refresh = (have_function[i++]) ? rna_manipulator_select_refresh_cb : NULL; + dummywt.draw = (have_function[i++]) ? rna_gizmo_draw_cb : NULL; + dummywt.draw_select = (have_function[i++]) ? rna_gizmo_draw_select_cb : NULL; + dummywt.test_select = (have_function[i++]) ? rna_gizmo_test_select_cb : NULL; + dummywt.modal = (have_function[i++]) ? rna_gizmo_modal_cb : NULL; +// dummywt.property_update = (have_function[i++]) ? rna_gizmo_property_update : NULL; +// dummywt.position_get = (have_function[i++]) ? rna_gizmo_position_get : NULL; + dummywt.setup = (have_function[i++]) ? rna_gizmo_setup_cb : NULL; + dummywt.invoke = (have_function[i++]) ? rna_gizmo_invoke_cb : NULL; + dummywt.exit = (have_function[i++]) ? rna_gizmo_exit_cb : NULL; + dummywt.select_refresh = (have_function[i++]) ? rna_gizmo_select_refresh_cb : NULL; BLI_assert(i == ARRAY_SIZE(have_function)); } - WM_manipulatortype_append_ptr(BPY_RNA_manipulator_wrapper, (void *)&dummywt); + WM_gizmotype_append_ptr(BPY_RNA_gizmo_wrapper, (void *)&dummywt); /* update while blender is running */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); @@ -511,9 +511,9 @@ static StructRNA *rna_Manipulator_register( return dummywt.ext.srna; } -static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type) +static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type) { - wmManipulatorType *wt = RNA_struct_blender_type_get(type); + wmGizmoType *wt = RNA_struct_blender_type_get(type); if (!wt) return; @@ -523,71 +523,71 @@ static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type) WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - WM_manipulatortype_remove_ptr(NULL, bmain, wt); + WM_gizmotype_remove_ptr(NULL, bmain, wt); } -static void **rna_Manipulator_instance(PointerRNA *ptr) +static void **rna_Gizmo_instance(PointerRNA *ptr) { - wmManipulator *mpr = ptr->data; + wmGizmo *mpr = ptr->data; return &mpr->py_instance; } #endif /* WITH_PYTHON */ -static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr) +static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr) { - wmManipulator *mpr = mnp_ptr->data; - return (mpr->type && mpr->type->ext.srna) ? mpr->type->ext.srna : &RNA_Manipulator; + wmGizmo *mpr = mnp_ptr->data; + return (mpr->type && mpr->type->ext.srna) ? mpr->type->ext.srna : &RNA_Gizmo; } /** \} */ -/** \name Manipulator Group API +/** \name Gizmo Group API * \{ */ -static wmManipulator *rna_ManipulatorGroup_manipulator_new( - wmManipulatorGroup *mgroup, ReportList *reports, const char *idname) +static wmGizmo *rna_GizmoGroup_gizmo_new( + wmGizmoGroup *mgroup, ReportList *reports, const char *idname) { - const wmManipulatorType *wt = WM_manipulatortype_find(idname, true); + const wmGizmoType *wt = WM_gizmotype_find(idname, true); if (wt == NULL) { - BKE_reportf(reports, RPT_ERROR, "ManipulatorType '%s' not known", idname); + BKE_reportf(reports, RPT_ERROR, "GizmoType '%s' not known", idname); return NULL; } - wmManipulator *mpr = WM_manipulator_new_ptr(wt, mgroup, NULL); + wmGizmo *mpr = WM_gizmo_new_ptr(wt, mgroup, NULL); return mpr; } -static void rna_ManipulatorGroup_manipulator_remove( - wmManipulatorGroup *mgroup, bContext *C, wmManipulator *mpr) +static void rna_GizmoGroup_gizmo_remove( + wmGizmoGroup *mgroup, bContext *C, wmGizmo *mpr) { - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C); + WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, mpr, C); } -static void rna_ManipulatorGroup_manipulator_clear( - wmManipulatorGroup *mgroup, bContext *C) +static void rna_GizmoGroup_gizmo_clear( + wmGizmoGroup *mgroup, bContext *C) { - while (mgroup->manipulators.first) { - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mgroup->manipulators.first, C); + while (mgroup->gizmos.first) { + WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, mgroup->gizmos.first, C); } } -static void rna_ManipulatorGroup_name_get(PointerRNA *ptr, char *value) +static void rna_GizmoGroup_name_get(PointerRNA *ptr, char *value) { - wmManipulatorGroup *mgroup = ptr->data; + wmGizmoGroup *mgroup = ptr->data; strcpy(value, mgroup->type->name); } -static int rna_ManipulatorGroup_name_length(PointerRNA *ptr) +static int rna_GizmoGroup_name_length(PointerRNA *ptr) { - wmManipulatorGroup *mgroup = ptr->data; + wmGizmoGroup *mgroup = ptr->data; return strlen(mgroup->type->name); } /* just to work around 'const char *' warning and to ensure this is a python op */ -static void rna_ManipulatorGroup_bl_idname_set(PointerRNA *ptr, const char *value) +static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value) { - wmManipulatorGroup *data = ptr->data; + wmGizmoGroup *data = ptr->data; char *str = (char *)data->type->idname; if (!str[0]) BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ @@ -595,9 +595,9 @@ static void rna_ManipulatorGroup_bl_idname_set(PointerRNA *ptr, const char *valu assert(!"setting the bl_idname on a non-builtin operator"); } -static void rna_ManipulatorGroup_bl_label_set(PointerRNA *ptr, const char *value) +static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value) { - wmManipulatorGroup *data = ptr->data; + wmGizmoGroup *data = ptr->data; char *str = (char *)data->type->name; if (!str[0]) BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ @@ -605,18 +605,18 @@ static void rna_ManipulatorGroup_bl_label_set(PointerRNA *ptr, const char *value assert(!"setting the bl_label on a non-builtin operator"); } -static bool rna_ManipulatorGroup_has_reports_get(PointerRNA *ptr) +static bool rna_GizmoGroup_has_reports_get(PointerRNA *ptr) { - wmManipulatorGroup *mgroup = ptr->data; + wmGizmoGroup *mgroup = ptr->data; return (mgroup->reports && mgroup->reports->list.first); } #ifdef WITH_PYTHON -static bool rna_manipulatorgroup_poll_cb(const bContext *C, wmManipulatorGroupType *wgt) +static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *wgt) { - extern FunctionRNA rna_ManipulatorGroup_poll_func; + extern FunctionRNA rna_GizmoGroup_poll_func; PointerRNA ptr; ParameterList list; @@ -625,7 +625,7 @@ static bool rna_manipulatorgroup_poll_cb(const bContext *C, wmManipulatorGroupTy int visible; RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ - func = &rna_ManipulatorGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ + func = &rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); @@ -639,16 +639,16 @@ static bool rna_manipulatorgroup_poll_cb(const bContext *C, wmManipulatorGroupTy return visible; } -static void rna_manipulatorgroup_setup_cb(const bContext *C, wmManipulatorGroup *mgroup) +static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *mgroup) { - extern FunctionRNA rna_ManipulatorGroup_setup_func; + extern FunctionRNA rna_GizmoGroup_setup_func; PointerRNA mgroup_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); - func = &rna_ManipulatorGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */ + func = &rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */ RNA_parameter_list_create(&list, &mgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); @@ -657,9 +657,9 @@ static void rna_manipulatorgroup_setup_cb(const bContext *C, wmManipulatorGroup RNA_parameter_list_free(&list); } -static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupType *wgt, wmKeyConfig *config) +static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *wgt, wmKeyConfig *config) { - extern FunctionRNA rna_ManipulatorGroup_setup_keymap_func; + extern FunctionRNA rna_GizmoGroup_setup_keymap_func; void *ret; PointerRNA ptr; @@ -667,7 +667,7 @@ static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupTy FunctionRNA *func; RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ - func = &rna_ManipulatorGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */ + func = &rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "keyconfig", &config); @@ -681,16 +681,16 @@ static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupTy return keymap; } -static void rna_manipulatorgroup_refresh_cb(const bContext *C, wmManipulatorGroup *mgroup) +static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *mgroup) { - extern FunctionRNA rna_ManipulatorGroup_refresh_func; + extern FunctionRNA rna_GizmoGroup_refresh_func; PointerRNA mgroup_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); - func = &rna_ManipulatorGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */ + func = &rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */ RNA_parameter_list_create(&list, &mgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); @@ -699,16 +699,16 @@ static void rna_manipulatorgroup_refresh_cb(const bContext *C, wmManipulatorGrou RNA_parameter_list_free(&list); } -static void rna_manipulatorgroup_draw_prepare_cb(const bContext *C, wmManipulatorGroup *mgroup) +static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *mgroup) { - extern FunctionRNA rna_ManipulatorGroup_draw_prepare_func; + extern FunctionRNA rna_GizmoGroup_draw_prepare_func; PointerRNA mgroup_ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); - func = &rna_ManipulatorGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */ + func = &rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */ RNA_parameter_list_create(&list, &mgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); @@ -717,10 +717,10 @@ static void rna_manipulatorgroup_draw_prepare_cb(const bContext *C, wmManipulato RNA_parameter_list_free(&list); } -void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata); -static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type); +void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *wgt, void *userdata); +static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type); -static StructRNA *rna_ManipulatorGroup_register( +static StructRNA *rna_GizmoGroup_register( Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { @@ -729,19 +729,19 @@ static StructRNA *rna_ManipulatorGroup_register( char idname[MAX_NAME]; } temp_buffers; - wmManipulatorGroupType dummywgt = {NULL}; - wmManipulatorGroup dummywg = {NULL}; + wmGizmoGroupType dummywgt = {NULL}; + wmGizmoGroup dummywg = {NULL}; PointerRNA wgptr; /* Two sets of functions. */ int have_function[5]; - /* setup dummy manipulatorgroup & manipulatorgroup type to store static properties in */ + /* setup dummy gizmogroup & gizmogroup type to store static properties in */ dummywg.type = &dummywgt; dummywgt.name = temp_buffers.name; dummywgt.idname = temp_buffers.idname; - RNA_pointer_create(NULL, &RNA_ManipulatorGroup, &dummywg, &wgptr); + RNA_pointer_create(NULL, &RNA_GizmoGroup, &dummywg, &wgptr); /* Clear so we can detect if it's left unset. */ temp_buffers.idname[0] = temp_buffers.name[0] = '\0'; @@ -751,28 +751,28 @@ static StructRNA *rna_ManipulatorGroup_register( return NULL; if (strlen(identifier) >= sizeof(temp_buffers.idname)) { - BKE_reportf(reports, RPT_ERROR, "Registering manipulatorgroup class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering gizmogroup class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(temp_buffers.idname)); return NULL; } /* check if the area supports widgets */ - const struct wmManipulatorMapType_Params wmap_params = { + const struct wmGizmoMapType_Params wmap_params = { .spaceid = dummywgt.mmap_params.spaceid, .regionid = dummywgt.mmap_params.regionid, }; - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wmap_params); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wmap_params); if (mmap_type == NULL) { - BKE_reportf(reports, RPT_ERROR, "Area type does not support manipulators"); + BKE_reportf(reports, RPT_ERROR, "Area type does not support gizmos"); return NULL; } - /* check if we have registered this manipulatorgroup type before, and remove it */ + /* check if we have registered this gizmogroup type before, and remove it */ { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(dummywgt.idname, true); if (wgt && wgt->ext.srna) { - rna_ManipulatorGroup_unregister(bmain, wgt->ext.srna); + rna_GizmoGroup_unregister(bmain, wgt->ext.srna); } } if (!RNA_struct_available_or_report(reports, dummywgt.idname)) { @@ -792,23 +792,23 @@ static StructRNA *rna_ManipulatorGroup_register( BLI_assert(ARRAY_SIZE(strings) == 2); } - /* create a new manipulatorgroup type */ - dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_ManipulatorGroup); - RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* manipulatorgroup properties are registered separately */ + /* create a new gizmogroup type */ + dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_GizmoGroup); + RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* gizmogroup properties are registered separately */ dummywgt.ext.data = data; dummywgt.ext.call = call; dummywgt.ext.free = free; /* We used to register widget group types like this, now we do it similar to * operator types. Thus we should be able to do the same as operator types now. */ - dummywgt.poll = (have_function[0]) ? rna_manipulatorgroup_poll_cb : NULL; - dummywgt.setup_keymap = (have_function[1]) ? rna_manipulatorgroup_setup_keymap_cb : NULL; - dummywgt.setup = (have_function[2]) ? rna_manipulatorgroup_setup_cb : NULL; - dummywgt.refresh = (have_function[3]) ? rna_manipulatorgroup_refresh_cb : NULL; - dummywgt.draw_prepare = (have_function[4]) ? rna_manipulatorgroup_draw_prepare_cb : NULL; + dummywgt.poll = (have_function[0]) ? rna_gizmogroup_poll_cb : NULL; + dummywgt.setup_keymap = (have_function[1]) ? rna_gizmogroup_setup_keymap_cb : NULL; + dummywgt.setup = (have_function[2]) ? rna_gizmogroup_setup_cb : NULL; + dummywgt.refresh = (have_function[3]) ? rna_gizmogroup_refresh_cb : NULL; + dummywgt.draw_prepare = (have_function[4]) ? rna_gizmogroup_draw_prepare_cb : NULL; - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr( - BPY_RNA_manipulatorgroup_wrapper, (void *)&dummywgt); + wmGizmoGroupType *wgt = WM_gizmogrouptype_append_ptr( + BPY_RNA_gizmogroup_wrapper, (void *)&dummywgt); { const char *owner_id = RNA_struct_state_owner_get(); @@ -817,8 +817,8 @@ static StructRNA *rna_ManipulatorGroup_register( } } - if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) { - WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); + if (wgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { + WM_gizmo_group_type_add_ptr_ex(wgt, mmap_type); /* update while blender is running */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); @@ -827,9 +827,9 @@ static StructRNA *rna_ManipulatorGroup_register( return dummywgt.ext.srna; } -static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type) +static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type) { - wmManipulatorGroupType *wgt = RNA_struct_blender_type_get(type); + wmGizmoGroupType *wgt = RNA_struct_blender_type_get(type); if (!wgt) return; @@ -839,27 +839,27 @@ static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type) WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - WM_manipulator_group_type_remove_ptr(bmain, wgt); + WM_gizmo_group_type_remove_ptr(bmain, wgt); } -static void **rna_ManipulatorGroup_instance(PointerRNA *ptr) +static void **rna_GizmoGroup_instance(PointerRNA *ptr) { - wmManipulatorGroup *mgroup = ptr->data; + wmGizmoGroup *mgroup = ptr->data; return &mgroup->py_instance; } #endif /* WITH_PYTHON */ -static StructRNA *rna_ManipulatorGroup_refine(PointerRNA *mgroup_ptr) +static StructRNA *rna_GizmoGroup_refine(PointerRNA *mgroup_ptr) { - wmManipulatorGroup *mgroup = mgroup_ptr->data; - return (mgroup->type && mgroup->type->ext.srna) ? mgroup->type->ext.srna : &RNA_ManipulatorGroup; + wmGizmoGroup *mgroup = mgroup_ptr->data; + return (mgroup->type && mgroup->type->ext.srna) ? mgroup->type->ext.srna : &RNA_GizmoGroup; } -static void rna_ManipulatorGroup_manipulators_begin(CollectionPropertyIterator *iter, PointerRNA *mgroup_ptr) +static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *mgroup_ptr) { - wmManipulatorGroup *mgroup = mgroup_ptr->data; - rna_iterator_listbase_begin(iter, &mgroup->manipulators, NULL); + wmGizmoGroup *mgroup = mgroup_ptr->data; + rna_iterator_listbase_begin(iter, &mgroup->gizmos, NULL); } /** \} */ @@ -868,40 +868,40 @@ static void rna_ManipulatorGroup_manipulators_begin(CollectionPropertyIterator * #else /* RNA_RUNTIME */ -/* ManipulatorGroup.manipulators */ -static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop) +/* GizmoGroup.gizmos */ +static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - RNA_def_property_srna(cprop, "Manipulators"); - srna = RNA_def_struct(brna, "Manipulators", NULL); - RNA_def_struct_sdna(srna, "wmManipulatorGroup"); - RNA_def_struct_ui_text(srna, "Manipulators", "Collection of manipulators"); + RNA_def_property_srna(cprop, "Gizmos"); + srna = RNA_def_struct(brna, "Gizmos", NULL); + RNA_def_struct_sdna(srna, "wmGizmoGroup"); + RNA_def_struct_ui_text(srna, "Gizmos", "Collection of gizmos"); - func = RNA_def_function(srna, "new", "rna_ManipulatorGroup_manipulator_new"); - RNA_def_function_ui_description(func, "Add manipulator"); + func = RNA_def_function(srna, "new", "rna_GizmoGroup_gizmo_new"); + RNA_def_function_ui_description(func, "Add gizmo"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_string(func, "type", "Type", 0, "", "Manipulator identifier"); /* optional */ - parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator"); + RNA_def_string(func, "type", "Type", 0, "", "Gizmo identifier"); /* optional */ + parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo"); RNA_def_function_return(func, parm); - func = RNA_def_function(srna, "remove", "rna_ManipulatorGroup_manipulator_remove"); + func = RNA_def_function(srna, "remove", "rna_GizmoGroup_gizmo_remove"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); - RNA_def_function_ui_description(func, "Delete manipulator"); - parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator"); + RNA_def_function_ui_description(func, "Delete gizmo"); + parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); - func = RNA_def_function(srna, "clear", "rna_ManipulatorGroup_manipulator_clear"); + func = RNA_def_function(srna, "clear", "rna_GizmoGroup_gizmo_clear"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); - RNA_def_function_ui_description(func, "Delete all manipulators"); + RNA_def_function_ui_description(func, "Delete all gizmos"); } -static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; PropertyRNA *prop; @@ -909,26 +909,26 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) FunctionRNA *func; PropertyRNA *parm; - RNA_def_property_srna(cprop, "Manipulator"); - srna = RNA_def_struct(brna, "Manipulator", NULL); - RNA_def_struct_sdna(srna, "wmManipulator"); - RNA_def_struct_ui_text(srna, "Manipulator", "Collection of manipulators"); - RNA_def_struct_refine_func(srna, "rna_Manipulator_refine"); + RNA_def_property_srna(cprop, "Gizmo"); + srna = RNA_def_struct(brna, "Gizmo", NULL); + RNA_def_struct_sdna(srna, "wmGizmo"); + RNA_def_struct_ui_text(srna, "Gizmo", "Collection of gizmos"); + RNA_def_struct_refine_func(srna, "rna_Gizmo_refine"); #ifdef WITH_PYTHON RNA_def_struct_register_funcs( srna, - "rna_Manipulator_register", - "rna_Manipulator_unregister", - "rna_Manipulator_instance"); + "rna_Gizmo_register", + "rna_Gizmo_unregister", + "rna_Gizmo_instance"); #endif RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "ManipulatorProperties"); + RNA_def_property_struct_type(prop, "GizmoProperties"); RNA_def_property_ui_text(prop, "Properties", ""); - RNA_def_property_pointer_funcs(prop, "rna_Manipulator_properties_get", NULL, NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_Gizmo_properties_get", NULL, NULL, NULL); /* -------------------------------------------------------------------- */ /* Registerable Variables */ @@ -938,20 +938,20 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->idname"); RNA_def_property_string_maxlength(prop, MAX_NAME); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Manipulator_bl_idname_set"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Gizmo_bl_idname_set"); /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ RNA_def_property_flag(prop, PROP_REGISTER); RNA_define_verify_sdna(1); /* not in sdna */ - /* wmManipulator.draw */ + /* wmGizmo.draw */ func = RNA_def_function(srna, "draw", NULL); RNA_def_function_ui_description(func, ""); RNA_def_function_flag(func, FUNC_REGISTER); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - /* wmManipulator.draw_select */ + /* wmGizmo.draw_select */ func = RNA_def_function(srna, "draw_select", NULL); RNA_def_function_ui_description(func, ""); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); @@ -959,7 +959,7 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX); - /* wmManipulator.test_select */ + /* wmGizmo.test_select */ func = RNA_def_function(srna, "test_select", NULL); RNA_def_function_ui_description(func, ""); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); @@ -970,10 +970,10 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_int(func, "intersect_id", 0, 0, INT_MAX, "", "", 0, INT_MAX); RNA_def_function_return(func, parm); - /* wmManipulator.handler */ + /* wmGizmo.handler */ static EnumPropertyItem tweak_actions[] = { - {WM_MANIPULATOR_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""}, - {WM_MANIPULATOR_TWEAK_SNAP, "SNAP", 0, "Snap", ""}, + {WM_GIZMO_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""}, + {WM_GIZMO_TWEAK_SNAP, "SNAP", 0, "Snap", ""}, {0, NULL, 0, NULL, NULL} }; func = RNA_def_function(srna, "modal", NULL); @@ -988,15 +988,15 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", ""); RNA_def_function_return(func, parm); - /* wmManipulator.property_update */ + /* wmGizmo.property_update */ /* TODO */ - /* wmManipulator.setup */ + /* wmGizmo.setup */ func = RNA_def_function(srna, "setup", NULL); RNA_def_function_ui_description(func, ""); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - /* wmManipulator.invoke */ + /* wmGizmo.invoke */ func = RNA_def_function(srna, "invoke", NULL); RNA_def_function_ui_description(func, ""); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); @@ -1007,7 +1007,7 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", ""); RNA_def_function_return(func, parm); - /* wmManipulator.exit */ + /* wmGizmo.exit */ func = RNA_def_function(srna, "exit", NULL); RNA_def_function_ui_description(func, ""); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); @@ -1016,10 +1016,10 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - /* wmManipulator.cursor_get */ + /* wmGizmo.cursor_get */ /* TODO */ - /* wmManipulator.select_refresh */ + /* wmGizmo.select_refresh */ func = RNA_def_function(srna, "select_refresh", NULL); RNA_def_function_ui_description(func, ""); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); @@ -1030,146 +1030,146 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_struct_type(prop, "ManipulatorGroup"); - RNA_def_property_pointer_funcs(prop, "rna_Manipulator_group_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "", "Manipulator group this manipulator is a member of"); + RNA_def_property_struct_type(prop, "GizmoGroup"); + RNA_def_property_pointer_funcs(prop, "rna_Gizmo_group_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "", "Gizmo group this gizmo is a member of"); /* Color & Alpha */ prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); - RNA_def_property_float_funcs(prop, "rna_Manipulator_color_get", "rna_Manipulator_color_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_color_get", "rna_Gizmo_color_set", NULL); prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text(prop, "Alpha", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_get", "rna_Manipulator_alpha_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_get", "rna_Gizmo_alpha_set", NULL); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); /* Color & Alpha (highlight) */ prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); - RNA_def_property_float_funcs(prop, "rna_Manipulator_color_hi_get", "rna_Manipulator_color_hi_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_color_hi_get", "rna_Gizmo_color_hi_set", NULL); prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text(prop, "Alpha", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_hi_get", "rna_Manipulator_alpha_hi_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_hi_get", "rna_Gizmo_alpha_hi_set", NULL); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(prop, "Space Matrix", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_space_get", "rna_Manipulator_matrix_space_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_space_get", "rna_Gizmo_matrix_space_set", NULL); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(prop, "Basis Matrix", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_basis_get", "rna_Manipulator_matrix_basis_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_basis_get", "rna_Gizmo_matrix_basis_set", NULL); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(prop, "Offset Matrix", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_offset_get", "rna_Manipulator_matrix_offset_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_offset_get", "rna_Gizmo_matrix_offset_set", NULL); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(prop, "Final World Matrix", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_world_get", NULL, NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_world_get", NULL, NULL); prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text(prop, "Scale Basis", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_scale_basis_get", "rna_Manipulator_scale_basis_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_scale_basis_get", "rna_Gizmo_scale_basis_set", NULL); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL); RNA_def_property_ui_text(prop, "Line Width", ""); - RNA_def_property_float_funcs(prop, "rna_Manipulator_line_width_get", "rna_Manipulator_line_width_set", NULL); + RNA_def_property_float_funcs(prop, "rna_Gizmo_line_width_get", "rna_Gizmo_line_width_set", NULL); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* wmManipulator.flag */ - /* WM_MANIPULATOR_HIDDEN */ + /* wmGizmo.flag */ + /* WM_GIZMO_HIDDEN */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_hide_get", "rna_Manipulator_flag_hide_set"); + prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set"); RNA_def_property_ui_text(prop, "Hide", ""); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_GRAB_CURSOR */ + /* WM_GIZMO_GRAB_CURSOR */ prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_grab_cursor_get", "rna_Manipulator_flag_use_grab_cursor_set"); + prop, "rna_Gizmo_flag_use_grab_cursor_get", "rna_Gizmo_flag_use_grab_cursor_set"); RNA_def_property_ui_text(prop, "Grab Cursor", ""); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_HOVER */ + /* WM_GIZMO_DRAW_HOVER */ prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_hover_get", "rna_Manipulator_flag_use_draw_hover_set"); + prop, "rna_Gizmo_flag_use_draw_hover_get", "rna_Gizmo_flag_use_draw_hover_set"); RNA_def_property_ui_text(prop, "Draw Hover", ""); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_MODAL */ + /* WM_GIZMO_DRAW_MODAL */ prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_modal_get", "rna_Manipulator_flag_use_draw_modal_set"); + prop, "rna_Gizmo_flag_use_draw_modal_get", "rna_Gizmo_flag_use_draw_modal_set"); RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging"); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_VALUE */ + /* WM_GIZMO_DRAW_VALUE */ prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_value_get", "rna_Manipulator_flag_use_draw_value_set"); + prop, "rna_Gizmo_flag_use_draw_value_get", "rna_Gizmo_flag_use_draw_value_set"); RNA_def_property_ui_text(prop, "Draw Value", "Show an indicator for the current value while dragging"); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_OFFSET_SCALE */ + /* WM_GIZMO_DRAW_OFFSET_SCALE */ prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_offset_scale_get", "rna_Manipulator_flag_use_draw_offset_scale_set"); + prop, "rna_Gizmo_flag_use_draw_offset_scale_get", "rna_Gizmo_flag_use_draw_offset_scale_set"); RNA_def_property_ui_text(prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)"); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_DRAW_NO_SCALE (negated) */ + /* WM_GIZMO_DRAW_NO_SCALE (negated) */ prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_draw_scale_get", "rna_Manipulator_flag_use_draw_scale_set"); + prop, "rna_Gizmo_flag_use_draw_scale_get", "rna_Gizmo_flag_use_draw_scale_set"); RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix"); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* WM_MANIPULATOR_SELECT_BACKGROUND */ + /* WM_GIZMO_SELECT_BACKGROUND */ prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( - prop, "rna_Manipulator_flag_use_select_background_get", "rna_Manipulator_flag_use_select_background_set"); + prop, "rna_Gizmo_flag_use_select_background_get", "rna_Gizmo_flag_use_select_background_set"); RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer"); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); - /* wmManipulator.state (readonly) */ - /* WM_MANIPULATOR_STATE_HIGHLIGHT */ + /* wmGizmo.state (readonly) */ + /* WM_GIZMO_STATE_HIGHLIGHT */ prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_highlight_get", NULL); + RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_highlight_get", NULL); RNA_def_property_ui_text(prop, "Highlight", ""); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - /* WM_MANIPULATOR_STATE_MODAL */ + /* WM_GIZMO_STATE_MODAL */ prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_modal_get", NULL); + RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_modal_get", NULL); RNA_def_property_ui_text(prop, "Highlight", ""); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - /* WM_MANIPULATOR_STATE_SELECT */ + /* WM_GIZMO_STATE_SELECT */ /* (note that setting is involved, needs to handle array) */ prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_select_get", "rna_Manipulator_state_select_set"); + RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_select_get", "rna_Gizmo_state_select_set"); RNA_def_property_ui_text(prop, "Select", ""); - RNA_api_manipulator(srna); + RNA_api_gizmo(srna); - srna = RNA_def_struct(brna, "ManipulatorProperties", NULL); - RNA_def_struct_ui_text(srna, "Manipulator Properties", "Input properties of an Manipulator"); - RNA_def_struct_refine_func(srna, "rna_ManipulatorProperties_refine"); - RNA_def_struct_idprops_func(srna, "rna_ManipulatorProperties_idprops"); + srna = RNA_def_struct(brna, "GizmoProperties", NULL); + RNA_def_struct_ui_text(srna, "Gizmo Properties", "Input properties of an Gizmo"); + RNA_def_struct_refine_func(srna, "rna_GizmoProperties_refine"); + RNA_def_struct_idprops_func(srna, "rna_GizmoProperties_idprops"); RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); } -static void rna_def_manipulatorgroup(BlenderRNA *brna) +static void rna_def_gizmogroup(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -1177,16 +1177,16 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna) FunctionRNA *func; PropertyRNA *parm; - srna = RNA_def_struct(brna, "ManipulatorGroup", NULL); - RNA_def_struct_ui_text(srna, "ManipulatorGroup", "Storage of an operator being executed, or registered after execution"); - RNA_def_struct_sdna(srna, "wmManipulatorGroup"); - RNA_def_struct_refine_func(srna, "rna_ManipulatorGroup_refine"); + srna = RNA_def_struct(brna, "GizmoGroup", NULL); + RNA_def_struct_ui_text(srna, "GizmoGroup", "Storage of an operator being executed, or registered after execution"); + RNA_def_struct_sdna(srna, "wmGizmoGroup"); + RNA_def_struct_refine_func(srna, "rna_GizmoGroup_refine"); #ifdef WITH_PYTHON RNA_def_struct_register_funcs( srna, - "rna_ManipulatorGroup_register", - "rna_ManipulatorGroup_unregister", - "rna_ManipulatorGroup_instance"); + "rna_GizmoGroup_register", + "rna_GizmoGroup_unregister", + "rna_GizmoGroup_instance"); #endif RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); @@ -1198,14 +1198,14 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna) prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->idname"); RNA_def_property_string_maxlength(prop, MAX_NAME); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_idname_set"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GizmoGroup_bl_idname_set"); RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_struct_name_property(srna, prop); prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->name"); RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */ - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_label_set"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GizmoGroup_bl_label_set"); /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ RNA_def_property_flag(prop, PROP_REGISTER); @@ -1226,24 +1226,24 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); /* bl_options */ - static EnumPropertyItem manipulatorgroup_flag_items[] = { - {WM_MANIPULATORGROUPTYPE_3D, "3D", 0, "3D", + static EnumPropertyItem gizmogroup_flag_items[] = { + {WM_GIZMOGROUPTYPE_3D, "3D", 0, "3D", "Use in 3D viewport"}, - {WM_MANIPULATORGROUPTYPE_SCALE, "SCALE", 0, "Scale", + {WM_GIZMOGROUPTYPE_SCALE, "SCALE", 0, "Scale", "Scale to respect zoom (otherwise zoom independent draw size)"}, - {WM_MANIPULATORGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D", + {WM_GIZMOGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D", "Supports culled depth by other objects in the view"}, - {WM_MANIPULATORGROUPTYPE_SELECT, "SELECT", 0, "Select", + {WM_GIZMOGROUPTYPE_SELECT, "SELECT", 0, "Select", "Supports selection"}, - {WM_MANIPULATORGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", + {WM_GIZMOGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", ""}, - {WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All", + {WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All", "Show all while interacting"}, {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type->flag"); - RNA_def_property_enum_items(prop, manipulatorgroup_flag_items); + RNA_def_property_enum_items(prop, gizmogroup_flag_items); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG); RNA_def_property_ui_text(prop, "Options", "Options for this operator type"); @@ -1254,7 +1254,7 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna) /* poll */ func = RNA_def_function(srna, "poll", NULL); - RNA_def_function_ui_description(func, "Test if the manipulator group can be called or not"); + RNA_def_function_ui_description(func, "Test if the gizmo group can be called or not"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); parm = RNA_def_pointer(func, "context", "Context", "", ""); @@ -1264,7 +1264,7 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna) func = RNA_def_function(srna, "setup_keymap", NULL); RNA_def_function_ui_description( func, - "Initialize keymaps for this manipulator group, use fallback keymap when not present"); + "Initialize keymaps for this gizmo group, use fallback keymap when not present"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); @@ -1275,7 +1275,7 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna) /* setup */ func = RNA_def_function(srna, "setup", NULL); - RNA_def_function_ui_description(func, "Create manipulators function for the manipulator group"); + RNA_def_function_ui_description(func, "Create gizmos function for the gizmo group"); RNA_def_function_flag(func, FUNC_REGISTER); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); @@ -1298,38 +1298,38 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna) prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_string_funcs(prop, "rna_ManipulatorGroup_name_get", "rna_ManipulatorGroup_name_length", NULL); + RNA_def_property_string_funcs(prop, "rna_GizmoGroup_name_get", "rna_GizmoGroup_name_length", NULL); RNA_def_property_ui_text(prop, "Name", ""); prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */ - RNA_def_property_boolean_funcs(prop, "rna_ManipulatorGroup_has_reports_get", NULL); + RNA_def_property_boolean_funcs(prop, "rna_GizmoGroup_has_reports_get", NULL); RNA_def_property_ui_text(prop, "Has Reports", - "ManipulatorGroup has a set of reports (warnings and errors) from last execution"); + "GizmoGroup has a set of reports (warnings and errors) from last execution"); RNA_define_verify_sdna(0); /* not in sdna */ - prop = RNA_def_property(srna, "manipulators", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "manipulators", NULL); - RNA_def_property_struct_type(prop, "Manipulator"); + prop = RNA_def_property(srna, "gizmos", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "gizmos", NULL); + RNA_def_property_struct_type(prop, "Gizmo"); RNA_def_property_collection_funcs( - prop, "rna_ManipulatorGroup_manipulators_begin", "rna_iterator_listbase_next", + prop, "rna_GizmoGroup_gizmos_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", NULL, NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Manipulators", "List of manipulators in the Manipulator Map"); - rna_def_manipulator(brna, prop); - rna_def_manipulators(brna, prop); + RNA_def_property_ui_text(prop, "Gizmos", "List of gizmos in the Gizmo Map"); + rna_def_gizmo(brna, prop); + rna_def_gizmos(brna, prop); RNA_define_verify_sdna(1); /* not in sdna */ - RNA_api_manipulatorgroup(srna); + RNA_api_gizmogroup(srna); } -void RNA_def_wm_manipulator(BlenderRNA *brna) +void RNA_def_wm_gizmo(BlenderRNA *brna) { - rna_def_manipulatorgroup(brna); + rna_def_gizmogroup(brna); } #endif /* RNA_RUNTIME */ diff --git a/source/blender/makesrna/intern/rna_wm_gizmo_api.c b/source/blender/makesrna/intern/rna_wm_gizmo_api.c index b06ba4d3dac..04c02889fa3 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo_api.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo_api.c @@ -46,43 +46,43 @@ #include "ED_gizmo_library.h" -static void rna_manipulator_draw_preset_box( - wmManipulator *mpr, float matrix[16], int select_id) +static void rna_gizmo_draw_preset_box( + wmGizmo *mpr, float matrix[16], int select_id) { - ED_manipulator_draw_preset_box(mpr, (float (*)[4])matrix, select_id); + ED_gizmo_draw_preset_box(mpr, (float (*)[4])matrix, select_id); } -static void rna_manipulator_draw_preset_arrow( - wmManipulator *mpr, float matrix[16], int axis, int select_id) +static void rna_gizmo_draw_preset_arrow( + wmGizmo *mpr, float matrix[16], int axis, int select_id) { - ED_manipulator_draw_preset_arrow(mpr, (float (*)[4])matrix, axis, select_id); + ED_gizmo_draw_preset_arrow(mpr, (float (*)[4])matrix, axis, select_id); } -static void rna_manipulator_draw_preset_circle( - wmManipulator *mpr, float matrix[16], int axis, int select_id) +static void rna_gizmo_draw_preset_circle( + wmGizmo *mpr, float matrix[16], int axis, int select_id) { - ED_manipulator_draw_preset_circle(mpr, (float (*)[4])matrix, axis, select_id); + ED_gizmo_draw_preset_circle(mpr, (float (*)[4])matrix, axis, select_id); } -static void rna_manipulator_draw_preset_facemap( - wmManipulator *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id) +static void rna_gizmo_draw_preset_facemap( + wmGizmo *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id) { struct Scene *scene = CTX_data_scene(C); - ED_manipulator_draw_preset_facemap(C, mpr, scene, ob, facemap, select_id); + ED_gizmo_draw_preset_facemap(C, mpr, scene, ob, facemap, select_id); } /* -------------------------------------------------------------------- */ -/** \name Manipulator Property Define +/** \name Gizmo Property Define * \{ */ -static void rna_manipulator_target_set_prop( - wmManipulator *mpr, ReportList *reports, const char *target_propname, +static void rna_gizmo_target_set_prop( + wmGizmo *mpr, ReportList *reports, const char *target_propname, PointerRNA *ptr, const char *propname, int index) { - const wmManipulatorPropertyType *mpr_prop_type = - WM_manipulatortype_target_property_find(mpr->type, target_propname); + const wmGizmoPropertyType *mpr_prop_type = + WM_gizmotype_target_property_find(mpr->type, target_propname); if (mpr_prop_type == NULL) { - BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found", + BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' not found", mpr->type->idname, target_propname); return; } @@ -95,13 +95,13 @@ static void rna_manipulator_target_set_prop( } if (mpr_prop_type->data_type != RNA_property_type(prop)) { - const int manipulator_type_index = RNA_enum_from_value(rna_enum_property_type_items, mpr_prop_type->data_type); + const int gizmo_type_index = RNA_enum_from_value(rna_enum_property_type_items, mpr_prop_type->data_type); const int prop_type_index = RNA_enum_from_value(rna_enum_property_type_items, RNA_property_type(prop)); - BLI_assert((manipulator_type_index != -1) && (prop_type_index == -1)); + BLI_assert((gizmo_type_index != -1) && (prop_type_index == -1)); - BKE_reportf(reports, RPT_ERROR, "Manipulator target '%s.%s' expects '%s', '%s.%s' is '%s'", + BKE_reportf(reports, RPT_ERROR, "Gizmo target '%s.%s' expects '%s', '%s.%s' is '%s'", mpr->type->idname, target_propname, - rna_enum_property_type_items[manipulator_type_index].identifier, + rna_enum_property_type_items[gizmo_type_index].identifier, RNA_struct_identifier(ptr->type), propname, rna_enum_property_type_items[prop_type_index].identifier); return; @@ -112,7 +112,7 @@ static void rna_manipulator_target_set_prop( const int prop_array_length = RNA_property_array_length(ptr, prop); if (mpr_prop_type->array_length != prop_array_length) { BKE_reportf(reports, RPT_ERROR, - "Manipulator target property '%s.%s' expects an array of length %d, found %d", + "Gizmo target property '%s.%s' expects an array of length %d, found %d", mpr->type->idname, target_propname, mpr_prop_type->array_length, prop_array_length); @@ -123,7 +123,7 @@ static void rna_manipulator_target_set_prop( else { if (mpr_prop_type->array_length != 1) { BKE_reportf(reports, RPT_ERROR, - "Manipulator target property '%s.%s' expects an array of length %d", + "Gizmo target property '%s.%s' expects an array of length %d", mpr->type->idname, target_propname, mpr_prop_type->array_length); return; @@ -131,16 +131,16 @@ static void rna_manipulator_target_set_prop( } if (index >= mpr_prop_type->array_length) { - BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s', index %d must be below %d", + BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s', index %d must be below %d", mpr->type->idname, target_propname, index, mpr_prop_type->array_length); return; } - WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); + WM_gizmo_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); } -static PointerRNA rna_manipulator_target_set_operator( - wmManipulator *mpr, ReportList *reports, const char *opname, int part_index) +static PointerRNA rna_gizmo_target_set_operator( + wmGizmo *mpr, ReportList *reports, const char *opname, int part_index) { wmOperatorType *ot; @@ -154,36 +154,36 @@ static PointerRNA rna_manipulator_target_set_operator( IDProperty *properties; { IDPropertyTemplate val = {0}; - properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties"); + properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties"); } - return *WM_manipulator_operator_set(mpr, part_index, ot, properties); + return *WM_gizmo_operator_set(mpr, part_index, ot, properties); } /** \} */ /* -------------------------------------------------------------------- */ -/** \name Manipulator Property Access +/** \name Gizmo Property Access * \{ */ -static bool rna_manipulator_target_is_valid( - wmManipulator *mpr, ReportList *reports, const char *target_propname) +static bool rna_gizmo_target_is_valid( + wmGizmo *mpr, ReportList *reports, const char *target_propname) { - wmManipulatorProperty *mpr_prop = - WM_manipulator_target_property_find(mpr, target_propname); + wmGizmoProperty *mpr_prop = + WM_gizmo_target_property_find(mpr, target_propname); if (mpr_prop == NULL) { - BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found", + BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' not found", mpr->type->idname, target_propname); return false; } - return WM_manipulator_target_property_is_valid(mpr_prop); + return WM_gizmo_target_property_is_valid(mpr_prop); } /** \} */ #else -void RNA_api_manipulator(StructRNA *srna) +void RNA_api_gizmo(StructRNA *srna) { /* Utility draw functions, since we don't expose new OpenGL drawing wrappers via Python yet. * exactly how these should be exposed isn't totally clear. @@ -198,7 +198,7 @@ void RNA_api_manipulator(StructRNA *srna) /* Primitive Shapes */ /* draw_preset_box */ - func = RNA_def_function(srna, "draw_preset_box", "rna_manipulator_draw_preset_box"); + func = RNA_def_function(srna, "draw_preset_box", "rna_gizmo_draw_preset_box"); RNA_def_function_ui_description(func, "Draw a box"); parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -207,7 +207,7 @@ void RNA_api_manipulator(StructRNA *srna) RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); /* draw_preset_box */ - func = RNA_def_function(srna, "draw_preset_arrow", "rna_manipulator_draw_preset_arrow"); + func = RNA_def_function(srna, "draw_preset_arrow", "rna_gizmo_draw_preset_arrow"); RNA_def_function_ui_description(func, "Draw a box"); parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -216,7 +216,7 @@ void RNA_api_manipulator(StructRNA *srna) RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation"); RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); - func = RNA_def_function(srna, "draw_preset_circle", "rna_manipulator_draw_preset_circle"); + func = RNA_def_function(srna, "draw_preset_circle", "rna_gizmo_draw_preset_circle"); RNA_def_function_ui_description(func, "Draw a box"); parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -229,7 +229,7 @@ void RNA_api_manipulator(StructRNA *srna) /* Other Shapes */ /* draw_preset_facemap */ - func = RNA_def_function(srna, "draw_preset_facemap", "rna_manipulator_draw_preset_facemap"); + func = RNA_def_function(srna, "draw_preset_facemap", "rna_gizmo_draw_preset_facemap"); RNA_def_function_ui_description(func, "Draw the face-map of a mesh object"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "object", "Object", "", "Object"); @@ -243,7 +243,7 @@ void RNA_api_manipulator(StructRNA *srna) /* Define Properties */ /* note, 'target_set_handler' is defined in 'bpy_rna_gizmo.c' */ - func = RNA_def_function(srna, "target_set_prop", "rna_manipulator_target_set_prop"); + func = RNA_def_function(srna, "target_set_prop", "rna_gizmo_target_set_prop"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, ""); parm = RNA_def_string(func, "target", NULL, 0, "", "Target property"); @@ -255,10 +255,10 @@ void RNA_api_manipulator(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_int(func, "index", -1, -1, INT_MAX, "", "", -1, INT_MAX); /* RNA_NO_INDEX == -1 */ - func = RNA_def_function(srna, "target_set_operator", "rna_manipulator_target_set_operator"); + func = RNA_def_function(srna, "target_set_operator", "rna_gizmo_target_set_operator"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description( - func, "Operator to run when activating the manipulator " + func, "Operator to run when activating the gizmo " "(overrides property targets)"); parm = RNA_def_string(func, "operator", NULL, 0, "", "Target operator"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -271,7 +271,7 @@ void RNA_api_manipulator(StructRNA *srna) /* Access Properties */ /* note, 'target_get', 'target_set' is defined in 'bpy_rna_gizmo.c' */ - func = RNA_def_function(srna, "target_is_valid", "rna_manipulator_target_is_valid"); + func = RNA_def_function(srna, "target_is_valid", "rna_gizmo_target_is_valid"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_string(func, "property", NULL, 0, "", "Property identifier"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -282,7 +282,7 @@ void RNA_api_manipulator(StructRNA *srna) } -void RNA_api_manipulatorgroup(StructRNA *UNUSED(srna)) +void RNA_api_gizmogroup(StructRNA *UNUSED(srna)) { /* nothing yet */ } diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c index eceaaeec3a4..98e84f60b33 100644 --- a/source/blender/makesrna/intern/rna_workspace_api.c +++ b/source/blender/makesrna/intern/rna_workspace_api.c @@ -51,7 +51,7 @@ static void rna_WorkspaceTool_setup( /* Args for: 'bToolRef_Runtime'. */ int cursor, const char *keymap, - const char *manipulator_group, + const char *gizmo_group, const char *data_block, const char *operator, int index) @@ -60,7 +60,7 @@ static void rna_WorkspaceTool_setup( tref_rt.cursor = cursor; STRNCPY(tref_rt.keymap, keymap); - STRNCPY(tref_rt.manipulator_group, manipulator_group); + STRNCPY(tref_rt.gizmo_group, gizmo_group); STRNCPY(tref_rt.data_block, data_block); STRNCPY(tref_rt.operator, operator); tref_rt.index = index; @@ -110,7 +110,7 @@ void RNA_api_workspace_tool(StructRNA *srna) parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(parm, rna_enum_window_cursor_items); RNA_def_string(func, "keymap", NULL, KMAP_MAX_NAME, "Key Map", ""); - RNA_def_string(func, "manipulator_group", NULL, MAX_NAME, "Manipulator Group", ""); + RNA_def_string(func, "gizmo_group", NULL, MAX_NAME, "Gizmo Group", ""); RNA_def_string(func, "data_block", NULL, MAX_NAME, "Data Block", ""); RNA_def_string(func, "operator", NULL, MAX_NAME, "Operator", ""); RNA_def_int(func, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX); diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 3083322d496..07ad8274f11 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -340,7 +340,7 @@ void BPy_init_modules(void) BPY_rna_id_collection_module(mod); - BPY_rna_manipulator_module(mod); + BPY_rna_gizmo_module(mod); bpy_import_test("bpy_types"); PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */ diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c index eda1f58a4cc..4b71ea92010 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.c +++ b/source/blender/python/intern/bpy_gizmo_wrap.c @@ -49,12 +49,12 @@ /* -------------------------------------------------------------------- */ -/** \name Manipulator +/** \name Gizmo * \{ */ -static bool bpy_manipulatortype_target_property_def( - wmManipulatorType *wt, PyObject *item) +static bool bpy_gizmotype_target_property_def( + wmGizmoType *wt, PyObject *item) { /* Note: names based on 'rna_rna.c' */ PyObject *empty_tuple = PyTuple_New(0); @@ -102,7 +102,7 @@ static bool bpy_manipulatortype_target_property_def( goto fail; } - WM_manipulatortype_target_property_def(wt, params.id, params.type, params.array_length); + WM_gizmotype_target_property_def(wt, params.id, params.type, params.array_length); Py_DECREF(empty_tuple); return true; @@ -111,7 +111,7 @@ fail: return false; } -static void manipulator_properties_init(wmManipulatorType *wt) +static void gizmo_properties_init(wmGizmoType *wt) { PyTypeObject *py_class = wt->ext.data; RNA_struct_blender_type_set(wt->ext.srna, wt); @@ -149,7 +149,7 @@ static void manipulator_properties_init(wmManipulatorType *wt) PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast); for (uint i = 0; i < items_len; i++) { - if (!bpy_manipulatortype_target_property_def(wt, items[i])) { + if (!bpy_gizmotype_target_property_def(wt, items[i])) { PyErr_Print(); PyErr_Clear(); break; @@ -161,25 +161,25 @@ static void manipulator_properties_init(wmManipulatorType *wt) } } -void BPY_RNA_manipulator_wrapper(wmManipulatorType *wt, void *userdata) +void BPY_RNA_gizmo_wrapper(wmGizmoType *wt, void *userdata) { /* take care not to overwrite anything set in - * WM_manipulatormaptype_group_link_ptr before opfunc() is called */ + * WM_gizmomaptype_group_link_ptr before opfunc() is called */ StructRNA *srna = wt->srna; - *wt = *((wmManipulatorType *)userdata); + *wt = *((wmGizmoType *)userdata); wt->srna = srna; /* restore */ /* don't do translations here yet */ #if 0 - /* Use i18n context from ext.srna if possible (py manipulatorgroups). */ + /* Use i18n context from ext.srna if possible (py gizmogroups). */ if (wt->ext.srna) { RNA_def_struct_translation_context(wt->srna, RNA_struct_translation_context(wt->ext.srna)); } #endif - wt->struct_size = sizeof(wmManipulator); + wt->struct_size = sizeof(wmGizmo); - manipulator_properties_init(wt); + gizmo_properties_init(wt); } /** \} */ @@ -187,10 +187,10 @@ void BPY_RNA_manipulator_wrapper(wmManipulatorType *wt, void *userdata) /* -------------------------------------------------------------------- */ -/** \name Manipulator Group +/** \name Gizmo Group * \{ */ -static void manipulatorgroup_properties_init(wmManipulatorGroupType *wgt) +static void gizmogroup_properties_init(wmGizmoGroupType *wgt) { #ifdef USE_SRNA PyTypeObject *py_class = wgt->ext.data; @@ -210,26 +210,26 @@ static void manipulatorgroup_properties_init(wmManipulatorGroupType *wgt) #endif } -void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata) +void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *wgt, void *userdata) { /* take care not to overwrite anything set in - * WM_manipulatormaptype_group_link_ptr before opfunc() is called */ + * WM_gizmomaptype_group_link_ptr before opfunc() is called */ #ifdef USE_SRNA StructRNA *srna = wgt->srna; #endif - *wgt = *((wmManipulatorGroupType *)userdata); + *wgt = *((wmGizmoGroupType *)userdata); #ifdef USE_SRNA wgt->srna = srna; /* restore */ #endif #ifdef USE_SRNA - /* Use i18n context from ext.srna if possible (py manipulatorgroups). */ + /* Use i18n context from ext.srna if possible (py gizmogroups). */ if (wgt->ext.srna) { RNA_def_struct_translation_context(wgt->srna, RNA_struct_translation_context(wgt->ext.srna)); } #endif - manipulatorgroup_properties_init(wgt); + gizmogroup_properties_init(wgt); } /** \} */ diff --git a/source/blender/python/intern/bpy_gizmo_wrap.h b/source/blender/python/intern/bpy_gizmo_wrap.h index 71fa123d6ce..4d6639d977f 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.h +++ b/source/blender/python/intern/bpy_gizmo_wrap.h @@ -25,11 +25,11 @@ #ifndef __BPY_GIZMO_WRAP_H__ #define __BPY_GIZMO_WRAP_H__ -struct wmManipulatorType; -struct wmManipulatorGroupType; +struct wmGizmoType; +struct wmGizmoGroupType; /* exposed to rna/wm api */ -void BPY_RNA_manipulator_wrapper(struct wmManipulatorType *wt, void *userdata); -void BPY_RNA_manipulatorgroup_wrapper(struct wmManipulatorGroupType *wgt, void *userdata); +void BPY_RNA_gizmo_wrapper(struct wmGizmoType *wt, void *userdata); +void BPY_RNA_gizmogroup_wrapper(struct wmGizmoGroupType *wgt, void *userdata); #endif /* __BPY_GIZMO_WRAP_H__ */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index b288e311633..e0fbd144590 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1853,13 +1853,13 @@ static int pyrna_py_to_prop( { const StructRNA *base_type = RNA_struct_base_child_of(((const BPy_StructRNA *)value)->ptr.type, NULL); - if (ELEM(base_type, &RNA_Operator, &RNA_Manipulator)) { + if (ELEM(base_type, &RNA_Operator, &RNA_Gizmo)) { value = PyObject_GetAttr(value, bpy_intern_str_properties); value_new = value; } } - /* if property is an OperatorProperties/ManipulatorProperties pointer and value is a map, + /* if property is an OperatorProperties/GizmoProperties pointer and value is a map, * forward back to pyrna_pydict_to_props */ if (PyDict_Check(value)) { const StructRNA *base_type = RNA_struct_base_child_of(ptr_type, NULL); @@ -1867,7 +1867,7 @@ static int pyrna_py_to_prop( PointerRNA opptr = RNA_property_pointer_get(ptr, prop); return pyrna_pydict_to_props(&opptr, value, false, error_prefix); } - else if (base_type == &RNA_ManipulatorProperties) { + else if (base_type == &RNA_GizmoProperties) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); return pyrna_pydict_to_props(&opptr, value, false, error_prefix); } @@ -7738,7 +7738,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param #ifdef USE_PEDANTIC_WRITE const bool is_readonly_init = !(RNA_struct_is_a(ptr->type, &RNA_Operator) || - RNA_struct_is_a(ptr->type, &RNA_Manipulator)); + RNA_struct_is_a(ptr->type, &RNA_Gizmo)); // const char *func_id = RNA_function_identifier(func); /* UNUSED */ /* testing, for correctness, not operator and not draw function */ const bool is_readonly = !(RNA_function_flag(func) & FUNC_ALLOW_WRITE); diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.c index 34a4594bdae..e834595114a 100644 --- a/source/blender/python/intern/bpy_rna_gizmo.c +++ b/source/blender/python/intern/bpy_rna_gizmo.c @@ -51,29 +51,29 @@ /* -------------------------------------------------------------------- */ -/** \name Manipulator Target Property Define API +/** \name Gizmo Target Property Define API * \{ */ enum { - BPY_MANIPULATOR_FN_SLOT_GET = 0, - BPY_MANIPULATOR_FN_SLOT_SET, - BPY_MANIPULATOR_FN_SLOT_RANGE_GET, + BPY_GIZMO_FN_SLOT_GET = 0, + BPY_GIZMO_FN_SLOT_SET, + BPY_GIZMO_FN_SLOT_RANGE_GET, }; -#define BPY_MANIPULATOR_FN_SLOT_LEN (BPY_MANIPULATOR_FN_SLOT_RANGE_GET + 1) +#define BPY_GIZMO_FN_SLOT_LEN (BPY_GIZMO_FN_SLOT_RANGE_GET + 1) -struct BPyManipulatorHandlerUserData { +struct BPyGizmoHandlerUserData { - PyObject *fn_slots[BPY_MANIPULATOR_FN_SLOT_LEN]; + PyObject *fn_slots[BPY_GIZMO_FN_SLOT_LEN]; }; -static void py_rna_manipulator_handler_get_cb( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void py_rna_gizmo_handler_get_cb( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, void *value_p) { PyGILState_STATE gilstate = PyGILState_Ensure(); - struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_GET], NULL); + struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data; + PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_GET], NULL); if (ret == NULL) { goto fail; } @@ -87,7 +87,7 @@ static void py_rna_manipulator_handler_get_cb( } else { if (PyC_AsArray(value, ret, mpr_prop->type->array_length, &PyFloat_Type, false, - "Manipulator get callback: ") == -1) + "Gizmo get callback: ") == -1) { goto fail; } @@ -110,13 +110,13 @@ fail: PyGILState_Release(gilstate); } -static void py_rna_manipulator_handler_set_cb( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void py_rna_gizmo_handler_set_cb( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, const void *value_p) { PyGILState_STATE gilstate = PyGILState_Ensure(); - struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data; PyObject *args = PyTuple_New(1); @@ -139,7 +139,7 @@ static void py_rna_manipulator_handler_set_cb( goto fail; } - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_SET], args); + PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_SET], args); if (ret == NULL) { goto fail; } @@ -157,15 +157,15 @@ fail: PyGILState_Release(gilstate); } -static void py_rna_manipulator_handler_range_get_cb( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop, +static void py_rna_gizmo_handler_range_get_cb( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, void *value_p) { - struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data; PyGILState_STATE gilstate = PyGILState_Ensure(); - PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET], NULL); + PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_RANGE_GET], NULL); if (ret == NULL) { goto fail; } @@ -214,13 +214,13 @@ fail: PyGILState_Release(gilstate); } -static void py_rna_manipulator_handler_free_cb( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop) +static void py_rna_gizmo_handler_free_cb( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop) { - struct BPyManipulatorHandlerUserData *data = mpr_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data; PyGILState_STATE gilstate = PyGILState_Ensure(); - for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { + for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) { Py_XDECREF(data->fn_slots[i]); } PyGILState_Release(gilstate); @@ -229,26 +229,26 @@ static void py_rna_manipulator_handler_free_cb( } -PyDoc_STRVAR(bpy_manipulator_target_set_handler_doc, +PyDoc_STRVAR(bpy_gizmo_target_set_handler_doc, ".. method:: target_set_handler(target, get, set, range=None):\n" "\n" -" Assigns callbacks to a manipulators property.\n" +" Assigns callbacks to a gizmos property.\n" "\n" " :arg get: Function that returns the value for this property (single value or sequence).\n" " :type get: callable\n" " :arg set: Function that takes a single value argument and applies it.\n" " :type set: callable\n" -" :arg range: Function that returns a (min, max) tuple for manipulators that use a range.\n" +" :arg range: Function that returns a (min, max) tuple for gizmos that use a range.\n" " :type range: callable\n" ); -static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kw) { PyGILState_STATE gilstate = PyGILState_Ensure(); struct { PyObject *self; char *target; - PyObject *py_fn_slots[BPY_MANIPULATOR_FN_SLOT_LEN]; + PyObject *py_fn_slots[BPY_GIZMO_FN_SLOT_LEN]; } params = { .self = NULL, .target = NULL, @@ -256,28 +256,28 @@ static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyOb }; /* Note: this is a counter-part to functions: - * 'Manipulator.target_set_prop & target_set_operator' - * (see: rna_wm_manipulator_api.c). conventions should match. */ + * 'Gizmo.target_set_prop & target_set_operator' + * (see: rna_wm_gizmo_api.c). conventions should match. */ static const char * const _keywords[] = {"self", "target", "get", "set", "range", NULL}; static _PyArg_Parser _parser = {"Os|$OOO:target_set_handler", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, ¶ms.self, ¶ms.target, - ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_GET], - ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_SET], - ¶ms.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET])) + ¶ms.py_fn_slots[BPY_GIZMO_FN_SLOT_GET], + ¶ms.py_fn_slots[BPY_GIZMO_FN_SLOT_SET], + ¶ms.py_fn_slots[BPY_GIZMO_FN_SLOT_RANGE_GET])) { goto fail; } - wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data; - const wmManipulatorPropertyType *mpr_prop_type = - WM_manipulatortype_target_property_find(mpr->type, params.target); + const wmGizmoPropertyType *mpr_prop_type = + WM_gizmotype_target_property_find(mpr->type, params.target); if (mpr_prop_type == NULL) { PyErr_Format(PyExc_ValueError, - "Manipulator target property '%s.%s' not found", + "Gizmo target property '%s.%s' not found", mpr->type->idname, params.target); goto fail; } @@ -285,7 +285,7 @@ static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyOb { const int slots_required = 2; const int slots_start = 2; - for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { + for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) { if (params.py_fn_slots[i] == NULL) { if (i < slots_required) { PyErr_Format(PyExc_ValueError, "Argument '%s' not given", _keywords[slots_start + i]); @@ -299,20 +299,20 @@ static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyOb } } - struct BPyManipulatorHandlerUserData *data = MEM_callocN(sizeof(*data), __func__); + struct BPyGizmoHandlerUserData *data = MEM_callocN(sizeof(*data), __func__); - for (int i = 0; i < BPY_MANIPULATOR_FN_SLOT_LEN; i++) { + for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) { data->fn_slots[i] = params.py_fn_slots[i]; Py_XINCREF(params.py_fn_slots[i]); } - WM_manipulator_target_property_def_func_ptr( + WM_gizmo_target_property_def_func_ptr( mpr, mpr_prop_type, - &(const struct wmManipulatorPropertyFnParams) { - .value_get_fn = py_rna_manipulator_handler_get_cb, - .value_set_fn = py_rna_manipulator_handler_set_cb, - .range_get_fn = py_rna_manipulator_handler_range_get_cb, - .free_fn = py_rna_manipulator_handler_free_cb, + &(const struct wmGizmoPropertyFnParams) { + .value_get_fn = py_rna_gizmo_handler_get_cb, + .value_set_fn = py_rna_gizmo_handler_set_cb, + .range_get_fn = py_rna_gizmo_handler_range_get_cb, + .free_fn = py_rna_gizmo_handler_free_cb, .user_data = data, }); @@ -328,10 +328,10 @@ fail: /** \} */ /* -------------------------------------------------------------------- */ -/** \name Manipulator Target Property Access API +/** \name Gizmo Target Property Access API * \{ */ -PyDoc_STRVAR(bpy_manipulator_target_get_value_doc, +PyDoc_STRVAR(bpy_gizmo_target_get_value_doc, ".. method:: target_get_value(target):\n" "\n" " Get the value of this target property.\n" @@ -341,7 +341,7 @@ PyDoc_STRVAR(bpy_manipulator_target_get_value_doc, " :return: The value of the target property.\n" " :rtype: Single value or array based on the target type\n" ); -static PyObject *bpy_manipulator_target_get_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) { struct { PyObject *self; @@ -361,28 +361,28 @@ static PyObject *bpy_manipulator_target_get_value(PyObject *UNUSED(self), PyObje goto fail; } - wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data; - wmManipulatorProperty *mpr_prop = - WM_manipulator_target_property_find(mpr, params.target); + wmGizmoProperty *mpr_prop = + WM_gizmo_target_property_find(mpr, params.target); if (mpr_prop == NULL) { PyErr_Format(PyExc_ValueError, - "Manipulator target property '%s.%s' not found", + "Gizmo target property '%s.%s' not found", mpr->type->idname, params.target); goto fail; } - const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop); + const int array_len = WM_gizmo_target_property_array_length(mpr, mpr_prop); switch (mpr_prop->type->data_type) { case PROP_FLOAT: { if (array_len != 0) { float *value = BLI_array_alloca(value, array_len); - WM_manipulator_target_property_value_get_array(mpr, mpr_prop, value); + WM_gizmo_target_property_value_get_array(mpr, mpr_prop, value); return PyC_Tuple_PackArray_F32(value, array_len); } else { - float value = WM_manipulator_target_property_value_get(mpr, mpr_prop); + float value = WM_gizmo_target_property_value_get(mpr, mpr_prop); return PyFloat_FromDouble(value); } break; @@ -398,7 +398,7 @@ fail: return NULL; } -PyDoc_STRVAR(bpy_manipulator_target_set_value_doc, +PyDoc_STRVAR(bpy_gizmo_target_set_value_doc, ".. method:: target_set_value(target):\n" "\n" " Set the value of this target property.\n" @@ -406,7 +406,7 @@ PyDoc_STRVAR(bpy_manipulator_target_set_value_doc, " :arg target: Target property name.\n" " :type target: string\n" ); -static PyObject *bpy_manipulator_target_set_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw) { struct { PyObject *self; @@ -429,36 +429,36 @@ static PyObject *bpy_manipulator_target_set_value(PyObject *UNUSED(self), PyObje goto fail; } - wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data; - wmManipulatorProperty *mpr_prop = - WM_manipulator_target_property_find(mpr, params.target); + wmGizmoProperty *mpr_prop = + WM_gizmo_target_property_find(mpr, params.target); if (mpr_prop == NULL) { PyErr_Format(PyExc_ValueError, - "Manipulator target property '%s.%s' not found", + "Gizmo target property '%s.%s' not found", mpr->type->idname, params.target); goto fail; } - const int array_len = WM_manipulator_target_property_array_length(mpr, mpr_prop); + const int array_len = WM_gizmo_target_property_array_length(mpr, mpr_prop); switch (mpr_prop->type->data_type) { case PROP_FLOAT: { if (array_len != 0) { float *value = BLI_array_alloca(value, array_len); if (PyC_AsArray(value, params.value, mpr_prop->type->array_length, &PyFloat_Type, false, - "Manipulator target property array") == -1) + "Gizmo target property array") == -1) { goto fail; } - WM_manipulator_target_property_value_set_array(BPy_GetContext(), mpr, mpr_prop, value); + WM_gizmo_target_property_value_set_array(BPy_GetContext(), mpr, mpr_prop, value); } else { float value; if ((value = PyFloat_AsDouble(params.value)) == -1.0f && PyErr_Occurred()) { goto fail; } - WM_manipulator_target_property_value_set(BPy_GetContext(), mpr, mpr_prop, value); + WM_gizmo_target_property_value_set(BPy_GetContext(), mpr, mpr_prop, value); } Py_RETURN_NONE; } @@ -474,7 +474,7 @@ fail: } -PyDoc_STRVAR(bpy_manipulator_target_get_range_doc, +PyDoc_STRVAR(bpy_gizmo_target_get_range_doc, ".. method:: target_get_range(target):\n" "\n" " Get the range for this target property.\n" @@ -484,7 +484,7 @@ PyDoc_STRVAR(bpy_manipulator_target_get_range_doc, " :return: The range of this property (min, max).\n" " :rtype: tuple pair.\n" ); -static PyObject *bpy_manipulator_target_get_range(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *args, PyObject *kw) { struct { PyObject *self; @@ -504,13 +504,13 @@ static PyObject *bpy_manipulator_target_get_range(PyObject *UNUSED(self), PyObje goto fail; } - wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data; - wmManipulatorProperty *mpr_prop = - WM_manipulator_target_property_find(mpr, params.target); + wmGizmoProperty *mpr_prop = + WM_gizmo_target_property_find(mpr, params.target); if (mpr_prop == NULL) { PyErr_Format(PyExc_ValueError, - "Manipulator target property '%s.%s' not found", + "Gizmo target property '%s.%s' not found", mpr->type->idname, params.target); goto fail; } @@ -519,7 +519,7 @@ static PyObject *bpy_manipulator_target_get_range(PyObject *UNUSED(self), PyObje case PROP_FLOAT: { float range[2]; - WM_manipulator_target_property_range_get(mpr, mpr_prop, range); + WM_gizmo_target_property_range_get(mpr, mpr_prop, range); return PyC_Tuple_PackArray_F32(range, 2); } default: @@ -535,19 +535,19 @@ fail: /** \} */ -int BPY_rna_manipulator_module(PyObject *mod_par) +int BPY_rna_gizmo_module(PyObject *mod_par) { static PyMethodDef method_def_array[] = { - /* Manipulator Target Property Define API */ - {"target_set_handler", (PyCFunction)bpy_manipulator_target_set_handler, - METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_handler_doc}, - /* Manipulator Target Property Access API */ - {"target_get_value", (PyCFunction)bpy_manipulator_target_get_value, - METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_value_doc}, - {"target_set_value", (PyCFunction)bpy_manipulator_target_set_value, - METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_set_value_doc}, - {"target_get_range", (PyCFunction)bpy_manipulator_target_get_range, - METH_VARARGS | METH_KEYWORDS, bpy_manipulator_target_get_range_doc}, + /* Gizmo Target Property Define API */ + {"target_set_handler", (PyCFunction)bpy_gizmo_target_set_handler, + METH_VARARGS | METH_KEYWORDS, bpy_gizmo_target_set_handler_doc}, + /* Gizmo Target Property Access API */ + {"target_get_value", (PyCFunction)bpy_gizmo_target_get_value, + METH_VARARGS | METH_KEYWORDS, bpy_gizmo_target_get_value_doc}, + {"target_set_value", (PyCFunction)bpy_gizmo_target_set_value, + METH_VARARGS | METH_KEYWORDS, bpy_gizmo_target_set_value_doc}, + {"target_get_range", (PyCFunction)bpy_gizmo_target_get_range, + METH_VARARGS | METH_KEYWORDS, bpy_gizmo_target_get_range_doc}, /* no sentinel needed. */ }; @@ -556,7 +556,7 @@ int BPY_rna_manipulator_module(PyObject *mod_par) PyObject *func = PyCFunction_New(m, NULL); PyObject *func_inst = PyInstanceMethod_New(func); char name_prefix[128]; - PyOS_snprintf(name_prefix, sizeof(name_prefix), "_rna_manipulator_%s", m->ml_name); + PyOS_snprintf(name_prefix, sizeof(name_prefix), "_rna_gizmo_%s", m->ml_name); /* TODO, return a type that binds nearly to a method. */ PyModule_AddObject(mod_par, name_prefix, func_inst); } diff --git a/source/blender/python/intern/bpy_rna_gizmo.h b/source/blender/python/intern/bpy_rna_gizmo.h index e848fd9800f..68d8c1e052a 100644 --- a/source/blender/python/intern/bpy_rna_gizmo.h +++ b/source/blender/python/intern/bpy_rna_gizmo.h @@ -27,6 +27,6 @@ #ifndef __BPY_RNA_GIZMO_H__ #define __BPY_RNA_GIZMO_H__ -int BPY_rna_manipulator_module(PyObject *); +int BPY_rna_gizmo_module(PyObject *); #endif /* __BPY_RNA_GIZMO_H__ */ diff --git a/source/blender/python/intern/gpu_py_select.c b/source/blender/python/intern/gpu_py_select.c index f570c4cdae2..fcdcce24935 100644 --- a/source/blender/python/intern/gpu_py_select.c +++ b/source/blender/python/intern/gpu_py_select.c @@ -23,7 +23,7 @@ * * This file defines the gpu.select API. * - * \note Currently only used for manipulator selection, + * \note Currently only used for gizmo selection, * will need to add begin/end and a way to access the hits. */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 32900b75514..67ca5f8a08a 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -77,9 +77,9 @@ struct wmNDOFMotionData; #endif typedef struct wmJob wmJob; -typedef struct wmManipulator wmManipulator; -typedef struct wmManipulatorMap wmManipulatorMap; -typedef struct wmManipulatorMapType wmManipulatorMapType; +typedef struct wmGizmo wmGizmo; +typedef struct wmGizmoMap wmGizmoMap; +typedef struct wmGizmoMapType wmGizmoMapType; /* general API */ void WM_init_state_size_set (int stax, int stay, int sizx, int sizy); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 486eae0a0ed..a5536dbd652 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -123,7 +123,7 @@ struct ImBuf; #include "wm_event_types.h" #include "gizmo/WM_gizmo_types.h" -/* Include external manipulator API's */ +/* Include external gizmo API's */ #include "gizmo/WM_gizmo_api.h" /* ************** wmOperatorType ************************ */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index ffd18af496e..1d2abab8af4 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -26,8 +26,8 @@ /** \file blender/windowmanager/gizmos/WM_gizmo_api.h * \ingroup wm * - * \name Manipulator API - * \brief API for external use of wmManipulator types. + * \name Gizmo API + * \brief API for external use of wmGizmo types. * * Only included in WM_api.h */ @@ -42,302 +42,302 @@ struct IDProperty; struct Main; struct PropertyRNA; struct wmKeyConfig; -struct wmManipulator; -struct wmManipulatorProperty; -struct wmManipulatorPropertyType; -struct wmManipulatorType; -struct wmManipulatorGroup; -struct wmManipulatorGroupType; -struct wmManipulatorMap; -struct wmManipulatorMapType; -struct wmManipulatorMapType_Params; +struct wmGizmo; +struct wmGizmoProperty; +struct wmGizmoPropertyType; +struct wmGizmoType; +struct wmGizmoGroup; +struct wmGizmoGroupType; +struct wmGizmoMap; +struct wmGizmoMapType; +struct wmGizmoMapType_Params; struct wmMsgSubscribeKey; struct wmMsgSubscribeValue; #include "wm_gizmo_fn.h" /* -------------------------------------------------------------------- */ -/* wmManipulator */ +/* wmGizmo */ -struct wmManipulator *WM_manipulator_new_ptr( - const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup, +struct wmGizmo *WM_gizmo_new_ptr( + const struct wmGizmoType *wt, struct wmGizmoGroup *mgroup, struct PointerRNA *properties); -struct wmManipulator *WM_manipulator_new( - const char *idname, struct wmManipulatorGroup *mgroup, +struct wmGizmo *WM_gizmo_new( + const char *idname, struct wmGizmoGroup *mgroup, struct PointerRNA *properties); -void WM_manipulator_free(struct wmManipulator *mpr); -void WM_manipulator_unlink( - ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr, +void WM_gizmo_free(struct wmGizmo *mpr); +void WM_gizmo_unlink( + ListBase *gizmolist, struct wmGizmoMap *mmap, struct wmGizmo *mpr, struct bContext *C); -void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name); +void WM_gizmo_name_set(struct wmGizmoGroup *mgroup, struct wmGizmo *mpr, const char *name); -bool WM_manipulator_select_unlink(struct wmManipulatorMap *mmap, struct wmManipulator *mpr); -bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select); -void WM_manipulator_highlight_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr); +bool WM_gizmo_select_unlink(struct wmGizmoMap *mmap, struct wmGizmo *mpr); +bool WM_gizmo_select_set(struct wmGizmoMap *mmap, struct wmGizmo *mpr, bool select); +void WM_gizmo_highlight_set(struct wmGizmoMap *mmap, struct wmGizmo *mpr); -void WM_manipulator_modal_set_from_setup( - struct wmManipulatorMap *mmap, struct bContext *C, - struct wmManipulator *mpr, int part_index, const struct wmEvent *event); +void WM_gizmo_modal_set_from_setup( + struct wmGizmoMap *mmap, struct bContext *C, + struct wmGizmo *mpr, int part_index, const struct wmEvent *event); -struct wmManipulatorOpElem *WM_manipulator_operator_get( - struct wmManipulator *mpr, int part_index); -struct PointerRNA *WM_manipulator_operator_set( - struct wmManipulator *mpr, int part_index, +struct wmGizmoOpElem *WM_gizmo_operator_get( + struct wmGizmo *mpr, int part_index); +struct PointerRNA *WM_gizmo_operator_set( + struct wmGizmo *mpr, int part_index, struct wmOperatorType *ot, struct IDProperty *properties); /* callbacks */ -void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn); - -void WM_manipulator_set_matrix_location( - struct wmManipulator *mpr, const float origin[3]); -void WM_manipulator_set_matrix_rotation_from_z_axis( - struct wmManipulator *mpr, const float z_axis[3]); -void WM_manipulator_set_matrix_rotation_from_yz_axis( - struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]); - -void WM_manipulator_set_matrix_offset_location( - struct wmManipulator *mpr, const float origin[3]); -void WM_manipulator_set_matrix_offset_rotation_from_z_axis( - struct wmManipulator *mpr, const float z_axis[3]); -void WM_manipulator_set_matrix_offset_rotation_from_yz_axis( - struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]); - -void WM_manipulator_set_flag(struct wmManipulator *mpr, const int flag, const bool enable); -void WM_manipulator_set_scale(struct wmManipulator *mpr, float scale); -void WM_manipulator_set_line_width(struct wmManipulator *mpr, const float line_width); - -void WM_manipulator_get_color(const struct wmManipulator *mpr, float color[4]); -void WM_manipulator_set_color(struct wmManipulator *mpr, const float color[4]); -void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float color_hi[4]); -void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float color[4]); +void WM_gizmo_set_fn_custom_modal(struct wmGizmo *mpr, wmGizmoFnModal fn); + +void WM_gizmo_set_matrix_location( + struct wmGizmo *mpr, const float origin[3]); +void WM_gizmo_set_matrix_rotation_from_z_axis( + struct wmGizmo *mpr, const float z_axis[3]); +void WM_gizmo_set_matrix_rotation_from_yz_axis( + struct wmGizmo *mpr, const float y_axis[3], const float z_axis[3]); + +void WM_gizmo_set_matrix_offset_location( + struct wmGizmo *mpr, const float origin[3]); +void WM_gizmo_set_matrix_offset_rotation_from_z_axis( + struct wmGizmo *mpr, const float z_axis[3]); +void WM_gizmo_set_matrix_offset_rotation_from_yz_axis( + struct wmGizmo *mpr, const float y_axis[3], const float z_axis[3]); + +void WM_gizmo_set_flag(struct wmGizmo *mpr, const int flag, const bool enable); +void WM_gizmo_set_scale(struct wmGizmo *mpr, float scale); +void WM_gizmo_set_line_width(struct wmGizmo *mpr, const float line_width); + +void WM_gizmo_get_color(const struct wmGizmo *mpr, float color[4]); +void WM_gizmo_set_color(struct wmGizmo *mpr, const float color[4]); +void WM_gizmo_get_color_highlight(const struct wmGizmo *mpr, float color_hi[4]); +void WM_gizmo_set_color_highlight(struct wmGizmo *mpr, const float color[4]); /** - * Leaving values NULL use values from #wmManipulator. + * Leaving values NULL use values from #wmGizmo. */ -struct WM_ManipulatorMatrixParams { +struct WM_GizmoMatrixParams { const float(*matrix_space)[4]; const float(*matrix_basis)[4]; const float(*matrix_offset)[4]; const float *scale_final; }; -void WM_manipulator_calc_matrix_final_params( - const struct wmManipulator *mpr, const struct WM_ManipulatorMatrixParams *params, +void WM_gizmo_calc_matrix_final_params( + const struct wmGizmo *mpr, const struct WM_GizmoMatrixParams *params, float r_mat[4][4]); -void WM_manipulator_calc_matrix_final_no_offset( - const struct wmManipulator *mpr, float r_mat[4][4]); +void WM_gizmo_calc_matrix_final_no_offset( + const struct wmGizmo *mpr, float r_mat[4][4]); -void WM_manipulator_calc_matrix_final( - const struct wmManipulator *mpr, float r_mat[4][4]); +void WM_gizmo_calc_matrix_final( + const struct wmGizmo *mpr, float r_mat[4][4]); /* properties */ -void WM_manipulator_properties_create_ptr(struct PointerRNA *ptr, struct wmManipulatorType *wt); -void WM_manipulator_properties_create(struct PointerRNA *ptr, const char *opstring); -void WM_manipulator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring); -void WM_manipulator_properties_sanitize(struct PointerRNA *ptr, const bool no_context); -bool WM_manipulator_properties_default(struct PointerRNA *ptr, const bool do_update); -void WM_manipulator_properties_reset(struct wmManipulator *op); -void WM_manipulator_properties_clear(struct PointerRNA *ptr); -void WM_manipulator_properties_free(struct PointerRNA *ptr); - - -/* wm_manipulator_type.c */ -const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet); -void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)); -void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata); -bool WM_manipulatortype_remove(struct bContext *C, struct Main *bmain, const char *idname); -void WM_manipulatortype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmManipulatorType *wt); -void WM_manipulatortype_iter(struct GHashIterator *ghi); - -/* wm_manipulator_group_type.c */ -struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet); -struct wmManipulatorGroupType *WM_manipulatorgrouptype_append(void (*wtfunc)(struct wmManipulatorGroupType *)); -struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata); -bool WM_manipulatorgrouptype_free(const char *idname); -void WM_manipulatorgrouptype_free_ptr(struct wmManipulatorGroupType *wt); -void WM_manipulatorgrouptype_iter(struct GHashIterator *ghi); - -struct wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( - struct wmManipulatorMapType *mmap_type, - void (*wtfunc)(struct wmManipulatorGroupType *)); - -/* wm_manipulator_map.c */ +void WM_gizmo_properties_create_ptr(struct PointerRNA *ptr, struct wmGizmoType *wt); +void WM_gizmo_properties_create(struct PointerRNA *ptr, const char *opstring); +void WM_gizmo_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring); +void WM_gizmo_properties_sanitize(struct PointerRNA *ptr, const bool no_context); +bool WM_gizmo_properties_default(struct PointerRNA *ptr, const bool do_update); +void WM_gizmo_properties_reset(struct wmGizmo *op); +void WM_gizmo_properties_clear(struct PointerRNA *ptr); +void WM_gizmo_properties_free(struct PointerRNA *ptr); + + +/* wm_gizmo_type.c */ +const struct wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet); +void WM_gizmotype_append(void (*wtfunc)(struct wmGizmoType *)); +void WM_gizmotype_append_ptr(void (*mnpfunc)(struct wmGizmoType *, void *), void *userdata); +bool WM_gizmotype_remove(struct bContext *C, struct Main *bmain, const char *idname); +void WM_gizmotype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmGizmoType *wt); +void WM_gizmotype_iter(struct GHashIterator *ghi); + +/* wm_gizmo_group_type.c */ +struct wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet); +struct wmGizmoGroupType *WM_gizmogrouptype_append(void (*wtfunc)(struct wmGizmoGroupType *)); +struct wmGizmoGroupType *WM_gizmogrouptype_append_ptr(void (*mnpfunc)(struct wmGizmoGroupType *, void *), void *userdata); +bool WM_gizmogrouptype_free(const char *idname); +void WM_gizmogrouptype_free_ptr(struct wmGizmoGroupType *wt); +void WM_gizmogrouptype_iter(struct GHashIterator *ghi); + +struct wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link( + struct wmGizmoMapType *mmap_type, + void (*wtfunc)(struct wmGizmoGroupType *)); + +/* wm_gizmo_map.c */ /* Dynamic Updates (for RNA runtime registration) */ -void WM_manipulatorconfig_update_tag_init(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); -void WM_manipulatorconfig_update_tag_remove(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); -void WM_manipulatorconfig_update(struct Main *bmain); +void WM_gizmoconfig_update_tag_init(struct wmGizmoMapType *mmap_type, struct wmGizmoGroupType *wgt); +void WM_gizmoconfig_update_tag_remove(struct wmGizmoMapType *mmap_type, struct wmGizmoGroupType *wgt); +void WM_gizmoconfig_update(struct Main *bmain); /* wm_maniulator_target_props.c */ -struct wmManipulatorProperty *WM_manipulator_target_property_array(struct wmManipulator *mpr); -struct wmManipulatorProperty *WM_manipulator_target_property_at_index( - struct wmManipulator *mpr, int index); -struct wmManipulatorProperty *WM_manipulator_target_property_find( - struct wmManipulator *mpr, const char *idname); - -void WM_manipulator_target_property_def_rna_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, +struct wmGizmoProperty *WM_gizmo_target_property_array(struct wmGizmo *mpr); +struct wmGizmoProperty *WM_gizmo_target_property_at_index( + struct wmGizmo *mpr, int index); +struct wmGizmoProperty *WM_gizmo_target_property_find( + struct wmGizmo *mpr, const char *idname); + +void WM_gizmo_target_property_def_rna_ptr( + struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type, struct PointerRNA *ptr, struct PropertyRNA *prop, int index); -void WM_manipulator_target_property_def_rna( - struct wmManipulator *mpr, const char *idname, +void WM_gizmo_target_property_def_rna( + struct wmGizmo *mpr, const char *idname, struct PointerRNA *ptr, const char *propname, int index); -void WM_manipulator_target_property_def_func_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, - const struct wmManipulatorPropertyFnParams *params); -void WM_manipulator_target_property_def_func( - struct wmManipulator *mpr, const char *idname, - const struct wmManipulatorPropertyFnParams *params); - -void WM_manipulator_target_property_clear_rna_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type); -void WM_manipulator_target_property_clear_rna( - struct wmManipulator *mpr, const char *idname); - -bool WM_manipulator_target_property_is_valid_any(struct wmManipulator *mpr); -bool WM_manipulator_target_property_is_valid( - const struct wmManipulatorProperty *mpr_prop); -float WM_manipulator_target_property_value_get( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); -void WM_manipulator_target_property_value_set( - struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_def_func_ptr( + struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type, + const struct wmGizmoPropertyFnParams *params); +void WM_gizmo_target_property_def_func( + struct wmGizmo *mpr, const char *idname, + const struct wmGizmoPropertyFnParams *params); + +void WM_gizmo_target_property_clear_rna_ptr( + struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type); +void WM_gizmo_target_property_clear_rna( + struct wmGizmo *mpr, const char *idname); + +bool WM_gizmo_target_property_is_valid_any(struct wmGizmo *mpr); +bool WM_gizmo_target_property_is_valid( + const struct wmGizmoProperty *mpr_prop); +float WM_gizmo_target_property_value_get( + const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop); +void WM_gizmo_target_property_value_set( + struct bContext *C, const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, const float value); -void WM_manipulator_target_property_value_get_array( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_value_get_array( + const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, float *value); -void WM_manipulator_target_property_value_set_array( - struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_value_set_array( + struct bContext *C, const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, const float *value); -bool WM_manipulator_target_property_range_get( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, +bool WM_gizmo_target_property_range_get( + const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, float range[2]); -int WM_manipulator_target_property_array_length( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); +int WM_gizmo_target_property_array_length( + const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop); /* definitions */ -const struct wmManipulatorPropertyType *WM_manipulatortype_target_property_find( - const struct wmManipulatorType *wt, const char *idname); -void WM_manipulatortype_target_property_def( - struct wmManipulatorType *wt, const char *idname, int data_type, int array_length); +const struct wmGizmoPropertyType *WM_gizmotype_target_property_find( + const struct wmGizmoType *wt, const char *idname); +void WM_gizmotype_target_property_def( + struct wmGizmoType *wt, const char *idname, int data_type, int array_length); /* utilities */ -void WM_manipulator_do_msg_notify_tag_refresh( +void WM_gizmo_do_msg_notify_tag_refresh( struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val); -void WM_manipulator_target_property_subscribe_all( - struct wmManipulator *mpr, struct wmMsgBus *mbus, struct ARegion *ar); +void WM_gizmo_target_property_subscribe_all( + struct wmGizmo *mpr, struct wmMsgBus *mbus, struct ARegion *ar); /* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ +/* wmGizmoGroup */ -/* Callbacks for 'wmManipulatorGroupType.setup_keymap' */ -struct wmKeyMap *WM_manipulatorgroup_keymap_common( - const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); -struct wmKeyMap *WM_manipulatorgroup_keymap_common_select( - const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); +/* Callbacks for 'wmGizmoGroupType.setup_keymap' */ +struct wmKeyMap *WM_gizmogroup_keymap_common( + const struct wmGizmoGroupType *wgt, struct wmKeyConfig *config); +struct wmKeyMap *WM_gizmogroup_keymap_common_select( + const struct wmGizmoGroupType *wgt, struct wmKeyConfig *config); /* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ +/* wmGizmoMap */ -struct wmManipulatorMap *WM_manipulatormap_new_from_type( - const struct wmManipulatorMapType_Params *mmap_params); -const struct ListBase *WM_manipulatormap_group_list(struct wmManipulatorMap *mmap); -struct wmManipulatorGroup *WM_manipulatormap_group_find( - struct wmManipulatorMap *mmap, +struct wmGizmoMap *WM_gizmomap_new_from_type( + const struct wmGizmoMapType_Params *mmap_params); +const struct ListBase *WM_gizmomap_group_list(struct wmGizmoMap *mmap); +struct wmGizmoGroup *WM_gizmomap_group_find( + struct wmGizmoMap *mmap, const char *idname); -struct wmManipulatorGroup *WM_manipulatormap_group_find_ptr( - struct wmManipulatorMap *mmap, - const struct wmManipulatorGroupType *wgt); -void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap); -void WM_manipulatormap_draw( - struct wmManipulatorMap *mmap, const struct bContext *C, const eWM_ManipulatorMapDrawStep drawstep); -void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap *mmap); -bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action); -bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win); -void WM_manipulatormap_message_subscribe( - struct bContext *C, struct wmManipulatorMap *mmap, struct ARegion *ar, struct wmMsgBus *mbus); -bool WM_manipulatormap_is_any_selected(const struct wmManipulatorMap *mmap); -bool WM_manipulatormap_minmax( - const struct wmManipulatorMap *mmap, bool use_hidden, bool use_select, +struct wmGizmoGroup *WM_gizmomap_group_find_ptr( + struct wmGizmoMap *mmap, + const struct wmGizmoGroupType *wgt); +void WM_gizmomap_tag_refresh(struct wmGizmoMap *mmap); +void WM_gizmomap_draw( + struct wmGizmoMap *mmap, const struct bContext *C, const eWM_GizmoFlagMapDrawStep drawstep); +void WM_gizmomap_add_handlers(struct ARegion *ar, struct wmGizmoMap *mmap); +bool WM_gizmomap_select_all(struct bContext *C, struct wmGizmoMap *mmap, const int action); +bool WM_gizmomap_cursor_set(const struct wmGizmoMap *mmap, struct wmWindow *win); +void WM_gizmomap_message_subscribe( + struct bContext *C, struct wmGizmoMap *mmap, struct ARegion *ar, struct wmMsgBus *mbus); +bool WM_gizmomap_is_any_selected(const struct wmGizmoMap *mmap); +bool WM_gizmomap_minmax( + const struct wmGizmoMap *mmap, bool use_hidden, bool use_select, float r_min[3], float r_max[3]); -struct ARegion *WM_manipulatormap_tooltip_init( +struct ARegion *WM_gizmomap_tooltip_init( struct bContext *C, struct ARegion *ar, bool *r_exit_on_event); /* -------------------------------------------------------------------- */ -/* wmManipulatorMapType */ +/* wmGizmoMapType */ -struct wmManipulatorMapType *WM_manipulatormaptype_find( - const struct wmManipulatorMapType_Params *mmap_params); -struct wmManipulatorMapType *WM_manipulatormaptype_ensure( - const struct wmManipulatorMapType_Params *mmap_params); +struct wmGizmoMapType *WM_gizmomaptype_find( + const struct wmGizmoMapType_Params *mmap_params); +struct wmGizmoMapType *WM_gizmomaptype_ensure( + const struct wmGizmoMapType_Params *mmap_params); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( - struct wmManipulatorMapType *mmap_type, +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find( + struct wmGizmoMapType *mmap_type, const char *idname); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( - struct wmManipulatorMapType *mmap_type, - const struct wmManipulatorGroupType *wgt); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( - struct wmManipulatorMapType *mmap_type, +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr( + struct wmGizmoMapType *mmap_type, + const struct wmGizmoGroupType *wgt); +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_link( + struct wmGizmoMapType *mmap_type, const char *idname); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( - struct wmManipulatorMapType *mmap_type, - struct wmManipulatorGroupType *wgt); +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr( + struct wmGizmoMapType *mmap_type, + struct wmGizmoGroupType *wgt); -void WM_manipulatormaptype_group_init_runtime_keymap( +void WM_gizmomaptype_group_init_runtime_keymap( const struct Main *bmain, - struct wmManipulatorGroupType *wgt); -void WM_manipulatormaptype_group_init_runtime( - const struct Main *bmain, struct wmManipulatorMapType *mmap_type, - struct wmManipulatorGroupType *wgt); -void WM_manipulatormaptype_group_unlink( - struct bContext *C, struct Main *bmain, struct wmManipulatorMapType *mmap_type, - const struct wmManipulatorGroupType *wgt); + struct wmGizmoGroupType *wgt); +void WM_gizmomaptype_group_init_runtime( + const struct Main *bmain, struct wmGizmoMapType *mmap_type, + struct wmGizmoGroupType *wgt); +void WM_gizmomaptype_group_unlink( + struct bContext *C, struct Main *bmain, struct wmGizmoMapType *mmap_type, + const struct wmGizmoGroupType *wgt); -void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt); +void WM_gizmomaptype_group_free(struct wmGizmoGroupTypeRef *wgt); /* -------------------------------------------------------------------- */ -/* ManipulatorGroup */ +/* GizmoGroup */ /* Add/Ensure/Remove (High level API) */ -void WM_manipulator_group_type_add_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_add_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_add(const char *idname); - -void WM_manipulator_group_type_ensure_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_ensure_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_ensure(const char *idname); - -void WM_manipulator_group_type_remove_ptr_ex( - struct Main *bmain, struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_remove_ptr( - struct Main *bmain, struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname); - -void WM_manipulator_group_type_unlink_delayed_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_unlink_delayed_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_unlink_delayed(const char *idname); +void WM_gizmo_group_type_add_ptr_ex( + struct wmGizmoGroupType *wgt, + struct wmGizmoMapType *mmap_type); +void WM_gizmo_group_type_add_ptr( + struct wmGizmoGroupType *wgt); +void WM_gizmo_group_type_add(const char *idname); + +void WM_gizmo_group_type_ensure_ptr_ex( + struct wmGizmoGroupType *wgt, + struct wmGizmoMapType *mmap_type); +void WM_gizmo_group_type_ensure_ptr( + struct wmGizmoGroupType *wgt); +void WM_gizmo_group_type_ensure(const char *idname); + +void WM_gizmo_group_type_remove_ptr_ex( + struct Main *bmain, struct wmGizmoGroupType *wgt, + struct wmGizmoMapType *mmap_type); +void WM_gizmo_group_type_remove_ptr( + struct Main *bmain, struct wmGizmoGroupType *wgt); +void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname); + +void WM_gizmo_group_type_unlink_delayed_ptr_ex( + struct wmGizmoGroupType *wgt, + struct wmGizmoMapType *mmap_type); +void WM_gizmo_group_type_unlink_delayed_ptr( + struct wmGizmoGroupType *wgt); +void WM_gizmo_group_type_unlink_delayed(const char *idname); /* Utilities */ -bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step); +bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step); -bool WM_manipulator_group_type_poll(const struct bContext *C, const struct wmManipulatorGroupType *wgt); +bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *wgt); #endif /* __WM_GIZMO_API_H__ */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index 0f6af6db24c..ecdda256306 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -26,8 +26,8 @@ /** \file blender/windowmanager/gizmo/WM_gizmo_types.h * \ingroup wm * - * \name Manipulator Types - * \brief Manipulator defines for external use. + * \name Gizmo Types + * \brief Gizmo defines for external use. * * Only included in WM_types.h and lower level files. */ @@ -38,11 +38,11 @@ #include "BLI_compiler_attrs.h" -struct wmManipulatorMapType; -struct wmManipulatorGroupType; -struct wmManipulatorGroup; -struct wmManipulator; -struct wmManipulatorProperty; +struct wmGizmoMapType; +struct wmGizmoGroupType; +struct wmGizmoGroup; +struct wmGizmo; +struct wmGizmoProperty; struct wmKeyConfig; #include "DNA_listBase.h" @@ -53,154 +53,154 @@ struct wmKeyConfig; /** - * #wmManipulator.state + * #wmGizmo.state */ -typedef enum eWM_ManipulatorState { - WM_MANIPULATOR_STATE_HIGHLIGHT = (1 << 0), /* while hovered */ - WM_MANIPULATOR_STATE_MODAL = (1 << 1), /* while dragging */ - WM_MANIPULATOR_STATE_SELECT = (1 << 2), -} eWM_ManipulatorState; +typedef enum eWM_GizmoFlagState { + WM_GIZMO_STATE_HIGHLIGHT = (1 << 0), /* while hovered */ + WM_GIZMO_STATE_MODAL = (1 << 1), /* while dragging */ + WM_GIZMO_STATE_SELECT = (1 << 2), +} eWM_GizmoFlagState; /** - * #wmManipulator.flag - * Flags for individual manipulators. + * #wmGizmo.flag + * Flags for individual gizmos. */ -typedef enum eWM_ManipulatorFlag { - WM_MANIPULATOR_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */ - WM_MANIPULATOR_DRAW_MODAL = (1 << 1), /* draw while dragging */ - WM_MANIPULATOR_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */ - WM_MANIPULATOR_HIDDEN = (1 << 3), +typedef enum eWM_GizmoFlagFlag { + WM_GIZMO_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */ + WM_GIZMO_DRAW_MODAL = (1 << 1), /* draw while dragging */ + WM_GIZMO_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */ + WM_GIZMO_HIDDEN = (1 << 3), /** * When set 'scale_final' value also scales the offset. * Use when offset is to avoid screen-space overlap instead of absolute positioning. */ - WM_MANIPULATOR_DRAW_OFFSET_SCALE = (1 << 4), + WM_GIZMO_DRAW_OFFSET_SCALE = (1 << 4), /** * User should still use 'scale_final' for any handles and UI elements. * This simply skips scale when calculating the final matrix. - * Needed when the manipulator needs to align with the interface underneath it. */ - WM_MANIPULATOR_DRAW_NO_SCALE = (1 << 5), + * Needed when the gizmo needs to align with the interface underneath it. */ + WM_GIZMO_DRAW_NO_SCALE = (1 << 5), /** - * Hide the cursor and lock it's position while interacting with this manipulator. + * Hide the cursor and lock it's position while interacting with this gizmo. */ - WM_MANIPULATOR_GRAB_CURSOR = (1 << 6), + WM_GIZMO_GRAB_CURSOR = (1 << 6), /** Don't write into the depth buffer when selecting. */ - WM_MANIPULATOR_SELECT_BACKGROUND = (1 << 7), -} eWM_ManipulatorFlag; + WM_GIZMO_SELECT_BACKGROUND = (1 << 7), +} eWM_GizmoFlagFlag; /** - * #wmManipulatorGroupType.flag - * Flags that influence the behavior of all manipulators in the group. + * #wmGizmoGroupType.flag + * Flags that influence the behavior of all gizmos in the group. */ -typedef enum eWM_ManipulatorGroupTypeFlag { - /* Mark manipulator-group as being 3D */ - WM_MANIPULATORGROUPTYPE_3D = (1 << 0), - /* Scale manipulators as 3D object that respects zoom (otherwise zoom independent draw size). +typedef enum eWM_GizmoFlagGroupTypeFlag { + /* Mark gizmo-group as being 3D */ + WM_GIZMOGROUPTYPE_3D = (1 << 0), + /* Scale gizmos as 3D object that respects zoom (otherwise zoom independent draw size). * note: currently only for 3D views, 2D support needs adding. */ - WM_MANIPULATORGROUPTYPE_SCALE = (1 << 1), - /* Manipulators can be depth culled with scene objects (covered by other geometry - TODO) */ - WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2), - /* Manipulators can be selected */ - WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3), - /* The manipulator group is to be kept (not removed on loading a new file for eg). */ - WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4), - /* Show all other manipulators when interacting. */ - WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL = (1 << 5), -} eWM_ManipulatorGroupTypeFlag; + WM_GIZMOGROUPTYPE_SCALE = (1 << 1), + /* Gizmos can be depth culled with scene objects (covered by other geometry - TODO) */ + WM_GIZMOGROUPTYPE_DEPTH_3D = (1 << 2), + /* Gizmos can be selected */ + WM_GIZMOGROUPTYPE_SELECT = (1 << 3), + /* The gizmo group is to be kept (not removed on loading a new file for eg). */ + WM_GIZMOGROUPTYPE_PERSISTENT = (1 << 4), + /* Show all other gizmos when interacting. */ + WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL = (1 << 5), +} eWM_GizmoFlagGroupTypeFlag; /** - * #wmManipulatorGroup.init_flag + * #wmGizmoGroup.init_flag */ -typedef enum eWM_ManipulatorGroupInitFlag { +typedef enum eWM_GizmoFlagGroupInitFlag { /* mgroup has been initialized */ - WM_MANIPULATORGROUP_INIT_SETUP = (1 << 0), - WM_MANIPULATORGROUP_INIT_REFRESH = (1 << 1), -} eWM_ManipulatorGroupInitFlag; + WM_GIZMOGROUP_INIT_SETUP = (1 << 0), + WM_GIZMOGROUP_INIT_REFRESH = (1 << 1), +} eWM_GizmoFlagGroupInitFlag; /** - * #wmManipulatorMapType.type_update_flag - * Manipulator-map type update flag + * #wmGizmoMapType.type_update_flag + * Gizmo-map type update flag */ -typedef enum eWM_ManipulatorMapTypeUpdateFlag { +typedef enum eWM_GizmoFlagMapTypeUpdateFlag { /* A new type has been added, needs to be initialized for all views. */ - WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0), - WM_MANIPULATORMAPTYPE_UPDATE_REMOVE = (1 << 1), + WM_GIZMOMAPTYPE_UPDATE_INIT = (1 << 0), + WM_GIZMOMAPTYPE_UPDATE_REMOVE = (1 << 1), /* Needed because keymap may be registered before and after window initialization. * So we need to keep track of keymap initialization separately. */ - WM_MANIPULATORMAPTYPE_KEYMAP_INIT = (1 << 2), -} eWM_ManipulatorMapTypeUpdateFlag; + WM_GIZMOMAPTYPE_KEYMAP_INIT = (1 << 2), +} eWM_GizmoFlagMapTypeUpdateFlag; /* -------------------------------------------------------------------- */ -/* wmManipulator */ +/* wmGizmo */ /** - * \brief Manipulator tweak flag. - * Bitflag passed to manipulator while tweaking. + * \brief Gizmo tweak flag. + * Bitflag passed to gizmo while tweaking. * - * \note Manipulators are responsible for handling this #wmManipulator.modal callback!. + * \note Gizmos are responsible for handling this #wmGizmo.modal callback!. */ typedef enum { /* Drag with extra precision (Shift). */ - WM_MANIPULATOR_TWEAK_PRECISE = (1 << 0), + WM_GIZMO_TWEAK_PRECISE = (1 << 0), /* Drag with snap enabled (Ctrl). */ - WM_MANIPULATOR_TWEAK_SNAP = (1 << 1), -} eWM_ManipulatorTweak; + WM_GIZMO_TWEAK_SNAP = (1 << 1), +} eWM_GizmoFlagTweak; #include "wm_gizmo_fn.h" -typedef struct wmManipulatorOpElem { +typedef struct wmGizmoOpElem { struct wmOperatorType *type; - /* operator properties if manipulator spawns and controls an operator, - * or owner pointer if manipulator spawns and controls a property */ + /* operator properties if gizmo spawns and controls an operator, + * or owner pointer if gizmo spawns and controls a property */ PointerRNA ptr; bool is_redo; -} wmManipulatorOpElem; +} wmGizmoOpElem; -/* manipulators are set per region by registering them on manipulator-maps */ -struct wmManipulator { - struct wmManipulator *next, *prev; +/* gizmos are set per region by registering them on gizmo-maps */ +struct wmGizmo { + struct wmGizmo *next, *prev; /* While we don't have a real type, use this to put type-like vars. */ - const struct wmManipulatorType *type; + const struct wmGizmoType *type; /* Overrides 'type->modal' when set. * Note that this is a workaround, remove if we can. */ - wmManipulatorFnModal custom_modal; + wmGizmoFnModal custom_modal; - /* pointer back to group this manipulator is in (just for quick access) */ - struct wmManipulatorGroup *parent_mgroup; + /* pointer back to group this gizmo is in (just for quick access) */ + struct wmGizmoGroup *parent_mgroup; void *py_instance; /* rna pointer to access properties */ struct PointerRNA *ptr; - /* flags that influence the behavior or how the manipulators are drawn */ - eWM_ManipulatorFlag flag; + /* flags that influence the behavior or how the gizmos are drawn */ + eWM_GizmoFlagFlag flag; /* state flags (active, highlighted, selected) */ - eWM_ManipulatorState state; + eWM_GizmoFlagState state; - /* Optional ID for highlighting different parts of this manipulator. + /* Optional ID for highlighting different parts of this gizmo. * -1 when unset, otherwise a valid index. (Used as index to 'op_data'). */ int highlight_part; - /* For single click button manipulators, use a different part as a fallback, -1 when unused. */ + /* For single click button gizmos, use a different part as a fallback, -1 when unused. */ int drag_part; - /* Transformation of the manipulator in 2d or 3d space. + /* Transformation of the gizmo in 2d or 3d space. * - Matrix axis are expected to be unit length (scale is applied after). - * - Behavior when axis aren't orthogonal depends on each manipulator. - * - Typically the +Z is the primary axis for manipulators to use. + * - Behavior when axis aren't orthogonal depends on each gizmo. + * - Typically the +Z is the primary axis for gizmos to use. * - 'matrix[3]' must be used for location, - * besides this it's up to the manipulators internal code how the + * besides this it's up to the gizmos internal code how the * rotation components are used for drawing and interaction. */ - /* The space this manipulator is being modified in. */ + /* The space this gizmo is being modified in. */ float matrix_space[4][4]; - /* Transformation of this manipulator. */ + /* Transformation of this gizmo. */ float matrix_basis[4][4]; /* custom offset from origin */ float matrix_offset[4][4]; @@ -210,25 +210,25 @@ struct wmManipulator { float scale_basis; /* user defined width for line drawing */ float line_width; - /* manipulator colors (uses default fallbacks if not defined) */ + /* gizmo colors (uses default fallbacks if not defined) */ float color[4], color_hi[4]; /* data used during interaction */ void *interaction_data; - /* Operator to spawn when activating the manipulator (overrides property editing), - * an array of items (aligned with #wmManipulator.highlight_part). */ - wmManipulatorOpElem *op_data; + /* Operator to spawn when activating the gizmo (overrides property editing), + * an array of items (aligned with #wmGizmo.highlight_part). */ + wmGizmoOpElem *op_data; int op_data_len; struct IDProperty *properties; - /* over alloc target_properties after 'wmManipulatorType.struct_size' */ + /* over alloc target_properties after 'wmGizmoType.struct_size' */ }; /* Similar to PropertyElemRNA, but has an identifier. */ -typedef struct wmManipulatorProperty { - const struct wmManipulatorPropertyType *type; +typedef struct wmGizmoProperty { + const struct wmGizmoPropertyType *type; PointerRNA ptr; PropertyRNA *prop; @@ -237,88 +237,88 @@ typedef struct wmManipulatorProperty { /* Optional functions for converting to/from RNA */ struct { - wmManipulatorPropertyFnGet value_get_fn; - wmManipulatorPropertyFnSet value_set_fn; - wmManipulatorPropertyFnRangeGet range_get_fn; - wmManipulatorPropertyFnFree free_fn; + wmGizmoPropertyFnGet value_get_fn; + wmGizmoPropertyFnSet value_set_fn; + wmGizmoPropertyFnRangeGet range_get_fn; + wmGizmoPropertyFnFree free_fn; void *user_data; } custom_func; -} wmManipulatorProperty; +} wmGizmoProperty; -typedef struct wmManipulatorPropertyType { - struct wmManipulatorPropertyType *next, *prev; +typedef struct wmGizmoPropertyType { + struct wmGizmoPropertyType *next, *prev; /* PropertyType, typically 'PROP_FLOAT' */ int data_type; int array_length; - /* index within 'wmManipulatorType' */ + /* index within 'wmGizmoType' */ int index_in_type; /* over alloc */ char idname[0]; -} wmManipulatorPropertyType; +} wmGizmoPropertyType; /** - * Simple utility wrapper for storing a single manipulator as wmManipulatorGroup.customdata (which gets freed). + * Simple utility wrapper for storing a single gizmo as wmGizmoGroup.customdata (which gets freed). */ -typedef struct wmManipulatorWrapper { - struct wmManipulator *manipulator; -} wmManipulatorWrapper; +typedef struct wmGizmoWrapper { + struct wmGizmo *gizmo; +} wmGizmoWrapper; -struct wmManipulatorMapType_Params { +struct wmGizmoMapType_Params { short spaceid; short regionid; }; -typedef struct wmManipulatorType { +typedef struct wmGizmoType { const char *idname; /* MAX_NAME */ - /* Set to 'sizeof(wmManipulator)' or larger for instances of this type, + /* Set to 'sizeof(wmGizmo)' or larger for instances of this type, * use so we can cant to other types without the hassle of a custom-data pointer. */ uint struct_size; /* Initialize struct (calloc'd 'struct_size' region). */ - wmManipulatorFnSetup setup; + wmGizmoFnSetup setup; - /* draw manipulator */ - wmManipulatorFnDraw draw; + /* draw gizmo */ + wmGizmoFnDraw draw; - /* determines 3d intersection by rendering the manipulator in a selection routine. */ - wmManipulatorFnDrawSelect draw_select; + /* determines 3d intersection by rendering the gizmo in a selection routine. */ + wmGizmoFnDrawSelect draw_select; - /* Determine if the mouse intersects with the manipulator. + /* Determine if the mouse intersects with the gizmo. * The calculation should be done in the callback itself, -1 for no seleciton. */ - wmManipulatorFnTestSelect test_select; + wmGizmoFnTestSelect test_select; - /* handler used by the manipulator. Usually handles interaction tied to a manipulator type */ - wmManipulatorFnModal modal; + /* handler used by the gizmo. Usually handles interaction tied to a gizmo type */ + wmGizmoFnModal modal; - /* manipulator-specific handler to update manipulator attributes based on the property value */ - wmManipulatorFnPropertyUpdate property_update; + /* gizmo-specific handler to update gizmo attributes based on the property value */ + wmGizmoFnPropertyUpdate property_update; /* Returns the final transformation which may be different from the 'matrix', - * depending on the manipulator. + * depending on the gizmo. * Notes: - * - Scale isn't applied (wmManipulator.scale/user_scale). - * - Offset isn't applied (wmManipulator.matrix_offset). + * - Scale isn't applied (wmGizmo.scale/user_scale). + * - Offset isn't applied (wmGizmo.matrix_offset). */ - wmManipulatorFnMatrixBasisGet matrix_basis_get; + wmGizmoFnMatrixBasisGet matrix_basis_get; - /* activate a manipulator state when the user clicks on it */ - wmManipulatorFnInvoke invoke; + /* activate a gizmo state when the user clicks on it */ + wmGizmoFnInvoke invoke; - /* called when manipulator tweaking is done - used to free data and reset property when cancelling */ - wmManipulatorFnExit exit; + /* called when gizmo tweaking is done - used to free data and reset property when cancelling */ + wmGizmoFnExit exit; - wmManipulatorFnCursorGet cursor_get; + wmGizmoFnCursorGet cursor_get; - /* called when manipulator selection state changes */ - wmManipulatorFnSelectRefresh select_refresh; + /* called when gizmo selection state changes */ + wmGizmoFnSelectRefresh select_refresh; - /* Free data (not the manipulator it's self), use when the manipulator allocates it's own members. */ - wmManipulatorFnFree free; + /* Free data (not the gizmo it's self), use when the gizmo allocates it's own members. */ + wmGizmoFnFree free; /* RNA for properties */ struct StructRNA *srna; @@ -329,41 +329,41 @@ typedef struct wmManipulatorType { ListBase target_property_defs; int target_property_defs_len; -} wmManipulatorType; +} wmGizmoType; /* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ +/* wmGizmoGroup */ -/* factory class for a manipulator-group type, gets called every time a new area is spawned */ -typedef struct wmManipulatorGroupTypeRef { - struct wmManipulatorGroupTypeRef *next, *prev; - struct wmManipulatorGroupType *type; -} wmManipulatorGroupTypeRef; +/* factory class for a gizmo-group type, gets called every time a new area is spawned */ +typedef struct wmGizmoGroupTypeRef { + struct wmGizmoGroupTypeRef *next, *prev; + struct wmGizmoGroupType *type; +} wmGizmoGroupTypeRef; -/* factory class for a manipulator-group type, gets called every time a new area is spawned */ -typedef struct wmManipulatorGroupType { +/* factory class for a gizmo-group type, gets called every time a new area is spawned */ +typedef struct wmGizmoGroupType { const char *idname; /* MAX_NAME */ - const char *name; /* manipulator-group name - displayed in UI (keymap editor) */ + const char *name; /* gizmo-group name - displayed in UI (keymap editor) */ char owner_id[64]; /* MAX_NAME */ - /* poll if manipulator-map should be visible */ - wmManipulatorGroupFnPoll poll; - /* initially create manipulators and set permanent data - stuff you only need to do once */ - wmManipulatorGroupFnInit setup; - /* refresh data, only called if recreate flag is set (WM_manipulatormap_tag_refresh) */ - wmManipulatorGroupFnRefresh refresh; + /* poll if gizmo-map should be visible */ + wmGizmoGroupFnPoll poll; + /* initially create gizmos and set permanent data - stuff you only need to do once */ + wmGizmoGroupFnInit setup; + /* refresh data, only called if recreate flag is set (WM_gizmomap_tag_refresh) */ + wmGizmoGroupFnRefresh refresh; /* refresh data for drawing, called before each redraw */ - wmManipulatorGroupFnDrawPrepare draw_prepare; + wmGizmoGroupFnDrawPrepare draw_prepare; - /* Keymap init callback for this manipulator-group (optional), + /* Keymap init callback for this gizmo-group (optional), * will fall back to default tweak keymap when left NULL. */ - wmManipulatorGroupFnSetupKeymap setup_keymap; + wmGizmoGroupFnSetupKeymap setup_keymap; /* Optionally subscribe to wmMsgBus events, * these are calculated automatically from RNA properties, - * only needed if manipulators depend indirectly on properties. */ - wmManipulatorGroupFnMsgBusSubscribe message_subscribe; + * only needed if gizmos depend indirectly on properties. */ + wmGizmoGroupFnMsgBusSubscribe message_subscribe; /* keymap created with callback from above */ struct wmKeyMap *keymap; @@ -379,44 +379,44 @@ typedef struct wmManipulatorGroupType { /* RNA integration */ ExtensionRNA ext; - eWM_ManipulatorGroupTypeFlag flag; + eWM_GizmoFlagGroupTypeFlag flag; /* So we know which group type to update. */ - eWM_ManipulatorMapTypeUpdateFlag type_update_flag; + eWM_GizmoFlagMapTypeUpdateFlag type_update_flag; - /* same as manipulator-maps, so registering/unregistering goes to the correct region */ - struct wmManipulatorMapType_Params mmap_params; + /* same as gizmo-maps, so registering/unregistering goes to the correct region */ + struct wmGizmoMapType_Params mmap_params; -} wmManipulatorGroupType; +} wmGizmoGroupType; -typedef struct wmManipulatorGroup { - struct wmManipulatorGroup *next, *prev; +typedef struct wmGizmoGroup { + struct wmGizmoGroup *next, *prev; - struct wmManipulatorGroupType *type; - ListBase manipulators; + struct wmGizmoGroupType *type; + ListBase gizmos; - struct wmManipulatorMap *parent_mmap; + struct wmGizmoMap *parent_mmap; void *py_instance; /* python stores the class instance here */ struct ReportList *reports; /* errors and warnings storage */ void *customdata; void (*customdata_free)(void *); /* for freeing customdata from above */ - eWM_ManipulatorGroupInitFlag init_flag; -} wmManipulatorGroup; + eWM_GizmoFlagGroupInitFlag init_flag; +} wmGizmoGroup; /* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ +/* wmGizmoMap */ /** - * Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw. + * Pass a value of this enum to #WM_gizmomap_draw to tell it what to draw. */ -typedef enum eWM_ManipulatorMapDrawStep { - /** Draw 2D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D not set). */ - WM_MANIPULATORMAP_DRAWSTEP_2D = 0, - /** Draw 3D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D set). */ - WM_MANIPULATORMAP_DRAWSTEP_3D, -} eWM_ManipulatorMapDrawStep; -#define WM_MANIPULATORMAP_DRAWSTEP_MAX 2 +typedef enum eWM_GizmoFlagMapDrawStep { + /** Draw 2D gizmo-groups (#WM_GIZMOGROUPTYPE_3D not set). */ + WM_GIZMOMAP_DRAWSTEP_2D = 0, + /** Draw 3D gizmo-groups (#WM_GIZMOGROUPTYPE_3D set). */ + WM_GIZMOMAP_DRAWSTEP_3D, +} eWM_GizmoFlagMapDrawStep; +#define WM_GIZMOMAP_DRAWSTEP_MAX 2 #endif /* __WM_GIZMO_TYPES_H__ */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c index bef193f6c56..da8b301b536 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c @@ -59,42 +59,42 @@ #include "BPY_extern.h" #endif -/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */ #include "wm.h" /* own includes */ #include "wm_gizmo_wmapi.h" #include "wm_gizmo_intern.h" -static void wm_manipulator_register( - wmManipulatorGroup *mgroup, wmManipulator *mpr); +static void wm_gizmo_register( + wmGizmoGroup *mgroup, wmGizmo *mpr); /** * \note Follow #wm_operator_create convention. */ -static wmManipulator *wm_manipulator_create( - const wmManipulatorType *wt, +static wmGizmo *wm_gizmo_create( + const wmGizmoType *wt, PointerRNA *properties) { BLI_assert(wt != NULL); - BLI_assert(wt->struct_size >= sizeof(wmManipulator)); + BLI_assert(wt->struct_size >= sizeof(wmGizmo)); - wmManipulator *mpr = MEM_callocN( - wt->struct_size + (sizeof(wmManipulatorProperty) * wt->target_property_defs_len), __func__); + wmGizmo *mpr = MEM_callocN( + wt->struct_size + (sizeof(wmGizmoProperty) * wt->target_property_defs_len), __func__); mpr->type = wt; /* initialize properties, either copy or create */ - mpr->ptr = MEM_callocN(sizeof(PointerRNA), "wmManipulatorPtrRNA"); + mpr->ptr = MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA"); if (properties && properties->data) { mpr->properties = IDP_CopyProperty(properties->data); } else { IDPropertyTemplate val = {0}; - mpr->properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties"); + mpr->properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties"); } RNA_pointer_create(G_MAIN->wm.first, wt->srna, mpr->properties, mpr->ptr); - WM_manipulator_properties_sanitize(mpr->ptr, 0); + WM_gizmo_properties_sanitize(mpr->ptr, 0); unit_m4(mpr->matrix_space); unit_m4(mpr->matrix_basis); @@ -105,13 +105,13 @@ static wmManipulator *wm_manipulator_create( return mpr; } -wmManipulator *WM_manipulator_new_ptr( - const wmManipulatorType *wt, wmManipulatorGroup *mgroup, +wmGizmo *WM_gizmo_new_ptr( + const wmGizmoType *wt, wmGizmoGroup *mgroup, PointerRNA *properties) { - wmManipulator *mpr = wm_manipulator_create(wt, properties); + wmGizmo *mpr = wm_gizmo_create(wt, properties); - wm_manipulator_register(mgroup, mpr); + wm_gizmo_register(mgroup, mpr); if (mpr->type->setup != NULL) { mpr->type->setup(mpr); @@ -122,21 +122,21 @@ wmManipulator *WM_manipulator_new_ptr( /** * \param wt: Must be valid, - * if you need to check it exists use #WM_manipulator_new_ptr + * if you need to check it exists use #WM_gizmo_new_ptr * because callers of this function don't NULL check the return value. */ -wmManipulator *WM_manipulator_new( - const char *idname, wmManipulatorGroup *mgroup, +wmGizmo *WM_gizmo_new( + const char *idname, wmGizmoGroup *mgroup, PointerRNA *properties) { - const wmManipulatorType *wt = WM_manipulatortype_find(idname, false); - return WM_manipulator_new_ptr(wt, mgroup, properties); + const wmGizmoType *wt = WM_gizmotype_find(idname, false); + return WM_gizmo_new_ptr(wt, mgroup, properties); } /** * Initialize default values and allocate needed memory for members. */ -static void manipulator_init(wmManipulator *mpr) +static void gizmo_init(wmGizmo *mpr) { const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -149,24 +149,24 @@ static void manipulator_init(wmManipulator *mpr) } /** - * Register \a manipulator. + * Register \a gizmo. * - * \param name: name used to create a unique idname for \a manipulator in \a mgroup + * \param name: name used to create a unique idname for \a gizmo in \a mgroup * * \note Not to be confused with type registration from RNA. */ -static void wm_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr) +static void wm_gizmo_register(wmGizmoGroup *mgroup, wmGizmo *mpr) { - manipulator_init(mpr); - wm_manipulatorgroup_manipulator_register(mgroup, mpr); + gizmo_init(mpr); + wm_gizmogroup_gizmo_register(mgroup, mpr); } /** - * \warning this doesn't check #wmManipulatorMap (highlight, selection etc). + * \warning this doesn't check #wmGizmoMap (highlight, selection etc). * Typical use is when freeing the windowing data, * where caller can manage clearing selection, highlight... etc. */ -void WM_manipulator_free(wmManipulator *mpr) +void WM_gizmo_free(wmGizmo *mpr) { if (mpr->type->free != NULL) { mpr->type->free(mpr); @@ -188,14 +188,14 @@ void WM_manipulator_free(wmManipulator *mpr) } if (mpr->ptr != NULL) { - WM_manipulator_properties_free(mpr->ptr); + WM_gizmo_properties_free(mpr->ptr); MEM_freeN(mpr->ptr); } if (mpr->type->target_property_defs_len != 0) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; if (mpr_prop->custom_func.free_fn) { mpr_prop->custom_func.free_fn(mpr, mpr_prop); } @@ -206,41 +206,41 @@ void WM_manipulator_free(wmManipulator *mpr) } /** - * Free \a manipulator and unlink from \a manipulatorlist. - * \a manipulatorlist is allowed to be NULL. + * Free \a gizmo and unlink from \a gizmolist. + * \a gizmolist is allowed to be NULL. */ -void WM_manipulator_unlink(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmManipulator *mpr, bContext *C) +void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *mmap, wmGizmo *mpr, bContext *C) { - if (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + if (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) { + wm_gizmomap_highlight_set(mmap, C, NULL, 0); } - if (mpr->state & WM_MANIPULATOR_STATE_MODAL) { - wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false); + if (mpr->state & WM_GIZMO_STATE_MODAL) { + wm_gizmomap_modal_set(mmap, C, mpr, NULL, false); } /* Unlink instead of setting so we don't run callbacks. */ - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { - WM_manipulator_select_unlink(mmap, mpr); + if (mpr->state & WM_GIZMO_STATE_SELECT) { + WM_gizmo_select_unlink(mmap, mpr); } - if (manipulatorlist) { - BLI_remlink(manipulatorlist, mpr); + if (gizmolist) { + BLI_remlink(gizmolist, mpr); } BLI_assert(mmap->mmap_context.highlight != mpr); BLI_assert(mmap->mmap_context.modal != mpr); - WM_manipulator_free(mpr); + WM_gizmo_free(mpr); } /* -------------------------------------------------------------------- */ -/** \name Manipulator Creation API +/** \name Gizmo Creation API * - * API for defining data on manipulator creation. + * API for defining data on gizmo creation. * * \{ */ -struct wmManipulatorOpElem *WM_manipulator_operator_get( - wmManipulator *mpr, int part_index) +struct wmGizmoOpElem *WM_gizmo_operator_get( + wmGizmo *mpr, int part_index) { if (mpr->op_data && ((part_index >= 0) && (part_index < mpr->op_data_len))) { return &mpr->op_data[part_index]; @@ -248,8 +248,8 @@ struct wmManipulatorOpElem *WM_manipulator_operator_get( return NULL; } -PointerRNA *WM_manipulator_operator_set( - wmManipulator *mpr, int part_index, +PointerRNA *WM_gizmo_operator_set( + wmGizmo *mpr, int part_index, wmOperatorType *ot, IDProperty *properties) { BLI_assert(part_index < 255); @@ -258,7 +258,7 @@ PointerRNA *WM_manipulator_operator_set( mpr->op_data_len = part_index + 1; mpr->op_data = MEM_recallocN(mpr->op_data, sizeof(*mpr->op_data) * mpr->op_data_len); } - wmManipulatorOpElem *mpop = &mpr->op_data[part_index]; + wmGizmoOpElem *mpop = &mpr->op_data[part_index]; mpop->type = ot; if (mpop->ptr.data) { @@ -273,7 +273,7 @@ PointerRNA *WM_manipulator_operator_set( return &mpop->ptr; } -static void wm_manipulator_set_matrix_rotation_from_z_axis__internal( +static void wm_gizmo_set_matrix_rotation_from_z_axis__internal( float matrix[4][4], const float z_axis[3]) { /* old code, seems we can use simpler method */ @@ -292,7 +292,7 @@ static void wm_manipulator_set_matrix_rotation_from_z_axis__internal( } -static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal( +static void wm_gizmo_set_matrix_rotation_from_yz_axis__internal( float matrix[4][4], const float y_axis[3], const float z_axis[3]) { normalize_v3_v3(matrix[1], y_axis); @@ -302,42 +302,42 @@ static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal( } /** - * wmManipulator.matrix utils. + * wmGizmo.matrix utils. */ -void WM_manipulator_set_matrix_rotation_from_z_axis( - wmManipulator *mpr, const float z_axis[3]) +void WM_gizmo_set_matrix_rotation_from_z_axis( + wmGizmo *mpr, const float z_axis[3]) { - wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis); + wm_gizmo_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis); } -void WM_manipulator_set_matrix_rotation_from_yz_axis( - wmManipulator *mpr, const float y_axis[3], const float z_axis[3]) +void WM_gizmo_set_matrix_rotation_from_yz_axis( + wmGizmo *mpr, const float y_axis[3], const float z_axis[3]) { - wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis); + wm_gizmo_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis); } -void WM_manipulator_set_matrix_location(wmManipulator *mpr, const float origin[3]) +void WM_gizmo_set_matrix_location(wmGizmo *mpr, const float origin[3]) { copy_v3_v3(mpr->matrix_basis[3], origin); } /** - * wmManipulator.matrix_offset utils. + * wmGizmo.matrix_offset utils. */ -void WM_manipulator_set_matrix_offset_rotation_from_z_axis( - wmManipulator *mpr, const float z_axis[3]) +void WM_gizmo_set_matrix_offset_rotation_from_z_axis( + wmGizmo *mpr, const float z_axis[3]) { - wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis); + wm_gizmo_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis); } -void WM_manipulator_set_matrix_offset_rotation_from_yz_axis( - wmManipulator *mpr, const float y_axis[3], const float z_axis[3]) +void WM_gizmo_set_matrix_offset_rotation_from_yz_axis( + wmGizmo *mpr, const float y_axis[3], const float z_axis[3]) { - wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis); + wm_gizmo_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis); } -void WM_manipulator_set_matrix_offset_location(wmManipulator *mpr, const float offset[3]) +void WM_gizmo_set_matrix_offset_location(wmGizmo *mpr, const float offset[3]) { copy_v3_v3(mpr->matrix_offset[3], offset); } -void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enable) +void WM_gizmo_set_flag(wmGizmo *mpr, const int flag, const bool enable) { if (enable) { mpr->flag |= flag; @@ -347,50 +347,50 @@ void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enab } } -void WM_manipulator_set_scale(wmManipulator *mpr, const float scale) +void WM_gizmo_set_scale(wmGizmo *mpr, const float scale) { mpr->scale_basis = scale; } -void WM_manipulator_set_line_width(wmManipulator *mpr, const float line_width) +void WM_gizmo_set_line_width(wmGizmo *mpr, const float line_width) { mpr->line_width = line_width; } /** - * Set manipulator rgba colors. + * Set gizmo rgba colors. * * \param col Normal state color. * \param col_hi Highlighted state color. */ -void WM_manipulator_get_color(const wmManipulator *mpr, float color[4]) +void WM_gizmo_get_color(const wmGizmo *mpr, float color[4]) { copy_v4_v4(color, mpr->color); } -void WM_manipulator_set_color(wmManipulator *mpr, const float color[4]) +void WM_gizmo_set_color(wmGizmo *mpr, const float color[4]) { copy_v4_v4(mpr->color, color); } -void WM_manipulator_get_color_highlight(const wmManipulator *mpr, float color_hi[4]) +void WM_gizmo_get_color_highlight(const wmGizmo *mpr, float color_hi[4]) { copy_v4_v4(color_hi, mpr->color_hi); } -void WM_manipulator_set_color_highlight(wmManipulator *mpr, const float color_hi[4]) +void WM_gizmo_set_color_highlight(wmGizmo *mpr, const float color_hi[4]) { copy_v4_v4(mpr->color_hi, color_hi); } -/** \} */ // Manipulator Creation API +/** \} */ // Gizmo Creation API /* -------------------------------------------------------------------- */ -/** \name Manipulator Callback Assignment +/** \name Gizmo Callback Assignment * * \{ */ -void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn) +void WM_gizmo_set_fn_custom_modal(struct wmGizmo *mpr, wmGizmoFnModal fn) { mpr->custom_modal = fn; } @@ -401,32 +401,32 @@ void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulator /* -------------------------------------------------------------------- */ /** - * Add/Remove \a manipulator to selection. - * Reallocates memory for selected manipulators so better not call for selecting multiple ones. + * Add/Remove \a gizmo to selection. + * Reallocates memory for selected gizmos so better not call for selecting multiple ones. * * \return if the selection has changed. */ -bool wm_manipulator_select_set_ex( - wmManipulatorMap *mmap, wmManipulator *mpr, bool select, +bool wm_gizmo_select_set_ex( + wmGizmoMap *mmap, wmGizmo *mpr, bool select, bool use_array, bool use_callback) { bool changed = false; if (select) { - if ((mpr->state & WM_MANIPULATOR_STATE_SELECT) == 0) { + if ((mpr->state & WM_GIZMO_STATE_SELECT) == 0) { if (use_array) { - wm_manipulatormap_select_array_push_back(mmap, mpr); + wm_gizmomap_select_array_push_back(mmap, mpr); } - mpr->state |= WM_MANIPULATOR_STATE_SELECT; + mpr->state |= WM_GIZMO_STATE_SELECT; changed = true; } } else { - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { + if (mpr->state & WM_GIZMO_STATE_SELECT) { if (use_array) { - wm_manipulatormap_select_array_remove(mmap, mpr); + wm_gizmomap_select_array_remove(mmap, mpr); } - mpr->state &= ~WM_MANIPULATOR_STATE_SELECT; + mpr->state &= ~WM_GIZMO_STATE_SELECT; changed = true; } } @@ -443,25 +443,25 @@ bool wm_manipulator_select_set_ex( } /* Remove from selection array without running callbacks. */ -bool WM_manipulator_select_unlink(wmManipulatorMap *mmap, wmManipulator *mpr) +bool WM_gizmo_select_unlink(wmGizmoMap *mmap, wmGizmo *mpr) { - return wm_manipulator_select_set_ex(mmap, mpr, false, true, false); + return wm_gizmo_select_set_ex(mmap, mpr, false, true, false); } -bool WM_manipulator_select_set(wmManipulatorMap *mmap, wmManipulator *mpr, bool select) +bool WM_gizmo_select_set(wmGizmoMap *mmap, wmGizmo *mpr, bool select) { - return wm_manipulator_select_set_ex(mmap, mpr, select, true, true); + return wm_gizmo_select_set_ex(mmap, mpr, select, true, true); } -void WM_manipulator_highlight_set(wmManipulatorMap *mmap, wmManipulator *mpr) +void WM_gizmo_highlight_set(wmGizmoMap *mmap, wmGizmo *mpr) { - wm_manipulatormap_highlight_set(mmap, NULL, mpr, mpr ? mpr->highlight_part : 0); + wm_gizmomap_highlight_set(mmap, NULL, mpr, mpr ? mpr->highlight_part : 0); } -bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr) +bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *mmap, wmGizmo *mpr) { - if (WM_manipulator_select_set(mmap, mpr, true)) { - wm_manipulatormap_highlight_set(mmap, C, mpr, mpr->highlight_part); + if (WM_gizmo_select_set(mmap, mpr, true)) { + wm_gizmomap_highlight_set(mmap, C, mpr, mpr->highlight_part); return true; } else { @@ -470,32 +470,32 @@ bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wm } /** - * Special function to run from setup so manipulators start out interactive. + * Special function to run from setup so gizmos start out interactive. * * We could do this when linking them, but this complicates things since the window update code needs to run first. */ -void WM_manipulator_modal_set_from_setup( - struct wmManipulatorMap *mmap, struct bContext *C, - struct wmManipulator *mpr, int part_index, const wmEvent *event) +void WM_gizmo_modal_set_from_setup( + struct wmGizmoMap *mmap, struct bContext *C, + struct wmGizmo *mpr, int part_index, const wmEvent *event) { mpr->highlight_part = part_index; - WM_manipulator_highlight_set(mmap, mpr); + WM_gizmo_highlight_set(mmap, mpr); if (false) { - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + wm_gizmomap_modal_set(mmap, C, mpr, event, true); } else { /* WEAK: but it works. */ - WM_operator_name_call(C, "MANIPULATORGROUP_OT_manipulator_tweak", WM_OP_INVOKE_DEFAULT, NULL); + WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_DEFAULT, NULL); } } -void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C) +void wm_gizmo_calculate_scale(wmGizmo *mpr, const bContext *C) { const RegionView3D *rv3d = CTX_wm_region_view3d(C); float scale = UI_DPI_FAC; - if ((mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE) == 0) { - scale *= U.manipulator_size; + if ((mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_SCALE) == 0) { + scale *= U.gizmo_size; if (rv3d) { /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */ float matrix_world[4][4]; @@ -519,53 +519,53 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C) mpr->scale_final = mpr->scale_basis * scale; } -static void manipulator_update_prop_data(wmManipulator *mpr) +static void gizmo_update_prop_data(wmGizmo *mpr) { - /* manipulator property might have been changed, so update manipulator */ + /* gizmo property might have been changed, so update gizmo */ if (mpr->type->property_update) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_gizmo_target_property_is_valid(mpr_prop)) { mpr->type->property_update(mpr, mpr_prop); } } } } -void wm_manipulator_update(wmManipulator *mpr, const bContext *C, const bool refresh_map) +void wm_gizmo_update(wmGizmo *mpr, const bContext *C, const bool refresh_map) { if (refresh_map) { - manipulator_update_prop_data(mpr); + gizmo_update_prop_data(mpr); } - wm_manipulator_calculate_scale(mpr, C); + wm_gizmo_calculate_scale(mpr, C); } -int wm_manipulator_is_visible(wmManipulator *mpr) +int wm_gizmo_is_visible(wmGizmo *mpr) { - if (mpr->flag & WM_MANIPULATOR_HIDDEN) { + if (mpr->flag & WM_GIZMO_HIDDEN) { return 0; } - if ((mpr->state & WM_MANIPULATOR_STATE_MODAL) && - !(mpr->flag & (WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_VALUE))) + if ((mpr->state & WM_GIZMO_STATE_MODAL) && + !(mpr->flag & (WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_VALUE))) { /* don't draw while modal (dragging) */ return 0; } - if ((mpr->flag & WM_MANIPULATOR_DRAW_HOVER) && - !(mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) && - !(mpr->state & WM_MANIPULATOR_STATE_SELECT)) /* still draw selected manipulators */ + if ((mpr->flag & WM_GIZMO_DRAW_HOVER) && + !(mpr->state & WM_GIZMO_STATE_HIGHLIGHT) && + !(mpr->state & WM_GIZMO_STATE_SELECT)) /* still draw selected gizmos */ { /* update but don't draw */ - return WM_MANIPULATOR_IS_VISIBLE_UPDATE; + return WM_GIZMO_IS_VISIBLE_UPDATE; } - return WM_MANIPULATOR_IS_VISIBLE_UPDATE | WM_MANIPULATOR_IS_VISIBLE_DRAW; + return WM_GIZMO_IS_VISIBLE_UPDATE | WM_GIZMO_IS_VISIBLE_DRAW; } -void WM_manipulator_calc_matrix_final_params( - const wmManipulator *mpr, - const struct WM_ManipulatorMatrixParams *params, +void WM_gizmo_calc_matrix_final_params( + const wmGizmo *mpr, + const struct WM_GizmoMatrixParams *params, float r_mat[4][4]) { const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : mpr->matrix_space; @@ -581,11 +581,11 @@ void WM_manipulator_calc_matrix_final_params( copy_m4_m4(final_matrix, matrix_basis); } - if (mpr->flag & WM_MANIPULATOR_DRAW_NO_SCALE) { + if (mpr->flag & WM_GIZMO_DRAW_NO_SCALE) { mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); } else { - if (mpr->flag & WM_MANIPULATOR_DRAW_OFFSET_SCALE) { + if (mpr->flag & WM_GIZMO_DRAW_OFFSET_SCALE) { mul_mat3_m4_fl(final_matrix, *scale_final); mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); } @@ -598,14 +598,14 @@ void WM_manipulator_calc_matrix_final_params( mul_m4_m4m4(r_mat, matrix_space, final_matrix); } -void WM_manipulator_calc_matrix_final_no_offset(const wmManipulator *mpr, float r_mat[4][4]) +void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *mpr, float r_mat[4][4]) { float mat_identity[4][4]; unit_m4(mat_identity); - WM_manipulator_calc_matrix_final_params( + WM_gizmo_calc_matrix_final_params( mpr, - &((struct WM_ManipulatorMatrixParams) { + &((struct WM_GizmoMatrixParams) { .matrix_space = NULL, .matrix_basis = NULL, .matrix_offset = mat_identity, @@ -614,11 +614,11 @@ void WM_manipulator_calc_matrix_final_no_offset(const wmManipulator *mpr, float ); } -void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4]) +void WM_gizmo_calc_matrix_final(const wmGizmo *mpr, float r_mat[4][4]) { - WM_manipulator_calc_matrix_final_params( + WM_gizmo_calc_matrix_final_params( mpr, - &((struct WM_ManipulatorMatrixParams) { + &((struct WM_GizmoMatrixParams) { .matrix_space = NULL, .matrix_basis = NULL, .matrix_offset = NULL, @@ -627,31 +627,31 @@ void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4 ); } -/** \name Manipulator Propery Access +/** \name Gizmo Propery Access * * Matches `WM_operator_properties` conventions. * * \{ */ -void WM_manipulator_properties_create_ptr(PointerRNA *ptr, wmManipulatorType *wt) +void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *wt) { RNA_pointer_create(NULL, wt->srna, NULL, ptr); } -void WM_manipulator_properties_create(PointerRNA *ptr, const char *wtstring) +void WM_gizmo_properties_create(PointerRNA *ptr, const char *wtstring) { - const wmManipulatorType *wt = WM_manipulatortype_find(wtstring, false); + const wmGizmoType *wt = WM_gizmotype_find(wtstring, false); if (wt) - WM_manipulator_properties_create_ptr(ptr, (wmManipulatorType *)wt); + WM_gizmo_properties_create_ptr(ptr, (wmGizmoType *)wt); else - RNA_pointer_create(NULL, &RNA_ManipulatorProperties, NULL, ptr); + RNA_pointer_create(NULL, &RNA_GizmoProperties, NULL, ptr); } /* similar to the function above except its uses ID properties * used for keymaps and macros */ -void WM_manipulator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *wtstring) +void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *wtstring) { if (*properties == NULL) { IDPropertyTemplate val = {0}; @@ -660,14 +660,14 @@ void WM_manipulator_properties_alloc(PointerRNA **ptr, IDProperty **properties, if (*ptr == NULL) { *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"); - WM_manipulator_properties_create(*ptr, wtstring); + WM_gizmo_properties_create(*ptr, wtstring); } (*ptr)->data = *properties; } -void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context) +void WM_gizmo_properties_sanitize(PointerRNA *ptr, const bool no_context) { RNA_STRUCT_BEGIN (ptr, prop) { @@ -682,10 +682,10 @@ void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context) { StructRNA *ptype = RNA_property_pointer_type(ptr, prop); - /* recurse into manipulator properties */ - if (RNA_struct_is_a(ptype, &RNA_ManipulatorProperties)) { + /* recurse into gizmo properties */ + if (RNA_struct_is_a(ptype, &RNA_GizmoProperties)) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); - WM_manipulator_properties_sanitize(&opptr, no_context); + WM_gizmo_properties_sanitize(&opptr, no_context); } break; } @@ -700,10 +700,10 @@ void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context) /** set all props to their default, * \param do_update Only update un-initialized props. * - * \note, theres nothing specific to manipulators here. + * \note, theres nothing specific to gizmos here. * this could be made a general function. */ -bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update) +bool WM_gizmo_properties_default(PointerRNA *ptr, const bool do_update) { bool changed = false; RNA_STRUCT_BEGIN (ptr, prop) @@ -714,7 +714,7 @@ bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update) StructRNA *ptype = RNA_property_pointer_type(ptr, prop); if (ptype != &RNA_Struct) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); - changed |= WM_manipulator_properties_default(&opptr, do_update); + changed |= WM_gizmo_properties_default(&opptr, do_update); } break; } @@ -733,7 +733,7 @@ bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update) } /* remove all props without PROP_SKIP_SAVE */ -void WM_manipulator_properties_reset(wmManipulator *mpr) +void WM_gizmo_properties_reset(wmGizmo *mpr) { if (mpr->ptr->data) { PropertyRNA *iterprop; @@ -752,7 +752,7 @@ void WM_manipulator_properties_reset(wmManipulator *mpr) } } -void WM_manipulator_properties_clear(PointerRNA *ptr) +void WM_gizmo_properties_clear(PointerRNA *ptr) { IDProperty *properties = ptr->data; @@ -761,7 +761,7 @@ void WM_manipulator_properties_clear(PointerRNA *ptr) } } -void WM_manipulator_properties_free(PointerRNA *ptr) +void WM_gizmo_properties_free(PointerRNA *ptr) { IDProperty *properties = ptr->data; @@ -778,14 +778,14 @@ void WM_manipulator_properties_free(PointerRNA *ptr) * * \{ */ -bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step) +bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step) { switch (step) { - case WM_MANIPULATORMAP_DRAWSTEP_2D: + case WM_GIZMOMAP_DRAWSTEP_2D: { break; } - case WM_MANIPULATORMAP_DRAWSTEP_3D: + case WM_GIZMOMAP_DRAWSTEP_3D: { wmWindowManager *wm = CTX_wm_manager(C); if (ED_screen_animation_playing(wm)) { diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 83af1a71163..f30744859aa 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -26,9 +26,9 @@ /** \file blender/windowmanager/gizmo/intern/wm_gizmo_group.c * \ingroup wm * - * \name Manipulator-Group + * \name Gizmo-Group * - * Manipulator-groups store and manage groups of manipulators. They can be + * Gizmo-groups store and manage groups of gizmos. They can be * attached to modal handlers and have own keymaps. */ @@ -64,22 +64,22 @@ # include "BPY_extern.h" #endif -/* Allow manipulator part's to be single click only, +/* Allow gizmo part's to be single click only, * dragging falls back to activating their 'drag_part' action. */ #define USE_DRAG_DETECT /* -------------------------------------------------------------------- */ -/** \name wmManipulatorGroup +/** \name wmGizmoGroup * * \{ */ /** - * Create a new manipulator-group from \a wgt. + * Create a new gizmo-group from \a wgt. */ -wmManipulatorGroup *wm_manipulatorgroup_new_from_type( - wmManipulatorMap *mmap, wmManipulatorGroupType *wgt) +wmGizmoGroup *wm_gizmogroup_new_from_type( + wmGizmoMap *mmap, wmGizmoGroupType *wgt) { - wmManipulatorGroup *mgroup = MEM_callocN(sizeof(*mgroup), "manipulator-group"); + wmGizmoGroup *mgroup = MEM_callocN(sizeof(*mgroup), "gizmo-group"); mgroup->type = wgt; /* keep back-link */ @@ -90,27 +90,27 @@ wmManipulatorGroup *wm_manipulatorgroup_new_from_type( return mgroup; } -void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup) +void wm_gizmogroup_free(bContext *C, wmGizmoGroup *mgroup) { - wmManipulatorMap *mmap = mgroup->parent_mmap; + wmGizmoMap *mmap = mgroup->parent_mmap; - /* Similar to WM_manipulator_unlink, but only to keep mmap state correct, + /* Similar to WM_gizmo_unlink, but only to keep mmap state correct, * we don't want to run callbacks. */ if (mmap->mmap_context.highlight && mmap->mmap_context.highlight->parent_mgroup == mgroup) { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + wm_gizmomap_highlight_set(mmap, C, NULL, 0); } if (mmap->mmap_context.modal && mmap->mmap_context.modal->parent_mgroup == mgroup) { - wm_manipulatormap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false); + wm_gizmomap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false); } - for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) { + for (wmGizmo *mpr = mgroup->gizmos.first, *mpr_next; mpr; mpr = mpr_next) { mpr_next = mpr->next; if (mmap->mmap_context.select.len) { - WM_manipulator_select_unlink(mmap, mpr); + WM_gizmo_select_unlink(mmap, mpr); } - WM_manipulator_free(mpr); + WM_gizmo_free(mpr); } - BLI_listbase_clear(&mgroup->manipulators); + BLI_listbase_clear(&mgroup->gizmos); #ifdef WITH_PYTHON if (mgroup->py_instance) { @@ -138,21 +138,21 @@ void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup) } /** - * Add \a manipulator to \a mgroup and make sure its name is unique within the group. + * Add \a gizmo to \a mgroup and make sure its name is unique within the group. */ -void wm_manipulatorgroup_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr) +void wm_gizmogroup_gizmo_register(wmGizmoGroup *mgroup, wmGizmo *mpr) { - BLI_assert(BLI_findindex(&mgroup->manipulators, mpr) == -1); - BLI_addtail(&mgroup->manipulators, mpr); + BLI_assert(BLI_findindex(&mgroup->gizmos, mpr) == -1); + BLI_addtail(&mgroup->gizmos, mpr); mpr->parent_mgroup = mgroup; } -wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( - const wmManipulatorGroup *mgroup, bContext *C, const wmEvent *event, +wmGizmo *wm_gizmogroup_find_intersected_gizmo( + const wmGizmoGroup *mgroup, bContext *C, const wmEvent *event, int *r_part) { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->type->test_select && (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) { + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if (mpr->type->test_select && (mpr->flag & WM_GIZMO_HIDDEN) == 0) { if ((*r_part = mpr->type->test_select(C, mpr, event)) != -1) { return mpr; } @@ -163,14 +163,14 @@ wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( } /** - * Adds all manipulators of \a mgroup that can be selected to the head of \a listbase. Added items need freeing! + * Adds all gizmos of \a mgroup that can be selected to the head of \a listbase. Added items need freeing! */ -void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorGroup *mgroup, ListBase *listbase) +void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *mgroup, ListBase *listbase) { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if ((mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) { - if (((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) && mpr->type->draw_select) || - ((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0 && mpr->type->test_select)) + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if ((mpr->flag & WM_GIZMO_HIDDEN) == 0) { + if (((mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) && mpr->type->draw_select) || + ((mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && mpr->type->test_select)) { BLI_addhead(listbase, BLI_genericNodeN(mpr)); } @@ -178,32 +178,32 @@ void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorG } } -void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bContext *C) +void wm_gizmogroup_ensure_initialized(wmGizmoGroup *mgroup, const bContext *C) { /* prepare for first draw */ - if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0)) { + if (UNLIKELY((mgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0)) { mgroup->type->setup(C, mgroup); - /* Not ideal, initialize keymap here, needed for RNA runtime generated manipulators. */ - wmManipulatorGroupType *wgt = mgroup->type; + /* Not ideal, initialize keymap here, needed for RNA runtime generated gizmos. */ + wmGizmoGroupType *wgt = mgroup->type; if (wgt->keymap == NULL) { wmWindowManager *wm = CTX_wm_manager(C); - wm_manipulatorgrouptype_setup_keymap(wgt, wm->defaultconf); + wm_gizmogrouptype_setup_keymap(wgt, wm->defaultconf); BLI_assert(wgt->keymap != NULL); } - mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_SETUP; + mgroup->init_flag |= WM_GIZMOGROUP_INIT_SETUP; } /* refresh may be called multiple times, this just ensures its called at least once before we draw. */ - if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_REFRESH) == 0)) { + if (UNLIKELY((mgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0)) { if (mgroup->type->refresh) { mgroup->type->refresh(C, mgroup); } - mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_REFRESH; + mgroup->init_flag |= WM_GIZMOGROUP_INIT_REFRESH; } } -bool WM_manipulator_group_type_poll(const bContext *C, const struct wmManipulatorGroupType *wgt) +bool WM_gizmo_group_type_poll(const bContext *C, const struct wmGizmoGroupType *wgt) { /* If we're tagged, only use compatible. */ if (wgt->owner_id[0] != '\0') { @@ -212,29 +212,29 @@ bool WM_manipulator_group_type_poll(const bContext *C, const struct wmManipulato return false; } } - /* Check for poll function, if manipulator-group belongs to an operator, also check if the operator is running. */ - return (!wgt->poll || wgt->poll(C, (wmManipulatorGroupType *)wgt)); + /* Check for poll function, if gizmo-group belongs to an operator, also check if the operator is running. */ + return (!wgt->poll || wgt->poll(C, (wmGizmoGroupType *)wgt)); } -bool wm_manipulatorgroup_is_visible_in_drawstep( - const wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep) +bool wm_gizmogroup_is_visible_in_drawstep( + const wmGizmoGroup *mgroup, const eWM_GizmoFlagMapDrawStep drawstep) { switch (drawstep) { - case WM_MANIPULATORMAP_DRAWSTEP_2D: - return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; - case WM_MANIPULATORMAP_DRAWSTEP_3D: - return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D); + case WM_GIZMOMAP_DRAWSTEP_2D: + return (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; + case WM_GIZMOMAP_DRAWSTEP_3D: + return (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D); default: BLI_assert(0); return false; } } -bool wm_manipulatorgroup_is_any_selected(const wmManipulatorGroup *mgroup) +bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *mgroup) { - if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT) { - for (const wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { + if (mgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT) { + for (const wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if (mpr->state & WM_GIZMO_STATE_SELECT) { return true; } } @@ -244,18 +244,18 @@ bool wm_manipulatorgroup_is_any_selected(const wmManipulatorGroup *mgroup) /** \} */ -/** \name Manipulator operators +/** \name Gizmo operators * - * Basic operators for manipulator interaction with user configurable keymaps. + * Basic operators for gizmo interaction with user configurable keymaps. * * \{ */ -static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { ARegion *ar = CTX_wm_region(C); - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - wmManipulator *highlight = mmap->mmap_context.highlight; + wmGizmoMap *mmap = ar->gizmo_map; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmo *highlight = mmap->mmap_context.highlight; bool extend = RNA_boolean_get(op->ptr, "extend"); bool deselect = RNA_boolean_get(op->ptr, "deselect"); @@ -263,13 +263,13 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent /* deselect all first */ if (extend == false && deselect == false && toggle == false) { - wm_manipulatormap_deselect_all(mmap); + wm_gizmomap_deselect_all(mmap); BLI_assert(msel->items == NULL && msel->len == 0); UNUSED_VARS_NDEBUG(msel); } if (highlight) { - const bool is_selected = (highlight->state & WM_MANIPULATOR_STATE_SELECT); + const bool is_selected = (highlight->state & WM_GIZMO_STATE_SELECT); bool redraw = false; if (toggle) { @@ -278,11 +278,11 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent } if (deselect) { - if (is_selected && WM_manipulator_select_set(mmap, highlight, false)) { + if (is_selected && WM_gizmo_select_set(mmap, highlight, false)) { redraw = true; } } - else if (wm_manipulator_select_and_highlight(C, mmap, highlight)) { + else if (wm_gizmo_select_and_highlight(C, mmap, highlight)) { redraw = true; } @@ -300,32 +300,32 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent return OPERATOR_PASS_THROUGH; } -void MANIPULATORGROUP_OT_manipulator_select(wmOperatorType *ot) +void GIZMOGROUP_OT_gizmo_select(wmOperatorType *ot) { /* identifiers */ ot->name = "Gizmo Select"; - ot->description = "Select the currently highlighted manipulator"; - ot->idname = "MANIPULATORGROUP_OT_manipulator_select"; + ot->description = "Select the currently highlighted gizmo"; + ot->idname = "GIZMOGROUP_OT_gizmo_select"; /* api callbacks */ - ot->invoke = manipulator_select_invoke; + ot->invoke = gizmo_select_invoke; ot->flag = OPTYPE_UNDO; WM_operator_properties_mouse_select(ot); } -typedef struct ManipulatorTweakData { - wmManipulatorMap *mmap; - wmManipulatorGroup *mgroup; - wmManipulator *mpr_modal; +typedef struct GizmoTweakData { + wmGizmoMap *mmap; + wmGizmoGroup *mgroup; + wmGizmo *mpr_modal; int init_event; /* initial event type */ int flag; /* tweak flags */ #ifdef USE_DRAG_DETECT /* True until the mouse is moved (only use when the operator has no modal). - * this allows some manipulators to be click-only. */ + * this allows some gizmos to be click-only. */ enum { /* Don't detect dragging. */ DRAG_NOP = 0, @@ -333,27 +333,27 @@ typedef struct ManipulatorTweakData { DRAG_DETECT, /* Drag has started, idle until there is no active modal operator. * This is needed because finishing the modal operator also exits - * the modal manipulator state (un-grabbs the cursor). + * the modal gizmo state (un-grabbs the cursor). * Ideally this workaround could be removed later. */ DRAG_IDLE, } drag_state; #endif -} ManipulatorTweakData; +} GizmoTweakData; -static bool manipulator_tweak_start( - bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event) +static bool gizmo_tweak_start( + bContext *C, wmGizmoMap *mmap, wmGizmo *mpr, const wmEvent *event) { - /* activate highlighted manipulator */ - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + /* activate highlighted gizmo */ + wm_gizmomap_modal_set(mmap, C, mpr, event, true); - return (mpr->state & WM_MANIPULATOR_STATE_MODAL); + return (mpr->state & WM_GIZMO_STATE_MODAL); } -static bool manipulator_tweak_start_and_finish( - bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event, bool *r_is_modal) +static bool gizmo_tweak_start_and_finish( + bContext *C, wmGizmoMap *mmap, wmGizmo *mpr, const wmEvent *event, bool *r_is_modal) { - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); if (r_is_modal) { *r_is_modal = false; } @@ -364,7 +364,7 @@ static bool manipulator_tweak_start_and_finish( wmWindowManager *wm = CTX_wm_manager(C); wmOperator *op = WM_operator_last_redo(C); - /* We may want to enable this, for now the manipulator can manage it's own properties. */ + /* We may want to enable this, for now the gizmo can manage it's own properties. */ #if 0 IDP_MergeGroup(mpop->ptr.data, op->properties, false); #endif @@ -373,17 +373,17 @@ static bool manipulator_tweak_start_and_finish( ED_undo_pop_op(C, op); } - /* XXX temporary workaround for modal manipulator operator - * conflicting with modal operator attached to manipulator */ + /* XXX temporary workaround for modal gizmo operator + * conflicting with modal operator attached to gizmo */ if (mpop->type->modal) { - /* activate highlighted manipulator */ - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + /* activate highlighted gizmo */ + wm_gizmomap_modal_set(mmap, C, mpr, event, true); if (r_is_modal) { *r_is_modal = true; } } else { - /* Allow for 'button' manipulators, single click to run an action. */ + /* Allow for 'button' gizmos, single click to run an action. */ WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); } return true; @@ -393,27 +393,27 @@ static bool manipulator_tweak_start_and_finish( } } -static void manipulator_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal) +static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal) { - ManipulatorTweakData *mtweak = op->customdata; + GizmoTweakData *mtweak = op->customdata; if (mtweak->mpr_modal->type->exit) { mtweak->mpr_modal->type->exit(C, mtweak->mpr_modal, cancel); } if (clear_modal) { - /* The manipulator may have been removed. */ + /* The gizmo may have been removed. */ if ((BLI_findindex(&mtweak->mmap->groups, mtweak->mgroup) != -1) && - (BLI_findindex(&mtweak->mgroup->manipulators, mtweak->mpr_modal) != -1)) + (BLI_findindex(&mtweak->mgroup->gizmos, mtweak->mpr_modal) != -1)) { - wm_manipulatormap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false); + wm_gizmomap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false); } } MEM_freeN(mtweak); } -static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) +static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) { - ManipulatorTweakData *mtweak = op->customdata; - wmManipulator *mpr = mtweak->mpr_modal; + GizmoTweakData *mtweak = op->customdata; + wmGizmo *mpr = mtweak->mpr_modal; int retval = OPERATOR_PASS_THROUGH; bool clear_modal = true; @@ -423,7 +423,7 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e } #ifdef USE_DRAG_DETECT - wmManipulatorMap *mmap = mtweak->mmap; + wmGizmoMap *mmap = mtweak->mmap; if (mtweak->drag_state == DRAG_DETECT) { if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { if (len_manhattan_v2v2_int(&event->x, mmap->mmap_context.event_xy) > 2) { @@ -437,15 +437,15 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e } if (mtweak->drag_state != DRAG_DETECT) { - /* Follow logic in 'manipulator_tweak_invoke' */ + /* Follow logic in 'gizmo_tweak_invoke' */ bool is_modal = false; - if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, &is_modal)) { + if (gizmo_tweak_start_and_finish(C, mmap, mpr, event, &is_modal)) { if (is_modal) { clear_modal = false; } } else { - if (!manipulator_tweak_start(C, mmap, mpr, event)) { + if (!gizmo_tweak_start(C, mmap, mpr, event)) { retval = OPERATOR_FINISHED; } } @@ -456,7 +456,7 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e return OPERATOR_PASS_THROUGH; } else { - manipulator_tweak_finish(C, op, false, false); + gizmo_tweak_finish(C, op, false, false); return OPERATOR_FINISHED; } } @@ -477,51 +477,51 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e retval = OPERATOR_FINISHED; break; case TWEAK_MODAL_PRECISION_ON: - mtweak->flag |= WM_MANIPULATOR_TWEAK_PRECISE; + mtweak->flag |= WM_GIZMO_TWEAK_PRECISE; break; case TWEAK_MODAL_PRECISION_OFF: - mtweak->flag &= ~WM_MANIPULATOR_TWEAK_PRECISE; + mtweak->flag &= ~WM_GIZMO_TWEAK_PRECISE; break; case TWEAK_MODAL_SNAP_ON: - mtweak->flag |= WM_MANIPULATOR_TWEAK_SNAP; + mtweak->flag |= WM_GIZMO_TWEAK_SNAP; break; case TWEAK_MODAL_SNAP_OFF: - mtweak->flag &= ~WM_MANIPULATOR_TWEAK_SNAP; + mtweak->flag &= ~WM_GIZMO_TWEAK_SNAP; break; } } if (retval != OPERATOR_PASS_THROUGH) { - manipulator_tweak_finish(C, op, retval != OPERATOR_FINISHED, clear_modal); + gizmo_tweak_finish(C, op, retval != OPERATOR_FINISHED, clear_modal); return retval; } - /* handle manipulator */ - wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; + /* handle gizmo */ + wmGizmoFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; if (modal_fn) { int modal_retval = modal_fn(C, mpr, event, mtweak->flag); if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) { - manipulator_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true); + gizmo_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true); return OPERATOR_FINISHED; } - /* Ugly hack to send manipulator events */ - ((wmEvent *)event)->type = EVT_MANIPULATOR_UPDATE; + /* Ugly hack to send gizmo events */ + ((wmEvent *)event)->type = EVT_GIZMO_UPDATE; } /* always return PASS_THROUGH so modal handlers - * with manipulators attached can update */ + * with gizmos attached can update */ BLI_assert(retval == OPERATOR_PASS_THROUGH); return OPERATOR_PASS_THROUGH; } -static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) +static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulator *mpr = mmap->mmap_context.highlight; + wmGizmoMap *mmap = ar->gizmo_map; + wmGizmo *mpr = mmap->mmap_context.highlight; /* Needed for single click actions which don't enter modal state. */ WM_tooltip_clear(C, CTX_wm_window(C)); @@ -539,7 +539,7 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * #endif if (use_drag_fallback == false) { - if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, NULL)) { + if (gizmo_tweak_start_and_finish(C, mmap, mpr, event, NULL)) { return OPERATOR_FINISHED; } } @@ -547,7 +547,7 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * bool use_drag_detect = false; #ifdef USE_DRAG_DETECT if (use_drag_fallback) { - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); if (mpop && mpop->type) { if (mpop->type->modal == NULL) { use_drag_detect = true; @@ -557,13 +557,13 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * #endif if (use_drag_detect == false) { - if (!manipulator_tweak_start(C, mmap, mpr, event)) { + if (!gizmo_tweak_start(C, mmap, mpr, event)) { /* failed to start */ return OPERATOR_PASS_THROUGH; } } - ManipulatorTweakData *mtweak = MEM_mallocN(sizeof(ManipulatorTweakData), __func__); + GizmoTweakData *mtweak = MEM_mallocN(sizeof(GizmoTweakData), __func__); mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type); mtweak->mpr_modal = mmap->mmap_context.highlight; @@ -582,16 +582,16 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_RUNNING_MODAL; } -void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) +void GIZMOGROUP_OT_gizmo_tweak(wmOperatorType *ot) { /* identifiers */ ot->name = "Gizmo Tweak"; ot->description = "Tweak the active gizmo"; - ot->idname = "MANIPULATORGROUP_OT_manipulator_tweak"; + ot->idname = "GIZMOGROUP_OT_gizmo_tweak"; /* api callbacks */ - ot->invoke = manipulator_tweak_invoke; - ot->modal = manipulator_tweak_modal; + ot->invoke = gizmo_tweak_invoke; + ot->modal = gizmo_tweak_modal; /* TODO(campbell) This causes problems tweaking settings for operators, * need to find a way to support this. */ @@ -603,7 +603,7 @@ void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) /** \} */ -static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname) +static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname) { wmKeyMap *keymap; char name[KMAP_MAX_NAME]; @@ -646,44 +646,44 @@ static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON); WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF); - WM_modalkeymap_assign(keymap, "MANIPULATORGROUP_OT_manipulator_tweak"); + WM_modalkeymap_assign(keymap, "GIZMOGROUP_OT_gizmo_tweak"); return keymap; } /** - * Common default keymap for manipulator groups + * Common default keymap for gizmo groups */ -wmKeyMap *WM_manipulatorgroup_keymap_common( - const wmManipulatorGroupType *wgt, wmKeyConfig *config) +wmKeyMap *WM_gizmogroup_keymap_common( + const wmGizmoGroupType *wgt, wmKeyConfig *config) { - /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ + /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */ wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); - WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0); - manipulatorgroup_tweak_modal_keymap(config, wgt->name); + WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0); + gizmogroup_tweak_modal_keymap(config, wgt->name); return km; } /** - * Variation of #WM_manipulatorgroup_keymap_common but with keymap items for selection + * Variation of #WM_gizmogroup_keymap_common but with keymap items for selection */ -wmKeyMap *WM_manipulatorgroup_keymap_common_select( - const wmManipulatorGroupType *wgt, wmKeyConfig *config) +wmKeyMap *WM_gizmogroup_keymap_common_select( + const wmGizmoGroupType *wgt, wmKeyConfig *config) { - /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ + /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */ wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); - WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); - WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", EVT_TWEAK_S, KM_ANY, 0, 0); - manipulatorgroup_tweak_modal_keymap(config, wgt->name); + WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); + WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", EVT_TWEAK_S, KM_ANY, 0, 0); + gizmogroup_tweak_modal_keymap(config, wgt->name); - wmKeyMapItem *kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, 0, 0); + wmKeyMapItem *kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_boolean_set(kmi->ptr, "deselect", false); RNA_boolean_set(kmi->ptr, "toggle", false); - kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_boolean_set(kmi->ptr, "deselect", false); RNA_boolean_set(kmi->ptr, "toggle", true); @@ -691,19 +691,19 @@ wmKeyMap *WM_manipulatorgroup_keymap_common_select( return km; } -/** \} */ /* wmManipulatorGroup */ +/** \} */ /* wmGizmoGroup */ /* -------------------------------------------------------------------- */ -/** \name wmManipulatorGroupType +/** \name wmGizmoGroupType * * \{ */ -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( - struct wmManipulatorMapType *mmap_type, - const wmManipulatorGroupType *wgt) +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr( + struct wmGizmoMapType *mmap_type, + const wmGizmoGroupType *wgt) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { @@ -714,12 +714,12 @@ struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( return NULL; } -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( - struct wmManipulatorMapType *mmap_type, +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find( + struct wmGizmoMapType *mmap_type, const char *idname) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { @@ -731,49 +731,49 @@ struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( } /** - * Use this for registering manipulators on startup. For runtime, use #WM_manipulatormaptype_group_link_runtime. + * Use this for registering gizmos on startup. For runtime, use #WM_gizmomaptype_group_link_runtime. */ -wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( - wmManipulatorMapType *mmap_type, const char *idname) +wmGizmoGroupTypeRef *WM_gizmomaptype_group_link( + wmGizmoMapType *mmap_type, const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); + return WM_gizmomaptype_group_link_ptr(mmap_type, wgt); } -wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr( + wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) { - wmManipulatorGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmManipulatorGroupTypeRef), "manipulator-group-ref"); + wmGizmoGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmGizmoGroupTypeRef), "gizmo-group-ref"); wgt_ref->type = wgt; BLI_addtail(&mmap_type->grouptype_refs, wgt_ref); return wgt_ref; } -void WM_manipulatormaptype_group_init_runtime_keymap( +void WM_gizmomaptype_group_init_runtime_keymap( const Main *bmain, - wmManipulatorGroupType *wgt) + wmGizmoGroupType *wgt) { - /* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */ - wm_manipulatorgrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf); + /* init keymap - on startup there's an extra call to init keymaps for 'permanent' gizmo-groups */ + wm_gizmogrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf); } -void WM_manipulatormaptype_group_init_runtime( - const Main *bmain, wmManipulatorMapType *mmap_type, - wmManipulatorGroupType *wgt) +void WM_gizmomaptype_group_init_runtime( + const Main *bmain, wmGizmoMapType *mmap_type, + wmGizmoGroupType *wgt) { - /* now create a manipulator for all existing areas */ + /* now create a gizmo for all existing areas */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmManipulatorMap *mmap = ar->manipulator_map; + wmGizmoMap *mmap = ar->gizmo_map; if (mmap && mmap->type == mmap_type) { - wm_manipulatorgroup_new_from_type(mmap, wgt); + wm_gizmogroup_new_from_type(mmap, wgt); /* just add here, drawing will occur on next update */ - wm_manipulatormap_highlight_set(mmap, NULL, NULL, 0); + wm_gizmomap_highlight_set(mmap, NULL, NULL, 0); ED_region_tag_redraw(ar); } } @@ -784,16 +784,16 @@ void WM_manipulatormaptype_group_init_runtime( /** - * Unlike #WM_manipulatormaptype_group_unlink this doesn't maintain correct state, simply free. + * Unlike #WM_gizmomaptype_group_unlink this doesn't maintain correct state, simply free. */ -void WM_manipulatormaptype_group_free(wmManipulatorGroupTypeRef *wgt_ref) +void WM_gizmomaptype_group_free(wmGizmoGroupTypeRef *wgt_ref) { MEM_freeN(wgt_ref); } -void WM_manipulatormaptype_group_unlink( - bContext *C, Main *bmain, wmManipulatorMapType *mmap_type, - const wmManipulatorGroupType *wgt) +void WM_gizmomaptype_group_unlink( + bContext *C, Main *bmain, wmGizmoMapType *mmap_type, + const wmGizmoGroupType *wgt) { /* Free instances. */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -801,14 +801,14 @@ void WM_manipulatormaptype_group_unlink( for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmManipulatorMap *mmap = ar->manipulator_map; + wmGizmoMap *mmap = ar->gizmo_map; if (mmap && mmap->type == mmap_type) { - wmManipulatorGroup *mgroup, *mgroup_next; + wmGizmoGroup *mgroup, *mgroup_next; for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup_next) { mgroup_next = mgroup->next; if (mgroup->type == wgt) { BLI_assert(mgroup->parent_mmap == mmap); - wm_manipulatorgroup_free(C, mgroup); + wm_gizmogroup_free(C, mgroup); ED_region_tag_redraw(ar); } } @@ -819,131 +819,131 @@ void WM_manipulatormaptype_group_unlink( } /* Free types. */ - wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); + wmGizmoGroupTypeRef *wgt_ref = WM_gizmomaptype_group_find_ptr(mmap_type, wgt); if (wgt_ref) { BLI_remlink(&mmap_type->grouptype_refs, wgt_ref); - WM_manipulatormaptype_group_free(wgt_ref); + WM_gizmomaptype_group_free(wgt_ref); } /* Note, we may want to keep this keymap for editing */ WM_keymap_remove(wgt->keyconf, wgt->keymap); - BLI_assert(WM_manipulatormaptype_group_find_ptr(mmap_type, wgt) == NULL); + BLI_assert(WM_gizmomaptype_group_find_ptr(mmap_type, wgt) == NULL); } -void wm_manipulatorgrouptype_setup_keymap( - wmManipulatorGroupType *wgt, wmKeyConfig *keyconf) +void wm_gizmogrouptype_setup_keymap( + wmGizmoGroupType *wgt, wmKeyConfig *keyconf) { /* Use flag since setup_keymap may return NULL, * in that case we better not keep calling it. */ - if (wgt->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) { + if (wgt->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { wgt->keymap = wgt->setup_keymap(wgt, keyconf); wgt->keyconf = keyconf; - wgt->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + wgt->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; } } -/** \} */ /* wmManipulatorGroupType */ +/** \} */ /* wmGizmoGroupType */ /* -------------------------------------------------------------------- */ /** \name High Level Add/Remove API * * For use directly from operators & RNA registration. * - * \note In context of manipulator API these names are a bit misleading, + * \note In context of gizmo API these names are a bit misleading, * but for general use terms its OK. - * `WM_manipulator_group_type_add` would be more correctly called: - * `WM_manipulatormaptype_grouptype_reference_link` + * `WM_gizmo_group_type_add` would be more correctly called: + * `WM_gizmomaptype_grouptype_reference_link` * but for general purpose API this is too detailed & annoying. * * \note We may want to return a value if there is nothing to remove. * * \{ */ -void WM_manipulator_group_type_add_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) +void WM_gizmo_group_type_add_ptr_ex( + wmGizmoGroupType *wgt, + wmGizmoMapType *mmap_type) { - WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); + WM_gizmomaptype_group_link_ptr(mmap_type, wgt); - WM_manipulatorconfig_update_tag_init(mmap_type, wgt); + WM_gizmoconfig_update_tag_init(mmap_type, wgt); } -void WM_manipulator_group_type_add_ptr( - wmManipulatorGroupType *wgt) +void WM_gizmo_group_type_add_ptr( + wmGizmoGroupType *wgt) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmo_group_type_add_ptr_ex(wgt, mmap_type); } -void WM_manipulator_group_type_add(const char *idname) +void WM_gizmo_group_type_add(const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - WM_manipulator_group_type_add_ptr(wgt); + WM_gizmo_group_type_add_ptr(wgt); } -void WM_manipulator_group_type_ensure_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) +void WM_gizmo_group_type_ensure_ptr_ex( + wmGizmoGroupType *wgt, + wmGizmoMapType *mmap_type) { - wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); + wmGizmoGroupTypeRef *wgt_ref = WM_gizmomaptype_group_find_ptr(mmap_type, wgt); if (wgt_ref == NULL) { - WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); + WM_gizmo_group_type_add_ptr_ex(wgt, mmap_type); } } -void WM_manipulator_group_type_ensure_ptr( - wmManipulatorGroupType *wgt) +void WM_gizmo_group_type_ensure_ptr( + wmGizmoGroupType *wgt) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_ensure_ptr_ex(wgt, mmap_type); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmo_group_type_ensure_ptr_ex(wgt, mmap_type); } -void WM_manipulator_group_type_ensure(const char *idname) +void WM_gizmo_group_type_ensure(const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - WM_manipulator_group_type_ensure_ptr(wgt); + WM_gizmo_group_type_ensure_ptr(wgt); } -void WM_manipulator_group_type_remove_ptr_ex( - struct Main *bmain, wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) +void WM_gizmo_group_type_remove_ptr_ex( + struct Main *bmain, wmGizmoGroupType *wgt, + wmGizmoMapType *mmap_type) { - WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt); - WM_manipulatorgrouptype_free_ptr(wgt); + WM_gizmomaptype_group_unlink(NULL, bmain, mmap_type, wgt); + WM_gizmogrouptype_free_ptr(wgt); } -void WM_manipulator_group_type_remove_ptr( - struct Main *bmain, wmManipulatorGroupType *wgt) +void WM_gizmo_group_type_remove_ptr( + struct Main *bmain, wmGizmoGroupType *wgt) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_remove_ptr_ex(bmain, wgt, mmap_type); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmo_group_type_remove_ptr_ex(bmain, wgt, mmap_type); } -void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname) +void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - WM_manipulator_group_type_remove_ptr(bmain, wgt); + WM_gizmo_group_type_remove_ptr(bmain, wgt); } /* delayed versions */ -void WM_manipulator_group_type_unlink_delayed_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) +void WM_gizmo_group_type_unlink_delayed_ptr_ex( + wmGizmoGroupType *wgt, + wmGizmoMapType *mmap_type) { - WM_manipulatorconfig_update_tag_remove(mmap_type, wgt); + WM_gizmoconfig_update_tag_remove(mmap_type, wgt); } -void WM_manipulator_group_type_unlink_delayed_ptr( - wmManipulatorGroupType *wgt) +void WM_gizmo_group_type_unlink_delayed_ptr( + wmGizmoGroupType *wgt) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_unlink_delayed_ptr_ex(wgt, mmap_type); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmo_group_type_unlink_delayed_ptr_ex(wgt, mmap_type); } -void WM_manipulator_group_type_unlink_delayed(const char *idname) +void WM_gizmo_group_type_unlink_delayed(const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(wgt); } /** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c index f93beb0ac9f..44f5fac4cd4 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c @@ -36,7 +36,7 @@ #include "WM_api.h" #include "WM_types.h" -/* only for own init/exit calls (wm_manipulatorgrouptype_init/wm_manipulatorgrouptype_free) */ +/* only for own init/exit calls (wm_gizmogrouptype_init/wm_gizmogrouptype_free) */ #include "wm.h" /* own includes */ @@ -44,30 +44,30 @@ #include "wm_gizmo_intern.h" -/** \name ManipulatorGroup Type Append +/** \name GizmoGroup Type Append * * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. * \{ */ -static GHash *global_manipulatorgrouptype_hash = NULL; +static GHash *global_gizmogrouptype_hash = NULL; -wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet) +wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet) { if (idname[0]) { - wmManipulatorGroupType *wgt; + wmGizmoGroupType *wgt; - wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); + wgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname); if (wgt) { return wgt; } if (!quiet) { - printf("search for unknown manipulator group '%s'\n", idname); + printf("search for unknown gizmo group '%s'\n", idname); } } else { if (!quiet) { - printf("search for empty manipulator group\n"); + printf("search for empty gizmo group\n"); } } @@ -75,123 +75,123 @@ wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool qu } /* caller must free */ -void WM_manipulatorgrouptype_iter(GHashIterator *ghi) +void WM_gizmogrouptype_iter(GHashIterator *ghi) { - BLI_ghashIterator_init(ghi, global_manipulatorgrouptype_hash); + BLI_ghashIterator_init(ghi, global_gizmogrouptype_hash); } -static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void) +static wmGizmoGroupType *wm_gizmogrouptype_append__begin(void) { - wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulatorgrouptype"); + wmGizmoGroupType *wgt = MEM_callocN(sizeof(wmGizmoGroupType), "gizmogrouptype"); return wgt; } -static void wm_manipulatorgrouptype_append__end(wmManipulatorGroupType *wgt) +static void wm_gizmogrouptype_append__end(wmGizmoGroupType *wgt) { BLI_assert(wgt->name != NULL); BLI_assert(wgt->idname != NULL); - wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + wgt->type_update_flag |= WM_GIZMOMAPTYPE_KEYMAP_INIT; /* if not set, use default */ if (wgt->setup_keymap == NULL) { - if (wgt->flag & WM_MANIPULATORGROUPTYPE_SELECT) { - wgt->setup_keymap = WM_manipulatorgroup_keymap_common_select; + if (wgt->flag & WM_GIZMOGROUPTYPE_SELECT) { + wgt->setup_keymap = WM_gizmogroup_keymap_common_select; } else { - wgt->setup_keymap = WM_manipulatorgroup_keymap_common; + wgt->setup_keymap = WM_gizmogroup_keymap_common; } } - BLI_ghash_insert(global_manipulatorgrouptype_hash, (void *)wgt->idname, wgt); + BLI_ghash_insert(global_gizmogrouptype_hash, (void *)wgt->idname, wgt); } -wmManipulatorGroupType *WM_manipulatorgrouptype_append( - void (*wtfunc)(struct wmManipulatorGroupType *)) +wmGizmoGroupType *WM_gizmogrouptype_append( + void (*wtfunc)(struct wmGizmoGroupType *)) { - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); + wmGizmoGroupType *wgt = wm_gizmogrouptype_append__begin(); wtfunc(wgt); - wm_manipulatorgrouptype_append__end(wgt); + wm_gizmogrouptype_append__end(wgt); return wgt; } -wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr( - void (*wtfunc)(struct wmManipulatorGroupType *, void *), void *userdata) +wmGizmoGroupType *WM_gizmogrouptype_append_ptr( + void (*wtfunc)(struct wmGizmoGroupType *, void *), void *userdata) { - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); + wmGizmoGroupType *wgt = wm_gizmogrouptype_append__begin(); wtfunc(wgt, userdata); - wm_manipulatorgrouptype_append__end(wgt); + wm_gizmogrouptype_append__end(wgt); return wgt; } /** - * Append and insert into a manipulator typemap. - * This is most common for C manipulators which are enabled by default. + * Append and insert into a gizmo typemap. + * This is most common for C gizmos which are enabled by default. */ -wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( - wmManipulatorMapType *mmap_type, - void (*wtfunc)(struct wmManipulatorGroupType *)) +wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link( + wmGizmoMapType *mmap_type, + void (*wtfunc)(struct wmGizmoGroupType *)) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(wtfunc); + wmGizmoGroupType *wgt = WM_gizmogrouptype_append(wtfunc); wgt->mmap_params.spaceid = mmap_type->spaceid; wgt->mmap_params.regionid = mmap_type->regionid; - return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); + return WM_gizmomaptype_group_link_ptr(mmap_type, wgt); } /** * Free but don't remove from ghash. */ -static void manipulatorgrouptype_free(wmManipulatorGroupType *wgt) +static void gizmogrouptype_free(wmGizmoGroupType *wgt) { - if (wgt->ext.srna) { /* python manipulator group, allocs own string */ + if (wgt->ext.srna) { /* python gizmo group, allocs own string */ MEM_freeN((void *)wgt->idname); } MEM_freeN(wgt); } -void WM_manipulatorgrouptype_free_ptr(wmManipulatorGroupType *wgt) +void WM_gizmogrouptype_free_ptr(wmGizmoGroupType *wgt) { - BLI_assert(wgt == WM_manipulatorgrouptype_find(wgt->idname, false)); + BLI_assert(wgt == WM_gizmogrouptype_find(wgt->idname, false)); - BLI_ghash_remove(global_manipulatorgrouptype_hash, wgt->idname, NULL, NULL); + BLI_ghash_remove(global_gizmogrouptype_hash, wgt->idname, NULL, NULL); - manipulatorgrouptype_free(wgt); + gizmogrouptype_free(wgt); /* XXX, TODO, update the world! */ } -bool WM_manipulatorgrouptype_free(const char *idname) +bool WM_gizmogrouptype_free(const char *idname) { - wmManipulatorGroupType *wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); + wmGizmoGroupType *wgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname); if (wgt == NULL) { return false; } - WM_manipulatorgrouptype_free_ptr(wgt); + WM_gizmogrouptype_free_ptr(wgt); return true; } -static void wm_manipulatorgrouptype_ghash_free_cb(wmManipulatorGroupType *wgt) +static void wm_gizmogrouptype_ghash_free_cb(wmGizmoGroupType *wgt) { - manipulatorgrouptype_free(wgt); + gizmogrouptype_free(wgt); } -void wm_manipulatorgrouptype_free(void) +void wm_gizmogrouptype_free(void) { - BLI_ghash_free(global_manipulatorgrouptype_hash, NULL, (GHashValFreeFP)wm_manipulatorgrouptype_ghash_free_cb); - global_manipulatorgrouptype_hash = NULL; + BLI_ghash_free(global_gizmogrouptype_hash, NULL, (GHashValFreeFP)wm_gizmogrouptype_ghash_free_cb); + global_gizmogrouptype_hash = NULL; } /* called on initialize WM_init() */ -void wm_manipulatorgrouptype_init(void) +void wm_gizmogrouptype_init(void) { /* reserve size is set based on blender default setup */ - global_manipulatorgrouptype_hash = BLI_ghash_str_new_ex("wm_manipulatorgrouptype_init gh", 128); + global_gizmogrouptype_hash = BLI_ghash_str_new_ex("wm_gizmogrouptype_init gh", 128); } /** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h index 7a007a8a909..5eed4f2bda2 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h @@ -29,32 +29,32 @@ #define __WM_GIZMO_INTERN_H__ struct wmKeyConfig; -struct wmManipulatorMap; -struct ManipulatorGeomInfo; +struct wmGizmoMap; +struct GizmoGeomInfo; struct GHashIterator; #include "wm_gizmo_fn.h" /* -------------------------------------------------------------------- */ -/* wmManipulator */ +/* wmGizmo */ -bool wm_manipulator_select_set_ex( - struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select, +bool wm_gizmo_select_set_ex( + struct wmGizmoMap *mmap, struct wmGizmo *mpr, bool select, bool use_array, bool use_callback); -bool wm_manipulator_select_and_highlight(bContext *C, struct wmManipulatorMap *mmap, struct wmManipulator *mpr); +bool wm_gizmo_select_and_highlight(bContext *C, struct wmGizmoMap *mmap, struct wmGizmo *mpr); -void wm_manipulator_calculate_scale(struct wmManipulator *mpr, const bContext *C); -void wm_manipulator_update(struct wmManipulator *mpr, const bContext *C, const bool refresh_map); +void wm_gizmo_calculate_scale(struct wmGizmo *mpr, const bContext *C); +void wm_gizmo_update(struct wmGizmo *mpr, const bContext *C, const bool refresh_map); -int wm_manipulator_is_visible(struct wmManipulator *mpr); +int wm_gizmo_is_visible(struct wmGizmo *mpr); enum { - WM_MANIPULATOR_IS_VISIBLE_UPDATE = (1 << 0), - WM_MANIPULATOR_IS_VISIBLE_DRAW = (1 << 1), + WM_GIZMO_IS_VISIBLE_UPDATE = (1 << 0), + WM_GIZMO_IS_VISIBLE_DRAW = (1 << 1), }; /* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ +/* wmGizmoGroup */ enum { TWEAK_MODAL_CANCEL = 1, @@ -65,53 +65,53 @@ enum { TWEAK_MODAL_SNAP_OFF, }; -struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type( - struct wmManipulatorMap *mmap, struct wmManipulatorGroupType *wgt); -void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorGroup *mgroup); -void wm_manipulatorgroup_manipulator_register(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr); -struct wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( - const struct wmManipulatorGroup *mgroup, struct bContext *C, const struct wmEvent *event, +struct wmGizmoGroup *wm_gizmogroup_new_from_type( + struct wmGizmoMap *mmap, struct wmGizmoGroupType *wgt); +void wm_gizmogroup_free(bContext *C, struct wmGizmoGroup *mgroup); +void wm_gizmogroup_gizmo_register(struct wmGizmoGroup *mgroup, struct wmGizmo *mpr); +struct wmGizmo *wm_gizmogroup_find_intersected_gizmo( + const struct wmGizmoGroup *mgroup, struct bContext *C, const struct wmEvent *event, int *r_part); -void wm_manipulatorgroup_intersectable_manipulators_to_list( - const struct wmManipulatorGroup *mgroup, struct ListBase *listbase); -void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, const struct bContext *C); -bool wm_manipulatorgroup_is_visible_in_drawstep( - const struct wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep); +void wm_gizmogroup_intersectable_gizmos_to_list( + const struct wmGizmoGroup *mgroup, struct ListBase *listbase); +void wm_gizmogroup_ensure_initialized(struct wmGizmoGroup *mgroup, const struct bContext *C); +bool wm_gizmogroup_is_visible_in_drawstep( + const struct wmGizmoGroup *mgroup, const eWM_GizmoFlagMapDrawStep drawstep); -void wm_manipulatorgrouptype_setup_keymap( - struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf); +void wm_gizmogrouptype_setup_keymap( + struct wmGizmoGroupType *wgt, struct wmKeyConfig *keyconf); /* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ +/* wmGizmoMap */ -typedef struct wmManipulatorMapSelectState { - struct wmManipulator **items; +typedef struct wmGizmoMapSelectState { + struct wmGizmo **items; int len, len_alloc; -} wmManipulatorMapSelectState; +} wmGizmoMapSelectState; -struct wmManipulatorMap { +struct wmGizmoMap { - struct wmManipulatorMapType *type; - ListBase groups; /* wmManipulatorGroup */ + struct wmGizmoMapType *type; + ListBase groups; /* wmGizmoGroup */ /* private, update tagging (enum defined in C source). */ - char update_flag[WM_MANIPULATORMAP_DRAWSTEP_MAX]; + char update_flag[WM_GIZMOMAP_DRAWSTEP_MAX]; /** - * \brief Manipulator map runtime context + * \brief Gizmo map runtime context * - * Contains information about this manipulator-map. Currently - * highlighted manipulator, currently selected manipulators, ... + * Contains information about this gizmo-map. Currently + * highlighted gizmo, currently selected gizmos, ... */ struct { - /* we redraw the manipulator-map when this changes */ - struct wmManipulator *highlight; - /* User has clicked this manipulator and it gets all input. */ - struct wmManipulator *modal; - /* array for all selected manipulators */ - struct wmManipulatorMapSelectState select; - /* cursor location at point of entering modal (see: WM_MANIPULATOR_GRAB_CURSOR) */ + /* we redraw the gizmo-map when this changes */ + struct wmGizmo *highlight; + /* User has clicked this gizmo and it gets all input. */ + struct wmGizmo *modal; + /* array for all selected gizmos */ + struct wmGizmoMapSelectState select; + /* cursor location at point of entering modal (see: WM_GIZMO_GRAB_CURSOR) */ int event_xy[2]; short event_grabcursor; /* until we have nice cursor push/pop API. */ @@ -120,25 +120,25 @@ struct wmManipulatorMap { }; /** - * This is a container for all manipulator types that can be instantiated in a region. + * This is a container for all gizmo types that can be instantiated in a region. * (similar to dropboxes). * * \note There is only ever one of these for every (area, region) combination. */ -struct wmManipulatorMapType { - struct wmManipulatorMapType *next, *prev; +struct wmGizmoMapType { + struct wmGizmoMapType *next, *prev; short spaceid, regionid; - /* types of manipulator-groups for this manipulator-map type */ + /* types of gizmo-groups for this gizmo-map type */ ListBase grouptype_refs; - /* eManipulatorMapTypeUpdateFlags */ - eWM_ManipulatorMapTypeUpdateFlag type_update_flag; + /* eGizmoMapTypeUpdateFlags */ + eWM_GizmoFlagMapTypeUpdateFlag type_update_flag; }; -void wm_manipulatormap_select_array_clear(struct wmManipulatorMap *mmap); -bool wm_manipulatormap_deselect_all(struct wmManipulatorMap *mmap); -void wm_manipulatormap_select_array_shrink(struct wmManipulatorMap *mmap, int len_subtract); -void wm_manipulatormap_select_array_push_back(struct wmManipulatorMap *mmap, wmManipulator *mpr); -void wm_manipulatormap_select_array_remove(struct wmManipulatorMap *mmap, wmManipulator *mpr); +void wm_gizmomap_select_array_clear(struct wmGizmoMap *mmap); +bool wm_gizmomap_deselect_all(struct wmGizmoMap *mmap); +void wm_gizmomap_select_array_shrink(struct wmGizmoMap *mmap, int len_subtract); +void wm_gizmomap_select_array_push_back(struct wmGizmoMap *mmap, wmGizmo *mpr); +void wm_gizmomap_select_array_remove(struct wmGizmoMap *mmap, wmGizmo *mpr); #endif diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index 94db6b45887..9da1591d535 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -61,42 +61,42 @@ #include "wm_gizmo_intern.h" /** - * Store all manipulator-maps here. Anyone who wants to register a manipulator for a certain - * area type can query the manipulator-map to do so. + * Store all gizmo-maps here. Anyone who wants to register a gizmo for a certain + * area type can query the gizmo-map to do so. */ -static ListBase manipulatormaptypes = {NULL, NULL}; +static ListBase gizmomaptypes = {NULL, NULL}; /** - * Update when manipulator-map types change. + * Update when gizmo-map types change. */ /* so operator removal can trigger update */ -typedef enum eWM_ManipulatorGroupTypeGlobalFlag { - WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0), - WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1), -} eWM_ManipulatorGroupTypeGlobalFlag; +typedef enum eWM_GizmoFlagGroupTypeGlobalFlag { + WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0), + WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1), +} eWM_GizmoFlagGroupTypeGlobalFlag; -static eWM_ManipulatorGroupTypeGlobalFlag wm_mmap_type_update_flag = 0; +static eWM_GizmoFlagGroupTypeGlobalFlag wm_mmap_type_update_flag = 0; /** - * Manipulator-map update tagging. + * Gizmo-map update tagging. */ enum { - /** #manipulatormap_prepare_drawing has run */ - MANIPULATORMAP_IS_PREPARE_DRAW = (1 << 0), - MANIPULATORMAP_IS_REFRESH_CALLBACK = (1 << 1), + /** #gizmomap_prepare_drawing has run */ + GIZMOMAP_IS_PREPARE_DRAW = (1 << 0), + GIZMOMAP_IS_REFRESH_CALLBACK = (1 << 1), }; /* -------------------------------------------------------------------- */ -/** \name wmManipulatorMap Selection Array API +/** \name wmGizmoMap Selection Array API * - * Just handle ``wm_manipulatormap_select_array_*``, not flags or callbacks. + * Just handle ``wm_gizmomap_select_array_*``, not flags or callbacks. * * \{ */ -static void wm_manipulatormap_select_array_ensure_len_alloc(wmManipulatorMap *mmap, int len) +static void wm_gizmomap_select_array_ensure_len_alloc(wmGizmoMap *mmap, int len) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; if (len <= msel->len_alloc) { return; } @@ -104,20 +104,20 @@ static void wm_manipulatormap_select_array_ensure_len_alloc(wmManipulatorMap *mm msel->len_alloc = len; } -void wm_manipulatormap_select_array_clear(wmManipulatorMap *mmap) +void wm_gizmomap_select_array_clear(wmGizmoMap *mmap) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; MEM_SAFE_FREE(msel->items); msel->len = 0; msel->len_alloc = 0; } -void wm_manipulatormap_select_array_shrink(wmManipulatorMap *mmap, int len_subtract) +void wm_gizmomap_select_array_shrink(wmGizmoMap *mmap, int len_subtract) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; msel->len -= len_subtract; if (msel->len <= 0) { - wm_manipulatormap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(mmap); } else { if (msel->len < msel->len_alloc / 2) { @@ -127,9 +127,9 @@ void wm_manipulatormap_select_array_shrink(wmManipulatorMap *mmap, int len_subtr } } -void wm_manipulatormap_select_array_push_back(wmManipulatorMap *mmap, wmManipulator *mpr) +void wm_gizmomap_select_array_push_back(wmGizmoMap *mmap, wmGizmo *mpr) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; BLI_assert(msel->len <= msel->len_alloc); if (msel->len == msel->len_alloc) { msel->len_alloc = (msel->len + 1) * 2; @@ -138,16 +138,16 @@ void wm_manipulatormap_select_array_push_back(wmManipulatorMap *mmap, wmManipula msel->items[msel->len++] = mpr; } -void wm_manipulatormap_select_array_remove(wmManipulatorMap *mmap, wmManipulator *mpr) +void wm_gizmomap_select_array_remove(wmGizmoMap *mmap, wmGizmo *mpr) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - /* remove manipulator from selected_manipulators array */ + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + /* remove gizmo from selected_gizmos array */ for (int i = 0; i < msel->len; i++) { if (msel->items[i] == mpr) { for (int j = i; j < (msel->len - 1); j++) { msel->items[j] = msel->items[j + 1]; } - wm_manipulatormap_select_array_shrink(mmap, 1); + wm_gizmomap_select_array_shrink(mmap, 1); break; } } @@ -158,41 +158,41 @@ void wm_manipulatormap_select_array_remove(wmManipulatorMap *mmap, wmManipulator /* -------------------------------------------------------------------- */ -/** \name wmManipulatorMap +/** \name wmGizmoMap * * \{ */ /** - * Creates a manipulator-map with all registered manipulators for that type + * Creates a gizmo-map with all registered gizmos for that type */ -wmManipulatorMap *WM_manipulatormap_new_from_type( - const struct wmManipulatorMapType_Params *mmap_params) +wmGizmoMap *WM_gizmomap_new_from_type( + const struct wmGizmoMapType_Params *mmap_params) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(mmap_params); - wmManipulatorMap *mmap; + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(mmap_params); + wmGizmoMap *mmap; - mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap"); + mmap = MEM_callocN(sizeof(wmGizmoMap), "GizmoMap"); mmap->type = mmap_type; - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); - /* create all manipulator-groups for this manipulator-map. We may create an empty one - * too in anticipation of manipulators from operators etc */ - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { - wm_manipulatorgroup_new_from_type(mmap, wgt_ref->type); + /* create all gizmo-groups for this gizmo-map. We may create an empty one + * too in anticipation of gizmos from operators etc */ + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { + wm_gizmogroup_new_from_type(mmap, wgt_ref->type); } return mmap; } -void wm_manipulatormap_remove(wmManipulatorMap *mmap) +void wm_gizmomap_remove(wmGizmoMap *mmap) { /* Clear first so further calls don't waste time trying to maintain correct array state. */ - wm_manipulatormap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(mmap); - for (wmManipulatorGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) { + for (wmGizmoGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) { mgroup_next = mgroup->next; BLI_assert(mgroup->parent_mmap == mmap); - wm_manipulatorgroup_free(NULL, mgroup); + wm_gizmogroup_free(NULL, mgroup); } BLI_assert(BLI_listbase_is_empty(&mmap->groups)); @@ -200,22 +200,22 @@ void wm_manipulatormap_remove(wmManipulatorMap *mmap) } -wmManipulatorGroup *WM_manipulatormap_group_find( - struct wmManipulatorMap *mmap, +wmGizmoGroup *WM_gizmomap_group_find( + struct wmGizmoMap *mmap, const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); if (wgt) { - return WM_manipulatormap_group_find_ptr(mmap, wgt); + return WM_gizmomap_group_find_ptr(mmap, wgt); } return NULL; } -wmManipulatorGroup *WM_manipulatormap_group_find_ptr( - struct wmManipulatorMap *mmap, - const struct wmManipulatorGroupType *wgt) +wmGizmoGroup *WM_gizmomap_group_find_ptr( + struct wmGizmoMap *mmap, + const struct wmGizmoGroupType *wgt) { - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { if (mgroup->type == wgt) { return mgroup; } @@ -223,12 +223,12 @@ wmManipulatorGroup *WM_manipulatormap_group_find_ptr( return NULL; } -const ListBase *WM_manipulatormap_group_list(wmManipulatorMap *mmap) +const ListBase *WM_gizmomap_group_list(wmGizmoMap *mmap) { return &mmap->groups; } -bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap) +bool WM_gizmomap_is_any_selected(const wmGizmoMap *mmap) { return mmap->mmap_context.select.len != 0; } @@ -236,8 +236,8 @@ bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap) /** * \note We could use a callback to define bounds, for now just use matrix location. */ -bool WM_manipulatormap_minmax( - const wmManipulatorMap *mmap, bool UNUSED(use_hidden), bool use_select, +bool WM_gizmomap_minmax( + const wmGizmoMap *mmap, bool UNUSED(use_hidden), bool use_select, float r_min[3], float r_max[3]) { if (use_select) { @@ -255,26 +255,26 @@ bool WM_manipulatormap_minmax( } /** - * Creates and returns idname hash table for (visible) manipulators in \a mmap + * Creates and returns idname hash table for (visible) gizmos in \a mmap * - * \param poll Polling function for excluding manipulators. + * \param poll Polling function for excluding gizmos. * \param data Custom data passed to \a poll * * TODO(campbell): this uses unreliable order, * best we use an iterator function instead of a hash. */ -static GHash *WM_manipulatormap_manipulator_hash_new( - const bContext *C, wmManipulatorMap *mmap, - bool (*poll)(const wmManipulator *, void *), +static GHash *WM_gizmomap_gizmo_hash_new( + const bContext *C, wmGizmoMap *mmap, + bool (*poll)(const wmGizmo *, void *), void *data, const bool include_hidden) { GHash *hash = BLI_ghash_ptr_new(__func__); - /* collect manipulators */ - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (WM_manipulator_group_type_poll(C, mgroup->type)) { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) && + /* collect gizmos */ + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + if (WM_gizmo_group_type_poll(C, mgroup->type)) { + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if ((include_hidden || (mpr->flag & WM_GIZMO_HIDDEN) == 0) && (!poll || poll(mpr, data))) { BLI_ghash_insert(hash, mpr, mpr); @@ -286,35 +286,35 @@ static GHash *WM_manipulatormap_manipulator_hash_new( return hash; } -void WM_manipulatormap_tag_refresh(wmManipulatorMap *mmap) +void WM_gizmomap_tag_refresh(wmGizmoMap *mmap) { if (mmap) { /* We might want only to refresh some, for tag all steps. */ - for (int i = 0; i < WM_MANIPULATORMAP_DRAWSTEP_MAX; i++) { + for (int i = 0; i < WM_GIZMOMAP_DRAWSTEP_MAX; i++) { mmap->update_flag[i] |= ( - MANIPULATORMAP_IS_PREPARE_DRAW | - MANIPULATORMAP_IS_REFRESH_CALLBACK); + GIZMOMAP_IS_PREPARE_DRAW | + GIZMOMAP_IS_REFRESH_CALLBACK); } } } -static bool manipulator_prepare_drawing( - wmManipulatorMap *mmap, wmManipulator *mpr, - const bContext *C, ListBase *draw_manipulators, - const eWM_ManipulatorMapDrawStep drawstep) +static bool gizmo_prepare_drawing( + wmGizmoMap *mmap, wmGizmo *mpr, + const bContext *C, ListBase *draw_gizmos, + const eWM_GizmoFlagMapDrawStep drawstep) { - int do_draw = wm_manipulator_is_visible(mpr); + int do_draw = wm_gizmo_is_visible(mpr); if (do_draw == 0) { /* skip */ } else { /* Ensure we get RNA updates */ - if (do_draw & WM_MANIPULATOR_IS_VISIBLE_UPDATE) { - /* hover manipulators need updating, even if we don't draw them */ - wm_manipulator_update(mpr, C, (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_PREPARE_DRAW) != 0); + if (do_draw & WM_GIZMO_IS_VISIBLE_UPDATE) { + /* hover gizmos need updating, even if we don't draw them */ + wm_gizmo_update(mpr, C, (mmap->update_flag[drawstep] & GIZMOMAP_IS_PREPARE_DRAW) != 0); } - if (do_draw & WM_MANIPULATOR_IS_VISIBLE_DRAW) { - BLI_addhead(draw_manipulators, BLI_genericNodeN(mpr)); + if (do_draw & WM_GIZMO_IS_VISIBLE_DRAW) { + BLI_addhead(draw_gizmos, BLI_genericNodeN(mpr)); } return true; } @@ -323,67 +323,67 @@ static bool manipulator_prepare_drawing( } /** - * Update manipulators of \a mmap to prepare for drawing. Adds all manipulators that - * should be drawn to list \a draw_manipulators, note that added items need freeing. + * Update gizmos of \a mmap to prepare for drawing. Adds all gizmos that + * should be drawn to list \a draw_gizmos, note that added items need freeing. */ -static void manipulatormap_prepare_drawing( - wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators, - const eWM_ManipulatorMapDrawStep drawstep) +static void gizmomap_prepare_drawing( + wmGizmoMap *mmap, const bContext *C, ListBase *draw_gizmos, + const eWM_GizmoFlagMapDrawStep drawstep) { if (!mmap || BLI_listbase_is_empty(&mmap->groups)) return; - wmManipulator *mpr_modal = mmap->mmap_context.modal; + wmGizmo *mpr_modal = mmap->mmap_context.modal; - /* only active manipulator needs updating */ + /* only active gizmo needs updating */ if (mpr_modal) { - if ((mpr_modal->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL) == 0) { - if (wm_manipulatorgroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) { - if (manipulator_prepare_drawing(mmap, mpr_modal, C, draw_manipulators, drawstep)) { - mmap->update_flag[drawstep] &= ~MANIPULATORMAP_IS_PREPARE_DRAW; + if ((mpr_modal->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL) == 0) { + if (wm_gizmogroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) { + if (gizmo_prepare_drawing(mmap, mpr_modal, C, draw_gizmos, drawstep)) { + mmap->update_flag[drawstep] &= ~GIZMOMAP_IS_PREPARE_DRAW; } } - /* don't draw any other manipulators */ + /* don't draw any other gizmos */ return; } } - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */ - if (!wm_manipulatorgroup_is_visible_in_drawstep(mgroup, drawstep) || - !WM_manipulator_group_type_poll(C, mgroup->type)) + if (!wm_gizmogroup_is_visible_in_drawstep(mgroup, drawstep) || + !WM_gizmo_group_type_poll(C, mgroup->type)) { continue; } /* needs to be initialized on first draw */ - /* XXX weak: Manipulator-group may skip refreshing if it's invisible (map gets untagged nevertheless) */ - if (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_REFRESH_CALLBACK) { + /* XXX weak: Gizmo-group may skip refreshing if it's invisible (map gets untagged nevertheless) */ + if (mmap->update_flag[drawstep] & GIZMOMAP_IS_REFRESH_CALLBACK) { /* force refresh again. */ - mgroup->init_flag &= ~WM_MANIPULATORGROUP_INIT_REFRESH; + mgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH; } /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */ - wm_manipulatorgroup_ensure_initialized(mgroup, C); + wm_gizmogroup_ensure_initialized(mgroup, C); /* prepare drawing */ if (mgroup->type->draw_prepare) { mgroup->type->draw_prepare(C, mgroup); } - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - manipulator_prepare_drawing(mmap, mpr, C, draw_manipulators, drawstep); + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + gizmo_prepare_drawing(mmap, mpr, C, draw_gizmos, drawstep); } } mmap->update_flag[drawstep] &= - ~(MANIPULATORMAP_IS_REFRESH_CALLBACK | - MANIPULATORMAP_IS_PREPARE_DRAW); + ~(GIZMOMAP_IS_REFRESH_CALLBACK | + GIZMOMAP_IS_PREPARE_DRAW); } /** - * Draw all visible manipulators in \a mmap. - * Uses global draw_manipulators listbase. + * Draw all visible gizmos in \a mmap. + * Uses global draw_gizmos listbase. */ -static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators) +static void gizmos_draw_list(const wmGizmoMap *mmap, const bContext *C, ListBase *draw_gizmos) { /* Can be empty if we're dynamically added and removed. */ if ((mmap == NULL) || BLI_listbase_is_empty(&mmap->groups)) { @@ -391,19 +391,19 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext } /* TODO this will need it own shader probably? don't think it can be handled from that point though. */ -/* const bool use_lighting = (U.manipulator_flag & V3D_MANIPULATOR_SHADED) != 0; */ +/* const bool use_lighting = (U.gizmo_flag & V3D_GIZMO_SHADED) != 0; */ bool is_depth_prev = false; - /* draw_manipulators contains all visible manipulators - draw them */ - for (LinkData *link = draw_manipulators->first, *link_next; link; link = link_next) { - wmManipulator *mpr = link->data; + /* draw_gizmos contains all visible gizmos - draw them */ + for (LinkData *link = draw_gizmos->first, *link_next; link; link = link_next) { + wmGizmo *mpr = link->data; link_next = link->next; - bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0; + bool is_depth = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0; /* Weak! since we don't 100% support depth yet (select ignores depth) always show highlighted */ - if (is_depth && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)) { + if (is_depth && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT)) { is_depth = false; } @@ -420,7 +420,7 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext is_depth_prev = is_depth; } - /* XXX force AntiAlias Manipulators. */ + /* XXX force AntiAlias Gizmos. */ glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); @@ -429,8 +429,8 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_SMOOTH); - /* free/remove manipulator link after drawing */ - BLI_freelinkN(draw_manipulators, link); + /* free/remove gizmo link after drawing */ + BLI_freelinkN(draw_gizmos, link); } if (is_depth_prev) { @@ -438,34 +438,34 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext } } -void WM_manipulatormap_draw( - wmManipulatorMap *mmap, const bContext *C, - const eWM_ManipulatorMapDrawStep drawstep) +void WM_gizmomap_draw( + wmGizmoMap *mmap, const bContext *C, + const eWM_GizmoFlagMapDrawStep drawstep) { - if (!WM_manipulator_context_check_drawstep(C, drawstep)) { + if (!WM_gizmo_context_check_drawstep(C, drawstep)) { return; } - ListBase draw_manipulators = {NULL}; + ListBase draw_gizmos = {NULL}; - manipulatormap_prepare_drawing(mmap, C, &draw_manipulators, drawstep); - manipulators_draw_list(mmap, C, &draw_manipulators); - BLI_assert(BLI_listbase_is_empty(&draw_manipulators)); + gizmomap_prepare_drawing(mmap, C, &draw_gizmos, drawstep); + gizmos_draw_list(mmap, C, &draw_gizmos); + BLI_assert(BLI_listbase_is_empty(&draw_gizmos)); } -static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible_manipulators) +static void gizmo_draw_select_3D_loop(const bContext *C, ListBase *visible_gizmos) { int select_id = 0; - wmManipulator *mpr; + wmGizmo *mpr; /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */ bool is_depth_prev = false; bool is_depth_skip_prev = false; - for (LinkData *link = visible_manipulators->first; link; link = link->next) { + for (LinkData *link = visible_gizmos->first; link; link = link->next) { mpr = link->data; - bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0; + bool is_depth = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0; if (is_depth == is_depth_prev) { /* pass */ } @@ -478,7 +478,7 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible } is_depth_prev = is_depth; } - bool is_depth_skip = (mpr->flag & WM_MANIPULATOR_SELECT_BACKGROUND) != 0; + bool is_depth_skip = (mpr->flag & WM_GIZMO_SELECT_BACKGROUND) != 0; if (is_depth_skip == is_depth_skip_prev) { /* pass */ } @@ -487,7 +487,7 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible is_depth_skip_prev = is_depth_skip; } - /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected manipulator part id */ + /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected gizmo part id */ mpr->type->draw_select(C, mpr, select_id << 8); @@ -503,15 +503,15 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible } } -static int manipulator_find_intersected_3d_intern( - ListBase *visible_manipulators, const bContext *C, const int co[2], +static int gizmo_find_intersected_3d_intern( + ListBase *visible_gizmos, const bContext *C, const int co[2], const int hotspot) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = sa->spacedata.first; rcti rect; - /* Almost certainly overkill, but allow for many custom manipulators. */ + /* Almost certainly overkill, but allow for many custom gizmos. */ GLuint buffer[MAXPICKBUF]; short hits; const bool do_passes = GPU_select_query_check_active(); @@ -525,13 +525,13 @@ static int manipulator_find_intersected_3d_intern( else GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_ALL, 0); /* do the drawing */ - manipulator_draw_select_3D_loop(C, visible_manipulators); + gizmo_draw_select_3D_loop(C, visible_gizmos); hits = GPU_select_end(); if (do_passes && (hits > 0)) { GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); - manipulator_draw_select_3D_loop(C, visible_manipulators); + gizmo_draw_select_3D_loop(C, visible_gizmos); GPU_select_end(); } @@ -543,13 +543,13 @@ static int manipulator_find_intersected_3d_intern( } /** - * Try to find a 3D manipulator at screen-space coordinate \a co. Uses OpenGL picking. + * Try to find a 3D gizmo at screen-space coordinate \a co. Uses OpenGL picking. */ -static wmManipulator *manipulator_find_intersected_3d( - bContext *C, const int co[2], ListBase *visible_manipulators, +static wmGizmo *gizmo_find_intersected_3d( + bContext *C, const int co[2], ListBase *visible_gizmos, int *r_part) { - wmManipulator *result = NULL; + wmGizmo *result = NULL; int hit = -1; int hotspot_radii[] = { @@ -566,20 +566,20 @@ static wmManipulator *manipulator_find_intersected_3d( hit = -1; for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) { - hit = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, hotspot_radii[i]); + hit = gizmo_find_intersected_3d_intern(visible_gizmos, C, co, hotspot_radii[i]); if (hit != -1) { break; } } if (hit != -1) { - LinkData *link = BLI_findlink(visible_manipulators, hit >> 8); + LinkData *link = BLI_findlink(visible_gizmos, hit >> 8); if (link != NULL) { *r_part = hit & 255; result = link->data; } else { - /* All manipulators should use selection ID they're given as part of the callback, + /* All gizmos should use selection ID they're given as part of the callback, * if they don't it will attempt tp lookup non-existing index. */ BLI_assert(0); } @@ -589,51 +589,51 @@ static wmManipulator *manipulator_find_intersected_3d( } /** - * Try to find a manipulator under the mouse position. 2D intersections have priority over + * Try to find a gizmo under the mouse position. 2D intersections have priority over * 3D ones (could check for smallest screen-space distance but not needed right now). */ -wmManipulator *wm_manipulatormap_highlight_find( - wmManipulatorMap *mmap, bContext *C, const wmEvent *event, +wmGizmo *wm_gizmomap_highlight_find( + wmGizmoMap *mmap, bContext *C, const wmEvent *event, int *r_part) { - wmManipulator *mpr = NULL; - ListBase visible_3d_manipulators = {NULL}; - bool do_step[WM_MANIPULATORMAP_DRAWSTEP_MAX]; + wmGizmo *mpr = NULL; + ListBase visible_3d_gizmos = {NULL}; + bool do_step[WM_GIZMOMAP_DRAWSTEP_MAX]; for (int i = 0; i < ARRAY_SIZE(do_step); i++) { - do_step[i] = WM_manipulator_context_check_drawstep(C, i); + do_step[i] = WM_gizmo_context_check_drawstep(C, i); } - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { /* If it were important we could initialize here, * but this only happens when events are handled before drawing, - * just skip to keep code-path for initializing manipulators simple. */ - if ((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0) { + * just skip to keep code-path for initializing gizmos simple. */ + if ((mgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0) { continue; } - if (WM_manipulator_group_type_poll(C, mgroup->type)) { - eWM_ManipulatorMapDrawStep step; - if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - step = WM_MANIPULATORMAP_DRAWSTEP_3D; + if (WM_gizmo_group_type_poll(C, mgroup->type)) { + eWM_GizmoFlagMapDrawStep step; + if (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + step = WM_GIZMOMAP_DRAWSTEP_3D; } else { - step = WM_MANIPULATORMAP_DRAWSTEP_2D; + step = WM_GIZMOMAP_DRAWSTEP_2D; } if (do_step[step]) { - if ((mmap->update_flag[step] & MANIPULATORMAP_IS_REFRESH_CALLBACK) && + if ((mmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) && (mgroup->type->refresh != NULL)) { mgroup->type->refresh(C, mgroup); /* cleared below */ } - if (step == WM_MANIPULATORMAP_DRAWSTEP_3D) { - wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators); + if (step == WM_GIZMOMAP_DRAWSTEP_3D) { + wm_gizmogroup_intersectable_gizmos_to_list(mgroup, &visible_3d_gizmos); } - else if (step == WM_MANIPULATORMAP_DRAWSTEP_2D) { - if ((mpr = wm_manipulatorgroup_find_intersected_manipulator(mgroup, C, event, r_part))) { + else if (step == WM_GIZMOMAP_DRAWSTEP_2D) { + if ((mpr = wm_gizmogroup_find_intersected_gizmo(mgroup, C, event, r_part))) { break; } } @@ -641,62 +641,62 @@ wmManipulator *wm_manipulatormap_highlight_find( } } - if (!BLI_listbase_is_empty(&visible_3d_manipulators)) { - /* 2D manipulators get priority. */ + if (!BLI_listbase_is_empty(&visible_3d_gizmos)) { + /* 2D gizmos get priority. */ if (mpr == NULL) { - mpr = manipulator_find_intersected_3d(C, event->mval, &visible_3d_manipulators, r_part); + mpr = gizmo_find_intersected_3d(C, event->mval, &visible_3d_gizmos, r_part); } - BLI_freelistN(&visible_3d_manipulators); + BLI_freelistN(&visible_3d_gizmos); } - mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_3D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK; - mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_2D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK; + mmap->update_flag[WM_GIZMOMAP_DRAWSTEP_3D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; + mmap->update_flag[WM_GIZMOMAP_DRAWSTEP_2D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; return mpr; } -void WM_manipulatormap_add_handlers(ARegion *ar, wmManipulatorMap *mmap) +void WM_gizmomap_add_handlers(ARegion *ar, wmGizmoMap *mmap) { wmEventHandler *handler; for (handler = ar->handlers.first; handler; handler = handler->next) { - if (handler->manipulator_map == mmap) { + if (handler->gizmo_map == mmap) { return; } } - handler = MEM_callocN(sizeof(wmEventHandler), "manipulator handler"); + handler = MEM_callocN(sizeof(wmEventHandler), "gizmo handler"); - BLI_assert(mmap == ar->manipulator_map); - handler->manipulator_map = mmap; + BLI_assert(mmap == ar->gizmo_map); + handler->gizmo_map = mmap; BLI_addtail(&ar->handlers, handler); } -void wm_manipulatormaps_handled_modal_update( +void wm_gizmomaps_handled_modal_update( bContext *C, wmEvent *event, wmEventHandler *handler) { const bool modal_running = (handler->op != NULL); /* happens on render or when joining areas */ - if (!handler->op_region || !handler->op_region->manipulator_map) { + if (!handler->op_region || !handler->op_region->gizmo_map) { return; } - wmManipulatorMap *mmap = handler->op_region->manipulator_map; - wmManipulator *mpr = wm_manipulatormap_modal_get(mmap); + wmGizmoMap *mmap = handler->op_region->gizmo_map; + wmGizmo *mpr = wm_gizmomap_modal_get(mmap); ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - wm_manipulatormap_handler_context(C, handler); + wm_gizmomap_handler_context(C, handler); /* regular update for running operator */ if (modal_running) { - wmManipulatorOpElem *mpop = mpr ? WM_manipulator_operator_get(mpr, mpr->highlight_part) : NULL; + wmGizmoOpElem *mpop = mpr ? WM_gizmo_operator_get(mpr, mpr->highlight_part) : NULL; if (mpr && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) { - wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; + wmGizmoFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; if (modal_fn != NULL) { int retval = modal_fn(C, mpr, event, 0); - /* The manipulator is tried to the operator, we can't choose when to exit. */ + /* The gizmo is tried to the operator, we can't choose when to exit. */ BLI_assert(retval & OPERATOR_RUNNING_MODAL); UNUSED_VARS_NDEBUG(retval); } @@ -704,14 +704,14 @@ void wm_manipulatormaps_handled_modal_update( } /* operator not running anymore */ else { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + wm_gizmomap_highlight_set(mmap, C, NULL, 0); if (mpr) { /* This isn't defined if it ends because of success of cancel, we may want to change. */ bool cancel = true; if (mpr->type->exit) { mpr->type->exit(C, mpr, cancel); } - wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false); + wm_gizmomap_modal_set(mmap, C, mpr, NULL, false); } } @@ -721,58 +721,58 @@ void wm_manipulatormaps_handled_modal_update( } /** - * Deselect all selected manipulators in \a mmap. + * Deselect all selected gizmos in \a mmap. * \return if selection has changed. */ -bool wm_manipulatormap_deselect_all(wmManipulatorMap *mmap) +bool wm_gizmomap_deselect_all(wmGizmoMap *mmap) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; if (msel->items == NULL || msel->len == 0) { return false; } for (int i = 0; i < msel->len; i++) { - wm_manipulator_select_set_ex(mmap, msel->items[i], false, false, true); + wm_gizmo_select_set_ex(mmap, msel->items[i], false, false, true); } - wm_manipulatormap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(mmap); /* always return true, we already checked * if there's anything to deselect */ return true; } -BLI_INLINE bool manipulator_selectable_poll(const wmManipulator *mpr, void *UNUSED(data)) +BLI_INLINE bool gizmo_selectable_poll(const wmGizmo *mpr, void *UNUSED(data)) { - return (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT); + return (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT); } /** - * Select all selectable manipulators in \a mmap. + * Select all selectable gizmos in \a mmap. * \return if selection has changed. */ -static bool wm_manipulatormap_select_all_intern( - bContext *C, wmManipulatorMap *mmap) +static bool wm_gizmomap_select_all_intern( + bContext *C, wmGizmoMap *mmap) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - /* GHash is used here to avoid having to loop over all manipulators twice (once to + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + /* GHash is used here to avoid having to loop over all gizmos twice (once to * get tot_sel for allocating, once for actually selecting). Instead we collect - * selectable manipulators in hash table and use this to get tot_sel and do selection */ + * selectable gizmos in hash table and use this to get tot_sel and do selection */ - GHash *hash = WM_manipulatormap_manipulator_hash_new(C, mmap, manipulator_selectable_poll, NULL, true); + GHash *hash = WM_gizmomap_gizmo_hash_new(C, mmap, gizmo_selectable_poll, NULL, true); GHashIterator gh_iter; int i; bool changed = false; - wm_manipulatormap_select_array_ensure_len_alloc(mmap, BLI_ghash_len(hash)); + wm_gizmomap_select_array_ensure_len_alloc(mmap, BLI_ghash_len(hash)); GHASH_ITER_INDEX (gh_iter, hash, i) { - wmManipulator *mpr_iter = BLI_ghashIterator_getValue(&gh_iter); - WM_manipulator_select_set(mmap, mpr_iter, true); + wmGizmo *mpr_iter = BLI_ghashIterator_getValue(&gh_iter); + WM_gizmo_select_set(mmap, mpr_iter, true); } - /* highlight first manipulator */ - wm_manipulatormap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part); + /* highlight first gizmo */ + wm_gizmomap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part); BLI_assert(BLI_ghash_len(hash) == msel->len); @@ -781,21 +781,21 @@ static bool wm_manipulatormap_select_all_intern( } /** - * Select/Deselect all selectable manipulators in \a mmap. + * Select/Deselect all selectable gizmos in \a mmap. * \return if selection has changed. * * TODO select all by type */ -bool WM_manipulatormap_select_all(bContext *C, wmManipulatorMap *mmap, const int action) +bool WM_gizmomap_select_all(bContext *C, wmGizmoMap *mmap, const int action) { bool changed = false; switch (action) { case SEL_SELECT: - changed = wm_manipulatormap_select_all_intern(C, mmap); + changed = wm_gizmomap_select_all_intern(C, mmap); break; case SEL_DESELECT: - changed = wm_manipulatormap_deselect_all(mmap); + changed = wm_gizmomap_deselect_all(mmap); break; default: BLI_assert(0); @@ -809,10 +809,10 @@ bool WM_manipulatormap_select_all(bContext *C, wmManipulatorMap *mmap, const int } /** - * Prepare context for manipulator handling (but only if area/region is - * part of screen). Version of #wm_handler_op_context for manipulators. + * Prepare context for gizmo handling (but only if area/region is + * part of screen). Version of #wm_handler_op_context for gizmos. */ -void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler) +void wm_gizmomap_handler_context(bContext *C, wmEventHandler *handler) { bScreen *screen = CTX_wm_screen(C); @@ -829,8 +829,8 @@ void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler) if (sa == NULL) { /* when changing screen layouts with running modal handlers (like render display), this * is not an error to print */ - if (handler->manipulator_map == NULL) - printf("internal error: modal manipulator-map handler has invalid area\n"); + if (handler->gizmo_map == NULL) + printf("internal error: modal gizmo-map handler has invalid area\n"); } else { ARegion *ar; @@ -846,9 +846,9 @@ void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler) } } -bool WM_manipulatormap_cursor_set(const wmManipulatorMap *mmap, wmWindow *win) +bool WM_gizmomap_cursor_set(const wmGizmoMap *mmap, wmWindow *win) { - wmManipulator *mpr = mmap->mmap_context.highlight; + wmGizmo *mpr = mmap->mmap_context.highlight; if (mpr && mpr->type->cursor_get) { WM_cursor_set(win, mpr->type->cursor_get(mpr)); return true; @@ -857,21 +857,21 @@ bool WM_manipulatormap_cursor_set(const wmManipulatorMap *mmap, wmWindow *win) return false; } -bool wm_manipulatormap_highlight_set( - wmManipulatorMap *mmap, const bContext *C, wmManipulator *mpr, int part) +bool wm_gizmomap_highlight_set( + wmGizmoMap *mmap, const bContext *C, wmGizmo *mpr, int part) { if ((mpr != mmap->mmap_context.highlight) || (mpr && part != mpr->highlight_part)) { if (mmap->mmap_context.highlight) { - mmap->mmap_context.highlight->state &= ~WM_MANIPULATOR_STATE_HIGHLIGHT; + mmap->mmap_context.highlight->state &= ~WM_GIZMO_STATE_HIGHLIGHT; mmap->mmap_context.highlight->highlight_part = -1; } mmap->mmap_context.highlight = mpr; if (mpr) { - mpr->state |= WM_MANIPULATOR_STATE_HIGHLIGHT; + mpr->state |= WM_GIZMO_STATE_HIGHLIGHT; mpr->highlight_part = part; mmap->mmap_context.last_cursor = -1; @@ -900,7 +900,7 @@ bool wm_manipulatormap_highlight_set( return false; } -wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap) +wmGizmo *wm_gizmomap_highlight_get(wmGizmoMap *mmap) { return mmap->mmap_context.highlight; } @@ -908,8 +908,8 @@ wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap) /** * Caller should call exit when (enable == False). */ -void wm_manipulatormap_modal_set( - wmManipulatorMap *mmap, bContext *C, wmManipulator *mpr, const wmEvent *event, bool enable) +void wm_gizmomap_modal_set( + wmGizmoMap *mmap, bContext *C, wmGizmo *mpr, const wmEvent *event, bool enable) { if (enable) { BLI_assert(mmap->mmap_context.modal == NULL); @@ -926,10 +926,10 @@ void wm_manipulatormap_modal_set( } } - mpr->state |= WM_MANIPULATOR_STATE_MODAL; + mpr->state |= WM_GIZMO_STATE_MODAL; mmap->mmap_context.modal = mpr; - if ((mpr->flag & WM_MANIPULATOR_GRAB_CURSOR) && + if ((mpr->flag & WM_GIZMO_GRAB_CURSOR) && (event->is_motion_absolute == false)) { WM_cursor_grab_enable(win, true, true, NULL); @@ -940,16 +940,16 @@ void wm_manipulatormap_modal_set( mmap->mmap_context.event_xy[0] = INT_MAX; } - struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); if (mpop && mpop->type) { const int retval = WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); if ((retval & OPERATOR_RUNNING_MODAL) == 0) { - wm_manipulatormap_modal_set(mmap, C, mpr, event, false); + wm_gizmomap_modal_set(mmap, C, mpr, event, false); } - /* we failed to hook the manipulator to the operator handler or operator was cancelled, return */ + /* we failed to hook the gizmo to the operator handler or operator was cancelled, return */ if (!mmap->mmap_context.modal) { - mpr->state &= ~WM_MANIPULATOR_STATE_MODAL; + mpr->state &= ~WM_GIZMO_STATE_MODAL; MEM_SAFE_FREE(mpr->interaction_data); } return; @@ -958,9 +958,9 @@ void wm_manipulatormap_modal_set( else { BLI_assert(ELEM(mmap->mmap_context.modal, NULL, mpr)); - /* deactivate, manipulator but first take care of some stuff */ + /* deactivate, gizmo but first take care of some stuff */ if (mpr) { - mpr->state &= ~WM_MANIPULATOR_STATE_MODAL; + mpr->state &= ~WM_GIZMO_STATE_MODAL; MEM_SAFE_FREE(mpr->interaction_data); } mmap->mmap_context.modal = NULL; @@ -986,34 +986,34 @@ void wm_manipulatormap_modal_set( } } -wmManipulator *wm_manipulatormap_modal_get(wmManipulatorMap *mmap) +wmGizmo *wm_gizmomap_modal_get(wmGizmoMap *mmap) { return mmap->mmap_context.modal; } -wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len) +wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *mmap, int *r_selected_len) { *r_selected_len = mmap->mmap_context.select.len; return mmap->mmap_context.select.items; } -ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap) +ListBase *wm_gizmomap_groups_get(wmGizmoMap *mmap) { return &mmap->groups; } -void WM_manipulatormap_message_subscribe( - bContext *C, wmManipulatorMap *mmap, ARegion *ar, struct wmMsgBus *mbus) +void WM_gizmomap_message_subscribe( + bContext *C, wmGizmoMap *mmap, ARegion *ar, struct wmMsgBus *mbus) { - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (!WM_manipulator_group_type_poll(C, mgroup->type)) { + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + if (!WM_gizmo_group_type_poll(C, mgroup->type)) { continue; } - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->flag & WM_MANIPULATOR_HIDDEN) { + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if (mpr->flag & WM_GIZMO_HIDDEN) { continue; } - WM_manipulator_target_property_subscribe_all(mpr, mbus, ar); + WM_gizmo_target_property_subscribe_all(mpr, mbus, ar); } if (mgroup->type->message_subscribe != NULL) { mgroup->type->message_subscribe(C, mgroup, mbus); @@ -1021,7 +1021,7 @@ void WM_manipulatormap_message_subscribe( } } -/** \} */ /* wmManipulatorMap */ +/** \} */ /* wmGizmoMap */ /* -------------------------------------------------------------------- */ @@ -1029,31 +1029,31 @@ void WM_manipulatormap_message_subscribe( * * \{ */ -struct ARegion *WM_manipulatormap_tooltip_init( +struct ARegion *WM_gizmomap_tooltip_init( struct bContext *C, struct ARegion *ar, bool *r_exit_on_event) { - wmManipulatorMap *mmap = ar->manipulator_map; + wmGizmoMap *mmap = ar->gizmo_map; *r_exit_on_event = true; if (mmap) { - wmManipulator *mpr = mmap->mmap_context.highlight; + wmGizmo *mpr = mmap->mmap_context.highlight; if (mpr) { - return UI_tooltip_create_from_manipulator(C, mpr); + return UI_tooltip_create_from_gizmo(C, mpr); } } return NULL; } -/** \} */ /* wmManipulatorMapType */ +/** \} */ /* wmGizmoMapType */ /* -------------------------------------------------------------------- */ -/** \name wmManipulatorMapType +/** \name wmGizmoMapType * * \{ */ -wmManipulatorMapType *WM_manipulatormaptype_find( - const struct wmManipulatorMapType_Params *mmap_params) +wmGizmoMapType *WM_gizmomaptype_find( + const struct wmGizmoMapType_Params *mmap_params) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { + for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { if (mmap_type->spaceid == mmap_params->spaceid && mmap_type->regionid == mmap_params->regionid) { @@ -1064,57 +1064,57 @@ wmManipulatorMapType *WM_manipulatormaptype_find( return NULL; } -wmManipulatorMapType *WM_manipulatormaptype_ensure( - const struct wmManipulatorMapType_Params *mmap_params) +wmGizmoMapType *WM_gizmomaptype_ensure( + const struct wmGizmoMapType_Params *mmap_params) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_find(mmap_params); + wmGizmoMapType *mmap_type = WM_gizmomaptype_find(mmap_params); if (mmap_type) { return mmap_type; } - mmap_type = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list"); + mmap_type = MEM_callocN(sizeof(wmGizmoMapType), "gizmotype list"); mmap_type->spaceid = mmap_params->spaceid; mmap_type->regionid = mmap_params->regionid; - BLI_addhead(&manipulatormaptypes, mmap_type); + BLI_addhead(&gizmomaptypes, mmap_type); return mmap_type; } -void wm_manipulatormaptypes_free(void) +void wm_gizmomaptypes_free(void) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first, *mmap_type_next; + for (wmGizmoMapType *mmap_type = gizmomaptypes.first, *mmap_type_next; mmap_type; mmap_type = mmap_type_next) { mmap_type_next = mmap_type->next; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next; wgt_ref; wgt_ref = wgt_next) { wgt_next = wgt_ref->next; - WM_manipulatormaptype_group_free(wgt_ref); + WM_gizmomaptype_group_free(wgt_ref); } MEM_freeN(mmap_type); } } /** - * Initialize keymaps for all existing manipulator-groups + * Initialize keymaps for all existing gizmo-groups */ -void wm_manipulators_keymap(wmKeyConfig *keyconf) +void wm_gizmos_keymap(wmKeyConfig *keyconf) { - /* we add this item-less keymap once and use it to group manipulator-group keymaps into it */ - WM_keymap_find(keyconf, "Manipulators", 0, 0); + /* we add this item-less keymap once and use it to group gizmo-group keymaps into it */ + WM_keymap_find(keyconf, "Gizmos", 0, 0); - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { - wm_manipulatorgrouptype_setup_keymap(wgt_ref->type, keyconf); + for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { + wm_gizmogrouptype_setup_keymap(wgt_ref->type, keyconf); } } } -/** \} */ /* wmManipulatorMapType */ +/** \} */ /* wmGizmoMapType */ /* -------------------------------------------------------------------- */ /** \name Updates for Dynamic Type Registraion @@ -1122,31 +1122,31 @@ void wm_manipulators_keymap(wmKeyConfig *keyconf) * \{ */ -void WM_manipulatorconfig_update_tag_init( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +void WM_gizmoconfig_update_tag_init( + wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) { /* tag for update on next use */ - mmap_type->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT); - wgt->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT); + mmap_type->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT); + wgt->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT); - wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; + wm_mmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT; } -void WM_manipulatorconfig_update_tag_remove( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +void WM_gizmoconfig_update_tag_remove( + wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) { /* tag for update on next use */ - mmap_type->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; + mmap_type->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE; + wgt->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE; - wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE; + wm_mmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE; } /** * Run incase new types have been added (runs often, early exit where possible). * Follows #WM_keyconfig_update concentions. */ -void WM_manipulatorconfig_update(struct Main *bmain) +void WM_gizmoconfig_update(struct Main *bmain) { if (G.background) return; @@ -1154,55 +1154,55 @@ void WM_manipulatorconfig_update(struct Main *bmain) if (wm_mmap_type_update_flag == 0) return; - if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; + if (wm_mmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { + for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { - if (mmap_type->type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) { - mmap_type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_ref_next; + if (mmap_type->type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { + mmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_ref_next; wgt_ref; wgt_ref = wgt_ref_next) { wgt_ref_next = wgt_ref->next; - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_REMOVE) { - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type); + if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_REMOVE) { + wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; + WM_gizmomaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type); } } } } - wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE; + wm_mmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE; } - if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; + if (wm_mmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT) { + for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { - const uchar type_update_all = WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + const uchar type_update_all = WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT; if (mmap_type->type_update_flag & type_update_all) { mmap_type->type_update_flag &= ~type_update_all; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) { - WM_manipulatormaptype_group_init_runtime_keymap(bmain, wgt_ref->type); - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { + WM_gizmomaptype_group_init_runtime_keymap(bmain, wgt_ref->type); + wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; } - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) { - WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type); - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT; + if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_INIT) { + WM_gizmomaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type); + wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_INIT; } } } } - wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; + wm_mmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT; } } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c index 78d12e4e4ba..f3df001af55 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c @@ -51,43 +51,43 @@ /** \name Property Definition * \{ */ -BLI_INLINE wmManipulatorProperty *wm_manipulator_target_property_array(wmManipulator *mpr) +BLI_INLINE wmGizmoProperty *wm_gizmo_target_property_array(wmGizmo *mpr) { - return (wmManipulatorProperty *)(POINTER_OFFSET(mpr, mpr->type->struct_size)); + return (wmGizmoProperty *)(POINTER_OFFSET(mpr, mpr->type->struct_size)); } -wmManipulatorProperty *WM_manipulator_target_property_array(wmManipulator *mpr) +wmGizmoProperty *WM_gizmo_target_property_array(wmGizmo *mpr) { - return wm_manipulator_target_property_array(mpr); + return wm_gizmo_target_property_array(mpr); } -wmManipulatorProperty *WM_manipulator_target_property_at_index(wmManipulator *mpr, int index) +wmGizmoProperty *WM_gizmo_target_property_at_index(wmGizmo *mpr, int index) { BLI_assert(index < mpr->type->target_property_defs_len); BLI_assert(index != -1); - wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = wm_gizmo_target_property_array(mpr); return &mpr_prop_array[index]; } -wmManipulatorProperty *WM_manipulator_target_property_find(wmManipulator *mpr, const char *idname) +wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *mpr, const char *idname) { int index = BLI_findstringindex( - &mpr->type->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname)); + &mpr->type->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)); if (index != -1) { - return WM_manipulator_target_property_at_index(mpr, index); + return WM_gizmo_target_property_at_index(mpr, index); } else { return NULL; } } -void WM_manipulator_target_property_def_rna_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type, +void WM_gizmo_target_property_def_rna_ptr( + wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type, PointerRNA *ptr, PropertyRNA *prop, int index) { - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); - /* if manipulator evokes an operator we cannot use it for property manipulation */ + /* if gizmo evokes an operator we cannot use it for property manipulation */ BLI_assert(mpr->op_data == NULL); mpr_prop->type = mpr_prop_type; @@ -101,22 +101,22 @@ void WM_manipulator_target_property_def_rna_ptr( } } -void WM_manipulator_target_property_def_rna( - wmManipulator *mpr, const char *idname, +void WM_gizmo_target_property_def_rna( + wmGizmo *mpr, const char *idname, PointerRNA *ptr, const char *propname, int index) { - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); + const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); PropertyRNA *prop = RNA_struct_find_property(ptr, propname); - WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); + WM_gizmo_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); } -void WM_manipulator_target_property_def_func_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type, - const wmManipulatorPropertyFnParams *params) +void WM_gizmo_target_property_def_func_ptr( + wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type, + const wmGizmoPropertyFnParams *params) { - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); - /* if manipulator evokes an operator we cannot use it for property manipulation */ + /* if gizmo evokes an operator we cannot use it for property manipulation */ BLI_assert(mpr->op_data == NULL); mpr_prop->type = mpr_prop_type; @@ -132,20 +132,20 @@ void WM_manipulator_target_property_def_func_ptr( } } -void WM_manipulator_target_property_def_func( - wmManipulator *mpr, const char *idname, - const wmManipulatorPropertyFnParams *params) +void WM_gizmo_target_property_def_func( + wmGizmo *mpr, const char *idname, + const wmGizmoPropertyFnParams *params) { - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); - WM_manipulator_target_property_def_func_ptr(mpr, mpr_prop_type, params); + const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); + WM_gizmo_target_property_def_func_ptr(mpr, mpr_prop_type, params); } -void WM_manipulator_target_property_clear_rna_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type) +void WM_gizmo_target_property_clear_rna_ptr( + wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type) { - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); - /* if manipulator evokes an operator we cannot use it for property manipulation */ + /* if gizmo evokes an operator we cannot use it for property manipulation */ BLI_assert(mpr->op_data == NULL); mpr_prop->type = NULL; @@ -155,11 +155,11 @@ void WM_manipulator_target_property_clear_rna_ptr( mpr_prop->index = -1; } -void WM_manipulator_target_property_clear_rna( - wmManipulator *mpr, const char *idname) +void WM_gizmo_target_property_clear_rna( + wmGizmo *mpr, const char *idname) { - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); - WM_manipulator_target_property_clear_rna_ptr(mpr, mpr_prop_type); + const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); + WM_gizmo_target_property_clear_rna_ptr(mpr, mpr_prop_type); } @@ -171,26 +171,26 @@ void WM_manipulator_target_property_clear_rna( /** \name Property Access * \{ */ -bool WM_manipulator_target_property_is_valid_any(wmManipulator *mpr) +bool WM_gizmo_target_property_is_valid_any(wmGizmo *mpr) { - wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = wm_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_gizmo_target_property_is_valid(mpr_prop)) { return true; } } return false; } -bool WM_manipulator_target_property_is_valid(const wmManipulatorProperty *mpr_prop) +bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *mpr_prop) { return ((mpr_prop->prop != NULL) || (mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn)); } -float WM_manipulator_target_property_value_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +float WM_gizmo_target_property_value_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop) { if (mpr_prop->custom_func.value_get_fn) { float value = 0.0f; @@ -207,9 +207,9 @@ float WM_manipulator_target_property_value_get( } } -void WM_manipulator_target_property_value_set( - bContext *C, const wmManipulator *mpr, - wmManipulatorProperty *mpr_prop, const float value) +void WM_gizmo_target_property_value_set( + bContext *C, const wmGizmo *mpr, + wmGizmoProperty *mpr_prop, const float value) { if (mpr_prop->custom_func.value_set_fn) { BLI_assert(mpr_prop->type->array_length == 1); @@ -227,8 +227,8 @@ void WM_manipulator_target_property_value_set( RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } -void WM_manipulator_target_property_value_get_array( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_value_get_array( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, float *value) { if (mpr_prop->custom_func.value_get_fn) { @@ -238,8 +238,8 @@ void WM_manipulator_target_property_value_get_array( RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value); } -void WM_manipulator_target_property_value_set_array( - bContext *C, const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_value_set_array( + bContext *C, const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const float *value) { if (mpr_prop->custom_func.value_set_fn) { @@ -251,8 +251,8 @@ void WM_manipulator_target_property_value_set_array( RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } -bool WM_manipulator_target_property_range_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +bool WM_gizmo_target_property_range_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, float range[2]) { if (mpr_prop->custom_func.value_get_fn) { @@ -271,8 +271,8 @@ bool WM_manipulator_target_property_range_get( return true; } -int WM_manipulator_target_property_array_length( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop) +int WM_gizmo_target_property_array_length( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop) { if (mpr_prop->custom_func.value_get_fn) { return mpr_prop->type->array_length; @@ -288,21 +288,21 @@ int WM_manipulator_target_property_array_length( /** \name Property Define * \{ */ -const wmManipulatorPropertyType *WM_manipulatortype_target_property_find( - const wmManipulatorType *wt, const char *idname) +const wmGizmoPropertyType *WM_gizmotype_target_property_find( + const wmGizmoType *wt, const char *idname) { - return BLI_findstring(&wt->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname)); + return BLI_findstring(&wt->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)); } -void WM_manipulatortype_target_property_def( - wmManipulatorType *wt, const char *idname, int data_type, int array_length) +void WM_gizmotype_target_property_def( + wmGizmoType *wt, const char *idname, int data_type, int array_length) { - wmManipulatorPropertyType *mpt; + wmGizmoPropertyType *mpt; - BLI_assert(WM_manipulatortype_target_property_find(wt, idname) == NULL); + BLI_assert(WM_gizmotype_target_property_find(wt, idname) == NULL); const uint idname_size = strlen(idname) + 1; - mpt = MEM_callocN(sizeof(wmManipulatorPropertyType) + idname_size, __func__); + mpt = MEM_callocN(sizeof(wmGizmoPropertyType) + idname_size, __func__); memcpy(mpt->idname, idname, idname_size); mpt->data_type = data_type; mpt->array_length = array_length; @@ -318,28 +318,28 @@ void WM_manipulatortype_target_property_def( /** \name Property Utilities * \{ */ -void WM_manipulator_do_msg_notify_tag_refresh( +void WM_gizmo_do_msg_notify_tag_refresh( bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) { ARegion *ar = msg_val->owner; - wmManipulatorMap *mmap = msg_val->user_data; + wmGizmoMap *mmap = msg_val->user_data; ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); } /** * Runs on the "prepare draw" pass, * drawing the region clears. */ -void WM_manipulator_target_property_subscribe_all( - wmManipulator *mpr, struct wmMsgBus *mbus, ARegion *ar) +void WM_gizmo_target_property_subscribe_all( + wmGizmo *mpr, struct wmMsgBus *mbus, ARegion *ar) { if (mpr->type->target_property_defs_len) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_gizmo_target_property_is_valid(mpr_prop)) { if (mpr_prop->prop) { WM_msg_subscribe_rna( mbus, &mpr_prop->ptr, mpr_prop->prop, @@ -353,7 +353,7 @@ void WM_manipulator_target_property_subscribe_all( &(const wmMsgSubscribeValue){ .owner = ar, .user_data = mpr->parent_mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, + .notify = WM_gizmo_do_msg_notify_tag_refresh, }, __func__); } } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index 4f31afb5b56..ba145af9582 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -44,7 +44,7 @@ #include "ED_screen.h" -/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */ #include "wm.h" /* own includes */ @@ -52,30 +52,30 @@ #include "wm_gizmo_intern.h" -/** \name Manipulator Type Append +/** \name Gizmo Type Append * * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. * \{ */ -static GHash *global_manipulatortype_hash = NULL; +static GHash *global_gizmotype_hash = NULL; -const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) +const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet) { if (idname[0]) { - wmManipulatorType *wt; + wmGizmoType *wt; - wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); + wt = BLI_ghash_lookup(global_gizmotype_hash, idname); if (wt) { return wt; } if (!quiet) { - printf("search for unknown manipulator '%s'\n", idname); + printf("search for unknown gizmo '%s'\n", idname); } } else { if (!quiet) { - printf("search for empty manipulator\n"); + printf("search for empty gizmo\n"); } } @@ -83,15 +83,15 @@ const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) } /* caller must free */ -void WM_manipulatortype_iter(GHashIterator *ghi) +void WM_gizmotype_iter(GHashIterator *ghi) { - BLI_ghashIterator_init(ghi, global_manipulatortype_hash); + BLI_ghashIterator_init(ghi, global_gizmotype_hash); } -static wmManipulatorType *wm_manipulatortype_append__begin(void) +static wmGizmoType *wm_gizmotype_append__begin(void) { - wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype"); - wt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_ManipulatorProperties); + wmGizmoType *wt = MEM_callocN(sizeof(wmGizmoType), "gizmotype"); + wt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoProperties); #if 0 /* Set the default i18n context now, so that opfunc can redefine it if needed! */ RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); @@ -99,35 +99,35 @@ static wmManipulatorType *wm_manipulatortype_append__begin(void) #endif return wt; } -static void wm_manipulatortype_append__end(wmManipulatorType *wt) +static void wm_gizmotype_append__end(wmGizmoType *wt) { - BLI_assert(wt->struct_size >= sizeof(wmManipulator)); + BLI_assert(wt->struct_size >= sizeof(wmGizmo)); RNA_def_struct_identifier(&BLENDER_RNA, wt->srna, wt->idname); - BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt); + BLI_ghash_insert(global_gizmotype_hash, (void *)wt->idname, wt); } -void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)) +void WM_gizmotype_append(void (*wtfunc)(struct wmGizmoType *)) { - wmManipulatorType *wt = wm_manipulatortype_append__begin(); + wmGizmoType *wt = wm_gizmotype_append__begin(); wtfunc(wt); - wm_manipulatortype_append__end(wt); + wm_gizmotype_append__end(wt); } -void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata) +void WM_gizmotype_append_ptr(void (*wtfunc)(struct wmGizmoType *, void *), void *userdata) { - wmManipulatorType *mt = wm_manipulatortype_append__begin(); + wmGizmoType *mt = wm_gizmotype_append__begin(); wtfunc(mt, userdata); - wm_manipulatortype_append__end(mt); + wm_gizmotype_append__end(mt); } /** * Free but don't remove from ghash. */ -static void manipulatortype_free(wmManipulatorType *wt) +static void gizmotype_free(wmGizmoType *wt) { - if (wt->ext.srna) { /* python manipulator, allocs own string */ + if (wt->ext.srna) { /* python gizmo, allocs own string */ MEM_freeN((void *)wt->idname); } @@ -138,8 +138,8 @@ static void manipulatortype_free(wmManipulatorType *wt) /** * \param C: May be NULL. */ -static void manipulatortype_unlink( - bContext *C, Main *bmain, wmManipulatorType *wt) +static void gizmotype_unlink( + bContext *C, Main *bmain, wmGizmoType *wt) { /* Free instances. */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -147,15 +147,15 @@ static void manipulatortype_unlink( for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmManipulatorMap *mmap = ar->manipulator_map; + wmGizmoMap *mmap = ar->gizmo_map; if (mmap) { - wmManipulatorGroup *mgroup; + wmGizmoGroup *mgroup; for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) { + for (wmGizmo *mpr = mgroup->gizmos.first, *mpr_next; mpr; mpr = mpr_next) { mpr_next = mpr->next; BLI_assert(mgroup->parent_mmap == mmap); if (mpr->type == wt) { - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C); + WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, mpr, C); ED_region_tag_redraw(ar); } } @@ -167,46 +167,46 @@ static void manipulatortype_unlink( } } -void WM_manipulatortype_remove_ptr(bContext *C, Main *bmain, wmManipulatorType *wt) +void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *wt) { - BLI_assert(wt == WM_manipulatortype_find(wt->idname, false)); + BLI_assert(wt == WM_gizmotype_find(wt->idname, false)); - BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL); + BLI_ghash_remove(global_gizmotype_hash, wt->idname, NULL, NULL); - manipulatortype_unlink(C, bmain, wt); + gizmotype_unlink(C, bmain, wt); - manipulatortype_free(wt); + gizmotype_free(wt); } -bool WM_manipulatortype_remove(bContext *C, Main *bmain, const char *idname) +bool WM_gizmotype_remove(bContext *C, Main *bmain, const char *idname) { - wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); + wmGizmoType *wt = BLI_ghash_lookup(global_gizmotype_hash, idname); if (wt == NULL) { return false; } - WM_manipulatortype_remove_ptr(C, bmain, wt); + WM_gizmotype_remove_ptr(C, bmain, wt); return true; } -static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt) +static void wm_gizmotype_ghash_free_cb(wmGizmoType *mt) { - manipulatortype_free(mt); + gizmotype_free(mt); } -void wm_manipulatortype_free(void) +void wm_gizmotype_free(void) { - BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb); - global_manipulatortype_hash = NULL; + BLI_ghash_free(global_gizmotype_hash, NULL, (GHashValFreeFP)wm_gizmotype_ghash_free_cb); + global_gizmotype_hash = NULL; } /* called on initialize WM_init() */ -void wm_manipulatortype_init(void) +void wm_gizmotype_init(void) { /* reserve size is set based on blender default setup */ - global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128); + global_gizmotype_hash = BLI_ghash_str_new_ex("wm_gizmotype_init gh", 128); } /** \} */ diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h index 8d28febbd5d..a94f1e994e9 100644 --- a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h +++ b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h @@ -29,60 +29,60 @@ #include "BLI_compiler_attrs.h" -/* wmManipulatorGroup */ -typedef bool (*wmManipulatorGroupFnPoll)( - const struct bContext *, struct wmManipulatorGroupType *) +/* wmGizmoGroup */ +typedef bool (*wmGizmoGroupFnPoll)( + const struct bContext *, struct wmGizmoGroupType *) ATTR_WARN_UNUSED_RESULT; -typedef void (*wmManipulatorGroupFnInit)( - const struct bContext *, struct wmManipulatorGroup *); -typedef void (*wmManipulatorGroupFnRefresh)( - const struct bContext *, struct wmManipulatorGroup *); -typedef void (*wmManipulatorGroupFnDrawPrepare)( - const struct bContext *, struct wmManipulatorGroup *); -typedef struct wmKeyMap *(*wmManipulatorGroupFnSetupKeymap)( - const struct wmManipulatorGroupType *, struct wmKeyConfig *) +typedef void (*wmGizmoGroupFnInit)( + const struct bContext *, struct wmGizmoGroup *); +typedef void (*wmGizmoGroupFnRefresh)( + const struct bContext *, struct wmGizmoGroup *); +typedef void (*wmGizmoGroupFnDrawPrepare)( + const struct bContext *, struct wmGizmoGroup *); +typedef struct wmKeyMap *(*wmGizmoGroupFnSetupKeymap)( + const struct wmGizmoGroupType *, struct wmKeyConfig *) ATTR_WARN_UNUSED_RESULT; -typedef void (*wmManipulatorGroupFnMsgBusSubscribe)( - const struct bContext *, struct wmManipulatorGroup *, struct wmMsgBus *); +typedef void (*wmGizmoGroupFnMsgBusSubscribe)( + const struct bContext *, struct wmGizmoGroup *, struct wmMsgBus *); -/* wmManipulator */ -/* See: wmManipulatorType for docs on each type. */ +/* wmGizmo */ +/* See: wmGizmoType for docs on each type. */ -typedef void (*wmManipulatorFnSetup)(struct wmManipulator *); -typedef void (*wmManipulatorFnDraw)(const struct bContext *, struct wmManipulator *); -typedef void (*wmManipulatorFnDrawSelect)(const struct bContext *, struct wmManipulator *, int); -typedef int (*wmManipulatorFnTestSelect)(struct bContext *, struct wmManipulator *, const struct wmEvent *); -typedef int (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, eWM_ManipulatorTweak); -typedef void (*wmManipulatorFnPropertyUpdate)(struct wmManipulator *, struct wmManipulatorProperty *); -typedef void (*wmManipulatorFnMatrixBasisGet)(const struct wmManipulator *, float[4][4]); -typedef int (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *); -typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *, const bool); -typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *); -typedef void (*wmManipulatorFnSelectRefresh)(struct wmManipulator *); -typedef void (*wmManipulatorFnFree)(struct wmManipulator *); +typedef void (*wmGizmoFnSetup)(struct wmGizmo *); +typedef void (*wmGizmoFnDraw)(const struct bContext *, struct wmGizmo *); +typedef void (*wmGizmoFnDrawSelect)(const struct bContext *, struct wmGizmo *, int); +typedef int (*wmGizmoFnTestSelect)(struct bContext *, struct wmGizmo *, const struct wmEvent *); +typedef int (*wmGizmoFnModal)(struct bContext *, struct wmGizmo *, const struct wmEvent *, eWM_GizmoFlagTweak); +typedef void (*wmGizmoFnPropertyUpdate)(struct wmGizmo *, struct wmGizmoProperty *); +typedef void (*wmGizmoFnMatrixBasisGet)(const struct wmGizmo *, float[4][4]); +typedef int (*wmGizmoFnInvoke)(struct bContext *, struct wmGizmo *, const struct wmEvent *); +typedef void (*wmGizmoFnExit)(struct bContext *, struct wmGizmo *, const bool); +typedef int (*wmGizmoFnCursorGet)(struct wmGizmo *); +typedef void (*wmGizmoFnSelectRefresh)(struct wmGizmo *); +typedef void (*wmGizmoFnFree)(struct wmGizmo *); -/* wmManipulatorProperty ('value' type defined by 'wmManipulatorProperty.data_type') */ -typedef void (*wmManipulatorPropertyFnGet)( - const struct wmManipulator *, struct wmManipulatorProperty *, +/* wmGizmoProperty ('value' type defined by 'wmGizmoProperty.data_type') */ +typedef void (*wmGizmoPropertyFnGet)( + const struct wmGizmo *, struct wmGizmoProperty *, /* typically 'float *' */ void *value); -typedef void (*wmManipulatorPropertyFnSet)( - const struct wmManipulator *, struct wmManipulatorProperty *, +typedef void (*wmGizmoPropertyFnSet)( + const struct wmGizmo *, struct wmGizmoProperty *, /* typically 'const float *' */ const void *value); -typedef void (*wmManipulatorPropertyFnRangeGet)( - const struct wmManipulator *, struct wmManipulatorProperty *, +typedef void (*wmGizmoPropertyFnRangeGet)( + const struct wmGizmo *, struct wmGizmoProperty *, /* typically 'float[2]' */ void *range); -typedef void (*wmManipulatorPropertyFnFree)( - const struct wmManipulator *, struct wmManipulatorProperty *); +typedef void (*wmGizmoPropertyFnFree)( + const struct wmGizmo *, struct wmGizmoProperty *); -typedef struct wmManipulatorPropertyFnParams { - wmManipulatorPropertyFnGet value_get_fn; - wmManipulatorPropertyFnSet value_set_fn; - wmManipulatorPropertyFnRangeGet range_get_fn; - wmManipulatorPropertyFnFree free_fn; +typedef struct wmGizmoPropertyFnParams { + wmGizmoPropertyFnGet value_get_fn; + wmGizmoPropertyFnSet value_set_fn; + wmGizmoPropertyFnRangeGet range_get_fn; + wmGizmoPropertyFnFree free_fn; void *user_data; -} wmManipulatorPropertyFnParams; +} wmGizmoPropertyFnParams; #endif /* __WM_GIZMO_FN_H__ */ diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h index 80418cbfeb3..5b1085db4a1 100644 --- a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h +++ b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h @@ -26,10 +26,10 @@ /** \file blender/windowmanager/gizmo/wm_gizmo_wmapi.h * \ingroup wm * - * \name Manipulators Window Manager API + * \name Gizmos Window Manager API * API for usage in window manager code only. It should contain all functionality - * needed to hook up the manipulator system with Blender's window manager. It's - * mostly the event system that needs to communicate with manipulator code. + * needed to hook up the gizmo system with Blender's window manager. It's + * mostly the event system that needs to communicate with gizmo code. * * Only included in wm.h and lower level files. */ @@ -39,59 +39,59 @@ #define __WM_GIZMO_WMAPI_H__ struct wmEventHandler; -struct wmManipulatorMap; +struct wmGizmoMap; struct wmOperatorType; struct wmOperator; /* -------------------------------------------------------------------- */ -/* wmManipulator */ +/* wmGizmo */ -/* wm_manipulator_type.c, for init/exit */ -void wm_manipulatortype_free(void); -void wm_manipulatortype_init(void); +/* wm_gizmo_type.c, for init/exit */ +void wm_gizmotype_free(void); +void wm_gizmotype_init(void); -/* wm_manipulatorgroup_type.c, for init/exit */ -void wm_manipulatorgrouptype_free(void); -void wm_manipulatorgrouptype_init(void); +/* wm_gizmogroup_type.c, for init/exit */ +void wm_gizmogrouptype_free(void); +void wm_gizmogrouptype_init(void); /* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ +/* wmGizmoGroup */ -void MANIPULATORGROUP_OT_manipulator_select(struct wmOperatorType *ot); -void MANIPULATORGROUP_OT_manipulator_tweak(struct wmOperatorType *ot); +void GIZMOGROUP_OT_gizmo_select(struct wmOperatorType *ot); +void GIZMOGROUP_OT_gizmo_tweak(struct wmOperatorType *ot); -bool wm_manipulatorgroup_is_any_selected(const struct wmManipulatorGroup *mgroup); +bool wm_gizmogroup_is_any_selected(const struct wmGizmoGroup *mgroup); /* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ +/* wmGizmoMap */ -void wm_manipulatormap_remove(struct wmManipulatorMap *mmap); +void wm_gizmomap_remove(struct wmGizmoMap *mmap); -void wm_manipulators_keymap(struct wmKeyConfig *keyconf); +void wm_gizmos_keymap(struct wmKeyConfig *keyconf); -void wm_manipulatormaps_handled_modal_update( +void wm_gizmomaps_handled_modal_update( bContext *C, struct wmEvent *event, struct wmEventHandler *handler); -void wm_manipulatormap_handler_context(bContext *C, struct wmEventHandler *handler); +void wm_gizmomap_handler_context(bContext *C, struct wmEventHandler *handler); -struct wmManipulator *wm_manipulatormap_highlight_find( - struct wmManipulatorMap *mmap, bContext *C, const struct wmEvent *event, +struct wmGizmo *wm_gizmomap_highlight_find( + struct wmGizmoMap *mmap, bContext *C, const struct wmEvent *event, int *r_part); -bool wm_manipulatormap_highlight_set( - struct wmManipulatorMap *mmap, const bContext *C, - struct wmManipulator *mpr, int part); -struct wmManipulator *wm_manipulatormap_highlight_get(struct wmManipulatorMap *mmap); -void wm_manipulatormap_modal_set( - struct wmManipulatorMap *mmap, bContext *C, struct wmManipulator *mpr, +bool wm_gizmomap_highlight_set( + struct wmGizmoMap *mmap, const bContext *C, + struct wmGizmo *mpr, int part); +struct wmGizmo *wm_gizmomap_highlight_get(struct wmGizmoMap *mmap); +void wm_gizmomap_modal_set( + struct wmGizmoMap *mmap, bContext *C, struct wmGizmo *mpr, const struct wmEvent *event, bool enable); -struct wmManipulator *wm_manipulatormap_modal_get(struct wmManipulatorMap *mmap); -struct wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len); -struct ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap); +struct wmGizmo *wm_gizmomap_modal_get(struct wmGizmoMap *mmap); +struct wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *mmap, int *r_selected_len); +struct ListBase *wm_gizmomap_groups_get(wmGizmoMap *mmap); /* -------------------------------------------------------------------- */ -/* wmManipulatorMapType */ +/* wmGizmoMapType */ -void wm_manipulatormaptypes_free(void); +void wm_gizmomaptypes_free(void); #endif /* __WM_GIZMO_WMAPI_H__ */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 8469dc9da0e..bc24b7698e2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2004,8 +2004,8 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand CTX_wm_region_set(C, NULL); } - /* update manipulators during modal handlers */ - wm_manipulatormaps_handled_modal_update(C, event, handler); + /* update gizmos during modal handlers */ + wm_gizmomaps_handled_modal_update(C, event, handler); /* remove modal handler, operator itself should have been canceled and freed */ if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { @@ -2392,32 +2392,32 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers } } } - else if (handler->manipulator_map) { + else if (handler->gizmo_map) { ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - wmManipulatorMap *mmap = handler->manipulator_map; - wmManipulator *mpr = wm_manipulatormap_highlight_get(mmap); + wmGizmoMap *mmap = handler->gizmo_map; + wmGizmo *mpr = wm_gizmomap_highlight_get(mmap); - if (region->manipulator_map != handler->manipulator_map) { - WM_manipulatormap_tag_refresh(handler->manipulator_map); + if (region->gizmo_map != handler->gizmo_map) { + WM_gizmomap_tag_refresh(handler->gizmo_map); } - wm_manipulatormap_handler_context(C, handler); + wm_gizmomap_handler_context(C, handler); wm_region_mouse_co(C, event); - /* handle manipulator highlighting */ - if (event->type == MOUSEMOVE && !wm_manipulatormap_modal_get(mmap)) { + /* handle gizmo highlighting */ + if (event->type == MOUSEMOVE && !wm_gizmomap_modal_get(mmap)) { int part; - mpr = wm_manipulatormap_highlight_find(mmap, C, event, &part); - if (wm_manipulatormap_highlight_set(mmap, C, mpr, part) && mpr != NULL) { - WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_manipulatormap_tooltip_init); + mpr = wm_gizmomap_highlight_find(mmap, C, event, &part); + if (wm_gizmomap_highlight_set(mmap, C, mpr, part) && mpr != NULL) { + WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_gizmomap_tooltip_init); } } else { /* Either we operate on a single highlighted item - * or groups attached to the selected manipulators. + * or groups attached to the selected gizmos. * To simplify things both cases loop over an array of items. */ - wmManipulatorGroup *mgroup_first; + wmGizmoGroup *mgroup_first; bool is_mgroup_single; if (ISMOUSE(event->type)) { @@ -2431,8 +2431,8 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers is_mgroup_single = true; } else { - if (WM_manipulatormap_is_any_selected(mmap)) { - const ListBase *groups = WM_manipulatormap_group_list(mmap); + if (WM_gizmomap_is_any_selected(mmap)) { + const ListBase *groups = WM_gizmomap_group_list(mmap); mgroup_first = groups->first; } else { @@ -2444,13 +2444,13 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers /* Don't use from now on. */ mpr = NULL; - for (wmManipulatorGroup *mgroup = mgroup_first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *mgroup = mgroup_first; mgroup; mgroup = mgroup->next) { /* get user customized keymap from default one */ if ((is_mgroup_single == false) && - /* We might want to change the logic here and use some kind of manipulator edit-mode. + /* We might want to change the logic here and use some kind of gizmo edit-mode. * For now just use keymap when a selection exists. */ - wm_manipulatorgroup_is_any_selected(mgroup) == false) + wm_gizmogroup_is_any_selected(mgroup) == false) { continue; } @@ -2472,14 +2472,14 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers /* weak, but allows interactive callback to not use rawkey */ event->keymap_idname = kmi->idname; - CTX_wm_manipulator_group_set(C, mgroup); + CTX_wm_gizmo_group_set(C, mgroup); /* handler->op is called later, we want keymap op to be triggered here */ handler->op = NULL; action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr); handler->op = op; - CTX_wm_manipulator_group_set(C, NULL); + CTX_wm_gizmo_group_set(C, NULL); if (action & WM_HANDLER_BREAK) { if (keymap_callback.handle_post_fn != NULL) { @@ -2804,7 +2804,7 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event) } #ifdef USE_WORKSPACE_TOOL -static void wm_event_manipulator_temp_handler_apply( +static void wm_event_gizmo_temp_handler_apply( bContext *C, ScrArea *sa, ARegion *ar, wmEventHandler *sneaky_handler) { if (ar->regiontype == RGN_TYPE_WINDOW) { @@ -2818,17 +2818,17 @@ static void wm_event_manipulator_temp_handler_apply( /* Handle widgets first. */ wmEventHandler *handler_last = ar->handlers.last; - while (handler_last && handler_last->manipulator_map == NULL) { + while (handler_last && handler_last->gizmo_map == NULL) { handler_last = handler_last->prev; } - /* Head of list or after last manipulator. */ + /* Head of list or after last gizmo. */ BLI_insertlinkafter(&ar->handlers, handler_last, sneaky_handler); } } } } -static void wm_event_manipulator_temp_handler_clear( +static void wm_event_gizmo_temp_handler_clear( bContext *UNUSED(C), ScrArea *UNUSED(sa), ARegion *ar, wmEventHandler *sneaky_handler) { if (sneaky_handler->keymap) { @@ -2846,7 +2846,7 @@ void wm_event_do_handlers(bContext *C) /* update key configuration before handling events */ WM_keyconfig_update(wm); - WM_manipulatorconfig_update(CTX_data_main(C)); + WM_gizmoconfig_update(CTX_data_main(C)); for (win = wm->windows.first; win; win = win->next) { bScreen *screen = WM_window_get_active_screen(win); @@ -3021,13 +3021,13 @@ void wm_event_do_handlers(bContext *C) * to fetch its current keymap. */ wmEventHandler sneaky_handler = {NULL}; - wm_event_manipulator_temp_handler_apply(C, sa, ar, &sneaky_handler); + wm_event_gizmo_temp_handler_apply(C, sa, ar, &sneaky_handler); #endif /* USE_WORKSPACE_TOOL */ action |= wm_handlers_do(C, event, &ar->handlers); #ifdef USE_WORKSPACE_TOOL - wm_event_manipulator_temp_handler_clear(C, sa, ar, &sneaky_handler); + wm_event_gizmo_temp_handler_clear(C, sa, ar, &sneaky_handler); #endif /* USE_WORKSPACE_TOOL */ /* fileread case (python), [#29489] */ @@ -3094,7 +3094,7 @@ void wm_event_do_handlers(bContext *C) /* update key configuration after handling events */ WM_keyconfig_update(wm); - WM_manipulatorconfig_update(CTX_data_main(C)); + WM_gizmoconfig_update(CTX_data_main(C)); } /* ********** filesector handling ************ */ @@ -4470,7 +4470,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) #ifdef USE_WORKSPACE_TOOL wmEventHandler sneaky_handler = {NULL}; - wm_event_manipulator_temp_handler_apply(C, sa, ar, &sneaky_handler); + wm_event_gizmo_temp_handler_apply(C, sa, ar, &sneaky_handler); #endif ListBase *handlers[] = { @@ -4503,7 +4503,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } #ifdef USE_WORKSPACE_TOOL - wm_event_manipulator_temp_handler_clear(C, sa, ar, &sneaky_handler); + wm_event_gizmo_temp_handler_clear(C, sa, ar, &sneaky_handler); #endif if (memcmp(&cd_prev.text, &cd->text, sizeof(cd_prev.text)) != 0) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 463508674d5..0c7c85e0d94 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -212,15 +212,15 @@ void WM_init(bContext *C, int argc, const char **argv) WM_paneltype_init(); /* Lookup table only. */ WM_menutype_init(); WM_uilisttype_init(); - wm_manipulatortype_init(); - wm_manipulatorgrouptype_init(); + wm_gizmotype_init(); + wm_gizmogrouptype_init(); ED_undosys_type_init(); BKE_library_callback_free_window_manager_set(wm_close_and_free); /* library.c */ BKE_library_callback_free_notifier_reference_set(WM_main_remove_notifier_reference); /* library.c */ - BKE_region_callback_free_manipulatormap_set(wm_manipulatormap_remove); /* screen.c */ - BKE_region_callback_refresh_tag_manipulatormap_set(WM_manipulatormap_tag_refresh); + BKE_region_callback_free_gizmomap_set(wm_gizmomap_remove); /* screen.c */ + BKE_region_callback_refresh_tag_gizmomap_set(WM_gizmomap_tag_refresh); BKE_library_callback_remap_editor_id_reference_set(WM_main_remap_editor_id_reference); /* library.c */ BKE_blender_callback_test_break_set(wm_window_testbreak); /* blender.c */ BKE_spacedata_callback_id_remap_set(ED_spacedata_id_remap); /* screen.c */ @@ -507,10 +507,10 @@ void WM_exit_ext(bContext *C, const bool do_python) ED_gpencil_strokes_copybuf_free(); BKE_node_clipboard_clear(); - /* free manipulator-maps after freeing blender, so no deleted data get accessed during cleaning up of areas */ - wm_manipulatormaptypes_free(); - wm_manipulatorgrouptype_free(); - wm_manipulatortype_free(); + /* free gizmo-maps after freeing blender, so no deleted data get accessed during cleaning up of areas */ + wm_gizmomaptypes_free(); + wm_gizmogrouptype_free(); + wm_gizmotype_free(); BLF_exit(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index dd9b8324b11..5cf9ac625c3 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3248,9 +3248,9 @@ void wm_operatortypes_register(void) WM_operatortype_append(WM_OT_previews_clear); WM_operatortype_append(WM_OT_doc_view_manual_ui_context); - /* manipulators */ - WM_operatortype_append(MANIPULATORGROUP_OT_manipulator_select); - WM_operatortype_append(MANIPULATORGROUP_OT_manipulator_tweak); + /* gizmos */ + WM_operatortype_append(GIZMOGROUP_OT_gizmo_select); + WM_operatortype_append(GIZMOGROUP_OT_gizmo_tweak); } /* circleselect-like modal operators */ @@ -3580,7 +3580,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) RNA_float_set(kmi->ptr, "value", 1.0f / 1.5f); #endif /* WITH_INPUT_NDOF */ - wm_manipulators_keymap(keyconf); + wm_gizmos_keymap(keyconf); gesture_circle_modal_keymap(keyconf); gesture_border_modal_keymap(keyconf); gesture_zoom_border_modal_keymap(keyconf); diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index d06cc21ec21..350327e8590 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -131,8 +131,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t { bToolRef_Runtime *tref_rt = tref->runtime; - if (tref_rt->manipulator_group[0]) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(tref_rt->manipulator_group, false); + if (tref_rt->gizmo_group[0]) { + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false); if (wgt != NULL) { bool found = false; @@ -144,7 +144,7 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t for (wmWindow *win = wm->windows.first; win; win = win->next) { const WorkSpace *workspace_iter = WM_window_get_active_workspace(win); if (workspace != workspace_iter) { - if (STREQ(workspace->tool.manipulator_group, workspace_iter->tool.manipulator_group)) { + if (STREQ(workspace->tool.gizmo_group, workspace_iter->tool.gizmo_group)) { found = true; break; } @@ -154,8 +154,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t UNUSED_VARS(workspace); #endif if (!found) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulatormaptype_group_unlink(C, bmain, mmap_type, wgt); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmomaptype_group_unlink(C, bmain, mmap_type, wgt); } } } @@ -171,11 +171,11 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tke static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tref) { bToolRef_Runtime *tref_rt = tref->runtime; - if (tref_rt->manipulator_group[0]) { - const char *idname = tref_rt->manipulator_group; - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + if (tref_rt->gizmo_group[0]) { + const char *idname = tref_rt->gizmo_group; + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); if (wgt != NULL) { - WM_manipulator_group_type_ensure_ptr(wgt); + WM_gizmo_group_type_ensure_ptr(wgt); } else { CLOG_WARN(WM_LOG_TOOLS, "'%s' widget not found", idname); diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index d191fe4a9c2..1dcd0cb62d0 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -77,8 +77,8 @@ typedef struct wmEventHandler { /* drop box handler */ ListBase *dropboxes; - /* manipulator handler */ - struct wmManipulatorMap *manipulator_map; + /* gizmo handler */ + struct wmGizmoMap *gizmo_map; } wmEventHandler; /* custom types for handlers, for signaling, freeing */ diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 3f98b6ef512..6a0e4882830 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -339,8 +339,8 @@ enum { EVT_DROP = 0x5023, EVT_BUT_CANCEL = 0x5024, - /* could become manipulator callback */ - EVT_MANIPULATOR_UPDATE = 0x5025, + /* could become gizmo callback */ + EVT_GIZMO_UPDATE = 0x5025, /* ********** End of Blender internal events. ********** */ }; -- cgit v1.2.3 From 89299f66207bd278e37e9e55ade87e8989b0de3d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 23:55:20 +0200 Subject: WM: rename manipulator to gizmo in Python API --- release/scripts/modules/bpy_types.py | 10 ++++---- .../scripts/templates_py/gizmo_custom_geometry.py | 12 ++++----- release/scripts/templates_py/gizmo_operator.py | 30 +++++++++++----------- .../scripts/templates_py/gizmo_operator_target.py | 12 ++++----- release/scripts/templates_py/gizmo_simple.py | 10 ++++---- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index e9f40bd0c3c..f4fd188c641 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -556,7 +556,7 @@ class RNAMetaPropGroup(StructMetaPropGroup, RNAMeta): # Same as 'Operator' # only without 'as_keywords' -class Manipulator(StructRNA): +class Gizmo(StructRNA): __slots__ = () def __getattribute__(self, attr): @@ -590,15 +590,15 @@ class Manipulator(StructRNA): # Convenience wrappers around private `_gawain` module. def draw_custom_shape(self, shape, *, matrix=None, select_id=None): """ - Draw a shape created form :class:`bpy.types.Manipulator.draw_custom_shape`. + Draw a shape created form :class:`bpy.types.Gizmo.draw_custom_shape`. :arg shape: The cached shape to draw. :type shape: Undefined. :arg matrix: 4x4 matrix, when not given - :class:`bpy.types.Manipulator.matrix_world` is used. + :class:`bpy.types.Gizmo.matrix_world` is used. :type matrix: :class:`mathutils.Matrix` :arg select_id: The selection id. - Only use when drawing within :class:`bpy.types.Manipulator.draw_select`. + Only use when drawing within :class:`bpy.types.Gizmo.draw_select`. :type select_it: int """ import gpu @@ -627,7 +627,7 @@ class Manipulator(StructRNA): @staticmethod def new_custom_shape(type, verts): """ - Create a new shape that can be passed to :class:`bpy.types.Manipulator.draw_custom_shape`. + Create a new shape that can be passed to :class:`bpy.types.Gizmo.draw_custom_shape`. :arg type: The type of shape to create in (POINTS, LINES, TRIS, LINE_STRIP). :type type: string diff --git a/release/scripts/templates_py/gizmo_custom_geometry.py b/release/scripts/templates_py/gizmo_custom_geometry.py index de324a909db..f71237f52f7 100644 --- a/release/scripts/templates_py/gizmo_custom_geometry.py +++ b/release/scripts/templates_py/gizmo_custom_geometry.py @@ -5,8 +5,8 @@ # import bpy from bpy.types import ( - Manipulator, - ManipulatorGroup, + Gizmo, + GizmoGroup, ) # Coordinates (each one is a triangle). @@ -62,7 +62,7 @@ custom_shape_verts = ( ) -class MyCustomShapeWidget(Manipulator): +class MyCustomShapeWidget(Gizmo): bl_idname = "VIEW3D_WT_auto_facemap" bl_target_properties = ( {"id": "offset", "type": 'FLOAT', "array_length": 1}, @@ -108,11 +108,11 @@ class MyCustomShapeWidget(Manipulator): delta /= 10.0 value = self.init_value + delta self.target_set_value("offset", value) - context.area.header_text_set("My Manipulator: %.4f" % value) + context.area.header_text_set("My Gizmo: %.4f" % value) return {'RUNNING_MODAL'} -class MyCustomShapeWidgetGroup(ManipulatorGroup): +class MyCustomShapeWidgetGroup(GizmoGroup): bl_idname = "OBJECT_WGT_light_test" bl_label = "Test Light Widget" bl_space_type = 'VIEW_3D' @@ -127,7 +127,7 @@ class MyCustomShapeWidgetGroup(ManipulatorGroup): def setup(self, context): # Assign the 'offset' target property to the light energy. ob = context.object - mpr = self.manipulators.new(MyCustomShapeWidget.bl_idname) + mpr = self.gizmos.new(MyCustomShapeWidget.bl_idname) mpr.target_set_prop("offset", ob.data, "energy") mpr.matrix_basis = ob.matrix_world.normalized() diff --git a/release/scripts/templates_py/gizmo_operator.py b/release/scripts/templates_py/gizmo_operator.py index 61796489a95..3cbb0801e9c 100644 --- a/release/scripts/templates_py/gizmo_operator.py +++ b/release/scripts/templates_py/gizmo_operator.py @@ -1,15 +1,15 @@ -# Example of an operator which uses manipulators to control its properties. +# Example of an operator which uses gizmos to control its properties. # # Usage: Run this script, then in mesh edit-mode press Spacebar # to activate the operator "Select Side of Plane" -# The manipulators can then be used to adjust the plane in the 3D view. +# The gizmos can then be used to adjust the plane in the 3D view. # import bpy import bmesh from bpy.types import ( Operator, - ManipulatorGroup, + GizmoGroup, ) from bpy.props import ( @@ -68,7 +68,7 @@ class SelectSideOfPlane(Operator): if context.space_data.type == 'VIEW_3D': wm = context.window_manager - wm.manipulator_group_type_add(SelectSideOfPlaneManipulatorGroup.bl_idname) + wm.gizmo_group_type_add(SelectSideOfPlaneGizmoGroup.bl_idname) return {'FINISHED'} @@ -78,10 +78,10 @@ class SelectSideOfPlane(Operator): return {'FINISHED'} -# Manipulators for plane_co, plane_no -class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): +# Gizmos for plane_co, plane_no +class SelectSideOfPlaneGizmoGroup(GizmoGroup): bl_idname = "MESH_WGT_select_side_of_plane" - bl_label = "Side of Plane Manipulator" + bl_label = "Side of Plane Gizmo" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' bl_options = {'3D'} @@ -106,7 +106,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): op = cls.my_target_operator(context) if op is None: wm = context.window_manager - wm.manipulator_group_type_remove(SelectSideOfPlaneManipulatorGroup.bl_idname) + wm.gizmo_group_type_remove(SelectSideOfPlaneGizmoGroup.bl_idname) return False return True @@ -117,16 +117,16 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): # Grab def grab_get_cb(): - op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) + op = SelectSideOfPlaneGizmoGroup.my_target_operator(context) return op.plane_co def grab_set_cb(value): - op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) + op = SelectSideOfPlaneGizmoGroup.my_target_operator(context) op.plane_co = value # XXX, this may change! op.execute(context) - mpr = self.manipulators.new("MANIPULATOR_WT_grab_3d") + mpr = self.gizmos.new("GIZMO_WT_grab_3d") mpr.target_set_handler("offset", get=grab_get_cb, set=grab_set_cb) mpr.use_draw_value = True @@ -145,7 +145,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): # Dial def direction_get_cb(): - op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) + op = SelectSideOfPlaneGizmoGroup.my_target_operator(context) no_a = self.widget_dial.matrix_basis.col[1].xyz no_b = Vector(op.plane_no) @@ -155,13 +155,13 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): return no_a.angle_signed(no_b) def direction_set_cb(value): - op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) + op = SelectSideOfPlaneGizmoGroup.my_target_operator(context) matrix_rotate = Matrix.Rotation(-value, 3, self.rotate_axis) no = matrix_rotate * self.widget_dial.matrix_basis.col[1].xyz op.plane_no = no op.execute(context) - mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d") + mpr = self.gizmos.new("GIZMO_WT_dial_3d") mpr.target_set_handler("offset", get=direction_get_cb, set=direction_set_cb) mpr.draw_options = {'ANGLE_START_Y'} @@ -216,7 +216,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): classes = ( SelectSideOfPlane, - SelectSideOfPlaneManipulatorGroup, + SelectSideOfPlaneGizmoGroup, ) diff --git a/release/scripts/templates_py/gizmo_operator_target.py b/release/scripts/templates_py/gizmo_operator_target.py index ba53b5e10ff..08fe63ef0b7 100644 --- a/release/scripts/templates_py/gizmo_operator_target.py +++ b/release/scripts/templates_py/gizmo_operator_target.py @@ -1,15 +1,15 @@ -# Example of a manipulator that activates an operator -# using the predefined dial manipulator to change the camera roll. +# Example of a gizmo that activates an operator +# using the predefined dial gizmo to change the camera roll. # # Usage: Run this script and select a camera in the 3D view. # import bpy from bpy.types import ( - ManipulatorGroup, + GizmoGroup, ) -class MyCameraWidgetGroup(ManipulatorGroup): +class MyCameraWidgetGroup(GizmoGroup): bl_idname = "OBJECT_WGT_test_camera" bl_label = "Object Camera Test Widget" bl_space_type = 'VIEW_3D' @@ -22,9 +22,9 @@ class MyCameraWidgetGroup(ManipulatorGroup): return (ob and ob.type == 'CAMERA') def setup(self, context): - # Run an operator using the dial manipulator + # Run an operator using the dial gizmo ob = context.object - mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d") + mpr = self.gizmos.new("GIZMO_WT_dial_3d") props = mpr.target_set_operator("transform.rotate") props.constraint_axis = False, False, True props.constraint_orientation = 'LOCAL' diff --git a/release/scripts/templates_py/gizmo_simple.py b/release/scripts/templates_py/gizmo_simple.py index cb10a8b94bb..0fd1e0b386b 100644 --- a/release/scripts/templates_py/gizmo_simple.py +++ b/release/scripts/templates_py/gizmo_simple.py @@ -1,16 +1,16 @@ # Example of a group that edits a single property -# using the predefined manipulator arrow. +# using the predefined gizmo arrow. # # Usage: Select a light in the 3D view and drag the arrow at it's rear # to change it's energy value. # import bpy from bpy.types import ( - ManipulatorGroup, + GizmoGroup, ) -class MyLightWidgetGroup(ManipulatorGroup): +class MyLightWidgetGroup(GizmoGroup): bl_idname = "OBJECT_WGT_light_test" bl_label = "Test Light Widget" bl_space_type = 'VIEW_3D' @@ -23,9 +23,9 @@ class MyLightWidgetGroup(ManipulatorGroup): return (ob and ob.type == 'LIGHT') def setup(self, context): - # Arrow manipulator has one 'offset' property we can assign to the light energy. + # Arrow gizmo has one 'offset' property we can assign to the light energy. ob = context.object - mpr = self.manipulators.new("MANIPULATOR_WT_arrow_3d") + mpr = self.gizmos.new("GIZMO_WT_arrow_3d") mpr.target_set_prop("offset", ob.data, "energy") mpr.matrix_basis = ob.matrix_world.normalized() mpr.draw_style = 'BOX' -- cgit v1.2.3 From fdcd9103cc12c2722e02f6c2591915e26af12ce5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jul 2018 23:58:07 +0200 Subject: WM: rename manipulator to gizmo in the toolbar --- .../startup/bl_ui/space_toolsystem_toolbar.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 527dfdc3c6f..dbab7c7e037 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -133,9 +133,9 @@ class _defs_transform: text="Grab", # cursor='SCROLL_XY', icon="ops.transform.translate", - widget="TRANSFORM_WGT_manipulator", + widget="TRANSFORM_WGT_gizmo", operator="transform.translate", - # TODO, implement as optional fallback manipulator + # TODO, implement as optional fallback gizmo # keymap=( # ("transform.translate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), # ), @@ -147,9 +147,9 @@ class _defs_transform: text="Rotate", # cursor='SCROLL_XY', icon="ops.transform.rotate", - widget="TRANSFORM_WGT_manipulator", + widget="TRANSFORM_WGT_gizmo", operator="transform.rotate", - # TODO, implement as optional fallback manipulator + # TODO, implement as optional fallback gizmo # keymap=( # ("transform.rotate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), # ), @@ -161,9 +161,9 @@ class _defs_transform: text="Scale", # cursor='SCROLL_XY', icon="ops.transform.resize", - widget="TRANSFORM_WGT_manipulator", + widget="TRANSFORM_WGT_gizmo", operator="transform.resize", - # TODO, implement as optional fallback manipulator + # TODO, implement as optional fallback gizmo # keymap=( # ("transform.resize", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), # ), @@ -182,13 +182,13 @@ class _defs_transform: def transform(): def draw_settings(context, layout, tool): tool_settings = context.tool_settings - layout.prop(tool_settings, "use_manipulator_mode") + layout.prop(tool_settings, "use_gizmo") return dict( text="Transform", icon="ops.transform.transform", - widget="TRANSFORM_WGT_manipulator", - # No keymap default action, only for manipulators! + widget="TRANSFORM_WGT_gizmo", + # No keymap default action, only for gizmo! draw_settings=draw_settings, ) @@ -320,7 +320,7 @@ class _defs_edit_mesh: widget=None, keymap=( ("view3d.cursor3d", dict(), dict(type='ACTIONMOUSE', value='CLICK')), - ("mesh.primitive_cube_add_manipulator", dict(), dict(type='EVT_TWEAK_A', value='ANY')), + ("mesh.primitive_cube_add_gizmo", dict(), dict(type='EVT_TWEAK_A', value='ANY')), ), ) -- cgit v1.2.3 From 4697604331482c394c8a148c54a8e942120b634f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 14 Jul 2018 15:38:58 +0200 Subject: Cleanup: use float3 SSE instead of ssef for voronoi texture. --- intern/cycles/kernel/svm/svm_noise.h | 57 ++++++++++------------------------ intern/cycles/kernel/svm/svm_voronoi.h | 57 ++++++---------------------------- intern/cycles/util/util_math.h | 10 ++++++ intern/cycles/util/util_math_float3.h | 12 +++++++ intern/cycles/util/util_math_int3.h | 18 +++++++++++ 5 files changed, 67 insertions(+), 87 deletions(-) diff --git a/intern/cycles/kernel/svm/svm_noise.h b/intern/cycles/kernel/svm/svm_noise.h index 38074f0faff..8c425ecf326 100644 --- a/intern/cycles/kernel/svm/svm_noise.h +++ b/intern/cycles/kernel/svm/svm_noise.h @@ -32,12 +32,7 @@ CCL_NAMESPACE_BEGIN -#ifndef __KERNEL_SSE2__ -ccl_device int quick_floor(float x) -{ - return float_to_int(x) - ((x < 0) ? 1 : 0); -} -#else +#ifdef __KERNEL_SSE2__ ccl_device_inline ssei quick_floor_sse(const ssef& x) { ssei b = truncatei(x); @@ -46,18 +41,6 @@ ccl_device_inline ssei quick_floor_sse(const ssef& x) } #endif -#ifndef __KERNEL_SSE2__ -ccl_device float bits_to_01(uint bits) -{ - return bits * (1.0f/(float)0xFFFFFFFF); -} -#else -ccl_device_inline ssef bits_to_01_sse(const ssei& bits) -{ - return uint32_to_float(bits) * ssef(1.0f/(float)0xFFFFFFFF); -} -#endif - ccl_device uint hash(uint kx, uint ky, uint kz) { // define some handy macros @@ -129,7 +112,7 @@ ccl_device uint phash(int kx, int ky, int kz, int3 p) #ifndef __KERNEL_SSE2__ ccl_device float floorfrac(float x, int* i) { - *i = quick_floor(x); + *i = quick_floor_to_int(x); return x - *i; } #else @@ -304,33 +287,27 @@ ccl_device float snoise(float3 p) } /* cell noise */ -#ifndef __KERNEL_SSE2__ -ccl_device_noinline float cellnoise(float3 p) +ccl_device float cellnoise(float3 p) { - uint ix = quick_floor(p.x); - uint iy = quick_floor(p.y); - uint iz = quick_floor(p.z); - - return bits_to_01(hash(ix, iy, iz)); + int3 ip = quick_floor_to_int3(p); + return bits_to_01(hash(ip.x, ip.y, ip.z)); } -ccl_device float3 cellnoise_color(float3 p) +ccl_device float3 cellnoise3(float3 p) { - float r = cellnoise(p); - float g = cellnoise(make_float3(p.y, p.x, p.z)); - float b = cellnoise(make_float3(p.y, p.z, p.x)); - + int3 ip = quick_floor_to_int3(p); +#ifndef __KERNEL_SSE__ + float r = bits_to_01(hash(ip.x, ip.y, ip.z)); + float g = bits_to_01(hash(ip.y, ip.x, ip.z)); + float b = bits_to_01(hash(ip.y, ip.z, ip.x)); return make_float3(r, g, b); -} #else -ccl_device ssef cellnoise_color(const ssef& p) -{ - ssei ip = quick_floor_sse(p); - ssei ip_yxz = shuffle<1, 0, 2, 3>(ip); - ssei ip_xyy = shuffle<0, 1, 1, 3>(ip); - ssei ip_zzx = shuffle<2, 2, 0, 3>(ip); - return bits_to_01_sse(hash_sse(ip_xyy, ip_yxz, ip_zzx)); -} + ssei ip_yxz = shuffle<1, 0, 2, 3>(ssei(ip.m128)); + ssei ip_xyy = shuffle<0, 1, 1, 3>(ssei(ip.m128)); + ssei ip_zzx = shuffle<2, 2, 0, 3>(ssei(ip.m128)); + ssei bits = hash_sse(ip_xyy, ip_yxz, ip_zzx); + return float3(uint32_to_float(bits) * ssef(1.0f/(float)0xFFFFFFFF)); #endif +} CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h index 9bfb182544b..5d0b8a2a406 100644 --- a/intern/cycles/kernel/svm/svm_voronoi.h +++ b/intern/cycles/kernel/svm/svm_voronoi.h @@ -23,34 +23,19 @@ ccl_device float voronoi_F1_distance(float3 p) /* returns squared distance in da */ float da = 1e10f; -#ifndef __KERNEL_SSE2__ - int ix = floor_to_int(p.x), iy = floor_to_int(p.y), iz = floor_to_int(p.z); + int3 xyzi = quick_floor_to_int3(p); for(int xx = -1; xx <= 1; xx++) { for(int yy = -1; yy <= 1; yy++) { for(int zz = -1; zz <= 1; zz++) { - float3 ip = make_float3(ix + xx, iy + yy, iz + zz); - float3 vp = ip + cellnoise_color(ip); + int3 ip = xyzi + make_int3(xx, yy, zz); + float3 fp = make_float3(ip.x, ip.y, ip.z); + float3 vp = fp + cellnoise3(fp); float d = len_squared(p - vp); da = min(d, da); } } } -#else - ssef vec_p = load4f(p); - ssei xyzi = quick_floor_sse(vec_p); - - for(int xx = -1; xx <= 1; xx++) { - for(int yy = -1; yy <= 1; yy++) { - for(int zz = -1; zz <= 1; zz++) { - ssef ip = ssef(xyzi + ssei(xx, yy, zz, 0)); - ssef vp = ip + cellnoise_color(ip); - float d = len_squared<1, 1, 1, 0>(vec_p - vp); - da = min(d, da); - } - } - } -#endif return da; } @@ -59,37 +44,17 @@ ccl_device float3 voronoi_F1_color(float3 p) { /* returns color of the nearest point */ float da = 1e10f; - -#ifndef __KERNEL_SSE2__ float3 pa; - int ix = floor_to_int(p.x), iy = floor_to_int(p.y), iz = floor_to_int(p.z); - for(int xx = -1; xx <= 1; xx++) { - for(int yy = -1; yy <= 1; yy++) { - for(int zz = -1; zz <= 1; zz++) { - float3 ip = make_float3(ix + xx, iy + yy, iz + zz); - float3 vp = ip + cellnoise_color(ip); - float d = len_squared(p - vp); - - if(d < da) { - da = d; - pa = vp; - } - } - } - } - - return cellnoise_color(pa); -#else - ssef pa, vec_p = load4f(p); - ssei xyzi = quick_floor_sse(vec_p); + int3 xyzi = quick_floor_to_int3(p); for(int xx = -1; xx <= 1; xx++) { for(int yy = -1; yy <= 1; yy++) { for(int zz = -1; zz <= 1; zz++) { - ssef ip = ssef(xyzi + ssei(xx, yy, zz, 0)); - ssef vp = ip + cellnoise_color(ip); - float d = len_squared<1, 1, 1, 0>(vec_p - vp); + int3 ip = xyzi + make_int3(xx, yy, zz); + float3 fp = make_float3(ip.x, ip.y, ip.z); + float3 vp = fp + cellnoise3(fp); + float d = len_squared(p - vp); if(d < da) { da = d; @@ -99,9 +64,7 @@ ccl_device float3 voronoi_F1_color(float3 p) } } - ssef color = cellnoise_color(pa); - return (float3 &)color; -#endif + return cellnoise3(pa); } ccl_device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float3 p) diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index fd3199f209f..85cbd18b7ba 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -266,6 +266,11 @@ ccl_device_inline int floor_to_int(float f) return float_to_int(floorf(f)); } +ccl_device_inline int quick_floor_to_int(float x) +{ + return float_to_int(x) - ((x < 0) ? 1 : 0); +} + ccl_device_inline int ceil_to_int(float f) { return float_to_int(ceilf(f)); @@ -550,6 +555,11 @@ ccl_device_inline float xor_signmask(float x, int y) return __int_as_float(__float_as_int(x) ^ y); } +ccl_device float bits_to_01(uint bits) +{ + return bits * (1.0f/(float)0xFFFFFFFF); +} + /* projections */ ccl_device_inline float2 map_to_tube(const float3 co) { diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h index f5149fe13ed..e42ded76c75 100644 --- a/intern/cycles/util/util_math_float3.h +++ b/intern/cycles/util/util_math_float3.h @@ -377,6 +377,18 @@ ccl_device_inline bool isequal_float3(const float3 a, const float3 b) #endif } +ccl_device_inline int3 quick_floor_to_int3(const float3 a) +{ +#ifdef __KERNEL_SSE__ + int3 b = int3(_mm_cvttps_epi32(a.m128)); + int3 isneg = int3(_mm_castps_si128(_mm_cmplt_ps(a.m128, _mm_set_ps1(0.0f)))); + /* Unsaturated add 0xffffffff is the same as subtract -1. */ + return b + isneg; +#else + return make_int3(quick_floor_to_int(a.x), quick_floor_to_int(a.y), quick_floor_to_int(a.z)); +#endif +} + ccl_device_inline bool isfinite3_safe(float3 v) { return isfinite_safe(v.x) && isfinite_safe(v.y) && isfinite_safe(v.z); diff --git a/intern/cycles/util/util_math_int3.h b/intern/cycles/util/util_math_int3.h index 6eef8517665..81b10f31f4a 100644 --- a/intern/cycles/util/util_math_int3.h +++ b/intern/cycles/util/util_math_int3.h @@ -91,6 +91,24 @@ ccl_device_inline bool operator<(const int3 &a, const int3 &b) { return a.x < b.x && a.y < b.y && a.z < b.z; } + +ccl_device_inline int3 operator+(const int3 &a, const int3 &b) +{ +#ifdef __KERNEL_SSE__ + return int3(_mm_add_epi32(a.m128, b.m128)); +#else + return make_int3(a.x + b.x, a.y + b.y, a.z + b.z); +#endif +} + +ccl_device_inline int3 operator-(const int3 &a, const int3 &b) +{ +#ifdef __KERNEL_SSE__ + return int3(_mm_sub_epi32(a.m128, b.m128)); +#else + return make_int3(a.x - b.x, a.y - b.y, a.z - b.z); +#endif +} #endif /* !__KERNEL_OPENCL__ */ CCL_NAMESPACE_END -- cgit v1.2.3 From 92a6b0ad6fbaef51f27105623f9be1b68103bd5d Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Sun, 15 Jul 2018 00:13:35 +0200 Subject: UI: Hide Preview panel by default on Material properties And move Custom Properties panel last --- release/scripts/startup/bl_ui/properties_material.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 3761cbba372..ed133f427f2 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -65,6 +65,7 @@ class MaterialButtonsPanel: class MATERIAL_PT_preview(MaterialButtonsPanel, Panel): bl_label = "Preview" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_EEVEE'} def draw(self, context): @@ -242,11 +243,11 @@ classes = ( MATERIAL_MT_specials, MATERIAL_UL_matslots, MATERIAL_PT_preview, - MATERIAL_PT_custom_props, EEVEE_MATERIAL_PT_context_material, EEVEE_MATERIAL_PT_surface, EEVEE_MATERIAL_PT_options, MATERIAL_PT_viewport, + MATERIAL_PT_custom_props, ) -- cgit v1.2.3 From 83a4e1aaf9d1aa5e4747213dee5485945cecb05d Mon Sep 17 00:00:00 2001 From: charlie Date: Sat, 14 Jul 2018 13:11:28 +0200 Subject: Cycles: add voronoi features and distance settings from Blender. Features to get the 2nd, 3rd, 4th closest point instead of the closest, and various distance metrics. No viewport/Eevee support yet. Patch by Michel Anders, Charlie Jolly and Brecht Van Lommel. Differential Revision: https://developer.blender.org/D3503 --- intern/cycles/blender/blender_shader.cpp | 2 + .../cycles/kernel/shaders/node_voronoi_texture.osl | 122 +++++++++++++++- intern/cycles/kernel/svm/svm_types.h | 15 ++ intern/cycles/kernel/svm/svm_voronoi.h | 156 ++++++++++++++------- intern/cycles/render/nodes.cpp | 39 +++++- intern/cycles/render/nodes.h | 4 +- intern/cycles/util/util_math_float3.h | 5 + source/blender/editors/space_node/drawnode.c | 2 + .../blender/gpu/shaders/gpu_shader_material.glsl | 2 +- source/blender/makesdna/DNA_node_types.h | 19 ++- source/blender/makesrna/intern/rna_nodetree.c | 46 ++++-- .../nodes/shader/nodes/node_shader_tex_voronoi.c | 21 +++ 12 files changed, 350 insertions(+), 83 deletions(-) diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 8afcb0ce885..956f8f767a6 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -748,6 +748,8 @@ static ShaderNode *add_node(Scene *scene, BL::ShaderNodeTexVoronoi b_voronoi_node(b_node); VoronoiTextureNode *voronoi = new VoronoiTextureNode(); voronoi->coloring = (NodeVoronoiColoring)b_voronoi_node.coloring(); + voronoi->metric = (NodeVoronoiDistanceMetric)b_voronoi_node.distance(); + voronoi->feature = (NodeVoronoiFeature)b_voronoi_node.feature(); BL::TexMapping b_texture_mapping(b_voronoi_node.texture_mapping()); get_tex_mapping(&voronoi->tex_mapping, b_texture_mapping); node = voronoi; diff --git a/intern/cycles/kernel/shaders/node_voronoi_texture.osl b/intern/cycles/kernel/shaders/node_voronoi_texture.osl index 0c3b95ae4d0..2e47d74a414 100644 --- a/intern/cycles/kernel/shaders/node_voronoi_texture.osl +++ b/intern/cycles/kernel/shaders/node_voronoi_texture.osl @@ -17,12 +17,93 @@ #include "stdosl.h" #include "node_texture.h" +void voronoi_m(point p, string metric, float e, float da[4], point pa[4]) +{ + /* Compute the distance to and the position of the four closest neighbors to p. + * + * The neighbors are randomly placed, 1 each in a 3x3x3 grid (Worley pattern). + * The distances and points are returned in ascending order, i.e. da[0] and pa[0] will + * contain the distance to the closest point and its coordinates respectively. + */ + int xx, yy, zz, xi, yi, zi; + + xi = (int)floor(p[0]); + yi = (int)floor(p[1]); + zi = (int)floor(p[2]); + + da[0] = 1e10; + da[1] = 1e10; + da[2] = 1e10; + da[3] = 1e10; + + for (xx = xi - 1; xx <= xi + 1; xx++) { + for (yy = yi - 1; yy <= yi + 1; yy++) { + for (zz = zi - 1; zz <= zi + 1; zz++) { + point ip = point(xx, yy, zz); + point vp = (point)cellnoise_color(ip); + point pd = p - (vp + ip); + + float d = 0.0; + if (metric == "distance") { + d = dot(pd, pd); + } + else if (metric == "manhattan") { + d = fabs(pd[0]) + fabs(pd[1]) + fabs(pd[2]); + } + else if (metric == "chebychev") { + d = max(fabs(pd[0]), max(fabs(pd[1]), fabs(pd[2]))); + } + else if (metric == "minkowski") { + d = pow(pow(fabs(pd[0]), e) + pow(fabs(pd[1]), e) + pow(fabs(pd[2]), e), 1.0/e); + } + + vp += point(xx, yy, zz); + + if (d < da[0]) { + da[3] = da[2]; + da[2] = da[1]; + da[1] = da[0]; + da[0] = d; + + pa[3] = pa[2]; + pa[2] = pa[1]; + pa[1] = pa[0]; + pa[0] = vp; + } + else if (d < da[1]) { + da[3] = da[2]; + da[2] = da[1]; + da[1] = d; + + pa[3] = pa[2]; + pa[2] = pa[1]; + pa[1] = vp; + } + else if (d < da[2]) { + da[3] = da[2]; + da[2] = d; + + pa[3] = pa[2]; + pa[2] = vp; + } + else if (d < da[3]) { + da[3] = d; + pa[3] = vp; + } + } + } + } +} + /* Voronoi */ shader node_voronoi_texture( int use_mapping = 0, matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), string coloring = "intensity", + string metric = "distance", + string feature = "F1", + float Exponent = 1.0, float Scale = 5.0, point Vector = P, output float Fac = 0.0, @@ -37,17 +118,48 @@ shader node_voronoi_texture( float da[4]; point pa[4]; - voronoi(p * Scale, 1.0, da, pa); + /* compute distance and point coordinate of 4 nearest neighbours */ + voronoi_m(p * Scale, metric, Exponent, da, pa); - /* Colored output */ if (coloring == "intensity") { - Fac = fabs(da[0]); + /* Intensity output */ + if (feature == "F1") { + Fac = fabs(da[0]); + } + else if (feature == "F2") { + Fac = fabs(da[1]); + } + else if (feature == "F3") { + Fac = fabs(da[2]); + } + else if (feature == "F4") { + Fac = fabs(da[3]); + } + else if (feature == "F2F1") { + Fac = fabs(da[1] - da[0]); + } Color = color(Fac); } else { - Color = cellnoise_color(pa[0]); - Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0); + /* Color output */ + if (feature == "F1") { + Color = pa[0]; + } + else if (feature == "F2") { + Color = pa[1]; + } + else if (feature == "F3") { + Color = pa[2]; + } + else if (feature == "F4") { + Color = pa[3]; + } + else if (feature == "F2F1") { + Color = fabs(pa[1] - pa[0]); + } + Color = cellnoise_color(Color); + Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0); } } diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index 0fde5126434..e03ad3a0cfe 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -338,6 +338,21 @@ typedef enum NodeVoronoiColoring { NODE_VORONOI_CELLS } NodeVoronoiColoring; +typedef enum NodeVoronoiDistanceMetric { + NODE_VORONOI_DISTANCE, + NODE_VORONOI_MANHATTAN, + NODE_VORONOI_CHEBYCHEV, + NODE_VORONOI_MINKOWSKI +} NodeVoronoiDistanceMetric; + +typedef enum NodeVoronoiFeature { + NODE_VORONOI_F1, + NODE_VORONOI_F2, + NODE_VORONOI_F3, + NODE_VORONOI_F4, + NODE_VORONOI_F2F1 +} NodeVoronoiFeature; + typedef enum NodeBlendWeightType { NODE_LAYER_WEIGHT_FRESNEL, NODE_LAYER_WEIGHT_FACING diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h index 5d0b8a2a406..e5e350bf76a 100644 --- a/intern/cycles/kernel/svm/svm_voronoi.h +++ b/intern/cycles/kernel/svm/svm_voronoi.h @@ -18,10 +18,19 @@ CCL_NAMESPACE_BEGIN /* Voronoi */ -ccl_device float voronoi_F1_distance(float3 p) +ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance, float e, float da[4], float3 pa[4]) { - /* returns squared distance in da */ - float da = 1e10f; + /* Compute the distance to and the position of the closest neighbors to p. + * + * The neighbors are randomly placed, 1 each in a 3x3x3 grid (Worley pattern). + * The distances and points are returned in ascending order, i.e. da[0] and pa[0] will + * contain the distance to the closest point and its coordinates respectively. + */ + + da[0] = 1e10f; + da[1] = 1e10f; + da[2] = 1e10f; + da[3] = 1e10f; int3 xyzi = quick_floor_to_int3(p); @@ -31,71 +40,114 @@ ccl_device float voronoi_F1_distance(float3 p) int3 ip = xyzi + make_int3(xx, yy, zz); float3 fp = make_float3(ip.x, ip.y, ip.z); float3 vp = fp + cellnoise3(fp); - float d = len_squared(p - vp); - da = min(d, da); - } - } - } - - return da; -} -ccl_device float3 voronoi_F1_color(float3 p) -{ - /* returns color of the nearest point */ - float da = 1e10f; - float3 pa; - - int3 xyzi = quick_floor_to_int3(p); + float d; + switch(distance) { + case NODE_VORONOI_DISTANCE: + d = len_squared(p - vp); + break; + case NODE_VORONOI_MANHATTAN: + d = reduce_add(fabs(vp - p)); + break; + case NODE_VORONOI_CHEBYCHEV: + d = max3(fabs(vp - p)); + break; + case NODE_VORONOI_MINKOWSKI: + float3 n = fabs(vp - p); + if(e == 0.5f) { + d = sqr(reduce_add(sqrt(n))); + } + else { + d = powf(reduce_add(pow3(n, e)), 1.0f/e); + } + break; + } - for(int xx = -1; xx <= 1; xx++) { - for(int yy = -1; yy <= 1; yy++) { - for(int zz = -1; zz <= 1; zz++) { - int3 ip = xyzi + make_int3(xx, yy, zz); - float3 fp = make_float3(ip.x, ip.y, ip.z); - float3 vp = fp + cellnoise3(fp); - float d = len_squared(p - vp); + /* To keep the shortest four distances and associated points we have to keep them in sorted order. */ + if (d < da[0]) { + da[3] = da[2]; + da[2] = da[1]; + da[1] = da[0]; + da[0] = d; + + pa[3] = pa[2]; + pa[2] = pa[1]; + pa[1] = pa[0]; + pa[0] = vp; + } + else if (d < da[1]) { + da[3] = da[2]; + da[2] = da[1]; + da[1] = d; + + pa[3] = pa[2]; + pa[2] = pa[1]; + pa[1] = vp; + } + else if (d < da[2]) { + da[3] = da[2]; + da[2] = d; - if(d < da) { - da = d; - pa = vp; + pa[3] = pa[2]; + pa[2] = vp; + } + else if (d < da[3]) { + da[3] = d; + pa[3] = vp; } } } } - - return cellnoise3(pa); -} - -ccl_device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float3 p) -{ - if(coloring == NODE_VORONOI_INTENSITY) { - /* compute squared distance to the nearest neighbour */ - float fac = voronoi_F1_distance(p); - return make_float4(fac, fac, fac, fac); - } - else { - /* compute color of the nearest neighbour */ - float3 color = voronoi_F1_color(p); - return make_float4(color.x, color.y, color.z, average(color)); - } } ccl_device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { - uint coloring = node.y; - uint scale_offset, co_offset, fac_offset, color_offset; + uint4 node2 = read_node(kg, offset); + + uint co_offset, coloring, distance, feature; + uint scale_offset, e_offset, fac_offset, color_offset; - decode_node_uchar4(node.z, &scale_offset, &co_offset, &fac_offset, &color_offset); + decode_node_uchar4(node.y, &co_offset, &coloring, &distance, &feature); + decode_node_uchar4(node.z, &scale_offset, &e_offset, &fac_offset, &color_offset); float3 co = stack_load_float3(stack, co_offset); - float scale = stack_load_float_default(stack, scale_offset, node.w); + float scale = stack_load_float_default(stack, scale_offset, node2.x); + float exponent = stack_load_float_default(stack, e_offset, node2.y); - float4 result = svm_voronoi((NodeVoronoiColoring)coloring, co*scale); - float3 color = make_float3(result.x, result.y, result.z); - float f = result.w; + float dist[4]; + float3 neighbor[4]; + voronoi_neighbors(co*scale, (NodeVoronoiDistanceMetric)distance, exponent, dist, neighbor); + + float3 color; + float fac; + if(coloring == NODE_VORONOI_INTENSITY) { + switch(feature) { + case NODE_VORONOI_F1: fac = dist[0]; break; + case NODE_VORONOI_F2: fac = dist[1]; break; + case NODE_VORONOI_F3: fac = dist[2]; break; + case NODE_VORONOI_F4: fac = dist[3]; break; + case NODE_VORONOI_F2F1: fac = dist[1] - dist[0]; break; + } + + color = make_float3(fac, fac, fac); + } + else { + /* NODE_VORONOI_CELLS */ + switch(feature) { + case NODE_VORONOI_F1: color = neighbor[0]; break; + case NODE_VORONOI_F2: color = neighbor[1]; break; + case NODE_VORONOI_F3: color = neighbor[2]; break; + case NODE_VORONOI_F4: color = neighbor[3]; break; + /* Usefulness of this vector is questionable. Note F2 >= F1 but the + * individual vector components might not be. */ + case NODE_VORONOI_F2F1: color = fabs(neighbor[1] - neighbor[0]); break; + } + + color = cellnoise3(color); + fac = average(color); + } - if(stack_valid(fac_offset)) stack_store_float(stack, fac_offset, f); + if(stack_valid(fac_offset)) stack_store_float(stack, fac_offset, fac); if(stack_valid(color_offset)) stack_store_float3(stack, color_offset, color); } diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index fe2916d21d4..986004433e4 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -913,7 +913,23 @@ NODE_DEFINE(VoronoiTextureNode) coloring_enum.insert("cells", NODE_VORONOI_CELLS); SOCKET_ENUM(coloring, "Coloring", coloring_enum, NODE_VORONOI_INTENSITY); + static NodeEnum metric; + metric.insert("distance", NODE_VORONOI_DISTANCE); + metric.insert("manhattan", NODE_VORONOI_MANHATTAN); + metric.insert("chebychev", NODE_VORONOI_CHEBYCHEV); + metric.insert("minkowski", NODE_VORONOI_MINKOWSKI); + SOCKET_ENUM(metric, "Distance Metric", metric, NODE_VORONOI_INTENSITY); + + static NodeEnum feature_enum; + feature_enum.insert("F1", NODE_VORONOI_F1); + feature_enum.insert("F2", NODE_VORONOI_F2); + feature_enum.insert("F3", NODE_VORONOI_F3); + feature_enum.insert("F4", NODE_VORONOI_F4); + feature_enum.insert("F2F1", NODE_VORONOI_F2F1); + SOCKET_ENUM(feature, "Feature", feature_enum, NODE_VORONOI_INTENSITY); + SOCKET_IN_FLOAT(scale, "Scale", 1.0f); + SOCKET_IN_FLOAT(exponent, "Exponent", 0.5f); SOCKET_IN_POINT(vector, "Vector", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); SOCKET_OUT_COLOR(color, "Color"); @@ -931,19 +947,32 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler) { ShaderInput *scale_in = input("Scale"); ShaderInput *vector_in = input("Vector"); + ShaderInput *exponent_in = input("Exponent"); ShaderOutput *color_out = output("Color"); ShaderOutput *fac_out = output("Fac"); + if (vector_in->link) compiler.stack_assign(vector_in); + if (scale_in->link) compiler.stack_assign(scale_in); + if (exponent_in->link) compiler.stack_assign(exponent_in); + int vector_offset = tex_mapping.compile_begin(compiler, vector_in); compiler.add_node(NODE_TEX_VORONOI, - coloring, compiler.encode_uchar4( - compiler.stack_assign_if_linked(scale_in), vector_offset, + coloring, + metric, + feature + ), + compiler.encode_uchar4( + compiler.stack_assign_if_linked(scale_in), + compiler.stack_assign_if_linked(exponent_in), compiler.stack_assign(fac_out), - compiler.stack_assign(color_out)), - __float_as_int(scale)); + compiler.stack_assign(color_out) + )); + compiler.add_node( + __float_as_int(scale), + __float_as_int(exponent)); tex_mapping.compile_end(compiler, vector_in, vector_offset); } @@ -953,6 +982,8 @@ void VoronoiTextureNode::compile(OSLCompiler& compiler) tex_mapping.compile(compiler); compiler.parameter(this, "coloring"); + compiler.parameter(this, "metric"); + compiler.parameter(this, "feature"); compiler.add(this, "node_voronoi_texture"); } diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index f24445ea2e9..ebe6db6e362 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -189,7 +189,9 @@ public: virtual int get_group() { return NODE_GROUP_LEVEL_2; } NodeVoronoiColoring coloring; - float scale; + NodeVoronoiDistanceMetric metric; + NodeVoronoiFeature feature; + float scale, exponent; float3 vector; }; diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h index e42ded76c75..3a5a2ab2244 100644 --- a/intern/cycles/util/util_math_float3.h +++ b/intern/cycles/util/util_math_float3.h @@ -280,6 +280,11 @@ ccl_device_inline float3 sqrt(const float3& a) #endif } +ccl_device_inline float3 pow3(const float3& a, float e) +{ + return make_float3(powf(a.x, e), powf(a.y, e), powf(a.z, e)); +} + ccl_device_inline float3 mix(const float3& a, const float3& b, float t) { return a + t*(b - a); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index fff6c5d9f2c..b0440b39823 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -961,6 +961,8 @@ static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE); + uiItemR(layout, ptr, "distance", 0, "", ICON_NONE); + uiItemR(layout, ptr, "feature", 0, "", ICON_NONE); } static void node_shader_buts_tex_pointdensity(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 2cb92fd1cbc..ab044fff100 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -3660,7 +3660,7 @@ void node_tex_sky(vec3 co, out vec4 color) color = vec4(1.0); } -void node_tex_voronoi(vec3 co, float scale, float coloring, out vec4 color, out float fac) +void node_tex_voronoi(vec3 co, float scale, float exponent, float coloring, out vec4 color, out float fac) { #ifdef BIT_OPERATIONS vec3 p = co * scale; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index f6d92a95c3a..129172315dd 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -778,6 +778,8 @@ typedef struct NodeTexNoise { typedef struct NodeTexVoronoi { NodeTexBase base; int coloring; + int distance; + int feature; int pad; } NodeTexVoronoi; @@ -976,17 +978,20 @@ typedef struct NodeSunBeams { #define SHD_NOISE_HARD 1 /* voronoi texture */ -#define SHD_VORONOI_DISTANCE_SQUARED 0 -#define SHD_VORONOI_ACTUAL_DISTANCE 1 -#define SHD_VORONOI_MANHATTAN 2 -#define SHD_VORONOI_CHEBYCHEV 3 -#define SHD_VORONOI_MINKOVSKY_H 4 -#define SHD_VORONOI_MINKOVSKY_4 5 -#define SHD_VORONOI_MINKOVSKY 6 +#define SHD_VORONOI_DISTANCE 0 +#define SHD_VORONOI_MANHATTAN 1 +#define SHD_VORONOI_CHEBYCHEV 2 +#define SHD_VORONOI_MINKOWSKI 3 #define SHD_VORONOI_INTENSITY 0 #define SHD_VORONOI_CELLS 1 +#define SHD_VORONOI_F1 0 +#define SHD_VORONOI_F2 1 +#define SHD_VORONOI_F3 2 +#define SHD_VORONOI_F4 3 +#define SHD_VORONOI_F2F1 4 + /* musgrave texture */ #define SHD_MUSGRAVE_MULTIFRACTAL 0 #define SHD_MUSGRAVE_FBM 1 diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 5fe42e11765..e66c1e937e6 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3055,16 +3055,7 @@ static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *p ED_node_tag_update_nodetree(bmain, ntree, node); } -static void rna_ShaderNodePrincipled_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - bNodeTree *ntree = (bNodeTree *)ptr->id.data; - bNode *node = (bNode *)ptr->data; - - nodeUpdate(ntree, node); - rna_Node_update(bmain, scene, ptr); -} - -static void rna_ShaderNodeSubsurface_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_ShaderNode_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->id.data; bNode *node = (bNode *)ptr->data; @@ -4003,6 +3994,23 @@ static void def_sh_tex_voronoi(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem prop_distance_items[] = { + { SHD_VORONOI_DISTANCE, "DISTANCE", 0, "Distance", "Distance" }, + { SHD_VORONOI_MANHATTAN, "MANHATTAN", 0, "Manhattan", "Manhattan (city block) distance" }, + { SHD_VORONOI_CHEBYCHEV, "CHEBYCHEV", 0, "Chebychev", "Chebychev distance" }, + { SHD_VORONOI_MINKOWSKI, "MINKOWSKI", 0, "Minkowski", "Minkowski distance" }, + { 0, NULL, 0, NULL, NULL } + }; + + static EnumPropertyItem prop_feature_items[] = { + { SHD_VORONOI_F1, "F1", 0, "Closest", "Closest point" }, + { SHD_VORONOI_F2, "F2", 0, "2nd Closest", "2nd closest point" }, + { SHD_VORONOI_F3, "F3", 0, "3rd Closest", "3rd closest point" }, + { SHD_VORONOI_F4, "F4", 0, "4th Closest", "4th closest point" }, + { SHD_VORONOI_F2F1, "F2F1", 0, "Crackle", "Difference between 2nd and 1st closest point" }, + { 0, NULL, 0, NULL, NULL } + }; + PropertyRNA *prop; RNA_def_struct_sdna_from(srna, "NodeTexVoronoi", "storage"); @@ -4013,6 +4021,18 @@ static void def_sh_tex_voronoi(StructRNA *srna) RNA_def_property_enum_items(prop, prop_coloring_items); RNA_def_property_ui_text(prop, "Coloring", ""); RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "distance", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "distance"); + RNA_def_property_enum_items(prop, prop_distance_items); + RNA_def_property_ui_text(prop, "Distance metric", ""); + RNA_def_property_update(prop, 0, "rna_ShaderNode_socket_update"); + + prop = RNA_def_property(srna, "feature", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "feature"); + RNA_def_property_enum_items(prop, prop_feature_items); + RNA_def_property_ui_text(prop, "Feature Output", ""); + RNA_def_property_update(prop, 0, "rna_Node_update"); } static void def_sh_tex_wave(StructRNA *srna) @@ -4284,13 +4304,13 @@ static void def_principled(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, node_principled_distribution_items); RNA_def_property_ui_text(prop, "Distribution", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodePrincipled_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); prop = RNA_def_property(srna, "subsurface_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom2"); RNA_def_property_enum_items(prop, node_subsurface_method_items); RNA_def_property_ui_text(prop, "Subsurface Method", "Method for rendering subsurface scattering"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodePrincipled_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); } static void def_refraction(StructRNA *srna) @@ -4525,7 +4545,7 @@ static void def_sh_subsurface(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, prop_subsurface_falloff_items); RNA_def_property_ui_text(prop, "Falloff", "Function to determine how much light nearby points contribute based on their distance to the shading point"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeSubsurface_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); } static void def_sh_tex_ies(StructRNA *srna) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c index 8c5ddaafa1e..e5bf8f49717 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c @@ -32,6 +32,7 @@ static bNodeSocketTemplate sh_node_tex_voronoi_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + { SOCK_FLOAT, 1, N_("Exponent"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 32.0f}, { -1, 0, "" } }; @@ -47,6 +48,8 @@ static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node) BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); tex->coloring = SHD_VORONOI_INTENSITY; + tex->distance = SHD_VORONOI_DISTANCE; + tex->feature = SHD_VORONOI_F1; node->storage = tex; } @@ -66,6 +69,23 @@ static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *node, bNodeExecD return GPU_stack_link(mat, "node_tex_voronoi", in, out, GPU_uniform(&coloring)); } +static void node_shader_update_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node) +{ + NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage; + bNodeSocket *sock; + + for (sock = node->inputs.first; sock; sock = sock->next) { + if (STREQ(sock->name, "Exponent")) { + if (tex->distance == SHD_VORONOI_MINKOWSKI) { + sock->flag &= ~SOCK_UNAVAIL; + } + else { + sock->flag |= SOCK_UNAVAIL; + } + } + } +} + /* node type definition */ void register_node_type_sh_tex_voronoi(void) { @@ -77,6 +97,7 @@ void register_node_type_sh_tex_voronoi(void) node_type_init(&ntype, node_shader_init_tex_voronoi); node_type_storage(&ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage); node_type_gpu(&ntype, node_shader_gpu_tex_voronoi); + node_type_update(&ntype, node_shader_update_tex_voronoi, NULL); nodeRegisterType(&ntype); } -- cgit v1.2.3 From b6a97baa0efa65da678d72408cb29eebf1ee658a Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Sun, 15 Jul 2018 01:15:32 +0200 Subject: UI: Use full width for ID blocks in World, Light, Camera, Texture Also close Preview panel for lights by default and move World custom props last --- release/scripts/startup/bl_ui/properties_data_camera.py | 7 ++----- release/scripts/startup/bl_ui/properties_data_light.py | 7 +++---- release/scripts/startup/bl_ui/properties_texture.py | 17 +++++++++-------- release/scripts/startup/bl_ui/properties_world.py | 7 +++---- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index 3b5f21d616e..2d5fbf4b52f 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -62,13 +62,10 @@ class DATA_PT_context_camera(CameraButtonsPanel, Panel): cam = context.camera space = context.space_data - split = layout.split(percentage=0.65) if ob: - split.template_ID(ob, "data") - split.separator() + layout.template_ID(ob, "data") elif cam: - split.template_ID(space, "pin_id") - split.separator() + layout.template_ID(space, "pin_id") class DATA_PT_lens(CameraButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_data_light.py b/release/scripts/startup/bl_ui/properties_data_light.py index 057f7dffce0..a92414c0e7c 100644 --- a/release/scripts/startup/bl_ui/properties_data_light.py +++ b/release/scripts/startup/bl_ui/properties_data_light.py @@ -45,16 +45,15 @@ class DATA_PT_context_light(DataButtonsPanel, Panel): light = context.light space = context.space_data - split = layout.split(percentage=0.65) - if ob: - split.template_ID(ob, "data") + layout.template_ID(ob, "data") elif light: - split.template_ID(space, "pin_id") + layout.template_ID(space, "pin_id") class DATA_PT_preview(DataButtonsPanel, Panel): bl_label = "Preview" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw(self, context): diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index b08b47fbe77..b3b7341a734 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -123,27 +123,28 @@ class TEXTURE_PT_context(TextureButtonsPanel, Panel): use_pin_id = space.use_pin_id user = context.texture_user + col = layout.column() + if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)): pin_id = None if not pin_id: - layout.template_texture_user() - - if user or pin_id: - layout.separator() + col.template_texture_user() - split = layout.split(percentage=0.65) - col = split.column() + col.separator() + if user or pin_id: if pin_id: col.template_ID(space, "pin_id") else: propname = context.texture_user_property.identifier col.template_ID(user, propname, new="texture.new") + col.separator() + if tex: - split = layout.split(percentage=0.2) - split.label(text="Type:") + split = col.split(percentage=0.2) + split.label(text="Type") split.prop(tex, "type", text="") diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py index 52a769fd223..b6ea8054b0c 100644 --- a/release/scripts/startup/bl_ui/properties_world.py +++ b/release/scripts/startup/bl_ui/properties_world.py @@ -50,11 +50,10 @@ class WORLD_PT_context_world(WorldButtonsPanel, Panel): world = context.world space = context.space_data - split = layout.split(percentage=0.85) if scene: - split.template_ID(scene, "world", new="world.new") + layout.template_ID(scene, "world", new="world.new") elif world: - split.template_ID(space, "pin_id") + layout.template_ID(space, "pin_id") class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel): @@ -125,9 +124,9 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel): classes = ( WORLD_PT_context_world, - WORLD_PT_custom_props, EEVEE_WORLD_PT_surface, EEVEE_WORLD_PT_mist, + WORLD_PT_custom_props, ) if __name__ == "__main__": # only for live edit. -- cgit v1.2.3 From d2b28a8bf1b4d5abd9507e02702c6dc511ccf2c6 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Sun, 15 Jul 2018 01:22:24 +0200 Subject: UI: Use icon for Material Link Communicates the same by giving more room to the Material datablock name --- .../scripts/startup/bl_ui/properties_material.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index ed133f427f2..b601922e944 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -119,25 +119,23 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' + row = layout.row() + + if ob: + row.template_ID(ob, "active_material", new="material.new") + + if slot: + icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA' + row.prop(slot, "link", icon=icon_link, icon_only=True) + if ob.mode == 'EDIT': row = layout.row(align=True) row.operator("object.material_slot_assign", text="Assign") row.operator("object.material_slot_select", text="Select") row.operator("object.material_slot_deselect", text="Deselect") - split = layout.split(percentage=0.65) - - if ob: - split.template_ID(ob, "active_material", new="material.new") - row = split.row() - - if slot: - row.prop(slot, "link", text="") - else: - row.label() elif mat: - split.template_ID(space, "pin_id") - split.separator() + row.template_ID(space, "pin_id") def panel_node_draw(layout, ntree, output_type): -- cgit v1.2.3 From f8537a5d0dea7c698a92477cb9280c22b48e2dce Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Sun, 15 Jul 2018 02:35:33 +0200 Subject: UI: Camera Display panel rename to Viewport Display Matches all other panels with Viewport properties --- release/scripts/startup/bl_ui/properties_data_camera.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index 2d5fbf4b52f..4730fc56602 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -363,7 +363,7 @@ class DATA_PT_camera_background_image(CameraButtonsPanel, Panel): class DATA_PT_camera_display(CameraButtonsPanel, Panel): - bl_label = "Display" + bl_label = "Viewport Display" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} -- cgit v1.2.3 From 52ebbeedc916780d88769ca23e815895d1657e1d Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Sun, 15 Jul 2018 04:44:45 +0200 Subject: UI: Default theme minor tweaks Darker color for group nodes and minor adjustments --- release/datafiles/userdef/userdef_default_theme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index f77b06b56e2..11a9fbaca00 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -773,18 +773,18 @@ const bTheme U_theme_default = { .syntaxb = RGBA(0xccb83dff), .syntaxn = RGBA(0xe64555ff), .syntaxv = RGBA(0x66c4ffff), - .syntaxc = RGBA(0x49b300ff), + .syntaxc = RGBA(0x426628ff), .syntaxd = RGBA(0x749797ff), .syntaxr = RGBA(0x808080ff), .nodeclass_output = RGBA(0xb33641ff), .nodeclass_filter = RGBA(0x584d80ff), .nodeclass_vector = RGBA(0x9b80ffff), .nodeclass_texture = RGBA(0xe68745ff), - .nodeclass_shader = RGBA(0x39bf6dff), + .nodeclass_shader = RGBA(0x39c884ff), .nodeclass_script = RGBA(0x084d4dff), .nodeclass_pattern = RGBA(0x6c696fff), .nodeclass_layout = RGBA(0x6c696fff), - .movie = RGBA(0x9b9b9ba0), + .movie = RGBA(0x1a1a1acc), .gp_vertex_size = 3, .gp_vertex = RGBA(0x97979700), .gp_vertex_select = RGBA(0xff8500ff), -- cgit v1.2.3 From 09431033e9e2defcea42ffe056632b4bf4fd7a2a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jul 2018 10:34:31 +0200 Subject: Cleanup: split GPU_batch Split out presets and utilities for creating batches. These functions are quite specialized and not related to typical usage. --- source/blender/draw/intern/draw_cache.c | 2 + source/blender/editors/curve/editcurve_paint.c | 1 + .../gizmo_library/gizmo_types/button2d_gizmo.c | 1 + source/blender/editors/interface/interface_draw.c | 1 + .../blender/editors/interface/interface_widgets.c | 1 + source/blender/editors/space_node/drawnode.c | 1 + source/blender/editors/space_view3d/view3d_draw.c | 1 + source/blender/gpu/CMakeLists.txt | 1 + source/blender/gpu/GPU_batch.h | 23 -- source/blender/gpu/GPU_batch_presets.h | 52 +++++ source/blender/gpu/GPU_batch_utils.h | 40 ++++ source/blender/gpu/intern/gpu_batch.c | 212 +----------------- source/blender/gpu/intern/gpu_batch_presets.c | 73 ++++--- source/blender/gpu/intern/gpu_batch_utils.c | 243 +++++++++++++++++++++ source/blender/windowmanager/intern/wm_window.c | 1 + 15 files changed, 386 insertions(+), 267 deletions(-) create mode 100644 source/blender/gpu/GPU_batch_presets.h create mode 100644 source/blender/gpu/GPU_batch_utils.h create mode 100644 source/blender/gpu/intern/gpu_batch_utils.c diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 2251285be74..1bf40673239 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -39,6 +39,8 @@ #include "BLI_math.h" #include "GPU_batch.h" +#include "GPU_batch_presets.h" +#include "GPU_batch_utils.h" #include "draw_cache.h" #include "draw_cache_impl.h" diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index ce72a5ffc9f..90f9b2e0569 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -50,6 +50,7 @@ #include "BIF_gl.h" #include "GPU_batch.h" +#include "GPU_batch_presets.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index 33639dd7ec7..ede070f0bed 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -45,6 +45,7 @@ #include "GPU_matrix.h" #include "GPU_select.h" #include "GPU_batch.h" +#include "GPU_batch_utils.h" #include "GPU_state.h" #include "RNA_access.h" diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 0a8a6d1f832..51f2c7e8ece 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -55,6 +55,7 @@ #include "BLF_api.h" #include "GPU_batch.h" +#include "GPU_batch_presets.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 03ff6593c59..fea88388be7 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -55,6 +55,7 @@ #include "GPU_basic_shader.h" #include "GPU_batch.h" +#include "GPU_batch_presets.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 33515ebc645..97b112ebbd1 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -54,6 +54,7 @@ #include "GPU_draw.h" #include "GPU_batch.h" +#include "GPU_batch_presets.h" #include "GPU_immediate.h" #include "GPU_matrix.h" #include "GPU_state.h" diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3b86e574a1a..be79cef182d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -74,6 +74,7 @@ #include "DEG_depsgraph_query.h" #include "GPU_batch.h" +#include "GPU_batch_presets.h" #include "GPU_draw.h" #include "GPU_matrix.h" #include "GPU_immediate.h" diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 27977c16b51..716e00164ce 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -61,6 +61,7 @@ set(SRC intern/gpu_basic_shader.c intern/gpu_batch.c intern/gpu_batch_presets.c + intern/gpu_batch_utils.c intern/gpu_buffers.c intern/gpu_codegen.c intern/gpu_debug.c diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index b706bdbf189..f73968eda54 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -34,8 +34,6 @@ #include "../../../intern/gawain/gawain/gwn_batch.h" #include "../../../intern/gawain/gawain/gwn_batch_private.h" -struct rctf; - // TODO: CMake magic to do this: // #include "gawain/batch.h" @@ -44,31 +42,10 @@ struct rctf; #include "GPU_shader.h" -/* Extend GWN_batch_program_set to use Blender’s library of built-in shader programs. */ - /* gpu_batch.c */ void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id) ATTR_NONNULL(1); -Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( - const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect - ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); -Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( - const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect - ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); - void gpu_batch_init(void); void gpu_batch_exit(void); -/* gpu_batch_presets.c */ -/* Only use by draw manager. Use the presets function instead for interface. */ -Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT; -/* Replacement for gluSphere */ -Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT; -Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT; - -void gpu_batch_presets_init(void); -void gpu_batch_presets_register(Gwn_Batch *preset_batch); -void gpu_batch_presets_reset(void); -void gpu_batch_presets_exit(void); - #endif /* __GPU_BATCH_H__ */ diff --git a/source/blender/gpu/GPU_batch_presets.h b/source/blender/gpu/GPU_batch_presets.h new file mode 100644 index 00000000000..2450a1760c3 --- /dev/null +++ b/source/blender/gpu/GPU_batch_presets.h @@ -0,0 +1,52 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Mike Erwin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/* Batched geometry rendering is powered by the Gawain library. + * This file contains any additions or modifications specific to Blender. + */ + +#ifndef __GPU_BATCH_PRESETS_H__ +#define __GPU_BATCH_PRESETS_H__ + +struct rctf; +struct Gwn_VertFormat; + +#include "BLI_compiler_attrs.h" +#include "BLI_sys_types.h" + +/* gpu_batch_presets.c */ +struct Gwn_VertFormat *GPU_batch_preset_format_3d(void); + +/* Replacement for gluSphere */ +struct Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT; +struct Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT; + +void gpu_batch_presets_init(void); +void gpu_batch_presets_register(struct Gwn_Batch *preset_batch); +void gpu_batch_presets_reset(void); +void gpu_batch_presets_exit(void); + +#endif /* __GPU_BATCH_PRESETS_H__ */ diff --git a/source/blender/gpu/GPU_batch_utils.h b/source/blender/gpu/GPU_batch_utils.h new file mode 100644 index 00000000000..b23b7723dc0 --- /dev/null +++ b/source/blender/gpu/GPU_batch_utils.h @@ -0,0 +1,40 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __GPU_BATCH_UTILS_H__ +#define __GPU_BATCH_UTILS_H__ + +struct rctf; + +#include "BLI_compiler_attrs.h" +#include "BLI_sys_types.h" + +/* gpu_batch_utils.c */ +struct Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( + const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect + ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +struct Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( + const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect + ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); + +/* Only use by draw manager. Use the presets function instead for interface. */ +struct Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT; + +#endif /* __GPU_BATCH_UTILS_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 391a3812073..5bfd20e3c8b 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -37,8 +37,8 @@ #include "BLI_polyfill_2d.h" #include "BLI_sort_utils.h" - #include "GPU_batch.h" /* own include */ +#include "GPU_batch_presets.h" #include "gpu_shader_private.h" /* -------------------------------------------------------------------- */ @@ -53,216 +53,6 @@ void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id) /** \} */ - - -/* -------------------------------------------------------------------- */ -/** \name Batch Creation - * \{ */ - -/** - * Creates triangles from a byte-array of polygons. - * - * See 'make_shape_2d_from_blend.py' utility to create data to pass to this function. - * - * \param polys_flat: Pairs of X, Y coordinates (repeating to signify closing the polygon). - * \param polys_flat_len: Length of the array (must be an even number). - * \param rect: Optional region to map the byte 0..255 coords to. When not set use -1..1. - */ -Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( - const uchar *polys_flat, uint polys_flat_len, const rctf *rect) -{ - const uchar (*polys)[2] = (const void *)polys_flat; - const uint polys_len = polys_flat_len / 2; - BLI_assert(polys_flat_len == polys_len * 2); - - /* Over alloc in both cases */ - float (*verts)[2] = MEM_mallocN(sizeof(*verts) * polys_len, __func__); - float (*verts_step)[2] = verts; - uint (*tris)[3] = MEM_mallocN(sizeof(*tris) * polys_len, __func__); - uint (*tris_step)[3] = tris; - - const float range_uchar[2] = { - (rect ? (rect->xmax - rect->xmin) : 2.0f) / 255.0f, - (rect ? (rect->ymax - rect->ymin) : 2.0f) / 255.0f, - }; - const float min_uchar[2] = { - (rect ? rect->xmin : -1.0f), - (rect ? rect->ymin : -1.0f), - }; - - uint i_poly = 0; - uint i_vert = 0; - while (i_poly != polys_len) { - for (uint j = 0; j < 2; j++) { - verts[i_vert][j] = min_uchar[j] + ((float)polys[i_poly][j] * range_uchar[j]); - } - i_vert++; - i_poly++; - if (polys[i_poly - 1][0] == polys[i_poly][0] && - polys[i_poly - 1][1] == polys[i_poly][1]) - { - const uint verts_step_len = (&verts[i_vert]) - verts_step; - BLI_assert(verts_step_len >= 3); - const uint tris_len = (verts_step_len - 2); - BLI_polyfill_calc(verts_step, verts_step_len, -1, tris_step); - /* offset indices */ - if (verts_step != verts) { - uint *t = tris_step[0]; - const uint offset = (verts_step - verts); - uint tot = tris_len * 3; - while (tot--) { - *t += offset; - t++; - } - BLI_assert(t == tris_step[tris_len]); - } - verts_step += verts_step_len; - tris_step += tris_len; - i_poly++; - /* ignore the duplicate point */ - } - } - - /* We have vertices and tris, make a batch from this. */ - static Gwn_VertFormat format = {0}; - static struct { uint pos; } attr_id; - if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - } - - const uint verts_len = (verts_step - verts); - const uint tris_len = (tris_step - tris); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, verts_len); - - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); - - for (uint i = 0; i < verts_len; i++) { - copy_v2_v2(GWN_vertbuf_raw_step(&pos_step), verts[i]); - } - - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tris_len, verts_len); - for (uint i = 0; i < tris_len; i++) { - GWN_indexbuf_add_tri_verts(&elb, UNPACK3(tris[i])); - } - Gwn_IndexBuf *indexbuf = GWN_indexbuf_build(&elb); - - MEM_freeN(tris); - MEM_freeN(verts); - - return GWN_batch_create_ex( - GWN_PRIM_TRIS, vbo, - indexbuf, - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); -} - -Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( - const uchar *polys_flat, uint polys_flat_len, const rctf *rect) -{ - const uchar (*polys)[2] = (const void *)polys_flat; - const uint polys_len = polys_flat_len / 2; - BLI_assert(polys_flat_len == polys_len * 2); - - /* Over alloc */ - /* Lines are pairs of (x, y) byte locations packed into an int32_t. */ - int32_t *lines = MEM_mallocN(sizeof(*lines) * polys_len, __func__); - int32_t *lines_step = lines; - - const float range_uchar[2] = { - (rect ? (rect->xmax - rect->xmin) : 2.0f) / 255.0f, - (rect ? (rect->ymax - rect->ymin) : 2.0f) / 255.0f, - }; - const float min_uchar[2] = { - (rect ? rect->xmin : -1.0f), - (rect ? rect->ymin : -1.0f), - }; - - uint i_poly_prev = 0; - uint i_poly = 0; - while (i_poly != polys_len) { - i_poly++; - if (polys[i_poly - 1][0] == polys[i_poly][0] && - polys[i_poly - 1][1] == polys[i_poly][1]) - { - const uchar (*polys_step)[2] = polys + i_poly_prev; - const uint polys_step_len = i_poly - i_poly_prev; - BLI_assert(polys_step_len >= 2); - for (uint i_prev = polys_step_len - 1, i = 0; i < polys_step_len; i_prev = i++) { - union { - uint8_t as_u8[4]; - uint16_t as_u16[2]; - uint32_t as_u32; - } data; - data.as_u16[0] = *((const uint16_t *)polys_step[i_prev]); - data.as_u16[1] = *((const uint16_t *)polys_step[i]); - if (data.as_u16[0] > data.as_u16[1]) { - SWAP(uint16_t, data.as_u16[0], data.as_u16[1]); - } - *lines_step = data.as_u32; - lines_step++; - } - i_poly++; - i_poly_prev = i_poly; - /* ignore the duplicate point */ - } - } - - uint lines_len = lines_step - lines; - - /* Hide Lines (we could make optional) */ - { - qsort(lines, lines_len, sizeof(int32_t), BLI_sortutil_cmp_int); - lines_step = lines; - for (uint i_prev = 0, i = 1; i < lines_len; i_prev = i++) { - if (lines[i] != lines[i_prev]) { - *lines_step++ = lines[i_prev]; - } - else { - i++; - } - } - lines_len = lines_step - lines; - } - - /* We have vertices and tris, make a batch from this. */ - static Gwn_VertFormat format = {0}; - static struct { uint pos; } attr_id; - if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - } - - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - const uint vbo_len_capacity = lines_len * 2; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); - - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); - - for (uint i = 0; i < lines_len; i++) { - union { - uint8_t as_u8_pair[2][2]; - uint32_t as_u32; - } data; - data.as_u32 = lines[i]; - for (uint k = 0; k < 2; k++) { - float *pos_v2 = GWN_vertbuf_raw_step(&pos_step); - for (uint j = 0; j < 2; j++) { - pos_v2[j] = min_uchar[j] + ((float)data.as_u8_pair[k][j] * range_uchar[j]); - } - } - } - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); - MEM_freeN(lines); - return GWN_batch_create_ex( - GWN_PRIM_LINES, vbo, - NULL, - GWN_BATCH_OWNS_VBO); -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Init/Exit * \{ */ diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c index eaf0a6821ff..fb696fd09a5 100644 --- a/source/blender/gpu/intern/gpu_batch_presets.c +++ b/source/blender/gpu/intern/gpu_batch_presets.c @@ -38,6 +38,8 @@ #include "UI_interface.h" #include "GPU_batch.h" +#include "GPU_batch_utils.h" +#include "GPU_batch_presets.h" /* own include */ #include "gpu_shader_private.h" /* Struct to store 3D Batches and their format */ @@ -59,11 +61,12 @@ static struct { static ListBase presets_list = {NULL, NULL}; + /* -------------------------------------------------------------------- */ /** \name 3D Primitives * \{ */ -static Gwn_VertFormat *preset_3D_format(void) +static Gwn_VertFormat *preset_3d_format(void) { if (g_presets_3d.format.attr_len == 0) { Gwn_VertFormat *format = &g_presets_3d.format; @@ -84,6 +87,40 @@ static void batch_sphere_lat_lon_vert( copy_v3_v3(GWN_vertbuf_raw_step(pos_step), pos); copy_v3_v3(GWN_vertbuf_raw_step(nor_step), pos); } +Gwn_Batch *GPU_batch_preset_sphere(int lod) +{ + BLI_assert(lod >= 0 && lod <= 2); + BLI_assert(BLI_thread_is_main()); + + if (lod == 0) { + return g_presets_3d.batch.sphere_low; + } + else if (lod == 1) { + return g_presets_3d.batch.sphere_med; + } + else { + return g_presets_3d.batch.sphere_high; + } +} + +Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) +{ + BLI_assert(lod >= 0 && lod <= 1); + BLI_assert(BLI_thread_is_main()); + + if (lod == 0) { + return g_presets_3d.batch.sphere_wire_low; + } + else { + return g_presets_3d.batch.sphere_wire_med; + } +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Create Sphere (3D) + * \{ */ /* Replacement for gluSphere */ Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) @@ -92,7 +129,7 @@ Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) const float lat_inc = M_PI / lat_res; float lon, lat; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3D_format()); + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3d_format()); const uint vbo_len = (lat_res - 1) * lon_res * 6; GWN_vertbuf_data_alloc(vbo, vbo_len); @@ -130,7 +167,7 @@ static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res) const float lat_inc = M_PI / lat_res; float lon, lat; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3D_format()); + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3d_format()); const uint vbo_len = (lat_res * lon_res * 2) + ((lat_res - 1) * lon_res * 2); GWN_vertbuf_data_alloc(vbo, vbo_len); @@ -158,38 +195,8 @@ static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res) return GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } -Gwn_Batch *GPU_batch_preset_sphere(int lod) -{ - BLI_assert(lod >= 0 && lod <= 2); - BLI_assert(BLI_thread_is_main()); - - if (lod == 0) { - return g_presets_3d.batch.sphere_low; - } - else if (lod == 1) { - return g_presets_3d.batch.sphere_med; - } - else { - return g_presets_3d.batch.sphere_high; - } -} - -Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) -{ - BLI_assert(lod >= 0 && lod <= 1); - BLI_assert(BLI_thread_is_main()); - - if (lod == 0) { - return g_presets_3d.batch.sphere_wire_low; - } - else { - return g_presets_3d.batch.sphere_wire_med; - } -} - /** \} */ - void gpu_batch_presets_init(void) { /* Hard coded resolution */ diff --git a/source/blender/gpu/intern/gpu_batch_utils.c b/source/blender/gpu/intern/gpu_batch_utils.c new file mode 100644 index 00000000000..d6d82ac18b6 --- /dev/null +++ b/source/blender/gpu/intern/gpu_batch_utils.c @@ -0,0 +1,243 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gpu_batch_utils.c + * \ingroup gpu + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_rect.h" +#include "BLI_math.h" +#include "BLI_polyfill_2d.h" +#include "BLI_sort_utils.h" + +#include "GPU_batch.h" +#include "GPU_batch_utils.h" /* own include */ +#include "gpu_shader_private.h" + +/* -------------------------------------------------------------------- */ +/** \name Polygon Creation (2D) + * \{ */ + +/** + * Creates triangles from a byte-array of polygons. + * + * See 'make_shape_2d_from_blend.py' utility to create data to pass to this function. + * + * \param polys_flat: Pairs of X, Y coordinates (repeating to signify closing the polygon). + * \param polys_flat_len: Length of the array (must be an even number). + * \param rect: Optional region to map the byte 0..255 coords to. When not set use -1..1. + */ +Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( + const uchar *polys_flat, uint polys_flat_len, const rctf *rect) +{ + const uchar (*polys)[2] = (const void *)polys_flat; + const uint polys_len = polys_flat_len / 2; + BLI_assert(polys_flat_len == polys_len * 2); + + /* Over alloc in both cases */ + float (*verts)[2] = MEM_mallocN(sizeof(*verts) * polys_len, __func__); + float (*verts_step)[2] = verts; + uint (*tris)[3] = MEM_mallocN(sizeof(*tris) * polys_len, __func__); + uint (*tris_step)[3] = tris; + + const float range_uchar[2] = { + (rect ? (rect->xmax - rect->xmin) : 2.0f) / 255.0f, + (rect ? (rect->ymax - rect->ymin) : 2.0f) / 255.0f, + }; + const float min_uchar[2] = { + (rect ? rect->xmin : -1.0f), + (rect ? rect->ymin : -1.0f), + }; + + uint i_poly = 0; + uint i_vert = 0; + while (i_poly != polys_len) { + for (uint j = 0; j < 2; j++) { + verts[i_vert][j] = min_uchar[j] + ((float)polys[i_poly][j] * range_uchar[j]); + } + i_vert++; + i_poly++; + if (polys[i_poly - 1][0] == polys[i_poly][0] && + polys[i_poly - 1][1] == polys[i_poly][1]) + { + const uint verts_step_len = (&verts[i_vert]) - verts_step; + BLI_assert(verts_step_len >= 3); + const uint tris_len = (verts_step_len - 2); + BLI_polyfill_calc(verts_step, verts_step_len, -1, tris_step); + /* offset indices */ + if (verts_step != verts) { + uint *t = tris_step[0]; + const uint offset = (verts_step - verts); + uint tot = tris_len * 3; + while (tot--) { + *t += offset; + t++; + } + BLI_assert(t == tris_step[tris_len]); + } + verts_step += verts_step_len; + tris_step += tris_len; + i_poly++; + /* ignore the duplicate point */ + } + } + + /* We have vertices and tris, make a batch from this. */ + static Gwn_VertFormat format = {0}; + static struct { uint pos; } attr_id; + if (format.attr_len == 0) { + attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + } + + const uint verts_len = (verts_step - verts); + const uint tris_len = (tris_step - tris); + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GWN_vertbuf_data_alloc(vbo, verts_len); + + Gwn_VertBufRaw pos_step; + GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + + for (uint i = 0; i < verts_len; i++) { + copy_v2_v2(GWN_vertbuf_raw_step(&pos_step), verts[i]); + } + + Gwn_IndexBufBuilder elb; + GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tris_len, verts_len); + for (uint i = 0; i < tris_len; i++) { + GWN_indexbuf_add_tri_verts(&elb, UNPACK3(tris[i])); + } + Gwn_IndexBuf *indexbuf = GWN_indexbuf_build(&elb); + + MEM_freeN(tris); + MEM_freeN(verts); + + return GWN_batch_create_ex( + GWN_PRIM_TRIS, vbo, + indexbuf, + GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); +} + +Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( + const uchar *polys_flat, uint polys_flat_len, const rctf *rect) +{ + const uchar (*polys)[2] = (const void *)polys_flat; + const uint polys_len = polys_flat_len / 2; + BLI_assert(polys_flat_len == polys_len * 2); + + /* Over alloc */ + /* Lines are pairs of (x, y) byte locations packed into an int32_t. */ + int32_t *lines = MEM_mallocN(sizeof(*lines) * polys_len, __func__); + int32_t *lines_step = lines; + + const float range_uchar[2] = { + (rect ? (rect->xmax - rect->xmin) : 2.0f) / 255.0f, + (rect ? (rect->ymax - rect->ymin) : 2.0f) / 255.0f, + }; + const float min_uchar[2] = { + (rect ? rect->xmin : -1.0f), + (rect ? rect->ymin : -1.0f), + }; + + uint i_poly_prev = 0; + uint i_poly = 0; + while (i_poly != polys_len) { + i_poly++; + if (polys[i_poly - 1][0] == polys[i_poly][0] && + polys[i_poly - 1][1] == polys[i_poly][1]) + { + const uchar (*polys_step)[2] = polys + i_poly_prev; + const uint polys_step_len = i_poly - i_poly_prev; + BLI_assert(polys_step_len >= 2); + for (uint i_prev = polys_step_len - 1, i = 0; i < polys_step_len; i_prev = i++) { + union { + uint8_t as_u8[4]; + uint16_t as_u16[2]; + uint32_t as_u32; + } data; + data.as_u16[0] = *((const uint16_t *)polys_step[i_prev]); + data.as_u16[1] = *((const uint16_t *)polys_step[i]); + if (data.as_u16[0] > data.as_u16[1]) { + SWAP(uint16_t, data.as_u16[0], data.as_u16[1]); + } + *lines_step = data.as_u32; + lines_step++; + } + i_poly++; + i_poly_prev = i_poly; + /* ignore the duplicate point */ + } + } + + uint lines_len = lines_step - lines; + + /* Hide Lines (we could make optional) */ + { + qsort(lines, lines_len, sizeof(int32_t), BLI_sortutil_cmp_int); + lines_step = lines; + for (uint i_prev = 0, i = 1; i < lines_len; i_prev = i++) { + if (lines[i] != lines[i_prev]) { + *lines_step++ = lines[i_prev]; + } + else { + i++; + } + } + lines_len = lines_step - lines; + } + + /* We have vertices and tris, make a batch from this. */ + static Gwn_VertFormat format = {0}; + static struct { uint pos; } attr_id; + if (format.attr_len == 0) { + attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + } + + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + const uint vbo_len_capacity = lines_len * 2; + GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + + Gwn_VertBufRaw pos_step; + GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + + for (uint i = 0; i < lines_len; i++) { + union { + uint8_t as_u8_pair[2][2]; + uint32_t as_u32; + } data; + data.as_u32 = lines[i]; + for (uint k = 0; k < 2; k++) { + float *pos_v2 = GWN_vertbuf_raw_step(&pos_step); + for (uint j = 0; j < 2; j++) { + pos_v2[j] = min_uchar[j] + ((float)data.as_u8_pair[k][j] * range_uchar[j]); + } + } + } + BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + MEM_freeN(lines); + return GWN_batch_create_ex( + GWN_PRIM_LINES, vbo, + NULL, + GWN_BATCH_OWNS_VBO); +} + +/** \} */ diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index fcd74f32bde..f55fc5703f4 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -82,6 +82,7 @@ #include "PIL_time.h" #include "GPU_batch.h" +#include "GPU_batch_presets.h" #include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_framebuffer.h" -- cgit v1.2.3 From e00f0686f7ca3d95ab865bb66a7c0663cfb558ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jul 2018 10:53:34 +0200 Subject: Cleanup: style, doxy file --- source/blender/makesrna/intern/rna_scene.c | 6 ++++-- source/blender/windowmanager/gizmo/WM_gizmo_api.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 54b553e94ae..f8d6757c601 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1985,10 +1985,12 @@ static void rna_GPUDOFSettings_blades_set(PointerRNA *ptr, const int value) if (value == 1 || value == 2) { if (dofsettings->num_blades == 0) { dofsettings->num_blades = 3; - } else { + } + else { dofsettings->num_blades = 0; } - } else { + } + else { dofsettings->num_blades = value; } } diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index 1d2abab8af4..a93597d4f64 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -23,7 +23,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/windowmanager/gizmos/WM_gizmo_api.h +/** \file blender/windowmanager/gizmo/WM_gizmo_api.h * \ingroup wm * * \name Gizmo API -- cgit v1.2.3 From b5451a642f2c08519e2ce46e16d3274e1f5dcbd3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jul 2018 11:28:28 +0200 Subject: 3D View: New view gizmo design Simplify the default navigation gizmo. See: T54723 --- .../editors/space_view3d/view3d_gizmo_navigate.c | 2 +- .../space_view3d/view3d_gizmo_navigate_type.c | 236 +++++++++++++++------ 2 files changed, 171 insertions(+), 67 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index 98669739745..f4a8bad7e30 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -53,7 +53,7 @@ /* Offset from screen edge. */ #define GIZMO_OFFSET_FAC 1.5f /* Size of main icon. */ -#define GIZMO_SIZE 64 +#define GIZMO_SIZE 80 /* Factor for size of smaller button. */ #define GIZMO_MINI_FAC 0.35f /* How much mini buttons offset from the primary. */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 0136b235cc0..041fe343526 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -44,6 +44,8 @@ #include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_state.h" +#include "GPU_batch.h" +#include "GPU_batch_presets.h" #include "RNA_access.h" #include "RNA_define.h" @@ -62,8 +64,111 @@ #define HANDLE_SIZE 0.33 -static void axis_geom_draw( - const wmGizmo *mpr, const float color[4], const bool UNUSED(select)) +/** + * \param viewmat_local_unit is typically the 'rv3d->viewmatob' + * copied into a 3x3 matrix and normalized. + */ +static void draw_xyz_wire( + uint pos_id, const float viewmat_local_unit[3][3], const float c[3], float size, int axis) +{ + int line_type; + float buffer[4][3]; + int n = 0; + + float v1[3] = {0.0f, 0.0f, 0.0f}, v2[3] = {0.0f, 0.0f, 0.0f}; + float dim = size * 0.1f; + float dx[3], dy[3]; + + dx[0] = dim; dx[1] = 0.0f; dx[2] = 0.0f; + dy[0] = 0.0f; dy[1] = dim; dy[2] = 0.0f; + + switch (axis) { + case 0: /* x axis */ + line_type = GWN_PRIM_LINES; + + /* bottom left to top right */ + negate_v3_v3(v1, dx); + sub_v3_v3(v1, dy); + copy_v3_v3(v2, dx); + add_v3_v3(v2, dy); + + copy_v3_v3(buffer[n++], v1); + copy_v3_v3(buffer[n++], v2); + + /* top left to bottom right */ + mul_v3_fl(dy, 2.0f); + add_v3_v3(v1, dy); + sub_v3_v3(v2, dy); + + copy_v3_v3(buffer[n++], v1); + copy_v3_v3(buffer[n++], v2); + + break; + case 1: /* y axis */ + line_type = GWN_PRIM_LINES; + + /* bottom left to top right */ + mul_v3_fl(dx, 0.75f); + negate_v3_v3(v1, dx); + sub_v3_v3(v1, dy); + copy_v3_v3(v2, dx); + add_v3_v3(v2, dy); + + copy_v3_v3(buffer[n++], v1); + copy_v3_v3(buffer[n++], v2); + + /* top left to center */ + mul_v3_fl(dy, 2.0f); + add_v3_v3(v1, dy); + zero_v3(v2); + + copy_v3_v3(buffer[n++], v1); + copy_v3_v3(buffer[n++], v2); + + break; + case 2: /* z axis */ + line_type = GWN_PRIM_LINE_STRIP; + + /* start at top left */ + negate_v3_v3(v1, dx); + add_v3_v3(v1, dy); + + copy_v3_v3(buffer[n++], v1); + + mul_v3_fl(dx, 2.0f); + add_v3_v3(v1, dx); + + copy_v3_v3(buffer[n++], v1); + + mul_v3_fl(dy, 2.0f); + sub_v3_v3(v1, dx); + sub_v3_v3(v1, dy); + + copy_v3_v3(buffer[n++], v1); + + add_v3_v3(v1, dx); + + copy_v3_v3(buffer[n++], v1); + + break; + default: + BLI_assert(0); + return; + } + + for (int i = 0; i < n; i++) { + mul_transposed_m3_v3((float (*)[3])viewmat_local_unit, buffer[i]); + add_v3_v3(buffer[i], c); + } + + immBegin(line_type, n); + for (int i = 0; i < n; i++) { + immVertex3fv(pos_id, buffer[i]); + } + immEnd(); +} + +static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool UNUSED(select)) { GPU_line_width(mpr->line_width); @@ -71,15 +176,6 @@ static void axis_geom_draw( const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - /* flip z for reverse */ - const float cone_coords[5][3] = { - {-1, -1, 4}, - {-1, +1, 4}, - {+1, +1, 4}, - {+1, -1, 4}, - {0, 0, 2}, - }; - struct { float depth; char index; @@ -97,7 +193,6 @@ static void axis_geom_draw( const float scale_axis = 0.25f; static const float axis_highlight[4] = {1, 1, 1, 1}; - static const float axis_nop[4] = {1, 1, 1, 0}; static const float axis_black[4] = {0, 0, 0, 1}; static float axis_color[3][4]; gpuPushMatrix(); @@ -105,10 +200,19 @@ static void axis_geom_draw( bool draw_center_done = false; + int axis_align = -1; + for (int axis = 0; axis < 3; axis++) { + if (len_squared_v2(mpr->matrix_offset[axis]) < 1e-6f) { + axis_align = axis; + break; + } + } + for (int axis_index = 0; axis_index < ARRAY_SIZE(axis_order); axis_index++) { const int index = axis_order[axis_index].index; const int axis = axis_order[axis_index].axis; const bool is_pos = axis_order[axis_index].is_pos; + const bool is_highlight = index + 1 == mpr->highlight_part; /* Draw slightly before, so axis aligned arrows draw ontop. */ if ((draw_center_done == false) && (axis_order[axis_index].depth > -0.01f)) { @@ -121,41 +225,6 @@ static void axis_geom_draw( gpuPushMatrix(); gpuMultMatrix(mpr->matrix_offset); } - - /* Center cube. */ - { - float center[3], size[3]; - - zero_v3(center); - copy_v3_fl(size, HANDLE_SIZE); - - GPU_depth_test(true); - glDepthMask(GL_TRUE); - glDepthFunc(GL_LEQUAL); - GPU_blend_set_func(GPU_ONE, GPU_ZERO); - GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - - GPU_line_smooth(true); - GPU_blend(true); - GPU_line_width(1.0f); - /* Just draw depth values. */ - immUniformColor4fv(axis_nop); - imm_draw_cube_fill_3d(pos_id, center, size); - immUniformColor4fv(axis_black); - madd_v3_v3fl( - center, - (float[3]){ - mpr->matrix_offset[0][2], - mpr->matrix_offset[1][2], - mpr->matrix_offset[2][2], - }, - 0.08f); - imm_draw_cube_wire_3d(pos_id, center, size); - GPU_blend(false); - GPU_line_smooth(false); - GPU_depth_test(false); - } - draw_center_done = true; } UI_GetThemeColor3fv(TH_AXIS_X + axis, axis_color[axis]); @@ -165,33 +234,68 @@ static void axis_geom_draw( const int index_y = (axis + 1) % 3; const int index_x = (axis + 2) % 3; -#define ROTATED_VERT(v_orig) \ - { \ - float v[3]; \ - copy_v3_v3(v, v_orig); \ - if (is_pos == 0) { \ - v[2] *= -1.0f; \ - } \ - immVertex3f(pos_id, v[index_x] * scale_axis, v[index_y] * scale_axis, v[index_z] * scale_axis); \ - } ((void)0) - bool ok = true; /* skip view align axis */ - if (len_squared_v2(mpr->matrix_offset[axis]) < 1e-6f && (mpr->matrix_offset[axis][2] > 0.0f) == is_pos) { + if ((axis_align == axis) && (mpr->matrix_offset[axis][2] > 0.0f) == is_pos) { ok = false; } if (ok) { - immUniformColor4fv(index + 1 == mpr->highlight_part ? axis_highlight : axis_color[axis]); - immBegin(GWN_PRIM_TRI_FAN, 6); - ROTATED_VERT(cone_coords[4]); - for (int j = 0; j <= 4; j++) { - ROTATED_VERT(cone_coords[j % 4]); + const float v[3] = {0, 0, 3 * (is_pos ? 1 : -1)}; + const float v_final[3] = { + v[index_x] * scale_axis, + v[index_y] * scale_axis, + v[index_z] * scale_axis, + }; + const float *color_current = is_highlight ? axis_highlight : axis_color[axis]; + float color_current_fade[4]; + copy_v4_v4(color_current_fade, color_current); + color_current_fade[3] *= 0.2; + + /* Axis Line. */ + if (is_pos) { + float v_start[3]; + GPU_line_width(2.0f); + immUniformColor4fv(color_current); + immBegin(GWN_PRIM_LINES, 2); + if (axis_align == -1) { + zero_v3(v_start); + } + else { + /* When axis aligned we don't draw the front most axis + * (allowing us to switch to the opposite side). + * In this case don't draw lines over axis pointing away from us + * because it obscures character and looks noisy. + */ + mul_v3_v3fl(v_start, v_final, 0.3f); + } + immVertex3fv(pos_id, v_start); + immVertex3fv(pos_id, v_final); + immEnd(); + } + + /* Axis Ball. */ + { + gpuPushMatrix(); + gpuTranslate3fv(v_final); + gpuScaleUniform(is_pos ? 0.22f : 0.18f); + + Gwn_Batch *sphere = GPU_batch_preset_sphere(0); + GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); + GWN_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade); + GWN_batch_draw(sphere); + gpuPopMatrix(); } - immEnd(); - } -#undef ROTATED_VERT + /* Axis XYZ Character. */ + if (is_pos) { + GPU_line_width(1.0f); + float m3[3][3]; + copy_m3_m4(m3, mpr->matrix_offset); + immUniformColor4fv(is_highlight ? axis_black : axis_highlight); + draw_xyz_wire(pos_id, m3, v_final, 1.0, axis); + } + } } gpuPopMatrix(); -- cgit v1.2.3 From b457cae397054a1be4e60f3007995f97c198b2b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jul 2018 14:24:10 +0200 Subject: Cleanup: use variable names based on term gizmo --- .../startup/bl_ui/space_toolsystem_toolbar.py | 14 +- .../scripts/templates_py/gizmo_custom_geometry.py | 4 +- release/scripts/templates_py/gizmo_operator.py | 6 +- .../scripts/templates_py/gizmo_operator_target.py | 4 +- release/scripts/templates_py/gizmo_simple.py | 4 +- source/blender/blenkernel/BKE_context.h | 2 +- source/blender/blenkernel/intern/context.c | 4 +- source/blender/draw/intern/draw_manager.c | 2 +- .../editors/gizmo_library/gizmo_library_intern.h | 10 +- .../editors/gizmo_library/gizmo_library_presets.c | 24 +- .../editors/gizmo_library/gizmo_library_utils.c | 36 +- .../gizmo_library/gizmo_types/arrow2d_gizmo.c | 66 +-- .../gizmo_library/gizmo_types/arrow3d_gizmo.c | 124 ++--- .../gizmo_library/gizmo_types/button2d_gizmo.c | 94 ++-- .../gizmo_library/gizmo_types/cage2d_gizmo.c | 208 ++++---- .../gizmo_library/gizmo_types/cage3d_gizmo.c | 188 +++---- .../gizmo_library/gizmo_types/dial3d_gizmo.c | 136 ++--- .../gizmo_library/gizmo_types/grab3d_gizmo.c | 124 ++--- .../gizmo_library/gizmo_types/primitive3d_gizmo.c | 50 +- source/blender/editors/include/ED_gizmo_library.h | 12 +- source/blender/editors/include/ED_transform.h | 12 +- source/blender/editors/include/UI_interface.h | 2 +- .../editors/interface/interface_region_tooltip.c | 26 +- source/blender/editors/mesh/editmesh_add_gizmo.c | 100 ++-- source/blender/editors/mesh/editmesh_bevel.c | 8 +- source/blender/editors/mesh/editmesh_bisect.c | 110 ++-- source/blender/editors/mesh/editmesh_extrude.c | 58 +-- .../blender/editors/mesh/editmesh_extrude_spin.c | 118 ++--- source/blender/editors/mesh/editmesh_inset.c | 8 +- source/blender/editors/space_image/space_image.c | 20 +- source/blender/editors/space_node/node_gizmo.c | 202 ++++---- source/blender/editors/space_node/node_intern.h | 8 +- source/blender/editors/space_node/space_node.c | 20 +- source/blender/editors/space_view3d/space_view3d.c | 50 +- source/blender/editors/space_view3d/view3d_draw.c | 2 +- .../editors/space_view3d/view3d_gizmo_armature.c | 66 +-- .../editors/space_view3d/view3d_gizmo_camera.c | 180 +++---- .../editors/space_view3d/view3d_gizmo_empty.c | 80 +-- .../editors/space_view3d/view3d_gizmo_forcefield.c | 54 +- .../editors/space_view3d/view3d_gizmo_lamp.c | 148 +++--- .../editors/space_view3d/view3d_gizmo_navigate.c | 138 ++--- .../space_view3d/view3d_gizmo_navigate_type.c | 74 +-- .../editors/space_view3d/view3d_gizmo_ruler.c | 162 +++--- .../blender/editors/space_view3d/view3d_intern.h | 26 +- source/blender/editors/transform/transform.h | 2 +- .../blender/editors/transform/transform_generics.c | 6 +- .../blender/editors/transform/transform_gizmo_2d.c | 28 +- .../blender/editors/transform/transform_gizmo_3d.c | 172 +++---- source/blender/makesdna/DNA_view3d_types.h | 2 +- source/blender/makesrna/intern/rna_space.c | 8 +- source/blender/makesrna/intern/rna_wm_api.c | 20 +- source/blender/makesrna/intern/rna_wm_gizmo.c | 389 +++++++------- source/blender/makesrna/intern/rna_wm_gizmo_api.c | 66 +-- source/blender/python/intern/bpy_gizmo_wrap.c | 56 +- source/blender/python/intern/bpy_gizmo_wrap.h | 4 +- source/blender/python/intern/bpy_rna_gizmo.c | 94 ++-- source/blender/windowmanager/gizmo/WM_gizmo_api.h | 192 +++---- .../blender/windowmanager/gizmo/WM_gizmo_types.h | 6 +- .../blender/windowmanager/gizmo/intern/wm_gizmo.c | 352 ++++++------- .../windowmanager/gizmo/intern/wm_gizmo_group.c | 422 +++++++-------- .../gizmo/intern/wm_gizmo_group_type.c | 82 +-- .../windowmanager/gizmo/intern/wm_gizmo_intern.h | 38 +- .../windowmanager/gizmo/intern/wm_gizmo_map.c | 564 ++++++++++----------- .../gizmo/intern/wm_gizmo_target_props.c | 216 ++++---- .../windowmanager/gizmo/intern/wm_gizmo_type.c | 80 +-- .../blender/windowmanager/gizmo/wm_gizmo_wmapi.h | 20 +- .../blender/windowmanager/intern/wm_event_system.c | 48 +- .../blender/windowmanager/intern/wm_toolsystem.c | 14 +- 68 files changed, 2833 insertions(+), 2832 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index dbab7c7e037..eeb47595213 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -118,7 +118,7 @@ class _defs_view3d_generic: return dict( text="Ruler", icon="ops.view3d.ruler", - widget="VIEW3D_WGT_ruler", + widget="VIEW3D_GGT_ruler", keymap=( ("view3d.ruler_add", dict(), dict(type='EVT_TWEAK_A', value='ANY')), ), @@ -133,7 +133,7 @@ class _defs_transform: text="Grab", # cursor='SCROLL_XY', icon="ops.transform.translate", - widget="TRANSFORM_WGT_gizmo", + widget="TRANSFORM_GGT_gizmo", operator="transform.translate", # TODO, implement as optional fallback gizmo # keymap=( @@ -147,7 +147,7 @@ class _defs_transform: text="Rotate", # cursor='SCROLL_XY', icon="ops.transform.rotate", - widget="TRANSFORM_WGT_gizmo", + widget="TRANSFORM_GGT_gizmo", operator="transform.rotate", # TODO, implement as optional fallback gizmo # keymap=( @@ -161,7 +161,7 @@ class _defs_transform: text="Scale", # cursor='SCROLL_XY', icon="ops.transform.resize", - widget="TRANSFORM_WGT_gizmo", + widget="TRANSFORM_GGT_gizmo", operator="transform.resize", # TODO, implement as optional fallback gizmo # keymap=( @@ -174,7 +174,7 @@ class _defs_transform: return dict( text="Scale Cage", icon="ops.transform.resize.cage", - widget="VIEW3D_WGT_xform_cage", + widget="VIEW3D_GGT_xform_cage", operator="transform.resize", ) @@ -187,7 +187,7 @@ class _defs_transform: return dict( text="Transform", icon="ops.transform.transform", - widget="TRANSFORM_WGT_gizmo", + widget="TRANSFORM_GGT_gizmo", # No keymap default action, only for gizmo! draw_settings=draw_settings, ) @@ -462,7 +462,7 @@ class _defs_edit_mesh: return dict( text="Extrude Region", icon="ops.mesh.extrude_region_move", - widget="MESH_WGT_extrude", + widget="MESH_GGT_extrude", operator="view3d.edit_mesh_extrude_move_normal", keymap=( ("mesh.extrude_context_move", dict(TRANSFORM_OT_translate=dict(release_confirm=True)), diff --git a/release/scripts/templates_py/gizmo_custom_geometry.py b/release/scripts/templates_py/gizmo_custom_geometry.py index f71237f52f7..8125498fa85 100644 --- a/release/scripts/templates_py/gizmo_custom_geometry.py +++ b/release/scripts/templates_py/gizmo_custom_geometry.py @@ -63,7 +63,7 @@ custom_shape_verts = ( class MyCustomShapeWidget(Gizmo): - bl_idname = "VIEW3D_WT_auto_facemap" + bl_idname = "VIEW3D_GT_auto_facemap" bl_target_properties = ( {"id": "offset", "type": 'FLOAT', "array_length": 1}, ) @@ -113,7 +113,7 @@ class MyCustomShapeWidget(Gizmo): class MyCustomShapeWidgetGroup(GizmoGroup): - bl_idname = "OBJECT_WGT_light_test" + bl_idname = "OBJECT_GGT_light_test" bl_label = "Test Light Widget" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' diff --git a/release/scripts/templates_py/gizmo_operator.py b/release/scripts/templates_py/gizmo_operator.py index 3cbb0801e9c..bdc1bc9893c 100644 --- a/release/scripts/templates_py/gizmo_operator.py +++ b/release/scripts/templates_py/gizmo_operator.py @@ -80,7 +80,7 @@ class SelectSideOfPlane(Operator): # Gizmos for plane_co, plane_no class SelectSideOfPlaneGizmoGroup(GizmoGroup): - bl_idname = "MESH_WGT_select_side_of_plane" + bl_idname = "MESH_GGT_select_side_of_plane" bl_label = "Side of Plane Gizmo" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' @@ -126,7 +126,7 @@ class SelectSideOfPlaneGizmoGroup(GizmoGroup): # XXX, this may change! op.execute(context) - mpr = self.gizmos.new("GIZMO_WT_grab_3d") + mpr = self.gizmos.new("GIZMO_GT_grab_3d") mpr.target_set_handler("offset", get=grab_get_cb, set=grab_set_cb) mpr.use_draw_value = True @@ -161,7 +161,7 @@ class SelectSideOfPlaneGizmoGroup(GizmoGroup): op.plane_no = no op.execute(context) - mpr = self.gizmos.new("GIZMO_WT_dial_3d") + mpr = self.gizmos.new("GIZMO_GT_dial_3d") mpr.target_set_handler("offset", get=direction_get_cb, set=direction_set_cb) mpr.draw_options = {'ANGLE_START_Y'} diff --git a/release/scripts/templates_py/gizmo_operator_target.py b/release/scripts/templates_py/gizmo_operator_target.py index 08fe63ef0b7..28465ad2fa5 100644 --- a/release/scripts/templates_py/gizmo_operator_target.py +++ b/release/scripts/templates_py/gizmo_operator_target.py @@ -10,7 +10,7 @@ from bpy.types import ( class MyCameraWidgetGroup(GizmoGroup): - bl_idname = "OBJECT_WGT_test_camera" + bl_idname = "OBJECT_GGT_test_camera" bl_label = "Object Camera Test Widget" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' @@ -24,7 +24,7 @@ class MyCameraWidgetGroup(GizmoGroup): def setup(self, context): # Run an operator using the dial gizmo ob = context.object - mpr = self.gizmos.new("GIZMO_WT_dial_3d") + mpr = self.gizmos.new("GIZMO_GGT_dial_3d") props = mpr.target_set_operator("transform.rotate") props.constraint_axis = False, False, True props.constraint_orientation = 'LOCAL' diff --git a/release/scripts/templates_py/gizmo_simple.py b/release/scripts/templates_py/gizmo_simple.py index 0fd1e0b386b..df80acea0ae 100644 --- a/release/scripts/templates_py/gizmo_simple.py +++ b/release/scripts/templates_py/gizmo_simple.py @@ -11,7 +11,7 @@ from bpy.types import ( class MyLightWidgetGroup(GizmoGroup): - bl_idname = "OBJECT_WGT_light_test" + bl_idname = "OBJECT_GGT_light_test" bl_label = "Test Light Widget" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' @@ -25,7 +25,7 @@ class MyLightWidgetGroup(GizmoGroup): def setup(self, context): # Arrow gizmo has one 'offset' property we can assign to the light energy. ob = context.object - mpr = self.gizmos.new("GIZMO_WT_arrow_3d") + mpr = self.gizmos.new("GIZMO_GGT_arrow_3d") mpr.target_set_prop("offset", ob.data, "energy") mpr.matrix_basis = ob.matrix_world.normalized() mpr.draw_style = 'BOX' diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 6703d828bf0..9f57859d318 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -185,7 +185,7 @@ void CTX_wm_screen_set(bContext *C, struct bScreen *screen); /* to be removed */ void CTX_wm_area_set(bContext *C, struct ScrArea *sa); void CTX_wm_region_set(bContext *C, struct ARegion *region); void CTX_wm_menu_set(bContext *C, struct ARegion *menu); -void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *mgroup); +void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup); const char *CTX_wm_operator_poll_msg_get(struct bContext *C); void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 68a1e607517..3dfe9732062 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -876,9 +876,9 @@ void CTX_wm_menu_set(bContext *C, ARegion *menu) C->wm.menu = menu; } -void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *mgroup) +void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup) { - C->wm.gizmo_group = mgroup; + C->wm.gizmo_group = gzgroup; } void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 98d6f167d30..a16d0bab104 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1440,7 +1440,7 @@ void DRW_draw_render_loop_ex( if (DST.draw_ctx.evil_C) { /* needed so gizmo isn't obscured */ if (((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && - ((v3d->mpr_flag & V3D_GIZMO_HIDE) == 0)) + ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0)) { glDisable(GL_DEPTH_TEST); DRW_draw_gizmo_3d(); diff --git a/source/blender/editors/gizmo_library/gizmo_library_intern.h b/source/blender/editors/gizmo_library/gizmo_library_intern.h index f1689ee93db..f5584d86847 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_intern.h +++ b/source/blender/editors/gizmo_library/gizmo_library_intern.h @@ -76,25 +76,25 @@ float gizmo_value_from_offset( const bool constrained, const bool inverted, const bool use_precision); void gizmo_property_data_update( - struct wmGizmo *mpr, GizmoCommonData *data, wmGizmoProperty *mpr_prop, + struct wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop, const bool constrained, const bool inverted); void gizmo_property_value_reset( - bContext *C, const struct wmGizmo *mpr, GizmoInteraction *inter, wmGizmoProperty *mpr_prop); + bContext *C, const struct wmGizmo *gz, GizmoInteraction *inter, wmGizmoProperty *gz_prop); /* -------------------------------------------------------------------- */ void gizmo_color_get( - const struct wmGizmo *mpr, const bool highlight, + const struct wmGizmo *gz, const bool highlight, float r_color[4]); bool gizmo_window_project_2d( - bContext *C, const struct wmGizmo *mpr, const float mval[2], int axis, bool use_offset, + bContext *C, const struct wmGizmo *gz, const float mval[2], int axis, bool use_offset, float r_co[2]); bool gizmo_window_project_3d( - bContext *C, const struct wmGizmo *mpr, const float mval[2], bool use_offset, + bContext *C, const struct wmGizmo *gz, const float mval[2], bool use_offset, float r_co[3]); /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c index 8a6b92e48d6..e16f8ed21bf 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_presets.c +++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c @@ -81,14 +81,14 @@ static void single_axis_convert( * Use for all geometry. */ static void ed_gizmo_draw_preset_geometry( - const struct wmGizmo *mpr, float mat[4][4], int select_id, + const struct wmGizmo *gz, float mat[4][4], int select_id, const GizmoGeomInfo *info) { const bool is_select = (select_id != -1); - const bool is_highlight = is_select && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float color[4]; - gizmo_color_get(mpr, is_highlight, color); + gizmo_color_get(gz, is_highlight, color); if (is_select) { GPU_select_load_id(select_id); @@ -105,35 +105,35 @@ static void ed_gizmo_draw_preset_geometry( } void ED_gizmo_draw_preset_box( - const struct wmGizmo *mpr, float mat[4][4], int select_id) + const struct wmGizmo *gz, float mat[4][4], int select_id) { - ed_gizmo_draw_preset_geometry(mpr, mat, select_id, &wm_gizmo_geom_data_cube); + ed_gizmo_draw_preset_geometry(gz, mat, select_id, &wm_gizmo_geom_data_cube); } void ED_gizmo_draw_preset_arrow( - const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id) + const struct wmGizmo *gz, float mat[4][4], int axis, int select_id) { float mat_rotate[4][4]; single_axis_convert(OB_POSZ, mat, axis, mat_rotate); - ed_gizmo_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_gizmo_geom_data_arrow); + ed_gizmo_draw_preset_geometry(gz, mat_rotate, select_id, &wm_gizmo_geom_data_arrow); } void ED_gizmo_draw_preset_circle( - const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id) + const struct wmGizmo *gz, float mat[4][4], int axis, int select_id) { float mat_rotate[4][4]; single_axis_convert(OB_POSZ, mat, axis, mat_rotate); - ed_gizmo_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_gizmo_geom_data_dial); + ed_gizmo_draw_preset_geometry(gz, mat_rotate, select_id, &wm_gizmo_geom_data_dial); } void ED_gizmo_draw_preset_facemap( - const bContext *C, const struct wmGizmo *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id) + const bContext *C, const struct wmGizmo *gz, struct Scene *scene, Object *ob, const int facemap, int select_id) { const bool is_select = (select_id != -1); - const bool is_highlight = is_select && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float color[4]; - gizmo_color_get(mpr, is_highlight, color); + gizmo_color_get(gz, is_highlight, color); if (is_select) { GPU_select_load_id(select_id); diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c index 6e6bc2ed824..07c230c5503 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_utils.c +++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c @@ -107,13 +107,13 @@ float gizmo_value_from_offset( } void gizmo_property_data_update( - wmGizmo *mpr, GizmoCommonData *data, wmGizmoProperty *mpr_prop, + wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop, const bool constrained, const bool inverted) { - if (mpr_prop->custom_func.value_get_fn != NULL) { + if (gz_prop->custom_func.value_get_fn != NULL) { /* pass */ } - else if (mpr_prop->prop != NULL) { + else if (gz_prop->prop != NULL) { /* pass */ } else { @@ -121,12 +121,12 @@ void gizmo_property_data_update( return; } - float value = WM_gizmo_target_property_value_get(mpr, mpr_prop); + float value = WM_gizmo_target_property_value_get(gz, gz_prop); if (constrained) { if ((data->flag & GIZMO_CUSTOM_RANGE_SET) == 0) { float range[2]; - if (WM_gizmo_target_property_range_get(mpr, mpr_prop, range)) { + if (WM_gizmo_target_property_range_get(gz, gz_prop, range)) { data->range = range[1] - range[0]; data->min = range[0]; } @@ -142,23 +142,23 @@ void gizmo_property_data_update( } void gizmo_property_value_reset( - bContext *C, const wmGizmo *mpr, GizmoInteraction *inter, - wmGizmoProperty *mpr_prop) + bContext *C, const wmGizmo *gz, GizmoInteraction *inter, + wmGizmoProperty *gz_prop) { - WM_gizmo_target_property_value_set(C, mpr, mpr_prop, inter->init_value); + WM_gizmo_target_property_value_set(C, gz, gz_prop, inter->init_value); } /* -------------------------------------------------------------------- */ void gizmo_color_get( - const wmGizmo *mpr, const bool highlight, + const wmGizmo *gz, const bool highlight, float r_col[4]) { - if (highlight && !(mpr->flag & WM_GIZMO_DRAW_HOVER)) { - copy_v4_v4(r_col, mpr->color_hi); + if (highlight && !(gz->flag & WM_GIZMO_DRAW_HOVER)) { + copy_v4_v4(r_col, gz->color_hi); } else { - copy_v4_v4(r_col, mpr->color); + copy_v4_v4(r_col, gz->color); } } @@ -169,7 +169,7 @@ void gizmo_color_get( * Both 2D & 3D supported, use so we can use 2D gizmos in the 3D view. */ bool gizmo_window_project_2d( - bContext *C, const struct wmGizmo *mpr, const float mval[2], int axis, bool use_offset, + bContext *C, const struct wmGizmo *gz, const float mval[2], int axis, bool use_offset, float r_co[2]) { float mat[4][4]; @@ -180,11 +180,11 @@ bool gizmo_window_project_2d( unit_m4(mat_identity); params.matrix_offset = mat_identity; } - WM_gizmo_calc_matrix_final_params(mpr, ¶ms, mat); + WM_gizmo_calc_matrix_final_params(gz, ¶ms, mat); } /* rotate mouse in relation to the center and relocate it */ - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { /* For 3d views, transform 2D mouse pos onto plane. */ View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); @@ -221,7 +221,7 @@ bool gizmo_window_project_2d( } bool gizmo_window_project_3d( - bContext *C, const struct wmGizmo *mpr, const float mval[2], bool use_offset, + bContext *C, const struct wmGizmo *gz, const float mval[2], bool use_offset, float r_co[3]) { float mat[4][4]; @@ -232,10 +232,10 @@ bool gizmo_window_project_3d( unit_m4(mat_identity); params.matrix_offset = mat_identity; } - WM_gizmo_calc_matrix_final_params(mpr, ¶ms, mat); + WM_gizmo_calc_matrix_final_params(gz, ¶ms, mat); } - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); /* Note: we might want a custom reference point passed in, diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c index dfa2eeeb38b..0faeeefb4a3 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c @@ -61,14 +61,14 @@ #include "../gizmo_library_intern.h" -static void arrow2d_draw_geom(wmGizmo *mpr, const float matrix[4][4], const float color[4]) +static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float color[4]) { const float size = 0.11f; const float size_breadth = size / 2.0f; const float size_length = size * 1.7f; /* Subtract the length so the arrow fits in the hotspot. */ - const float arrow_length = RNA_float_get(mpr->ptr, "length") - size_length; - const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); + const float arrow_length = RNA_float_get(gz->ptr, "length") - size_length; + const float arrow_angle = RNA_float_get(gz->ptr, "angle"); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -96,60 +96,60 @@ static void arrow2d_draw_geom(wmGizmo *mpr, const float matrix[4][4], const floa gpuPopMatrix(); } -static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *mpr) +static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *gz) { float color[4]; float matrix_final[4][4]; - gizmo_color_get(mpr, mpr->state & WM_GIZMO_STATE_HIGHLIGHT, color); + gizmo_color_get(gz, gz->state & WM_GIZMO_STATE_HIGHLIGHT, color); - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); GPU_blend(true); - arrow2d_draw_geom(mpr, matrix_final, color); + arrow2d_draw_geom(gz, matrix_final, color); GPU_blend(false); - if (mpr->interaction_data) { - GizmoInteraction *inter = mpr->interaction_data; + if (gz->interaction_data) { + GizmoInteraction *inter = gz->interaction_data; GPU_blend(true); - arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); + arrow2d_draw_geom(gz, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); GPU_blend(false); } } -static void gizmo_arrow2d_setup(wmGizmo *mpr) +static void gizmo_arrow2d_setup(wmGizmo *gz) { - mpr->flag |= WM_GIZMO_DRAW_MODAL; + gz->flag |= WM_GIZMO_DRAW_MODAL; } static int gizmo_arrow2d_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *UNUSED(event)) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *UNUSED(event)) { GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); - copy_m4_m4(inter->init_matrix_basis, mpr->matrix_basis); - WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); + copy_m4_m4(inter->init_matrix_basis, gz->matrix_basis); + WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final); - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } static int gizmo_arrow2d_test_select( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { const float mval[2] = {event->mval[0], event->mval[1]}; - const float arrow_length = RNA_float_get(mpr->ptr, "length"); - const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); - const float line_len = arrow_length * mpr->scale_final; + const float arrow_length = RNA_float_get(gz->ptr, "length"); + const float arrow_angle = RNA_float_get(gz->ptr, "angle"); + const float line_len = arrow_length * gz->scale_final; float mval_local[2]; copy_v2_v2(mval_local, mval); - sub_v2_v2(mval_local, mpr->matrix_basis[3]); + sub_v2_v2(mval_local, gz->matrix_basis[3]); float line[2][2]; line[0][0] = line[0][1] = line[1][0] = 0.0f; @@ -165,7 +165,7 @@ static int gizmo_arrow2d_test_select( /* arrow line intersection check */ float isect_1[2], isect_2[2]; const int isect = isect_line_sphere_v2( - line[0], line[1], mval_local, GIZMO_HOTSPOT + mpr->line_width * 0.5f, + line[0], line[1], mval_local, GIZMO_HOTSPOT + gz->line_width * 0.5f, isect_1, isect_2); if (isect > 0) { @@ -197,29 +197,29 @@ static int gizmo_arrow2d_test_select( * * \{ */ -static void GIZMO_WT_arrow_2d(wmGizmoType *wt) +static void GIZMO_GT_arrow_2d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_arrow_2d"; + gzt->idname = "GIZMO_GT_arrow_2d"; /* api callbacks */ - wt->draw = gizmo_arrow2d_draw; - wt->setup = gizmo_arrow2d_setup; - wt->invoke = gizmo_arrow2d_invoke; - wt->test_select = gizmo_arrow2d_test_select; + gzt->draw = gizmo_arrow2d_draw; + gzt->setup = gizmo_arrow2d_setup; + gzt->invoke = gizmo_arrow2d_invoke; + gzt->test_select = gizmo_arrow2d_test_select; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); /* rna */ - RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); + RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); RNA_def_float_rotation( - wt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f), + gzt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f), "Roll", "", DEG2RADF(-360.0f), DEG2RADF(360.0f)); } void ED_gizmotypes_arrow_2d(void) { - WM_gizmotype_append(GIZMO_WT_arrow_2d); + WM_gizmotype_append(GIZMO_GT_arrow_2d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index 9807a111d26..09c6485c29e 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -80,9 +80,9 @@ typedef struct ArrowGizmo3D { /* -------------------------------------------------------------------- */ -static void gizmo_arrow_matrix_basis_get(const wmGizmo *mpr, float r_matrix[4][4]) +static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4]) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis); madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset); @@ -182,13 +182,13 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight) { - wmGizmo *mpr = &arrow->gizmo; + wmGizmo *gz = &arrow->gizmo; float color[4]; float matrix_final[4][4]; - gizmo_color_get(mpr, highlight, color); + gizmo_color_get(gz, highlight, color); - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); @@ -198,8 +198,8 @@ static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool gpuPopMatrix(); - if (mpr->interaction_data) { - GizmoInteraction *inter = mpr->interaction_data; + if (gz->interaction_data) { + GizmoInteraction *inter = gz->interaction_data; gpuPushMatrix(); gpuMultMatrix(inter->init_matrix_final); @@ -214,16 +214,16 @@ static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool } static void gizmo_arrow_draw_select( - const bContext *UNUSED(C), wmGizmo *mpr, + const bContext *UNUSED(C), wmGizmo *gz, int select_id) { GPU_select_load_id(select_id); - arrow_draw_intern((ArrowGizmo3D *)mpr, true, false); + arrow_draw_intern((ArrowGizmo3D *)gz, true, false); } -static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *mpr) +static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz) { - arrow_draw_intern((ArrowGizmo3D *)mpr, false, (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0); + arrow_draw_intern((ArrowGizmo3D *)gz, false, (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0); } /** @@ -231,11 +231,11 @@ static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *mpr) * meaning the range will not be offset by min value first. */ static int gizmo_arrow_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; - GizmoInteraction *inter = mpr->interaction_data; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; + GizmoInteraction *inter = gz->interaction_data; View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; @@ -299,19 +299,19 @@ static int gizmo_arrow_modal( GizmoCommonData *data = &arrow->data; const float ofs_new = facdir * len_v3(offset); - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); /* set the property for the operator and call its modal function */ - if (WM_gizmo_target_property_is_valid(mpr_prop)) { + if (WM_gizmo_target_property_is_valid(gz_prop)) { const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform"); const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0; const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0; const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0; float value = gizmo_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); - WM_gizmo_target_property_value_set(C, mpr, mpr_prop, value); + WM_gizmo_target_property_value_set(C, gz, gz_prop, value); /* get clamped value */ - value = WM_gizmo_target_property_value_get(mpr, mpr_prop); + value = WM_gizmo_target_property_value_get(gz, gz_prop); data->offset = gizmo_offset_from_value(data, value, constrained, inverted); } @@ -326,9 +326,9 @@ static int gizmo_arrow_modal( return OPERATOR_RUNNING_MODAL; } -static void gizmo_arrow_setup(wmGizmo *mpr) +static void gizmo_arrow_setup(wmGizmo *gz) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; arrow->gizmo.flag |= WM_GIZMO_DRAW_MODAL; @@ -336,15 +336,15 @@ static void gizmo_arrow_setup(wmGizmo *mpr) } static int gizmo_arrow_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); /* Some gizmos don't use properties. */ - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - inter->init_value = WM_gizmo_target_property_value_get(mpr, mpr_prop); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + inter->init_value = WM_gizmo_target_property_value_get(gz, gz_prop); } inter->init_offset = arrow->data.offset; @@ -352,42 +352,42 @@ static int gizmo_arrow_invoke( inter->init_mval[0] = event->mval[0]; inter->init_mval[1] = event->mval[1]; - gizmo_arrow_matrix_basis_get(mpr, inter->init_matrix_basis); - WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); + gizmo_arrow_matrix_basis_get(gz, inter->init_matrix_basis); + WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final); - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } -static void gizmo_arrow_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) +static void gizmo_arrow_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform"); const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0; const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0; - gizmo_property_data_update(mpr, &arrow->data, mpr_prop, constrained, inverted); + gizmo_property_data_update(gz, &arrow->data, gz_prop, constrained, inverted); } -static void gizmo_arrow_exit(bContext *C, wmGizmo *mpr, const bool cancel) +static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; GizmoCommonData *data = &arrow->data; - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - const bool is_prop_valid = WM_gizmo_target_property_is_valid(mpr_prop); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop); if (!cancel) { /* Assign incase applying the opetration needs an updated offset * editmesh bisect needs this. */ if (is_prop_valid) { - data->offset = WM_gizmo_target_property_value_get(mpr, mpr_prop); + data->offset = WM_gizmo_target_property_value_get(gz, gz_prop); } return; } - GizmoInteraction *inter = mpr->interaction_data; + GizmoInteraction *inter = gz->interaction_data; if (is_prop_valid) { - gizmo_property_value_reset(C, mpr, inter, mpr_prop); + gizmo_property_value_reset(C, gz, inter, gz_prop); } data->offset = inter->init_offset; } @@ -403,12 +403,12 @@ static void gizmo_arrow_exit(bContext *C, wmGizmo *mpr, const bool cancel) * * \note Needs to be called before WM_gizmo_target_property_def_rna! */ -void ED_gizmo_arrow3d_set_ui_range(wmGizmo *mpr, const float min, const float max) +void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; BLI_assert(min < max); - BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(mpr, "offset")) && + BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(gz, "offset")) && "Make sure this function is called before WM_gizmo_target_property_def_rna")); arrow->data.range = max - min; @@ -421,31 +421,31 @@ void ED_gizmo_arrow3d_set_ui_range(wmGizmo *mpr, const float min, const float ma * * \note Needs to be called before WM_gizmo_target_property_def_rna! */ -void ED_gizmo_arrow3d_set_range_fac(wmGizmo *mpr, const float range_fac) +void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; - BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(mpr, "offset")) && + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; + BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(gz, "offset")) && "Make sure this function is called before WM_gizmo_target_property_def_rna")); arrow->data.range_fac = range_fac; } -static void GIZMO_WT_arrow_3d(wmGizmoType *wt) +static void GIZMO_GT_arrow_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_arrow_3d"; + gzt->idname = "GIZMO_GT_arrow_3d"; /* api callbacks */ - wt->draw = gizmo_arrow_draw; - wt->draw_select = gizmo_arrow_draw_select; - wt->matrix_basis_get = gizmo_arrow_matrix_basis_get; - wt->modal = gizmo_arrow_modal; - wt->setup = gizmo_arrow_setup; - wt->invoke = gizmo_arrow_invoke; - wt->property_update = gizmo_arrow_property_update; - wt->exit = gizmo_arrow_exit; + gzt->draw = gizmo_arrow_draw; + gzt->draw_select = gizmo_arrow_draw_select; + gzt->matrix_basis_get = gizmo_arrow_matrix_basis_get; + gzt->modal = gizmo_arrow_modal; + gzt->setup = gizmo_arrow_setup; + gzt->invoke = gizmo_arrow_invoke; + gzt->property_update = gizmo_arrow_property_update; + gzt->exit = gizmo_arrow_exit; - wt->struct_size = sizeof(ArrowGizmo3D); + gzt->struct_size = sizeof(ArrowGizmo3D); /* rna */ static EnumPropertyItem rna_enum_draw_style_items[] = { @@ -466,27 +466,27 @@ static void GIZMO_WT_arrow_3d(wmGizmoType *wt) }; RNA_def_enum( - wt->srna, "draw_style", rna_enum_draw_style_items, + gzt->srna, "draw_style", rna_enum_draw_style_items, ED_GIZMO_ARROW_STYLE_NORMAL, "Draw Style", ""); RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options_items, + gzt->srna, "draw_options", rna_enum_draw_options_items, ED_GIZMO_ARROW_DRAW_FLAG_STEM, "Draw Options", ""); RNA_def_enum_flag( - wt->srna, "transform", rna_enum_transform_items, + gzt->srna, "transform", rna_enum_transform_items, 0, "Transform", ""); - RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); - RNA_def_float_vector(wt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX); + RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); + RNA_def_float_vector(gzt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX); - WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 1); + WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1); } void ED_gizmotypes_arrow_3d(void) { - WM_gizmotype_append(GIZMO_WT_arrow_3d); + WM_gizmotype_append(GIZMO_GT_arrow_3d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index ede070f0bed..dfe2c8b2413 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -80,9 +80,9 @@ typedef struct ButtonGizmo2D { /* -------------------------------------------------------------------- */ static void button2d_geom_draw_backdrop( - const wmGizmo *mpr, const float color[4], const bool select) + const wmGizmo *gz, const float color[4], const bool select) { - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -100,24 +100,24 @@ static void button2d_geom_draw_backdrop( } static void button2d_draw_intern( - const bContext *C, wmGizmo *mpr, + const bContext *C, wmGizmo *gz, const bool select, const bool highlight) { - ButtonGizmo2D *button = (ButtonGizmo2D *)mpr; + ButtonGizmo2D *button = (ButtonGizmo2D *)gz; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); if (button->is_init == false) { button->is_init = true; - PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "icon"); - if (RNA_property_is_set(mpr->ptr, prop)) { - button->icon = RNA_property_enum_get(mpr->ptr, prop); + PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon"); + if (RNA_property_is_set(gz->ptr, prop)) { + button->icon = RNA_property_enum_get(gz->ptr, prop); } else { - prop = RNA_struct_find_property(mpr->ptr, "shape"); - const uint polys_len = RNA_property_string_length(mpr->ptr, prop); + prop = RNA_struct_find_property(gz->ptr, "shape"); + const uint polys_len = RNA_property_string_length(gz->ptr, prop); /* We shouldn't need the +1, but a NULL char is set. */ char *polys = MEM_mallocN(polys_len + 1, __func__); - RNA_property_string_get(mpr->ptr, prop, polys); + RNA_property_string_get(gz->ptr, prop, polys); button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded((uchar *)polys, polys_len, NULL); button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded((uchar *)polys, polys_len, NULL); MEM_freeN(polys); @@ -127,20 +127,20 @@ static void button2d_draw_intern( float color[4]; float matrix_final[4][4]; - gizmo_color_get(mpr, highlight, color); - WM_gizmo_calc_matrix_final(mpr, matrix_final); + gizmo_color_get(gz, highlight, color); + WM_gizmo_calc_matrix_final(gz, matrix_final); - bool is_3d = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) != 0; + bool is_3d = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) != 0; if (draw_options & ED_GIZMO_BUTTON_SHOW_HELPLINE) { float matrix_final_no_offset[4][4]; - WM_gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); + WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); immUniformColor4fv(color); immBegin(GWN_PRIM_LINE_STRIP, 2); immVertex3fv(pos, matrix_final[3]); @@ -166,7 +166,7 @@ static void button2d_draw_intern( if (select) { BLI_assert(is_3d); - button2d_geom_draw_backdrop(mpr, color, select); + button2d_geom_draw_backdrop(gz, color, select); } else { @@ -191,7 +191,7 @@ static void button2d_draw_intern( GPU_polygon_smooth(true); } else if (button->icon != ICON_NONE) { - button2d_geom_draw_backdrop(mpr, color, select); + button2d_geom_draw_backdrop(gz, color, select); float size[2]; if (is_3d) { const float fac = 2.0f; @@ -201,8 +201,8 @@ static void button2d_draw_intern( size[1] = 1.0f; } else { - size[0] = mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; - size[1] = mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; + size[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; + size[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; gpuPopMatrix(); need_to_pop = false; } @@ -216,40 +216,40 @@ static void button2d_draw_intern( } } -static void gizmo_button2d_draw_select(const bContext *C, wmGizmo *mpr, int select_id) +static void gizmo_button2d_draw_select(const bContext *C, wmGizmo *gz, int select_id) { GPU_select_load_id(select_id); - button2d_draw_intern(C, mpr, true, false); + button2d_draw_intern(C, gz, true, false); } -static void gizmo_button2d_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_button2d_draw(const bContext *C, wmGizmo *gz) { - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; GPU_blend(true); - button2d_draw_intern(C, mpr, false, is_highlight); + button2d_draw_intern(C, gz, false, is_highlight); GPU_blend(false); } static int gizmo_button2d_test_select( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { float point_local[2]; if (0) { /* correct, but unnecessarily slow. */ if (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; } } else { copy_v2_v2(point_local, (float[2]){UNPACK2(event->mval)}); - sub_v2_v2(point_local, mpr->matrix_basis[3]); - mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC)); + sub_v2_v2(point_local, gz->matrix_basis[3]); + mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC)); } - /* The 'mpr->scale_final' is already applied when projecting. */ + /* The 'gz->scale_final' is already applied when projecting. */ if (len_squared_v2(point_local) < 1.0f) { return 0; } @@ -257,17 +257,17 @@ static int gizmo_button2d_test_select( return -1; } -static int gizmo_button2d_cursor_get(wmGizmo *mpr) +static int gizmo_button2d_cursor_get(wmGizmo *gz) { - if (RNA_boolean_get(mpr->ptr, "show_drag")) { + if (RNA_boolean_get(gz->ptr, "show_drag")) { return BC_NSEW_SCROLLCURSOR; } return CURSOR_STD; } -static void gizmo_button2d_free(wmGizmo *mpr) +static void gizmo_button2d_free(wmGizmo *gz) { - ButtonGizmo2D *shape = (ButtonGizmo2D *)mpr; + ButtonGizmo2D *shape = (ButtonGizmo2D *)gz; for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) { GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]); @@ -281,19 +281,19 @@ static void gizmo_button2d_free(wmGizmo *mpr) * * \{ */ -static void GIZMO_WT_button_2d(wmGizmoType *wt) +static void GIZMO_GT_button_2d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_button_2d"; + gzt->idname = "GIZMO_GT_button_2d"; /* api callbacks */ - wt->draw = gizmo_button2d_draw; - wt->draw_select = gizmo_button2d_draw_select; - wt->test_select = gizmo_button2d_test_select; - wt->cursor_get = gizmo_button2d_cursor_get; - wt->free = gizmo_button2d_free; + gzt->draw = gizmo_button2d_draw; + gzt->draw_select = gizmo_button2d_draw_select; + gzt->test_select = gizmo_button2d_test_select; + gzt->cursor_get = gizmo_button2d_cursor_get; + gzt->free = gizmo_button2d_free; - wt->struct_size = sizeof(ButtonGizmo2D); + gzt->struct_size = sizeof(ButtonGizmo2D); /* rna */ static EnumPropertyItem rna_enum_draw_options[] = { @@ -303,21 +303,21 @@ static void GIZMO_WT_button_2d(wmGizmoType *wt) }; PropertyRNA *prop; - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - prop = RNA_def_property(wt->srna, "icon", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(gzt->srna, "icon", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_icon_items); /* Passed to 'GPU_batch_tris_from_poly_2d_encoded' */ - RNA_def_property(wt->srna, "shape", PROP_STRING, PROP_BYTESTRING); + RNA_def_property(gzt->srna, "shape", PROP_STRING, PROP_BYTESTRING); /* Currently only used for cursor display. */ - RNA_def_boolean(wt->srna, "show_drag", true, "Show Drag", ""); + RNA_def_boolean(gzt->srna, "show_drag", true, "Show Drag", ""); } void ED_gizmotypes_button_2d(void) { - WM_gizmotype_append(GIZMO_WT_button_2d); + WM_gizmotype_append(GIZMO_GT_button_2d); } /** \} */ // Button Gizmo API diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index a037727de58..8a830302f51 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -68,7 +68,7 @@ #define GIZMO_MARGIN_OFFSET_SCALE 1.5f static void gizmo_calc_rect_view_scale( - const wmGizmo *mpr, const float dims[2], float scale[2]) + const wmGizmo *gz, const float dims[2], float scale[2]) { float matrix_final_no_offset[4][4]; float asp[2] = {1.0f, 1.0f}; @@ -79,9 +79,9 @@ static void gizmo_calc_rect_view_scale( asp[1] = dims[0] / dims[1]; } float x_axis[3], y_axis[3]; - WM_gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); - mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); - mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); + WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset); + mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]); + mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]); mul_v2_v2(x_axis, asp); mul_v2_v2(y_axis, asp); @@ -91,18 +91,18 @@ static void gizmo_calc_rect_view_scale( } static void gizmo_calc_rect_view_margin( - const wmGizmo *mpr, const float dims[2], float margin[2]) + const wmGizmo *gz, const float dims[2], float margin[2]) { float handle_size; - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { handle_size = 0.15f; } else { handle_size = GIZMO_RESIZER_SIZE; } - handle_size *= mpr->scale_final; + handle_size *= gz->scale_final; float scale_xy[2]; - gizmo_calc_rect_view_scale(mpr, dims, scale_xy); + gizmo_calc_rect_view_scale(gz, dims, scale_xy); margin[0] = ((handle_size * scale_xy[0])); margin[1] = ((handle_size * scale_xy[1])); } @@ -536,26 +536,26 @@ static void cage2d_draw_circle_handles( /** \} */ static void gizmo_cage2d_draw_intern( - wmGizmo *mpr, const bool select, const bool highlight, const int select_id) + wmGizmo *gz, const bool select, const bool highlight, const int select_id) { - // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; + // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); float matrix_final[4][4]; - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + const int draw_style = RNA_enum_get(gz->ptr, "draw_style"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); float margin[2]; - gizmo_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(gz, dims, margin); /* Handy for quick testing draw (if it's outside bounds). */ if (false) { @@ -588,18 +588,18 @@ static void gizmo_cage2d_draw_intern( for (int i = 0; i < ARRAY_SIZE(scale_parts); i++) { GPU_select_load_id(select_id | scale_parts[i]); cage2d_draw_box_interaction( - mpr->color, scale_parts[i], size, margin, mpr->line_width, true, draw_options); + gz->color, scale_parts[i], size, margin, gz->line_width, true, draw_options); } } if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { const int transform_part = ED_GIZMO_CAGE2D_PART_TRANSLATE; GPU_select_load_id(select_id | transform_part); cage2d_draw_box_interaction( - mpr->color, transform_part, size, margin, mpr->line_width, true, draw_options); + gz->color, transform_part, size, margin, gz->line_width, true, draw_options); } if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { cage2d_draw_box_interaction( - mpr->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, true, draw_options); + gz->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, gz->line_width, true, draw_options); } } else { @@ -611,17 +611,17 @@ static void gizmo_cage2d_draw_intern( }; if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) { /* corner gizmos */ - GPU_line_width(mpr->line_width + 3.0f); + GPU_line_width(gz->line_width + 3.0f); cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0}); /* corner gizmos */ float color[4]; - gizmo_color_get(mpr, highlight, color); - GPU_line_width(mpr->line_width); + gizmo_color_get(gz, highlight, color); + GPU_line_width(gz->line_width); cage2d_draw_box_corners(&r, margin, color); bool show = false; - if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { + if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { /* Only show if we're drawing the center handle * otherwise the entire rectangle is the hotspot. */ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { @@ -634,24 +634,24 @@ static void gizmo_cage2d_draw_intern( if (show) { cage2d_draw_box_interaction( - mpr->color, mpr->highlight_part, size_real, margin, mpr->line_width, false, draw_options); + gz->color, gz->highlight_part, size_real, margin, gz->line_width, false, draw_options); } if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { cage2d_draw_box_interaction( - mpr->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, false, draw_options); + gz->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, gz->line_width, false, draw_options); } } else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) { float color[4]; - gizmo_color_get(mpr, highlight, color); + gizmo_color_get(gz, highlight, color); GPU_line_smooth(true); GPU_blend(true); - GPU_line_width(mpr->line_width + 3.0f); + GPU_line_width(gz->line_width + 3.0f); cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options); @@ -674,22 +674,22 @@ static void gizmo_cage2d_draw_intern( /** * For when we want to draw 2d cage in 3d views. */ -static void gizmo_cage2d_draw_select(const bContext *UNUSED(C), wmGizmo *mpr, int select_id) +static void gizmo_cage2d_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id) { - gizmo_cage2d_draw_intern(mpr, true, false, select_id); + gizmo_cage2d_draw_intern(gz, true, false, select_id); } -static void gizmo_cage2d_draw(const bContext *UNUSED(C), wmGizmo *mpr) +static void gizmo_cage2d_draw(const bContext *UNUSED(C), wmGizmo *gz) { - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; - gizmo_cage2d_draw_intern(mpr, false, is_highlight, -1); + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + gizmo_cage2d_draw_intern(gz, false, is_highlight, -1); } -static int gizmo_cage2d_get_cursor(wmGizmo *mpr) +static int gizmo_cage2d_get_cursor(wmGizmo *gz) { - int highlight_part = mpr->highlight_part; + int highlight_part = gz->highlight_part; - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { return BC_NSEW_SCROLLCURSOR; } @@ -718,26 +718,26 @@ static int gizmo_cage2d_get_cursor(wmGizmo *mpr) } static int gizmo_cage2d_test_select( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { float point_local[2]; float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; if (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; } float margin[2]; - gizmo_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(gz, dims, margin); /* expand for hotspot */ const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { rctf r; @@ -821,32 +821,32 @@ typedef struct RectTransformInteraction { Dial *dial; } RectTransformInteraction; -static void gizmo_cage2d_setup(wmGizmo *mpr) +static void gizmo_cage2d_setup(wmGizmo *gz) { - mpr->flag |= WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_NO_SCALE; + gz->flag |= WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_NO_SCALE; } static int gizmo_cage2d_invoke( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); - copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); - WM_gizmo_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset); + copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset); + WM_gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset); if (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) { zero_v2(data->orig_mouse); } - mpr->interaction_data = data; + gz->interaction_data = data; return OPERATOR_RUNNING_MODAL; } static int gizmo_cage2d_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { /* For transform logic to be managable we operate in -0.5..0.5 2D space, @@ -856,40 +856,40 @@ static int gizmo_cage2d_modal( * - The cursor offset are multiplied by 'dims'. * - Matrix translation is also multiplied by 'dims'. */ - RectTransformInteraction *data = mpr->interaction_data; + RectTransformInteraction *data = gz->interaction_data; float point_local[2]; float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); { float matrix_back[4][4]; - copy_m4_m4(matrix_back, mpr->matrix_offset); - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(matrix_back, gz->matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); bool ok = gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local); - copy_m4_m4(mpr->matrix_offset, matrix_back); + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local); + copy_m4_m4(gz->matrix_offset, matrix_back); if (!ok) { return OPERATOR_RUNNING_MODAL; } } - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - wmGizmoProperty *mpr_prop; + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + wmGizmoProperty *gz_prop; - mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + gz_prop = WM_gizmo_target_property_find(gz, "matrix"); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]); } - if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { + if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { /* do this to prevent clamping from changing size */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); - mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); + gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); + gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); } - else if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_ROTATE) { + else if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_ROTATE) { #define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \ mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0})) @@ -915,28 +915,28 @@ static int gizmo_cage2d_modal( copy_v3_v3(pivot, data->orig_matrix_offset[3]); - invert_m4_m4(matrix_space_inv, mpr->matrix_space); + invert_m4_m4(matrix_space_inv, gz->matrix_space); unit_m4(matrix_rotate); mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv); rotate_m4(matrix_rotate, 'Z', -angle); - mul_m4_m4m4(matrix_rotate, matrix_rotate, mpr->matrix_space); + mul_m4_m4m4(matrix_rotate, matrix_rotate, gz->matrix_space); zero_v3(matrix_rotate[3]); transform_pivot_set_m4(matrix_rotate, pivot); - mul_m4_m4m4(mpr->matrix_offset, matrix_rotate, data->orig_matrix_offset); + mul_m4_m4m4(gz->matrix_offset, matrix_rotate, data->orig_matrix_offset); #undef MUL_V2_V3_M4_FINAL } else { /* scale */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); float pivot[2]; bool constrain_axis[2] = {false}; if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { - gizmo_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); + gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis); } else { zero_v2(pivot); @@ -991,11 +991,11 @@ static int gizmo_cage2d_modal( mul_v3_fl(matrix_scale[1], scale[1]); transform_pivot_set_m4(matrix_scale, (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], 0.0f}); - mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale); + mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale); } - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]); } /* tag the region for redraw */ @@ -1005,11 +1005,11 @@ static int gizmo_cage2d_modal( return OPERATOR_RUNNING_MODAL; } -static void gizmo_cage2d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) +static void gizmo_cage2d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop) { - if (STREQ(mpr_prop->type->idname, "matrix")) { - if (WM_gizmo_target_property_array_length(mpr, mpr_prop) == 16) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (STREQ(gz_prop->type->idname, "matrix")) { + if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]); } else { BLI_assert(0); @@ -1020,24 +1020,24 @@ static void gizmo_cage2d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop } } -static void gizmo_cage2d_exit(bContext *C, wmGizmo *mpr, const bool cancel) +static void gizmo_cage2d_exit(bContext *C, wmGizmo *gz, const bool cancel) { - RectTransformInteraction *data = mpr->interaction_data; + RectTransformInteraction *data = gz->interaction_data; MEM_SAFE_FREE(data->dial); if (!cancel) return; - wmGizmoProperty *mpr_prop; + wmGizmoProperty *gz_prop; /* reset properties */ - mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); + gz_prop = WM_gizmo_target_property_find(gz, "matrix"); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]); } - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); } @@ -1046,23 +1046,23 @@ static void gizmo_cage2d_exit(bContext *C, wmGizmo *mpr, const bool cancel) * * \{ */ -static void GIZMO_WT_cage_2d(wmGizmoType *wt) +static void GIZMO_GT_cage_2d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_cage_2d"; + gzt->idname = "GIZMO_GT_cage_2d"; /* api callbacks */ - wt->draw = gizmo_cage2d_draw; - wt->draw_select = gizmo_cage2d_draw_select; - wt->test_select = gizmo_cage2d_test_select; - wt->setup = gizmo_cage2d_setup; - wt->invoke = gizmo_cage2d_invoke; - wt->property_update = gizmo_cage2d_property_update; - wt->modal = gizmo_cage2d_modal; - wt->exit = gizmo_cage2d_exit; - wt->cursor_get = gizmo_cage2d_get_cursor; - - wt->struct_size = sizeof(wmGizmo); + gzt->draw = gizmo_cage2d_draw; + gzt->draw_select = gizmo_cage2d_draw_select; + gzt->test_select = gizmo_cage2d_test_select; + gzt->setup = gizmo_cage2d_setup; + gzt->invoke = gizmo_cage2d_invoke; + gzt->property_update = gizmo_cage2d_property_update; + gzt->modal = gizmo_cage2d_modal; + gzt->exit = gizmo_cage2d_exit; + gzt->cursor_get = gizmo_cage2d_get_cursor; + + gzt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { @@ -1082,19 +1082,19 @@ static void GIZMO_WT_cage_2d(wmGizmoType *wt) {0, NULL, 0, NULL, NULL} }; static float unit_v2[2] = {1.0f, 1.0f}; - RNA_def_float_vector(wt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); - RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); + RNA_def_float_vector(gzt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); + RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); + RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options, + gzt->srna, "draw_options", rna_enum_draw_options, ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); - WM_gizmotype_target_property_def(wt, "matrix", PROP_FLOAT, 16); + WM_gizmotype_target_property_def(gzt, "matrix", PROP_FLOAT, 16); } void ED_gizmotypes_cage_2d(void) { - WM_gizmotype_append(GIZMO_WT_cage_2d); + WM_gizmotype_append(GIZMO_GT_cage_2d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index e266514855b..c3fb5a08cdb 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -67,7 +67,7 @@ #define GIZMO_MARGIN_OFFSET_SCALE 1.5f static void gizmo_calc_matrix_final_no_offset( - const wmGizmo *mpr, float orig_matrix_final_no_offset[4][4], bool use_space) + const wmGizmo *gz, float orig_matrix_final_no_offset[4][4], bool use_space) { float mat_identity[4][4]; struct WM_GizmoMatrixParams params = {NULL}; @@ -76,11 +76,11 @@ static void gizmo_calc_matrix_final_no_offset( params.matrix_basis = mat_identity; } params.matrix_offset = mat_identity; - WM_gizmo_calc_matrix_final_params(mpr, ¶ms, orig_matrix_final_no_offset); + WM_gizmo_calc_matrix_final_params(gz, ¶ms, orig_matrix_final_no_offset); } static void gizmo_calc_rect_view_scale( - const wmGizmo *mpr, const float dims[3], float scale[3]) + const wmGizmo *gz, const float dims[3], float scale[3]) { UNUSED_VARS(dims); @@ -88,10 +88,10 @@ static void gizmo_calc_rect_view_scale( float matrix_final_no_offset[4][4]; float x_axis[3], y_axis[3], z_axis[3]; - gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset, false); - mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); - mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); - mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, mpr->matrix_offset[2]); + gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset, false); + mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]); + mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]); + mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, gz->matrix_offset[2]); scale[0] = 1.0f / len_v3(x_axis); scale[1] = 1.0f / len_v3(y_axis); @@ -99,20 +99,20 @@ static void gizmo_calc_rect_view_scale( } static void gizmo_calc_rect_view_margin( - const wmGizmo *mpr, const float dims[3], float margin[3]) + const wmGizmo *gz, const float dims[3], float margin[3]) { float handle_size; - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { handle_size = 0.15f; } else { handle_size = GIZMO_RESIZER_SIZE; } // XXX, the scale isn't taking offset into account, we need to calculate scale per handle! - // handle_size *= mpr->scale_final; + // handle_size *= gz->scale_final; float scale_xyz[3]; - gizmo_calc_rect_view_scale(mpr, dims, scale_xyz); + gizmo_calc_rect_view_scale(gz, dims, scale_xyz); margin[0] = ((handle_size * scale_xyz[0])); margin[1] = ((handle_size * scale_xyz[1])); margin[2] = ((handle_size * scale_xyz[2])); @@ -281,26 +281,26 @@ static void cage3d_draw_circle_handles( static void gizmo_cage3d_draw_intern( RegionView3D *rv3d, - wmGizmo *mpr, const bool select, const bool highlight, const int select_id) + wmGizmo *gz, const bool select, const bool highlight, const int select_id) { - // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; + // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; float dims[3]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); float matrix_final[4][4]; - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + const int draw_style = RNA_enum_get(gz->ptr, "draw_style"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f}; - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); float margin[3]; - gizmo_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(gz, dims, margin); /* Handy for quick testing draw (if it's outside bounds). */ if (false) { @@ -338,14 +338,14 @@ static void gizmo_cage3d_draw_intern( } GPU_select_load_id(select_id | i); cage3d_draw_box_interaction( - mpr->color, i, size, margin); + gz->color, i, size, margin); } } if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { const int transform_part = ED_GIZMO_CAGE3D_PART_TRANSLATE; GPU_select_load_id(select_id | transform_part); cage3d_draw_box_interaction( - mpr->color, transform_part, size, margin); + gz->color, transform_part, size, margin); } } else { @@ -359,17 +359,17 @@ static void gizmo_cage3d_draw_intern( #endif if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) { /* corner gizmos */ - GPU_line_width(mpr->line_width + 3.0f); + GPU_line_width(gz->line_width + 3.0f); cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0}); /* corner gizmos */ float color[4]; - gizmo_color_get(mpr, highlight, color); - GPU_line_width(mpr->line_width); + gizmo_color_get(gz, highlight, color); + GPU_line_width(gz->line_width); cage3d_draw_box_corners(size_real, margin, color); bool show = false; - if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { + if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { /* Only show if we're drawing the center handle * otherwise the entire rectangle is the hotspot. */ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { @@ -382,20 +382,20 @@ static void gizmo_cage3d_draw_intern( if (show) { cage3d_draw_box_interaction( - mpr->color, mpr->highlight_part, size_real, margin); + gz->color, gz->highlight_part, size_real, margin); } } else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) { float color[4]; - gizmo_color_get(mpr, highlight, color); + gizmo_color_get(gz, highlight, color); GPU_line_smooth(true); GPU_polygon_smooth(true); GPU_blend(true); - GPU_line_width(mpr->line_width + 3.0f); + GPU_line_width(gz->line_width + 3.0f); cage3d_draw_circle_wire(size_real, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options); /* corner gizmos */ @@ -418,24 +418,24 @@ static void gizmo_cage3d_draw_intern( /** * For when we want to draw 3d cage in 3d views. */ -static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *mpr, int select_id) +static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id) { ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - gizmo_cage3d_draw_intern(rv3d, mpr, true, false, select_id); + gizmo_cage3d_draw_intern(rv3d, gz, true, false, select_id); } -static void gizmo_cage3d_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz) { ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; - gizmo_cage3d_draw_intern(rv3d, mpr, false, is_highlight, -1); + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + gizmo_cage3d_draw_intern(rv3d, gz, false, is_highlight, -1); } -static int gizmo_cage3d_get_cursor(wmGizmo *mpr) +static int gizmo_cage3d_get_cursor(wmGizmo *gz) { - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { return BC_NSEW_SCROLLCURSOR; } @@ -448,33 +448,33 @@ typedef struct RectTransformInteraction { float orig_matrix_final_no_offset[4][4]; } RectTransformInteraction; -static void gizmo_cage3d_setup(wmGizmo *mpr) +static void gizmo_cage3d_setup(wmGizmo *gz) { - mpr->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */ + gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */ WM_GIZMO_DRAW_NO_SCALE; } static int gizmo_cage3d_invoke( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); - copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); - gizmo_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset, true); + copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset); + gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset, true); if (gizmo_window_project_3d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) + C, gz, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) { zero_v3(data->orig_mouse); } - mpr->interaction_data = data; + gz->interaction_data = data; return OPERATOR_RUNNING_MODAL; } static int gizmo_cage3d_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { /* For transform logic to be managable we operate in -0.5..0.5 2D space, @@ -484,51 +484,51 @@ static int gizmo_cage3d_modal( * - The cursor offset are multiplied by 'dims'. * - Matrix translation is also multiplied by 'dims'. */ - RectTransformInteraction *data = mpr->interaction_data; + RectTransformInteraction *data = gz->interaction_data; float point_local[3]; float dims[3]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); { float matrix_back[4][4]; - copy_m4_m4(matrix_back, mpr->matrix_offset); - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(matrix_back, gz->matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); bool ok = gizmo_window_project_3d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, false, point_local); - copy_m4_m4(mpr->matrix_offset, matrix_back); + C, gz, (const float[2]){UNPACK2(event->mval)}, false, point_local); + copy_m4_m4(gz->matrix_offset, matrix_back); if (!ok) { return OPERATOR_RUNNING_MODAL; } } - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - wmGizmoProperty *mpr_prop; + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + wmGizmoProperty *gz_prop; - mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + gz_prop = WM_gizmo_target_property_find(gz, "matrix"); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]); } - if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { + if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { /* do this to prevent clamping from changing size */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); - mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); - mpr->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); + gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); + gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); + gz->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]); } - else if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_ROTATE) { + else if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_ROTATE) { /* TODO (if needed) */ } else { /* scale */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); float pivot[3]; bool constrain_axis[3] = {false}; if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { - gizmo_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); + gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis); } else { zero_v3(pivot); @@ -587,11 +587,11 @@ static int gizmo_cage3d_modal( transform_pivot_set_m4( matrix_scale, (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]}); - mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale); + mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale); } - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]); } /* tag the region for redraw */ @@ -601,11 +601,11 @@ static int gizmo_cage3d_modal( return OPERATOR_RUNNING_MODAL; } -static void gizmo_cage3d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) +static void gizmo_cage3d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop) { - if (STREQ(mpr_prop->type->idname, "matrix")) { - if (WM_gizmo_target_property_array_length(mpr, mpr_prop) == 16) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (STREQ(gz_prop->type->idname, "matrix")) { + if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]); } else { BLI_assert(0); @@ -616,22 +616,22 @@ static void gizmo_cage3d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop } } -static void gizmo_cage3d_exit(bContext *C, wmGizmo *mpr, const bool cancel) +static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel) { - RectTransformInteraction *data = mpr->interaction_data; + RectTransformInteraction *data = gz->interaction_data; if (!cancel) return; - wmGizmoProperty *mpr_prop; + wmGizmoProperty *gz_prop; /* reset properties */ - mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); + gz_prop = WM_gizmo_target_property_find(gz, "matrix"); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]); } - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); } @@ -640,22 +640,22 @@ static void gizmo_cage3d_exit(bContext *C, wmGizmo *mpr, const bool cancel) * * \{ */ -static void GIZMO_WT_cage_3d(wmGizmoType *wt) +static void GIZMO_GT_cage_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_cage_3d"; + gzt->idname = "GIZMO_GT_cage_3d"; /* api callbacks */ - wt->draw = gizmo_cage3d_draw; - wt->draw_select = gizmo_cage3d_draw_select; - wt->setup = gizmo_cage3d_setup; - wt->invoke = gizmo_cage3d_invoke; - wt->property_update = gizmo_cage3d_property_update; - wt->modal = gizmo_cage3d_modal; - wt->exit = gizmo_cage3d_exit; - wt->cursor_get = gizmo_cage3d_get_cursor; + gzt->draw = gizmo_cage3d_draw; + gzt->draw_select = gizmo_cage3d_draw_select; + gzt->setup = gizmo_cage3d_setup; + gzt->invoke = gizmo_cage3d_invoke; + gzt->property_update = gizmo_cage3d_property_update; + gzt->modal = gizmo_cage3d_modal; + gzt->exit = gizmo_cage3d_exit; + gzt->cursor_get = gizmo_cage3d_get_cursor; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { @@ -674,19 +674,19 @@ static void GIZMO_WT_cage_3d(wmGizmoType *wt) {0, NULL, 0, NULL, NULL} }; static float unit_v3[3] = {1.0f, 1.0f, 1.0f}; - RNA_def_float_vector(wt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); - RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); + RNA_def_float_vector(gzt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); + RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); + RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options, + gzt->srna, "draw_options", rna_enum_draw_options, ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); - WM_gizmotype_target_property_def(wt, "matrix", PROP_FLOAT, 16); + WM_gizmotype_target_property_def(gzt, "matrix", PROP_FLOAT, 16); } void ED_gizmotypes_cage_3d(void) { - WM_gizmotype_append(GIZMO_WT_cage_3d); + WM_gizmotype_append(GIZMO_GT_cage_3d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c index b93b87b1efa..b45f3d8a242 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -71,7 +71,7 @@ // #define USE_GIZMO_CUSTOM_DIAL static int gizmo_dial_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag); typedef struct DialInteraction { @@ -101,30 +101,30 @@ typedef struct DialInteraction { /** * We can't use this for the #wmGizmoType.matrix_basis_get callback, it conflicts with depth picking. */ -static void dial_calc_matrix(const wmGizmo *mpr, float mat[4][4]) +static void dial_calc_matrix(const wmGizmo *gz, float mat[4][4]) { float rot[3][3]; const float up[3] = {0.0f, 0.0f, 1.0f}; - rotation_between_vecs_to_mat3(rot, up, mpr->matrix_basis[2]); + rotation_between_vecs_to_mat3(rot, up, gz->matrix_basis[2]); copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], mpr->matrix_basis[3]); + copy_v3_v3(mat[3], gz->matrix_basis[3]); } /* -------------------------------------------------------------------- */ static void dial_geom_draw( - const wmGizmo *mpr, const float color[4], const bool select, + const wmGizmo *gz, const float color[4], const bool select, float axis_modal_mat[4][4], float clip_plane[4]) { #ifdef USE_GIZMO_CUSTOM_DIAL UNUSED_VARS(dial, col, axis_modal_mat, clip_plane); wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_dial, select); #else - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); const bool filled = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_FILL) != 0; - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -181,9 +181,9 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[ } static void dial_ghostarc_draw( - const wmGizmo *mpr, const float angle_ofs, const float angle_delta, const float color[4]) + const wmGizmo *gz, const float angle_ofs, const float angle_delta, const float color[4]) { - const float width_inner = DIAL_WIDTH - mpr->line_width * 0.5f / U.gizmo_size; + const float width_inner = DIAL_WIDTH - gz->line_width * 0.5f / U.gizmo_size; Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -196,24 +196,24 @@ static void dial_ghostarc_draw( static void dial_ghostarc_get_angles( struct Depsgraph *depsgraph, - const wmGizmo *mpr, + const wmGizmo *gz, const wmEvent *event, const ARegion *ar, const View3D *v3d, float mat[4][4], const float co_outer[3], float *r_start, float *r_delta) { - DialInteraction *inter = mpr->interaction_data; + DialInteraction *inter = gz->interaction_data; const RegionView3D *rv3d = ar->regiondata; const float mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; /* we might need to invert the direction of the angles */ float view_vec[3], axis_vec[3]; - ED_view3d_global_to_vector(rv3d, mpr->matrix_basis[3], view_vec); - normalize_v3_v3(axis_vec, mpr->matrix_basis[2]); + ED_view3d_global_to_vector(rv3d, gz->matrix_basis[3], view_vec); + normalize_v3_v3(axis_vec, gz->matrix_basis[2]); float proj_outer_rel[3]; mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer); - sub_v3_v3(proj_outer_rel, mpr->matrix_basis[3]); + sub_v3_v3(proj_outer_rel, gz->matrix_basis[3]); float proj_mval_new_rel[3]; float proj_mval_init_rel[3]; @@ -221,7 +221,7 @@ static void dial_ghostarc_get_angles( float ray_co[3], ray_no[3]; float ray_lambda; - plane_from_point_normal_v3(dial_plane, mpr->matrix_basis[3], axis_vec); + plane_from_point_normal_v3(dial_plane, gz->matrix_basis[3], axis_vec); if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, inter->init_mval, ray_co, ray_no, false) || !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) @@ -229,7 +229,7 @@ static void dial_ghostarc_get_angles( goto fail; } madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_init_rel, mpr->matrix_basis[3]); + sub_v3_v3(proj_mval_init_rel, gz->matrix_basis[3]); if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, mval, ray_co, ray_no, false) || !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) @@ -237,14 +237,14 @@ static void dial_ghostarc_get_angles( goto fail; } madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_new_rel, mpr->matrix_basis[3]); + sub_v3_v3(proj_mval_new_rel, gz->matrix_basis[3]); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); /* Start direction from mouse or set by user */ const float *proj_init_rel = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y) ? - mpr->matrix_basis[1] : proj_mval_init_rel; + gz->matrix_basis[1] : proj_mval_init_rel; /* return angles */ const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec)); @@ -274,7 +274,7 @@ fail: } static void dial_draw_intern( - const bContext *C, wmGizmo *mpr, + const bContext *C, wmGizmo *gz, const bool select, const bool highlight, float clip_plane[4]) { float matrix_basis_adjust[4][4]; @@ -283,12 +283,12 @@ static void dial_draw_intern( BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D); - gizmo_color_get(mpr, highlight, color); + gizmo_color_get(gz, highlight, color); - dial_calc_matrix(mpr, matrix_basis_adjust); + dial_calc_matrix(gz, matrix_basis_adjust); WM_gizmo_calc_matrix_final_params( - mpr, &((struct WM_GizmoMatrixParams) { + gz, &((struct WM_GizmoMatrixParams) { .matrix_basis = (void *)matrix_basis_adjust, }), matrix_final); @@ -296,17 +296,17 @@ static void dial_draw_intern( gpuMultMatrix(matrix_final); /* draw rotation indicator arc first */ - if ((mpr->flag & WM_GIZMO_DRAW_VALUE) && - (mpr->state & WM_GIZMO_STATE_MODAL)) + if ((gz->flag & WM_GIZMO_DRAW_VALUE) && + (gz->state & WM_GIZMO_STATE_MODAL)) { const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ - DialInteraction *inter = mpr->interaction_data; + DialInteraction *inter = gz->interaction_data; /* XXX, View3D rotation gizmo doesn't call modal. */ - if (!WM_gizmo_target_property_is_valid_any(mpr)) { + if (!WM_gizmo_target_property_is_valid_any(gz)) { wmWindow *win = CTX_wm_window(C); - gizmo_dial_modal((bContext *)C, mpr, win->eventstate, 0); + gizmo_dial_modal((bContext *)C, gz, win->eventstate, 0); } float angle_ofs = inter->output.angle_ofs; @@ -315,14 +315,14 @@ static void dial_draw_intern( /* draw! */ for (int i = 0; i < 2; i++) { GPU_polygon_smooth(false); - dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f}); + dial_ghostarc_draw(gz, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f}); GPU_polygon_smooth(true); dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */ dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */ if (i == 0) { - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); if ((draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) { break; } @@ -333,15 +333,15 @@ static void dial_draw_intern( } /* draw actual dial gizmo */ - dial_geom_draw(mpr, color, select, matrix_basis_adjust, clip_plane); + dial_geom_draw(gz, color, select, matrix_basis_adjust, clip_plane); gpuPopMatrix(); } -static void gizmo_dial_draw_select(const bContext *C, wmGizmo *mpr, int select_id) +static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id) { float clip_plane_buf[4]; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); float *clip_plane = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL; /* enable clipping if needed */ @@ -350,25 +350,25 @@ static void gizmo_dial_draw_select(const bContext *C, wmGizmo *mpr, int select_i RegionView3D *rv3d = ar->regiondata; copy_v3_v3(clip_plane, rv3d->viewinv[2]); - clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]); - clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final; + clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]); + clip_plane[3] += DIAL_CLIP_BIAS * gz->scale_final; glEnable(GL_CLIP_DISTANCE0); } GPU_select_load_id(select_id); - dial_draw_intern(C, mpr, true, false, clip_plane); + dial_draw_intern(C, gz, true, false, clip_plane); if (clip_plane) { glDisable(GL_CLIP_DISTANCE0); } } -static void gizmo_dial_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_dial_draw(const bContext *C, wmGizmo *gz) { - const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL; + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float clip_plane_buf[4]; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); float *clip_plane = (!is_modal && (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL; /* enable clipping if needed */ @@ -377,14 +377,14 @@ static void gizmo_dial_draw(const bContext *C, wmGizmo *mpr) RegionView3D *rv3d = ar->regiondata; copy_v3_v3(clip_plane, rv3d->viewinv[2]); - clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]); - clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final; + clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]); + clip_plane[3] += DIAL_CLIP_BIAS * gz->scale_final; glEnable(GL_CLIP_DISTANCE0); } GPU_blend(true); - dial_draw_intern(C, mpr, false, is_highlight, clip_plane); + dial_draw_intern(C, gz, false, is_highlight, clip_plane); GPU_blend(false); if (clip_plane) { @@ -393,7 +393,7 @@ static void gizmo_dial_draw(const bContext *C, wmGizmo *mpr) } static int gizmo_dial_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ @@ -401,48 +401,48 @@ static int gizmo_dial_modal( float matrix[4][4]; - dial_calc_matrix(mpr, matrix); + dial_calc_matrix(gz, matrix); dial_ghostarc_get_angles( CTX_data_depsgraph(C), - mpr, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta); + gz, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta); - DialInteraction *inter = mpr->interaction_data; + DialInteraction *inter = gz->interaction_data; inter->output.angle_delta = angle_delta; inter->output.angle_ofs = angle_ofs; /* set the property for the operator and call its modal function */ - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - WM_gizmo_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_value_set(C, gz, gz_prop, inter->init_prop_angle + angle_delta); } return OPERATOR_RUNNING_MODAL; } -static void gizmo_dial_setup(wmGizmo *mpr) +static void gizmo_dial_setup(wmGizmo *gz) { const float dir_default[3] = {0.0f, 0.0f, 1.0f}; /* defaults */ - copy_v3_v3(mpr->matrix_basis[2], dir_default); + copy_v3_v3(gz->matrix_basis[2], dir_default); } static int gizmo_dial_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__); inter->init_mval[0] = event->mval[0]; inter->init_mval[1] = event->mval[1]; - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - inter->init_prop_angle = WM_gizmo_target_property_value_get(mpr, mpr_prop); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + inter->init_prop_angle = WM_gizmo_target_property_value_get(gz, gz_prop); } - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } @@ -452,19 +452,19 @@ static int gizmo_dial_invoke( * * \{ */ -static void GIZMO_WT_dial_3d(wmGizmoType *wt) +static void GIZMO_GT_dial_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_dial_3d"; + gzt->idname = "GIZMO_GT_dial_3d"; /* api callbacks */ - wt->draw = gizmo_dial_draw; - wt->draw_select = gizmo_dial_draw_select; - wt->setup = gizmo_dial_setup; - wt->invoke = gizmo_dial_invoke; - wt->modal = gizmo_dial_modal; + gzt->draw = gizmo_dial_draw; + gzt->draw_select = gizmo_dial_draw_select; + gzt->setup = gizmo_dial_setup; + gzt->invoke = gizmo_dial_invoke; + gzt->modal = gizmo_dial_modal; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_options[] = { @@ -474,14 +474,14 @@ static void GIZMO_WT_dial_3d(wmGizmoType *wt) {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""}, {0, NULL, 0, NULL, NULL} }; - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 1); + WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1); } void ED_gizmotypes_dial_3d(void) { - WM_gizmotype_append(GIZMO_WT_dial_3d); + WM_gizmotype_append(GIZMO_GT_dial_3d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c index 2a89c8cc4ab..c6d11347e9f 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c @@ -68,16 +68,16 @@ typedef struct GrabGizmo3D { float prop_co[3]; } GrabGizmo3D; -static void gizmo_grab_matrix_basis_get(const wmGizmo *mpr, float r_matrix[4][4]) +static void gizmo_grab_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4]) { - GrabGizmo3D *grab = (GrabGizmo3D *)mpr; + GrabGizmo3D *grab = (GrabGizmo3D *)gz; copy_m4_m4(r_matrix, grab->gizmo.matrix_basis); add_v3_v3(r_matrix[3], grab->prop_co); } static int gizmo_grab_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag); typedef struct GrabInteraction { @@ -94,16 +94,16 @@ typedef struct GrabInteraction { /* -------------------------------------------------------------------- */ static void grab_geom_draw( - const wmGizmo *mpr, const float color[4], const bool select, const int draw_options) + const wmGizmo *gz, const float color[4], const bool select, const int draw_options) { #ifdef USE_GIZMO_CUSTOM_DIAL UNUSED_VARS(grab3d, col, axis_modal_mat); wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_grab3d, select); #else - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); + const int draw_style = RNA_enum_get(gz->ptr, "draw_style"); const bool filled = (draw_options & ED_GIZMO_GRAB_DRAW_FLAG_FILL) != 0; - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -140,10 +140,10 @@ static void grab_geom_draw( } static void grab3d_get_translate( - const wmGizmo *mpr, const wmEvent *event, const ARegion *ar, + const wmGizmo *gz, const wmEvent *event, const ARegion *ar, float co_delta[3]) { - GrabInteraction *inter = mpr->interaction_data; + GrabInteraction *inter = gz->interaction_data; const float mval_delta[2] = { event->mval[0] - inter->init_mval[0], event->mval[1] - inter->init_mval[1], @@ -151,30 +151,30 @@ static void grab3d_get_translate( RegionView3D *rv3d = ar->regiondata; float co_ref[3]; - mul_v3_mat3_m4v3(co_ref, mpr->matrix_space, inter->init_prop_co); + mul_v3_mat3_m4v3(co_ref, gz->matrix_space, inter->init_prop_co); const float zfac = ED_view3d_calc_zfac(rv3d, co_ref, NULL); ED_view3d_win_to_delta(ar, mval_delta, co_delta, zfac); float matrix_space_inv[3][3]; - copy_m3_m4(matrix_space_inv, mpr->matrix_space); + copy_m3_m4(matrix_space_inv, gz->matrix_space); invert_m3(matrix_space_inv); mul_m3_v3(matrix_space_inv, co_delta); } static void grab3d_draw_intern( - const bContext *C, wmGizmo *mpr, + const bContext *C, wmGizmo *gz, const bool select, const bool highlight) { - GrabInteraction *inter = mpr->interaction_data; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + GrabInteraction *inter = gz->interaction_data; + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); const bool align_view = (draw_options & ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0; float color[4]; float matrix_final[4][4]; float matrix_align[4][4]; - gizmo_color_get(mpr, highlight, color); - WM_gizmo_calc_matrix_final(mpr, matrix_final); + gizmo_color_get(gz, highlight, color); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); @@ -190,11 +190,11 @@ static void grab3d_draw_intern( } GPU_blend(true); - grab_geom_draw(mpr, color, select, draw_options); + grab_geom_draw(gz, color, select, draw_options); GPU_blend(false); gpuPopMatrix(); - if (mpr->interaction_data) { + if (gz->interaction_data) { gpuPushMatrix(); gpuMultMatrix(inter->init_matrix_final); @@ -203,48 +203,48 @@ static void grab3d_draw_intern( } GPU_blend(true); - grab_geom_draw(mpr, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); + grab_geom_draw(gz, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); GPU_blend(false); gpuPopMatrix(); } } -static void gizmo_grab_draw_select(const bContext *C, wmGizmo *mpr, int select_id) +static void gizmo_grab_draw_select(const bContext *C, wmGizmo *gz, int select_id) { GPU_select_load_id(select_id); - grab3d_draw_intern(C, mpr, true, false); + grab3d_draw_intern(C, gz, true, false); } -static void gizmo_grab_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_grab_draw(const bContext *C, wmGizmo *gz) { - const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL; + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; (void)is_modal; GPU_blend(true); - grab3d_draw_intern(C, mpr, false, is_highlight); + grab3d_draw_intern(C, gz, false, is_highlight); GPU_blend(false); } static int gizmo_grab_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { - GrabGizmo3D *grab = (GrabGizmo3D *)mpr; - GrabInteraction *inter = mpr->interaction_data; + GrabGizmo3D *grab = (GrabGizmo3D *)gz; + GrabInteraction *inter = gz->interaction_data; ARegion *ar = CTX_wm_region(C); float prop_delta[3]; if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) { - grab3d_get_translate(mpr, event, ar, prop_delta); + grab3d_get_translate(gz, event, ar, prop_delta); } else { float mval_proj_init[2], mval_proj_curr[2]; if ((gizmo_window_project_2d( - C, mpr, inter->init_mval, 2, false, mval_proj_init) == false) || + C, gz, inter->init_mval, 2, false, mval_proj_init) == false) || (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) { return OPERATOR_RUNNING_MODAL; } @@ -254,9 +254,9 @@ static int gizmo_grab_modal( add_v3_v3v3(grab->prop_co, inter->init_prop_co, prop_delta); /* set the property for the operator and call its modal function */ - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, grab->prop_co); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, grab->prop_co); } else { zero_v3(grab->prop_co); @@ -268,7 +268,7 @@ static int gizmo_grab_modal( } static int gizmo_grab_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__); @@ -278,32 +278,32 @@ static int gizmo_grab_invoke( #if 0 copy_v3_v3(inter->init_prop_co, grab->prop_co); #else - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, inter->init_prop_co); } #endif - WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); + WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final); - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } static int gizmo_grab_test_select( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { float point_local[2]; if (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; } - /* The 'mpr->scale_final' is already applied when projecting. */ + /* The 'gz->scale_final' is already applied when projecting. */ if (len_squared_v2(point_local) < 1.0f) { return 0; } @@ -311,18 +311,18 @@ static int gizmo_grab_test_select( return -1; } -static void gizmo_grab_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) +static void gizmo_grab_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop) { - GrabGizmo3D *grab = (GrabGizmo3D *)mpr; - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, grab->prop_co); + GrabGizmo3D *grab = (GrabGizmo3D *)gz; + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, grab->prop_co); } else { zero_v3(grab->prop_co); } } -static int gizmo_grab_cursor_get(wmGizmo *UNUSED(mpr)) +static int gizmo_grab_cursor_get(wmGizmo *UNUSED(gz)) { return BC_NSEW_SCROLLCURSOR; } @@ -332,22 +332,22 @@ static int gizmo_grab_cursor_get(wmGizmo *UNUSED(mpr)) * * \{ */ -static void GIZMO_WT_grab_3d(wmGizmoType *wt) +static void GIZMO_GT_grab_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_grab_3d"; + gzt->idname = "GIZMO_GT_grab_3d"; /* api callbacks */ - wt->draw = gizmo_grab_draw; - wt->draw_select = gizmo_grab_draw_select; - wt->test_select = gizmo_grab_test_select; - wt->matrix_basis_get = gizmo_grab_matrix_basis_get; - wt->invoke = gizmo_grab_invoke; - wt->property_update = gizmo_grab_property_update; - wt->modal = gizmo_grab_modal; - wt->cursor_get = gizmo_grab_cursor_get; + gzt->draw = gizmo_grab_draw; + gzt->draw_select = gizmo_grab_draw_select; + gzt->test_select = gizmo_grab_test_select; + gzt->matrix_basis_get = gizmo_grab_matrix_basis_get; + gzt->invoke = gizmo_grab_invoke; + gzt->property_update = gizmo_grab_property_update; + gzt->modal = gizmo_grab_modal; + gzt->cursor_get = gizmo_grab_cursor_get; - wt->struct_size = sizeof(GrabGizmo3D); + gzt->struct_size = sizeof(GrabGizmo3D); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { @@ -361,15 +361,15 @@ static void GIZMO_WT_grab_3d(wmGizmoType *wt) {0, NULL, 0, NULL, NULL} }; - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_GRAB_STYLE_RING_2D, "Draw Style", ""); - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_GRAB_STYLE_RING_2D, "Draw Style", ""); + RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 3); + WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 3); } void ED_gizmotypes_grab_3d(void) { - WM_gizmotype_append(GIZMO_WT_grab_3d); + WM_gizmotype_append(GIZMO_GT_grab_3d); } /** \} */ // Grab Gizmo API diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c index ff02517dafa..be2bf7d2c56 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c @@ -86,18 +86,18 @@ static void gizmo_primitive_draw_geom( } static void gizmo_primitive_draw_intern( - wmGizmo *mpr, const bool UNUSED(select), + wmGizmo *gz, const bool UNUSED(select), const bool highlight) { float color_inner[4], color_outer[4]; float matrix_final[4][4]; - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); + const int draw_style = RNA_enum_get(gz->ptr, "draw_style"); - gizmo_color_get(mpr, highlight, color_outer); + gizmo_color_get(gz, highlight, color_outer); copy_v4_v4(color_inner, color_outer); color_inner[3] *= 0.5f; - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); @@ -108,8 +108,8 @@ static void gizmo_primitive_draw_intern( gpuPopMatrix(); - if (mpr->interaction_data) { - GizmoInteraction *inter = mpr->interaction_data; + if (gz->interaction_data) { + GizmoInteraction *inter = gz->interaction_data; copy_v4_fl(color_inner, 0.5f); copy_v3_fl(color_outer, 0.5f); @@ -127,33 +127,33 @@ static void gizmo_primitive_draw_intern( } static void gizmo_primitive_draw_select( - const bContext *UNUSED(C), wmGizmo *mpr, + const bContext *UNUSED(C), wmGizmo *gz, int select_id) { GPU_select_load_id(select_id); - gizmo_primitive_draw_intern(mpr, true, false); + gizmo_primitive_draw_intern(gz, true, false); } -static void gizmo_primitive_draw(const bContext *UNUSED(C), wmGizmo *mpr) +static void gizmo_primitive_draw(const bContext *UNUSED(C), wmGizmo *gz) { gizmo_primitive_draw_intern( - mpr, false, - (mpr->state & WM_GIZMO_STATE_HIGHLIGHT)); + gz, false, + (gz->state & WM_GIZMO_STATE_HIGHLIGHT)); } -static void gizmo_primitive_setup(wmGizmo *mpr) +static void gizmo_primitive_setup(wmGizmo *gz) { - mpr->flag |= WM_GIZMO_DRAW_MODAL; + gz->flag |= WM_GIZMO_DRAW_MODAL; } static int gizmo_primitive_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *UNUSED(event)) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *UNUSED(event)) { GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); - WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); + WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final); - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } @@ -163,29 +163,29 @@ static int gizmo_primitive_invoke( * * \{ */ -static void GIZMO_WT_primitive_3d(wmGizmoType *wt) +static void GIZMO_GT_primitive_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_primitive_3d"; + gzt->idname = "GIZMO_GT_primitive_3d"; /* api callbacks */ - wt->draw = gizmo_primitive_draw; - wt->draw_select = gizmo_primitive_draw_select; - wt->setup = gizmo_primitive_setup; - wt->invoke = gizmo_primitive_invoke; + gzt->draw = gizmo_primitive_draw; + gzt->draw_select = gizmo_primitive_draw_select; + gzt->setup = gizmo_primitive_setup; + gzt->invoke = gizmo_primitive_invoke; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); static EnumPropertyItem rna_enum_draw_style[] = { {ED_GIZMO_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""}, {0, NULL, 0, NULL, NULL} }; - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); + RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); } void ED_gizmotypes_primitive_3d(void) { - WM_gizmotype_append(GIZMO_WT_primitive_3d); + WM_gizmotype_append(GIZMO_GT_primitive_3d); } /** \} */ diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h index 39a58929b7c..2bf3488a8d3 100644 --- a/source/blender/editors/include/ED_gizmo_library.h +++ b/source/blender/editors/include/ED_gizmo_library.h @@ -53,13 +53,13 @@ struct wmGizmoGroup; /* gizmo_library_presets.c */ void ED_gizmo_draw_preset_box( - const struct wmGizmo *mpr, float mat[4][4], int select_id); + const struct wmGizmo *gz, float mat[4][4], int select_id); void ED_gizmo_draw_preset_arrow( - const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id); + const struct wmGizmo *gz, float mat[4][4], int axis, int select_id); void ED_gizmo_draw_preset_circle( - const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id); + const struct wmGizmo *gz, float mat[4][4], int axis, int select_id); void ED_gizmo_draw_preset_facemap( - const struct bContext *C, const struct wmGizmo *mpr, struct Scene *scene, + const struct bContext *C, const struct wmGizmo *gz, struct Scene *scene, struct Object *ob, const int facemap, int select_id); @@ -87,8 +87,8 @@ enum { ED_GIZMO_ARROW_DRAW_FLAG_STEM = (1 << 0), }; -void ED_gizmo_arrow3d_set_ui_range(struct wmGizmo *mpr, const float min, const float max); -void ED_gizmo_arrow3d_set_range_fac(struct wmGizmo *mpr, const float range_fac); +void ED_gizmo_arrow3d_set_ui_range(struct wmGizmo *gz, const float min, const float max); +void ED_gizmo_arrow3d_set_range_fac(struct wmGizmo *gz, const float range_fac); /* -------------------------------------------------------------------- */ /* 2D Arrow Gizmo */ diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 80dea103f8c..cb04ac40acd 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -159,13 +159,13 @@ void Transform_Properties(struct wmOperatorType *ot, int flags); /* transform gizmos */ -void TRANSFORM_WGT_gizmo(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_xform_cage(struct wmGizmoGroupType *wgt); +void TRANSFORM_GGT_gizmo(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_xform_cage(struct wmGizmoGroupType *gzgt); -bool ED_widgetgroup_gizmo2d_poll(const struct bContext *C, struct wmGizmoGroupType *wgt); -void ED_widgetgroup_gizmo2d_setup(const struct bContext *C, struct wmGizmoGroup *mgroup); -void ED_widgetgroup_gizmo2d_refresh(const struct bContext *C, struct wmGizmoGroup *mgroup); -void ED_widgetgroup_gizmo2d_draw_prepare(const struct bContext *C, struct wmGizmoGroup *mgroup); +bool ED_widgetgroup_gizmo2d_poll(const struct bContext *C, struct wmGizmoGroupType *gzgt); +void ED_widgetgroup_gizmo2d_setup(const struct bContext *C, struct wmGizmoGroup *gzgroup); +void ED_widgetgroup_gizmo2d_refresh(const struct bContext *C, struct wmGizmoGroup *gzgroup); +void ED_widgetgroup_gizmo2d_draw_prepare(const struct bContext *C, struct wmGizmoGroup *gzgroup); /* Snapping */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 723dde640e4..07259b91b86 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1265,7 +1265,7 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p); /* ui_interface_region_tooltip.c */ struct ARegion *UI_tooltip_create_from_button(struct bContext *C, struct ARegion *butregion, uiBut *but); -struct ARegion *UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *mpr); +struct ARegion *UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *gz); void UI_tooltip_free(struct bContext *C, struct bScreen *sc, struct ARegion *ar); /* How long before a tool-tip shows. */ diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index fae547d460c..97f501b7448 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -615,7 +615,7 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) } } -static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *mpr) +static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz) { uiTooltipData *data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); @@ -623,23 +623,23 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *mpr) /* Operator Actions */ { - bool use_drag = mpr->drag_part != -1 && mpr->highlight_part != mpr->drag_part; + bool use_drag = gz->drag_part != -1 && gz->highlight_part != gz->drag_part; const struct { int part; const char *prefix; } mpop_actions[] = { { - .part = mpr->highlight_part, + .part = gz->highlight_part, .prefix = use_drag ? TIP_("Click") : NULL, }, { - .part = use_drag ? mpr->drag_part : -1, + .part = use_drag ? gz->drag_part : -1, .prefix = use_drag ? TIP_("Drag") : NULL, }, }; for (int i = 0; i < ARRAY_SIZE(mpop_actions); i++) { - wmGizmoOpElem *mpop = (mpop_actions[i].part != -1) ? WM_gizmo_operator_get(mpr, mpop_actions[i].part) : NULL; + wmGizmoOpElem *mpop = (mpop_actions[i].part != -1) ? WM_gizmo_operator_get(gz, mpop_actions[i].part) : NULL; if (mpop != NULL) { /* Description */ const char *info = RNA_struct_ui_description(mpop->type->srna); @@ -691,13 +691,13 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *mpr) } /* Property Actions */ - if (mpr->type->target_property_defs_len) { - wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { + if (gz->type->target_property_defs_len) { + wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz); + for (int i = 0; i < gz->type->target_property_defs_len; i++) { /* TODO(campbell): function callback descriptions. */ - wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; - if (mpr_prop->prop != NULL) { - const char *info = RNA_property_ui_description(mpr_prop->prop); + wmGizmoProperty *gz_prop = &gz_prop_array[i]; + if (gz_prop->prop != NULL) { + const char *info = RNA_property_ui_description(gz_prop->prop); if (info && info[0]) { uiTooltipField *field = text_field_add( data, &(uiTooltipFormat){ @@ -934,13 +934,13 @@ ARegion *UI_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *b return ui_tooltip_create_with_data(C, data, init_position, aspect); } -ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *mpr) +ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *gz) { wmWindow *win = CTX_wm_window(C); const float aspect = 1.0f; float init_position[2]; - uiTooltipData *data = ui_tooltip_data_from_gizmo(C, mpr); + uiTooltipData *data = ui_tooltip_data_from_gizmo(C, gz); if (data == NULL) { return NULL; } diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.c index be5c01e08df..6fa0eb33b89 100644 --- a/source/blender/editors/mesh/editmesh_add_gizmo.c +++ b/source/blender/editors/mesh/editmesh_add_gizmo.c @@ -160,14 +160,14 @@ static void gizmo_mesh_placement_update_from_op(GizmoPlacementGroup *man) /* translate callbacks */ static void gizmo_placement_prop_matrix_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoPlacementGroup *man = mpr->parent_mgroup->customdata; + GizmoPlacementGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 16); + UNUSED_VARS_NDEBUG(gz_prop); if (value_p != man->cage->matrix_offset) { mul_m4_m4m4(value_p, man->cage->matrix_basis, man->cage->matrix_offset); @@ -176,14 +176,14 @@ static void gizmo_placement_prop_matrix_get( } static void gizmo_placement_prop_matrix_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value) { - GizmoPlacementGroup *man = mpr->parent_mgroup->customdata; + GizmoPlacementGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; - BLI_assert(mpr_prop->type->array_length == 16); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 16); + UNUSED_VARS_NDEBUG(gz_prop); float mat[4][4]; mul_m4_m4m4(mat, man->cage->matrix_basis, value); @@ -197,38 +197,38 @@ static void gizmo_placement_prop_matrix_set( gizmo_placement_exec(man); } -static bool gizmo_mesh_placement_poll(const bContext *C, wmGizmoGroupType *wgt) +static bool gizmo_mesh_placement_poll(const bContext *C, wmGizmoGroupType *gzgt) { wmOperator *op = WM_operator_last_redo(C); if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_gizmo")) { - WM_gizmo_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); return false; } return true; } static void gizmo_mesh_placement_modal_from_setup( - const bContext *C, wmGizmoGroup *mgroup) + const bContext *C, wmGizmoGroup *gzgroup) { - GizmoPlacementGroup *man = mgroup->customdata; + GizmoPlacementGroup *man = gzgroup->customdata; /* Initial size. */ { - wmGizmo *mpr = man->cage; - zero_m4(mpr->matrix_offset); - - /* TODO: support zero scaled matrix in 'GIZMO_WT_cage_3d'. */ - mpr->matrix_offset[0][0] = 0.01; - mpr->matrix_offset[1][1] = 0.01; - mpr->matrix_offset[2][2] = 0.01; - mpr->matrix_offset[3][3] = 1.0f; + wmGizmo *gz = man->cage; + zero_m4(gz->matrix_offset); + + /* TODO: support zero scaled matrix in 'GIZMO_GT_cage_3d'. */ + gz->matrix_offset[0][0] = 0.01; + gz->matrix_offset[1][1] = 0.01; + gz->matrix_offset[2][2] = 0.01; + gz->matrix_offset[3][3] = 1.0f; } /* Start off dragging. */ { wmWindow *win = CTX_wm_window(C); ARegion *ar = CTX_wm_region(C); - wmGizmo *mpr = man->cage; + wmGizmo *gz = man->cage; { float mat3[3][3]; @@ -239,19 +239,19 @@ static void gizmo_mesh_placement_modal_from_setup( win->eventstate->y - ar->winrct.ymin, }, location, mat3); - copy_m4_m3(mpr->matrix_basis, mat3); - copy_v3_v3(mpr->matrix_basis[3], location); + copy_m4_m3(gz->matrix_basis, mat3); + copy_v3_v3(gz->matrix_basis[3], location); } if (1) { - wmGizmoMap *mmap = mgroup->parent_mmap; + wmGizmoMap *gzmap = gzgroup->parent_gzmap; WM_gizmo_modal_set_from_setup( - mmap, (bContext *)C, man->cage, ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, win->eventstate); + gzmap, (bContext *)C, man->cage, ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z, win->eventstate); } } } -static void gizmo_mesh_placement_setup(const bContext *C, wmGizmoGroup *mgroup) +static void gizmo_mesh_placement_setup(const bContext *C, wmGizmoGroup *gzgroup) { wmOperator *op = WM_operator_last_redo(C); @@ -260,11 +260,11 @@ static void gizmo_mesh_placement_setup(const bContext *C, wmGizmoGroup *mgroup) } struct GizmoPlacementGroup *man = MEM_callocN(sizeof(GizmoPlacementGroup), __func__); - mgroup->customdata = man; + gzgroup->customdata = man; - const wmGizmoType *wt_cage = WM_gizmotype_find("GIZMO_WT_cage_3d", true); + const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_3d", true); - man->cage = WM_gizmo_new_ptr(wt_cage, mgroup, NULL); + man->cage = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->cage->color); @@ -293,32 +293,32 @@ static void gizmo_mesh_placement_setup(const bContext *C, wmGizmoGroup *mgroup) }); } - gizmo_mesh_placement_modal_from_setup(C, mgroup); + gizmo_mesh_placement_modal_from_setup(C, gzgroup); } static void gizmo_mesh_placement_draw_prepare( - const bContext *UNUSED(C), wmGizmoGroup *mgroup) + const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { - GizmoPlacementGroup *man = mgroup->customdata; + GizmoPlacementGroup *man = gzgroup->customdata; if (man->data.op->next) { man->data.op = WM_operator_last_redo((bContext *)man->data.context); } gizmo_mesh_placement_update_from_op(man); } -static void MESH_WGT_add_bounds(struct wmGizmoGroupType *wgt) +static void MESH_GGT_add_bounds(struct wmGizmoGroupType *gzgt) { - wgt->name = "Mesh Add Bounds"; - wgt->idname = "MESH_WGT_add_bounds"; + gzgt->name = "Mesh Add Bounds"; + gzgt->idname = "MESH_GGT_add_bounds"; - wgt->flag = WM_GIZMOGROUPTYPE_3D; + gzgt->flag = WM_GIZMOGROUPTYPE_3D; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = gizmo_mesh_placement_poll; - wgt->setup = gizmo_mesh_placement_setup; - wgt->draw_prepare = gizmo_mesh_placement_draw_prepare; + gzgt->poll = gizmo_mesh_placement_poll; + gzgt->setup = gizmo_mesh_placement_setup; + gzgt->draw_prepare = gizmo_mesh_placement_draw_prepare; } /** \} */ @@ -379,18 +379,18 @@ static int add_primitive_cube_gizmo_invoke(bContext *C, wmOperator *op, const wm int ret = add_primitive_cube_gizmo_exec(C, op); if (ret & OPERATOR_FINISHED) { /* Setup gizmos */ - if (v3d && ((v3d->mpr_flag & V3D_GIZMO_HIDE) == 0)) { + if (v3d && ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0)) { ARegion *ar = CTX_wm_region(C); - wmGizmoMap *mmap = ar->gizmo_map; - wmGizmoGroupType *wgt = WM_gizmogrouptype_find("MESH_WGT_add_bounds", false); - wmGizmoGroup *mgroup = WM_gizmomap_group_find_ptr(mmap, wgt); - if (mgroup != NULL) { - GizmoPlacementGroup *man = mgroup->customdata; + wmGizmoMap *gzmap = ar->gizmo_map; + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find("MESH_GGT_add_bounds", false); + wmGizmoGroup *gzgroup = WM_gizmomap_group_find_ptr(gzmap, gzgt); + if (gzgroup != NULL) { + GizmoPlacementGroup *man = gzgroup->customdata; man->data.op = op; - gizmo_mesh_placement_modal_from_setup(C, mgroup); + gizmo_mesh_placement_modal_from_setup(C, gzgroup); } else { - WM_gizmo_group_type_ensure_ptr(wgt); + WM_gizmo_group_type_ensure_ptr(gzgt); } } } @@ -420,7 +420,7 @@ void MESH_OT_primitive_cube_add_gizmo(wmOperatorType *ot) PropertyRNA *prop = RNA_def_float_matrix(ot->srna, "matrix", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - WM_gizmogrouptype_append(MESH_WGT_add_bounds); + WM_gizmogrouptype_append(MESH_GGT_add_bounds); } /** \} */ diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index b73ce410626..66e40df2527 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -95,7 +95,7 @@ typedef struct { /* modal only */ float mcenter[2]; void *draw_handle_pixel; - short mpr_flag; + short gizmo_flag; short value_mode; /* Which value does mouse movement and numeric input affect? */ float segments; /* Segments as float so smooth mouse pan works in small increments */ } BevelData; @@ -201,8 +201,8 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) G.moving = G_TRANSFORM_EDIT; if (v3d) { - opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = V3D_GIZMO_HIDE; + opdata->gizmo_flag = v3d->gizmo_flag; + v3d->gizmo_flag = V3D_GIZMO_HIDE; } } @@ -284,7 +284,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op) } ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel); if (v3d) { - v3d->mpr_flag = opdata->mpr_flag; + v3d->gizmo_flag = opdata->gizmo_flag; } G.moving = 0; } diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index a9e11b7b411..9416d889a3b 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -70,7 +70,7 @@ typedef struct { /* modal only */ BMBackup mesh_backup; bool is_first; - short mpr_flag; + short gizmo_flag; } BisectData; static bool mesh_bisect_interactive_calc( @@ -156,8 +156,8 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* misc other vars */ G.moving = G_TRANSFORM_EDIT; - opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = V3D_GIZMO_HIDE; + opdata->gizmo_flag = v3d->gizmo_flag; + v3d->gizmo_flag = V3D_GIZMO_HIDE; /* initialize modal callout */ ED_workspace_status_text(C, IFACE_("LMB: Click and drag to draw cut line")); @@ -169,7 +169,7 @@ static void edbm_bisect_exit(bContext *C, BisectData *opdata) { View3D *v3d = CTX_wm_view3d(C); EDBM_redo_state_free(&opdata->mesh_backup, NULL, false); - v3d->mpr_flag = opdata->mpr_flag; + v3d->gizmo_flag = opdata->gizmo_flag; G.moving = 0; } @@ -199,8 +199,8 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Setup gizmos */ { View3D *v3d = CTX_wm_view3d(C); - if (v3d && (v3d->mpr_flag & V3D_GIZMO_HIDE) == 0) { - WM_gizmo_group_type_ensure("MESH_WGT_bisect"); + if (v3d && (v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) { + WM_gizmo_group_type_ensure("MESH_GGT_bisect"); } } #endif @@ -334,7 +334,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) } #ifdef USE_GIZMO -static void MESH_WGT_bisect(struct wmGizmoGroupType *wgt); +static void MESH_GGT_bisect(struct wmGizmoGroupType *gzgt); #endif void MESH_OT_bisect(struct wmOperatorType *ot) @@ -374,7 +374,7 @@ void MESH_OT_bisect(struct wmOperatorType *ot) WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); #ifdef USE_GIZMO - WM_gizmogrouptype_append(MESH_WGT_bisect); + WM_gizmogrouptype_append(MESH_GGT_bisect); #endif } @@ -459,40 +459,40 @@ static void gizmo_mesh_bisect_update_from_op(GizmoGroup *man) /* depth callbacks */ static void gizmo_bisect_prop_depth_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); float plane_co[3], plane_no[3]; RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co); RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); - value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix_basis[3]); + value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, gz->matrix_basis[3]); } static void gizmo_bisect_prop_depth_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; const float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); float plane_co[3], plane[4]; RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co); RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane); normalize_v3(plane); - plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix_basis[3]); + plane[3] = -value[0] - dot_v3v3(plane, gz->matrix_basis[3]); /* Keep our location, may be offset simply to be inside the viewport. */ closest_to_plane_normalized_v3(plane_co, plane, plane_co); @@ -504,27 +504,27 @@ static void gizmo_bisect_prop_depth_set( /* translate callbacks */ static void gizmo_bisect_prop_translate_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; - BLI_assert(mpr_prop->type->array_length == 3); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 3); + UNUSED_VARS_NDEBUG(gz_prop); RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, value_p); } static void gizmo_bisect_prop_translate_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; - BLI_assert(mpr_prop->type->array_length == 3); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 3); + UNUSED_VARS_NDEBUG(gz_prop); RNA_property_float_set_array(op->ptr, man->data.prop_plane_co, value_p); @@ -533,15 +533,15 @@ static void gizmo_bisect_prop_translate_set( /* angle callbacks */ static void gizmo_bisect_prop_angle_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); float plane_no[4]; RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); @@ -560,15 +560,15 @@ static void gizmo_bisect_prop_angle_get( } static void gizmo_bisect_prop_angle_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *man = mpr->parent_mgroup->customdata; + GizmoGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; const float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); float plane_no[4]; RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); @@ -593,17 +593,17 @@ static void gizmo_bisect_prop_angle_set( } } -static bool gizmo_mesh_bisect_poll(const bContext *C, wmGizmoGroupType *wgt) +static bool gizmo_mesh_bisect_poll(const bContext *C, wmGizmoGroupType *gzgt) { wmOperator *op = WM_operator_last_redo(C); if (op == NULL || !STREQ(op->type->idname, "MESH_OT_bisect")) { - WM_gizmo_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); return false; } return true; } -static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *mgroup) +static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *gzgroup) { wmOperator *op = WM_operator_last_redo(C); @@ -612,15 +612,15 @@ static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *mgroup) } struct GizmoGroup *man = MEM_callocN(sizeof(GizmoGroup), __func__); - mgroup->customdata = man; + gzgroup->customdata = man; - const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); - const wmGizmoType *wt_grab = WM_gizmotype_find("GIZMO_WT_grab_3d", true); - const wmGizmoType *wt_dial = WM_gizmotype_find("GIZMO_WT_dial_3d", true); + const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); + const wmGizmoType *gzt_grab = WM_gizmotype_find("GIZMO_GT_grab_3d", true); + const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true); - man->translate_z = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); - man->translate_c = WM_gizmo_new_ptr(wt_grab, mgroup, NULL); - man->rotate_c = WM_gizmo_new_ptr(wt_dial, mgroup, NULL); + man->translate_z = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + man->translate_c = WM_gizmo_new_ptr(gzt_grab, gzgroup, NULL); + man->rotate_c = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_z->color); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_c->color); @@ -673,28 +673,28 @@ static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *mgroup) } static void gizmo_mesh_bisect_draw_prepare( - const bContext *UNUSED(C), wmGizmoGroup *mgroup) + const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { - GizmoGroup *man = mgroup->customdata; + GizmoGroup *man = gzgroup->customdata; if (man->data.op->next) { man->data.op = WM_operator_last_redo((bContext *)man->data.context); } gizmo_mesh_bisect_update_from_op(man); } -static void MESH_WGT_bisect(struct wmGizmoGroupType *wgt) +static void MESH_GGT_bisect(struct wmGizmoGroupType *gzgt) { - wgt->name = "Mesh Bisect"; - wgt->idname = "MESH_WGT_bisect"; + gzgt->name = "Mesh Bisect"; + gzgt->idname = "MESH_GGT_bisect"; - wgt->flag = WM_GIZMOGROUPTYPE_3D; + gzgt->flag = WM_GIZMOGROUPTYPE_3D; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = gizmo_mesh_bisect_poll; - wgt->setup = gizmo_mesh_bisect_setup; - wgt->draw_prepare = gizmo_mesh_bisect_draw_prepare; + gzgt->poll = gizmo_mesh_bisect_poll; + gzgt->setup = gizmo_mesh_bisect_setup; + gzgt->draw_prepare = gizmo_mesh_bisect_draw_prepare; } /** \} */ diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index dd167c1fc15..061cc3ebc32 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -417,31 +417,31 @@ static void gizmo_mesh_extrude_orientation_matrix_set( } } -static bool gizmo_mesh_extrude_poll(const bContext *C, wmGizmoGroupType *wgt) +static bool gizmo_mesh_extrude_poll(const bContext *C, wmGizmoGroupType *gzgt) { ScrArea *sa = CTX_wm_area(C); bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->gizmo_group) || + !STREQ(gzgt->idname, tref_rt->gizmo_group) || !ED_operator_editmesh_view3d((bContext *)C)) { - WM_gizmo_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); return false; } return true; } -static void gizmo_mesh_extrude_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void gizmo_mesh_extrude_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { struct GizmoExtrudeGroup *man = MEM_callocN(sizeof(GizmoExtrudeGroup), __func__); - mgroup->customdata = man; + gzgroup->customdata = man; - const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); - const wmGizmoType *wt_grab = WM_gizmotype_find("GIZMO_WT_button_2d", true); + const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); + const wmGizmoType *gzt_grab = WM_gizmotype_find("GIZMO_GT_button_2d", true); for (int i = 0; i < 4; i++) { - man->adjust_xyz_no[i] = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); - man->invoke_xyz_no[i] = WM_gizmo_new_ptr(wt_grab, mgroup, NULL); + man->adjust_xyz_no[i] = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + man->invoke_xyz_no[i] = WM_gizmo_new_ptr(gzt_grab, gzgroup, NULL); man->invoke_xyz_no[i]->flag |= WM_GIZMO_DRAW_OFFSET_SCALE; } @@ -503,9 +503,9 @@ static void gizmo_mesh_extrude_setup(const bContext *UNUSED(C), wmGizmoGroup *mg } } -static void gizmo_mesh_extrude_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void gizmo_mesh_extrude_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoExtrudeGroup *man = mgroup->customdata; + GizmoExtrudeGroup *man = gzgroup->customdata; for (int i = 0; i < 4; i++) { WM_gizmo_set_flag(man->invoke_xyz_no[i], WM_GIZMO_HIDDEN, true); @@ -623,9 +623,9 @@ static void gizmo_mesh_extrude_refresh(const bContext *C, wmGizmoGroup *mgroup) } } -static void gizmo_mesh_extrude_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void gizmo_mesh_extrude_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoExtrudeGroup *man = mgroup->customdata; + GizmoExtrudeGroup *man = gzgroup->customdata; switch (man->data.orientation_type) { case V3D_MANIP_VIEW: { @@ -640,38 +640,38 @@ static void gizmo_mesh_extrude_draw_prepare(const bContext *C, wmGizmoGroup *mgr } static void gizmo_mesh_extrude_message_subscribe( - const bContext *C, wmGizmoGroup *mgroup, struct wmMsgBus *mbus) + const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { ARegion *ar = CTX_wm_region(C); /* Subscribe to view properties */ - wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { + wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { .owner = ar, - .user_data = mgroup->parent_mmap, + .user_data = gzgroup->parent_gzmap, .notify = WM_gizmo_do_msg_notify_tag_refresh, }; { - WM_msg_subscribe_rna_anon_prop(mbus, Scene, transform_orientation, &msg_sub_value_mpr_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, Scene, transform_orientation, &msg_sub_value_gz_tag_refresh); } } -static void MESH_WGT_extrude(struct wmGizmoGroupType *wgt) +static void MESH_GGT_extrude(struct wmGizmoGroupType *gzgt) { - wgt->name = "Mesh Extrude"; - wgt->idname = "MESH_WGT_extrude"; + gzgt->name = "Mesh Extrude"; + gzgt->idname = "MESH_GGT_extrude"; - wgt->flag = WM_GIZMOGROUPTYPE_3D; + gzgt->flag = WM_GIZMOGROUPTYPE_3D; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = gizmo_mesh_extrude_poll; - wgt->setup = gizmo_mesh_extrude_setup; - wgt->refresh = gizmo_mesh_extrude_refresh; - wgt->draw_prepare = gizmo_mesh_extrude_draw_prepare; - wgt->message_subscribe = gizmo_mesh_extrude_message_subscribe; + gzgt->poll = gizmo_mesh_extrude_poll; + gzgt->setup = gizmo_mesh_extrude_setup; + gzgt->refresh = gizmo_mesh_extrude_refresh; + gzgt->draw_prepare = gizmo_mesh_extrude_draw_prepare; + gzgt->message_subscribe = gizmo_mesh_extrude_message_subscribe; } #endif /* USE_GIZMO */ @@ -826,7 +826,7 @@ void MESH_OT_extrude_context(wmOperatorType *ot) Transform_Properties(ot, P_NO_DEFAULTS | P_MIRROR_DUMMY); #ifdef USE_GIZMO - WM_gizmogrouptype_append(MESH_WGT_extrude); + WM_gizmogrouptype_append(MESH_GGT_extrude); #endif } diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index 3864bd63036..adb7ee71ee0 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -143,40 +143,40 @@ static void gizmo_mesh_spin_update_from_op(GizmoSpinGroup *man) /* depth callbacks */ static void gizmo_spin_prop_depth_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); float plane_co[3], plane_no[3]; RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co); RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no); - value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix_basis[3]); + value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, gz->matrix_basis[3]); } static void gizmo_spin_prop_depth_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; const float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); float plane_co[3], plane[4]; RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co); RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane); normalize_v3(plane); - plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix_basis[3]); + plane[3] = -value[0] - dot_v3v3(plane, gz->matrix_basis[3]); /* Keep our location, may be offset simply to be inside the viewport. */ closest_to_plane_normalized_v3(plane_co, plane, plane_co); @@ -188,28 +188,28 @@ static void gizmo_spin_prop_depth_set( /* translate callbacks */ static void gizmo_spin_prop_translate_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 3); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 3); + UNUSED_VARS_NDEBUG(gz_prop); RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, value); } static void gizmo_spin_prop_translate_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value) { - GizmoSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; - BLI_assert(mpr_prop->type->array_length == 3); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 3); + UNUSED_VARS_NDEBUG(gz_prop); RNA_property_float_set_array(op->ptr, man->data.prop_axis_co, value); @@ -218,15 +218,15 @@ static void gizmo_spin_prop_translate_set( /* angle callbacks */ static void gizmo_spin_prop_axis_angle_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); float plane_no[4]; RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no); @@ -245,15 +245,15 @@ static void gizmo_spin_prop_axis_angle_get( } static void gizmo_spin_prop_axis_angle_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; const float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); float plane_no[4]; RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no); @@ -280,43 +280,43 @@ static void gizmo_spin_prop_axis_angle_set( /* angle callbacks */ static void gizmo_spin_prop_angle_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); value[0] = RNA_property_float_get(op->ptr, man->data.prop_angle); } static void gizmo_spin_prop_angle_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoSpinGroup *man = mpr->parent_mgroup->customdata; + GizmoSpinGroup *man = gz->parent_gzgroup->customdata; wmOperator *op = man->data.op; - BLI_assert(mpr_prop->type->array_length == 1); - UNUSED_VARS_NDEBUG(mpr_prop); + BLI_assert(gz_prop->type->array_length == 1); + UNUSED_VARS_NDEBUG(gz_prop); const float *value = value_p; RNA_property_float_set(op->ptr, man->data.prop_angle, value[0]); gizmo_spin_exec(man); } -static bool gizmo_mesh_spin_poll(const bContext *C, wmGizmoGroupType *wgt) +static bool gizmo_mesh_spin_poll(const bContext *C, wmGizmoGroupType *gzgt) { wmOperator *op = WM_operator_last_redo(C); if (op == NULL || !STREQ(op->type->idname, "MESH_OT_spin")) { - WM_gizmo_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); return false; } return true; } -static void gizmo_mesh_spin_setup(const bContext *C, wmGizmoGroup *mgroup) +static void gizmo_mesh_spin_setup(const bContext *C, wmGizmoGroup *gzgroup) { wmOperator *op = WM_operator_last_redo(C); @@ -325,16 +325,16 @@ static void gizmo_mesh_spin_setup(const bContext *C, wmGizmoGroup *mgroup) } struct GizmoSpinGroup *man = MEM_callocN(sizeof(GizmoSpinGroup), __func__); - mgroup->customdata = man; + gzgroup->customdata = man; - const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); - const wmGizmoType *wt_grab = WM_gizmotype_find("GIZMO_WT_grab_3d", true); - const wmGizmoType *wt_dial = WM_gizmotype_find("GIZMO_WT_dial_3d", true); + const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); + const wmGizmoType *gzt_grab = WM_gizmotype_find("GIZMO_GT_grab_3d", true); + const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true); - man->translate_z = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); - man->translate_c = WM_gizmo_new_ptr(wt_grab, mgroup, NULL); - man->rotate_c = WM_gizmo_new_ptr(wt_dial, mgroup, NULL); - man->angle_z = WM_gizmo_new_ptr(wt_dial, mgroup, NULL); + man->translate_z = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + man->translate_c = WM_gizmo_new_ptr(gzt_grab, gzgroup, NULL); + man->rotate_c = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); + man->angle_z = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_z->color); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_c->color); @@ -403,28 +403,28 @@ static void gizmo_mesh_spin_setup(const bContext *C, wmGizmoGroup *mgroup) } static void gizmo_mesh_spin_draw_prepare( - const bContext *UNUSED(C), wmGizmoGroup *mgroup) + const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { - GizmoSpinGroup *man = mgroup->customdata; + GizmoSpinGroup *man = gzgroup->customdata; if (man->data.op->next) { man->data.op = WM_operator_last_redo((bContext *)man->data.context); } gizmo_mesh_spin_update_from_op(man); } -static void MESH_WGT_spin(struct wmGizmoGroupType *wgt) +static void MESH_GGT_spin(struct wmGizmoGroupType *gzgt) { - wgt->name = "Mesh Spin"; - wgt->idname = "MESH_WGT_spin"; + gzgt->name = "Mesh Spin"; + gzgt->idname = "MESH_GGT_spin"; - wgt->flag = WM_GIZMOGROUPTYPE_3D; + gzgt->flag = WM_GIZMOGROUPTYPE_3D; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = gizmo_mesh_spin_poll; - wgt->setup = gizmo_mesh_spin_setup; - wgt->draw_prepare = gizmo_mesh_spin_draw_prepare; + gzgt->poll = gizmo_mesh_spin_poll; + gzgt->setup = gizmo_mesh_spin_setup; + gzgt->draw_prepare = gizmo_mesh_spin_draw_prepare; } /** \} */ @@ -511,8 +511,8 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e #ifdef USE_GIZMO if (ret & OPERATOR_FINISHED) { /* Setup gizmos */ - if (v3d && ((v3d->mpr_flag & V3D_GIZMO_HIDE) == 0)) { - WM_gizmo_group_type_ensure("MESH_WGT_spin"); + if (v3d && ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0)) { + WM_gizmo_group_type_ensure("MESH_GGT_spin"); } } #endif @@ -549,6 +549,6 @@ void MESH_OT_spin(wmOperatorType *ot) RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); #ifdef USE_GIZMO - WM_gizmogrouptype_append(MESH_WGT_spin); + WM_gizmogrouptype_append(MESH_GGT_spin); #endif } diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 1be180b852c..486203462a0 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -78,7 +78,7 @@ typedef struct { /* modal only */ float mcenter[2]; void *draw_handle_pixel; - short mpr_flag; + short gizmo_flag; } InsetData; @@ -173,8 +173,8 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL); G.moving = G_TRANSFORM_EDIT; if (v3d) { - opdata->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = V3D_GIZMO_HIDE; + opdata->gizmo_flag = v3d->gizmo_flag; + v3d->gizmo_flag = V3D_GIZMO_HIDE; } } @@ -196,7 +196,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) } ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel); if (v3d) { - v3d->mpr_flag = opdata->mpr_flag; + v3d->gizmo_flag = opdata->gizmo_flag; } G.moving = 0; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 68b0f42768a..d87bfbe00ce 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -581,25 +581,25 @@ static int image_context(const bContext *C, const char *member, bContextDataResu return 0; } -static void IMAGE_WGT_gizmo2d(wmGizmoGroupType *wgt) +static void IMAGE_GGT_gizmo2d(wmGizmoGroupType *gzgt) { - wgt->name = "UV Transform Gizmo"; - wgt->idname = "IMAGE_WGT_gizmo2d"; + gzgt->name = "UV Transform Gizmo"; + gzgt->idname = "IMAGE_GGT_gizmo2d"; - wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; + gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; - wgt->poll = ED_widgetgroup_gizmo2d_poll; - wgt->setup = ED_widgetgroup_gizmo2d_setup; - wgt->refresh = ED_widgetgroup_gizmo2d_refresh; - wgt->draw_prepare = ED_widgetgroup_gizmo2d_draw_prepare; + gzgt->poll = ED_widgetgroup_gizmo2d_poll; + gzgt->setup = ED_widgetgroup_gizmo2d_setup; + gzgt->refresh = ED_widgetgroup_gizmo2d_refresh; + gzgt->draw_prepare = ED_widgetgroup_gizmo2d_draw_prepare; } static void image_widgets(void) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure( + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure( &(const struct wmGizmoMapType_Params){SPACE_IMAGE, RGN_TYPE_WINDOW}); - WM_gizmogrouptype_append_and_link(mmap_type, IMAGE_WGT_gizmo2d); + WM_gizmogrouptype_append_and_link(gzmap_type, IMAGE_GGT_gizmo2d); } /************************** main region ***************************/ diff --git a/source/blender/editors/space_node/node_gizmo.c b/source/blender/editors/space_node/node_gizmo.c index 37ea53aa710..b265d95c06a 100644 --- a/source/blender/editors/space_node/node_gizmo.c +++ b/source/blender/editors/space_node/node_gizmo.c @@ -83,12 +83,12 @@ static void node_gizmo_calc_matrix_space_with_image_dims( * \{ */ static void gizmo_node_backdrop_prop_matrix_get( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, void *value_p) { float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - const SpaceNode *snode = mpr_prop->custom_func.user_data; + BLI_assert(gz_prop->type->array_length == 16); + const SpaceNode *snode = gz_prop->custom_func.user_data; matrix[0][0] = snode->zoom; matrix[1][1] = snode->zoom; matrix[3][0] = snode->xof; @@ -96,19 +96,19 @@ static void gizmo_node_backdrop_prop_matrix_get( } static void gizmo_node_backdrop_prop_matrix_set( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, const void *value_p) { const float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - SpaceNode *snode = mpr_prop->custom_func.user_data; + BLI_assert(gz_prop->type->array_length == 16); + SpaceNode *snode = gz_prop->custom_func.user_data; snode->zoom = matrix[0][0]; snode->zoom = matrix[1][1]; snode->xof = matrix[3][0]; snode->yof = matrix[3][1]; } -static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -127,22 +127,22 @@ static bool WIDGETGROUP_node_transform_poll(const bContext *C, wmGizmoGroupType return false; } -static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); - wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); + wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL); RNA_enum_set(wwrapper->gizmo->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); - mgroup->customdata = wwrapper; + gzgroup->customdata = wwrapper; } -static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmGizmoGroup *gzgroup) { Main *bmain = CTX_data_main(C); - wmGizmo *cage = ((wmGizmoWrapper *)mgroup->customdata)->gizmo; + wmGizmo *cage = ((wmGizmoWrapper *)gzgroup->customdata)->gizmo; const ARegion *ar = CTX_wm_region(C); /* center is always at the origin */ const float origin[3] = {ar->winx / 2, ar->winy / 2}; @@ -186,16 +186,16 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmGizmoGroup * BKE_image_release_ibuf(ima, ibuf, lock); } -void NODE_WGT_backdrop_transform(wmGizmoGroupType *wgt) +void NODE_GGT_backdrop_transform(wmGizmoGroupType *gzgt) { - wgt->name = "Backdrop Transform Widget"; - wgt->idname = "NODE_WGT_backdrop_transform"; + gzgt->name = "Backdrop Transform Widget"; + gzgt->idname = "NODE_GGT_backdrop_transform"; - wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; + gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; - wgt->poll = WIDGETGROUP_node_transform_poll; - wgt->setup = WIDGETGROUP_node_transform_setup; - wgt->refresh = WIDGETGROUP_node_transform_refresh; + gzgt->poll = WIDGETGROUP_node_transform_poll; + gzgt->setup = WIDGETGROUP_node_transform_setup; + gzgt->refresh = WIDGETGROUP_node_transform_refresh; } /** \} */ @@ -258,14 +258,14 @@ static void two_xy_from_rect(NodeTwoXYs *nxy, const rctf *rect, const float dims /* scale callbacks */ static void gizmo_node_crop_prop_matrix_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata; + BLI_assert(gz_prop->type->array_length == 16); + struct NodeCropWidgetGroup *crop_group = gz->parent_gzgroup->customdata; const float *dims = crop_group->state.dims; - const bNode *node = mpr_prop->custom_func.user_data; + const bNode *node = gz_prop->custom_func.user_data; const NodeTwoXYs *nxy = node->storage; bool is_relative = (bool)node->custom2; rctf rct; @@ -277,14 +277,14 @@ static void gizmo_node_crop_prop_matrix_get( } static void gizmo_node_crop_prop_matrix_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { const float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct NodeCropWidgetGroup *crop_group = mpr->parent_mgroup->customdata; + BLI_assert(gz_prop->type->array_length == 16); + struct NodeCropWidgetGroup *crop_group = gz->parent_gzgroup->customdata; const float *dims = crop_group->state.dims; - bNode *node = mpr_prop->custom_func.user_data; + bNode *node = gz_prop->custom_func.user_data; NodeTwoXYs *nxy = node->storage; bool is_relative = (bool)node->custom2; rctf rct; @@ -296,7 +296,7 @@ static void gizmo_node_crop_prop_matrix_set( gizmo_node_crop_update(crop_group); } -static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -318,33 +318,33 @@ static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmGizmoGroupType *UNUS return false; } -static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_crop_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { struct NodeCropWidgetGroup *crop_group = MEM_mallocN(sizeof(struct NodeCropWidgetGroup), __func__); - crop_group->border = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); + crop_group->border = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL); RNA_enum_set(crop_group->border->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); - mgroup->customdata = crop_group; + gzgroup->customdata = crop_group; } -static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { ARegion *ar = CTX_wm_region(C); - wmGizmo *mpr = mgroup->gizmos.first; + wmGizmo *gz = gzgroup->gizmos.first; SpaceNode *snode = CTX_wm_space_node(C); - node_gizmo_calc_matrix_space(snode, ar, mpr->matrix_space); + node_gizmo_calc_matrix_space(snode, ar, gz->matrix_space); } -static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *gzgroup) { Main *bmain = CTX_data_main(C); - struct NodeCropWidgetGroup *crop_group = mgroup->customdata; - wmGizmo *mpr = crop_group->border; + struct NodeCropWidgetGroup *crop_group = gzgroup->customdata; + wmGizmo *gz = crop_group->border; void *lock; Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); @@ -354,8 +354,8 @@ static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *mgrou crop_group->state.dims[0] = (ibuf->x > 0) ? ibuf->x : 64.0f; crop_group->state.dims[1] = (ibuf->y > 0) ? ibuf->y : 64.0f; - RNA_float_set_array(mpr->ptr, "dimensions", crop_group->state.dims); - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + RNA_float_set_array(gz->ptr, "dimensions", crop_group->state.dims); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); SpaceNode *snode = CTX_wm_space_node(C); bNode *node = nodeGetActive(snode->edittree); @@ -365,7 +365,7 @@ static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *mgrou crop_group->update_data.prop = RNA_struct_find_property(&crop_group->update_data.ptr, "relative"); WM_gizmo_target_property_def_func( - mpr, "matrix", + gz, "matrix", &(const struct wmGizmoPropertyFnParams) { .value_get_fn = gizmo_node_crop_prop_matrix_get, .value_set_fn = gizmo_node_crop_prop_matrix_set, @@ -374,23 +374,23 @@ static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *mgrou }); } else { - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true); } BKE_image_release_ibuf(ima, ibuf, lock); } -void NODE_WGT_backdrop_crop(wmGizmoGroupType *wgt) +void NODE_GGT_backdrop_crop(wmGizmoGroupType *gzgt) { - wgt->name = "Backdrop Crop Widget"; - wgt->idname = "NODE_WGT_backdrop_crop"; + gzgt->name = "Backdrop Crop Widget"; + gzgt->idname = "NODE_GGT_backdrop_crop"; - wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; + gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; - wgt->poll = WIDGETGROUP_node_crop_poll; - wgt->setup = WIDGETGROUP_node_crop_setup; - wgt->draw_prepare = WIDGETGROUP_node_crop_draw_prepare; - wgt->refresh = WIDGETGROUP_node_crop_refresh; + gzgt->poll = WIDGETGROUP_node_crop_poll; + gzgt->setup = WIDGETGROUP_node_crop_setup; + gzgt->draw_prepare = WIDGETGROUP_node_crop_draw_prepare; + gzgt->refresh = WIDGETGROUP_node_crop_refresh; } /** \} */ @@ -408,7 +408,7 @@ struct NodeSunBeamsWidgetGroup { } state; }; -static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -427,36 +427,36 @@ static bool WIDGETGROUP_node_sbeam_poll(const bContext *C, wmGizmoGroupType *UNU return false; } -static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_sbeam_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { struct NodeSunBeamsWidgetGroup *sbeam_group = MEM_mallocN(sizeof(struct NodeSunBeamsWidgetGroup), __func__); - sbeam_group->gizmo = WM_gizmo_new("GIZMO_WT_grab_3d", mgroup, NULL); - wmGizmo *mpr = sbeam_group->gizmo; + sbeam_group->gizmo = WM_gizmo_new("GIZMO_GT_grab_3d", gzgroup, NULL); + wmGizmo *gz = sbeam_group->gizmo; - RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_CROSS_2D); + RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_CROSS_2D); - mpr->scale_basis = 0.05f; + gz->scale_basis = 0.05f; - mgroup->customdata = sbeam_group; + gzgroup->customdata = sbeam_group; } -static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata; + struct NodeSunBeamsWidgetGroup *sbeam_group = gzgroup->customdata; ARegion *ar = CTX_wm_region(C); - wmGizmo *mpr = mgroup->gizmos.first; + wmGizmo *gz = gzgroup->gizmos.first; SpaceNode *snode = CTX_wm_space_node(C); - node_gizmo_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, mpr->matrix_space); + node_gizmo_calc_matrix_space_with_image_dims(snode, ar, sbeam_group->state.dims, gz->matrix_space); } -static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmGizmoGroup *gzgroup) { Main *bmain = CTX_data_main(C); - struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata; - wmGizmo *mpr = sbeam_group->gizmo; + struct NodeSunBeamsWidgetGroup *sbeam_group = gzgroup->customdata; + wmGizmo *gz = sbeam_group->gizmo; void *lock; Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); @@ -472,28 +472,28 @@ static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmGizmoGroup *mgro /* need to set property here for undo. TODO would prefer to do this in _init */ PointerRNA nodeptr; RNA_pointer_create((ID *)snode->edittree, &RNA_CompositorNodeSunBeams, node, &nodeptr); - WM_gizmo_target_property_def_rna(mpr, "offset", &nodeptr, "source", -1); + WM_gizmo_target_property_def_rna(gz, "offset", &nodeptr, "source", -1); - WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_MODAL, true); + WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_MODAL, true); } else { - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true); } BKE_image_release_ibuf(ima, ibuf, lock); } -void NODE_WGT_backdrop_sun_beams(wmGizmoGroupType *wgt) +void NODE_GGT_backdrop_sun_beams(wmGizmoGroupType *gzgt) { - wgt->name = "Sun Beams Widget"; - wgt->idname = "NODE_WGT_sbeam"; + gzgt->name = "Sun Beams Widget"; + gzgt->idname = "NODE_GGT_sbeam"; - wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; + gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; - wgt->poll = WIDGETGROUP_node_sbeam_poll; - wgt->setup = WIDGETGROUP_node_sbeam_setup; - wgt->draw_prepare = WIDGETGROUP_node_sbeam_draw_prepare; - wgt->refresh = WIDGETGROUP_node_sbeam_refresh; + gzgt->poll = WIDGETGROUP_node_sbeam_poll; + gzgt->setup = WIDGETGROUP_node_sbeam_setup; + gzgt->draw_prepare = WIDGETGROUP_node_sbeam_draw_prepare; + gzgt->refresh = WIDGETGROUP_node_sbeam_refresh; } /** \} */ @@ -513,7 +513,7 @@ struct NodeCornerPinWidgetGroup { } state; }; -static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -532,26 +532,26 @@ static bool WIDGETGROUP_node_corner_pin_poll(const bContext *C, wmGizmoGroupType return false; } -static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_corner_pin_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { struct NodeCornerPinWidgetGroup *cpin_group = MEM_mallocN(sizeof(struct NodeCornerPinWidgetGroup), __func__); - const wmGizmoType *wt_grab_3d = WM_gizmotype_find("GIZMO_WT_grab_3d", false); + const wmGizmoType *gzt_grab_3d = WM_gizmotype_find("GIZMO_GT_grab_3d", false); for (int i = 0; i < 4; i++) { - cpin_group->gizmos[i] = WM_gizmo_new_ptr(wt_grab_3d, mgroup, NULL); - wmGizmo *mpr = cpin_group->gizmos[i]; + cpin_group->gizmos[i] = WM_gizmo_new_ptr(gzt_grab_3d, gzgroup, NULL); + wmGizmo *gz = cpin_group->gizmos[i]; - RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_CROSS_2D); + RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_CROSS_2D); - mpr->scale_basis = 0.01f; + gz->scale_basis = 0.01f; } - mgroup->customdata = cpin_group; + gzgroup->customdata = cpin_group; } -static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata; + struct NodeCornerPinWidgetGroup *cpin_group = gzgroup->customdata; ARegion *ar = CTX_wm_region(C); SpaceNode *snode = CTX_wm_space_node(C); @@ -560,15 +560,15 @@ static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmGizmoG node_gizmo_calc_matrix_space_with_image_dims(snode, ar, cpin_group->state.dims, matrix_space); for (int i = 0; i < 4; i++) { - wmGizmo *mpr = cpin_group->gizmos[i]; - copy_m4_m4(mpr->matrix_space, matrix_space); + wmGizmo *gz = cpin_group->gizmos[i]; + copy_m4_m4(gz->matrix_space, matrix_space); } } -static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmGizmoGroup *gzgroup) { Main *bmain = CTX_data_main(C); - struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata; + struct NodeCornerPinWidgetGroup *cpin_group = gzgroup->customdata; void *lock; Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); @@ -585,37 +585,37 @@ static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmGizmoGroup int i = 0; for (bNodeSocket *sock = node->inputs.first; sock && i < 4; sock = sock->next) { if (sock->type == SOCK_VECTOR) { - wmGizmo *mpr = cpin_group->gizmos[i++]; + wmGizmo *gz = cpin_group->gizmos[i++]; PointerRNA sockptr; RNA_pointer_create((ID *)snode->edittree, &RNA_NodeSocket, sock, &sockptr); - WM_gizmo_target_property_def_rna(mpr, "offset", &sockptr, "default_value", -1); + WM_gizmo_target_property_def_rna(gz, "offset", &sockptr, "default_value", -1); - WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_MODAL, true); + WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_MODAL, true); } } } else { for (int i = 0; i < 4; i++) { - wmGizmo *mpr = cpin_group->gizmos[i]; - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); + wmGizmo *gz = cpin_group->gizmos[i]; + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true); } } BKE_image_release_ibuf(ima, ibuf, lock); } -void NODE_WGT_backdrop_corner_pin(wmGizmoGroupType *wgt) +void NODE_GGT_backdrop_corner_pin(wmGizmoGroupType *gzgt) { - wgt->name = "Corner Pin Widget"; - wgt->idname = "NODE_WGT_backdrop_corner_pin"; + gzgt->name = "Corner Pin Widget"; + gzgt->idname = "NODE_GGT_backdrop_corner_pin"; - wgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; + gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT; - wgt->poll = WIDGETGROUP_node_corner_pin_poll; - wgt->setup = WIDGETGROUP_node_corner_pin_setup; - wgt->draw_prepare = WIDGETGROUP_node_corner_pin_draw_prepare; - wgt->refresh = WIDGETGROUP_node_corner_pin_refresh; + gzgt->poll = WIDGETGROUP_node_corner_pin_poll; + gzgt->setup = WIDGETGROUP_node_corner_pin_setup; + gzgt->draw_prepare = WIDGETGROUP_node_corner_pin_draw_prepare; + gzgt->refresh = WIDGETGROUP_node_corner_pin_refresh; } /** \} */ diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 742c3975c8d..1a0f738ab8a 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -224,10 +224,10 @@ void NODE_OT_viewer_border(struct wmOperatorType *ot); void NODE_OT_clear_viewer_border(struct wmOperatorType *ot); /* node_widgets.c */ -void NODE_WGT_backdrop_transform(struct wmGizmoGroupType *wgt); -void NODE_WGT_backdrop_crop(struct wmGizmoGroupType *wgt); -void NODE_WGT_backdrop_sun_beams(struct wmGizmoGroupType *wgt); -void NODE_WGT_backdrop_corner_pin(struct wmGizmoGroupType *wgt); +void NODE_GGT_backdrop_transform(struct wmGizmoGroupType *gzgt); +void NODE_GGT_backdrop_crop(struct wmGizmoGroupType *gzgt); +void NODE_GGT_backdrop_sun_beams(struct wmGizmoGroupType *gzgt); +void NODE_GGT_backdrop_corner_pin(struct wmGizmoGroupType *gzgt); extern const char *node_context_dir[]; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 1149b910947..10f337440d4 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -752,7 +752,7 @@ static void node_region_listener( wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) { - wmGizmoMap *mmap = ar->gizmo_map; + wmGizmoMap *gzmap = ar->gizmo_map; /* context changes */ switch (wmn->category) { @@ -762,13 +762,13 @@ static void node_region_listener( ED_region_tag_redraw(ar); break; case ND_SPACE_NODE_VIEW: - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); break; } break; case NC_SCREEN: if (wmn->data == ND_LAYOUTSET || wmn->action == NA_EDITED) { - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); } switch (wmn->data) { case ND_ANIMPLAY: @@ -784,13 +784,13 @@ static void node_region_listener( case NC_SCENE: ED_region_tag_redraw(ar); if (wmn->data == ND_RENDER_RESULT) { - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); } break; case NC_NODE: ED_region_tag_redraw(ar); if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); } break; case NC_MATERIAL: @@ -863,12 +863,12 @@ static int node_context(const bContext *C, const char *member, bContextDataResul static void node_widgets(void) { /* create the widgetmap for the area here */ - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure( + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure( &(const struct wmGizmoMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW}); - WM_gizmogrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_transform); - WM_gizmogrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_crop); - WM_gizmogrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_sun_beams); - WM_gizmogrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_corner_pin); + WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_transform); + WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_crop); + WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_sun_beams); + WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_corner_pin); } static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 6d4009e9d2b..dca4b3f4f76 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -716,26 +716,26 @@ static void view3d_dropboxes(void) static void view3d_widgets(void) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure( + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure( &(const struct wmGizmoMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW}); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera_view); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_empty_image); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_armature_spline); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_lamp_spot); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_lamp_area); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_lamp_target); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_force_field); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_camera); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_camera_view); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_empty_image); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_armature_spline); - WM_gizmogrouptype_append(TRANSFORM_WGT_gizmo); - WM_gizmogrouptype_append(VIEW3D_WGT_xform_cage); + WM_gizmogrouptype_append(TRANSFORM_GGT_gizmo); + WM_gizmogrouptype_append(VIEW3D_GGT_xform_cage); - WM_gizmogrouptype_append(VIEW3D_WGT_ruler); - WM_gizmotype_append(VIEW3D_WT_ruler_item); + WM_gizmogrouptype_append(VIEW3D_GGT_ruler); + WM_gizmotype_append(VIEW3D_GT_ruler_item); - WM_gizmogrouptype_append_and_link(mmap_type, VIEW3D_WGT_navigate); - WM_gizmotype_append(VIEW3D_WT_navigate_rotate); + WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_navigate); + WM_gizmotype_append(VIEW3D_GT_navigate_rotate); } @@ -815,13 +815,13 @@ static void view3d_main_region_listener( { View3D *v3d = sa->spacedata.first; RegionView3D *rv3d = ar->regiondata; - wmGizmoMap *mmap = ar->gizmo_map; + wmGizmoMap *gzmap = ar->gizmo_map; /* context changes */ switch (wmn->category) { case NC_WM: if (ELEM(wmn->data, ND_UNDO)) { - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); } break; case NC_ANIMATION: @@ -848,14 +848,14 @@ static void view3d_main_region_listener( if (wmn->reference) view3d_recalc_used_layers(ar, wmn, wmn->reference); ED_region_tag_redraw(ar); - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); break; case ND_LAYER: if (wmn->reference) { BKE_screen_view3d_sync(v3d, wmn->reference); } ED_region_tag_redraw(ar); - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); break; case ND_OB_ACTIVE: case ND_OB_SELECT: @@ -867,7 +867,7 @@ static void view3d_main_region_listener( case ND_MARKERS: case ND_MODE: ED_region_tag_redraw(ar); - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); break; case ND_WORLD: /* handled by space_view3d_listener() for v3d access */ @@ -899,7 +899,7 @@ static void view3d_main_region_listener( case ND_POINTCACHE: case ND_LOD: ED_region_tag_redraw(ar); - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); break; } switch (wmn->action) { @@ -912,7 +912,7 @@ static void view3d_main_region_listener( switch (wmn->data) { case ND_SELECT: { - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); ATTR_FALLTHROUGH; } case ND_DATA: @@ -993,7 +993,7 @@ static void view3d_main_region_listener( break; case ND_LIGHTING_DRAW: ED_region_tag_redraw(ar); - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); break; } break; @@ -1019,7 +1019,7 @@ static void view3d_main_region_listener( rv3d->rflag |= RV3D_GPULIGHT_UPDATE; } ED_region_tag_redraw(ar); - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); } break; case NC_ID: @@ -1035,7 +1035,7 @@ static void view3d_main_region_listener( case ND_LAYOUTBROWSE: case ND_LAYOUTDELETE: case ND_LAYOUTSET: - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); ED_region_tag_redraw(ar); break; case ND_LAYER: diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index be79cef182d..89d01727d9b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1207,7 +1207,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(of if ((U.uiflag & USER_SHOW_GIZMO_AXIS) || (v3d->flag2 & V3D_RENDER_OVERRIDE) || /* No need to display gizmo and this info. */ - (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) { /* pass */ } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c index c7b12529798..88a95e89bd8 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_armature.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c @@ -80,14 +80,14 @@ struct BoneSplineWidgetGroup { }; static void gizmo_bbone_offset_get( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, void *value_p) { - struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data; + struct BoneSplineHandle *bh = gz_prop->custom_func.user_data; bPoseChannel *pchan = bh->pchan; float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 3); + BLI_assert(gz_prop->type->array_length == 3); if (bh->index == 0) { bh->co[1] = pchan->bone->ease1 / BBONE_SCALE_Y; @@ -103,15 +103,15 @@ static void gizmo_bbone_offset_get( } static void gizmo_bbone_offset_set( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, const void *value_p) { - struct BoneSplineHandle *bh = mpr_prop->custom_func.user_data; + struct BoneSplineHandle *bh = gz_prop->custom_func.user_data; bPoseChannel *pchan = bh->pchan; const float *value = value_p; - BLI_assert(mpr_prop->type->array_length == 3); + BLI_assert(gz_prop->type->array_length == 3); copy_v3_v3(bh->co, value); if (bh->index == 0) { @@ -127,7 +127,7 @@ static void gizmo_bbone_offset_set( } -static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); if (ob != NULL) { @@ -136,7 +136,7 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType if (arm->act_bone && arm->act_bone->segments > 1) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { /* pass */ } @@ -150,59 +150,59 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType } -static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *gzgroup) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan = BKE_pose_channel_active(ob); - const wmGizmoType *wt_grab = WM_gizmotype_find("GIZMO_WT_grab_3d", true); + const wmGizmoType *gzt_grab = WM_gizmotype_find("GIZMO_GT_grab_3d", true); struct BoneSplineWidgetGroup *bspline_group = MEM_callocN(sizeof(struct BoneSplineWidgetGroup), __func__); - mgroup->customdata = bspline_group; + gzgroup->customdata = bspline_group; /* Handles */ for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { - wmGizmo *mpr; - mpr = bspline_group->handles[i].gizmo = WM_gizmo_new_ptr(wt_grab, mgroup, NULL); - RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_RING_2D); - RNA_enum_set(mpr->ptr, "draw_options", + wmGizmo *gz; + gz = bspline_group->handles[i].gizmo = WM_gizmo_new_ptr(gzt_grab, gzgroup, NULL); + RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_GRAB_STYLE_RING_2D); + RNA_enum_set(gz->ptr, "draw_options", ED_GIZMO_GRAB_DRAW_FLAG_FILL | ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW); - WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_VALUE, true); + WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_VALUE, true); - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi); - mpr->scale_basis = 0.06f; + gz->scale_basis = 0.06f; if (i == 0) { - copy_v3_v3(mpr->matrix_basis[3], pchan->loc); + copy_v3_v3(gz->matrix_basis[3], pchan->loc); } } } -static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup *gzgroup) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - if (!mgroup->customdata) + if (!gzgroup->customdata) return; - struct BoneSplineWidgetGroup *bspline_group = mgroup->customdata; + struct BoneSplineWidgetGroup *bspline_group = gzgroup->customdata; bPoseChannel *pchan = BKE_pose_channel_active(ob); /* Handles */ for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { - wmGizmo *mpr = bspline_group->handles[i].gizmo; + wmGizmo *gz = bspline_group->handles[i].gizmo; bspline_group->handles[i].pchan = pchan; bspline_group->handles[i].index = i; float mat[4][4]; mul_m4_m4m4(mat, ob->obmat, (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat); - copy_m4_m4(mpr->matrix_space, mat); + copy_m4_m4(gz->matrix_space, mat); /* need to set property here for undo. TODO would prefer to do this in _init */ WM_gizmo_target_property_def_func( - mpr, "offset", + gz, "offset", &(const struct wmGizmoPropertyFnParams) { .value_get_fn = gizmo_bbone_offset_get, .value_set_fn = gizmo_bbone_offset_set, @@ -212,17 +212,17 @@ static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup } } -void VIEW3D_WGT_armature_spline(wmGizmoGroupType *wgt) +void VIEW3D_GGT_armature_spline(wmGizmoGroupType *gzgt) { - wgt->name = "Armature Spline Widgets"; - wgt->idname = "VIEW3D_WGT_armature_spline"; + gzgt->name = "Armature Spline Widgets"; + gzgt->idname = "VIEW3D_GGT_armature_spline"; - wgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_3D); - wgt->poll = WIDGETGROUP_armature_spline_poll; - wgt->setup = WIDGETGROUP_armature_spline_setup; - wgt->refresh = WIDGETGROUP_armature_spline_refresh; + gzgt->poll = WIDGETGROUP_armature_spline_poll; + gzgt->setup = WIDGETGROUP_armature_spline_setup; + gzgt->refresh = WIDGETGROUP_armature_spline_refresh; } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index b011e6e2e21..87b11f5d7a3 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -61,11 +61,11 @@ struct CameraWidgetGroup { wmGizmo *ortho_scale; }; -static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -81,57 +81,57 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED( return false; } -static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *gzgroup) { Object *ob = CTX_data_active_object(C); float dir[3]; - const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); + const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); - struct CameraWidgetGroup *camgroup = MEM_callocN(sizeof(struct CameraWidgetGroup), __func__); - mgroup->customdata = camgroup; + struct CameraWidgetGroup *cagzgroup = MEM_callocN(sizeof(struct CameraWidgetGroup), __func__); + gzgroup->customdata = cagzgroup; negate_v3_v3(dir, ob->obmat[2]); /* dof distance */ { - wmGizmo *mpr; - mpr = camgroup->dop_dist = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); - RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CROSS); - WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_HOVER, true); + wmGizmo *gz; + gz = cagzgroup->dop_dist = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CROSS); + WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_HOVER, true); - UI_GetThemeColor3fv(TH_GIZMO_A, mpr->color); - UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_A, gz->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi); } /* focal length * - logic/calculations are similar to BKE_camera_view_frame_ex, better keep in sync */ { - wmGizmo *mpr; - mpr = camgroup->focal_len = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); - mpr->flag |= WM_GIZMO_DRAW_NO_SCALE; - RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CONE); - RNA_enum_set(mpr->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); - - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); - - mpr = camgroup->ortho_scale = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); - mpr->flag |= WM_GIZMO_DRAW_NO_SCALE; - RNA_enum_set(mpr->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CONE); - RNA_enum_set(mpr->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); - - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); + wmGizmo *gz; + gz = cagzgroup->focal_len = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + gz->flag |= WM_GIZMO_DRAW_NO_SCALE; + RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CONE); + RNA_enum_set(gz->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); + + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi); + + gz = cagzgroup->ortho_scale = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + gz->flag |= WM_GIZMO_DRAW_NO_SCALE; + RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_CONE); + RNA_enum_set(gz->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); + + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi); } } -static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - if (!mgroup->customdata) + if (!gzgroup->customdata) return; - struct CameraWidgetGroup *camgroup = mgroup->customdata; + struct CameraWidgetGroup *cagzgroup = gzgroup->customdata; Object *ob = CTX_data_active_object(C); Camera *ca = ob->data; PointerRNA camera_ptr; @@ -149,16 +149,16 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *mgroup) negate_v3_v3(dir, ob->obmat[2]); if (ca->flag & CAM_SHOWLIMITS) { - WM_gizmo_set_matrix_location(camgroup->dop_dist, ob->obmat[3]); - WM_gizmo_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob->obmat[1], dir); - WM_gizmo_set_scale(camgroup->dop_dist, ca->drawsize); - WM_gizmo_set_flag(camgroup->dop_dist, WM_GIZMO_HIDDEN, false); + WM_gizmo_set_matrix_location(cagzgroup->dop_dist, ob->obmat[3]); + WM_gizmo_set_matrix_rotation_from_yz_axis(cagzgroup->dop_dist, ob->obmat[1], dir); + WM_gizmo_set_scale(cagzgroup->dop_dist, ca->drawsize); + WM_gizmo_set_flag(cagzgroup->dop_dist, WM_GIZMO_HIDDEN, false); /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_gizmo_target_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); + WM_gizmo_target_property_def_rna(cagzgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); } else { - WM_gizmo_set_flag(camgroup->dop_dist, WM_GIZMO_HIDDEN, true); + WM_gizmo_set_flag(cagzgroup->dop_dist, WM_GIZMO_HIDDEN, true); } /* TODO - make focal length/ortho ob_scale_inv widget optional */ @@ -167,14 +167,14 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *mgroup) const float aspy = (float)scene->r.ysch * scene->r.yasp; const bool is_ortho = (ca->type == CAM_ORTHO); const int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, aspx, aspy); - wmGizmo *widget = is_ortho ? camgroup->ortho_scale : camgroup->focal_len; + wmGizmo *widget = is_ortho ? cagzgroup->ortho_scale : cagzgroup->focal_len; float scale_matrix; if (true) { float offset[3]; float aspect[2]; WM_gizmo_set_flag(widget, WM_GIZMO_HIDDEN, false); - WM_gizmo_set_flag(is_ortho ? camgroup->focal_len : camgroup->ortho_scale, WM_GIZMO_HIDDEN, true); + WM_gizmo_set_flag(is_ortho ? cagzgroup->focal_len : cagzgroup->ortho_scale, WM_GIZMO_HIDDEN, true); /* account for lens shifting */ @@ -208,9 +208,9 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *mgroup) { const char *propname = is_ortho ? "ortho_scale" : "lens"; PropertyRNA *prop = RNA_struct_find_property(&camera_ptr, propname); - const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(widget->type, "offset"); + const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(widget->type, "offset"); - WM_gizmo_target_property_clear_rna_ptr(widget, mpr_prop_type); + WM_gizmo_target_property_clear_rna_ptr(widget, gz_prop_type); float min, max, range; float step, precision; @@ -226,21 +226,21 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *mgroup) /* Half sensor, intentionally use sensor from camera and not calculated above. */ (0.5f * ((ca->sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_x)))); - WM_gizmo_target_property_def_rna_ptr(widget, mpr_prop_type, &camera_ptr, prop, -1); + WM_gizmo_target_property_def_rna_ptr(widget, gz_prop_type, &camera_ptr, prop, -1); } } static void WIDGETGROUP_camera_message_subscribe( - const bContext *C, wmGizmoGroup *mgroup, struct wmMsgBus *mbus) + const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); Camera *ca = ob->data; - wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { + wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { .owner = ar, - .user_data = mgroup->parent_mmap, + .user_data = gzgroup->parent_gzmap, .notify = WM_gizmo_do_msg_notify_tag_refresh, }; @@ -270,32 +270,32 @@ static void WIDGETGROUP_camera_message_subscribe( RNA_id_pointer_create(&ca->id, &idptr); for (int i = 0; i < ARRAY_SIZE(props); i++) { - WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); + WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_gz_tag_refresh, __func__); } } /* Subscribe to render settings */ { - WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_x, &msg_sub_value_mpr_tag_refresh); - WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_y, &msg_sub_value_mpr_tag_refresh); - WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_x, &msg_sub_value_mpr_tag_refresh); - WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_y, &msg_sub_value_mpr_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_x, &msg_sub_value_gz_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_y, &msg_sub_value_gz_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_x, &msg_sub_value_gz_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_y, &msg_sub_value_gz_tag_refresh); } } -void VIEW3D_WGT_camera(wmGizmoGroupType *wgt) +void VIEW3D_GGT_camera(wmGizmoGroupType *gzgt) { - wgt->name = "Camera Widgets"; - wgt->idname = "VIEW3D_WGT_camera"; + gzgt->name = "Camera Widgets"; + gzgt->idname = "VIEW3D_GGT_camera"; - wgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_DEPTH_3D); - wgt->poll = WIDGETGROUP_camera_poll; - wgt->setup = WIDGETGROUP_camera_setup; - wgt->refresh = WIDGETGROUP_camera_refresh; - wgt->message_subscribe = WIDGETGROUP_camera_message_subscribe; + gzgt->poll = WIDGETGROUP_camera_poll; + gzgt->setup = WIDGETGROUP_camera_setup; + gzgt->refresh = WIDGETGROUP_camera_refresh; + gzgt->message_subscribe = WIDGETGROUP_camera_message_subscribe; } /** \} */ @@ -316,12 +316,12 @@ struct CameraViewWidgetGroup { /* scale callbacks */ static void gizmo_render_border_prop_matrix_get( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, void *value_p) { float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data; + BLI_assert(gz_prop->type->array_length == 16); + struct CameraViewWidgetGroup *viewgroup = gz_prop->custom_func.user_data; const rctf *border = viewgroup->state.edit_border; unit_m4(matrix); @@ -332,20 +332,20 @@ static void gizmo_render_border_prop_matrix_get( } static void gizmo_render_border_prop_matrix_set( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, const void *value_p) { const float (*matrix)[4] = value_p; - struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data; + struct CameraViewWidgetGroup *viewgroup = gz_prop->custom_func.user_data; rctf *border = viewgroup->state.edit_border; - BLI_assert(mpr_prop->type->array_length == 16); + BLI_assert(gz_prop->type->array_length == 16); BLI_rctf_resize(border, len_v3(matrix[0]), len_v3(matrix[1])); BLI_rctf_recenter(border, matrix[3][0], matrix[3][1]); BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, border, border); } -static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { Scene *scene = CTX_data_scene(C); @@ -361,7 +361,7 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UN View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -382,11 +382,11 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UN return false; } -static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { struct CameraViewWidgetGroup *viewgroup = MEM_mallocN(sizeof(struct CameraViewWidgetGroup), __func__); - viewgroup->border = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); + viewgroup->border = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL); RNA_enum_set(viewgroup->border->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); @@ -394,12 +394,12 @@ static void WIDGETGROUP_camera_view_setup(const bContext *UNUSED(C), wmGizmoGrou RNA_enum_set(viewgroup->border->ptr, "draw_style", ED_GIZMO_CAGE2D_STYLE_BOX); - mgroup->customdata = viewgroup; + gzgroup->customdata = viewgroup; } -static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; + struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata; ARegion *ar = CTX_wm_region(C); struct Depsgraph *depsgraph = CTX_data_depsgraph(C); @@ -413,17 +413,17 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup viewgroup->state.view_border = (rctf){.xmin = 0, .ymin = 0, .xmax = ar->winx, .ymax = ar->winy}; } - wmGizmo *mpr = viewgroup->border; - unit_m4(mpr->matrix_space); - mul_v3_fl(mpr->matrix_space[0], BLI_rctf_size_x(&viewgroup->state.view_border)); - mul_v3_fl(mpr->matrix_space[1], BLI_rctf_size_y(&viewgroup->state.view_border)); - mpr->matrix_space[3][0] = viewgroup->state.view_border.xmin; - mpr->matrix_space[3][1] = viewgroup->state.view_border.ymin; + wmGizmo *gz = viewgroup->border; + unit_m4(gz->matrix_space); + mul_v3_fl(gz->matrix_space[0], BLI_rctf_size_x(&viewgroup->state.view_border)); + mul_v3_fl(gz->matrix_space[1], BLI_rctf_size_y(&viewgroup->state.view_border)); + gz->matrix_space[3][0] = viewgroup->state.view_border.xmin; + gz->matrix_space[3][1] = viewgroup->state.view_border.ymin; } -static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; + struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata; View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); @@ -431,8 +431,8 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmGizmoGroup *mgr Scene *scene = CTX_data_scene(C); { - wmGizmo *mpr = viewgroup->border; - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + wmGizmo *gz = viewgroup->border; + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); RNA_enum_set(viewgroup->border->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); @@ -445,7 +445,7 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmGizmoGroup *mgr } WM_gizmo_target_property_def_func( - mpr, "matrix", + gz, "matrix", &(const struct wmGizmoPropertyFnParams) { .value_get_fn = gizmo_render_border_prop_matrix_get, .value_set_fn = gizmo_render_border_prop_matrix_set, @@ -456,18 +456,18 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmGizmoGroup *mgr } -void VIEW3D_WGT_camera_view(wmGizmoGroupType *wgt) +void VIEW3D_GGT_camera_view(wmGizmoGroupType *gzgt) { - wgt->name = "Camera View Widgets"; - wgt->idname = "VIEW3D_WGT_camera_view"; + gzgt->name = "Camera View Widgets"; + gzgt->idname = "VIEW3D_GGT_camera_view"; - wgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag = (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_SCALE); - wgt->poll = WIDGETGROUP_camera_view_poll; - wgt->setup = WIDGETGROUP_camera_view_setup; - wgt->draw_prepare = WIDGETGROUP_camera_view_draw_prepare; - wgt->refresh = WIDGETGROUP_camera_view_refresh; + gzgt->poll = WIDGETGROUP_camera_view_poll; + gzgt->setup = WIDGETGROUP_camera_view_setup; + gzgt->draw_prepare = WIDGETGROUP_camera_view_draw_prepare; + gzgt->refresh = WIDGETGROUP_camera_view_refresh; } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.c b/source/blender/editors/space_view3d/view3d_gizmo_empty.c index 3b51af5ca15..2913ba245e7 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_empty.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.c @@ -63,20 +63,20 @@ struct EmptyImageWidgetGroup { /* translate callbacks */ static void gizmo_empty_image_prop_matrix_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data; - const Object *ob = imgroup->state.ob; + BLI_assert(gz_prop->type->array_length == 16); + struct EmptyImageWidgetGroup *igzgroup = gz_prop->custom_func.user_data; + const Object *ob = igzgroup->state.ob; unit_m4(matrix); matrix[0][0] = ob->empty_drawsize; matrix[1][1] = ob->empty_drawsize; float dims[2] = {0.0f, 0.0f}; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); dims[0] *= ob->empty_drawsize; dims[1] *= ob->empty_drawsize; @@ -85,18 +85,18 @@ static void gizmo_empty_image_prop_matrix_get( } static void gizmo_empty_image_prop_matrix_set( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { const float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data; - Object *ob = imgroup->state.ob; + BLI_assert(gz_prop->type->array_length == 16); + struct EmptyImageWidgetGroup *igzgroup = gz_prop->custom_func.user_data; + Object *ob = igzgroup->state.ob; ob->empty_drawsize = matrix[0][0]; float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); dims[0] *= ob->empty_drawsize; dims[1] *= ob->empty_drawsize; @@ -104,12 +104,12 @@ static void gizmo_empty_image_prop_matrix_set( ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1]; } -static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -122,36 +122,36 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UN return false; } -static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { - struct EmptyImageWidgetGroup *imgroup = MEM_mallocN(sizeof(struct EmptyImageWidgetGroup), __func__); - imgroup->gizmo = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); - wmGizmo *mpr = imgroup->gizmo; - RNA_enum_set(mpr->ptr, "transform", + struct EmptyImageWidgetGroup *igzgroup = MEM_mallocN(sizeof(struct EmptyImageWidgetGroup), __func__); + igzgroup->gizmo = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL); + wmGizmo *gz = igzgroup->gizmo; + RNA_enum_set(gz->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); - mgroup->customdata = imgroup; + gzgroup->customdata = igzgroup; - WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_HOVER, true); + WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_HOVER, true); - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi); } -static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - struct EmptyImageWidgetGroup *imgroup = mgroup->customdata; + struct EmptyImageWidgetGroup *igzgroup = gzgroup->customdata; Object *ob = CTX_data_active_object(C); - wmGizmo *mpr = imgroup->gizmo; + wmGizmo *gz = igzgroup->gizmo; - copy_m4_m4(mpr->matrix_basis, ob->obmat); + copy_m4_m4(gz->matrix_basis, ob->obmat); - RNA_enum_set(mpr->ptr, "transform", + RNA_enum_set(gz->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM); - imgroup->state.ob = ob; + igzgroup->state.ob = ob; /* Use dimensions for aspect. */ if (ob->data != NULL) { @@ -169,36 +169,36 @@ static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *mgr } const float dims_max = max_ff(size[0], size[1]); - imgroup->state.dims[0] = size[0] / dims_max; - imgroup->state.dims[1] = size[1] / dims_max; + igzgroup->state.dims[0] = size[0] / dims_max; + igzgroup->state.dims[1] = size[1] / dims_max; } else { - copy_v2_fl(imgroup->state.dims, 1.0f); + copy_v2_fl(igzgroup->state.dims, 1.0f); } - RNA_float_set_array(mpr->ptr, "dimensions", imgroup->state.dims); + RNA_float_set_array(gz->ptr, "dimensions", igzgroup->state.dims); WM_gizmo_target_property_def_func( - mpr, "matrix", + gz, "matrix", &(const struct wmGizmoPropertyFnParams) { .value_get_fn = gizmo_empty_image_prop_matrix_get, .value_set_fn = gizmo_empty_image_prop_matrix_set, .range_get_fn = NULL, - .user_data = imgroup, + .user_data = igzgroup, }); } -void VIEW3D_WGT_empty_image(wmGizmoGroupType *wgt) +void VIEW3D_GGT_empty_image(wmGizmoGroupType *gzgt) { - wgt->name = "Area Light Widgets"; - wgt->idname = "VIEW3D_WGT_empty_image"; + gzgt->name = "Area Light Widgets"; + gzgt->idname = "VIEW3D_GGT_empty_image"; - wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_DEPTH_3D); - wgt->poll = WIDGETGROUP_empty_image_poll; - wgt->setup = WIDGETGROUP_empty_image_setup; - wgt->refresh = WIDGETGROUP_empty_image_refresh; + gzgt->poll = WIDGETGROUP_empty_image_poll; + gzgt->setup = WIDGETGROUP_empty_image_setup; + gzgt->refresh = WIDGETGROUP_empty_image_refresh; } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c index d4605bb0c7d..e2a8d2802e7 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c @@ -52,12 +52,12 @@ /** \name Force Field Gizmos * \{ */ -static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -67,26 +67,26 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNU return (ob && ob->pd && ob->pd->forcefield); } -static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { /* only wind effector for now */ wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); - mgroup->customdata = wwrapper; + gzgroup->customdata = wwrapper; - wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_arrow_3d", mgroup, NULL); - wmGizmo *mpr = wwrapper->gizmo; - RNA_enum_set(mpr->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); - ED_gizmo_arrow3d_set_ui_range(mpr, -200.0f, 200.0f); - ED_gizmo_arrow3d_set_range_fac(mpr, 6.0f); + wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_arrow_3d", gzgroup, NULL); + wmGizmo *gz = wwrapper->gizmo; + RNA_enum_set(gz->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED); + ED_gizmo_arrow3d_set_ui_range(gz, -200.0f, 200.0f); + ED_gizmo_arrow3d_set_range_fac(gz, 6.0f); - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi); } -static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - wmGizmoWrapper *wwrapper = mgroup->customdata; - wmGizmo *mpr = wwrapper->gizmo; + wmGizmoWrapper *wwrapper = gzgroup->customdata; + wmGizmo *gz = wwrapper->gizmo; Object *ob = CTX_data_active_object(C); PartDeflect *pd = ob->pd; @@ -96,30 +96,30 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *mgro PointerRNA field_ptr; RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd, &field_ptr); - WM_gizmo_set_matrix_location(mpr, ob->obmat[3]); - WM_gizmo_set_matrix_rotation_from_z_axis(mpr, ob->obmat[2]); - WM_gizmo_set_matrix_offset_location(mpr, ofs); - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); - WM_gizmo_target_property_def_rna(mpr, "offset", &field_ptr, "strength", -1); + WM_gizmo_set_matrix_location(gz, ob->obmat[3]); + WM_gizmo_set_matrix_rotation_from_z_axis(gz, ob->obmat[2]); + WM_gizmo_set_matrix_offset_location(gz, ofs); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); + WM_gizmo_target_property_def_rna(gz, "offset", &field_ptr, "strength", -1); } else { - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true); } } -void VIEW3D_WGT_force_field(wmGizmoGroupType *wgt) +void VIEW3D_GGT_force_field(wmGizmoGroupType *gzgt) { - wgt->name = "Force Field Widgets"; - wgt->idname = "VIEW3D_WGT_force_field"; + gzgt->name = "Force Field Widgets"; + gzgt->idname = "VIEW3D_GGT_force_field"; - wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_SCALE | WM_GIZMOGROUPTYPE_DEPTH_3D); - wgt->poll = WIDGETGROUP_forcefield_poll; - wgt->setup = WIDGETGROUP_forcefield_setup; - wgt->refresh = WIDGETGROUP_forcefield_refresh; + gzgt->poll = WIDGETGROUP_forcefield_poll; + gzgt->setup = WIDGETGROUP_forcefield_setup; + gzgt->refresh = WIDGETGROUP_forcefield_refresh; } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_lamp.c b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c index a872cc96172..057c085b69d 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_lamp.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c @@ -52,11 +52,11 @@ /** \name Spot Lamp Gizmos * \{ */ -static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) { return false; } @@ -70,53 +70,53 @@ static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmGizmoGroupType *UNUS return false; } -static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); - wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_arrow_3d", mgroup, NULL); - wmGizmo *mpr = wwrapper->gizmo; - RNA_enum_set(mpr->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_INVERTED); + wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_arrow_3d", gzgroup, NULL); + wmGizmo *gz = wwrapper->gizmo; + RNA_enum_set(gz->ptr, "transform", ED_GIZMO_ARROW_XFORM_FLAG_INVERTED); - mgroup->customdata = wwrapper; + gzgroup->customdata = wwrapper; - ED_gizmo_arrow3d_set_range_fac(mpr, 4.0f); + ED_gizmo_arrow3d_set_range_fac(gz, 4.0f); - UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, mpr->color); + UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, gz->color); } -static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - wmGizmoWrapper *wwrapper = mgroup->customdata; - wmGizmo *mpr = wwrapper->gizmo; + wmGizmoWrapper *wwrapper = gzgroup->customdata; + wmGizmo *gz = wwrapper->gizmo; Object *ob = CTX_data_active_object(C); Lamp *la = ob->data; float dir[3]; negate_v3_v3(dir, ob->obmat[2]); - WM_gizmo_set_matrix_rotation_from_z_axis(mpr, dir); - WM_gizmo_set_matrix_location(mpr, ob->obmat[3]); + WM_gizmo_set_matrix_rotation_from_z_axis(gz, dir); + WM_gizmo_set_matrix_location(gz, ob->obmat[3]); /* need to set property here for undo. TODO would prefer to do this in _init */ PointerRNA lamp_ptr; const char *propname = "spot_size"; RNA_pointer_create(&la->id, &RNA_Light, la, &lamp_ptr); - WM_gizmo_target_property_def_rna(mpr, "offset", &lamp_ptr, propname, -1); + WM_gizmo_target_property_def_rna(gz, "offset", &lamp_ptr, propname, -1); } -void VIEW3D_WGT_lamp_spot(wmGizmoGroupType *wgt) +void VIEW3D_GGT_lamp_spot(wmGizmoGroupType *gzgt) { - wgt->name = "Spot Light Widgets"; - wgt->idname = "VIEW3D_WGT_lamp_spot"; + gzgt->name = "Spot Light Widgets"; + gzgt->idname = "VIEW3D_GGT_lamp_spot"; - wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_DEPTH_3D); - wgt->poll = WIDGETGROUP_lamp_spot_poll; - wgt->setup = WIDGETGROUP_lamp_spot_setup; - wgt->refresh = WIDGETGROUP_lamp_spot_refresh; + gzgt->poll = WIDGETGROUP_lamp_spot_poll; + gzgt->setup = WIDGETGROUP_lamp_spot_setup; + gzgt->refresh = WIDGETGROUP_lamp_spot_refresh; } /** \} */ @@ -128,24 +128,24 @@ void VIEW3D_WGT_lamp_spot(wmGizmoGroupType *wgt) /* scale callbacks */ static void gizmo_area_lamp_prop_matrix_get( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, void *value_p) { - BLI_assert(mpr_prop->type->array_length == 16); + BLI_assert(gz_prop->type->array_length == 16); float (*matrix)[4] = value_p; - const Lamp *la = mpr_prop->custom_func.user_data; + const Lamp *la = gz_prop->custom_func.user_data; matrix[0][0] = la->area_size; matrix[1][1] = ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE) ? la->area_sizey : la->area_size; } static void gizmo_area_lamp_prop_matrix_set( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, const void *value_p) { const float (*matrix)[4] = value_p; - BLI_assert(mpr_prop->type->array_length == 16); - Lamp *la = mpr_prop->custom_func.user_data; + BLI_assert(gz_prop->type->array_length == 16); + Lamp *la = gz_prop->custom_func.user_data; if (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE)) { la->area_size = len_v3(matrix[0]); @@ -156,7 +156,7 @@ static void gizmo_area_lamp_prop_matrix_set( } } -static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); if (v3d->flag2 & V3D_RENDER_OVERRIDE) { @@ -171,40 +171,40 @@ static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmGizmoGroupType *UNUS return false; } -static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); - wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_cage_2d", mgroup, NULL); - wmGizmo *mpr = wwrapper->gizmo; - RNA_enum_set(mpr->ptr, "transform", + wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_cage_2d", gzgroup, NULL); + wmGizmo *gz = wwrapper->gizmo; + RNA_enum_set(gz->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE); - mgroup->customdata = wwrapper; + gzgroup->customdata = wwrapper; - WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_HOVER, true); + WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_HOVER, true); - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi); } -static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - wmGizmoWrapper *wwrapper = mgroup->customdata; + wmGizmoWrapper *wwrapper = gzgroup->customdata; Object *ob = CTX_data_active_object(C); Lamp *la = ob->data; - wmGizmo *mpr = wwrapper->gizmo; + wmGizmo *gz = wwrapper->gizmo; - copy_m4_m4(mpr->matrix_basis, ob->obmat); + copy_m4_m4(gz->matrix_basis, ob->obmat); int flag = ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE; if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) { flag |= ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM; } - RNA_enum_set(mpr->ptr, "transform", flag); + RNA_enum_set(gz->ptr, "transform", flag); /* need to set property here for undo. TODO would prefer to do this in _init */ WM_gizmo_target_property_def_func( - mpr, "matrix", + gz, "matrix", &(const struct wmGizmoPropertyFnParams) { .value_get_fn = gizmo_area_lamp_prop_matrix_get, .value_set_fn = gizmo_area_lamp_prop_matrix_set, @@ -213,18 +213,18 @@ static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmGizmoGroup *mgrou }); } -void VIEW3D_WGT_lamp_area(wmGizmoGroupType *wgt) +void VIEW3D_GGT_lamp_area(wmGizmoGroupType *gzgt) { - wgt->name = "Area Light Widgets"; - wgt->idname = "VIEW3D_WGT_lamp_area"; + gzgt->name = "Area Light Widgets"; + gzgt->idname = "VIEW3D_GGT_lamp_area"; - wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_DEPTH_3D); - wgt->poll = WIDGETGROUP_lamp_area_poll; - wgt->setup = WIDGETGROUP_lamp_area_setup; - wgt->refresh = WIDGETGROUP_lamp_area_refresh; + gzgt->poll = WIDGETGROUP_lamp_area_poll; + gzgt->setup = WIDGETGROUP_lamp_area_setup; + gzgt->refresh = WIDGETGROUP_lamp_area_refresh; } /** \} */ @@ -235,7 +235,7 @@ void VIEW3D_WGT_lamp_area(wmGizmoGroupType *wgt) /** \name Lamp Target Gizmo * \{ */ -static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); if (v3d->flag2 & V3D_RENDER_OVERRIDE) { @@ -258,50 +258,50 @@ static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmGizmoGroupType *UN return false; } -static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { wmGizmoWrapper *wwrapper = MEM_mallocN(sizeof(wmGizmoWrapper), __func__); - wwrapper->gizmo = WM_gizmo_new("GIZMO_WT_grab_3d", mgroup, NULL); - wmGizmo *mpr = wwrapper->gizmo; + wwrapper->gizmo = WM_gizmo_new("GIZMO_GT_grab_3d", gzgroup, NULL); + wmGizmo *gz = wwrapper->gizmo; - mgroup->customdata = wwrapper; + gzgroup->customdata = wwrapper; - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, mpr->color); - UI_GetThemeColor3fv(TH_GIZMO_HI, mpr->color_hi); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); + UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi); - mpr->scale_basis = 0.06f; + gz->scale_basis = 0.06f; wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_transform_axis_target", true); - RNA_enum_set(mpr->ptr, "draw_options", + RNA_enum_set(gz->ptr, "draw_options", ED_GIZMO_GRAB_DRAW_FLAG_FILL | ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW); - WM_gizmo_operator_set(mpr, 0, ot, NULL); + WM_gizmo_operator_set(gz, 0, ot, NULL); } -static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - wmGizmoWrapper *wwrapper = mgroup->customdata; + wmGizmoWrapper *wwrapper = gzgroup->customdata; Object *ob = CTX_data_active_object(C); - wmGizmo *mpr = wwrapper->gizmo; + wmGizmo *gz = wwrapper->gizmo; - copy_m4_m4(mpr->matrix_basis, ob->obmat); - unit_m4(mpr->matrix_offset); - mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis; - WM_gizmo_set_flag(mpr, WM_GIZMO_DRAW_OFFSET_SCALE, true); + copy_m4_m4(gz->matrix_basis, ob->obmat); + unit_m4(gz->matrix_offset); + gz->matrix_offset[3][2] = -2.4f / gz->scale_basis; + WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_OFFSET_SCALE, true); } -void VIEW3D_WGT_lamp_target(wmGizmoGroupType *wgt) +void VIEW3D_GGT_lamp_target(wmGizmoGroupType *gzgt) { - wgt->name = "Target Light Widgets"; - wgt->idname = "VIEW3D_WGT_lamp_target"; + gzgt->name = "Target Light Widgets"; + gzgt->idname = "VIEW3D_GGT_lamp_target"; - wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_3D); - wgt->poll = WIDGETGROUP_lamp_target_poll; - wgt->setup = WIDGETGROUP_lamp_target_setup; - wgt->draw_prepare = WIDGETGROUP_lamp_target_draw_prepare; + gzgt->poll = WIDGETGROUP_lamp_target_poll; + gzgt->setup = WIDGETGROUP_lamp_target_setup; + gzgt->draw_prepare = WIDGETGROUP_lamp_target_draw_prepare; } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index f4a8bad7e30..388d9a29eff 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -134,28 +134,28 @@ struct NavigateGizmoInfo { struct NavigateGizmoInfo g_navigate_params[MPR_TOTAL] = { { .opname = "VIEW3D_OT_move", - .gizmo = "GIZMO_WT_button_2d", + .gizmo = "GIZMO_GT_button_2d", .SHAPE_VARS(shape_pan), }, { .opname = "VIEW3D_OT_rotate", - .gizmo = "VIEW3D_WT_navigate_rotate", + .gizmo = "VIEW3D_GT_navigate_rotate", .shape = NULL, .shape_size = 0, }, { .opname = "VIEW3D_OT_zoom", - .gizmo = "GIZMO_WT_button_2d", + .gizmo = "GIZMO_GT_button_2d", .SHAPE_VARS(shape_zoom), }, { .opname = "VIEW3D_OT_view_persportho", - .gizmo = "GIZMO_WT_button_2d", + .gizmo = "GIZMO_GT_button_2d", .SHAPE_VARS(shape_persp), }, { .opname = "VIEW3D_OT_view_persportho", - .gizmo = "GIZMO_WT_button_2d", + .gizmo = "GIZMO_GT_button_2d", .SHAPE_VARS(shape_ortho), }, { .opname = "VIEW3D_OT_view_camera", - .gizmo = "GIZMO_WT_button_2d", + .gizmo = "GIZMO_GT_button_2d", .SHAPE_VARS(shape_camera), }, }; @@ -163,7 +163,7 @@ struct NavigateGizmoInfo g_navigate_params[MPR_TOTAL] = { #undef SHAPE_VARS struct NavigateWidgetGroup { - wmGizmo *mpr_array[MPR_TOTAL]; + wmGizmo *gz_array[MPR_TOTAL]; /* Store the view state to check for changes. */ struct { rcti rect_visible; @@ -176,12 +176,12 @@ struct NavigateWidgetGroup { int region_size[2]; }; -static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); if (((U.uiflag & USER_SHOW_GIZMO_AXIS) == 0) || (v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) { return false; } @@ -189,7 +189,7 @@ static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType *UNUSE } -static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { struct NavigateWidgetGroup *navgroup = MEM_callocN(sizeof(struct NavigateWidgetGroup), __func__); @@ -201,53 +201,53 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup * for (int i = 0; i < MPR_TOTAL; i++) { const struct NavigateGizmoInfo *info = &g_navigate_params[i]; - navgroup->mpr_array[i] = WM_gizmo_new(info->gizmo, mgroup, NULL); - wmGizmo *mpr = navgroup->mpr_array[i]; - mpr->flag |= WM_GIZMO_GRAB_CURSOR | WM_GIZMO_DRAW_MODAL; - mpr->color[3] = 0.2f; - mpr->color_hi[3] = 0.4f; + navgroup->gz_array[i] = WM_gizmo_new(info->gizmo, gzgroup, NULL); + wmGizmo *gz = navgroup->gz_array[i]; + gz->flag |= WM_GIZMO_GRAB_CURSOR | WM_GIZMO_DRAW_MODAL; + gz->color[3] = 0.2f; + gz->color_hi[3] = 0.4f; /* may be overwritten later */ - mpr->scale_basis = (GIZMO_SIZE * GIZMO_MINI_FAC) / 2; + gz->scale_basis = (GIZMO_SIZE * GIZMO_MINI_FAC) / 2; if (info->shape != NULL) { - PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "shape"); + PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "shape"); RNA_property_string_set_bytes( - mpr->ptr, prop, + gz->ptr, prop, (const char *)info->shape, info->shape_size); - RNA_enum_set(mpr->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_OUTLINE); + RNA_enum_set(gz->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_OUTLINE); } wmOperatorType *ot = WM_operatortype_find(info->opname, true); - WM_gizmo_operator_set(mpr, 0, ot, NULL); + WM_gizmo_operator_set(gz, 0, ot, NULL); } { - wmGizmo *mpr = navgroup->mpr_array[MPR_CAMERA]; - WM_gizmo_operator_set(mpr, 0, ot_view_camera, NULL); + wmGizmo *gz = navgroup->gz_array[MPR_CAMERA]; + WM_gizmo_operator_set(gz, 0, ot_view_camera, NULL); } /* Click only buttons (not modal). */ { - int mpr_ids[] = {MPR_PERSP, MPR_ORTHO, MPR_CAMERA}; - for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) { - wmGizmo *mpr = navgroup->mpr_array[mpr_ids[i]]; - RNA_boolean_set(mpr->ptr, "show_drag", false); + int gz_ids[] = {MPR_PERSP, MPR_ORTHO, MPR_CAMERA}; + for (int i = 0; i < ARRAY_SIZE(gz_ids); i++) { + wmGizmo *gz = navgroup->gz_array[gz_ids[i]]; + RNA_boolean_set(gz->ptr, "show_drag", false); } } /* Modal operators, don't use initial mouse location since we're clicking on a button. */ { - int mpr_ids[] = {MPR_MOVE, MPR_ROTATE, MPR_ZOOM}; - for (int i = 0; i < ARRAY_SIZE(mpr_ids); i++) { - wmGizmo *mpr = navgroup->mpr_array[mpr_ids[i]]; - wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, 0); + int gz_ids[] = {MPR_MOVE, MPR_ROTATE, MPR_ZOOM}; + for (int i = 0; i < ARRAY_SIZE(gz_ids); i++) { + wmGizmo *gz = navgroup->gz_array[gz_ids[i]]; + wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, 0); RNA_boolean_set(&mpop->ptr, "use_mouse_init", false); } } { - wmGizmo *mpr = navgroup->mpr_array[MPR_ROTATE]; - mpr->scale_basis = GIZMO_SIZE / 2; + wmGizmo *gz = navgroup->gz_array[MPR_ROTATE]; + gz->scale_basis = GIZMO_SIZE / 2; char mapping[6] = { RV3D_VIEW_LEFT, RV3D_VIEW_RIGHT, @@ -258,25 +258,25 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup * }; for (int part_index = 0; part_index < 6; part_index += 1) { - PointerRNA *ptr = WM_gizmo_operator_set(mpr, part_index + 1, ot_view_axis, NULL); + PointerRNA *ptr = WM_gizmo_operator_set(gz, part_index + 1, ot_view_axis, NULL); RNA_enum_set(ptr, "type", mapping[part_index]); } /* When dragging an axis, use this instead. */ - mpr->drag_part = 0; + gz->drag_part = 0; } - mgroup->customdata = navgroup; + gzgroup->customdata = navgroup; } -static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - struct NavigateWidgetGroup *navgroup = mgroup->customdata; + struct NavigateWidgetGroup *navgroup = gzgroup->customdata; ARegion *ar = CTX_wm_region(C); const RegionView3D *rv3d = ar->regiondata; for (int i = 0; i < 3; i++) { - copy_v3_v3(navgroup->mpr_array[MPR_ROTATE]->matrix_offset[i], rv3d->viewmat[i]); + copy_v3_v3(navgroup->gz_array[MPR_ROTATE]->matrix_offset[i], rv3d->viewmat[i]); } rcti rect_visible; @@ -312,60 +312,60 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *m rect_visible.ymax - icon_offset_mini * 0.75f, }; - wmGizmo *mpr; + wmGizmo *gz; - for (uint i = 0; i < ARRAY_SIZE(navgroup->mpr_array); i++) { - mpr = navgroup->mpr_array[i]; - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); + for (uint i = 0; i < ARRAY_SIZE(navgroup->gz_array); i++) { + gz = navgroup->gz_array[i]; + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true); } /* RV3D_LOCKED or Camera: only show supported buttons. */ if (show_rotate) { - mpr = navgroup->mpr_array[MPR_ROTATE]; - mpr->matrix_basis[3][0] = co_rotate[0]; - mpr->matrix_basis[3][1] = co_rotate[1]; - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + gz = navgroup->gz_array[MPR_ROTATE]; + gz->matrix_basis[3][0] = co_rotate[0]; + gz->matrix_basis[3][1] = co_rotate[1]; + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); } int icon_mini_slot = 0; - mpr = navgroup->mpr_array[MPR_ZOOM]; - mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); - mpr->matrix_basis[3][1] = co[1]; - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + gz = navgroup->gz_array[MPR_ZOOM]; + gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); + gz->matrix_basis[3][1] = co[1]; + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); - mpr = navgroup->mpr_array[MPR_MOVE]; - mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); - mpr->matrix_basis[3][1] = co[1]; - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + gz = navgroup->gz_array[MPR_MOVE]; + gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); + gz->matrix_basis[3][1] = co[1]; + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); if ((rv3d->viewlock & RV3D_LOCKED) == 0) { - mpr = navgroup->mpr_array[MPR_CAMERA]; - mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); - mpr->matrix_basis[3][1] = co[1]; - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + gz = navgroup->gz_array[MPR_CAMERA]; + gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); + gz->matrix_basis[3][1] = co[1]; + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); if (navgroup->state.rv3d.is_camera == false) { - mpr = navgroup->mpr_array[rv3d->is_persp ? MPR_PERSP : MPR_ORTHO]; - mpr->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); - mpr->matrix_basis[3][1] = co[1]; - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); + gz = navgroup->gz_array[rv3d->is_persp ? MPR_PERSP : MPR_ORTHO]; + gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++); + gz->matrix_basis[3][1] = co[1]; + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); } } } -void VIEW3D_WGT_navigate(wmGizmoGroupType *wgt) +void VIEW3D_GGT_navigate(wmGizmoGroupType *gzgt) { - wgt->name = "View3D Navigate"; - wgt->idname = "VIEW3D_WGT_navigate"; + gzgt->name = "View3D Navigate"; + gzgt->idname = "VIEW3D_GGT_navigate"; - wgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | + gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_SCALE | WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL); - wgt->poll = WIDGETGROUP_navigate_poll; - wgt->setup = WIDGETGROUP_navigate_setup; - wgt->draw_prepare = WIDGETGROUP_navigate_draw_prepare; + gzgt->poll = WIDGETGROUP_navigate_poll; + gzgt->setup = WIDGETGROUP_navigate_setup; + gzgt->draw_prepare = WIDGETGROUP_navigate_draw_prepare; } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 041fe343526..f296c2ee874 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -168,9 +168,9 @@ static void draw_xyz_wire( immEnd(); } -static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool UNUSED(select)) +static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool UNUSED(select)) { - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); Gwn_VertFormat *format = immVertexFormat(); const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -182,12 +182,12 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool char axis; char is_pos; } axis_order[6] = { - {-mpr->matrix_offset[0][2], 0, 0, false}, - {+mpr->matrix_offset[0][2], 1, 0, true}, - {-mpr->matrix_offset[1][2], 2, 1, false}, - {+mpr->matrix_offset[1][2], 3, 1, true}, - {-mpr->matrix_offset[2][2], 4, 2, false}, - {+mpr->matrix_offset[2][2], 5, 2, true}, + {-gz->matrix_offset[0][2], 0, 0, false}, + {+gz->matrix_offset[0][2], 1, 0, true}, + {-gz->matrix_offset[1][2], 2, 1, false}, + {+gz->matrix_offset[1][2], 3, 1, true}, + {-gz->matrix_offset[2][2], 4, 2, false}, + {+gz->matrix_offset[2][2], 5, 2, true}, }; qsort(&axis_order, ARRAY_SIZE(axis_order), sizeof(axis_order[0]), BLI_sortutil_cmp_float); @@ -196,13 +196,13 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool static const float axis_black[4] = {0, 0, 0, 1}; static float axis_color[3][4]; gpuPushMatrix(); - gpuMultMatrix(mpr->matrix_offset); + gpuMultMatrix(gz->matrix_offset); bool draw_center_done = false; int axis_align = -1; for (int axis = 0; axis < 3; axis++) { - if (len_squared_v2(mpr->matrix_offset[axis]) < 1e-6f) { + if (len_squared_v2(gz->matrix_offset[axis]) < 1e-6f) { axis_align = axis; break; } @@ -212,7 +212,7 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool const int index = axis_order[axis_index].index; const int axis = axis_order[axis_index].axis; const bool is_pos = axis_order[axis_index].is_pos; - const bool is_highlight = index + 1 == mpr->highlight_part; + const bool is_highlight = index + 1 == gz->highlight_part; /* Draw slightly before, so axis aligned arrows draw ontop. */ if ((draw_center_done == false) && (axis_order[axis_index].depth > -0.01f)) { @@ -223,7 +223,7 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool immUniformColor4fv(color); imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION); gpuPushMatrix(); - gpuMultMatrix(mpr->matrix_offset); + gpuMultMatrix(gz->matrix_offset); } draw_center_done = true; } @@ -237,7 +237,7 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool bool ok = true; /* skip view align axis */ - if ((axis_align == axis) && (mpr->matrix_offset[axis][2] > 0.0f) == is_pos) { + if ((axis_align == axis) && (gz->matrix_offset[axis][2] > 0.0f) == is_pos) { ok = false; } if (ok) { @@ -291,7 +291,7 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool if (is_pos) { GPU_line_width(1.0f); float m3[3][3]; - copy_m3_m4(m3, mpr->matrix_offset); + copy_m3_m4(m3, gz->matrix_offset); immUniformColor4fv(is_highlight ? axis_black : axis_highlight); draw_xyz_wire(pos_id, m3, v_final, 1.0, axis); } @@ -303,17 +303,17 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool } static void axis3d_draw_intern( - const bContext *UNUSED(C), wmGizmo *mpr, + const bContext *UNUSED(C), wmGizmo *gz, const bool select, const bool highlight) { - const float *color = highlight ? mpr->color_hi : mpr->color; + const float *color = highlight ? gz->color_hi : gz->color; float matrix_final[4][4]; float matrix_unit[4][4]; unit_m4(matrix_unit); WM_gizmo_calc_matrix_final_params( - mpr, + gz, &((struct WM_GizmoMatrixParams) { .matrix_offset = matrix_unit, }), matrix_final); @@ -322,29 +322,29 @@ static void axis3d_draw_intern( gpuMultMatrix(matrix_final); GPU_blend(true); - axis_geom_draw(mpr, color, select); + axis_geom_draw(gz, color, select); GPU_blend(false); gpuPopMatrix(); } -static void gizmo_axis_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_axis_draw(const bContext *C, wmGizmo *gz) { - const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL; + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; (void)is_modal; GPU_blend(true); - axis3d_draw_intern(C, mpr, false, is_highlight); + axis3d_draw_intern(C, gz, false, is_highlight); GPU_blend(false); } static int gizmo_axis_test_select( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { float point_local[2] = {UNPACK2(event->mval)}; - sub_v2_v2(point_local, mpr->matrix_basis[3]); - mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC)); + sub_v2_v2(point_local, gz->matrix_basis[3]); + mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC)); const float len_sq = len_squared_v2(point_local); if (len_sq > 1.0) { @@ -358,14 +358,14 @@ static int gizmo_axis_test_select( for (int i = 0; i < 3; i++) { for (int is_pos = 0; is_pos < 2; is_pos++) { float co[2] = { - mpr->matrix_offset[i][0] * (is_pos ? 1 : -1), - mpr->matrix_offset[i][1] * (is_pos ? 1 : -1), + gz->matrix_offset[i][0] * (is_pos ? 1 : -1), + gz->matrix_offset[i][1] * (is_pos ? 1 : -1), }; bool ok = true; /* Check if we're viewing on an axis, there is no point to clicking on the current axis so show the reverse. */ - if (len_squared_v2(co) < 1e-6f && (mpr->matrix_offset[i][2] > 0.0f) == is_pos) { + if (len_squared_v2(co) < 1e-6f && (gz->matrix_offset[i][2] > 0.0f) == is_pos) { ok = false; } @@ -384,7 +384,7 @@ static int gizmo_axis_test_select( return part_best; } - /* The 'mpr->scale_final' is already applied when projecting. */ + /* The 'gz->scale_final' is already applied when projecting. */ if (len_sq < 1.0f) { return 0; } @@ -392,23 +392,23 @@ static int gizmo_axis_test_select( return -1; } -static int gizmo_axis_cursor_get(wmGizmo *mpr) +static int gizmo_axis_cursor_get(wmGizmo *gz) { - if (mpr->highlight_part > 0) { + if (gz->highlight_part > 0) { return CURSOR_EDIT; } return BC_NSEW_SCROLLCURSOR; } -void VIEW3D_WT_navigate_rotate(wmGizmoType *wt) +void VIEW3D_GT_navigate_rotate(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "VIEW3D_WT_navigate_rotate"; + gzt->idname = "VIEW3D_GT_navigate_rotate"; /* api callbacks */ - wt->draw = gizmo_axis_draw; - wt->test_select = gizmo_axis_test_select; - wt->cursor_get = gizmo_axis_cursor_get; + gzt->draw = gizmo_axis_draw; + gzt->test_select = gizmo_axis_test_select; + gzt->cursor_get = gizmo_axis_cursor_get; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index ac6a984bea5..db7ba040b3b 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -68,7 +68,7 @@ #include "BLF_api.h" -static const char *view3d_wgt_ruler_id = "VIEW3D_WGT_ruler"; +static const char *view3d_gzgt_ruler_id = "VIEW3D_GGT_ruler"; #define MVAL_MAX_PX_DIST 12.0f @@ -123,7 +123,7 @@ typedef struct RulerInfo { /* Ruler Item (two or three points) */ typedef struct RulerItem { - wmGizmo mpr; + wmGizmo gz; /* worldspace coords, middle being optional */ float co[3][3]; @@ -143,18 +143,18 @@ typedef struct RulerInteraction { /** \name Internal Ruler Utilities * \{ */ -static RulerItem *ruler_item_add(wmGizmoGroup *mgroup) +static RulerItem *ruler_item_add(wmGizmoGroup *gzgroup) { /* could pass this as an arg */ - const wmGizmoType *wt_ruler = WM_gizmotype_find("VIEW3D_WT_ruler_item", true); - RulerItem *ruler_item = (RulerItem *)WM_gizmo_new_ptr(wt_ruler, mgroup, NULL); - WM_gizmo_set_flag(&ruler_item->mpr, WM_GIZMO_DRAW_MODAL, true); + const wmGizmoType *gzt_ruler = WM_gizmotype_find("VIEW3D_GT_ruler_item", true); + RulerItem *ruler_item = (RulerItem *)WM_gizmo_new_ptr(gzt_ruler, gzgroup, NULL); + WM_gizmo_set_flag(&ruler_item->gz, WM_GIZMO_DRAW_MODAL, true); return ruler_item; } -static void ruler_item_remove(bContext *C, wmGizmoGroup *mgroup, RulerItem *ruler_item) +static void ruler_item_remove(bContext *C, wmGizmoGroup *gzgroup, RulerItem *ruler_item) { - WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, &ruler_item->mpr, C); + WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, &ruler_item->gz, C); } static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit, @@ -192,10 +192,10 @@ static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit, } static bool view3d_ruler_pick( - wmGizmoGroup *mgroup, RulerItem *ruler_item, const float mval[2], + wmGizmoGroup *gzgroup, RulerItem *ruler_item, const float mval[2], int *r_co_index) { - RulerInfo *ruler_info = mgroup->customdata; + RulerInfo *ruler_info = gzgroup->customdata; ARegion *ar = ruler_info->ar; bool found = false; @@ -304,7 +304,7 @@ static bool view3d_ruler_item_mousemove( RulerInfo *ruler_info, RulerItem *ruler_item, const int mval[2], const bool do_thickness, const bool do_snap) { - RulerInteraction *inter = ruler_item->mpr.interaction_data; + RulerInteraction *inter = ruler_item->gz.interaction_data; const float eps_bias = 0.0002f; float dist_px = MVAL_MAX_PX_DIST * U.pixelsize; /* snap dist */ @@ -380,9 +380,9 @@ static bool view3d_ruler_item_mousemove( * \{ */ #define RULER_ID "RulerData3D" -static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *mgroup) +static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup) { - // RulerInfo *ruler_info = mgroup->customdata; + // RulerInfo *ruler_info = gzgroup->customdata; Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bGPDlayer *gpl; @@ -419,7 +419,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *mgroup) gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); BKE_gpencil_free_strokes(gpf); - for (ruler_item = mgroup->gizmos.first; ruler_item; ruler_item = (RulerItem *)ruler_item->mpr.next) { + for (ruler_item = gzgroup->gizmos.first; ruler_item; ruler_item = (RulerItem *)ruler_item->gz.next) { bGPDspoint *pt; int j; @@ -457,7 +457,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *mgroup) return changed; } -static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *mgroup) +static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *gzgroup) { Scene *scene = CTX_data_scene(C); bool changed = false; @@ -476,7 +476,7 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *mgroup) int j; RulerItem *ruler_item = NULL; if (gps->totpoints == 3) { - ruler_item = ruler_item_add(mgroup); + ruler_item = ruler_item_add(gzgroup); for (j = 0; j < 3; j++) { copy_v3_v3(ruler_item->co[j], &pt->x); pt++; @@ -485,7 +485,7 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *mgroup) changed = true; } else if (gps->totpoints == 2) { - ruler_item = ruler_item_add(mgroup); + ruler_item = ruler_item_add(gzgroup); for (j = 0; j < 3; j += 2) { copy_v3_v3(ruler_item->co[j], &pt->x); pt++; @@ -506,12 +506,12 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *mgroup) /** \name Ruler Item Gizmo Type * \{ */ -static void gizmo_ruler_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) { Scene *scene = CTX_data_scene(C); UnitSettings *unit = &scene->unit; - RulerInfo *ruler_info = mpr->parent_mgroup->customdata; - RulerItem *ruler_item = (RulerItem *)mpr; + RulerInfo *ruler_info = gz->parent_gzgroup->customdata; + RulerItem *ruler_item = (RulerItem *)gz; ARegion *ar = ruler_info->ar; RegionView3D *rv3d = ar->regiondata; const float cap_size = 4.0f; @@ -536,7 +536,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *mpr) UI_GetThemeColor3ubv(TH_TEXT, color_text); UI_GetThemeColor3ubv(TH_WIRE, color_wire); - const bool is_act = (mpr->flag & WM_GIZMO_DRAW_HOVER); + const bool is_act = (gz->flag & WM_GIZMO_DRAW_HOVER); float dir_ruler[2]; float co_ss[3][2]; int j; @@ -785,9 +785,9 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *mpr) /* draw snap */ if ((ruler_info->snap_flag & RULER_SNAP_OK) && (ruler_info->state == RULER_STATE_DRAG) && - (ruler_item->mpr.interaction_data != NULL)) + (ruler_item->gz.interaction_data != NULL)) { - RulerInteraction *inter = ruler_item->mpr.interaction_data; + RulerInteraction *inter = ruler_item->gz.interaction_data; /* size from drawSnapping */ const float size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); float co_ss_snap[3]; @@ -805,14 +805,14 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *mpr) } static int gizmo_ruler_test_select( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { - RulerItem *ruler_item_pick = (RulerItem *)mpr; + RulerItem *ruler_item_pick = (RulerItem *)gz; float mval_fl[2] = {UNPACK2(event->mval)}; int co_index; /* select and drag */ - if (view3d_ruler_pick(mpr->parent_mgroup, ruler_item_pick, mval_fl, &co_index)) { + if (view3d_ruler_pick(gz->parent_gzgroup, ruler_item_pick, mval_fl, &co_index)) { if (co_index == -1) { if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) { return PART_LINE; @@ -826,14 +826,14 @@ static int gizmo_ruler_test_select( } static int gizmo_ruler_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { bool do_draw = false; int exit_code = OPERATOR_RUNNING_MODAL; - RulerInfo *ruler_info = mpr->parent_mgroup->customdata; - RulerItem *ruler_item = (RulerItem *)mpr; - RulerInteraction *inter = ruler_item->mpr.interaction_data; + RulerInfo *ruler_info = gz->parent_gzgroup->customdata; + RulerItem *ruler_item = (RulerItem *)gz; + RulerInteraction *inter = ruler_item->gz.interaction_data; ARegion *ar = CTX_wm_region(C); ruler_info->ar = ar; @@ -860,20 +860,20 @@ static int gizmo_ruler_modal( } static int gizmo_ruler_invoke( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { - wmGizmoGroup *mgroup = mpr->parent_mgroup; - RulerInfo *ruler_info = mgroup->customdata; - RulerItem *ruler_item_pick = (RulerItem *)mpr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + RulerInfo *ruler_info = gzgroup->customdata; + RulerItem *ruler_item_pick = (RulerItem *)gz; RulerInteraction *inter = MEM_callocN(sizeof(RulerInteraction), __func__); - mpr->interaction_data = inter; + gz->interaction_data = inter; ARegion *ar = ruler_info->ar; const float mval_fl[2] = {UNPACK2(event->mval)}; /* select and drag */ - if (mpr->highlight_part == PART_LINE) { + if (gz->highlight_part == PART_LINE) { if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) { /* Add Center Point */ ruler_item_pick->flag |= RULERITEM_USE_ANGLE; @@ -903,7 +903,7 @@ static int gizmo_ruler_invoke( } } else { - inter->co_index = mpr->highlight_part; + inter->co_index = gz->highlight_part; ruler_state_set(C, ruler_info, RULER_STATE_DRAG); /* store the initial depth */ @@ -913,15 +913,15 @@ static int gizmo_ruler_invoke( return OPERATOR_RUNNING_MODAL; } -static void gizmo_ruler_exit(bContext *C, wmGizmo *mpr, const bool cancel) +static void gizmo_ruler_exit(bContext *C, wmGizmo *gz, const bool cancel) { - wmGizmoGroup *mgroup = mpr->parent_mgroup; - RulerInfo *ruler_info = mgroup->customdata; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + RulerInfo *ruler_info = gzgroup->customdata; if (!cancel) { if (ruler_info->state == RULER_STATE_DRAG) { - RulerItem *ruler_item = (RulerItem *)mpr; - RulerInteraction *inter = mpr->interaction_data; + RulerItem *ruler_item = (RulerItem *)gz; + RulerInteraction *inter = gz->interaction_data; /* rubber-band angle removal */ if (!inter->inside_region) { if ((inter->co_index == 1) && (ruler_item->flag & RULERITEM_USE_ANGLE)) { @@ -930,9 +930,9 @@ static void gizmo_ruler_exit(bContext *C, wmGizmo *mpr, const bool cancel) else { /* Not ideal, since the ruler isn't a mode and we don't want to override delete key * use dragging out of the view for removal. */ - ruler_item_remove(C, mgroup, ruler_item); + ruler_item_remove(C, gzgroup, ruler_item); ruler_item = NULL; - mpr = NULL; + gz = NULL; inter = NULL; } } @@ -942,38 +942,38 @@ static void gizmo_ruler_exit(bContext *C, wmGizmo *mpr, const bool cancel) ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); } /* We could convert only the current gizmo, for now just re-generate. */ - view3d_ruler_to_gpencil(C, mgroup); + view3d_ruler_to_gpencil(C, gzgroup); } - if (mpr) { - MEM_SAFE_FREE(mpr->interaction_data); + if (gz) { + MEM_SAFE_FREE(gz->interaction_data); } ruler_state_set(C, ruler_info, RULER_STATE_NORMAL); } -static int gizmo_ruler_cursor_get(wmGizmo *mpr) +static int gizmo_ruler_cursor_get(wmGizmo *gz) { - if (mpr->highlight_part == PART_LINE) { + if (gz->highlight_part == PART_LINE) { return BC_CROSSCURSOR; } return BC_NSEW_SCROLLCURSOR; } -void VIEW3D_WT_ruler_item(wmGizmoType *wt) +void VIEW3D_GT_ruler_item(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "VIEW3D_WT_ruler_item"; + gzt->idname = "VIEW3D_GT_ruler_item"; /* api callbacks */ - wt->draw = gizmo_ruler_draw; - wt->test_select = gizmo_ruler_test_select; - wt->modal = gizmo_ruler_modal; - wt->invoke = gizmo_ruler_invoke; - wt->exit = gizmo_ruler_exit; - wt->cursor_get = gizmo_ruler_cursor_get; - - wt->struct_size = sizeof(RulerItem); + gzt->draw = gizmo_ruler_draw; + gzt->test_select = gizmo_ruler_test_select; + gzt->modal = gizmo_ruler_modal; + gzt->invoke = gizmo_ruler_invoke; + gzt->exit = gizmo_ruler_exit; + gzt->cursor_get = gizmo_ruler_cursor_get; + + gzt->struct_size = sizeof(RulerItem); } /** \} */ @@ -982,23 +982,23 @@ void VIEW3D_WT_ruler_item(wmGizmoType *wt) /** \name Ruler Gizmo Group * \{ */ -static bool WIDGETGROUP_ruler_poll(const bContext *C, wmGizmoGroupType *wgt) +static bool WIDGETGROUP_ruler_poll(const bContext *C, wmGizmoGroupType *gzgt) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->gizmo_group)) + !STREQ(gzgt->idname, tref_rt->gizmo_group)) { - WM_gizmo_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); return false; } return true; } -static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *gzgroup) { RulerInfo *ruler_info = MEM_callocN(sizeof(RulerInfo), __func__); - if (view3d_ruler_from_gpencil(C, mgroup)) { + if (view3d_ruler_from_gpencil(C, gzgroup)) { /* nop */ } @@ -1009,21 +1009,21 @@ static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *mgroup) ruler_info->sa = sa; ruler_info->ar = ar; - mgroup->customdata = ruler_info; + gzgroup->customdata = ruler_info; } -void VIEW3D_WGT_ruler(wmGizmoGroupType *wgt) +void VIEW3D_GGT_ruler(wmGizmoGroupType *gzgt) { - wgt->name = "Ruler Widgets"; - wgt->idname = view3d_wgt_ruler_id; + gzgt->name = "Ruler Widgets"; + gzgt->idname = view3d_gzgt_ruler_id; - wgt->flag |= WM_GIZMOGROUPTYPE_SCALE | WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL; + gzgt->flag |= WM_GIZMOGROUPTYPE_SCALE | WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = WIDGETGROUP_ruler_poll; - wgt->setup = WIDGETGROUP_ruler_setup; + gzgt->poll = WIDGETGROUP_ruler_poll; + gzgt->setup = WIDGETGROUP_ruler_setup; } /** \} */ @@ -1036,7 +1036,7 @@ static bool view3d_ruler_poll(bContext *C) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || - !STREQ(view3d_wgt_ruler_id, tref_rt->gizmo_group) || + !STREQ(view3d_gzgt_ruler_id, tref_rt->gizmo_group) || CTX_wm_region_view3d(C) == NULL) { return false; @@ -1050,22 +1050,22 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wm View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ar->regiondata; - wmGizmoMap *mmap = ar->gizmo_map; - wmGizmoGroup *mgroup = WM_gizmomap_group_find(mmap, view3d_wgt_ruler_id); + wmGizmoMap *gzmap = ar->gizmo_map; + wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); const bool use_depth = (v3d->drawtype >= OB_SOLID); /* Create new line */ RulerItem *ruler_item; - ruler_item = ruler_item_add(mgroup); + ruler_item = ruler_item_add(gzgroup); /* This is a little weak, but there is no real good way to tweak directly. */ - WM_gizmo_highlight_set(mmap, &ruler_item->mpr); + WM_gizmo_highlight_set(gzmap, &ruler_item->gz); if (WM_operator_name_call( C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_REGION_WIN, NULL) == OPERATOR_RUNNING_MODAL) { - RulerInfo *ruler_info = mgroup->customdata; - RulerInteraction *inter = ruler_item->mpr.interaction_data; + RulerInfo *ruler_info = gzgroup->customdata; + RulerInteraction *inter = ruler_item->gz.interaction_data; if (use_depth) { /* snap the first point added, not essential but handy */ inter->co_index = 0; @@ -1079,7 +1079,7 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wm } copy_v3_v3(ruler_item->co[2], ruler_item->co[0]); - ruler_item->mpr.highlight_part = inter->co_index = 2; + ruler_item->gz.highlight_part = inter->co_index = 2; } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 89dd254c130..5796014571a 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -254,21 +254,21 @@ ARegion *view3d_has_tools_region(ScrArea *sa); extern const char *view3d_context_dir[]; /* doc access */ /* view3d_widgets.c */ -void VIEW3D_WGT_lamp_spot(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_lamp_area(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_lamp_target(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_camera(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_camera_view(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_force_field(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_empty_image(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_armature_spline(struct wmGizmoGroupType *wgt); -void VIEW3D_WGT_navigate(struct wmGizmoGroupType *wgt); - -void VIEW3D_WGT_ruler(struct wmGizmoGroupType *wgt); -void VIEW3D_WT_ruler_item(struct wmGizmoType *wt); +void VIEW3D_GGT_lamp_spot(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_lamp_area(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_lamp_target(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_camera(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_camera_view(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_force_field(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_empty_image(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_armature_spline(struct wmGizmoGroupType *gzgt); +void VIEW3D_GGT_navigate(struct wmGizmoGroupType *gzgt); + +void VIEW3D_GGT_ruler(struct wmGizmoGroupType *gzgt); +void VIEW3D_GT_ruler_item(struct wmGizmoType *gzt); void VIEW3D_OT_ruler_add(struct wmOperatorType *ot); -void VIEW3D_WT_navigate_rotate(struct wmGizmoType *wt); +void VIEW3D_GT_navigate_rotate(struct wmGizmoType *gzt); /* draw_volume.c */ void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob, diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 2006bd830b4..ded2a49a33f 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -505,7 +505,7 @@ typedef struct TransInfo { short current_orientation; TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */ - short mpr_flag; /* backup from view3d, to restore on end */ + short gizmo_flag; /* backup from view3d, to restore on end */ short prop_mode; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index e32bef72cf6..e54b154ee0d 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1350,8 +1350,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* turn gizmo off during transform */ if (t->flag & T_MODAL) { - t->mpr_flag = v3d->mpr_flag; - v3d->mpr_flag = V3D_GIZMO_HIDE; + t->gizmo_flag = v3d->gizmo_flag; + v3d->gizmo_flag = V3D_GIZMO_HIDE; } if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) { @@ -1690,7 +1690,7 @@ void postTrans(bContext *C, TransInfo *t) View3D *v3d = t->sa->spacedata.first; /* restore gizmo */ if (t->flag & T_MODAL) { - v3d->mpr_flag = t->mpr_flag; + v3d->gizmo_flag = t->gizmo_flag; } } diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c index 995faae8333..ff69c2859fc 100644 --- a/source/blender/editors/transform/transform_gizmo_2d.c +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -128,16 +128,16 @@ static void gizmo2d_get_axis_color(const int axis_idx, float *r_col, float *r_co r_col_hi[3] *= alpha_hi; } -static GizmoGroup2D *gizmogroup2d_init(wmGizmoGroup *mgroup) +static GizmoGroup2D *gizmogroup2d_init(wmGizmoGroup *gzgroup) { - const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_2d", true); - const wmGizmoType *wt_cage = WM_gizmotype_find("GIZMO_WT_cage_2d", true); + const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_2d", true); + const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_2d", true); GizmoGroup2D *man = MEM_callocN(sizeof(GizmoGroup2D), __func__); - man->translate_x = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); - man->translate_y = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); - man->cage = WM_gizmo_new_ptr(wt_cage, mgroup, NULL); + man->translate_x = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + man->translate_y = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + man->cage = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL); RNA_enum_set(man->cage->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | @@ -197,11 +197,11 @@ static int gizmo2d_modal( return OPERATOR_RUNNING_MODAL; } -void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { wmOperatorType *ot_translate = WM_operatortype_find("TRANSFORM_OT_translate", true); - GizmoGroup2D *man = gizmogroup2d_init(mgroup); - mgroup->customdata = man; + GizmoGroup2D *man = gizmogroup2d_init(gzgroup); + gzgroup->customdata = man; MAN2D_ITER_AXES_BEGIN(axis, axis_idx) { @@ -271,9 +271,9 @@ void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *mgrou } } -void ED_widgetgroup_gizmo2d_refresh(const bContext *C, wmGizmoGroup *mgroup) +void ED_widgetgroup_gizmo2d_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoGroup2D *man = mgroup->customdata; + GizmoGroup2D *man = gzgroup->customdata; float origin[3]; gizmo2d_calc_bounds(C, origin, man->min, man->max); copy_v2_v2(man->origin, origin); @@ -321,10 +321,10 @@ void ED_widgetgroup_gizmo2d_refresh(const bContext *C, wmGizmoGroup *mgroup) } } -void ED_widgetgroup_gizmo2d_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +void ED_widgetgroup_gizmo2d_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { ARegion *ar = CTX_wm_region(C); - GizmoGroup2D *man = mgroup->customdata; + GizmoGroup2D *man = gzgroup->customdata; float origin[3] = {UNPACK2(man->origin), 0.0f}; float origin_aa[3] = {UNPACK2(man->origin), 0.0f}; @@ -346,7 +346,7 @@ void ED_widgetgroup_gizmo2d_draw_prepare(const bContext *C, wmGizmoGroup *mgroup * - Called on every redraw, better to do a more simple poll and check for selection in _refresh * - UV editing only, could be expanded for other things. */ -bool ED_widgetgroup_gizmo2d_poll(const bContext *C, wmGizmoGroupType *UNUSED(wgt)) +bool ED_widgetgroup_gizmo2d_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { if ((U.gizmo_flag & USER_GIZMO_DRAW) == 0) { return false; diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 7d608c433c3..cbc2b312512 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -1137,13 +1137,13 @@ static void gizmo_line_range(const int twtype, const short axis_type, float *r_s } static void gizmo_xform_message_subscribe( - wmGizmoGroup *mgroup, struct wmMsgBus *mbus, + wmGizmoGroup *gzgroup, struct wmMsgBus *mbus, Scene *scene, bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar, const void *type_fn) { /* Subscribe to view properties */ - wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { + wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { .owner = ar, - .user_data = mgroup->parent_mmap, + .user_data = gzgroup->parent_gzmap, .notify = WM_gizmo_do_msg_notify_tag_refresh, }; @@ -1159,7 +1159,7 @@ static void gizmo_xform_message_subscribe( }; for (int i = 0; i < ARRAY_SIZE(props); i++) { if (props[i]) { - WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); + WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__); } } } @@ -1167,7 +1167,7 @@ static void gizmo_xform_message_subscribe( PointerRNA toolsettings_ptr; RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr); - if (type_fn == TRANSFORM_WGT_gizmo) { + if (type_fn == TRANSFORM_GGT_gizmo) { extern PropertyRNA rna_ToolSettings_transform_pivot_point; extern PropertyRNA rna_ToolSettings_use_gizmo_mode; const PropertyRNA *props[] = { @@ -1175,17 +1175,17 @@ static void gizmo_xform_message_subscribe( &rna_ToolSettings_use_gizmo_mode, }; for (int i = 0; i < ARRAY_SIZE(props); i++) { - WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); + WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__); } } - else if (type_fn == VIEW3D_WGT_xform_cage) { + else if (type_fn == VIEW3D_GGT_xform_cage) { /* pass */ } else { BLI_assert(0); } - WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_mpr_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_gz_tag_refresh); } /** \} */ @@ -1195,26 +1195,26 @@ static void gizmo_xform_message_subscribe( /** \name Transform Gizmo * \{ */ -static GizmoGroup *gizmogroup_init(wmGizmoGroup *mgroup) +static GizmoGroup *gizmogroup_init(wmGizmoGroup *gzgroup) { GizmoGroup *man; man = MEM_callocN(sizeof(GizmoGroup), "gizmo_data"); - const wmGizmoType *wt_arrow = WM_gizmotype_find("GIZMO_WT_arrow_3d", true); - const wmGizmoType *wt_dial = WM_gizmotype_find("GIZMO_WT_dial_3d", true); - const wmGizmoType *wt_prim = WM_gizmotype_find("GIZMO_WT_primitive_3d", true); + const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); + const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true); + const wmGizmoType *gzt_prim = WM_gizmotype_find("GIZMO_GT_primitive_3d", true); #define GIZMO_NEW_ARROW(v, draw_style) { \ - man->gizmos[v] = WM_gizmo_new_ptr(wt_arrow, mgroup, NULL); \ + man->gizmos[v] = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); \ RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \ } ((void)0) #define GIZMO_NEW_DIAL(v, draw_options) { \ - man->gizmos[v] = WM_gizmo_new_ptr(wt_dial, mgroup, NULL); \ + man->gizmos[v] = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); \ RNA_enum_set(man->gizmos[v]->ptr, "draw_options", draw_options); \ } ((void)0) #define GIZMO_NEW_PRIM(v, draw_style) { \ - man->gizmos[v] = WM_gizmo_new_ptr(wt_prim, mgroup, NULL); \ + man->gizmos[v] = WM_gizmo_new_ptr(gzt_prim, gzgroup, NULL); \ RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \ } ((void)0) @@ -1286,12 +1286,12 @@ static int gizmo_modal( return OPERATOR_RUNNING_MODAL; } -static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *mgroup) +static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *gzgroup) { struct { wmOperatorType *translate, *rotate, *trackball, *resize; } ot_store = {NULL}; - GizmoGroup *man = mgroup->customdata; + GizmoGroup *man = gzgroup->customdata; MAN_ITER_AXES_BEGIN(axis, axis_idx) { const short axis_type = gizmo_get_axis_type(axis_idx); @@ -1406,11 +1406,11 @@ static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *mgroup) MAN_ITER_AXES_END; } -static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoGroup *man = gizmogroup_init(mgroup); + GizmoGroup *man = gizmogroup_init(gzgroup); - mgroup->customdata = man; + gzgroup->customdata = man; { man->twtype = 0; @@ -1436,12 +1436,12 @@ static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *mgroup) } /* *** set properties for axes *** */ - gizmogroup_init_properties_from_twtype(mgroup); + gizmogroup_init_properties_from_twtype(gzgroup); } -static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoGroup *man = mgroup->customdata; + GizmoGroup *man = gzgroup->customdata; ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = sa->spacedata.first; @@ -1453,7 +1453,7 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *mgroup) man->twtype = scene->toolsettings->gizmo_flag & man->twtype_init; if (man->twtype != man->twtype_prev) { man->twtype_prev = man->twtype; - gizmogroup_init_properties_from_twtype(mgroup); + gizmogroup_init_properties_from_twtype(gzgroup); } } @@ -1527,18 +1527,18 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *mgroup) } static void WIDGETGROUP_gizmo_message_subscribe( - const bContext *C, wmGizmoGroup *mgroup, struct wmMsgBus *mbus) + const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - gizmo_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, TRANSFORM_WGT_gizmo); + gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, ar, TRANSFORM_GGT_gizmo); } -static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoGroup *man = mgroup->customdata; + GizmoGroup *man = gzgroup->customdata; // ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); // View3D *v3d = sa->spacedata.first; @@ -1588,39 +1588,39 @@ static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *mgro MAN_ITER_AXES_END; } -static bool WIDGETGROUP_gizmo_poll(const struct bContext *C, struct wmGizmoGroupType *wgt) +static bool WIDGETGROUP_gizmo_poll(const struct bContext *C, struct wmGizmoGroupType *gzgt) { /* it's a given we only use this in 3D view */ bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->gizmo_group)) + !STREQ(gzgt->idname, tref_rt->gizmo_group)) { - WM_gizmo_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); return false; } View3D *v3d = CTX_wm_view3d(C); - if (v3d->mpr_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { + if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { return false; } return true; } -void TRANSFORM_WGT_gizmo(wmGizmoGroupType *wgt) +void TRANSFORM_GGT_gizmo(wmGizmoGroupType *gzgt) { - wgt->name = "Transform Gizmo"; - wgt->idname = "TRANSFORM_WGT_gizmo"; + gzgt->name = "Transform Gizmo"; + gzgt->idname = "TRANSFORM_GGT_gizmo"; - wgt->flag |= WM_GIZMOGROUPTYPE_3D; + gzgt->flag |= WM_GIZMOGROUPTYPE_3D; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = WIDGETGROUP_gizmo_poll; - wgt->setup = WIDGETGROUP_gizmo_setup; - wgt->refresh = WIDGETGROUP_gizmo_refresh; - wgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe; - wgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare; + gzgt->poll = WIDGETGROUP_gizmo_poll; + gzgt->setup = WIDGETGROUP_gizmo_setup; + gzgt->refresh = WIDGETGROUP_gizmo_refresh; + gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe; + gzgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare; } /** \} */ @@ -1634,31 +1634,31 @@ struct XFormCageWidgetGroup { wmGizmo *gizmo; }; -static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmGizmoGroupType *wgt) +static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmGizmoGroupType *gzgt) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); - if (!STREQ(wgt->idname, tref_rt->gizmo_group)) { - WM_gizmo_group_type_unlink_delayed_ptr(wgt); + if (!STREQ(gzgt->idname, tref_rt->gizmo_group)) { + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); return false; } return true; } -static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup *mgroup) +static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { - struct XFormCageWidgetGroup *xmgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__); - const wmGizmoType *wt_cage = WM_gizmotype_find("GIZMO_WT_cage_3d", true); - xmgroup->gizmo = WM_gizmo_new_ptr(wt_cage, mgroup, NULL); - wmGizmo *mpr = xmgroup->gizmo; + struct XFormCageWidgetGroup *xgzgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__); + const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_3d", true); + xgzgroup->gizmo = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL); + wmGizmo *gz = xgzgroup->gizmo; - RNA_enum_set(mpr->ptr, "transform", + RNA_enum_set(gz->ptr, "transform", ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE); - mpr->color[0] = 1; - mpr->color_hi[0] = 1; + gz->color[0] = 1; + gz->color_hi[0] = 1; - mgroup->customdata = xmgroup; + gzgroup->customdata = xgzgroup; { wmOperatorType *ot_resize = WM_operatortype_find("TRANSFORM_OT_resize", true); @@ -1673,7 +1673,7 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { bool constraint[3] = {x != 1, y != 1, z != 1}; - ptr = WM_gizmo_operator_set(mpr, i, ot_resize, NULL); + ptr = WM_gizmo_operator_set(gz, i, ot_resize, NULL); if (prop_release_confirm == NULL) { prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); @@ -1687,15 +1687,15 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup } } -static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgroup) { ScrArea *sa = CTX_wm_area(C); View3D *v3d = sa->spacedata.first; ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; - wmGizmo *mpr = xmgroup->gizmo; + struct XFormCageWidgetGroup *xgzgroup = gzgroup->customdata; + wmGizmo *gz = xgzgroup->gizmo; struct TransformBounds tbounds; @@ -1705,22 +1705,22 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *mgro }, &tbounds) == 0) || equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max)) { - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, true); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true); } else { gizmo_prepare_mat(C, v3d, rv3d, &tbounds); - WM_gizmo_set_flag(mpr, WM_GIZMO_HIDDEN, false); - WM_gizmo_set_flag(mpr, WM_GIZMO_GRAB_CURSOR, true); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); + WM_gizmo_set_flag(gz, WM_GIZMO_GRAB_CURSOR, true); float dims[3]; sub_v3_v3v3(dims, rv3d->tw_axis_max, rv3d->tw_axis_min); - RNA_float_set_array(mpr->ptr, "dimensions", dims); + RNA_float_set_array(gz->ptr, "dimensions", dims); mul_v3_fl(dims, 0.5f); - copy_m4_m3(mpr->matrix_offset, rv3d->tw_axis_matrix); - mid_v3_v3v3(mpr->matrix_offset[3], rv3d->tw_axis_max, rv3d->tw_axis_min); - mul_m3_v3(rv3d->tw_axis_matrix, mpr->matrix_offset[3]); + copy_m4_m3(gz->matrix_offset, rv3d->tw_axis_matrix); + mid_v3_v3v3(gz->matrix_offset[3], rv3d->tw_axis_max, rv3d->tw_axis_min); + mul_m3_v3(rv3d->tw_axis_matrix, gz->matrix_offset[3]); PropertyRNA *prop_center_override = NULL; float center[3]; @@ -1732,11 +1732,11 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *mgro center[1] = (float)(1 - y) * dims[1]; for (int z = 0; z < 3; z++) { center[2] = (float)(1 - z) * dims[2]; - struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, i); + struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, i); if (prop_center_override == NULL) { prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); } - mul_v3_m4v3(center_global, mpr->matrix_offset, center); + mul_v3_m4v3(center_global, gz->matrix_offset, center); RNA_property_float_set_array(&mpop->ptr, prop_center_override, center_global); i++; } @@ -1746,45 +1746,45 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *mgro } static void WIDGETGROUP_xform_cage_message_subscribe( - const bContext *C, wmGizmoGroup *mgroup, struct wmMsgBus *mbus) + const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - gizmo_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, VIEW3D_WGT_xform_cage); + gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, ar, VIEW3D_GGT_xform_cage); } -static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup *mgroup) +static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; - wmGizmo *mpr = xmgroup->gizmo; + struct XFormCageWidgetGroup *xgzgroup = gzgroup->customdata; + wmGizmo *gz = xgzgroup->gizmo; ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); if (ob && ob->mode & OB_MODE_EDIT) { - copy_m4_m4(mpr->matrix_space, ob->obmat); + copy_m4_m4(gz->matrix_space, ob->obmat); } else { - unit_m4(mpr->matrix_space); + unit_m4(gz->matrix_space); } } -void VIEW3D_WGT_xform_cage(wmGizmoGroupType *wgt) +void VIEW3D_GGT_xform_cage(wmGizmoGroupType *gzgt) { - wgt->name = "Transform Cage"; - wgt->idname = "VIEW3D_WGT_xform_cage"; + gzgt->name = "Transform Cage"; + gzgt->idname = "VIEW3D_GGT_xform_cage"; - wgt->flag |= WM_GIZMOGROUPTYPE_3D; + gzgt->flag |= WM_GIZMOGROUPTYPE_3D; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = WIDGETGROUP_xform_cage_poll; - wgt->setup = WIDGETGROUP_xform_cage_setup; - wgt->refresh = WIDGETGROUP_xform_cage_refresh; - wgt->message_subscribe = WIDGETGROUP_xform_cage_message_subscribe; - wgt->draw_prepare = WIDGETGROUP_xform_cage_draw_prepare; + gzgt->poll = WIDGETGROUP_xform_cage_poll; + gzgt->setup = WIDGETGROUP_xform_cage_setup; + gzgt->refresh = WIDGETGROUP_xform_cage_refresh; + gzgt->message_subscribe = WIDGETGROUP_xform_cage_message_subscribe; + gzgt->draw_prepare = WIDGETGROUP_xform_cage_draw_prepare; } /** \} */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 40551701627..8abec3474f9 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -237,7 +237,7 @@ typedef struct View3D { char gridflag; /* transform gizmo info */ - char _pad5[2], mpr_flag; + char _pad5[2], gizmo_flag; short flag3; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5c30cdb2b07..df838264cb7 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2940,22 +2940,22 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_gizmo", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_GIZMO_HIDE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE); RNA_def_property_ui_text(prop, "Show Gizmo", "Show gizmos of all types"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_gizmo_navigate", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_GIZMO_HIDE_NAVIGATE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_NAVIGATE); RNA_def_property_ui_text(prop, "Navigate Gizmo", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_gizmo_context", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_GIZMO_HIDE_CONTEXT); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_CONTEXT); RNA_def_property_ui_text(prop, "Context Gizmo", "Context sensitive gizmos for the active item"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_gizmo_tool", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mpr_flag", V3D_GIZMO_HIDE_TOOL); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_TOOL); RNA_def_property_ui_text(prop, "Tool Gizmo", "Active tool gizmo"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 7abcf0f0667..a1780b45aed 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -120,31 +120,31 @@ static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer) static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports, const char *idname) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, true); - if (wgt == NULL) { + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, true); + if (gzgt == NULL) { BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname); return NULL; } - if (wgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { + if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname); return NULL; } - return wgt; + return gzgt; } static void rna_gizmo_group_type_add(ReportList *reports, const char *idname) { - wmGizmoGroupType *wgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); - if (wgt != NULL) { - WM_gizmo_group_type_add_ptr(wgt); + wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); + if (gzgt != NULL) { + WM_gizmo_group_type_add_ptr(gzgt); } } static void rna_gizmo_group_type_remove(Main *bmain, ReportList *reports, const char *idname) { - wmGizmoGroupType *wgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); - if (wgt != NULL) { - WM_gizmo_group_type_remove_ptr(bmain, wgt); + wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); + if (gzgt != NULL) { + WM_gizmo_group_type_remove_ptr(bmain, gzgt); } } diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index 754ef4575a4..7a2460a7694 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -76,55 +76,55 @@ #ifdef WITH_PYTHON static void rna_gizmo_draw_cb( - const struct bContext *C, struct wmGizmo *mpr) + const struct bContext *C, struct wmGizmo *gz) { extern FunctionRNA rna_Gizmo_draw_func; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "draw"); */ + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "draw"); */ func = &rna_Gizmo_draw_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } static void rna_gizmo_draw_select_cb( - const struct bContext *C, struct wmGizmo *mpr, int select_id) + const struct bContext *C, struct wmGizmo *gz, int select_id) { extern FunctionRNA rna_Gizmo_draw_select_func; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "draw_select"); */ + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "draw_select"); */ func = &rna_Gizmo_draw_select_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "select_id", &select_id); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } static int rna_gizmo_test_select_cb( - struct bContext *C, struct wmGizmo *mpr, const struct wmEvent *event) + struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event) { extern FunctionRNA rna_Gizmo_test_select_func; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "test_select"); */ + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "test_select"); */ func = &rna_Gizmo_test_select_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); void *ret; RNA_parameter_get_lookup(&list, "intersect_id", &ret); @@ -135,23 +135,23 @@ static int rna_gizmo_test_select_cb( } static int rna_gizmo_modal_cb( - struct bContext *C, struct wmGizmo *mpr, const struct wmEvent *event, + struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event, eWM_GizmoFlagTweak tweak_flag) { extern FunctionRNA rna_Gizmo_modal_func; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; const int tweak_flag_int = tweak_flag; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "modal"); */ + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "modal"); */ func = &rna_Gizmo_modal_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); void *ret; RNA_parameter_get_lookup(&list, "result", &ret); @@ -162,37 +162,37 @@ static int rna_gizmo_modal_cb( } static void rna_gizmo_setup_cb( - struct wmGizmo *mpr) + struct wmGizmo *gz) { extern FunctionRNA rna_Gizmo_setup_func; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "setup"); */ + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "setup"); */ func = &rna_Gizmo_setup_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); + RNA_parameter_list_create(&list, &gz_ptr, func); + gzgroup->type->ext.call((bContext *)NULL, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } static int rna_gizmo_invoke_cb( - struct bContext *C, struct wmGizmo *mpr, const struct wmEvent *event) + struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event) { extern FunctionRNA rna_Gizmo_invoke_func; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "invoke"); */ + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "invoke"); */ func = &rna_Gizmo_invoke_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); void *ret; RNA_parameter_get_lookup(&list, "result", &ret); @@ -203,39 +203,39 @@ static int rna_gizmo_invoke_cb( } static void rna_gizmo_exit_cb( - struct bContext *C, struct wmGizmo *mpr, bool cancel) + struct bContext *C, struct wmGizmo *gz, bool cancel) { extern FunctionRNA rna_Gizmo_exit_func; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "exit"); */ + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "exit"); */ func = &rna_Gizmo_exit_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); { int cancel_i = cancel; RNA_parameter_set_lookup(&list, "cancel", &cancel_i); } - mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } static void rna_gizmo_select_refresh_cb( - struct wmGizmo *mpr) + struct wmGizmo *gz) { extern FunctionRNA rna_Gizmo_select_refresh_func; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - PointerRNA mpr_ptr; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); - /* RNA_struct_find_function(&mpr_ptr, "select_refresh"); */ + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "select_refresh"); */ func = &rna_Gizmo_select_refresh_func; - RNA_parameter_list_create(&list, &mpr_ptr, func); - mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); + RNA_parameter_list_create(&list, &gz_ptr, func); + gzgroup->type->ext.call((bContext *)NULL, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -266,14 +266,14 @@ static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr) for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->gizmo_map) { - wmGizmoMap *mmap = ar->gizmo_map; - for (wmGizmoGroup *mgroup = WM_gizmomap_group_list(mmap)->first; - mgroup; - mgroup = mgroup->next) + wmGizmoMap *gzmap = ar->gizmo_map; + for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; + gzgroup; + gzgroup = gzgroup->next) { - for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { - if (mpr->properties == properties) { - return mpr; + for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + if (gz->properties == properties) { + return gz; } } } @@ -286,10 +286,10 @@ static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr) static StructRNA *rna_GizmoProperties_refine(PointerRNA *ptr) { - wmGizmo *mpr = rna_GizmoProperties_find_operator(ptr); + wmGizmo *gz = rna_GizmoProperties_find_operator(ptr); - if (mpr) - return mpr->type->srna; + if (gz) + return gz->type->srna; else return ptr->type; } @@ -306,77 +306,77 @@ static IDProperty *rna_GizmoProperties_idprops(PointerRNA *ptr, bool create) static PointerRNA rna_Gizmo_properties_get(PointerRNA *ptr) { - wmGizmo *mpr = ptr->data; - return rna_pointer_inherit_refine(ptr, mpr->type->srna, mpr->properties); + wmGizmo *gz = ptr->data; + return rna_pointer_inherit_refine(ptr, gz->type->srna, gz->properties); } /* wmGizmo.float */ #define RNA_GIZMO_GENERIC_FLOAT_RW_DEF(func_id, member_id) \ static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmGizmo *mpr = ptr->data; \ - return mpr->member_id; \ + wmGizmo *gz = ptr->data; \ + return gz->member_id; \ } \ static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \ { \ - wmGizmo *mpr = ptr->data; \ - mpr->member_id = value; \ + wmGizmo *gz = ptr->data; \ + gz->member_id = value; \ } #define RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \ static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmGizmo *mpr = ptr->data; \ - return mpr->member_id[index]; \ + wmGizmo *gz = ptr->data; \ + return gz->member_id[index]; \ } \ static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \ { \ - wmGizmo *mpr = ptr->data; \ - mpr->member_id[index] = value; \ + wmGizmo *gz = ptr->data; \ + gz->member_id[index] = value; \ } /* wmGizmo.float[len] */ #define RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \ static void rna_Gizmo_##func_id##_get(PointerRNA *ptr, float value[len]) \ { \ - wmGizmo *mpr = ptr->data; \ - memcpy(value, mpr->member_id, sizeof(float[len])); \ + wmGizmo *gz = ptr->data; \ + memcpy(value, gz->member_id, sizeof(float[len])); \ } \ static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, const float value[len]) \ { \ - wmGizmo *mpr = ptr->data; \ - memcpy(mpr->member_id, value, sizeof(float[len])); \ + wmGizmo *gz = ptr->data; \ + memcpy(gz->member_id, value, sizeof(float[len])); \ } /* wmGizmo.flag */ #define RNA_GIZMO_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \ static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmGizmo *mpr = ptr->data; \ - return (mpr->member_id & flag_value) != 0; \ + wmGizmo *gz = ptr->data; \ + return (gz->member_id & flag_value) != 0; \ } \ static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \ { \ - wmGizmo *mpr = ptr->data; \ - SET_FLAG_FROM_TEST(mpr->member_id, value, flag_value); \ + wmGizmo *gz = ptr->data; \ + SET_FLAG_FROM_TEST(gz->member_id, value, flag_value); \ } /* wmGizmo.flag (negative) */ #define RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \ static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmGizmo *mpr = ptr->data; \ - return (mpr->member_id & flag_value) == 0; \ + wmGizmo *gz = ptr->data; \ + return (gz->member_id & flag_value) == 0; \ } \ static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \ { \ - wmGizmo *mpr = ptr->data; \ - SET_FLAG_FROM_TEST(mpr->member_id, !value, flag_value); \ + wmGizmo *gz = ptr->data; \ + SET_FLAG_FROM_TEST(gz->member_id, !value, flag_value); \ } #define RNA_GIZMO_FLAG_RO_DEF(func_id, member_id, flag_value) \ static int rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ { \ - wmGizmo *mpr = ptr->data; \ - return (mpr->member_id & flag_value) != 0; \ + wmGizmo *gz = ptr->data; \ + return (gz->member_id & flag_value) != 0; \ } RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3); @@ -391,8 +391,8 @@ RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16); static void rna_Gizmo_matrix_world_get(PointerRNA *ptr, float value[16]) { - wmGizmo *mpr = ptr->data; - WM_gizmo_calc_matrix_final(mpr, (float (*)[4])value); + wmGizmo *gz = ptr->data; + WM_gizmo_calc_matrix_final(gz, (float (*)[4])value); } RNA_GIZMO_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis); @@ -414,21 +414,21 @@ RNA_GIZMO_FLAG_RO_DEF(state_select, state, WM_GIZMO_STATE_SELECT); static void rna_Gizmo_state_select_set(struct PointerRNA *ptr, bool value) { - wmGizmo *mpr = ptr->data; - wmGizmoGroup *mgroup = mpr->parent_mgroup; - WM_gizmo_select_set(mgroup->parent_mmap, mpr, value); + wmGizmo *gz = ptr->data; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + WM_gizmo_select_set(gzgroup->parent_gzmap, gz, value); } static PointerRNA rna_Gizmo_group_get(PointerRNA *ptr) { - wmGizmo *mpr = ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_GizmoGroup, mpr->parent_mgroup); + wmGizmo *gz = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_GizmoGroup, gz->parent_gzgroup); } #ifdef WITH_PYTHON static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type); -void BPY_RNA_gizmo_wrapper(wmGizmoType *wgt, void *userdata); +void BPY_RNA_gizmo_wrapper(wmGizmoType *gzgt, void *userdata); static StructRNA *rna_Gizmo_register( Main *bmain, ReportList *reports, void *data, const char *identifier, @@ -438,7 +438,7 @@ static StructRNA *rna_Gizmo_register( char idname[MAX_NAME]; } temp_buffers; - wmGizmoType dummywt = {NULL}; + wmGizmoType dummygt = {NULL}; wmGizmo dummymnp = {NULL}; PointerRNA mnp_ptr; @@ -446,8 +446,8 @@ static StructRNA *rna_Gizmo_register( int have_function[8]; /* setup dummy gizmo & gizmo type to store static properties in */ - dummymnp.type = &dummywt; - dummywt.idname = temp_buffers.idname; + dummymnp.type = &dummygt; + dummygt.idname = temp_buffers.idname; RNA_pointer_create(NULL, &RNA_Gizmo, &dummymnp, &mnp_ptr); /* Clear so we can detect if it's left unset. */ @@ -465,71 +465,72 @@ static StructRNA *rna_Gizmo_register( /* check if we have registered this gizmo type before, and remove it */ { - const wmGizmoType *wt = WM_gizmotype_find(dummywt.idname, true); - if (wt && wt->ext.srna) { - rna_Gizmo_unregister(bmain, wt->ext.srna); + const wmGizmoType *gzt = WM_gizmotype_find(dummygt.idname, true); + if (gzt && gzt->ext.srna) { + rna_Gizmo_unregister(bmain, gzt->ext.srna); } } - if (!RNA_struct_available_or_report(reports, dummywt.idname)) { + if (!RNA_struct_available_or_report(reports, dummygt.idname)) { return NULL; } { /* allocate the idname */ /* For multiple strings see GizmoGroup. */ - dummywt.idname = BLI_strdup(temp_buffers.idname); + dummygt.idname = BLI_strdup(temp_buffers.idname); } /* create a new gizmo type */ - dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Gizmo); + dummygt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummygt.idname, &RNA_Gizmo); /* gizmo properties are registered separately */ - RNA_def_struct_flag(dummywt.ext.srna, STRUCT_NO_IDPROPERTIES); - dummywt.ext.data = data; - dummywt.ext.call = call; - dummywt.ext.free = free; + RNA_def_struct_flag(dummygt.ext.srna, STRUCT_NO_IDPROPERTIES); + dummygt.ext.data = data; + dummygt.ext.call = call; + dummygt.ext.free = free; { int i = 0; - dummywt.draw = (have_function[i++]) ? rna_gizmo_draw_cb : NULL; - dummywt.draw_select = (have_function[i++]) ? rna_gizmo_draw_select_cb : NULL; - dummywt.test_select = (have_function[i++]) ? rna_gizmo_test_select_cb : NULL; - dummywt.modal = (have_function[i++]) ? rna_gizmo_modal_cb : NULL; -// dummywt.property_update = (have_function[i++]) ? rna_gizmo_property_update : NULL; -// dummywt.position_get = (have_function[i++]) ? rna_gizmo_position_get : NULL; - dummywt.setup = (have_function[i++]) ? rna_gizmo_setup_cb : NULL; - dummywt.invoke = (have_function[i++]) ? rna_gizmo_invoke_cb : NULL; - dummywt.exit = (have_function[i++]) ? rna_gizmo_exit_cb : NULL; - dummywt.select_refresh = (have_function[i++]) ? rna_gizmo_select_refresh_cb : NULL; + dummygt.draw = (have_function[i++]) ? rna_gizmo_draw_cb : NULL; + dummygt.draw_select = (have_function[i++]) ? rna_gizmo_draw_select_cb : NULL; + dummygt.test_select = (have_function[i++]) ? rna_gizmo_test_select_cb : NULL; + dummygt.modal = (have_function[i++]) ? rna_gizmo_modal_cb : NULL; +// dummygt.property_update = (have_function[i++]) ? rna_gizmo_property_update : NULL; +// dummygt.position_get = (have_function[i++]) ? rna_gizmo_position_get : NULL; + dummygt.setup = (have_function[i++]) ? rna_gizmo_setup_cb : NULL; + dummygt.invoke = (have_function[i++]) ? rna_gizmo_invoke_cb : NULL; + dummygt.exit = (have_function[i++]) ? rna_gizmo_exit_cb : NULL; + dummygt.select_refresh = (have_function[i++]) ? rna_gizmo_select_refresh_cb : NULL; BLI_assert(i == ARRAY_SIZE(have_function)); } - WM_gizmotype_append_ptr(BPY_RNA_gizmo_wrapper, (void *)&dummywt); + WM_gizmotype_append_ptr(BPY_RNA_gizmo_wrapper, (void *)&dummygt); /* update while blender is running */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - return dummywt.ext.srna; + return dummygt.ext.srna; } static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type) { - wmGizmoType *wt = RNA_struct_blender_type_get(type); + wmGizmoType *gzt = RNA_struct_blender_type_get(type); - if (!wt) + if (!gzt) { return; + } - RNA_struct_free_extension(type, &wt->ext); + RNA_struct_free_extension(type, &gzt->ext); RNA_struct_free(&BLENDER_RNA, type); WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - WM_gizmotype_remove_ptr(NULL, bmain, wt); + WM_gizmotype_remove_ptr(NULL, bmain, gzt); } static void **rna_Gizmo_instance(PointerRNA *ptr) { - wmGizmo *mpr = ptr->data; - return &mpr->py_instance; + wmGizmo *gz = ptr->data; + return &gz->py_instance; } #endif /* WITH_PYTHON */ @@ -537,8 +538,8 @@ static void **rna_Gizmo_instance(PointerRNA *ptr) static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr) { - wmGizmo *mpr = mnp_ptr->data; - return (mpr->type && mpr->type->ext.srna) ? mpr->type->ext.srna : &RNA_Gizmo; + wmGizmo *gz = mnp_ptr->data; + return (gz->type && gz->type->ext.srna) ? gz->type->ext.srna : &RNA_Gizmo; } /** \} */ @@ -547,41 +548,41 @@ static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr) * \{ */ static wmGizmo *rna_GizmoGroup_gizmo_new( - wmGizmoGroup *mgroup, ReportList *reports, const char *idname) + wmGizmoGroup *gzgroup, ReportList *reports, const char *idname) { - const wmGizmoType *wt = WM_gizmotype_find(idname, true); - if (wt == NULL) { + const wmGizmoType *gzt = WM_gizmotype_find(idname, true); + if (gzt == NULL) { BKE_reportf(reports, RPT_ERROR, "GizmoType '%s' not known", idname); return NULL; } - wmGizmo *mpr = WM_gizmo_new_ptr(wt, mgroup, NULL); - return mpr; + wmGizmo *gz = WM_gizmo_new_ptr(gzt, gzgroup, NULL); + return gz; } static void rna_GizmoGroup_gizmo_remove( - wmGizmoGroup *mgroup, bContext *C, wmGizmo *mpr) + wmGizmoGroup *gzgroup, bContext *C, wmGizmo *gz) { - WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, mpr, C); + WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C); } static void rna_GizmoGroup_gizmo_clear( - wmGizmoGroup *mgroup, bContext *C) + wmGizmoGroup *gzgroup, bContext *C) { - while (mgroup->gizmos.first) { - WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, mgroup->gizmos.first, C); + while (gzgroup->gizmos.first) { + WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gzgroup->gizmos.first, C); } } static void rna_GizmoGroup_name_get(PointerRNA *ptr, char *value) { - wmGizmoGroup *mgroup = ptr->data; - strcpy(value, mgroup->type->name); + wmGizmoGroup *gzgroup = ptr->data; + strcpy(value, gzgroup->type->name); } static int rna_GizmoGroup_name_length(PointerRNA *ptr) { - wmGizmoGroup *mgroup = ptr->data; - return strlen(mgroup->type->name); + wmGizmoGroup *gzgroup = ptr->data; + return strlen(gzgroup->type->name); } /* just to work around 'const char *' warning and to ensure this is a python op */ @@ -607,13 +608,13 @@ static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value) static bool rna_GizmoGroup_has_reports_get(PointerRNA *ptr) { - wmGizmoGroup *mgroup = ptr->data; - return (mgroup->reports && mgroup->reports->list.first); + wmGizmoGroup *gzgroup = ptr->data; + return (gzgroup->reports && gzgroup->reports->list.first); } #ifdef WITH_PYTHON -static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *wgt) +static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *gzgt) { extern FunctionRNA rna_GizmoGroup_poll_func; @@ -624,12 +625,12 @@ static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *wgt) void *ret; int visible; - RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ + RNA_pointer_create(NULL, gzgt->ext.srna, NULL, &ptr); /* dummy */ func = &rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - wgt->ext.call((bContext *)C, &ptr, func, &list); + gzgt->ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_get_lookup(&list, "visible", &ret); visible = *(int *)ret; @@ -639,25 +640,25 @@ static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *wgt) return visible; } -static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *mgroup) +static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *gzgroup) { extern FunctionRNA rna_GizmoGroup_setup_func; - PointerRNA mgroup_ptr; + PointerRNA gzgroup_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); func = &rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */ - RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_list_create(&list, &gzgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); RNA_parameter_list_free(&list); } -static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *wgt, wmKeyConfig *config) +static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *gzgt, wmKeyConfig *config) { extern FunctionRNA rna_GizmoGroup_setup_keymap_func; void *ret; @@ -666,12 +667,12 @@ static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *wgt, wmK ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ + RNA_pointer_create(NULL, gzgt->ext.srna, NULL, &ptr); /* dummy */ func = &rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "keyconfig", &config); - wgt->ext.call(NULL, &ptr, func, &list); + gzgt->ext.call(NULL, &ptr, func, &list); RNA_parameter_get_lookup(&list, "keymap", &ret); wmKeyMap *keymap = *(wmKeyMap **)ret; @@ -681,43 +682,43 @@ static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *wgt, wmK return keymap; } -static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *mgroup) +static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *gzgroup) { extern FunctionRNA rna_GizmoGroup_refresh_func; - PointerRNA mgroup_ptr; + PointerRNA gzgroup_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); func = &rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */ - RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_list_create(&list, &gzgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); RNA_parameter_list_free(&list); } -static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *mgroup) +static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *gzgroup) { extern FunctionRNA rna_GizmoGroup_draw_prepare_func; - PointerRNA mgroup_ptr; + PointerRNA gzgroup_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); func = &rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */ - RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_list_create(&list, &gzgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); RNA_parameter_list_free(&list); } -void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *wgt, void *userdata); +void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata); static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type); static StructRNA *rna_GizmoGroup_register( @@ -758,21 +759,21 @@ static StructRNA *rna_GizmoGroup_register( /* check if the area supports widgets */ const struct wmGizmoMapType_Params wmap_params = { - .spaceid = dummywgt.mmap_params.spaceid, - .regionid = dummywgt.mmap_params.regionid, + .spaceid = dummywgt.gzmap_params.spaceid, + .regionid = dummywgt.gzmap_params.regionid, }; - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wmap_params); - if (mmap_type == NULL) { + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params); + if (gzmap_type == NULL) { BKE_reportf(reports, RPT_ERROR, "Area type does not support gizmos"); return NULL; } /* check if we have registered this gizmogroup type before, and remove it */ { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(dummywgt.idname, true); - if (wgt && wgt->ext.srna) { - rna_GizmoGroup_unregister(bmain, wgt->ext.srna); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummywgt.idname, true); + if (gzgt && gzgt->ext.srna) { + rna_GizmoGroup_unregister(bmain, gzgt->ext.srna); } } if (!RNA_struct_available_or_report(reports, dummywgt.idname)) { @@ -807,18 +808,18 @@ static StructRNA *rna_GizmoGroup_register( dummywgt.refresh = (have_function[3]) ? rna_gizmogroup_refresh_cb : NULL; dummywgt.draw_prepare = (have_function[4]) ? rna_gizmogroup_draw_prepare_cb : NULL; - wmGizmoGroupType *wgt = WM_gizmogrouptype_append_ptr( + wmGizmoGroupType *gzgt = WM_gizmogrouptype_append_ptr( BPY_RNA_gizmogroup_wrapper, (void *)&dummywgt); { const char *owner_id = RNA_struct_state_owner_get(); if (owner_id) { - BLI_strncpy(wgt->owner_id, owner_id, sizeof(wgt->owner_id)); + BLI_strncpy(gzgt->owner_id, owner_id, sizeof(gzgt->owner_id)); } } - if (wgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { - WM_gizmo_group_type_add_ptr_ex(wgt, mmap_type); + if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { + WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type); /* update while blender is running */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); @@ -829,37 +830,37 @@ static StructRNA *rna_GizmoGroup_register( static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type) { - wmGizmoGroupType *wgt = RNA_struct_blender_type_get(type); + wmGizmoGroupType *gzgt = RNA_struct_blender_type_get(type); - if (!wgt) + if (!gzgt) return; - RNA_struct_free_extension(type, &wgt->ext); + RNA_struct_free_extension(type, &gzgt->ext); RNA_struct_free(&BLENDER_RNA, type); WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - WM_gizmo_group_type_remove_ptr(bmain, wgt); + WM_gizmo_group_type_remove_ptr(bmain, gzgt); } static void **rna_GizmoGroup_instance(PointerRNA *ptr) { - wmGizmoGroup *mgroup = ptr->data; - return &mgroup->py_instance; + wmGizmoGroup *gzgroup = ptr->data; + return &gzgroup->py_instance; } #endif /* WITH_PYTHON */ -static StructRNA *rna_GizmoGroup_refine(PointerRNA *mgroup_ptr) +static StructRNA *rna_GizmoGroup_refine(PointerRNA *gzgroup_ptr) { - wmGizmoGroup *mgroup = mgroup_ptr->data; - return (mgroup->type && mgroup->type->ext.srna) ? mgroup->type->ext.srna : &RNA_GizmoGroup; + wmGizmoGroup *gzgroup = gzgroup_ptr->data; + return (gzgroup->type && gzgroup->type->ext.srna) ? gzgroup->type->ext.srna : &RNA_GizmoGroup; } -static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *mgroup_ptr) +static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *gzgroup_ptr) { - wmGizmoGroup *mgroup = mgroup_ptr->data; - rna_iterator_listbase_begin(iter, &mgroup->gizmos, NULL); + wmGizmoGroup *gzgroup = gzgroup_ptr->data; + rna_iterator_listbase_begin(iter, &gzgroup->gizmos, NULL); } /** \} */ @@ -1210,13 +1211,13 @@ static void rna_def_gizmogroup(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER); prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.spaceid"); + RNA_def_property_enum_sdna(prop, NULL, "type->gzmap_params.spaceid"); RNA_def_property_enum_items(prop, rna_enum_space_type_items); RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in"); prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.regionid"); + RNA_def_property_enum_sdna(prop, NULL, "type->gzmap_params.regionid"); RNA_def_property_enum_items(prop, rna_enum_region_type_items); RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in"); diff --git a/source/blender/makesrna/intern/rna_wm_gizmo_api.c b/source/blender/makesrna/intern/rna_wm_gizmo_api.c index 04c02889fa3..e8a9e585165 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo_api.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo_api.c @@ -47,28 +47,28 @@ #include "ED_gizmo_library.h" static void rna_gizmo_draw_preset_box( - wmGizmo *mpr, float matrix[16], int select_id) + wmGizmo *gz, float matrix[16], int select_id) { - ED_gizmo_draw_preset_box(mpr, (float (*)[4])matrix, select_id); + ED_gizmo_draw_preset_box(gz, (float (*)[4])matrix, select_id); } static void rna_gizmo_draw_preset_arrow( - wmGizmo *mpr, float matrix[16], int axis, int select_id) + wmGizmo *gz, float matrix[16], int axis, int select_id) { - ED_gizmo_draw_preset_arrow(mpr, (float (*)[4])matrix, axis, select_id); + ED_gizmo_draw_preset_arrow(gz, (float (*)[4])matrix, axis, select_id); } static void rna_gizmo_draw_preset_circle( - wmGizmo *mpr, float matrix[16], int axis, int select_id) + wmGizmo *gz, float matrix[16], int axis, int select_id) { - ED_gizmo_draw_preset_circle(mpr, (float (*)[4])matrix, axis, select_id); + ED_gizmo_draw_preset_circle(gz, (float (*)[4])matrix, axis, select_id); } static void rna_gizmo_draw_preset_facemap( - wmGizmo *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id) + wmGizmo *gz, struct bContext *C, struct Object *ob, int facemap, int select_id) { struct Scene *scene = CTX_data_scene(C); - ED_gizmo_draw_preset_facemap(C, mpr, scene, ob, facemap, select_id); + ED_gizmo_draw_preset_facemap(C, gz, scene, ob, facemap, select_id); } /* -------------------------------------------------------------------- */ @@ -76,14 +76,14 @@ static void rna_gizmo_draw_preset_facemap( * \{ */ static void rna_gizmo_target_set_prop( - wmGizmo *mpr, ReportList *reports, const char *target_propname, + wmGizmo *gz, ReportList *reports, const char *target_propname, PointerRNA *ptr, const char *propname, int index) { - const wmGizmoPropertyType *mpr_prop_type = - WM_gizmotype_target_property_find(mpr->type, target_propname); - if (mpr_prop_type == NULL) { + const wmGizmoPropertyType *gz_prop_type = + WM_gizmotype_target_property_find(gz->type, target_propname); + if (gz_prop_type == NULL) { BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' not found", - mpr->type->idname, target_propname); + gz->type->idname, target_propname); return; } @@ -94,13 +94,13 @@ static void rna_gizmo_target_set_prop( return; } - if (mpr_prop_type->data_type != RNA_property_type(prop)) { - const int gizmo_type_index = RNA_enum_from_value(rna_enum_property_type_items, mpr_prop_type->data_type); + if (gz_prop_type->data_type != RNA_property_type(prop)) { + const int gizmo_type_index = RNA_enum_from_value(rna_enum_property_type_items, gz_prop_type->data_type); const int prop_type_index = RNA_enum_from_value(rna_enum_property_type_items, RNA_property_type(prop)); BLI_assert((gizmo_type_index != -1) && (prop_type_index == -1)); BKE_reportf(reports, RPT_ERROR, "Gizmo target '%s.%s' expects '%s', '%s.%s' is '%s'", - mpr->type->idname, target_propname, + gz->type->idname, target_propname, rna_enum_property_type_items[gizmo_type_index].identifier, RNA_struct_identifier(ptr->type), propname, rna_enum_property_type_items[prop_type_index].identifier); @@ -110,37 +110,37 @@ static void rna_gizmo_target_set_prop( if (RNA_property_array_check(prop)) { if (index == -1) { const int prop_array_length = RNA_property_array_length(ptr, prop); - if (mpr_prop_type->array_length != prop_array_length) { + if (gz_prop_type->array_length != prop_array_length) { BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' expects an array of length %d, found %d", - mpr->type->idname, target_propname, - mpr_prop_type->array_length, + gz->type->idname, target_propname, + gz_prop_type->array_length, prop_array_length); return; } } } else { - if (mpr_prop_type->array_length != 1) { + if (gz_prop_type->array_length != 1) { BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' expects an array of length %d", - mpr->type->idname, target_propname, - mpr_prop_type->array_length); + gz->type->idname, target_propname, + gz_prop_type->array_length); return; } } - if (index >= mpr_prop_type->array_length) { + if (index >= gz_prop_type->array_length) { BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s', index %d must be below %d", - mpr->type->idname, target_propname, index, mpr_prop_type->array_length); + gz->type->idname, target_propname, index, gz_prop_type->array_length); return; } - WM_gizmo_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); + WM_gizmo_target_property_def_rna_ptr(gz, gz_prop_type, ptr, prop, index); } static PointerRNA rna_gizmo_target_set_operator( - wmGizmo *mpr, ReportList *reports, const char *opname, int part_index) + wmGizmo *gz, ReportList *reports, const char *opname, int part_index) { wmOperatorType *ot; @@ -157,7 +157,7 @@ static PointerRNA rna_gizmo_target_set_operator( properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties"); } - return *WM_gizmo_operator_set(mpr, part_index, ot, properties); + return *WM_gizmo_operator_set(gz, part_index, ot, properties); } /** \} */ @@ -167,16 +167,16 @@ static PointerRNA rna_gizmo_target_set_operator( * \{ */ static bool rna_gizmo_target_is_valid( - wmGizmo *mpr, ReportList *reports, const char *target_propname) + wmGizmo *gz, ReportList *reports, const char *target_propname) { - wmGizmoProperty *mpr_prop = - WM_gizmo_target_property_find(mpr, target_propname); - if (mpr_prop == NULL) { + wmGizmoProperty *gz_prop = + WM_gizmo_target_property_find(gz, target_propname); + if (gz_prop == NULL) { BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' not found", - mpr->type->idname, target_propname); + gz->type->idname, target_propname); return false; } - return WM_gizmo_target_property_is_valid(mpr_prop); + return WM_gizmo_target_property_is_valid(gz_prop); } /** \} */ diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c index 4b71ea92010..2a932cb6a99 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.c +++ b/source/blender/python/intern/bpy_gizmo_wrap.c @@ -54,7 +54,7 @@ static bool bpy_gizmotype_target_property_def( - wmGizmoType *wt, PyObject *item) + wmGizmoType *gzt, PyObject *item) { /* Note: names based on 'rna_rna.c' */ PyObject *empty_tuple = PyTuple_New(0); @@ -102,7 +102,7 @@ static bool bpy_gizmotype_target_property_def( goto fail; } - WM_gizmotype_target_property_def(wt, params.id, params.type, params.array_length); + WM_gizmotype_target_property_def(gzt, params.id, params.type, params.array_length); Py_DECREF(empty_tuple); return true; @@ -111,17 +111,17 @@ fail: return false; } -static void gizmo_properties_init(wmGizmoType *wt) +static void gizmo_properties_init(wmGizmoType *gzt) { - PyTypeObject *py_class = wt->ext.data; - RNA_struct_blender_type_set(wt->ext.srna, wt); + PyTypeObject *py_class = gzt->ext.data; + RNA_struct_blender_type_set(gzt->ext.srna, gzt); /* only call this so pyrna_deferred_register_class gives a useful error * WM_operatortype_append_ptr will call RNA_def_struct_identifier * later */ - RNA_def_struct_identifier_no_struct_map(wt->srna, wt->idname); + RNA_def_struct_identifier_no_struct_map(gzt->srna, gzt->idname); - if (pyrna_deferred_register_class(wt->srna, py_class) != 0) { + if (pyrna_deferred_register_class(gzt->srna, py_class) != 0) { PyErr_Print(); /* failed to register operator props */ PyErr_Clear(); } @@ -149,7 +149,7 @@ static void gizmo_properties_init(wmGizmoType *wt) PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast); for (uint i = 0; i < items_len; i++) { - if (!bpy_gizmotype_target_property_def(wt, items[i])) { + if (!bpy_gizmotype_target_property_def(gzt, items[i])) { PyErr_Print(); PyErr_Clear(); break; @@ -161,25 +161,25 @@ static void gizmo_properties_init(wmGizmoType *wt) } } -void BPY_RNA_gizmo_wrapper(wmGizmoType *wt, void *userdata) +void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata) { /* take care not to overwrite anything set in * WM_gizmomaptype_group_link_ptr before opfunc() is called */ - StructRNA *srna = wt->srna; - *wt = *((wmGizmoType *)userdata); - wt->srna = srna; /* restore */ + StructRNA *srna = gzt->srna; + *gzt = *((wmGizmoType *)userdata); + gzt->srna = srna; /* restore */ /* don't do translations here yet */ #if 0 /* Use i18n context from ext.srna if possible (py gizmogroups). */ - if (wt->ext.srna) { - RNA_def_struct_translation_context(wt->srna, RNA_struct_translation_context(wt->ext.srna)); + if (gt->ext.srna) { + RNA_def_struct_translation_context(gt->srna, RNA_struct_translation_context(gt->ext.srna)); } #endif - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); - gizmo_properties_init(wt); + gizmo_properties_init(gzt); } /** \} */ @@ -190,46 +190,46 @@ void BPY_RNA_gizmo_wrapper(wmGizmoType *wt, void *userdata) /** \name Gizmo Group * \{ */ -static void gizmogroup_properties_init(wmGizmoGroupType *wgt) +static void gizmogroup_properties_init(wmGizmoGroupType *gzgt) { #ifdef USE_SRNA - PyTypeObject *py_class = wgt->ext.data; + PyTypeObject *py_class = gzgt->ext.data; #endif - RNA_struct_blender_type_set(wgt->ext.srna, wgt); + RNA_struct_blender_type_set(gzgt->ext.srna, gzgt); #ifdef USE_SRNA /* only call this so pyrna_deferred_register_class gives a useful error * WM_operatortype_append_ptr will call RNA_def_struct_identifier * later */ - RNA_def_struct_identifier(wgt->srna, wgt->idname); + RNA_def_struct_identifier(gzgt->srna, gzgt->idname); - if (pyrna_deferred_register_class(wgt->srna, py_class) != 0) { + if (pyrna_deferred_register_class(gzgt->srna, py_class) != 0) { PyErr_Print(); /* failed to register operator props */ PyErr_Clear(); } #endif } -void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *wgt, void *userdata) +void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata) { /* take care not to overwrite anything set in * WM_gizmomaptype_group_link_ptr before opfunc() is called */ #ifdef USE_SRNA - StructRNA *srna = wgt->srna; + StructRNA *srna = gzgt->srna; #endif - *wgt = *((wmGizmoGroupType *)userdata); + *gzgt = *((wmGizmoGroupType *)userdata); #ifdef USE_SRNA - wgt->srna = srna; /* restore */ + gzgt->srna = srna; /* restore */ #endif #ifdef USE_SRNA /* Use i18n context from ext.srna if possible (py gizmogroups). */ - if (wgt->ext.srna) { - RNA_def_struct_translation_context(wgt->srna, RNA_struct_translation_context(wgt->ext.srna)); + if (gzgt->ext.srna) { + RNA_def_struct_translation_context(gzgt->srna, RNA_struct_translation_context(gzgt->ext.srna)); } #endif - gizmogroup_properties_init(wgt); + gizmogroup_properties_init(gzgt); } /** \} */ diff --git a/source/blender/python/intern/bpy_gizmo_wrap.h b/source/blender/python/intern/bpy_gizmo_wrap.h index 4d6639d977f..96f15312a4e 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.h +++ b/source/blender/python/intern/bpy_gizmo_wrap.h @@ -29,7 +29,7 @@ struct wmGizmoType; struct wmGizmoGroupType; /* exposed to rna/wm api */ -void BPY_RNA_gizmo_wrapper(struct wmGizmoType *wt, void *userdata); -void BPY_RNA_gizmogroup_wrapper(struct wmGizmoGroupType *wgt, void *userdata); +void BPY_RNA_gizmo_wrapper(struct wmGizmoType *gzt, void *userdata); +void BPY_RNA_gizmogroup_wrapper(struct wmGizmoGroupType *gzgt, void *userdata); #endif /* __BPY_GIZMO_WRAP_H__ */ diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.c index e834595114a..ded26f777a5 100644 --- a/source/blender/python/intern/bpy_rna_gizmo.c +++ b/source/blender/python/intern/bpy_rna_gizmo.c @@ -67,26 +67,26 @@ struct BPyGizmoHandlerUserData { }; static void py_rna_gizmo_handler_get_cb( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, void *value_p) { PyGILState_STATE gilstate = PyGILState_Ensure(); - struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data; PyObject *ret = PyObject_CallObject(data->fn_slots[BPY_GIZMO_FN_SLOT_GET], NULL); if (ret == NULL) { goto fail; } - if (mpr_prop->type->data_type == PROP_FLOAT) { + if (gz_prop->type->data_type == PROP_FLOAT) { float *value = value_p; - if (mpr_prop->type->array_length == 1) { + if (gz_prop->type->array_length == 1) { if ((*value = PyFloat_AsDouble(ret)) == -1.0f && PyErr_Occurred()) { goto fail; } } else { - if (PyC_AsArray(value, ret, mpr_prop->type->array_length, &PyFloat_Type, false, + if (PyC_AsArray(value, ret, gz_prop->type->array_length, &PyFloat_Type, false, "Gizmo get callback: ") == -1) { goto fail; @@ -111,23 +111,23 @@ fail: } static void py_rna_gizmo_handler_set_cb( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, const void *value_p) { PyGILState_STATE gilstate = PyGILState_Ensure(); - struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data; PyObject *args = PyTuple_New(1); - if (mpr_prop->type->data_type == PROP_FLOAT) { + if (gz_prop->type->data_type == PROP_FLOAT) { const float *value = value_p; PyObject *py_value; - if (mpr_prop->type->array_length == 1) { + if (gz_prop->type->array_length == 1) { py_value = PyFloat_FromDouble(*value); } else { - py_value = PyC_Tuple_PackArray_F32(value, mpr_prop->type->array_length); + py_value = PyC_Tuple_PackArray_F32(value, gz_prop->type->array_length); } if (py_value == NULL) { goto fail; @@ -158,10 +158,10 @@ fail: } static void py_rna_gizmo_handler_range_get_cb( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop, + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop, void *value_p) { - struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data; PyGILState_STATE gilstate = PyGILState_Ensure(); @@ -184,7 +184,7 @@ static void py_rna_gizmo_handler_range_get_cb( goto fail; } - if (mpr_prop->type->data_type == PROP_FLOAT) { + if (gz_prop->type->data_type == PROP_FLOAT) { float range[2]; for (int i = 0; i < 2; i++) { if (((range[i] = PyFloat_AsDouble(PyTuple_GET_ITEM(ret, i))) == -1.0f && PyErr_Occurred()) == 0) { @@ -215,9 +215,9 @@ fail: } static void py_rna_gizmo_handler_free_cb( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop) + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop) { - struct BPyGizmoHandlerUserData *data = mpr_prop->custom_func.user_data; + struct BPyGizmoHandlerUserData *data = gz_prop->custom_func.user_data; PyGILState_STATE gilstate = PyGILState_Ensure(); for (int i = 0; i < BPY_GIZMO_FN_SLOT_LEN; i++) { @@ -271,14 +271,14 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject * goto fail; } - wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data; - const wmGizmoPropertyType *mpr_prop_type = - WM_gizmotype_target_property_find(mpr->type, params.target); - if (mpr_prop_type == NULL) { + const wmGizmoPropertyType *gz_prop_type = + WM_gizmotype_target_property_find(gz->type, params.target); + if (gz_prop_type == NULL) { PyErr_Format(PyExc_ValueError, "Gizmo target property '%s.%s' not found", - mpr->type->idname, params.target); + gz->type->idname, params.target); goto fail; } @@ -307,7 +307,7 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject * } WM_gizmo_target_property_def_func_ptr( - mpr, mpr_prop_type, + gz, gz_prop_type, &(const struct wmGizmoPropertyFnParams) { .value_get_fn = py_rna_gizmo_handler_get_cb, .value_set_fn = py_rna_gizmo_handler_set_cb, @@ -361,28 +361,28 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar goto fail; } - wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data; - wmGizmoProperty *mpr_prop = - WM_gizmo_target_property_find(mpr, params.target); - if (mpr_prop == NULL) { + wmGizmoProperty *gz_prop = + WM_gizmo_target_property_find(gz, params.target); + if (gz_prop == NULL) { PyErr_Format(PyExc_ValueError, "Gizmo target property '%s.%s' not found", - mpr->type->idname, params.target); + gz->type->idname, params.target); goto fail; } - const int array_len = WM_gizmo_target_property_array_length(mpr, mpr_prop); - switch (mpr_prop->type->data_type) { + const int array_len = WM_gizmo_target_property_array_length(gz, gz_prop); + switch (gz_prop->type->data_type) { case PROP_FLOAT: { if (array_len != 0) { float *value = BLI_array_alloca(value, array_len); - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, value); + WM_gizmo_target_property_value_get_array(gz, gz_prop, value); return PyC_Tuple_PackArray_F32(value, array_len); } else { - float value = WM_gizmo_target_property_value_get(mpr, mpr_prop); + float value = WM_gizmo_target_property_value_get(gz, gz_prop); return PyFloat_FromDouble(value); } break; @@ -429,36 +429,36 @@ static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *ar goto fail; } - wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data; - wmGizmoProperty *mpr_prop = - WM_gizmo_target_property_find(mpr, params.target); - if (mpr_prop == NULL) { + wmGizmoProperty *gz_prop = + WM_gizmo_target_property_find(gz, params.target); + if (gz_prop == NULL) { PyErr_Format(PyExc_ValueError, "Gizmo target property '%s.%s' not found", - mpr->type->idname, params.target); + gz->type->idname, params.target); goto fail; } - const int array_len = WM_gizmo_target_property_array_length(mpr, mpr_prop); - switch (mpr_prop->type->data_type) { + const int array_len = WM_gizmo_target_property_array_length(gz, gz_prop); + switch (gz_prop->type->data_type) { case PROP_FLOAT: { if (array_len != 0) { float *value = BLI_array_alloca(value, array_len); - if (PyC_AsArray(value, params.value, mpr_prop->type->array_length, &PyFloat_Type, false, + if (PyC_AsArray(value, params.value, gz_prop->type->array_length, &PyFloat_Type, false, "Gizmo target property array") == -1) { goto fail; } - WM_gizmo_target_property_value_set_array(BPy_GetContext(), mpr, mpr_prop, value); + WM_gizmo_target_property_value_set_array(BPy_GetContext(), gz, gz_prop, value); } else { float value; if ((value = PyFloat_AsDouble(params.value)) == -1.0f && PyErr_Occurred()) { goto fail; } - WM_gizmo_target_property_value_set(BPy_GetContext(), mpr, mpr_prop, value); + WM_gizmo_target_property_value_set(BPy_GetContext(), gz, gz_prop, value); } Py_RETURN_NONE; } @@ -504,22 +504,22 @@ static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *ar goto fail; } - wmGizmo *mpr = ((BPy_StructRNA *)params.self)->ptr.data; + wmGizmo *gz = ((BPy_StructRNA *)params.self)->ptr.data; - wmGizmoProperty *mpr_prop = - WM_gizmo_target_property_find(mpr, params.target); - if (mpr_prop == NULL) { + wmGizmoProperty *gz_prop = + WM_gizmo_target_property_find(gz, params.target); + if (gz_prop == NULL) { PyErr_Format(PyExc_ValueError, "Gizmo target property '%s.%s' not found", - mpr->type->idname, params.target); + gz->type->idname, params.target); goto fail; } - switch (mpr_prop->type->data_type) { + switch (gz_prop->type->data_type) { case PROP_FLOAT: { float range[2]; - WM_gizmo_target_property_range_get(mpr, mpr_prop, range); + WM_gizmo_target_property_range_get(gz, gz_prop, range); return PyC_Tuple_PackArray_F32(range, 2); } default: diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index a93597d4f64..9b8cecfb4bc 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -60,57 +60,57 @@ struct wmMsgSubscribeValue; /* wmGizmo */ struct wmGizmo *WM_gizmo_new_ptr( - const struct wmGizmoType *wt, struct wmGizmoGroup *mgroup, + const struct wmGizmoType *gzt, struct wmGizmoGroup *gzgroup, struct PointerRNA *properties); struct wmGizmo *WM_gizmo_new( - const char *idname, struct wmGizmoGroup *mgroup, + const char *idname, struct wmGizmoGroup *gzgroup, struct PointerRNA *properties); -void WM_gizmo_free(struct wmGizmo *mpr); +void WM_gizmo_free(struct wmGizmo *gz); void WM_gizmo_unlink( - ListBase *gizmolist, struct wmGizmoMap *mmap, struct wmGizmo *mpr, + ListBase *gizmolist, struct wmGizmoMap *gzmap, struct wmGizmo *gz, struct bContext *C); -void WM_gizmo_name_set(struct wmGizmoGroup *mgroup, struct wmGizmo *mpr, const char *name); +void WM_gizmo_name_set(struct wmGizmoGroup *gzgroup, struct wmGizmo *gz, const char *name); -bool WM_gizmo_select_unlink(struct wmGizmoMap *mmap, struct wmGizmo *mpr); -bool WM_gizmo_select_set(struct wmGizmoMap *mmap, struct wmGizmo *mpr, bool select); -void WM_gizmo_highlight_set(struct wmGizmoMap *mmap, struct wmGizmo *mpr); +bool WM_gizmo_select_unlink(struct wmGizmoMap *gzmap, struct wmGizmo *gz); +bool WM_gizmo_select_set(struct wmGizmoMap *gzmap, struct wmGizmo *gz, bool select); +void WM_gizmo_highlight_set(struct wmGizmoMap *gzmap, struct wmGizmo *gz); void WM_gizmo_modal_set_from_setup( - struct wmGizmoMap *mmap, struct bContext *C, - struct wmGizmo *mpr, int part_index, const struct wmEvent *event); + struct wmGizmoMap *gzmap, struct bContext *C, + struct wmGizmo *gz, int part_index, const struct wmEvent *event); struct wmGizmoOpElem *WM_gizmo_operator_get( - struct wmGizmo *mpr, int part_index); + struct wmGizmo *gz, int part_index); struct PointerRNA *WM_gizmo_operator_set( - struct wmGizmo *mpr, int part_index, + struct wmGizmo *gz, int part_index, struct wmOperatorType *ot, struct IDProperty *properties); /* callbacks */ -void WM_gizmo_set_fn_custom_modal(struct wmGizmo *mpr, wmGizmoFnModal fn); +void WM_gizmo_set_fn_custom_modal(struct wmGizmo *gz, wmGizmoFnModal fn); void WM_gizmo_set_matrix_location( - struct wmGizmo *mpr, const float origin[3]); + struct wmGizmo *gz, const float origin[3]); void WM_gizmo_set_matrix_rotation_from_z_axis( - struct wmGizmo *mpr, const float z_axis[3]); + struct wmGizmo *gz, const float z_axis[3]); void WM_gizmo_set_matrix_rotation_from_yz_axis( - struct wmGizmo *mpr, const float y_axis[3], const float z_axis[3]); + struct wmGizmo *gz, const float y_axis[3], const float z_axis[3]); void WM_gizmo_set_matrix_offset_location( - struct wmGizmo *mpr, const float origin[3]); + struct wmGizmo *gz, const float origin[3]); void WM_gizmo_set_matrix_offset_rotation_from_z_axis( - struct wmGizmo *mpr, const float z_axis[3]); + struct wmGizmo *gz, const float z_axis[3]); void WM_gizmo_set_matrix_offset_rotation_from_yz_axis( - struct wmGizmo *mpr, const float y_axis[3], const float z_axis[3]); + struct wmGizmo *gz, const float y_axis[3], const float z_axis[3]); -void WM_gizmo_set_flag(struct wmGizmo *mpr, const int flag, const bool enable); -void WM_gizmo_set_scale(struct wmGizmo *mpr, float scale); -void WM_gizmo_set_line_width(struct wmGizmo *mpr, const float line_width); +void WM_gizmo_set_flag(struct wmGizmo *gz, const int flag, const bool enable); +void WM_gizmo_set_scale(struct wmGizmo *gz, float scale); +void WM_gizmo_set_line_width(struct wmGizmo *gz, const float line_width); -void WM_gizmo_get_color(const struct wmGizmo *mpr, float color[4]); -void WM_gizmo_set_color(struct wmGizmo *mpr, const float color[4]); -void WM_gizmo_get_color_highlight(const struct wmGizmo *mpr, float color_hi[4]); -void WM_gizmo_set_color_highlight(struct wmGizmo *mpr, const float color[4]); +void WM_gizmo_get_color(const struct wmGizmo *gz, float color[4]); +void WM_gizmo_set_color(struct wmGizmo *gz, const float color[4]); +void WM_gizmo_get_color_highlight(const struct wmGizmo *gz, float color_hi[4]); +void WM_gizmo_set_color_highlight(struct wmGizmo *gz, const float color[4]); /** * Leaving values NULL use values from #wmGizmo. @@ -123,16 +123,16 @@ struct WM_GizmoMatrixParams { }; void WM_gizmo_calc_matrix_final_params( - const struct wmGizmo *mpr, const struct WM_GizmoMatrixParams *params, + const struct wmGizmo *gz, const struct WM_GizmoMatrixParams *params, float r_mat[4][4]); void WM_gizmo_calc_matrix_final_no_offset( - const struct wmGizmo *mpr, float r_mat[4][4]); + const struct wmGizmo *gz, float r_mat[4][4]); void WM_gizmo_calc_matrix_final( - const struct wmGizmo *mpr, float r_mat[4][4]); + const struct wmGizmo *gz, float r_mat[4][4]); /* properties */ -void WM_gizmo_properties_create_ptr(struct PointerRNA *ptr, struct wmGizmoType *wt); +void WM_gizmo_properties_create_ptr(struct PointerRNA *ptr, struct wmGizmoType *gzt); void WM_gizmo_properties_create(struct PointerRNA *ptr, const char *opstring); void WM_gizmo_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring); void WM_gizmo_properties_sanitize(struct PointerRNA *ptr, const bool no_context); @@ -147,7 +147,7 @@ const struct wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet); void WM_gizmotype_append(void (*wtfunc)(struct wmGizmoType *)); void WM_gizmotype_append_ptr(void (*mnpfunc)(struct wmGizmoType *, void *), void *userdata); bool WM_gizmotype_remove(struct bContext *C, struct Main *bmain, const char *idname); -void WM_gizmotype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmGizmoType *wt); +void WM_gizmotype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmGizmoType *gzt); void WM_gizmotype_iter(struct GHashIterator *ghi); /* wm_gizmo_group_type.c */ @@ -159,111 +159,111 @@ void WM_gizmogrouptype_free_ptr(struct wmGizmoGroupType *wt); void WM_gizmogrouptype_iter(struct GHashIterator *ghi); struct wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link( - struct wmGizmoMapType *mmap_type, + struct wmGizmoMapType *gzmap_type, void (*wtfunc)(struct wmGizmoGroupType *)); /* wm_gizmo_map.c */ /* Dynamic Updates (for RNA runtime registration) */ -void WM_gizmoconfig_update_tag_init(struct wmGizmoMapType *mmap_type, struct wmGizmoGroupType *wgt); -void WM_gizmoconfig_update_tag_remove(struct wmGizmoMapType *mmap_type, struct wmGizmoGroupType *wgt); +void WM_gizmoconfig_update_tag_init(struct wmGizmoMapType *gzmap_type, struct wmGizmoGroupType *gzgt); +void WM_gizmoconfig_update_tag_remove(struct wmGizmoMapType *gzmap_type, struct wmGizmoGroupType *gzgt); void WM_gizmoconfig_update(struct Main *bmain); /* wm_maniulator_target_props.c */ -struct wmGizmoProperty *WM_gizmo_target_property_array(struct wmGizmo *mpr); +struct wmGizmoProperty *WM_gizmo_target_property_array(struct wmGizmo *gz); struct wmGizmoProperty *WM_gizmo_target_property_at_index( - struct wmGizmo *mpr, int index); + struct wmGizmo *gz, int index); struct wmGizmoProperty *WM_gizmo_target_property_find( - struct wmGizmo *mpr, const char *idname); + struct wmGizmo *gz, const char *idname); void WM_gizmo_target_property_def_rna_ptr( - struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type, + struct wmGizmo *gz, const struct wmGizmoPropertyType *gz_prop_type, struct PointerRNA *ptr, struct PropertyRNA *prop, int index); void WM_gizmo_target_property_def_rna( - struct wmGizmo *mpr, const char *idname, + struct wmGizmo *gz, const char *idname, struct PointerRNA *ptr, const char *propname, int index); void WM_gizmo_target_property_def_func_ptr( - struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type, + struct wmGizmo *gz, const struct wmGizmoPropertyType *gz_prop_type, const struct wmGizmoPropertyFnParams *params); void WM_gizmo_target_property_def_func( - struct wmGizmo *mpr, const char *idname, + struct wmGizmo *gz, const char *idname, const struct wmGizmoPropertyFnParams *params); void WM_gizmo_target_property_clear_rna_ptr( - struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type); + struct wmGizmo *gz, const struct wmGizmoPropertyType *gz_prop_type); void WM_gizmo_target_property_clear_rna( - struct wmGizmo *mpr, const char *idname); + struct wmGizmo *gz, const char *idname); -bool WM_gizmo_target_property_is_valid_any(struct wmGizmo *mpr); +bool WM_gizmo_target_property_is_valid_any(struct wmGizmo *gz); bool WM_gizmo_target_property_is_valid( - const struct wmGizmoProperty *mpr_prop); + const struct wmGizmoProperty *gz_prop); float WM_gizmo_target_property_value_get( - const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop); + const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop); void WM_gizmo_target_property_value_set( - struct bContext *C, const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, + struct bContext *C, const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop, const float value); void WM_gizmo_target_property_value_get_array( - const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, + const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop, float *value); void WM_gizmo_target_property_value_set_array( - struct bContext *C, const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, + struct bContext *C, const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop, const float *value); bool WM_gizmo_target_property_range_get( - const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, + const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop, float range[2]); int WM_gizmo_target_property_array_length( - const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop); + const struct wmGizmo *gz, struct wmGizmoProperty *gz_prop); /* definitions */ const struct wmGizmoPropertyType *WM_gizmotype_target_property_find( - const struct wmGizmoType *wt, const char *idname); + const struct wmGizmoType *gzt, const char *idname); void WM_gizmotype_target_property_def( - struct wmGizmoType *wt, const char *idname, int data_type, int array_length); + struct wmGizmoType *gzt, const char *idname, int data_type, int array_length); /* utilities */ void WM_gizmo_do_msg_notify_tag_refresh( struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val); void WM_gizmo_target_property_subscribe_all( - struct wmGizmo *mpr, struct wmMsgBus *mbus, struct ARegion *ar); + struct wmGizmo *gz, struct wmMsgBus *mbus, struct ARegion *ar); /* -------------------------------------------------------------------- */ /* wmGizmoGroup */ /* Callbacks for 'wmGizmoGroupType.setup_keymap' */ struct wmKeyMap *WM_gizmogroup_keymap_common( - const struct wmGizmoGroupType *wgt, struct wmKeyConfig *config); + const struct wmGizmoGroupType *gzgt, struct wmKeyConfig *config); struct wmKeyMap *WM_gizmogroup_keymap_common_select( - const struct wmGizmoGroupType *wgt, struct wmKeyConfig *config); + const struct wmGizmoGroupType *gzgt, struct wmKeyConfig *config); /* -------------------------------------------------------------------- */ /* wmGizmoMap */ struct wmGizmoMap *WM_gizmomap_new_from_type( - const struct wmGizmoMapType_Params *mmap_params); -const struct ListBase *WM_gizmomap_group_list(struct wmGizmoMap *mmap); + const struct wmGizmoMapType_Params *gzmap_params); +const struct ListBase *WM_gizmomap_group_list(struct wmGizmoMap *gzmap); struct wmGizmoGroup *WM_gizmomap_group_find( - struct wmGizmoMap *mmap, + struct wmGizmoMap *gzmap, const char *idname); struct wmGizmoGroup *WM_gizmomap_group_find_ptr( - struct wmGizmoMap *mmap, - const struct wmGizmoGroupType *wgt); -void WM_gizmomap_tag_refresh(struct wmGizmoMap *mmap); + struct wmGizmoMap *gzmap, + const struct wmGizmoGroupType *gzgt); +void WM_gizmomap_tag_refresh(struct wmGizmoMap *gzmap); void WM_gizmomap_draw( - struct wmGizmoMap *mmap, const struct bContext *C, const eWM_GizmoFlagMapDrawStep drawstep); -void WM_gizmomap_add_handlers(struct ARegion *ar, struct wmGizmoMap *mmap); -bool WM_gizmomap_select_all(struct bContext *C, struct wmGizmoMap *mmap, const int action); -bool WM_gizmomap_cursor_set(const struct wmGizmoMap *mmap, struct wmWindow *win); + struct wmGizmoMap *gzmap, const struct bContext *C, const eWM_GizmoFlagMapDrawStep drawstep); +void WM_gizmomap_add_handlers(struct ARegion *ar, struct wmGizmoMap *gzmap); +bool WM_gizmomap_select_all(struct bContext *C, struct wmGizmoMap *gzmap, const int action); +bool WM_gizmomap_cursor_set(const struct wmGizmoMap *gzmap, struct wmWindow *win); void WM_gizmomap_message_subscribe( - struct bContext *C, struct wmGizmoMap *mmap, struct ARegion *ar, struct wmMsgBus *mbus); -bool WM_gizmomap_is_any_selected(const struct wmGizmoMap *mmap); + struct bContext *C, struct wmGizmoMap *gzmap, struct ARegion *ar, struct wmMsgBus *mbus); +bool WM_gizmomap_is_any_selected(const struct wmGizmoMap *gzmap); bool WM_gizmomap_minmax( - const struct wmGizmoMap *mmap, bool use_hidden, bool use_select, + const struct wmGizmoMap *gzmap, bool use_hidden, bool use_select, float r_min[3], float r_max[3]); struct ARegion *WM_gizmomap_tooltip_init( @@ -273,34 +273,34 @@ struct ARegion *WM_gizmomap_tooltip_init( /* wmGizmoMapType */ struct wmGizmoMapType *WM_gizmomaptype_find( - const struct wmGizmoMapType_Params *mmap_params); + const struct wmGizmoMapType_Params *gzmap_params); struct wmGizmoMapType *WM_gizmomaptype_ensure( - const struct wmGizmoMapType_Params *mmap_params); + const struct wmGizmoMapType_Params *gzmap_params); struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find( - struct wmGizmoMapType *mmap_type, + struct wmGizmoMapType *gzmap_type, const char *idname); struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr( - struct wmGizmoMapType *mmap_type, - const struct wmGizmoGroupType *wgt); + struct wmGizmoMapType *gzmap_type, + const struct wmGizmoGroupType *gzgt); struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_link( - struct wmGizmoMapType *mmap_type, + struct wmGizmoMapType *gzmap_type, const char *idname); struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr( - struct wmGizmoMapType *mmap_type, - struct wmGizmoGroupType *wgt); + struct wmGizmoMapType *gzmap_type, + struct wmGizmoGroupType *gzgt); void WM_gizmomaptype_group_init_runtime_keymap( const struct Main *bmain, - struct wmGizmoGroupType *wgt); + struct wmGizmoGroupType *gzgt); void WM_gizmomaptype_group_init_runtime( - const struct Main *bmain, struct wmGizmoMapType *mmap_type, - struct wmGizmoGroupType *wgt); + const struct Main *bmain, struct wmGizmoMapType *gzmap_type, + struct wmGizmoGroupType *gzgt); void WM_gizmomaptype_group_unlink( - struct bContext *C, struct Main *bmain, struct wmGizmoMapType *mmap_type, - const struct wmGizmoGroupType *wgt); + struct bContext *C, struct Main *bmain, struct wmGizmoMapType *gzmap_type, + const struct wmGizmoGroupType *gzgt); -void WM_gizmomaptype_group_free(struct wmGizmoGroupTypeRef *wgt); +void WM_gizmomaptype_group_free(struct wmGizmoGroupTypeRef *gzgt); /* -------------------------------------------------------------------- */ /* GizmoGroup */ @@ -308,36 +308,36 @@ void WM_gizmomaptype_group_free(struct wmGizmoGroupTypeRef *wgt); /* Add/Ensure/Remove (High level API) */ void WM_gizmo_group_type_add_ptr_ex( - struct wmGizmoGroupType *wgt, - struct wmGizmoMapType *mmap_type); + struct wmGizmoGroupType *gzgt, + struct wmGizmoMapType *gzmap_type); void WM_gizmo_group_type_add_ptr( - struct wmGizmoGroupType *wgt); + struct wmGizmoGroupType *gzgt); void WM_gizmo_group_type_add(const char *idname); void WM_gizmo_group_type_ensure_ptr_ex( - struct wmGizmoGroupType *wgt, - struct wmGizmoMapType *mmap_type); + struct wmGizmoGroupType *gzgt, + struct wmGizmoMapType *gzmap_type); void WM_gizmo_group_type_ensure_ptr( - struct wmGizmoGroupType *wgt); + struct wmGizmoGroupType *gzgt); void WM_gizmo_group_type_ensure(const char *idname); void WM_gizmo_group_type_remove_ptr_ex( - struct Main *bmain, struct wmGizmoGroupType *wgt, - struct wmGizmoMapType *mmap_type); + struct Main *bmain, struct wmGizmoGroupType *gzgt, + struct wmGizmoMapType *gzmap_type); void WM_gizmo_group_type_remove_ptr( - struct Main *bmain, struct wmGizmoGroupType *wgt); + struct Main *bmain, struct wmGizmoGroupType *gzgt); void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname); void WM_gizmo_group_type_unlink_delayed_ptr_ex( - struct wmGizmoGroupType *wgt, - struct wmGizmoMapType *mmap_type); + struct wmGizmoGroupType *gzgt, + struct wmGizmoMapType *gzmap_type); void WM_gizmo_group_type_unlink_delayed_ptr( - struct wmGizmoGroupType *wgt); + struct wmGizmoGroupType *gzgt); void WM_gizmo_group_type_unlink_delayed(const char *idname); /* Utilities */ bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step); -bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *wgt); +bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *gzgt); #endif /* __WM_GIZMO_API_H__ */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index ecdda256306..2339523db5e 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -171,7 +171,7 @@ struct wmGizmo { wmGizmoFnModal custom_modal; /* pointer back to group this gizmo is in (just for quick access) */ - struct wmGizmoGroup *parent_mgroup; + struct wmGizmoGroup *parent_gzgroup; void *py_instance; @@ -385,7 +385,7 @@ typedef struct wmGizmoGroupType { eWM_GizmoFlagMapTypeUpdateFlag type_update_flag; /* same as gizmo-maps, so registering/unregistering goes to the correct region */ - struct wmGizmoMapType_Params mmap_params; + struct wmGizmoMapType_Params gzmap_params; } wmGizmoGroupType; @@ -395,7 +395,7 @@ typedef struct wmGizmoGroup { struct wmGizmoGroupType *type; ListBase gizmos; - struct wmGizmoMap *parent_mmap; + struct wmGizmoMap *parent_gzmap; void *py_instance; /* python stores the class instance here */ struct ReportList *reports; /* errors and warnings storage */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c index da8b301b536..14deb0be725 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c @@ -67,98 +67,98 @@ #include "wm_gizmo_intern.h" static void wm_gizmo_register( - wmGizmoGroup *mgroup, wmGizmo *mpr); + wmGizmoGroup *gzgroup, wmGizmo *gz); /** * \note Follow #wm_operator_create convention. */ static wmGizmo *wm_gizmo_create( - const wmGizmoType *wt, + const wmGizmoType *gzt, PointerRNA *properties) { - BLI_assert(wt != NULL); - BLI_assert(wt->struct_size >= sizeof(wmGizmo)); + BLI_assert(gzt != NULL); + BLI_assert(gzt->struct_size >= sizeof(wmGizmo)); - wmGizmo *mpr = MEM_callocN( - wt->struct_size + (sizeof(wmGizmoProperty) * wt->target_property_defs_len), __func__); - mpr->type = wt; + wmGizmo *gz = MEM_callocN( + gzt->struct_size + (sizeof(wmGizmoProperty) * gzt->target_property_defs_len), __func__); + gz->type = gzt; /* initialize properties, either copy or create */ - mpr->ptr = MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA"); + gz->ptr = MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA"); if (properties && properties->data) { - mpr->properties = IDP_CopyProperty(properties->data); + gz->properties = IDP_CopyProperty(properties->data); } else { IDPropertyTemplate val = {0}; - mpr->properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties"); + gz->properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties"); } - RNA_pointer_create(G_MAIN->wm.first, wt->srna, mpr->properties, mpr->ptr); + RNA_pointer_create(G_MAIN->wm.first, gzt->srna, gz->properties, gz->ptr); - WM_gizmo_properties_sanitize(mpr->ptr, 0); + WM_gizmo_properties_sanitize(gz->ptr, 0); - unit_m4(mpr->matrix_space); - unit_m4(mpr->matrix_basis); - unit_m4(mpr->matrix_offset); + unit_m4(gz->matrix_space); + unit_m4(gz->matrix_basis); + unit_m4(gz->matrix_offset); - mpr->drag_part = -1; + gz->drag_part = -1; - return mpr; + return gz; } wmGizmo *WM_gizmo_new_ptr( - const wmGizmoType *wt, wmGizmoGroup *mgroup, + const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties) { - wmGizmo *mpr = wm_gizmo_create(wt, properties); + wmGizmo *gz = wm_gizmo_create(gzt, properties); - wm_gizmo_register(mgroup, mpr); + wm_gizmo_register(gzgroup, gz); - if (mpr->type->setup != NULL) { - mpr->type->setup(mpr); + if (gz->type->setup != NULL) { + gz->type->setup(gz); } - return mpr; + return gz; } /** - * \param wt: Must be valid, + * \param gt: Must be valid, * if you need to check it exists use #WM_gizmo_new_ptr * because callers of this function don't NULL check the return value. */ wmGizmo *WM_gizmo_new( - const char *idname, wmGizmoGroup *mgroup, + const char *idname, wmGizmoGroup *gzgroup, PointerRNA *properties) { - const wmGizmoType *wt = WM_gizmotype_find(idname, false); - return WM_gizmo_new_ptr(wt, mgroup, properties); + const wmGizmoType *gzt = WM_gizmotype_find(idname, false); + return WM_gizmo_new_ptr(gzt, gzgroup, properties); } /** * Initialize default values and allocate needed memory for members. */ -static void gizmo_init(wmGizmo *mpr) +static void gizmo_init(wmGizmo *gz) { const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - mpr->scale_basis = 1.0f; - mpr->line_width = 1.0f; + gz->scale_basis = 1.0f; + gz->line_width = 1.0f; /* defaults */ - copy_v4_v4(mpr->color, color_default); - copy_v4_v4(mpr->color_hi, color_default); + copy_v4_v4(gz->color, color_default); + copy_v4_v4(gz->color_hi, color_default); } /** * Register \a gizmo. * - * \param name: name used to create a unique idname for \a gizmo in \a mgroup + * \param name: name used to create a unique idname for \a gizmo in \a gzgroup * * \note Not to be confused with type registration from RNA. */ -static void wm_gizmo_register(wmGizmoGroup *mgroup, wmGizmo *mpr) +static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz) { - gizmo_init(mpr); - wm_gizmogroup_gizmo_register(mgroup, mpr); + gizmo_init(gz); + wm_gizmogroup_gizmo_register(gzgroup, gz); } /** @@ -166,70 +166,70 @@ static void wm_gizmo_register(wmGizmoGroup *mgroup, wmGizmo *mpr) * Typical use is when freeing the windowing data, * where caller can manage clearing selection, highlight... etc. */ -void WM_gizmo_free(wmGizmo *mpr) +void WM_gizmo_free(wmGizmo *gz) { - if (mpr->type->free != NULL) { - mpr->type->free(mpr); + if (gz->type->free != NULL) { + gz->type->free(gz); } #ifdef WITH_PYTHON - if (mpr->py_instance) { + if (gz->py_instance) { /* do this first in case there are any __del__ functions or * similar that use properties */ - BPY_DECREF_RNA_INVALIDATE(mpr->py_instance); + BPY_DECREF_RNA_INVALIDATE(gz->py_instance); } #endif - if (mpr->op_data) { - for (int i = 0; i < mpr->op_data_len; i++) { - WM_operator_properties_free(&mpr->op_data[i].ptr); + if (gz->op_data) { + for (int i = 0; i < gz->op_data_len; i++) { + WM_operator_properties_free(&gz->op_data[i].ptr); } - MEM_freeN(mpr->op_data); + MEM_freeN(gz->op_data); } - if (mpr->ptr != NULL) { - WM_gizmo_properties_free(mpr->ptr); - MEM_freeN(mpr->ptr); + if (gz->ptr != NULL) { + WM_gizmo_properties_free(gz->ptr); + MEM_freeN(gz->ptr); } - if (mpr->type->target_property_defs_len != 0) { - wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; - if (mpr_prop->custom_func.free_fn) { - mpr_prop->custom_func.free_fn(mpr, mpr_prop); + if (gz->type->target_property_defs_len != 0) { + wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz); + for (int i = 0; i < gz->type->target_property_defs_len; i++) { + wmGizmoProperty *gz_prop = &gz_prop_array[i]; + if (gz_prop->custom_func.free_fn) { + gz_prop->custom_func.free_fn(gz, gz_prop); } } } - MEM_freeN(mpr); + MEM_freeN(gz); } /** * Free \a gizmo and unlink from \a gizmolist. * \a gizmolist is allowed to be NULL. */ -void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *mmap, wmGizmo *mpr, bContext *C) +void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C) { - if (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) { - wm_gizmomap_highlight_set(mmap, C, NULL, 0); + if (gz->state & WM_GIZMO_STATE_HIGHLIGHT) { + wm_gizmomap_highlight_set(gzmap, C, NULL, 0); } - if (mpr->state & WM_GIZMO_STATE_MODAL) { - wm_gizmomap_modal_set(mmap, C, mpr, NULL, false); + if (gz->state & WM_GIZMO_STATE_MODAL) { + wm_gizmomap_modal_set(gzmap, C, gz, NULL, false); } /* Unlink instead of setting so we don't run callbacks. */ - if (mpr->state & WM_GIZMO_STATE_SELECT) { - WM_gizmo_select_unlink(mmap, mpr); + if (gz->state & WM_GIZMO_STATE_SELECT) { + WM_gizmo_select_unlink(gzmap, gz); } if (gizmolist) { - BLI_remlink(gizmolist, mpr); + BLI_remlink(gizmolist, gz); } - BLI_assert(mmap->mmap_context.highlight != mpr); - BLI_assert(mmap->mmap_context.modal != mpr); + BLI_assert(gzmap->gzmap_context.highlight != gz); + BLI_assert(gzmap->gzmap_context.modal != gz); - WM_gizmo_free(mpr); + WM_gizmo_free(gz); } /* -------------------------------------------------------------------- */ @@ -240,25 +240,25 @@ void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *mmap, wmGizmo *mpr, bConte * \{ */ struct wmGizmoOpElem *WM_gizmo_operator_get( - wmGizmo *mpr, int part_index) + wmGizmo *gz, int part_index) { - if (mpr->op_data && ((part_index >= 0) && (part_index < mpr->op_data_len))) { - return &mpr->op_data[part_index]; + if (gz->op_data && ((part_index >= 0) && (part_index < gz->op_data_len))) { + return &gz->op_data[part_index]; } return NULL; } PointerRNA *WM_gizmo_operator_set( - wmGizmo *mpr, int part_index, + wmGizmo *gz, int part_index, wmOperatorType *ot, IDProperty *properties) { BLI_assert(part_index < 255); /* We could pre-allocate these but using multiple is such a rare thing. */ - if (part_index >= mpr->op_data_len) { - mpr->op_data_len = part_index + 1; - mpr->op_data = MEM_recallocN(mpr->op_data, sizeof(*mpr->op_data) * mpr->op_data_len); + if (part_index >= gz->op_data_len) { + gz->op_data_len = part_index + 1; + gz->op_data = MEM_recallocN(gz->op_data, sizeof(*gz->op_data) * gz->op_data_len); } - wmGizmoOpElem *mpop = &mpr->op_data[part_index]; + wmGizmoOpElem *mpop = &gz->op_data[part_index]; mpop->type = ot; if (mpop->ptr.data) { @@ -305,56 +305,56 @@ static void wm_gizmo_set_matrix_rotation_from_yz_axis__internal( * wmGizmo.matrix utils. */ void WM_gizmo_set_matrix_rotation_from_z_axis( - wmGizmo *mpr, const float z_axis[3]) + wmGizmo *gz, const float z_axis[3]) { - wm_gizmo_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis); + wm_gizmo_set_matrix_rotation_from_z_axis__internal(gz->matrix_basis, z_axis); } void WM_gizmo_set_matrix_rotation_from_yz_axis( - wmGizmo *mpr, const float y_axis[3], const float z_axis[3]) + wmGizmo *gz, const float y_axis[3], const float z_axis[3]) { - wm_gizmo_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis); + wm_gizmo_set_matrix_rotation_from_yz_axis__internal(gz->matrix_basis, y_axis, z_axis); } -void WM_gizmo_set_matrix_location(wmGizmo *mpr, const float origin[3]) +void WM_gizmo_set_matrix_location(wmGizmo *gz, const float origin[3]) { - copy_v3_v3(mpr->matrix_basis[3], origin); + copy_v3_v3(gz->matrix_basis[3], origin); } /** * wmGizmo.matrix_offset utils. */ void WM_gizmo_set_matrix_offset_rotation_from_z_axis( - wmGizmo *mpr, const float z_axis[3]) + wmGizmo *gz, const float z_axis[3]) { - wm_gizmo_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis); + wm_gizmo_set_matrix_rotation_from_z_axis__internal(gz->matrix_offset, z_axis); } void WM_gizmo_set_matrix_offset_rotation_from_yz_axis( - wmGizmo *mpr, const float y_axis[3], const float z_axis[3]) + wmGizmo *gz, const float y_axis[3], const float z_axis[3]) { - wm_gizmo_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis); + wm_gizmo_set_matrix_rotation_from_yz_axis__internal(gz->matrix_offset, y_axis, z_axis); } -void WM_gizmo_set_matrix_offset_location(wmGizmo *mpr, const float offset[3]) +void WM_gizmo_set_matrix_offset_location(wmGizmo *gz, const float offset[3]) { - copy_v3_v3(mpr->matrix_offset[3], offset); + copy_v3_v3(gz->matrix_offset[3], offset); } -void WM_gizmo_set_flag(wmGizmo *mpr, const int flag, const bool enable) +void WM_gizmo_set_flag(wmGizmo *gz, const int flag, const bool enable) { if (enable) { - mpr->flag |= flag; + gz->flag |= flag; } else { - mpr->flag &= ~flag; + gz->flag &= ~flag; } } -void WM_gizmo_set_scale(wmGizmo *mpr, const float scale) +void WM_gizmo_set_scale(wmGizmo *gz, const float scale) { - mpr->scale_basis = scale; + gz->scale_basis = scale; } -void WM_gizmo_set_line_width(wmGizmo *mpr, const float line_width) +void WM_gizmo_set_line_width(wmGizmo *gz, const float line_width) { - mpr->line_width = line_width; + gz->line_width = line_width; } /** @@ -363,22 +363,22 @@ void WM_gizmo_set_line_width(wmGizmo *mpr, const float line_width) * \param col Normal state color. * \param col_hi Highlighted state color. */ -void WM_gizmo_get_color(const wmGizmo *mpr, float color[4]) +void WM_gizmo_get_color(const wmGizmo *gz, float color[4]) { - copy_v4_v4(color, mpr->color); + copy_v4_v4(color, gz->color); } -void WM_gizmo_set_color(wmGizmo *mpr, const float color[4]) +void WM_gizmo_set_color(wmGizmo *gz, const float color[4]) { - copy_v4_v4(mpr->color, color); + copy_v4_v4(gz->color, color); } -void WM_gizmo_get_color_highlight(const wmGizmo *mpr, float color_hi[4]) +void WM_gizmo_get_color_highlight(const wmGizmo *gz, float color_hi[4]) { - copy_v4_v4(color_hi, mpr->color_hi); + copy_v4_v4(color_hi, gz->color_hi); } -void WM_gizmo_set_color_highlight(wmGizmo *mpr, const float color_hi[4]) +void WM_gizmo_set_color_highlight(wmGizmo *gz, const float color_hi[4]) { - copy_v4_v4(mpr->color_hi, color_hi); + copy_v4_v4(gz->color_hi, color_hi); } @@ -390,9 +390,9 @@ void WM_gizmo_set_color_highlight(wmGizmo *mpr, const float color_hi[4]) * * \{ */ -void WM_gizmo_set_fn_custom_modal(struct wmGizmo *mpr, wmGizmoFnModal fn) +void WM_gizmo_set_fn_custom_modal(struct wmGizmo *gz, wmGizmoFnModal fn) { - mpr->custom_modal = fn; + gz->custom_modal = fn; } /** \} */ @@ -407,26 +407,26 @@ void WM_gizmo_set_fn_custom_modal(struct wmGizmo *mpr, wmGizmoFnModal fn) * \return if the selection has changed. */ bool wm_gizmo_select_set_ex( - wmGizmoMap *mmap, wmGizmo *mpr, bool select, + wmGizmoMap *gzmap, wmGizmo *gz, bool select, bool use_array, bool use_callback) { bool changed = false; if (select) { - if ((mpr->state & WM_GIZMO_STATE_SELECT) == 0) { + if ((gz->state & WM_GIZMO_STATE_SELECT) == 0) { if (use_array) { - wm_gizmomap_select_array_push_back(mmap, mpr); + wm_gizmomap_select_array_push_back(gzmap, gz); } - mpr->state |= WM_GIZMO_STATE_SELECT; + gz->state |= WM_GIZMO_STATE_SELECT; changed = true; } } else { - if (mpr->state & WM_GIZMO_STATE_SELECT) { + if (gz->state & WM_GIZMO_STATE_SELECT) { if (use_array) { - wm_gizmomap_select_array_remove(mmap, mpr); + wm_gizmomap_select_array_remove(gzmap, gz); } - mpr->state &= ~WM_GIZMO_STATE_SELECT; + gz->state &= ~WM_GIZMO_STATE_SELECT; changed = true; } } @@ -434,8 +434,8 @@ bool wm_gizmo_select_set_ex( /* In the case of unlinking we only want to remove from the array * and not write to the external state */ if (use_callback && changed) { - if (mpr->type->select_refresh) { - mpr->type->select_refresh(mpr); + if (gz->type->select_refresh) { + gz->type->select_refresh(gz); } } @@ -443,25 +443,25 @@ bool wm_gizmo_select_set_ex( } /* Remove from selection array without running callbacks. */ -bool WM_gizmo_select_unlink(wmGizmoMap *mmap, wmGizmo *mpr) +bool WM_gizmo_select_unlink(wmGizmoMap *gzmap, wmGizmo *gz) { - return wm_gizmo_select_set_ex(mmap, mpr, false, true, false); + return wm_gizmo_select_set_ex(gzmap, gz, false, true, false); } -bool WM_gizmo_select_set(wmGizmoMap *mmap, wmGizmo *mpr, bool select) +bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select) { - return wm_gizmo_select_set_ex(mmap, mpr, select, true, true); + return wm_gizmo_select_set_ex(gzmap, gz, select, true, true); } -void WM_gizmo_highlight_set(wmGizmoMap *mmap, wmGizmo *mpr) +void WM_gizmo_highlight_set(wmGizmoMap *gzmap, wmGizmo *gz) { - wm_gizmomap_highlight_set(mmap, NULL, mpr, mpr ? mpr->highlight_part : 0); + wm_gizmomap_highlight_set(gzmap, NULL, gz, gz ? gz->highlight_part : 0); } -bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *mmap, wmGizmo *mpr) +bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz) { - if (WM_gizmo_select_set(mmap, mpr, true)) { - wm_gizmomap_highlight_set(mmap, C, mpr, mpr->highlight_part); + if (WM_gizmo_select_set(gzmap, gz, true)) { + wm_gizmomap_highlight_set(gzmap, C, gz, gz->highlight_part); return true; } else { @@ -475,13 +475,13 @@ bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *mmap, wmGizmo *mpr) * We could do this when linking them, but this complicates things since the window update code needs to run first. */ void WM_gizmo_modal_set_from_setup( - struct wmGizmoMap *mmap, struct bContext *C, - struct wmGizmo *mpr, int part_index, const wmEvent *event) + struct wmGizmoMap *gzmap, struct bContext *C, + struct wmGizmo *gz, int part_index, const wmEvent *event) { - mpr->highlight_part = part_index; - WM_gizmo_highlight_set(mmap, mpr); + gz->highlight_part = part_index; + WM_gizmo_highlight_set(gzmap, gz); if (false) { - wm_gizmomap_modal_set(mmap, C, mpr, event, true); + wm_gizmomap_modal_set(gzmap, C, gz, event, true); } else { /* WEAK: but it works. */ @@ -489,23 +489,23 @@ void WM_gizmo_modal_set_from_setup( } } -void wm_gizmo_calculate_scale(wmGizmo *mpr, const bContext *C) +void wm_gizmo_calculate_scale(wmGizmo *gz, const bContext *C) { const RegionView3D *rv3d = CTX_wm_region_view3d(C); float scale = UI_DPI_FAC; - if ((mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_SCALE) == 0) { + if ((gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_SCALE) == 0) { scale *= U.gizmo_size; if (rv3d) { /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */ float matrix_world[4][4]; - if (mpr->type->matrix_basis_get) { + if (gz->type->matrix_basis_get) { float matrix_basis[4][4]; - mpr->type->matrix_basis_get(mpr, matrix_basis); - mul_m4_m4m4(matrix_world, mpr->matrix_space, matrix_basis); + gz->type->matrix_basis_get(gz, matrix_basis); + mul_m4_m4m4(matrix_world, gz->matrix_space, matrix_basis); } else { - mul_m4_m4m4(matrix_world, mpr->matrix_space, mpr->matrix_basis); + mul_m4_m4m4(matrix_world, gz->matrix_space, gz->matrix_basis); } /* Exclude matrix_offset from scale. */ @@ -516,45 +516,45 @@ void wm_gizmo_calculate_scale(wmGizmo *mpr, const bContext *C) } } - mpr->scale_final = mpr->scale_basis * scale; + gz->scale_final = gz->scale_basis * scale; } -static void gizmo_update_prop_data(wmGizmo *mpr) +static void gizmo_update_prop_data(wmGizmo *gz) { /* gizmo property might have been changed, so update gizmo */ - if (mpr->type->property_update) { - wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - mpr->type->property_update(mpr, mpr_prop); + if (gz->type->property_update) { + wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz); + for (int i = 0; i < gz->type->target_property_defs_len; i++) { + wmGizmoProperty *gz_prop = &gz_prop_array[i]; + if (WM_gizmo_target_property_is_valid(gz_prop)) { + gz->type->property_update(gz, gz_prop); } } } } -void wm_gizmo_update(wmGizmo *mpr, const bContext *C, const bool refresh_map) +void wm_gizmo_update(wmGizmo *gz, const bContext *C, const bool refresh_map) { if (refresh_map) { - gizmo_update_prop_data(mpr); + gizmo_update_prop_data(gz); } - wm_gizmo_calculate_scale(mpr, C); + wm_gizmo_calculate_scale(gz, C); } -int wm_gizmo_is_visible(wmGizmo *mpr) +int wm_gizmo_is_visible(wmGizmo *gz) { - if (mpr->flag & WM_GIZMO_HIDDEN) { + if (gz->flag & WM_GIZMO_HIDDEN) { return 0; } - if ((mpr->state & WM_GIZMO_STATE_MODAL) && - !(mpr->flag & (WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_VALUE))) + if ((gz->state & WM_GIZMO_STATE_MODAL) && + !(gz->flag & (WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_VALUE))) { /* don't draw while modal (dragging) */ return 0; } - if ((mpr->flag & WM_GIZMO_DRAW_HOVER) && - !(mpr->state & WM_GIZMO_STATE_HIGHLIGHT) && - !(mpr->state & WM_GIZMO_STATE_SELECT)) /* still draw selected gizmos */ + if ((gz->flag & WM_GIZMO_DRAW_HOVER) && + !(gz->state & WM_GIZMO_STATE_HIGHLIGHT) && + !(gz->state & WM_GIZMO_STATE_SELECT)) /* still draw selected gizmos */ { /* update but don't draw */ return WM_GIZMO_IS_VISIBLE_UPDATE; @@ -564,28 +564,28 @@ int wm_gizmo_is_visible(wmGizmo *mpr) } void WM_gizmo_calc_matrix_final_params( - const wmGizmo *mpr, + const wmGizmo *gz, const struct WM_GizmoMatrixParams *params, float r_mat[4][4]) { - const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : mpr->matrix_space; - const float (* const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis : mpr->matrix_basis; - const float (* const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset : mpr->matrix_offset; - const float *scale_final = params->scale_final ? params->scale_final : &mpr->scale_final; + const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : gz->matrix_space; + const float (* const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis : gz->matrix_basis; + const float (* const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset : gz->matrix_offset; + const float *scale_final = params->scale_final ? params->scale_final : &gz->scale_final; float final_matrix[4][4]; - if (params->matrix_basis == NULL && mpr->type->matrix_basis_get) { - mpr->type->matrix_basis_get(mpr, final_matrix); + if (params->matrix_basis == NULL && gz->type->matrix_basis_get) { + gz->type->matrix_basis_get(gz, final_matrix); } else { copy_m4_m4(final_matrix, matrix_basis); } - if (mpr->flag & WM_GIZMO_DRAW_NO_SCALE) { + if (gz->flag & WM_GIZMO_DRAW_NO_SCALE) { mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); } else { - if (mpr->flag & WM_GIZMO_DRAW_OFFSET_SCALE) { + if (gz->flag & WM_GIZMO_DRAW_OFFSET_SCALE) { mul_mat3_m4_fl(final_matrix, *scale_final); mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); } @@ -598,13 +598,13 @@ void WM_gizmo_calc_matrix_final_params( mul_m4_m4m4(r_mat, matrix_space, final_matrix); } -void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *mpr, float r_mat[4][4]) +void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4]) { float mat_identity[4][4]; unit_m4(mat_identity); WM_gizmo_calc_matrix_final_params( - mpr, + gz, &((struct WM_GizmoMatrixParams) { .matrix_space = NULL, .matrix_basis = NULL, @@ -614,10 +614,10 @@ void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *mpr, float r_mat[4][4]) ); } -void WM_gizmo_calc_matrix_final(const wmGizmo *mpr, float r_mat[4][4]) +void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4]) { WM_gizmo_calc_matrix_final_params( - mpr, + gz, &((struct WM_GizmoMatrixParams) { .matrix_space = NULL, .matrix_basis = NULL, @@ -634,24 +634,24 @@ void WM_gizmo_calc_matrix_final(const wmGizmo *mpr, float r_mat[4][4]) * \{ */ -void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *wt) +void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *gzt) { - RNA_pointer_create(NULL, wt->srna, NULL, ptr); + RNA_pointer_create(NULL, gzt->srna, NULL, ptr); } -void WM_gizmo_properties_create(PointerRNA *ptr, const char *wtstring) +void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring) { - const wmGizmoType *wt = WM_gizmotype_find(wtstring, false); + const wmGizmoType *gzt = WM_gizmotype_find(gtstring, false); - if (wt) - WM_gizmo_properties_create_ptr(ptr, (wmGizmoType *)wt); + if (gzt) + WM_gizmo_properties_create_ptr(ptr, (wmGizmoType *)gzt); else RNA_pointer_create(NULL, &RNA_GizmoProperties, NULL, ptr); } /* similar to the function above except its uses ID properties * used for keymaps and macros */ -void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *wtstring) +void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring) { if (*properties == NULL) { IDPropertyTemplate val = {0}; @@ -660,7 +660,7 @@ void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const if (*ptr == NULL) { *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"); - WM_gizmo_properties_create(*ptr, wtstring); + WM_gizmo_properties_create(*ptr, gtstring); } (*ptr)->data = *properties; @@ -733,19 +733,19 @@ bool WM_gizmo_properties_default(PointerRNA *ptr, const bool do_update) } /* remove all props without PROP_SKIP_SAVE */ -void WM_gizmo_properties_reset(wmGizmo *mpr) +void WM_gizmo_properties_reset(wmGizmo *gz) { - if (mpr->ptr->data) { + if (gz->ptr->data) { PropertyRNA *iterprop; - iterprop = RNA_struct_iterator_property(mpr->type->srna); + iterprop = RNA_struct_iterator_property(gz->type->srna); - RNA_PROP_BEGIN (mpr->ptr, itemptr, iterprop) + RNA_PROP_BEGIN (gz->ptr, itemptr, iterprop) { PropertyRNA *prop = itemptr.data; if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) { const char *identifier = RNA_property_identifier(prop); - RNA_struct_idprops_unset(mpr->ptr, identifier); + RNA_struct_idprops_unset(gz->ptr, identifier); } } RNA_PROP_END; diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index f30744859aa..9cc096e1cdd 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -74,87 +74,87 @@ * \{ */ /** - * Create a new gizmo-group from \a wgt. + * Create a new gizmo-group from \a gzgt. */ wmGizmoGroup *wm_gizmogroup_new_from_type( - wmGizmoMap *mmap, wmGizmoGroupType *wgt) + wmGizmoMap *gzmap, wmGizmoGroupType *gzgt) { - wmGizmoGroup *mgroup = MEM_callocN(sizeof(*mgroup), "gizmo-group"); - mgroup->type = wgt; + wmGizmoGroup *gzgroup = MEM_callocN(sizeof(*gzgroup), "gizmo-group"); + gzgroup->type = gzgt; /* keep back-link */ - mgroup->parent_mmap = mmap; + gzgroup->parent_gzmap = gzmap; - BLI_addtail(&mmap->groups, mgroup); + BLI_addtail(&gzmap->groups, gzgroup); - return mgroup; + return gzgroup; } -void wm_gizmogroup_free(bContext *C, wmGizmoGroup *mgroup) +void wm_gizmogroup_free(bContext *C, wmGizmoGroup *gzgroup) { - wmGizmoMap *mmap = mgroup->parent_mmap; + wmGizmoMap *gzmap = gzgroup->parent_gzmap; - /* Similar to WM_gizmo_unlink, but only to keep mmap state correct, + /* Similar to WM_gizmo_unlink, but only to keep gzmap state correct, * we don't want to run callbacks. */ - if (mmap->mmap_context.highlight && mmap->mmap_context.highlight->parent_mgroup == mgroup) { - wm_gizmomap_highlight_set(mmap, C, NULL, 0); + if (gzmap->gzmap_context.highlight && gzmap->gzmap_context.highlight->parent_gzgroup == gzgroup) { + wm_gizmomap_highlight_set(gzmap, C, NULL, 0); } - if (mmap->mmap_context.modal && mmap->mmap_context.modal->parent_mgroup == mgroup) { - wm_gizmomap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false); + if (gzmap->gzmap_context.modal && gzmap->gzmap_context.modal->parent_gzgroup == gzgroup) { + wm_gizmomap_modal_set(gzmap, C, gzmap->gzmap_context.modal, NULL, false); } - for (wmGizmo *mpr = mgroup->gizmos.first, *mpr_next; mpr; mpr = mpr_next) { - mpr_next = mpr->next; - if (mmap->mmap_context.select.len) { - WM_gizmo_select_unlink(mmap, mpr); + for (wmGizmo *gz = gzgroup->gizmos.first, *gz_next; gz; gz = gz_next) { + gz_next = gz->next; + if (gzmap->gzmap_context.select.len) { + WM_gizmo_select_unlink(gzmap, gz); } - WM_gizmo_free(mpr); + WM_gizmo_free(gz); } - BLI_listbase_clear(&mgroup->gizmos); + BLI_listbase_clear(&gzgroup->gizmos); #ifdef WITH_PYTHON - if (mgroup->py_instance) { + if (gzgroup->py_instance) { /* do this first in case there are any __del__ functions or * similar that use properties */ - BPY_DECREF_RNA_INVALIDATE(mgroup->py_instance); + BPY_DECREF_RNA_INVALIDATE(gzgroup->py_instance); } #endif - if (mgroup->reports && (mgroup->reports->flag & RPT_FREE)) { - BKE_reports_clear(mgroup->reports); - MEM_freeN(mgroup->reports); + if (gzgroup->reports && (gzgroup->reports->flag & RPT_FREE)) { + BKE_reports_clear(gzgroup->reports); + MEM_freeN(gzgroup->reports); } - if (mgroup->customdata_free) { - mgroup->customdata_free(mgroup->customdata); + if (gzgroup->customdata_free) { + gzgroup->customdata_free(gzgroup->customdata); } else { - MEM_SAFE_FREE(mgroup->customdata); + MEM_SAFE_FREE(gzgroup->customdata); } - BLI_remlink(&mmap->groups, mgroup); + BLI_remlink(&gzmap->groups, gzgroup); - MEM_freeN(mgroup); + MEM_freeN(gzgroup); } /** - * Add \a gizmo to \a mgroup and make sure its name is unique within the group. + * Add \a gizmo to \a gzgroup and make sure its name is unique within the group. */ -void wm_gizmogroup_gizmo_register(wmGizmoGroup *mgroup, wmGizmo *mpr) +void wm_gizmogroup_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz) { - BLI_assert(BLI_findindex(&mgroup->gizmos, mpr) == -1); - BLI_addtail(&mgroup->gizmos, mpr); - mpr->parent_mgroup = mgroup; + BLI_assert(BLI_findindex(&gzgroup->gizmos, gz) == -1); + BLI_addtail(&gzgroup->gizmos, gz); + gz->parent_gzgroup = gzgroup; } wmGizmo *wm_gizmogroup_find_intersected_gizmo( - const wmGizmoGroup *mgroup, bContext *C, const wmEvent *event, + const wmGizmoGroup *gzgroup, bContext *C, const wmEvent *event, int *r_part) { - for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { - if (mpr->type->test_select && (mpr->flag & WM_GIZMO_HIDDEN) == 0) { - if ((*r_part = mpr->type->test_select(C, mpr, event)) != -1) { - return mpr; + for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + if (gz->type->test_select && (gz->flag & WM_GIZMO_HIDDEN) == 0) { + if ((*r_part = gz->type->test_select(C, gz, event)) != -1) { + return gz; } } } @@ -163,78 +163,78 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo( } /** - * Adds all gizmos of \a mgroup that can be selected to the head of \a listbase. Added items need freeing! + * Adds all gizmos of \a gzgroup that can be selected to the head of \a listbase. Added items need freeing! */ -void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *mgroup, ListBase *listbase) +void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *gzgroup, ListBase *listbase) { - for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { - if ((mpr->flag & WM_GIZMO_HIDDEN) == 0) { - if (((mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) && mpr->type->draw_select) || - ((mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && mpr->type->test_select)) + for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + if ((gz->flag & WM_GIZMO_HIDDEN) == 0) { + if (((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) && gz->type->draw_select) || + ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && gz->type->test_select)) { - BLI_addhead(listbase, BLI_genericNodeN(mpr)); + BLI_addhead(listbase, BLI_genericNodeN(gz)); } } } } -void wm_gizmogroup_ensure_initialized(wmGizmoGroup *mgroup, const bContext *C) +void wm_gizmogroup_ensure_initialized(wmGizmoGroup *gzgroup, const bContext *C) { /* prepare for first draw */ - if (UNLIKELY((mgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0)) { - mgroup->type->setup(C, mgroup); + if (UNLIKELY((gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0)) { + gzgroup->type->setup(C, gzgroup); /* Not ideal, initialize keymap here, needed for RNA runtime generated gizmos. */ - wmGizmoGroupType *wgt = mgroup->type; - if (wgt->keymap == NULL) { + wmGizmoGroupType *gzgt = gzgroup->type; + if (gzgt->keymap == NULL) { wmWindowManager *wm = CTX_wm_manager(C); - wm_gizmogrouptype_setup_keymap(wgt, wm->defaultconf); - BLI_assert(wgt->keymap != NULL); + wm_gizmogrouptype_setup_keymap(gzgt, wm->defaultconf); + BLI_assert(gzgt->keymap != NULL); } - mgroup->init_flag |= WM_GIZMOGROUP_INIT_SETUP; + gzgroup->init_flag |= WM_GIZMOGROUP_INIT_SETUP; } /* refresh may be called multiple times, this just ensures its called at least once before we draw. */ - if (UNLIKELY((mgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0)) { - if (mgroup->type->refresh) { - mgroup->type->refresh(C, mgroup); + if (UNLIKELY((gzgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0)) { + if (gzgroup->type->refresh) { + gzgroup->type->refresh(C, gzgroup); } - mgroup->init_flag |= WM_GIZMOGROUP_INIT_REFRESH; + gzgroup->init_flag |= WM_GIZMOGROUP_INIT_REFRESH; } } -bool WM_gizmo_group_type_poll(const bContext *C, const struct wmGizmoGroupType *wgt) +bool WM_gizmo_group_type_poll(const bContext *C, const struct wmGizmoGroupType *gzgt) { /* If we're tagged, only use compatible. */ - if (wgt->owner_id[0] != '\0') { + if (gzgt->owner_id[0] != '\0') { const WorkSpace *workspace = CTX_wm_workspace(C); - if (BKE_workspace_owner_id_check(workspace, wgt->owner_id) == false) { + if (BKE_workspace_owner_id_check(workspace, gzgt->owner_id) == false) { return false; } } /* Check for poll function, if gizmo-group belongs to an operator, also check if the operator is running. */ - return (!wgt->poll || wgt->poll(C, (wmGizmoGroupType *)wgt)); + return (!gzgt->poll || gzgt->poll(C, (wmGizmoGroupType *)gzgt)); } bool wm_gizmogroup_is_visible_in_drawstep( - const wmGizmoGroup *mgroup, const eWM_GizmoFlagMapDrawStep drawstep) + const wmGizmoGroup *gzgroup, const eWM_GizmoFlagMapDrawStep drawstep) { switch (drawstep) { case WM_GIZMOMAP_DRAWSTEP_2D: - return (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; + return (gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; case WM_GIZMOMAP_DRAWSTEP_3D: - return (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D); + return (gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D); default: BLI_assert(0); return false; } } -bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *mgroup) +bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *gzgroup) { - if (mgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT) { - for (const wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { - if (mpr->state & WM_GIZMO_STATE_SELECT) { + if (gzgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT) { + for (const wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + if (gz->state & WM_GIZMO_STATE_SELECT) { return true; } } @@ -253,9 +253,9 @@ bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *mgroup) static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { ARegion *ar = CTX_wm_region(C); - wmGizmoMap *mmap = ar->gizmo_map; - wmGizmoMapSelectState *msel = &mmap->mmap_context.select; - wmGizmo *highlight = mmap->mmap_context.highlight; + wmGizmoMap *gzmap = ar->gizmo_map; + wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select; + wmGizmo *highlight = gzmap->gzmap_context.highlight; bool extend = RNA_boolean_get(op->ptr, "extend"); bool deselect = RNA_boolean_get(op->ptr, "deselect"); @@ -263,7 +263,7 @@ static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE /* deselect all first */ if (extend == false && deselect == false && toggle == false) { - wm_gizmomap_deselect_all(mmap); + wm_gizmomap_deselect_all(gzmap); BLI_assert(msel->items == NULL && msel->len == 0); UNUSED_VARS_NDEBUG(msel); } @@ -278,11 +278,11 @@ static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE } if (deselect) { - if (is_selected && WM_gizmo_select_set(mmap, highlight, false)) { + if (is_selected && WM_gizmo_select_set(gzmap, highlight, false)) { redraw = true; } } - else if (wm_gizmo_select_and_highlight(C, mmap, highlight)) { + else if (wm_gizmo_select_and_highlight(C, gzmap, highlight)) { redraw = true; } @@ -316,9 +316,9 @@ void GIZMOGROUP_OT_gizmo_select(wmOperatorType *ot) } typedef struct GizmoTweakData { - wmGizmoMap *mmap; - wmGizmoGroup *mgroup; - wmGizmo *mpr_modal; + wmGizmoMap *gzmap; + wmGizmoGroup *gzgroup; + wmGizmo *gz_modal; int init_event; /* initial event type */ int flag; /* tweak flags */ @@ -342,18 +342,18 @@ typedef struct GizmoTweakData { } GizmoTweakData; static bool gizmo_tweak_start( - bContext *C, wmGizmoMap *mmap, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmoMap *gzmap, wmGizmo *gz, const wmEvent *event) { /* activate highlighted gizmo */ - wm_gizmomap_modal_set(mmap, C, mpr, event, true); + wm_gizmomap_modal_set(gzmap, C, gz, event, true); - return (mpr->state & WM_GIZMO_STATE_MODAL); + return (gz->state & WM_GIZMO_STATE_MODAL); } static bool gizmo_tweak_start_and_finish( - bContext *C, wmGizmoMap *mmap, wmGizmo *mpr, const wmEvent *event, bool *r_is_modal) + bContext *C, wmGizmoMap *gzmap, wmGizmo *gz, const wmEvent *event, bool *r_is_modal) { - wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, gz->highlight_part); if (r_is_modal) { *r_is_modal = false; } @@ -377,7 +377,7 @@ static bool gizmo_tweak_start_and_finish( * conflicting with modal operator attached to gizmo */ if (mpop->type->modal) { /* activate highlighted gizmo */ - wm_gizmomap_modal_set(mmap, C, mpr, event, true); + wm_gizmomap_modal_set(gzmap, C, gz, event, true); if (r_is_modal) { *r_is_modal = true; } @@ -396,15 +396,15 @@ static bool gizmo_tweak_start_and_finish( static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal) { GizmoTweakData *mtweak = op->customdata; - if (mtweak->mpr_modal->type->exit) { - mtweak->mpr_modal->type->exit(C, mtweak->mpr_modal, cancel); + if (mtweak->gz_modal->type->exit) { + mtweak->gz_modal->type->exit(C, mtweak->gz_modal, cancel); } if (clear_modal) { /* The gizmo may have been removed. */ - if ((BLI_findindex(&mtweak->mmap->groups, mtweak->mgroup) != -1) && - (BLI_findindex(&mtweak->mgroup->gizmos, mtweak->mpr_modal) != -1)) + if ((BLI_findindex(&mtweak->gzmap->groups, mtweak->gzgroup) != -1) && + (BLI_findindex(&mtweak->gzgroup->gizmos, mtweak->gz_modal) != -1)) { - wm_gizmomap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false); + wm_gizmomap_modal_set(mtweak->gzmap, C, mtweak->gz_modal, NULL, false); } } MEM_freeN(mtweak); @@ -413,22 +413,22 @@ static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, b static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) { GizmoTweakData *mtweak = op->customdata; - wmGizmo *mpr = mtweak->mpr_modal; + wmGizmo *gz = mtweak->gz_modal; int retval = OPERATOR_PASS_THROUGH; bool clear_modal = true; - if (mpr == NULL) { + if (gz == NULL) { BLI_assert(0); return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } #ifdef USE_DRAG_DETECT - wmGizmoMap *mmap = mtweak->mmap; + wmGizmoMap *gzmap = mtweak->gzmap; if (mtweak->drag_state == DRAG_DETECT) { if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { - if (len_manhattan_v2v2_int(&event->x, mmap->mmap_context.event_xy) > 2) { + if (len_manhattan_v2v2_int(&event->x, gzmap->gzmap_context.event_xy) > 2) { mtweak->drag_state = DRAG_IDLE; - mpr->highlight_part = mpr->drag_part; + gz->highlight_part = gz->drag_part; } } else if (event->type == mtweak->init_event && event->val == KM_RELEASE) { @@ -439,20 +439,20 @@ static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) if (mtweak->drag_state != DRAG_DETECT) { /* Follow logic in 'gizmo_tweak_invoke' */ bool is_modal = false; - if (gizmo_tweak_start_and_finish(C, mmap, mpr, event, &is_modal)) { + if (gizmo_tweak_start_and_finish(C, gzmap, gz, event, &is_modal)) { if (is_modal) { clear_modal = false; } } else { - if (!gizmo_tweak_start(C, mmap, mpr, event)) { + if (!gizmo_tweak_start(C, gzmap, gz, event)) { retval = OPERATOR_FINISHED; } } } } if (mtweak->drag_state == DRAG_IDLE) { - if (mmap->mmap_context.modal != NULL) { + if (gzmap->gzmap_context.modal != NULL) { return OPERATOR_PASS_THROUGH; } else { @@ -498,9 +498,9 @@ static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* handle gizmo */ - wmGizmoFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; + wmGizmoFnModal modal_fn = gz->custom_modal ? gz->custom_modal : gz->type->modal; if (modal_fn) { - int modal_retval = modal_fn(C, mpr, event, mtweak->flag); + int modal_retval = modal_fn(C, gz, event, mtweak->flag); if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) { gizmo_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true); @@ -520,13 +520,13 @@ static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); - wmGizmoMap *mmap = ar->gizmo_map; - wmGizmo *mpr = mmap->mmap_context.highlight; + wmGizmoMap *gzmap = ar->gizmo_map; + wmGizmo *gz = gzmap->gzmap_context.highlight; /* Needed for single click actions which don't enter modal state. */ WM_tooltip_clear(C, CTX_wm_window(C)); - if (!mpr) { + if (!gz) { /* wm_handlers_do_intern shouldn't let this happen */ BLI_assert(0); return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); @@ -535,11 +535,11 @@ static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) bool use_drag_fallback = false; #ifdef USE_DRAG_DETECT - use_drag_fallback = !ELEM(mpr->drag_part, -1, mpr->highlight_part); + use_drag_fallback = !ELEM(gz->drag_part, -1, gz->highlight_part); #endif if (use_drag_fallback == false) { - if (gizmo_tweak_start_and_finish(C, mmap, mpr, event, NULL)) { + if (gizmo_tweak_start_and_finish(C, gzmap, gz, event, NULL)) { return OPERATOR_FINISHED; } } @@ -547,7 +547,7 @@ static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) bool use_drag_detect = false; #ifdef USE_DRAG_DETECT if (use_drag_fallback) { - wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, gz->highlight_part); if (mpop && mpop->type) { if (mpop->type->modal == NULL) { use_drag_detect = true; @@ -557,7 +557,7 @@ static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) #endif if (use_drag_detect == false) { - if (!gizmo_tweak_start(C, mmap, mpr, event)) { + if (!gizmo_tweak_start(C, gzmap, gz, event)) { /* failed to start */ return OPERATOR_PASS_THROUGH; } @@ -566,9 +566,9 @@ static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) GizmoTweakData *mtweak = MEM_mallocN(sizeof(GizmoTweakData), __func__); mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type); - mtweak->mpr_modal = mmap->mmap_context.highlight; - mtweak->mgroup = mtweak->mpr_modal->parent_mgroup; - mtweak->mmap = mmap; + mtweak->gz_modal = gzmap->gzmap_context.highlight; + mtweak->gzgroup = mtweak->gz_modal->parent_gzgroup; + mtweak->gzmap = gzmap; mtweak->flag = 0; #ifdef USE_DRAG_DETECT @@ -603,7 +603,7 @@ void GIZMOGROUP_OT_gizmo_tweak(wmOperatorType *ot) /** \} */ -static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname) +static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *gzgroupname) { wmKeyMap *keymap; char name[KMAP_MAX_NAME]; @@ -619,7 +619,7 @@ static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char }; - BLI_snprintf(name, sizeof(name), "%s Tweak Modal Map", mgroupname); + BLI_snprintf(name, sizeof(name), "%s Tweak Modal Map", gzgroupname); keymap = WM_modalkeymap_get(keyconf, name); /* this function is called for each spacetype, only needs to add map once */ @@ -655,13 +655,13 @@ static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char * Common default keymap for gizmo groups */ wmKeyMap *WM_gizmogroup_keymap_common( - const wmGizmoGroupType *wgt, wmKeyConfig *config) + const wmGizmoGroupType *gzgt, wmKeyConfig *config) { /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */ - wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); + wmKeyMap *km = WM_keymap_find(config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid); WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0); - gizmogroup_tweak_modal_keymap(config, wgt->name); + gizmogroup_tweak_modal_keymap(config, gzgt->name); return km; } @@ -670,14 +670,14 @@ wmKeyMap *WM_gizmogroup_keymap_common( * Variation of #WM_gizmogroup_keymap_common but with keymap items for selection */ wmKeyMap *WM_gizmogroup_keymap_common_select( - const wmGizmoGroupType *wgt, wmKeyConfig *config) + const wmGizmoGroupType *gzgt, wmKeyConfig *config) { /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */ - wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); + wmKeyMap *km = WM_keymap_find(config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid); WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", EVT_TWEAK_S, KM_ANY, 0, 0); - gizmogroup_tweak_modal_keymap(config, wgt->name); + gizmogroup_tweak_modal_keymap(config, gzgt->name); wmKeyMapItem *kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); @@ -699,32 +699,32 @@ wmKeyMap *WM_gizmogroup_keymap_common_select( * \{ */ struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr( - struct wmGizmoMapType *mmap_type, - const wmGizmoGroupType *wgt) + struct wmGizmoMapType *gzmap_type, + const wmGizmoGroupType *gzgt) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; - wgt_ref; - wgt_ref = wgt_ref->next) + for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; + gzgt_ref; + gzgt_ref = gzgt_ref->next) { - if (wgt_ref->type == wgt) { - return wgt_ref; + if (gzgt_ref->type == gzgt) { + return gzgt_ref; } } return NULL; } struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find( - struct wmGizmoMapType *mmap_type, + struct wmGizmoMapType *gzmap_type, const char *idname) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; - wgt_ref; - wgt_ref = wgt_ref->next) + for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; + gzgt_ref; + gzgt_ref = gzgt_ref->next) { - if (STREQ(idname, wgt_ref->type->idname)) { - return wgt_ref; + if (STREQ(idname, gzgt_ref->type->idname)) { + return gzgt_ref; } } return NULL; @@ -734,33 +734,33 @@ struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find( * Use this for registering gizmos on startup. For runtime, use #WM_gizmomaptype_group_link_runtime. */ wmGizmoGroupTypeRef *WM_gizmomaptype_group_link( - wmGizmoMapType *mmap_type, const char *idname) + wmGizmoMapType *gzmap_type, const char *idname) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); - BLI_assert(wgt != NULL); - return WM_gizmomaptype_group_link_ptr(mmap_type, wgt); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + BLI_assert(gzgt != NULL); + return WM_gizmomaptype_group_link_ptr(gzmap_type, gzgt); } wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr( - wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) + wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt) { - wmGizmoGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmGizmoGroupTypeRef), "gizmo-group-ref"); - wgt_ref->type = wgt; - BLI_addtail(&mmap_type->grouptype_refs, wgt_ref); - return wgt_ref; + wmGizmoGroupTypeRef *gzgt_ref = MEM_callocN(sizeof(wmGizmoGroupTypeRef), "gizmo-group-ref"); + gzgt_ref->type = gzgt; + BLI_addtail(&gzmap_type->grouptype_refs, gzgt_ref); + return gzgt_ref; } void WM_gizmomaptype_group_init_runtime_keymap( const Main *bmain, - wmGizmoGroupType *wgt) + wmGizmoGroupType *gzgt) { /* init keymap - on startup there's an extra call to init keymaps for 'permanent' gizmo-groups */ - wm_gizmogrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf); + wm_gizmogrouptype_setup_keymap(gzgt, ((wmWindowManager *)bmain->wm.first)->defaultconf); } void WM_gizmomaptype_group_init_runtime( - const Main *bmain, wmGizmoMapType *mmap_type, - wmGizmoGroupType *wgt) + const Main *bmain, wmGizmoMapType *gzmap_type, + wmGizmoGroupType *gzgt) { /* now create a gizmo for all existing areas */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -768,12 +768,12 @@ void WM_gizmomaptype_group_init_runtime( for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmGizmoMap *mmap = ar->gizmo_map; - if (mmap && mmap->type == mmap_type) { - wm_gizmogroup_new_from_type(mmap, wgt); + wmGizmoMap *gzmap = ar->gizmo_map; + if (gzmap && gzmap->type == gzmap_type) { + wm_gizmogroup_new_from_type(gzmap, gzgt); /* just add here, drawing will occur on next update */ - wm_gizmomap_highlight_set(mmap, NULL, NULL, 0); + wm_gizmomap_highlight_set(gzmap, NULL, NULL, 0); ED_region_tag_redraw(ar); } } @@ -786,14 +786,14 @@ void WM_gizmomaptype_group_init_runtime( /** * Unlike #WM_gizmomaptype_group_unlink this doesn't maintain correct state, simply free. */ -void WM_gizmomaptype_group_free(wmGizmoGroupTypeRef *wgt_ref) +void WM_gizmomaptype_group_free(wmGizmoGroupTypeRef *gzgt_ref) { - MEM_freeN(wgt_ref); + MEM_freeN(gzgt_ref); } void WM_gizmomaptype_group_unlink( - bContext *C, Main *bmain, wmGizmoMapType *mmap_type, - const wmGizmoGroupType *wgt) + bContext *C, Main *bmain, wmGizmoMapType *gzmap_type, + const wmGizmoGroupType *gzgt) { /* Free instances. */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -801,14 +801,14 @@ void WM_gizmomaptype_group_unlink( for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmGizmoMap *mmap = ar->gizmo_map; - if (mmap && mmap->type == mmap_type) { - wmGizmoGroup *mgroup, *mgroup_next; - for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup_next) { - mgroup_next = mgroup->next; - if (mgroup->type == wgt) { - BLI_assert(mgroup->parent_mmap == mmap); - wm_gizmogroup_free(C, mgroup); + wmGizmoMap *gzmap = ar->gizmo_map; + if (gzmap && gzmap->type == gzmap_type) { + wmGizmoGroup *gzgroup, *gzgroup_next; + for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup_next) { + gzgroup_next = gzgroup->next; + if (gzgroup->type == gzgt) { + BLI_assert(gzgroup->parent_gzmap == gzmap); + wm_gizmogroup_free(C, gzgroup); ED_region_tag_redraw(ar); } } @@ -819,27 +819,27 @@ void WM_gizmomaptype_group_unlink( } /* Free types. */ - wmGizmoGroupTypeRef *wgt_ref = WM_gizmomaptype_group_find_ptr(mmap_type, wgt); - if (wgt_ref) { - BLI_remlink(&mmap_type->grouptype_refs, wgt_ref); - WM_gizmomaptype_group_free(wgt_ref); + wmGizmoGroupTypeRef *gzgt_ref = WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt); + if (gzgt_ref) { + BLI_remlink(&gzmap_type->grouptype_refs, gzgt_ref); + WM_gizmomaptype_group_free(gzgt_ref); } /* Note, we may want to keep this keymap for editing */ - WM_keymap_remove(wgt->keyconf, wgt->keymap); + WM_keymap_remove(gzgt->keyconf, gzgt->keymap); - BLI_assert(WM_gizmomaptype_group_find_ptr(mmap_type, wgt) == NULL); + BLI_assert(WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt) == NULL); } void wm_gizmogrouptype_setup_keymap( - wmGizmoGroupType *wgt, wmKeyConfig *keyconf) + wmGizmoGroupType *gzgt, wmKeyConfig *keyconf) { /* Use flag since setup_keymap may return NULL, * in that case we better not keep calling it. */ - if (wgt->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { - wgt->keymap = wgt->setup_keymap(wgt, keyconf); - wgt->keyconf = keyconf; - wgt->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; + if (gzgt->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { + gzgt->keymap = gzgt->setup_keymap(gzgt, keyconf); + gzgt->keyconf = keyconf; + gzgt->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; } } @@ -861,89 +861,89 @@ void wm_gizmogrouptype_setup_keymap( * \{ */ void WM_gizmo_group_type_add_ptr_ex( - wmGizmoGroupType *wgt, - wmGizmoMapType *mmap_type) + wmGizmoGroupType *gzgt, + wmGizmoMapType *gzmap_type) { - WM_gizmomaptype_group_link_ptr(mmap_type, wgt); + WM_gizmomaptype_group_link_ptr(gzmap_type, gzgt); - WM_gizmoconfig_update_tag_init(mmap_type, wgt); + WM_gizmoconfig_update_tag_init(gzmap_type, gzgt); } void WM_gizmo_group_type_add_ptr( - wmGizmoGroupType *wgt) + wmGizmoGroupType *gzgt) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); - WM_gizmo_group_type_add_ptr_ex(wgt, mmap_type); + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); + WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type); } void WM_gizmo_group_type_add(const char *idname) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); - BLI_assert(wgt != NULL); - WM_gizmo_group_type_add_ptr(wgt); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + BLI_assert(gzgt != NULL); + WM_gizmo_group_type_add_ptr(gzgt); } void WM_gizmo_group_type_ensure_ptr_ex( - wmGizmoGroupType *wgt, - wmGizmoMapType *mmap_type) + wmGizmoGroupType *gzgt, + wmGizmoMapType *gzmap_type) { - wmGizmoGroupTypeRef *wgt_ref = WM_gizmomaptype_group_find_ptr(mmap_type, wgt); - if (wgt_ref == NULL) { - WM_gizmo_group_type_add_ptr_ex(wgt, mmap_type); + wmGizmoGroupTypeRef *gzgt_ref = WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt); + if (gzgt_ref == NULL) { + WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type); } } void WM_gizmo_group_type_ensure_ptr( - wmGizmoGroupType *wgt) + wmGizmoGroupType *gzgt) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); - WM_gizmo_group_type_ensure_ptr_ex(wgt, mmap_type); + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); + WM_gizmo_group_type_ensure_ptr_ex(gzgt, gzmap_type); } void WM_gizmo_group_type_ensure(const char *idname) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); - BLI_assert(wgt != NULL); - WM_gizmo_group_type_ensure_ptr(wgt); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + BLI_assert(gzgt != NULL); + WM_gizmo_group_type_ensure_ptr(gzgt); } void WM_gizmo_group_type_remove_ptr_ex( - struct Main *bmain, wmGizmoGroupType *wgt, - wmGizmoMapType *mmap_type) + struct Main *bmain, wmGizmoGroupType *gzgt, + wmGizmoMapType *gzmap_type) { - WM_gizmomaptype_group_unlink(NULL, bmain, mmap_type, wgt); - WM_gizmogrouptype_free_ptr(wgt); + WM_gizmomaptype_group_unlink(NULL, bmain, gzmap_type, gzgt); + WM_gizmogrouptype_free_ptr(gzgt); } void WM_gizmo_group_type_remove_ptr( - struct Main *bmain, wmGizmoGroupType *wgt) + struct Main *bmain, wmGizmoGroupType *gzgt) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); - WM_gizmo_group_type_remove_ptr_ex(bmain, wgt, mmap_type); + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); + WM_gizmo_group_type_remove_ptr_ex(bmain, gzgt, gzmap_type); } void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); - BLI_assert(wgt != NULL); - WM_gizmo_group_type_remove_ptr(bmain, wgt); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + BLI_assert(gzgt != NULL); + WM_gizmo_group_type_remove_ptr(bmain, gzgt); } /* delayed versions */ void WM_gizmo_group_type_unlink_delayed_ptr_ex( - wmGizmoGroupType *wgt, - wmGizmoMapType *mmap_type) + wmGizmoGroupType *gzgt, + wmGizmoMapType *gzmap_type) { - WM_gizmoconfig_update_tag_remove(mmap_type, wgt); + WM_gizmoconfig_update_tag_remove(gzmap_type, gzgt); } void WM_gizmo_group_type_unlink_delayed_ptr( - wmGizmoGroupType *wgt) + wmGizmoGroupType *gzgt) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); - WM_gizmo_group_type_unlink_delayed_ptr_ex(wgt, mmap_type); + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); + WM_gizmo_group_type_unlink_delayed_ptr_ex(gzgt, gzmap_type); } void WM_gizmo_group_type_unlink_delayed(const char *idname) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); - BLI_assert(wgt != NULL); - WM_gizmo_group_type_unlink_delayed_ptr(wgt); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + BLI_assert(gzgt != NULL); + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); } /** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c index 44f5fac4cd4..a44005a7d28 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c @@ -54,11 +54,11 @@ static GHash *global_gizmogrouptype_hash = NULL; wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet) { if (idname[0]) { - wmGizmoGroupType *wgt; + wmGizmoGroupType *gzgt; - wgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname); - if (wgt) { - return wgt; + gzgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname); + if (gzgt) { + return gzgt; } if (!quiet) { @@ -82,46 +82,46 @@ void WM_gizmogrouptype_iter(GHashIterator *ghi) static wmGizmoGroupType *wm_gizmogrouptype_append__begin(void) { - wmGizmoGroupType *wgt = MEM_callocN(sizeof(wmGizmoGroupType), "gizmogrouptype"); + wmGizmoGroupType *gzgt = MEM_callocN(sizeof(wmGizmoGroupType), "gizmogrouptype"); - return wgt; + return gzgt; } -static void wm_gizmogrouptype_append__end(wmGizmoGroupType *wgt) +static void wm_gizmogrouptype_append__end(wmGizmoGroupType *gzgt) { - BLI_assert(wgt->name != NULL); - BLI_assert(wgt->idname != NULL); + BLI_assert(gzgt->name != NULL); + BLI_assert(gzgt->idname != NULL); - wgt->type_update_flag |= WM_GIZMOMAPTYPE_KEYMAP_INIT; + gzgt->type_update_flag |= WM_GIZMOMAPTYPE_KEYMAP_INIT; /* if not set, use default */ - if (wgt->setup_keymap == NULL) { - if (wgt->flag & WM_GIZMOGROUPTYPE_SELECT) { - wgt->setup_keymap = WM_gizmogroup_keymap_common_select; + if (gzgt->setup_keymap == NULL) { + if (gzgt->flag & WM_GIZMOGROUPTYPE_SELECT) { + gzgt->setup_keymap = WM_gizmogroup_keymap_common_select; } else { - wgt->setup_keymap = WM_gizmogroup_keymap_common; + gzgt->setup_keymap = WM_gizmogroup_keymap_common; } } - BLI_ghash_insert(global_gizmogrouptype_hash, (void *)wgt->idname, wgt); + BLI_ghash_insert(global_gizmogrouptype_hash, (void *)gzgt->idname, gzgt); } wmGizmoGroupType *WM_gizmogrouptype_append( void (*wtfunc)(struct wmGizmoGroupType *)) { - wmGizmoGroupType *wgt = wm_gizmogrouptype_append__begin(); - wtfunc(wgt); - wm_gizmogrouptype_append__end(wgt); - return wgt; + wmGizmoGroupType *gzgt = wm_gizmogrouptype_append__begin(); + wtfunc(gzgt); + wm_gizmogrouptype_append__end(gzgt); + return gzgt; } wmGizmoGroupType *WM_gizmogrouptype_append_ptr( void (*wtfunc)(struct wmGizmoGroupType *, void *), void *userdata) { - wmGizmoGroupType *wgt = wm_gizmogrouptype_append__begin(); - wtfunc(wgt, userdata); - wm_gizmogrouptype_append__end(wgt); - return wgt; + wmGizmoGroupType *gzgt = wm_gizmogrouptype_append__begin(); + wtfunc(gzgt, userdata); + wm_gizmogrouptype_append__end(gzgt); + return gzgt; } /** @@ -129,56 +129,56 @@ wmGizmoGroupType *WM_gizmogrouptype_append_ptr( * This is most common for C gizmos which are enabled by default. */ wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link( - wmGizmoMapType *mmap_type, + wmGizmoMapType *gzmap_type, void (*wtfunc)(struct wmGizmoGroupType *)) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_append(wtfunc); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_append(wtfunc); - wgt->mmap_params.spaceid = mmap_type->spaceid; - wgt->mmap_params.regionid = mmap_type->regionid; + gzgt->gzmap_params.spaceid = gzmap_type->spaceid; + gzgt->gzmap_params.regionid = gzmap_type->regionid; - return WM_gizmomaptype_group_link_ptr(mmap_type, wgt); + return WM_gizmomaptype_group_link_ptr(gzmap_type, gzgt); } /** * Free but don't remove from ghash. */ -static void gizmogrouptype_free(wmGizmoGroupType *wgt) +static void gizmogrouptype_free(wmGizmoGroupType *gzgt) { - if (wgt->ext.srna) { /* python gizmo group, allocs own string */ - MEM_freeN((void *)wgt->idname); + if (gzgt->ext.srna) { /* python gizmo group, allocs own string */ + MEM_freeN((void *)gzgt->idname); } - MEM_freeN(wgt); + MEM_freeN(gzgt); } -void WM_gizmogrouptype_free_ptr(wmGizmoGroupType *wgt) +void WM_gizmogrouptype_free_ptr(wmGizmoGroupType *gzgt) { - BLI_assert(wgt == WM_gizmogrouptype_find(wgt->idname, false)); + BLI_assert(gzgt == WM_gizmogrouptype_find(gzgt->idname, false)); - BLI_ghash_remove(global_gizmogrouptype_hash, wgt->idname, NULL, NULL); + BLI_ghash_remove(global_gizmogrouptype_hash, gzgt->idname, NULL, NULL); - gizmogrouptype_free(wgt); + gizmogrouptype_free(gzgt); /* XXX, TODO, update the world! */ } bool WM_gizmogrouptype_free(const char *idname) { - wmGizmoGroupType *wgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname); + wmGizmoGroupType *gzgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname); - if (wgt == NULL) { + if (gzgt == NULL) { return false; } - WM_gizmogrouptype_free_ptr(wgt); + WM_gizmogrouptype_free_ptr(gzgt); return true; } -static void wm_gizmogrouptype_ghash_free_cb(wmGizmoGroupType *wgt) +static void wm_gizmogrouptype_ghash_free_cb(wmGizmoGroupType *gzgt) { - gizmogrouptype_free(wgt); + gizmogrouptype_free(gzgt); } void wm_gizmogrouptype_free(void) diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h index 5eed4f2bda2..d4a9dc4f54c 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h @@ -40,14 +40,14 @@ struct GHashIterator; bool wm_gizmo_select_set_ex( - struct wmGizmoMap *mmap, struct wmGizmo *mpr, bool select, + struct wmGizmoMap *gzmap, struct wmGizmo *gz, bool select, bool use_array, bool use_callback); -bool wm_gizmo_select_and_highlight(bContext *C, struct wmGizmoMap *mmap, struct wmGizmo *mpr); +bool wm_gizmo_select_and_highlight(bContext *C, struct wmGizmoMap *gzmap, struct wmGizmo *gz); -void wm_gizmo_calculate_scale(struct wmGizmo *mpr, const bContext *C); -void wm_gizmo_update(struct wmGizmo *mpr, const bContext *C, const bool refresh_map); +void wm_gizmo_calculate_scale(struct wmGizmo *gz, const bContext *C); +void wm_gizmo_update(struct wmGizmo *gz, const bContext *C, const bool refresh_map); -int wm_gizmo_is_visible(struct wmGizmo *mpr); +int wm_gizmo_is_visible(struct wmGizmo *gz); enum { WM_GIZMO_IS_VISIBLE_UPDATE = (1 << 0), WM_GIZMO_IS_VISIBLE_DRAW = (1 << 1), @@ -66,20 +66,20 @@ enum { }; struct wmGizmoGroup *wm_gizmogroup_new_from_type( - struct wmGizmoMap *mmap, struct wmGizmoGroupType *wgt); -void wm_gizmogroup_free(bContext *C, struct wmGizmoGroup *mgroup); -void wm_gizmogroup_gizmo_register(struct wmGizmoGroup *mgroup, struct wmGizmo *mpr); + struct wmGizmoMap *gzmap, struct wmGizmoGroupType *gzgt); +void wm_gizmogroup_free(bContext *C, struct wmGizmoGroup *gzgroup); +void wm_gizmogroup_gizmo_register(struct wmGizmoGroup *gzgroup, struct wmGizmo *gz); struct wmGizmo *wm_gizmogroup_find_intersected_gizmo( - const struct wmGizmoGroup *mgroup, struct bContext *C, const struct wmEvent *event, + const struct wmGizmoGroup *gzgroup, struct bContext *C, const struct wmEvent *event, int *r_part); void wm_gizmogroup_intersectable_gizmos_to_list( - const struct wmGizmoGroup *mgroup, struct ListBase *listbase); -void wm_gizmogroup_ensure_initialized(struct wmGizmoGroup *mgroup, const struct bContext *C); + const struct wmGizmoGroup *gzgroup, struct ListBase *listbase); +void wm_gizmogroup_ensure_initialized(struct wmGizmoGroup *gzgroup, const struct bContext *C); bool wm_gizmogroup_is_visible_in_drawstep( - const struct wmGizmoGroup *mgroup, const eWM_GizmoFlagMapDrawStep drawstep); + const struct wmGizmoGroup *gzgroup, const eWM_GizmoFlagMapDrawStep drawstep); void wm_gizmogrouptype_setup_keymap( - struct wmGizmoGroupType *wgt, struct wmKeyConfig *keyconf); + struct wmGizmoGroupType *gzgt, struct wmKeyConfig *keyconf); /* -------------------------------------------------------------------- */ @@ -116,7 +116,7 @@ struct wmGizmoMap { short event_grabcursor; /* until we have nice cursor push/pop API. */ int last_cursor; - } mmap_context; + } gzmap_context; }; /** @@ -135,10 +135,10 @@ struct wmGizmoMapType { eWM_GizmoFlagMapTypeUpdateFlag type_update_flag; }; -void wm_gizmomap_select_array_clear(struct wmGizmoMap *mmap); -bool wm_gizmomap_deselect_all(struct wmGizmoMap *mmap); -void wm_gizmomap_select_array_shrink(struct wmGizmoMap *mmap, int len_subtract); -void wm_gizmomap_select_array_push_back(struct wmGizmoMap *mmap, wmGizmo *mpr); -void wm_gizmomap_select_array_remove(struct wmGizmoMap *mmap, wmGizmo *mpr); +void wm_gizmomap_select_array_clear(struct wmGizmoMap *gzmap); +bool wm_gizmomap_deselect_all(struct wmGizmoMap *gzmap); +void wm_gizmomap_select_array_shrink(struct wmGizmoMap *gzmap, int len_subtract); +void wm_gizmomap_select_array_push_back(struct wmGizmoMap *gzmap, wmGizmo *gz); +void wm_gizmomap_select_array_remove(struct wmGizmoMap *gzmap, wmGizmo *gz); #endif diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index 9da1591d535..9321ec674a9 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -75,7 +75,7 @@ typedef enum eWM_GizmoFlagGroupTypeGlobalFlag { WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1), } eWM_GizmoFlagGroupTypeGlobalFlag; -static eWM_GizmoFlagGroupTypeGlobalFlag wm_mmap_type_update_flag = 0; +static eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag = 0; /** * Gizmo-map update tagging. @@ -94,9 +94,9 @@ enum { * * \{ */ -static void wm_gizmomap_select_array_ensure_len_alloc(wmGizmoMap *mmap, int len) +static void wm_gizmomap_select_array_ensure_len_alloc(wmGizmoMap *gzmap, int len) { - wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select; if (len <= msel->len_alloc) { return; } @@ -104,20 +104,20 @@ static void wm_gizmomap_select_array_ensure_len_alloc(wmGizmoMap *mmap, int len) msel->len_alloc = len; } -void wm_gizmomap_select_array_clear(wmGizmoMap *mmap) +void wm_gizmomap_select_array_clear(wmGizmoMap *gzmap) { - wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select; MEM_SAFE_FREE(msel->items); msel->len = 0; msel->len_alloc = 0; } -void wm_gizmomap_select_array_shrink(wmGizmoMap *mmap, int len_subtract) +void wm_gizmomap_select_array_shrink(wmGizmoMap *gzmap, int len_subtract) { - wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select; msel->len -= len_subtract; if (msel->len <= 0) { - wm_gizmomap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(gzmap); } else { if (msel->len < msel->len_alloc / 2) { @@ -127,27 +127,27 @@ void wm_gizmomap_select_array_shrink(wmGizmoMap *mmap, int len_subtract) } } -void wm_gizmomap_select_array_push_back(wmGizmoMap *mmap, wmGizmo *mpr) +void wm_gizmomap_select_array_push_back(wmGizmoMap *gzmap, wmGizmo *gz) { - wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select; BLI_assert(msel->len <= msel->len_alloc); if (msel->len == msel->len_alloc) { msel->len_alloc = (msel->len + 1) * 2; msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len_alloc); } - msel->items[msel->len++] = mpr; + msel->items[msel->len++] = gz; } -void wm_gizmomap_select_array_remove(wmGizmoMap *mmap, wmGizmo *mpr) +void wm_gizmomap_select_array_remove(wmGizmoMap *gzmap, wmGizmo *gz) { - wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select; /* remove gizmo from selected_gizmos array */ for (int i = 0; i < msel->len; i++) { - if (msel->items[i] == mpr) { + if (msel->items[i] == gz) { for (int j = i; j < (msel->len - 1); j++) { msel->items[j] = msel->items[j + 1]; } - wm_gizmomap_select_array_shrink(mmap, 1); + wm_gizmomap_select_array_shrink(gzmap, 1); break; } } @@ -166,84 +166,84 @@ void wm_gizmomap_select_array_remove(wmGizmoMap *mmap, wmGizmo *mpr) * Creates a gizmo-map with all registered gizmos for that type */ wmGizmoMap *WM_gizmomap_new_from_type( - const struct wmGizmoMapType_Params *mmap_params) + const struct wmGizmoMapType_Params *gzmap_params) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(mmap_params); - wmGizmoMap *mmap; + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(gzmap_params); + wmGizmoMap *gzmap; - mmap = MEM_callocN(sizeof(wmGizmoMap), "GizmoMap"); - mmap->type = mmap_type; - WM_gizmomap_tag_refresh(mmap); + gzmap = MEM_callocN(sizeof(wmGizmoMap), "GizmoMap"); + gzmap->type = gzmap_type; + WM_gizmomap_tag_refresh(gzmap); /* create all gizmo-groups for this gizmo-map. We may create an empty one * too in anticipation of gizmos from operators etc */ - for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { - wm_gizmogroup_new_from_type(mmap, wgt_ref->type); + for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; gzgt_ref = gzgt_ref->next) { + wm_gizmogroup_new_from_type(gzmap, gzgt_ref->type); } - return mmap; + return gzmap; } -void wm_gizmomap_remove(wmGizmoMap *mmap) +void wm_gizmomap_remove(wmGizmoMap *gzmap) { /* Clear first so further calls don't waste time trying to maintain correct array state. */ - wm_gizmomap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(gzmap); - for (wmGizmoGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) { - mgroup_next = mgroup->next; - BLI_assert(mgroup->parent_mmap == mmap); - wm_gizmogroup_free(NULL, mgroup); + for (wmGizmoGroup *gzgroup = gzmap->groups.first, *gzgroup_next; gzgroup; gzgroup = gzgroup_next) { + gzgroup_next = gzgroup->next; + BLI_assert(gzgroup->parent_gzmap == gzmap); + wm_gizmogroup_free(NULL, gzgroup); } - BLI_assert(BLI_listbase_is_empty(&mmap->groups)); + BLI_assert(BLI_listbase_is_empty(&gzmap->groups)); - MEM_freeN(mmap); + MEM_freeN(gzmap); } wmGizmoGroup *WM_gizmomap_group_find( - struct wmGizmoMap *mmap, + struct wmGizmoMap *gzmap, const char *idname) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); - if (wgt) { - return WM_gizmomap_group_find_ptr(mmap, wgt); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + if (gzgt) { + return WM_gizmomap_group_find_ptr(gzmap, gzgt); } return NULL; } wmGizmoGroup *WM_gizmomap_group_find_ptr( - struct wmGizmoMap *mmap, - const struct wmGizmoGroupType *wgt) + struct wmGizmoMap *gzmap, + const struct wmGizmoGroupType *gzgt) { - for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (mgroup->type == wgt) { - return mgroup; + for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + if (gzgroup->type == gzgt) { + return gzgroup; } } return NULL; } -const ListBase *WM_gizmomap_group_list(wmGizmoMap *mmap) +const ListBase *WM_gizmomap_group_list(wmGizmoMap *gzmap) { - return &mmap->groups; + return &gzmap->groups; } -bool WM_gizmomap_is_any_selected(const wmGizmoMap *mmap) +bool WM_gizmomap_is_any_selected(const wmGizmoMap *gzmap) { - return mmap->mmap_context.select.len != 0; + return gzmap->gzmap_context.select.len != 0; } /** * \note We could use a callback to define bounds, for now just use matrix location. */ bool WM_gizmomap_minmax( - const wmGizmoMap *mmap, bool UNUSED(use_hidden), bool use_select, + const wmGizmoMap *gzmap, bool UNUSED(use_hidden), bool use_select, float r_min[3], float r_max[3]) { if (use_select) { int i; - for (i = 0; i < mmap->mmap_context.select.len; i++) { - minmax_v3v3_v3(r_min, r_max, mmap->mmap_context.select.items[i]->matrix_basis[3]); + for (i = 0; i < gzmap->gzmap_context.select.len; i++) { + minmax_v3v3_v3(r_min, r_max, gzmap->gzmap_context.select.items[i]->matrix_basis[3]); } return i != 0; } @@ -255,7 +255,7 @@ bool WM_gizmomap_minmax( } /** - * Creates and returns idname hash table for (visible) gizmos in \a mmap + * Creates and returns idname hash table for (visible) gizmos in \a gzmap * * \param poll Polling function for excluding gizmos. * \param data Custom data passed to \a poll @@ -264,20 +264,20 @@ bool WM_gizmomap_minmax( * best we use an iterator function instead of a hash. */ static GHash *WM_gizmomap_gizmo_hash_new( - const bContext *C, wmGizmoMap *mmap, + const bContext *C, wmGizmoMap *gzmap, bool (*poll)(const wmGizmo *, void *), void *data, const bool include_hidden) { GHash *hash = BLI_ghash_ptr_new(__func__); /* collect gizmos */ - for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (WM_gizmo_group_type_poll(C, mgroup->type)) { - for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { - if ((include_hidden || (mpr->flag & WM_GIZMO_HIDDEN) == 0) && - (!poll || poll(mpr, data))) + for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + if (WM_gizmo_group_type_poll(C, gzgroup->type)) { + for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + if ((include_hidden || (gz->flag & WM_GIZMO_HIDDEN) == 0) && + (!poll || poll(gz, data))) { - BLI_ghash_insert(hash, mpr, mpr); + BLI_ghash_insert(hash, gz, gz); } } } @@ -286,12 +286,12 @@ static GHash *WM_gizmomap_gizmo_hash_new( return hash; } -void WM_gizmomap_tag_refresh(wmGizmoMap *mmap) +void WM_gizmomap_tag_refresh(wmGizmoMap *gzmap) { - if (mmap) { + if (gzmap) { /* We might want only to refresh some, for tag all steps. */ for (int i = 0; i < WM_GIZMOMAP_DRAWSTEP_MAX; i++) { - mmap->update_flag[i] |= ( + gzmap->update_flag[i] |= ( GIZMOMAP_IS_PREPARE_DRAW | GIZMOMAP_IS_REFRESH_CALLBACK); } @@ -299,11 +299,11 @@ void WM_gizmomap_tag_refresh(wmGizmoMap *mmap) } static bool gizmo_prepare_drawing( - wmGizmoMap *mmap, wmGizmo *mpr, + wmGizmoMap *gzmap, wmGizmo *gz, const bContext *C, ListBase *draw_gizmos, const eWM_GizmoFlagMapDrawStep drawstep) { - int do_draw = wm_gizmo_is_visible(mpr); + int do_draw = wm_gizmo_is_visible(gz); if (do_draw == 0) { /* skip */ } @@ -311,10 +311,10 @@ static bool gizmo_prepare_drawing( /* Ensure we get RNA updates */ if (do_draw & WM_GIZMO_IS_VISIBLE_UPDATE) { /* hover gizmos need updating, even if we don't draw them */ - wm_gizmo_update(mpr, C, (mmap->update_flag[drawstep] & GIZMOMAP_IS_PREPARE_DRAW) != 0); + wm_gizmo_update(gz, C, (gzmap->update_flag[drawstep] & GIZMOMAP_IS_PREPARE_DRAW) != 0); } if (do_draw & WM_GIZMO_IS_VISIBLE_DRAW) { - BLI_addhead(draw_gizmos, BLI_genericNodeN(mpr)); + BLI_addhead(draw_gizmos, BLI_genericNodeN(gz)); } return true; } @@ -323,23 +323,23 @@ static bool gizmo_prepare_drawing( } /** - * Update gizmos of \a mmap to prepare for drawing. Adds all gizmos that + * Update gizmos of \a gzmap to prepare for drawing. Adds all gizmos that * should be drawn to list \a draw_gizmos, note that added items need freeing. */ static void gizmomap_prepare_drawing( - wmGizmoMap *mmap, const bContext *C, ListBase *draw_gizmos, + wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos, const eWM_GizmoFlagMapDrawStep drawstep) { - if (!mmap || BLI_listbase_is_empty(&mmap->groups)) + if (!gzmap || BLI_listbase_is_empty(&gzmap->groups)) return; - wmGizmo *mpr_modal = mmap->mmap_context.modal; + wmGizmo *gz_modal = gzmap->gzmap_context.modal; /* only active gizmo needs updating */ - if (mpr_modal) { - if ((mpr_modal->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL) == 0) { - if (wm_gizmogroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) { - if (gizmo_prepare_drawing(mmap, mpr_modal, C, draw_gizmos, drawstep)) { - mmap->update_flag[drawstep] &= ~GIZMOMAP_IS_PREPARE_DRAW; + if (gz_modal) { + if ((gz_modal->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL) == 0) { + if (wm_gizmogroup_is_visible_in_drawstep(gz_modal->parent_gzgroup, drawstep)) { + if (gizmo_prepare_drawing(gzmap, gz_modal, C, draw_gizmos, drawstep)) { + gzmap->update_flag[drawstep] &= ~GIZMOMAP_IS_PREPARE_DRAW; } } /* don't draw any other gizmos */ @@ -347,46 +347,46 @@ static void gizmomap_prepare_drawing( } } - for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */ - if (!wm_gizmogroup_is_visible_in_drawstep(mgroup, drawstep) || - !WM_gizmo_group_type_poll(C, mgroup->type)) + if (!wm_gizmogroup_is_visible_in_drawstep(gzgroup, drawstep) || + !WM_gizmo_group_type_poll(C, gzgroup->type)) { continue; } /* needs to be initialized on first draw */ /* XXX weak: Gizmo-group may skip refreshing if it's invisible (map gets untagged nevertheless) */ - if (mmap->update_flag[drawstep] & GIZMOMAP_IS_REFRESH_CALLBACK) { + if (gzmap->update_flag[drawstep] & GIZMOMAP_IS_REFRESH_CALLBACK) { /* force refresh again. */ - mgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH; + gzgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH; } /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */ - wm_gizmogroup_ensure_initialized(mgroup, C); + wm_gizmogroup_ensure_initialized(gzgroup, C); /* prepare drawing */ - if (mgroup->type->draw_prepare) { - mgroup->type->draw_prepare(C, mgroup); + if (gzgroup->type->draw_prepare) { + gzgroup->type->draw_prepare(C, gzgroup); } - for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { - gizmo_prepare_drawing(mmap, mpr, C, draw_gizmos, drawstep); + for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + gizmo_prepare_drawing(gzmap, gz, C, draw_gizmos, drawstep); } } - mmap->update_flag[drawstep] &= + gzmap->update_flag[drawstep] &= ~(GIZMOMAP_IS_REFRESH_CALLBACK | GIZMOMAP_IS_PREPARE_DRAW); } /** - * Draw all visible gizmos in \a mmap. + * Draw all visible gizmos in \a gzmap. * Uses global draw_gizmos listbase. */ -static void gizmos_draw_list(const wmGizmoMap *mmap, const bContext *C, ListBase *draw_gizmos) +static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos) { /* Can be empty if we're dynamically added and removed. */ - if ((mmap == NULL) || BLI_listbase_is_empty(&mmap->groups)) { + if ((gzmap == NULL) || BLI_listbase_is_empty(&gzmap->groups)) { return; } @@ -397,13 +397,13 @@ static void gizmos_draw_list(const wmGizmoMap *mmap, const bContext *C, ListBase /* draw_gizmos contains all visible gizmos - draw them */ for (LinkData *link = draw_gizmos->first, *link_next; link; link = link_next) { - wmGizmo *mpr = link->data; + wmGizmo *gz = link->data; link_next = link->next; - bool is_depth = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0; + bool is_depth = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0; /* Weak! since we don't 100% support depth yet (select ignores depth) always show highlighted */ - if (is_depth && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT)) { + if (is_depth && (gz->state & WM_GIZMO_STATE_HIGHLIGHT)) { is_depth = false; } @@ -424,7 +424,7 @@ static void gizmos_draw_list(const wmGizmoMap *mmap, const bContext *C, ListBase glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); - mpr->type->draw(C, mpr); + gz->type->draw(C, gz); glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_SMOOTH); @@ -439,7 +439,7 @@ static void gizmos_draw_list(const wmGizmoMap *mmap, const bContext *C, ListBase } void WM_gizmomap_draw( - wmGizmoMap *mmap, const bContext *C, + wmGizmoMap *gzmap, const bContext *C, const eWM_GizmoFlagMapDrawStep drawstep) { if (!WM_gizmo_context_check_drawstep(C, drawstep)) { @@ -448,24 +448,24 @@ void WM_gizmomap_draw( ListBase draw_gizmos = {NULL}; - gizmomap_prepare_drawing(mmap, C, &draw_gizmos, drawstep); - gizmos_draw_list(mmap, C, &draw_gizmos); + gizmomap_prepare_drawing(gzmap, C, &draw_gizmos, drawstep); + gizmos_draw_list(gzmap, C, &draw_gizmos); BLI_assert(BLI_listbase_is_empty(&draw_gizmos)); } static void gizmo_draw_select_3D_loop(const bContext *C, ListBase *visible_gizmos) { int select_id = 0; - wmGizmo *mpr; + wmGizmo *gz; /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */ bool is_depth_prev = false; bool is_depth_skip_prev = false; for (LinkData *link = visible_gizmos->first; link; link = link->next) { - mpr = link->data; + gz = link->data; - bool is_depth = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0; + bool is_depth = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0; if (is_depth == is_depth_prev) { /* pass */ } @@ -478,7 +478,7 @@ static void gizmo_draw_select_3D_loop(const bContext *C, ListBase *visible_gizmo } is_depth_prev = is_depth; } - bool is_depth_skip = (mpr->flag & WM_GIZMO_SELECT_BACKGROUND) != 0; + bool is_depth_skip = (gz->flag & WM_GIZMO_SELECT_BACKGROUND) != 0; if (is_depth_skip == is_depth_skip_prev) { /* pass */ } @@ -489,7 +489,7 @@ static void gizmo_draw_select_3D_loop(const bContext *C, ListBase *visible_gizmo /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected gizmo part id */ - mpr->type->draw_select(C, mpr, select_id << 8); + gz->type->draw_select(C, gz, select_id << 8); select_id++; @@ -593,10 +593,10 @@ static wmGizmo *gizmo_find_intersected_3d( * 3D ones (could check for smallest screen-space distance but not needed right now). */ wmGizmo *wm_gizmomap_highlight_find( - wmGizmoMap *mmap, bContext *C, const wmEvent *event, + wmGizmoMap *gzmap, bContext *C, const wmEvent *event, int *r_part) { - wmGizmo *mpr = NULL; + wmGizmo *gz = NULL; ListBase visible_3d_gizmos = {NULL}; bool do_step[WM_GIZMOMAP_DRAWSTEP_MAX]; @@ -604,18 +604,18 @@ wmGizmo *wm_gizmomap_highlight_find( do_step[i] = WM_gizmo_context_check_drawstep(C, i); } - for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { /* If it were important we could initialize here, * but this only happens when events are handled before drawing, * just skip to keep code-path for initializing gizmos simple. */ - if ((mgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0) { + if ((gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0) { continue; } - if (WM_gizmo_group_type_poll(C, mgroup->type)) { + if (WM_gizmo_group_type_poll(C, gzgroup->type)) { eWM_GizmoFlagMapDrawStep step; - if (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { step = WM_GIZMOMAP_DRAWSTEP_3D; } else { @@ -623,17 +623,17 @@ wmGizmo *wm_gizmomap_highlight_find( } if (do_step[step]) { - if ((mmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) && - (mgroup->type->refresh != NULL)) + if ((gzmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) && + (gzgroup->type->refresh != NULL)) { - mgroup->type->refresh(C, mgroup); + gzgroup->type->refresh(C, gzgroup); /* cleared below */ } if (step == WM_GIZMOMAP_DRAWSTEP_3D) { - wm_gizmogroup_intersectable_gizmos_to_list(mgroup, &visible_3d_gizmos); + wm_gizmogroup_intersectable_gizmos_to_list(gzgroup, &visible_3d_gizmos); } else if (step == WM_GIZMOMAP_DRAWSTEP_2D) { - if ((mpr = wm_gizmogroup_find_intersected_gizmo(mgroup, C, event, r_part))) { + if ((gz = wm_gizmogroup_find_intersected_gizmo(gzgroup, C, event, r_part))) { break; } } @@ -643,32 +643,32 @@ wmGizmo *wm_gizmomap_highlight_find( if (!BLI_listbase_is_empty(&visible_3d_gizmos)) { /* 2D gizmos get priority. */ - if (mpr == NULL) { - mpr = gizmo_find_intersected_3d(C, event->mval, &visible_3d_gizmos, r_part); + if (gz == NULL) { + gz = gizmo_find_intersected_3d(C, event->mval, &visible_3d_gizmos, r_part); } BLI_freelistN(&visible_3d_gizmos); } - mmap->update_flag[WM_GIZMOMAP_DRAWSTEP_3D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; - mmap->update_flag[WM_GIZMOMAP_DRAWSTEP_2D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; + gzmap->update_flag[WM_GIZMOMAP_DRAWSTEP_3D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; + gzmap->update_flag[WM_GIZMOMAP_DRAWSTEP_2D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; - return mpr; + return gz; } -void WM_gizmomap_add_handlers(ARegion *ar, wmGizmoMap *mmap) +void WM_gizmomap_add_handlers(ARegion *ar, wmGizmoMap *gzmap) { wmEventHandler *handler; for (handler = ar->handlers.first; handler; handler = handler->next) { - if (handler->gizmo_map == mmap) { + if (handler->gizmo_map == gzmap) { return; } } handler = MEM_callocN(sizeof(wmEventHandler), "gizmo handler"); - BLI_assert(mmap == ar->gizmo_map); - handler->gizmo_map = mmap; + BLI_assert(gzmap == ar->gizmo_map); + handler->gizmo_map = gzmap; BLI_addtail(&ar->handlers, handler); } @@ -682,8 +682,8 @@ void wm_gizmomaps_handled_modal_update( return; } - wmGizmoMap *mmap = handler->op_region->gizmo_map; - wmGizmo *mpr = wm_gizmomap_modal_get(mmap); + wmGizmoMap *gzmap = handler->op_region->gizmo_map; + wmGizmo *gz = wm_gizmomap_modal_get(gzmap); ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); @@ -691,11 +691,11 @@ void wm_gizmomaps_handled_modal_update( /* regular update for running operator */ if (modal_running) { - wmGizmoOpElem *mpop = mpr ? WM_gizmo_operator_get(mpr, mpr->highlight_part) : NULL; - if (mpr && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) { - wmGizmoFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; + wmGizmoOpElem *mpop = gz ? WM_gizmo_operator_get(gz, gz->highlight_part) : NULL; + if (gz && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) { + wmGizmoFnModal modal_fn = gz->custom_modal ? gz->custom_modal : gz->type->modal; if (modal_fn != NULL) { - int retval = modal_fn(C, mpr, event, 0); + int retval = modal_fn(C, gz, event, 0); /* The gizmo is tried to the operator, we can't choose when to exit. */ BLI_assert(retval & OPERATOR_RUNNING_MODAL); UNUSED_VARS_NDEBUG(retval); @@ -704,14 +704,14 @@ void wm_gizmomaps_handled_modal_update( } /* operator not running anymore */ else { - wm_gizmomap_highlight_set(mmap, C, NULL, 0); - if (mpr) { + wm_gizmomap_highlight_set(gzmap, C, NULL, 0); + if (gz) { /* This isn't defined if it ends because of success of cancel, we may want to change. */ bool cancel = true; - if (mpr->type->exit) { - mpr->type->exit(C, mpr, cancel); + if (gz->type->exit) { + gz->type->exit(C, gz, cancel); } - wm_gizmomap_modal_set(mmap, C, mpr, NULL, false); + wm_gizmomap_modal_set(gzmap, C, gz, NULL, false); } } @@ -721,58 +721,58 @@ void wm_gizmomaps_handled_modal_update( } /** - * Deselect all selected gizmos in \a mmap. + * Deselect all selected gizmos in \a gzmap. * \return if selection has changed. */ -bool wm_gizmomap_deselect_all(wmGizmoMap *mmap) +bool wm_gizmomap_deselect_all(wmGizmoMap *gzmap) { - wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select; if (msel->items == NULL || msel->len == 0) { return false; } for (int i = 0; i < msel->len; i++) { - wm_gizmo_select_set_ex(mmap, msel->items[i], false, false, true); + wm_gizmo_select_set_ex(gzmap, msel->items[i], false, false, true); } - wm_gizmomap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(gzmap); /* always return true, we already checked * if there's anything to deselect */ return true; } -BLI_INLINE bool gizmo_selectable_poll(const wmGizmo *mpr, void *UNUSED(data)) +BLI_INLINE bool gizmo_selectable_poll(const wmGizmo *gz, void *UNUSED(data)) { - return (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT); + return (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT); } /** - * Select all selectable gizmos in \a mmap. + * Select all selectable gizmos in \a gzmap. * \return if selection has changed. */ static bool wm_gizmomap_select_all_intern( - bContext *C, wmGizmoMap *mmap) + bContext *C, wmGizmoMap *gzmap) { - wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select; /* GHash is used here to avoid having to loop over all gizmos twice (once to * get tot_sel for allocating, once for actually selecting). Instead we collect * selectable gizmos in hash table and use this to get tot_sel and do selection */ - GHash *hash = WM_gizmomap_gizmo_hash_new(C, mmap, gizmo_selectable_poll, NULL, true); + GHash *hash = WM_gizmomap_gizmo_hash_new(C, gzmap, gizmo_selectable_poll, NULL, true); GHashIterator gh_iter; int i; bool changed = false; - wm_gizmomap_select_array_ensure_len_alloc(mmap, BLI_ghash_len(hash)); + wm_gizmomap_select_array_ensure_len_alloc(gzmap, BLI_ghash_len(hash)); GHASH_ITER_INDEX (gh_iter, hash, i) { - wmGizmo *mpr_iter = BLI_ghashIterator_getValue(&gh_iter); - WM_gizmo_select_set(mmap, mpr_iter, true); + wmGizmo *gz_iter = BLI_ghashIterator_getValue(&gh_iter); + WM_gizmo_select_set(gzmap, gz_iter, true); } /* highlight first gizmo */ - wm_gizmomap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part); + wm_gizmomap_highlight_set(gzmap, C, msel->items[0], msel->items[0]->highlight_part); BLI_assert(BLI_ghash_len(hash) == msel->len); @@ -781,21 +781,21 @@ static bool wm_gizmomap_select_all_intern( } /** - * Select/Deselect all selectable gizmos in \a mmap. + * Select/Deselect all selectable gizmos in \a gzmap. * \return if selection has changed. * * TODO select all by type */ -bool WM_gizmomap_select_all(bContext *C, wmGizmoMap *mmap, const int action) +bool WM_gizmomap_select_all(bContext *C, wmGizmoMap *gzmap, const int action) { bool changed = false; switch (action) { case SEL_SELECT: - changed = wm_gizmomap_select_all_intern(C, mmap); + changed = wm_gizmomap_select_all_intern(C, gzmap); break; case SEL_DESELECT: - changed = wm_gizmomap_deselect_all(mmap); + changed = wm_gizmomap_deselect_all(gzmap); break; default: BLI_assert(0); @@ -846,11 +846,11 @@ void wm_gizmomap_handler_context(bContext *C, wmEventHandler *handler) } } -bool WM_gizmomap_cursor_set(const wmGizmoMap *mmap, wmWindow *win) +bool WM_gizmomap_cursor_set(const wmGizmoMap *gzmap, wmWindow *win) { - wmGizmo *mpr = mmap->mmap_context.highlight; - if (mpr && mpr->type->cursor_get) { - WM_cursor_set(win, mpr->type->cursor_get(mpr)); + wmGizmo *gz = gzmap->gzmap_context.highlight; + if (gz && gz->type->cursor_get) { + WM_cursor_set(win, gz->type->cursor_get(gz)); return true; } @@ -858,33 +858,33 @@ bool WM_gizmomap_cursor_set(const wmGizmoMap *mmap, wmWindow *win) } bool wm_gizmomap_highlight_set( - wmGizmoMap *mmap, const bContext *C, wmGizmo *mpr, int part) + wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz, int part) { - if ((mpr != mmap->mmap_context.highlight) || - (mpr && part != mpr->highlight_part)) + if ((gz != gzmap->gzmap_context.highlight) || + (gz && part != gz->highlight_part)) { - if (mmap->mmap_context.highlight) { - mmap->mmap_context.highlight->state &= ~WM_GIZMO_STATE_HIGHLIGHT; - mmap->mmap_context.highlight->highlight_part = -1; + if (gzmap->gzmap_context.highlight) { + gzmap->gzmap_context.highlight->state &= ~WM_GIZMO_STATE_HIGHLIGHT; + gzmap->gzmap_context.highlight->highlight_part = -1; } - mmap->mmap_context.highlight = mpr; + gzmap->gzmap_context.highlight = gz; - if (mpr) { - mpr->state |= WM_GIZMO_STATE_HIGHLIGHT; - mpr->highlight_part = part; - mmap->mmap_context.last_cursor = -1; + if (gz) { + gz->state |= WM_GIZMO_STATE_HIGHLIGHT; + gz->highlight_part = part; + gzmap->gzmap_context.last_cursor = -1; - if (C && mpr->type->cursor_get) { + if (C && gz->type->cursor_get) { wmWindow *win = CTX_wm_window(C); - mmap->mmap_context.last_cursor = win->cursor; - WM_cursor_set(win, mpr->type->cursor_get(mpr)); + gzmap->gzmap_context.last_cursor = win->cursor; + WM_cursor_set(win, gz->type->cursor_get(gz)); } } else { - if (C && mmap->mmap_context.last_cursor != -1) { + if (C && gzmap->gzmap_context.last_cursor != -1) { wmWindow *win = CTX_wm_window(C); - WM_cursor_set(win, mmap->mmap_context.last_cursor); + WM_cursor_set(win, gzmap->gzmap_context.last_cursor); } } @@ -900,123 +900,123 @@ bool wm_gizmomap_highlight_set( return false; } -wmGizmo *wm_gizmomap_highlight_get(wmGizmoMap *mmap) +wmGizmo *wm_gizmomap_highlight_get(wmGizmoMap *gzmap) { - return mmap->mmap_context.highlight; + return gzmap->gzmap_context.highlight; } /** * Caller should call exit when (enable == False). */ void wm_gizmomap_modal_set( - wmGizmoMap *mmap, bContext *C, wmGizmo *mpr, const wmEvent *event, bool enable) + wmGizmoMap *gzmap, bContext *C, wmGizmo *gz, const wmEvent *event, bool enable) { if (enable) { - BLI_assert(mmap->mmap_context.modal == NULL); + BLI_assert(gzmap->gzmap_context.modal == NULL); wmWindow *win = CTX_wm_window(C); WM_tooltip_clear(C, win); - if (mpr->type->invoke && - (mpr->type->modal || mpr->custom_modal)) + if (gz->type->invoke && + (gz->type->modal || gz->custom_modal)) { - const int retval = mpr->type->invoke(C, mpr, event); + const int retval = gz->type->invoke(C, gz, event); if ((retval & OPERATOR_RUNNING_MODAL) == 0) { return; } } - mpr->state |= WM_GIZMO_STATE_MODAL; - mmap->mmap_context.modal = mpr; + gz->state |= WM_GIZMO_STATE_MODAL; + gzmap->gzmap_context.modal = gz; - if ((mpr->flag & WM_GIZMO_GRAB_CURSOR) && + if ((gz->flag & WM_GIZMO_GRAB_CURSOR) && (event->is_motion_absolute == false)) { WM_cursor_grab_enable(win, true, true, NULL); - copy_v2_v2_int(mmap->mmap_context.event_xy, &event->x); - mmap->mmap_context.event_grabcursor = win->grabcursor; + copy_v2_v2_int(gzmap->gzmap_context.event_xy, &event->x); + gzmap->gzmap_context.event_grabcursor = win->grabcursor; } else { - mmap->mmap_context.event_xy[0] = INT_MAX; + gzmap->gzmap_context.event_xy[0] = INT_MAX; } - struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); + struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, gz->highlight_part); if (mpop && mpop->type) { const int retval = WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); if ((retval & OPERATOR_RUNNING_MODAL) == 0) { - wm_gizmomap_modal_set(mmap, C, mpr, event, false); + wm_gizmomap_modal_set(gzmap, C, gz, event, false); } /* we failed to hook the gizmo to the operator handler or operator was cancelled, return */ - if (!mmap->mmap_context.modal) { - mpr->state &= ~WM_GIZMO_STATE_MODAL; - MEM_SAFE_FREE(mpr->interaction_data); + if (!gzmap->gzmap_context.modal) { + gz->state &= ~WM_GIZMO_STATE_MODAL; + MEM_SAFE_FREE(gz->interaction_data); } return; } } else { - BLI_assert(ELEM(mmap->mmap_context.modal, NULL, mpr)); + BLI_assert(ELEM(gzmap->gzmap_context.modal, NULL, gz)); /* deactivate, gizmo but first take care of some stuff */ - if (mpr) { - mpr->state &= ~WM_GIZMO_STATE_MODAL; - MEM_SAFE_FREE(mpr->interaction_data); + if (gz) { + gz->state &= ~WM_GIZMO_STATE_MODAL; + MEM_SAFE_FREE(gz->interaction_data); } - mmap->mmap_context.modal = NULL; + gzmap->gzmap_context.modal = NULL; if (C) { wmWindow *win = CTX_wm_window(C); - if (mmap->mmap_context.event_xy[0] != INT_MAX) { + if (gzmap->gzmap_context.event_xy[0] != INT_MAX) { /* Check if some other part of Blender (typically operators) * have adjusted the grab mode since it was set. * If so: warp, so we have a predictable outcome. */ - if (mmap->mmap_context.event_grabcursor == win->grabcursor) { - WM_cursor_grab_disable(win, mmap->mmap_context.event_xy); + if (gzmap->gzmap_context.event_grabcursor == win->grabcursor) { + WM_cursor_grab_disable(win, gzmap->gzmap_context.event_xy); } else { - WM_cursor_warp(win, UNPACK2(mmap->mmap_context.event_xy)); + WM_cursor_warp(win, UNPACK2(gzmap->gzmap_context.event_xy)); } } ED_region_tag_redraw(CTX_wm_region(C)); WM_event_add_mousemove(C); } - mmap->mmap_context.event_xy[0] = INT_MAX; + gzmap->gzmap_context.event_xy[0] = INT_MAX; } } -wmGizmo *wm_gizmomap_modal_get(wmGizmoMap *mmap) +wmGizmo *wm_gizmomap_modal_get(wmGizmoMap *gzmap) { - return mmap->mmap_context.modal; + return gzmap->gzmap_context.modal; } -wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *mmap, int *r_selected_len) +wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *gzmap, int *r_selected_len) { - *r_selected_len = mmap->mmap_context.select.len; - return mmap->mmap_context.select.items; + *r_selected_len = gzmap->gzmap_context.select.len; + return gzmap->gzmap_context.select.items; } -ListBase *wm_gizmomap_groups_get(wmGizmoMap *mmap) +ListBase *wm_gizmomap_groups_get(wmGizmoMap *gzmap) { - return &mmap->groups; + return &gzmap->groups; } void WM_gizmomap_message_subscribe( - bContext *C, wmGizmoMap *mmap, ARegion *ar, struct wmMsgBus *mbus) + bContext *C, wmGizmoMap *gzmap, ARegion *ar, struct wmMsgBus *mbus) { - for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (!WM_gizmo_group_type_poll(C, mgroup->type)) { + for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + if (!WM_gizmo_group_type_poll(C, gzgroup->type)) { continue; } - for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { - if (mpr->flag & WM_GIZMO_HIDDEN) { + for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + if (gz->flag & WM_GIZMO_HIDDEN) { continue; } - WM_gizmo_target_property_subscribe_all(mpr, mbus, ar); + WM_gizmo_target_property_subscribe_all(gz, mbus, ar); } - if (mgroup->type->message_subscribe != NULL) { - mgroup->type->message_subscribe(C, mgroup, mbus); + if (gzgroup->type->message_subscribe != NULL) { + gzgroup->type->message_subscribe(C, gzgroup, mbus); } } } @@ -1032,12 +1032,12 @@ void WM_gizmomap_message_subscribe( struct ARegion *WM_gizmomap_tooltip_init( struct bContext *C, struct ARegion *ar, bool *r_exit_on_event) { - wmGizmoMap *mmap = ar->gizmo_map; + wmGizmoMap *gzmap = ar->gizmo_map; *r_exit_on_event = true; - if (mmap) { - wmGizmo *mpr = mmap->mmap_context.highlight; - if (mpr) { - return UI_tooltip_create_from_gizmo(C, mpr); + if (gzmap) { + wmGizmo *gz = gzmap->gzmap_context.highlight; + if (gz) { + return UI_tooltip_create_from_gizmo(C, gz); } } return NULL; @@ -1051,13 +1051,13 @@ struct ARegion *WM_gizmomap_tooltip_init( * \{ */ wmGizmoMapType *WM_gizmomaptype_find( - const struct wmGizmoMapType_Params *mmap_params) + const struct wmGizmoMapType_Params *gzmap_params) { - for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { - if (mmap_type->spaceid == mmap_params->spaceid && - mmap_type->regionid == mmap_params->regionid) + for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; gzmap_type = gzmap_type->next) { + if (gzmap_type->spaceid == gzmap_params->spaceid && + gzmap_type->regionid == gzmap_params->regionid) { - return mmap_type; + return gzmap_type; } } @@ -1065,37 +1065,37 @@ wmGizmoMapType *WM_gizmomaptype_find( } wmGizmoMapType *WM_gizmomaptype_ensure( - const struct wmGizmoMapType_Params *mmap_params) + const struct wmGizmoMapType_Params *gzmap_params) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_find(mmap_params); + wmGizmoMapType *gzmap_type = WM_gizmomaptype_find(gzmap_params); - if (mmap_type) { - return mmap_type; + if (gzmap_type) { + return gzmap_type; } - mmap_type = MEM_callocN(sizeof(wmGizmoMapType), "gizmotype list"); - mmap_type->spaceid = mmap_params->spaceid; - mmap_type->regionid = mmap_params->regionid; - BLI_addhead(&gizmomaptypes, mmap_type); + gzmap_type = MEM_callocN(sizeof(wmGizmoMapType), "gizmotype list"); + gzmap_type->spaceid = gzmap_params->spaceid; + gzmap_type->regionid = gzmap_params->regionid; + BLI_addhead(&gizmomaptypes, gzmap_type); - return mmap_type; + return gzmap_type; } void wm_gizmomaptypes_free(void) { - for (wmGizmoMapType *mmap_type = gizmomaptypes.first, *mmap_type_next; - mmap_type; - mmap_type = mmap_type_next) + for (wmGizmoMapType *gzmap_type = gizmomaptypes.first, *gzmap_type_next; + gzmap_type; + gzmap_type = gzmap_type_next) { - mmap_type_next = mmap_type->next; - for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next; - wgt_ref; - wgt_ref = wgt_next) + gzmap_type_next = gzmap_type->next; + for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_next; + gzgt_ref; + gzgt_ref = gzgt_next) { - wgt_next = wgt_ref->next; - WM_gizmomaptype_group_free(wgt_ref); + gzgt_next = gzgt_ref->next; + WM_gizmomaptype_group_free(gzgt_ref); } - MEM_freeN(mmap_type); + MEM_freeN(gzmap_type); } } @@ -1107,9 +1107,9 @@ void wm_gizmos_keymap(wmKeyConfig *keyconf) /* we add this item-less keymap once and use it to group gizmo-group keymaps into it */ WM_keymap_find(keyconf, "Gizmos", 0, 0); - for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { - for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { - wm_gizmogrouptype_setup_keymap(wgt_ref->type, keyconf); + for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; gzmap_type = gzmap_type->next) { + for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; gzgt_ref = gzgt_ref->next) { + wm_gizmogrouptype_setup_keymap(gzgt_ref->type, keyconf); } } } @@ -1123,23 +1123,23 @@ void wm_gizmos_keymap(wmKeyConfig *keyconf) void WM_gizmoconfig_update_tag_init( - wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) + wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt) { /* tag for update on next use */ - mmap_type->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT); - wgt->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT); + gzmap_type->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT); + gzgt->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT); - wm_mmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT; + wm_gzmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT; } void WM_gizmoconfig_update_tag_remove( - wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) + wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt) { /* tag for update on next use */ - mmap_type->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE; - wgt->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE; + gzmap_type->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE; + gzgt->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE; - wm_mmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE; + wm_gzmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE; } /** @@ -1151,58 +1151,58 @@ void WM_gizmoconfig_update(struct Main *bmain) if (G.background) return; - if (wm_mmap_type_update_flag == 0) + if (wm_gzmap_type_update_flag == 0) return; - if (wm_mmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { - for (wmGizmoMapType *mmap_type = gizmomaptypes.first; - mmap_type; - mmap_type = mmap_type->next) + if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { + for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; + gzmap_type; + gzmap_type = gzmap_type->next) { - if (mmap_type->type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { - mmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; - for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_ref_next; - wgt_ref; - wgt_ref = wgt_ref_next) + if (gzmap_type->type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { + gzmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; + for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_ref_next; + gzgt_ref; + gzgt_ref = gzgt_ref_next) { - wgt_ref_next = wgt_ref->next; - if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_REMOVE) { - wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; - WM_gizmomaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type); + gzgt_ref_next = gzgt_ref->next; + if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_REMOVE) { + gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; + WM_gizmomaptype_group_unlink(NULL, bmain, gzmap_type, gzgt_ref->type); } } } } - wm_mmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE; + wm_gzmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE; } - if (wm_mmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT) { - for (wmGizmoMapType *mmap_type = gizmomaptypes.first; - mmap_type; - mmap_type = mmap_type->next) + if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT) { + for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; + gzmap_type; + gzmap_type = gzmap_type->next) { const uchar type_update_all = WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT; - if (mmap_type->type_update_flag & type_update_all) { - mmap_type->type_update_flag &= ~type_update_all; - for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; - wgt_ref; - wgt_ref = wgt_ref->next) + if (gzmap_type->type_update_flag & type_update_all) { + gzmap_type->type_update_flag &= ~type_update_all; + for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; + gzgt_ref; + gzgt_ref = gzgt_ref->next) { - if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { - WM_gizmomaptype_group_init_runtime_keymap(bmain, wgt_ref->type); - wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; + if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { + WM_gizmomaptype_group_init_runtime_keymap(bmain, gzgt_ref->type); + gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; } - if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_INIT) { - WM_gizmomaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type); - wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_INIT; + if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_INIT) { + WM_gizmomaptype_group_init_runtime(bmain, gzmap_type, gzgt_ref->type); + gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_INIT; } } } } - wm_mmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT; + wm_gzmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT; } } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c index f3df001af55..601c54b8be5 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c @@ -51,30 +51,30 @@ /** \name Property Definition * \{ */ -BLI_INLINE wmGizmoProperty *wm_gizmo_target_property_array(wmGizmo *mpr) +BLI_INLINE wmGizmoProperty *wm_gizmo_target_property_array(wmGizmo *gz) { - return (wmGizmoProperty *)(POINTER_OFFSET(mpr, mpr->type->struct_size)); + return (wmGizmoProperty *)(POINTER_OFFSET(gz, gz->type->struct_size)); } -wmGizmoProperty *WM_gizmo_target_property_array(wmGizmo *mpr) +wmGizmoProperty *WM_gizmo_target_property_array(wmGizmo *gz) { - return wm_gizmo_target_property_array(mpr); + return wm_gizmo_target_property_array(gz); } -wmGizmoProperty *WM_gizmo_target_property_at_index(wmGizmo *mpr, int index) +wmGizmoProperty *WM_gizmo_target_property_at_index(wmGizmo *gz, int index) { - BLI_assert(index < mpr->type->target_property_defs_len); + BLI_assert(index < gz->type->target_property_defs_len); BLI_assert(index != -1); - wmGizmoProperty *mpr_prop_array = wm_gizmo_target_property_array(mpr); - return &mpr_prop_array[index]; + wmGizmoProperty *gz_prop_array = wm_gizmo_target_property_array(gz); + return &gz_prop_array[index]; } -wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *mpr, const char *idname) +wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *gz, const char *idname) { int index = BLI_findstringindex( - &mpr->type->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)); + &gz->type->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)); if (index != -1) { - return WM_gizmo_target_property_at_index(mpr, index); + return WM_gizmo_target_property_at_index(gz, index); } else { return NULL; @@ -82,84 +82,84 @@ wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *mpr, const char *idname) } void WM_gizmo_target_property_def_rna_ptr( - wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type, + wmGizmo *gz, const wmGizmoPropertyType *gz_prop_type, PointerRNA *ptr, PropertyRNA *prop, int index) { - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type); /* if gizmo evokes an operator we cannot use it for property manipulation */ - BLI_assert(mpr->op_data == NULL); + BLI_assert(gz->op_data == NULL); - mpr_prop->type = mpr_prop_type; + gz_prop->type = gz_prop_type; - mpr_prop->ptr = *ptr; - mpr_prop->prop = prop; - mpr_prop->index = index; + gz_prop->ptr = *ptr; + gz_prop->prop = prop; + gz_prop->index = index; - if (mpr->type->property_update) { - mpr->type->property_update(mpr, mpr_prop); + if (gz->type->property_update) { + gz->type->property_update(gz, gz_prop); } } void WM_gizmo_target_property_def_rna( - wmGizmo *mpr, const char *idname, + wmGizmo *gz, const char *idname, PointerRNA *ptr, const char *propname, int index) { - const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); + const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(gz->type, idname); PropertyRNA *prop = RNA_struct_find_property(ptr, propname); - WM_gizmo_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); + WM_gizmo_target_property_def_rna_ptr(gz, gz_prop_type, ptr, prop, index); } void WM_gizmo_target_property_def_func_ptr( - wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type, + wmGizmo *gz, const wmGizmoPropertyType *gz_prop_type, const wmGizmoPropertyFnParams *params) { - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type); /* if gizmo evokes an operator we cannot use it for property manipulation */ - BLI_assert(mpr->op_data == NULL); + BLI_assert(gz->op_data == NULL); - mpr_prop->type = mpr_prop_type; + gz_prop->type = gz_prop_type; - mpr_prop->custom_func.value_get_fn = params->value_get_fn; - mpr_prop->custom_func.value_set_fn = params->value_set_fn; - mpr_prop->custom_func.range_get_fn = params->range_get_fn; - mpr_prop->custom_func.free_fn = params->free_fn; - mpr_prop->custom_func.user_data = params->user_data; + gz_prop->custom_func.value_get_fn = params->value_get_fn; + gz_prop->custom_func.value_set_fn = params->value_set_fn; + gz_prop->custom_func.range_get_fn = params->range_get_fn; + gz_prop->custom_func.free_fn = params->free_fn; + gz_prop->custom_func.user_data = params->user_data; - if (mpr->type->property_update) { - mpr->type->property_update(mpr, mpr_prop); + if (gz->type->property_update) { + gz->type->property_update(gz, gz_prop); } } void WM_gizmo_target_property_def_func( - wmGizmo *mpr, const char *idname, + wmGizmo *gz, const char *idname, const wmGizmoPropertyFnParams *params) { - const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); - WM_gizmo_target_property_def_func_ptr(mpr, mpr_prop_type, params); + const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(gz->type, idname); + WM_gizmo_target_property_def_func_ptr(gz, gz_prop_type, params); } void WM_gizmo_target_property_clear_rna_ptr( - wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type) + wmGizmo *gz, const wmGizmoPropertyType *gz_prop_type) { - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type); /* if gizmo evokes an operator we cannot use it for property manipulation */ - BLI_assert(mpr->op_data == NULL); + BLI_assert(gz->op_data == NULL); - mpr_prop->type = NULL; + gz_prop->type = NULL; - mpr_prop->ptr = PointerRNA_NULL; - mpr_prop->prop = NULL; - mpr_prop->index = -1; + gz_prop->ptr = PointerRNA_NULL; + gz_prop->prop = NULL; + gz_prop->index = -1; } void WM_gizmo_target_property_clear_rna( - wmGizmo *mpr, const char *idname) + wmGizmo *gz, const char *idname) { - const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); - WM_gizmo_target_property_clear_rna_ptr(mpr, mpr_prop_type); + const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(gz->type, idname); + WM_gizmo_target_property_clear_rna_ptr(gz, gz_prop_type); } @@ -171,93 +171,93 @@ void WM_gizmo_target_property_clear_rna( /** \name Property Access * \{ */ -bool WM_gizmo_target_property_is_valid_any(wmGizmo *mpr) +bool WM_gizmo_target_property_is_valid_any(wmGizmo *gz) { - wmGizmoProperty *mpr_prop_array = wm_gizmo_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_gizmo_target_property_is_valid(mpr_prop)) { + wmGizmoProperty *gz_prop_array = wm_gizmo_target_property_array(gz); + for (int i = 0; i < gz->type->target_property_defs_len; i++) { + wmGizmoProperty *gz_prop = &gz_prop_array[i]; + if (WM_gizmo_target_property_is_valid(gz_prop)) { return true; } } return false; } -bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *mpr_prop) +bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop) { - return ((mpr_prop->prop != NULL) || - (mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn)); + return ((gz_prop->prop != NULL) || + (gz_prop->custom_func.value_get_fn && gz_prop->custom_func.value_set_fn)); } float WM_gizmo_target_property_value_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop) + const wmGizmo *gz, wmGizmoProperty *gz_prop) { - if (mpr_prop->custom_func.value_get_fn) { + if (gz_prop->custom_func.value_get_fn) { float value = 0.0f; - BLI_assert(mpr_prop->type->array_length == 1); - mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, &value); + BLI_assert(gz_prop->type->array_length == 1); + gz_prop->custom_func.value_get_fn(gz, gz_prop, &value); return value; } - if (mpr_prop->index == -1) { - return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop); + if (gz_prop->index == -1) { + return RNA_property_float_get(&gz_prop->ptr, gz_prop->prop); } else { - return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index); + return RNA_property_float_get_index(&gz_prop->ptr, gz_prop->prop, gz_prop->index); } } void WM_gizmo_target_property_value_set( - bContext *C, const wmGizmo *mpr, - wmGizmoProperty *mpr_prop, const float value) + bContext *C, const wmGizmo *gz, + wmGizmoProperty *gz_prop, const float value) { - if (mpr_prop->custom_func.value_set_fn) { - BLI_assert(mpr_prop->type->array_length == 1); - mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, &value); + if (gz_prop->custom_func.value_set_fn) { + BLI_assert(gz_prop->type->array_length == 1); + gz_prop->custom_func.value_set_fn(gz, gz_prop, &value); return; } /* reset property */ - if (mpr_prop->index == -1) { - RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, value); + if (gz_prop->index == -1) { + RNA_property_float_set(&gz_prop->ptr, gz_prop->prop, value); } else { - RNA_property_float_set_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index, value); + RNA_property_float_set_index(&gz_prop->ptr, gz_prop->prop, gz_prop->index, value); } - RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); + RNA_property_update(C, &gz_prop->ptr, gz_prop->prop); } void WM_gizmo_target_property_value_get_array( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, float *value) { - if (mpr_prop->custom_func.value_get_fn) { - mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, value); + if (gz_prop->custom_func.value_get_fn) { + gz_prop->custom_func.value_get_fn(gz, gz_prop, value); return; } - RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value); + RNA_property_float_get_array(&gz_prop->ptr, gz_prop->prop, value); } void WM_gizmo_target_property_value_set_array( - bContext *C, const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float *value) { - if (mpr_prop->custom_func.value_set_fn) { - mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, value); + if (gz_prop->custom_func.value_set_fn) { + gz_prop->custom_func.value_set_fn(gz, gz_prop, value); return; } - RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, value); + RNA_property_float_set_array(&gz_prop->ptr, gz_prop->prop, value); - RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); + RNA_property_update(C, &gz_prop->ptr, gz_prop->prop); } bool WM_gizmo_target_property_range_get( - const wmGizmo *mpr, wmGizmoProperty *mpr_prop, + const wmGizmo *gz, wmGizmoProperty *gz_prop, float range[2]) { - if (mpr_prop->custom_func.value_get_fn) { - if (mpr_prop->custom_func.range_get_fn) { - mpr_prop->custom_func.range_get_fn(mpr, mpr_prop, range); + if (gz_prop->custom_func.value_get_fn) { + if (gz_prop->custom_func.range_get_fn) { + gz_prop->custom_func.range_get_fn(gz, gz_prop, range); return true; } else { @@ -267,17 +267,17 @@ bool WM_gizmo_target_property_range_get( } float step, precision; - RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &range[0], &range[1], &step, &precision); + RNA_property_float_ui_range(&gz_prop->ptr, gz_prop->prop, &range[0], &range[1], &step, &precision); return true; } int WM_gizmo_target_property_array_length( - const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop) + const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop) { - if (mpr_prop->custom_func.value_get_fn) { - return mpr_prop->type->array_length; + if (gz_prop->custom_func.value_get_fn) { + return gz_prop->type->array_length; } - return RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop); + return RNA_property_array_length(&gz_prop->ptr, gz_prop->prop); } /** \} */ @@ -289,26 +289,26 @@ int WM_gizmo_target_property_array_length( * \{ */ const wmGizmoPropertyType *WM_gizmotype_target_property_find( - const wmGizmoType *wt, const char *idname) + const wmGizmoType *gzt, const char *idname) { - return BLI_findstring(&wt->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)); + return BLI_findstring(&gzt->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)); } void WM_gizmotype_target_property_def( - wmGizmoType *wt, const char *idname, int data_type, int array_length) + wmGizmoType *gzt, const char *idname, int data_type, int array_length) { wmGizmoPropertyType *mpt; - BLI_assert(WM_gizmotype_target_property_find(wt, idname) == NULL); + BLI_assert(WM_gizmotype_target_property_find(gzt, idname) == NULL); const uint idname_size = strlen(idname) + 1; mpt = MEM_callocN(sizeof(wmGizmoPropertyType) + idname_size, __func__); memcpy(mpt->idname, idname, idname_size); mpt->data_type = data_type; mpt->array_length = array_length; - mpt->index_in_type = wt->target_property_defs_len; - wt->target_property_defs_len += 1; - BLI_addtail(&wt->target_property_defs, mpt); + mpt->index_in_type = gzt->target_property_defs_len; + gzt->target_property_defs_len += 1; + BLI_addtail(&gzt->target_property_defs, mpt); } /** \} */ @@ -322,10 +322,10 @@ void WM_gizmo_do_msg_notify_tag_refresh( bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) { ARegion *ar = msg_val->owner; - wmGizmoMap *mmap = msg_val->user_data; + wmGizmoMap *gzmap = msg_val->user_data; ED_region_tag_redraw(ar); - WM_gizmomap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(gzmap); } /** @@ -333,26 +333,26 @@ void WM_gizmo_do_msg_notify_tag_refresh( * drawing the region clears. */ void WM_gizmo_target_property_subscribe_all( - wmGizmo *mpr, struct wmMsgBus *mbus, ARegion *ar) + wmGizmo *gz, struct wmMsgBus *mbus, ARegion *ar) { - if (mpr->type->target_property_defs_len) { - wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - if (mpr_prop->prop) { + if (gz->type->target_property_defs_len) { + wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz); + for (int i = 0; i < gz->type->target_property_defs_len; i++) { + wmGizmoProperty *gz_prop = &gz_prop_array[i]; + if (WM_gizmo_target_property_is_valid(gz_prop)) { + if (gz_prop->prop) { WM_msg_subscribe_rna( - mbus, &mpr_prop->ptr, mpr_prop->prop, + mbus, &gz_prop->ptr, gz_prop->prop, &(const wmMsgSubscribeValue){ .owner = ar, .user_data = ar, .notify = ED_region_do_msg_notify_tag_redraw, }, __func__); WM_msg_subscribe_rna( - mbus, &mpr_prop->ptr, mpr_prop->prop, + mbus, &gz_prop->ptr, gz_prop->prop, &(const wmMsgSubscribeValue){ .owner = ar, - .user_data = mpr->parent_mgroup->parent_mmap, + .user_data = gz->parent_gzgroup->parent_gzmap, .notify = WM_gizmo_do_msg_notify_tag_refresh, }, __func__); } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index ba145af9582..2ff0148044c 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -62,11 +62,11 @@ static GHash *global_gizmotype_hash = NULL; const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet) { if (idname[0]) { - wmGizmoType *wt; + wmGizmoType *gzt; - wt = BLI_ghash_lookup(global_gizmotype_hash, idname); - if (wt) { - return wt; + gzt = BLI_ghash_lookup(global_gizmotype_hash, idname); + if (gzt) { + return gzt; } if (!quiet) { @@ -90,56 +90,56 @@ void WM_gizmotype_iter(GHashIterator *ghi) static wmGizmoType *wm_gizmotype_append__begin(void) { - wmGizmoType *wt = MEM_callocN(sizeof(wmGizmoType), "gizmotype"); - wt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoProperties); + wmGizmoType *gzt = MEM_callocN(sizeof(wmGizmoType), "gizmotype"); + gzt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoProperties); #if 0 /* Set the default i18n context now, so that opfunc can redefine it if needed! */ RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; #endif - return wt; + return gzt; } -static void wm_gizmotype_append__end(wmGizmoType *wt) +static void wm_gizmotype_append__end(wmGizmoType *gzt) { - BLI_assert(wt->struct_size >= sizeof(wmGizmo)); + BLI_assert(gzt->struct_size >= sizeof(wmGizmo)); - RNA_def_struct_identifier(&BLENDER_RNA, wt->srna, wt->idname); + RNA_def_struct_identifier(&BLENDER_RNA, gzt->srna, gzt->idname); - BLI_ghash_insert(global_gizmotype_hash, (void *)wt->idname, wt); + BLI_ghash_insert(global_gizmotype_hash, (void *)gzt->idname, gzt); } -void WM_gizmotype_append(void (*wtfunc)(struct wmGizmoType *)) +void WM_gizmotype_append(void (*gtfunc)(struct wmGizmoType *)) { - wmGizmoType *wt = wm_gizmotype_append__begin(); - wtfunc(wt); - wm_gizmotype_append__end(wt); + wmGizmoType *gzt = wm_gizmotype_append__begin(); + gtfunc(gzt); + wm_gizmotype_append__end(gzt); } -void WM_gizmotype_append_ptr(void (*wtfunc)(struct wmGizmoType *, void *), void *userdata) +void WM_gizmotype_append_ptr(void (*gtfunc)(struct wmGizmoType *, void *), void *userdata) { wmGizmoType *mt = wm_gizmotype_append__begin(); - wtfunc(mt, userdata); + gtfunc(mt, userdata); wm_gizmotype_append__end(mt); } /** * Free but don't remove from ghash. */ -static void gizmotype_free(wmGizmoType *wt) +static void gizmotype_free(wmGizmoType *gzt) { - if (wt->ext.srna) { /* python gizmo, allocs own string */ - MEM_freeN((void *)wt->idname); + if (gzt->ext.srna) { /* python gizmo, allocs own string */ + MEM_freeN((void *)gzt->idname); } - BLI_freelistN(&wt->target_property_defs); - MEM_freeN(wt); + BLI_freelistN(&gzt->target_property_defs); + MEM_freeN(gzt); } /** * \param C: May be NULL. */ static void gizmotype_unlink( - bContext *C, Main *bmain, wmGizmoType *wt) + bContext *C, Main *bmain, wmGizmoType *gzt) { /* Free instances. */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -147,15 +147,15 @@ static void gizmotype_unlink( for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmGizmoMap *mmap = ar->gizmo_map; - if (mmap) { - wmGizmoGroup *mgroup; - for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - for (wmGizmo *mpr = mgroup->gizmos.first, *mpr_next; mpr; mpr = mpr_next) { - mpr_next = mpr->next; - BLI_assert(mgroup->parent_mmap == mmap); - if (mpr->type == wt) { - WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, mpr, C); + wmGizmoMap *gzmap = ar->gizmo_map; + if (gzmap) { + wmGizmoGroup *gzgroup; + for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + for (wmGizmo *gz = gzgroup->gizmos.first, *gz_next; gz; gz = gz_next) { + gz_next = gz->next; + BLI_assert(gzgroup->parent_gzmap == gzmap); + if (gz->type == gzt) { + WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C); ED_region_tag_redraw(ar); } } @@ -167,26 +167,26 @@ static void gizmotype_unlink( } } -void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *wt) +void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt) { - BLI_assert(wt == WM_gizmotype_find(wt->idname, false)); + BLI_assert(gzt == WM_gizmotype_find(gzt->idname, false)); - BLI_ghash_remove(global_gizmotype_hash, wt->idname, NULL, NULL); + BLI_ghash_remove(global_gizmotype_hash, gzt->idname, NULL, NULL); - gizmotype_unlink(C, bmain, wt); + gizmotype_unlink(C, bmain, gzt); - gizmotype_free(wt); + gizmotype_free(gzt); } bool WM_gizmotype_remove(bContext *C, Main *bmain, const char *idname) { - wmGizmoType *wt = BLI_ghash_lookup(global_gizmotype_hash, idname); + wmGizmoType *gzt = BLI_ghash_lookup(global_gizmotype_hash, idname); - if (wt == NULL) { + if (gzt == NULL) { return false; } - WM_gizmotype_remove_ptr(C, bmain, wt); + WM_gizmotype_remove_ptr(C, bmain, gzt); return true; } diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h index 5b1085db4a1..414109e89e5 100644 --- a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h +++ b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h @@ -61,12 +61,12 @@ void wm_gizmogrouptype_init(void); void GIZMOGROUP_OT_gizmo_select(struct wmOperatorType *ot); void GIZMOGROUP_OT_gizmo_tweak(struct wmOperatorType *ot); -bool wm_gizmogroup_is_any_selected(const struct wmGizmoGroup *mgroup); +bool wm_gizmogroup_is_any_selected(const struct wmGizmoGroup *gzgroup); /* -------------------------------------------------------------------- */ /* wmGizmoMap */ -void wm_gizmomap_remove(struct wmGizmoMap *mmap); +void wm_gizmomap_remove(struct wmGizmoMap *gzmap); void wm_gizmos_keymap(struct wmKeyConfig *keyconf); @@ -75,19 +75,19 @@ void wm_gizmomaps_handled_modal_update( void wm_gizmomap_handler_context(bContext *C, struct wmEventHandler *handler); struct wmGizmo *wm_gizmomap_highlight_find( - struct wmGizmoMap *mmap, bContext *C, const struct wmEvent *event, + struct wmGizmoMap *gzmap, bContext *C, const struct wmEvent *event, int *r_part); bool wm_gizmomap_highlight_set( - struct wmGizmoMap *mmap, const bContext *C, - struct wmGizmo *mpr, int part); -struct wmGizmo *wm_gizmomap_highlight_get(struct wmGizmoMap *mmap); + struct wmGizmoMap *gzmap, const bContext *C, + struct wmGizmo *gz, int part); +struct wmGizmo *wm_gizmomap_highlight_get(struct wmGizmoMap *gzmap); void wm_gizmomap_modal_set( - struct wmGizmoMap *mmap, bContext *C, struct wmGizmo *mpr, + struct wmGizmoMap *gzmap, bContext *C, struct wmGizmo *gz, const struct wmEvent *event, bool enable); -struct wmGizmo *wm_gizmomap_modal_get(struct wmGizmoMap *mmap); -struct wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *mmap, int *r_selected_len); -struct ListBase *wm_gizmomap_groups_get(wmGizmoMap *mmap); +struct wmGizmo *wm_gizmomap_modal_get(struct wmGizmoMap *gzmap); +struct wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *gzmap, int *r_selected_len); +struct ListBase *wm_gizmomap_groups_get(wmGizmoMap *gzmap); /* -------------------------------------------------------------------- */ /* wmGizmoMapType */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index bc24b7698e2..e2247b2adff 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2395,8 +2395,8 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers else if (handler->gizmo_map) { ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - wmGizmoMap *mmap = handler->gizmo_map; - wmGizmo *mpr = wm_gizmomap_highlight_get(mmap); + wmGizmoMap *gzmap = handler->gizmo_map; + wmGizmo *gz = wm_gizmomap_highlight_get(gzmap); if (region->gizmo_map != handler->gizmo_map) { WM_gizmomap_tag_refresh(handler->gizmo_map); @@ -2406,10 +2406,10 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers wm_region_mouse_co(C, event); /* handle gizmo highlighting */ - if (event->type == MOUSEMOVE && !wm_gizmomap_modal_get(mmap)) { + if (event->type == MOUSEMOVE && !wm_gizmomap_modal_get(gzmap)) { int part; - mpr = wm_gizmomap_highlight_find(mmap, C, event, &part); - if (wm_gizmomap_highlight_set(mmap, C, mpr, part) && mpr != NULL) { + gz = wm_gizmomap_highlight_find(gzmap, C, event, &part); + if (wm_gizmomap_highlight_set(gzmap, C, gz, part) && gz != NULL) { WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_gizmomap_tooltip_init); } } @@ -2417,45 +2417,45 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers /* Either we operate on a single highlighted item * or groups attached to the selected gizmos. * To simplify things both cases loop over an array of items. */ - wmGizmoGroup *mgroup_first; - bool is_mgroup_single; + wmGizmoGroup *gzgroup_first; + bool is_gzgroup_single; if (ISMOUSE(event->type)) { - /* Keep mpr set as-is, just fake single selection. */ - if (mpr) { - mgroup_first = mpr->parent_mgroup; + /* Keep gz set as-is, just fake single selection. */ + if (gz) { + gzgroup_first = gz->parent_gzgroup; } else { - mgroup_first = NULL; + gzgroup_first = NULL; } - is_mgroup_single = true; + is_gzgroup_single = true; } else { - if (WM_gizmomap_is_any_selected(mmap)) { - const ListBase *groups = WM_gizmomap_group_list(mmap); - mgroup_first = groups->first; + if (WM_gizmomap_is_any_selected(gzmap)) { + const ListBase *groups = WM_gizmomap_group_list(gzmap); + gzgroup_first = groups->first; } else { - mgroup_first = NULL; + gzgroup_first = NULL; } - is_mgroup_single = false; + is_gzgroup_single = false; } /* Don't use from now on. */ - mpr = NULL; + gz = NULL; - for (wmGizmoGroup *mgroup = mgroup_first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *gzgroup = gzgroup_first; gzgroup; gzgroup = gzgroup->next) { /* get user customized keymap from default one */ - if ((is_mgroup_single == false) && + if ((is_gzgroup_single == false) && /* We might want to change the logic here and use some kind of gizmo edit-mode. * For now just use keymap when a selection exists. */ - wm_gizmogroup_is_any_selected(mgroup) == false) + wm_gizmogroup_is_any_selected(gzgroup) == false) { continue; } - wmKeyMap *keymap = WM_keymap_active(wm, mgroup->type->keymap); + wmKeyMap *keymap = WM_keymap_active(wm, gzgroup->type->keymap); wmKeyMapItem *kmi; PRINT("%s: checking '%s' ...", __func__, keymap->idname); @@ -2472,7 +2472,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers /* weak, but allows interactive callback to not use rawkey */ event->keymap_idname = kmi->idname; - CTX_wm_gizmo_group_set(C, mgroup); + CTX_wm_gizmo_group_set(C, gzgroup); /* handler->op is called later, we want keymap op to be triggered here */ handler->op = NULL; @@ -2515,7 +2515,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers break; } - if (is_mgroup_single) { + if (is_gzgroup_single) { break; } } diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 350327e8590..dcb33376f05 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -132,8 +132,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t bToolRef_Runtime *tref_rt = tref->runtime; if (tref_rt->gizmo_group[0]) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false); - if (wgt != NULL) { + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false); + if (gzgt != NULL) { bool found = false; /* TODO(campbell) */ @@ -154,8 +154,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t UNUSED_VARS(workspace); #endif if (!found) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); - WM_gizmomaptype_group_unlink(C, bmain, mmap_type, wgt); + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); + WM_gizmomaptype_group_unlink(C, bmain, gzmap_type, gzgt); } } } @@ -173,9 +173,9 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre bToolRef_Runtime *tref_rt = tref->runtime; if (tref_rt->gizmo_group[0]) { const char *idname = tref_rt->gizmo_group; - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); - if (wgt != NULL) { - WM_gizmo_group_type_ensure_ptr(wgt); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + if (gzgt != NULL) { + WM_gizmo_group_type_ensure_ptr(gzgt); } else { CLOG_WARN(WM_LOG_TOOLS, "'%s' widget not found", idname); -- cgit v1.2.3 From 57ab7daa2aee436b0b0acfa00b2e2b1d28b55b2c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jul 2018 15:27:15 +0200 Subject: GPU_matrix: use Blender's naming conventions Thanks to @sergey for review --- intern/gawain/gawain/gwn_batch.h | 2 +- intern/gawain/src/gwn_batch.c | 4 +- intern/gawain/src/gwn_immediate.c | 10 +- source/blender/blenfont/intern/blf.c | 12 +-- source/blender/blenfont/intern/blf_font.c | 8 +- .../draw/engines/external/external_engine.c | 4 +- source/blender/draw/intern/draw_manager.c | 18 ++-- source/blender/draw/intern/draw_manager_text.c | 10 +- source/blender/draw/intern/draw_view.c | 16 +-- source/blender/editors/animation/anim_draw.c | 6 +- source/blender/editors/animation/anim_markers.c | 6 +- source/blender/editors/curve/editcurve_paint.c | 14 +-- .../editors/gizmo_library/gizmo_library_presets.c | 12 +-- .../gizmo_library/gizmo_types/arrow2d_gizmo.c | 8 +- .../gizmo_library/gizmo_types/arrow3d_gizmo.c | 22 ++-- .../gizmo_library/gizmo_types/button2d_gizmo.c | 14 +-- .../gizmo_library/gizmo_types/cage2d_gizmo.c | 6 +- .../gizmo_library/gizmo_types/cage3d_gizmo.c | 6 +- .../gizmo_library/gizmo_types/dial3d_gizmo.c | 12 +-- .../gizmo_library/gizmo_types/grab3d_gizmo.c | 16 +-- .../gizmo_library/gizmo_types/primitive3d_gizmo.c | 12 +-- source/blender/editors/interface/interface.c | 12 +-- source/blender/editors/interface/interface_draw.c | 50 ++++----- source/blender/editors/interface/interface_icons.c | 2 +- .../blender/editors/interface/interface_widgets.c | 8 +- source/blender/editors/interface/view2d.c | 2 +- source/blender/editors/mask/mask_draw.c | 22 ++-- source/blender/editors/mesh/editmesh_knife.c | 6 +- source/blender/editors/mesh/editmesh_loopcut.c | 6 +- source/blender/editors/render/render_opengl.c | 2 +- source/blender/editors/screen/area.c | 16 +-- source/blender/editors/screen/glutil.c | 4 +- source/blender/editors/screen/screen_draw.c | 8 +- source/blender/editors/sculpt_paint/paint_cursor.c | 36 +++---- source/blender/editors/sculpt_paint/paint_utils.c | 4 +- source/blender/editors/space_action/action_draw.c | 8 +- source/blender/editors/space_clip/clip_draw.c | 70 ++++++------ .../blender/editors/space_clip/clip_graph_draw.c | 8 +- source/blender/editors/space_clip/space_clip.c | 12 +-- source/blender/editors/space_graph/graph_draw.c | 32 +++--- source/blender/editors/space_image/image_draw.c | 10 +- source/blender/editors/space_node/drawnode.c | 8 +- source/blender/editors/space_node/node_draw.c | 10 +- .../editors/space_sequencer/sequencer_draw.c | 6 +- source/blender/editors/space_view3d/drawobject.c | 4 +- source/blender/editors/space_view3d/space_view3d.c | 2 +- source/blender/editors/space_view3d/view3d_draw.c | 16 +-- .../editors/space_view3d/view3d_draw_legacy.c | 14 +-- .../space_view3d/view3d_gizmo_navigate_type.c | 26 ++--- .../blender/editors/space_view3d/view3d_project.c | 4 +- .../blender/editors/space_view3d/view3d_select.c | 4 +- source/blender/editors/space_view3d/view3d_utils.c | 4 +- source/blender/editors/space_view3d/view3d_view.c | 6 +- source/blender/editors/transform/transform.c | 40 +++---- .../editors/transform/transform_constraints.c | 8 +- .../blender/editors/transform/transform_generics.c | 4 +- source/blender/editors/uvedit/uvedit_draw.c | 6 +- source/blender/gpu/GPU_matrix.h | 90 ++++++++-------- source/blender/gpu/intern/gpu_matrix.c | 118 ++++++++++----------- source/blender/gpu/intern/gpu_shader.c | 2 +- source/blender/python/intern/gpu_py_matrix.c | 40 +++---- source/blender/windowmanager/intern/wm_operators.c | 18 ++-- source/blender/windowmanager/intern/wm_playanim.c | 16 +-- source/blender/windowmanager/intern/wm_subwindow.c | 8 +- 64 files changed, 495 insertions(+), 495 deletions(-) diff --git a/intern/gawain/gawain/gwn_batch.h b/intern/gawain/gawain/gwn_batch.h index cf7b0c9f1b5..734df3c91b6 100644 --- a/intern/gawain/gawain/gwn_batch.h +++ b/intern/gawain/gawain/gwn_batch.h @@ -119,7 +119,7 @@ void GWN_batch_uniform_mat4(Gwn_Batch*, const char* name, const float data[4][4] void GWN_batch_draw(Gwn_Batch*); -// This does not bind/unbind shader and does not call gpuBindMatrices() +// This does not bind/unbind shader and does not call GPU_matrix_bind() void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance); // Does not even need batch diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c index 62342cfc42f..4979d93b15e 100644 --- a/intern/gawain/src/gwn_batch.c +++ b/intern/gawain/src/gwn_batch.c @@ -18,7 +18,7 @@ #include // necessary functions from matrix API -extern void gpuBindMatrices(const Gwn_ShaderInterface* shaderface); +extern void GPU_matrix_bind(const Gwn_ShaderInterface* shaderface); static void batch_update_program_bindings(Gwn_Batch* batch, unsigned int v_first); @@ -537,7 +537,7 @@ void GWN_batch_draw(Gwn_Batch* batch) assert(batch->verts[0]->vbo_id != 0); #endif GWN_batch_program_use_begin(batch); - gpuBindMatrices(batch->interface); // external call. + GPU_matrix_bind(batch->interface); // external call. GWN_batch_draw_range_ex(batch, 0, 0, false); diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c index d43e52cc525..f6760b0e9da 100644 --- a/intern/gawain/src/gwn_immediate.c +++ b/intern/gawain/src/gwn_immediate.c @@ -19,8 +19,8 @@ #include // necessary functions from matrix API -extern void gpuBindMatrices(const Gwn_ShaderInterface*); -extern bool gpuMatricesDirty(void); +extern void GPU_matrix_bind(const Gwn_ShaderInterface*); +extern bool GPU_matrix_dirty_get(void); typedef struct { // TODO: organize this struct by frequency of change (run-time) @@ -129,7 +129,7 @@ void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface) glUseProgram(program); get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface); - gpuBindMatrices(shaderface); + GPU_matrix_bind(shaderface); } void immUnbindProgram(void) @@ -341,8 +341,8 @@ static void immDrawSetup(void) } } - if (gpuMatricesDirty()) - gpuBindMatrices(imm.shader_interface); + if (GPU_matrix_dirty_get()) + GPU_matrix_bind(imm.shader_interface); } void immEnd(void) diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 5dd692d3855..b0e0cdac407 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -594,24 +594,24 @@ static void blf_draw_gl__start(FontBLF *font) if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) == 0) return; /* glyphs will be translated individually and batched. */ - gpuPushMatrix(); + GPU_matrix_push(); if (font->flags & BLF_MATRIX) - gpuMultMatrix(font->m); + GPU_matrix_mul(font->m); - gpuTranslate3fv(font->pos); + GPU_matrix_translate_3fv(font->pos); if (font->flags & BLF_ASPECT) - gpuScale3fv(font->aspect); + GPU_matrix_scale_3fv(font->aspect); if (font->flags & BLF_ROTATION) - gpuRotate2D(RAD2DEG(font->angle)); + GPU_matrix_rotate_2d(RAD2DEG(font->angle)); } static void blf_draw_gl__end(FontBLF *font) { if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) != 0) - gpuPopMatrix(); + GPU_matrix_pop(); } void BLF_draw_ex( diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index b3ab36f7bcc..3f4c430ee4b 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -142,15 +142,15 @@ void blf_batch_draw_begin(FontBLF *font) if (g_batch.active) { float gpumat[4][4]; - gpuGetModelViewMatrix(gpumat); + GPU_matrix_model_view_get(gpumat); bool mat_changed = (memcmp(gpumat, g_batch.mat, sizeof(g_batch.mat)) != 0); if (mat_changed) { /* Modelviewmat is no longer the same. * Flush cache but with the previous mat. */ - gpuPushMatrix(); - gpuLoadMatrix(g_batch.mat); + GPU_matrix_push(); + GPU_matrix_set(g_batch.mat); } /* flush cache if config is not the same. */ @@ -165,7 +165,7 @@ void blf_batch_draw_begin(FontBLF *font) } if (mat_changed) { - gpuPopMatrix(); + GPU_matrix_pop(); /* Save for next memcmp. */ memcpy(g_batch.mat, gpumat, sizeof(g_batch.mat)); } diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c index 2917805d233..35ff777b885 100644 --- a/source/blender/draw/engines/external/external_engine.c +++ b/source/blender/draw/engines/external/external_engine.c @@ -165,14 +165,14 @@ static void external_draw_scene_do(void *vedata) } /* Rendered draw. */ - gpuPushProjectionMatrix(); + GPU_matrix_push_projection(); ED_region_pixelspace(ar); /* Render result draw. */ type = rv3d->render_engine->type; type->view_draw(rv3d->render_engine, draw_ctx->evil_C); - gpuPopProjectionMatrix(); + GPU_matrix_pop_projection(); /* Set render info. */ EXTERNAL_Data *data = vedata; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index a16d0bab104..1460f9a88f2 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -120,16 +120,16 @@ void DRW_draw_callbacks_pre_scene(void) { RegionView3D *rv3d = DST.draw_ctx.rv3d; - gpuLoadProjectionMatrix(rv3d->winmat); - gpuLoadMatrix(rv3d->viewmat); + GPU_matrix_projection_set(rv3d->winmat); + GPU_matrix_set(rv3d->viewmat); } void DRW_draw_callbacks_post_scene(void) { RegionView3D *rv3d = DST.draw_ctx.rv3d; - gpuLoadProjectionMatrix(rv3d->winmat); - gpuLoadMatrix(rv3d->viewmat); + GPU_matrix_projection_set(rv3d->winmat); + GPU_matrix_set(rv3d->viewmat); } struct DRWTextStore *DRW_text_cache_ensure(void) @@ -2074,18 +2074,18 @@ void DRW_draw_depth_loop( DRW_opengl_context_disable(); /* XXX Drawing the resulting buffer to the BACK_BUFFER */ - gpuPushMatrix(); - gpuPushProjectionMatrix(); + GPU_matrix_push(); + GPU_matrix_push_projection(); wmOrtho2_region_pixelspace(ar); - gpuLoadIdentity(); + GPU_matrix_identity_set(); glEnable(GL_DEPTH_TEST); /* Cannot write to depth buffer without testing */ glDepthFunc(GL_ALWAYS); draw_depth_texture_to_screen(g_select_buffer.texture_depth); glDepthFunc(GL_LEQUAL); - gpuPopMatrix(); - gpuPopProjectionMatrix(); + GPU_matrix_pop(); + GPU_matrix_pop_projection(); } /** \} */ diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c index 977374a00c5..b32853959c8 100644 --- a/source/blender/draw/intern/draw_manager_text.c +++ b/source/blender/draw/intern/draw_manager_text.c @@ -141,11 +141,11 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar) } float original_proj[4][4]; - gpuGetProjectionMatrix(original_proj); + GPU_matrix_projection_get(original_proj); wmOrtho2_region_pixelspace(ar); - gpuPushMatrix(); - gpuLoadIdentity(); + GPU_matrix_push(); + GPU_matrix_identity_set(); const int font_id = BLF_default(); @@ -173,8 +173,8 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *ar) } } - gpuPopMatrix(); - gpuLoadProjectionMatrix(original_proj); + GPU_matrix_pop(); + GPU_matrix_projection_set(original_proj); if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_enable(); diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 75a7d567d5c..688712a97b6 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -548,8 +548,8 @@ void DRW_draw_grid(void) *(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */ drawgrid(&scene->unit, ar, v3d, &grid_unit); - gpuLoadProjectionMatrix(rv3d->winmat); - gpuLoadMatrix(rv3d->viewmat); + GPU_matrix_projection_set(rv3d->winmat); + GPU_matrix_set(rv3d->viewmat); } else { glDepthMask(GL_TRUE); @@ -587,9 +587,9 @@ void DRW_draw_background(void) uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); uchar col_hi[3], col_lo[3]; - gpuPushMatrix(); - gpuLoadIdentity(); - gpuLoadProjectionMatrix(m); + GPU_matrix_push(); + GPU_matrix_identity_set(); + GPU_matrix_projection_set(m); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR_DITHER); @@ -608,7 +608,7 @@ void DRW_draw_background(void) immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -724,8 +724,8 @@ void DRW_draw_cursor(void) } ED_region_pixelspace(ar); - gpuTranslate2f(co[0] + 0.5f, co[1] + 0.5f); - gpuScale2f(U.widget_unit, U.widget_unit); + GPU_matrix_translate_2f(co[0] + 0.5f, co[1] + 0.5f); + GPU_matrix_scale_2f(U.widget_unit, U.widget_unit); Gwn_Batch *cursor_batch = DRW_cache_cursor_get(is_aligned); GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 51ba7d9c269..129cf07b7c4 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -87,8 +87,8 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag) /* because the frame number text is subject to the same scaling as the contents of the view */ UI_view2d_scale_get(v2d, &xscale, NULL); - gpuPushMatrix(); - gpuScale2f(1.0f / xscale, 1.0f); + GPU_matrix_push(); + GPU_matrix_scale_2f(1.0f / xscale, 1.0f); /* get timecode string * - padding on str-buf passed so that it doesn't sit on the frame indicator @@ -128,7 +128,7 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag) numstr, col); /* restore view transform */ - gpuPopMatrix(); + GPU_matrix_pop(); } /* General call for drawing current frame indicator in animation editor */ diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index c5f7782dcee..f809bff536f 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -505,8 +505,8 @@ void ED_markers_draw(const bContext *C, int flag) /* no time correction for framelen! space is drawn with old values */ ypixels = BLI_rcti_size_y(&v2d->mask); UI_view2d_scale_get(v2d, &xscale, &yscale); - gpuPushMatrix(); - gpuScale2f(1.0f / xscale, 1.0f); + GPU_matrix_push(); + GPU_matrix_scale_2f(1.0f / xscale, 1.0f); /* x-bounds with offset for text (adjust for long string, avoid checking string width) */ font_width_max = (10 * UI_DPI_FAC) / xscale; @@ -529,7 +529,7 @@ void ED_markers_draw(const bContext *C, int flag) } } - gpuPopMatrix(); + GPU_matrix_pop(); } /* ************************ Marker Wrappers API ********************* */ diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 90f9b2e0569..130e3cc5475 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -392,12 +392,12 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS GWN_batch_uniform_3fv(sphere, "color", color); /* scale to edit-mode space */ - gpuPushMatrix(); - gpuMultMatrix(obedit->obmat); + GPU_matrix_push(); + GPU_matrix_mul(obedit->obmat); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) { - gpuTranslate3f( + GPU_matrix_translate_3f( selem->location_local[0] - location_prev[0], selem->location_local[1] - location_prev[1], selem->location_local[2] - location_prev[2]); @@ -405,15 +405,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS const float radius = stroke_elem_radius(cdd, selem); - gpuPushMatrix(); - gpuScaleUniform(radius); + GPU_matrix_push(); + GPU_matrix_scale_1f(radius); GWN_batch_draw(sphere); - gpuPopMatrix(); + GPU_matrix_pop(); location_prev = selem->location_local; } - gpuPopMatrix(); + GPU_matrix_pop(); } if (stroke_len > 1) { diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c index e16f8ed21bf..ab92905192b 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_presets.c +++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c @@ -94,10 +94,10 @@ static void ed_gizmo_draw_preset_geometry( GPU_select_load_id(select_id); } - gpuPushMatrix(); - gpuMultMatrix(mat); + GPU_matrix_push(); + GPU_matrix_mul(mat); wm_gizmo_geometryinfo_draw(info, is_select, color); - gpuPopMatrix(); + GPU_matrix_pop(); if (is_select) { GPU_select_load_id(-1); @@ -139,10 +139,10 @@ void ED_gizmo_draw_preset_facemap( GPU_select_load_id(select_id); } - gpuPushMatrix(); - gpuMultMatrix(ob->obmat); + GPU_matrix_push(); + GPU_matrix_mul(ob->obmat); ED_draw_object_facemap(CTX_data_depsgraph(C), scene, ob, color, facemap); - gpuPopMatrix(); + GPU_matrix_pop(); if (is_select) { GPU_select_load_id(-1); diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c index 0faeeefb4a3..673e38e4a1a 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c @@ -72,9 +72,9 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - gpuPushMatrix(); - gpuMultMatrix(matrix); - gpuRotate2D(RAD2DEGF(arrow_angle)); + GPU_matrix_push(); + GPU_matrix_mul(matrix); + GPU_matrix_rotate_2d(RAD2DEGF(arrow_angle)); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -93,7 +93,7 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); } static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *gz) diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index 09c6485c29e..da4bce680b8 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -143,15 +143,15 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const /* *** draw arrow head *** */ - gpuPushMatrix(); + GPU_matrix_push(); if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) { const float size = 0.05f; /* translate to line end with some extra offset so box starts exactly where line ends */ - gpuTranslate3f(0.0f, 0.0f, arrow_length + size); + GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length + size); /* scale down to box size */ - gpuScale3f(size, size, size); + GPU_matrix_scale_3f(size, size, size); /* draw cube */ immUnbindProgram(); @@ -165,13 +165,13 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const const float width = 0.06f; /* translate to line end */ - gpuTranslate3f(0.0f, 0.0f, arrow_length); + GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length); imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8); imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1); } - gpuPopMatrix(); + GPU_matrix_pop(); #endif /* USE_GIZMO_CUSTOM_ARROWS */ } @@ -190,26 +190,26 @@ static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool WM_gizmo_calc_matrix_final(gz, matrix_final); - gpuPushMatrix(); - gpuMultMatrix(matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(matrix_final); GPU_blend(true); arrow_draw_geom(arrow, select, color); GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); if (gz->interaction_data) { GizmoInteraction *inter = gz->interaction_data; - gpuPushMatrix(); - gpuMultMatrix(inter->init_matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(inter->init_matrix_final); GPU_blend(true); arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index dfe2c8b2413..13711325038 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -150,8 +150,8 @@ static void button2d_draw_intern( } bool need_to_pop = true; - gpuPushMatrix(); - gpuMultMatrix(matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(matrix_final); if (is_3d) { RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -161,7 +161,7 @@ static void button2d_draw_intern( mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); zero_v3(matrix_align[3]); transpose_m4(matrix_align); - gpuMultMatrix(matrix_align); + GPU_matrix_mul(matrix_align); } if (select) { @@ -195,15 +195,15 @@ static void button2d_draw_intern( float size[2]; if (is_3d) { const float fac = 2.0f; - gpuTranslate2f(-(fac / 2), -(fac / 2)); - gpuScale2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC)); + GPU_matrix_translate_2f(-(fac / 2), -(fac / 2)); + GPU_matrix_scale_2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC)); size[0] = 1.0f; size[1] = 1.0f; } else { size[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; size[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; - gpuPopMatrix(); + GPU_matrix_pop(); need_to_pop = false; } UI_icon_draw(size[0], size[1], button->icon); @@ -212,7 +212,7 @@ static void button2d_draw_intern( } if (need_to_pop) { - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index 8a830302f51..5e3b7bb21c6 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -551,8 +551,8 @@ static void gizmo_cage2d_draw_intern( WM_gizmo_calc_matrix_final(gz, matrix_final); - gpuPushMatrix(); - gpuMultMatrix(matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(matrix_final); float margin[2]; gizmo_calc_rect_view_margin(gz, dims, margin); @@ -668,7 +668,7 @@ static void gizmo_cage2d_draw_intern( } GPU_line_width(1.0); - gpuPopMatrix(); + GPU_matrix_pop(); } /** diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index c3fb5a08cdb..9cad82619ba 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -296,8 +296,8 @@ static void gizmo_cage3d_draw_intern( WM_gizmo_calc_matrix_final(gz, matrix_final); - gpuPushMatrix(); - gpuMultMatrix(matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(matrix_final); float margin[3]; gizmo_calc_rect_view_margin(gz, dims, margin); @@ -412,7 +412,7 @@ static void gizmo_cage3d_draw_intern( } GPU_line_width(1.0); - gpuPopMatrix(); + GPU_matrix_pop(); } /** diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c index b45f3d8a242..300ae222189 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -161,8 +161,8 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[ { GPU_line_width(1.0f); - gpuPushMatrix(); - gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); + GPU_matrix_push(); + GPU_matrix_rotate_3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -177,7 +177,7 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[ immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); } static void dial_ghostarc_draw( @@ -292,8 +292,8 @@ static void dial_draw_intern( .matrix_basis = (void *)matrix_basis_adjust, }), matrix_final); - gpuPushMatrix(); - gpuMultMatrix(matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(matrix_final); /* draw rotation indicator arc first */ if ((gz->flag & WM_GIZMO_DRAW_VALUE) && @@ -335,7 +335,7 @@ static void dial_draw_intern( /* draw actual dial gizmo */ dial_geom_draw(gz, color, select, matrix_basis_adjust, clip_plane); - gpuPopMatrix(); + GPU_matrix_pop(); } static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id) diff --git a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c index c6d11347e9f..840ea793b89 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c @@ -176,8 +176,8 @@ static void grab3d_draw_intern( gizmo_color_get(gz, highlight, color); WM_gizmo_calc_matrix_final(gz, matrix_final); - gpuPushMatrix(); - gpuMultMatrix(matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(matrix_final); if (align_view) { float matrix_final_unit[4][4]; @@ -186,26 +186,26 @@ static void grab3d_draw_intern( mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit); zero_v3(matrix_align[3]); transpose_m4(matrix_align); - gpuMultMatrix(matrix_align); + GPU_matrix_mul(matrix_align); } GPU_blend(true); grab_geom_draw(gz, color, select, draw_options); GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); if (gz->interaction_data) { - gpuPushMatrix(); - gpuMultMatrix(inter->init_matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(inter->init_matrix_final); if (align_view) { - gpuMultMatrix(matrix_align); + GPU_matrix_mul(matrix_align); } GPU_blend(true); grab_geom_draw(gz, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c index be2bf7d2c56..b61c16b8d65 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c @@ -99,14 +99,14 @@ static void gizmo_primitive_draw_intern( WM_gizmo_calc_matrix_final(gz, matrix_final); - gpuPushMatrix(); - gpuMultMatrix(matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(matrix_final); GPU_blend(true); gizmo_primitive_draw_geom(color_inner, color_outer, draw_style); GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); if (gz->interaction_data) { GizmoInteraction *inter = gz->interaction_data; @@ -115,14 +115,14 @@ static void gizmo_primitive_draw_intern( copy_v3_fl(color_outer, 0.5f); color_outer[3] = 0.8f; - gpuPushMatrix(); - gpuMultMatrix(inter->init_matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(inter->init_matrix_final); GPU_blend(true); gizmo_primitive_draw_geom(color_inner, color_outer, draw_style); GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3e01c5f356f..37c56d454bb 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -280,7 +280,7 @@ static void ui_update_window_matrix(const wmWindow *window, const ARegion *regio /* window matrix and aspect */ if (region && region->visible) { /* Get projection matrix which includes View2D translation and zoom. */ - gpuGetProjectionMatrix(block->winmat); + GPU_matrix_projection_get(block->winmat); block->aspect = 2.0f / fabsf(region->winx * block->winmat[0][0]); } else { @@ -1448,9 +1448,9 @@ void UI_block_draw(const bContext *C, uiBlock *block) ui_but_to_pixelrect(&rect, ar, block, NULL); /* pixel space for AA widgets */ - gpuPushProjectionMatrix(); - gpuPushMatrix(); - gpuLoadIdentity(); + GPU_matrix_push_projection(); + GPU_matrix_push(); + GPU_matrix_identity_set(); wmOrtho2_region_pixelspace(ar); @@ -1485,8 +1485,8 @@ void UI_block_draw(const bContext *C, uiBlock *block) BLF_batch_draw_end(); /* restore matrix */ - gpuPopProjectionMatrix(); - gpuPopMatrix(); + GPU_matrix_pop_projection(); + GPU_matrix_pop(); } static void ui_block_message_subscribe(ARegion *ar, struct wmMsgBus *mbus, uiBlock *block) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 51f2c7e8ece..b1c3795b1af 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1027,13 +1027,13 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { float col[3] = {alpha, alpha, alpha}; - gpuPushMatrix(); - gpuTranslate2f(rect.xmin, yofs); - gpuScale2f(w, h); + GPU_matrix_push(); + GPU_matrix_translate_2f(rect.xmin, yofs); + GPU_matrix_scale_2f(w, h); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col); - gpuPopMatrix(); + GPU_matrix_pop(); /* min max */ immUniformColor3f(0.5f, 0.5f, 0.5f); @@ -1049,15 +1049,15 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE } /* RGB (3 channel) */ else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) { - gpuPushMatrix(); - gpuTranslate2f(rect.xmin, yofs); - gpuScale2f(w, h); + GPU_matrix_push(); + GPU_matrix_translate_2f(rect.xmin, yofs); + GPU_matrix_scale_2f(w, h); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]); waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]); waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, colors_alpha[2]); - gpuPopMatrix(); + GPU_matrix_pop(); } /* PARADE / YCC (3 channels) */ else if (ELEM(scopes->wavefrm_mode, @@ -1069,19 +1069,19 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE { int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE); - gpuPushMatrix(); - gpuTranslate2f(rect.xmin, yofs); - gpuScale2f(w3, h); + GPU_matrix_push(); + GPU_matrix_translate_2f(rect.xmin, yofs); + GPU_matrix_scale_2f(w3, h); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]); - gpuTranslate2f(1.0f, 0.0f); + GPU_matrix_translate_2f(1.0f, 0.0f); waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]); - gpuTranslate2f(1.0f, 0.0f); + GPU_matrix_translate_2f(1.0f, 0.0f); waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]); - gpuPopMatrix(); + GPU_matrix_pop(); } /* min max */ @@ -1263,13 +1263,13 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN glBlendFunc(GL_ONE, GL_ONE); GPU_point_size(1.0); - gpuPushMatrix(); - gpuTranslate2f(centerx, centery); - gpuScaleUniform(diam); + GPU_matrix_push(); + GPU_matrix_translate_2f(centerx, centery); + GPU_matrix_scale_1f(diam); waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col); - gpuPopMatrix(); + GPU_matrix_pop(); } immUnbindProgram(); @@ -1548,15 +1548,15 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) ui_but_v3_get(but, light); /* transform to button */ - gpuPushMatrix(); + GPU_matrix_push(); if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect)) size = 0.5f * BLI_rcti_size_x(rect); else size = 0.5f * BLI_rcti_size_y(rect); - gpuTranslate2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect)); - gpuScaleUniform(size); + GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect)); + GPU_matrix_scale_1f(size); Gwn_Batch *sphere = GPU_batch_preset_sphere(2); GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); @@ -1580,7 +1580,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) GPU_line_smooth(false); /* matrix after circle */ - gpuPopMatrix(); + GPU_matrix_pop(); immUnbindProgram(); } @@ -1900,7 +1900,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U } if (!ok && scopes->track_preview) { - gpuPushMatrix(); + GPU_matrix_push(); /* draw content of pattern area */ GPU_scissor(rect.xmin, rect.ymin, scissor[2], scissor[3]); @@ -1919,7 +1919,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U immDrawPixelsTex(&state, rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL); /* draw cross for pixel position */ - gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]); + GPU_matrix_translate_2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]); GPU_scissor( rect.xmin, rect.ymin, @@ -1958,7 +1958,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U immUnbindProgram(); } - gpuPopMatrix(); + GPU_matrix_pop(); ok = true; } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 62413e2434c..b9183461b4c 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1292,7 +1292,7 @@ static void icon_draw_texture_cached( { float mvp[4][4]; - gpuGetModelViewProjectionMatrix(mvp); + GPU_matrix_model_view_projection_get(mvp); IconDrawCall *call = &g_icon_draw_cache.drawcall_cache[g_icon_draw_cache.calls]; g_icon_draw_cache.calls++; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index fea88388be7..aa3106b135b 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1110,7 +1110,7 @@ void UI_widgetbase_draw_cache_flush(void) GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, (float *)g_widget_base_batch.params); GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - gpuBindMatrices(batch->interface); + GPU_matrix_bind(batch->interface); GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true); GWN_batch_program_use_end(batch); } @@ -4532,8 +4532,8 @@ void ui_draw_pie_center(uiBlock *block) float angle = atan2f(pie_dir[1], pie_dir[0]); float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4; - gpuPushMatrix(); - gpuTranslate2f(cx, cy); + GPU_matrix_push(); + GPU_matrix_translate_2f(cx, cy); GPU_blend(true); if (btheme->tui.wcol_pie_menu.shaded) { @@ -4579,7 +4579,7 @@ void ui_draw_pie_center(uiBlock *block) } GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 1b449877abe..7d9eb1181ed 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1151,7 +1151,7 @@ void UI_view2d_view_restore(const bContext *C) int height = BLI_rcti_size_y(&ar->winrct) + 1; wmOrtho2(0.0f, (float)width, 0.0f, (float)height); - gpuLoadIdentity(); + GPU_matrix_identity_set(); // ED_region_pixelspace(CTX_wm_region(C)); } diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 4717ef309f3..14cec724168 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -695,17 +695,17 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO); } - gpuPushMatrix(); - gpuTranslate2f(x, y); - gpuScale2f(zoomx, zoomy); + GPU_matrix_push(); + GPU_matrix_translate_2f(x, y); + GPU_matrix_scale_2f(zoomx, zoomy); if (stabmat) { - gpuMultMatrix(stabmat); + GPU_matrix_mul(stabmat); } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); immDrawPixelsTex(&state, 0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL); - gpuPopMatrix(); + GPU_matrix_pop(); if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { GPU_blend(false); @@ -715,13 +715,13 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, } /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ - gpuPushMatrix(); - gpuTranslate2f(x + xofs, y + yofs); - gpuScale2f(zoomx, zoomy); + GPU_matrix_push(); + GPU_matrix_translate_2f(x + xofs, y + yofs); + GPU_matrix_scale_2f(zoomx, zoomy); if (stabmat) { - gpuMultMatrix(stabmat); + GPU_matrix_mul(stabmat); } - gpuScale2f(maxdim, maxdim); + GPU_matrix_scale_2f(maxdim, maxdim); if (do_draw_cb) { ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); @@ -734,7 +734,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); } - gpuPopMatrix(); + GPU_matrix_pop(); } void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra, const int efra) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 8a9a5eadbdd..a2717e53358 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1045,8 +1045,8 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void glPolygonOffset(1.0f, 1.0f); - gpuPushMatrix(); - gpuMultMatrix(kcd->ob->obmat); + GPU_matrix_push(); + GPU_matrix_mul(kcd->ob->obmat); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -1193,7 +1193,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); /* Reset default */ GPU_depth_test(true); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 87c006095ed..9a58f1dcd08 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -113,8 +113,8 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a if ((lcd->totedge > 0) || (lcd->totpoint > 0)) { GPU_depth_test(false); - gpuPushMatrix(); - gpuMultMatrix(lcd->ob->obmat); + GPU_matrix_push(); + GPU_matrix_mul(lcd->ob->obmat); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -146,7 +146,7 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); /* Reset default */ GPU_depth_test(true); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index b5c1ffc64dd..1b8d8cf7af2 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -326,7 +326,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); wmOrtho2(0, sizex, 0, sizey); - gpuTranslate2f(sizex / 2, sizey / 2); + GPU_matrix_translate_2f(sizex / 2, sizey / 2); G.f |= G_RENDER_OGL; ED_gpencil_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 41c3209dbb1..cb8fdba0ae1 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -146,7 +146,7 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides) void ED_region_pixelspace(ARegion *ar) { wmOrtho2_region_pixelspace(ar); - gpuLoadIdentity(); + GPU_matrix_identity_set(); } /* only exported for WM */ @@ -352,8 +352,8 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar) GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - gpuPushMatrix(); - gpuTranslate2f(-ar->winrct.xmin, -ar->winrct.ymin); + GPU_matrix_push(); + GPU_matrix_translate_2f(-ar->winrct.xmin, -ar->winrct.ymin); for (az = sa->actionzones.first; az; az = az->next) { /* test if action zone is over this region */ @@ -388,7 +388,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar) } } - gpuPopMatrix(); + GPU_matrix_pop(); GPU_blend(false); } @@ -2674,11 +2674,11 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, return; /* find window pixel coordinates of origin */ - gpuPushMatrix(); + GPU_matrix_push(); /* offset and zoom using ogl */ - gpuTranslate2f(x, y); - gpuScale2f(zoomx, zoomy); + GPU_matrix_translate_2f(x, y); + GPU_matrix_scale_2f(zoomx, zoomy); BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi); @@ -2732,7 +2732,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, BLF_disable(blf_mono_font, BLF_CLIPPING); } - gpuPopMatrix(); + GPU_matrix_pop(); } void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 6cff82295f0..41404aee9c9 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -364,7 +364,7 @@ void bglPolygonOffset(float viewdist, float dist) // glPolygonOffset(-1.0, -1.0); /* hack below is to mimic polygon offset */ - gpuGetProjectionMatrix(winmat); + GPU_matrix_projection_get(winmat); /* dist is from camera to center point */ @@ -401,7 +401,7 @@ void bglPolygonOffset(float viewdist, float dist) offset = 0.0; } - gpuLoadProjectionMatrix(winmat); + GPU_matrix_projection_set(winmat); } /* **** Color management helper functions for GLSL display/transform ***** */ diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index 9c46938a90f..6e512d6d4df 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -627,14 +627,14 @@ static void screen_preview_draw(const bScreen *screen, int size_x, int size_y) wmOrtho2(0.0f, size_x, 0.0f, size_y); /* center */ - gpuPushMatrix(); - gpuLoadIdentity(); - gpuTranslate2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f); + GPU_matrix_push(); + GPU_matrix_identity_set(); + GPU_matrix_translate_2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f); screen_preview_scale_get(screen, size_x, size_y, asp, scale); screen_preview_draw_areas(screen, scale, col, 1.5f); - gpuPopMatrix(); + GPU_matrix_pop(); } /** diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 6b3c358d2ac..e1de86910ff 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -618,19 +618,19 @@ static void paint_draw_tex_overlay( glDepthFunc(GL_ALWAYS); if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { - gpuPushMatrix(); + GPU_matrix_push(); /* brush rotation */ - gpuTranslate2f(x, y); - gpuRotate2D(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec)); - gpuTranslate2f(-x, -y); + GPU_matrix_translate_2f(x, y); + GPU_matrix_rotate_2d(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec)); + GPU_matrix_translate_2f(-x, -y); /* scale based on tablet pressure */ if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) { const float scale = ups->size_pressure_value; - gpuTranslate2f(x, y); - gpuScale2f(scale, scale); - gpuTranslate2f(-x, -y); + GPU_matrix_translate_2f(x, y); + GPU_matrix_scale_2f(scale, scale); + GPU_matrix_translate_2f(-x, -y); } if (ups->draw_anchored) { @@ -671,12 +671,12 @@ static void paint_draw_tex_overlay( quad.xmax = brush->mask_stencil_dimension[0]; quad.ymax = brush->mask_stencil_dimension[1]; } - gpuPushMatrix(); + GPU_matrix_push(); if (primary) - gpuTranslate2fv(brush->stencil_pos); + GPU_matrix_translate_2fv(brush->stencil_pos); else - gpuTranslate2fv(brush->mask_stencil_pos); - gpuRotate2D(RAD2DEGF(mtex->rot)); + GPU_matrix_translate_2fv(brush->mask_stencil_pos); + GPU_matrix_rotate_2d(RAD2DEGF(mtex->rot)); } /* set quad color. Colored overlay does not get blending */ @@ -710,7 +710,7 @@ static void paint_draw_tex_overlay( immUnbindProgram(); if (ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_VIEW)) { - gpuPopMatrix(); + GPU_matrix_pop(); } } } @@ -762,11 +762,11 @@ static void paint_draw_cursor_overlay( /* scale based on tablet pressure */ if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) { do_pop = true; - gpuPushMatrix(); - gpuLoadIdentity(); - gpuTranslate2fv(center); - gpuScaleUniform(ups->size_pressure_value); - gpuTranslate2f(-center[0], -center[1]); + GPU_matrix_push(); + GPU_matrix_identity_set(); + GPU_matrix_translate_2fv(center); + GPU_matrix_scale_1f(ups->size_pressure_value); + GPU_matrix_translate_2f(-center[0], -center[1]); } Gwn_VertFormat *format = immVertexFormat(); @@ -796,7 +796,7 @@ static void paint_draw_cursor_overlay( immUnbindProgram(); if (do_pop) - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 697ffc32759..e914a24092e 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -299,8 +299,8 @@ static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, unsig /* get the needed opengl matrices */ GPU_viewport_size_get_i(view); - gpuGetModelViewMatrix(matrix); - gpuGetProjectionMatrix(proj); + GPU_matrix_model_view_get(matrix); + GPU_matrix_projection_get(proj); view[0] = view[1] = 0; mul_m4_m4m4(matrix, matrix, ob_eval->obmat); mul_m4_m4m4(matrix, proj, matrix); diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 8e521c997fd..6ebb04fafc4 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -436,9 +436,9 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) if (pid->cache->cached_frames == NULL) continue; - gpuPushMatrix(); - gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT_TEXT + yoffs); - gpuScale2f(1.0, cache_draw_height); + GPU_matrix_push(); + GPU_matrix_translate_2f(0.0, (float)V2D_SCROLL_HEIGHT_TEXT + yoffs); + GPU_matrix_scale_2f(1.0, cache_draw_height); switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: @@ -512,7 +512,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); yoffs += cache_draw_height; } diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 164565192fd..29bc0543426 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -356,11 +356,11 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); - gpuPushMatrix(); - gpuTranslate2f(x, y); + GPU_matrix_push(); + GPU_matrix_translate_2f(x, y); - gpuScale2f(zoomx, zoomy); - gpuMultMatrix(sc->stabmat); + GPU_matrix_scale_2f(zoomx, zoomy); + GPU_matrix_mul(sc->stabmat); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -377,7 +377,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); glDisable(GL_COLOR_LOGIC_OP); } @@ -603,8 +603,8 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT } /* pattern and search outline */ - gpuPushMatrix(); - gpuTranslate2fv(marker_pos); + GPU_matrix_push(); + GPU_matrix_translate_2fv(marker_pos); if (sc->flag & SC_SHOW_MARKER_PATTERN) { immBegin(GWN_PRIM_LINE_LOOP, 4); @@ -625,7 +625,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT marker->search_max[1]); } - gpuPopMatrix(); + GPU_matrix_pop(); } static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3]) @@ -745,8 +745,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra } /* pattern */ - gpuPushMatrix(); - gpuTranslate2fv(marker_pos); + GPU_matrix_push(); + GPU_matrix_translate_2fv(marker_pos); if (track->flag & TRACK_LOCKED) { if (act) { @@ -800,7 +800,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra marker->search_max[0], marker->search_max[1]); } - gpuPopMatrix(); + GPU_matrix_pop(); /* Restore default shader */ immUnbindProgram(); @@ -884,8 +884,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo immUniformThemeColor(TH_MARKER_OUTLINE); } - gpuPushMatrix(); - gpuTranslate2fv(marker_pos); + GPU_matrix_push(); + GPU_matrix_translate_2fv(marker_pos); dx = 6.0f / width / sc->zoom; dy = 6.0f / height / sc->zoom; @@ -944,7 +944,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px, pos); } - gpuPopMatrix(); + GPU_matrix_pop(); } static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, @@ -1141,8 +1141,8 @@ static void draw_plane_marker_image(Scene *scene, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); - gpuPushMatrix(); - gpuMultMatrix(gl_matrix); + GPU_matrix_push(); + GPU_matrix_mul(gl_matrix); Gwn_VertFormat *imm_format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -1170,7 +1170,7 @@ static void draw_plane_marker_image(Scene *scene, immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); glBindTexture(GL_TEXTURE_2D, 0); @@ -1342,13 +1342,13 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y); - gpuPushMatrix(); - gpuTranslate2f(x, y); + GPU_matrix_push(); + GPU_matrix_translate_2f(x, y); - gpuPushMatrix(); - gpuScale2f(zoomx, zoomy); - gpuMultMatrix(sc->stabmat); - gpuScale2f(width, height); + GPU_matrix_push(); + GPU_matrix_scale_2f(zoomx, zoomy); + GPU_matrix_mul(sc->stabmat); + GPU_matrix_scale_2f(width, height); act_track = BKE_tracking_track_get_active(tracking); @@ -1539,7 +1539,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); if (sc->flag & SC_SHOW_NAMES) { /* scaling should be cleared before drawing texts, otherwise font would also be scaled */ @@ -1565,7 +1565,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie } } - gpuPopMatrix(); + GPU_matrix_pop(); if (marker_pos) MEM_freeN(marker_pos); @@ -1592,11 +1592,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y); - gpuPushMatrix(); - gpuTranslate2f(x, y); - gpuScale2f(zoomx, zoomy); - gpuMultMatrix(sc->stabmat); - gpuScale2f(width, height); + GPU_matrix_push(); + GPU_matrix_translate_2f(x, y); + GPU_matrix_scale_2f(zoomx, zoomy); + GPU_matrix_mul(sc->stabmat); + GPU_matrix_scale_2f(width, height); uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -1774,7 +1774,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); } void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar) @@ -1871,8 +1871,8 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) * associated with the clip is already drawn in draw_distortion */ if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) { - gpuPushMatrix(); - gpuMultMatrix(sc->unistabmat); + GPU_matrix_push(); + GPU_matrix_mul(sc->unistabmat); if (is_track_source) { MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); @@ -1881,13 +1881,13 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); - gpuTranslate2fv(marker->pos); + GPU_matrix_translate_2fv(marker->pos); } } ED_gpencil_draw_2dimage(C); - gpuPopMatrix(); + GPU_matrix_pop(); } } else { diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 34720b3a627..0bc9c74cd8c 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -119,13 +119,13 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track, if (sel == data->sel) { immUniformThemeColor(sel ? TH_HANDLE_VERTEX_SELECT : TH_HANDLE_VERTEX); - gpuPushMatrix(); - gpuTranslate2f(scene_framenr, val); - gpuScale2f(1.0f / data->xscale * data->hsize, 1.0f / data->yscale * data->hsize); + GPU_matrix_push(); + GPU_matrix_translate_2f(scene_framenr, val); + GPU_matrix_scale_2f(1.0f / data->xscale * data->hsize, 1.0f / data->yscale * data->hsize); imm_draw_circle_wire_2d(data->pos, 0, 0, 0.7, 8); - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 4ac9010d3b5..2b98ff43c5f 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1185,13 +1185,13 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar) show_cursor |= sc->around == V3D_AROUND_CURSOR; if (show_cursor) { - gpuPushMatrix(); - gpuTranslate2f(x, y); - gpuScale2f(zoomx, zoomy); - gpuMultMatrix(sc->stabmat); - gpuScale2f(width, height); + GPU_matrix_push(); + GPU_matrix_translate_2f(x, y); + GPU_matrix_scale_2f(zoomx, zoomy); + GPU_matrix_mul(sc->stabmat); + GPU_matrix_scale_2f(width, height); ED_image_draw_cursor(ar, sc->cursor); - gpuPopMatrix(); + GPU_matrix_pop(); } clip_draw_cache_and_notes(C, sc, ar); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 16658c0d8db..2b2d404168f 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -422,9 +422,9 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize, unsigned int pos) { /* adjust view transform before starting */ - gpuPushMatrix(); - gpuTranslate2f(x, y); - gpuScale2f(1.0f / xscale * hsize, 1.0f / yscale * hsize); + GPU_matrix_push(); + GPU_matrix_translate_2f(x, y); + GPU_matrix_scale_2f(1.0f / xscale * hsize, 1.0f / yscale * hsize); /* draw X shape */ immBegin(GWN_PRIM_LINES, 4); @@ -436,7 +436,7 @@ static void draw_fcurve_sample_control(float x, float y, float xscale, float ysc immEnd(); /* restore view transform */ - gpuPopMatrix(); + GPU_matrix_pop(); } /* helper func - draw keyframe vertices only for an F-Curve */ @@ -585,10 +585,10 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie } /* apply unit mapping */ - gpuPushMatrix(); + GPU_matrix_push(); unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset); - gpuScale2f(1.0f, unit_scale); - gpuTranslate2f(0.0f, offset); + GPU_matrix_scale_2f(1.0f, unit_scale); + GPU_matrix_translate_2f(0.0f, offset); immBegin(GWN_PRIM_LINE_STRIP, count); @@ -645,7 +645,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie immEnd(); - gpuPopMatrix(); + GPU_matrix_pop(); } /* helper func - check if the F-Curve only contains easily drawable segments @@ -679,10 +679,10 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 short mapping_flag = ANIM_get_normalization_flags(ac); /* apply unit mapping */ - gpuPushMatrix(); + GPU_matrix_push(); unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset); - gpuScale2f(1.0f, unit_scale); - gpuTranslate2f(0.0f, offset); + GPU_matrix_scale_2f(1.0f, unit_scale); + GPU_matrix_translate_2f(0.0f, offset); /* For now, this assumes the worst case scenario, where all the keyframes have * bezier interpolation, and are drawn at full res. @@ -827,7 +827,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 immEnd(); - gpuPopMatrix(); + GPU_matrix_pop(); } /* Debugging -------------------------------- */ @@ -1136,9 +1136,9 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset); /* apply unit-scaling to all values via OpenGL */ - gpuPushMatrix(); - gpuScale2f(1.0f, unit_scale); - gpuTranslate2f(0.0f, offset); + GPU_matrix_push(); + GPU_matrix_scale_2f(1.0f, unit_scale); + GPU_matrix_translate_2f(0.0f, offset); /* set this once and for all - all handles and handle-verts should use the same thickness */ GPU_line_width(1.0); @@ -1160,7 +1160,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid draw_fcurve_samples(sipo, ar, fcu); } - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 24b02106021..ff90e59540e 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -117,13 +117,13 @@ static void draw_render_info(const bContext *C, int x, y; UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); - gpuPushMatrix(); - gpuTranslate2f(x, y); - gpuScale2f(zoomx, zoomy); + GPU_matrix_push(); + GPU_matrix_translate_2f(x, y); + GPU_matrix_scale_2f(zoomx, zoomy); if (rd->mode & R_BORDER) { /* TODO: round or floor instead of casting to int */ - gpuTranslate2f((int)(-rd->border.xmin * rd->xsch * rd->size * 0.01f), + GPU_matrix_translate_2f((int)(-rd->border.xmin * rd->xsch * rd->size * 0.01f), (int)(-rd->border.ymin * rd->ysch * rd->size * 0.01f)); } @@ -144,7 +144,7 @@ static void draw_render_info(const bContext *C, MEM_freeN(tiles); } - gpuPopMatrix(); + GPU_matrix_pop(); } } } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 97b112ebbd1..dfb85d3c8a4 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3193,8 +3193,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b if (ibuf) { float x, y; - gpuPushProjectionMatrix(); - gpuPushMatrix(); + GPU_matrix_push_projection(); + GPU_matrix_push(); /* somehow the offset has to be calculated inverse */ wmOrtho2_region_pixelspace(ar); @@ -3277,8 +3277,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b } } - gpuPopProjectionMatrix(); - gpuPopMatrix(); + GPU_matrix_pop_projection(); + GPU_matrix_pop(); } BKE_image_release_ibuf(ima, ibuf, lock); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index c632b354440..6976edce563 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1405,17 +1405,17 @@ void drawnodespace(const bContext *C, ARegion *ar) { float original_proj[4][4]; - gpuGetProjectionMatrix(original_proj); + GPU_matrix_projection_get(original_proj); - gpuPushMatrix(); - gpuLoadIdentity(); + GPU_matrix_push(); + GPU_matrix_identity_set(); wmOrtho2_pixelspace(ar->winx, ar->winy); WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); - gpuPopMatrix(); - gpuLoadProjectionMatrix(original_proj); + GPU_matrix_pop(); + GPU_matrix_projection_set(original_proj); } draw_nodetree(C, ar, ntree, path->parent_key); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index a10eda5c3e6..204559ebf4f 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1308,8 +1308,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (draw_backdrop) { /* XXX: need to load identity projection too? */ - gpuPushMatrix(); - gpuLoadIdentity(); + GPU_matrix_push(); + GPU_matrix_identity_set(); } glGenTextures(1, (GLuint *)&texid); @@ -1439,7 +1439,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq } if (draw_backdrop) { - gpuPopMatrix(); + GPU_matrix_pop(); return; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index beb323fb21c..f48d7ef578f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -621,7 +621,7 @@ void draw_object_backbufsel( select_mode = ts->selectmode; } - gpuMultMatrix(ob->obmat); + GPU_matrix_mul(ob->obmat); glClearDepth(1.0); GPU_clear(GPU_DEPTH_BIT); GPU_depth_test(true); @@ -688,7 +688,7 @@ void draw_object_backbufsel( break; } - gpuLoadMatrix(rv3d->viewmat); + GPU_matrix_set(rv3d->viewmat); } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index dca4b3f4f76..75c9b4a050f 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -251,7 +251,7 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d) /* we have to multiply instead of loading viewmatob to make * it work with duplis using displists, otherwise it will * override the dupli-matrix */ - gpuMultMatrix(ob->obmat); + GPU_matrix_mul(ob->obmat); } #ifdef DEBUG diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 89d01727d9b..4928f6e1f28 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -184,8 +184,8 @@ static void view3d_main_region_setup_view( ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, viewmat, winmat, rect); /* set for opengl */ - gpuLoadProjectionMatrix(rv3d->winmat); - gpuLoadMatrix(rv3d->viewmat); + GPU_matrix_projection_set(rv3d->winmat); + GPU_matrix_set(rv3d->viewmat); } static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d) @@ -1355,10 +1355,10 @@ void ED_view3d_draw_offscreen( GPU_free_images_anim(G.main); /* XXX :((( */ } - gpuPushProjectionMatrix(); - gpuLoadIdentity(); - gpuPushMatrix(); - gpuLoadIdentity(); + GPU_matrix_push_projection(); + GPU_matrix_identity_set(); + GPU_matrix_push(); + GPU_matrix_identity_set(); if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera) view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname); @@ -1375,8 +1375,8 @@ void ED_view3d_draw_offscreen( ar->winy = bwiny; ar->winrct = brect; - gpuPopProjectionMatrix(); - gpuPopMatrix(); + GPU_matrix_pop_projection(); + GPU_matrix_pop(); UI_Theme_Restore(&theme_state); diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index cfeb199de15..cc7f23e2c18 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -685,13 +685,13 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - gpuPushProjectionMatrix(); - gpuPushMatrix(); + GPU_matrix_push_projection(); + GPU_matrix_push(); ED_region_pixelspace(ar); - gpuTranslate2f(centx, centy); - gpuScaleUniform(bgpic->scale); - gpuRotate2D(RAD2DEGF(-bgpic->rotation)); + GPU_matrix_translate_2f(centx, centy); + GPU_matrix_scale_1f(bgpic->scale); + GPU_matrix_rotate_2d(RAD2DEGF(-bgpic->rotation)); if (bgpic->flag & CAM_BGIMG_FLAG_FLIP_X) { zoomx *= -1.0f; @@ -707,8 +707,8 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, immDrawPixelsTex(&state, x1 - centx, y1 - centy, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect, zoomx, zoomy, col); - gpuPopProjectionMatrix(); - gpuPopMatrix(); + GPU_matrix_pop_projection(); + GPU_matrix_pop(); GPU_blend(false); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index f296c2ee874..6040e21aacb 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -195,8 +195,8 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U static const float axis_highlight[4] = {1, 1, 1, 1}; static const float axis_black[4] = {0, 0, 0, 1}; static float axis_color[3][4]; - gpuPushMatrix(); - gpuMultMatrix(gz->matrix_offset); + GPU_matrix_push(); + GPU_matrix_mul(gz->matrix_offset); bool draw_center_done = false; @@ -219,11 +219,11 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U /* Circle defining active area (revert back to 2D space). */ { - gpuPopMatrix(); + GPU_matrix_pop(); immUniformColor4fv(color); imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION); - gpuPushMatrix(); - gpuMultMatrix(gz->matrix_offset); + GPU_matrix_push(); + GPU_matrix_mul(gz->matrix_offset); } draw_center_done = true; } @@ -276,15 +276,15 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U /* Axis Ball. */ { - gpuPushMatrix(); - gpuTranslate3fv(v_final); - gpuScaleUniform(is_pos ? 0.22f : 0.18f); + GPU_matrix_push(); + GPU_matrix_translate_3fv(v_final); + GPU_matrix_scale_1f(is_pos ? 0.22f : 0.18f); Gwn_Batch *sphere = GPU_batch_preset_sphere(0); GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); GWN_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade); GWN_batch_draw(sphere); - gpuPopMatrix(); + GPU_matrix_pop(); } /* Axis XYZ Character. */ @@ -298,7 +298,7 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U } } - gpuPopMatrix(); + GPU_matrix_pop(); immUnbindProgram(); } @@ -318,13 +318,13 @@ static void axis3d_draw_intern( .matrix_offset = matrix_unit, }), matrix_final); - gpuPushMatrix(); - gpuMultMatrix(matrix_final); + GPU_matrix_push(); + GPU_matrix_mul(matrix_final); GPU_blend(true); axis_geom_draw(gz, color, select); GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); } static void gizmo_axis_draw(const bContext *C, wmGizmo *gz) diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 30b91c1a8ee..91e255aec82 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -677,7 +677,7 @@ void ED_view3d_project(const struct ARegion *ar, const float world[3], float reg RegionView3D *rv3d = ar->regiondata; int viewport[4] = {0, 0, ar->winx, ar->winy}; - gpuProject(world, rv3d->viewmat, rv3d->winmat, viewport, region); + GPU_matrix_project(world, rv3d->viewmat, rv3d->winmat, viewport, region); } bool ED_view3d_unproject(const struct ARegion *ar, float regionx, float regiony, float regionz, float world[3]) @@ -686,5 +686,5 @@ bool ED_view3d_unproject(const struct ARegion *ar, float regionx, float regiony, int viewport[4] = {0, 0, ar->winx, ar->winy}; float region[3] = {regionx, regiony, regionz}; - return gpuUnProject(region, rv3d->viewmat, rv3d->winmat, viewport, world); + return GPU_matrix_unproject(region, rv3d->viewmat, rv3d->winmat, viewport, world); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 0f82dfa775c..3175075e9c3 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -510,7 +510,7 @@ static void do_lasso_select_mesh( /* for non zbuf projections, don't change the GL state */ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - gpuLoadMatrix(vc->rv3d->viewmat); + GPU_matrix_set(vc->rv3d->viewmat); bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); if (ts->selectmode & SCE_SELECT_VERTEX) { @@ -1936,7 +1936,7 @@ static int do_mesh_box_select( /* for non zbuf projections, don't change the GL state */ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - gpuLoadMatrix(vc->rv3d->viewmat); + GPU_matrix_set(vc->rv3d->viewmat); bbsel = EDBM_backbuf_border_init(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax); if (ts->selectmode & SCE_SELECT_VERTEX) { diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index ca5375b6b54..9b006bf4d9b 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -189,8 +189,8 @@ void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *ar) RegionView3D *rv3d = ar->regiondata; wmViewport(&ar->winrct); // TODO: bad - gpuLoadProjectionMatrix(rv3d->winmat); - gpuLoadMatrix(rv3d->viewmat); + GPU_matrix_projection_set(rv3d->winmat); + GPU_matrix_set(rv3d->viewmat); } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c9e915a6415..bb0745b1998 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -721,14 +721,14 @@ void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *ar, const View3D *v3d, } if (is_ortho) { - gpuOrtho(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); + GPU_matrix_ortho_set(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); } else { - gpuFrustum(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); + GPU_matrix_frustum_set(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); } /* update matrix in 3d view region */ - gpuGetProjectionMatrix(rv3d->winmat); + GPU_matrix_projection_get(rv3d->winmat); } static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ad7b5d55ba5..c49c9a8706c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1813,7 +1813,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) tmval[i] += offset[i]; } - gpuPushMatrix(); + GPU_matrix_push(); /* Dashed lines first. */ if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE)) { @@ -1853,8 +1853,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) case HLP_SPRING: immUniformThemeColor(TH_VIEW_OVERLAY); - gpuTranslate3fv(mval); - gpuRotateAxis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z'); + GPU_matrix_translate_3fv(mval); + GPU_matrix_rotate_axis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z'); GPU_line_width(3.0f); drawArrow(UP, 5, 10, 5); @@ -1862,7 +1862,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) break; case HLP_HARROW: immUniformThemeColor(TH_VIEW_OVERLAY); - gpuTranslate3fv(mval); + GPU_matrix_translate_3fv(mval); GPU_line_width(3.0f); drawArrow(RIGHT, 5, 10, 5); @@ -1871,7 +1871,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) case HLP_VARROW: immUniformThemeColor(TH_VIEW_OVERLAY); - gpuTranslate3fv(mval); + GPU_matrix_translate_3fv(mval); GPU_line_width(3.0f); drawArrow(UP, 5, 10, 5); @@ -1887,23 +1887,23 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) immUniformThemeColor(TH_VIEW_OVERLAY); - gpuTranslate3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0); + GPU_matrix_translate_3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0); GPU_line_width(3.0f); drawArc(dist, angle - delta_angle, angle - spacing_angle, 10); drawArc(dist, angle + spacing_angle, angle + delta_angle, 10); - gpuPushMatrix(); + GPU_matrix_push(); - gpuTranslate3f(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0); - gpuRotateAxis(RAD2DEGF(angle - delta_angle), 'Z'); + GPU_matrix_translate_3f(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0); + GPU_matrix_rotate_axis(RAD2DEGF(angle - delta_angle), 'Z'); drawArrowHead(DOWN, 5); - gpuPopMatrix(); + GPU_matrix_pop(); - gpuTranslate3f(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0); - gpuRotateAxis(RAD2DEGF(angle + delta_angle), 'Z'); + GPU_matrix_translate_3f(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0); + GPU_matrix_rotate_axis(RAD2DEGF(angle + delta_angle), 'Z'); drawArrowHead(UP, 5); break; @@ -1913,7 +1913,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) unsigned char col[3], col2[3]; UI_GetThemeColor3ubv(TH_GRID, col); - gpuTranslate3fv(mval); + GPU_matrix_translate_3fv(mval); GPU_line_width(3.0f); @@ -1933,7 +1933,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) } immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); } } @@ -7049,8 +7049,8 @@ static void drawEdgeSlide(TransInfo *t) GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - gpuPushMatrix(); - gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); + GPU_matrix_push(); + GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -7138,7 +7138,7 @@ static void drawEdgeSlide(TransInfo *t) immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); GPU_blend(false); @@ -7682,8 +7682,8 @@ static void drawVertSlide(TransInfo *t) GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - gpuPushMatrix(); - gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); + GPU_matrix_push(); + GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); GPU_line_width(line_size); @@ -7769,7 +7769,7 @@ static void drawVertSlide(TransInfo *t) immUnbindProgram(); } - gpuPopMatrix(); + GPU_matrix_pop(); GPU_depth_test(true); } diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index d40602f8d43..a02948a9951 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -800,13 +800,13 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) unit_m4(imat); } - gpuPushMatrix(); + GPU_matrix_push(); if (t->spacetype == SPACE_VIEW3D) { /* pass */ } else if (t->spacetype == SPACE_IMAGE) { - gpuScale2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]); + GPU_matrix_scale_2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]); } else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) { /* only scale y */ @@ -816,7 +816,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) float ysize = BLI_rctf_size_y(datamask); float xmask = BLI_rcti_size_x(mask); float ymask = BLI_rcti_size_y(mask); - gpuScale2f(1.0f, (ysize / xsize) * (xmask / ymask)); + GPU_matrix_scale_2f(1.0f, (ysize / xsize) * (xmask / ymask)); } depth_test_enabled = GPU_depth_test_enabled(); @@ -837,7 +837,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) if (depth_test_enabled) GPU_depth_test(true); - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index e54b154ee0d..c1aa0263ef8 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1116,7 +1116,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = t->view; - gpuPushMatrix(); + GPU_matrix_push(); copy_v3_v3(v3, dir); mul_v3_fl(v3, v3d->far); @@ -1144,7 +1144,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index f0d6b5c2a71..5ff008e1de2 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -90,7 +90,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) GPU_line_width(1.0f); - gpuTranslate2fv(cursor); + GPU_matrix_translate_2fv(cursor); const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -141,7 +141,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) immUnbindProgram(); - gpuTranslate2f(-cursor[0], -cursor[1]); + GPU_matrix_translate_2f(-cursor[0], -cursor[1]); } static int draw_uvs_face_check(Scene *scene) @@ -814,7 +814,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* Now draw each face contour separately with another builtin program. */ GWN_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR); - gpuBindMatrices(loop_batch->interface); + GPU_matrix_bind(loop_batch->interface); GWN_batch_program_use_begin(loop_batch); index = 0; diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h index f22c0cd5c4d..f5e34bd4c90 100644 --- a/source/blender/gpu/GPU_matrix.h +++ b/source/blender/gpu/GPU_matrix.h @@ -40,79 +40,79 @@ extern "C" { struct Gwn_ShaderInterface; -void gpuMatrixReset(void); /* to Identity transform & empty stack */ +void GPU_matrix_reset(void); /* to Identity transform & empty stack */ /* ModelView Matrix (2D or 3D) */ -void gpuPushMatrix(void); /* TODO: PushCopy vs PushIdentity? */ -void gpuPopMatrix(void); +void GPU_matrix_push(void); /* TODO: PushCopy vs PushIdentity? */ +void GPU_matrix_pop(void); -void gpuLoadIdentity(void); +void GPU_matrix_identity_set(void); -void gpuScaleUniform(float factor); +void GPU_matrix_scale_1f(float factor); /* 3D ModelView Matrix */ -void gpuLoadMatrix(const float m[4][4]); -void gpuMultMatrix(const float m[4][4]); +void GPU_matrix_set(const float m[4][4]); +void GPU_matrix_mul(const float m[4][4]); -void gpuTranslate3f(float x, float y, float z); -void gpuTranslate3fv(const float vec[3]); -void gpuScale3f(float x, float y, float z); -void gpuScale3fv(const float vec[3]); -void gpuRotate3f(float deg, float x, float y, float z); /* axis of rotation should be a unit vector */ -void gpuRotate3fv(float deg, const float axis[3]); /* axis of rotation should be a unit vector */ -void gpuRotateAxis(float deg, char axis); /* TODO: enum for axis? */ +void GPU_matrix_translate_3f(float x, float y, float z); +void GPU_matrix_translate_3fv(const float vec[3]); +void GPU_matrix_scale_3f(float x, float y, float z); +void GPU_matrix_scale_3fv(const float vec[3]); +void GPU_matrix_rotate_3f(float deg, float x, float y, float z); /* axis of rotation should be a unit vector */ +void GPU_matrix_rotate_3fv(float deg, const float axis[3]); /* axis of rotation should be a unit vector */ +void GPU_matrix_rotate_axis(float deg, char axis); /* TODO: enum for axis? */ -void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ); +void GPU_matrix_look_at(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ); /* TODO: variant that takes eye[3], center[3], up[3] */ /* 2D ModelView Matrix */ -void gpuTranslate2f(float x, float y); -void gpuTranslate2fv(const float vec[2]); -void gpuScale2f(float x, float y); -void gpuScale2fv(const float vec[2]); -void gpuRotate2D(float deg); +void GPU_matrix_translate_2f(float x, float y); +void GPU_matrix_translate_2fv(const float vec[2]); +void GPU_matrix_scale_2f(float x, float y); +void GPU_matrix_scale_2fv(const float vec[2]); +void GPU_matrix_rotate_2d(float deg); /* Projection Matrix (2D or 3D) */ -void gpuPushProjectionMatrix(void); -void gpuPopProjectionMatrix(void); +void GPU_matrix_push_projection(void); +void GPU_matrix_pop_projection(void); /* 3D Projection Matrix */ -void gpuLoadIdentityProjectionMatrix(void); -void gpuLoadProjectionMatrix(const float m[4][4]); +void GPU_matrix_identity_projection_set(void); +void GPU_matrix_projection_set(const float m[4][4]); -void gpuOrtho(float left, float right, float bottom, float top, float near, float far); -void gpuFrustum(float left, float right, float bottom, float top, float near, float far); -void gpuPerspective(float fovy, float aspect, float near, float far); +void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far); +void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far); +void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far); /* 3D Projection between Window and World Space */ -void gpuProject(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]); -bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]); +void GPU_matrix_project(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]); +bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]); /* 2D Projection Matrix */ -void gpuOrtho2D(float left, float right, float bottom, float top); +void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top); /* functions to get matrix values */ -const float (*gpuGetModelViewMatrix(float m[4][4]))[4]; -const float (*gpuGetProjectionMatrix(float m[4][4]))[4]; -const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4]; +const float (*GPU_matrix_model_view_get(float m[4][4]))[4]; +const float (*GPU_matrix_projection_get(float m[4][4]))[4]; +const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]; -const float (*gpuGetNormalMatrix(float m[3][3]))[3]; -const float (*gpuGetNormalMatrixInverse(float m[3][3]))[3]; +const float (*GPU_matrix_normal_get(float m[3][3]))[3]; +const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]; /* set uniform values for currently bound shader */ -void gpuBindMatrices(const struct Gwn_ShaderInterface *); -bool gpuMatricesDirty(void); /* since last bind */ +void GPU_matrix_bind(const struct Gwn_ShaderInterface *); +bool GPU_matrix_dirty_get(void); /* since last bind */ /* Python API needs to be able to inspect the stack so errors raise exceptions instead of crashing. */ @@ -177,14 +177,14 @@ int GPU_matrix_stack_level_get_projection(void); #endif /* C11 */ /* make matrix inputs generic, to avoid warnings */ -# define gpuMultMatrix(x) gpuMultMatrix(_GPU_MAT4_CONST_CAST(x)) -# define gpuLoadMatrix(x) gpuLoadMatrix(_GPU_MAT4_CONST_CAST(x)) -# define gpuLoadProjectionMatrix(x) gpuLoadProjectionMatrix(_GPU_MAT4_CONST_CAST(x)) -# define gpuGetModelViewMatrix(x) gpuGetModelViewMatrix(_GPU_MAT4_CAST(x)) -# define gpuGetProjectionMatrix(x) gpuGetProjectionMatrix(_GPU_MAT4_CAST(x)) -# define gpuGetModelViewProjectionMatrix(x) gpuGetModelViewProjectionMatrix(_GPU_MAT4_CAST(x)) -# define gpuGetNormalMatrix(x) gpuGetNormalMatrix(_GPU_MAT3_CAST(x)) -# define gpuGetNormalMatrixInverse(x) gpuGetNormalMatrixInverse(_GPU_MAT3_CAST(x)) +# define GPU_matrix_mul(x) GPU_matrix_mul(_GPU_MAT4_CONST_CAST(x)) +# define GPU_matrix_set(x) GPU_matrix_set(_GPU_MAT4_CONST_CAST(x)) +# define GPU_matrix_projection_set(x) GPU_matrix_projection_set(_GPU_MAT4_CONST_CAST(x)) +# define GPU_matrix_model_view_get(x) GPU_matrix_model_view_get(_GPU_MAT4_CAST(x)) +# define GPU_matrix_projection_get(x) GPU_matrix_projection_get(_GPU_MAT4_CAST(x)) +# define GPU_matrix_model_view_projection_get(x) GPU_matrix_model_view_projection_get(_GPU_MAT4_CAST(x)) +# define GPU_matrix_normal_get(x) GPU_matrix_normal_get(_GPU_MAT3_CAST(x)) +# define GPU_matrix_normal_inverse_get(x) GPU_matrix_normal_inverse_get(_GPU_MAT3_CAST(x)) #endif /* SUPPRESS_GENERIC_MATRIX_API */ #endif /* __GPU_MATRIX_H__ */ diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c index b6214f2778b..2af1375a620 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.c @@ -86,7 +86,7 @@ static MatrixState state = { #define ProjectionStack state.projection_stack #define Projection ProjectionStack.stack[ProjectionStack.top] -void gpuMatrixReset(void) +void GPU_matrix_reset(void) { state.model_view_stack.top = 0; state.projection_stack.top = 0; @@ -119,76 +119,76 @@ static void checkmat(cosnt float *m) #endif -void gpuPushMatrix(void) +void GPU_matrix_push(void) { BLI_assert(ModelViewStack.top + 1 < MATRIX_STACK_DEPTH); ModelViewStack.top++; copy_m4_m4(ModelView, ModelViewStack.stack[ModelViewStack.top - 1]); } -void gpuPopMatrix(void) +void GPU_matrix_pop(void) { BLI_assert(ModelViewStack.top > 0); ModelViewStack.top--; state.dirty = true; } -void gpuPushProjectionMatrix(void) +void GPU_matrix_push_projection(void) { BLI_assert(ProjectionStack.top + 1 < MATRIX_STACK_DEPTH); ProjectionStack.top++; copy_m4_m4(Projection, ProjectionStack.stack[ProjectionStack.top - 1]); } -void gpuPopProjectionMatrix(void) +void GPU_matrix_pop_projection(void) { BLI_assert(ProjectionStack.top > 0); ProjectionStack.top--; state.dirty = true; } -void gpuLoadMatrix(const float m[4][4]) +void GPU_matrix_set(const float m[4][4]) { copy_m4_m4(ModelView, m); CHECKMAT(ModelView3D); state.dirty = true; } -void gpuLoadIdentityProjectionMatrix(void) +void GPU_matrix_identity_projection_set(void) { unit_m4(Projection); CHECKMAT(Projection3D); state.dirty = true; } -void gpuLoadProjectionMatrix(const float m[4][4]) +void GPU_matrix_projection_set(const float m[4][4]) { copy_m4_m4(Projection, m); CHECKMAT(Projection3D); state.dirty = true; } -void gpuLoadIdentity(void) +void GPU_matrix_identity_set(void) { unit_m4(ModelView); state.dirty = true; } -void gpuTranslate2f(float x, float y) +void GPU_matrix_translate_2f(float x, float y) { Mat4 m; unit_m4(m); m[3][0] = x; m[3][1] = y; - gpuMultMatrix(m); + GPU_matrix_mul(m); } -void gpuTranslate2fv(const float vec[2]) +void GPU_matrix_translate_2fv(const float vec[2]) { - gpuTranslate2f(vec[0], vec[1]); + GPU_matrix_translate_2f(vec[0], vec[1]); } -void gpuTranslate3f(float x, float y, float z) +void GPU_matrix_translate_3f(float x, float y, float z) { #if 1 translate_m4(ModelView, x, y, z); @@ -199,61 +199,61 @@ void gpuTranslate3f(float x, float y, float z) m[3][0] = x; m[3][1] = y; m[3][2] = z; - gpuMultMatrix(m); + GPU_matrix_mul(m); #endif state.dirty = true; } -void gpuTranslate3fv(const float vec[3]) +void GPU_matrix_translate_3fv(const float vec[3]) { - gpuTranslate3f(vec[0], vec[1], vec[2]); + GPU_matrix_translate_3f(vec[0], vec[1], vec[2]); } -void gpuScaleUniform(float factor) +void GPU_matrix_scale_1f(float factor) { Mat4 m; scale_m4_fl(m, factor); - gpuMultMatrix(m); + GPU_matrix_mul(m); } -void gpuScale2f(float x, float y) +void GPU_matrix_scale_2f(float x, float y) { Mat4 m = {{0.0f}}; m[0][0] = x; m[1][1] = y; m[2][2] = 1.0f; m[3][3] = 1.0f; - gpuMultMatrix(m); + GPU_matrix_mul(m); } -void gpuScale2fv(const float vec[2]) +void GPU_matrix_scale_2fv(const float vec[2]) { - gpuScale2f(vec[0], vec[1]); + GPU_matrix_scale_2f(vec[0], vec[1]); } -void gpuScale3f(float x, float y, float z) +void GPU_matrix_scale_3f(float x, float y, float z) { Mat4 m = {{0.0f}}; m[0][0] = x; m[1][1] = y; m[2][2] = z; m[3][3] = 1.0f; - gpuMultMatrix(m); + GPU_matrix_mul(m); } -void gpuScale3fv(const float vec[3]) +void GPU_matrix_scale_3fv(const float vec[3]) { - gpuScale3f(vec[0], vec[1], vec[2]); + GPU_matrix_scale_3f(vec[0], vec[1], vec[2]); } -void gpuMultMatrix(const float m[4][4]) +void GPU_matrix_mul(const float m[4][4]) { mul_m4_m4_post(ModelView, m); CHECKMAT(ModelView); state.dirty = true; } -void gpuRotate2D(float deg) +void GPU_matrix_rotate_2d(float deg) { /* essentially RotateAxis('Z') * TODO: simpler math for 2D case @@ -261,20 +261,20 @@ void gpuRotate2D(float deg) rotate_m4(ModelView, 'Z', DEG2RADF(deg)); } -void gpuRotate3f(float deg, float x, float y, float z) +void GPU_matrix_rotate_3f(float deg, float x, float y, float z) { const float axis[3] = {x, y, z}; - gpuRotate3fv(deg, axis); + GPU_matrix_rotate_3fv(deg, axis); } -void gpuRotate3fv(float deg, const float axis[3]) +void GPU_matrix_rotate_3fv(float deg, const float axis[3]) { Mat4 m; axis_angle_to_mat4(m, axis, DEG2RADF(deg)); - gpuMultMatrix(m); + GPU_matrix_mul(m); } -void gpuRotateAxis(float deg, char axis) +void GPU_matrix_rotate_axis(float deg, char axis) { /* rotate_m4 works in place */ rotate_m4(ModelView, axis, DEG2RADF(deg)); @@ -398,14 +398,14 @@ static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3 state.dirty = true; } -void gpuOrtho(float left, float right, float bottom, float top, float near, float far) +void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far) { mat4_ortho_set(Projection, left, right, bottom, top, near, far); CHECKMAT(Projection); state.dirty = true; } -void gpuOrtho2D(float left, float right, float bottom, float top) +void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top) { Mat4 m; mat4_ortho_set(m, left, right, bottom, top, -1.0f, 1.0f); @@ -413,21 +413,21 @@ void gpuOrtho2D(float left, float right, float bottom, float top) state.dirty = true; } -void gpuFrustum(float left, float right, float bottom, float top, float near, float far) +void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far) { mat4_frustum_set(Projection, left, right, bottom, top, near, far); CHECKMAT(Projection); state.dirty = true; } -void gpuPerspective(float fovy, float aspect, float near, float far) +void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far) { float half_height = tanf(fovy * (float)(M_PI / 360.0)) * near; float half_width = half_height * aspect; - gpuFrustum(-half_width, +half_width, -half_height, +half_height, near, far); + GPU_matrix_frustum_set(-half_width, +half_width, -half_height, +half_height, near, far); } -void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) +void GPU_matrix_look_at(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) { Mat4 cm; float lookdir[3]; @@ -439,11 +439,11 @@ void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, mat4_look_from_origin(cm, lookdir, camup); - gpuMultMatrix(cm); - gpuTranslate3f(-eyeX, -eyeY, -eyeZ); + GPU_matrix_mul(cm); + GPU_matrix_translate_3f(-eyeX, -eyeY, -eyeZ); } -void gpuProject(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]) +void GPU_matrix_project(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]) { float v[4]; @@ -459,7 +459,7 @@ void gpuProject(const float world[3], const float model[4][4], const float proj[ win[2] = (v[2] + 1) * 0.5f; } -bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]) +bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]) { float pm[4][4]; float in[4]; @@ -497,7 +497,7 @@ bool gpuUnProject(const float win[3], const float model[4][4], const float proj[ return true; } -const float (*gpuGetModelViewMatrix(float m[4][4]))[4] +const float (*GPU_matrix_model_view_get(float m[4][4]))[4] { if (m) { copy_m4_m4(m, ModelView); @@ -508,7 +508,7 @@ const float (*gpuGetModelViewMatrix(float m[4][4]))[4] } } -const float (*gpuGetProjectionMatrix(float m[4][4]))[4] +const float (*GPU_matrix_projection_get(float m[4][4]))[4] { if (m) { copy_m4_m4(m, Projection); @@ -519,7 +519,7 @@ const float (*gpuGetProjectionMatrix(float m[4][4]))[4] } } -const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4] +const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4] { if (m == NULL) { static Mat4 temp; @@ -530,14 +530,14 @@ const float (*gpuGetModelViewProjectionMatrix(float m[4][4]))[4] return m; } -const float (*gpuGetNormalMatrix(float m[3][3]))[3] +const float (*GPU_matrix_normal_get(float m[3][3]))[3] { if (m == NULL) { static Mat3 temp3; m = temp3; } - copy_m3_m4(m, (const float (*)[4])gpuGetModelViewMatrix(NULL)); + copy_m3_m4(m, (const float (*)[4])GPU_matrix_model_view_get(NULL)); invert_m3(m); transpose_m3(m); @@ -545,20 +545,20 @@ const float (*gpuGetNormalMatrix(float m[3][3]))[3] return m; } -const float (*gpuGetNormalMatrixInverse(float m[3][3]))[3] +const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3] { if (m == NULL) { static Mat3 temp3; m = temp3; } - gpuGetNormalMatrix(m); + GPU_matrix_normal_get(m); invert_m3(m); return m; } -void gpuBindMatrices(const Gwn_ShaderInterface *shaderface) +void GPU_matrix_bind(const Gwn_ShaderInterface *shaderface) { /* set uniform values to matrix stack values * call this before a draw call if desired matrices are dirty @@ -578,7 +578,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface) puts("setting MV matrix"); #endif - glUniformMatrix4fv(MV->location, 1, GL_FALSE, (const float *)gpuGetModelViewMatrix(NULL)); + glUniformMatrix4fv(MV->location, 1, GL_FALSE, (const float *)GPU_matrix_model_view_get(NULL)); } if (P) { @@ -586,7 +586,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface) puts("setting P matrix"); #endif - glUniformMatrix4fv(P->location, 1, GL_FALSE, (const float *)gpuGetProjectionMatrix(NULL)); + glUniformMatrix4fv(P->location, 1, GL_FALSE, (const float *)GPU_matrix_projection_get(NULL)); } if (MVP) { @@ -594,7 +594,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface) puts("setting MVP matrix"); #endif - glUniformMatrix4fv(MVP->location, 1, GL_FALSE, (const float *)gpuGetModelViewProjectionMatrix(NULL)); + glUniformMatrix4fv(MVP->location, 1, GL_FALSE, (const float *)GPU_matrix_model_view_projection_get(NULL)); } if (N) { @@ -602,19 +602,19 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface) puts("setting normal matrix"); #endif - glUniformMatrix3fv(N->location, 1, GL_FALSE, (const float *)gpuGetNormalMatrix(NULL)); + glUniformMatrix3fv(N->location, 1, GL_FALSE, (const float *)GPU_matrix_normal_get(NULL)); } if (MV_inv) { Mat4 m; - gpuGetModelViewMatrix(m); + GPU_matrix_model_view_get(m); invert_m4(m); glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float *)m); } if (P_inv) { Mat4 m; - gpuGetProjectionMatrix(m); + GPU_matrix_projection_get(m); invert_m4(m); glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float *)m); } @@ -622,7 +622,7 @@ void gpuBindMatrices(const Gwn_ShaderInterface *shaderface) state.dirty = false; } -bool gpuMatricesDirty(void) +bool GPU_matrix_dirty_get(void) { return state.dirty; } diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 8c978be81c1..99baaa1164f 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -532,7 +532,7 @@ void GPU_shader_bind(GPUShader *shader) BLI_assert(shader && shader->program); glUseProgram(shader->program); - gpuBindMatrices(shader->interface); + GPU_matrix_bind(shader->interface); } void GPU_shader_unbind(void) diff --git a/source/blender/python/intern/gpu_py_matrix.c b/source/blender/python/intern/gpu_py_matrix.c index 68b08dfb324..2ab6fd864eb 100644 --- a/source/blender/python/intern/gpu_py_matrix.c +++ b/source/blender/python/intern/gpu_py_matrix.c @@ -102,7 +102,7 @@ static PyObject *pygpu_matrix_push(PyObject *UNUSED(self)) if (!pygpu_stack_is_push_model_view_ok_or_error()) { return NULL; } - gpuPushMatrix(); + GPU_matrix_push(); Py_RETURN_NONE; } @@ -116,7 +116,7 @@ static PyObject *pygpu_matrix_pop(PyObject *UNUSED(self)) if (!pygpu_stack_is_pop_model_view_ok_or_error()) { return NULL; } - gpuPopMatrix(); + GPU_matrix_pop(); Py_RETURN_NONE; } @@ -130,7 +130,7 @@ static PyObject *pygpu_matrix_push_projection(PyObject *UNUSED(self)) if (!pygpu_stack_is_push_projection_ok_or_error()) { return NULL; } - gpuPushProjectionMatrix(); + GPU_matrix_push_projection(); Py_RETURN_NONE; } @@ -144,7 +144,7 @@ static PyObject *pygpu_matrix_pop_projection(PyObject *UNUSED(self)) if (!pygpu_stack_is_pop_projection_ok_or_error()) { return NULL; } - gpuPopProjectionMatrix(); + GPU_matrix_pop_projection(); Py_RETURN_NONE; } @@ -197,14 +197,14 @@ static PyObject *pygpu_matrix_stack_context_enter(BPy_GPU_MatrixStackContext *se if (!pygpu_stack_is_push_model_view_ok_or_error()) { return NULL; } - gpuPushMatrix(); + GPU_matrix_push(); self->level = GPU_matrix_stack_level_get_model_view(); } else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) { if (!pygpu_stack_is_push_projection_ok_or_error()) { return NULL; } - gpuPushProjectionMatrix(); + GPU_matrix_push_projection(); self->level = GPU_matrix_stack_level_get_projection(); } else { @@ -227,7 +227,7 @@ static PyObject *pygpu_matrix_stack_context_exit(BPy_GPU_MatrixStackContext *sel fprintf(stderr, "Level push/pop mismatch, expected %d, got %d\n", self->level, level); } if (level != 0) { - gpuPopMatrix(); + GPU_matrix_pop(); } } else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) { @@ -236,7 +236,7 @@ static PyObject *pygpu_matrix_stack_context_exit(BPy_GPU_MatrixStackContext *sel fprintf(stderr, "Level push/pop mismatch, expected %d, got %d", self->level, level); } if (level != 0) { - gpuPopProjectionMatrix(); + GPU_matrix_pop_projection(); } } else { @@ -294,7 +294,7 @@ static PyObject *pygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject * if (!Matrix_Parse4x4(value, &pymat)) { return NULL; } - gpuMultMatrix(pymat->matrix); + GPU_matrix_mul(pymat->matrix); Py_RETURN_NONE; } @@ -314,10 +314,10 @@ static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value) return NULL; } if (len == 2) { - gpuScale2fv(scale); + GPU_matrix_scale_2fv(scale); } else { - gpuScale3fv(scale); + GPU_matrix_scale_3fv(scale); } Py_RETURN_NONE; } @@ -337,7 +337,7 @@ static PyObject *pygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *va Py_TYPE(value)->tp_name); return NULL; } - gpuScaleUniform(scalar); + GPU_matrix_scale_1f(scalar); Py_RETURN_NONE; } @@ -357,10 +357,10 @@ static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value) return NULL; } if (len == 2) { - gpuTranslate2fv(offset); + GPU_matrix_translate_2fv(offset); } else { - gpuTranslate3fv(offset); + GPU_matrix_translate_3fv(offset); } Py_RETURN_NONE; } @@ -378,7 +378,7 @@ PyDoc_STRVAR(pygpu_matrix_reset_doc, ); static PyObject *pygpu_matrix_reset(PyObject *UNUSED(self)) { - gpuMatrixReset(); + GPU_matrix_reset(); Py_RETURN_NONE; } @@ -389,7 +389,7 @@ PyDoc_STRVAR(pygpu_matrix_load_identity_doc, ); static PyObject *pygpu_matrix_load_identity(PyObject *UNUSED(self)) { - gpuLoadIdentity(); + GPU_matrix_identity_set(); Py_RETURN_NONE; } @@ -407,7 +407,7 @@ static PyObject *pygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *valu if (!Matrix_Parse4x4(value, &pymat)) { return NULL; } - gpuLoadMatrix(pymat->matrix); + GPU_matrix_set(pymat->matrix); Py_RETURN_NONE; } @@ -428,7 +428,7 @@ PyDoc_STRVAR(pygpu_matrix_get_projection_matrix_doc, static PyObject *pygpu_matrix_get_projection_matrix(PyObject *UNUSED(self)) { float matrix[4][4]; - gpuGetModelViewMatrix(matrix); + GPU_matrix_model_view_get(matrix); return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL); } @@ -444,7 +444,7 @@ PyDoc_STRVAR(pygpu_matrix_get_modal_view_matrix_doc, static PyObject *pygpu_matrix_get_modal_view_matrix(PyObject *UNUSED(self)) { float matrix[4][4]; - gpuGetProjectionMatrix(matrix); + GPU_matrix_projection_get(matrix); return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL); } @@ -459,7 +459,7 @@ PyDoc_STRVAR(pygpu_matrix_get_normal_matrix_doc, static PyObject *pygpu_matrix_get_normal_matrix(PyObject *UNUSED(self)) { float matrix[3][3]; - gpuGetNormalMatrix(matrix); + GPU_matrix_normal_get(matrix); return Matrix_CreatePyObject(&matrix[0][0], 3, 3, NULL); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 5cf9ac625c3..64aa64e1478 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2118,8 +2118,8 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph /* set up rotation if available */ if (rc->rot_prop) { rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop); - gpuPushMatrix(); - gpuRotate2D(RAD2DEGF(rot)); + GPU_matrix_push(); + GPU_matrix_rotate_2d(RAD2DEGF(rot)); } /* draw textured quad */ @@ -2141,7 +2141,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph /* undo rotation */ if (rc->rot_prop) - gpuPopMatrix(); + GPU_matrix_pop(); } else { /* flat color if no texture available */ @@ -2208,7 +2208,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void /* Keep cursor in the original place */ x = rc->initial_mouse[0]; y = rc->initial_mouse[1]; - gpuTranslate2f((float)x, (float)y); + GPU_matrix_translate_2f((float)x, (float)y); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -2216,7 +2216,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void /* apply zoom if available */ if (rc->zoom_prop) { RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); - gpuScale2fv(zoom); + GPU_matrix_scale_2fv(zoom); } /* draw rotated texture */ @@ -2233,23 +2233,23 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void immUniformColor3fvAlpha(col, 0.5f); if (rc->subtype == PROP_ANGLE) { - gpuPushMatrix(); + GPU_matrix_push(); /* draw original angle line */ - gpuRotate2D(RAD2DEGF(rc->initial_value)); + GPU_matrix_rotate_2d(RAD2DEGF(rc->initial_value)); immBegin(GWN_PRIM_LINES, 2); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immEnd(); /* draw new angle line */ - gpuRotate2D(RAD2DEGF(rc->current_value - rc->initial_value)); + GPU_matrix_rotate_2d(RAD2DEGF(rc->current_value - rc->initial_value)); immBegin(GWN_PRIM_LINES, 2); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immEnd(); - gpuPopMatrix(); + GPU_matrix_pop(); } /* draw circles on top */ diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 003932930ed..7ddc87a2524 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -201,8 +201,8 @@ static void playanim_window_get_size(int *r_width, int *r_height) static void playanim_gl_matrix(void) { /* unified matrix, note it affects offset for drawing */ - /* note! cannot use gpuOrtho2D here because shader ignores. */ - gpuOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0, 1.0f); + /* note! cannot use GPU_matrix_ortho_2d_set here because shader ignores. */ + GPU_matrix_ortho_set(0.0f, 1.0f, 0.0f, 1.0f, -1.0, 1.0f); } /* implementation */ @@ -366,10 +366,10 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf float fac = ps->picture->frame / (double)(((PlayAnimPict *)picsbase.last)->frame - ((PlayAnimPict *)picsbase.first)->frame); fac = 2.0f * fac - 1.0f; - gpuPushProjectionMatrix(); - gpuLoadIdentityProjectionMatrix(); - gpuPushMatrix(); - gpuLoadIdentity(); + GPU_matrix_push_projection(); + GPU_matrix_identity_projection_set(); + GPU_matrix_push(); + GPU_matrix_identity_set(); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -383,8 +383,8 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf immUnbindProgram(); - gpuPopMatrix(); - gpuPopProjectionMatrix(); + GPU_matrix_pop(); + GPU_matrix_pop_projection(); } GHOST_SwapWindowBuffers(g_WS.ghost_window); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index f55eee69f71..ff3c712dae0 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -50,7 +50,7 @@ void wmViewport(const rcti *winrct) glScissor(winrct->xmin, winrct->ymin, width, height); wmOrtho2_pixelspace(width, height); - gpuLoadIdentity(); + GPU_matrix_identity_set(); } void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct) @@ -89,7 +89,7 @@ void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct glScissor(x, y, scissor_width, scissor_height); wmOrtho2_pixelspace(width, height); - gpuLoadIdentity(); + GPU_matrix_identity_set(); } void wmWindowViewport(wmWindow *win) @@ -101,7 +101,7 @@ void wmWindowViewport(wmWindow *win) glScissor(0, 0, width, height); wmOrtho2_pixelspace(width, height); - gpuLoadIdentity(); + GPU_matrix_identity_set(); } void wmOrtho2(float x1, float x2, float y1, float y2) @@ -110,7 +110,7 @@ void wmOrtho2(float x1, float x2, float y1, float y2) if (x1 == x2) x2 += 1.0f; if (y1 == y2) y2 += 1.0f; - gpuOrtho(x1, x2, y1, y2, -100, 100); + GPU_matrix_ortho_set(x1, x2, y1, y2, -100, 100); } static void wmOrtho2_offset(const float x, const float y, const float ofs) -- cgit v1.2.3 From edbb2d22791f04af6b775f5d46321f533c705781 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 15 Jul 2018 18:34:31 +0200 Subject: Fix Cycles incorrect resize and CMYK conversion of uint16/half images. --- intern/cycles/render/image.cpp | 37 +++++++++++--------- intern/cycles/util/util_half.h | 2 +- intern/cycles/util/util_image.h | 62 +++++++++++++++++++++++++++++++++ intern/cycles/util/util_image_impl.h | 66 ++---------------------------------- 4 files changed, 86 insertions(+), 81 deletions(-) diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 7f0660cee07..27d6ae78289 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -33,15 +33,15 @@ CCL_NAMESPACE_BEGIN /* Some helpers to silence warning in templated function. */ static bool isfinite(uchar /*value*/) { - return false; + return true; } static bool isfinite(half /*value*/) { - return false; + return true; } static bool isfinite(uint16_t /*value*/) { - return false; + return true; } ImageManager::ImageManager(const DeviceInfo& info) @@ -508,7 +508,6 @@ bool ImageManager::file_load_image(Image *img, int texture_limit, device_vector& tex_img) { - const StorageType alpha_one = (FileFormat == TypeDesc::UINT8)? 255 : 1; ImageInput *in = NULL; if(!file_load_image_generic(img, &in)) { return false; @@ -601,13 +600,19 @@ bool ImageManager::file_load_image(Image *img, type == IMAGE_DATA_TYPE_BYTE4 || type == IMAGE_DATA_TYPE_USHORT4); if(is_rgba) { + const StorageType one = util_image_cast_from_float(1.0f); + if(cmyk) { /* CMYK */ for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) { - pixels[i*4+2] = (pixels[i*4+2]*pixels[i*4+3])/255; - pixels[i*4+1] = (pixels[i*4+1]*pixels[i*4+3])/255; - pixels[i*4+0] = (pixels[i*4+0]*pixels[i*4+3])/255; - pixels[i*4+3] = alpha_one; + float c = util_image_cast_to_float(pixels[i*4+0]); + float m = util_image_cast_to_float(pixels[i*4+1]); + float y = util_image_cast_to_float(pixels[i*4+2]); + float k = util_image_cast_to_float(pixels[i*4+3]); + pixels[i*4+0] = util_image_cast_from_float((1.0f - c) * (1.0f - k)); + pixels[i*4+1] = util_image_cast_from_float((1.0f - m) * (1.0f - k)); + pixels[i*4+2] = util_image_cast_from_float((1.0f - y) * (1.0f - k)); + pixels[i*4+3] = one; } } else if(components == 2) { @@ -622,7 +627,7 @@ bool ImageManager::file_load_image(Image *img, else if(components == 3) { /* RGB */ for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) { - pixels[i*4+3] = alpha_one; + pixels[i*4+3] = one; pixels[i*4+2] = pixels[i*3+2]; pixels[i*4+1] = pixels[i*3+1]; pixels[i*4+0] = pixels[i*3+0]; @@ -631,7 +636,7 @@ bool ImageManager::file_load_image(Image *img, else if(components == 1) { /* grayscale */ for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) { - pixels[i*4+3] = alpha_one; + pixels[i*4+3] = one; pixels[i*4+2] = pixels[i]; pixels[i*4+1] = pixels[i]; pixels[i*4+0] = pixels[i]; @@ -639,7 +644,7 @@ bool ImageManager::file_load_image(Image *img, } if(img->use_alpha == false) { for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) { - pixels[i*4+3] = alpha_one; + pixels[i*4+3] = one; } } } @@ -871,7 +876,7 @@ void ImageManager::device_load_image(Device *device, thread_scoped_lock device_lock(device_mutex); uint16_t *pixels = (uint16_t*)tex_img->alloc(1, 1); - pixels[0] = TEX_IMAGE_MISSING_R; + pixels[0] = (TEX_IMAGE_MISSING_R * 65535); } img->mem = tex_img; @@ -893,10 +898,10 @@ void ImageManager::device_load_image(Device *device, thread_scoped_lock device_lock(device_mutex); uint16_t *pixels = (uint16_t*)tex_img->alloc(1, 1); - pixels[0] = TEX_IMAGE_MISSING_R; - pixels[1] = TEX_IMAGE_MISSING_G; - pixels[2] = TEX_IMAGE_MISSING_B; - pixels[3] = TEX_IMAGE_MISSING_A; + pixels[0] = (TEX_IMAGE_MISSING_R * 65535); + pixels[1] = (TEX_IMAGE_MISSING_G * 65535); + pixels[2] = (TEX_IMAGE_MISSING_B * 65535); + pixels[3] = (TEX_IMAGE_MISSING_A * 65535); } img->mem = tex_img; diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h index 58f3f903619..53b7f2472bd 100644 --- a/intern/cycles/util/util_half.h +++ b/intern/cycles/util/util_half.h @@ -42,7 +42,7 @@ public: half() : v(0) {} half(const unsigned short& i) : v(i) {} operator unsigned short() { return v; } - half & operator =(const unsigned short& i) { v = i; return *this; } + half& operator =(const unsigned short& i) { v = i; return *this; } private: unsigned short v; }; diff --git a/intern/cycles/util/util_image.h b/intern/cycles/util/util_image.h index 18876841b5b..85bdb0d8050 100644 --- a/intern/cycles/util/util_image.h +++ b/intern/cycles/util/util_image.h @@ -38,6 +38,68 @@ void util_image_resize_pixels(const vector& input_pixels, size_t *output_height, size_t *output_depth); +/* Cast input pixel from unknown storage to float. */ +template +inline float util_image_cast_to_float(T value); + +template<> +inline float util_image_cast_to_float(float value) +{ + return value; +} +template<> +inline float util_image_cast_to_float(uchar value) +{ + return (float)value / 255.0f; +} +template<> +inline float util_image_cast_to_float(uint16_t value) +{ + return (float)value / 65535.0f; +} +template<> +inline float util_image_cast_to_float(half value) +{ + return half_to_float(value); +} + +/* Cast float value to output pixel type. */ +template +inline T util_image_cast_from_float(float value); + +template<> +inline float util_image_cast_from_float(float value) +{ + return value; +} +template<> +inline uchar util_image_cast_from_float(float value) +{ + if(value < 0.0f) { + return 0; + } + else if(value > (1.0f - 0.5f / 255.0f)) { + return 255; + } + return (uchar)((255.0f * value) + 0.5f); +} +template<> +inline uint16_t util_image_cast_from_float(float value) +{ + if(value < 0.0f) { + return 0; + } + else if(value > (1.0f - 0.5f / 65535.0f)) { + return 65535; + } + return (uint16_t)((65535.0f * value) + 0.5f); +} +template<> +inline half util_image_cast_from_float(float value) +{ + return float_to_half(value); +} + CCL_NAMESPACE_END #endif /* __UTIL_IMAGE_H__ */ diff --git a/intern/cycles/util/util_image_impl.h b/intern/cycles/util/util_image_impl.h index fb953a43ab2..5bc1c727595 100644 --- a/intern/cycles/util/util_image_impl.h +++ b/intern/cycles/util/util_image_impl.h @@ -38,68 +38,6 @@ const T *util_image_read(const vector& pixels, return &pixels[index]; } -/* Cast input pixel from unknown storage to float. */ -template -inline float cast_to_float(T value); - -template<> -inline float cast_to_float(float value) -{ - return value; -} -template<> -inline float cast_to_float(uchar value) -{ - return (float)value / 255.0f; -} -template<> -inline float cast_to_float(uint16_t value) -{ - return (float)value / 65535.0f; -} -template<> -inline float cast_to_float(half value) -{ - return half_to_float(value); -} - -/* Cast float value to output pixel type. */ -template -inline T cast_from_float(float value); - -template<> -inline float cast_from_float(float value) -{ - return value; -} -template<> -inline uchar cast_from_float(float value) -{ - if(value < 0.0f) { - return 0; - } - else if(value > (1.0f - 0.5f / 255.0f)) { - return 255; - } - return (uchar)((255.0f * value) + 0.5f); -} -template<> -inline uint16_t cast_from_float(float value) -{ - if(value < 0.0f) { - return 0; - } - else if(value >(1.0f - 0.5f / 65535.0f)) { - return 65535; - } - return (uchar)((65535.0f * value) + 0.5f); -} -template<> -inline half cast_from_float(float value) -{ - return float_to_half(value); -} - template void util_image_downscale_sample(const vector& pixels, const size_t width, @@ -133,7 +71,7 @@ void util_image_downscale_sample(const vector& pixels, components, nx, ny, nz); for(size_t k = 0; k < components; ++k) { - accum[k] += cast_to_float(pixel[k]); + accum[k] += util_image_cast_to_float(pixel[k]); } ++count; } @@ -142,7 +80,7 @@ void util_image_downscale_sample(const vector& pixels, if(count != 0) { const float inv_count = 1.0f / (float)count; for(size_t k = 0; k < components; ++k) { - result[k] = cast_from_float(accum[k] * inv_count); + result[k] = util_image_cast_from_float(accum[k] * inv_count); } } else { -- cgit v1.2.3 From b29b73a67eca3e5ac71c4b7c89f25bf3fb694cc3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jul 2018 19:49:07 +0200 Subject: Gizmo: update Python templates --- doc/python_api/sphinx_doc_gen.py | 6 +++--- release/scripts/startup/bl_ui/space_toolsystem_common.py | 2 +- release/scripts/startup/bl_ui/space_view3d.py | 2 +- release/scripts/templates_py/gizmo_operator_target.py | 2 +- release/scripts/templates_py/gizmo_simple.py | 2 +- source/blender/editors/gpencil/gpencil_brush.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index bfa8a295f5b..6c631891418 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -334,9 +334,9 @@ except ImportError: # to avoid having to match Blender's source tree. EXTRA_SOURCE_FILES = ( "../../../release/scripts/templates_py/bmesh_simple.py", - "../../../release/scripts/templates_py/manipulator_operator.py", - "../../../release/scripts/templates_py/manipulator_operator_target.py", - "../../../release/scripts/templates_py/manipulator_simple.py", + "../../../release/scripts/templates_py/gizmo_operator.py", + "../../../release/scripts/templates_py/gizmo_operator_target.py", + "../../../release/scripts/templates_py/gizmo_simple.py", "../../../release/scripts/templates_py/operator_simple.py", "../../../release/scripts/templates_py/ui_panel_simple.py", "../../../release/scripts/templates_py/ui_previews_custom_icon.py", diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 4c954874f0d..4f6e42d4a98 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -74,7 +74,7 @@ ToolDef = namedtuple( "icon", # An optional cursor to use when this tool is active. "cursor", - # An optional manipulator group to activate when the tool is set or None for no widget. + # An optional gizmo group to activate when the tool is set or None for no gizmo. "widget", # Optional keymap for tool, either: # - A function that populates a keymaps passed in as an argument. diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 682af76500b..36bfe5ec65e 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -51,7 +51,7 @@ class VIEW3D_HT_header(Header): layout.template_header_3D_mode() - # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode... + # Contains buttons like Mode, Pivot, Layer, Mesh Select Mode... shading_type = view.shading.type shading_item = bpy.types.View3DShading.bl_rna.properties["type"].enum_items[shading_type] diff --git a/release/scripts/templates_py/gizmo_operator_target.py b/release/scripts/templates_py/gizmo_operator_target.py index 28465ad2fa5..606aa6749d0 100644 --- a/release/scripts/templates_py/gizmo_operator_target.py +++ b/release/scripts/templates_py/gizmo_operator_target.py @@ -24,7 +24,7 @@ class MyCameraWidgetGroup(GizmoGroup): def setup(self, context): # Run an operator using the dial gizmo ob = context.object - mpr = self.gizmos.new("GIZMO_GGT_dial_3d") + mpr = self.gizmos.new("GIZMO_GT_dial_3d") props = mpr.target_set_operator("transform.rotate") props.constraint_axis = False, False, True props.constraint_orientation = 'LOCAL' diff --git a/release/scripts/templates_py/gizmo_simple.py b/release/scripts/templates_py/gizmo_simple.py index df80acea0ae..396378da04c 100644 --- a/release/scripts/templates_py/gizmo_simple.py +++ b/release/scripts/templates_py/gizmo_simple.py @@ -25,7 +25,7 @@ class MyLightWidgetGroup(GizmoGroup): def setup(self, context): # Arrow gizmo has one 'offset' property we can assign to the light energy. ob = context.object - mpr = self.gizmos.new("GIZMO_GGT_arrow_3d") + mpr = self.gizmos.new("GIZMO_GT_arrow_3d") mpr.target_set_prop("offset", ob.data, "energy") mpr.matrix_basis = ob.matrix_world.normalized() mpr.draw_style = 'BOX' diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 0ddd8700c09..a8810df35ff 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -1832,7 +1832,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even case DOWNARROWKEY: return OPERATOR_PASS_THROUGH; - /* Camera/View Manipulations - Allowed */ + /* Camera/View Gizmo's - Allowed */ /* (See rationale in gpencil_paint.c -> gpencil_draw_modal()) */ case PAD0: case PAD1: case PAD2: case PAD3: case PAD4: case PAD5: case PAD6: case PAD7: case PAD8: case PAD9: -- cgit v1.2.3 From ab9bd557added48a1f46b9624b874a40b46b71d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jul 2018 20:29:11 +0200 Subject: Cleanup: doxy comments --- source/blender/windowmanager/intern/wm_operator_type.c | 5 +++++ source/blender/windowmanager/intern/wm_playanim.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 62b378e0866..25ca84f3d57 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -96,6 +96,11 @@ void WM_operatortype_iter(GHashIterator *ghi) BLI_ghashIterator_init(ghi, global_ops_hash); } +/** \} */ + +/** \name Operator Type Append + * \{ */ + /* all ops in 1 list (for time being... needs evaluation later) */ void WM_operatortype_append(void (*opfunc)(wmOperatorType *)) { diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index b4f2435ee2d..f2c24858e17 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -28,8 +28,11 @@ /** \file blender/windowmanager/intern/wm_playanim.c * \ingroup wm * + * Animation player for image sequences & video's with sound support. + * Launched in a separate process from Blender's #RENDER_OT_play_rendered_anim + * * \note This file uses ghost directly and none of the WM definitions. - * this could be made into its own module, alongside creator/ + * this could be made into its own module, alongside creator. */ #include -- cgit v1.2.3 From d9203820467665ba19e1956e035de663849e695c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 09:28:05 +0200 Subject: OpenSubdiv: Re-work C-API integration Main goal is to make API simpler to follow (at least ion terms what is defined/declared where, as opposite of handful big headers which includes all the declarations), and also avoid a big set of long and obscure functions. Now C-API files are split into smaller ones, following OpenSubdiv behavior more closely, and also function pointers in structures used a lot more, which shortens functions names, UV integration part in GL Mesh is mainly stripped away, it needs to be done differently. On a related topic, UV coordinates API in converter needs to be removed as well, we do not need coordinates, only island connectivity information there. Additional changes: - Varying interpolation in evaluator API are temporarily disabled, need to extend API somewhere (probably, evaluator's API) to inform layout information of vertex data (whether it contains varying data, width, stride and such). - Evaluator now can interpolate face-varying data. Only works for adaptive refiner, since some issues in OpenSubdiv itself. Planned changes: - Remove uv coordinates from TopologyConverter. - Support evaluation of patches (as opposite to individual coordinates as it happens currently). - Support more flexible layout of varying and face-varying data. It is stupid to assume varying is 3 floats and face-varying 2 floats. - Support of second order derivatives. - Everything else what i'm missing in this list. --- intern/opensubdiv/CMakeLists.txt | 48 +- .../opensubdiv/gpu_shader_opensubdiv_fragment.glsl | 172 ----- .../opensubdiv/gpu_shader_opensubdiv_geometry.glsl | 154 ---- .../opensubdiv/gpu_shader_opensubdiv_vertex.glsl | 46 -- intern/opensubdiv/internal/opensubdiv.cc | 99 +++ .../internal/opensubdiv_converter_factory.cc | 438 ++++++++++++ .../internal/opensubdiv_converter_factory.h | 37 + .../internal/opensubdiv_converter_internal.cc | 70 ++ .../internal/opensubdiv_converter_internal.h | 50 ++ .../internal/opensubdiv_converter_orient.cc | 66 ++ .../internal/opensubdiv_converter_orient.h | 50 ++ .../internal/opensubdiv_converter_orient_impl.h | 66 ++ .../internal/opensubdiv_device_context_cuda.cc | 226 ++++++ .../internal/opensubdiv_device_context_cuda.h | 54 ++ .../internal/opensubdiv_device_context_opencl.cc | 269 +++++++ .../internal/opensubdiv_device_context_opencl.h | 52 ++ intern/opensubdiv/internal/opensubdiv_evaluator.cc | 154 ++++ .../internal/opensubdiv_evaluator_internal.cc | 734 +++++++++++++++++++ .../internal/opensubdiv_evaluator_internal.h | 134 ++++ intern/opensubdiv/internal/opensubdiv_gl_mesh.cc | 287 ++++++++ .../opensubdiv/internal/opensubdiv_gl_mesh_draw.cc | 587 +++++++++++++++ .../opensubdiv/internal/opensubdiv_gl_mesh_draw.h | 39 + .../opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc | 175 +++++ .../opensubdiv/internal/opensubdiv_gl_mesh_fvar.h | 57 ++ .../internal/opensubdiv_gl_mesh_internal.cc | 32 + .../internal/opensubdiv_gl_mesh_internal.h | 43 ++ intern/opensubdiv/internal/opensubdiv_gpu.cc | 788 +++++++++++++++++++++ intern/opensubdiv/internal/opensubdiv_internal.h | 38 + .../internal/opensubdiv_topology_refiner.cc | 315 ++++++++ .../internal/opensubdiv_topology_refiner.h | 41 ++ .../opensubdiv_topology_refiner_internal.cc | 26 + .../opensubdiv_topology_refiner_internal.h | 47 ++ intern/opensubdiv/internal/opensubdiv_util.cc | 61 ++ intern/opensubdiv/internal/opensubdiv_util.h | 39 + intern/opensubdiv/opensubdiv_capi.cc | 441 ------------ intern/opensubdiv/opensubdiv_capi.h | 178 +---- intern/opensubdiv/opensubdiv_capi_type.h | 41 ++ intern/opensubdiv/opensubdiv_converter.cc | 764 -------------------- intern/opensubdiv/opensubdiv_converter_capi.h | 263 +++---- .../opensubdiv/opensubdiv_device_context_cuda.cc | 237 ------- intern/opensubdiv/opensubdiv_device_context_cuda.h | 54 -- .../opensubdiv/opensubdiv_device_context_opencl.cc | 251 ------- .../opensubdiv/opensubdiv_device_context_opencl.h | 58 -- intern/opensubdiv/opensubdiv_evaluator_capi.cc | 516 -------------- intern/opensubdiv/opensubdiv_evaluator_capi.h | 117 +++ intern/opensubdiv/opensubdiv_gl_mesh.h | 40 -- intern/opensubdiv/opensubdiv_gl_mesh_capi.h | 92 +++ intern/opensubdiv/opensubdiv_gpu_capi.cc | 788 --------------------- intern/opensubdiv/opensubdiv_intern.h | 46 -- intern/opensubdiv/opensubdiv_topology_refiner.h | 41 -- .../opensubdiv/opensubdiv_topology_refiner_capi.h | 110 +++ intern/opensubdiv/opensubdiv_utils_capi.cc | 88 --- .../shader/gpu_shader_opensubdiv_fragment.glsl | 172 +++++ .../shader/gpu_shader_opensubdiv_geometry.glsl | 154 ++++ .../shader/gpu_shader_opensubdiv_vertex.glsl | 46 ++ source/blender/blenkernel/intern/CCGSubSurf.c | 6 +- .../blender/blenkernel/intern/CCGSubSurf_intern.h | 4 +- .../blenkernel/intern/CCGSubSurf_opensubdiv.c | 139 ++-- .../intern/CCGSubSurf_opensubdiv_converter.c | 96 +-- 59 files changed, 6120 insertions(+), 4116 deletions(-) delete mode 100644 intern/opensubdiv/gpu_shader_opensubdiv_fragment.glsl delete mode 100644 intern/opensubdiv/gpu_shader_opensubdiv_geometry.glsl delete mode 100644 intern/opensubdiv/gpu_shader_opensubdiv_vertex.glsl create mode 100644 intern/opensubdiv/internal/opensubdiv.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_converter_factory.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_converter_factory.h create mode 100644 intern/opensubdiv/internal/opensubdiv_converter_internal.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_converter_internal.h create mode 100644 intern/opensubdiv/internal/opensubdiv_converter_orient.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_converter_orient.h create mode 100644 intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h create mode 100644 intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_device_context_cuda.h create mode 100644 intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_device_context_opencl.h create mode 100644 intern/opensubdiv/internal/opensubdiv_evaluator.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_evaluator_internal.h create mode 100644 intern/opensubdiv/internal/opensubdiv_gl_mesh.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h create mode 100644 intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h create mode 100644 intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h create mode 100644 intern/opensubdiv/internal/opensubdiv_gpu.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_internal.h create mode 100644 intern/opensubdiv/internal/opensubdiv_topology_refiner.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_topology_refiner.h create mode 100644 intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.h create mode 100644 intern/opensubdiv/internal/opensubdiv_util.cc create mode 100644 intern/opensubdiv/internal/opensubdiv_util.h delete mode 100644 intern/opensubdiv/opensubdiv_capi.cc create mode 100644 intern/opensubdiv/opensubdiv_capi_type.h delete mode 100644 intern/opensubdiv/opensubdiv_converter.cc delete mode 100644 intern/opensubdiv/opensubdiv_device_context_cuda.cc delete mode 100644 intern/opensubdiv/opensubdiv_device_context_cuda.h delete mode 100644 intern/opensubdiv/opensubdiv_device_context_opencl.cc delete mode 100644 intern/opensubdiv/opensubdiv_device_context_opencl.h delete mode 100644 intern/opensubdiv/opensubdiv_evaluator_capi.cc create mode 100644 intern/opensubdiv/opensubdiv_evaluator_capi.h delete mode 100644 intern/opensubdiv/opensubdiv_gl_mesh.h create mode 100644 intern/opensubdiv/opensubdiv_gl_mesh_capi.h delete mode 100644 intern/opensubdiv/opensubdiv_gpu_capi.cc delete mode 100644 intern/opensubdiv/opensubdiv_intern.h delete mode 100644 intern/opensubdiv/opensubdiv_topology_refiner.h create mode 100644 intern/opensubdiv/opensubdiv_topology_refiner_capi.h delete mode 100644 intern/opensubdiv/opensubdiv_utils_capi.cc create mode 100644 intern/opensubdiv/shader/gpu_shader_opensubdiv_fragment.glsl create mode 100644 intern/opensubdiv/shader/gpu_shader_opensubdiv_geometry.glsl create mode 100644 intern/opensubdiv/shader/gpu_shader_opensubdiv_vertex.glsl diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt index 876b5c0181f..887eb399224 100644 --- a/intern/opensubdiv/CMakeLists.txt +++ b/intern/opensubdiv/CMakeLists.txt @@ -34,20 +34,40 @@ set(INC_SYS ) set(SRC - opensubdiv_capi.cc - opensubdiv_converter.cc - opensubdiv_device_context_cuda.cc - opensubdiv_device_context_opencl.cc - opensubdiv_evaluator_capi.cc - opensubdiv_gpu_capi.cc - opensubdiv_utils_capi.cc + internal/opensubdiv.cc + internal/opensubdiv_converter_factory.cc + internal/opensubdiv_converter_internal.cc + internal/opensubdiv_converter_orient.cc + internal/opensubdiv_device_context_cuda.cc + internal/opensubdiv_device_context_opencl.cc + internal/opensubdiv_evaluator.cc + internal/opensubdiv_evaluator_internal.cc + internal/opensubdiv_gl_mesh.cc + internal/opensubdiv_gl_mesh_draw.cc + internal/opensubdiv_gl_mesh_fvar.cc + internal/opensubdiv_gl_mesh_internal.cc + internal/opensubdiv_topology_refiner.cc + internal/opensubdiv_topology_refiner_internal.cc + internal/opensubdiv_util.cc + + internal/opensubdiv_converter_internal.h + internal/opensubdiv_converter_orient.h + internal/opensubdiv_converter_orient_impl.h + internal/opensubdiv_device_context_cuda.h + internal/opensubdiv_device_context_opencl.h + internal/opensubdiv_evaluator_internal.h + internal/opensubdiv_gl_mesh_fvar.h + internal/opensubdiv_gl_mesh_internal.h + internal/opensubdiv_internal.h + internal/opensubdiv_topology_refiner_internal.h + internal/opensubdiv_util.h opensubdiv_capi.h + opensubdiv_capi_type.h opensubdiv_converter_capi.h - opensubdiv_device_context_cuda.h - opensubdiv_device_context_opencl.h - opensubdiv_intern.h - opensubdiv_topology_refiner.h + opensubdiv_evaluator_capi.h + opensubdiv_gl_mesh_capi.h + opensubdiv_topology_refiner_capi.h ) macro(OPENSUBDIV_DEFINE_COMPONENT component) @@ -64,9 +84,9 @@ OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_OPENMP) OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK) OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_COMPUTE) -data_to_c_simple(gpu_shader_opensubdiv_vertex.glsl SRC) -data_to_c_simple(gpu_shader_opensubdiv_geometry.glsl SRC) -data_to_c_simple(gpu_shader_opensubdiv_fragment.glsl SRC) +data_to_c_simple(shader/gpu_shader_opensubdiv_vertex.glsl SRC) +data_to_c_simple(shader/gpu_shader_opensubdiv_geometry.glsl SRC) +data_to_c_simple(shader/gpu_shader_opensubdiv_fragment.glsl SRC) add_definitions(-DGLEW_STATIC) diff --git a/intern/opensubdiv/gpu_shader_opensubdiv_fragment.glsl b/intern/opensubdiv/gpu_shader_opensubdiv_fragment.glsl deleted file mode 100644 index 1e36d549360..00000000000 --- a/intern/opensubdiv/gpu_shader_opensubdiv_fragment.glsl +++ /dev/null @@ -1,172 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin - * - * ***** END GPL LICENSE BLOCK ***** - */ - -struct VertexData { - vec4 position; - vec3 normal; - vec2 uv; -}; - -#define MAX_LIGHTS 8 -#define NUM_SOLID_LIGHTS 3 - -struct LightSource { - vec4 position; - vec4 ambient; - vec4 diffuse; - vec4 specular; - vec4 spotDirection; -#ifdef SUPPORT_COLOR_MATERIAL - float constantAttenuation; - float linearAttenuation; - float quadraticAttenuation; - float spotCutoff; - float spotExponent; - float spotCosCutoff; - float pad, pad2; -#endif -}; - -layout(std140) uniform Lighting { - LightSource lightSource[MAX_LIGHTS]; - int num_enabled_lights; -}; - -uniform vec4 diffuse; -uniform vec4 specular; -uniform float shininess; - -uniform sampler2D texture_buffer; - -in block { - VertexData v; -} inpt; - -void main() -{ -#ifdef WIREFRAME - gl_FragColor = diffuse; -#else - vec3 N = inpt.v.normal; - - if (!gl_FrontFacing) - N = -N; - - /* Compute diffuse and specular lighting. */ - vec3 L_diffuse = vec3(0.0); - vec3 L_specular = vec3(0.0); - -#ifdef USE_LIGHTING -#ifndef USE_COLOR_MATERIAL - /* Assume NUM_SOLID_LIGHTS directional lights. */ - for (int i = 0; i < NUM_SOLID_LIGHTS; i++) { - vec4 Plight = lightSource[i].position; -#ifdef USE_DIRECTIONAL_LIGHT - vec3 l = (Plight.w == 0.0) - ? normalize(Plight.xyz) - : normalize(inpt.v.position.xyz); -#else /* USE_DIRECTIONAL_LIGHT */ - /* TODO(sergey): We can normalize it outside of the shader. */ - vec3 l = normalize(Plight.xyz); -#endif /* USE_DIRECTIONAL_LIGHT */ - vec3 h = normalize(l + vec3(0, 0, 1)); - float d = max(0.0, dot(N, l)); - float s = pow(max(0.0, dot(N, h)), shininess); - L_diffuse += d * lightSource[i].diffuse.rgb; - L_specular += s * lightSource[i].specular.rgb; - } -#else /* USE_COLOR_MATERIAL */ - vec3 varying_position = inpt.v.position.xyz; - vec3 V = (gl_ProjectionMatrix[3][3] == 0.0) ? - normalize(varying_position) : vec3(0.0, 0.0, -1.0); - for (int i = 0; i < num_enabled_lights; i++) { - /* todo: this is a slow check for disabled lights */ - if (lightSource[i].specular.a == 0.0) - continue; - - float intensity = 1.0; - vec3 light_direction; - - if (lightSource[i].position.w == 0.0) { - /* directional light */ - light_direction = lightSource[i].position.xyz; - } - else { - /* point light */ - vec3 d = lightSource[i].position.xyz - varying_position; - light_direction = normalize(d); - - /* spot light cone */ - if (lightSource[i].spotCutoff < 90.0) { - float cosine = max(dot(light_direction, - -lightSource[i].spotDirection.xyz), - 0.0); - intensity = pow(cosine, lightSource[i].spotExponent); - intensity *= step(lightSource[i].spotCosCutoff, cosine); - } - - /* falloff */ - float distance = length(d); - - intensity /= lightSource[i].constantAttenuation + - lightSource[i].linearAttenuation * distance + - lightSource[i].quadraticAttenuation * distance * distance; - } - - /* diffuse light */ - vec3 light_diffuse = lightSource[i].diffuse.rgb; - float diffuse_bsdf = max(dot(N, light_direction), 0.0); - L_diffuse += light_diffuse * diffuse_bsdf * intensity; - - /* specular light */ - vec3 light_specular = lightSource[i].specular.rgb; - vec3 H = normalize(light_direction - V); - - float specular_bsdf = pow(max(dot(N, H), 0.0), - gl_FrontMaterial.shininess); - L_specular += light_specular * specular_bsdf * intensity; - } -#endif /* USE_COLOR_MATERIAL */ -#else /* USE_LIGHTING */ - L_diffuse = vec3(1.0); -#endif - - /* Compute diffuse color. */ -#ifdef USE_TEXTURE_2D - L_diffuse *= texture2D(texture_buffer, inpt.v.uv).rgb; -#else - L_diffuse *= diffuse.rgb; -#endif - - /* Sum lighting. */ - vec3 L = L_diffuse; - if (shininess != 0) { - L += L_specular * specular.rgb; - } - - /* Write out fragment color. */ - gl_FragColor = vec4(L, diffuse.a); -#endif -} diff --git a/intern/opensubdiv/gpu_shader_opensubdiv_geometry.glsl b/intern/opensubdiv/gpu_shader_opensubdiv_geometry.glsl deleted file mode 100644 index b16a5cca733..00000000000 --- a/intern/opensubdiv/gpu_shader_opensubdiv_geometry.glsl +++ /dev/null @@ -1,154 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin - * - * ***** END GPL LICENSE BLOCK ***** - */ - -struct VertexData { - vec4 position; - vec3 normal; - vec2 uv; -}; - -layout(lines_adjacency) in; -#ifdef WIREFRAME -layout(line_strip, max_vertices = 8) out; -#else -layout(triangle_strip, max_vertices = 4) out; -#endif - -uniform mat4 modelViewMatrix; -uniform mat4 projectionMatrix; -uniform int PrimitiveIdBase; -uniform int osd_fvar_count; -uniform int osd_active_uv_offset; - -in block { - VertexData v; -} inpt[]; - -#define INTERP_FACE_VARYING_2(result, fvarOffset, tessCoord) \ - { \ - vec2 v[4]; \ - int primOffset = (gl_PrimitiveID + PrimitiveIdBase) * 4; \ - for (int i = 0; i < 4; ++i) { \ - int index = (primOffset + i) * osd_fvar_count + fvarOffset; \ - v[i] = vec2(texelFetch(FVarDataBuffer, index).s, \ - texelFetch(FVarDataBuffer, index + 1).s); \ - } \ - result = mix(mix(v[0], v[1], tessCoord.s), \ - mix(v[3], v[2], tessCoord.s), \ - tessCoord.t); \ - } - -uniform samplerBuffer FVarDataBuffer; -uniform isamplerBuffer FVarDataOffsetBuffer; - -out block { - VertexData v; -} outpt; - -#ifdef FLAT_SHADING -void emit(int index, vec3 normal) -{ - outpt.v.position = inpt[index].v.position; - outpt.v.normal = normal; - - /* TODO(sergey): Only uniform subdivisions atm. */ - vec2 quadst[4] = vec2[](vec2(0, 0), vec2(1, 0), vec2(1, 1), vec2(0, 1)); - vec2 st = quadst[index]; - - INTERP_FACE_VARYING_2(outpt.v.uv, osd_active_uv_offset, st); - - gl_Position = projectionMatrix * inpt[index].v.position; - EmitVertex(); -} - -# ifdef WIREFRAME -void emit_edge(int v0, int v1, vec3 normal) -{ - emit(v0, normal); - emit(v1, normal); -} -# endif - -#else -void emit(int index) -{ - outpt.v.position = inpt[index].v.position; - outpt.v.normal = inpt[index].v.normal; - - /* TODO(sergey): Only uniform subdivisions atm. */ - vec2 quadst[4] = vec2[](vec2(0, 0), vec2(1, 0), vec2(1, 1), vec2(0, 1)); - vec2 st = quadst[index]; - - INTERP_FACE_VARYING_2(outpt.v.uv, osd_active_uv_offset, st); - - gl_Position = projectionMatrix * inpt[index].v.position; - EmitVertex(); -} - -# ifdef WIREFRAME -void emit_edge(int v0, int v1) -{ - emit(v0); - emit(v1); -} -# endif - -#endif - -void main() -{ - gl_PrimitiveID = gl_PrimitiveIDIn; - -#ifdef FLAT_SHADING - vec3 A = (inpt[0].v.position - inpt[1].v.position).xyz; - vec3 B = (inpt[3].v.position - inpt[1].v.position).xyz; - vec3 flat_normal = normalize(cross(B, A)); -# ifndef WIREFRAME - emit(0, flat_normal); - emit(1, flat_normal); - emit(3, flat_normal); - emit(2, flat_normal); -# else - emit_edge(0, 1, flat_normal); - emit_edge(1, 2, flat_normal); - emit_edge(2, 3, flat_normal); - emit_edge(3, 0, flat_normal); -# endif -#else -# ifndef WIREFRAME - emit(0); - emit(1); - emit(3); - emit(2); -# else - emit_edge(0, 1); - emit_edge(1, 2); - emit_edge(2, 3); - emit_edge(3, 0); -# endif -#endif - - EndPrimitive(); -} diff --git a/intern/opensubdiv/gpu_shader_opensubdiv_vertex.glsl b/intern/opensubdiv/gpu_shader_opensubdiv_vertex.glsl deleted file mode 100644 index 6fcf5ad20cd..00000000000 --- a/intern/opensubdiv/gpu_shader_opensubdiv_vertex.glsl +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin - * - * ***** END GPL LICENSE BLOCK ***** - */ - -struct VertexData { - vec4 position; - vec3 normal; - vec2 uv; -}; - -in vec3 normal; -in vec4 position; - -uniform mat4 modelViewMatrix; -uniform mat3 normalMatrix; - -out block { - VertexData v; -} outpt; - -void main() -{ - outpt.v.position = modelViewMatrix * position; - outpt.v.normal = normalize(normalMatrix * normal); -} diff --git a/intern/opensubdiv/internal/opensubdiv.cc b/intern/opensubdiv/internal/opensubdiv.cc new file mode 100644 index 00000000000..c2945ed25ab --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv.cc @@ -0,0 +1,99 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin +// Contributor(s): Brecht van Lommel + +#include "opensubdiv_capi.h" + +#ifdef _MSC_VER +# include +#endif + +#include + +#include "opensubdiv_device_context_opencl.h" +#include "opensubdiv_device_context_cuda.h" +#include "opensubdiv_gl_mesh_capi.h" + +void openSubdiv_init(void) { + // Ensure all OpenGL strings are cached. + openSubdiv_getAvailableEvaluators(); +} + +void openSubdiv_cleanup(void) { + openSubdiv_deinitGLMeshDrawingResources(); +} + +int openSubdiv_getAvailableEvaluators(void) { + int flags = OPENSUBDIV_EVALUATOR_CPU; + +#ifdef OPENSUBDIV_HAS_OPENMP + flags |= OPENSUBDIV_EVALUATOR_OPENMP; +#endif + +#ifdef OPENSUBDIV_HAS_OPENCL + if (CLDeviceContext::HAS_CL_VERSION_1_1()) { + flags |= OPENSUBDIV_EVALUATOR_OPENCL; + } +#endif + +#ifdef OPENSUBDIV_HAS_CUDA + if (CudaDeviceContext::HAS_CUDA_VERSION_4_0()) { + flags |= OPENSUBDIV_EVALUATOR_CUDA; + } +#endif + +#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK + if (GLEW_VERSION_4_1) { + flags |= OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK; + } +#endif + +#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE + if (GLEW_VERSION_4_3 || GLEW_ARB_compute_shader) { + flags |= OPENSUBDIV_EVALUATOR_GLSL_COMPUTE; + } +#endif + + return flags; +} + +int openSubdiv_getVersionHex(void) { +#if defined(OPENSUBDIV_VERSION_NUMBER) + return OPENSUBDIV_VERSION_NUMBER; +#elif defined(OPENSUBDIV_VERSION_MAJOR) + return OPENSUBDIV_VERSION_MAJOR * 10000 + + OPENSUBDIV_VERSION_MINOR * 100 + + OPENSUBDIV_VERSION_PATCH; +#elif defined(OPENSUBDIV_VERSION) + const char* version = STRINGIFY(OPENSUBDIV_VERSION); + if (version[0] == 'v') { + version += 1; + } + int major = 0, minor = 0, patch = 0; + vector tokens; + opensubdiv_capi::stringSplit(&tokens, version, "_", true); + if (tokens.size() == 3) { + major = atoi(tokens[0].c_str()); + minor = atoi(tokens[1].c_str()); + patch = atoi(tokens[2].c_str()); + } + return major * 10000 + minor * 100 + patch; +#else + return 0; +#endif +} diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc new file mode 100644 index 00000000000..bd6edbb9648 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc @@ -0,0 +1,438 @@ +// Copyright 2015 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifdef _MSC_VER +# include +#endif + +#include "internal/opensubdiv_converter_factory.h" + +#include +#include +#include +#include + +#include + +#include "internal/opensubdiv_converter_internal.h" +#include "internal/opensubdiv_converter_orient.h" +#include "internal/opensubdiv_internal.h" +#include "opensubdiv_converter_capi.h" + +struct TopologyRefinerData { + const OpenSubdiv_Converter* converter; +}; + +namespace OpenSubdiv { +namespace OPENSUBDIV_VERSION { +namespace Far { + +template <> +inline bool +TopologyRefinerFactory::resizeComponentTopology( + TopologyRefiner& refiner, + const TopologyRefinerData& cb_data) { + const OpenSubdiv_Converter* converter = cb_data.converter; + /// Faces and face-vertices. + const int num_faces = converter->getNumFaces(converter); + setNumBaseFaces(refiner, num_faces); + for (int face_index = 0; face_index < num_faces; ++face_index) { + const int num_face_vertices = + converter->getNumFaceVertices(converter, face_index); + setNumBaseFaceVertices(refiner, face_index, num_face_vertices); + } + // Edges and edge-faces. + const int num_edges = converter->getNumEdges(converter); + setNumBaseEdges(refiner, num_edges); + for (int edge_index = 0; edge_index < num_edges; ++edge_index) { + const int num_edge_faces = + converter->getNumEdgeFaces(converter, edge_index); + setNumBaseEdgeFaces(refiner, edge_index, num_edge_faces); + } + // Vertices and vertex-faces and vertex-edges. + const int num_vertices = converter->getNumVertices(converter); + setNumBaseVertices(refiner, num_vertices); + for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index) { + const int num_vert_edges = + converter->getNumVertexEdges(converter, vertex_index); + const int num_vert_faces = + converter->getNumVertexFaces(converter, vertex_index); + setNumBaseVertexEdges(refiner, vertex_index, num_vert_edges); + setNumBaseVertexFaces(refiner, vertex_index, num_vert_faces); + } + return true; +} + +template <> +inline bool +TopologyRefinerFactory::assignComponentTopology( + TopologyRefiner& refiner, + const TopologyRefinerData& cb_data) { + using Far::IndexArray; + const OpenSubdiv_Converter* converter = cb_data.converter; + // Face relations. + const int num_faces = converter->getNumFaces(converter); + for (int face_index = 0; face_index < num_faces; ++face_index) { + IndexArray dst_face_verts = getBaseFaceVertices(refiner, face_index); + converter->getFaceVertices(converter, face_index, &dst_face_verts[0]); + IndexArray dst_face_edges = getBaseFaceEdges(refiner, face_index); + converter->getFaceEdges(converter, face_index, &dst_face_edges[0]); + } + // Edge relations. + const int num_edges = converter->getNumEdges(converter); + for (int edge_index = 0; edge_index < num_edges; ++edge_index) { + // Edge-vertices. + IndexArray dst_edge_vertices = getBaseEdgeVertices(refiner, edge_index); + converter->getEdgeVertices(converter, edge_index, &dst_edge_vertices[0]); + // Edge-faces. + IndexArray dst_edge_faces = getBaseEdgeFaces(refiner, edge_index); + converter->getEdgeFaces(converter, edge_index, &dst_edge_faces[0]); + } +// TODO(sergey): Find a way to move this to an utility function. +#ifdef OPENSUBDIV_ORIENT_TOPOLOGY + // Make face normals consistent. + std::vector face_used(num_faces, false); + std::stack traverse_stack; + int face_start = 0, num_traversed_faces = 0; + // Traverse all islands. + while (num_traversed_faces != num_faces) { + // Find first face of any untraversed islands. + while (face_used[face_start]) { + ++face_start; + } + // Add first face to the stack. + traverse_stack.push(face_start); + face_used[face_start] = true; + // Go over whole connected component. + while (!traverse_stack.empty()) { + int face = traverse_stack.top(); + traverse_stack.pop(); + IndexArray face_edges = getBaseFaceEdges(refiner, face); + ConstIndexArray face_vertices = getBaseFaceVertices(refiner, face); + for (int i = 0; i < face_edges.size(); ++i) { + const int edge = face_edges[i]; + ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge); + if (edge_faces.size() != 2) { + /* Can't make consistent normals for non-manifolds. */ + continue; + } + ConstIndexArray edge_vertices = getBaseEdgeVertices(refiner, edge); + // Get winding of the reference face. + const int vert0_of_face = face_vertices.FindIndex(edge_vertices[0]); + const int vert1_of_face = face_vertices.FindIndex(edge_vertices[1]); + const int delta_face = + opensubdiv_capi::getLoopWinding(vert0_of_face, vert1_of_face); + for (int edge_face = 0; edge_face < edge_faces.size(); ++edge_face) { + const int other_face_index = edge_faces[edge_face]; + // Never re-traverse faces, only move forward. + if (face_used[other_face_index]) { + continue; + } + IndexArray other_face_vertics = + getBaseFaceVertices(refiner, other_face_index); + const int vert0_of_other_face = + other_face_vertics.FindIndex(edge_vertices[0]); + const int vert1_of_other_face = + other_face_vertics.FindIndex(edge_vertices[1]); + const int delta_other_face = opensubdiv_capi::getLoopWinding( + vert0_of_other_face, vert1_of_other_face); + if (delta_face * delta_other_face > 0) { + IndexArray other_face_vertices = + getBaseFaceVertices(refiner, other_face_index); + IndexArray other_face_edges = + getBaseFaceEdges(refiner, other_face_index); + opensubdiv_capi::reverseFaceLoops(&other_face_vertices, + &other_face_edges); + } + traverse_stack.push(other_face_index); + face_used[other_face_index] = true; + } + } + ++num_traversed_faces; + } + } +#endif // OPENSUBDIV_ORIENT_TOPOLOGY + // Vertex relations. + const int num_vertices = converter->getNumVertices(converter); + std::vector vertex_faces, vertex_edges; + for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index) { + // Vertex-faces. + IndexArray dst_vertex_faces = getBaseVertexFaces(refiner, vertex_index); + const int num_vertex_faces = + converter->getNumVertexFaces(converter, vertex_index); + vertex_faces.resize(num_vertex_faces); + converter->getVertexFaces(converter, vertex_index, &vertex_faces[0]); + // Vertex-edges. + IndexArray dst_vertex_edges = getBaseVertexEdges(refiner, vertex_index); + const int num_vertex_edges = + converter->getNumVertexEdges(converter, vertex_index); + vertex_edges.resize(num_vertex_edges); + converter->getVertexEdges(converter, vertex_index, &vertex_edges[0]); +// TODO(sergey): Find a way to move this to an utility function. +#ifdef OPENSUBDIV_ORIENT_TOPOLOGY + // Order vertex edges and faces to be in a CCW order. + std::fill(face_used.begin(), face_used.end(), false); + // Number of edges and faces added to the ordered array. + int edge_count_ordered = 0, face_count_ordered = 0; + // Add loose edges straight into the edges array. + bool has_fan_connections = false; + for (int i = 0; i < num_vertex_edges; ++i) { + IndexArray edge_faces = getBaseEdgeFaces(refiner, vertex_edges[i]); + if (edge_faces.size() == 0) { + dst_vertex_edges[edge_count_ordered++] = vertex_edges[i]; + } else if (edge_faces.size() > 2) { + has_fan_connections = true; + } + } + if (has_fan_connections) { + // OpenSubdiv currently doesn't give us clues how to handle fan face + // connections. and since handling such connections complicates the loop + // below we simply don't do special orientation for them. + memcpy(&dst_vertex_edges[0], &vertex_edges[0], + sizeof(int) * num_vertex_edges); + memcpy(&dst_vertex_faces[0], &vertex_faces[0], + sizeof(int) * num_vertex_faces); + continue; + } + // Perform at max numbder of vert-edges iteration and try to avoid + // deadlock here for malformed mesh. + for (int global_iter = 0; global_iter < num_vertex_edges; ++global_iter) { + // Number of edges and faces which are still to be ordered. + const int num_vertex_edges_remained = + num_vertex_edges - edge_count_ordered; + const int num_vertex_faces_remained = + num_vertex_faces - face_count_ordered; + if (num_vertex_edges_remained == 0 && num_vertex_faces_remained == 0) { + // All done, nothing to do anymore. + break; + } + // Face, edge and face-vertex index to start traversal from. + int face_start = -1, edge_start = -1, face_vertex_start = -1; + if (num_vertex_edges_remained == num_vertex_faces_remained) { + // Vertex is either complete manifold or is connected to several + // manifold islands (hourglass-like configuration), can pick up + // random edge unused and start from it. + // + // TODO(sergey): Start from previous edge from which traversal began at + // previous iteration. + for (int i = 0; i < num_vertex_edges; ++i) { + face_start = vertex_faces[i]; + if (!face_used[face_start]) { + ConstIndexArray face_vertices = + getBaseFaceVertices(refiner, face_start); + ConstIndexArray face_edges = getBaseFaceEdges(refiner, face_start); + face_vertex_start = face_vertices.FindIndex(vertex_index); + edge_start = face_edges[face_vertex_start]; + break; + } + } + } else { + // Special handle of non-manifold vertex. + for (int i = 0; i < num_vertex_edges; ++i) { + edge_start = vertex_edges[i]; + IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_start); + if (edge_faces.size() == 1) { + face_start = edge_faces[0]; + if (!face_used[face_start]) { + ConstIndexArray face_vertices = + getBaseFaceVertices(refiner, face_start); + ConstIndexArray face_edges = + getBaseFaceEdges(refiner, face_start); + face_vertex_start = face_vertices.FindIndex(vertex_index); + if (edge_start == face_edges[face_vertex_start]) { + break; + } + } + } + // Reset indices for sanity check below. + face_start = edge_start = face_vertex_start = -1; + } + } + // Sanity check. + assert(face_start != -1); + assert(edge_start != -1); + assert(face_vertex_start != -1); + // Traverse faces starting from the current one. */ + int edge_first = edge_start; + dst_vertex_faces[face_count_ordered++] = face_start; + dst_vertex_edges[edge_count_ordered++] = edge_start; + face_used[face_start] = true; + while (edge_count_ordered < num_vertex_edges) { + IndexArray face_vertices = getBaseFaceVertices(refiner, face_start); + IndexArray face_edges = getBaseFaceEdges(refiner, face_start); + int face_edge_start = face_vertex_start; + int face_edge_next = (face_edge_start > 0) ? (face_edge_start - 1) + : (face_vertices.size() - 1); + Index edge_next = face_edges[face_edge_next]; + if (edge_next == edge_first) { + // Multiple manifolds found, stop for now and handle rest + // in the next iteration. + break; + } + dst_vertex_edges[edge_count_ordered++] = edge_next; + if (face_count_ordered < num_vertex_faces) { + IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_next); + assert(edge_faces.size() != 0); + if (edge_faces.size() == 1) { + assert(edge_faces[0] == face_start); + break; + } else if (edge_faces.size() != 2) { + break; + } + assert(edge_faces.size() == 2); + face_start = edge_faces[(edge_faces[0] == face_start) ? 1 : 0]; + face_vertex_start = + getBaseFaceEdges(refiner, face_start).FindIndex(edge_next); + dst_vertex_faces[face_count_ordered++] = face_start; + face_used[face_start] = true; + } + edge_start = edge_next; + } + } + // Verify ordering doesn't ruin connectivity information. + assert(face_count_ordered == num_vertex_faces); + assert(edge_count_ordered == num_vertex_edges); + opensubdiv_capi::checkOrientedVertexConnectivity( + num_vertex_edges, num_vertex_faces, &vertex_edges[0], &vertex_faces[0], + &dst_vertex_edges[0], &dst_vertex_faces[0]); + // For the release builds we're failing mesh construction so instead of + // nasty bugs the unsupported mesh will simply disappear from the viewport. + if (face_count_ordered != num_vertex_faces || + edge_count_ordered != num_vertex_edges) { + return false; + } +#else // OPENSUBDIV_ORIENT_TOPOLOGY + memcpy(&dst_vertex_edges[0], &vertex_edges[0], + sizeof(int) * num_vertex_edges); + memcpy(&dst_vertex_faces[0], &vertex_faces[0], + sizeof(int) * num_vertex_faces); +#endif // OPENSUBDIV_ORIENT_TOPOLOGY + } + populateBaseLocalIndices(refiner); + return true; +} + +template <> +inline bool TopologyRefinerFactory::assignComponentTags( + TopologyRefiner& refiner, + const TopologyRefinerData& cb_data) { + using OpenSubdiv::Sdc::Crease; + const OpenSubdiv_Converter* converter = cb_data.converter; + const int num_edges = converter->getNumEdges(converter); + for (int edge_index = 0; edge_index < num_edges; ++edge_index) { + const float sharpness = + opensubdiv_capi::getCompatibleEdgeSharpness(converter, edge_index); + setBaseEdgeSharpness(refiner, edge_index, sharpness); + } + // OpenSubdiv expects non-manifold vertices to be sharp but at the time it + // handles correct cases when vertex is a corner of plane. Currently mark + // vertices which are adjacent to a loose edge as sharp, but this decision + // needs some more investigation. + const int num_vertices = converter->getNumVertices(converter); + for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index) { + ConstIndexArray vertex_edges = getBaseVertexEdges(refiner, vertex_index); + for (int i = 0; i < vertex_edges.size(); ++i) { + const int edge_index = vertex_edges[i]; + ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge_index); + if (edge_faces.size() == 0) { + setBaseVertexSharpness(refiner, vertex_index, + Crease::SHARPNESS_INFINITE); + break; + } + } + if (vertex_edges.size() == 2) { + const int edge0 = vertex_edges[0], edge1 = vertex_edges[1]; + const float sharpness0 = converter->getEdgeSharpness(converter, edge0); + const float sharpness1 = converter->getEdgeSharpness(converter, edge1); + const float sharpness = std::min(sharpness0, sharpness1); + setBaseVertexSharpness(refiner, vertex_index, sharpness); + } + } + return true; +} + +template <> +inline bool +TopologyRefinerFactory::assignFaceVaryingTopology( + TopologyRefiner& refiner, + const TopologyRefinerData& cb_data) { + const OpenSubdiv_Converter* converter = cb_data.converter; + const int num_layers = converter->getNumUVLayers(converter); + if (num_layers <= 0) { + // No UV maps, we can skip any face-varying data. + return true; + } + const int num_faces = getNumBaseFaces(refiner); + for (int layer_index = 0; layer_index < num_layers; ++layer_index) { + converter->precalcUVLayer(converter, layer_index); + const int num_uvs = converter->getNumUVCoordinates(converter); + // Fill in per-corner index of the UV. + const int channel = createBaseFVarChannel(refiner, num_uvs); + for (int face_index = 0; face_index < num_faces; ++face_index) { + Far::IndexArray dst_face_uvs = + getBaseFaceFVarValues(refiner, face_index, channel); + for (int corner = 0; corner < dst_face_uvs.size(); ++corner) { + const int uv_index = + converter->getFaceCornerUVIndex(converter, face_index, corner); + dst_face_uvs[corner] = uv_index; + } + } + converter->finishUVLayer(converter); + } + return true; +} + +template <> +inline void TopologyRefinerFactory::reportInvalidTopology( + TopologyError /*errCode*/, const char* msg, + const TopologyRefinerData& /*mesh*/) { + printf("OpenSubdiv Error: %s\n", msg); +} + +} /* namespace Far */ +} /* namespace OPENSUBDIV_VERSION */ +} /* namespace OpenSubdiv */ + +namespace opensubdiv_capi { + +OpenSubdiv::Far::TopologyRefiner* createOSDTopologyRefinerFromConverter( + OpenSubdiv_Converter* converter) { + using OpenSubdiv::Sdc::Options; + using OpenSubdiv::Far::TopologyRefinerFactory; + const OpenSubdiv::Sdc::SchemeType scheme_type = + getSchemeTypeFromCAPI(converter->getSchemeType(converter)); + const Options::FVarLinearInterpolation linear_interpolation = + getFVarLinearInterpolationFromCAPI( + converter->getFVarLinearInterpolation(converter)); + Options options; + options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY); + options.SetCreasingMethod(Options::CREASE_UNIFORM); + options.SetFVarLinearInterpolation(linear_interpolation); + + TopologyRefinerFactory::Options topology_options( + scheme_type, options); +#ifdef OPENSUBDIV_VALIDATE_TOPOLOGY + topology_options.validateFullTopology = true; +#endif + TopologyRefinerData cb_data; + cb_data.converter = converter; + return TopologyRefinerFactory::Create( + cb_data, topology_options); +} + +} // namespace opensubdiv_capi diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.h b/intern/opensubdiv/internal/opensubdiv_converter_factory.h new file mode 100644 index 00000000000..451418813e1 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.h @@ -0,0 +1,37 @@ +// Copyright 2015 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_CONVERTER_FACTORY_H_ +#define OPENSUBDIV_CONVERTER_FACTORY_H_ + +#ifdef _MSC_VER +# include +#endif + +#include + +struct OpenSubdiv_Converter; + +namespace opensubdiv_capi { + +OpenSubdiv::Far::TopologyRefiner* createOSDTopologyRefinerFromConverter( + struct OpenSubdiv_Converter* converter); + +} // namespace opensubdiv_capi + +#endif // OPENSUBDIV_CONVERTER_FACTORY_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_converter_internal.cc b/intern/opensubdiv/internal/opensubdiv_converter_internal.cc new file mode 100644 index 00000000000..56b5657121d --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_converter_internal.cc @@ -0,0 +1,70 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifdef _MSC_VER +# include +#endif + +#include "internal/opensubdiv_converter_internal.h" + +#include +#include + +namespace opensubdiv_capi { + +OpenSubdiv::Sdc::SchemeType getSchemeTypeFromCAPI(OpenSubdiv_SchemeType type) { + switch (type) { + case OSD_SCHEME_BILINEAR: + return OpenSubdiv::Sdc::SCHEME_BILINEAR; + case OSD_SCHEME_CATMARK: + return OpenSubdiv::Sdc::SCHEME_CATMARK; + case OSD_SCHEME_LOOP: + return OpenSubdiv::Sdc::SCHEME_LOOP; + } + assert(!"Unknown scheme type passed via C-API"); + return OpenSubdiv::Sdc::SCHEME_CATMARK; +} + +OpenSubdiv::Sdc::Options::FVarLinearInterpolation +getFVarLinearInterpolationFromCAPI( + OpenSubdiv_FVarLinearInterpolation linear_interpolation) { + typedef OpenSubdiv::Sdc::Options Options; + switch (linear_interpolation) { + case OSD_FVAR_LINEAR_INTERPOLATION_NONE: + return Options::FVAR_LINEAR_NONE; + case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY: + return Options::FVAR_LINEAR_CORNERS_ONLY; + case OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES: + return Options::FVAR_LINEAR_BOUNDARIES; + case OSD_FVAR_LINEAR_INTERPOLATION_ALL: + return Options::FVAR_LINEAR_ALL; + } + assert(!"Unknown fvar linear interpolation passed via C-API"); + return Options::FVAR_LINEAR_NONE; +} + +float getCompatibleEdgeSharpness(const OpenSubdiv_Converter* converter, + int edge_index) { + if (converter->getNumEdgeFaces(converter, edge_index) == 2) { + return converter->getEdgeSharpness(converter, edge_index); + } else { + return OpenSubdiv::Sdc::Crease::SHARPNESS_INFINITE; + } +} + +} // namespace opensubdiv_capi diff --git a/intern/opensubdiv/internal/opensubdiv_converter_internal.h b/intern/opensubdiv/internal/opensubdiv_converter_internal.h new file mode 100644 index 00000000000..68518d67884 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_converter_internal.h @@ -0,0 +1,50 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_CONVERTER_INTERNAL_H_ +#define OPENSUBDIV_CONVERTER_INTERNAL_H_ + +#ifdef _MSC_VER +# include +#endif + +#include +#include + +#include "opensubdiv_converter_capi.h" + +struct OpenSubdiv_Converter; + +namespace opensubdiv_capi { + +// Convert scheme type from C-API enum to an OpenSubdiv native enum. +OpenSubdiv::Sdc::SchemeType getSchemeTypeFromCAPI(OpenSubdiv_SchemeType type); + +// Convert face-varying interpolation type from C-API to an OpenSubdiv +// native enum. +OpenSubdiv::Sdc::Options::FVarLinearInterpolation +getFVarLinearInterpolationFromCAPI( + OpenSubdiv_FVarLinearInterpolation linear_interpolation); + +// Get edge sharpness in a way which makes OpenSubdiv happy. +float getCompatibleEdgeSharpness(const OpenSubdiv_Converter* converter, + int edge_index); + +} // namespace opensubdiv_capi + +#endif // OPENSUBDIV_CONVERTER_INTERNAL_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient.cc b/intern/opensubdiv/internal/opensubdiv_converter_orient.cc new file mode 100644 index 00000000000..449e9028180 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_converter_orient.cc @@ -0,0 +1,66 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/opensubdiv_converter_orient.h" + +#include "internal/opensubdiv_internal.h" + +namespace opensubdiv_capi { + +void checkOrientedVertexConnectivity(const int num_vertex_edges, + const int num_vertex_faces, + const int* vertex_edges, + const int* vertex_faces, + const int* dst_vertex_edges, + const int* dst_vertex_faces) { +#ifndef NDEBUG + for (int i = 0; i < num_vertex_faces; ++i) { + bool found = false; + for (int j = 0; j < num_vertex_faces; ++j) { + if (vertex_faces[i] == dst_vertex_faces[j]) { + found = true; + break; + } + } + if (!found) { + assert(!"vert-faces connectivity ruined"); + } + } + for (int i = 0; i < num_vertex_edges; ++i) { + bool found = false; + for (int j = 0; j < num_vertex_edges; ++j) { + if (vertex_edges[i] == dst_vertex_edges[j]) { + found = true; + break; + } + } + if (!found) { + assert(!"vert-edges connectivity ruined"); + } + } +#else + (void) num_vertex_edges; + (void) num_vertex_faces; + (void) vertex_edges; + (void) vertex_faces; + (void) dst_vertex_edges; + (void) dst_vertex_faces; +#endif +} + +} // namespace opensubdiv_capi diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient.h b/intern/opensubdiv/internal/opensubdiv_converter_orient.h new file mode 100644 index 00000000000..b783007a0cb --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_converter_orient.h @@ -0,0 +1,50 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_CONVERTER_ORIENT_H_ +#define OPENSUBDIV_CONVERTER_ORIENT_H_ + +#include + +// Set of utility functions which are needed to bring topology to an orientation +// (or, winding, if you wish) which OpenSubdiv expects. + +namespace opensubdiv_capi { + +inline void reverseFaceVertices(int* face_vertices, const int num_vertices); + +// TODO(sergey): Document which value corresponds to which winding. +inline int getLoopWinding(int vert0_of_face, int vert1_of_face); + +inline void reverseFaceLoops( + OpenSubdiv::Far::IndexArray* face_vertices, + OpenSubdiv::Far::IndexArray* face_edges); + +// Used for debugging, checks whether orientation happened correct. +void checkOrientedVertexConnectivity(const int num_vertex_edges, + const int num_vertex_faces, + const int* vertex_edges, + const int* vertex_faces, + const int* dst_vertex_edges, + const int* dst_vertex_faces); + +} // namespace opensubdiv_capi + +#endif // OPENSUBDIV_CONVERTER_ORIENT_H_ + +#include "internal/opensubdiv_converter_orient_impl.h" diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h b/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h new file mode 100644 index 00000000000..3125bc600e5 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h @@ -0,0 +1,66 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_ +#define OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_ + +#include "internal/opensubdiv_converter_orient.h" + +#include +#include +#include + +namespace opensubdiv_capi { + +inline void reverseFaceVertices(int* face_vertices, const int num_vertices) { + int last_vert = face_vertices[num_vertices - 1]; + for (int i = num_vertices - 1; i > 0; --i) { + face_vertices[i] = face_vertices[i - 1]; + } + face_vertices[0] = last_vert; +} + +inline int getLoopWinding(int vert0_of_face, int vert1_of_face) { + int delta_face = vert1_of_face - vert0_of_face; + if (abs(delta_face) != 1) { + if (delta_face > 0) { + delta_face = -1; + } else { + delta_face = 1; + } + } + return delta_face; +} + +inline void reverseFaceLoops( + OpenSubdiv::Far::IndexArray* face_vertices, + OpenSubdiv::Far::IndexArray* face_edges) { + const int num_face_vertices = face_vertices->size(); + for (int i = 0; i < num_face_vertices / 2; ++i) { + const int j = num_face_vertices - i - 1; + if (i != j) { + std::swap((*face_vertices)[i], (*face_vertices)[j]); + std::swap((*face_edges)[i], (*face_edges)[j]); + } + } + reverseFaceVertices(&(*face_vertices)[0], num_face_vertices); +} + +} // namespace opensubdiv_capi + +#endif // OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc new file mode 100644 index 00000000000..875f503b9ab --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc @@ -0,0 +1,226 @@ +// Adopted from OpenSubdiv with the following license: +// +// Copyright 2015 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. + +#ifdef OPENSUBDIV_HAS_CUDA + +#ifdef _MSC_VER +# include +#endif + +#include "opensubdiv_device_context_cuda.h" + +#if defined(_WIN32) +# include +#elif defined(__APPLE__) +# include +#else +# include +# include +#endif + +#include +#include +#include +#include +#include + +#define message(fmt, ...) +// #define message(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__) +#define error(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__) + +namespace { + +int getCudaDeviceForCurrentGLContext() { + // Find and use the CUDA device for the current GL context + unsigned int interop_device_count = 0; + int interopDevices[1]; + cudaError_t status = cudaGLGetDevices(&interop_device_count, + interopDevices, + 1, + cudaGLDeviceListCurrentFrame); + if (status == cudaErrorNoDevice || interop_device_count != 1) { + message("CUDA no interop devices found.\n"); + return 0; + } + int device = interopDevices[0]; +#if defined(_WIN32) + return device; +#elif defined(__APPLE__) + return device; +#else // X11 + Display* display = glXGetCurrentDisplay(); + int screen = DefaultScreen(display); + if (device != screen) { + error("The CUDA interop device (%d) does not match " + "the screen used by the current GL context (%d), " + "which may cause slow performance on systems " + "with multiple GPU devices.", + device, screen); + } + message("CUDA init using device for current GL context: %d\n", device); + return device; +#endif +} + +// Beginning of GPU Architecture definitions. +int convertSMVer2Cores_local(int major, int minor) { + // Defines for GPU Architecture types (using the SM version to determine + // the # of cores per SM + typedef struct { + int SM; // 0xMm (hexidecimal notation), + // M = SM Major version, + // and m = SM minor version + int Cores; + } sSMtoCores; + + sSMtoCores nGpuArchCoresPerSM[] = { + {0x10, 8}, // Tesla Generation (SM 1.0) G80 class. + {0x11, 8}, // Tesla Generation (SM 1.1) G8x class. + {0x12, 8}, // Tesla Generation (SM 1.2) G9x class. + {0x13, 8}, // Tesla Generation (SM 1.3) GT200 class. + {0x20, 32}, // Fermi Generation (SM 2.0) GF100 class. + {0x21, 48}, // Fermi Generation (SM 2.1) GF10x class. + {0x30, 192}, // Fermi Generation (SM 3.0) GK10x class. + {-1, -1}}; + int index = 0; + while (nGpuArchCoresPerSM[index].SM != -1) { + if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) { + return nGpuArchCoresPerSM[index].Cores; + } + index++; + } + printf("MapSMtoCores undefined SMversion %d.%d!\n", major, minor); + return -1; +} + +// This function returns the best GPU (with maximum GFLOPS). +int cutGetMaxGflopsDeviceId() { + int current_device = 0, sm_per_multiproc = 0; + int max_compute_perf = 0, max_perf_device = -1; + int device_count = 0, best_SM_arch = 0; + int compat_major, compat_minor; + cuDeviceGetCount(&device_count); + // Find the best major SM Architecture GPU device. + while (current_device < device_count) { + cuDeviceComputeCapability(&compat_major, &compat_minor, current_device); + if (compat_major > 0 && compat_major < 9999) { + best_SM_arch = std::max(best_SM_arch, compat_major); + } + current_device++; + } + // Find the best CUDA capable GPU device. + current_device = 0; + while (current_device < device_count) { + cuDeviceComputeCapability(&compat_major, &compat_minor, current_device); + if (compat_major == 9999 && compat_minor == 9999) { + sm_per_multiproc = 1; + } else { + sm_per_multiproc = convertSMVer2Cores_local(compat_major, compat_minor); + } + int multi_processor_count; + cuDeviceGetAttribute(&multi_processor_count, + CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, + current_device); + int clock_rate; + cuDeviceGetAttribute(&clock_rate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, + current_device); + int compute_perf = multi_processor_count * sm_per_multiproc * clock_rate; + if (compute_perf > max_compute_perf) { + /* If we find GPU with SM major > 2, search only these */ + if (best_SM_arch > 2) { + /* If our device==dest_SM_arch, choose this, or else pass. */ + if (compat_major == best_SM_arch) { + max_compute_perf = compute_perf; + max_perf_device = current_device; + } + } else { + max_compute_perf = compute_perf; + max_perf_device = current_device; + } + } + ++current_device; + } + return max_perf_device; +} + +} // namespace + +bool CudaDeviceContext::HAS_CUDA_VERSION_4_0() { +#ifdef OPENSUBDIV_HAS_CUDA + static bool cuda_initialized = false; + static bool cuda_load_success = true; + if (!cuda_initialized) { + cuda_initialized = true; + +#ifdef OPENSUBDIV_HAS_CUEW + cuda_load_success = cuewInit(CUEW_INIT_CUDA) == CUEW_SUCCESS; + if (!cuda_load_success) { + fprintf(stderr, "Loading CUDA failed.\n"); + } +#endif + // Need to initialize CUDA here so getting device + // with the maximum FPLOS works fine. + if (cuInit(0) == CUDA_SUCCESS) { + // This is to deal with cases like NVidia Optimus, + // when there might be CUDA library installed but + // NVidia card is not being active. + if (cutGetMaxGflopsDeviceId() < 0) { + cuda_load_success = false; + } + } else { + cuda_load_success = false; + } + } + return cuda_load_success; +#else + return false; +#endif +} + +CudaDeviceContext::CudaDeviceContext() + : initialized_(false) { +} + +CudaDeviceContext::~CudaDeviceContext() { + cudaDeviceReset(); +} + +bool CudaDeviceContext::Initialize() { + // See if any cuda device is available. + int device_count = 0; + cudaGetDeviceCount(&device_count); + message("CUDA device count: %d\n", device_count); + if (device_count <= 0) { + return false; + } + cudaGLSetGLDevice(getCudaDeviceForCurrentGLContext()); + initialized_ = true; + return true; +} + +bool CudaDeviceContext::IsInitialized() const { + return initialized_; +} + +#endif // OPENSUBDIV_HAS_CUDA diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_cuda.h b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.h new file mode 100644 index 00000000000..ef212df10f0 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.h @@ -0,0 +1,54 @@ +// Adopted from OpenSubdiv with the following license: +// +// Copyright 2013 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http: //www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. + +#ifndef OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_ +#define OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_ + +#ifdef OPENSUBDIV_HAS_CUDA + +struct ID3D11Device; + +class CudaDeviceContext { + public: + CudaDeviceContext(); + ~CudaDeviceContext(); + + static bool HAS_CUDA_VERSION_4_0(); + + // Initialze cuda device from the current GL context. + bool Initialize(); + + // Initialze cuda device from the ID3D11Device. + bool Initialize(ID3D11Device* device); + + // Returns true if the cuda device has already been initialized. + bool IsInitialized() const; + + private: + bool initialized_; +}; + +#endif // OPENSUBDIV_HAS_CUDA + +#endif // _OPENSUBDIV_DEVICE_CONTEXT_CUDA_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc new file mode 100644 index 00000000000..00f58af894a --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc @@ -0,0 +1,269 @@ +// Adopted from OpenSubdiv with the following license: +// +// Copyright 2015 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. + +#include "opensubdiv_device_context_opencl.h" + +#ifdef OPENSUBDIV_HAS_OPENCL + +#if defined(_WIN32) +# include +#elif defined(__APPLE__) +# include +#else +# include +#endif + +#include +#include +#include +#include + +#define message(...) // fprintf(stderr, __VA_ARGS__) +#define error(...) fprintf(stderr, __VA_ARGS__) + +namespace { + +// Returns the first found platform. +cl_platform_id findPlatform() { + cl_uint num_platforms; + cl_int ci_error_number = clGetPlatformIDs(0, NULL, &num_platforms); + if (ci_error_number != CL_SUCCESS) { + error("Error %d in clGetPlatformIDs call.\n", ci_error_number); + return NULL; + } + if (num_platforms == 0) { + error("No OpenCL platform found.\n"); + return NULL; + } + std::vector cl_platform_ids(num_platforms); + ci_error_number = clGetPlatformIDs(num_platforms, &cl_platform_ids[0], NULL); + char ch_buffer[1024]; + for (cl_uint i = 0; i < num_platforms; ++i) { + ci_error_number = clGetPlatformInfo(cl_platform_ids[i], + CL_PLATFORM_NAME, + sizeof(ch_buffer), + ch_buffer, + NULL); + if (ci_error_number == CL_SUCCESS) { + cl_platform_id platform_id = cl_platform_ids[i]; + return platform_id; + } + } + return NULL; +} + +// Return the device in cl_devices which supports the extension. +int findExtensionSupportedDevice(cl_device_id* cl_devices, + int num_devices, + const char* extension_name) { + // Find a device that supports sharing with GL/D3D11 + // (SLI / X-fire configurations) + cl_int cl_error_number; + for (int i = 0; i < num_devices; ++i) { + // Get extensions string size. + size_t extensions_size; + cl_error_number = clGetDeviceInfo(cl_devices[i], + CL_DEVICE_EXTENSIONS, + 0, + NULL, + &extensions_size); + if (cl_error_number != CL_SUCCESS) { + error("Error %d in clGetDeviceInfo\n", cl_error_number); + return -1; + } + if (extensions_size > 0) { + // Get extensions string. + std::string extensions('\0', extensions_size); + cl_error_number = clGetDeviceInfo(cl_devices[i], + CL_DEVICE_EXTENSIONS, + extensions_size, + &extensions[0], + &extensions_size); + if (cl_error_number != CL_SUCCESS) { + error("Error %d in clGetDeviceInfo\n", cl_error_number); + continue; + } + // Parse string. This is bit deficient since the extentions + // is space separated. + // + // The actual string would be "cl_khr_d3d11_sharing" + // or "cl_nv_d3d11_sharing" + if (extensions.find(extension_name) != std::string::npos) { + return i; + } + } + } + return -1; +} + +} // namespace + +CLDeviceContext::CLDeviceContext() + : cl_context_(NULL), + cl_command_queue_(NULL) { +} + +CLDeviceContext::~CLDeviceContext() { + if (cl_command_queue_) { + clReleaseCommandQueue(cl_command_queue_); + } + if (cl_context_) { + clReleaseContext(cl_context_); + } +} + +bool CLDeviceContext::HAS_CL_VERSION_1_1() { +#ifdef OPENSUBDIV_HAS_CLEW + static bool clew_initialized = false; + static bool clew_load_success; + if (!clew_initialized) { + clew_initialized = true; + clew_load_success = clewInit() == CLEW_SUCCESS; + if (!clew_load_success) { + error("Loading OpenCL failed.\n"); + } + } + return clew_load_success; +#endif + return true; +} + +bool CLDeviceContext::Initialize() { +#ifdef OPENSUBDIV_HAS_CLEW + if (!clGetPlatformIDs) { + error("Error clGetPlatformIDs function not bound.\n"); + return false; + } +#endif + cl_int cl_error_number; + cl_platform_id cp_platform = findPlatform(); + +#if defined(_WIN32) + cl_context_properties props[] = { + CL_GL_CONTEXT_KHR, + (cl_context_properties)wglGetCurrentContext(), + CL_WGL_HDC_KHR, + (cl_context_properties)wglGetCurrentDC(), + CL_CONTEXT_PLATFORM, + (cl_context_properties)cp_platform, + 0}; +#elif defined(__APPLE__) + CGLContextObj kCGLContext = CGLGetCurrentContext(); + CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext); + cl_context_properties props[] = {CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, + (cl_context_properties)kCGLShareGroup, + 0}; +#else + cl_context_properties props[] = { + CL_GL_CONTEXT_KHR, + (cl_context_properties)glXGetCurrentContext(), + CL_GLX_DISPLAY_KHR, + (cl_context_properties)glXGetCurrentDisplay(), + CL_CONTEXT_PLATFORM, + (cl_context_properties)cp_platform, + 0}; +#endif + +#if defined(__APPLE__) + _clContext = clCreateContext(props, 0, NULL, clLogMessagesToStdoutAPPLE, NULL, + &cl_error_number); + if (cl_error_number != CL_SUCCESS) { + error("Error %d in clCreateContext\n", cl_error_number); + return false; + } + size_t devices_size = 0; + clGetGLContextInfoAPPLE(_clContext, kCGLContext, + CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE, + 0, + NULL, + &devices_size); + const int num_devices = devices_size / sizeof(cl_device_id); + if (num_devices == 0) { + error("No sharable devices.\n"); + return false; + } + std::vector cl_devices(num_devices); + clGetGLContextInfoAPPLE(_clContext, kCGLContext, + CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE, + num_devices * sizeof(cl_device_id), + &cl_devices[0], + NULL); + int cl_device_used = 0; +#else // not __APPLE__ + // Get the number of GPU devices available to the platform. + cl_uint num_devices = 0; + clGetDeviceIDs(cp_platform, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); + if (num_devices == 0) { + error("No CL GPU device found.\n"); + return false; + } + // Create the device list. + std::vector cl_devices(num_devices); + clGetDeviceIDs(cp_platform, + CL_DEVICE_TYPE_GPU, + num_devices, + &cl_devices[0], + NULL); + const char* extension = "cl_khr_gl_sharing"; + int cl_device_used = findExtensionSupportedDevice(&cl_devices[0], + num_devices, + extension); + if (cl_device_used < 0) { + error("No device found that supports CL/GL context sharing\n"); + return false; + } + cl_context_ = clCreateContext(props, + 1, + &cl_devices[cl_device_used], + NULL, NULL, + &cl_error_number); +#endif // not __APPLE__ + if (cl_error_number != CL_SUCCESS) { + error("Error %d in clCreateContext\n", cl_error_number); + return false; + } + cl_command_queue_ = clCreateCommandQueue(cl_context_, + cl_devices[cl_device_used], + 0, + &cl_error_number); + if (cl_error_number != CL_SUCCESS) { + error("Error %d in clCreateCommandQueue\n", cl_error_number); + return false; + } + return true; +} + +bool CLDeviceContext::IsInitialized() const { + return (cl_context_ != NULL); +} + +cl_context CLDeviceContext::GetContext() const { + return cl_context_; +} + +cl_command_queue CLDeviceContext::GetCommandQueue() const { + return cl_command_queue_; +} + +#endif // OPENSUBDIV_HAS_OPENCL diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_opencl.h b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.h new file mode 100644 index 00000000000..bc751cb6954 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.h @@ -0,0 +1,52 @@ +// Adopted from OpenSubdiv with the following license: +// +// Copyright 2015 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. + +#ifndef OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_ +#define OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_ + +#ifdef OPENSUBDIV_HAS_OPENCL +#include + +class CLDeviceContext { + public: + static bool HAS_CL_VERSION_1_1(); + + CLDeviceContext(); + ~CLDeviceContext(); + + bool Initialize(); + + bool IsInitialized() const; + + cl_context GetContext() const; + cl_command_queue GetCommandQueue() const; + + protected: + cl_context cl_context_; + cl_command_queue cl_command_queue_; +}; + +#endif // OPENSUBDIV_HAS_OPENCL + +#endif // _OPENSUBDIV_DEVICE_CONTEXT_OPENCL_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator.cc b/intern/opensubdiv/internal/opensubdiv_evaluator.cc new file mode 100644 index 00000000000..29d42a903ba --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_evaluator.cc @@ -0,0 +1,154 @@ +// Copyright 2015 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "opensubdiv_evaluator_capi.h" + +#include +#include "MEM_guardedalloc.h" + +#include "internal/opensubdiv_evaluator_internal.h" + +namespace { + +void setCoarsePositions(OpenSubdiv_Evaluator* evaluator, + const float* positions, + const int start_vertex_index, const int num_vertices) { + evaluator->internal->eval_output->setCoarsePositions(positions, + start_vertex_index, + num_vertices); +} + +void setVaryingData(OpenSubdiv_Evaluator* evaluator, + const float* varying_data, + const int start_vertex_index, const int num_vertices) { + evaluator->internal->eval_output->setVaryingData(varying_data, + start_vertex_index, + num_vertices); +} + +void setFaceVaryingData(OpenSubdiv_Evaluator* evaluator, + const float* face_varying_data, + const int start_vertex_index, const int num_vertices) { + evaluator->internal->eval_output->setFaceVaryingData(face_varying_data, + start_vertex_index, + num_vertices); +} + +void setCoarsePositionsFromBuffer(OpenSubdiv_Evaluator* evaluator, + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices) { + evaluator->internal->eval_output->setCoarsePositionsFromBuffer( + buffer, + start_offset, + stride, + start_vertex_index, + num_vertices); +} + +void setVaryingDataFromBuffer(OpenSubdiv_Evaluator* evaluator, + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices) { + evaluator->internal->eval_output->setVaryingDataFromBuffer( + buffer, + start_offset, + stride, + start_vertex_index, + num_vertices); +} + +void setFaceVaryingDataFromBuffer(OpenSubdiv_Evaluator* evaluator, + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices) { + evaluator->internal->eval_output->setFaceVaryingDataFromBuffer( + buffer, + start_offset, + stride, + start_vertex_index, + num_vertices); +} + +void refine(OpenSubdiv_Evaluator* evaluator) { + evaluator->internal->eval_output->refine(); +} + +void evaluateLimit(OpenSubdiv_Evaluator* evaluator, + const int ptex_face_index, + const float face_u, const float face_v, + float P[3], float dPdu[3], float dPdv[3]) { + evaluator->internal->eval_output->evaluateLimit(ptex_face_index, + face_u, face_v, + P, dPdu, dPdv); +} + +void evaluateVarying(OpenSubdiv_Evaluator* evaluator, + const int ptex_face_index, + float face_u, float face_v, + float varying[3]) { + evaluator->internal->eval_output->evaluateVarying(ptex_face_index, + face_u, face_v, + varying); +} + +void evaluateFaceVarying(OpenSubdiv_Evaluator* evaluator, + const int ptex_face_index, + float face_u, float face_v, + float face_varying[2]) { + evaluator->internal->eval_output->evaluateFaceVarying(ptex_face_index, + face_u, face_v, + face_varying); +} + +void assignFunctionPointers(OpenSubdiv_Evaluator* evaluator) { + evaluator->setCoarsePositions = setCoarsePositions; + evaluator->setVaryingData = setVaryingData; + evaluator->setFaceVaryingData = setFaceVaryingData; + + evaluator->setCoarsePositionsFromBuffer = setCoarsePositionsFromBuffer; + evaluator->setVaryingDataFromBuffer = setVaryingDataFromBuffer; + evaluator->setFaceVaryingDataFromBuffer = setFaceVaryingDataFromBuffer; + + evaluator->refine = refine; + + evaluator->evaluateLimit = evaluateLimit; + evaluator->evaluateVarying = evaluateVarying; + evaluator->evaluateFaceVarying = evaluateFaceVarying; +} + +} // namespace + +OpenSubdiv_Evaluator* openSubdiv_createEvaluatorFromTopologyRefiner( + OpenSubdiv_TopologyRefiner* topology_refiner) { + OpenSubdiv_Evaluator* evaluator = OBJECT_GUARDED_NEW(OpenSubdiv_Evaluator); + assignFunctionPointers(evaluator); + evaluator->internal = openSubdiv_createEvaluatorInternal(topology_refiner); + return evaluator; +} + +void openSubdiv_deleteEvaluator(OpenSubdiv_Evaluator* evaluator) { + openSubdiv_deleteEvaluatorInternal(evaluator->internal); + OBJECT_GUARDED_DELETE(evaluator, OpenSubdiv_Evaluator); +} diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc new file mode 100644 index 00000000000..595df3eaa75 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc @@ -0,0 +1,734 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/opensubdiv_evaluator_internal.h" + +#include +#include +#include + +#ifdef _MSC_VER +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "MEM_guardedalloc.h" + +#include "internal/opensubdiv_topology_refiner_internal.h" +#include "opensubdiv_topology_refiner_capi.h" + +using OpenSubdiv::Osd::BufferDescriptor; +using OpenSubdiv::Osd::CpuEvaluator; +using OpenSubdiv::Osd::CpuPatchTable; +using OpenSubdiv::Osd::CpuVertexBuffer; +using OpenSubdiv::Osd::PatchCoord; +using OpenSubdiv::Far::PatchMap; +using OpenSubdiv::Far::PatchTable; +using OpenSubdiv::Far::PatchTableFactory; +using OpenSubdiv::Far::StencilTable; +using OpenSubdiv::Far::StencilTableFactory; +using OpenSubdiv::Far::TopologyRefiner; + +namespace opensubdiv_capi { + +namespace { + +// Helper class to wrap numerous of patch coordinates into a buffer. +// Used to pass coordinates to the CPU evaluator. Other evaluators are not +// supported. +class PatchCoordBuffer : public std::vector { + public: + static PatchCoordBuffer* Create(int size) { + PatchCoordBuffer* buffer = new PatchCoordBuffer(); + buffer->resize(size); + return buffer; + } + + PatchCoord* BindCpuBuffer() { + return reinterpret_cast(&(*this)[0]); + } + + int GetNumVertices() { + return size(); + } + + void UpdateData(const PatchCoord* patch_coords, int num_patch_coords) { + memcpy(&(*this)[0], + reinterpret_cast(patch_coords), + sizeof(PatchCoord) * num_patch_coords); + } +}; + +// Helper class to wrap single of patch coord into a buffer. Used to pass +// coordinates to the CPU evaluator. Other evaluators are not supported. +class SinglePatchCoordBuffer { + public: + static SinglePatchCoordBuffer* Create() { + return new SinglePatchCoordBuffer(); + } + + SinglePatchCoordBuffer() { + } + + explicit SinglePatchCoordBuffer(const PatchCoord &patch_coord) + : patch_coord_(patch_coord) { + } + + PatchCoord* BindCpuBuffer() { + return &patch_coord_; + } + + int GetNumVertices() { + return 1; + } + + void UpdateData(const PatchCoord &patch_coord) { + patch_coord_ = patch_coord; + } + + protected: + PatchCoord patch_coord_; +}; + +// Helper class which is aimed to be used in cases when buffer is small enough +// and better to be allocated in stack rather than in heap. +// +// TODO(sergey): Check if bare arrays could be used by CPU evaluator. +template +class StackAllocatedBuffer { + public: + static PatchCoordBuffer* Create(int /*size*/) { + // TODO(sergey): Validate that requested dize is smaller than static + // stack memory size. + return new StackAllocatedBuffer(); + } + + float* BindCpuBuffer() { + return &data_[0]; + } + + int GetNumVertices() { + return num_vertices; + } + + // TODO(sergey): Support UpdateData(). + protected: + float data_[element_size * num_vertices]; +}; + +// Volatile evaluator which can be used from threads. +// +// TODO(sergey): Make it possible to evaluate coordinates in chunks. +// TODO(sergey): Make it possible to evaluate multiple face varying layers. +// (or maybe, it's cheap to create new evaluator for existing +// topology to evaluate all needed face varying layers?) +template +class VolatileEvalOutput { + public: + typedef OpenSubdiv::Osd::EvaluatorCacheT EvaluatorCache; + + VolatileEvalOutput(const StencilTable* vertex_stencils, + const StencilTable* varying_stencils, + const StencilTable* face_varying_stencils, + const int face_varying_channel, + const int face_varying_width, + const PatchTable* patch_table, + EvaluatorCache* evaluator_cache = NULL, + DEVICE_CONTEXT* device_context = NULL) + : src_desc_(0, 3, 3), + src_varying_desc_(0, 3, 3), + src_face_varying_desc_(0, face_varying_width, face_varying_width), + face_varying_channel_(face_varying_channel), + face_varying_width_(face_varying_width), + evaluator_cache_(evaluator_cache), + device_context_(device_context) { + // Total number of vertices = coarse points + refined points + local points. + int num_total_vertices = vertex_stencils->GetNumControlVertices() + + vertex_stencils->GetNumStencils(); + num_coarse_vertices_ = vertex_stencils->GetNumControlVertices(); + using OpenSubdiv::Osd::convertToCompatibleStencilTable; + src_data_ = + SRC_VERTEX_BUFFER::Create(3, num_total_vertices, device_context_); + src_varying_data_ = + SRC_VERTEX_BUFFER::Create(3, num_total_vertices, device_context_); + patch_table_ = PATCH_TABLE::Create(patch_table, device_context_); + patch_coords_ = NULL; + vertex_stencils_ = convertToCompatibleStencilTable( + vertex_stencils, device_context_); + varying_stencils_ = convertToCompatibleStencilTable( + varying_stencils, device_context_); + if (face_varying_stencils != NULL) { + num_coarse_face_varying_vertices_ = + face_varying_stencils->GetNumControlVertices(); + const int num_total_face_varying_vertices = + face_varying_stencils->GetNumControlVertices() + + face_varying_stencils->GetNumStencils(); + src_face_varying_data_ = + EVAL_VERTEX_BUFFER::Create(2, + num_total_face_varying_vertices, + device_context_); + face_varying_stencils_ = convertToCompatibleStencilTable( + face_varying_stencils, device_context_); + } else { + num_coarse_face_varying_vertices_ = 0; + src_face_varying_data_ = NULL; + face_varying_stencils_ = NULL; + } + } + + ~VolatileEvalOutput() { + delete src_data_; + delete src_varying_data_; + delete src_face_varying_data_; + delete patch_table_; + delete vertex_stencils_; + delete varying_stencils_; + delete face_varying_stencils_; + } + + // TODO(sergey): Implement binding API. + + void updateData(const float* src, int start_vertex, int num_vertices) { + src_data_->UpdateData(src, start_vertex, num_vertices, device_context_); + } + + void updateVaryingData(const float* src, int start_vertex, int num_vertices) { + src_varying_data_->UpdateData(src, + start_vertex, + num_vertices, + device_context_); + } + + void updateFaceVaryingData(const float* src, + int start_vertex, + int num_vertices) { + src_face_varying_data_->UpdateData(src, + start_vertex, + num_vertices, + device_context_); + } + + bool hasVaryingData() const { + // return varying_stencils_ != NULL; + // TODO(sergey): Check this based on actual topology. + return false; + } + + bool hasFaceVaryingData() const { + return face_varying_stencils_ != NULL; + } + + void refine() { + // Evaluate vertex positions. + BufferDescriptor dst_desc = src_desc_; + dst_desc.offset += num_coarse_vertices_ * src_desc_.stride; + const EVALUATOR* eval_instance = + OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, + src_desc_, + dst_desc, + device_context_); + EVALUATOR::EvalStencils(src_data_, src_desc_, + src_data_, dst_desc, + vertex_stencils_, + eval_instance, + device_context_); + // Evaluate varying data. + if (hasVaryingData()) { + BufferDescriptor dst_varying_desc = src_varying_desc_; + dst_varying_desc.offset += + num_coarse_vertices_ * src_varying_desc_.stride; + eval_instance = OpenSubdiv::Osd::GetEvaluator( + evaluator_cache_, + src_varying_desc_, + dst_varying_desc, + device_context_); + EVALUATOR::EvalStencils(src_varying_data_, src_varying_desc_, + src_varying_data_, dst_varying_desc, + varying_stencils_, + eval_instance, device_context_); + } + // Evaluate face-varying data. + if (hasFaceVaryingData()) { + BufferDescriptor dst_face_varying_desc = src_face_varying_desc_; + dst_face_varying_desc.offset += num_coarse_face_varying_vertices_ * + src_face_varying_desc_.stride; + eval_instance = OpenSubdiv::Osd::GetEvaluator( + evaluator_cache_, + src_face_varying_desc_, + dst_face_varying_desc, + device_context_); + EVALUATOR::EvalStencils(src_face_varying_data_, src_face_varying_desc_, + src_face_varying_data_, dst_face_varying_desc, + face_varying_stencils_, + eval_instance, + device_context_); + } + } + + void evalPatchCoord(const PatchCoord& patch_coord, float P[3]) { + StackAllocatedBuffer<6, 1> vertex_data; + // TODO(sergey): Varying data is interleaved in vertex array, so need to + // adjust stride if there is a varying data. + // BufferDescriptor vertex_desc(0, 3, 6); + BufferDescriptor vertex_desc(0, 3, 3); + SinglePatchCoordBuffer patch_coord_buffer(patch_coord); + const EVALUATOR* eval_instance = + OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, + src_desc_, + vertex_desc, + device_context_); + EVALUATOR::EvalPatches(src_data_, + src_desc_, + &vertex_data, + vertex_desc, + patch_coord_buffer.GetNumVertices(), + &patch_coord_buffer, + patch_table_, + eval_instance, + device_context_); + const float* refined_vertices = vertex_data.BindCpuBuffer(); + memcpy(P, refined_vertices, sizeof(float) * 3); + } + + void evalPatchesWithDerivatives(const PatchCoord& patch_coord, + float P[3], + float dPdu[3], float dPdv[3]) { + StackAllocatedBuffer<6, 1> vertex_data, derivatives; + // TODO(sergey): Varying data is interleaved in vertex array, so need to + // adjust stride if there is a varying data. + // BufferDescriptor vertex_desc(0, 3, 6); + BufferDescriptor vertex_desc(0, 3, 3); + BufferDescriptor du_desc(0, 3, 6), dv_desc(3, 3, 6); + SinglePatchCoordBuffer patch_coord_buffer(patch_coord); + const EVALUATOR* eval_instance = + OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, + src_desc_, + vertex_desc, + du_desc, dv_desc, + device_context_); + EVALUATOR::EvalPatches(src_data_, src_desc_, + &vertex_data, vertex_desc, + &derivatives, du_desc, + &derivatives, dv_desc, + patch_coord_buffer.GetNumVertices(), + &patch_coord_buffer, + patch_table_, + eval_instance, + device_context_); + const float* refined_vertices = vertex_data.BindCpuBuffer(); + memcpy(P, refined_vertices, sizeof(float) * 3); + if (dPdu != NULL || dPdv != NULL) { + const float* refined_derivatives = derivatives.BindCpuBuffer(); + if (dPdu != NULL) { + memcpy(dPdu, refined_derivatives, sizeof(float) * 3); + } + if (dPdv != NULL) { + memcpy(dPdv, refined_derivatives + 3, sizeof(float) * 3); + } + } + } + + void evalPatchVarying(const PatchCoord& patch_coord, float varying[3]) { + StackAllocatedBuffer<6, 1> varying_data; + BufferDescriptor varying_desc(3, 3, 6); + SinglePatchCoordBuffer patch_coord_buffer(patch_coord); + const EVALUATOR* eval_instance = + OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, + src_varying_desc_, + varying_desc, + device_context_); + EVALUATOR::EvalPatchesVarying(src_varying_data_, src_varying_desc_, + &varying_data, varying_desc, + patch_coord_buffer.GetNumVertices(), + &patch_coord_buffer, + patch_table_, + eval_instance, + device_context_); + const float* refined_varying = varying_data.BindCpuBuffer(); + memcpy(varying, refined_varying, sizeof(float) * 3); + } + + void evalPatchFaceVarying(const PatchCoord& patch_coord, + float face_varying[2]) { + StackAllocatedBuffer<2, 1> face_varying_data; + BufferDescriptor face_varying_desc(0, 2, 2); + SinglePatchCoordBuffer patch_coord_buffer(patch_coord); + const EVALUATOR* eval_instance = + OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, + src_face_varying_desc_, + face_varying_desc, + device_context_); + EVALUATOR::EvalPatchesFaceVarying( + src_face_varying_data_, src_face_varying_desc_, + &face_varying_data, face_varying_desc, + patch_coord_buffer.GetNumVertices(), + &patch_coord_buffer, + patch_table_, + face_varying_channel_, + eval_instance, + device_context_); + const float* refined_face_varying = face_varying_data.BindCpuBuffer(); + memcpy(face_varying, refined_face_varying, sizeof(float) * 2); + } + + private: + SRC_VERTEX_BUFFER* src_data_; + SRC_VERTEX_BUFFER* src_varying_data_; + EVAL_VERTEX_BUFFER* src_face_varying_data_; + PatchCoordBuffer* patch_coords_; + PATCH_TABLE* patch_table_; + BufferDescriptor src_desc_; + BufferDescriptor src_varying_desc_; + BufferDescriptor src_face_varying_desc_; + + int num_coarse_vertices_; + int face_varying_channel_; + int face_varying_width_; + int num_coarse_face_varying_vertices_; + + const STENCIL_TABLE* vertex_stencils_; + const STENCIL_TABLE* varying_stencils_; + const STENCIL_TABLE* face_varying_stencils_; + + EvaluatorCache* evaluator_cache_; + DEVICE_CONTEXT* device_context_; +}; + +} // namespace + +// Note: Define as a class instead of typedcef to make it possible +// to have anonymous class in opensubdiv_evaluator_internal.h +class CpuEvalOutput : public VolatileEvalOutput { + public: + CpuEvalOutput(const StencilTable* vertex_stencils, + const StencilTable* varying_stencils, + const StencilTable* face_varying_stencils, + const int face_varying_channel, + const int face_varying_width, + const PatchTable* patch_table, + EvaluatorCache* evaluator_cache = NULL) + : VolatileEvalOutput (vertex_stencils, + varying_stencils, + face_varying_stencils, + face_varying_channel, + face_varying_width, + patch_table, + evaluator_cache) { + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// Evaluator wrapper for anonymous API. + +CpuEvalOutputAPI::CpuEvalOutputAPI(CpuEvalOutput* implementation, + OpenSubdiv::Far::PatchMap* patch_map) + : implementation_(implementation), + patch_map_(patch_map) { +} + +CpuEvalOutputAPI::~CpuEvalOutputAPI() { + delete implementation_; +} + +void CpuEvalOutputAPI::setCoarsePositions(const float* positions, + const int start_vertex_index, + const int num_vertices) { + // TODO(sergey): Add sanity check on indices. + implementation_->updateData(positions, start_vertex_index, num_vertices); +} + +void CpuEvalOutputAPI::setVaryingData(const float* varying_data, + const int start_vertex_index, + const int num_vertices) { + // TODO(sergey): Add sanity check on indices. + implementation_->updateVaryingData(varying_data, + start_vertex_index, + num_vertices); +} + +void CpuEvalOutputAPI::setFaceVaryingData(const float* face_varying_data, + const int start_vertex_index, + const int num_vertices) { + // TODO(sergey): Add sanity check on indices. + implementation_->updateFaceVaryingData(face_varying_data, + start_vertex_index, + num_vertices); +} + +void CpuEvalOutputAPI::setCoarsePositionsFromBuffer( + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices) { + // TODO(sergey): Add sanity check on indices. + const unsigned char* current_buffer = (unsigned char *)buffer; + current_buffer += start_offset; + for (int i = 0; i < num_vertices; ++i) { + const int current_vertex_index = start_vertex_index + i; + implementation_->updateData(reinterpret_cast(current_buffer), + current_vertex_index, 1); + current_buffer += stride; + } +} + +void CpuEvalOutputAPI::setVaryingDataFromBuffer( + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices) { + // TODO(sergey): Add sanity check on indices. + const unsigned char* current_buffer = (unsigned char *)buffer; + current_buffer += start_offset; + for (int i = 0; i < num_vertices; ++i) { + const int current_vertex_index = start_vertex_index + i; + implementation_->updateVaryingData( + reinterpret_cast(current_buffer), + current_vertex_index, 1); + current_buffer += stride; + } +} + +void CpuEvalOutputAPI::setFaceVaryingDataFromBuffer( + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices) { + // TODO(sergey): Add sanity check on indices. + const unsigned char* current_buffer = (unsigned char *)buffer; + current_buffer += start_offset; + for (int i = 0; i < num_vertices; ++i) { + const int current_vertex_index = start_vertex_index + i; + implementation_->updateFaceVaryingData( + reinterpret_cast(current_buffer), + current_vertex_index, 1); + current_buffer += stride; + } +} + +void CpuEvalOutputAPI::refine() { + implementation_->refine(); +} + +void CpuEvalOutputAPI::evaluateLimit(const int ptex_face_index, + float face_u, float face_v, + float P[3], float dPdu[3], float dPdv[3]) { + assert(face_u >= 0.0f); + assert(face_u <= 1.0f); + assert(face_v >= 0.0f); + assert(face_v <= 1.0f); + const PatchTable::PatchHandle* handle = + patch_map_->FindPatch(ptex_face_index, face_u, face_v); + PatchCoord patch_coord(*handle, face_u, face_v); + if (dPdu != NULL || dPdv != NULL) { + implementation_->evalPatchesWithDerivatives(patch_coord, P, dPdu, dPdv); + } else { + implementation_->evalPatchCoord(patch_coord, P); + }} + +void CpuEvalOutputAPI::evaluateVarying(const int ptex_face_index, + float face_u, float face_v, + float varying[3]) { + assert(face_u >= 0.0f); + assert(face_u <= 1.0f); + assert(face_v >= 0.0f); + assert(face_v <= 1.0f); + const PatchTable::PatchHandle* handle = + patch_map_->FindPatch(ptex_face_index, face_u, face_v); + PatchCoord patch_coord(*handle, face_u, face_v); + implementation_->evalPatchVarying(patch_coord, varying); +} + +void CpuEvalOutputAPI::evaluateFaceVarying(const int ptex_face_index, + float face_u, float face_v, + float face_varying[2]) { + assert(face_u >= 0.0f); + assert(face_u <= 1.0f); + assert(face_v >= 0.0f); + assert(face_v <= 1.0f); + const PatchTable::PatchHandle* handle = + patch_map_->FindPatch(ptex_face_index, face_u, face_v); + PatchCoord patch_coord(*handle, face_u, face_v); + implementation_->evalPatchFaceVarying(patch_coord, face_varying); +} + +} // namespace opensubdiv_capi + +OpenSubdiv_EvaluatorInternal::OpenSubdiv_EvaluatorInternal() + : eval_output(NULL), + patch_map(NULL), + patch_table(NULL) { +} + +OpenSubdiv_EvaluatorInternal::~OpenSubdiv_EvaluatorInternal() { + delete eval_output; + delete patch_map; + delete patch_table; +} + +OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal( + OpenSubdiv_TopologyRefiner* topology_refiner) { + TopologyRefiner* refiner = topology_refiner->internal->osd_topology_refiner; + if (refiner == NULL) { + // Happens on bad topology. + return NULL; + } + // TODO(sergey): Base this on actual topology. + // const bool bas_varying_data = false; + const bool has_face_varying_data = + (refiner->GetNumFVarChannels() != 0); + const int level = topology_refiner->getSubdivisionLevel(topology_refiner); + // TODO(sergey): Query from topology refiner. + const bool is_adaptive = topology_refiner->getIsAdaptive(topology_refiner); + // Refine the topology with given settings. + // TODO(sergey): What if topology is already refined? + if (is_adaptive) { + TopologyRefiner::AdaptiveOptions options(level); + options.considerFVarChannels = has_face_varying_data; + options.useInfSharpPatch = false; + refiner->RefineAdaptive(options); + } else { + TopologyRefiner::UniformOptions options(level); + refiner->RefineUniform(options); + } + // Generate stencil table to update the bi-cubic patches control vertices + // after they have been re-posed (both for vertex & varying interpolation). + // + // Vertex stencils. + StencilTableFactory::Options vertex_stencil_options; + vertex_stencil_options.generateOffsets = true; + vertex_stencil_options.generateIntermediateLevels = is_adaptive; + const StencilTable* vertex_stencils = + StencilTableFactory::Create(*refiner, vertex_stencil_options); + // Varying stencils. + // + // TODO(sergey): Seems currently varying stencils are always required in + // OpenSubdiv itself. + const StencilTable* varying_stencils = NULL; + StencilTableFactory::Options varying_stencil_options; + varying_stencil_options.generateOffsets = true; + varying_stencil_options.generateIntermediateLevels = is_adaptive; + varying_stencil_options.interpolationMode = + StencilTableFactory::INTERPOLATE_VARYING; + varying_stencils = + StencilTableFactory::Create(*refiner, varying_stencil_options); + // Face warying stencil. + const StencilTable* face_varying_stencils = NULL; + if (has_face_varying_data) { + StencilTableFactory::Options face_varying_stencil_options; + face_varying_stencil_options.generateOffsets = true; + face_varying_stencil_options.generateIntermediateLevels = is_adaptive; + face_varying_stencil_options.interpolationMode = + StencilTableFactory::INTERPOLATE_FACE_VARYING; + // TODO(sergey): Make it configurable which face varying channel is being + // interpolated. + face_varying_stencil_options.fvarChannel = 0; + face_varying_stencils = + StencilTableFactory::Create(*refiner, face_varying_stencil_options); + } + // Generate bi-cubic patch table for the limit surface. + // TODO(sergey): Ideally we would want to expose end-cap settings via + // C-API to make it more generic. Currently it matches old Blender's + // subsurf code. + PatchTableFactory::Options patch_options(level); + patch_options.SetEndCapType(PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS); + patch_options.useInfSharpPatch = false; + patch_options.generateFVarTables = has_face_varying_data; + patch_options.generateFVarLegacyLinearPatches = false; + const PatchTable* patch_table = PatchTableFactory::Create( + *refiner, patch_options); + // Append local points stencils. + const StencilTable* local_point_stencil_table = + patch_table->GetLocalPointStencilTable(); + if (local_point_stencil_table != NULL) { + const StencilTable* table = + StencilTableFactory::AppendLocalPointStencilTable( + *refiner, vertex_stencils, local_point_stencil_table); + delete vertex_stencils; + vertex_stencils = table; + } + const StencilTable* local_point_varying_stencil_table = + patch_table->GetLocalPointVaryingStencilTable(); + if (local_point_varying_stencil_table != NULL) { + const StencilTable* table = + StencilTableFactory::AppendLocalPointStencilTable( + *refiner, varying_stencils, local_point_varying_stencil_table); + delete varying_stencils; + varying_stencils = table; + } + const StencilTable* local_point_face_varying_stencil_table = + patch_table->GetLocalPointFaceVaryingStencilTable(); + if (local_point_face_varying_stencil_table != NULL) { + const StencilTable* table = + StencilTableFactory::AppendLocalPointStencilTableFaceVarying( + *refiner, + face_varying_stencils, + local_point_face_varying_stencil_table); + delete face_varying_stencils; + face_varying_stencils = table; + } + // Create OpenSubdiv's CPU side evaluator. + // TODO(sergey): Make it possible to use different evaluators. + opensubdiv_capi::CpuEvalOutput* eval_output = + new opensubdiv_capi::CpuEvalOutput(vertex_stencils, + varying_stencils, + face_varying_stencils, + 0, 2, + patch_table); + OpenSubdiv::Far::PatchMap* patch_map = new PatchMap(*patch_table); + // Wrap everything we need into an object which we control from our side. + OpenSubdiv_EvaluatorInternal* evaluator_descr; + evaluator_descr = OBJECT_GUARDED_NEW(OpenSubdiv_EvaluatorInternal); + evaluator_descr->eval_output = + new opensubdiv_capi::CpuEvalOutputAPI(eval_output, patch_map); + evaluator_descr->patch_map = patch_map; + evaluator_descr->patch_table = patch_table; + // TOOD(sergey): Look into whether we've got duplicated stencils arrays. + delete vertex_stencils; + delete varying_stencils; + delete face_varying_stencils; + return evaluator_descr; +} + +void openSubdiv_deleteEvaluatorInternal( + OpenSubdiv_EvaluatorInternal* evaluator) { + OBJECT_GUARDED_DELETE(evaluator, OpenSubdiv_EvaluatorInternal); +} diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h new file mode 100644 index 00000000000..cc69db6abc6 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h @@ -0,0 +1,134 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_EVALUATOR_INTERNAL_H_ +#define OPENSUBDIV_EVALUATOR_INTERNAL_H_ + +#ifdef _MSC_VER +# include +#endif + +#include +#include + +struct OpenSubdiv_TopologyRefiner; + +namespace opensubdiv_capi { + +// Anonymous forward declaration of actual evaluator implementation. +class CpuEvalOutput; + +// Wrapper around implementaiton, which defines API which we are capable to +// provide over the implementation. +// +// TODO(sergey): It is almost the same as C-API object, so ideally need to +// merge them somehow, but how to do this and keep files with all the templates +// and such separate? +class CpuEvalOutputAPI { + public: + // NOTE: API object becomes an owner of evaluator. Patch we are referencing. + CpuEvalOutputAPI(CpuEvalOutput* implementation, + OpenSubdiv::Far::PatchMap* patch_map); + ~CpuEvalOutputAPI(); + + // Set coarse positions from a continuous array of coordinates. + void setCoarsePositions(const float* positions, + const int start_vertex_index, + const int num_vertices); + // Set varying data from a continuous array of data. + void setVaryingData(const float* varying_data, + const int start_vertex_index, const int num_vertices); + // Set face varying data from a continuous array of data. + // + // TODO(sergey): Find a better name for vertex here. It is not the vertex of + // geometry, but a vertex of UV map. + void setFaceVaryingData(const float* varying_data, + const int start_vertex_index, const int num_vertices); + + // Set coarse vertex position from a continuous memory buffer where + // first coordinate starts at offset of `start_offset` and there is `stride` + // bytes between adjacent vertex coordinates. + void setCoarsePositionsFromBuffer(const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices); + // Set varying data from a continuous memory buffer where + // first coordinate starts at offset of `start_offset` and there is `stride` + // bytes between adjacent vertex coordinates. + void setVaryingDataFromBuffer(const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices); + // Set face varying data from a continuous memory buffer where + // first coordinate starts at offset of `start_offset` and there is `stride` + // bytes between adjacent vertex coordinates. + // + // TODO(sergey): Find a better name for vertex here. It is not the vertex of + // geometry, but a vertex of UV map. + void setFaceVaryingDataFromBuffer(const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices); + + // Refine after coarse positions update. + void refine(); + + // Evaluate given ptex face at given bilinear coordinate. + // If derivatives are NULL, they will not be evaluated. + void evaluateLimit(const int ptex_face_index, + float face_u, float face_v, + float P[3], float dPdu[3], float dPdv[3]); + + // Evaluate varying data at a given bilinear coordinate of given ptex face. + void evaluateVarying(const int ptes_face_index, + float face_u, float face_v, + float varying[3]); + + // Evaluate facee-varying data at a given bilinear coordinate of given + // ptex face. + void evaluateFaceVarying(const int ptes_face_index, + float face_u, float face_v, + float face_varying[2]); + + protected: + CpuEvalOutput* implementation_; + OpenSubdiv::Far::PatchMap* patch_map_; +}; + +} // namespace opensubdiv_capi + +struct OpenSubdiv_EvaluatorInternal { + public: + OpenSubdiv_EvaluatorInternal(); + ~OpenSubdiv_EvaluatorInternal(); + + opensubdiv_capi::CpuEvalOutputAPI* eval_output; + const OpenSubdiv::Far::PatchMap* patch_map; + const OpenSubdiv::Far::PatchTable* patch_table; +}; + +OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal( + struct OpenSubdiv_TopologyRefiner* topology_refiner); + +void openSubdiv_deleteEvaluatorInternal( + OpenSubdiv_EvaluatorInternal* evaluator); + +#endif // OPENSUBDIV_EVALUATOR_INTERNAL_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc new file mode 100644 index 00000000000..34d27591d0b --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc @@ -0,0 +1,287 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin +// Contributor(s): Brecht van Lommel + +#include "opensubdiv_gl_mesh_capi.h" + +#ifdef _MSC_VER +# include +#endif + +#include +#include +#include + +using OpenSubdiv::Far::StencilTable; +using OpenSubdiv::Osd::GLMeshInterface; +using OpenSubdiv::Osd::GLPatchTable; +using OpenSubdiv::Osd::Mesh; +using OpenSubdiv::Osd::MeshBitset; + +// CPU backend. +#include +#include +using OpenSubdiv::Osd::CpuGLVertexBuffer; +using OpenSubdiv::Osd::CpuEvaluator; +typedef Mesh OsdCpuMesh; +// OpenMP backend. +#ifdef OPENSUBDIV_HAS_OPENMP +# include +using OpenSubdiv::Osd::OmpEvaluator; +typedef Mesh OsdOmpMesh; +#endif +// OpenCL backend. +#ifdef OPENSUBDIV_HAS_OPENCL +# include +# include +# include "opensubdiv_device_context_opencl.h" +using OpenSubdiv::Osd::CLEvaluator; +using OpenSubdiv::Osd::CLGLVertexBuffer; +using OpenSubdiv::Osd::CLStencilTable; +/* TODO(sergey): Use CLDeviceContext similar to OSD examples? */ +typedef Mesh OsdCLMesh; +static CLDeviceContext g_cl_device_context; +#endif +// CUDA backend. +#ifdef OPENSUBDIV_HAS_CUDA +# include +# include +# include "opensubdiv_device_context_cuda.h" +using OpenSubdiv::Osd::CudaEvaluator; +using OpenSubdiv::Osd::CudaGLVertexBuffer; +using OpenSubdiv::Osd::CudaStencilTable; +typedef Mesh OsdCudaMesh; +static CudaDeviceContext g_cuda_device_context; +#endif +// Transform feedback backend. +#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK +# include +# include +using OpenSubdiv::Osd::GLXFBEvaluator; +using OpenSubdiv::Osd::GLStencilTableTBO; +using OpenSubdiv::Osd::GLVertexBuffer; +typedef Mesh OsdGLSLTransformFeedbackMesh; +#endif +// GLSL compute backend. +#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE +# include +# include +using OpenSubdiv::Osd::GLComputeEvaluator; +using OpenSubdiv::Osd::GLStencilTableSSBO; +using OpenSubdiv::Osd::GLVertexBuffer; +typedef Mesh OsdGLSLComputeMesh; +#endif + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "opensubdiv_topology_refiner_capi.h" +#include "internal/opensubdiv_gl_mesh_draw.h" +#include "internal/opensubdiv_gl_mesh_fvar.h" +#include "internal/opensubdiv_gl_mesh_internal.h" +#include "internal/opensubdiv_topology_refiner_internal.h" + +namespace { + +GLMeshInterface* createGLMeshInterface( + OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const MeshBitset& bits, + const int num_vertex_elements, + const int num_varying_elements, + const int level, + eOpenSubdivEvaluator evaluator_type) { + GLMeshInterface* mesh = NULL; + switch (evaluator_type) { +#define CHECK_EVALUATOR_TYPE(type, class) \ + case OPENSUBDIV_EVALUATOR_##type: \ + mesh = new class(topology_refiner, \ + num_vertex_elements, \ + num_varying_elements, \ + level, \ + bits); \ + break; + +#define CHECK_EVALUATOR_TYPE_STUB(type) \ + case OPENSUBDIV_EVALUATOR_##type: \ + mesh = NULL; \ + break; + + CHECK_EVALUATOR_TYPE(CPU, OsdCpuMesh) +#ifdef OPENSUBDIV_HAS_OPENMP + CHECK_EVALUATOR_TYPE(OPENMP, OsdOmpMesh) +#else + CHECK_EVALUATOR_TYPE_STUB(OPENMP) +#endif +#ifdef OPENSUBDIV_HAS_OPENCL + CHECK_EVALUATOR_TYPE(OPENCL, OsdCLMesh) +#else + CHECK_EVALUATOR_TYPE_STUB(OPENCL) +#endif +#ifdef OPENSUBDIV_HAS_CUDA + CHECK_EVALUATOR_TYPE(CUDA, OsdCudaMesh) +#else + CHECK_EVALUATOR_TYPE_STUB(CUDA) +#endif +#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK + CHECK_EVALUATOR_TYPE(GLSL_TRANSFORM_FEEDBACK, OsdGLSLTransformFeedbackMesh) +#else + CHECK_EVALUATOR_TYPE_STUB(GLSL_TRANSFORM_FEEDBACK) +#endif +#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE + CHECK_EVALUATOR_TYPE(GLSL_COMPUTE, OsdGLSLComputeMesh) +#else + CHECK_EVALUATOR_TYPE_STUB(GLSL_COMPUTE) +#endif + +#undef CHECK_EVALUATOR_TYPE +#undef CHECK_EVALUATOR_TYPE_STUB + } + return mesh; +} + +//////////////////////////////////////////////////////////////////////////////// +// GLMesh structure "methods". + +opensubdiv_capi::GLMeshFVarData* createFVarData( + OpenSubdiv::Far::TopologyRefiner* topology_refiner, + GLMeshInterface* mesh, + const float *fvar_src_buffer) { + using opensubdiv_capi::GLMeshFVarData; + GLMeshFVarData* fvar_data = new GLMeshFVarData(); + fvar_data->create(topology_refiner, + mesh->GetFarPatchTable(), + 2, + fvar_src_buffer); + return fvar_data; +} + +unsigned int getPatchIndexBuffer(OpenSubdiv_GLMesh* gl_mesh) { + return gl_mesh->internal->mesh_interface + ->GetPatchTable() + ->GetPatchIndexBuffer(); +} + +void bindVertexBuffer(OpenSubdiv_GLMesh* gl_mesh) { + gl_mesh->internal->mesh_interface->BindVertexBuffer(); +} + +void setCoarsePositions(OpenSubdiv_GLMesh* gl_mesh, + const float* positions, + const int start_vertex, + const int num_vertices) { + gl_mesh->internal->mesh_interface->UpdateVertexBuffer(positions, + start_vertex, + num_vertices); +} + +void refine(OpenSubdiv_GLMesh* gl_mesh) { + gl_mesh->internal->mesh_interface->Refine(); +} + +void synchronize(struct OpenSubdiv_GLMesh* gl_mesh) { + gl_mesh->internal->mesh_interface->Synchronize(); +} + +void assignFunctionPointers(OpenSubdiv_GLMesh* gl_mesh) { + gl_mesh->getPatchIndexBuffer = getPatchIndexBuffer; + gl_mesh->bindVertexBuffer = bindVertexBuffer; + gl_mesh->setCoarsePositions = setCoarsePositions; + gl_mesh->refine = refine; + gl_mesh->synchronize = synchronize; + + gl_mesh->prepareDraw = opensubdiv_capi::GLMeshDisplayPrepare; + gl_mesh->drawPatches = opensubdiv_capi::GLMeshDisplayDrawPatches; +} + +} // namespace + +struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner( + OpenSubdiv_TopologyRefiner* topology_refiner, + eOpenSubdivEvaluator evaluator_type) { + using OpenSubdiv::Far::TopologyRefiner; + TopologyRefiner* osd_topology_refiner = + topology_refiner->internal->osd_topology_refiner; + // TODO(sergey): Query this from refiner. + const bool is_adaptive = false; + MeshBitset bits; + bits.set(OpenSubdiv::Osd::MeshAdaptive, is_adaptive); + bits.set(OpenSubdiv::Osd::MeshUseSingleCreasePatch, 0); + bits.set(OpenSubdiv::Osd::MeshInterleaveVarying, 1); + bits.set(OpenSubdiv::Osd::MeshFVarData, 1); + bits.set(OpenSubdiv::Osd::MeshEndCapBSplineBasis, 1); + const int num_vertex_elements = 3; + const int num_varying_elements = 3; + GLMeshInterface* mesh = createGLMeshInterface( + osd_topology_refiner, + bits, + num_vertex_elements, + num_varying_elements, + osd_topology_refiner->GetMaxLevel(), + evaluator_type); + if (mesh == NULL) { + return NULL; + } + OpenSubdiv_GLMesh* gl_mesh = OBJECT_GUARDED_NEW(OpenSubdiv_GLMesh); + assignFunctionPointers(gl_mesh); + gl_mesh->internal = new OpenSubdiv_GLMeshInternal(); + gl_mesh->internal->evaluator_type = evaluator_type; + gl_mesh->internal->mesh_interface = mesh; + // Face-varying support. + // TODO(sergey): This part needs to be re-done. + if (osd_topology_refiner->GetNumFVarChannels() > 0) { + // TODO(sergey): This is a temporary stub to get things compiled. Need + // to store base level UVs somewhere else. + std::vector uvs; + std::vector fvar_data_buffer; + opensubdiv_capi::interpolateFVarData(*osd_topology_refiner, + uvs, + &fvar_data_buffer); + gl_mesh->internal->fvar_data = createFVarData(osd_topology_refiner, + mesh, + &fvar_data_buffer[0]); + } else { + gl_mesh->internal->fvar_data = NULL; + } + return gl_mesh; +} + +void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh) { + delete gl_mesh->internal; + OBJECT_GUARDED_DELETE(gl_mesh, OpenSubdiv_GLMesh); +} diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc new file mode 100644 index 00000000000..0d2f8dc9842 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc @@ -0,0 +1,587 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/opensubdiv_gl_mesh_draw.h" + +#ifdef _MSC_VER +# include +#endif + +#include +#include +#include + +#include + +#ifdef OPENSUBDIV_HAS_CUDA +# include +#endif // OPENSUBDIV_HAS_CUDA + +#include +#include + +#include "internal/opensubdiv_gl_mesh_fvar.h" +#include "internal/opensubdiv_gl_mesh_internal.h" +#include "opensubdiv_capi.h" +#include "opensubdiv_gl_mesh_capi.h" + +using OpenSubdiv::Osd::GLMeshInterface; + +extern "C" char datatoc_gpu_shader_opensubdiv_vertex_glsl[]; +extern "C" char datatoc_gpu_shader_opensubdiv_geometry_glsl[]; +extern "C" char datatoc_gpu_shader_opensubdiv_fragment_glsl[]; + +// TODO(sergey): Those are a bit of bad level calls :S +extern "C" { +void copy_m3_m3(float m1[3][3], float m2[3][3]); +void copy_m3_m4(float m1[3][3], float m2[4][4]); +void adjoint_m3_m3(float m1[3][3], float m[3][3]); +float determinant_m3_array(float m[3][3]); +bool invert_m3_m3(float m1[3][3], float m2[3][3]); +bool invert_m3(float m[3][3]); +void transpose_m3(float mat[3][3]); +} + +#define MAX_LIGHTS 8 +#define SUPPORT_COLOR_MATERIAL + +typedef struct Light { + float position[4]; + float ambient[4]; + float diffuse[4]; + float specular[4]; + float spot_direction[4]; +#ifdef SUPPORT_COLOR_MATERIAL + float constant_attenuation; + float linear_attenuation; + float quadratic_attenuation; + float spot_cutoff; + float spot_exponent; + float spot_cos_cutoff; + float pad, pad2; +#endif +} Light; + +typedef struct Lighting { + Light lights[MAX_LIGHTS]; + int num_enabled; +} Lighting; + +typedef struct Transform { + float projection_matrix[16]; + float model_view_matrix[16]; + float normal_matrix[9]; +} Transform; + +static bool g_use_osd_glsl = false; +static int g_active_uv_index = 0; + +static GLuint g_flat_fill_solid_program = 0; +static GLuint g_flat_fill_texture2d_program = 0; +static GLuint g_smooth_fill_solid_program = 0; +static GLuint g_smooth_fill_texture2d_program = 0; + +static GLuint g_flat_fill_solid_shadeless_program = 0; +static GLuint g_flat_fill_texture2d_shadeless_program = 0; +static GLuint g_smooth_fill_solid_shadeless_program = 0; +static GLuint g_smooth_fill_texture2d_shadeless_program = 0; + +static GLuint g_wireframe_program = 0; + +static GLuint g_lighting_ub = 0; +static Lighting g_lighting_data; +static Transform g_transform; + +namespace { + +GLuint compileShader(GLenum shaderType, + const char* version, + const char* define, + const char* source) { + const char* sources[] = { + version, define, +#ifdef SUPPORT_COLOR_MATERIAL + "#define SUPPORT_COLOR_MATERIAL\n", +#else + "", +#endif + source, + }; + + GLuint shader = glCreateShader(shaderType); + glShaderSource(shader, 4, sources, NULL); + glCompileShader(shader); + + GLint status; + glGetShaderiv(shader, GL_COMPILE_STATUS, &status); + if (status == GL_FALSE) { + GLchar emsg[1024]; + glGetShaderInfoLog(shader, sizeof(emsg), 0, emsg); + fprintf(stderr, "Error compiling GLSL: %s\n", emsg); + fprintf(stderr, "Version: %s\n", version); + fprintf(stderr, "Defines: %s\n", define); + fprintf(stderr, "Source: %s\n", source); + return 0; + } + + return shader; +} + +GLuint linkProgram(const char* version, const char* define) { + GLuint vertexShader = + compileShader(GL_VERTEX_SHADER, version, define, + datatoc_gpu_shader_opensubdiv_vertex_glsl); + if (vertexShader == 0) { + return 0; + } + GLuint geometryShader = + compileShader(GL_GEOMETRY_SHADER, version, define, + datatoc_gpu_shader_opensubdiv_geometry_glsl); + if (geometryShader == 0) { + return 0; + } + GLuint fragmentShader = + compileShader(GL_FRAGMENT_SHADER, version, define, + datatoc_gpu_shader_opensubdiv_fragment_glsl); + if (fragmentShader == 0) { + return 0; + } + + GLuint program = glCreateProgram(); + + glAttachShader(program, vertexShader); + glAttachShader(program, geometryShader); + glAttachShader(program, fragmentShader); + + glBindAttribLocation(program, 0, "position"); + glBindAttribLocation(program, 1, "normal"); + + glLinkProgram(program); + + glDeleteShader(vertexShader); + glDeleteShader(geometryShader); + glDeleteShader(fragmentShader); + + GLint status; + glGetProgramiv(program, GL_LINK_STATUS, &status); + if (status == GL_FALSE) { + GLchar emsg[1024]; + glGetProgramInfoLog(program, sizeof(emsg), 0, emsg); + fprintf(stderr, "Error linking GLSL program : %s\n", emsg); + fprintf(stderr, "Defines: %s\n", define); + glDeleteProgram(program); + return 0; + } + + glUniformBlockBinding(program, glGetUniformBlockIndex(program, "Lighting"), + 0); + + if (GLEW_VERSION_4_1) { + glProgramUniform1i( + program, glGetUniformLocation(program, "texture_buffer"), 0); + glProgramUniform1i( + program, glGetUniformLocation(program, "FVarDataOffsetBuffer"), 30); + glProgramUniform1i( + program, glGetUniformLocation(program, "FVarDataBuffer"), 31); + } else { + glUseProgram(program); + glUniform1i(glGetUniformLocation(program, "texture_buffer"), 0); + glUniform1i(glGetUniformLocation(program, "FVarDataOffsetBuffer"), 30); + glUniform1i(glGetUniformLocation(program, "FVarDataBuffer"), 31); + glUseProgram(0); + } + + return program; +} + +void bindProgram(OpenSubdiv_GLMesh* gl_mesh, int program) { + glUseProgram(program); + // Matrices + glUniformMatrix4fv(glGetUniformLocation(program, "modelViewMatrix"), + 1, + false, + g_transform.model_view_matrix); + glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), + 1, + false, + g_transform.projection_matrix); + glUniformMatrix3fv(glGetUniformLocation(program, "normalMatrix"), + 1, + false, + g_transform.normal_matrix); + // Lighting. + glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub); + glBufferSubData( + GL_UNIFORM_BUFFER, 0, sizeof(g_lighting_data), &g_lighting_data); + glBindBuffer(GL_UNIFORM_BUFFER, 0); + glBindBufferBase(GL_UNIFORM_BUFFER, 0, g_lighting_ub); + // Color. + { + // TODO(sergey): Stop using glGetMaterial. + float color[4]; + glGetMaterialfv(GL_FRONT, GL_DIFFUSE, color); + glUniform4fv(glGetUniformLocation(program, "diffuse"), 1, color); + glGetMaterialfv(GL_FRONT, GL_SPECULAR, color); + glUniform4fv(glGetUniformLocation(program, "specular"), 1, color); + glGetMaterialfv(GL_FRONT, GL_SHININESS, color); + glUniform1f(glGetUniformLocation(program, "shininess"), color[0]); + } + // Face-vertex data. + opensubdiv_capi::GLMeshFVarData* fvar_data = gl_mesh->internal->fvar_data; + if (fvar_data != NULL) { + if (fvar_data->texture_buffer) { + glActiveTexture(GL_TEXTURE31); + glBindTexture(GL_TEXTURE_BUFFER, fvar_data->texture_buffer); + glActiveTexture(GL_TEXTURE0); + } + if (fvar_data->offset_buffer) { + glActiveTexture(GL_TEXTURE30); + glBindTexture(GL_TEXTURE_BUFFER, fvar_data->offset_buffer); + glActiveTexture(GL_TEXTURE0); + } + glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), + fvar_data->fvar_width); + if (fvar_data->channel_offsets.size() > 0 && g_active_uv_index >= 0) { + glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), + fvar_data->channel_offsets[g_active_uv_index]); + } else { + glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); + } + } else { + glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0); + glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); + } +} + +} // namespace + +bool openSubdiv_initGLMeshDrawingResources(void) { + static bool need_init = true; + static bool init_success = false; + if (!need_init) { + return init_success; + } + // TODO(sergey): Update OSD drawing to OpenGL 3.3 core, + // then remove following line. + return false; + const char* version = ""; + if (GLEW_VERSION_3_2) { + version = "#version 150 compatibility\n"; + } else if (GLEW_VERSION_3_1) { + version = "#version 140\n" + "#extension GL_ARB_compatibility: enable\n"; + } else { + version = "#version 130\n"; + // Minimum supported for OpenSubdiv. + } + g_flat_fill_solid_program = linkProgram(version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_LIGHTING\n" + "#define FLAT_SHADING\n"); + g_flat_fill_texture2d_program = linkProgram(version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_LIGHTING\n" + "#define USE_TEXTURE_2D\n" + "#define FLAT_SHADING\n"); + g_smooth_fill_solid_program = linkProgram(version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_LIGHTING\n" + "#define SMOOTH_SHADING\n"); + g_smooth_fill_texture2d_program = linkProgram(version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_LIGHTING\n" + "#define USE_TEXTURE_2D\n" + "#define SMOOTH_SHADING\n"); + + g_flat_fill_solid_shadeless_program = + linkProgram(version, + "#define USE_COLOR_MATERIAL\n" + "#define FLAT_SHADING\n"); + g_flat_fill_texture2d_shadeless_program = + linkProgram(version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_TEXTURE_2D\n" + "#define FLAT_SHADING\n"); + g_smooth_fill_solid_shadeless_program = + linkProgram(version, + "#define USE_COLOR_MATERIAL\n" + "#define SMOOTH_SHADING\n"); + g_smooth_fill_texture2d_shadeless_program = + linkProgram(version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_TEXTURE_2D\n" + "#define SMOOTH_SHADING\n"); + g_wireframe_program = linkProgram(version, "#define WIREFRAME\n"); + + glGenBuffers(1, &g_lighting_ub); + glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub); + glBufferData(GL_UNIFORM_BUFFER, + sizeof(g_lighting_data), + NULL, + GL_STATIC_DRAW); + need_init = false; + init_success = g_flat_fill_solid_program != 0 && + g_flat_fill_texture2d_program != 0 && + g_smooth_fill_solid_program != 0 && + g_smooth_fill_texture2d_program != 0 && g_wireframe_program; + return init_success; +} + +void openSubdiv_deinitGLMeshDrawingResources(void) { + if (g_lighting_ub != 0) { + glDeleteBuffers(1, &g_lighting_ub); + } +#define SAFE_DELETE_PROGRAM(program) \ + do { \ + if (program) { \ + glDeleteProgram(program); \ + } \ + } while (false) + + SAFE_DELETE_PROGRAM(g_flat_fill_solid_program); + SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_program); + SAFE_DELETE_PROGRAM(g_smooth_fill_solid_program); + SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_program); + SAFE_DELETE_PROGRAM(g_flat_fill_solid_shadeless_program); + SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_shadeless_program); + SAFE_DELETE_PROGRAM(g_smooth_fill_solid_shadeless_program); + SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_shadeless_program); + SAFE_DELETE_PROGRAM(g_wireframe_program); + +#undef SAFE_DELETE_PROGRAM +} + +namespace opensubdiv_capi { + +namespace { + +GLuint prepare_patchDraw(OpenSubdiv_GLMesh* gl_mesh, bool fill_quads) { + GLint program = 0; + if (!g_use_osd_glsl) { + glGetIntegerv(GL_CURRENT_PROGRAM, &program); + if (program) { + GLint model; + glGetIntegerv(GL_SHADE_MODEL, &model); + GLint location = glGetUniformLocation(program, "osd_flat_shading"); + if (location != -1) { + glUniform1i(location, model == GL_FLAT); + } + // Face-vertex data. + opensubdiv_capi::GLMeshFVarData* fvar_data = gl_mesh->internal->fvar_data; + if (fvar_data != NULL) { + if (fvar_data->texture_buffer) { + glActiveTexture(GL_TEXTURE31); + glBindTexture(GL_TEXTURE_BUFFER, fvar_data->texture_buffer); + glActiveTexture(GL_TEXTURE0); + } + if (fvar_data->offset_buffer) { + glActiveTexture(GL_TEXTURE30); + glBindTexture(GL_TEXTURE_BUFFER, fvar_data->offset_buffer); + glActiveTexture(GL_TEXTURE0); + } + GLint location = glGetUniformLocation(program, "osd_fvar_count"); + if (location != -1) { + glUniform1i(location, fvar_data->fvar_width); + } + location = glGetUniformLocation(program, "osd_active_uv_offset"); + if (location != -1) { + if (fvar_data->channel_offsets.size() > 0 && g_active_uv_index >= 0) { + glUniform1i(location, + fvar_data->channel_offsets[g_active_uv_index]); + } else { + glUniform1i(location, 0); + } + } + } else { + glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0); + glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); + } + } + return program; + } + if (fill_quads) { + int model; + GLboolean use_texture_2d; + glGetIntegerv(GL_SHADE_MODEL, &model); + glGetBooleanv(GL_TEXTURE_2D, &use_texture_2d); + if (model == GL_FLAT) { + if (use_texture_2d) { + program = g_flat_fill_texture2d_program; + } else { + program = g_flat_fill_solid_program; + } + } else { + if (use_texture_2d) { + program = g_smooth_fill_texture2d_program; + } else { + program = g_smooth_fill_solid_program; + } + } + + } else { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + program = g_wireframe_program; + } + bindProgram(gl_mesh, program); + return program; +} + +void perform_drawElements(GLuint program, + int patch_index, + int num_elements, + int start_element) { + if (program) { + glUniform1i(glGetUniformLocation(program, "PrimitiveIdBase"), patch_index); + } + glDrawElements(GL_LINES_ADJACENCY, + num_elements, + GL_UNSIGNED_INT, + reinterpret_cast(start_element * sizeof(unsigned int))); +} + +void finishPatchDraw(bool fill_quads) { + // TODO(sergey): Some of the stuff could be done once after the whole + // mesh is displayed. + /// Restore state. + if (!fill_quads) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + glBindVertexArray(0); + if (g_use_osd_glsl) { + // TODO(sergey): Store previously used program and roll back to it? + glUseProgram(0); + } +} + +void drawPartitionPatchesRange(GLMeshInterface* mesh, + GLuint program, + int start_patch, + int num_patches) { + int traversed_patches = 0, num_remained_patches = num_patches; + const OpenSubdiv::Osd::PatchArrayVector &patches = + mesh->GetPatchTable()->GetPatchArrays(); + for (int i = 0; i < patches.size(); ++i) { + const OpenSubdiv::Osd::PatchArray &patch = patches[i]; + OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor(); + OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType(); + if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) { + const int num_block_patches = patch.GetNumPatches(); + if (start_patch >= traversed_patches && + start_patch < traversed_patches + num_block_patches) { + const int num_control_verts = desc.GetNumControlVertices(); + const int start_draw_patch = start_patch - traversed_patches; + const int num_draw_patches = std::min( + num_remained_patches, num_block_patches - start_draw_patch); + perform_drawElements( + program, i + start_draw_patch, num_draw_patches * num_control_verts, + patch.GetIndexBase() + start_draw_patch * num_control_verts); + num_remained_patches -= num_draw_patches; + } + if (num_remained_patches == 0) { + break; + } + traversed_patches += num_block_patches; + } + } +} + +static void drawAllPatches(GLMeshInterface* mesh, GLuint program) { + const OpenSubdiv::Osd::PatchArrayVector &patches = + mesh->GetPatchTable()->GetPatchArrays(); + for (int i = 0; i < patches.size(); ++i) { + const OpenSubdiv::Osd::PatchArray &patch = patches[i]; + OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor(); + OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType(); + + if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) { + perform_drawElements(program, i, + patch.GetNumPatches() * desc.GetNumControlVertices(), + patch.GetIndexBase()); + } + } +} + +} // namespace + +void GLMeshDisplayPrepare(struct OpenSubdiv_GLMesh* /*gl_mesh*/, + const bool use_osd_glsl, + const int active_uv_index) { + g_active_uv_index = active_uv_index; + g_use_osd_glsl = (use_osd_glsl != 0); + // Update transformation matrices. + glGetFloatv(GL_PROJECTION_MATRIX, g_transform.projection_matrix); + glGetFloatv(GL_MODELVIEW_MATRIX, g_transform.model_view_matrix); + copy_m3_m4((float(*)[3])g_transform.normal_matrix, + (float(*)[4])g_transform.model_view_matrix); + invert_m3((float(*)[3])g_transform.normal_matrix); + transpose_m3((float(*)[3])g_transform.normal_matrix); + // Update OpenGL lights positions, colors etc. + g_lighting_data.num_enabled = 0; + for (int i = 0; i < MAX_LIGHTS; ++i) { + GLboolean enabled; + glGetBooleanv(GL_LIGHT0 + i, &enabled); + if (enabled) { + g_lighting_data.num_enabled++; + } + // TODO(sergey): Stop using glGetLight. + glGetLightfv(GL_LIGHT0 + i, GL_POSITION, + g_lighting_data.lights[i].position); + glGetLightfv(GL_LIGHT0 + i, GL_AMBIENT, g_lighting_data.lights[i].ambient); + glGetLightfv(GL_LIGHT0 + i, GL_DIFFUSE, g_lighting_data.lights[i].diffuse); + glGetLightfv(GL_LIGHT0 + i, GL_SPECULAR, + g_lighting_data.lights[i].specular); + glGetLightfv(GL_LIGHT0 + i, GL_SPOT_DIRECTION, + g_lighting_data.lights[i].spot_direction); +#ifdef SUPPORT_COLOR_MATERIAL + glGetLightfv(GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, + &g_lighting_data.lights[i].constant_attenuation); + glGetLightfv(GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, + &g_lighting_data.lights[i].linear_attenuation); + glGetLightfv(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, + &g_lighting_data.lights[i].quadratic_attenuation); + glGetLightfv(GL_LIGHT0 + i, GL_SPOT_CUTOFF, + &g_lighting_data.lights[i].spot_cutoff); + glGetLightfv(GL_LIGHT0 + i, GL_SPOT_EXPONENT, + &g_lighting_data.lights[i].spot_exponent); + g_lighting_data.lights[i].spot_cos_cutoff = + cos(g_lighting_data.lights[i].spot_cutoff); +#endif + } +} + +void GLMeshDisplayDrawPatches(OpenSubdiv_GLMesh* gl_mesh, + const bool fill_quads, + const int start_patch, + const int num_patches) { + GLMeshInterface* mesh = gl_mesh->internal->mesh_interface; + // Make sure all global invariants are initialized. + if (!openSubdiv_initGLMeshDrawingResources()) { + return; + } + /// Setup GLSL/OpenGL to draw patches in current context. + GLuint program = prepare_patchDraw(gl_mesh, fill_quads != 0); + if (start_patch != -1) { + drawPartitionPatchesRange(mesh, program, start_patch, num_patches); + } else { + drawAllPatches(mesh, program); + } + // Finish patch drawing by restoring all changes to the OpenGL context. + finishPatchDraw(fill_quads != 0); +} + +} // namespace opensubdiv_capi diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h new file mode 100644 index 00000000000..5421b5cf707 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.h @@ -0,0 +1,39 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_GL_MESH_DRAW_H_ +#define OPENSUBDIV_GL_MESH_DRAW_H_ + +#include // for bool + +struct OpenSubdiv_GLMesh; + +namespace opensubdiv_capi { + +void GLMeshDisplayPrepare(struct OpenSubdiv_GLMesh* gl_mesh, + const bool use_osd_glsl, + const int active_uv_index); + +void GLMeshDisplayDrawPatches(OpenSubdiv_GLMesh* gl_mesh, + const bool fill_quads, + const int start_patch, + const int num_patches); + +} // namespace opensubdiv_capi + +#endif // OPENSUBDIV_GL_MESH_DRAW_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc new file mode 100644 index 00000000000..5c9033c8dd1 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc @@ -0,0 +1,175 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/opensubdiv_gl_mesh_fvar.h" + +#include +#include + +namespace opensubdiv_capi { + +//////////////////////////////////////////////////////////////////////////////// +// GLMeshFVarData + +GLMeshFVarData::GLMeshFVarData() + : texture_buffer(0), + offset_buffer(0) { +} + +GLMeshFVarData::~GLMeshFVarData() { + release(); +} + +void GLMeshFVarData::release() { + if (texture_buffer) { + glDeleteTextures(1, &texture_buffer); + } + if (offset_buffer) { + glDeleteTextures(1, &offset_buffer); + } + texture_buffer = 0; + offset_buffer = 0; + fvar_width = 0; + channel_offsets.clear(); +} + +void GLMeshFVarData::create( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv::Far::PatchTable* patch_table, + int fvar_width, + const float* fvar_src_data) { + release(); + this->fvar_width = fvar_width; + /// Expand fvar data to per-patch array. + const int max_level = topology_refiner->GetMaxLevel(); + const int num_channels = patch_table->GetNumFVarChannels(); + std::vector data; + int fvar_data_offset = 0; + channel_offsets.resize(num_channels); + for (int channel = 0; channel < num_channels; ++channel) { + OpenSubdiv::Far::ConstIndexArray indices = + patch_table->GetFVarValues(channel); + channel_offsets[channel] = data.size(); + data.reserve(data.size() + indices.size() * fvar_width); + for (int fvert = 0; fvert < indices.size(); ++fvert) { + int index = indices[fvert] * fvar_width; + for (int i = 0; i < fvar_width; ++i) { + data.push_back(fvar_src_data[fvar_data_offset + index++]); + } + } + if (topology_refiner->IsUniform()) { + const int num_values_max = + topology_refiner->GetLevel(max_level).GetNumFVarValues(channel); + fvar_data_offset += num_values_max * fvar_width; + } else { + const int num_values_total = + topology_refiner->GetNumFVarValuesTotal(channel); + fvar_data_offset += num_values_total * fvar_width; + } + } + GLuint buffer; + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferData(GL_ARRAY_BUFFER, + data.size() * sizeof(float), &data[0], + GL_STATIC_DRAW); + glGenTextures(1, &texture_buffer); + glBindTexture(GL_TEXTURE_BUFFER, texture_buffer); + glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, buffer); + glDeleteBuffers(1, &buffer); + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferData(GL_ARRAY_BUFFER, + channel_offsets.size() * sizeof(int), + &channel_offsets[0], + GL_STATIC_DRAW); + glGenTextures(1, &offset_buffer); + glBindTexture(GL_TEXTURE_BUFFER, offset_buffer); + glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer); + glBindTexture(GL_TEXTURE_BUFFER, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); +} + +//////////////////////////////////////////////////////////////////////////////// +// Helper functions. + +struct FVarVertex { + float u, v; + + void Clear() { + u = v = 0.0f; + } + + void AddWithWeight(FVarVertex const& src, float weight) { + u += weight * src.u; + v += weight * src.v; + } +}; + +void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner, + const std::vector& uvs, + std::vector* fvar_data) { + const int fvar_width = 2; + const int max_level = refiner.GetMaxLevel(); + size_t fvar_data_offset = 0, values_offset = 0; + for (int channel = 0; channel < refiner.GetNumFVarChannels(); ++channel) { + const int num_values = refiner.GetLevel(0).GetNumFVarValues(channel) * 2; + const int num_values_max = + refiner.GetLevel(max_level).GetNumFVarValues(channel); + const int num_values_total = refiner.GetNumFVarValuesTotal(channel); + if (num_values_total <= 0) { + continue; + } + OpenSubdiv::Far::PrimvarRefiner primvar_refiner(refiner); + if (refiner.IsUniform()) { + // For uniform we only keep the highest level of refinement. + fvar_data->resize(fvar_data->size() + num_values_max * fvar_width); + std::vector buffer(num_values_total - num_values_max); + FVarVertex* src = &buffer[0]; + memcpy(src, &uvs[values_offset], num_values * sizeof(float)); + // Defer the last level to treat separately with its alternate + // destination. + for (int level = 1; level < max_level; ++level) { + FVarVertex* dst = + src + refiner.GetLevel(level - 1).GetNumFVarValues(channel); + primvar_refiner.InterpolateFaceVarying(level, src, dst, channel); + src = dst; + } + FVarVertex* dst = + reinterpret_cast(&(*fvar_data)[fvar_data_offset]); + primvar_refiner.InterpolateFaceVarying(max_level, src, dst, channel); + fvar_data_offset += num_values_max * fvar_width; + } else { + // For adaptive we keep all levels. + fvar_data->resize(fvar_data->size() + num_values_total * fvar_width); + FVarVertex* src = + reinterpret_cast(&(*fvar_data)[fvar_data_offset]); + memcpy(src, &uvs[values_offset], num_values * sizeof(float)); + for (int level = 1; level <= max_level; ++level) { + FVarVertex* dst = + src + refiner.GetLevel(level - 1).GetNumFVarValues(channel); + primvar_refiner.InterpolateFaceVarying(level, src, dst, channel); + src = dst; + } + fvar_data_offset += num_values_total * fvar_width; + } + values_offset += num_values; + } +} + +} // namespace opensubdiv_capi diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h new file mode 100644 index 00000000000..039a94eaf86 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h @@ -0,0 +1,57 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_GL_MESH_FVAR_H_ +#define OPENSUBDIV_GL_MESH_FVAR_H_ + +// NOTE: This is a [sane(er)] port of previous ground work for getting UVs to +// work. Still needs a lot of work to make it easy, correct and have proper +// data ownership. + +#include +#include + +#include + +namespace opensubdiv_capi { + +// The buffer which holds GPU resources for face-varying elements. +class GLMeshFVarData { + public: + GLMeshFVarData(); + ~GLMeshFVarData(); + + void release(); + void create(const OpenSubdiv::Far::TopologyRefiner* refiner, + const OpenSubdiv::Far::PatchTable* patch_table, + int fvar_width, + const float* fvar_src_data); + + unsigned int texture_buffer; + unsigned int offset_buffer; + std::vector channel_offsets; + int fvar_width; +}; + +void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner, + const std::vector& uvs, + std::vector* fvar_data); + +} // namespace opensubdiv_capi + +#endif // OPENSUBDIV_GL_MESH_FVAR_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc new file mode 100644 index 00000000000..3abba9cf8f8 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.cc @@ -0,0 +1,32 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/opensubdiv_gl_mesh_internal.h" + +#include "internal/opensubdiv_gl_mesh_fvar.h" + +OpenSubdiv_GLMeshInternal::OpenSubdiv_GLMeshInternal() + : evaluator_type(OPENSUBDIV_EVALUATOR_CPU), + mesh_interface(NULL), + fvar_data(NULL) { +} + +OpenSubdiv_GLMeshInternal::~OpenSubdiv_GLMeshInternal() { + delete mesh_interface; + delete fvar_data; +} diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h b/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h new file mode 100644 index 00000000000..7796b450e69 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_internal.h @@ -0,0 +1,43 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_GL_MESH_INTERNAL_H_ +#define OPENSUBDIV_GL_MESH_INTERNAL_H_ + +#ifdef _MSC_VER +# include +#endif + +#include + +#include "opensubdiv_capi_type.h" + +namespace opensubdiv_capi { +class GLMeshFVarData; +} // namespace opensubdiv_capi + +typedef struct OpenSubdiv_GLMeshInternal { + OpenSubdiv_GLMeshInternal(); + ~OpenSubdiv_GLMeshInternal(); + + eOpenSubdivEvaluator evaluator_type; + OpenSubdiv::Osd::GLMeshInterface* mesh_interface; + opensubdiv_capi::GLMeshFVarData* fvar_data; +} OpenSubdiv_GLMeshInternal; + +#endif // OPENSUBDIV_GL_MESH_INTERNAL_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_gpu.cc b/intern/opensubdiv/internal/opensubdiv_gpu.cc new file mode 100644 index 00000000000..d28b48ddd18 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_gpu.cc @@ -0,0 +1,788 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2013 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "opensubdiv_capi.h" + +#ifdef _MSC_VER +# include "iso646.h" +#endif + +#include +#include +#include + +#include + +#ifdef OPENSUBDIV_HAS_CUDA +# include +#endif /* OPENSUBDIV_HAS_CUDA */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "opensubdiv_capi.h" +#include "opensubdiv_gl_mesh.h" +#include "opensubdiv_topology_refiner.h" + +using OpenSubdiv::Osd::GLMeshInterface; + +extern "C" char datatoc_gpu_shader_opensubdiv_vertex_glsl[]; +extern "C" char datatoc_gpu_shader_opensubdiv_geometry_glsl[]; +extern "C" char datatoc_gpu_shader_opensubdiv_fragment_glsl[]; + +/* TODO(sergey): This is bit of bad level calls :S */ +extern "C" { +void copy_m3_m3(float m1[3][3], float m2[3][3]); +void copy_m3_m4(float m1[3][3], float m2[4][4]); +void adjoint_m3_m3(float m1[3][3], float m[3][3]); +float determinant_m3_array(float m[3][3]); +bool invert_m3_m3(float m1[3][3], float m2[3][3]); +bool invert_m3(float m[3][3]); +void transpose_m3(float mat[3][3]); +} + +#define MAX_LIGHTS 8 +#define SUPPORT_COLOR_MATERIAL + +typedef struct Light { + float position[4]; + float ambient[4]; + float diffuse[4]; + float specular[4]; + float spot_direction[4]; +#ifdef SUPPORT_COLOR_MATERIAL + float constant_attenuation; + float linear_attenuation; + float quadratic_attenuation; + float spot_cutoff; + float spot_exponent; + float spot_cos_cutoff; + float pad, pad2; +#endif +} Light; + +typedef struct Lighting { + Light lights[MAX_LIGHTS]; + int num_enabled; +} Lighting; + +typedef struct Transform { + float projection_matrix[16]; + float model_view_matrix[16]; + float normal_matrix[9]; +} Transform; + +static bool g_use_osd_glsl = false; +static int g_active_uv_index = 0; + +static GLuint g_flat_fill_solid_program = 0; +static GLuint g_flat_fill_texture2d_program = 0; +static GLuint g_smooth_fill_solid_program = 0; +static GLuint g_smooth_fill_texture2d_program = 0; + +static GLuint g_flat_fill_solid_shadeless_program = 0; +static GLuint g_flat_fill_texture2d_shadeless_program = 0; +static GLuint g_smooth_fill_solid_shadeless_program = 0; +static GLuint g_smooth_fill_texture2d_shadeless_program = 0; + +static GLuint g_wireframe_program = 0; + +static GLuint g_lighting_ub = 0; +static Lighting g_lighting_data; +static Transform g_transform; + +struct OpenSubdiv_GLMeshFVarData +{ + OpenSubdiv_GLMeshFVarData() : + texture_buffer(0), offset_buffer(0) { + } + + ~OpenSubdiv_GLMeshFVarData() + { + Release(); + } + + void Release() + { + if (texture_buffer) { + glDeleteTextures(1, &texture_buffer); + } + if (offset_buffer) { + glDeleteTextures(1, &offset_buffer); + } + texture_buffer = 0; + offset_buffer = 0; + fvar_width = 0; + channel_offsets.clear(); + } + + void Create(const OpenSubdiv::Far::TopologyRefiner *refiner, + const OpenSubdiv::Far::PatchTable *patch_table, + int fvar_width, + const float *fvar_src_data) + { + Release(); + + this->fvar_width = fvar_width; + + /* Expand fvar data to per-patch array */ + const int max_level = refiner->GetMaxLevel(); + const int num_channels = patch_table->GetNumFVarChannels(); + std::vector data; + int fvar_data_offset = 0; + channel_offsets.resize(num_channels); + for (int channel = 0; channel < num_channels; ++channel) { + OpenSubdiv::Far::ConstIndexArray indices = + patch_table->GetFVarValues(channel); + + channel_offsets[channel] = data.size(); + data.reserve(data.size() + indices.size() * fvar_width); + + for (int fvert = 0; fvert < (int)indices.size(); ++fvert) { + int index = indices[fvert] * fvar_width; + for (int i = 0; i < fvar_width; ++i) { + data.push_back(fvar_src_data[fvar_data_offset + index++]); + } + } + if (refiner->IsUniform()) { + const int num_values_max = refiner->GetLevel(max_level).GetNumFVarValues(channel); + fvar_data_offset += num_values_max * fvar_width; + } else { + const int num_values_total = refiner->GetNumFVarValuesTotal(channel); + fvar_data_offset += num_values_total * fvar_width; + } + } + + GLuint buffer; + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferData(GL_ARRAY_BUFFER, data.size()*sizeof(float), + &data[0], GL_STATIC_DRAW); + + glGenTextures(1, &texture_buffer); + glBindTexture(GL_TEXTURE_BUFFER, texture_buffer); + glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, buffer); + + glDeleteBuffers(1, &buffer); + + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferData(GL_ARRAY_BUFFER, channel_offsets.size()*sizeof(int), + &channel_offsets[0], GL_STATIC_DRAW); + + glGenTextures(1, &offset_buffer); + glBindTexture(GL_TEXTURE_BUFFER, offset_buffer); + glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer); + glBindTexture(GL_TEXTURE_BUFFER, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + GLuint texture_buffer; + GLuint offset_buffer; + std::vector channel_offsets; + int fvar_width; +}; + +namespace { + +GLuint compileShader(GLenum shaderType, + const char *version, + const char *define, + const char *source) +{ + const char *sources[] = { + version, + define, +#ifdef SUPPORT_COLOR_MATERIAL + "#define SUPPORT_COLOR_MATERIAL\n", +#else + "", +#endif + source, + }; + + GLuint shader = glCreateShader(shaderType); + glShaderSource(shader, 4, sources, NULL); + glCompileShader(shader); + + GLint status; + glGetShaderiv(shader, GL_COMPILE_STATUS, &status); + if (status == GL_FALSE) { + GLchar emsg[1024]; + glGetShaderInfoLog(shader, sizeof(emsg), 0, emsg); + fprintf(stderr, "Error compiling GLSL: %s\n", emsg); + fprintf(stderr, "Version: %s\n", version); + fprintf(stderr, "Defines: %s\n", define); + fprintf(stderr, "Source: %s\n", source); + return 0; + } + + return shader; +} + +GLuint linkProgram(const char *version, const char *define) +{ + GLuint vertexShader = compileShader(GL_VERTEX_SHADER, + version, + define, + datatoc_gpu_shader_opensubdiv_vertex_glsl); + if (vertexShader == 0) { + return 0; + } + GLuint geometryShader = compileShader(GL_GEOMETRY_SHADER, + version, + define, + datatoc_gpu_shader_opensubdiv_geometry_glsl); + if (geometryShader == 0) { + return 0; + } + GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER, + version, + define, + datatoc_gpu_shader_opensubdiv_fragment_glsl ); + if (fragmentShader == 0) { + return 0; + } + + GLuint program = glCreateProgram(); + + glAttachShader(program, vertexShader); + glAttachShader(program, geometryShader); + glAttachShader(program, fragmentShader); + + glBindAttribLocation(program, 0, "position"); + glBindAttribLocation(program, 1, "normal"); + + glLinkProgram(program); + + glDeleteShader(vertexShader); + glDeleteShader(geometryShader); + glDeleteShader(fragmentShader); + + GLint status; + glGetProgramiv(program, GL_LINK_STATUS, &status); + if (status == GL_FALSE) { + GLchar emsg[1024]; + glGetProgramInfoLog(program, sizeof(emsg), 0, emsg); + fprintf(stderr, "Error linking GLSL program : %s\n", emsg); + fprintf(stderr, "Defines: %s\n", define); + glDeleteProgram(program); + return 0; + } + + glUniformBlockBinding(program, + glGetUniformBlockIndex(program, "Lighting"), + 0); + + if (GLEW_VERSION_4_1) { + glProgramUniform1i(program, + glGetUniformLocation(program, "texture_buffer"), + 0); /* GL_TEXTURE0 */ + + glProgramUniform1i(program, + glGetUniformLocation(program, "FVarDataOffsetBuffer"), + 30); /* GL_TEXTURE30 */ + + glProgramUniform1i(program, + glGetUniformLocation(program, "FVarDataBuffer"), + 31); /* GL_TEXTURE31 */ + } + else { + glUseProgram(program); + glUniform1i(glGetUniformLocation(program, "texture_buffer"), 0); /* GL_TEXTURE0 */ + glUniform1i(glGetUniformLocation(program, "FVarDataOffsetBuffer"), 30); /* GL_TEXTURE30 */ + glUniform1i(glGetUniformLocation(program, "FVarDataBuffer"), 31); /* GL_TEXTURE31 */ + glUseProgram(0); + } + + return program; +} + +void bindProgram(OpenSubdiv_GLMesh *gl_mesh, int program) +{ + glUseProgram(program); + + /* Matrices */ + glUniformMatrix4fv(glGetUniformLocation(program, "modelViewMatrix"), + 1, false, + g_transform.model_view_matrix); + glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), + 1, false, + g_transform.projection_matrix); + glUniformMatrix3fv(glGetUniformLocation(program, "normalMatrix"), + 1, false, + g_transform.normal_matrix); + + /* Lighting */ + glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub); + glBufferSubData(GL_UNIFORM_BUFFER, + 0, sizeof(g_lighting_data), &g_lighting_data); + glBindBuffer(GL_UNIFORM_BUFFER, 0); + + glBindBufferBase(GL_UNIFORM_BUFFER, 0, g_lighting_ub); + + /* Color */ + { + /* TODO: stop using glGetMaterial */ + float color[4]; + glGetMaterialfv(GL_FRONT, GL_DIFFUSE, color); + glUniform4fv(glGetUniformLocation(program, "diffuse"), 1, color); + + glGetMaterialfv(GL_FRONT, GL_SPECULAR, color); + glUniform4fv(glGetUniformLocation(program, "specular"), 1, color); + + glGetMaterialfv(GL_FRONT, GL_SHININESS, color); + glUniform1f(glGetUniformLocation(program, "shininess"), color[0]); + } + + /* Face-vertex data */ + if (gl_mesh->fvar_data != NULL) { + if (gl_mesh->fvar_data->texture_buffer) { + glActiveTexture(GL_TEXTURE31); + glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->texture_buffer); + glActiveTexture(GL_TEXTURE0); + } + + if (gl_mesh->fvar_data->offset_buffer) { + glActiveTexture(GL_TEXTURE30); + glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->offset_buffer); + glActiveTexture(GL_TEXTURE0); + } + + glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), + gl_mesh->fvar_data->fvar_width); + if (gl_mesh->fvar_data->channel_offsets.size() > 0 && + g_active_uv_index >= 0) + { + glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), + gl_mesh->fvar_data->channel_offsets[g_active_uv_index]); + } else { + glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); + } + } else { + glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0); + glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); + } +} + +} /* namespace */ + +bool openSubdiv_osdGLDisplayInit(void) +{ + static bool need_init = true; + static bool init_success = false; + + if (need_init) { + /* TODO: update OSD drawing to OpenGL 3.3 core, then remove following line */ + return false; + + const char *version = ""; + if (GLEW_VERSION_3_2) { + version = "#version 150 compatibility\n"; + } + else if (GLEW_VERSION_3_1) { + version = "#version 140\n" + "#extension GL_ARB_compatibility: enable\n"; + } + else { + version = "#version 130\n"; + /* minimum supported for OpenSubdiv */ + } + + g_flat_fill_solid_program = linkProgram( + version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_LIGHTING\n" + "#define FLAT_SHADING\n"); + g_flat_fill_texture2d_program = linkProgram( + version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_LIGHTING\n" + "#define USE_TEXTURE_2D\n" + "#define FLAT_SHADING\n"); + g_smooth_fill_solid_program = linkProgram( + version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_LIGHTING\n" + "#define SMOOTH_SHADING\n"); + g_smooth_fill_texture2d_program = linkProgram( + version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_LIGHTING\n" + "#define USE_TEXTURE_2D\n" + "#define SMOOTH_SHADING\n"); + + g_flat_fill_solid_shadeless_program = linkProgram( + version, + "#define USE_COLOR_MATERIAL\n" + "#define FLAT_SHADING\n"); + g_flat_fill_texture2d_shadeless_program = linkProgram( + version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_TEXTURE_2D\n" + "#define FLAT_SHADING\n"); + g_smooth_fill_solid_shadeless_program = linkProgram( + version, + "#define USE_COLOR_MATERIAL\n" + "#define SMOOTH_SHADING\n"); + g_smooth_fill_texture2d_shadeless_program = linkProgram( + version, + "#define USE_COLOR_MATERIAL\n" + "#define USE_TEXTURE_2D\n" + "#define SMOOTH_SHADING\n"); + + g_wireframe_program = linkProgram( + version, + "#define WIREFRAME\n"); + + glGenBuffers(1, &g_lighting_ub); + glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub); + glBufferData(GL_UNIFORM_BUFFER, + sizeof(g_lighting_data), NULL, GL_STATIC_DRAW); + + need_init = false; + init_success = g_flat_fill_solid_program != 0 && + g_flat_fill_texture2d_program != 0 && + g_smooth_fill_solid_program != 0 && + g_smooth_fill_texture2d_program != 0 && + g_wireframe_program; + } + return init_success; +} + +void openSubdiv_osdGLDisplayDeinit(void) +{ + if (g_lighting_ub != 0) { + glDeleteBuffers(1, &g_lighting_ub); + } +#define SAFE_DELETE_PROGRAM(program) \ + do { \ + if (program) { \ + glDeleteProgram(program); \ + } \ + } while (false) + + SAFE_DELETE_PROGRAM(g_flat_fill_solid_program); + SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_program); + SAFE_DELETE_PROGRAM(g_smooth_fill_solid_program); + SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_program); + SAFE_DELETE_PROGRAM(g_flat_fill_solid_shadeless_program); + SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_shadeless_program); + SAFE_DELETE_PROGRAM(g_smooth_fill_solid_shadeless_program); + SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_shadeless_program); + SAFE_DELETE_PROGRAM(g_wireframe_program); + +#undef SAFE_DELETE_PROGRAM +} + +void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl, + int active_uv_index) +{ + g_active_uv_index = active_uv_index; + g_use_osd_glsl = (use_osd_glsl != 0); + + /* Update transformation matrices. */ + glGetFloatv(GL_PROJECTION_MATRIX, g_transform.projection_matrix); + glGetFloatv(GL_MODELVIEW_MATRIX, g_transform.model_view_matrix); + + copy_m3_m4((float (*)[3])g_transform.normal_matrix, + (float (*)[4])g_transform.model_view_matrix); + invert_m3((float (*)[3])g_transform.normal_matrix); + transpose_m3((float (*)[3])g_transform.normal_matrix); + + /* Update OpenGL lights positions, colors etc. */ + g_lighting_data.num_enabled = 0; + for (int i = 0; i < MAX_LIGHTS; ++i) { + GLboolean enabled; + glGetBooleanv(GL_LIGHT0 + i, &enabled); + if (enabled) { + g_lighting_data.num_enabled++; + } + + /* TODO: stop using glGetLight */ + glGetLightfv(GL_LIGHT0 + i, + GL_POSITION, + g_lighting_data.lights[i].position); + glGetLightfv(GL_LIGHT0 + i, + GL_AMBIENT, + g_lighting_data.lights[i].ambient); + glGetLightfv(GL_LIGHT0 + i, + GL_DIFFUSE, + g_lighting_data.lights[i].diffuse); + glGetLightfv(GL_LIGHT0 + i, + GL_SPECULAR, + g_lighting_data.lights[i].specular); + glGetLightfv(GL_LIGHT0 + i, + GL_SPOT_DIRECTION, + g_lighting_data.lights[i].spot_direction); +#ifdef SUPPORT_COLOR_MATERIAL + glGetLightfv(GL_LIGHT0 + i, + GL_CONSTANT_ATTENUATION, + &g_lighting_data.lights[i].constant_attenuation); + glGetLightfv(GL_LIGHT0 + i, + GL_LINEAR_ATTENUATION, + &g_lighting_data.lights[i].linear_attenuation); + glGetLightfv(GL_LIGHT0 + i, + GL_QUADRATIC_ATTENUATION, + &g_lighting_data.lights[i].quadratic_attenuation); + glGetLightfv(GL_LIGHT0 + i, + GL_SPOT_CUTOFF, + &g_lighting_data.lights[i].spot_cutoff); + glGetLightfv(GL_LIGHT0 + i, + GL_SPOT_EXPONENT, + &g_lighting_data.lights[i].spot_exponent); + g_lighting_data.lights[i].spot_cos_cutoff = + cos(g_lighting_data.lights[i].spot_cutoff); +#endif + } +} + +static GLuint prepare_patchDraw(OpenSubdiv_GLMesh *gl_mesh, + bool fill_quads) +{ + GLint program = 0; + if (!g_use_osd_glsl) { + glGetIntegerv(GL_CURRENT_PROGRAM, &program); + if (program) { + GLint model; + glGetIntegerv(GL_SHADE_MODEL, &model); + + GLint location = glGetUniformLocation(program, "osd_flat_shading"); + if (location != -1) { + glUniform1i(location, model == GL_FLAT); + } + + /* Face-vertex data */ + if (gl_mesh->fvar_data != NULL) { + if (gl_mesh->fvar_data->texture_buffer) { + glActiveTexture(GL_TEXTURE31); + glBindTexture(GL_TEXTURE_BUFFER, + gl_mesh->fvar_data->texture_buffer); + glActiveTexture(GL_TEXTURE0); + } + + if (gl_mesh->fvar_data->offset_buffer) { + glActiveTexture(GL_TEXTURE30); + glBindTexture(GL_TEXTURE_BUFFER, + gl_mesh->fvar_data->offset_buffer); + glActiveTexture(GL_TEXTURE0); + } + + GLint location = glGetUniformLocation(program, "osd_fvar_count"); + if (location != -1) { + glUniform1i(location, gl_mesh->fvar_data->fvar_width); + } + + location = glGetUniformLocation(program, "osd_active_uv_offset"); + if (location != -1) { + if (gl_mesh->fvar_data->channel_offsets.size() > 0 && + g_active_uv_index >= 0) + { + glUniform1i(location, + gl_mesh->fvar_data->channel_offsets[g_active_uv_index]); + } else { + glUniform1i(location, 0); + } + } + } else { + glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0); + glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); + } + } + return program; + } + + if (fill_quads) { + int model; + GLboolean use_texture_2d; + glGetIntegerv(GL_SHADE_MODEL, &model); + glGetBooleanv(GL_TEXTURE_2D, &use_texture_2d); + + if (model == GL_FLAT) { + if (use_texture_2d) { + program = g_flat_fill_texture2d_program; + } + else { + program = g_flat_fill_solid_program; + } + } + else { + if (use_texture_2d) { + program = g_smooth_fill_texture2d_program; + } + else { + program = g_smooth_fill_solid_program; + } + } + + } + else { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + program = g_wireframe_program; + } + + bindProgram(gl_mesh, program); + + return program; +} + +static void perform_drawElements(GLuint program, + int patch_index, + int num_elements, + int start_element) +{ + if (program) { + glUniform1i(glGetUniformLocation(program, "PrimitiveIdBase"), + patch_index); + } + glDrawElements(GL_LINES_ADJACENCY, + num_elements, + GL_UNSIGNED_INT, + (void *)(start_element * sizeof(unsigned int))); +} + +static void finish_patchDraw(bool fill_quads) +{ + /* TODO(sergey): Some of the stuff could be done once after the whole + * mesh is displayed. + */ + + /* Restore state. */ + if (!fill_quads) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + glBindVertexArray(0); + + if (g_use_osd_glsl) { + /* TODO(sergey): Store previously used program and roll back to it? */ + glUseProgram(0); + } +} + +static void draw_partition_patches_range(GLMeshInterface *mesh, + GLuint program, + int start_patch, + int num_patches) +{ + int traversed_patches = 0, num_remained_patches = num_patches; + const OpenSubdiv::Osd::PatchArrayVector& patches = + mesh->GetPatchTable()->GetPatchArrays(); + for (int i = 0; i < (int)patches.size(); ++i) { + const OpenSubdiv::Osd::PatchArray& patch = patches[i]; + OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor(); + OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType(); + + if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) { + const int num_block_patches = patch.GetNumPatches(); + if (start_patch >= traversed_patches && + start_patch < traversed_patches + num_block_patches) + { + const int num_control_verts = desc.GetNumControlVertices(); + const int start_draw_patch = start_patch - traversed_patches; + const int num_draw_patches = std::min(num_remained_patches, + num_block_patches - start_draw_patch); + perform_drawElements(program, + i + start_draw_patch, + num_draw_patches * num_control_verts, + patch.GetIndexBase() + start_draw_patch * num_control_verts); + num_remained_patches -= num_draw_patches; + } + if (num_remained_patches == 0) { + break; + } + traversed_patches += num_block_patches; + } + } +} + +static void draw_all_patches(GLMeshInterface *mesh, + GLuint program) +{ + const OpenSubdiv::Osd::PatchArrayVector& patches = + mesh->GetPatchTable()->GetPatchArrays(); + for (int i = 0; i < (int)patches.size(); ++i) { + const OpenSubdiv::Osd::PatchArray& patch = patches[i]; + OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor(); + OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType(); + + if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) { + perform_drawElements(program, + i, + patch.GetNumPatches() * desc.GetNumControlVertices(), + patch.GetIndexBase()); + } + } +} + +void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh, + int fill_quads, + int start_patch, + int num_patches) +{ + GLMeshInterface *mesh = + (GLMeshInterface *)(gl_mesh->descriptor); + + /* Make sure all global invariants are initialized. */ + if (!openSubdiv_osdGLDisplayInit()) { + return; + } + + /* Setup GLSL/OpenGL to draw patches in current context. */ + GLuint program = prepare_patchDraw(gl_mesh, fill_quads != 0); + + if (start_patch != -1) { + draw_partition_patches_range(mesh, + program, + start_patch, + num_patches); + } + else { + draw_all_patches(mesh, program); + } + + /* Finish patch drawing by restoring all changes to the OpenGL context. */ + finish_patchDraw(fill_quads != 0); +} + +void openSubdiv_osdGLAllocFVar(OpenSubdiv_TopologyRefinerDescr *topology_refiner, + OpenSubdiv_GLMesh *gl_mesh, + const float *fvar_data) +{ + GLMeshInterface *mesh = + (GLMeshInterface *)(gl_mesh->descriptor); + gl_mesh->fvar_data = OBJECT_GUARDED_NEW(OpenSubdiv_GLMeshFVarData); + gl_mesh->fvar_data->Create(topology_refiner->osd_refiner, + mesh->GetFarPatchTable(), + 2, + fvar_data); +} + +void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh) +{ + if (gl_mesh->fvar_data != NULL) { + OBJECT_GUARDED_DELETE(gl_mesh->fvar_data, OpenSubdiv_GLMeshFVarData); + } +} diff --git a/intern/opensubdiv/internal/opensubdiv_internal.h b/intern/opensubdiv/internal/opensubdiv_internal.h new file mode 100644 index 00000000000..b9d196bbe9e --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_internal.h @@ -0,0 +1,38 @@ +// Copyright 2015 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_INTERNAL_H_ +#define OPENSUBDIV_INTERNAL_H_ + +// Perform full topology validation when exporting it to OpenSubdiv. +#ifdef NDEBUG +// Never do for release builds. +# undef OPENSUBDIV_VALIDATE_TOPOLOGY +#else +// TODO(sergey): Always disabled for now, the check doesn't handle multiple +// non-manifolds from the OpenSubdiv side currently. +// # undef OPENSUBDIV_VALIDATE_TOPOLOGY +# define OPENSUBDIV_VALIDATE_TOPOLOGY +#endif + +// Currently OpenSubdiv expects topology to be oriented, but sometimes it's +// handy to disable orientation code to check whether it causes some weird +// issues by using pre-oriented model. +#define OPENSUBDIV_ORIENT_TOPOLOGY + +#endif // OPENSUBDIV_INTERNAL_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc new file mode 100644 index 00000000000..aa6ba953ef9 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc @@ -0,0 +1,315 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "opensubdiv_topology_refiner_capi.h" + +#include + +#include "MEM_guardedalloc.h" +#include "internal/opensubdiv_converter_factory.h" +#include "internal/opensubdiv_converter_internal.h" +#include "internal/opensubdiv_internal.h" +#include "internal/opensubdiv_topology_refiner_internal.h" + +namespace { + +const OpenSubdiv::Far::TopologyRefiner* getOSDTopologyRefiner( + const OpenSubdiv_TopologyRefiner* topology_refiner) { + return topology_refiner->internal->osd_topology_refiner; +} + +const OpenSubdiv::Far::TopologyLevel* getOSDTopologyBaseLevel( + const OpenSubdiv_TopologyRefiner* topology_refiner) { + return &getOSDTopologyRefiner(topology_refiner)->GetLevel(0); +} + +int getSubdivisionLevel(const OpenSubdiv_TopologyRefiner* topology_refiner) { + return topology_refiner->internal->settings.level; +} + +bool getIsAdaptive(const OpenSubdiv_TopologyRefiner* topology_refiner) { + return topology_refiner->internal->settings.is_adaptive; +} + +int getNumVertices(const OpenSubdiv_TopologyRefiner* topology_refiner) { + return getOSDTopologyBaseLevel(topology_refiner)->GetNumVertices(); +} + +int getNumEdges(const OpenSubdiv_TopologyRefiner* topology_refiner) { + return getOSDTopologyBaseLevel(topology_refiner)->GetNumEdges(); +} + +int getNumFaces(const OpenSubdiv_TopologyRefiner* topology_refiner) { + return getOSDTopologyBaseLevel(topology_refiner)->GetNumFaces(); +} + +int getNumFaceVertices(const OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index) { + const OpenSubdiv::Far::TopologyLevel* base_level = + getOSDTopologyBaseLevel(topology_refiner); + return base_level->GetFaceVertices(face_index).size(); +} + +int getNumFacePtexFaces(const OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index) { + const int num_face_vertices = + topology_refiner->getNumFaceVertices(topology_refiner, face_index); + if (num_face_vertices == 4) { + return 1; + } else { + return num_face_vertices; + } +} + +int getNumPtexFaces(const OpenSubdiv_TopologyRefiner* topology_refiner) { + const int num_faces = topology_refiner->getNumFaces(topology_refiner); + int num_ptex_faces = 0; + for (int face_index = 0; face_index < num_faces; ++face_index) { + num_ptex_faces += + topology_refiner->getNumFacePtexFaces(topology_refiner, face_index); + } + return num_ptex_faces; +} + +void fillFacePtexIndexOffset(const OpenSubdiv_TopologyRefiner* topology_refiner, + int* face_ptex_index_offset) { + const int num_faces = topology_refiner->getNumFaces(topology_refiner); + int num_ptex_faces = 0; + for (int face_index = 0; face_index < num_faces; ++face_index) { + face_ptex_index_offset[face_index] = num_ptex_faces; + num_ptex_faces += + topology_refiner->getNumFacePtexFaces(topology_refiner, face_index); + } +} + +void assignFunctionPointers(OpenSubdiv_TopologyRefiner* topology_refiner) { + topology_refiner->getSubdivisionLevel = getSubdivisionLevel; + topology_refiner->getIsAdaptive = getIsAdaptive; + + topology_refiner->getNumVertices = getNumVertices; + topology_refiner->getNumEdges = getNumEdges; + topology_refiner->getNumFaces = getNumFaces; + topology_refiner->getNumFaceVertices = getNumFaceVertices; + + topology_refiner->getNumFacePtexFaces = getNumFacePtexFaces; + topology_refiner->getNumPtexFaces = getNumPtexFaces; + topology_refiner->fillFacePtexIndexOffset = fillFacePtexIndexOffset; +} + +OpenSubdiv_TopologyRefiner* allocateTopologyRefiner() { + OpenSubdiv_TopologyRefiner* topology_refiner = + OBJECT_GUARDED_NEW(OpenSubdiv_TopologyRefiner); + topology_refiner->internal = + OBJECT_GUARDED_NEW(OpenSubdiv_TopologyRefinerInternal); + assignFunctionPointers(topology_refiner); + return topology_refiner; +} + +} // namespace + +OpenSubdiv_TopologyRefiner* openSubdiv_createTopologyRefinerFromConverter( + OpenSubdiv_Converter* converter, + const OpenSubdiv_TopologyRefinerSettings* settings) { + OpenSubdiv_TopologyRefiner* topology_refiner = allocateTopologyRefiner(); + topology_refiner->internal->osd_topology_refiner = + opensubdiv_capi::createOSDTopologyRefinerFromConverter(converter); + // Store setting which we want to keep track of and which can not be stored + // in OpenSubdiv's descriptor yet. + topology_refiner->internal->settings = *settings; + return topology_refiner; +} + +void openSubdiv_deleteTopologyRefiner( + OpenSubdiv_TopologyRefiner* topology_refiner) { + OBJECT_GUARDED_DELETE(topology_refiner->internal, + OpenSubdiv_TopologyRefinerInternal); + OBJECT_GUARDED_DELETE(topology_refiner, OpenSubdiv_TopologyRefiner); +} + +//////////////////////////////////////////////////////////////////////////////// +// Comparison with converter. + +namespace { + +/////////////////////////////////////////////////////////// +// Quick preliminary checks. + +bool checkSchemeTypeMatches( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + const OpenSubdiv::Sdc::SchemeType converter_scheme_type = + opensubdiv_capi::getSchemeTypeFromCAPI( + converter->getSchemeType(converter)); + return (converter_scheme_type == topology_refiner->GetSchemeType()); +} + +bool checkOptionsMatches( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + typedef OpenSubdiv::Sdc::Options Options; + const Options options = topology_refiner->GetSchemeOptions(); + const Options::FVarLinearInterpolation fvar_interpolation = + options.GetFVarLinearInterpolation(); + const Options::FVarLinearInterpolation converter_fvar_interpolation = + opensubdiv_capi::getFVarLinearInterpolationFromCAPI( + converter->getFVarLinearInterpolation(converter)); + if (fvar_interpolation != converter_fvar_interpolation) { + return false; + } + return true; +} + +bool checkGeometryCoountersMatches( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + using OpenSubdiv::Far::TopologyLevel; + const TopologyLevel& base_level = topology_refiner->GetLevel(0); + return ( + (converter->getNumVertices(converter) == base_level.GetNumVertices()) && + (converter->getNumEdges(converter) == base_level.GetNumEdges()) && + (converter->getNumFaces(converter) == base_level.GetNumFaces())); +} + +bool checkPreliminaryMatches( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + return checkSchemeTypeMatches(topology_refiner, converter) && + checkOptionsMatches(topology_refiner, converter) && + checkGeometryCoountersMatches(topology_refiner, converter); +} + +/////////////////////////////////////////////////////////// +// Geometry comparison. + +bool checkGeometryEdgesMatch( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + using OpenSubdiv::Far::ConstIndexArray; + using OpenSubdiv::Far::TopologyLevel; + const TopologyLevel& base_level = topology_refiner->GetLevel(0); + const int num_edges = base_level.GetNumEdges(); + for (int edge_index = 0; edge_index < num_edges; ++edge_index) { + const ConstIndexArray& edge_vertices = + base_level.GetEdgeVertices(edge_index); + int conv_edge_vertices[2]; + converter->getEdgeVertices(converter, edge_index, conv_edge_vertices); + if (conv_edge_vertices[0] != edge_vertices[0] || + conv_edge_vertices[1] != edge_vertices[1]) { + return false; + } + } + return true; +} + +bool checkGeometryFacesMatch( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + using OpenSubdiv::Far::ConstIndexArray; + using OpenSubdiv::Far::TopologyLevel; + const TopologyLevel& base_level = topology_refiner->GetLevel(0); + const int num_faces = base_level.GetNumFaces(); + // TODO(sergey): Consider using data structure which keeps handful of + // elements on stack before doing heep allocation. + std::vector conv_face_vertices; + for (int face_index = 0; face_index < num_faces; ++face_index) { + const ConstIndexArray& face_vertices = + base_level.GetFaceVertices(face_index); + const int num_face_vertices = face_vertices.size(); + if (num_face_vertices != + converter->getNumFaceVertices(converter, face_index)) { + return false; + } + conv_face_vertices.resize(num_face_vertices); + converter->getFaceVertices(converter, face_index, &conv_face_vertices[0]); + // Check face-vertex indices in the direct order (assuming topology + // orientation is disabled or did not flip order of the face-vertices). + // + // TODO(sergey): Can we simply memcmp() with OpenSubdiv's array? + bool direct_match = true; + for (int face_vertex_index = 0; face_vertex_index < num_face_vertices; + ++face_vertex_index) { + if (conv_face_vertices[face_vertex_index] != + face_vertices[face_vertex_index]) { + direct_match = false; + break; + } + } + if (!direct_match) { +// If face didn't match in direct direction we also test if it matches in +// reversed direction. This is because conversion might reverse loops to +// make normals consistent. +#ifdef OPENSUBDIV_ORIENT_TOPOLOGY + for (int face_vertex_index = 0; face_vertex_index < num_face_vertices; + ++face_vertex_index) { + if (conv_face_vertices[face_vertex_index] != + face_vertices[num_face_vertices - face_vertex_index - 1]) { + return false; + } + } +#endif + return false; + } + } + return true; +} + +bool checkGeometryMatches( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + return checkGeometryEdgesMatch(topology_refiner, converter) && + checkGeometryFacesMatch(topology_refiner, converter); +} + +/////////////////////////////////////////////////////////// +// Compare attributes which affects on topology + +bool checkEdgeSharpnessMatch( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + using OpenSubdiv::Far::ConstIndexArray; + using OpenSubdiv::Far::TopologyLevel; + const TopologyLevel& base_level = topology_refiner->GetLevel(0); + const int num_edges = base_level.GetNumEdges(); + for (int edge_index = 0; edge_index < num_edges; ++edge_index) { + const float sharpness = base_level.GetEdgeSharpness(edge_index); + const float conv_sharpness = + opensubdiv_capi::getCompatibleEdgeSharpness(converter, edge_index); + if (sharpness != conv_sharpness) { + return false; + } + } + return false; +} + +bool checkTopologyAttributesMatch( + const OpenSubdiv::Far::TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + return checkEdgeSharpnessMatch(topology_refiner, converter); +} + +} // namespace + +bool openSubdiv_topologyRefinerCompareWithConverter( + const OpenSubdiv_TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter) { + const OpenSubdiv::Far::TopologyRefiner* refiner = + getOSDTopologyRefiner(topology_refiner); + return (checkPreliminaryMatches(refiner, converter) && + checkGeometryMatches(refiner, converter) && + checkTopologyAttributesMatch(refiner, converter)); +} diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner.h b/intern/opensubdiv/internal/opensubdiv_topology_refiner.h new file mode 100644 index 00000000000..b00f6a54201 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner.h @@ -0,0 +1,41 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __OPENSUBDIV_TOPOLOGY_REFINER_H__ +#define __OPENSUBDIV_TOPOLOGY_REFINER_H__ + +#include + +typedef struct OpenSubdiv_TopologyRefinerDescr { + OpenSubdiv::Far::TopologyRefiner *osd_refiner; + + /* TODO(sergey): For now only, need to find better place + * after revisiting whole OSD drawing pipeline and Blender + * integration. + */ + std::vector uvs; +} OpenSubdiv_TopologyRefinerDescr; + +#endif /* __OPENSUBDIV_TOPOLOGY_REFINER_H__ */ diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.cc b/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.cc new file mode 100644 index 00000000000..4636679761f --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.cc @@ -0,0 +1,26 @@ +// Copyright 2016 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#include "internal/opensubdiv_topology_refiner_internal.h" + +OpenSubdiv_TopologyRefinerInternal::OpenSubdiv_TopologyRefinerInternal() + : osd_topology_refiner(NULL) {} + +OpenSubdiv_TopologyRefinerInternal::~OpenSubdiv_TopologyRefinerInternal() { + delete osd_topology_refiner; +} diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.h b/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.h new file mode 100644 index 00000000000..f7ca6a7ad5e --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner_internal.h @@ -0,0 +1,47 @@ +// Copyright 2016 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_TOPOLOGY_REFINER_INTERNAL_H_ +#define OPENSUBDIV_TOPOLOGY_REFINER_INTERNAL_H_ + +#ifdef _MSC_VER +# include +#endif + +#include + +#include "opensubdiv_topology_refiner_capi.h" + +struct OpenSubdiv_TopologyRefinerInternal { + public: + OpenSubdiv_TopologyRefinerInternal(); + ~OpenSubdiv_TopologyRefinerInternal(); + + OpenSubdiv::Far::TopologyRefiner* osd_topology_refiner; + + // Subdivision settingsa this refiner is created for. + // + // We store it here since OpenSubdiv's refiner will only know about level and + // "adaptivity" after performing actual "refine" step. + // + // Ideally, we would also support refining topology without re-importing it + // from external world, but that is for later. + OpenSubdiv_TopologyRefinerSettings settings; +}; + +#endif // OPENSUBDIV_TOPOLOGY_REFINER_H_ diff --git a/intern/opensubdiv/internal/opensubdiv_util.cc b/intern/opensubdiv/internal/opensubdiv_util.cc new file mode 100644 index 00000000000..87bfce2116c --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_util.cc @@ -0,0 +1,61 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin +// Contributor(s): Brecht van Lommel + +#include "internal/opensubdiv_util.h" + +#include +#include + +#ifdef _MSC_VER +# include +#endif + +namespace opensubdiv_capi { + +void stringSplit(std::vector* tokens, + const std::string& str, + const std::string& separators, + bool skip_empty) { + size_t token_start = 0, token_length = 0; + for (size_t i = 0; i < str.length(); ++i) { + const char ch = str[i]; + if (separators.find(ch) == std::string::npos) { + // Append non-separator char to a token. + ++token_length; + } else { + // Append current token to the list (if any). + if (token_length > 0 || !skip_empty) { + std::string token = str.substr(token_start, token_length); + tokens->push_back(token); + } + // Re-set token pointers, + token_start = i + 1; + token_length = 0; + } + } + // Append token which might be at the end of the string. + if ((token_length != 0) || + (!skip_empty && token_start > 0 && + separators.find(str[token_start-1]) != std::string::npos)) { + std::string token = str.substr(token_start, token_length); + tokens->push_back(token); + } +} + +} // namespace opensubdiv_capi diff --git a/intern/opensubdiv/internal/opensubdiv_util.h b/intern/opensubdiv/internal/opensubdiv_util.h new file mode 100644 index 00000000000..6ed19b37e33 --- /dev/null +++ b/intern/opensubdiv/internal/opensubdiv_util.h @@ -0,0 +1,39 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin +// Contributor(s): Brecht van Lommel + +#ifndef OPENSUBDIV_UTIL_H_ +#define OPENSUBDIV_UTIL_H_ + +#include +#include + +namespace opensubdiv_capi { + +#define STRINGIFY_ARG(x) "" #x +#define STRINGIFY_APPEND(a, b) "" a #b +#define STRINGIFY(x) STRINGIFY_APPEND("", x) + +void stringSplit(std::vector* tokens, + const std::string& str, + const std::string& separators, + bool skip_empty); + +} // namespace opensubdiv_capi + +#endif // OPENSUBDIV_UTIL_H_ diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc deleted file mode 100644 index 638039f4f3e..00000000000 --- a/intern/opensubdiv/opensubdiv_capi.cc +++ /dev/null @@ -1,441 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2013 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * Brecht van Lommel - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "opensubdiv_capi.h" - -#ifdef _MSC_VER -# include "iso646.h" -#endif - -#include -#include - -#include -#include - -/* CPU Backend */ -#include -#include - -#ifdef OPENSUBDIV_HAS_OPENMP -# include -#endif /* OPENSUBDIV_HAS_OPENMP */ - -#ifdef OPENSUBDIV_HAS_OPENCL -# include -# include -# include "opensubdiv_device_context_opencl.h" -#endif /* OPENSUBDIV_HAS_OPENCL */ - -#ifdef OPENSUBDIV_HAS_CUDA -# include -# include -# include "opensubdiv_device_context_cuda.h" -#endif /* OPENSUBDIV_HAS_CUDA */ - -#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK -# include -# include -#endif /* OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK */ - -#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE -# include -# include -#endif /* OPENSUBDIV_HAS_GLSL_COMPUTE */ - -#include -#include -#include - -#include "opensubdiv_gl_mesh.h" -#include "opensubdiv_intern.h" -#include "opensubdiv_topology_refiner.h" - -#include "MEM_guardedalloc.h" - -#include -#include - -using std::string; -using std::vector; - -#define STRINGIFY_ARG(x) "" #x -#define STRINGIFY_APPEND(a, b) "" a #b -#define STRINGIFY(x) STRINGIFY_APPEND("", x) - -/* **************** Types declaration **************** */ - -using OpenSubdiv::Osd::GLMeshInterface; -using OpenSubdiv::Osd::Mesh; -using OpenSubdiv::Osd::MeshBitset; -using OpenSubdiv::Far::StencilTable; -using OpenSubdiv::Osd::GLPatchTable; - -using OpenSubdiv::Osd::Mesh; - -/* CPU backend */ -using OpenSubdiv::Osd::CpuGLVertexBuffer; -using OpenSubdiv::Osd::CpuEvaluator; -typedef Mesh OsdCpuMesh; - -#ifdef OPENSUBDIV_HAS_OPENMP -using OpenSubdiv::Osd::OmpEvaluator; -typedef Mesh OsdOmpMesh; -#endif /* OPENSUBDIV_HAS_OPENMP */ - -#ifdef OPENSUBDIV_HAS_OPENCL -using OpenSubdiv::Osd::CLEvaluator; -using OpenSubdiv::Osd::CLGLVertexBuffer; -using OpenSubdiv::Osd::CLStencilTable; -/* TODO(sergey): Use CLDeviceCOntext similar to OSD examples? */ -typedef Mesh OsdCLMesh; -static CLDeviceContext g_clDeviceContext; -#endif /* OPENSUBDIV_HAS_OPENCL */ - -#ifdef OPENSUBDIV_HAS_CUDA -using OpenSubdiv::Osd::CudaEvaluator; -using OpenSubdiv::Osd::CudaGLVertexBuffer; -using OpenSubdiv::Osd::CudaStencilTable; -typedef Mesh OsdCudaMesh; -static CudaDeviceContext g_cudaDeviceContext; -#endif /* OPENSUBDIV_HAS_CUDA */ - -#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK -using OpenSubdiv::Osd::GLXFBEvaluator; -using OpenSubdiv::Osd::GLStencilTableTBO; -using OpenSubdiv::Osd::GLVertexBuffer; -typedef Mesh OsdGLSLTransformFeedbackMesh; -#endif /* OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK */ - -#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE -using OpenSubdiv::Osd::GLComputeEvaluator; -using OpenSubdiv::Osd::GLStencilTableSSBO; -using OpenSubdiv::Osd::GLVertexBuffer; -typedef Mesh OsdGLSLComputeMesh; -#endif - -namespace { - -#if !defined(OPENSUBDIV_VERSION_NUMBER) && !defined(OPENSUBDIV_VERSION_MINOR) -void stringSplit(vector* tokens, - const string& str, - const string& separators, - bool skip_empty) { - size_t token_start = 0, token_length = 0; - for (size_t i = 0; i < str.length(); ++i) { - const char ch = str[i]; - if (separators.find(ch) == string::npos) { - /* Append non-separator char to a token. */ - ++token_length; - } else { - /* Append current token to the list (if any). */ - if (token_length > 0 || !skip_empty) { - string token = str.substr(token_start, token_length); - tokens->push_back(token); - } - /* Re-set token pointers, */ - token_start = i + 1; - token_length = 0; - } - } - /* Append token which might be at the end of the string. */ - if ((token_length != 0) || - (!skip_empty && token_start > 0 && - separators.find(str[token_start-1]) != string::npos)) { - string token = str.substr(token_start, token_length); - tokens->push_back(token); - } -} -#endif - -struct FVarVertex { - float u, v; - void Clear() { - u = v = 0.0f; - } - void AddWithWeight(FVarVertex const & src, float weight) { - u += weight * src.u; - v += weight * src.v; - } -}; - -static void interpolate_fvar_data(OpenSubdiv::Far::TopologyRefiner& refiner, - const std::vector uvs, - std::vector &fvar_data) { - /* TODO(sergey): Make it somehow more generic way. */ - const int fvar_width = 2; - const int max_level = refiner.GetMaxLevel(); - size_t fvar_data_offset = 0, values_offset = 0; - for (int channel = 0; channel < refiner.GetNumFVarChannels(); ++channel) { - const int num_values = refiner.GetLevel(0).GetNumFVarValues(channel) * 2, - num_values_max = refiner.GetLevel(max_level).GetNumFVarValues(channel), - num_values_total = refiner.GetNumFVarValuesTotal(channel); - if (num_values_total <= 0) { - continue; - } - OpenSubdiv::Far::PrimvarRefiner primvar_refiner(refiner); - if (refiner.IsUniform()) { - /* For uniform we only keep the highest level of refinement. */ - fvar_data.resize(fvar_data.size() + num_values_max * fvar_width); - std::vector buffer(num_values_total - num_values_max); - FVarVertex *src = &buffer[0]; - memcpy(src, &uvs[values_offset], num_values * sizeof(float)); - /* Defer the last level to treat separately with its alternate - * destination. - */ - for (int level = 1; level < max_level; ++level) { - FVarVertex *dst = src + refiner.GetLevel(level-1).GetNumFVarValues(channel); - primvar_refiner.InterpolateFaceVarying(level, src, dst, channel); - src = dst; - } - FVarVertex *dst = reinterpret_cast(&fvar_data[fvar_data_offset]); - primvar_refiner.InterpolateFaceVarying(max_level, src, dst, channel); - fvar_data_offset += num_values_max * fvar_width; - } else { - /* For adaptive we keep all levels. */ - fvar_data.resize(fvar_data.size() + num_values_total * fvar_width); - FVarVertex *src = reinterpret_cast(&fvar_data[fvar_data_offset]); - memcpy(src, &uvs[values_offset], num_values * sizeof(float)); - for (int level = 1; level <= max_level; ++level) { - FVarVertex *dst = src + refiner.GetLevel(level-1).GetNumFVarValues(channel); - primvar_refiner.InterpolateFaceVarying(level, src, dst, channel); - src = dst; - } - fvar_data_offset += num_values_total * fvar_width; - } - values_offset += num_values; - } -} - -} // namespace - -struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner( - OpenSubdiv_TopologyRefinerDescr *topology_refiner, - int evaluator_type, - int level) -{ - using OpenSubdiv::Far::TopologyRefiner; - - MeshBitset bits; - /* TODO(sergey): Adaptive subdivisions are not currently - * possible because of the lack of tessellation shader. - */ - bits.set(OpenSubdiv::Osd::MeshAdaptive, 0); - bits.set(OpenSubdiv::Osd::MeshUseSingleCreasePatch, 0); - bits.set(OpenSubdiv::Osd::MeshInterleaveVarying, 1); - bits.set(OpenSubdiv::Osd::MeshFVarData, 1); - bits.set(OpenSubdiv::Osd::MeshEndCapBSplineBasis, 1); - - const int num_vertex_elements = 3; - const int num_varying_elements = 3; - - GLMeshInterface *mesh = NULL; - TopologyRefiner *refiner = topology_refiner->osd_refiner; - - switch(evaluator_type) { -#define CHECK_EVALUATOR_TYPE(type, class) \ - case OPENSUBDIV_EVALUATOR_ ## type: \ - mesh = new class(refiner, \ - num_vertex_elements, \ - num_varying_elements, \ - level, \ - bits); \ - break; - - CHECK_EVALUATOR_TYPE(CPU, OsdCpuMesh) - -#ifdef OPENSUBDIV_HAS_OPENMP - CHECK_EVALUATOR_TYPE(OPENMP, OsdOmpMesh) -#endif - -#ifdef OPENSUBDIV_HAS_OPENCL - CHECK_EVALUATOR_TYPE(OPENCL, OsdCLMesh) -#endif - -#ifdef OPENSUBDIV_HAS_CUDA - CHECK_EVALUATOR_TYPE(CUDA, OsdCudaMesh) -#endif - -#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK - CHECK_EVALUATOR_TYPE(GLSL_TRANSFORM_FEEDBACK, - OsdGLSLTransformFeedbackMesh) -#endif - -#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE - CHECK_EVALUATOR_TYPE(GLSL_COMPUTE, OsdGLSLComputeMesh) -#endif - -#undef CHECK_EVALUATOR_TYPE - } - - if (mesh == NULL) { - return NULL; - } - - OpenSubdiv_GLMesh *gl_mesh = - (OpenSubdiv_GLMesh *) OBJECT_GUARDED_NEW(OpenSubdiv_GLMesh); - gl_mesh->evaluator_type = evaluator_type; - gl_mesh->descriptor = (OpenSubdiv_GLMeshDescr *) mesh; - gl_mesh->topology_refiner = topology_refiner; - - if (refiner->GetNumFVarChannels() > 0) { - std::vector fvar_data; - interpolate_fvar_data(*refiner, topology_refiner->uvs, fvar_data); - openSubdiv_osdGLAllocFVar(topology_refiner, gl_mesh, &fvar_data[0]); - } - else { - gl_mesh->fvar_data = NULL; - } - - return gl_mesh; -} - -void openSubdiv_deleteOsdGLMesh(struct OpenSubdiv_GLMesh *gl_mesh) -{ - openSubdiv_osdGLDestroyFVar(gl_mesh); - switch (gl_mesh->evaluator_type) { -#define CHECK_EVALUATOR_TYPE(type, class) \ - case OPENSUBDIV_EVALUATOR_ ## type: \ - delete (class *) gl_mesh->descriptor; \ - break; - - CHECK_EVALUATOR_TYPE(CPU, OsdCpuMesh) - -#ifdef OPENSUBDIV_HAS_OPENMP - CHECK_EVALUATOR_TYPE(OPENMP, OsdOmpMesh) -#endif - -#ifdef OPENSUBDIV_HAS_OPENCL - CHECK_EVALUATOR_TYPE(OPENCL, OsdCLMesh) -#endif - -#ifdef OPENSUBDIV_HAS_CUDA - CHECK_EVALUATOR_TYPE(CUDA, OsdCudaMesh) -#endif - -#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK - CHECK_EVALUATOR_TYPE(GLSL_TRANSFORM_FEEDBACK, - OsdGLSLTransformFeedbackMesh) -#endif - -#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE - CHECK_EVALUATOR_TYPE(GLSL_COMPUTE, OsdGLSLComputeMesh) -#endif - -#undef CHECK_EVALUATOR_TYPE - } - - /* NOTE: OSD refiner was owned by gl_mesh, no need to free it here. */ - OBJECT_GUARDED_DELETE(gl_mesh->topology_refiner, OpenSubdiv_TopologyRefinerDescr); - OBJECT_GUARDED_DELETE(gl_mesh, OpenSubdiv_GLMesh); -} - -unsigned int openSubdiv_getOsdGLMeshPatchIndexBuffer(struct OpenSubdiv_GLMesh *gl_mesh) -{ - return ((GLMeshInterface *)gl_mesh->descriptor)->GetPatchTable()->GetPatchIndexBuffer(); -} - -unsigned int openSubdiv_getOsdGLMeshVertexBuffer(struct OpenSubdiv_GLMesh *gl_mesh) -{ - return ((GLMeshInterface *)gl_mesh->descriptor)->BindVertexBuffer(); -} - -void openSubdiv_osdGLMeshUpdateVertexBuffer(struct OpenSubdiv_GLMesh *gl_mesh, - const float *vertex_data, - int start_vertex, - int num_verts) -{ - ((GLMeshInterface *)gl_mesh->descriptor)->UpdateVertexBuffer(vertex_data, - start_vertex, - num_verts); -} - -void openSubdiv_osdGLMeshRefine(struct OpenSubdiv_GLMesh *gl_mesh) -{ - ((GLMeshInterface *)gl_mesh->descriptor)->Refine(); -} - -void openSubdiv_osdGLMeshSynchronize(struct OpenSubdiv_GLMesh *gl_mesh) -{ - ((GLMeshInterface *)gl_mesh->descriptor)->Synchronize(); -} - -void openSubdiv_osdGLMeshBindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh) -{ - ((GLMeshInterface *)gl_mesh->descriptor)->BindVertexBuffer(); -} - -const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefiner( - OpenSubdiv_GLMesh *gl_mesh) -{ - return gl_mesh->topology_refiner; -} - -int openSubdiv_getVersionHex(void) -{ -#if defined(OPENSUBDIV_VERSION_NUMBER) - return OPENSUBDIV_VERSION_NUMBER; -#elif defined(OPENSUBDIV_VERSION_MAJOR) - return OPENSUBDIV_VERSION_MAJOR * 10000 + - OPENSUBDIV_VERSION_MINOR * 100 + - OPENSUBDIV_VERSION_PATCH; -#elif defined(OPENSUBDIV_VERSION) - const char* version = STRINGIFY(OPENSUBDIV_VERSION); - if (version[0] == 'v') { - version += 1; - } - int major = 0, minor = 0, patch = 0; - vector tokens; - stringSplit(&tokens, version, "_", true); - if (tokens.size() == 3) { - major = atoi(tokens[0].c_str()); - minor = atoi(tokens[1].c_str()); - patch = atoi(tokens[2].c_str()); - } - return major * 10000 + minor * 100 + patch; -#else - return 0; -#endif -} diff --git a/intern/opensubdiv/opensubdiv_capi.h b/intern/opensubdiv/opensubdiv_capi.h index c29d08a77e1..a26ea36b863 100644 --- a/intern/opensubdiv/opensubdiv_capi.h +++ b/intern/opensubdiv/opensubdiv_capi.h @@ -1,163 +1,43 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2013 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __OPENSUBDIV_CAPI_H__ -#define __OPENSUBDIV_CAPI_H__ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_CAPI_H_ +#define OPENSUBDIV_CAPI_H_ + +#include "opensubdiv_capi_type.h" #ifdef __cplusplus extern "C" { #endif -// Types declaration. -struct OpenSubdiv_GLMesh; -struct OpenSubdiv_GLMeshDescr; -struct OpenSubdiv_GLMeshFVarData; -struct OpenSubdiv_TopologyRefinerDescr; - -typedef struct OpenSubdiv_GLMesh OpenSubdiv_GLMesh; - -// Keep this a bitmask os it's possible to pass available -// evaluators to Blender. -enum { - OPENSUBDIV_EVALUATOR_CPU = (1 << 0), - OPENSUBDIV_EVALUATOR_OPENMP = (1 << 1), - OPENSUBDIV_EVALUATOR_OPENCL = (1 << 2), - OPENSUBDIV_EVALUATOR_CUDA = (1 << 3), - OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK = (1 << 4), - OPENSUBDIV_EVALUATOR_GLSL_COMPUTE = (1 << 5), -}; - -enum { - OPENSUBDIV_SCHEME_CATMARK, - OPENSUBDIV_SCHEME_BILINEAR, - OPENSUBDIV_SCHEME_LOOP, -}; - -/* TODO(sergey): Re-name and avoid bad level data access. */ -OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner( - struct OpenSubdiv_TopologyRefinerDescr *topology_refiner, - int evaluator_type, - int level); - -void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh); -unsigned int openSubdiv_getOsdGLMeshPatchIndexBuffer( - OpenSubdiv_GLMesh *gl_mesh); -unsigned int openSubdiv_getOsdGLMeshVertexBuffer(OpenSubdiv_GLMesh *gl_mesh); -void openSubdiv_osdGLMeshUpdateVertexBuffer(OpenSubdiv_GLMesh *gl_mesh, - const float *vertex_data, - int start_vertex, - int num_verts); -void openSubdiv_osdGLMeshRefine(OpenSubdiv_GLMesh *gl_mesh); -void openSubdiv_osdGLMeshSynchronize(OpenSubdiv_GLMesh *gl_mesh); -void openSubdiv_osdGLMeshBindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh); - -const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefiner( - OpenSubdiv_GLMesh *gl_mesh); - -/* ============================= Evaluator API ============================== */ - -struct OpenSubdiv_EvaluatorDescr; -typedef struct OpenSubdiv_EvaluatorDescr OpenSubdiv_EvaluatorDescr; - -/* TODO(sergey): Avoid bad-level data access, */ -OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr( - struct OpenSubdiv_TopologyRefinerDescr *topology_refiner, - int subsurf_level); - -void openSubdiv_deleteEvaluatorDescr( - OpenSubdiv_EvaluatorDescr *evaluator_descr); - -void openSubdiv_setEvaluatorCoarsePositions( - OpenSubdiv_EvaluatorDescr *evaluator_descr, - const float *positions, - int start_vertex_index, - int num_vertices); -void openSubdiv_setEvaluatorVaryingData( - OpenSubdiv_EvaluatorDescr *evaluator_descr, - const float *varying_data, - int start_vertex_index, - int num_vertices); - -void openSubdiv_setEvaluatorCoarsePositionsFromBuffer( - OpenSubdiv_EvaluatorDescr *evaluator_descr, - const void *buffer, - int start_offset, - int stride, - int start_vertex_index, - int num_vertices); - -void openSubdiv_refineEvaluator(OpenSubdiv_EvaluatorDescr *evaluator_descr); - -void openSubdiv_evaluateLimit(OpenSubdiv_EvaluatorDescr *evaluator_descr, - int osd_face_index, - float face_u, float face_v, - float P[3], - float dPdu[3], - float dPdv[3]); - -void openSubdiv_evaluateVarying(OpenSubdiv_EvaluatorDescr *evaluator_descr, - int osd_face_index, - float face_u, float face_v, - float varying[3]); - -/* ============================== Mesh drawing =============================== */ - -/* Initialize/Deinitialize global OpenGL drawing buffers/GLSL programs. */ -bool openSubdiv_osdGLDisplayInit(void); -void openSubdiv_osdGLDisplayDeinit(void); - -/* Initialize all the invariants which stays the same for every single path, - * for example lighting model stays untouched for the whole mesh. - * - * TODO(sergey): Some of the stuff could be initialized once for all meshes. - */ -void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl, int active_uv_index); - -/* Draw specified patches. */ -void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh, - int fill_quads, - int start_patch, - int num_patches); - -void openSubdiv_osdGLAllocFVar( - struct OpenSubdiv_TopologyRefinerDescr *topology_refiner, - OpenSubdiv_GLMesh *gl_mesh, - const float *fvar_data); - -void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh); - -/* =========================== Utility functions ============================ */ - -int openSubdiv_getAvailableEvaluators(void); +// Global initialization/deinitialization. +// +// Supposed to be called from main thread. void openSubdiv_init(void); void openSubdiv_cleanup(void); +// Bitmask of eOpenSubdivEvaluator. +int openSubdiv_getAvailableEvaluators(void); + int openSubdiv_getVersionHex(void); #ifdef __cplusplus } #endif -#endif // __OPENSUBDIV_CAPI_H__ +#endif // OPENSUBDIV_CAPI_H_ diff --git a/intern/opensubdiv/opensubdiv_capi_type.h b/intern/opensubdiv/opensubdiv_capi_type.h new file mode 100644 index 00000000000..04fe2afff53 --- /dev/null +++ b/intern/opensubdiv/opensubdiv_capi_type.h @@ -0,0 +1,41 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_CAPI_TYPES_H_ +#define OPENSUBDIV_CAPI_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// Keep this a bitmask os it's possible to pass available +// evaluators to Blender. +typedef enum eOpenSubdivEvaluator { + OPENSUBDIV_EVALUATOR_CPU = (1 << 0), + OPENSUBDIV_EVALUATOR_OPENMP = (1 << 1), + OPENSUBDIV_EVALUATOR_OPENCL = (1 << 2), + OPENSUBDIV_EVALUATOR_CUDA = (1 << 3), + OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK = (1 << 4), + OPENSUBDIV_EVALUATOR_GLSL_COMPUTE = (1 << 5), +} eOpenSubdivEvaluator; + +#ifdef __cplusplus +} +#endif + +#endif // OPENSUBDIV_CAPI_TYPES_H_ diff --git a/intern/opensubdiv/opensubdiv_converter.cc b/intern/opensubdiv/opensubdiv_converter.cc deleted file mode 100644 index fec15b118ae..00000000000 --- a/intern/opensubdiv/opensubdiv_converter.cc +++ /dev/null @@ -1,764 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2015 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include -#include - -#ifdef _MSC_VER -# include "iso646.h" -#endif - -#include - -#include "MEM_guardedalloc.h" - -#include "opensubdiv_converter_capi.h" -#include "opensubdiv_intern.h" -#include "opensubdiv_topology_refiner.h" - - -#include - -#ifdef OPENSUBDIV_ORIENT_TOPOLOGY -namespace { - -inline void reverse_face_verts(int *face_verts, int num_verts) -{ - int last_vert = face_verts[num_verts - 1]; - for (int i = num_verts - 1; i > 0; --i) { - face_verts[i] = face_verts[i - 1]; - } - face_verts[0] = last_vert; -} - -struct TopologyRefinerData { - const OpenSubdiv_Converter& conv; - std::vector *uvs; -}; - -} /* namespace */ -#endif /* OPENSUBDIV_ORIENT_TOPOLOGY */ - -namespace OpenSubdiv { -namespace OPENSUBDIV_VERSION { -namespace Far { - -namespace { - -template -inline int findInArray(T array, int value) -{ - return (int)(std::find(array.begin(), array.end(), value) - array.begin()); -} - -#ifdef OPENSUBDIV_ORIENT_TOPOLOGY -inline int get_loop_winding(int vert0_of_face, int vert1_of_face) -{ - int delta_face = vert1_of_face - vert0_of_face; - if (abs(delta_face) != 1) { - if (delta_face > 0) { - delta_face = -1; - } - else { - delta_face = 1; - } - } - return delta_face; -} - -inline void reverse_face_loops(IndexArray face_verts, IndexArray face_edges) -{ - for (int i = 0; i < face_verts.size() / 2; ++i) { - int j = face_verts.size() - i - 1; - if (i != j) { - std::swap(face_verts[i], face_verts[j]); - std::swap(face_edges[i], face_edges[j]); - } - } - reverse_face_verts(&face_verts[0], face_verts.size()); -} - -inline void check_oriented_vert_connectivity(const int num_vert_edges, - const int num_vert_faces, - const int *vert_edges, - const int *vert_faces, - const int *dst_vert_edges, - const int *dst_vert_faces) -{ -# ifndef NDEBUG - for (int i = 0; i < num_vert_faces; ++i) { - bool found = false; - for (int j = 0; j < num_vert_faces; ++j) { - if (vert_faces[i] == dst_vert_faces[j]) { - found = true; - break; - } - } - if (!found) { - assert(!"vert-faces connectivity ruined"); - } - } - for (int i = 0; i < num_vert_edges; ++i) { - bool found = false; - for (int j = 0; j < num_vert_edges; ++j) { - if (vert_edges[i] == dst_vert_edges[j]) { - found = true; - break; - } - } - if (!found) { - assert(!"vert-edges connectivity ruined"); - } - } -# else - (void)num_vert_edges; - (void)num_vert_faces; - (void)vert_edges; - (void)vert_faces; - (void)dst_vert_edges; - (void)dst_vert_faces; -# endif -} -#endif - -} /* namespace */ - -template <> -inline bool TopologyRefinerFactory::resizeComponentTopology( - TopologyRefiner& refiner, - const TopologyRefinerData& cb_data) -{ - const OpenSubdiv_Converter& conv = cb_data.conv; - /* Faces and face-verts */ - const int num_faces = conv.get_num_faces(&conv); - setNumBaseFaces(refiner, num_faces); - for (int face = 0; face < num_faces; ++face) { - const int num_verts = conv.get_num_face_verts(&conv, face); - setNumBaseFaceVertices(refiner, face, num_verts); - } - /* Edges and edge-faces. */ - const int num_edges = conv.get_num_edges(&conv); - setNumBaseEdges(refiner, num_edges); - for (int edge = 0; edge < num_edges; ++edge) { - const int num_edge_faces = conv.get_num_edge_faces(&conv, edge); - setNumBaseEdgeFaces(refiner, edge, num_edge_faces); - } - /* Vertices and vert-faces and vert-edges/ */ - const int num_verts = conv.get_num_verts(&conv); - setNumBaseVertices(refiner, num_verts); - for (int vert = 0; vert < num_verts; ++vert) { - const int num_vert_edges = conv.get_num_vert_edges(&conv, vert), - num_vert_faces = conv.get_num_vert_faces(&conv, vert); - setNumBaseVertexEdges(refiner, vert, num_vert_edges); - setNumBaseVertexFaces(refiner, vert, num_vert_faces); - } - return true; -} - -template <> -inline bool TopologyRefinerFactory::assignComponentTopology( - TopologyRefiner& refiner, - const TopologyRefinerData &cb_data) -{ - const OpenSubdiv_Converter& conv = cb_data.conv; - using Far::IndexArray; - /* Face relations. */ - const int num_faces = conv.get_num_faces(&conv); - for (int face = 0; face < num_faces; ++face) { - IndexArray dst_face_verts = getBaseFaceVertices(refiner, face); - conv.get_face_verts(&conv, face, &dst_face_verts[0]); - IndexArray dst_face_edges = getBaseFaceEdges(refiner, face); - conv.get_face_edges(&conv, face, &dst_face_edges[0]); - } - /* Edge relations. */ - const int num_edges = conv.get_num_edges(&conv); - for (int edge = 0; edge < num_edges; ++edge) { - /* Edge-vertices */ - IndexArray dst_edge_verts = getBaseEdgeVertices(refiner, edge); - conv.get_edge_verts(&conv, edge, &dst_edge_verts[0]); - /* Edge-faces */ - IndexArray dst_edge_faces = getBaseEdgeFaces(refiner, edge); - conv.get_edge_faces(&conv, edge, &dst_edge_faces[0]); - } -#ifdef OPENSUBDIV_ORIENT_TOPOLOGY - /* Make face normals consistent. */ - bool *face_used = new bool[num_faces]; - memset(face_used, 0, sizeof(bool) * num_faces); - std::stack traverse_stack; - int face_start = 0, num_traversed_faces = 0; - /* Traverse all islands. */ - while (num_traversed_faces != num_faces) { - /* Find first face of any untraversed islands. */ - while (face_used[face_start]) { - ++face_start; - } - /* Add first face to the stack. */ - traverse_stack.push(face_start); - face_used[face_start] = true; - /* Go over whole connected component. */ - while (!traverse_stack.empty()) { - int face = traverse_stack.top(); - traverse_stack.pop(); - IndexArray face_edges = getBaseFaceEdges(refiner, face); - ConstIndexArray face_verts = getBaseFaceVertices(refiner, face); - for (int edge_index = 0; edge_index < face_edges.size(); ++edge_index) { - const int edge = face_edges[edge_index]; - ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge); - if (edge_faces.size() != 2) { - /* Can't make consistent normals for non-manifolds. */ - continue; - } - ConstIndexArray edge_verts = getBaseEdgeVertices(refiner, edge); - /* Get winding of the reference face. */ - int vert0_of_face = findInArray(face_verts, edge_verts[0]), - vert1_of_face = findInArray(face_verts, edge_verts[1]); - int delta_face = get_loop_winding(vert0_of_face, vert1_of_face); - for (int edge_face = 0; edge_face < edge_faces.size(); ++edge_face) { - int other_face = edge_faces[edge_face]; - /* Never re-traverse faces, only move forward. */ - if (face_used[other_face]) { - continue; - } - IndexArray other_face_verts = getBaseFaceVertices(refiner, - other_face); - int vert0_of_other_face = findInArray(other_face_verts, - edge_verts[0]), - vert1_of_other_face = findInArray(other_face_verts, - edge_verts[1]); - int delta_other_face = get_loop_winding(vert0_of_other_face, - vert1_of_other_face); - if (delta_face * delta_other_face > 0) { - IndexArray other_face_verts = getBaseFaceVertices(refiner, - other_face), - other_face_edges = getBaseFaceEdges(refiner, - other_face); - reverse_face_loops(other_face_verts, - other_face_edges); - } - traverse_stack.push(other_face); - face_used[other_face] = true; - } - } - ++num_traversed_faces; - } - } -#endif /* OPENSUBDIV_ORIENT_TOPOLOGY */ - /* Vertex relations */ - const int num_verts = conv.get_num_verts(&conv); - for (int vert = 0; vert < num_verts; ++vert) { - - /* Vert-Faces */ - IndexArray dst_vert_faces = getBaseVertexFaces(refiner, vert); - int num_vert_faces = conv.get_num_vert_faces(&conv, vert); - int *vert_faces = new int[num_vert_faces]; - conv.get_vert_faces(&conv, vert, vert_faces); - /* Vert-Edges */ - IndexArray dst_vert_edges = getBaseVertexEdges(refiner, vert); - int num_vert_edges = conv.get_num_vert_edges(&conv, vert); - int *vert_edges = new int[num_vert_edges]; - conv.get_vert_edges(&conv, vert, vert_edges); -#ifdef OPENSUBDIV_ORIENT_TOPOLOGY - /* ** Order vertex edges and faces in a CCW order. ** */ - memset(face_used, 0, sizeof(bool) * num_faces); - /* Number of edges and faces added to the ordered array. */ - int edge_count_ordered = 0, face_count_ordered = 0; - /* Add loose edges straight into the edges array. */ - bool has_fan_connections = false; - for (int i = 0; i < num_vert_edges; ++i) { - IndexArray edge_faces = getBaseEdgeFaces(refiner, vert_edges[i]); - if (edge_faces.size() == 0) { - dst_vert_edges[edge_count_ordered++] = vert_edges[i]; - } - else if (edge_faces.size() > 2) { - has_fan_connections = true; - } - } - if (has_fan_connections) { - /* OpenSubdiv currently doesn't give us clues how to handle - * fan face connections. and since handling such connections - * complicates the loop below we simply don't do special - * orientation for them. - */ - memcpy(&dst_vert_edges[0], vert_edges, sizeof(int) * num_vert_edges); - memcpy(&dst_vert_faces[0], vert_faces, sizeof(int) * num_vert_faces); - delete [] vert_edges; - delete [] vert_faces; - continue; - } - /* Perform at max numbder of vert-edges iteration and try to avoid - * deadlock here for malformed mesh. - */ - for (int global_iter = 0; global_iter < num_vert_edges; ++global_iter) { - /* Numbr of edges and faces which are still to be ordered. */ - int num_vert_edges_remained = num_vert_edges - edge_count_ordered, - num_vert_faces_remained = num_vert_faces - face_count_ordered; - if (num_vert_edges_remained == 0 && num_vert_faces_remained == 0) { - /* All done, nothing to do anymore. */ - break; - } - /* Face, edge and face-vertex inndex to start traversal from. */ - int face_start = -1, edge_start = -1, face_vert_start = -1; - if (num_vert_edges_remained == num_vert_faces_remained) { - /* Vertex is eitehr complete manifold or is connected to seevral - * manifold islands (hourglass-like configuration), can pick up - * random edge unused and start from it. - */ - /* TODO(sergey): Start from previous edge from which traversal - * began at previous iteration. - */ - for (int i = 0; i < num_vert_edges; ++i) { - face_start = vert_faces[i]; - if (!face_used[face_start]) { - ConstIndexArray - face_verts = getBaseFaceVertices(refiner, face_start), - face_edges = getBaseFaceEdges(refiner, face_start); - face_vert_start = findInArray(face_verts, vert); - edge_start = face_edges[face_vert_start]; - break; - } - } - } - else { - /* Special handle of non-manifold vertex. */ - for (int i = 0; i < num_vert_edges; ++i) { - edge_start = vert_edges[i]; - IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_start); - if (edge_faces.size() == 1) { - face_start = edge_faces[0]; - if (!face_used[face_start]) { - ConstIndexArray - face_verts = getBaseFaceVertices(refiner, face_start), - face_edges = getBaseFaceEdges(refiner, face_start); - face_vert_start = findInArray(face_verts, vert); - if (edge_start == face_edges[face_vert_start]) { - break; - } - } - } - /* Reset indices for sanity check below. */ - face_start = edge_start = face_vert_start = -1; - } - } - /* Sanity check. */ - assert(face_start != -1 && - edge_start != -1 && - face_vert_start != -1); - /* Traverse faces starting from the current one. */ - int edge_first = edge_start; - dst_vert_faces[face_count_ordered++] = face_start; - dst_vert_edges[edge_count_ordered++] = edge_start; - face_used[face_start] = true; - while (edge_count_ordered < num_vert_edges) { - IndexArray face_verts = getBaseFaceVertices(refiner, face_start); - IndexArray face_edges = getBaseFaceEdges(refiner, face_start); - int face_edge_start = face_vert_start; - int face_edge_next = (face_edge_start > 0) ? (face_edge_start - 1) : (face_verts.size() - 1); - Index edge_next = face_edges[face_edge_next]; - if (edge_next == edge_first) { - /* Multiple manifolds found, stop for now and handle rest - * in the next iteration. - */ - break; - } - dst_vert_edges[edge_count_ordered++] = edge_next; - if (face_count_ordered < num_vert_faces) { - IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_next); - assert(edge_faces.size() != 0); - if (edge_faces.size() == 1) { - assert(edge_faces[0] == face_start); - break; - } - else if (edge_faces.size() != 2) { - break; - } - assert(edge_faces.size() == 2); - face_start = edge_faces[(edge_faces[0] == face_start) ? 1 : 0]; - face_vert_start = findInArray(getBaseFaceEdges(refiner, face_start), edge_next); - dst_vert_faces[face_count_ordered++] = face_start; - face_used[face_start] = true; - } - edge_start = edge_next; - } - } - /* Verify ordering doesn't ruin connectivity information. */ - assert(face_count_ordered == num_vert_faces); - assert(edge_count_ordered == num_vert_edges); - check_oriented_vert_connectivity(num_vert_edges, - num_vert_faces, - vert_edges, - vert_faces, - &dst_vert_edges[0], - &dst_vert_faces[0]); - /* For the release builds we're failing mesh construction so instead - * of nasty bugs the unsupported mesh will simply disappear from the - * viewport. - */ - if (face_count_ordered != num_vert_faces || - edge_count_ordered != num_vert_edges) - { - delete [] vert_edges; - delete [] vert_faces; - return false; - } -#else /* OPENSUBDIV_ORIENT_TOPOLOGY */ - memcpy(&dst_vert_edges[0], vert_edges, sizeof(int) * num_vert_edges); - memcpy(&dst_vert_faces[0], vert_faces, sizeof(int) * num_vert_faces); -#endif /* OPENSUBDIV_ORIENT_TOPOLOGY */ - delete [] vert_edges; - delete [] vert_faces; - } -#ifdef OPENSUBDIV_ORIENT_TOPOLOGY - delete [] face_used; -#endif - populateBaseLocalIndices(refiner); - return true; -}; - -template <> -inline bool TopologyRefinerFactory::assignComponentTags( - TopologyRefiner& refiner, - const TopologyRefinerData& cb_data) -{ - const OpenSubdiv_Converter& conv = cb_data.conv; - typedef OpenSubdiv::Sdc::Crease Crease; - - int num_edges = conv.get_num_edges(&conv); - for (int edge = 0; edge < num_edges; ++edge) { - float sharpness; - ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge); - if (edge_faces.size() == 2) { - sharpness = conv.get_edge_sharpness(&conv, edge); - } - else { - /* Non-manifold edges must be sharp. */ - sharpness = Crease::SHARPNESS_INFINITE; - } - setBaseEdgeSharpness(refiner, edge, sharpness); - } - - /* OpenSubdiv expects non-manifold vertices to be sharp but at the - * time it handles correct cases when vertex is a corner of plane. - * Currently mark verts which are adjacent to a loose edge as sharp, - * but this decision needs some more investigation. - */ - int num_vert = conv.get_num_verts(&conv); - for (int vert = 0; vert < num_vert; ++vert) { - ConstIndexArray vert_edges = getBaseVertexEdges(refiner, vert); - for (int edge_index = 0; edge_index < vert_edges.size(); ++edge_index) { - int edge = vert_edges[edge_index]; - ConstIndexArray edge_faces = getBaseEdgeFaces(refiner, edge); - if (edge_faces.size() == 0) { - setBaseVertexSharpness(refiner, vert, Crease::SHARPNESS_INFINITE); - break; - } - } - if (vert_edges.size() == 2) { - int edge0 = vert_edges[0], - edge1 = vert_edges[1]; - float sharpness0 = conv.get_edge_sharpness(&conv, edge0), - sharpness1 = conv.get_edge_sharpness(&conv, edge1); - float sharpness = std::min(sharpness0, sharpness1); - setBaseVertexSharpness(refiner, vert, sharpness); - } - } - - return true; -} - -template <> -inline void TopologyRefinerFactory::reportInvalidTopology( - TopologyError /*errCode*/, - const char *msg, - const TopologyRefinerData& /*mesh*/) -{ - printf("OpenSubdiv Error: %s\n", msg); -} - -template <> -inline bool TopologyRefinerFactory::assignFaceVaryingTopology( - TopologyRefiner& refiner, - const TopologyRefinerData& cb_data) -{ - const OpenSubdiv_Converter& conv = cb_data.conv; - const int num_layers = conv.get_num_uv_layers(&conv); - if (num_layers <= 0) { - /* No UV maps, we can skip any face-varying data. */ - return true; - } - const int num_faces = getNumBaseFaces(refiner); - size_t uvs_offset = 0; - for (int layer = 0; layer < num_layers; ++layer) { - conv.precalc_uv_layer(&conv, layer); - const int num_uvs = conv.get_num_uvs(&conv); - /* Fill in UV coordinates. */ - cb_data.uvs->resize(cb_data.uvs->size() + num_uvs * 2); - conv.get_uvs(&conv, &cb_data.uvs->at(uvs_offset)); - uvs_offset += num_uvs * 2; - /* Fill in per-corner index of the UV. */ - const int channel = createBaseFVarChannel(refiner, num_uvs); - for (int face = 0; face < num_faces; ++face) { - Far::IndexArray dst_face_uvs = getBaseFaceFVarValues(refiner, - face, - channel); - for (int corner = 0; corner < dst_face_uvs.size(); ++corner) { - const int uv_index = conv.get_face_corner_uv_index(&conv, - face, - corner); - dst_face_uvs[corner] = uv_index; - } - } - conv.finish_uv_layer(&conv); - } - return true; -} - -} /* namespace Far */ -} /* namespace OPENSUBDIV_VERSION */ -} /* namespace OpenSubdiv */ - -namespace { - -OpenSubdiv::Sdc::SchemeType get_capi_scheme_type(OpenSubdiv_SchemeType type) -{ - switch (type) { - case OSD_SCHEME_BILINEAR: - return OpenSubdiv::Sdc::SCHEME_BILINEAR; - case OSD_SCHEME_CATMARK: - return OpenSubdiv::Sdc::SCHEME_CATMARK; - case OSD_SCHEME_LOOP: - return OpenSubdiv::Sdc::SCHEME_LOOP; - } - assert(!"Unknown scheme type passed via C-API"); - return OpenSubdiv::Sdc::SCHEME_CATMARK; -} - -OpenSubdiv::Sdc::Options::FVarLinearInterpolation -get_capi_fvar_linear_interpolation( - OpenSubdiv_FVarLinearInterpolation linear_interpolation) -{ - typedef OpenSubdiv::Sdc::Options Options; - switch (linear_interpolation) { - case OSD_FVAR_LINEAR_INTERPOLATION_NONE: - return Options::FVAR_LINEAR_NONE; - case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY: - return Options::FVAR_LINEAR_CORNERS_ONLY; - case OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES: - return Options::FVAR_LINEAR_BOUNDARIES; - case OSD_FVAR_LINEAR_INTERPOLATION_ALL: - return Options::FVAR_LINEAR_ALL; - } - assert(!"Unknown fvar linear interpolation passed via C-API"); - return Options::FVAR_LINEAR_NONE; -} - -} /* namespace */ - -struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr( - OpenSubdiv_Converter *converter) -{ - typedef OpenSubdiv::Sdc::Options Options; - - using OpenSubdiv::Far::TopologyRefinerFactory; - const OpenSubdiv::Sdc::SchemeType scheme_type = - get_capi_scheme_type(converter->get_scheme_type(converter)); - const Options::FVarLinearInterpolation linear_interpolation = - get_capi_fvar_linear_interpolation( - converter->get_fvar_linear_interpolation(converter)); - Options options; - options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY); - options.SetCreasingMethod(Options::CREASE_UNIFORM); - options.SetFVarLinearInterpolation(linear_interpolation); - - TopologyRefinerFactory::Options - topology_options(scheme_type, options); -#ifdef OPENSUBDIV_VALIDATE_TOPOLOGY - topology_options.validateFullTopology = true; -#endif - OpenSubdiv_TopologyRefinerDescr *result = OBJECT_GUARDED_NEW(OpenSubdiv_TopologyRefinerDescr); - TopologyRefinerData cb_data = {*converter, &result->uvs}; - /* We don't use guarded allocation here so we can re-use the refiner - * for GL mesh creation directly. - */ - result->osd_refiner = - TopologyRefinerFactory::Create( - cb_data, - topology_options); - - return result; -} - -void openSubdiv_deleteTopologyRefinerDescr( - OpenSubdiv_TopologyRefinerDescr *topology_refiner) -{ - delete topology_refiner->osd_refiner; - OBJECT_GUARDED_DELETE(topology_refiner, OpenSubdiv_TopologyRefinerDescr); -} - -int openSubdiv_topologyRefinerGetSubdivLevel( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner) -{ - using OpenSubdiv::Far::TopologyRefiner; - const TopologyRefiner *refiner = topology_refiner->osd_refiner; - return refiner->GetMaxLevel(); -} - -int openSubdiv_topologyRefinerGetNumVerts( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner) -{ - using OpenSubdiv::Far::TopologyLevel; - using OpenSubdiv::Far::TopologyRefiner; - const TopologyRefiner *refiner = topology_refiner->osd_refiner; - const TopologyLevel &base_level = refiner->GetLevel(0); - return base_level.GetNumVertices(); -} - -int openSubdiv_topologyRefinerGetNumEdges( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner) -{ - using OpenSubdiv::Far::TopologyLevel; - using OpenSubdiv::Far::TopologyRefiner; - const TopologyRefiner *refiner = topology_refiner->osd_refiner; - const TopologyLevel &base_level = refiner->GetLevel(0); - return base_level.GetNumEdges(); -} - -int openSubdiv_topologyRefinerGetNumFaces( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner) -{ - using OpenSubdiv::Far::TopologyLevel; - using OpenSubdiv::Far::TopologyRefiner; - const TopologyRefiner *refiner = topology_refiner->osd_refiner; - const TopologyLevel &base_level = refiner->GetLevel(0); - return base_level.GetNumFaces(); -} - -int openSubdiv_topologyRefinerGetNumFaceVerts( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner, - int face) -{ - using OpenSubdiv::Far::TopologyLevel; - using OpenSubdiv::Far::TopologyRefiner; - const TopologyRefiner *refiner = topology_refiner->osd_refiner; - const TopologyLevel &base_level = refiner->GetLevel(0); - return base_level.GetFaceVertices(face).size(); -} - -int openSubdiv_topologyRefnerCompareConverter( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner, - OpenSubdiv_Converter *converter) -{ - typedef OpenSubdiv::Sdc::Options Options; - using OpenSubdiv::Far::ConstIndexArray; - using OpenSubdiv::Far::TopologyRefiner; - using OpenSubdiv::Far::TopologyLevel; - const TopologyRefiner *refiner = topology_refiner->osd_refiner; - const TopologyLevel &base_level = refiner->GetLevel(0); - const int num_verts = base_level.GetNumVertices(); - const int num_edges = base_level.GetNumEdges(); - const int num_faces = base_level.GetNumFaces(); - /* Quick preliminary check. */ - OpenSubdiv::Sdc::SchemeType scheme_type = - get_capi_scheme_type(converter->get_scheme_type(converter)); - if (scheme_type != refiner->GetSchemeType()) { - return false; - } - const Options options = refiner->GetSchemeOptions(); - const Options::FVarLinearInterpolation interp = - options.GetFVarLinearInterpolation(); - const Options::FVarLinearInterpolation new_interp = - get_capi_fvar_linear_interpolation( - converter->get_fvar_linear_interpolation(converter)); - if (new_interp != interp) { - return false; - } - if (converter->get_num_verts(converter) != num_verts || - converter->get_num_edges(converter) != num_edges || - converter->get_num_faces(converter) != num_faces) - { - return false; - } - /* Compare all edges. */ - for (int edge = 0; edge < num_edges; ++edge) { - ConstIndexArray edge_verts = base_level.GetEdgeVertices(edge); - int conv_edge_verts[2]; - converter->get_edge_verts(converter, edge, conv_edge_verts); - if (conv_edge_verts[0] != edge_verts[0] || - conv_edge_verts[1] != edge_verts[1]) - { - return false; - } - } - /* Compare all faces. */ - std::vector conv_face_verts; - for (int face = 0; face < num_faces; ++face) { - ConstIndexArray face_verts = base_level.GetFaceVertices(face); - if (face_verts.size() != converter->get_num_face_verts(converter, - face)) - { - return false; - } - conv_face_verts.resize(face_verts.size()); - converter->get_face_verts(converter, face, &conv_face_verts[0]); - bool direct_match = true; - for (int i = 0; i < face_verts.size(); ++i) { - if (conv_face_verts[i] != face_verts[i]) { - direct_match = false; - break; - } - } - if (!direct_match) { - /* If face didn't match in direct direction we also test if it - * matches in reversed direction. This is because conversion might - * reverse loops to make normals consistent. - */ -#ifdef OPENSUBDIV_ORIENT_TOPOLOGY - reverse_face_verts(&conv_face_verts[0], conv_face_verts.size()); - for (int i = 0; i < face_verts.size(); ++i) { - if (conv_face_verts[i] != face_verts[i]) { - return false; - } - } -#else - return false; -#endif - } - } - /* Compare sharpness. */ - for (int edge = 0; edge < num_edges; ++edge) { - ConstIndexArray edge_faces = base_level.GetEdgeFaces(edge); - float sharpness = base_level.GetEdgeSharpness(edge); - float conv_sharpness; - if (edge_faces.size() == 2) { - conv_sharpness = converter->get_edge_sharpness(converter, edge); - } - else { - conv_sharpness = OpenSubdiv::Sdc::Crease::SHARPNESS_INFINITE; - } - if (sharpness != conv_sharpness) { - return false; - } - } - return true; -} diff --git a/intern/opensubdiv/opensubdiv_converter_capi.h b/intern/opensubdiv/opensubdiv_converter_capi.h index ea4f20c5961..1d76da4d76b 100644 --- a/intern/opensubdiv/opensubdiv_converter_capi.h +++ b/intern/opensubdiv/opensubdiv_converter_capi.h @@ -1,149 +1,150 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2015 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __OPENSUBDIV_CONVERTER_CAPI_H__ -#define __OPENSUBDIV_CONVERTER_CAPI_H__ +// Copyright 2015 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_CONVERTER_CAPI_H_ +#define OPENSUBDIV_CONVERTER_CAPI_H_ #ifdef __cplusplus extern "C" { #endif -struct OpenSubdiv_TopologyRefinerDescr; -typedef struct OpenSubdiv_TopologyRefinerDescr OpenSubdiv_TopologyRefinerDescr; - -typedef struct OpenSubdiv_Converter OpenSubdiv_Converter; - typedef enum OpenSubdiv_SchemeType { - OSD_SCHEME_BILINEAR, - OSD_SCHEME_CATMARK, - OSD_SCHEME_LOOP, + OSD_SCHEME_BILINEAR, + OSD_SCHEME_CATMARK, + OSD_SCHEME_LOOP, } OpenSubdiv_SchemeType; typedef enum OpenSubdiv_FVarLinearInterpolation { - OSD_FVAR_LINEAR_INTERPOLATION_NONE, - OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY, - OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES, - OSD_FVAR_LINEAR_INTERPOLATION_ALL, + OSD_FVAR_LINEAR_INTERPOLATION_NONE, + OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY, + OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES, + OSD_FVAR_LINEAR_INTERPOLATION_ALL, } OpenSubdiv_FVarLinearInterpolation; typedef struct OpenSubdiv_Converter { - /* TODO(sergey): Needs to be implemented. */ - /* OpenSubdiv::Sdc::Options get_options() const; */ - - OpenSubdiv_SchemeType (*get_scheme_type)( - const OpenSubdiv_Converter *converter); - - OpenSubdiv_FVarLinearInterpolation (*get_fvar_linear_interpolation)( - const OpenSubdiv_Converter *converter); - - int (*get_num_faces)(const OpenSubdiv_Converter *converter); - int (*get_num_edges)(const OpenSubdiv_Converter *converter); - int (*get_num_verts)(const OpenSubdiv_Converter *converter); - - /* Face relationships. */ - int (*get_num_face_verts)(const OpenSubdiv_Converter *converter, - int face); - void (*get_face_verts)(const OpenSubdiv_Converter *converter, - int face, - int *face_verts); - void (*get_face_edges)(const OpenSubdiv_Converter *converter, - int face, - int *face_edges); - - /* Edge relationships. */ - void (*get_edge_verts)(const OpenSubdiv_Converter *converter, - int edge, - int *edge_verts); - int (*get_num_edge_faces)(const OpenSubdiv_Converter *converter, - int edge); - void (*get_edge_faces)(const OpenSubdiv_Converter *converter, - int edge, - int *edge_faces); - float (*get_edge_sharpness)(const OpenSubdiv_Converter *converter, - int edge); - - /* Vertex relationships. */ - int (*get_num_vert_edges)(const OpenSubdiv_Converter *converter, int vert); - void (*get_vert_edges)(const OpenSubdiv_Converter *converter, - int vert, - int *vert_edges); - int (*get_num_vert_faces)(const OpenSubdiv_Converter *converter, int vert); - void (*get_vert_faces)(const OpenSubdiv_Converter *converter, - int vert, - int *vert_faces); - - /* Face-varying data. */ - int (*get_num_uv_layers)(const OpenSubdiv_Converter *converter); - - void (*precalc_uv_layer)(const OpenSubdiv_Converter *converter, int layer); - void (*finish_uv_layer)(const OpenSubdiv_Converter *converter); - - int (*get_num_uvs)(const OpenSubdiv_Converter *converter); - void (*get_uvs)(const OpenSubdiv_Converter *converter, float *uvs); - - int (*get_face_corner_uv_index)(const OpenSubdiv_Converter *converter, - int face, - int corner); - - /* User data associated with this converter. */ - void (*free_user_data)(const OpenSubdiv_Converter *converter); - void *user_data; + OpenSubdiv_SchemeType (*getSchemeType)( + const struct OpenSubdiv_Converter* converter); + + OpenSubdiv_FVarLinearInterpolation (*getFVarLinearInterpolation)( + const struct OpenSubdiv_Converter* converter); + + ////////////////////////////////////////////////////////////////////////////// + // Global geometry counters. + // Number of faces/edges/vertices in the base mesh. + int (*getNumFaces)(const struct OpenSubdiv_Converter* converter); + int (*getNumEdges)(const struct OpenSubdiv_Converter* converter); + int (*getNumVertices)(const struct OpenSubdiv_Converter* converter); + + ////////////////////////////////////////////////////////////////////////////// + // Face relationships. + + // Number of vertices the face consists of. + int (*getNumFaceVertices)(const struct OpenSubdiv_Converter* converter, + const int face_index); + // Array of vertex indices the face consists of. + void (*getFaceVertices)(const struct OpenSubdiv_Converter* converter, + const int face_index, + int* face_vertices); + // Array of edge indices the face consists of. + // Aligned with the vertex indices array, edge i connects face vertex i + // with face index i+1. + void (*getFaceEdges)(const struct OpenSubdiv_Converter *converter, + const int face_index, + int *face_edges); + + ////////////////////////////////////////////////////////////////////////////// + // Edge relationships. + + // Vertices the edge consists of. + void (*getEdgeVertices)(const struct OpenSubdiv_Converter* converter, + const int edge_index, + int edge_vertices[2]); + // Number of faces which are sharing the given edge. + int (*getNumEdgeFaces)(const struct OpenSubdiv_Converter* converter, + const int edge_index); + // Array of face indices which are sharing the given edge. + void (*getEdgeFaces)(const struct OpenSubdiv_Converter* converter, + const int edge, + int* edge_faces); + // Edge sharpness (aka crease). + float (*getEdgeSharpness)(const struct OpenSubdiv_Converter* converter, + const int edge_index); + + ////////////////////////////////////////////////////////////////////////////// + // Vertex relationships. + + // Number of edges which are adjacent to the given vertex. + int (*getNumVertexEdges)(const struct OpenSubdiv_Converter* converter, + const int vertex_index); + // Array fo edge indices which are adjacent to the given vertex. + void (*getVertexEdges)(const struct OpenSubdiv_Converter* converter, + const int vertex_index, + int* vertex_edges); + // Number of faces which are adjacent to the given vertex. + int (*getNumVertexFaces)(const struct OpenSubdiv_Converter* converter, + const int vertex_index); + // Array fo face indices which are adjacent to the given vertex. + void (*getVertexFaces)(const struct OpenSubdiv_Converter* converter, + const int vertex_index, + int* vertex_faces); + + ////////////////////////////////////////////////////////////////////////////// + // Face-varying data. + + ///////////////////////////////////// + // UV coordinates. + + // Number of UV layers. + int (*getNumUVLayers)(const struct OpenSubdiv_Converter* converter); + + // We need some corner connectivity information, which might not be trivial + // to be gathered (might require multiple matching calculations per corver + // query). + // precalc() is called before any corner connectivity or UV coordinate is + // queried from the given layer, allowing converter to calculate and cache + // complex complex-to-calculate information. + // finish() is called after converter is done porting UV layer to OpenSubdiv, + // allowing to free cached data. + void (*precalcUVLayer)(const struct OpenSubdiv_Converter* converter, + const int layer_index); + void (*finishUVLayer)(const struct OpenSubdiv_Converter* converter); + + // Get number of UV coordinates in the current layer (layer which was + // specified in precalcUVLayer(). + int (*getNumUVCoordinates)(const struct OpenSubdiv_Converter* converter); + // Get cooridnates themselves. + void (*getUVCoordinates)(const struct OpenSubdiv_Converter* converter, + float* uvs_coordinates); + // For the given face index and its corner (known as loop in Blender) + // get corrsponding UV coordinate index. + int (*getFaceCornerUVIndex)(const struct OpenSubdiv_Converter* converter, + const int face_index, + const int corner_index); + + ////////////////////////////////////////////////////////////////////////////// + // User data associated with this converter. + + void (*freeUserData)(const struct OpenSubdiv_Converter* converter); + void* user_data; } OpenSubdiv_Converter; -OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr( - OpenSubdiv_Converter *converter); - -void openSubdiv_deleteTopologyRefinerDescr( - OpenSubdiv_TopologyRefinerDescr *topology_refiner); - -/* TODO(sergey): Those calls are not strictly related to conversion. - * needs some dedicated file perhaps. - */ - -int openSubdiv_topologyRefinerGetSubdivLevel( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner); - -int openSubdiv_topologyRefinerGetNumVerts( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner); - -int openSubdiv_topologyRefinerGetNumEdges( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner); - -int openSubdiv_topologyRefinerGetNumFaces( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner); - -int openSubdiv_topologyRefinerGetNumFaceVerts( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner, - int face); - -int openSubdiv_topologyRefnerCompareConverter( - const OpenSubdiv_TopologyRefinerDescr *topology_refiner, - OpenSubdiv_Converter *converter); - #ifdef __cplusplus } #endif -#endif /* __OPENSUBDIV_CONVERTER_CAPI_H__ */ +#endif /* OPENSUBDIV_CONVERTER_CAPI_H_ */ diff --git a/intern/opensubdiv/opensubdiv_device_context_cuda.cc b/intern/opensubdiv/opensubdiv_device_context_cuda.cc deleted file mode 100644 index 46b66a6b35e..00000000000 --- a/intern/opensubdiv/opensubdiv_device_context_cuda.cc +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Adopted from OpenSubdiv with the following license: - * - * Copyright 2015 Pixar - * - * Licensed under the Apache License, Version 2.0 (the "Apache License") - * with the following modification; you may not use this file except in - * compliance with the Apache License and the following modification to it: - * Section 6. Trademarks. is deleted and replaced with: - * - * 6. Trademarks. This License does not grant permission to use the trade - * names, trademarks, service marks, or product names of the Licensor - * and its affiliates, except as required to comply with Section 4(c) of - * the License and to reproduce the content of the NOTICE file. - * - * You may obtain a copy of the Apache License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Apache License with the above modification is - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the Apache License for the specific - * language governing permissions and limitations under the Apache License. - */ - -#ifdef OPENSUBDIV_HAS_CUDA - -#ifdef _MSC_VER -# include "iso646.h" -#endif - -#include "opensubdiv_device_context_cuda.h" - -#if defined(_WIN32) -# include -#elif defined(__APPLE__) -# include -#else -# include -# include -#endif - -#include -#include -#include -#include -#include - -#define message(fmt, ...) -//#define message(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__) -#define error(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__) - -static int _GetCudaDeviceForCurrentGLContext() -{ - // Find and use the CUDA device for the current GL context - unsigned int interopDeviceCount = 0; - int interopDevices[1]; - cudaError_t status = cudaGLGetDevices(&interopDeviceCount, interopDevices, - 1, cudaGLDeviceListCurrentFrame); - if (status == cudaErrorNoDevice or interopDeviceCount != 1) { - message("CUDA no interop devices found.\n"); - return 0; - } - int device = interopDevices[0]; - -#if defined(_WIN32) - return device; - -#elif defined(__APPLE__) - return device; - -#else // X11 - Display * display = glXGetCurrentDisplay(); - int screen = DefaultScreen(display); - if (device != screen) { - error("The CUDA interop device (%d) does not match " - "the screen used by the current GL context (%d), " - "which may cause slow performance on systems " - "with multiple GPU devices.", device, screen); - } - message("CUDA init using device for current GL context: %d\n", device); - return device; -#endif -} - -/* From "NVIDIA GPU Computing SDK 4.2/C/common/inc/cutil_inline_runtime.h": */ - -/* Beginning of GPU Architecture definitions */ -inline int _ConvertSMVer2Cores_local(int major, int minor) -{ - /* Defines for GPU Architecture types (using the SM version to determine - * the # of cores per SM - */ - typedef struct { - int SM; /* 0xMm (hexidecimal notation), - * M = SM Major version, - * and m = SM minor version - */ - int Cores; - } sSMtoCores; - - sSMtoCores nGpuArchCoresPerSM[] = - { { 0x10, 8 }, /* Tesla Generation (SM 1.0) G80 class */ - { 0x11, 8 }, /* Tesla Generation (SM 1.1) G8x class */ - { 0x12, 8 }, /* Tesla Generation (SM 1.2) G9x class */ - { 0x13, 8 }, /* Tesla Generation (SM 1.3) GT200 class */ - { 0x20, 32 }, /* Fermi Generation (SM 2.0) GF100 class */ - { 0x21, 48 }, /* Fermi Generation (SM 2.1) GF10x class */ - { 0x30, 192}, /* Fermi Generation (SM 3.0) GK10x class */ - { -1, -1 } - }; - - int index = 0; - while (nGpuArchCoresPerSM[index].SM != -1) { - if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) { - return nGpuArchCoresPerSM[index].Cores; - } - index++; - } - printf("MapSMtoCores undefined SMversion %d.%d!\n", major, minor); - return -1; -} -/* End of GPU Architecture definitions. */ - -/* This function returns the best GPU (with maximum GFLOPS) */ -inline int cutGetMaxGflopsDeviceId() -{ - int current_device = 0, sm_per_multiproc = 0; - int max_compute_perf = 0, max_perf_device = -1; - int device_count = 0, best_SM_arch = 0; - int compat_major, compat_minor; - - cuDeviceGetCount(&device_count); - /* Find the best major SM Architecture GPU device. */ - while (current_device < device_count) { - cuDeviceComputeCapability(&compat_major, &compat_minor, current_device); - if (compat_major > 0 && compat_major < 9999) { - best_SM_arch = std::max(best_SM_arch, compat_major); - } - current_device++; - } - - /* Find the best CUDA capable GPU device. */ - current_device = 0; - while (current_device < device_count) { - cuDeviceComputeCapability(&compat_major, &compat_minor, current_device); - if (compat_major == 9999 && compat_minor == 9999) { - sm_per_multiproc = 1; - } else { - sm_per_multiproc = _ConvertSMVer2Cores_local(compat_major, - compat_minor); - } - int multi_processor_count; - cuDeviceGetAttribute(&multi_processor_count, - CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, - current_device); - int clock_rate; - cuDeviceGetAttribute(&clock_rate, - CU_DEVICE_ATTRIBUTE_CLOCK_RATE, - current_device); - int compute_perf = multi_processor_count * sm_per_multiproc * clock_rate; - if (compute_perf > max_compute_perf) { - /* If we find GPU with SM major > 2, search only these */ - if (best_SM_arch > 2) { - /* If our device==dest_SM_arch, choose this, or else pass. */ - if (compat_major == best_SM_arch) { - max_compute_perf = compute_perf; - max_perf_device = current_device; - } - } else { - max_compute_perf = compute_perf; - max_perf_device = current_device; - } - } - ++current_device; - } - return max_perf_device; -} - -bool CudaDeviceContext::HAS_CUDA_VERSION_4_0() -{ -#ifdef OPENSUBDIV_HAS_CUDA - static bool cudaInitialized = false; - static bool cudaLoadSuccess = true; - if (!cudaInitialized) { - cudaInitialized = true; - -# ifdef OPENSUBDIV_HAS_CUEW - cudaLoadSuccess = cuewInit(CUEW_INIT_CUDA) == CUEW_SUCCESS; - if (!cudaLoadSuccess) { - fprintf(stderr, "Loading CUDA failed.\n"); - } -# endif - // Need to initialize CUDA here so getting device - // with the maximum FPLOS works fine. - if (cuInit(0) == CUDA_SUCCESS) { - // This is to deal with cases like NVidia Optimus, - // when there might be CUDA library installed but - // NVidia card is not being active. - if (cutGetMaxGflopsDeviceId() < 0) { - cudaLoadSuccess = false; - } - } - else { - cudaLoadSuccess = false; - } - } - return cudaLoadSuccess; -#else - return false; -#endif -} - -CudaDeviceContext::CudaDeviceContext() - : _initialized(false) { -} - -CudaDeviceContext::~CudaDeviceContext() { - cudaDeviceReset(); -} - -bool CudaDeviceContext::Initialize() -{ - /* See if any cuda device is available. */ - int deviceCount = 0; - cudaGetDeviceCount(&deviceCount); - message("CUDA device count: %d\n", deviceCount); - if (deviceCount <= 0) { - return false; - } - cudaGLSetGLDevice(_GetCudaDeviceForCurrentGLContext()); - _initialized = true; - return true; -} - -#endif /* OPENSUBDIV_HAS_CUDA */ diff --git a/intern/opensubdiv/opensubdiv_device_context_cuda.h b/intern/opensubdiv/opensubdiv_device_context_cuda.h deleted file mode 100644 index eb30b76f507..00000000000 --- a/intern/opensubdiv/opensubdiv_device_context_cuda.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Adopted from OpenSubdiv with the following license: - * - * Copyright 2013 Pixar - * - * Licensed under the Apache License, Version 2.0 (the "Apache License") - * with the following modification; you may not use this file except in - * compliance with the Apache License and the following modification to it: - * Section 6. Trademarks. is deleted and replaced with: - * - * 6. Trademarks. This License does not grant permission to use the trade - * names, trademarks, service marks, or product names of the Licensor - * and its affiliates, except as required to comply with Section 4(c) of - * the License and to reproduce the content of the NOTICE file. - * - * You may obtain a copy of the Apache License at - * - * http: //www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Apache License with the above modification is - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the Apache License for the specific - * language governing permissions and limitations under the Apache License. - * - */ - -#ifndef __OPENSUBDIV_DEV_CE_CONTEXT_CUDA_H__ -#define __OPENSUBDIV_DEV_CE_CONTEXT_CUDA_H__ - -struct ID3D11Device; - -class CudaDeviceContext { -public: - CudaDeviceContext(); - ~CudaDeviceContext(); - - static bool HAS_CUDA_VERSION_4_0(); - - /* Initialze cuda device from the current GL context. */ - bool Initialize(); - - /* Initialze cuda device from the ID3D11Device/ */ - bool Initialize(ID3D11Device *device); - - /* Returns true if the cuda device has already been initialized. */ - bool IsInitialized() const { - return _initialized; - } -private: - bool _initialized; -}; - -#endif /* __OPENSUBDIV_DEV_CE_CONTEXT_OPENCL_H__ */ diff --git a/intern/opensubdiv/opensubdiv_device_context_opencl.cc b/intern/opensubdiv/opensubdiv_device_context_opencl.cc deleted file mode 100644 index 4cacdc9e845..00000000000 --- a/intern/opensubdiv/opensubdiv_device_context_opencl.cc +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Adopted from OpenSubdiv with the following license: - * - * Copyright 2015 Pixar - * - * Licensed under the Apache License, Version 2.0 (the "Apache License") - * with the following modification; you may not use this file except in - * compliance with the Apache License and the following modification to it: - * Section 6. Trademarks. is deleted and replaced with: - * - * 6. Trademarks. This License does not grant permission to use the trade - * names, trademarks, service marks, or product names of the Licensor - * and its affiliates, except as required to comply with Section 4(c) of - * the License and to reproduce the content of the NOTICE file. - * - * You may obtain a copy of the Apache License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Apache License with the above modification is - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the Apache License for the specific - * language governing permissions and limitations under the Apache License. - * - */ - -#ifdef OPENSUBDIV_HAS_OPENCL - -#ifdef _MSC_VER -# include "iso646.h" -#endif - -#include "opensubdiv_device_context_opencl.h" - -#if defined(_WIN32) -# include -#elif defined(__APPLE__) -# include -#else -# include -#endif - -#include -#include -#include - -#define message(...) // fprintf(stderr, __VA_ARGS__) -#define error(...) fprintf(stderr, __VA_ARGS__) - -/* Returns the first found platform. */ -static cl_platform_id findPlatform() { - cl_uint numPlatforms; - cl_int ciErrNum = clGetPlatformIDs(0, NULL, &numPlatforms); - if (ciErrNum != CL_SUCCESS) { - error("Error %d in clGetPlatformIDs call.\n", ciErrNum); - return NULL; - } - if (numPlatforms == 0) { - error("No OpenCL platform found.\n"); - return NULL; - } - cl_platform_id *clPlatformIDs = new cl_platform_id[numPlatforms]; - ciErrNum = clGetPlatformIDs(numPlatforms, clPlatformIDs, NULL); - char chBuffer[1024]; - for (cl_uint i = 0; i < numPlatforms; ++i) { - ciErrNum = clGetPlatformInfo(clPlatformIDs[i], CL_PLATFORM_NAME, - 1024, chBuffer,NULL); - if (ciErrNum == CL_SUCCESS) { - cl_platform_id platformId = clPlatformIDs[i]; - delete[] clPlatformIDs; - return platformId; - } - } - delete[] clPlatformIDs; - return NULL; -} - -/* Return. the device in clDevices which supports the extension. */ -static int findExtensionSupportedDevice(cl_device_id *clDevices, - int numDevices, - const char *extensionName) { - /* Find a device that supports sharing with GL/D3D11 - * (SLI / X-fire configurations) - */ - cl_int ciErrNum; - for (int i = 0; i < numDevices; ++i) { - /* Get extensions string size. */ - size_t extensionSize; - ciErrNum = clGetDeviceInfo(clDevices[i], - CL_DEVICE_EXTENSIONS, 0, NULL, - &extensionSize); - if (ciErrNum != CL_SUCCESS) { - error("Error %d in clGetDeviceInfo\n", ciErrNum); - return -1; - } - if (extensionSize > 0) { - /* Get extensions string. */ - char *extensions = new char[extensionSize]; - ciErrNum = clGetDeviceInfo(clDevices[i], CL_DEVICE_EXTENSIONS, - extensionSize, extensions, - &extensionSize); - if (ciErrNum != CL_SUCCESS) { - error("Error %d in clGetDeviceInfo\n", ciErrNum); - delete[] extensions; - continue; - } - std::string extString(extensions); - delete[] extensions; - /* Parse string. This is bit deficient since the extentions - * is space separated. - * - * The actual string would be "cl_khr_d3d11_sharing" - * or "cl_nv_d3d11_sharing" - */ - if (extString.find(extensionName) != std::string::npos) { - return i; - } - } - } - return -1; -} - -CLDeviceContext::CLDeviceContext() - : _clContext(NULL), - _clCommandQueue(NULL) { -} - -CLDeviceContext::~CLDeviceContext() { - if (_clCommandQueue) - clReleaseCommandQueue(_clCommandQueue); - if (_clContext) - clReleaseContext(_clContext); -} - -bool CLDeviceContext::HAS_CL_VERSION_1_1() -{ -#ifdef OPENSUBDIV_HAS_CLEW - static bool clewInitialized = false; - static bool clewLoadSuccess; - if (not clewInitialized) { - clewInitialized = true; - clewLoadSuccess = clewInit() == CLEW_SUCCESS; - if (!clewLoadSuccess) { - error("Loading OpenCL failed.\n"); - } - } - return clewLoadSuccess; -#endif - return true; -} - -bool CLDeviceContext::Initialize() -{ -#ifdef OPENSUBDIV_HAS_CLEW - if (!clGetPlatformIDs) { - error("Error clGetPlatformIDs function not bound.\n"); - return false; - } -#endif - cl_int ciErrNum; - cl_platform_id cpPlatform = findPlatform(); - -#if defined(_WIN32) - cl_context_properties props[] = { - CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(), - CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(), - CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform, - 0 - }; -#elif defined(__APPLE__) - CGLContextObj kCGLContext = CGLGetCurrentContext(); - CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext); - cl_context_properties props[] = { - CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, (cl_context_properties)kCGLShareGroup, - 0 - }; -#else - cl_context_properties props[] = { - CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(), - CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(), - CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform, - 0 - }; -#endif - -#if defined(__APPLE__) - _clContext = clCreateContext(props, 0, NULL, clLogMessagesToStdoutAPPLE, - NULL, &ciErrNum); - if (ciErrNum != CL_SUCCESS) { - error("Error %d in clCreateContext\n", ciErrNum); - return false; - } - - size_t devicesSize = 0; - clGetGLContextInfoAPPLE(_clContext, kCGLContext, - CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE, - 0, NULL, &devicesSize); - int numDevices = int(devicesSize / sizeof(cl_device_id)); - if (numDevices == 0) { - error("No sharable devices.\n"); - return false; - } - cl_device_id *clDevices = new cl_device_id[numDevices]; - clGetGLContextInfoAPPLE(_clContext, kCGLContext, - CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE, - numDevices * sizeof(cl_device_id), clDevices, NULL); - int clDeviceUsed = 0; - -#else // not __APPLE__ - /* Get the number of GPU devices available to the platform. */ - cl_uint numDevices = 0; - clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices); - if (numDevices == 0) { - error("No CL GPU device found.\n"); - return false; - } - - /* Create the device list. */ - cl_device_id *clDevices = new cl_device_id[numDevices]; - clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, numDevices, clDevices, NULL); - - const char *extension = "cl_khr_gl_sharing"; - int clDeviceUsed = findExtensionSupportedDevice(clDevices, numDevices, - extension); - - if (clDeviceUsed < 0) { - error("No device found that supports CL/GL context sharing\n"); - delete[] clDevices; - return false; - } - - _clContext = clCreateContext(props, 1, &clDevices[clDeviceUsed], - NULL, NULL, &ciErrNum); -#endif // not __APPLE__ - if (ciErrNum != CL_SUCCESS) { - error("Error %d in clCreateContext\n", ciErrNum); - delete[] clDevices; - return false; - } - _clCommandQueue = clCreateCommandQueue(_clContext, clDevices[clDeviceUsed], - 0, &ciErrNum); - delete[] clDevices; - if (ciErrNum != CL_SUCCESS) { - error("Error %d in clCreateCommandQueue\n", ciErrNum); - return false; - } - return true; -} - -#endif /* OPENSUBDIV_HAS_OPENCL */ diff --git a/intern/opensubdiv/opensubdiv_device_context_opencl.h b/intern/opensubdiv/opensubdiv_device_context_opencl.h deleted file mode 100644 index a640dce1f07..00000000000 --- a/intern/opensubdiv/opensubdiv_device_context_opencl.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Adopted from OpenSubdiv with the following license: - * - * Copyright 2015 Pixar - * - * Licensed under the Apache License, Version 2.0 (the "Apache License") - * with the following modification; you may not use this file except in - * compliance with the Apache License and the following modification to it: - * Section 6. Trademarks. is deleted and replaced with: - * - * 6. Trademarks. This License does not grant permission to use the trade - * names, trademarks, service marks, or product names of the Licensor - * and its affiliates, except as required to comply with Section 4(c) of - * the License and to reproduce the content of the NOTICE file. - * - * You may obtain a copy of the Apache License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Apache License with the above modification is - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the Apache License for the specific - * language governing permissions and limitations under the Apache License. - * - */ - -#ifndef __OPENSUBDIV_DEV_CE_CONTEXT_OPENCL_H__ -#define __OPENSUBDIV_DEV_CE_CONTEXT_OPENCL_H__ - -#include - -class CLDeviceContext { -public: - CLDeviceContext(); - ~CLDeviceContext(); - - static bool HAS_CL_VERSION_1_1 (); - - bool Initialize(); - - bool IsInitialized() const { - return (_clContext != NULL); - } - - cl_context GetContext() const { - return _clContext; - } - cl_command_queue GetCommandQueue() const { - return _clCommandQueue; - } - -protected: - cl_context _clContext; - cl_command_queue _clCommandQueue; -}; - -#endif /* __OPENSUBDIV_DEV_CE_CONTEXT_OPENCL_H__ */ diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.cc b/intern/opensubdiv/opensubdiv_evaluator_capi.cc deleted file mode 100644 index fb5313b8501..00000000000 --- a/intern/opensubdiv/opensubdiv_evaluator_capi.cc +++ /dev/null @@ -1,516 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2015 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "opensubdiv_capi.h" - -#include -#include - -#ifdef _MSC_VER -# include "iso646.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "opensubdiv_intern.h" -#include "opensubdiv_topology_refiner.h" - -#include "MEM_guardedalloc.h" - -using OpenSubdiv::Osd::BufferDescriptor; -using OpenSubdiv::Osd::PatchCoord; -using OpenSubdiv::Far::PatchMap; -using OpenSubdiv::Far::PatchTable; -using OpenSubdiv::Far::PatchTableFactory; -using OpenSubdiv::Far::StencilTable; -using OpenSubdiv::Far::StencilTableFactory; -using OpenSubdiv::Far::TopologyRefiner; - -namespace { - -/* Helper class to wrap numerous of patch coords into a buffer. - * Used to pass coordinates to the CPU evaluator. Other evaluators - * are not supported. - */ -class PatchCoordBuffer : public std::vector { -public: - static PatchCoordBuffer *Create(int size) - { - PatchCoordBuffer *buffer = new PatchCoordBuffer(); - buffer->resize(size); - return buffer; - } - PatchCoord *BindCpuBuffer() { - return (PatchCoord*)&(*this)[0]; - } - int GetNumVertices() { - return size(); - } - void UpdateData(const PatchCoord *patch_coords, - int num_patch_coords) - { - memcpy(&(*this)[0], - (void*)patch_coords, - num_patch_coords * sizeof(PatchCoord)); - } -}; - -/* Helper class to wrap single of patch coord into a buffer. - * Used to pass coordinates to the CPU evaluator. Other evaluators - * are not supported. - */ -class SinglePatchCoordBuffer { -public: - SinglePatchCoordBuffer() { - } - SinglePatchCoordBuffer(const PatchCoord& patch_coord) - : patch_coord_(patch_coord){ - } - static SinglePatchCoordBuffer *Create() - { - SinglePatchCoordBuffer *buffer = new SinglePatchCoordBuffer(); - return buffer; - } - PatchCoord *BindCpuBuffer() { - return (PatchCoord*)&patch_coord_; - } - int GetNumVertices() { - return 1; - } - void UpdateData(const PatchCoord& patch_coord) - { - patch_coord_ = patch_coord; - } -protected: - PatchCoord patch_coord_; -}; - -/* Helper class which is aimed to be used in cases when buffer - * is small enough and better to be allocated in stack rather - * than in heap. - * - * TODO(sergey): Check if bare arrays could be used by CPU evaluator. - */ -template -class StackAllocatedBuffer { -public: - static PatchCoordBuffer *Create(int /*size*/) - { - StackAllocatedBuffer *buffer = - new StackAllocatedBuffer(); - return buffer; - } - float *BindCpuBuffer() { - return &data_[0]; - } - int GetNumVertices() { - return num_verts; - } - /* TODO(sergey): Support UpdateData(). */ -protected: - float data_[element_size * num_verts]; -}; - -/* Volatile evaluator which can be used from threads. - * - * TODO(sergey): Make it possible to evaluate coordinates in chunks. - */ -template -class VolatileEvalOutput { -public: - typedef OpenSubdiv::Osd::EvaluatorCacheT EvaluatorCache; - - VolatileEvalOutput(const StencilTable *vertex_stencils, - const StencilTable *varying_stencils, - int num_coarse_verts, - int num_total_verts, - const PatchTable *patch_table, - EvaluatorCache *evaluator_cache = NULL, - DEVICE_CONTEXT *device_context = NULL) - : src_desc_( /*offset*/ 0, /*length*/ 3, /*stride*/ 3), - src_varying_desc_(/*offset*/ 0, /*length*/ 3, /*stride*/ 3), - num_coarse_verts_(num_coarse_verts), - evaluator_cache_ (evaluator_cache), - device_context_(device_context) - { - using OpenSubdiv::Osd::convertToCompatibleStencilTable; - src_data_ = SRC_VERTEX_BUFFER::Create(3, num_total_verts, device_context_); - src_varying_data_ = SRC_VERTEX_BUFFER::Create(3, num_total_verts, device_context_); - patch_table_ = PATCH_TABLE::Create(patch_table, device_context_); - patch_coords_ = NULL; - vertex_stencils_ = convertToCompatibleStencilTable(vertex_stencils, - device_context_); - varying_stencils_ = convertToCompatibleStencilTable(varying_stencils, - device_context_); - } - - ~VolatileEvalOutput() - { - delete src_data_; - delete src_varying_data_; - delete patch_table_; - delete vertex_stencils_; - delete varying_stencils_; - } - - void UpdateData(const float *src, int start_vertex, int num_vertices) - { - src_data_->UpdateData(src, start_vertex, num_vertices, device_context_); - } - - void UpdateVaryingData(const float *src, int start_vertex, int num_vertices) - { - src_varying_data_->UpdateData(src, - start_vertex, - num_vertices, - device_context_); - } - - void Refine() - { - BufferDescriptor dst_desc = src_desc_; - dst_desc.offset += num_coarse_verts_ * src_desc_.stride; - - const EVALUATOR *eval_instance = - OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, - src_desc_, - dst_desc, - device_context_); - - EVALUATOR::EvalStencils(src_data_, src_desc_, - src_data_, dst_desc, - vertex_stencils_, - eval_instance, - device_context_); - - dst_desc = src_varying_desc_; - dst_desc.offset += num_coarse_verts_ * src_varying_desc_.stride; - eval_instance = - OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, - src_varying_desc_, - dst_desc, - device_context_); - - EVALUATOR::EvalStencils(src_varying_data_, src_varying_desc_, - src_varying_data_, dst_desc, - varying_stencils_, - eval_instance, - device_context_); - } - - void EvalPatchCoord(PatchCoord& patch_coord, float P[3]) - { - StackAllocatedBuffer<6, 1> vertex_data; - BufferDescriptor vertex_desc(0, 3, 6); - SinglePatchCoordBuffer patch_coord_buffer(patch_coord); - const EVALUATOR *eval_instance = - OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, - src_desc_, - vertex_desc, - device_context_); - EVALUATOR::EvalPatches(src_data_, src_desc_, - &vertex_data, vertex_desc, - patch_coord_buffer.GetNumVertices(), - &patch_coord_buffer, - patch_table_, eval_instance, device_context_); - float *refined_verts = vertex_data.BindCpuBuffer(); - memcpy(P, refined_verts, sizeof(float) * 3); - } - - void EvalPatchesWithDerivatives(PatchCoord& patch_coord, - float P[3], - float dPdu[3], - float dPdv[3]) - { - StackAllocatedBuffer<6, 1> vertex_data, derivatives; - BufferDescriptor vertex_desc(0, 3, 6), - du_desc(0, 3, 6), - dv_desc(3, 3, 6); - SinglePatchCoordBuffer patch_coord_buffer(patch_coord); - const EVALUATOR *eval_instance = - OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, - src_desc_, - vertex_desc, - du_desc, - dv_desc, - device_context_); - EVALUATOR::EvalPatches(src_data_, src_desc_, - &vertex_data, vertex_desc, - &derivatives, du_desc, - &derivatives, dv_desc, - patch_coord_buffer.GetNumVertices(), - &patch_coord_buffer, - patch_table_, eval_instance, device_context_); - float *refined_verts = vertex_data.BindCpuBuffer(); - memcpy(P, refined_verts, sizeof(float) * 3); - if (dPdu != NULL || dPdv != NULL) { - float *refined_drivatives = derivatives.BindCpuBuffer(); - if (dPdu) { - memcpy(dPdu, refined_drivatives, sizeof(float) * 3); - } - if (dPdv) { - memcpy(dPdv, refined_drivatives + 3, sizeof(float) * 3); - } - } - } - - void EvalPatchVarying(PatchCoord& patch_coord, - float varying[3]) { - StackAllocatedBuffer<3, 1> varying_data; - BufferDescriptor varying_desc(0, 3, 3); - SinglePatchCoordBuffer patch_coord_buffer(patch_coord); - EVALUATOR const *eval_instance = - OpenSubdiv::Osd::GetEvaluator(evaluator_cache_, - src_varying_desc_, - varying_desc, - device_context_); - - EVALUATOR::EvalPatches(src_varying_data_, src_varying_desc_, - &varying_data, varying_desc, - patch_coord_buffer.GetNumVertices(), - &patch_coord_buffer, - patch_table_, eval_instance, device_context_); - float *refined_varying = varying_data.BindCpuBuffer(); - memcpy(varying, refined_varying, sizeof(float) * 3); - } -private: - SRC_VERTEX_BUFFER *src_data_; - SRC_VERTEX_BUFFER *src_varying_data_; - PatchCoordBuffer *patch_coords_; - PATCH_TABLE *patch_table_; - BufferDescriptor src_desc_; - BufferDescriptor src_varying_desc_; - int num_coarse_verts_; - - const STENCIL_TABLE *vertex_stencils_; - const STENCIL_TABLE *varying_stencils_; - - EvaluatorCache *evaluator_cache_; - DEVICE_CONTEXT *device_context_; -}; - -} /* namespace */ - -typedef VolatileEvalOutput CpuEvalOutput; - -typedef struct OpenSubdiv_EvaluatorDescr { - CpuEvalOutput *eval_output; - const PatchMap *patch_map; - const PatchTable *patch_table; -} OpenSubdiv_EvaluatorDescr; - -OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr( - OpenSubdiv_TopologyRefinerDescr *topology_refiner, - int subsurf_level) -{ - /* TODO(sergey): Look into re-using refiner with GLMesh. */ - TopologyRefiner *refiner = topology_refiner->osd_refiner; - if(refiner == NULL) { - /* Happens on bad topology. */ - return NULL; - } - /* Apply uniform refinement to the mesh so that we can use the - * limit evaluation API features. - */ - TopologyRefiner::UniformOptions options(subsurf_level); - refiner->RefineUniform(options); - /* Generate stencil table to update the bi-cubic patches control - * vertices after they have been re-posed (both for vertex & varying - * interpolation). - */ - StencilTableFactory::Options vertex_stencil_options; - vertex_stencil_options.generateOffsets = true; - vertex_stencil_options.generateIntermediateLevels = false; - const StencilTable *vertex_stencils = - StencilTableFactory::Create(*refiner, vertex_stencil_options); - StencilTableFactory::Options varying_stencil_options; - varying_stencil_options.generateOffsets = true; - varying_stencil_options.generateIntermediateLevels = false; - varying_stencil_options.interpolationMode = - StencilTableFactory::INTERPOLATE_VARYING; - const StencilTable *varying_stencils = - StencilTableFactory::Create(*refiner, varying_stencil_options); - /* Generate bi-cubic patch table for the limit surface. */ - PatchTableFactory::Options poptions; - poptions.SetEndCapType(PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS); - const PatchTable *patch_table = - PatchTableFactory::Create(*refiner, poptions); - /* Append local points stencils. */ - const StencilTable *local_point_stencil_table = - patch_table->GetLocalPointStencilTable(); - if (local_point_stencil_table != NULL) { - const StencilTable *table = - StencilTableFactory::AppendLocalPointStencilTable( - *refiner, - vertex_stencils, - local_point_stencil_table); - delete vertex_stencils; - vertex_stencils = table; - } - const StencilTable *local_point_varying_stencil_table = - patch_table->GetLocalPointVaryingStencilTable(); - if (local_point_varying_stencil_table != NULL) { - const StencilTable *table = - StencilTableFactory::AppendLocalPointStencilTable( - *refiner, - varying_stencils, - local_point_varying_stencil_table); - delete varying_stencils; - varying_stencils = table; - } - - /* Total number of vertices = coarse verts + refined verts + gregory - * basis verts. - */ - const int num_total_verts = vertex_stencils->GetNumControlVertices() + - vertex_stencils->GetNumStencils(); - const int num_coarse_verts = refiner->GetLevel(0).GetNumVertices(); - /* Create OpenSubdiv's CPU side evaluator. */ - CpuEvalOutput *eval_output = new CpuEvalOutput(vertex_stencils, - varying_stencils, - num_coarse_verts, - num_total_verts, - patch_table); - OpenSubdiv::Far::PatchMap *patch_map = new PatchMap(*patch_table); - /* Wrap everything we need into an object which we control from our - * side. - */ - OpenSubdiv_EvaluatorDescr *evaluator_descr; - evaluator_descr = OBJECT_GUARDED_NEW(OpenSubdiv_EvaluatorDescr); - evaluator_descr->eval_output = eval_output; - evaluator_descr->patch_map = patch_map; - evaluator_descr->patch_table = patch_table; - /* TOOD(sergey): Look into whether we've got duplicated stencils arrays. */ - delete varying_stencils; - delete vertex_stencils; - return evaluator_descr; -} - -void openSubdiv_deleteEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr) -{ - delete evaluator_descr->eval_output; - delete evaluator_descr->patch_map; - delete evaluator_descr->patch_table; - OBJECT_GUARDED_DELETE(evaluator_descr, OpenSubdiv_EvaluatorDescr); -} - -void openSubdiv_setEvaluatorCoarsePositions( - OpenSubdiv_EvaluatorDescr *evaluator_descr, - const float *positions, - int start_vertex_index, - int num_vertices) -{ - /* TODO(sergey): Add sanity check on indices. */ - evaluator_descr->eval_output->UpdateData(positions, - start_vertex_index, - num_vertices); -} - -void openSubdiv_setEvaluatorVaryingData( - OpenSubdiv_EvaluatorDescr *evaluator_descr, - const float *varying_data, - int start_vertex_index, - int num_vertices) -{ - /* TODO(sergey): Add sanity check on indices. */ - evaluator_descr->eval_output->UpdateVaryingData(varying_data, - start_vertex_index, - num_vertices); -} - -void openSubdiv_setEvaluatorCoarsePositionsFromBuffer( - OpenSubdiv_EvaluatorDescr *evaluator_descr, - const void *buffer, - int start_offset, - int stride, - int start_vertex_index, - int num_vertices) -{ - const unsigned char *current_buffer = (unsigned char *)buffer; - current_buffer += start_offset; - /* TODO(sergey): Add sanity check on indices. */ - for (int i = 0; i < num_vertices; ++i) { - const int current_vertex_index = start_vertex_index + i; - evaluator_descr->eval_output->UpdateData((float *)current_buffer, - current_vertex_index, - 1); - current_buffer += stride; - } -} - -void openSubdiv_refineEvaluator(OpenSubdiv_EvaluatorDescr *evaluator_descr) -{ - evaluator_descr->eval_output->Refine(); -} - -void openSubdiv_evaluateLimit(OpenSubdiv_EvaluatorDescr *evaluator_descr, - int osd_face_index, - float face_u, float face_v, - float P[3], - float dPdu[3], - float dPdv[3]) -{ - assert((face_u >= 0.0f) && (face_u <= 1.0f) && (face_v >= 0.0f) && (face_v <= 1.0f)); - const PatchTable::PatchHandle *handle = - evaluator_descr->patch_map->FindPatch(osd_face_index, face_u, face_v); - PatchCoord patch_coord(*handle, face_u, face_v); - if (dPdu != NULL || dPdv != NULL) { - evaluator_descr->eval_output->EvalPatchesWithDerivatives(patch_coord, - P, - dPdu, - dPdv); - } - else { - evaluator_descr->eval_output->EvalPatchCoord(patch_coord, P); - } -} - -void openSubdiv_evaluateVarying(OpenSubdiv_EvaluatorDescr *evaluator_descr, - int osd_face_index, - float face_u, float face_v, - float varying[3]) -{ - assert((face_u >= 0.0f) && (face_u <= 1.0f) && (face_v >= 0.0f) && (face_v <= 1.0f)); - const PatchTable::PatchHandle *handle = - evaluator_descr->patch_map->FindPatch(osd_face_index, face_u, face_v); - PatchCoord patch_coord(*handle, face_u, face_v); - evaluator_descr->eval_output->EvalPatchVarying(patch_coord, varying); -} diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.h b/intern/opensubdiv/opensubdiv_evaluator_capi.h new file mode 100644 index 00000000000..07a55cfd349 --- /dev/null +++ b/intern/opensubdiv/opensubdiv_evaluator_capi.h @@ -0,0 +1,117 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_EVALUATOR_CAPI_H_ +#define OPENSUBDIV_EVALUATOR_CAPI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +struct OpenSubdiv_EvaluatorInternal; +struct OpenSubdiv_TopologyRefiner; + +typedef struct OpenSubdiv_Evaluator { + // Set coarse positions from a continuous array of coordinates. + void (*setCoarsePositions)(struct OpenSubdiv_Evaluator* evaluator, + const float* positions, + const int start_vertex_index, + const int num_vertices); + // Set varying data from a continuous array of data. + void (*setVaryingData)(struct OpenSubdiv_Evaluator* evaluator, + const float* varying_data, + const int start_vertex_index, const int num_vertices); + // Set face varying data from a continuous array of data. + // + // TODO(sergey): Find a better name for vertex here. It is not the vertex of + // geometry, but a vertex of UV map. + void (*setFaceVaryingData)(struct OpenSubdiv_Evaluator* evaluator, + const float* face_varying_data, + const int start_vertex_index, + const int num_vertices); + + // Set coarse vertex position from a continuous memory buffer where + // first coordinate starts at offset of `start_offset` and there is `stride` + // bytes between adjacent vertex coordinates. + void (*setCoarsePositionsFromBuffer)(struct OpenSubdiv_Evaluator* evaluator, + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices); + // Set varying data from a continuous memory buffer where + // first coordinate starts at offset of `start_offset` and there is `stride` + // bytes between adjacent vertex coordinates. + void (*setVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator* evaluator, + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices); + // Set face varying data from a continuous memory buffer where + // first coordinate starts at offset of `start_offset` and there is `stride` + // bytes between adjacent vertex coordinates. + // + // TODO(sergey): Find a better name for vertex here. It is not the vertex of + // geometry, but a vertex of UV map. + void (*setFaceVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator* evaluator, + const void* buffer, + const int start_offset, + const int stride, + const int start_vertex_index, + const int num_vertices); + + // Refine after coarse positions update. + void (*refine)(struct OpenSubdiv_Evaluator* evaluator); + + // Evaluate given ptex face at given bilinear coordinate. + // If derivatives are NULL, they will not be evaluated. + void (*evaluateLimit)(struct OpenSubdiv_Evaluator* evaluator, + const int ptex_face_index, + float face_u, float face_v, + float P[3], float dPdu[3], float dPdv[3]); + + // Evaluate varying data at a given bilinear coordinate of given ptex face. + void (*evaluateVarying)(struct OpenSubdiv_Evaluator* evaluator, + const int ptex_face_index, + float face_u, float face_v, + float varying[3]); + + // Evaluate face-varying data at a given bilinear coordinate of given + // ptex face. + void (*evaluateFaceVarying)(struct OpenSubdiv_Evaluator* evaluator, + const int ptex_face_index, + float face_u, float face_v, + float face_varying[2]); + + // Internal storage for the use in this module only. + // + // This is where actual OpenSubdiv's evaluator is living. + struct OpenSubdiv_EvaluatorInternal* internal; +} OpenSubdiv_Evaluator; + +OpenSubdiv_Evaluator* openSubdiv_createEvaluatorFromTopologyRefiner( + struct OpenSubdiv_TopologyRefiner* topology_refiner); + +void openSubdiv_deleteEvaluator(OpenSubdiv_Evaluator* evaluator); + +#ifdef __cplusplus +} +#endif + +#endif // OPENSUBDIV_EVALUATOR_CAPI_H_ diff --git a/intern/opensubdiv/opensubdiv_gl_mesh.h b/intern/opensubdiv/opensubdiv_gl_mesh.h deleted file mode 100644 index 1e99fc5bce4..00000000000 --- a/intern/opensubdiv/opensubdiv_gl_mesh.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2018 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __OPENSUBDIV_GL_MESH_H__ -#define __OPENSUBDIV_GL_MESH_H__ - -struct OpenSubdiv_GLMeshDescr; -struct OpenSubdiv_TopologyRefinerDescr; -struct OpenSubdiv_GLMeshFVarData; - -typedef struct OpenSubdiv_GLMesh { - int evaluator_type; - OpenSubdiv_GLMeshDescr *descriptor; - OpenSubdiv_TopologyRefinerDescr *topology_refiner; - OpenSubdiv_GLMeshFVarData *fvar_data; -} OpenSubdiv_GLMesh; - -#endif /* __OPENSUBDIV_GL_MESH_H__ */ diff --git a/intern/opensubdiv/opensubdiv_gl_mesh_capi.h b/intern/opensubdiv/opensubdiv_gl_mesh_capi.h new file mode 100644 index 00000000000..971f6b9dcd3 --- /dev/null +++ b/intern/opensubdiv/opensubdiv_gl_mesh_capi.h @@ -0,0 +1,92 @@ +// Copyright 2013 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_CAPI_GL_MESH_CAPI_H_ +#define OPENSUBDIV_CAPI_GL_MESH_CAPI_H_ + +#include // for bool + +#include "opensubdiv_capi_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct OpenSubdiv_GLMeshInternal; + +// Mesh which is displayable in OpenGL context. +typedef struct OpenSubdiv_GLMesh { + ////////////////////////////////////////////////////////////////////////////// + // Subdivision/topology part. + + // Returns the GL index buffer containing the patch control vertices. + unsigned int (*getPatchIndexBuffer)(struct OpenSubdiv_GLMesh* gl_mesh); + + // Bind GL buffer which contains vertices (VBO). + // TODO(sergey): Is this a coarse vertices? + void (*bindVertexBuffer)(struct OpenSubdiv_GLMesh* gl_mesh); + + // Set coarse positions from a continuous array of coordinates. + void (*setCoarsePositions)(struct OpenSubdiv_GLMesh* gl_mesh, + const float* positions, + const int start_vertex, + const int num_vertices); + // TODO(sergey): setCoarsePositionsFromBuffer(). + + // Refine after coarse positions update. + void (*refine)(struct OpenSubdiv_GLMesh* gl_mesh); + + // Synchronize after coarse positions update and refine. + void (*synchronize)(struct OpenSubdiv_GLMesh* gl_mesh); + + ////////////////////////////////////////////////////////////////////////////// + // Drawing part. + + // Prepare mesh for display. + void (*prepareDraw)(struct OpenSubdiv_GLMesh* gl_mesh, + const bool use_osd_glsl, + const int active_uv_index); + + // Draw given range of patches. + // + // If fill_quads is false, then patches are drawn in wireframe. + void (*drawPatches)(struct OpenSubdiv_GLMesh *gl_mesh, + const bool fill_quads, + const int start_patch, const int num_patches); + + // Internal storage for the use in this module only. + // + // Tease: This contains an actual OpenSubdiv's Mesh object. + struct OpenSubdiv_GLMeshInternal* internal; +} OpenSubdiv_GLMesh; + +OpenSubdiv_GLMesh* openSubdiv_createOsdGLMeshFromTopologyRefiner( + struct OpenSubdiv_TopologyRefiner* topology_refiner, + eOpenSubdivEvaluator evaluator_type); + +void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh); + +// Global resources needed for GL mesh drawing. +bool openSubdiv_initGLMeshDrawingResources(void); +void openSubdiv_deinitGLMeshDrawingResources(void); + +#ifdef __cplusplus +} +#endif + +#endif // OPENSUBDIV_CAPI_GL_MESH_CAPI_H_ diff --git a/intern/opensubdiv/opensubdiv_gpu_capi.cc b/intern/opensubdiv/opensubdiv_gpu_capi.cc deleted file mode 100644 index d28b48ddd18..00000000000 --- a/intern/opensubdiv/opensubdiv_gpu_capi.cc +++ /dev/null @@ -1,788 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2013 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "opensubdiv_capi.h" - -#ifdef _MSC_VER -# include "iso646.h" -#endif - -#include -#include -#include - -#include - -#ifdef OPENSUBDIV_HAS_CUDA -# include -#endif /* OPENSUBDIV_HAS_CUDA */ - -#include -#include - -#include "MEM_guardedalloc.h" - -#include "opensubdiv_capi.h" -#include "opensubdiv_gl_mesh.h" -#include "opensubdiv_topology_refiner.h" - -using OpenSubdiv::Osd::GLMeshInterface; - -extern "C" char datatoc_gpu_shader_opensubdiv_vertex_glsl[]; -extern "C" char datatoc_gpu_shader_opensubdiv_geometry_glsl[]; -extern "C" char datatoc_gpu_shader_opensubdiv_fragment_glsl[]; - -/* TODO(sergey): This is bit of bad level calls :S */ -extern "C" { -void copy_m3_m3(float m1[3][3], float m2[3][3]); -void copy_m3_m4(float m1[3][3], float m2[4][4]); -void adjoint_m3_m3(float m1[3][3], float m[3][3]); -float determinant_m3_array(float m[3][3]); -bool invert_m3_m3(float m1[3][3], float m2[3][3]); -bool invert_m3(float m[3][3]); -void transpose_m3(float mat[3][3]); -} - -#define MAX_LIGHTS 8 -#define SUPPORT_COLOR_MATERIAL - -typedef struct Light { - float position[4]; - float ambient[4]; - float diffuse[4]; - float specular[4]; - float spot_direction[4]; -#ifdef SUPPORT_COLOR_MATERIAL - float constant_attenuation; - float linear_attenuation; - float quadratic_attenuation; - float spot_cutoff; - float spot_exponent; - float spot_cos_cutoff; - float pad, pad2; -#endif -} Light; - -typedef struct Lighting { - Light lights[MAX_LIGHTS]; - int num_enabled; -} Lighting; - -typedef struct Transform { - float projection_matrix[16]; - float model_view_matrix[16]; - float normal_matrix[9]; -} Transform; - -static bool g_use_osd_glsl = false; -static int g_active_uv_index = 0; - -static GLuint g_flat_fill_solid_program = 0; -static GLuint g_flat_fill_texture2d_program = 0; -static GLuint g_smooth_fill_solid_program = 0; -static GLuint g_smooth_fill_texture2d_program = 0; - -static GLuint g_flat_fill_solid_shadeless_program = 0; -static GLuint g_flat_fill_texture2d_shadeless_program = 0; -static GLuint g_smooth_fill_solid_shadeless_program = 0; -static GLuint g_smooth_fill_texture2d_shadeless_program = 0; - -static GLuint g_wireframe_program = 0; - -static GLuint g_lighting_ub = 0; -static Lighting g_lighting_data; -static Transform g_transform; - -struct OpenSubdiv_GLMeshFVarData -{ - OpenSubdiv_GLMeshFVarData() : - texture_buffer(0), offset_buffer(0) { - } - - ~OpenSubdiv_GLMeshFVarData() - { - Release(); - } - - void Release() - { - if (texture_buffer) { - glDeleteTextures(1, &texture_buffer); - } - if (offset_buffer) { - glDeleteTextures(1, &offset_buffer); - } - texture_buffer = 0; - offset_buffer = 0; - fvar_width = 0; - channel_offsets.clear(); - } - - void Create(const OpenSubdiv::Far::TopologyRefiner *refiner, - const OpenSubdiv::Far::PatchTable *patch_table, - int fvar_width, - const float *fvar_src_data) - { - Release(); - - this->fvar_width = fvar_width; - - /* Expand fvar data to per-patch array */ - const int max_level = refiner->GetMaxLevel(); - const int num_channels = patch_table->GetNumFVarChannels(); - std::vector data; - int fvar_data_offset = 0; - channel_offsets.resize(num_channels); - for (int channel = 0; channel < num_channels; ++channel) { - OpenSubdiv::Far::ConstIndexArray indices = - patch_table->GetFVarValues(channel); - - channel_offsets[channel] = data.size(); - data.reserve(data.size() + indices.size() * fvar_width); - - for (int fvert = 0; fvert < (int)indices.size(); ++fvert) { - int index = indices[fvert] * fvar_width; - for (int i = 0; i < fvar_width; ++i) { - data.push_back(fvar_src_data[fvar_data_offset + index++]); - } - } - if (refiner->IsUniform()) { - const int num_values_max = refiner->GetLevel(max_level).GetNumFVarValues(channel); - fvar_data_offset += num_values_max * fvar_width; - } else { - const int num_values_total = refiner->GetNumFVarValuesTotal(channel); - fvar_data_offset += num_values_total * fvar_width; - } - } - - GLuint buffer; - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, data.size()*sizeof(float), - &data[0], GL_STATIC_DRAW); - - glGenTextures(1, &texture_buffer); - glBindTexture(GL_TEXTURE_BUFFER, texture_buffer); - glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, buffer); - - glDeleteBuffers(1, &buffer); - - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, channel_offsets.size()*sizeof(int), - &channel_offsets[0], GL_STATIC_DRAW); - - glGenTextures(1, &offset_buffer); - glBindTexture(GL_TEXTURE_BUFFER, offset_buffer); - glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer); - glBindTexture(GL_TEXTURE_BUFFER, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - } - GLuint texture_buffer; - GLuint offset_buffer; - std::vector channel_offsets; - int fvar_width; -}; - -namespace { - -GLuint compileShader(GLenum shaderType, - const char *version, - const char *define, - const char *source) -{ - const char *sources[] = { - version, - define, -#ifdef SUPPORT_COLOR_MATERIAL - "#define SUPPORT_COLOR_MATERIAL\n", -#else - "", -#endif - source, - }; - - GLuint shader = glCreateShader(shaderType); - glShaderSource(shader, 4, sources, NULL); - glCompileShader(shader); - - GLint status; - glGetShaderiv(shader, GL_COMPILE_STATUS, &status); - if (status == GL_FALSE) { - GLchar emsg[1024]; - glGetShaderInfoLog(shader, sizeof(emsg), 0, emsg); - fprintf(stderr, "Error compiling GLSL: %s\n", emsg); - fprintf(stderr, "Version: %s\n", version); - fprintf(stderr, "Defines: %s\n", define); - fprintf(stderr, "Source: %s\n", source); - return 0; - } - - return shader; -} - -GLuint linkProgram(const char *version, const char *define) -{ - GLuint vertexShader = compileShader(GL_VERTEX_SHADER, - version, - define, - datatoc_gpu_shader_opensubdiv_vertex_glsl); - if (vertexShader == 0) { - return 0; - } - GLuint geometryShader = compileShader(GL_GEOMETRY_SHADER, - version, - define, - datatoc_gpu_shader_opensubdiv_geometry_glsl); - if (geometryShader == 0) { - return 0; - } - GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER, - version, - define, - datatoc_gpu_shader_opensubdiv_fragment_glsl ); - if (fragmentShader == 0) { - return 0; - } - - GLuint program = glCreateProgram(); - - glAttachShader(program, vertexShader); - glAttachShader(program, geometryShader); - glAttachShader(program, fragmentShader); - - glBindAttribLocation(program, 0, "position"); - glBindAttribLocation(program, 1, "normal"); - - glLinkProgram(program); - - glDeleteShader(vertexShader); - glDeleteShader(geometryShader); - glDeleteShader(fragmentShader); - - GLint status; - glGetProgramiv(program, GL_LINK_STATUS, &status); - if (status == GL_FALSE) { - GLchar emsg[1024]; - glGetProgramInfoLog(program, sizeof(emsg), 0, emsg); - fprintf(stderr, "Error linking GLSL program : %s\n", emsg); - fprintf(stderr, "Defines: %s\n", define); - glDeleteProgram(program); - return 0; - } - - glUniformBlockBinding(program, - glGetUniformBlockIndex(program, "Lighting"), - 0); - - if (GLEW_VERSION_4_1) { - glProgramUniform1i(program, - glGetUniformLocation(program, "texture_buffer"), - 0); /* GL_TEXTURE0 */ - - glProgramUniform1i(program, - glGetUniformLocation(program, "FVarDataOffsetBuffer"), - 30); /* GL_TEXTURE30 */ - - glProgramUniform1i(program, - glGetUniformLocation(program, "FVarDataBuffer"), - 31); /* GL_TEXTURE31 */ - } - else { - glUseProgram(program); - glUniform1i(glGetUniformLocation(program, "texture_buffer"), 0); /* GL_TEXTURE0 */ - glUniform1i(glGetUniformLocation(program, "FVarDataOffsetBuffer"), 30); /* GL_TEXTURE30 */ - glUniform1i(glGetUniformLocation(program, "FVarDataBuffer"), 31); /* GL_TEXTURE31 */ - glUseProgram(0); - } - - return program; -} - -void bindProgram(OpenSubdiv_GLMesh *gl_mesh, int program) -{ - glUseProgram(program); - - /* Matrices */ - glUniformMatrix4fv(glGetUniformLocation(program, "modelViewMatrix"), - 1, false, - g_transform.model_view_matrix); - glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), - 1, false, - g_transform.projection_matrix); - glUniformMatrix3fv(glGetUniformLocation(program, "normalMatrix"), - 1, false, - g_transform.normal_matrix); - - /* Lighting */ - glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub); - glBufferSubData(GL_UNIFORM_BUFFER, - 0, sizeof(g_lighting_data), &g_lighting_data); - glBindBuffer(GL_UNIFORM_BUFFER, 0); - - glBindBufferBase(GL_UNIFORM_BUFFER, 0, g_lighting_ub); - - /* Color */ - { - /* TODO: stop using glGetMaterial */ - float color[4]; - glGetMaterialfv(GL_FRONT, GL_DIFFUSE, color); - glUniform4fv(glGetUniformLocation(program, "diffuse"), 1, color); - - glGetMaterialfv(GL_FRONT, GL_SPECULAR, color); - glUniform4fv(glGetUniformLocation(program, "specular"), 1, color); - - glGetMaterialfv(GL_FRONT, GL_SHININESS, color); - glUniform1f(glGetUniformLocation(program, "shininess"), color[0]); - } - - /* Face-vertex data */ - if (gl_mesh->fvar_data != NULL) { - if (gl_mesh->fvar_data->texture_buffer) { - glActiveTexture(GL_TEXTURE31); - glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->texture_buffer); - glActiveTexture(GL_TEXTURE0); - } - - if (gl_mesh->fvar_data->offset_buffer) { - glActiveTexture(GL_TEXTURE30); - glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->offset_buffer); - glActiveTexture(GL_TEXTURE0); - } - - glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), - gl_mesh->fvar_data->fvar_width); - if (gl_mesh->fvar_data->channel_offsets.size() > 0 && - g_active_uv_index >= 0) - { - glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), - gl_mesh->fvar_data->channel_offsets[g_active_uv_index]); - } else { - glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); - } - } else { - glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0); - glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); - } -} - -} /* namespace */ - -bool openSubdiv_osdGLDisplayInit(void) -{ - static bool need_init = true; - static bool init_success = false; - - if (need_init) { - /* TODO: update OSD drawing to OpenGL 3.3 core, then remove following line */ - return false; - - const char *version = ""; - if (GLEW_VERSION_3_2) { - version = "#version 150 compatibility\n"; - } - else if (GLEW_VERSION_3_1) { - version = "#version 140\n" - "#extension GL_ARB_compatibility: enable\n"; - } - else { - version = "#version 130\n"; - /* minimum supported for OpenSubdiv */ - } - - g_flat_fill_solid_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_LIGHTING\n" - "#define FLAT_SHADING\n"); - g_flat_fill_texture2d_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_LIGHTING\n" - "#define USE_TEXTURE_2D\n" - "#define FLAT_SHADING\n"); - g_smooth_fill_solid_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_LIGHTING\n" - "#define SMOOTH_SHADING\n"); - g_smooth_fill_texture2d_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_LIGHTING\n" - "#define USE_TEXTURE_2D\n" - "#define SMOOTH_SHADING\n"); - - g_flat_fill_solid_shadeless_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define FLAT_SHADING\n"); - g_flat_fill_texture2d_shadeless_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_TEXTURE_2D\n" - "#define FLAT_SHADING\n"); - g_smooth_fill_solid_shadeless_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define SMOOTH_SHADING\n"); - g_smooth_fill_texture2d_shadeless_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_TEXTURE_2D\n" - "#define SMOOTH_SHADING\n"); - - g_wireframe_program = linkProgram( - version, - "#define WIREFRAME\n"); - - glGenBuffers(1, &g_lighting_ub); - glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub); - glBufferData(GL_UNIFORM_BUFFER, - sizeof(g_lighting_data), NULL, GL_STATIC_DRAW); - - need_init = false; - init_success = g_flat_fill_solid_program != 0 && - g_flat_fill_texture2d_program != 0 && - g_smooth_fill_solid_program != 0 && - g_smooth_fill_texture2d_program != 0 && - g_wireframe_program; - } - return init_success; -} - -void openSubdiv_osdGLDisplayDeinit(void) -{ - if (g_lighting_ub != 0) { - glDeleteBuffers(1, &g_lighting_ub); - } -#define SAFE_DELETE_PROGRAM(program) \ - do { \ - if (program) { \ - glDeleteProgram(program); \ - } \ - } while (false) - - SAFE_DELETE_PROGRAM(g_flat_fill_solid_program); - SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_program); - SAFE_DELETE_PROGRAM(g_smooth_fill_solid_program); - SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_program); - SAFE_DELETE_PROGRAM(g_flat_fill_solid_shadeless_program); - SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_shadeless_program); - SAFE_DELETE_PROGRAM(g_smooth_fill_solid_shadeless_program); - SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_shadeless_program); - SAFE_DELETE_PROGRAM(g_wireframe_program); - -#undef SAFE_DELETE_PROGRAM -} - -void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl, - int active_uv_index) -{ - g_active_uv_index = active_uv_index; - g_use_osd_glsl = (use_osd_glsl != 0); - - /* Update transformation matrices. */ - glGetFloatv(GL_PROJECTION_MATRIX, g_transform.projection_matrix); - glGetFloatv(GL_MODELVIEW_MATRIX, g_transform.model_view_matrix); - - copy_m3_m4((float (*)[3])g_transform.normal_matrix, - (float (*)[4])g_transform.model_view_matrix); - invert_m3((float (*)[3])g_transform.normal_matrix); - transpose_m3((float (*)[3])g_transform.normal_matrix); - - /* Update OpenGL lights positions, colors etc. */ - g_lighting_data.num_enabled = 0; - for (int i = 0; i < MAX_LIGHTS; ++i) { - GLboolean enabled; - glGetBooleanv(GL_LIGHT0 + i, &enabled); - if (enabled) { - g_lighting_data.num_enabled++; - } - - /* TODO: stop using glGetLight */ - glGetLightfv(GL_LIGHT0 + i, - GL_POSITION, - g_lighting_data.lights[i].position); - glGetLightfv(GL_LIGHT0 + i, - GL_AMBIENT, - g_lighting_data.lights[i].ambient); - glGetLightfv(GL_LIGHT0 + i, - GL_DIFFUSE, - g_lighting_data.lights[i].diffuse); - glGetLightfv(GL_LIGHT0 + i, - GL_SPECULAR, - g_lighting_data.lights[i].specular); - glGetLightfv(GL_LIGHT0 + i, - GL_SPOT_DIRECTION, - g_lighting_data.lights[i].spot_direction); -#ifdef SUPPORT_COLOR_MATERIAL - glGetLightfv(GL_LIGHT0 + i, - GL_CONSTANT_ATTENUATION, - &g_lighting_data.lights[i].constant_attenuation); - glGetLightfv(GL_LIGHT0 + i, - GL_LINEAR_ATTENUATION, - &g_lighting_data.lights[i].linear_attenuation); - glGetLightfv(GL_LIGHT0 + i, - GL_QUADRATIC_ATTENUATION, - &g_lighting_data.lights[i].quadratic_attenuation); - glGetLightfv(GL_LIGHT0 + i, - GL_SPOT_CUTOFF, - &g_lighting_data.lights[i].spot_cutoff); - glGetLightfv(GL_LIGHT0 + i, - GL_SPOT_EXPONENT, - &g_lighting_data.lights[i].spot_exponent); - g_lighting_data.lights[i].spot_cos_cutoff = - cos(g_lighting_data.lights[i].spot_cutoff); -#endif - } -} - -static GLuint prepare_patchDraw(OpenSubdiv_GLMesh *gl_mesh, - bool fill_quads) -{ - GLint program = 0; - if (!g_use_osd_glsl) { - glGetIntegerv(GL_CURRENT_PROGRAM, &program); - if (program) { - GLint model; - glGetIntegerv(GL_SHADE_MODEL, &model); - - GLint location = glGetUniformLocation(program, "osd_flat_shading"); - if (location != -1) { - glUniform1i(location, model == GL_FLAT); - } - - /* Face-vertex data */ - if (gl_mesh->fvar_data != NULL) { - if (gl_mesh->fvar_data->texture_buffer) { - glActiveTexture(GL_TEXTURE31); - glBindTexture(GL_TEXTURE_BUFFER, - gl_mesh->fvar_data->texture_buffer); - glActiveTexture(GL_TEXTURE0); - } - - if (gl_mesh->fvar_data->offset_buffer) { - glActiveTexture(GL_TEXTURE30); - glBindTexture(GL_TEXTURE_BUFFER, - gl_mesh->fvar_data->offset_buffer); - glActiveTexture(GL_TEXTURE0); - } - - GLint location = glGetUniformLocation(program, "osd_fvar_count"); - if (location != -1) { - glUniform1i(location, gl_mesh->fvar_data->fvar_width); - } - - location = glGetUniformLocation(program, "osd_active_uv_offset"); - if (location != -1) { - if (gl_mesh->fvar_data->channel_offsets.size() > 0 && - g_active_uv_index >= 0) - { - glUniform1i(location, - gl_mesh->fvar_data->channel_offsets[g_active_uv_index]); - } else { - glUniform1i(location, 0); - } - } - } else { - glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0); - glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); - } - } - return program; - } - - if (fill_quads) { - int model; - GLboolean use_texture_2d; - glGetIntegerv(GL_SHADE_MODEL, &model); - glGetBooleanv(GL_TEXTURE_2D, &use_texture_2d); - - if (model == GL_FLAT) { - if (use_texture_2d) { - program = g_flat_fill_texture2d_program; - } - else { - program = g_flat_fill_solid_program; - } - } - else { - if (use_texture_2d) { - program = g_smooth_fill_texture2d_program; - } - else { - program = g_smooth_fill_solid_program; - } - } - - } - else { - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - program = g_wireframe_program; - } - - bindProgram(gl_mesh, program); - - return program; -} - -static void perform_drawElements(GLuint program, - int patch_index, - int num_elements, - int start_element) -{ - if (program) { - glUniform1i(glGetUniformLocation(program, "PrimitiveIdBase"), - patch_index); - } - glDrawElements(GL_LINES_ADJACENCY, - num_elements, - GL_UNSIGNED_INT, - (void *)(start_element * sizeof(unsigned int))); -} - -static void finish_patchDraw(bool fill_quads) -{ - /* TODO(sergey): Some of the stuff could be done once after the whole - * mesh is displayed. - */ - - /* Restore state. */ - if (!fill_quads) { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - glBindVertexArray(0); - - if (g_use_osd_glsl) { - /* TODO(sergey): Store previously used program and roll back to it? */ - glUseProgram(0); - } -} - -static void draw_partition_patches_range(GLMeshInterface *mesh, - GLuint program, - int start_patch, - int num_patches) -{ - int traversed_patches = 0, num_remained_patches = num_patches; - const OpenSubdiv::Osd::PatchArrayVector& patches = - mesh->GetPatchTable()->GetPatchArrays(); - for (int i = 0; i < (int)patches.size(); ++i) { - const OpenSubdiv::Osd::PatchArray& patch = patches[i]; - OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor(); - OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType(); - - if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) { - const int num_block_patches = patch.GetNumPatches(); - if (start_patch >= traversed_patches && - start_patch < traversed_patches + num_block_patches) - { - const int num_control_verts = desc.GetNumControlVertices(); - const int start_draw_patch = start_patch - traversed_patches; - const int num_draw_patches = std::min(num_remained_patches, - num_block_patches - start_draw_patch); - perform_drawElements(program, - i + start_draw_patch, - num_draw_patches * num_control_verts, - patch.GetIndexBase() + start_draw_patch * num_control_verts); - num_remained_patches -= num_draw_patches; - } - if (num_remained_patches == 0) { - break; - } - traversed_patches += num_block_patches; - } - } -} - -static void draw_all_patches(GLMeshInterface *mesh, - GLuint program) -{ - const OpenSubdiv::Osd::PatchArrayVector& patches = - mesh->GetPatchTable()->GetPatchArrays(); - for (int i = 0; i < (int)patches.size(); ++i) { - const OpenSubdiv::Osd::PatchArray& patch = patches[i]; - OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor(); - OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType(); - - if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) { - perform_drawElements(program, - i, - patch.GetNumPatches() * desc.GetNumControlVertices(), - patch.GetIndexBase()); - } - } -} - -void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh, - int fill_quads, - int start_patch, - int num_patches) -{ - GLMeshInterface *mesh = - (GLMeshInterface *)(gl_mesh->descriptor); - - /* Make sure all global invariants are initialized. */ - if (!openSubdiv_osdGLDisplayInit()) { - return; - } - - /* Setup GLSL/OpenGL to draw patches in current context. */ - GLuint program = prepare_patchDraw(gl_mesh, fill_quads != 0); - - if (start_patch != -1) { - draw_partition_patches_range(mesh, - program, - start_patch, - num_patches); - } - else { - draw_all_patches(mesh, program); - } - - /* Finish patch drawing by restoring all changes to the OpenGL context. */ - finish_patchDraw(fill_quads != 0); -} - -void openSubdiv_osdGLAllocFVar(OpenSubdiv_TopologyRefinerDescr *topology_refiner, - OpenSubdiv_GLMesh *gl_mesh, - const float *fvar_data) -{ - GLMeshInterface *mesh = - (GLMeshInterface *)(gl_mesh->descriptor); - gl_mesh->fvar_data = OBJECT_GUARDED_NEW(OpenSubdiv_GLMeshFVarData); - gl_mesh->fvar_data->Create(topology_refiner->osd_refiner, - mesh->GetFarPatchTable(), - 2, - fvar_data); -} - -void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh) -{ - if (gl_mesh->fvar_data != NULL) { - OBJECT_GUARDED_DELETE(gl_mesh->fvar_data, OpenSubdiv_GLMeshFVarData); - } -} diff --git a/intern/opensubdiv/opensubdiv_intern.h b/intern/opensubdiv/opensubdiv_intern.h deleted file mode 100644 index ccb32f9d0ac..00000000000 --- a/intern/opensubdiv/opensubdiv_intern.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2015 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __OPENSUBDIV_INTERN_H__ -#define __OPENSUBDIV_INTERN_H__ - -/* Perform full topology validation when exporting it to OpenSubdiv. */ -#ifdef NDEBUG -# undef OPENSUBDIV_VALIDATE_TOPOLOGY -#else -/* TODO(sergey): Always disabled for now, the check doesn't handle - * multiple non-manifolds from the OpenSubdiv side currently. - */ -# undef OPENSUBDIV_VALIDATE_TOPOLOGY -#endif - -/* Currently OpenSubdiv expects topology to be oriented, - * but sometimes it's handy to disable orientation code - * to check whether it causes some weird issues by using - * pre-oriented model. - */ -#define OPENSUBDIV_ORIENT_TOPOLOGY - -#endif /* __OPENSUBDIV_INTERN_H__ */ diff --git a/intern/opensubdiv/opensubdiv_topology_refiner.h b/intern/opensubdiv/opensubdiv_topology_refiner.h deleted file mode 100644 index b00f6a54201..00000000000 --- a/intern/opensubdiv/opensubdiv_topology_refiner.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __OPENSUBDIV_TOPOLOGY_REFINER_H__ -#define __OPENSUBDIV_TOPOLOGY_REFINER_H__ - -#include - -typedef struct OpenSubdiv_TopologyRefinerDescr { - OpenSubdiv::Far::TopologyRefiner *osd_refiner; - - /* TODO(sergey): For now only, need to find better place - * after revisiting whole OSD drawing pipeline and Blender - * integration. - */ - std::vector uvs; -} OpenSubdiv_TopologyRefinerDescr; - -#endif /* __OPENSUBDIV_TOPOLOGY_REFINER_H__ */ diff --git a/intern/opensubdiv/opensubdiv_topology_refiner_capi.h b/intern/opensubdiv/opensubdiv_topology_refiner_capi.h new file mode 100644 index 00000000000..103ccd2c1f9 --- /dev/null +++ b/intern/opensubdiv/opensubdiv_topology_refiner_capi.h @@ -0,0 +1,110 @@ +// Copyright 2018 Blender Foundation. All rights reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// Author: Sergey Sharybin + +#ifndef OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_ +#define OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_ + +#include // for bool + +#ifdef __cplusplus +extern "C" { +#endif + +struct OpenSubdiv_Converter; +struct OpenSubdiv_TopologyRefinerInternal; + +// Those settings don't really belong to OpenSubdiv's topology refiner, but +// we are keeping track of them on our side of topology refiner. This is to +// make it possible to ensure we are not trying to abuse same OpenSubdiv's +// topology refiner with different subdivision levels or with different +// adaptive settings. +typedef struct OpenSubdiv_TopologyRefinerSettings { + bool is_adaptive; + int level; +} OpenSubdiv_TopologyRefinerSettings; + +typedef struct OpenSubdiv_TopologyRefiner { + // Query subdivision level the refiner is created for. + int (*getSubdivisionLevel)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner); + bool (*getIsAdaptive)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner); + + // Query basic topology information from base level. + int (*getNumVertices)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner); + int (*getNumEdges)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner); + int (*getNumFaces)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner); + int (*getNumFaceVertices)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index); + + // Ptex face corresponds to OpenSubdiv's internal "patch" and to Blender's + // subdivision grid. The rule commes as: + // - Triangle face consist of 3 ptex faces, ordered in the order of + // face-vertices. + // - Quad face consists of a single ptex face. + // - N-gons (similar to triangle) consists of N ptex faces, ordered same + // way as for triangle. + int (*getNumFacePtexFaces)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index); + int (*getNumPtexFaces)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner); + + // Initialize a per-base-face offset measured in ptex face indices. + // + // Basically, face_ptex_offset[base_face_index] is a total number of ptex + // faces created for bases faces [0 .. base_face_index - 1]. + // + // The array must contain at least total number of ptex faces elements. + void (*fillFacePtexIndexOffset)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + int* face_ptex_index_offset); + + // Internal storage for the use in this module only. + // + // Tease: Contains actual OpenSubdiv's refiner and (optionally) some other + // data and state needed for an internbal use. + struct OpenSubdiv_TopologyRefinerInternal* internal; +} OpenSubdiv_TopologyRefiner; + +OpenSubdiv_TopologyRefiner* openSubdiv_createTopologyRefinerFromConverter( + struct OpenSubdiv_Converter* converter, + const OpenSubdiv_TopologyRefinerSettings* settings); + +void openSubdiv_deleteTopologyRefiner( + OpenSubdiv_TopologyRefiner* topology_refiner); + +// Compare given topology refiner with converter. Returns truth if topology +// refiner matches given converter, false otherwise. +// +// This allows users to construct converter (which is supposed to be cheap) +// and compare with existing refiner before going into more computationally +// complicated parts of subdivision process. +bool openSubdiv_topologyRefinerCompareWithConverter( + const OpenSubdiv_TopologyRefiner* topology_refiner, + const OpenSubdiv_Converter* converter); + +#ifdef __cplusplus +} +#endif + +#endif // OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_ diff --git a/intern/opensubdiv/opensubdiv_utils_capi.cc b/intern/opensubdiv/opensubdiv_utils_capi.cc deleted file mode 100644 index 72e3751e6b3..00000000000 --- a/intern/opensubdiv/opensubdiv_utils_capi.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2013 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * Brecht van Lommel - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "opensubdiv_capi.h" - -#include -#include - -#ifdef _MSC_VER -# include "iso646.h" -#endif - -#ifdef OPENSUBDIV_HAS_OPENCL -# include "opensubdiv_device_context_opencl.h" -#endif /* OPENSUBDIV_HAS_OPENCL */ - -#ifdef OPENSUBDIV_HAS_CUDA -# include "opensubdiv_device_context_cuda.h" -#endif /* OPENSUBDIV_HAS_CUDA */ - -int openSubdiv_getAvailableEvaluators(void) -{ - int flags = OPENSUBDIV_EVALUATOR_CPU; - -#ifdef OPENSUBDIV_HAS_OPENMP - flags |= OPENSUBDIV_EVALUATOR_OPENMP; -#endif /* OPENSUBDIV_HAS_OPENMP */ - -#ifdef OPENSUBDIV_HAS_OPENCL - if (CLDeviceContext::HAS_CL_VERSION_1_1()) { - flags |= OPENSUBDIV_EVALUATOR_OPENCL; - } -#endif /* OPENSUBDIV_HAS_OPENCL */ - -#ifdef OPENSUBDIV_HAS_CUDA - if (CudaDeviceContext::HAS_CUDA_VERSION_4_0()) { - flags |= OPENSUBDIV_EVALUATOR_CUDA; - } -#endif /* OPENSUBDIV_HAS_OPENCL */ - -#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK - if (GLEW_VERSION_4_1) { - flags |= OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK; - } -#endif /* OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK */ - -#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE - if (GLEW_VERSION_4_3 || GLEW_ARB_compute_shader) { - flags |= OPENSUBDIV_EVALUATOR_GLSL_COMPUTE; - } -#endif /* OPENSUBDIV_HAS_GLSL_COMPUTE */ - - return flags; -} - -void openSubdiv_init(void) -{ - /* Ensure all OpenGL strings are cached. */ - (void)openSubdiv_getAvailableEvaluators(); -} - -void openSubdiv_cleanup(void) -{ - openSubdiv_osdGLDisplayDeinit(); -} diff --git a/intern/opensubdiv/shader/gpu_shader_opensubdiv_fragment.glsl b/intern/opensubdiv/shader/gpu_shader_opensubdiv_fragment.glsl new file mode 100644 index 00000000000..1e36d549360 --- /dev/null +++ b/intern/opensubdiv/shader/gpu_shader_opensubdiv_fragment.glsl @@ -0,0 +1,172 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +struct VertexData { + vec4 position; + vec3 normal; + vec2 uv; +}; + +#define MAX_LIGHTS 8 +#define NUM_SOLID_LIGHTS 3 + +struct LightSource { + vec4 position; + vec4 ambient; + vec4 diffuse; + vec4 specular; + vec4 spotDirection; +#ifdef SUPPORT_COLOR_MATERIAL + float constantAttenuation; + float linearAttenuation; + float quadraticAttenuation; + float spotCutoff; + float spotExponent; + float spotCosCutoff; + float pad, pad2; +#endif +}; + +layout(std140) uniform Lighting { + LightSource lightSource[MAX_LIGHTS]; + int num_enabled_lights; +}; + +uniform vec4 diffuse; +uniform vec4 specular; +uniform float shininess; + +uniform sampler2D texture_buffer; + +in block { + VertexData v; +} inpt; + +void main() +{ +#ifdef WIREFRAME + gl_FragColor = diffuse; +#else + vec3 N = inpt.v.normal; + + if (!gl_FrontFacing) + N = -N; + + /* Compute diffuse and specular lighting. */ + vec3 L_diffuse = vec3(0.0); + vec3 L_specular = vec3(0.0); + +#ifdef USE_LIGHTING +#ifndef USE_COLOR_MATERIAL + /* Assume NUM_SOLID_LIGHTS directional lights. */ + for (int i = 0; i < NUM_SOLID_LIGHTS; i++) { + vec4 Plight = lightSource[i].position; +#ifdef USE_DIRECTIONAL_LIGHT + vec3 l = (Plight.w == 0.0) + ? normalize(Plight.xyz) + : normalize(inpt.v.position.xyz); +#else /* USE_DIRECTIONAL_LIGHT */ + /* TODO(sergey): We can normalize it outside of the shader. */ + vec3 l = normalize(Plight.xyz); +#endif /* USE_DIRECTIONAL_LIGHT */ + vec3 h = normalize(l + vec3(0, 0, 1)); + float d = max(0.0, dot(N, l)); + float s = pow(max(0.0, dot(N, h)), shininess); + L_diffuse += d * lightSource[i].diffuse.rgb; + L_specular += s * lightSource[i].specular.rgb; + } +#else /* USE_COLOR_MATERIAL */ + vec3 varying_position = inpt.v.position.xyz; + vec3 V = (gl_ProjectionMatrix[3][3] == 0.0) ? + normalize(varying_position) : vec3(0.0, 0.0, -1.0); + for (int i = 0; i < num_enabled_lights; i++) { + /* todo: this is a slow check for disabled lights */ + if (lightSource[i].specular.a == 0.0) + continue; + + float intensity = 1.0; + vec3 light_direction; + + if (lightSource[i].position.w == 0.0) { + /* directional light */ + light_direction = lightSource[i].position.xyz; + } + else { + /* point light */ + vec3 d = lightSource[i].position.xyz - varying_position; + light_direction = normalize(d); + + /* spot light cone */ + if (lightSource[i].spotCutoff < 90.0) { + float cosine = max(dot(light_direction, + -lightSource[i].spotDirection.xyz), + 0.0); + intensity = pow(cosine, lightSource[i].spotExponent); + intensity *= step(lightSource[i].spotCosCutoff, cosine); + } + + /* falloff */ + float distance = length(d); + + intensity /= lightSource[i].constantAttenuation + + lightSource[i].linearAttenuation * distance + + lightSource[i].quadraticAttenuation * distance * distance; + } + + /* diffuse light */ + vec3 light_diffuse = lightSource[i].diffuse.rgb; + float diffuse_bsdf = max(dot(N, light_direction), 0.0); + L_diffuse += light_diffuse * diffuse_bsdf * intensity; + + /* specular light */ + vec3 light_specular = lightSource[i].specular.rgb; + vec3 H = normalize(light_direction - V); + + float specular_bsdf = pow(max(dot(N, H), 0.0), + gl_FrontMaterial.shininess); + L_specular += light_specular * specular_bsdf * intensity; + } +#endif /* USE_COLOR_MATERIAL */ +#else /* USE_LIGHTING */ + L_diffuse = vec3(1.0); +#endif + + /* Compute diffuse color. */ +#ifdef USE_TEXTURE_2D + L_diffuse *= texture2D(texture_buffer, inpt.v.uv).rgb; +#else + L_diffuse *= diffuse.rgb; +#endif + + /* Sum lighting. */ + vec3 L = L_diffuse; + if (shininess != 0) { + L += L_specular * specular.rgb; + } + + /* Write out fragment color. */ + gl_FragColor = vec4(L, diffuse.a); +#endif +} diff --git a/intern/opensubdiv/shader/gpu_shader_opensubdiv_geometry.glsl b/intern/opensubdiv/shader/gpu_shader_opensubdiv_geometry.glsl new file mode 100644 index 00000000000..b16a5cca733 --- /dev/null +++ b/intern/opensubdiv/shader/gpu_shader_opensubdiv_geometry.glsl @@ -0,0 +1,154 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +struct VertexData { + vec4 position; + vec3 normal; + vec2 uv; +}; + +layout(lines_adjacency) in; +#ifdef WIREFRAME +layout(line_strip, max_vertices = 8) out; +#else +layout(triangle_strip, max_vertices = 4) out; +#endif + +uniform mat4 modelViewMatrix; +uniform mat4 projectionMatrix; +uniform int PrimitiveIdBase; +uniform int osd_fvar_count; +uniform int osd_active_uv_offset; + +in block { + VertexData v; +} inpt[]; + +#define INTERP_FACE_VARYING_2(result, fvarOffset, tessCoord) \ + { \ + vec2 v[4]; \ + int primOffset = (gl_PrimitiveID + PrimitiveIdBase) * 4; \ + for (int i = 0; i < 4; ++i) { \ + int index = (primOffset + i) * osd_fvar_count + fvarOffset; \ + v[i] = vec2(texelFetch(FVarDataBuffer, index).s, \ + texelFetch(FVarDataBuffer, index + 1).s); \ + } \ + result = mix(mix(v[0], v[1], tessCoord.s), \ + mix(v[3], v[2], tessCoord.s), \ + tessCoord.t); \ + } + +uniform samplerBuffer FVarDataBuffer; +uniform isamplerBuffer FVarDataOffsetBuffer; + +out block { + VertexData v; +} outpt; + +#ifdef FLAT_SHADING +void emit(int index, vec3 normal) +{ + outpt.v.position = inpt[index].v.position; + outpt.v.normal = normal; + + /* TODO(sergey): Only uniform subdivisions atm. */ + vec2 quadst[4] = vec2[](vec2(0, 0), vec2(1, 0), vec2(1, 1), vec2(0, 1)); + vec2 st = quadst[index]; + + INTERP_FACE_VARYING_2(outpt.v.uv, osd_active_uv_offset, st); + + gl_Position = projectionMatrix * inpt[index].v.position; + EmitVertex(); +} + +# ifdef WIREFRAME +void emit_edge(int v0, int v1, vec3 normal) +{ + emit(v0, normal); + emit(v1, normal); +} +# endif + +#else +void emit(int index) +{ + outpt.v.position = inpt[index].v.position; + outpt.v.normal = inpt[index].v.normal; + + /* TODO(sergey): Only uniform subdivisions atm. */ + vec2 quadst[4] = vec2[](vec2(0, 0), vec2(1, 0), vec2(1, 1), vec2(0, 1)); + vec2 st = quadst[index]; + + INTERP_FACE_VARYING_2(outpt.v.uv, osd_active_uv_offset, st); + + gl_Position = projectionMatrix * inpt[index].v.position; + EmitVertex(); +} + +# ifdef WIREFRAME +void emit_edge(int v0, int v1) +{ + emit(v0); + emit(v1); +} +# endif + +#endif + +void main() +{ + gl_PrimitiveID = gl_PrimitiveIDIn; + +#ifdef FLAT_SHADING + vec3 A = (inpt[0].v.position - inpt[1].v.position).xyz; + vec3 B = (inpt[3].v.position - inpt[1].v.position).xyz; + vec3 flat_normal = normalize(cross(B, A)); +# ifndef WIREFRAME + emit(0, flat_normal); + emit(1, flat_normal); + emit(3, flat_normal); + emit(2, flat_normal); +# else + emit_edge(0, 1, flat_normal); + emit_edge(1, 2, flat_normal); + emit_edge(2, 3, flat_normal); + emit_edge(3, 0, flat_normal); +# endif +#else +# ifndef WIREFRAME + emit(0); + emit(1); + emit(3); + emit(2); +# else + emit_edge(0, 1); + emit_edge(1, 2); + emit_edge(2, 3); + emit_edge(3, 0); +# endif +#endif + + EndPrimitive(); +} diff --git a/intern/opensubdiv/shader/gpu_shader_opensubdiv_vertex.glsl b/intern/opensubdiv/shader/gpu_shader_opensubdiv_vertex.glsl new file mode 100644 index 00000000000..6fcf5ad20cd --- /dev/null +++ b/intern/opensubdiv/shader/gpu_shader_opensubdiv_vertex.glsl @@ -0,0 +1,46 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +struct VertexData { + vec4 position; + vec3 normal; + vec2 uv; +}; + +in vec3 normal; +in vec4 position; + +uniform mat4 modelViewMatrix; +uniform mat3 normalMatrix; + +out block { + VertexData v; +} outpt; + +void main() +{ + outpt.v.position = modelViewMatrix * position; + outpt.v.normal = normalize(normalMatrix * normal); +} diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 81b1afa3621..dd5a87a445d 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -40,6 +40,8 @@ #ifdef WITH_OPENSUBDIV # include "opensubdiv_capi.h" # include "opensubdiv_converter_capi.h" +# include "opensubdiv_evaluator_capi.h" +# include "opensubdiv_topology_refiner_capi.h" #endif #include "GPU_glew.h" @@ -329,7 +331,7 @@ void ccgSubSurf_free(CCGSubSurf *ss) CCGAllocatorHDL allocator = ss->allocator; #ifdef WITH_OPENSUBDIV if (ss->osd_evaluator != NULL) { - openSubdiv_deleteEvaluatorDescr(ss->osd_evaluator); + openSubdiv_deleteEvaluator(ss->osd_evaluator); } if (ss->osd_mesh != NULL) { ccgSubSurf__delete_osdGLMesh(ss->osd_mesh); @@ -341,7 +343,7 @@ void ccgSubSurf_free(CCGSubSurf *ss) MEM_freeN(ss->osd_coarse_coords); } if (ss->osd_topology_refiner != NULL) { - openSubdiv_deleteTopologyRefinerDescr(ss->osd_topology_refiner); + openSubdiv_deleteTopologyRefiner(ss->osd_topology_refiner); } #endif diff --git a/source/blender/blenkernel/intern/CCGSubSurf_intern.h b/source/blender/blenkernel/intern/CCGSubSurf_intern.h index 9df1c9021ef..29e327d8973 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_intern.h +++ b/source/blender/blenkernel/intern/CCGSubSurf_intern.h @@ -236,7 +236,7 @@ struct CCGSubSurf { * Refiner is created from the modifier stack and used later from the main * thread to construct GL mesh to avoid threaded access to GL. */ - struct OpenSubdiv_TopologyRefinerDescr *osd_topology_refiner; /* Only used at synchronization stage. */ + struct OpenSubdiv_TopologyRefiner *osd_topology_refiner; /* Only used at synchronization stage. */ /* Denotes whether osd_mesh is invalid now due to topology changes and needs * to be reconstructed. * @@ -249,7 +249,7 @@ struct CCGSubSurf { /* ** CPU backend. ** */ /* Limit evaluator, used to evaluate CCG. */ - struct OpenSubdiv_EvaluatorDescr *osd_evaluator; + struct OpenSubdiv_Evaluator *osd_evaluator; /* Next PTex face index, used while CCG synchronization * to fill in PTex index of CCGFace. */ diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c index 46204898709..98a17ad8009 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c @@ -42,6 +42,9 @@ #include "opensubdiv_capi.h" #include "opensubdiv_converter_capi.h" +#include "opensubdiv_evaluator_capi.h" +#include "opensubdiv_gl_mesh_capi.h" +#include "opensubdiv_topology_refiner_capi.h" #include "GPU_glew.h" #include "GPU_extensions.h" @@ -131,7 +134,6 @@ static bool compare_ccg_derivedmesh_topology(CCGSubSurf *ss, DerivedMesh *dm) static bool compare_osd_derivedmesh_topology(CCGSubSurf *ss, DerivedMesh *dm) { - const OpenSubdiv_TopologyRefinerDescr *topology_refiner; OpenSubdiv_Converter converter; bool result; if (ss->osd_mesh == NULL && ss->osd_topology_refiner == NULL) { @@ -140,15 +142,10 @@ static bool compare_osd_derivedmesh_topology(CCGSubSurf *ss, DerivedMesh *dm) /* TODO(sergey): De-duplicate with topology counter at the bottom of * the file. */ - if (ss->osd_topology_refiner != NULL) { - topology_refiner = ss->osd_topology_refiner; - } - else { - topology_refiner = openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh); - } ccgSubSurf_converter_setup_from_derivedmesh(ss, dm, &converter); - result = openSubdiv_topologyRefnerCompareConverter(topology_refiner, - &converter); + result = openSubdiv_topologyRefinerCompareWithConverter( + ss->osd_topology_refiner, + &converter); ccgSubSurf_converter_free(&converter); return result; } @@ -159,22 +156,13 @@ static bool opensubdiv_is_topology_changed(CCGSubSurf *ss, DerivedMesh *dm) return true; } if (ss->osd_topology_refiner != NULL) { - int levels = openSubdiv_topologyRefinerGetSubdivLevel( + const int levels = ss->osd_topology_refiner->getSubdivisionLevel( ss->osd_topology_refiner); BLI_assert(ss->osd_mesh_invalid == true); if (levels != ss->subdivLevels) { return true; } } - if (ss->osd_mesh != NULL && ss->osd_mesh_invalid == false) { - const OpenSubdiv_TopologyRefinerDescr *topology_refiner = - openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh); - int levels = openSubdiv_topologyRefinerGetSubdivLevel(topology_refiner); - BLI_assert(ss->osd_topology_refiner == NULL); - if (levels != ss->subdivLevels) { - return true; - } - } if (ss->skip_grids == false) { return compare_ccg_derivedmesh_topology(ss, dm) == false; } @@ -194,13 +182,13 @@ void ccgSubSurf_checkTopologyChanged(CCGSubSurf *ss, DerivedMesh *dm) /* Reset GPU part. */ ss->osd_mesh_invalid = true; if (ss->osd_topology_refiner != NULL) { - openSubdiv_deleteTopologyRefinerDescr(ss->osd_topology_refiner); + openSubdiv_deleteTopologyRefiner(ss->osd_topology_refiner); ss->osd_topology_refiner = NULL; } /* Reset CPU side. */ if (ss->osd_evaluator != NULL) { - openSubdiv_deleteEvaluatorDescr(ss->osd_evaluator); + openSubdiv_deleteEvaluator(ss->osd_evaluator); ss->osd_evaluator = NULL; } } @@ -209,10 +197,10 @@ void ccgSubSurf_checkTopologyChanged(CCGSubSurf *ss, DerivedMesh *dm) static void ccgSubSurf__updateGLMeshCoords(CCGSubSurf *ss) { BLI_assert(ss->meshIFC.numLayers == 3); - openSubdiv_osdGLMeshUpdateVertexBuffer(ss->osd_mesh, - (float *) ss->osd_coarse_coords, - 0, - ss->osd_num_coarse_coords); + ss->osd_mesh->setCoarsePositions(ss->osd_mesh, + (float *) ss->osd_coarse_coords, + 0, + ss->osd_num_coarse_coords); } bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss, @@ -259,9 +247,7 @@ bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss, ss->osd_mesh = openSubdiv_createOsdGLMeshFromTopologyRefiner( ss->osd_topology_refiner, - compute_type, - ss->subdivLevels); - ss->osd_topology_refiner = NULL; + compute_type); if (UNLIKELY(ss->osd_mesh == NULL)) { /* Most likely compute device is not available. */ @@ -269,13 +255,12 @@ bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss, } ccgSubSurf__updateGLMeshCoords(ss); - openSubdiv_osdGLMeshRefine(ss->osd_mesh); - openSubdiv_osdGLMeshSynchronize(ss->osd_mesh); + ss->osd_mesh->refine(ss->osd_mesh); + ss->osd_mesh->synchronize(ss->osd_mesh); ss->osd_coarse_coords_invalid = false; glBindVertexArray(ss->osd_vao); - glBindBuffer(GL_ARRAY_BUFFER, - openSubdiv_getOsdGLMeshVertexBuffer(ss->osd_mesh)); + ss->osd_mesh->bindVertexBuffer(ss->osd_mesh); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); @@ -289,12 +274,12 @@ bool ccgSubSurf_prepareGLMesh(CCGSubSurf *ss, } else if (ss->osd_coarse_coords_invalid) { ccgSubSurf__updateGLMeshCoords(ss); - openSubdiv_osdGLMeshRefine(ss->osd_mesh); - openSubdiv_osdGLMeshSynchronize(ss->osd_mesh); + ss->osd_mesh->refine(ss->osd_mesh); + ss->osd_mesh->synchronize(ss->osd_mesh); ss->osd_coarse_coords_invalid = false; } - openSubdiv_osdGLMeshDisplayPrepare(use_osd_glsl, active_uv_index); + ss->osd_mesh->prepareDraw(ss->osd_mesh, use_osd_glsl, active_uv_index); return true; } @@ -305,12 +290,12 @@ void ccgSubSurf_drawGLMesh(CCGSubSurf *ss, bool fill_quads, if (LIKELY(ss->osd_mesh != NULL)) { glBindVertexArray(ss->osd_vao); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, - openSubdiv_getOsdGLMeshPatchIndexBuffer(ss->osd_mesh)); + ss->osd_mesh->getPatchIndexBuffer(ss->osd_mesh)); - openSubdiv_osdGLMeshBindVertexBuffer(ss->osd_mesh); + ss->osd_mesh->bindVertexBuffer(ss->osd_mesh); glBindVertexArray(ss->osd_vao); - openSubdiv_osdGLMeshDisplay(ss->osd_mesh, fill_quads, - start_partition, num_partitions); + ss->osd_mesh->drawPatches(ss->osd_mesh, fill_quads, + start_partition, num_partitions); glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -319,33 +304,21 @@ void ccgSubSurf_drawGLMesh(CCGSubSurf *ss, bool fill_quads, int ccgSubSurf_getNumGLMeshBaseFaces(CCGSubSurf *ss) { - const OpenSubdiv_TopologyRefinerDescr *topology_refiner; if (ss->osd_topology_refiner != NULL) { - topology_refiner = ss->osd_topology_refiner; - } - else if (ss->osd_mesh != NULL) { - topology_refiner = openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh); - } - else { - return 0; + return ss->osd_topology_refiner->getNumFaces( + ss->osd_topology_refiner); } - return openSubdiv_topologyRefinerGetNumFaces(topology_refiner); + return 0; } /* Get number of vertices in base faces in a particular GL mesh. */ int ccgSubSurf_getNumGLMeshBaseFaceVerts(CCGSubSurf *ss, int face) { - const OpenSubdiv_TopologyRefinerDescr *topology_refiner; if (ss->osd_topology_refiner != NULL) { - topology_refiner = ss->osd_topology_refiner; - } - else if (ss->osd_mesh != NULL) { - topology_refiner = openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh); - } - else { - return 0; + return ss->osd_topology_refiner->getNumFaceVertices( + ss->osd_topology_refiner, face); } - return openSubdiv_topologyRefinerGetNumFaceVerts(topology_refiner, face); + return 0; } void ccgSubSurf_setSkipGrids(CCGSubSurf *ss, bool skip_grids) @@ -453,17 +426,21 @@ void ccgSubSurf_evaluatorFVarUV(CCGSubSurf *ss, static bool opensubdiv_createEvaluator(CCGSubSurf *ss) { OpenSubdiv_Converter converter; - OpenSubdiv_TopologyRefinerDescr *topology_refiner; + OpenSubdiv_TopologyRefiner *topology_refiner; if (ss->fMap->numEntries == 0) { /* OpenSubdiv doesn't support meshes without faces. */ return false; } ccgSubSurf_converter_setup_from_ccg(ss, &converter); - topology_refiner = openSubdiv_createTopologyRefinerDescr(&converter); + OpenSubdiv_TopologyRefinerSettings settings; + settings.level = ss->subdivLevels; + settings.is_adaptive = false; + topology_refiner = + openSubdiv_createTopologyRefinerFromConverter( + &converter, &settings); ccgSubSurf_converter_free(&converter); ss->osd_evaluator = - openSubdiv_createEvaluatorDescr(topology_refiner, - ss->subdivLevels); + openSubdiv_createEvaluatorFromTopologyRefiner(topology_refiner); if (ss->osd_evaluator == NULL) { BLI_assert(!"OpenSubdiv initialization failed, should not happen."); return false; @@ -519,11 +496,11 @@ static void opensubdiv_updateEvaluatorCoarsePositions(CCGSubSurf *ss) } } - openSubdiv_setEvaluatorCoarsePositions(ss->osd_evaluator, - (float *)positions, - 0, - num_basis_verts); - openSubdiv_refineEvaluator(ss->osd_evaluator); + ss->osd_evaluator->setCoarsePositions(ss->osd_evaluator, + (float *)positions, + 0, + num_basis_verts); + ss->osd_evaluator->refine(ss->osd_evaluator); MEM_freeN(positions); } @@ -558,11 +535,12 @@ static void opensubdiv_evaluateQuadFaceGrids(CCGSubSurf *ss, ccgSubSurf__mapGridToFace(S, grid_u, grid_v, &face_u, &face_v); /* TODO(sergey): Need proper port. */ - openSubdiv_evaluateLimit(ss->osd_evaluator, osd_face_index, - face_u, face_v, - P, - do_normals ? dPdu : NULL, - do_normals ? dPdv : NULL); + ss->osd_evaluator->evaluateLimit( + ss->osd_evaluator, osd_face_index, + face_u, face_v, + P, + do_normals ? dPdu : NULL, + do_normals ? dPdv : NULL); OSD_LOG("face=%d, corner=%d, grid_u=%f, grid_v=%f, face_u=%f, face_v=%f, P=(%f, %f, %f)\n", osd_face_index, S, grid_u, grid_v, face_u, face_v, P[0], P[1], P[2]); @@ -636,7 +614,11 @@ static void opensubdiv_evaluateQuadFaceGrids(CCGSubSurf *ss, * let's just re-evaluate for simplicity. */ /* TODO(sergey): Need proper port. */ - openSubdiv_evaluateLimit(ss->osd_evaluator, osd_face_index, u, v, P, dPdu, dPdv); + ss->osd_evaluator->evaluateLimit( + ss->osd_evaluator, + osd_face_index, + u, v, + P, dPdu, dPdv); VertDataCopy(co, P, ss); if (do_normals) { cross_v3_v3v3(no, dPdu, dPdv); @@ -700,7 +682,11 @@ static void opensubdiv_evaluateNGonFaceGrids(CCGSubSurf *ss, float P[3], dPdu[3], dPdv[3]; /* TODO(sergey): Need proper port. */ - openSubdiv_evaluateLimit(ss->osd_evaluator, osd_face_index + S, u, v, P, dPdu, dPdv); + ss->osd_evaluator->evaluateLimit( + ss->osd_evaluator, + osd_face_index + S, + u, v, + P, dPdu, dPdv); OSD_LOG("face=%d, corner=%d, u=%f, v=%f, P=(%f, %f, %f)\n", osd_face_index + S, S, u, v, P[0], P[1], P[2]); @@ -838,7 +824,12 @@ void ccgSubSurf_prepareTopologyRefiner(CCGSubSurf *ss, DerivedMesh *dm) OpenSubdiv_Converter converter; ccgSubSurf_converter_setup_from_derivedmesh(ss, dm, &converter); /* TODO(sergey): Remove possibly previously allocated refiner. */ - ss->osd_topology_refiner = openSubdiv_createTopologyRefinerDescr(&converter); + OpenSubdiv_TopologyRefinerSettings settings; + settings.level = ss->subdivLevels; + settings.is_adaptive = false; + ss->osd_topology_refiner = + openSubdiv_createTopologyRefinerFromConverter( + &converter, &settings); ccgSubSurf_converter_free(&converter); } } diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c index 8c1ba0c3782..219d77a6c52 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c @@ -432,35 +432,35 @@ void ccgSubSurf_converter_setup_from_derivedmesh( { ConvDMStorage *user_data; - converter->get_scheme_type = conv_dm_get_type; + converter->getSchemeType = conv_dm_get_type; - converter->get_fvar_linear_interpolation = + converter->getFVarLinearInterpolation = conv_dm_get_fvar_linear_interpolation; - converter->get_num_faces = conv_dm_get_num_faces; - converter->get_num_edges = conv_dm_get_num_edges; - converter->get_num_verts = conv_dm_get_num_verts; + converter->getNumFaces = conv_dm_get_num_faces; + converter->getNumEdges = conv_dm_get_num_edges; + converter->getNumVertices = conv_dm_get_num_verts; - converter->get_num_face_verts = conv_dm_get_num_face_verts; - converter->get_face_verts = conv_dm_get_face_verts; - converter->get_face_edges = conv_dm_get_face_edges; + converter->getNumFaceVertices = conv_dm_get_num_face_verts; + converter->getFaceVertices = conv_dm_get_face_verts; + converter->getFaceEdges = conv_dm_get_face_edges; - converter->get_edge_verts = conv_dm_get_edge_verts; - converter->get_num_edge_faces = conv_dm_get_num_edge_faces; - converter->get_edge_faces = conv_dm_get_edge_faces; - converter->get_edge_sharpness = conv_dm_get_edge_sharpness; + converter->getEdgeVertices = conv_dm_get_edge_verts; + converter->getNumEdgeFaces = conv_dm_get_num_edge_faces; + converter->getEdgeFaces = conv_dm_get_edge_faces; + converter->getEdgeSharpness = conv_dm_get_edge_sharpness; - converter->get_num_vert_edges = conv_dm_get_num_vert_edges; - converter->get_vert_edges = conv_dm_get_vert_edges; - converter->get_num_vert_faces = conv_dm_get_num_vert_faces; - converter->get_vert_faces = conv_dm_get_vert_faces; + converter->getNumVertexEdges = conv_dm_get_num_vert_edges; + converter->getVertexEdges = conv_dm_get_vert_edges; + converter->getNumVertexFaces = conv_dm_get_num_vert_faces; + converter->getVertexFaces = conv_dm_get_vert_faces; - converter->get_num_uv_layers = conv_dm_get_num_uv_layers; - converter->precalc_uv_layer = conv_dm_precalc_uv_layer; - converter->finish_uv_layer = conv_dm_finish_uv_layer; - converter->get_num_uvs = conv_dm_get_num_uvs; - converter->get_uvs = conv_dm_get_uvs; - converter->get_face_corner_uv_index = conv_dm_get_face_corner_uv_index; + converter->getNumUVLayers = conv_dm_get_num_uv_layers; + converter->precalcUVLayer = conv_dm_precalc_uv_layer; + converter->finishUVLayer = conv_dm_finish_uv_layer; + converter->getNumUVCoordinates = conv_dm_get_num_uvs; + converter->getUVCoordinates = conv_dm_get_uvs; + converter->getFaceCornerUVIndex = conv_dm_get_face_corner_uv_index; user_data = MEM_mallocN(sizeof(ConvDMStorage), __func__); user_data->ss = ss; @@ -476,7 +476,7 @@ void ccgSubSurf_converter_setup_from_derivedmesh( user_data->uvs = NULL; user_data->face_uvs = NULL; - converter->free_user_data = conv_dm_free_user_data; + converter->freeUserData = conv_dm_free_user_data; converter->user_data = user_data; #ifdef USE_MESH_ELEMENT_MAPPING @@ -717,45 +717,45 @@ static int conv_ccg_get_face_corner_uv_index(const OpenSubdiv_Converter *UNUSED( void ccgSubSurf_converter_setup_from_ccg(CCGSubSurf *ss, OpenSubdiv_Converter *converter) { - converter->get_scheme_type = conv_ccg_get_bilinear_type; + converter->getSchemeType = conv_ccg_get_bilinear_type; - converter->get_fvar_linear_interpolation = + converter->getFVarLinearInterpolation = conv_ccg_get_fvar_linear_interpolation; - converter->get_num_faces = conv_ccg_get_num_faces; - converter->get_num_edges = conv_ccg_get_num_edges; - converter->get_num_verts = conv_ccg_get_num_verts; + converter->getNumFaces = conv_ccg_get_num_faces; + converter->getNumEdges = conv_ccg_get_num_edges; + converter->getNumVertices = conv_ccg_get_num_verts; - converter->get_num_face_verts = conv_ccg_get_num_face_verts; - converter->get_face_verts = conv_ccg_get_face_verts; - converter->get_face_edges = conv_ccg_get_face_edges; + converter->getNumFaceVertices = conv_ccg_get_num_face_verts; + converter->getFaceVertices = conv_ccg_get_face_verts; + converter->getFaceEdges = conv_ccg_get_face_edges; - converter->get_edge_verts = conv_ccg_get_edge_verts; - converter->get_num_edge_faces = conv_ccg_get_num_edge_faces; - converter->get_edge_faces = conv_ccg_get_edge_faces; - converter->get_edge_sharpness = conv_ccg_get_edge_sharpness; + converter->getEdgeVertices = conv_ccg_get_edge_verts; + converter->getNumEdgeFaces = conv_ccg_get_num_edge_faces; + converter->getEdgeFaces = conv_ccg_get_edge_faces; + converter->getEdgeSharpness = conv_ccg_get_edge_sharpness; - converter->get_num_vert_edges = conv_ccg_get_num_vert_edges; - converter->get_vert_edges = conv_ccg_get_vert_edges; - converter->get_num_vert_faces = conv_ccg_get_num_vert_faces; - converter->get_vert_faces = conv_ccg_get_vert_faces; + converter->getNumVertexEdges = conv_ccg_get_num_vert_edges; + converter->getVertexEdges = conv_ccg_get_vert_edges; + converter->getNumVertexFaces = conv_ccg_get_num_vert_faces; + converter->getVertexFaces = conv_ccg_get_vert_faces; - converter->get_num_uv_layers = conv_ccg_get_num_uv_layers; - converter->precalc_uv_layer = conv_ccg_precalc_uv_layer; - converter->finish_uv_layer = conv_ccg_finish_uv_layer; - converter->get_num_uvs = conv_ccg_get_num_uvs; - converter->get_uvs = conv_ccg_get_uvs; - converter->get_face_corner_uv_index = conv_ccg_get_face_corner_uv_index; + converter->getNumUVLayers = conv_ccg_get_num_uv_layers; + converter->precalcUVLayer = conv_ccg_precalc_uv_layer; + converter->finishUVLayer = conv_ccg_finish_uv_layer; + converter->getNumUVCoordinates = conv_ccg_get_num_uvs; + converter->getUVCoordinates = conv_ccg_get_uvs; + converter->getFaceCornerUVIndex = conv_ccg_get_face_corner_uv_index; - converter->free_user_data = NULL; + converter->freeUserData = NULL; converter->user_data = ss; } void ccgSubSurf_converter_free( struct OpenSubdiv_Converter *converter) { - if (converter->free_user_data) { - converter->free_user_data(converter); + if (converter->freeUserData) { + converter->freeUserData(converter); } } -- cgit v1.2.3 From 010e24a95c9e53f2c0bee2aa4cc8450e4346233d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 11:12:02 +0200 Subject: OpenSubdiv: Remove UV coordinates from converter Converter only defines topology, not coordinates or (face)varying data. --- intern/opensubdiv/opensubdiv_converter_capi.h | 3 --- .../blenkernel/intern/CCGSubSurf_opensubdiv_converter.c | 13 ------------- 2 files changed, 16 deletions(-) diff --git a/intern/opensubdiv/opensubdiv_converter_capi.h b/intern/opensubdiv/opensubdiv_converter_capi.h index 1d76da4d76b..b16d6eb6c8f 100644 --- a/intern/opensubdiv/opensubdiv_converter_capi.h +++ b/intern/opensubdiv/opensubdiv_converter_capi.h @@ -127,9 +127,6 @@ typedef struct OpenSubdiv_Converter { // Get number of UV coordinates in the current layer (layer which was // specified in precalcUVLayer(). int (*getNumUVCoordinates)(const struct OpenSubdiv_Converter* converter); - // Get cooridnates themselves. - void (*getUVCoordinates)(const struct OpenSubdiv_Converter* converter, - float* uvs_coordinates); // For the given face index and its corner (known as loop in Blender) // get corrsponding UV coordinate index. int (*getFaceCornerUVIndex)(const struct OpenSubdiv_Converter* converter, diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c index 219d77a6c52..649b7c7fa4c 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c @@ -389,12 +389,6 @@ static int conv_dm_get_num_uvs(const OpenSubdiv_Converter *converter) return storage->num_uvs; } -static void conv_dm_get_uvs(const OpenSubdiv_Converter *converter, float *uvs) -{ - ConvDMStorage *storage = converter->user_data; - memcpy(uvs, storage->uvs, sizeof(float) * 2 * storage->num_uvs); -} - static int conv_dm_get_face_corner_uv_index(const OpenSubdiv_Converter *converter, int face, int corner) @@ -459,7 +453,6 @@ void ccgSubSurf_converter_setup_from_derivedmesh( converter->precalcUVLayer = conv_dm_precalc_uv_layer; converter->finishUVLayer = conv_dm_finish_uv_layer; converter->getNumUVCoordinates = conv_dm_get_num_uvs; - converter->getUVCoordinates = conv_dm_get_uvs; converter->getFaceCornerUVIndex = conv_dm_get_face_corner_uv_index; user_data = MEM_mallocN(sizeof(ConvDMStorage), __func__); @@ -702,11 +695,6 @@ static int conv_ccg_get_num_uvs(const OpenSubdiv_Converter *UNUSED(converter)) return 0; } -static void conv_ccg_get_uvs(const OpenSubdiv_Converter * UNUSED(converter), - float *UNUSED(uvs)) -{ -} - static int conv_ccg_get_face_corner_uv_index(const OpenSubdiv_Converter *UNUSED(converter), int UNUSED(face), int UNUSED(corner_)) @@ -744,7 +732,6 @@ void ccgSubSurf_converter_setup_from_ccg(CCGSubSurf *ss, converter->precalcUVLayer = conv_ccg_precalc_uv_layer; converter->finishUVLayer = conv_ccg_finish_uv_layer; converter->getNumUVCoordinates = conv_ccg_get_num_uvs; - converter->getUVCoordinates = conv_ccg_get_uvs; converter->getFaceCornerUVIndex = conv_ccg_get_face_corner_uv_index; converter->freeUserData = NULL; -- cgit v1.2.3 From d3674587b2e9a43e9dcf794a3c4c8b5eca878dfd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 12:33:32 +0200 Subject: OpenSubdiv: Remove unused file --- .../internal/opensubdiv_topology_refiner.h | 41 ---------------------- 1 file changed, 41 deletions(-) delete mode 100644 intern/opensubdiv/internal/opensubdiv_topology_refiner.h diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner.h b/intern/opensubdiv/internal/opensubdiv_topology_refiner.h deleted file mode 100644 index b00f6a54201..00000000000 --- a/intern/opensubdiv/internal/opensubdiv_topology_refiner.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __OPENSUBDIV_TOPOLOGY_REFINER_H__ -#define __OPENSUBDIV_TOPOLOGY_REFINER_H__ - -#include - -typedef struct OpenSubdiv_TopologyRefinerDescr { - OpenSubdiv::Far::TopologyRefiner *osd_refiner; - - /* TODO(sergey): For now only, need to find better place - * after revisiting whole OSD drawing pipeline and Blender - * integration. - */ - std::vector uvs; -} OpenSubdiv_TopologyRefinerDescr; - -#endif /* __OPENSUBDIV_TOPOLOGY_REFINER_H__ */ -- cgit v1.2.3 From 775c4eb903ef7ed23e734a2412b96d1bf2126e8f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 12:34:19 +0200 Subject: OpenSubdiv: Remove one more unused file --- intern/opensubdiv/internal/opensubdiv_gpu.cc | 788 --------------------------- 1 file changed, 788 deletions(-) delete mode 100644 intern/opensubdiv/internal/opensubdiv_gpu.cc diff --git a/intern/opensubdiv/internal/opensubdiv_gpu.cc b/intern/opensubdiv/internal/opensubdiv_gpu.cc deleted file mode 100644 index d28b48ddd18..00000000000 --- a/intern/opensubdiv/internal/opensubdiv_gpu.cc +++ /dev/null @@ -1,788 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2013 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Sergey Sharybin - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "opensubdiv_capi.h" - -#ifdef _MSC_VER -# include "iso646.h" -#endif - -#include -#include -#include - -#include - -#ifdef OPENSUBDIV_HAS_CUDA -# include -#endif /* OPENSUBDIV_HAS_CUDA */ - -#include -#include - -#include "MEM_guardedalloc.h" - -#include "opensubdiv_capi.h" -#include "opensubdiv_gl_mesh.h" -#include "opensubdiv_topology_refiner.h" - -using OpenSubdiv::Osd::GLMeshInterface; - -extern "C" char datatoc_gpu_shader_opensubdiv_vertex_glsl[]; -extern "C" char datatoc_gpu_shader_opensubdiv_geometry_glsl[]; -extern "C" char datatoc_gpu_shader_opensubdiv_fragment_glsl[]; - -/* TODO(sergey): This is bit of bad level calls :S */ -extern "C" { -void copy_m3_m3(float m1[3][3], float m2[3][3]); -void copy_m3_m4(float m1[3][3], float m2[4][4]); -void adjoint_m3_m3(float m1[3][3], float m[3][3]); -float determinant_m3_array(float m[3][3]); -bool invert_m3_m3(float m1[3][3], float m2[3][3]); -bool invert_m3(float m[3][3]); -void transpose_m3(float mat[3][3]); -} - -#define MAX_LIGHTS 8 -#define SUPPORT_COLOR_MATERIAL - -typedef struct Light { - float position[4]; - float ambient[4]; - float diffuse[4]; - float specular[4]; - float spot_direction[4]; -#ifdef SUPPORT_COLOR_MATERIAL - float constant_attenuation; - float linear_attenuation; - float quadratic_attenuation; - float spot_cutoff; - float spot_exponent; - float spot_cos_cutoff; - float pad, pad2; -#endif -} Light; - -typedef struct Lighting { - Light lights[MAX_LIGHTS]; - int num_enabled; -} Lighting; - -typedef struct Transform { - float projection_matrix[16]; - float model_view_matrix[16]; - float normal_matrix[9]; -} Transform; - -static bool g_use_osd_glsl = false; -static int g_active_uv_index = 0; - -static GLuint g_flat_fill_solid_program = 0; -static GLuint g_flat_fill_texture2d_program = 0; -static GLuint g_smooth_fill_solid_program = 0; -static GLuint g_smooth_fill_texture2d_program = 0; - -static GLuint g_flat_fill_solid_shadeless_program = 0; -static GLuint g_flat_fill_texture2d_shadeless_program = 0; -static GLuint g_smooth_fill_solid_shadeless_program = 0; -static GLuint g_smooth_fill_texture2d_shadeless_program = 0; - -static GLuint g_wireframe_program = 0; - -static GLuint g_lighting_ub = 0; -static Lighting g_lighting_data; -static Transform g_transform; - -struct OpenSubdiv_GLMeshFVarData -{ - OpenSubdiv_GLMeshFVarData() : - texture_buffer(0), offset_buffer(0) { - } - - ~OpenSubdiv_GLMeshFVarData() - { - Release(); - } - - void Release() - { - if (texture_buffer) { - glDeleteTextures(1, &texture_buffer); - } - if (offset_buffer) { - glDeleteTextures(1, &offset_buffer); - } - texture_buffer = 0; - offset_buffer = 0; - fvar_width = 0; - channel_offsets.clear(); - } - - void Create(const OpenSubdiv::Far::TopologyRefiner *refiner, - const OpenSubdiv::Far::PatchTable *patch_table, - int fvar_width, - const float *fvar_src_data) - { - Release(); - - this->fvar_width = fvar_width; - - /* Expand fvar data to per-patch array */ - const int max_level = refiner->GetMaxLevel(); - const int num_channels = patch_table->GetNumFVarChannels(); - std::vector data; - int fvar_data_offset = 0; - channel_offsets.resize(num_channels); - for (int channel = 0; channel < num_channels; ++channel) { - OpenSubdiv::Far::ConstIndexArray indices = - patch_table->GetFVarValues(channel); - - channel_offsets[channel] = data.size(); - data.reserve(data.size() + indices.size() * fvar_width); - - for (int fvert = 0; fvert < (int)indices.size(); ++fvert) { - int index = indices[fvert] * fvar_width; - for (int i = 0; i < fvar_width; ++i) { - data.push_back(fvar_src_data[fvar_data_offset + index++]); - } - } - if (refiner->IsUniform()) { - const int num_values_max = refiner->GetLevel(max_level).GetNumFVarValues(channel); - fvar_data_offset += num_values_max * fvar_width; - } else { - const int num_values_total = refiner->GetNumFVarValuesTotal(channel); - fvar_data_offset += num_values_total * fvar_width; - } - } - - GLuint buffer; - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, data.size()*sizeof(float), - &data[0], GL_STATIC_DRAW); - - glGenTextures(1, &texture_buffer); - glBindTexture(GL_TEXTURE_BUFFER, texture_buffer); - glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, buffer); - - glDeleteBuffers(1, &buffer); - - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, channel_offsets.size()*sizeof(int), - &channel_offsets[0], GL_STATIC_DRAW); - - glGenTextures(1, &offset_buffer); - glBindTexture(GL_TEXTURE_BUFFER, offset_buffer); - glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer); - glBindTexture(GL_TEXTURE_BUFFER, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - } - GLuint texture_buffer; - GLuint offset_buffer; - std::vector channel_offsets; - int fvar_width; -}; - -namespace { - -GLuint compileShader(GLenum shaderType, - const char *version, - const char *define, - const char *source) -{ - const char *sources[] = { - version, - define, -#ifdef SUPPORT_COLOR_MATERIAL - "#define SUPPORT_COLOR_MATERIAL\n", -#else - "", -#endif - source, - }; - - GLuint shader = glCreateShader(shaderType); - glShaderSource(shader, 4, sources, NULL); - glCompileShader(shader); - - GLint status; - glGetShaderiv(shader, GL_COMPILE_STATUS, &status); - if (status == GL_FALSE) { - GLchar emsg[1024]; - glGetShaderInfoLog(shader, sizeof(emsg), 0, emsg); - fprintf(stderr, "Error compiling GLSL: %s\n", emsg); - fprintf(stderr, "Version: %s\n", version); - fprintf(stderr, "Defines: %s\n", define); - fprintf(stderr, "Source: %s\n", source); - return 0; - } - - return shader; -} - -GLuint linkProgram(const char *version, const char *define) -{ - GLuint vertexShader = compileShader(GL_VERTEX_SHADER, - version, - define, - datatoc_gpu_shader_opensubdiv_vertex_glsl); - if (vertexShader == 0) { - return 0; - } - GLuint geometryShader = compileShader(GL_GEOMETRY_SHADER, - version, - define, - datatoc_gpu_shader_opensubdiv_geometry_glsl); - if (geometryShader == 0) { - return 0; - } - GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER, - version, - define, - datatoc_gpu_shader_opensubdiv_fragment_glsl ); - if (fragmentShader == 0) { - return 0; - } - - GLuint program = glCreateProgram(); - - glAttachShader(program, vertexShader); - glAttachShader(program, geometryShader); - glAttachShader(program, fragmentShader); - - glBindAttribLocation(program, 0, "position"); - glBindAttribLocation(program, 1, "normal"); - - glLinkProgram(program); - - glDeleteShader(vertexShader); - glDeleteShader(geometryShader); - glDeleteShader(fragmentShader); - - GLint status; - glGetProgramiv(program, GL_LINK_STATUS, &status); - if (status == GL_FALSE) { - GLchar emsg[1024]; - glGetProgramInfoLog(program, sizeof(emsg), 0, emsg); - fprintf(stderr, "Error linking GLSL program : %s\n", emsg); - fprintf(stderr, "Defines: %s\n", define); - glDeleteProgram(program); - return 0; - } - - glUniformBlockBinding(program, - glGetUniformBlockIndex(program, "Lighting"), - 0); - - if (GLEW_VERSION_4_1) { - glProgramUniform1i(program, - glGetUniformLocation(program, "texture_buffer"), - 0); /* GL_TEXTURE0 */ - - glProgramUniform1i(program, - glGetUniformLocation(program, "FVarDataOffsetBuffer"), - 30); /* GL_TEXTURE30 */ - - glProgramUniform1i(program, - glGetUniformLocation(program, "FVarDataBuffer"), - 31); /* GL_TEXTURE31 */ - } - else { - glUseProgram(program); - glUniform1i(glGetUniformLocation(program, "texture_buffer"), 0); /* GL_TEXTURE0 */ - glUniform1i(glGetUniformLocation(program, "FVarDataOffsetBuffer"), 30); /* GL_TEXTURE30 */ - glUniform1i(glGetUniformLocation(program, "FVarDataBuffer"), 31); /* GL_TEXTURE31 */ - glUseProgram(0); - } - - return program; -} - -void bindProgram(OpenSubdiv_GLMesh *gl_mesh, int program) -{ - glUseProgram(program); - - /* Matrices */ - glUniformMatrix4fv(glGetUniformLocation(program, "modelViewMatrix"), - 1, false, - g_transform.model_view_matrix); - glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), - 1, false, - g_transform.projection_matrix); - glUniformMatrix3fv(glGetUniformLocation(program, "normalMatrix"), - 1, false, - g_transform.normal_matrix); - - /* Lighting */ - glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub); - glBufferSubData(GL_UNIFORM_BUFFER, - 0, sizeof(g_lighting_data), &g_lighting_data); - glBindBuffer(GL_UNIFORM_BUFFER, 0); - - glBindBufferBase(GL_UNIFORM_BUFFER, 0, g_lighting_ub); - - /* Color */ - { - /* TODO: stop using glGetMaterial */ - float color[4]; - glGetMaterialfv(GL_FRONT, GL_DIFFUSE, color); - glUniform4fv(glGetUniformLocation(program, "diffuse"), 1, color); - - glGetMaterialfv(GL_FRONT, GL_SPECULAR, color); - glUniform4fv(glGetUniformLocation(program, "specular"), 1, color); - - glGetMaterialfv(GL_FRONT, GL_SHININESS, color); - glUniform1f(glGetUniformLocation(program, "shininess"), color[0]); - } - - /* Face-vertex data */ - if (gl_mesh->fvar_data != NULL) { - if (gl_mesh->fvar_data->texture_buffer) { - glActiveTexture(GL_TEXTURE31); - glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->texture_buffer); - glActiveTexture(GL_TEXTURE0); - } - - if (gl_mesh->fvar_data->offset_buffer) { - glActiveTexture(GL_TEXTURE30); - glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->offset_buffer); - glActiveTexture(GL_TEXTURE0); - } - - glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), - gl_mesh->fvar_data->fvar_width); - if (gl_mesh->fvar_data->channel_offsets.size() > 0 && - g_active_uv_index >= 0) - { - glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), - gl_mesh->fvar_data->channel_offsets[g_active_uv_index]); - } else { - glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); - } - } else { - glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0); - glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); - } -} - -} /* namespace */ - -bool openSubdiv_osdGLDisplayInit(void) -{ - static bool need_init = true; - static bool init_success = false; - - if (need_init) { - /* TODO: update OSD drawing to OpenGL 3.3 core, then remove following line */ - return false; - - const char *version = ""; - if (GLEW_VERSION_3_2) { - version = "#version 150 compatibility\n"; - } - else if (GLEW_VERSION_3_1) { - version = "#version 140\n" - "#extension GL_ARB_compatibility: enable\n"; - } - else { - version = "#version 130\n"; - /* minimum supported for OpenSubdiv */ - } - - g_flat_fill_solid_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_LIGHTING\n" - "#define FLAT_SHADING\n"); - g_flat_fill_texture2d_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_LIGHTING\n" - "#define USE_TEXTURE_2D\n" - "#define FLAT_SHADING\n"); - g_smooth_fill_solid_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_LIGHTING\n" - "#define SMOOTH_SHADING\n"); - g_smooth_fill_texture2d_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_LIGHTING\n" - "#define USE_TEXTURE_2D\n" - "#define SMOOTH_SHADING\n"); - - g_flat_fill_solid_shadeless_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define FLAT_SHADING\n"); - g_flat_fill_texture2d_shadeless_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_TEXTURE_2D\n" - "#define FLAT_SHADING\n"); - g_smooth_fill_solid_shadeless_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define SMOOTH_SHADING\n"); - g_smooth_fill_texture2d_shadeless_program = linkProgram( - version, - "#define USE_COLOR_MATERIAL\n" - "#define USE_TEXTURE_2D\n" - "#define SMOOTH_SHADING\n"); - - g_wireframe_program = linkProgram( - version, - "#define WIREFRAME\n"); - - glGenBuffers(1, &g_lighting_ub); - glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub); - glBufferData(GL_UNIFORM_BUFFER, - sizeof(g_lighting_data), NULL, GL_STATIC_DRAW); - - need_init = false; - init_success = g_flat_fill_solid_program != 0 && - g_flat_fill_texture2d_program != 0 && - g_smooth_fill_solid_program != 0 && - g_smooth_fill_texture2d_program != 0 && - g_wireframe_program; - } - return init_success; -} - -void openSubdiv_osdGLDisplayDeinit(void) -{ - if (g_lighting_ub != 0) { - glDeleteBuffers(1, &g_lighting_ub); - } -#define SAFE_DELETE_PROGRAM(program) \ - do { \ - if (program) { \ - glDeleteProgram(program); \ - } \ - } while (false) - - SAFE_DELETE_PROGRAM(g_flat_fill_solid_program); - SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_program); - SAFE_DELETE_PROGRAM(g_smooth_fill_solid_program); - SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_program); - SAFE_DELETE_PROGRAM(g_flat_fill_solid_shadeless_program); - SAFE_DELETE_PROGRAM(g_flat_fill_texture2d_shadeless_program); - SAFE_DELETE_PROGRAM(g_smooth_fill_solid_shadeless_program); - SAFE_DELETE_PROGRAM(g_smooth_fill_texture2d_shadeless_program); - SAFE_DELETE_PROGRAM(g_wireframe_program); - -#undef SAFE_DELETE_PROGRAM -} - -void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl, - int active_uv_index) -{ - g_active_uv_index = active_uv_index; - g_use_osd_glsl = (use_osd_glsl != 0); - - /* Update transformation matrices. */ - glGetFloatv(GL_PROJECTION_MATRIX, g_transform.projection_matrix); - glGetFloatv(GL_MODELVIEW_MATRIX, g_transform.model_view_matrix); - - copy_m3_m4((float (*)[3])g_transform.normal_matrix, - (float (*)[4])g_transform.model_view_matrix); - invert_m3((float (*)[3])g_transform.normal_matrix); - transpose_m3((float (*)[3])g_transform.normal_matrix); - - /* Update OpenGL lights positions, colors etc. */ - g_lighting_data.num_enabled = 0; - for (int i = 0; i < MAX_LIGHTS; ++i) { - GLboolean enabled; - glGetBooleanv(GL_LIGHT0 + i, &enabled); - if (enabled) { - g_lighting_data.num_enabled++; - } - - /* TODO: stop using glGetLight */ - glGetLightfv(GL_LIGHT0 + i, - GL_POSITION, - g_lighting_data.lights[i].position); - glGetLightfv(GL_LIGHT0 + i, - GL_AMBIENT, - g_lighting_data.lights[i].ambient); - glGetLightfv(GL_LIGHT0 + i, - GL_DIFFUSE, - g_lighting_data.lights[i].diffuse); - glGetLightfv(GL_LIGHT0 + i, - GL_SPECULAR, - g_lighting_data.lights[i].specular); - glGetLightfv(GL_LIGHT0 + i, - GL_SPOT_DIRECTION, - g_lighting_data.lights[i].spot_direction); -#ifdef SUPPORT_COLOR_MATERIAL - glGetLightfv(GL_LIGHT0 + i, - GL_CONSTANT_ATTENUATION, - &g_lighting_data.lights[i].constant_attenuation); - glGetLightfv(GL_LIGHT0 + i, - GL_LINEAR_ATTENUATION, - &g_lighting_data.lights[i].linear_attenuation); - glGetLightfv(GL_LIGHT0 + i, - GL_QUADRATIC_ATTENUATION, - &g_lighting_data.lights[i].quadratic_attenuation); - glGetLightfv(GL_LIGHT0 + i, - GL_SPOT_CUTOFF, - &g_lighting_data.lights[i].spot_cutoff); - glGetLightfv(GL_LIGHT0 + i, - GL_SPOT_EXPONENT, - &g_lighting_data.lights[i].spot_exponent); - g_lighting_data.lights[i].spot_cos_cutoff = - cos(g_lighting_data.lights[i].spot_cutoff); -#endif - } -} - -static GLuint prepare_patchDraw(OpenSubdiv_GLMesh *gl_mesh, - bool fill_quads) -{ - GLint program = 0; - if (!g_use_osd_glsl) { - glGetIntegerv(GL_CURRENT_PROGRAM, &program); - if (program) { - GLint model; - glGetIntegerv(GL_SHADE_MODEL, &model); - - GLint location = glGetUniformLocation(program, "osd_flat_shading"); - if (location != -1) { - glUniform1i(location, model == GL_FLAT); - } - - /* Face-vertex data */ - if (gl_mesh->fvar_data != NULL) { - if (gl_mesh->fvar_data->texture_buffer) { - glActiveTexture(GL_TEXTURE31); - glBindTexture(GL_TEXTURE_BUFFER, - gl_mesh->fvar_data->texture_buffer); - glActiveTexture(GL_TEXTURE0); - } - - if (gl_mesh->fvar_data->offset_buffer) { - glActiveTexture(GL_TEXTURE30); - glBindTexture(GL_TEXTURE_BUFFER, - gl_mesh->fvar_data->offset_buffer); - glActiveTexture(GL_TEXTURE0); - } - - GLint location = glGetUniformLocation(program, "osd_fvar_count"); - if (location != -1) { - glUniform1i(location, gl_mesh->fvar_data->fvar_width); - } - - location = glGetUniformLocation(program, "osd_active_uv_offset"); - if (location != -1) { - if (gl_mesh->fvar_data->channel_offsets.size() > 0 && - g_active_uv_index >= 0) - { - glUniform1i(location, - gl_mesh->fvar_data->channel_offsets[g_active_uv_index]); - } else { - glUniform1i(location, 0); - } - } - } else { - glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0); - glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0); - } - } - return program; - } - - if (fill_quads) { - int model; - GLboolean use_texture_2d; - glGetIntegerv(GL_SHADE_MODEL, &model); - glGetBooleanv(GL_TEXTURE_2D, &use_texture_2d); - - if (model == GL_FLAT) { - if (use_texture_2d) { - program = g_flat_fill_texture2d_program; - } - else { - program = g_flat_fill_solid_program; - } - } - else { - if (use_texture_2d) { - program = g_smooth_fill_texture2d_program; - } - else { - program = g_smooth_fill_solid_program; - } - } - - } - else { - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - program = g_wireframe_program; - } - - bindProgram(gl_mesh, program); - - return program; -} - -static void perform_drawElements(GLuint program, - int patch_index, - int num_elements, - int start_element) -{ - if (program) { - glUniform1i(glGetUniformLocation(program, "PrimitiveIdBase"), - patch_index); - } - glDrawElements(GL_LINES_ADJACENCY, - num_elements, - GL_UNSIGNED_INT, - (void *)(start_element * sizeof(unsigned int))); -} - -static void finish_patchDraw(bool fill_quads) -{ - /* TODO(sergey): Some of the stuff could be done once after the whole - * mesh is displayed. - */ - - /* Restore state. */ - if (!fill_quads) { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - glBindVertexArray(0); - - if (g_use_osd_glsl) { - /* TODO(sergey): Store previously used program and roll back to it? */ - glUseProgram(0); - } -} - -static void draw_partition_patches_range(GLMeshInterface *mesh, - GLuint program, - int start_patch, - int num_patches) -{ - int traversed_patches = 0, num_remained_patches = num_patches; - const OpenSubdiv::Osd::PatchArrayVector& patches = - mesh->GetPatchTable()->GetPatchArrays(); - for (int i = 0; i < (int)patches.size(); ++i) { - const OpenSubdiv::Osd::PatchArray& patch = patches[i]; - OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor(); - OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType(); - - if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) { - const int num_block_patches = patch.GetNumPatches(); - if (start_patch >= traversed_patches && - start_patch < traversed_patches + num_block_patches) - { - const int num_control_verts = desc.GetNumControlVertices(); - const int start_draw_patch = start_patch - traversed_patches; - const int num_draw_patches = std::min(num_remained_patches, - num_block_patches - start_draw_patch); - perform_drawElements(program, - i + start_draw_patch, - num_draw_patches * num_control_verts, - patch.GetIndexBase() + start_draw_patch * num_control_verts); - num_remained_patches -= num_draw_patches; - } - if (num_remained_patches == 0) { - break; - } - traversed_patches += num_block_patches; - } - } -} - -static void draw_all_patches(GLMeshInterface *mesh, - GLuint program) -{ - const OpenSubdiv::Osd::PatchArrayVector& patches = - mesh->GetPatchTable()->GetPatchArrays(); - for (int i = 0; i < (int)patches.size(); ++i) { - const OpenSubdiv::Osd::PatchArray& patch = patches[i]; - OpenSubdiv::Far::PatchDescriptor desc = patch.GetDescriptor(); - OpenSubdiv::Far::PatchDescriptor::Type patchType = desc.GetType(); - - if (patchType == OpenSubdiv::Far::PatchDescriptor::QUADS) { - perform_drawElements(program, - i, - patch.GetNumPatches() * desc.GetNumControlVertices(), - patch.GetIndexBase()); - } - } -} - -void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh, - int fill_quads, - int start_patch, - int num_patches) -{ - GLMeshInterface *mesh = - (GLMeshInterface *)(gl_mesh->descriptor); - - /* Make sure all global invariants are initialized. */ - if (!openSubdiv_osdGLDisplayInit()) { - return; - } - - /* Setup GLSL/OpenGL to draw patches in current context. */ - GLuint program = prepare_patchDraw(gl_mesh, fill_quads != 0); - - if (start_patch != -1) { - draw_partition_patches_range(mesh, - program, - start_patch, - num_patches); - } - else { - draw_all_patches(mesh, program); - } - - /* Finish patch drawing by restoring all changes to the OpenGL context. */ - finish_patchDraw(fill_quads != 0); -} - -void openSubdiv_osdGLAllocFVar(OpenSubdiv_TopologyRefinerDescr *topology_refiner, - OpenSubdiv_GLMesh *gl_mesh, - const float *fvar_data) -{ - GLMeshInterface *mesh = - (GLMeshInterface *)(gl_mesh->descriptor); - gl_mesh->fvar_data = OBJECT_GUARDED_NEW(OpenSubdiv_GLMeshFVarData); - gl_mesh->fvar_data->Create(topology_refiner->osd_refiner, - mesh->GetFarPatchTable(), - 2, - fvar_data); -} - -void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh) -{ - if (gl_mesh->fvar_data != NULL) { - OBJECT_GUARDED_DELETE(gl_mesh->fvar_data, OpenSubdiv_GLMeshFVarData); - } -} -- cgit v1.2.3 From e1423391621dcc72e55144541cb26b540698edba Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 12:55:39 +0200 Subject: Fix compilation with older OpenSubdiv libraries Only fixes compilation error, the functionality will be limited. Currently we don't care that much, since all the work is done in the branch anyway. Later on when we'll know which fixes we need to apply on top of latest OpenSubdiv library we will call a library upgrade. --- intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc index 595df3eaa75..d593518405f 100644 --- a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc +++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include "MEM_guardedalloc.h" @@ -52,6 +53,13 @@ using OpenSubdiv::Far::StencilTable; using OpenSubdiv::Far::StencilTableFactory; using OpenSubdiv::Far::TopologyRefiner; +// TODO(sergey): Remove after official requirement bump for OSD version. +#if OPENSUBDIV_VERSION_NUMBER >= 30200 +# define OPENSUBDIV_HAS_FVAR_EVALUATION +#else +# undef OPENSUBDIV_HAS_FVAR_EVALUATION +#endif + namespace opensubdiv_capi { namespace { @@ -652,6 +660,7 @@ OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal( StencilTableFactory::Create(*refiner, varying_stencil_options); // Face warying stencil. const StencilTable* face_varying_stencils = NULL; +#ifdef OPENSUBDIV_HAS_FVAR_EVALUATION if (has_face_varying_data) { StencilTableFactory::Options face_varying_stencil_options; face_varying_stencil_options.generateOffsets = true; @@ -664,6 +673,7 @@ OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal( face_varying_stencils = StencilTableFactory::Create(*refiner, face_varying_stencil_options); } +#endif // Generate bi-cubic patch table for the limit surface. // TODO(sergey): Ideally we would want to expose end-cap settings via // C-API to make it more generic. Currently it matches old Blender's @@ -694,6 +704,7 @@ OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal( delete varying_stencils; varying_stencils = table; } +#ifdef OPENSUBDIV_HAS_FVAR_EVALUATION const StencilTable* local_point_face_varying_stencil_table = patch_table->GetLocalPointFaceVaryingStencilTable(); if (local_point_face_varying_stencil_table != NULL) { @@ -705,6 +716,7 @@ OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal( delete face_varying_stencils; face_varying_stencils = table; } +#endif // Create OpenSubdiv's CPU side evaluator. // TODO(sergey): Make it possible to use different evaluators. opensubdiv_capi::CpuEvalOutput* eval_output = -- cgit v1.2.3 From 80795ff8976fabb210ef139f94d60a9e1080c8ce Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 16 Jul 2018 14:34:24 +0200 Subject: Buildbot: update for new VS2017 buildbot worker name. --- build_files/buildbot/slave_compile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index c43bb88b270..bf8f9f15751 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -78,7 +78,7 @@ if 'cmake' in builder: # cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc') elif builder.startswith('win'): - if builder.endswith('_vc2017'): + if builder.endswith('_vs2017'): if builder.startswith('win64'): cmake_options.extend(['-G', 'Visual Studio 15 2017 Win64']) elif builder.startswith('win32'): -- cgit v1.2.3 From 96b4e43e8dcdf3c051be2b52bb453c55d6afcd08 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 16 Jul 2018 09:37:24 +0200 Subject: Fix T55527: creating a Quaternion without args should result in identity quaternion Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D3487 --- source/blender/python/mathutils/mathutils_Quaternion.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 1a6fd0ee86f..48c18dd20c1 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -1100,7 +1100,8 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw { PyObject *seq = NULL; double angle = 0.0f; - float quat[QUAT_SIZE] = {0.0f, 0.0f, 0.0f, 0.0f}; + float quat[QUAT_SIZE]; + unit_qt(quat); if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, -- cgit v1.2.3 From 43f0af734e42d7e539cbb68ebf390b97016048bb Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 16 Jul 2018 09:48:52 +0200 Subject: Fix T55944: fbx export error with smoothing face ddee0931b868 added PROP_RAW_BOOLEAN case for foreach_set, but missed foreach_get Reviewed By: brecht Differential Revision: https://developer.blender.org/D3534 --- source/blender/python/intern/bpy_rna.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 80b0aa7a51b..28a6a4f7fb0 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -5047,6 +5047,9 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) case PROP_RAW_DOUBLE: item = PyFloat_FromDouble((double) ((double *)array)[i]); break; + case PROP_RAW_BOOLEAN: + item = PyBool_FromLong((long) ((bool *)array)[i]); + break; default: /* PROP_RAW_UNSET */ /* should never happen */ BLI_assert(!"Invalid array type - get"); -- cgit v1.2.3 From 20f3cbfb78b37fdc201d30be52a249cd08fa5d83 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 15:37:27 +0200 Subject: Cleanup: More clear naming in UV vertex/element mappings Also use unsigned short for loop index within a polygon for UV vertex mapping, which matches UV element mapping. --- source/blender/blenkernel/BKE_mesh_mapping.h | 12 ++++++--- source/blender/blenkernel/intern/mesh_mapping.c | 10 ++++---- source/blender/blenkernel/intern/subsurf_ccg.c | 6 ++--- source/blender/editors/mesh/editmesh_utils.c | 18 ++++++------- source/blender/editors/uvedit/uvedit_ops.c | 30 +++++++++++----------- .../blender/editors/uvedit/uvedit_smart_stitch.c | 9 ++++--- 6 files changed, 45 insertions(+), 40 deletions(-) diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index b5b5443574c..aedffb17ae6 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -50,8 +50,12 @@ typedef struct UvVertMap { typedef struct UvMapVert { struct UvMapVert *next; - unsigned int f; - unsigned char tfindex, separate, flag; + unsigned int poly_index; + unsigned short loop_of_poly_index; + bool separate; + /* Zero-ed by map creation, left for use by specific areas. Is not + * initialized to anything. */ + unsigned char flag; } UvMapVert; /* UvElement stores per uv information so that we can quickly access information for a uv. @@ -63,9 +67,9 @@ typedef struct UvElement { /* Face the element belongs to */ struct BMLoop *l; /* index in loop. */ - unsigned short tfindex; + unsigned short loop_of_poly_index; /* Whether this element is the first of coincident elements */ - unsigned char separate; + bool separate; /* general use flag */ unsigned char flag; /* If generating element map with island sorting, this stores the island index */ diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c index 699d6bce2b0..953d3ff2f96 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.c +++ b/source/blender/blenkernel/intern/mesh_mapping.c @@ -103,8 +103,8 @@ UvVertMap *BKE_mesh_uv_vert_map_create( nverts = mp->totloop; for (i = 0; i < nverts; i++) { - buf->tfindex = (unsigned char)i; - buf->f = a; + buf->loop_of_poly_index = (unsigned short)i; + buf->poly_index = a; buf->separate = 0; buf->next = vmap->vert[mloop[mp->loopstart + i].v]; vmap->vert[mloop[mp->loopstart + i].v] = buf; @@ -134,19 +134,19 @@ UvVertMap *BKE_mesh_uv_vert_map_create( v->next = newvlist; newvlist = v; - uv = mloopuv[mpoly[v->f].loopstart + v->tfindex].uv; + uv = mloopuv[mpoly[v->poly_index].loopstart + v->loop_of_poly_index].uv; lastv = NULL; iterv = vlist; while (iterv) { next = iterv->next; - uv2 = mloopuv[mpoly[iterv->f].loopstart + iterv->tfindex].uv; + uv2 = mloopuv[mpoly[iterv->poly_index].loopstart + iterv->loop_of_poly_index].uv; sub_v2_v2v2(uvdiff, uv2, uv); if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1] && - (!use_winding || winding[iterv->f] == winding[v->f])) + (!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) { if (lastv) lastv->next = next; else vlist = next; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 1f1270b85b6..dadffbf8fb4 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -285,11 +285,11 @@ static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct ML for (nv = v = BKE_mesh_uv_vert_map_get_vert(vmap, ml[j].v); v; v = v->next) { if (v->separate) nv = v; - if (v->f == fi) + if (v->poly_index == fi) break; } - fverts[j] = SET_UINT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex); + fverts[j] = SET_UINT_IN_POINTER(mpoly[nv->poly_index].loopstart + nv->loop_of_poly_index); } } @@ -337,7 +337,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i); v; v = v->next) { if (v->separate) { CCGVert *ssv; - int loopid = mpoly[v->f].loopstart + v->tfindex; + int loopid = mpoly[v->poly_index].loopstart + v->loop_of_poly_index; CCGVertHDL vhdl = SET_INT_IN_POINTER(loopid); copy_v2_v2(uv, mloopuv[loopid].uv); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 250d8ca23c1..7a344be8e5a 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -561,8 +561,8 @@ UvVertMap *BM_uv_vert_map_create( } BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i) { - buf->tfindex = i; - buf->f = a; + buf->loop_of_poly_index = i; + buf->poly_index = a; buf->separate = 0; buf->next = vmap->vert[BM_elem_index_get(l->v)]; @@ -593,10 +593,10 @@ UvVertMap *BM_uv_vert_map_create( v->next = newvlist; newvlist = v; - efa = BM_face_at_index(bm, v->f); + efa = BM_face_at_index(bm, v->poly_index); /* tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ - l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, v->tfindex); + l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, v->loop_of_poly_index); luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv = luv->uv; @@ -605,17 +605,17 @@ UvVertMap *BM_uv_vert_map_create( while (iterv) { next = iterv->next; - efa = BM_face_at_index(bm, iterv->f); + efa = BM_face_at_index(bm, iterv->poly_index); /* tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ - l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, iterv->tfindex); + l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, iterv->loop_of_poly_index); luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv2 = luv->uv; sub_v2_v2v2(uvdiff, uv2, uv); if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1] && - (!use_winding || winding[iterv->f] == winding[v->f])) + (!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) { if (lastv) lastv->next = next; else vlist = next; @@ -712,7 +712,7 @@ UvElementMap *BM_uv_element_map_create( buf->l = l; buf->separate = 0; buf->island = INVALID_ISLAND; - buf->tfindex = i; + buf->loop_of_poly_index = i; buf->next = element_map->vert[BM_elem_index_get(l->v)]; element_map->vert[BM_elem_index_get(l->v)] = buf; @@ -825,7 +825,7 @@ UvElementMap *BM_uv_element_map_create( map[element - element_map->buf] = islandbufsize; islandbuf[islandbufsize].l = element->l; islandbuf[islandbufsize].separate = element->separate; - islandbuf[islandbufsize].tfindex = element->tfindex; + islandbuf[islandbufsize].loop_of_poly_index = element->loop_of_poly_index; islandbuf[islandbufsize].island = nislands; islandbufsize++; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 3aacd9b4605..375dda7dd6a 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1043,7 +1043,7 @@ static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa for (iterv = first; iterv; iterv = iterv->next) { if (iterv->separate) first = iterv; - if (iterv->f == BM_elem_index_get(efa)) + if (iterv->poly_index == BM_elem_index_get(efa)) return first; } @@ -1065,9 +1065,9 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, if (iterv2->separate && iterv2 != first2) break; - if (iterv1->f == iterv2->f) { + if (iterv1->poly_index == iterv2->poly_index) { /* if face already tagged, don't do this edge */ - efa = BM_face_at_index(em->bm, iterv1->f); + efa = BM_face_at_index(em->bm, iterv1->poly_index); if (BM_elem_flag_test(efa, BM_ELEM_TAG)) return false; @@ -1091,8 +1091,8 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, if (iterv2->separate && iterv2 != first2) break; - if (iterv1->f == iterv2->f) { - efa = BM_face_at_index(em->bm, iterv1->f); + if (iterv1->poly_index == iterv2->poly_index) { + efa = BM_face_at_index(em->bm, iterv1->poly_index); BM_elem_flag_enable(efa, BM_ELEM_TAG); break; } @@ -1301,16 +1301,16 @@ static void uv_select_linked( for (iterv = vlist; iterv; iterv = iterv->next) { if (iterv->separate) startv = iterv; - if (iterv->f == a) + if (iterv->poly_index == a) break; } for (iterv = startv; iterv; iterv = iterv->next) { if ((startv != iterv) && (iterv->separate)) break; - else if (!flag[iterv->f]) { - flag[iterv->f] = 1; - stack[stacksize] = iterv->f; + else if (!flag[iterv->poly_index]) { + flag[iterv->poly_index] = 1; + stack[stacksize] = iterv->poly_index; stacksize++; } } @@ -2750,7 +2750,7 @@ static void uv_select_flush_from_tag_sticky_loc_internal( if (vlist_iter->separate) start_vlist = vlist_iter; - if (efa_index == vlist_iter->f) + if (efa_index == vlist_iter->poly_index) break; vlist_iter = vlist_iter->next; @@ -2762,12 +2762,12 @@ static void uv_select_flush_from_tag_sticky_loc_internal( if (vlist_iter != start_vlist && vlist_iter->separate) break; - if (efa_index != vlist_iter->f) { + if (efa_index != vlist_iter->poly_index) { BMLoop *l_other; - efa_vlist = BM_face_at_index(em->bm, vlist_iter->f); + efa_vlist = BM_face_at_index(em->bm, vlist_iter->poly_index); /* tf_vlist = BM_ELEM_CD_GET_VOID_P(efa_vlist, cd_poly_tex_offset); */ /* UNUSED */ - l_other = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex); + l_other = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->loop_of_poly_index); uvedit_uv_select_set(em, scene, l_other, select, false, cd_loop_uv_offset); } @@ -4241,14 +4241,14 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op) v1coincident = 0; separated2 = 0; - efa1 = BM_face_at_index(bm, mv1->f); + efa1 = BM_face_at_index(bm, mv1->poly_index); mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)]; for (mv2 = mvinit2; mv2; mv2 = mv2->next) { if (mv2->separate) mv2sep = mv2; - efa2 = BM_face_at_index(bm, mv2->f); + efa2 = BM_face_at_index(bm, mv2->poly_index); if (efa1 == efa2) { /* if v1 is not coincident no point in comparing */ if (v1coincident) { diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index e4452af4790..0b768350942 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -483,9 +483,10 @@ static void stitch_calculate_island_snapping( int face_preview_pos = preview_position[BM_elem_index_get(element->l->f)].data_position; stitch_uv_rotate(rotation_mat, island_stitch_data[i].medianPoint, - preview->preview_polys + face_preview_pos + 2 * element->tfindex, state->aspect); + preview->preview_polys + face_preview_pos + 2 * element->loop_of_poly_index, + state->aspect); - add_v2_v2(preview->preview_polys + face_preview_pos + 2 * element->tfindex, + add_v2_v2(preview->preview_polys + face_preview_pos + 2 * element->loop_of_poly_index, island_stitch_data[i].translation); } } @@ -901,7 +902,7 @@ static void stitch_propagate_uv_final_position( else { int face_preview_pos = preview_position[BM_elem_index_get(element_iter->l->f)].data_position; if (face_preview_pos != STITCH_NO_PREVIEW) { - copy_v2_v2(preview->preview_polys + face_preview_pos + 2 * element_iter->tfindex, + copy_v2_v2(preview->preview_polys + face_preview_pos + 2 * element_iter->loop_of_poly_index, final_position[index].uv); } } @@ -2013,7 +2014,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished) RNA_collection_add(op->ptr, "selection", &itemptr); RNA_int_set(&itemptr, "face_index", BM_elem_index_get(element->l->f)); - RNA_int_set(&itemptr, "element_index", element->tfindex); + RNA_int_set(&itemptr, "element_index", element->loop_of_poly_index); } uvedit_live_unwrap_update(sima, scene, obedit); -- cgit v1.2.3 From 72d1fb993445b6233e6d905c867625586bf62bfe Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 15:58:12 +0200 Subject: Cleanup: Use const qualifier for UV vertex map --- source/blender/blenkernel/BKE_mesh_mapping.h | 6 +++--- source/blender/blenkernel/intern/mesh_mapping.c | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index aedffb17ae6..1005a50a214 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -104,9 +104,9 @@ typedef struct MeshElemMap { /* mapping */ UvVertMap *BKE_mesh_uv_vert_map_create( - struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, - unsigned int totpoly, unsigned int totvert, - const float limit[2], const bool selected, const bool use_winding); + const struct MPoly *mpoly, const struct MLoop *mloop, const struct MLoopUV *mloopuv, + unsigned int totpoly, unsigned int totvert, const float limit[2], + const bool selected, const bool use_winding); UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v); void BKE_mesh_uv_vert_map_free(UvVertMap *vmap); diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c index 953d3ff2f96..5c9849f6b74 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.c +++ b/source/blender/blenkernel/intern/mesh_mapping.c @@ -55,13 +55,13 @@ * but for now this replaces it because its unused. */ UvVertMap *BKE_mesh_uv_vert_map_create( - struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, + const MPoly *mpoly, const MLoop *mloop, const MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, const float limit[2], const bool selected, const bool use_winding) { UvVertMap *vmap; UvMapVert *buf; - MPoly *mp; + const MPoly *mp; unsigned int a; int i, totuv, nverts; @@ -126,7 +126,8 @@ UvVertMap *BKE_mesh_uv_vert_map_create( for (a = 0; a < totvert; a++) { UvMapVert *newvlist = NULL, *vlist = vmap->vert[a]; UvMapVert *iterv, *v, *lastv, *next; - float *uv, *uv2, uvdiff[2]; + const float *uv, *uv2; + float uvdiff[2]; while (vlist) { v = vlist; -- cgit v1.2.3 From 1e1c858cf1bf900f0876b13f922beb0e2aeb0e8c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 16:15:57 +0200 Subject: Cleanup: Remove obscure flag which was only used for read in subsurf code Some sort of rudiment from many years ago, is never set by 2.5x code. --- source/blender/blenkernel/intern/subsurf_ccg.c | 15 +++------------ source/blender/makesdna/DNA_meshdata_types.h | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index dadffbf8fb4..e08560cccac 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -297,7 +297,6 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, { MPoly *mpoly = dm->getPolyArray(dm); MLoop *mloop = dm->getLoopArray(dm); - MVert *mvert = dm->getVertArray(dm); int totvert = dm->getNumVerts(dm); int totface = dm->getNumPolys(dm); int i, seam; @@ -309,13 +308,12 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, BLI_array_declare(fverts); #endif EdgeSet *eset; - float creaseFactor = (float)ccgSubSurf_getSubdivisionLevels(ss); float uv[3] = {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */ limit[0] = limit[1] = STD_UV_CONNECT_LIMIT; /* previous behavior here is without accounting for winding, however this causes stretching in * UV map in really simple cases with mirror + subsurf, see second part of T44530. Also, initially - * intention is to treat merged vertices from mirror modifier as seams, see code below with ME_VERT_MERGED + * intention is to treat merged vertices from mirror modifier as seams. * This fixes a very old regression (2.49 was correct here) */ vmap = BKE_mesh_uv_vert_map_create(mpoly, mloop, mloopuv, totface, totvert, limit, false, true); if (!vmap) @@ -332,7 +330,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, if (v->separate) break; - seam = (v != NULL) || ((mvert + i)->flag & ME_VERT_MERGED); + seam = (v != NULL); for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i); v; v = v->next) { if (v->separate) { @@ -370,18 +368,11 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, for (j = 0, j_next = nverts - 1; j < nverts; j_next = j++) { unsigned int v0 = GET_UINT_FROM_POINTER(fverts[j_next]); unsigned int v1 = GET_UINT_FROM_POINTER(fverts[j]); - MVert *mv0 = mvert + (ml[j_next].v); - MVert *mv1 = mvert + (ml[j].v); if (BLI_edgeset_add(eset, v0, v1)) { CCGEdge *e, *orige = ccgSubSurf_getFaceEdge(origf, j_next); CCGEdgeHDL ehdl = SET_INT_IN_POINTER(mp->loopstart + j_next); - float crease; - - if ((mv0->flag & mv1->flag) & ME_VERT_MERGED) - crease = creaseFactor; - else - crease = ccgSubSurf_getEdgeCrease(orige); + float crease = ccgSubSurf_getEdgeCrease(orige); ccgSubSurf_syncEdge(ss, ehdl, fverts[j_next], fverts[j], crease, &e); } diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index bda557fc59d..d1c137492de 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -401,7 +401,7 @@ enum { /* SELECT = (1 << 0), */ ME_VERT_TMP_TAG = (1 << 2), ME_HIDE = (1 << 4), - ME_VERT_MERGED = (1 << 6), +/* ME_VERT_MERGED = (1 << 6), */ ME_VERT_PBVH_UPDATE = (1 << 7), }; -- cgit v1.2.3 From e6af8758c86099790b003454195c4a748251c6a4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 16 Jul 2018 17:32:57 +0200 Subject: Ghost: Fix memory leak happening with keyboard mapping access So far only noticed system de-initialization doesn't perform full object free. So rather harmless but yet stupid. --- intern/ghost/intern/GHOST_SystemX11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index ac77fb3e196..3bace8fc35a 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -254,7 +254,7 @@ GHOST_SystemX11:: #endif /* WITH_X11_XINPUT */ if (m_xkb_descr) { - XkbFreeNames(m_xkb_descr, XkbKeyNamesMask, false); + XkbFreeKeyboard (m_xkb_descr, XkbAllComponentsMask, true); } XCloseDisplay(m_display); -- cgit v1.2.3 From 43593e846bbed183a54ee1dae1b76f3f8c4be9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 11 Jul 2018 19:01:12 +0200 Subject: Matcap: Fix missing pixel on preview icons --- source/blender/blenkernel/intern/studiolight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 200c50e5c23..5381d2be691 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -1037,7 +1037,7 @@ static void studiolight_matcap_preview(uint *icon_buffer, StudioLight *sl, bool if (flipped) { fx = 1.0f - fx; } - nearest_interpolation_color(ibuf, NULL, color, fx * ibuf->x, fy * ibuf->y); + nearest_interpolation_color(ibuf, NULL, color, fx * ibuf->x - 1.0f, fy * ibuf->y - 1.0f); uint alphamask = alpha_circle_mask(fx, fy, 0.5f - pixel_size, 0.5f); -- cgit v1.2.3 From 7a693626d63a52acd12e80209b634711154a2f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 16 Jul 2018 15:01:44 +0200 Subject: Smoke: Port display to Workbench + object mode This does not fix the smokesim. It only port the drawing method. The Object mode engine is in charge of rendering the velocity debugging. Things left to do: - Flame rendering. - Color Ramp coloring of volume data. - View facing slicing (for now it's only doing sampling starting from the volume bounds which gives a squarish look) - Add option to enable dithering (currently on by default. --- source/blender/blenloader/intern/readfile.c | 3 + source/blender/draw/CMakeLists.txt | 4 + .../workbench/shaders/workbench_volume_frag.glsl | 181 +++++++++++++++++++++ .../workbench/shaders/workbench_volume_vert.glsl | 31 ++++ .../draw/engines/workbench/workbench_data.c | 3 + .../draw/engines/workbench/workbench_deferred.c | 32 +++- .../draw/engines/workbench/workbench_forward.c | 23 ++- .../draw/engines/workbench/workbench_private.h | 14 ++ .../draw/engines/workbench/workbench_volume.c | 152 +++++++++++++++++ source/blender/draw/intern/draw_cache.c | 53 +++++- source/blender/draw/intern/draw_cache.h | 3 +- source/blender/draw/intern/draw_common.c | 25 +++ source/blender/draw/intern/draw_common.h | 2 + source/blender/draw/modes/object_mode.c | 101 +++++++++++- .../draw/modes/shaders/volume_velocity_vert.glsl | 115 +++++++++++++ source/blender/gpu/GPU_draw.h | 2 + source/blender/gpu/intern/gpu_draw.c | 46 ++++++ source/blender/makesdna/DNA_smoke_types.h | 3 + 18 files changed, 782 insertions(+), 11 deletions(-) create mode 100644 source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl create mode 100644 source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl create mode 100644 source/blender/draw/engines/workbench/workbench_volume.c create mode 100644 source/blender/draw/modes/shaders/volume_velocity_vert.glsl diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6b356ac2e96..f7d585e6fd7 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5100,6 +5100,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) smd->domain->tex = NULL; smd->domain->tex_shadow = NULL; smd->domain->tex_flame = NULL; + smd->domain->tex_velocity_x = NULL; + smd->domain->tex_velocity_y = NULL; + smd->domain->tex_velocity_z = NULL; smd->domain->tex_wt = NULL; smd->domain->coba = newdataadr(fd, smd->domain->coba); diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 2183bc26755..e4c6a372d34 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -118,6 +118,7 @@ set(SRC engines/workbench/workbench_forward.c engines/workbench/workbench_materials.c engines/workbench/workbench_studiolight.c + engines/workbench/workbench_volume.c engines/workbench/solid_mode.c engines/workbench/transparent_mode.c engines/external/external_engine.c @@ -225,6 +226,8 @@ data_to_c_simple(engines/workbench/shaders/workbench_shadow_vert.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_shadow_geom.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_shadow_caps_geom.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_shadow_debug_frag.glsl SRC) +data_to_c_simple(engines/workbench/shaders/workbench_volume_vert.glsl SRC) +data_to_c_simple(engines/workbench/shaders/workbench_volume_frag.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_world_light_lib.glsl SRC) data_to_c_simple(modes/shaders/common_globals_lib.glsl SRC) @@ -297,6 +300,7 @@ data_to_c_simple(modes/shaders/paint_wire_vert.glsl SRC) data_to_c_simple(modes/shaders/paint_vert_frag.glsl SRC) data_to_c_simple(modes/shaders/particle_strand_frag.glsl SRC) data_to_c_simple(modes/shaders/particle_strand_vert.glsl SRC) +data_to_c_simple(modes/shaders/volume_velocity_vert.glsl SRC) list(APPEND INC ) diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl new file mode 100644 index 00000000000..ba5b78f4ecf --- /dev/null +++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl @@ -0,0 +1,181 @@ + +uniform mat4 ProjectionMatrix; +uniform mat4 ModelMatrixInverse; +uniform mat4 ModelViewMatrixInverse; +uniform mat4 ModelMatrix; + +uniform sampler2D depthBuffer; +uniform sampler3D densityTexture; + +uniform int samplesLen = 256; +uniform float stepLength; /* Step length in local space. */ +uniform float densityScale; /* Simple Opacity multiplicator. */ +uniform vec4 viewvecs[3]; + +uniform float slicePosition; +uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */ + +#ifdef VOLUME_SLICE +in vec3 localPos; +#endif + +out vec4 fragColor; + +#define M_PI 3.1415926535897932 /* pi */ + +float phase_function_isotropic() +{ + return 1.0 / (4.0 * M_PI); +} + +float get_view_z_from_depth(float depth) +{ + if (ProjectionMatrix[3][3] == 0.0) { + float d = 2.0 * depth - 1.0; + return -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]); + } + else { + return viewvecs[0].z + depth * viewvecs[1].z; + } +} + +vec3 get_view_space_from_depth(vec2 uvcoords, float depth) +{ + if (ProjectionMatrix[3][3] == 0.0) { + return vec3(viewvecs[0].xy + uvcoords * viewvecs[1].xy, 1.0) * get_view_z_from_depth(depth); + } + else { + return viewvecs[0].xyz + vec3(uvcoords, depth) * viewvecs[1].xyz; + } +} + +float max_v3(vec3 v) { return max(v.x, max(v.y, v.z)); } + +float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection) +{ + /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ */ + vec3 firstplane = (vec3( 1.0) - lineorigin) / linedirection; + vec3 secondplane = (vec3(-1.0) - lineorigin) / linedirection; + vec3 furthestplane = min(firstplane, secondplane); + return max_v3(furthestplane); +} + +void volume_properties(vec3 ls_pos, out vec3 scattering, out float extinction) +{ + scattering = vec3(0.0); + extinction = 1e-8; + + vec4 density = texture(densityTexture, ls_pos * 0.5 + 0.5); + density.rgb /= density.a; + density *= densityScale; + + scattering = density.rgb; + extinction = max(1e-8, density.a); +} + +#define P(x) ((x + 0.5) * (1.0 / 16.0)) +const vec4 dither_mat[4] = vec4[4]( + vec4( P(0.0), P(8.0), P(2.0), P(10.0)), + vec4(P(12.0), P(4.0), P(14.0), P(6.0)), + vec4( P(3.0), P(11.0), P(1.0), P(9.0)), + vec4(P(15.0), P(7.0), P(13.0), P(5.0)) +); + +vec4 volume_integration( + vec3 ray_ori, vec3 ray_dir, float ray_inc, float ray_max, float step_len) +{ + /* Start with full transmittance and no scattered light. */ + vec3 final_scattering = vec3(0.0); + float final_transmittance = 1.0; + + ivec2 tx = ivec2(gl_FragCoord.xy) % 4; + float noise = dither_mat[tx.x][tx.y]; + + float ray_len = noise * ray_inc; + for (int i = 0; i < samplesLen && ray_len < ray_max; ++i, ray_len += ray_inc) { + vec3 ls_pos = ray_ori + ray_dir * ray_len; + + vec3 Lscat; + float s_extinction; + volume_properties(ls_pos, Lscat, s_extinction); + /* Evaluate Scattering */ + float Tr = exp(-s_extinction * step_len); + /* integrate along the current step segment */ + Lscat = (Lscat - Lscat * Tr) / s_extinction; + /* accumulate and also take into account the transmittance from previous steps */ + final_scattering += final_transmittance * Lscat; + final_transmittance *= Tr; + } + + return vec4(final_scattering, 1.0 - final_transmittance); +} + +void main() +{ +#ifdef VOLUME_SLICE + /* Manual depth test. TODO remove. */ + float depth = texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r; + if (gl_FragCoord.z >= depth) { + discard; + } + + ivec3 volume_size = textureSize(densityTexture, 0); + float step_len; + if (sliceAxis == 0) { + step_len = float(volume_size.x); + } + else if (sliceAxis == 1) { + step_len = float(volume_size.y); + } + else { + step_len = float(volume_size.z); + } + /* FIXME Should be in world space but is in local space. */ + step_len = 1.0 / step_len; + + vec3 Lscat; + float s_extinction; + volume_properties(localPos, Lscat, s_extinction); + /* Evaluate Scattering */ + float Tr = exp(-s_extinction * step_len); + /* integrate along the current step segment */ + Lscat = (Lscat - Lscat * Tr) / s_extinction; + + fragColor = vec4(Lscat, 1.0 - Tr); + +#else + vec2 screen_uv = gl_FragCoord.xy / vec2(textureSize(depthBuffer, 0).xy); + bool is_persp = ProjectionMatrix[3][3] == 0.0; + + vec3 volume_center = ModelMatrix[3].xyz; + + float depth = texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r; + float depth_end = min(depth, gl_FragCoord.z); + vec3 vs_ray_end = get_view_space_from_depth(screen_uv, depth_end); + vec3 vs_ray_ori = get_view_space_from_depth(screen_uv, 0.0); + vec3 vs_ray_dir = (is_persp) ? (vs_ray_end - vs_ray_ori) : vec3(0.0, 0.0, -1.0); + vs_ray_dir /= abs(vs_ray_dir.z); + + vec3 ls_ray_dir = mat3(ModelViewMatrixInverse) * vs_ray_dir; + vec3 ls_ray_ori = (ModelViewMatrixInverse * vec4(vs_ray_ori, 1.0)).xyz; + vec3 ls_ray_end = (ModelViewMatrixInverse * vec4(vs_ray_end, 1.0)).xyz; + + /* TODO: Align rays to volume center so that it mimics old behaviour of slicing the volume. */ + + float dist = line_unit_box_intersect_dist(ls_ray_ori, ls_ray_dir); + if (dist > 0.0) { + ls_ray_ori = ls_ray_dir * dist + ls_ray_ori; + } + + vec3 ls_vol_isect = ls_ray_end - ls_ray_ori; + if (dot(ls_ray_dir, ls_vol_isect) < 0.0) { + /* Start is further away than the end. + * That means no volume is intersected. */ + discard; + } + + fragColor = volume_integration(ls_ray_ori, ls_ray_dir, stepLength, + length(ls_vol_isect) / length(ls_ray_dir), + length(vs_ray_dir) * stepLength); +#endif +} \ No newline at end of file diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl new file mode 100644 index 00000000000..90a22d9d02f --- /dev/null +++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl @@ -0,0 +1,31 @@ + +uniform mat4 ModelViewProjectionMatrix; +uniform float slicePosition; +uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */ + +in vec3 pos; + +#ifdef VOLUME_SLICE +in vec3 uvs; + +out vec3 localPos; +#endif + +void main() +{ +#ifdef VOLUME_SLICE + if (sliceAxis == 0) { + localPos = vec3(slicePosition * 2.0 - 1.0, pos.xy); + } + else if (sliceAxis == 1) { + localPos = vec3(pos.x, slicePosition * 2.0 - 1.0, pos.y); + } + else { + localPos = vec3(pos.xy, slicePosition * 2.0 - 1.0); + } + + gl_Position = ModelViewProjectionMatrix * vec4(localPos, 1.0); +#else + gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); +#endif +} diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index 1f5a1e17277..ede1bd7fcb5 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -119,6 +119,9 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) wpd->viewvecs[1][2] = vec_far[2] - wpd->viewvecs[0][2]; } } + + wpd->volumes_do = false; + BLI_listbase_clear(&wpd->smoke_domains); } void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float r_light_direction[3]) diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 784ed861014..d17c48b0360 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -33,6 +33,7 @@ #include "BLI_rand.h" #include "BKE_node.h" +#include "BKE_modifier.h" #include "BKE_particle.h" #include "DNA_image_types.h" @@ -327,12 +328,11 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) char *cavity_frag = workbench_build_cavity_frag(); e_data.cavity_sh = DRW_shader_create_fullscreen(cavity_frag, NULL); MEM_freeN(cavity_frag); - } + workbench_volume_engine_init(); workbench_fxaa_engine_init(); workbench_taa_engine_init(vedata); - WORKBENCH_PrivateData *wpd = stl->g_data; workbench_private_data_init(wpd); @@ -370,6 +370,10 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx), }); + GPU_framebuffer_ensure_config(&fbl->volume_fb, { + GPU_ATTACHMENT_NONE, + GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx), + }); GPU_framebuffer_ensure_config(&fbl->effect_fb, { GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(e_data.color_buffer_tx), @@ -446,6 +450,7 @@ void workbench_deferred_engine_free(void) DRW_SHADER_FREE_SAFE(e_data.shadow_caps_sh); DRW_SHADER_FREE_SAFE(e_data.shadow_caps_manifold_sh); + workbench_volume_engine_free(); workbench_fxaa_engine_free(); workbench_taa_engine_free(); } @@ -485,7 +490,10 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) Scene *scene = draw_ctx->scene; + workbench_volume_cache_init(vedata); + select_deferred_shaders(wpd); + /* Deferred Mix Pass */ { workbench_private_data_get_light_direction(wpd, e_data.display.light_direction); @@ -636,6 +644,9 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; WORKBENCH_PrivateData *wpd = stl->g_data; + const DRWContextState *draw_ctx = DRW_context_state_get(); + Scene *scene = draw_ctx->scene; + if (!DRW_object_is_renderable(ob)) return; @@ -643,13 +654,22 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) workbench_cache_populate_particles(vedata, ob); } + ModifierData *md; + if (((ob->base_flag & BASE_FROMDUPLI) == 0) && + (md = modifiers_findByType(ob, eModifierType_Smoke)) && + (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && + (((SmokeModifierData *)md)->domain != NULL)) + { + workbench_volume_cache_populate(vedata, scene, ob, md); + return; /* Do not draw solid in this case. */ + } + if (!DRW_check_object_visible_within_active_context(ob)) { return; } WORKBENCH_MaterialData *material; if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { - const DRWContextState *draw_ctx = DRW_context_state_get(); const bool is_active = (ob == draw_ctx->obact); const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0; bool is_drawn = false; @@ -860,6 +880,12 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) DRW_draw_pass(psl->composite_pass); } + if (wpd->volumes_do) { + GPU_framebuffer_bind(fbl->volume_fb); + DRW_draw_pass(psl->volume_pass); + } + workbench_aa_draw_pass(vedata, e_data.composite_buffer_tx); workbench_private_data_free(wpd); + workbench_volume_smoke_textures_free(wpd); } diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index e921b2ac2f7..3fb68654188 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -33,6 +33,7 @@ #include "BKE_node.h" #include "BKE_particle.h" +#include "BKE_modifier.h" #include "DNA_image_types.h" #include "DNA_mesh_types.h" @@ -284,6 +285,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) MEM_freeN(defines_texture); MEM_freeN(defines_hair); } + workbench_volume_engine_init(); workbench_fxaa_engine_init(); workbench_taa_engine_init(vedata); @@ -305,13 +307,11 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx), }); - GPU_framebuffer_ensure_config(&fbl->transparent_accum_fb, { GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(e_data.transparent_accum_tx), GPU_ATTACHMENT_TEXTURE(e_data.transparent_revealage_tx), }); - GPU_framebuffer_ensure_config(&fbl->composite_fb, { GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx), @@ -321,6 +321,8 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) GPU_ATTACHMENT_TEXTURE(e_data.transparent_accum_tx), }); + workbench_volume_cache_init(vedata); + /* Transparency Accum */ { int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT; @@ -372,7 +374,9 @@ void workbench_forward_engine_free() DRW_SHADER_FREE_SAFE(e_data.object_outline_hair_sh); DRW_SHADER_FREE_SAFE(e_data.checker_depth_sh); + workbench_volume_engine_free(); workbench_fxaa_engine_free(); + workbench_taa_engine_free(); } void workbench_forward_cache_init(WORKBENCH_Data *UNUSED(vedata)) @@ -444,6 +448,8 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) { WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PrivateData *wpd = stl->g_data; + const DRWContextState *draw_ctx = DRW_context_state_get(); + Scene *scene = draw_ctx->scene; if (!DRW_object_is_renderable(ob)) return; @@ -452,13 +458,22 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) workbench_forward_cache_populate_particles(vedata, ob); } + ModifierData *md; + if (((ob->base_flag & BASE_FROMDUPLI) == 0) && + (md = modifiers_findByType(ob, eModifierType_Smoke)) && + (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && + (((SmokeModifierData *)md)->domain != NULL)) + { + workbench_volume_cache_populate(vedata, scene, ob, md); + return; /* Do not draw solid in this case. */ + } + if (!DRW_check_object_visible_within_active_context(ob)) { return; } WORKBENCH_MaterialData *material; if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { - const DRWContextState *draw_ctx = DRW_context_state_get(); const bool is_active = (ob == draw_ctx->obact); const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0; bool is_drawn = false; @@ -595,6 +610,7 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata) /* Composite */ GPU_framebuffer_bind(fbl->composite_fb); DRW_draw_pass(psl->composite_pass); + DRW_draw_pass(psl->volume_pass); /* Color correct and Anti aliasing */ workbench_aa_draw_pass(vedata, e_data.composite_buffer_tx); @@ -604,4 +620,5 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata) DRW_draw_pass(psl->checker_depth_pass); workbench_private_data_free(wpd); + workbench_volume_smoke_textures_free(wpd); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 4210e03f470..13e9686aa85 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -70,6 +70,7 @@ typedef struct WORKBENCH_FramebufferList { struct GPUFrameBuffer *effect_fb; struct GPUFrameBuffer *effect_taa_fb; struct GPUFrameBuffer *depth_buffer_fb; + struct GPUFrameBuffer *volume_fb; /* Forward render buffers */ struct GPUFrameBuffer *object_outline_fb; @@ -101,6 +102,7 @@ typedef struct WORKBENCH_PassList { struct DRWPass *composite_pass; struct DRWPass *composite_shadow_pass; struct DRWPass *effect_aa_pass; + struct DRWPass *volume_pass; /* forward rendering */ struct DRWPass *transparent_accum_pass; @@ -167,6 +169,10 @@ typedef struct WORKBENCH_PrivateData { float shadow_near_sides[2][4]; /* This is a parallelogram, so only 2 normal and distance to the edges. */ bool shadow_changed; + /* Volumes */ + bool volumes_do; + ListBase smoke_domains; + /* Ssao */ float winmat[4][4]; float viewvecs[3][4]; @@ -280,6 +286,14 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd); void workbench_private_data_free(WORKBENCH_PrivateData *wpd); void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float r_light_direction[3]); +/* workbench_volume.c */ +void workbench_volume_engine_init(void); +void workbench_volume_engine_free(void); +void workbench_volume_cache_init(WORKBENCH_Data *vedata); +void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Object *ob, struct ModifierData *md); +void workbench_volume_smoke_textures_free(WORKBENCH_PrivateData *wpd); + + extern DrawEngineType draw_engine_workbench_solid; extern DrawEngineType draw_engine_workbench_transparent; diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c new file mode 100644 index 00000000000..f28bfd01ae8 --- /dev/null +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -0,0 +1,152 @@ +/* + * Copyright 2018, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Institute + * + */ + +/** \file workbench_volumed.c + * \ingroup draw_engine + */ + +#include "workbench_private.h" + +#include "BKE_modifier.h" + +#include "DNA_modifier_types.h" +#include "DNA_object_force_types.h" +#include "DNA_smoke_types.h" + +#include "GPU_draw.h" + +static struct { + struct GPUShader *volume_sh; + struct GPUShader *volume_slice_sh; +} e_data = {NULL}; + +extern char datatoc_workbench_volume_vert_glsl[]; +extern char datatoc_workbench_volume_frag_glsl[]; + +void workbench_volume_engine_init(void) +{ + if (!e_data.volume_sh) { + e_data.volume_sh = DRW_shader_create( + datatoc_workbench_volume_vert_glsl, NULL, + datatoc_workbench_volume_frag_glsl, NULL); + e_data.volume_slice_sh = DRW_shader_create( + datatoc_workbench_volume_vert_glsl, NULL, + datatoc_workbench_volume_frag_glsl, "#define VOLUME_SLICE"); + } +} + +void workbench_volume_engine_free(void) +{ + DRW_SHADER_FREE_SAFE(e_data.volume_sh); + DRW_SHADER_FREE_SAFE(e_data.volume_slice_sh); +} + +void workbench_volume_cache_init(WORKBENCH_Data *vedata) +{ + vedata->psl->volume_pass = DRW_pass_create("Volumes", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_PREMUL | DRW_STATE_CULL_FRONT); +} + +void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Object *ob, ModifierData *md) +{ + SmokeModifierData *smd = (SmokeModifierData *)md; + SmokeDomainSettings *sds = smd->domain; + WORKBENCH_PrivateData *wpd = vedata->stl->g_data; + DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + + /* Don't show smoke before simulation starts, this could be made an option in the future. */ + if (!sds->fluid || CFRA < sds->point_cache[0]->startframe) { + return; + } + + wpd->volumes_do = true; + + if (!sds->wt || !(sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) { + GPU_create_smoke(smd, 0); + } + else if (sds->wt && (sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) { + GPU_create_smoke(smd, 1); + } + + if (sds->tex == NULL) { + return; + } + + if (sds->slice_method == MOD_SMOKE_SLICE_AXIS_ALIGNED && + sds->axis_slice_method == AXIS_SLICE_SINGLE) + { + float invviewmat[4][4]; + DRW_viewport_matrix_get(invviewmat, DRW_MAT_VIEWINV); + + const int axis = (sds->slice_axis == SLICE_AXIS_AUTO) + ? axis_dominant_v3_single(invviewmat[2]) + : sds->slice_axis - 1; + + DRWShadingGroup *grp = DRW_shgroup_create(e_data.volume_slice_sh, vedata->psl->volume_pass); + DRW_shgroup_uniform_texture(grp, "densityTexture", sds->tex); + DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); + DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * sds->display_thickness); + DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth); + DRW_shgroup_uniform_int_copy(grp, "sliceAxis", axis); + DRW_shgroup_state_disable(grp, DRW_STATE_CULL_FRONT); + BLI_addtail(&wpd->smoke_domains, BLI_genericNodeN(smd)); + + /* TODO Flame rendering */ + /* TODO COBA Rendering */ + + DRW_shgroup_call_object_add(grp, DRW_cache_quad_get(), ob); + } + else { + int max_slices = max_iii(sds->res[0], sds->res[1], sds->res[2]) * sds->slice_per_voxel; + + DRWShadingGroup *grp = DRW_shgroup_create(e_data.volume_sh, vedata->psl->volume_pass); + DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3); + DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); + DRW_shgroup_uniform_texture(grp, "densityTexture", sds->tex); + DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * sds->display_thickness); + DRW_shgroup_uniform_int_copy(grp, "samplesLen", max_slices); + /* TODO FIXME : This step size is in object space but the ray itself + * is NOT unit length in object space so the required number of subdivisions + * is tricky to get. */ + DRW_shgroup_uniform_float_copy(grp, "stepLength", 8.0f / max_slices); + DRW_shgroup_state_enable(grp, DRW_STATE_CULL_FRONT); + BLI_addtail(&wpd->smoke_domains, BLI_genericNodeN(smd)); + + /* TODO Flame rendering */ + /* TODO COBA Rendering */ + + DRW_shgroup_call_object_add(grp, DRW_cache_cube_get(), ob); + } +} + +void workbench_volume_smoke_textures_free(WORKBENCH_PrivateData *wpd) +{ + /* Free Smoke Textures after rendering */ + /* XXX This is a waste of processing and GPU bandwidth if nothing + * is updated. But the problem is since Textures are stored in the + * modifier we don't want them to take precious VRAM if the + * modifier is not used for display. We should share them for + * all viewport in a redraw at least. */ + for (LinkData *link = wpd->smoke_domains.first; link; link = link->next) { + SmokeModifierData *smd = (SmokeModifierData *)link->data; + GPU_free_smoke(smd); + } + BLI_freelistN(&wpd->smoke_domains); +} diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 1bf40673239..0d2317199fc 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -61,6 +61,7 @@ static struct DRWShapeCache { Gwn_Batch *drw_square; Gwn_Batch *drw_line; Gwn_Batch *drw_line_endpoints; + Gwn_Batch *drw_empty_cube; Gwn_Batch *drw_empty_sphere; Gwn_Batch *drw_empty_cone; Gwn_Batch *drw_arrows; @@ -341,6 +342,54 @@ Gwn_Batch *DRW_cache_cube_get(void) { 1.0f, 1.0f, 1.0f} }; + const uint indices[36] = { + 0, 1, 2, + 1, 3, 2, + 0, 4, 1, + 4, 5, 1, + 6, 5, 4, + 6, 7, 5, + 2, 7, 6, + 2, 3, 7, + 3, 1, 7, + 1, 5, 7, + 0, 2, 4, + 2, 6, 4, + }; + + /* Position Only 3D format */ + static Gwn_VertFormat format = { 0 }; + static struct { uint pos; } attr_id; + if (format.attr_len == 0) { + attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + } + + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GWN_vertbuf_data_alloc(vbo, 36); + + for (int i = 0; i < 36; ++i) { + GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); + } + + SHC.drw_cube = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + } + return SHC.drw_cube; +} + +Gwn_Batch *DRW_cache_empty_cube_get(void) +{ + if (!SHC.drw_empty_cube) { + const GLfloat verts[8][3] = { + {-1.0f, -1.0f, -1.0f}, + {-1.0f, -1.0f, 1.0f}, + {-1.0f, 1.0f, -1.0f}, + {-1.0f, 1.0f, 1.0f}, + { 1.0f, -1.0f, -1.0f}, + { 1.0f, -1.0f, 1.0f}, + { 1.0f, 1.0f, -1.0f}, + { 1.0f, 1.0f, 1.0f} + }; + const GLubyte indices[24] = {0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5, 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6}; /* Position Only 3D format */ @@ -357,9 +406,9 @@ Gwn_Batch *DRW_cache_cube_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); } - SHC.drw_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } - return SHC.drw_cube; + return SHC.drw_empty_cube; } Gwn_Batch *DRW_cache_circle_get(void) diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index e7ab847d42e..9114a4d872d 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -41,6 +41,7 @@ struct Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines); /* Common Shapes */ struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void); struct Gwn_Batch *DRW_cache_quad_get(void); +struct Gwn_Batch *DRW_cache_cube_get(void); struct Gwn_Batch *DRW_cache_sphere_get(void); struct Gwn_Batch *DRW_cache_single_vert_get(void); struct Gwn_Batch *DRW_cache_single_line_get(void); @@ -61,7 +62,7 @@ void DRW_cache_object_face_wireframe_get( /* Empties */ struct Gwn_Batch *DRW_cache_plain_axes_get(void); struct Gwn_Batch *DRW_cache_single_arrow_get(void); -struct Gwn_Batch *DRW_cache_cube_get(void); +struct Gwn_Batch *DRW_cache_empty_cube_get(void); struct Gwn_Batch *DRW_cache_circle_get(void); struct Gwn_Batch *DRW_cache_square_get(void); struct Gwn_Batch *DRW_cache_empty_sphere_get(void); diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index a1c60be4742..df80300417e 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -162,6 +162,8 @@ extern char datatoc_animviz_mpath_lines_vert_glsl[]; extern char datatoc_animviz_mpath_lines_geom_glsl[]; extern char datatoc_animviz_mpath_points_vert_glsl[]; +extern char datatoc_volume_velocity_vert_glsl[]; + extern char datatoc_armature_axes_vert_glsl[]; extern char datatoc_armature_sphere_solid_vert_glsl[]; extern char datatoc_armature_sphere_solid_frag_glsl[]; @@ -199,6 +201,9 @@ static struct { struct GPUShader *mpath_line_sh; struct GPUShader *mpath_points_sh; + struct GPUShader *volume_velocity_needle_sh; + struct GPUShader *volume_velocity_sh; + struct GPUShader *mball_handles; } g_shaders = {NULL}; @@ -736,6 +741,26 @@ struct GPUShader *mpath_points_shader_get(void) return g_shaders.mpath_points_sh; } +struct GPUShader *volume_velocity_shader_get(bool use_needle) +{ + if (use_needle) { + if (g_shaders.volume_velocity_needle_sh == NULL) { + g_shaders.volume_velocity_needle_sh = DRW_shader_create( + datatoc_volume_velocity_vert_glsl, NULL, + datatoc_gpu_shader_flat_color_frag_glsl, "#define USE_NEEDLE"); + } + return g_shaders.volume_velocity_needle_sh; + } + else { + if (g_shaders.volume_velocity_sh == NULL) { + g_shaders.volume_velocity_sh = DRW_shader_create( + datatoc_volume_velocity_vert_glsl, NULL, + datatoc_gpu_shader_flat_color_frag_glsl, NULL); + } + return g_shaders.volume_velocity_sh; + } +} + /* ******************************************** COLOR UTILS *********************************************** */ /* TODO FINISH */ diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index 6227130fb05..b4ae0600f02 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -138,6 +138,8 @@ struct DRWShadingGroup *shgroup_instance_bone_stick(struct DRWPass *pass); struct GPUShader *mpath_line_shader_get(void); struct GPUShader *mpath_points_shader_get(void); +struct GPUShader *volume_velocity_shader_get(bool use_needle); + int DRW_object_wire_theme_get( struct Object *ob, struct ViewLayer *view_layer, float **r_color); float *DRW_color_background_blend_get(int theme_id); diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 6c99024312c..2e41dbfd529 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -32,10 +32,12 @@ #include "DNA_curve_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_force_types.h" #include "DNA_lightprobe_types.h" #include "DNA_particle_types.h" #include "DNA_rigidbody_types.h" +#include "DNA_smoke_types.h" #include "DNA_view3d_types.h" #include "DNA_world_types.h" @@ -49,6 +51,7 @@ #include "BKE_global.h" #include "BKE_mball.h" #include "BKE_mesh.h" +#include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_image.h" @@ -58,6 +61,7 @@ #include "GPU_shader.h" #include "GPU_texture.h" +#include "GPU_draw.h" #include "MEM_guardedalloc.h" @@ -286,6 +290,8 @@ static struct { struct GPUTexture *outlines_id_tx; struct GPUTexture *outlines_color_tx; struct GPUTexture *outlines_blur_tx; + + ListBase smoke_domains; } e_data = {NULL}; /* Engine data */ @@ -1078,7 +1084,7 @@ static void OBJECT_cache_init(void *vedata) geom = DRW_cache_plain_axes_get(); stl->g_data->plain_axes = shgroup_instance(psl->non_meshes, geom); - geom = DRW_cache_cube_get(); + geom = DRW_cache_empty_cube_get(); stl->g_data->cube = shgroup_instance(psl->non_meshes, geom); geom = DRW_cache_circle_get(); @@ -1156,7 +1162,7 @@ static void OBJECT_cache_init(void *vedata) stl->g_data->camera_mist_points = shgroup_distance_lines_instance(psl->non_meshes, geom); /* Texture Space */ - geom = DRW_cache_cube_get(); + geom = DRW_cache_empty_cube_get(); stl->g_data->texspace = shgroup_instance(psl->non_meshes, geom); } @@ -1723,6 +1729,85 @@ static void DRW_shgroup_forcefield(OBJECT_StorageList *stl, Object *ob, ViewLaye } } +static void DRW_shgroup_volume_extra( + OBJECT_PassList *psl, OBJECT_StorageList *stl, + Object *ob, ViewLayer *view_layer, Scene *scene, ModifierData *md) +{ + SmokeModifierData *smd = (SmokeModifierData *)md; + SmokeDomainSettings *sds = smd->domain; + float *color; + float one = 1.0f; + + if (sds == NULL) { + return; + } + + DRW_object_wire_theme_get(ob, view_layer, &color); + + /* Small cube showing voxel size. */ + float voxel_cubemat[4][4] = {{0.0f}}; + voxel_cubemat[0][0] = 1.0f / (float)sds->res[0]; + voxel_cubemat[1][1] = 1.0f / (float)sds->res[1]; + voxel_cubemat[2][2] = 1.0f / (float)sds->res[2]; + voxel_cubemat[3][0] = voxel_cubemat[3][1] = voxel_cubemat[3][2] = -1.0f; + voxel_cubemat[3][3] = 1.0f; + translate_m4(voxel_cubemat, 1.0f, 1.0f, 1.0f); + mul_m4_m4m4(voxel_cubemat, ob->obmat, voxel_cubemat); + + DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &one, voxel_cubemat); + + /* Don't show smoke before simulation starts, this could be made an option in the future. */ + if (!sds->draw_velocity || !sds->fluid || CFRA < sds->point_cache[0]->startframe) { + return; + } + + const bool use_needle = (sds->vector_draw_type == VECTOR_DRAW_NEEDLE); + int line_count = (use_needle) ? 6 : 1; + int slice_axis = -1; + line_count *= sds->res[0] * sds->res[1] * sds->res[2]; + + if (sds->slice_method == MOD_SMOKE_SLICE_AXIS_ALIGNED && + sds->axis_slice_method == AXIS_SLICE_SINGLE) + { + float invviewmat[4][4]; + DRW_viewport_matrix_get(invviewmat, DRW_MAT_VIEWINV); + + const int axis = (sds->slice_axis == SLICE_AXIS_AUTO) + ? axis_dominant_v3_single(invviewmat[2]) + : sds->slice_axis - 1; + slice_axis = axis; + line_count /= sds->res[axis]; + } + + GPU_create_smoke_velocity(smd); + + DRWShadingGroup *grp = DRW_shgroup_create(volume_velocity_shader_get(use_needle), psl->non_meshes); + DRW_shgroup_uniform_texture(grp, "velocityX", sds->tex_velocity_x); + DRW_shgroup_uniform_texture(grp, "velocityY", sds->tex_velocity_y); + DRW_shgroup_uniform_texture(grp, "velocityZ", sds->tex_velocity_z); + DRW_shgroup_uniform_float_copy(grp, "displaySize", sds->vector_scale); + DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth); + DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis); + DRW_shgroup_call_procedural_lines_add(grp, line_count, ob->obmat); + + BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(smd)); +} + +static void volumes_free_smoke_textures(void) +{ + /* Free Smoke Textures after rendering */ + /* XXX This is a waste of processing and GPU bandwidth if nothing + * is updated. But the problem is since Textures are stored in the + * modifier we don't want them to take precious VRAM if the + * modifier is not used for display. We should share them for + * all viewport in a redraw at least. */ + for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) { + SmokeModifierData *smd = (SmokeModifierData *)link->data; + GPU_free_smoke(smd); + } + BLI_freelistN(&e_data.smoke_domains); +} + static void DRW_shgroup_speaker(OBJECT_StorageList *stl, Object *ob, ViewLayer *view_layer) { float *color; @@ -2142,7 +2227,9 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl; const DRWContextState *draw_ctx = DRW_context_state_get(); ViewLayer *view_layer = draw_ctx->view_layer; + Scene *scene = draw_ctx->scene; View3D *v3d = draw_ctx->v3d; + ModifierData *md = NULL; int theme_id = TH_UNDEFINED; /* Handle particles first in case the emitter itself shouldn't be rendered. */ @@ -2311,6 +2398,14 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) DRW_shgroup_forcefield(stl, ob, view_layer); } + if (((ob->base_flag & BASE_FROMDUPLI) == 0) && + (md = modifiers_findByType(ob, eModifierType_Smoke)) && + (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && + (((SmokeModifierData *)md)->domain != NULL)) + { + DRW_shgroup_volume_extra(psl, stl, ob, view_layer, scene, md); + } + /* don't show object extras in set's */ if ((ob->base_flag & (BASE_FROM_SET | BASE_FROMDUPLI)) == 0) { @@ -2437,6 +2532,8 @@ static void OBJECT_draw_scene(void *vedata) BLI_ghash_free(stl->g_data->image_plane_map, NULL, MEM_freeN); stl->g_data->image_plane_map = NULL; } + + volumes_free_smoke_textures(); } static const DrawEngineDataSize OBJECT_data_size = DRW_VIEWPORT_DATA_SIZE(OBJECT_Data); diff --git a/source/blender/draw/modes/shaders/volume_velocity_vert.glsl b/source/blender/draw/modes/shaders/volume_velocity_vert.glsl new file mode 100644 index 00000000000..574c434920e --- /dev/null +++ b/source/blender/draw/modes/shaders/volume_velocity_vert.glsl @@ -0,0 +1,115 @@ + +uniform mat4 ModelViewProjectionMatrix; + +uniform sampler3D velocityX; +uniform sampler3D velocityY; +uniform sampler3D velocityZ; +uniform float displaySize = 1.0; +uniform float slicePosition; +uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */ + +flat out vec4 finalColor; + +const vec3 corners[4] = vec3[4]( + vec3(0.0, 0.2, -0.5), + vec3(-0.2 * 0.866, -0.2 * 0.5, -0.5), + vec3(0.2 * 0.866, -0.2 * 0.5, -0.5), + vec3(0.0, 0.0, 0.5) +); + +const int indices[12] = int[12](0, 1, 1, 2, 2, 0, 0, 3, 1, 3, 2, 3); + +/* Straight Port from BKE_defvert_weight_to_rgb() + * TODO port this to a color ramp. */ +vec3 weight_to_color(float weight) +{ + vec3 r_rgb = vec3(0.0); + float blend = ((weight / 2.0) + 0.5); + + if (weight <= 0.25) { /* blue->cyan */ + r_rgb.g = blend * weight * 4.0; + r_rgb.b = blend; + } + else if (weight <= 0.50) { /* cyan->green */ + r_rgb.g = blend; + r_rgb.b = blend * (1.0 - ((weight - 0.25) * 4.0)); + } + else if (weight <= 0.75) { /* green->yellow */ + r_rgb.r = blend * ((weight - 0.50) * 4.0); + r_rgb.g = blend; + } + else if (weight <= 1.0) { /* yellow->red */ + r_rgb.r = blend; + r_rgb.g = blend * (1.0 - ((weight - 0.75) * 4.0)); + } + else { + /* exceptional value, unclamped or nan, + * avoid uninitialized memory use */ + r_rgb = vec3(1.0, 0.0, 1.0); + } + + return r_rgb; +} + +mat3 rotation_from_vector(vec3 v) +{ + /* Add epsilon to avoid NaN. */ + vec3 N = normalize(v + 1e-8); + vec3 UpVector = abs(N.z) < 0.99999 ? vec3(0.0,0.0,1.0) : vec3(1.0,0.0,0.0); + vec3 T = normalize(cross(UpVector, N)); + vec3 B = cross(N, T); + return mat3(T, B, N); +} + +void main() +{ +#ifdef USE_NEEDLE + int cell = gl_VertexID / 12; +#else + int cell = gl_VertexID / 2; +#endif + + ivec3 volume_size = textureSize(velocityX, 0); + float voxel_size = 1.0 / float(max(max(volume_size.x, volume_size.y), volume_size.z)); + + ivec3 cell_ofs = ivec3(0); + ivec3 cell_div = volume_size; + if (sliceAxis == 0) { + cell_ofs.x = int(slicePosition * float(volume_size.x)); + cell_div.x = 1; + } + else if (sliceAxis == 1) { + cell_ofs.y = int(slicePosition * float(volume_size.y)); + cell_div.y = 1; + } + else if (sliceAxis == 2) { + cell_ofs.z = int(slicePosition * float(volume_size.z)); + cell_div.z = 1; + } + + ivec3 cell_co; + cell_co.x = cell % cell_div.x; + cell_co.y = (cell / cell_div.x) % cell_div.y; + cell_co.z = cell / (cell_div.x * cell_div.y); + cell_co += cell_ofs; + + vec3 pos = (vec3(cell_co) + 0.5) / vec3(volume_size); + pos = pos * 2.0 - 1.0; + + vec3 velocity; + velocity.x = texelFetch(velocityX, cell_co, 0).r; + velocity.y = texelFetch(velocityY, cell_co, 0).r; + velocity.z = texelFetch(velocityZ, cell_co, 0).r; + + finalColor = vec4(weight_to_color(length(velocity)), 1.0); + +#ifdef USE_NEEDLE + mat3 rot_mat = rotation_from_vector(velocity); + vec3 rotated_pos = rot_mat * corners[indices[gl_VertexID % 12]]; + pos += rotated_pos * length(velocity) * displaySize * voxel_size; +#else + pos += (((gl_VertexID % 2) == 1) ? velocity : vec3(0.0)) * displaySize * voxel_size; +#endif + + gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); +} diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index ebce83d2a5f..028756bc739 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -101,7 +101,9 @@ void GPU_free_images_old(struct Main *bmain); /* smoke drawing functions */ void GPU_free_smoke(struct SmokeModifierData *smd); +void GPU_free_smoke_velocity(struct SmokeModifierData *smd); void GPU_create_smoke(struct SmokeModifierData *smd, int highres); +void GPU_create_smoke_velocity(struct SmokeModifierData *smd); /* Delayed free of OpenGL buffers by main thread */ void GPU_free_unused_buffers(struct Main *bmain); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7383868843d..e2c83d6fadf 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -971,6 +971,52 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres) #endif // WITH_SMOKE } +void GPU_create_smoke_velocity(SmokeModifierData *smd) +{ +#ifdef WITH_SMOKE + if (smd->type & MOD_SMOKE_TYPE_DOMAIN) { + SmokeDomainSettings *sds = smd->domain; + + const float *vel_x = smoke_get_velocity_x(sds->fluid); + const float *vel_y = smoke_get_velocity_y(sds->fluid); + const float *vel_z = smoke_get_velocity_z(sds->fluid); + + if (ELEM(NULL, vel_x, vel_y, vel_z)) { + return; + } + + if (!sds->tex_velocity_x) { + sds->tex_velocity_x = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_x, NULL); + sds->tex_velocity_y = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_y, NULL); + sds->tex_velocity_z = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_z, NULL); + } + } +#else // WITH_SMOKE + smd->domain->tex_velocity_x = NULL; + smd->domain->tex_velocity_y = NULL; + smd->domain->tex_velocity_z = NULL; +#endif // WITH_SMOKE +} + +/* TODO Unify with the other GPU_free_smoke. */ +void GPU_free_smoke_velocity(SmokeModifierData *smd) +{ + if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) { + if (smd->domain->tex_velocity_x) + GPU_texture_free(smd->domain->tex_velocity_x); + + if (smd->domain->tex_velocity_y) + GPU_texture_free(smd->domain->tex_velocity_y); + + if (smd->domain->tex_velocity_z) + GPU_texture_free(smd->domain->tex_velocity_z); + + smd->domain->tex_velocity_x = NULL; + smd->domain->tex_velocity_y = NULL; + smd->domain->tex_velocity_z = NULL; + } +} + static LinkNode *image_free_queue = NULL; static void gpu_queue_image_for_free(Image *ima) diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h index 76b609b0c6c..443c6923ed0 100644 --- a/source/blender/makesdna/DNA_smoke_types.h +++ b/source/blender/makesdna/DNA_smoke_types.h @@ -137,6 +137,9 @@ typedef struct SmokeDomainSettings { struct GPUTexture *tex_wt; struct GPUTexture *tex_shadow; struct GPUTexture *tex_flame; + struct GPUTexture *tex_velocity_x; + struct GPUTexture *tex_velocity_y; + struct GPUTexture *tex_velocity_z; float *shadow; /* simulation data */ -- cgit v1.2.3 From eef6e1cca16468d70166330c0f64fe202d619304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 16 Jul 2018 15:02:08 +0200 Subject: StudioLight: Fix codestyle --- source/blender/blenkernel/intern/studiolight.c | 42 -------------------------- 1 file changed, 42 deletions(-) diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 5381d2be691..df5cc7551aa 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -442,106 +442,64 @@ static void studiolight_calculate_spherical_harmonics_coefficient(StudioLight *s switch (sh_component) { /* L0 */ case 0: - { coef = 0.2822095f; break; - } - /* L1 */ case 1: - { coef = -0.488603f * nz * 2.0f / 3.0f; break; - } case 2: - { coef = 0.488603f * ny * 2.0f / 3.0f; break; - } case 3: - { coef = -0.488603f * nx * 2.0f / 3.0f; break; - } - /* L2 */ case 4: - { coef = 1.092548f * nx * nz * 1.0f / 4.0f; break; - } case 5: - { coef = -1.092548f * nz * ny * 1.0f / 4.0f; break; - } case 6: - { coef = 0.315392f * (3.0f * ny2 - 1.0f) * 1.0f / 4.0f; break; - } case 7: - { coef = 1.092548f * nx * ny * 1.0f / 4.0f; break; - } case 8: - { coef = 0.546274f * (nx2 - nz2) * 1.0f / 4.0f; break; - } - /* L4 */ case 9: - { coef = (2.5033429417967046f * nx * nz * (nx2 - nz2)) / -24.0f; break; - } case 10: - { coef = (-1.7701307697799304f * nz * ny * (3.0f * nx2 - nz2)) / -24.0f; break; - } case 11: - { coef = (0.9461746957575601f * nz * nx * (-1.0f + 7.0f * ny2)) / -24.0f; break; - } case 12: - { coef = (-0.6690465435572892f * nz * ny * (-3.0f + 7.0f * ny2)) / -24.0f; break; - } case 13: - { coef = ((105.0f * ny4 - 90.0f * ny2 + 9.0f) / 28.359261614f) / -24.0f; break; - } case 14: - { coef = (-0.6690465435572892f * nx * ny * (-3.0f + 7.0f * ny2)) / -24.0f; break; - } case 15: - { coef = (0.9461746957575601f * (nx2 - nz2) * (-1.0f + 7.0f * ny2)) / -24.0f; break; - } case 16: - { coef = (-1.7701307697799304f * nx * ny * (nx2 - 3.0f * nz2)) / -24.0f; break; - } case 17: - { coef = (0.6258357354491761f * (nx4 - 6.0f * nz2 * nx2 + nz4)) / -24.0f; break; - } - default: - { coef = 0.0f; - } } madd_v3_v3fl(sh, color, coef * weight); -- cgit v1.2.3 From 44a9c392290320b7ff1d439af75d073360386c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 16 Jul 2018 15:02:42 +0200 Subject: Workbench: Fix use of uninitialized memory. --- source/blender/draw/engines/workbench/workbench_forward.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 3fb68654188..e0e0bdea0f5 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -247,10 +247,10 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) if (!stl->g_data) { /* Alloc transient pointers */ - stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__); + stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__); } if (!stl->effects) { - stl->effects = MEM_mallocN(sizeof(*stl->effects), __func__); + stl->effects = MEM_callocN(sizeof(*stl->effects), __func__); workbench_effect_info_init(stl->effects); } WORKBENCH_PrivateData *wpd = stl->g_data; -- cgit v1.2.3 From 1f69ffd35b08768e8605496be4389e6bbea39ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 16 Jul 2018 19:54:37 +0200 Subject: Eevee: Fix Cascaded Shadow Maps glitches There was an issue that caused the cascaded shadow map to appear glitchy when the lamp was not at the origin. --- source/blender/draw/engines/eevee/eevee_lights.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index 0f0d9d281c9..431fc9fe561 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -891,7 +891,7 @@ static void eevee_shadow_cascade_setup( frustum_min_bounding_sphere(corners, center, &(sh_data->radius[c])); /* Project into lightspace */ - mul_mat3_m4_v3(viewmat, center); + mul_m4_v3(viewmat, center); /* Snap projection center to nearest texel to cancel shimmering. */ float shadow_origin[2], shadow_texco[2]; -- cgit v1.2.3 From db374d665875af0673ab576779649e0f2ee45704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 16 Jul 2018 20:07:13 +0200 Subject: DRWDebug: Add new debug functions for spheres and matrices. --- source/blender/draw/intern/DRW_render.h | 1 + source/blender/draw/intern/draw_debug.c | 74 +++++++++++++++++++++++++++++++ source/blender/draw/intern/draw_debug.h | 2 + source/blender/draw/intern/draw_manager.h | 7 +++ 4 files changed, 84 insertions(+) diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 4d1b8269494..a4a933250c9 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -55,6 +55,7 @@ #include "draw_view.h" #include "draw_manager_profiling.h" +#include "draw_debug.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/draw/intern/draw_debug.c b/source/blender/draw/intern/draw_debug.c index 0e4176f90a6..64e76a339c1 100644 --- a/source/blender/draw/intern/draw_debug.c +++ b/source/blender/draw/intern/draw_debug.c @@ -29,6 +29,8 @@ #include "DNA_object_types.h" +#include "BKE_object.h" + #include "BLI_link_utils.h" #include "GPU_immediate.h" @@ -105,6 +107,36 @@ void DRW_debug_bbox(const BoundBox *bbox, const float color[4]) DRW_debug_line_v3v3(bbox->vec[3], bbox->vec[7], color); } +void DRW_debug_m4_as_bbox(const float m[4][4], const float color[4], const bool invert) +{ + BoundBox bb; + const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; + float minv[4][4]; + if (invert) { + invert_m4_m4(minv, m); + } + + BKE_boundbox_init_from_minmax(&bb, min, max); + for (int i = 0; i < 8; ++i) { + mul_project_m4_v3((invert) ? minv : m, bb.vec[i]); + } + DRW_debug_bbox(&bb, color); +} + +void DRW_debug_sphere(const float center[3], const float radius, const float color[4]) +{ + float size_mat[4][4]; + DRWDebugSphere *sphere = MEM_mallocN(sizeof(DRWDebugSphere), "DRWDebugSphere"); + /* Bake all transform into a Matrix4 */ + scale_m4_fl(size_mat, radius); + copy_m4_m4(sphere->mat, g_modelmat); + translate_m4(sphere->mat, center[0], center[1], center[2]); + mul_m4_m4m4(sphere->mat, sphere->mat, size_mat); + + copy_v4_v4(sphere->color, color); + BLI_LINKS_PREPEND(DST.debug.spheres, sphere); +} + /* --------- Render --------- */ static void drw_debug_draw_lines(void) @@ -140,9 +172,51 @@ static void drw_debug_draw_lines(void) immUnbindProgram(); } +static void drw_debug_draw_spheres(void) +{ + int count = BLI_linklist_count((LinkNode *)DST.debug.spheres); + + if (count == 0) { + return; + } + + float one = 1.0f; + Gwn_VertFormat vert_format = {0}; + uint mat = GWN_vertformat_attr_add(&vert_format, "InstanceModelMatrix", GWN_COMP_F32, 16, GWN_FETCH_FLOAT); + uint col = GWN_vertformat_attr_add(&vert_format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint siz = GWN_vertformat_attr_add(&vert_format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + + Gwn_VertBuf *inst_vbo = GWN_vertbuf_create_with_format(&vert_format); + + GWN_vertbuf_data_alloc(inst_vbo, count); + + int v = 0; + while (DST.debug.spheres) { + void *next = DST.debug.spheres->next; + + GWN_vertbuf_attr_set(inst_vbo, mat, v, DST.debug.spheres->mat[0]); + GWN_vertbuf_attr_set(inst_vbo, col, v, DST.debug.spheres->color); + GWN_vertbuf_attr_set(inst_vbo, siz, v, &one); + v++; + + MEM_freeN(DST.debug.spheres); + DST.debug.spheres = next; + } + + Gwn_Batch *empty_sphere = DRW_cache_empty_sphere_get(); + + Gwn_Batch *draw_batch = GWN_batch_create(GWN_PRIM_LINES, empty_sphere->verts[0], NULL); + GWN_batch_instbuf_set(draw_batch, inst_vbo, true); + GWN_batch_program_set_builtin(draw_batch, GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); + + GWN_batch_draw(draw_batch); + GWN_batch_discard(draw_batch); +} + void drw_debug_draw(void) { drw_debug_draw_lines(); + drw_debug_draw_spheres(); } void drw_debug_init(void) diff --git a/source/blender/draw/intern/draw_debug.h b/source/blender/draw/intern/draw_debug.h index 1dab431fc88..319d2674279 100644 --- a/source/blender/draw/intern/draw_debug.h +++ b/source/blender/draw/intern/draw_debug.h @@ -34,6 +34,8 @@ void DRW_debug_modelmat(const float modelmat[4][4]); void DRW_debug_line_v3v3(const float v1[3], const float v2[3], const float color[4]); void DRW_debug_polygon_v3(const float (*v)[3], const int vert_len, const float color[4]); void DRW_debug_m4(const float m[4][4]); +void DRW_debug_m4_as_bbox(const float m[4][4], const float color[4], const bool invert); void DRW_debug_bbox(const BoundBox *bbox, const float color[4]); +void DRW_debug_sphere(const float center[3], const float radius, const float color[4]); #endif /* __DRAW_DEBUG_H__ */ diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 6eae3459c2b..d25e372c26e 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -296,6 +296,12 @@ typedef struct DRWDebugLine { float color[4]; } DRWDebugLine; +typedef struct DRWDebugSphere { + struct DRWDebugSphere *next; /* linked list */ + float mat[4][4]; + float color[4]; +} DRWDebugSphere; + /* ------------- DRAW MANAGER ------------ */ #define MAX_CLIP_PLANES 6 /* GL_MAX_CLIP_PLANES is at least 6 */ @@ -388,6 +394,7 @@ typedef struct DRWManager { struct { /* TODO(fclem) optimize: use chunks. */ DRWDebugLine *lines; + DRWDebugSphere *spheres; } debug; } DRWManager; -- cgit v1.2.3 From d5f048f8830d2cbb47a4845a9ca0a085f242f910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 16 Jul 2018 20:08:02 +0200 Subject: Eevee: Add debug visual for Cascaded Shadow Maps --- source/blender/draw/engines/eevee/eevee_lights.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index 431fc9fe561..dc9ce29a148 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -37,6 +37,8 @@ #define SHADOW_CASTER_ALLOC_CHUNK 16 +// #define DEBUG_CSM + static struct { struct GPUShader *shadow_sh; struct GPUShader *shadow_store_cube_sh[SHADOW_METHOD_MAX]; @@ -871,13 +873,13 @@ static void eevee_shadow_cascade_setup( /* Given 8 frustum corners */ float corners[8][3] = { /* Near Cap */ - {-1.0f, -1.0f, splits_start_ndc[c]}, { 1.0f, -1.0f, splits_start_ndc[c]}, + {-1.0f, -1.0f, splits_start_ndc[c]}, {-1.0f, 1.0f, splits_start_ndc[c]}, { 1.0f, 1.0f, splits_start_ndc[c]}, /* Far Cap */ - {-1.0f, -1.0f, splits_end_ndc[c]}, { 1.0f, -1.0f, splits_end_ndc[c]}, + {-1.0f, -1.0f, splits_end_ndc[c]}, {-1.0f, 1.0f, splits_end_ndc[c]}, { 1.0f, 1.0f, splits_end_ndc[c]} }; @@ -890,6 +892,15 @@ static void eevee_shadow_cascade_setup( float center[3]; frustum_min_bounding_sphere(corners, center, &(sh_data->radius[c])); +#ifdef DEBUG_CSM + float dbg_col[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + if (c < 3) { + dbg_col[c] = 1.0f; + } + DRW_debug_bbox((BoundBox *)&corners, dbg_col); + DRW_debug_sphere(center, sh_data->radius[c], dbg_col); +#endif + /* Project into lightspace */ mul_m4_v3(viewmat, center); @@ -919,6 +930,10 @@ static void eevee_shadow_cascade_setup( mul_m4_m4m4(sh_data->viewprojmat[c], projmat, viewmat); mul_m4_m4m4(cascade_data->shadowmat[c], texcomat, sh_data->viewprojmat[c]); + +#ifdef DEBUG_CSM + DRW_debug_m4_as_bbox(sh_data->viewprojmat[c], dbg_col, true); +#endif } ubo_data->bias = 0.05f * la->bias; -- cgit v1.2.3 From b85be88655ccc408d9545a077f33502fd583eb2e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 16 Jul 2018 22:29:26 +0200 Subject: Fix (IRC-reported) wrong usercount handling of deprecated IPO datablocks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit versionning code would unref those twice... Reported by @ßergey on IRC, thanks! --- source/blender/blenkernel/intern/ipo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 9d8ca1e352c..fd8cb6d6d98 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1732,8 +1732,7 @@ void do_versions_ipos_to_animato(Main *bmain) /* IPO first to take into any non-NLA'd Object Animation */ if (ob->ipo) { ipo_to_animdata(bmain, id, ob->ipo, NULL, NULL, NULL); - - id_us_min(&ob->ipo->id); + /* No need to id_us_min ipo ID here, ipo_to_animdata already does it. */ ob->ipo = NULL; } @@ -1766,7 +1765,7 @@ void do_versions_ipos_to_animato(Main *bmain) /* IPO second... */ if (ob->ipo) { ipo_to_animdata(bmain, id, ob->ipo, NULL, NULL, NULL); - id_us_min(&ob->ipo->id); + /* No need to id_us_min ipo ID here, ipo_to_animdata already does it. */ ob->ipo = NULL; { -- cgit v1.2.3 From dc3b3d945386b3651bb0fb4413753297f044e535 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 17 Jul 2018 00:45:56 +0200 Subject: UI: Lamp -> Light for the object type visibility operators Spotted in a live stream by Emilton Mendoza, thanks! --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/makesrna/intern/rna_space.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 36bfe5ec65e..693bb9c4efb 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3714,7 +3714,7 @@ class VIEW3D_PT_object_type_visibility(Panel): "lattice", "empty", "camera", - "lamp", + "light", "light_probe", "speaker", ) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index df838264cb7..d7024a149a3 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3100,8 +3100,8 @@ static void rna_def_space_view3d(BlenderRNA *brna) {"show_object_viewport_empty", "show_object_select_empty"}}, {"Camera", (1 << OB_CAMERA), {"show_object_viewport_camera", "show_object_select_camera"}}, - {"Lamp", (1 << OB_LAMP), - {"show_object_viewport_lamp", "show_object_select_lamp"}}, + {"Light", (1 << OB_LAMP), + {"show_object_viewport_light", "show_object_select_light"}}, {"Speaker", (1 << OB_SPEAKER), {"show_object_viewport_speaker", "show_object_select_speaker"}}, {"Light Probe", (1 << OB_LIGHTPROBE), -- cgit v1.2.3 From 7dcc7bd5eee89ebaba7fb036bb2f2970d1532804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 17 Jul 2018 11:36:07 +0200 Subject: Object Mode: Add back object bound display --- source/blender/draw/intern/draw_cache.c | 141 ++++++++++++++++++++++++++++++++ source/blender/draw/intern/draw_cache.h | 3 + source/blender/draw/modes/object_mode.c | 108 ++++++++++++++++++++++-- 3 files changed, 243 insertions(+), 9 deletions(-) diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 0d2317199fc..707aadbc229 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -63,6 +63,9 @@ static struct DRWShapeCache { Gwn_Batch *drw_line_endpoints; Gwn_Batch *drw_empty_cube; Gwn_Batch *drw_empty_sphere; + Gwn_Batch *drw_empty_cylinder; + Gwn_Batch *drw_empty_capsule_body; + Gwn_Batch *drw_empty_capsule_cap; Gwn_Batch *drw_empty_cone; Gwn_Batch *drw_arrows; Gwn_Batch *drw_axis_names; @@ -784,6 +787,144 @@ Gwn_Batch *DRW_cache_empty_cone_get(void) #undef NSEGMENTS } +Gwn_Batch *DRW_cache_empty_cylinder_get(void) +{ +#define NSEGMENTS 12 + if (!SHC.drw_empty_cylinder) { + /* a single ring of vertices */ + float p[NSEGMENTS][2]; + for (int i = 0; i < NSEGMENTS; ++i) { + float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS); + p[i][0] = cosf(angle); + p[i][1] = sinf(angle); + } + + /* Position Only 3D format */ + static Gwn_VertFormat format = { 0 }; + static struct { uint pos; } attr_id; + if (format.attr_len == 0) { + attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + } + + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 6); + + for (int i = 0; i < NSEGMENTS; ++i) { + float cv[2], pv[2], v[3]; + cv[0] = p[(i) % NSEGMENTS][0]; + cv[1] = p[(i) % NSEGMENTS][1]; + pv[0] = p[(i + 1) % NSEGMENTS][0]; + pv[1] = p[(i + 1) % NSEGMENTS][1]; + + /* cylinder sides */ + copy_v3_fl3(v, cv[0], cv[1], -1.0f); + GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6, v); + copy_v3_fl3(v, cv[0], cv[1], 1.0f); + GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 1, v); + + /* top ring */ + copy_v3_fl3(v, cv[0], cv[1], 1.0f); + GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 2, v); + copy_v3_fl3(v, pv[0], pv[1], 1.0f); + GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 3, v); + + /* bottom ring */ + copy_v3_fl3(v, cv[0], cv[1], -1.0f); + GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 4, v); + copy_v3_fl3(v, pv[0], pv[1], -1.0f); + GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 5, v); + } + + SHC.drw_empty_cylinder = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + } + return SHC.drw_empty_cylinder; +#undef NSEGMENTS +} + +Gwn_Batch *DRW_cache_empty_capsule_body_get(void) +{ + if (!SHC.drw_empty_capsule_body) { + const float pos[8][3] = { + { 1.0f, 0.0f, 1.0f}, + { 1.0f, 0.0f, 0.0f}, + { 0.0f, 1.0f, 1.0f}, + { 0.0f, 1.0f, 0.0f}, + {-1.0f, 0.0f, 1.0f}, + {-1.0f, 0.0f, 0.0f}, + { 0.0f, -1.0f, 1.0f}, + { 0.0f, -1.0f, 0.0f} + }; + + /* Position Only 3D format */ + static Gwn_VertFormat format = { 0 }; + static struct { uint pos; } attr_id; + if (format.attr_len == 0) { + attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + } + + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GWN_vertbuf_data_alloc(vbo, 8); + GWN_vertbuf_attr_fill(vbo, attr_id.pos, pos); + + SHC.drw_empty_capsule_body = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + } + return SHC.drw_empty_capsule_body; +} + +Gwn_Batch *DRW_cache_empty_capsule_cap_get(void) +{ +#define NSEGMENTS 24 /* Must be multiple of 2. */ + if (!SHC.drw_empty_capsule_cap) { + /* a single ring of vertices */ + float p[NSEGMENTS][2]; + for (int i = 0; i < NSEGMENTS; ++i) { + float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS); + p[i][0] = cosf(angle); + p[i][1] = sinf(angle); + } + + /* Position Only 3D format */ + static Gwn_VertFormat format = { 0 }; + static struct { uint pos; } attr_id; + if (format.attr_len == 0) { + attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + } + + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GWN_vertbuf_data_alloc(vbo, (NSEGMENTS * 2) * 2); + + /* Base circle */ + int vidx = 0; + for (int i = 0; i < NSEGMENTS; ++i) { + float v[3] = {0.0f, 0.0f, 0.0f}; + copy_v2_v2(v, p[(i) % NSEGMENTS]); + GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + copy_v2_v2(v, p[(i+1) % NSEGMENTS]); + GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + } + + for (int i = 0; i < NSEGMENTS / 2; ++i) { + float v[3] = {0.0f, 0.0f, 0.0f}; + int ci = i % NSEGMENTS; + int pi = (i + 1) % NSEGMENTS; + /* Y half circle */ + copy_v3_fl3(v, p[ci][0], 0.0f, p[ci][1]); + GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + copy_v3_fl3(v, p[pi][0], 0.0f, p[pi][1]); + GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + /* X half circle */ + copy_v3_fl3(v, 0.0f, p[ci][0], p[ci][1]); + GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + copy_v3_fl3(v, 0.0f, p[pi][0], p[pi][1]); + GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + } + + SHC.drw_empty_capsule_cap = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + } + return SHC.drw_empty_capsule_cap; +#undef NSEGMENTS +} + Gwn_Batch *DRW_cache_arrows_get(void) { if (!SHC.drw_arrows) { diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 9114a4d872d..c1c80d2c5bf 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -66,7 +66,10 @@ struct Gwn_Batch *DRW_cache_empty_cube_get(void); struct Gwn_Batch *DRW_cache_circle_get(void); struct Gwn_Batch *DRW_cache_square_get(void); struct Gwn_Batch *DRW_cache_empty_sphere_get(void); +struct Gwn_Batch *DRW_cache_empty_cylinder_get(void); struct Gwn_Batch *DRW_cache_empty_cone_get(void); +struct Gwn_Batch *DRW_cache_empty_capsule_cap_get(void); +struct Gwn_Batch *DRW_cache_empty_capsule_body_get(void); struct Gwn_Batch *DRW_cache_arrows_get(void); struct Gwn_Batch *DRW_cache_axis_names_get(void); struct Gwn_Batch *DRW_cache_image_plane_get(void); diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 2e41dbfd529..43400b3bac0 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -145,6 +145,9 @@ typedef struct OBJECT_PrivateData { DRWShadingGroup *cube; DRWShadingGroup *circle; DRWShadingGroup *sphere; + DRWShadingGroup *cylinder; + DRWShadingGroup *capsule_cap; + DRWShadingGroup *capsule_body; DRWShadingGroup *cone; DRWShadingGroup *single_arrow; DRWShadingGroup *single_arrow_line; @@ -1093,6 +1096,15 @@ static void OBJECT_cache_init(void *vedata) geom = DRW_cache_empty_sphere_get(); stl->g_data->sphere = shgroup_instance(psl->non_meshes, geom); + geom = DRW_cache_empty_cylinder_get(); + stl->g_data->cylinder = shgroup_instance(psl->non_meshes, geom); + + geom = DRW_cache_empty_capsule_cap_get(); + stl->g_data->capsule_cap = shgroup_instance(psl->non_meshes, geom); + + geom = DRW_cache_empty_capsule_body_get(); + stl->g_data->capsule_body = shgroup_instance(psl->non_meshes, geom); + geom = DRW_cache_empty_cone_get(); stl->g_data->cone = shgroup_instance(psl->non_meshes, geom); @@ -2146,6 +2158,82 @@ static void DRW_shgroup_texture_space(OBJECT_StorageList *stl, Object *ob, int t DRW_shgroup_call_dynamic_add(stl->g_data->texspace, color, &one, tmp); } +static void DRW_shgroup_bounds(OBJECT_StorageList *stl, Object *ob, int theme_id) +{ + float color[4], center[3], size[3], tmp[4][4], final_mat[4][4], one = 1.0f; + BoundBox bb_local; + + if (ob->type == OB_MBALL && !BKE_mball_is_basis(ob)) { + return; + } + + BoundBox *bb = BKE_object_boundbox_get(ob); + + if (!ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, + OB_MBALL, OB_ARMATURE, OB_LATTICE)) + { + const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; + bb = &bb_local; + BKE_boundbox_init_from_minmax(bb, min, max); + } + + UI_GetThemeColor4fv(theme_id, color); + BKE_boundbox_calc_center_aabb(bb, center); + BKE_boundbox_calc_size_aabb(bb, size); + + switch (ob->boundtype) { + case OB_BOUND_BOX: + size_to_mat4(tmp, size); + copy_v3_v3(tmp[3], center); + mul_m4_m4m4(tmp, ob->obmat, tmp); + DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &one, tmp); + break; + case OB_BOUND_SPHERE: + size[0] = max_fff(size[0], size[1], size[2]); + size[1] = size[2] = size[0]; + size_to_mat4(tmp, size); + copy_v3_v3(tmp[3], center); + mul_m4_m4m4(tmp, ob->obmat, tmp); + DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, &one, tmp); + break; + case OB_BOUND_CYLINDER: + size[0] = max_ff(size[0], size[1]); + size[1] = size[0]; + size_to_mat4(tmp, size); + copy_v3_v3(tmp[3], center); + mul_m4_m4m4(tmp, ob->obmat, tmp); + DRW_shgroup_call_dynamic_add(stl->g_data->cylinder, color, &one, tmp); + break; + case OB_BOUND_CONE: + size[0] = max_ff(size[0], size[1]); + size[1] = size[0]; + size_to_mat4(tmp, size); + copy_v3_v3(tmp[3], center); + /* Cone batch has base at 0 and is pointing towards +Y. */ + swap_v3_v3(tmp[1], tmp[2]); + tmp[3][2] -= size[2]; + mul_m4_m4m4(tmp, ob->obmat, tmp); + DRW_shgroup_call_dynamic_add(stl->g_data->cone, color, &one, tmp); + break; + case OB_BOUND_CAPSULE: + size[0] = max_ff(size[0], size[1]); + size[1] = size[0]; + scale_m4_fl(tmp, size[0]); + copy_v2_v2(tmp[3], center); + tmp[3][2] = center[2] + max_ff(0.0f, size[2] - size[0]); + mul_m4_m4m4(final_mat, ob->obmat, tmp); + DRW_shgroup_call_dynamic_add(stl->g_data->capsule_cap, color, &one, final_mat); + negate_v3(tmp[2]); + tmp[3][2] = center[2] - max_ff(0.0f, size[2] - size[0]); + mul_m4_m4m4(final_mat, ob->obmat, tmp); + DRW_shgroup_call_dynamic_add(stl->g_data->capsule_cap, color, &one, final_mat); + tmp[2][2] = max_ff(0.0f, size[2] * 2.0f - size[0] * 2.0f); + mul_m4_m4m4(final_mat, ob->obmat, tmp); + DRW_shgroup_call_dynamic_add(stl->g_data->capsule_body, color, &one, final_mat); + break; + } +} + static void OBJECT_cache_populate_particles(Object *ob, OBJECT_PassList *psl) { @@ -2398,17 +2486,8 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) DRW_shgroup_forcefield(stl, ob, view_layer); } - if (((ob->base_flag & BASE_FROMDUPLI) == 0) && - (md = modifiers_findByType(ob, eModifierType_Smoke)) && - (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && - (((SmokeModifierData *)md)->domain != NULL)) - { - DRW_shgroup_volume_extra(psl, stl, ob, view_layer, scene, md); - } - /* don't show object extras in set's */ if ((ob->base_flag & (BASE_FROM_SET | BASE_FROMDUPLI)) == 0) { - DRW_shgroup_object_center(stl, ob, view_layer, v3d); if (show_relations) { @@ -2434,6 +2513,17 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if ((ob->dtx & OB_TEXSPACE) && ELEM(ob->type, OB_MESH, OB_CURVE, OB_MBALL)) { DRW_shgroup_texture_space(stl, ob, theme_id); } + + if (ob->dtx & OB_DRAWBOUNDOX) { + DRW_shgroup_bounds(stl, ob, theme_id); + } + + if ((md = modifiers_findByType(ob, eModifierType_Smoke)) && + (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && + (((SmokeModifierData *)md)->domain != NULL)) + { + DRW_shgroup_volume_extra(psl, stl, ob, view_layer, scene, md); + } } } -- cgit v1.2.3 From 273482749ef7e937de8a1a2c886576a9418c7f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuk=20Garda=C5=A1evi=C4=87?= Date: Tue, 17 Jul 2018 11:59:24 +0200 Subject: UI: Minor fixes to separators on menus Closes D3547 --- release/scripts/startup/bl_ui/space_view3d.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 693bb9c4efb..77198168dcf 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -642,9 +642,12 @@ class VIEW3D_MT_view_align(Menu): layout.separator() - layout.operator("view3d.view_all", text="Center Cursor and View All").center = True layout.operator("view3d.camera_to_view", text="Align Active Camera to View") layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected") + + layout.separator() + + layout.operator("view3d.view_all", text="Center Cursor and View All").center = True layout.operator("view3d.view_center_cursor") layout.separator() @@ -667,6 +670,8 @@ class VIEW3D_MT_view_align_selected(Menu): props.align_active = True props.type = 'BOTTOM' + layout.separator() + props = layout.operator("view3d.view_axis", text="Front") props.align_active = True props.type = 'FRONT' @@ -675,6 +680,8 @@ class VIEW3D_MT_view_align_selected(Menu): props.align_active = True props.type = 'BACK' + layout.separator() + props = layout.operator("view3d.view_axis", text="Right") props.align_active = True props.type = 'RIGHT' @@ -2655,6 +2662,9 @@ class VIEW3D_MT_edit_mesh(Menu): layout.menu("VIEW3D_MT_edit_mesh_showhide") layout.operator_menu_enum("mesh.separate", "type") layout.menu("VIEW3D_MT_edit_mesh_clean") + + layout.separator() + layout.menu("VIEW3D_MT_edit_mesh_delete") @@ -2879,14 +2889,11 @@ class VIEW3D_MT_edit_mesh_edges_data(Menu): props.use_verts = True props.clear = True - layout.separator() - - layout.separator() - if with_freestyle: + layout.separator() + layout.operator("mesh.mark_freestyle_edge").clear = False layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True - layout.separator() class VIEW3D_MT_edit_mesh_edges(Menu): @@ -4493,9 +4500,9 @@ class VIEW3D_PT_pivot_point(Panel): col.label("Pivot Point") col.prop(toolsettings, "transform_pivot_point", expand=True) - col.separator() - if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}): + col.separator() + col.prop( toolsettings, "use_transform_pivot_point_align", -- cgit v1.2.3 From 84d4037363b325a279ef87b6b1c430be29984357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuk=20Garda=C5=A1evi=C4=87?= Date: Tue, 17 Jul 2018 12:17:42 +0200 Subject: UI: Single-column and flow layout for Scene properties See D3532 --- release/scripts/modules/rna_prop_ui.py | 17 +- .../startup/bl_ui/properties_physics_common.py | 87 +++++----- release/scripts/startup/bl_ui/properties_scene.py | 185 +++++++++++++++------ 3 files changed, 199 insertions(+), 90 deletions(-) diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index bdb0751c973..8453077be85 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -132,6 +132,11 @@ def draw(layout, context, context_member, property_type, use_edit=True): show_developer_ui = context.user_preferences.view.show_developer_ui rna_properties = {prop.identifier for prop in rna_item.bl_rna.properties if prop.is_runtime} if items else None + layout.use_property_split = True + layout.use_property_decorate = False # No animation. + + flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True) + for key, val in items: if key == '_RNA_UI': @@ -143,7 +148,6 @@ def draw(layout, context, context_member, property_type, use_edit=True): if is_rna and not show_developer_ui: continue - row = layout.row() to_dict = getattr(val, "to_dict", None) to_list = getattr(val, "to_list", None) @@ -157,17 +161,20 @@ def draw(layout, context, context_member, property_type, use_edit=True): else: val_draw = val + row = flow.row(align=True) box = row.box() if use_edit: split = box.split(percentage=0.75) - row = split.row() + row = split.row(align=True) else: - row = box.row() + row = box.row(align=True) + + row.alignment = "RIGHT" row.label(text=key, translate=False) - # explicit exception for arrays + # explicit exception for arrays. if to_dict or to_list: row.label(text=val_draw, translate=False) else: @@ -186,6 +193,8 @@ def draw(layout, context, context_member, property_type, use_edit=True): else: row.label(text="API Defined") + del flow + class PropertyPanel: """ diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index e071de0108b..c9bde32c53d 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -97,7 +97,7 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel): 'CONSTRAINT') # RB_TODO needs better icon -# cache-type can be 'PSYS' 'HAIR' 'SMOKE' etc +# cache-type can be 'PSYS' 'HAIR' 'SMOKE' etc. def point_cache_ui(self, context, cache, enabled, cachetype): layout = self.layout @@ -112,8 +112,8 @@ def point_cache_ui(self, context, cache, enabled, cachetype): col.operator("ptcache.add", icon='ZOOMIN', text="") col.operator("ptcache.remove", icon='ZOOMOUT', text="") - row = layout.row() if cachetype in {'PSYS', 'HAIR', 'SMOKE'}: + row = layout.row() row.prop(cache, "use_external") if cachetype == 'SMOKE': @@ -131,7 +131,9 @@ def point_cache_ui(self, context, cache, enabled, cachetype): cache_info = cache.info if cache_info: - layout.label(text=cache_info) + col = layout.column() + col.alignment = "RIGHT" + col.label(text=cache_info) else: if cachetype in {'SMOKE', 'DYNAMIC_PAINT'}: if not bpy.data.is_saved: @@ -147,45 +149,54 @@ def point_cache_ui(self, context, cache, enabled, cachetype): col.enabled = enabled col.prop(cache, "frame_start", text="Simulation Start") col.prop(cache, "frame_end") + if cachetype not in {'SMOKE', 'CLOTH', 'DYNAMIC_PAINT', 'RIGID_BODY'}: col.prop(cache, "frame_step") - if cachetype != 'SMOKE': - layout.label(text=cache.info) + cache_info = cache.info + if cachetype != 'SMOKE' and cache_info: # avoid empty space. + col = layout.column(align=True) + col.alignment = "RIGHT" + col.label(text=cache_info) can_bake = True if cachetype not in {'SMOKE', 'DYNAMIC_PAINT', 'RIGID_BODY'}: - split = layout.split() - split.enabled = enabled and bpy.data.is_saved + flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True) + flow.enabled = enabled and bpy.data.is_saved - col = split.column() - col.prop(cache, "use_disk_cache") + flow.use_property_split = True - col = split.column() - col.active = cache.use_disk_cache - col.prop(cache, "use_library_path", "Use Lib Path") + # NOTE: TODO temporarly used until the animate properties are properly skipped. + flow.use_property_decorate = False # No animation (remove this later on) - row = layout.row() - row.enabled = enabled and bpy.data.is_saved - row.active = cache.use_disk_cache - row.label(text="Compression:") - row.prop(cache, "compression", expand=True) + col = flow.column() + col.prop(cache, "use_disk_cache") - layout.separator() + subcol = col.column() + subcol.active = cache.use_disk_cache + subcol.prop(cache, "use_library_path", "Use Lib Path") + + col = flow.column() + col.enabled = enabled and bpy.data.is_saved + col.active = cache.use_disk_cache + col.prop(cache, "compression", text="Compression", expand=True) if cache.id_data.library and not cache.use_disk_cache: can_bake = False col = layout.column(align=True) - col.label(text="Linked object baking requires Disk Cache to be enabled", icon='INFO') + col.alignment = "RIGHT" + + col.separator() + + col.label(text="Linked object baking requires Disk Cache to be enabled") else: layout.separator() - split = layout.split() - split.active = can_bake - - col = split.column() + flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False) + col = flow.column() + col.active = can_bake if cache.is_baked is True: col.operator("ptcache.free_bake", text="Free Bake") @@ -200,7 +211,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): sub.enabled = enabled sub.operator("ptcache.bake_from_cache", text="Current Cache to Bake") - col = split.column() + col = flow.column() col.operator("ptcache.bake_all", text="Bake All Dynamics").bake = True col.operator("ptcache.free_bake_all", text="Free All Bakes") col.operator("ptcache.bake_all", text="Update All To Frame").bake = False @@ -212,31 +223,31 @@ def effector_weights_ui(self, context, weights, weight_type): layout.prop(weights, "group") - layout.use_property_split = False - - split = layout.split() - - split.prop(weights, "gravity", slider=True) - split.prop(weights, "all", slider=True) + # NOTE: TODO temporarly used until the animate properties are properly skipped + layout.use_property_decorate = False # No animation (remove this later on) - layout.separator() + flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True) - split = layout.split() - - col = split.column() + col = flow.column() + col.prop(weights, "gravity", slider=True) + col.prop(weights, "all", slider=True) col.prop(weights, "force", slider=True) col.prop(weights, "vortex", slider=True) + + col = flow.column() col.prop(weights, "magnetic", slider=True) + col.prop(weights, "harmonic", slider=True) + col.prop(weights, "charge", slider=True) + col.prop(weights, "lennardjones", slider=True) + + col = flow.column() col.prop(weights, "wind", slider=True) col.prop(weights, "curve_guide", slider=True) col.prop(weights, "texture", slider=True) if weight_type != 'SMOKE': col.prop(weights, "smokeflow", slider=True) - col = split.column() - col.prop(weights, "harmonic", slider=True) - col.prop(weights, "charge", slider=True) - col.prop(weights, "lennardjones", slider=True) + col = flow.column() col.prop(weights, "turbulence", slider=True) col.prop(weights, "drag", slider=True) col.prop(weights, "boid", slider=True) diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index d0fce0a2582..c0b8233a796 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -17,9 +17,9 @@ # ##### END GPL LICENSE BLOCK ##### # + import bpy from bpy.types import ( - Menu, Panel, UIList, ) @@ -71,6 +71,7 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel): def draw(self, context): layout = self.layout layout.use_property_split = True + scene = context.scene layout.prop(scene, "camera") @@ -92,13 +93,13 @@ class SCENE_PT_unit(SceneButtonsPanel, Panel): layout.use_property_split = True - col = layout.column() - col.prop(unit, "system") + flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) - col = layout.column() + col = flow.column() + col.prop(unit, "system") col.prop(unit, "system_rotation") - col = layout.column() + col = flow.column() col.enabled = unit.system != 'NONE' col.prop(unit, "scale_length") col.prop(unit, "use_separate") @@ -147,15 +148,17 @@ class SceneKeyingSetsPanel: propname = prop row = layout.row(align=True) - row.prop(item, toggle_prop, text="", icon='STYLUS_PRESSURE', toggle=True) # XXX: needs dedicated icon - subrow = row.row() + subrow = row.row(align=True) subrow.active = getattr(item, toggle_prop) + if subrow.active: subrow.prop(item, prop, text=label) else: subrow.prop(owner, propname, text=label) + row.prop(item, toggle_prop, text="", icon='STYLUS_PRESSURE', toggle=True) # XXX: needs dedicated icon + class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): bl_label = "Keying Sets" @@ -166,6 +169,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): layout = self.layout scene = context.scene + row = layout.row() col = row.column() @@ -175,20 +179,56 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): col.operator("anim.keying_set_add", icon='ZOOMIN', text="") col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="") + layout.use_property_split = True + layout.use_property_decorate = False # No animation. + + flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False) + ks = scene.keying_sets.active if ks and ks.is_path_absolute: - row = layout.row() - - col = row.column() + col = flow.column() col.prop(ks, "bl_description") - subcol = col.column() + subcol = flow.column() subcol.operator_context = 'INVOKE_DEFAULT' subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py" - col = row.column() - col.label(text="Keyframing Settings:") - self.draw_keyframing_settings(context, col, ks, None) + +class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): + bl_label = "Keyframing Settings" + bl_parent_id = "SCENE_PT_keying_sets" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + ks = context.scene.keying_sets.active + return (ks and ks.is_path_absolute) + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False # No animation. + + scene = context.scene + ks = scene.keying_sets.active + + flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) + + col = flow.column(align=True) + col.alignment = "RIGHT" + col.label(text="General Override") + + self.draw_keyframing_settings(context, col, ks, None) + + ksp = ks.paths.active + if ksp: + col.separator() + + col = flow.column(align=True) + col.alignment = "RIGHT" + col.label(text="Active Set Override") + + self.draw_keyframing_settings(context, col, ks, ksp) class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): @@ -219,34 +259,40 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="") col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="") + # TODO: 1) the template_any_ID needs to be fixed for the text alignment. + # 2) use_property_decorate has to properly skip the non animatable properties. + # Properties affected with needless draw: + # group_method, template_any_ID dropdown, use_entire_array + + layout.use_property_split = True + layout.use_property_decorate = False # No animation (remove this later on). + + flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=True) + ksp = ks.paths.active if ksp: - col = layout.column() - col.label(text="Target:") - col.template_any_ID(ksp, "id", "id_type") - col.template_path_builder(ksp, "data_path", ksp.id) - - row = col.row(align=True) - row.label(text="Array Target:") - row.prop(ksp, "use_entire_array", text="All Items") - if ksp.use_entire_array: - row.label(text=" ") # padding - else: - row.prop(ksp, "array_index", text="Index") + col = flow.column(align=True) + col.alignment = "RIGHT" + + col.template_any_ID(ksp, "id", "id_type", text="Target ID-Block") + + col.separator() - layout.separator() + col.template_path_builder(ksp, "data_path", ksp.id, text="Data Path") - row = layout.row() - col = row.column() - col.label(text="F-Curve Grouping:") - col.prop(ksp, "group_method", text="") + col = flow.column() + + col.prop(ksp, "use_entire_array", text="Array All Items") + + if not ksp.use_entire_array: + col.prop(ksp, "array_index", text="Index") + + col.separator() + + col.prop(ksp, "group_method", text="F-Curve Grouping") if ksp.group_method == 'NAMED': col.prop(ksp, "group") - col = row.column() - col.label(text="Keyframing Settings:") - self.draw_keyframing_settings(context, col, ks, ksp) - class SCENE_PT_color_management(SceneButtonsPanel, Panel): bl_label = "Color Management" @@ -260,16 +306,19 @@ class SCENE_PT_color_management(SceneButtonsPanel, Panel): scene = context.scene view = scene.view_settings - col = layout.column() + flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) + + col = flow.column() col.prop(scene.display_settings, "display_device") col.separator() - col = layout.column() col.prop(view, "view_transform") + col.prop(view, "look") + + col = flow.column() col.prop(view, "exposure") col.prop(view, "gamma") - col.prop(view, "look") col.separator() @@ -314,21 +363,28 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel): rd = context.scene.render ffmpeg = rd.ffmpeg - layout.prop(scene, "audio_volume") + flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True) - col = layout.column() - col.prop(scene, "audio_distance_model") + col = flow.column() + col.prop(scene, "audio_volume") + col.separator() + + col.prop(scene, "audio_distance_model") col.prop(ffmpeg, "audio_channels") + + col.separator() + + col = flow.column() col.prop(ffmpeg, "audio_mixrate", text="Sample Rate") - layout.separator() + col.separator() - col = layout.column(align=True) + col = col.column(align=True) col.prop(scene, "audio_doppler_speed", text="Doppler Speed") col.prop(scene, "audio_doppler_factor", text="Doppler Factor") - layout.separator() + col.separator() layout.operator("sound.bake_animation") @@ -372,7 +428,6 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel): layout.use_property_split = True scene = context.scene - rbw = scene.rigidbody_world if rbw is None: @@ -380,7 +435,28 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel): else: layout.operator("rigidbody.world_remove") - col = layout.column() + +class SCENE_PT_rigid_body_world_settings(SceneButtonsPanel, Panel): + bl_label = "Settings" + bl_parent_id = "SCENE_PT_rigid_body_world" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + scene = context.scene + return scene and scene.rigidbody_world and (context.engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + scene = context.scene + rbw = scene.rigidbody_world + + if rbw: + flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True) + + col = flow.column() col.active = rbw.enabled col = col.column() @@ -389,6 +465,9 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel): col = col.column() col.prop(rbw, "time_scale", text="Speed") + + col = flow.column() + col.active = rbw.enabled col.prop(rbw, "use_split_impulse") col = col.column() @@ -458,8 +537,12 @@ class SCENE_PT_simplify_viewport(SceneButtonsPanel, Panel): layout.active = rd.use_simplify - col = layout.column() + flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) + + col = flow.column() col.prop(rd, "simplify_subdivision", text="Max Subdivision") + + col = flow.column() col.prop(rd, "simplify_child_particles", text="Max Child Particles") @@ -476,8 +559,12 @@ class SCENE_PT_simplify_render(SceneButtonsPanel, Panel): layout.active = rd.use_simplify - col = layout.column() + flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) + + col = flow.column() col.prop(rd, "simplify_subdivision_render", text="Max Subdivision") + + col = flow.column() col.prop(rd, "simplify_child_particles_render", text="Max Child Particles") @@ -494,11 +581,13 @@ classes = ( SCENE_PT_unit, SCENE_PT_keying_sets, SCENE_PT_keying_set_paths, + SCENE_PT_keyframing_settings, SCENE_PT_color_management, SCENE_PT_color_management_curves, SCENE_PT_audio, SCENE_PT_physics, SCENE_PT_rigid_body_world, + SCENE_PT_rigid_body_world_settings, SCENE_PT_rigid_body_cache, SCENE_PT_rigid_body_field_weights, SCENE_PT_simplify, -- cgit v1.2.3 From 8d53b72b81212d9d87c71375d299af1dc535b487 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 17 Jul 2018 12:35:45 +0200 Subject: World: Added 'Viewport Display' panel The Properties->World tab had no Viewport Display panel. The world color itself was hidden when the 'use_node_tree' was enabled. Also renamed the World.horizon_color to World.color as it has nothing to do with the color of the horizon (old BI feature) --- intern/cycles/blender/addon/ui.py | 2 +- intern/cycles/blender/blender_shader.cpp | 2 +- release/scripts/startup/bl_ui/properties_world.py | 19 +++++++++++++++++-- source/blender/makesrna/intern/rna_world.c | 4 ++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 6e56e42f9b2..3d5ed6b9b44 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1227,7 +1227,7 @@ class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel): world = context.world if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'): - layout.prop(world, "horizon_color", text="Color") + layout.prop(world, "color") class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel): diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 6129565fec5..b3dfe1f6800 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -1330,7 +1330,7 @@ void BlenderSync::sync_world(BL::Depsgraph& b_depsgraph, bool update_all) } else if(b_world) { BackgroundNode *background = new BackgroundNode(); - background->color = get_float3(b_world.horizon_color()); + background->color = get_float3(b_world.color()); graph->add(background); ShaderNode *out = graph->output(); diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py index b6ea8054b0c..ed1b17a911d 100644 --- a/release/scripts/startup/bl_ui/properties_world.py +++ b/release/scripts/startup/bl_ui/properties_world.py @@ -90,7 +90,6 @@ class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel): class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel): bl_label = "Surface" - bl_context = "world" COMPAT_ENGINES = {'BLENDER_EEVEE'} @classmethod @@ -119,13 +118,29 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel): else: layout.label(text="No output node") else: - layout.prop(world, "horizon_color", text="Color") + layout.prop(world, "color") + + +class WORLD_PT_viewport_display(WorldButtonsPanel, Panel): + bl_label = "Viewport Display" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + return context.world + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + world = context.world + layout.prop(world, "color") classes = ( WORLD_PT_context_world, EEVEE_WORLD_PT_surface, EEVEE_WORLD_PT_mist, + WORLD_PT_viewport_display, WORLD_PT_custom_props, ) diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index ead67814f01..f4dc07cf6c3 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -207,10 +207,10 @@ void RNA_def_world(BlenderRNA *brna) rna_def_animdata_common(srna); /* colors */ - prop = RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "horr"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Horizon Color", "Color at the horizon"); + RNA_def_property_ui_text(prop, "Color", "Color of the background"); /* RNA_def_property_update(prop, 0, "rna_World_update"); */ /* render-only uses this */ RNA_def_property_update(prop, 0, "rna_World_draw_update"); -- cgit v1.2.3 From efe94793c0854454517f49f833f688e0652f4ec0 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 17 Jul 2018 13:55:43 +0200 Subject: Fix T56003: Opening image files as movies in VSE crashes. metadata loading code was assuming all videos in Blender were from FFMPEG... added empty place-holders for other types too, we probably could load some metadata from pictures or AVI files too! --- source/blender/imbuf/intern/anim_movie.c | 34 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 290226acf78..9ab2ee7dd21 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -243,21 +243,35 @@ void IMB_close_anim_proxies(struct anim *anim) struct IDProperty *IMB_anim_load_metadata(struct anim *anim) { + switch (anim->curtype) { + case ANIM_FFMPEG: + { #ifdef WITH_FFMPEG - AVDictionaryEntry *entry = NULL; + AVDictionaryEntry *entry = NULL; - BLI_assert(anim->pFormatCtx != NULL); - av_log(anim->pFormatCtx, AV_LOG_DEBUG, "METADATA FETCH\n"); + BLI_assert(anim->pFormatCtx != NULL); + av_log(anim->pFormatCtx, AV_LOG_DEBUG, "METADATA FETCH\n"); - while (true) { - entry = av_dict_get(anim->pFormatCtx->metadata, "", entry, AV_DICT_IGNORE_SUFFIX); - if (entry == NULL) break; + while (true) { + entry = av_dict_get(anim->pFormatCtx->metadata, "", entry, AV_DICT_IGNORE_SUFFIX); + if (entry == NULL) break; - /* Delay creation of the property group until there is actual metadata to put in there. */ - IMB_metadata_ensure(&anim->metadata); - IMB_metadata_set_field(anim->metadata, entry->key, entry->value); - } + /* Delay creation of the property group until there is actual metadata to put in there. */ + IMB_metadata_ensure(&anim->metadata); + IMB_metadata_set_field(anim->metadata, entry->key, entry->value); + } #endif + break; + } + case ANIM_SEQUENCE: + case ANIM_AVI: + case ANIM_MOVIE: + /* TODO */ + break; + case ANIM_NONE: + default: + break; + } return anim->metadata; } -- cgit v1.2.3 From 6d8e36b72355fd8642beca9c400388e9e2906f21 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 17 Jul 2018 12:33:47 +0200 Subject: Fix inconsistent shade smooth naming in object and edit mode. --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 77198168dcf..2c1ee3c5338 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1548,8 +1548,8 @@ class VIEW3D_MT_object(Menu): layout.separator() - layout.operator("object.shade_smooth", text="Smooth Shading") - layout.operator("object.shade_flat", text="Flat Shading") + layout.operator("object.shade_smooth") + layout.operator("object.shade_flat") layout.separator() -- cgit v1.2.3 From 117a5c0ac75a5c96dff3873bed93bd55f76192f2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 17 Jul 2018 14:21:16 +0200 Subject: Fix Python error removing studio lights in user preferences. --- release/scripts/startup/bl_operators/wm.py | 9 ++++++--- source/blender/makesrna/intern/rna_userdef.c | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index cfbc96696d6..3f0cdfa606b 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -2499,9 +2499,12 @@ class WM_OT_studiolight_uninstall(Operator): userpref = context.user_preferences for studio_light in userpref.studio_lights: if studio_light.index == self.index: - self._remove_path(pathlib.Path(studio_light.path)) - self._remove_path(pathlib.Path(studio_light.path_irr_cache)) - self._remove_path(pathlib.Path(studio_light.path_sh_cache)) + if len(studio_light.path) > 0: + self._remove_path(pathlib.Path(studio_light.path)) + if len(studio_light.path_irr_cache) > 0: + self._remove_path(pathlib.Path(studio_light.path_irr_cache)) + if len(studio_light.path_sh_cache) > 0: + self._remove_path(pathlib.Path(studio_light.path_sh_cache)) userpref.studio_lights.remove(studio_light) return {'FINISHED'} return {'CANCELLED'} diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 5557afdb33f..a54462e6b3e 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -683,7 +683,9 @@ static void rna_UserDef_studiolight_path_irr_cache_get(PointerRNA *ptr, char *va if (sl->path_irr_cache) { BLI_strncpy(value, sl->path_irr_cache, FILE_MAX); } - value[0] = 0x00; + else { + value[0] = '\0'; + } } static int rna_UserDef_studiolight_path_irr_cache_length(PointerRNA *ptr) @@ -702,7 +704,9 @@ static void rna_UserDef_studiolight_path_sh_cache_get(PointerRNA *ptr, char *val if (sl->path_sh_cache) { BLI_strncpy(value, sl->path_sh_cache, FILE_MAX); } - value[0] = 0x00; + else { + value[0] = '\0'; + } } static int rna_UserDef_studiolight_path_sh_cache_length(PointerRNA *ptr) -- cgit v1.2.3 From f8e2dba7fe429c6e514a2f12ff35addc8f474294 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 17 Jul 2018 13:58:08 +0200 Subject: UI: move specular light settings to Lights tab in user preferences. --- release/scripts/startup/bl_ui/space_userpref.py | 111 ++++++++++++------------ source/blender/makesrna/intern/rna_userdef.c | 6 -- 2 files changed, 55 insertions(+), 62 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index e2bca0b6b33..ed0389942ad 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -28,25 +28,6 @@ from bpy.app.translations import pgettext_iface as iface_ from bpy.app.translations import contexts as i18n_contexts -def opengl_light_buttons(column, light): - split = column.row() - - split.prop(light, "use", text="", icon='OUTLINER_OB_LIGHT' if light.use else 'LIGHT_DATA') - - col = split.column() - col.active = light.use - row = col.row() - row.label(text="Diffuse:") - row.prop(light, "diffuse_color", text="") - row = col.row() - row.label(text="Specular:") - row.prop(light, "specular_color", text="") - - col = split.column() - col.active = light.use - col.prop(light, "direction", text="") - - class USERPREF_HT_header(Header): bl_space_type = 'USER_PREFERENCES' @@ -550,43 +531,25 @@ class USERPREF_PT_system(Panel): col.label(text="Text Draw Options:") col.prop(system, "use_text_antialiasing") - col.separator() - - col.label(text="Textures:") - col.prop(system, "gl_texture_limit", text="Limit Size") - col.prop(system, "texture_time_out", text="Time Out") - col.prop(system, "texture_collection_rate", text="Collection Rate") - - col.separator() - - col.label(text="Images Draw Method:") - col.prop(system, "image_draw_method", text="") - - col.separator() - - col.label(text="Sequencer/Clip Editor:") - # currently disabled in the code - # col.prop(system, "prefetch_frames") - col.prop(system, "memory_cache_limit") - # 3. Column column = split.column() - column.label(text="Solid OpenGL Lights:") + column.label(text="Textures:") + column.prop(system, "gl_texture_limit", text="Limit Size") + column.prop(system, "texture_time_out", text="Time Out") + column.prop(system, "texture_collection_rate", text="Collection Rate") - split = column.split(percentage=0.1) - split.label() - split.label(text="Colors:") - split.label(text="Direction:") + column.separator() - light = system.solid_lights[0] - opengl_light_buttons(column, light) + column.label(text="Images Draw Method:") + column.prop(system, "image_draw_method", text="") - light = system.solid_lights[1] - opengl_light_buttons(column, light) + column.separator() - light = system.solid_lights[2] - opengl_light_buttons(column, light) + column.label(text="Sequencer/Clip Editor:") + # currently disabled in the code + # column.prop(system, "prefetch_frames") + column.prop(system, "memory_cache_limit") column.separator() @@ -1596,13 +1559,6 @@ class StudioLightPanelMixin(): def _get_lights(self, userpref): return [light for light in userpref.studio_lights if light.is_user_defined and light.orientation == self.sl_orientation] - def draw_header(self, context): - layout = self.layout - row = layout.row() - userpref = context.user_preferences - lights = self._get_lights(userpref) - row.label("({})".format(len(lights))) - def draw(self, context): layout = self.layout userpref = context.user_preferences @@ -1640,6 +1596,48 @@ class USERPREF_PT_studiolight_camera(Panel, StudioLightPanelMixin): sl_orientation = 'CAMERA' +class USERPREF_PT_studiolight_specular(Panel, StudioLightPanelMixin): + bl_label = "Specular Lights" + sl_orientation = 'CAMERA' + + @classmethod + def poll(cls, context): + userpref = context.user_preferences + return (userpref.active_section == 'LIGHTS') + + def opengl_light_buttons(self, column, light): + split = column.split() + + col = split.column() + col.prop(light, "use", text="Use", icon='OUTLINER_OB_LIGHT' if light.use else 'LIGHT_DATA') + + sub = col.column() + sub.active = light.use + sub.prop(light, "specular_color") + + col = split.column() + col.active = light.use + col.prop(light, "direction", text="") + + def draw(self, context): + layout = self.layout + column = layout.split() + + userpref = context.user_preferences + system = userpref.system + + light = system.solid_lights[0] + colsplit = column.split(percentage=0.85) + self.opengl_light_buttons(colsplit, light) + + light = system.solid_lights[1] + colsplit = column.split(percentage=0.85) + self.opengl_light_buttons(colsplit, light) + + light = system.solid_lights[2] + self.opengl_light_buttons(column, light) + + classes = ( USERPREF_HT_header, USERPREF_PT_tabs, @@ -1663,6 +1661,7 @@ classes = ( USERPREF_PT_studiolight_matcaps, USERPREF_PT_studiolight_world, USERPREF_PT_studiolight_camera, + USERPREF_PT_studiolight_specular, ) if __name__ == "__main__": # only for live edit. diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index a54462e6b3e..0823e8ddd9a 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3431,12 +3431,6 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Direction", "Direction that the OpenGL light is shining"); RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update"); - prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "col"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the OpenGL light"); - RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update"); - prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "spec"); RNA_def_property_array(prop, 3); -- cgit v1.2.3 From 7b3a18f0aa3ed9612aca602878a8ebdf2f1250f9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 11 Jul 2018 14:20:39 +0200 Subject: Cleanup: moving shading type into View3DShading. So all shading settings are in this struct and can be reused in the OpenGL render engine. --- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenloader/intern/readfile.c | 7 +- source/blender/blenloader/intern/versioning_280.c | 16 +++ source/blender/draw/engines/eevee/eevee_private.h | 2 +- source/blender/draw/intern/draw_manager.c | 10 +- source/blender/draw/modes/edit_mesh_mode.c | 2 +- source/blender/draw/modes/object_mode.c | 4 +- source/blender/editors/armature/armature_select.c | 4 +- source/blender/editors/curve/editcurve_paint.c | 2 +- source/blender/editors/include/ED_view3d.h | 2 +- source/blender/editors/render/render_opengl.c | 2 +- source/blender/editors/render/render_update.c | 2 +- .../editors/sculpt_paint/paint_image_proj.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 10 +- source/blender/editors/space_view3d/space_view3d.c | 11 +- source/blender/editors/space_view3d/view3d_draw.c | 2 +- .../editors/space_view3d/view3d_draw_legacy.c | 6 +- source/blender/editors/space_view3d/view3d_edit.c | 18 +-- .../editors/space_view3d/view3d_gizmo_ruler.c | 2 +- source/blender/editors/space_view3d/view3d_ruler.c | 2 +- .../blender/editors/space_view3d/view3d_select.c | 4 +- source/blender/editors/space_view3d/view3d_view.c | 6 +- source/blender/editors/transform/transform.c | 4 +- source/blender/makesdna/DNA_view3d_types.h | 10 +- source/blender/makesrna/intern/rna_space.c | 138 ++++++++++----------- 25 files changed, 145 insertions(+), 125 deletions(-) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6a8f46badd9..3b1416d2881 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1307,7 +1307,7 @@ static bool check_rendered_viewport_visible(Main *bmain) if (area->spacetype != SPACE_VIEW3D) { continue; } - if (v3d->drawtype == OB_RENDER) { + if (v3d->shading.type == OB_RENDER) { return true; } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f7d585e6fd7..18a6198254e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6606,9 +6606,10 @@ static void direct_link_area(FileData *fd, ScrArea *area) v3d->properties_storage = NULL; /* render can be quite heavy, set to solid on load */ - if (v3d->drawtype == OB_RENDER) - v3d->drawtype = OB_SOLID; - v3d->prev_drawtype = OB_SOLID; + if (v3d->shading.type == OB_RENDER) { + v3d->shading.type = OB_SOLID; + } + v3d->shading.prev_type = OB_SOLID; if (v3d->fx_settings.dof) v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index b854438ed47..5855b9d39de 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1599,5 +1599,21 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) { + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + if (v3d->drawtype == OB_RENDER) { + v3d->drawtype = OB_SOLID; + } + v3d->shading.type = v3d->drawtype; + v3d->shading.prev_type = OB_SOLID; + } + } + } + } + } } } diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index e2a875dca1f..1e43d6fba08 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -96,7 +96,7 @@ extern struct DrawEngineType draw_engine_eevee_type; } ((void)0) #define OVERLAY_ENABLED(v3d) ((v3d) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) -#define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->drawtype == OB_MATERIAL)) +#define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->shading.type == OB_MATERIAL)) #define LOOK_DEV_OVERLAY_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && (v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV)) #define USE_SCENE_LIGHT(v3d) ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS)))) #define LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d) (LOOK_DEV_MODE_ENABLED(v3d) && !(v3d->shading.flag & V3D_SHADING_SCENE_WORLD)) diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 1460f9a88f2..556f02c2899 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1200,7 +1200,7 @@ static void drw_engines_enable(ViewLayer *view_layer, RenderEngineType *engine_t Object *obact = OBACT(view_layer); const int mode = CTX_data_mode_enum_ex(DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode); View3D * v3d = DST.draw_ctx.v3d; - const int drawtype = v3d->drawtype; + const int drawtype = v3d->shading.type; drw_engines_enable_from_engine(engine_type, drawtype, v3d->shading.flag); @@ -1304,7 +1304,7 @@ void DRW_draw_view(const bContext *C) ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = DEG_get_evaluated_scene(depsgraph); - RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype); + RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type); GPUViewport *viewport = WM_draw_region_get_bound_viewport(ar); /* Reset before using it. */ @@ -1499,7 +1499,7 @@ void DRW_draw_render_loop( drw_state_prepare_clean_for_draw(&DST); Scene *scene = DEG_get_evaluated_scene(depsgraph); - RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype); + RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type); DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, viewport, NULL); } @@ -1764,7 +1764,7 @@ void DRW_draw_select_loop( DRW_ObjectFilterFn object_filter_fn, void *object_filter_user_data) { Scene *scene = DEG_get_evaluated_scene(depsgraph); - RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype); + RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type); ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); Object *obact = OBACT(view_layer); Object *obedit = OBEDIT_FROM_OBACT(obact); @@ -1983,7 +1983,7 @@ void DRW_draw_depth_loop( ARegion *ar, View3D *v3d) { Scene *scene = DEG_get_evaluated_scene(depsgraph); - RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype); + RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type); ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); RegionView3D *rv3d = ar->regiondata; diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 1e05b154974..b402494dfb5 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -365,7 +365,7 @@ static void EDIT_MESH_cache_init(void *vedata) const bool xray_enabled = ((draw_ctx->v3d->shading.flag & V3D_SHADING_XRAY) != 0) && - (draw_ctx->v3d->drawtype < OB_MATERIAL); + (draw_ctx->v3d->shading.type < OB_MATERIAL); stl->g_data->do_zbufclip = ((v3d->flag & V3D_ZBUF_SELECT) == 0) || xray_enabled; { diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 43400b3bac0..386261b64d7 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -907,7 +907,7 @@ static void OBJECT_cache_init(void *vedata) OBJECT_PrivateData *g_data; const DRWContextState *draw_ctx = DRW_context_state_get(); const bool xray_enabled = ((draw_ctx->v3d->shading.flag & V3D_SHADING_XRAY) != 0) && - (draw_ctx->v3d->drawtype < OB_MATERIAL); + (draw_ctx->v3d->shading.type < OB_MATERIAL); /* TODO : use dpi setting for enabling the second pass */ const bool do_outline_expand = false; @@ -2337,7 +2337,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if ((ob != draw_ctx->object_edit) && !((ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT))) { struct Gwn_Batch *geom; const bool xray_enabled = ((v3d->shading.flag & V3D_SHADING_XRAY) != 0) && - (v3d->drawtype < OB_MATERIAL); + (v3d->shading.type < OB_MATERIAL); if (xray_enabled) { geom = DRW_cache_object_edge_detection_get(ob, NULL); } diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index ae2e7339c66..7602bccc48c 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -426,7 +426,7 @@ static EditBone *get_nearest_editbonepoint( if (use_cycle) { static int last_mval[2] = {-100, -100}; - if (vc->v3d->drawtype > OB_WIRE) { + if (vc->v3d->shading.type > OB_WIRE) { do_nearest = true; if (len_manhattan_v2v2_int(vc->mval, last_mval) < 3) { do_nearest = false; @@ -435,7 +435,7 @@ static EditBone *get_nearest_editbonepoint( copy_v2_v2_int(last_mval, vc->mval); } else { - if (vc->v3d->drawtype > OB_WIRE) { + if (vc->v3d->shading.type > OB_WIRE) { do_nearest = true; } } diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 130e3cc5475..927b8b8514d 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -1095,7 +1095,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) } else { if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) && - (v3d->drawtype > OB_WIRE)) + (v3d->shading.type > OB_WIRE)) { /* needed or else the draw matrix can be incorrect */ view3d_operator_needs_opengl(C); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index efcf5978968..516b121031e 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -523,7 +523,7 @@ void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *a void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa); #define V3D_IS_ZBUF(v3d) \ - (((v3d)->flag & V3D_ZBUF_SELECT) && ((v3d)->drawtype > OB_WIRE)) + (((v3d)->flag & V3D_ZBUF_SELECT) && ((v3d)->shading.type > OB_WIRE)) void ED_view3d_id_remap(struct View3D *v3d, const struct ID *old_id, struct ID *new_id); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 1b8d8cf7af2..22000bd2a03 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -355,7 +355,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R if (view_context) { ibuf_view = ED_view3d_draw_offscreen_imbuf( - depsgraph, scene, v3d->drawtype, + depsgraph, scene, v3d->shading.type, v3d, ar, sizex, sizey, IB_rectfloat, draw_flags, alpha_mode, oglrender->ofs_samples, viewname, oglrender->ofs, err_out); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index e473b98b4a1..09d89e3b90f 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -144,7 +144,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update } else { RenderEngineType *engine_type = - ED_view3d_engine_type(scene, v3d->drawtype); + ED_view3d_engine_type(scene, v3d->shading.type); if (updated) { DRW_notify_view_update( (&(DRWUpdateContext){ diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 04329697b54..7badd30e6d0 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -5442,7 +5442,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) if (h > maxsize) h = maxsize; ibuf = ED_view3d_draw_offscreen_imbuf( - depsgraph, scene, v3d->drawtype, + depsgraph, scene, v3d->shading.type, v3d, CTX_wm_region(C), w, h, IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL, NULL, err_out); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f48d7ef578f..a6714927249 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -121,10 +121,10 @@ int view3d_effective_drawtype(const struct View3D *v3d) { - if (v3d->drawtype == OB_RENDER) { - return v3d->prev_drawtype; + if (v3d->shading.type == OB_RENDER) { + return v3d->shading.prev_type; } - return v3d->drawtype; + return v3d->shading.type; } static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) @@ -139,10 +139,10 @@ static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) return true; /* if its drawing textures with zbuf sel, then don't draw dots */ - if (dt == OB_TEXTURE && vd->drawtype == OB_TEXTURE) + if (dt == OB_TEXTURE && vd->shading.type == OB_TEXTURE) return false; - if ((vd->drawtype >= OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX)) + if ((vd->shading.type >= OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX)) return false; return true; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 75c9b4a050f..188ee928f3c 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -293,7 +293,7 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa) { wmWindowManager *wm = bmain->wm.first; - if (v3d->drawtype != OB_RENDER) { + if (v3d->shading.type != OB_RENDER) { ARegion *ar; for (ar = sa->regionbase.first; ar; ar = ar->next) { @@ -324,7 +324,8 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->grid = 1.0f; v3d->gridlines = 16; v3d->gridsubdiv = 10; - v3d->drawtype = OB_SOLID; + v3d->shading.type = OB_SOLID; + v3d->shading.prev_type = OB_SOLID; v3d->shading.flag = V3D_SHADING_SPECULAR_HIGHLIGHT; v3d->shading.light = V3D_LIGHTING_STUDIO; v3d->shading.shadow_intensity = 0.5f; @@ -431,8 +432,8 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) v3dn->lay = v3do->localvd->lay & 0xFFFFFF; } - if (v3dn->drawtype == OB_RENDER) - v3dn->drawtype = OB_SOLID; + if (v3dn->shading.type == OB_RENDER) + v3dn->shading.type = OB_SOLID; /* copy or clear inside new stuff */ @@ -1421,7 +1422,7 @@ static void space_view3d_listener( case NC_MATERIAL: switch (wmn->data) { case ND_NODES: - if (v3d->drawtype == OB_TEXTURE) + if (v3d->shading.type == OB_TEXTURE) ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); break; } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 4928f6e1f28..e03fe149af6 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1589,7 +1589,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( v3d.camera = camera; v3d.lay = scene->lay; - v3d.drawtype = drawtype; + v3d.shading.type = drawtype; v3d.flag2 = V3D_RENDER_OVERRIDE; if (draw_flags & V3D_OFSDRAW_USE_GPENCIL) { diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index cc7f23e2c18..94cd4dfc73d 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -179,7 +179,7 @@ static void backdrawview3d( } /* texture paint mode sampling */ else if (obact_eval && (obact_eval->mode & OB_MODE_TEXTURE_PAINT) && - (v3d->drawtype > OB_WIRE)) + (v3d->shading.type > OB_WIRE)) { /* do nothing */ } @@ -211,7 +211,7 @@ static void backdrawview3d( #endif #if 0 /* v3d->zbuf deprecated */ - if (v3d->drawtype > OB_WIRE) v3d->zbuf = true; + if (v3d->shading.type > OB_WIRE) v3d->zbuf = true; #endif /* dithering and AA break color coding, so disable */ @@ -1033,7 +1033,7 @@ bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View bool use_border; /* test if there is a 3d view rendering */ - if (v3d->drawtype != OB_RENDER || !view3d_main_region_do_render_draw(scene)) + if (v3d->shading.type != OB_RENDER || !view3d_main_region_do_render_draw(scene)) return false; /* test if there is a border render */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 792a341fba4..2cc1236e5c6 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4873,7 +4873,7 @@ static int toggle_shading_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); if (type == OB_SOLID) { - if (v3d->drawtype == OB_SOLID) { + if (v3d->shading.type == OB_SOLID) { /* Toggle X-Ray if already in solid mode. */ if (ED_operator_posemode(C) || ED_operator_editmesh(C)) { v3d->flag ^= V3D_ZBUF_SELECT; @@ -4884,24 +4884,24 @@ static int toggle_shading_exec(bContext *C, wmOperator *op) } else { /* Go to solid mode. */ - v3d->drawtype = OB_SOLID; + v3d->shading.type = OB_SOLID; } } else if (type == OB_MATERIAL) { - if (v3d->drawtype == OB_MATERIAL) { - v3d->drawtype = OB_SOLID; + if (v3d->shading.type == OB_MATERIAL) { + v3d->shading.type = OB_SOLID; } else { - v3d->drawtype = OB_MATERIAL; + v3d->shading.type = OB_MATERIAL; } } else if (type == OB_RENDER) { - if (v3d->drawtype == OB_RENDER) { - v3d->drawtype = v3d->prev_drawtype; + if (v3d->shading.type == OB_RENDER) { + v3d->shading.type = v3d->shading.prev_type; } else { - v3d->prev_drawtype = v3d->drawtype; - v3d->drawtype = OB_RENDER; + v3d->shading.prev_type = v3d->shading.type; + v3d->shading.type = OB_RENDER; } } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index db7ba040b3b..e9a8dd5ee08 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -1052,7 +1052,7 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *UNUSED(op), const wm wmGizmoMap *gzmap = ar->gizmo_map; wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); - const bool use_depth = (v3d->drawtype >= OB_SOLID); + const bool use_depth = (v3d->shading.type >= OB_SOLID); /* Create new line */ RulerItem *ruler_item; diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 4617b92c780..133af8e6da7 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -911,7 +911,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) BLI_listbase_is_empty(&ruler_info->items)) { View3D *v3d = CTX_wm_view3d(C); - const bool use_depth = (v3d->drawtype >= OB_SOLID); + const bool use_depth = (v3d->shading.type >= OB_SOLID); /* Create new line */ RulerItem *ruler_item_prev = ruler_item_active_get(ruler_info); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 3175075e9c3..7da69c5b2d5 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1189,7 +1189,7 @@ static int mixed_bones_object_selectbuffer( /* define if we use solid nearest select or not */ if (use_cycle) { - if (v3d->drawtype > OB_WIRE) { + if (v3d->shading.type > OB_WIRE) { do_nearest = true; if (len_manhattan_v2v2_int(mval, last_mval) < 3) { do_nearest = false; @@ -1198,7 +1198,7 @@ static int mixed_bones_object_selectbuffer( copy_v2_v2_int(last_mval, mval); } else { - if (v3d->drawtype > OB_WIRE) { + if (v3d->shading.type > OB_WIRE) { do_nearest = true; } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index bb0745b1998..8a4a0efad2a 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -184,7 +184,7 @@ void ED_view3d_smooth_view_ex( } /* skip smooth viewing for render engine draw */ - if (smooth_viewtx && v3d->drawtype != OB_RENDER) { + if (smooth_viewtx && v3d->shading.type != OB_RENDER) { bool changed = false; /* zero means no difference */ if (sview->camera_old != sview->camera) @@ -1003,7 +1003,7 @@ int view3d_opengl_select( * the object & bone view locking takes 'rect' into account, see: T51629. */ ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect); - if (v3d->drawtype > OB_WIRE) { + if (v3d->shading.type > OB_WIRE) { GPU_depth_test(true); } @@ -1048,7 +1048,7 @@ int view3d_opengl_select( G.f &= ~G_PICKSEL; ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL); - if (v3d->drawtype > OB_WIRE) { + if (v3d->shading.type > OB_WIRE) { GPU_depth_test(false); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index c49c9a8706c..e9abdd80d20 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -6654,7 +6654,7 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t if (t->spacetype == SPACE_VIEW3D) { v3d = t->sa ? t->sa->spacedata.first : NULL; rv3d = t->ar ? t->ar->regiondata : NULL; - use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); + use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->shading.type > OB_WIRE); } calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, true); @@ -6849,7 +6849,7 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t if (t->spacetype == SPACE_VIEW3D) { v3d = t->sa ? t->sa->spacedata.first : NULL; rv3d = t->ar ? t->ar->regiondata : NULL; - use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); + use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->shading.type > OB_WIRE); } calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, false); diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 8abec3474f9..fedc604f120 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -135,11 +135,14 @@ typedef struct View3DCursor { /* 3D Viewport Shading setings */ typedef struct View3DShading { + short type; /* Shading type (VIEW3D_SHADE_SOLID, ..) */ + short prev_type; /* Runtime, for toggle between rendered viewport. */ + short flag; short color_type; short light; - char pad[2]; + short pad[3]; char studio_light[256]; /* FILE_MAXFILE */ char matcap[256]; /* FILE_MAXFILE */ @@ -267,9 +270,8 @@ typedef struct View3D { float stereo3d_convergence_alpha; /* Display settings */ - short drawtype; /* Shading mode (OB_SOLID, OB_TEXTURE, ..) */ - short prev_drawtype; /* Runtime, for toggle between rendered viewport. */ - int pad5; + short drawtype DNA_DEPRECATED; + short pad5[3]; View3DShading shading; View3DOverlay overlay; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d7024a149a3..66ff29a8c16 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -581,14 +581,6 @@ static void rna_SpaceView3D_layer_update(Main *bmain, Scene *UNUSED(scene), Poin DEG_on_visible_update(bmain, false); } -static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) -{ - View3D *v3d = (View3D *)(ptr->data); - ScrArea *sa = rna_area_from_space(ptr); - - ED_view3d_shade_update(bmain, v3d, sa); -} - static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); @@ -685,29 +677,46 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value ED_view3d_from_m4(mat, rv3d->ofs, rv3d->viewquat, &rv3d->dist); } +static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + bScreen *screen = ptr->id.data; + + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + if (&v3d->shading == ptr->data) { + ED_view3d_shade_update(bmain, v3d, sa); + return; + } + } + } + } +} + static int rna_3DViewShading_type_get(PointerRNA *ptr) { bScreen *screen = ptr->id.data; Scene *scene = WM_windows_scene_get_from_screen(G_MAIN->wm.first, screen); RenderEngineType *type = RE_engines_find(scene->r.engine); - View3D *v3d = (View3D *)ptr->data; + View3DShading *shading = (View3DShading *)ptr->data; - if (!BKE_scene_uses_blender_eevee(scene) && v3d->drawtype == OB_RENDER) { + if (!BKE_scene_uses_blender_eevee(scene) && shading->type == OB_RENDER) { if (!(type && type->view_draw)) { return OB_MATERIAL; } } - return v3d->drawtype; + return shading->type; } static void rna_3DViewShading_type_set(PointerRNA *ptr, int value) { - View3D *v3d = (View3D *)ptr->data; - if (value != v3d->drawtype && value == OB_RENDER) { - v3d->prev_drawtype = v3d->drawtype; + View3DShading *shading = (View3DShading *)ptr->data; + if (value != shading->type && value == OB_RENDER) { + shading->prev_type = shading->type; } - v3d->drawtype = value; + shading->type = value; } static const EnumPropertyItem *rna_3DViewShading_type_itemf( @@ -743,13 +752,13 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf( /* Shading.selected_studio_light */ static PointerRNA rna_View3DShading_selected_studio_light_get(PointerRNA *ptr) { - View3D *v3d = (View3D *)ptr->data; + View3DShading *shading = (View3DShading *)ptr->data; StudioLight *sl; - if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) { - sl = BKE_studiolight_find(v3d->shading.matcap, STUDIOLIGHT_FLAG_ALL); + if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) { + sl = BKE_studiolight_find(shading->matcap, STUDIOLIGHT_FLAG_ALL); } else { - sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_FLAG_ALL); + sl = BKE_studiolight_find(shading->studio_light, STUDIOLIGHT_FLAG_ALL); } return rna_pointer_inherit_refine(ptr, &RNA_StudioLight, sl); } @@ -757,33 +766,33 @@ static PointerRNA rna_View3DShading_selected_studio_light_get(PointerRNA *ptr) /* shading.light */ static int rna_View3DShading_light_get(PointerRNA *ptr) { - View3D *v3d = (View3D *)ptr->data; - return v3d->shading.light; + View3DShading *shading = (View3DShading *)ptr->data; + return shading->light; } static void rna_View3DShading_light_set(PointerRNA *ptr, int value) { - View3D *v3d = (View3D *)ptr->data; - if (value == V3D_LIGHTING_MATCAP && v3d->shading.color_type == V3D_SHADING_TEXTURE_COLOR) { - v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR; + View3DShading *shading = (View3DShading *)ptr->data; + if (value == V3D_LIGHTING_MATCAP && shading->color_type == V3D_SHADING_TEXTURE_COLOR) { + shading->color_type = V3D_SHADING_MATERIAL_COLOR; } - v3d->shading.light = value; + shading->light = value; } static const EnumPropertyItem *rna_View3DShading_color_type_itemf( bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - View3D *v3d = (View3D *)ptr->data; + View3DShading *shading = (View3DShading *)ptr->data; int totitem = 0; EnumPropertyItem *item = NULL; - if (v3d->drawtype == OB_SOLID) { + if (shading->type == OB_SOLID) { RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_SINGLE_COLOR); RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_MATERIAL_COLOR); RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_RANDOM_COLOR); - if (v3d->shading.light != V3D_LIGHTING_MATCAP) { + if (shading->light != V3D_LIGHTING_MATCAP) { RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_TEXTURE_COLOR); } } @@ -796,15 +805,15 @@ static const EnumPropertyItem *rna_View3DShading_color_type_itemf( /* Studio light */ static int rna_View3DShading_studio_light_get(PointerRNA *ptr) { - View3D *v3d = (View3D *)ptr->data; - char *dna_storage = v3d->shading.studio_light; + View3DShading *shading = (View3DShading *)ptr->data; + char *dna_storage = shading->studio_light; int flag = STUDIOLIGHT_ORIENTATIONS_SOLID; - if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) { + if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) { flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL; - dna_storage = v3d->shading.matcap; + dna_storage = shading->matcap; } - else if (v3d->drawtype == OB_MATERIAL) { + else if (shading->type == OB_MATERIAL) { flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE; } StudioLight *sl = BKE_studiolight_find(dna_storage, flag); @@ -819,15 +828,15 @@ static int rna_View3DShading_studio_light_get(PointerRNA *ptr) static void rna_View3DShading_studio_light_set(PointerRNA *ptr, int value) { - View3D *v3d = (View3D *)ptr->data; - char *dna_storage = v3d->shading.studio_light; + View3DShading *shading = (View3DShading *)ptr->data; + char *dna_storage = shading->studio_light; int flag = STUDIOLIGHT_ORIENTATIONS_SOLID; - if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) { + if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) { flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL; - dna_storage = v3d->shading.matcap; + dna_storage = shading->matcap; } - else if (v3d->drawtype == OB_MATERIAL) { + else if (shading->type == OB_MATERIAL) { flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE; } StudioLight *sl = BKE_studiolight_findindex(value, flag); @@ -840,15 +849,15 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf( bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - View3D *v3d = (View3D *)ptr->data; + View3DShading *shading = (View3DShading *)ptr->data; EnumPropertyItem *item = NULL; int totitem = 0; - if (v3d->drawtype == OB_SOLID && v3d->shading.light == V3D_LIGHTING_MATCAP) { + if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) { const int flags = (STUDIOLIGHT_EXTERNAL_FILE | STUDIOLIGHT_ORIENTATION_VIEWNORMAL); LISTBASE_FOREACH(StudioLight *, sl, BKE_studiolight_listbase()) { - int icon_id = (v3d->shading.flag & V3D_SHADING_MATCAP_FLIP_X) ? sl->icon_id_matcap_flipped: sl->icon_id_matcap; + int icon_id = (shading->flag & V3D_SHADING_MATCAP_FLIP_X) ? sl->icon_id_matcap_flipped: sl->icon_id_matcap; if ((sl->flag & flags) == flags) { EnumPropertyItem tmp = {sl->index, sl->name, icon_id, sl->name, ""}; RNA_enum_item_add(&item, &totitem, &tmp); @@ -862,12 +871,12 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf( if (sl->flag & STUDIOLIGHT_INTERNAL) { /* always show internal lights for solid */ - if (v3d->drawtype == OB_SOLID) { + if (shading->type == OB_SOLID) { show_studiolight = true; } } else { - switch (v3d->drawtype) { + switch (shading->type) { case OB_SOLID: case OB_TEXTURE: show_studiolight = ( @@ -914,11 +923,6 @@ static int rna_SpaceView3D_icon_from_show_object_viewport_get(PointerRNA *ptr) return ICON_VIS_SEL_11 + (view_value << 1) + select_value; } -static PointerRNA rna_SpaceView3D_shading_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_View3DShading, ptr->data); -} - static char *rna_View3DShading_path(PointerRNA *UNUSED(ptr)) { return BLI_sprintfN("shading"); @@ -2398,13 +2402,10 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) PropertyRNA *prop; srna = RNA_def_struct(brna, "View3DShading", NULL); - RNA_def_struct_sdna(srna, "View3D"); - RNA_def_struct_nested(brna, srna, "SpaceView3D"); RNA_def_struct_path_func(srna, "rna_View3DShading_path"); RNA_def_struct_ui_text(srna, "3D View Shading Settings", "Settings for shading in the 3D viewport"); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "drawtype"); RNA_def_property_enum_items(prop, rna_enum_shading_type_items); RNA_def_property_enum_funcs(prop, "rna_3DViewShading_type_get", "rna_3DViewShading_type_set", "rna_3DViewShading_type_itemf"); @@ -2412,14 +2413,14 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update"); prop = RNA_def_property(srna, "light", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "shading.light"); + RNA_def_property_enum_sdna(prop, NULL, "light"); RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items); RNA_def_property_enum_funcs(prop, "rna_View3DShading_light_get", "rna_View3DShading_light_set", NULL); RNA_def_property_ui_text(prop, "Lighting", "Lighting Method for Solid/Texture Viewport Shading"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_object_outline", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_OBJECT_OUTLINE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_OBJECT_OUTLINE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Outline", "Show Object Outline"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); @@ -2432,13 +2433,13 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_cavity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_CAVITY); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_CAVITY); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Cavity", "Show Cavity"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "cavity_ridge_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "shading.cavity_ridge_factor"); + RNA_def_property_float_sdna(prop, NULL, "cavity_ridge_factor"); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_ui_text(prop, "Ridge", "Factor for the ridges"); RNA_def_property_range(prop, 0.0f, 250.0f); @@ -2447,7 +2448,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "cavity_valley_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "shading.cavity_valley_factor"); + RNA_def_property_float_sdna(prop, NULL, "cavity_valley_factor"); RNA_def_property_float_default(prop, 1.0); RNA_def_property_ui_text(prop, "Valley", "Factor for the valleys"); RNA_def_property_range(prop, 0.0f, 250.0f); @@ -2464,7 +2465,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_define_verify_sdna(1); prop = RNA_def_property(srna, "studiolight_rotate_z", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "shading.studiolight_rot_z"); + RNA_def_property_float_sdna(prop, NULL, "studiolight_rot_z"); RNA_def_property_float_default(prop, 0.0); RNA_def_property_ui_text(prop, "Studiolight Rotation", "Rotation of the studiolight around the Z-Axis"); RNA_def_property_range(prop, -M_PI, M_PI); @@ -2472,33 +2473,33 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "color_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "shading.color_type"); + RNA_def_property_enum_sdna(prop, NULL, "color_type"); RNA_def_property_enum_items(prop, rna_enum_shading_color_type_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_View3DShading_color_type_itemf"); RNA_def_property_ui_text(prop, "Color", "Color Type"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "single_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "shading.single_color"); + RNA_def_property_float_sdna(prop, NULL, "single_color"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Color", "Color for single color mode"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SHADOW); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SHADOW); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Shadow", "Show Shadow"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_xray", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_XRAY); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_XRAY); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "X-Ray", "Show whole scene transparent"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "xray_alpha", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "shading.xray_alpha"); + RNA_def_property_float_sdna(prop, NULL, "xray_alpha"); RNA_def_property_float_default(prop, 0.5); RNA_def_property_ui_text(prop, "X-Ray Alpha", "Amount of alpha to use"); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -2506,32 +2507,32 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "use_scene_lights", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SCENE_LIGHTS); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_LIGHTS); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Scene Lights", "Render lights and light probes of the scene"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "use_scene_world", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SCENE_WORLD); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_WORLD); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Scene World", "Use scene world for lighting"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_specular_highlight", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shading.flag", V3D_SHADING_SPECULAR_HIGHLIGHT); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SPECULAR_HIGHLIGHT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Specular Highlights", "Render specular highlights"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "object_outline_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "shading.object_outline_color"); + RNA_def_property_float_sdna(prop, NULL, "object_outline_color"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Outline Color", "Color for object outline"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "shadow_intensity", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "shading.shadow_intensity"); + RNA_def_property_float_sdna(prop, NULL, "shadow_intensity"); RNA_def_property_float_default(prop, 0.5); RNA_def_property_ui_text(prop, "Shadow Intensity", "Darkness of shadows"); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -2540,7 +2541,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "studiolight_background_alpha", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "shading.studiolight_background"); + RNA_def_property_float_sdna(prop, NULL, "studiolight_background"); RNA_def_property_float_default(prop, 0.0); RNA_def_property_ui_text(prop, "Background", "Show the studiolight in the background"); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -3134,7 +3135,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "View3DShading"); - RNA_def_property_pointer_funcs(prop, "rna_SpaceView3D_shading_get", NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Shading Settings", "Settings for shading in the 3D viewport"); prop = RNA_def_property(srna, "overlay", PROP_POINTER, PROP_NONE); -- cgit v1.2.3 From 644fadf2f0131f8ecd73da6c994ec8a8d4b0a7d1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 11 Jul 2018 11:43:56 +0200 Subject: Render: add "OpenGL" render engine. This is intended for quick renders for previsualization, animation previews or sequencer previews. It provides the same settings as found in the 3D view Shading popover in solid display mode, but in the scene render properties. The "Workbench" engine was removed, and this name no longer appears in the user interface, it's purely an internal name. We might come up with a better name for this OpenGL engine still, but it's good to be consistent with the OpenGL Render operator name since this has a similar purpose. --- .../startup/bl_ui/properties_data_armature.py | 2 +- .../scripts/startup/bl_ui/properties_data_bone.py | 2 +- .../startup/bl_ui/properties_data_camera.py | 22 +-- .../scripts/startup/bl_ui/properties_data_curve.py | 4 +- .../startup/bl_ui/properties_data_lattice.py | 2 +- .../scripts/startup/bl_ui/properties_data_light.py | 77 +-------- .../scripts/startup/bl_ui/properties_data_mesh.py | 22 ++- .../startup/bl_ui/properties_data_metaball.py | 4 +- .../startup/bl_ui/properties_data_speaker.py | 10 +- .../scripts/startup/bl_ui/properties_material.py | 4 +- release/scripts/startup/bl_ui/properties_object.py | 2 +- .../scripts/startup/bl_ui/properties_particle.py | 90 +++++------ .../startup/bl_ui/properties_physics_cloth.py | 12 +- .../startup/bl_ui/properties_physics_common.py | 2 +- .../bl_ui/properties_physics_dynamicpaint.py | 18 +-- .../startup/bl_ui/properties_physics_field.py | 10 +- .../startup/bl_ui/properties_physics_rigidbody.py | 6 +- .../properties_physics_rigidbody_constraint.py | 2 +- .../startup/bl_ui/properties_physics_smoke.py | 16 +- .../startup/bl_ui/properties_physics_softbody.py | 14 +- release/scripts/startup/bl_ui/properties_render.py | 83 ++++++++-- release/scripts/startup/bl_ui/properties_scene.py | 30 ++-- .../scripts/startup/bl_ui/properties_texture.py | 38 ++--- .../scripts/startup/bl_ui/properties_view_layer.py | 2 +- release/scripts/startup/bl_ui/properties_world.py | 4 +- release/scripts/startup/bl_ui/space_sequencer.py | 2 +- release/scripts/startup/bl_ui/space_view3d.py | 29 ++-- source/blender/blenkernel/BKE_scene.h | 1 + source/blender/blenkernel/BKE_screen.h | 3 + source/blender/blenkernel/intern/scene.c | 13 +- source/blender/blenkernel/intern/screen.c | 18 ++- source/blender/blenloader/intern/versioning_280.c | 6 + source/blender/draw/CMakeLists.txt | 1 + source/blender/draw/engines/workbench/solid_mode.c | 10 +- .../draw/engines/workbench/workbench_data.c | 42 ++--- .../draw/engines/workbench/workbench_deferred.c | 9 ++ .../draw/engines/workbench/workbench_effect_aa.c | 20 ++- .../draw/engines/workbench/workbench_effect_taa.c | 16 +- .../draw/engines/workbench/workbench_engine.c | 12 +- .../draw/engines/workbench/workbench_engine.h | 2 +- .../draw/engines/workbench/workbench_private.h | 15 +- .../draw/engines/workbench/workbench_render.c | 172 +++++++++++++++++++++ source/blender/draw/intern/DRW_render.h | 1 + source/blender/draw/intern/draw_cache.c | 30 ++++ source/blender/draw/intern/draw_cache.h | 1 + source/blender/draw/intern/draw_manager.c | 25 ++- source/blender/editors/space_view3d/space_view3d.c | 10 +- source/blender/makesdna/DNA_scene_types.h | 5 +- source/blender/makesrna/intern/rna_scene.c | 4 + source/blender/makesrna/intern/rna_space.c | 48 ++++-- 50 files changed, 655 insertions(+), 318 deletions(-) create mode 100644 source/blender/draw/engines/workbench/workbench_render.c diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 6cfc4b6ea3f..63d80638ae2 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -328,7 +328,7 @@ class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object.data" _property_type = bpy.types.Armature diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py index cc593fbb0a2..6d364ee6539 100644 --- a/release/scripts/startup/bl_ui/properties_data_bone.py +++ b/release/scripts/startup/bl_ui/properties_data_bone.py @@ -402,7 +402,7 @@ class BONE_PT_deform(BoneButtonsPanel, Panel): class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _property_type = bpy.types.Bone, bpy.types.EditBone, bpy.types.PoseBone @property diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index 4730fc56602..f66419a7f8e 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -39,7 +39,7 @@ class CAMERA_PT_presets(PresetMenu): preset_subdir = "camera" preset_operator = "script.execute_preset" preset_add_operator = "camera.preset_add" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} class SAFE_AREAS_PT_presets(PresetMenu): @@ -47,13 +47,13 @@ class SAFE_AREAS_PT_presets(PresetMenu): preset_subdir = "safe_areas" preset_operator = "script.execute_preset" preset_add_operator = "safe_areas.preset_add" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} class DATA_PT_context_camera(CameraButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -70,7 +70,7 @@ class DATA_PT_context_camera(CameraButtonsPanel, Panel): class DATA_PT_lens(CameraButtonsPanel, Panel): bl_label = "Lens" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -111,7 +111,7 @@ class DATA_PT_lens(CameraButtonsPanel, Panel): sub = col.column(align=True) sub.prop(ccam, "longitude_min", text="Longiture Min") sub.prop(ccam, "longitude_max", text="Max") - elif engine in {'BLENDER_RENDER', 'BLENDER_EEVEE'}: + elif engine in {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}: if cam.lens_unit == 'MILLIMETERS': col.prop(cam, "lens") elif cam.lens_unit == 'FOV': @@ -133,7 +133,7 @@ class DATA_PT_lens(CameraButtonsPanel, Panel): class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel): bl_label = "Stereoscopy" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -181,7 +181,7 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel): class DATA_PT_camera(CameraButtonsPanel, Panel): bl_label = "Camera" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header_preset(self, context): CAMERA_PT_presets.draw_panel_header(self.layout) @@ -264,7 +264,7 @@ class DATA_PT_camera_dof_aperture(CameraButtonsPanel, Panel): class DATA_PT_camera_background_image(CameraButtonsPanel, Panel): bl_label = "Background Images" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): cam = context.camera @@ -365,7 +365,7 @@ class DATA_PT_camera_background_image(CameraButtonsPanel, Panel): class DATA_PT_camera_display(CameraButtonsPanel, Panel): bl_label = "Viewport Display" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -398,7 +398,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel): class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel): bl_label = "Safe Areas" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): cam = context.camera @@ -417,7 +417,7 @@ class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel): class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object.data" _property_type = bpy.types.Camera diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index c0ab9da949f..4002568fb7d 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -135,7 +135,7 @@ class DATA_PT_shape_curve(CurveButtonsPanel, Panel): class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel): bl_label = "Texture Space" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -459,7 +459,7 @@ class DATA_PT_text_boxes(CurveButtonsPanelText, Panel): class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object.data" _property_type = bpy.types.Curve diff --git a/release/scripts/startup/bl_ui/properties_data_lattice.py b/release/scripts/startup/bl_ui/properties_data_lattice.py index 40e82bc0a52..9aa8a4dee64 100644 --- a/release/scripts/startup/bl_ui/properties_data_lattice.py +++ b/release/scripts/startup/bl_ui/properties_data_lattice.py @@ -85,7 +85,7 @@ class DATA_PT_lattice(DataButtonsPanel, Panel): class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object.data" _property_type = bpy.types.Lattice diff --git a/release/scripts/startup/bl_ui/properties_data_light.py b/release/scripts/startup/bl_ui/properties_data_light.py index a92414c0e7c..f5c985f2abe 100644 --- a/release/scripts/startup/bl_ui/properties_data_light.py +++ b/release/scripts/startup/bl_ui/properties_data_light.py @@ -36,7 +36,7 @@ class DataButtonsPanel: class DATA_PT_context_light(DataButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -62,7 +62,7 @@ class DATA_PT_preview(DataButtonsPanel, Panel): class DATA_PT_light(DataButtonsPanel, Panel): bl_label = "Light" - COMPAT_ENGINES = {'BLENDER_RENDER'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -71,38 +71,6 @@ class DATA_PT_light(DataButtonsPanel, Panel): layout.row().prop(light, "type", expand=True) - layout.use_property_split = True - - col = col.column() - col.prop(light, "color") - col.prop(light, "energy") - - if light.type in {'POINT', 'SPOT'}: - - col = col.column() - col.label(text="Falloff") - col.prop(light, "falloff_type") - col.prop(light, "distance") - col.prop(light, "shadow_soft_size") - - if light.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED': - sub = col.column(align=True) - sub.prop(light, "linear_attenuation", slider=True, text="Linear") - sub.prop(light, "quadratic_attenuation", slider=True, text="Quadratic") - - elif light.falloff_type == 'INVERSE_COEFFICIENTS': - col.label(text="Inverse Coefficients") - sub = col.column(align=True) - sub.prop(light, "constant_coefficient", text="Constant") - sub.prop(light, "linear_coefficient", text="Linear") - sub.prop(light, "quadratic_coefficient", text="Quadratic") - - if light.type == 'AREA': - col.prop(light, "distance") - - col = split.column() - col.label() - class DATA_PT_EEVEE_light(DataButtonsPanel, Panel): bl_label = "Light" @@ -234,7 +202,7 @@ class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel): class DATA_PT_area(DataButtonsPanel, Panel): bl_label = "Area Shape" - COMPAT_ENGINES = {'BLENDER_RENDER'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -258,45 +226,10 @@ class DATA_PT_area(DataButtonsPanel, Panel): sub.prop(light, "size_y", text="Size Y") -class DATA_PT_spot(DataButtonsPanel, Panel): - bl_label = "Spot Shape" - COMPAT_ENGINES = {'BLENDER_RENDER'} - - @classmethod - def poll(cls, context): - light = context.light - engine = context.engine - return (light and light.type == 'SPOT') and (engine in cls.COMPAT_ENGINES) - - def draw(self, context): - layout = self.layout - - light = context.light - - split = layout.split() - - col = split.column() - sub = col.column() - sub.prop(light, "spot_size", text="Size") - sub.prop(light, "spot_blend", text="Blend", slider=True) - col.prop(light, "use_square") - col.prop(light, "show_cone") - - col = split.column() - - col.active = (light.shadow_method != 'BUFFER_SHADOW' or light.shadow_buffer_type != 'DEEP') - col.prop(light, "use_halo") - sub = col.column(align=True) - sub.active = light.use_halo - sub.prop(light, "halo_intensity", text="Intensity") - if light.shadow_method == 'BUFFER_SHADOW': - sub.prop(light, "halo_step", text="Step") - - class DATA_PT_spot(DataButtonsPanel, Panel): bl_label = "Spot Shape" bl_parent_id = "DATA_PT_EEVEE_light" - COMPAT_ENGINES = {'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -337,7 +270,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, Panel): class DATA_PT_custom_props_light(DataButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object.data" _property_type = bpy.types.Light diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index e8015327c1d..214852cc826 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -24,7 +24,6 @@ from rna_prop_ui import PropertyPanel class MESH_MT_vertex_group_specials(Menu): bl_label = "Vertex Group Specials" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw(self, context): layout = self.layout @@ -48,7 +47,6 @@ class MESH_MT_vertex_group_specials(Menu): class MESH_MT_shape_key_specials(Menu): bl_label = "Shape Key Specials" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw(self, context): layout = self.layout @@ -137,7 +135,7 @@ class MeshButtonsPanel: class DATA_PT_context_mesh(MeshButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -154,7 +152,7 @@ class DATA_PT_context_mesh(MeshButtonsPanel, Panel): class DATA_PT_normals(MeshButtonsPanel, Panel): bl_label = "Normals" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -174,7 +172,7 @@ class DATA_PT_normals(MeshButtonsPanel, Panel): class DATA_PT_texture_space(MeshButtonsPanel, Panel): bl_label = "Texture Space" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -194,7 +192,7 @@ class DATA_PT_texture_space(MeshButtonsPanel, Panel): class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): bl_label = "Vertex Groups" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -241,7 +239,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): class DATA_PT_face_maps(MeshButtonsPanel, Panel): bl_label = "Face Maps" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -283,7 +281,7 @@ class DATA_PT_face_maps(MeshButtonsPanel, Panel): class DATA_PT_shape_keys(MeshButtonsPanel, Panel): bl_label = "Shape Keys" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -373,7 +371,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel): class DATA_PT_uv_texture(MeshButtonsPanel, Panel): bl_label = "UV Maps" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -392,7 +390,7 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel): class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): bl_label = "Vertex Colors" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -412,7 +410,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): class DATA_PT_customdata(MeshButtonsPanel, Panel): bl_label = "Geometry Data" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -439,7 +437,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel): class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object.data" _property_type = bpy.types.Mesh diff --git a/release/scripts/startup/bl_ui/properties_data_metaball.py b/release/scripts/startup/bl_ui/properties_data_metaball.py index 2a61e6cda79..75015a57f5f 100644 --- a/release/scripts/startup/bl_ui/properties_data_metaball.py +++ b/release/scripts/startup/bl_ui/properties_data_metaball.py @@ -71,7 +71,7 @@ class DATA_PT_metaball(DataButtonsPanel, Panel): class DATA_PT_mball_texture_space(DataButtonsPanel, Panel): bl_label = "Texture Space" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -125,7 +125,7 @@ class DATA_PT_metaball_element(DataButtonsPanel, Panel): class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object.data" _property_type = bpy.types.MetaBall diff --git a/release/scripts/startup/bl_ui/properties_data_speaker.py b/release/scripts/startup/bl_ui/properties_data_speaker.py index 2a3dc4d02c1..d7c93095489 100644 --- a/release/scripts/startup/bl_ui/properties_data_speaker.py +++ b/release/scripts/startup/bl_ui/properties_data_speaker.py @@ -36,7 +36,7 @@ class DataButtonsPanel: class DATA_PT_context_speaker(DataButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -55,7 +55,7 @@ class DATA_PT_context_speaker(DataButtonsPanel, Panel): class DATA_PT_speaker(DataButtonsPanel, Panel): bl_label = "Sound" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -76,7 +76,7 @@ class DATA_PT_speaker(DataButtonsPanel, Panel): class DATA_PT_distance(DataButtonsPanel, Panel): bl_label = "Distance" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -99,7 +99,7 @@ class DATA_PT_distance(DataButtonsPanel, Panel): class DATA_PT_cone(DataButtonsPanel, Panel): bl_label = "Cone" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -121,7 +121,7 @@ class DATA_PT_cone(DataButtonsPanel, Panel): class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object.data" _property_type = bpy.types.Speaker diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index b601922e944..0e3e50b3497 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -73,7 +73,7 @@ class MATERIAL_PT_preview(MaterialButtonsPanel, Panel): class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "material" _property_type = bpy.types.Material @@ -82,7 +82,7 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): bl_label = "" bl_context = "material" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 63b708ae059..64bc8d52068 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -359,7 +359,7 @@ class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit fr class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "object" _property_type = bpy.types.Object diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 05538e71faf..9d891a07989 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -67,7 +67,7 @@ def particle_get_settings(context): class PARTICLE_MT_specials(Menu): bl_label = "Particle Specials" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -88,7 +88,7 @@ class PARTICLE_PT_hair_dynamics_presets(PresetMenu): preset_subdir = "hair_dynamics" preset_operator = "script.execute_preset" preset_add_operator = "particle.hair_dynamics_preset_add" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} class ParticleButtonsPanel: @@ -132,7 +132,7 @@ class PARTICLE_UL_particle_systems(bpy.types.UIList): class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -235,7 +235,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): class PARTICLE_PT_emission(ParticleButtonsPanel, Panel): bl_label = "Emission" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -287,7 +287,7 @@ class PARTICLE_PT_emission_source(ParticleButtonsPanel, Panel): bl_label = "Source" bl_parent_id = "PARTICLE_PT_emission" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -325,7 +325,7 @@ class PARTICLE_PT_emission_source(ParticleButtonsPanel, Panel): class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel): bl_label = "Hair Dynamics" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -406,7 +406,7 @@ class PARTICLE_PT_hair_dynamics_structure(ParticleButtonsPanel, Panel): bl_label = "Structure" bl_parent_id = "PARTICLE_PT_hair_dynamics" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -438,7 +438,7 @@ class PARTICLE_PT_hair_dynamics_volume(ParticleButtonsPanel, Panel): bl_label = "Volume" bl_parent_id = "PARTICLE_PT_hair_dynamics" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -470,7 +470,7 @@ class PARTICLE_PT_hair_dynamics_volume(ParticleButtonsPanel, Panel): class PARTICLE_PT_cache(ParticleButtonsPanel, Panel): bl_label = "Cache" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -501,7 +501,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, Panel): class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel): bl_label = "Velocity" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -550,7 +550,7 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel): class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel): bl_label = "Rotation" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -603,7 +603,7 @@ class PARTICLE_PT_rotation_angular_velocity(ParticleButtonsPanel, Panel): bl_label = "Angular Velocity" bl_parent_id = "PARTICLE_PT_rotation" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -628,7 +628,7 @@ class PARTICLE_PT_rotation_angular_velocity(ParticleButtonsPanel, Panel): class PARTICLE_PT_physics(ParticleButtonsPanel, Panel): bl_label = "Physics" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -826,7 +826,7 @@ class PARTICLE_PT_physics_deflection(ParticleButtonsPanel, Panel): bl_label = "Deflection" bl_parent_id = "PARTICLE_PT_physics" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -852,7 +852,7 @@ class PARTICLE_PT_physics_deflection(ParticleButtonsPanel, Panel): class PARTICLE_PT_physics_forces(ParticleButtonsPanel, Panel): bl_label = "Forces" bl_parent_id = "PARTICLE_PT_physics" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -879,7 +879,7 @@ class PARTICLE_PT_physics_integration(ParticleButtonsPanel, Panel): bl_label = "Integration" bl_options = {'DEFAULT_CLOSED'} bl_parent_id = "PARTICLE_PT_physics" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -911,7 +911,7 @@ class PARTICLE_PT_physics_integration(ParticleButtonsPanel, Panel): class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel): bl_label = "Boid Brain" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1015,7 +1015,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel): class PARTICLE_PT_render(ParticleButtonsPanel, Panel): bl_label = "Render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1055,7 +1055,7 @@ class PARTICLE_PT_render_extra(ParticleButtonsPanel, Panel): bl_label = "Extra" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1082,7 +1082,7 @@ class PARTICLE_PT_render_line(ParticleButtonsPanel, Panel): bl_label = "Line" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1110,7 +1110,7 @@ class PARTICLE_PT_render_path(ParticleButtonsPanel, Panel): bl_label = "Path" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1145,7 +1145,7 @@ class PARTICLE_PT_render_path_timing(ParticleButtonsPanel, Panel): bl_label = "Timing" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1177,7 +1177,7 @@ class PARTICLE_PT_render_object(ParticleButtonsPanel, Panel): bl_label = "Object" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1205,7 +1205,7 @@ class PARTICLE_PT_render_collection(ParticleButtonsPanel, Panel): bl_label = "Collection" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1237,7 +1237,7 @@ class PARTICLE_PT_render_collection_use_count(ParticleButtonsPanel, Panel): bl_label = "Use Count" bl_parent_id = "PARTICLE_PT_render_collection" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1288,7 +1288,7 @@ class PARTICLE_PT_render_billboards_alignment(ParticleButtonsPanel, Panel): bl_label = "Billboard Alignment" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1314,7 +1314,7 @@ class PARTICLE_PT_render_billboards_tilt(ParticleButtonsPanel, Panel): bl_label = "Billboard Tilt" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1348,7 +1348,7 @@ class PARTICLE_PT_render_billboards_uv(ParticleButtonsPanel, Panel): bl_label = "Billboard UVs" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1384,7 +1384,7 @@ class PARTICLE_PT_render_trails(ParticleButtonsPanel, Panel): bl_label = "Trails" bl_parent_id = "PARTICLE_PT_render" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1412,7 +1412,7 @@ class PARTICLE_PT_render_trails(ParticleButtonsPanel, Panel): class PARTICLE_PT_draw(ParticleButtonsPanel, Panel): bl_label = "Viewport Display" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1474,7 +1474,7 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, Panel): class PARTICLE_PT_children(ParticleButtonsPanel, Panel): bl_label = "Children" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1530,7 +1530,7 @@ class PARTICLE_PT_children_parting(ParticleButtonsPanel, Panel): bl_label = "Parting" bl_parent_id = "PARTICLE_PT_children" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1555,7 +1555,7 @@ class PARTICLE_PT_children_clumping(ParticleButtonsPanel, Panel): bl_label = "Clumping" bl_parent_id = "PARTICLE_PT_children" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1597,7 +1597,7 @@ class PARTICLE_PT_children_roughness(ParticleButtonsPanel, Panel): bl_label = "Roughness" bl_parent_id = "PARTICLE_PT_children" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1639,7 +1639,7 @@ class PARTICLE_PT_children_kink(ParticleButtonsPanel, Panel): bl_label = "Kink" bl_parent_id = "PARTICLE_PT_children" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1690,7 +1690,7 @@ class PARTICLE_PT_children_kink(ParticleButtonsPanel, Panel): class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel): bl_label = "Field Weights" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1711,7 +1711,7 @@ class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel): class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel): bl_label = "Force Field Settings" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -1727,7 +1727,7 @@ class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel): class PARTICLE_PT_force_fields_type1(ParticleButtonsPanel, Panel): bl_label = "Type 1" bl_parent_id = "PARTICLE_PT_force_fields" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -1743,7 +1743,7 @@ class PARTICLE_PT_force_fields_type1(ParticleButtonsPanel, Panel): class PARTICLE_PT_force_fields_type2(ParticleButtonsPanel, Panel): bl_label = "Type 2" bl_parent_id = "PARTICLE_PT_force_fields" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -1760,7 +1760,7 @@ class PARTICLE_PT_force_fields_type1_falloff(ParticleButtonsPanel, Panel): bl_label = "Falloff" bl_options = {'DEFAULT_CLOSED'} bl_parent_id = "PARTICLE_PT_force_fields_type1" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -1775,7 +1775,7 @@ class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel): bl_label = "Falloff" bl_options = {'DEFAULT_CLOSED'} bl_parent_id = "PARTICLE_PT_force_fields_type2" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -1789,7 +1789,7 @@ class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel): class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel): bl_label = "Vertex Groups" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1862,7 +1862,7 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel): class PARTICLE_PT_textures(ParticleButtonsPanel, Panel): bl_label = "Textures" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1894,7 +1894,7 @@ class PARTICLE_PT_textures(ParticleButtonsPanel, Panel): class PARTICLE_PT_hair_shape(ParticleButtonsPanel, Panel): bl_label = "Hair Shape" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -1921,7 +1921,7 @@ class PARTICLE_PT_hair_shape(ParticleButtonsPanel, Panel): class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "particle_system.settings" _property_type = bpy.types.ParticleSettings diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py index 2f659af3891..7775722784b 100644 --- a/release/scripts/startup/bl_ui/properties_physics_cloth.py +++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py @@ -51,7 +51,7 @@ class PhysicButtonsPanel: class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel): bl_label = "Cloth" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header_preset(self, context): CLOTH_PT_presets.draw_panel_header(self.layout) @@ -129,7 +129,7 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel): bl_label = "Cache" bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): md = context.cloth @@ -140,7 +140,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel): bl_label = "Collision" bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): cloth = context.cloth.collision_settings @@ -181,7 +181,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): bl_label = "Stiffness Scaling" bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): cloth = context.cloth.settings @@ -215,7 +215,7 @@ class PHYSICS_PT_cloth_sewing(PhysicButtonsPanel, Panel): bl_label = "Sewing Springs" bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): cloth = context.cloth.settings @@ -250,7 +250,7 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel): bl_label = "Field Weights" bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): cloth = context.cloth.settings diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index c9bde32c53d..bed5617c76c 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -56,7 +56,7 @@ def physics_add_special(self, layout, data, name, addop, removeop, typeicon): class PHYSICS_PT_add(PhysicButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): obj = context.object diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py index 6a66dafadf0..611f477a31b 100644 --- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py +++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py @@ -60,7 +60,7 @@ class PhysicButtonsPanel: class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel): bl_label = "Dynamic Paint" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -129,7 +129,7 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel): bl_label = "Advanced" bl_parent_id = "PHYSICS_PT_dynamic_paint" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -206,7 +206,7 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel): bl_label = "Output" bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -300,7 +300,7 @@ class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel): bl_label = "Initial Color" bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -337,7 +337,7 @@ class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel): bl_label = "Effects" bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -387,7 +387,7 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel): bl_label = "Cache" bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -409,7 +409,7 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel): bl_label = "Source" bl_parent_id = "PHYSICS_PT_dynamic_paint" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -463,7 +463,7 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel): bl_label = "Velocity" bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -500,7 +500,7 @@ class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, Panel): bl_label = "Waves" bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py index 3b01015047f..1a4e24fbc0c 100644 --- a/release/scripts/startup/bl_ui/properties_physics_field.py +++ b/release/scripts/startup/bl_ui/properties_physics_field.py @@ -38,7 +38,7 @@ class PhysicButtonsPanel: class PHYSICS_PT_field(PhysicButtonsPanel, Panel): bl_label = "Force Fields" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -112,7 +112,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel): class PHYSICS_PT_field_falloff(PhysicButtonsPanel, Panel): bl_label = "Falloff" bl_parent_id = "PHYSICS_PT_field" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -170,7 +170,7 @@ class PHYSICS_PT_field_falloff(PhysicButtonsPanel, Panel): class PHYSICS_PT_collision(PhysicButtonsPanel, Panel): bl_label = "Collision" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -199,7 +199,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel): class PHYSICS_PT_collision_particle(PhysicButtonsPanel, Panel): bl_label = "Particle" bl_parent_id = "PHYSICS_PT_collision" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -241,7 +241,7 @@ class PHYSICS_PT_collision_particle(PhysicButtonsPanel, Panel): class PHYSICS_PT_collision_softbody(PhysicButtonsPanel, Panel): bl_label = "Softbody" bl_parent_id = "PHYSICS_PT_collision" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py index db59665e21d..013822793de 100644 --- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py @@ -29,7 +29,7 @@ class PHYSICS_PT_rigidbody_panel: class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel): bl_label = "Rigid Body" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -57,7 +57,7 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel): class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel): bl_label = "Collisions" bl_parent_id = 'PHYSICS_PT_rigid_body' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -103,7 +103,7 @@ class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel): bl_label = "Dynamics" bl_parent_id = 'PHYSICS_PT_rigid_body' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py index aca989fd0ba..69491f36c63 100644 --- a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py +++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py @@ -29,7 +29,7 @@ class PHYSICS_PT_rigidbody_constraint_panel: class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Panel): bl_label = "Rigid Body Constraint" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py index acbaecbda4c..0a4f1c71126 100644 --- a/release/scripts/startup/bl_ui/properties_physics_smoke.py +++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py @@ -39,7 +39,7 @@ class PhysicButtonsPanel: class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel): bl_label = "Smoke" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -138,7 +138,7 @@ class PHYSICS_PT_smoke_flow_advanced(PhysicButtonsPanel, Panel): bl_label = "Advanced" bl_parent_id = 'PHYSICS_PT_smoke' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -174,7 +174,7 @@ class PHYSICS_PT_smoke_fire(PhysicButtonsPanel, Panel): bl_label = "Flames" bl_parent_id = 'PHYSICS_PT_smoke' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -205,7 +205,7 @@ class PHYSICS_PT_smoke_adaptive_domain(PhysicButtonsPanel, Panel): bl_label = "Adaptive Domain" bl_parent_id = 'PHYSICS_PT_smoke' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -240,7 +240,7 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel): bl_label = "High Resolution" bl_parent_id = 'PHYSICS_PT_smoke' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -280,7 +280,7 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel): bl_label = "Groups" bl_parent_id = 'PHYSICS_PT_smoke' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -309,7 +309,7 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel): bl_label = "Cache" bl_parent_id = 'PHYSICS_PT_smoke' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -346,7 +346,7 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel): bl_label = "Field Weights" bl_parent_id = 'PHYSICS_PT_smoke' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py index 68db165875e..77440bdc628 100644 --- a/release/scripts/startup/bl_ui/properties_physics_softbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py @@ -46,7 +46,7 @@ class PhysicButtonsPanel: class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel): bl_label = "Soft Body" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -77,7 +77,7 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel): bl_label = "Cache" bl_parent_id = 'PHYSICS_PT_softbody' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): md = context.soft_body @@ -88,7 +88,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel): bl_label = "Goal" bl_parent_id = 'PHYSICS_PT_softbody' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): softbody = context.soft_body.settings @@ -129,7 +129,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel): bl_label = "Edges" bl_parent_id = 'PHYSICS_PT_softbody' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): softbody = context.soft_body.settings @@ -180,7 +180,7 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel): bl_label = "Self Collision" bl_parent_id = 'PHYSICS_PT_softbody' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): softbody = context.soft_body.settings @@ -210,7 +210,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel): bl_label = "Solver" bl_parent_id = 'PHYSICS_PT_softbody' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -244,7 +244,7 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel): bl_label = "Field Weights" bl_parent_id = 'PHYSICS_PT_softbody' bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): md = context.soft_body diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index a7cfee5ed8f..b1c5edf97e7 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -21,6 +21,11 @@ import bpy from bpy.types import Menu, Panel, UIList from bl_operators.presets import PresetMenu +from .space_view3d import ( + VIEW3D_PT_shading_lighting, + VIEW3D_PT_shading_color, + VIEW3D_PT_shading_options, +) class RENDER_PT_presets(PresetMenu): @@ -79,7 +84,7 @@ class RENDER_PT_context(Panel): class RENDER_PT_dimensions(RenderButtonsPanel, Panel): bl_label = "Dimensions" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _frame_rate_args_prev = None _preset_class = None @@ -166,7 +171,7 @@ class RENDER_PT_frame_remapping(RenderButtonsPanel, Panel): bl_label = "Time Remapping" bl_parent_id = "RENDER_PT_dimensions" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -183,7 +188,7 @@ class RENDER_PT_frame_remapping(RenderButtonsPanel, Panel): class RENDER_PT_post_processing(RenderButtonsPanel, Panel): bl_label = "Post Processing" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -201,7 +206,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel, Panel): class RENDER_PT_stamp(RenderButtonsPanel, Panel): bl_label = "Metadata" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -242,7 +247,7 @@ class RENDER_PT_stamp_burn(RenderButtonsPanel, Panel): bl_label = "Burn Into Image" bl_parent_id = "RENDER_PT_stamp" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): rd = context.scene.render @@ -266,7 +271,7 @@ class RENDER_PT_stamp_burn(RenderButtonsPanel, Panel): class RENDER_PT_output(RenderButtonsPanel, Panel): bl_label = "Output" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -298,7 +303,7 @@ class RENDER_PT_output(RenderButtonsPanel, Panel): class RENDER_PT_encoding(RenderButtonsPanel, Panel): bl_label = "Encoding" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header_preset(self, context): RENDER_PT_ffmpeg_presets.draw_panel_header(self.layout) @@ -395,7 +400,7 @@ class RENDER_UL_renderviews(UIList): class RENDER_PT_stereoscopy(RenderButtonsPanel, Panel): bl_label = "Stereoscopy" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} bl_options = {'DEFAULT_CLOSED'} def draw_header(self, context): @@ -777,7 +782,7 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel): col.prop(rd, "alpha_mode", text="Alpha") -class RENDER_PT_hair(RenderButtonsPanel, Panel): +class RENDER_PT_eevee_hair(RenderButtonsPanel, Panel): bl_label = "Hair" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_EEVEE'} @@ -798,6 +803,60 @@ class RENDER_PT_hair(RenderButtonsPanel, Panel): layout.prop(rd, "hair_subdiv") +class RENDER_PT_opengl_film(RenderButtonsPanel, Panel): + bl_label = "Film" + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_OPENGL'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False # No animation. + + rd = context.scene.render + + layout.prop(rd, "use_antialiasing") + + layout.prop(rd, "antialiasing_samples") + layout.prop(rd, "alpha_mode") + + +class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel): + bl_label = "Lighting" + COMPAT_ENGINES = {'BLENDER_OPENGL'} + + @classmethod + def poll(cls, context): + return (context.engine in cls.COMPAT_ENGINES) + + def draw(self, context): + VIEW3D_PT_shading_lighting.draw(self, context) + + +class RENDER_PT_opengl_color(RenderButtonsPanel, Panel): + bl_label = "Color" + COMPAT_ENGINES = {'BLENDER_OPENGL'} + + @classmethod + def poll(cls, context): + return (context.engine in cls.COMPAT_ENGINES) + + def draw(self, context): + VIEW3D_PT_shading_color.draw(self, context) + + +class RENDER_PT_opengl_options(RenderButtonsPanel, Panel): + bl_label = "Options" + COMPAT_ENGINES = {'BLENDER_OPENGL'} + + @classmethod + def poll(cls, context): + return (context.engine in cls.COMPAT_ENGINES) + + def draw(self, context): + VIEW3D_PT_shading_options.draw(self, context) + + classes = ( RENDER_PT_presets, RENDER_PT_ffmpeg_presets, @@ -812,7 +871,7 @@ classes = ( RENDER_PT_stamp_burn, RENDER_UL_renderviews, RENDER_PT_stereoscopy, - RENDER_PT_hair, + RENDER_PT_eevee_hair, RENDER_PT_eevee_sampling, RENDER_PT_eevee_film, RENDER_PT_eevee_shadows, @@ -824,6 +883,10 @@ classes = ( RENDER_PT_eevee_motion_blur, RENDER_PT_eevee_depth_of_field, RENDER_PT_eevee_bloom, + RENDER_PT_opengl_film, + RENDER_PT_opengl_lighting, + RENDER_PT_opengl_color, + RENDER_PT_opengl_options, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index c0b8233a796..1b21ac8fcdf 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -66,7 +66,7 @@ class SceneButtonsPanel: class SCENE_PT_scene(SceneButtonsPanel, Panel): bl_label = "Scene" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -81,7 +81,7 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel): class SCENE_PT_unit(SceneButtonsPanel, Panel): bl_label = "Units" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header_preset(self, context): SCENE_PT_units_length_presets.draw_panel_header(self.layout) @@ -163,7 +163,7 @@ class SceneKeyingSetsPanel: class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): bl_label = "Keying Sets" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -234,7 +234,7 @@ class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Pane class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): bl_label = "Active Keying Set" bl_parent_id = "SCENE_PT_keying_sets" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -297,7 +297,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): class SCENE_PT_color_management(SceneButtonsPanel, Panel): bl_label = "Color Management" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -329,7 +329,7 @@ class SCENE_PT_color_management_curves(SceneButtonsPanel, Panel): bl_label = "Use Curves" bl_parent_id = "SCENE_PT_color_management" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): @@ -353,7 +353,7 @@ class SCENE_PT_color_management_curves(SceneButtonsPanel, Panel): class SCENE_PT_audio(SceneButtonsPanel, Panel): bl_label = "Audio" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -392,7 +392,7 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel): class SCENE_PT_physics(SceneButtonsPanel, Panel): bl_label = "Gravity" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): self.layout.prop(context.scene, "use_gravity", text="") @@ -411,7 +411,7 @@ class SCENE_PT_physics(SceneButtonsPanel, Panel): class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel): bl_label = "Rigid Body World" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -479,7 +479,7 @@ class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel): bl_label = "Cache" bl_parent_id = "SCENE_PT_rigid_body_world" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -497,7 +497,7 @@ class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel): bl_label = "Field Weights" bl_parent_id = "SCENE_PT_rigid_body_world" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -514,7 +514,7 @@ class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel): class SCENE_PT_simplify(SceneButtonsPanel, Panel): bl_label = "Simplify" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): rd = context.scene.render @@ -527,7 +527,7 @@ class SCENE_PT_simplify(SceneButtonsPanel, Panel): class SCENE_PT_simplify_viewport(SceneButtonsPanel, Panel): bl_label = "Viewport" bl_parent_id = "SCENE_PT_simplify" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -549,7 +549,7 @@ class SCENE_PT_simplify_viewport(SceneButtonsPanel, Panel): class SCENE_PT_simplify_render(SceneButtonsPanel, Panel): bl_label = "Render" bl_parent_id = "SCENE_PT_simplify" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -569,7 +569,7 @@ class SCENE_PT_simplify_render(SceneButtonsPanel, Panel): class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "scene" _property_type = bpy.types.Scene diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index b3b7341a734..d937f2470b8 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -83,7 +83,7 @@ class TextureButtonsPanel: class TEXTURE_PT_preview(TextureButtonsPanel, Panel): bl_label = "Preview" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -112,7 +112,7 @@ class TEXTURE_PT_context(TextureButtonsPanel, Panel): bl_label = "" bl_context = "texture" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -151,7 +151,7 @@ class TEXTURE_PT_context(TextureButtonsPanel, Panel): class TEXTURE_PT_node(TextureButtonsPanel, Panel): bl_label = "Node" bl_context = "texture" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -169,7 +169,7 @@ class TEXTURE_PT_node(TextureButtonsPanel, Panel): class TEXTURE_PT_node_mapping(TextureButtonsPanel, Panel): bl_label = "Mapping" bl_context = "texture" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -212,7 +212,7 @@ class TextureTypePanel(TextureButtonsPanel): class TEXTURE_PT_clouds(TextureTypePanel, Panel): bl_label = "Clouds" tex_type = 'CLOUDS' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -236,7 +236,7 @@ class TEXTURE_PT_clouds(TextureTypePanel, Panel): class TEXTURE_PT_wood(TextureTypePanel, Panel): bl_label = "Wood" tex_type = 'WOOD' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -265,7 +265,7 @@ class TEXTURE_PT_wood(TextureTypePanel, Panel): class TEXTURE_PT_marble(TextureTypePanel, Panel): bl_label = "Marble" tex_type = 'MARBLE' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -292,7 +292,7 @@ class TEXTURE_PT_marble(TextureTypePanel, Panel): class TEXTURE_PT_magic(TextureTypePanel, Panel): bl_label = "Magic" tex_type = 'MAGIC' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -307,7 +307,7 @@ class TEXTURE_PT_magic(TextureTypePanel, Panel): class TEXTURE_PT_blend(TextureTypePanel, Panel): bl_label = "Blend" tex_type = 'BLEND' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -325,7 +325,7 @@ class TEXTURE_PT_blend(TextureTypePanel, Panel): class TEXTURE_PT_stucci(TextureTypePanel, Panel): bl_label = "Stucci" tex_type = 'STUCCI' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -345,7 +345,7 @@ class TEXTURE_PT_stucci(TextureTypePanel, Panel): class TEXTURE_PT_image(TextureTypePanel, Panel): bl_label = "Image" tex_type = 'IMAGE' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -475,7 +475,7 @@ class TEXTURE_PT_image_mapping(TextureTypePanel, Panel): class TEXTURE_PT_musgrave(TextureTypePanel, Panel): bl_label = "Musgrave" tex_type = 'MUSGRAVE' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -511,7 +511,7 @@ class TEXTURE_PT_musgrave(TextureTypePanel, Panel): class TEXTURE_PT_voronoi(TextureTypePanel, Panel): bl_label = "Voronoi" tex_type = 'VORONOI' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -547,7 +547,7 @@ class TEXTURE_PT_voronoi(TextureTypePanel, Panel): class TEXTURE_PT_distortednoise(TextureTypePanel, Panel): bl_label = "Distorted Noise" tex_type = 'DISTORTED_NOISE' - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -567,7 +567,7 @@ class TEXTURE_PT_distortednoise(TextureTypePanel, Panel): class TextureSlotPanel(TextureButtonsPanel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -579,7 +579,7 @@ class TextureSlotPanel(TextureButtonsPanel): class TEXTURE_PT_mapping(TextureSlotPanel, Panel): bl_label = "Mapping" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -657,7 +657,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel): class TEXTURE_PT_influence(TextureSlotPanel, Panel): bl_label = "Influence" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -745,7 +745,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel): class TEXTURE_PT_colors(TextureButtonsPanel, Panel): bl_label = "Colors" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -776,7 +776,7 @@ class TEXTURE_PT_colors(TextureButtonsPanel, Panel): class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "texture" _property_type = Texture diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py index 05dc15216a2..f96bf041311 100644 --- a/release/scripts/startup/bl_ui/properties_view_layer.py +++ b/release/scripts/startup/bl_ui/properties_view_layer.py @@ -34,7 +34,7 @@ class ViewLayerButtonsPanel: class VIEWLAYER_PT_layer(ViewLayerButtonsPanel, Panel): bl_label = "View Layer" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py index ed1b17a911d..7395fa13d9a 100644 --- a/release/scripts/startup/bl_ui/properties_world.py +++ b/release/scripts/startup/bl_ui/properties_world.py @@ -37,7 +37,7 @@ class WorldButtonsPanel: class WORLD_PT_context_world(WorldButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @classmethod def poll(cls, context): @@ -83,7 +83,7 @@ class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel): class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "world" _property_type = bpy.types.World diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 0bdfcc39ed9..5fc9be2aa5b 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -1289,7 +1289,7 @@ class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, SequencerButtonsP class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} _context_path = "scene.sequence_editor.active_strip" _property_type = (bpy.types.Sequence,) bl_category = "Strip" diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 2c1ee3c5338..e8c640721c8 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3748,6 +3748,15 @@ class VIEW3D_PT_shading(Panel): bl_label = "Shading" bl_ui_units_x = 11 + @classmethod + def get_shading(cls, context): + # Get settings from 3D viewport or OpenGL render engine + view = context.space_data + if view.type == 'VIEW_3D': + return view.shading + else: + return context.scene.display.shading + def draw(self, context): pass @@ -3760,9 +3769,7 @@ class VIEW3D_PT_shading_lighting(Panel): def draw(self, context): layout = self.layout - - view = context.space_data - shading = view.shading + shading = VIEW3D_PT_shading.get_shading(context) col = layout.column() split = col.split(0.9) @@ -3824,15 +3831,13 @@ class VIEW3D_PT_shading_color(Panel): @classmethod def poll(cls, context): - view = context.space_data - shading = view.shading + shading = VIEW3D_PT_shading.get_shading(context) return shading.type == 'SOLID' def draw(self, context): layout = self.layout - view = context.space_data - shading = view.shading + shading = VIEW3D_PT_shading.get_shading(context) layout.row().prop(shading, "color_type", expand=True) @@ -3848,15 +3853,13 @@ class VIEW3D_PT_shading_options(Panel): @classmethod def poll(cls, context): - view = context.space_data - shading = view.shading + shading = VIEW3D_PT_shading.get_shading(context) return shading.type == 'SOLID' def draw(self, context): layout = self.layout - view = context.space_data - shading = view.shading + shading = VIEW3D_PT_shading.get_shading(context) col = layout.column() @@ -3909,7 +3912,9 @@ class VIEW3D_PT_shading_options(Panel): if not shading.light == 'MATCAP': col.prop(shading, "show_specular_highlight") - col.prop(view, "show_world") + view = context.space_data + if view.type == 'VIEW_3D': + col.prop(view, "show_world") class VIEW3D_PT_shading_options_shadow(Panel): diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 270ab60c02b..adccfda8e25 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -156,6 +156,7 @@ bool BKE_scene_use_shading_nodes_custom(struct Scene *scene); bool BKE_scene_use_spherical_stereo(struct Scene *scene); bool BKE_scene_uses_blender_eevee(const struct Scene *scene); +bool BKE_scene_uses_blender_opengl(const struct Scene *scene); bool BKE_scene_uses_cycles(const struct Scene *scene); void BKE_scene_disable_color_management(struct Scene *scene); diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 60981c6e76e..c74170becb4 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -45,6 +45,7 @@ struct ScrVert; struct SpaceType; struct TransformOrientation; struct View3D; +struct View3DShading; struct bContext; struct bContextDataResult; struct bScreen; @@ -355,6 +356,8 @@ bool BKE_screen_is_used(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT AT float BKE_screen_view3d_zoom_to_fac(float camzoom); float BKE_screen_view3d_zoom_from_fac(float zoomfac); +void BKE_screen_view3d_shading_init(struct View3DShading *shading); + /* screen */ void BKE_screen_free(struct bScreen *sc); void BKE_screen_area_map_free(struct ScrAreaMap *area_map) ATTR_NONNULL(); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 3b1416d2881..f99a30b75d0 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -113,7 +113,7 @@ #include "bmesh.h" const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE"; -const char *RE_engine_id_BLENDER_WORKBENCH = "BLENDER_WORKBENCH"; +const char *RE_engine_id_BLENDER_OPENGL = "BLENDER_OPENGL"; const char *RE_engine_id_CYCLES = "CYCLES"; void free_avicodecdata(AviCodecData *acd) @@ -361,6 +361,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) curvemapping_copy_data(&sce_copy->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve); + /* viewport display settings */ + sce_copy->display = sce->display; + /* tool settings */ sce_copy->toolsettings = BKE_toolsettings_copy(sce->toolsettings, 0); @@ -820,6 +823,9 @@ void BKE_scene_init(Scene *sce) sce->display.matcap_ssao_attenuation = 1.0f; sce->display.matcap_ssao_samples = 16; + /* OpenGL Render. */ + BKE_screen_view3d_shading_init(&sce->display.shading); + /* SceneEEVEE */ sce->eevee.gi_diffuse_bounces = 3; sce->eevee.gi_cubemap_resolution = 512; @@ -1541,6 +1547,11 @@ bool BKE_scene_uses_blender_eevee(const Scene *scene) return STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE); } +bool BKE_scene_uses_blender_opengl(const Scene *scene) +{ + return STREQ(scene->r.engine, RE_engine_id_BLENDER_OPENGL); +} + bool BKE_scene_uses_cycles(const Scene *scene) { return STREQ(scene->r.engine, RE_engine_id_CYCLES); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 448b97c63b3..f8d926a13ed 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -45,9 +45,10 @@ #include "DNA_view3d_types.h" #include "DNA_workspace_types.h" +#include "BLI_math_vector.h" #include "BLI_listbase.h" -#include "BLI_utildefines.h" #include "BLI_rect.h" +#include "BLI_utildefines.h" #include "BKE_icons.h" #include "BKE_idprop.h" @@ -855,6 +856,21 @@ void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene) } } +void BKE_screen_view3d_shading_init(View3DShading *shading) +{ + memset(shading, 0, sizeof(*shading)); + + shading->type = OB_SOLID; + shading->prev_type = OB_SOLID; + shading->flag = V3D_SHADING_SPECULAR_HIGHLIGHT; + shading->light = V3D_LIGHTING_STUDIO; + shading->shadow_intensity = 0.5f; + shading->xray_alpha = 0.5f; + shading->cavity_valley_factor = 1.0f; + shading->cavity_ridge_factor = 1.0f; + copy_v3_fl(shading->single_color, 0.8f); +} + /* magic zoom calculation, no idea what * it signifies, if you find out, tell me! -zr */ diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 5855b9d39de..d1ed166ba89 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1615,5 +1615,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { + BKE_screen_view3d_shading_init(&scene->display.shading); + } + } } } diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index e4c6a372d34..6ec7b03501b 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -117,6 +117,7 @@ set(SRC engines/workbench/workbench_effect_taa.c engines/workbench/workbench_forward.c engines/workbench/workbench_materials.c + engines/workbench/workbench_render.c engines/workbench/workbench_studiolight.c engines/workbench/workbench_volume.c engines/workbench/solid_mode.c diff --git a/source/blender/draw/engines/workbench/solid_mode.c b/source/blender/draw/engines/workbench/solid_mode.c index b28263d48cf..5c64cebd981 100644 --- a/source/blender/draw/engines/workbench/solid_mode.c +++ b/source/blender/draw/engines/workbench/solid_mode.c @@ -30,6 +30,8 @@ #include "GPU_shader.h" +#include "RE_pipeline.h" + #include "workbench_private.h" /* Functions */ @@ -69,6 +71,7 @@ static void workbench_solid_draw_scene(void *vedata) { WORKBENCH_Data *data = vedata; workbench_deferred_draw_scene(data); + workbench_deferred_draw_finish(data); } static void workbench_solid_engine_free(void) @@ -82,6 +85,11 @@ static void workbench_solid_view_update(void *vedata) workbench_taa_view_updated(data); } +static void workbench_render_to_image(void *vedata, RenderEngine *engine, RenderLayer *render_layer, const rcti *rect) +{ + workbench_render(vedata, engine, render_layer, rect); +} + static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data); DrawEngineType draw_engine_workbench_solid = { @@ -97,5 +105,5 @@ DrawEngineType draw_engine_workbench_solid = { &workbench_solid_draw_scene, &workbench_solid_view_update, NULL, - NULL, + &workbench_render_to_image, }; diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index ede1bd7fcb5..07df067f324 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -19,37 +19,37 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) wpd->user_preferences = &U; View3D *v3d = draw_ctx->v3d; - if (v3d) { + if (!v3d) { + wpd->shading = scene->display.shading; + } + else if (v3d->shading.type == OB_RENDER && + BKE_scene_uses_blender_opengl(scene)) + { + wpd->shading = scene->display.shading; + } + else { wpd->shading = v3d->shading; - if (wpd->shading.light == V3D_LIGHTING_MATCAP) { - wpd->studio_light = BKE_studiolight_find( - wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL); - } - else { - wpd->studio_light = BKE_studiolight_find( - wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD); - } + } + + if (wpd->shading.light == V3D_LIGHTING_MATCAP) { + wpd->studio_light = BKE_studiolight_find( + wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL); } else { - memset(&wpd->shading, 0, sizeof(wpd->shading)); - wpd->shading.light = V3D_LIGHTING_STUDIO; - wpd->shading.shadow_intensity = 0.5; - copy_v3_fl(wpd->shading.single_color, 0.8f); - wpd->studio_light = BKE_studiolight_find_first(STUDIOLIGHT_INTERNAL); + wpd->studio_light = BKE_studiolight_find( + wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD); } wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity; WORKBENCH_UBO_World *wd = &wpd->world_data; wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0; - wd->background_alpha = 1.0f; + wd->background_alpha = (v3d || scene->r.alphamode == R_ADDSKY) ? 1.0f : 0.0f; - if ((v3d->flag3 & V3D_SHOW_WORLD) && - (scene->world != NULL)) - { + if (!v3d || ((v3d->flag3 & V3D_SHOW_WORLD) && (scene->world != NULL))) { copy_v3_v3(wd->background_color_low, &scene->world->horr); copy_v3_v3(wd->background_color_high, &scene->world->horr); } - else { + else if (v3d) { UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD : TH_HIGH_GRAD, wd->background_color_low); UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high); @@ -58,6 +58,10 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) srgb_to_linearrgb_v3_v3(wd->background_color_high, wd->background_color_high); srgb_to_linearrgb_v3_v3(wd->background_color_low, wd->background_color_low); } + else { + zero_v3(wd->background_color_low); + zero_v3(wd->background_color_high); + } studiolight_update_world(wpd->studio_light, wd); diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index d17c48b0360..0ad755049b1 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -842,6 +842,7 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) WORKBENCH_PrivateData *wpd = stl->g_data; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); + /* TODO. */ if (TAA_ENABLED(wpd)) { workbench_taa_draw_scene_start(vedata); } @@ -885,7 +886,15 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) DRW_draw_pass(psl->volume_pass); } + /* TODO */ workbench_aa_draw_pass(vedata, e_data.composite_buffer_tx); +} + +void workbench_deferred_draw_finish(WORKBENCH_Data *vedata) +{ + WORKBENCH_StorageList *stl = vedata->stl; + WORKBENCH_PrivateData *wpd = stl->g_data; + workbench_private_data_free(wpd); workbench_volume_smoke_textures_free(wpd); } diff --git a/source/blender/draw/engines/workbench/workbench_effect_aa.c b/source/blender/draw/engines/workbench/workbench_effect_aa.c index f1d5d5d6078..66f1de7f9fc 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_aa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_aa.c @@ -45,6 +45,18 @@ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx) } } +static void workspace_aa_draw_transform(GPUTexture *tx) +{ + if (DRW_state_is_image_render()) { + /* Linear result for render. */ + DRW_transform_none(tx); + } + else { + /* Display space result for viewport. */ + DRW_transform_to_display(tx); + } +} + void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx) { WORKBENCH_StorageList *stl = vedata->stl; @@ -56,7 +68,7 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx) DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); if (FXAA_ENABLED(wpd)) { GPU_framebuffer_bind(fbl->effect_fb); - DRW_transform_to_display(tx); + workspace_aa_draw_transform(tx); GPU_framebuffer_bind(dfbl->color_only_fb); DRW_draw_pass(psl->effect_aa_pass); } @@ -69,11 +81,11 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx) */ if (effect_info->jitter_index == 1) { GPU_framebuffer_bind(dfbl->color_only_fb); - DRW_transform_to_display(tx); + workspace_aa_draw_transform(tx); } else { GPU_framebuffer_bind(fbl->effect_fb); - DRW_transform_to_display(tx); + workspace_aa_draw_transform(tx); GPU_framebuffer_bind(dfbl->color_only_fb); DRW_draw_pass(psl->effect_aa_pass); } @@ -81,6 +93,6 @@ void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx) } else { GPU_framebuffer_bind(dfbl->color_only_fb); - DRW_transform_to_display(tx); + workspace_aa_draw_transform(tx); } } diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c index fbeccc19660..403338d55c4 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_taa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c @@ -93,15 +93,19 @@ int workbench_taa_calculate_num_iterations(WORKBENCH_Data *vedata) WORKBENCH_PrivateData *wpd = stl->g_data; int result = 1; if (TAA_ENABLED(wpd)) { - if (IN_RANGE_INCL( + if (DRW_state_is_image_render()) { + const Scene *scene = DRW_context_state_get()->scene; + result = (scene->r.mode & R_OSA) ? scene->r.osa : 1; + } + else if (IN_RANGE_INCL( wpd->user_preferences->gpu_viewport_quality, GPU_VIEWPORT_QUALITY_TAA8, GPU_VIEWPORT_QUALITY_TAA16)) { result = 8; } else if (IN_RANGE_INCL( - wpd->user_preferences->gpu_viewport_quality, - GPU_VIEWPORT_QUALITY_TAA16, GPU_VIEWPORT_QUALITY_TAA32)) + wpd->user_preferences->gpu_viewport_quality, + GPU_VIEWPORT_QUALITY_TAA16, GPU_VIEWPORT_QUALITY_TAA32)) { result = 16; } @@ -276,10 +280,12 @@ void workbench_taa_draw_scene_end(WORKBENCH_Data *vedata) GPU_framebuffer_blit(dfbl->color_only_fb, 0, fbl->effect_taa_fb, 0, GPU_COLOR_BIT); - DRW_viewport_matrix_override_unset_all(); + if (!DRW_state_is_image_render()) { + DRW_viewport_matrix_override_unset_all(); + } copy_m4_m4(effect_info->last_mat, effect_info->curr_mat); - if (effect_info->jitter_index != 0) { + if (effect_info->jitter_index != 0 && !DRW_state_is_image_render()) { DRW_viewport_request_redraw(); } } diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 26ae1c289c8..642c5820895 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -29,16 +29,16 @@ #include "DRW_render.h" #include "workbench_engine.h" -/* Shaders */ - -#define WORKBENCH_ENGINE "BLENDER_WORKBENCH" +#include "workbench_private.h" +#define OPENGL_ENGINE "BLENDER_OPENGL" /* Note: currently unused, we may want to register so we can see this when debugging the view. */ -RenderEngineType DRW_engine_viewport_workbench_type = { +RenderEngineType DRW_engine_viewport_opengl_type = { NULL, NULL, - WORKBENCH_ENGINE, N_("Workbench"), RE_INTERNAL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, + OPENGL_ENGINE, N_("OpenGL"), RE_INTERNAL, + NULL, &DRW_render_to_image, NULL, NULL, NULL, NULL, + &workbench_render_update_passes, &draw_engine_workbench_solid, {NULL, NULL, NULL} }; diff --git a/source/blender/draw/engines/workbench/workbench_engine.h b/source/blender/draw/engines/workbench/workbench_engine.h index a7f168db093..24f68cacd21 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.h +++ b/source/blender/draw/engines/workbench/workbench_engine.h @@ -28,6 +28,6 @@ extern DrawEngineType draw_engine_workbench_solid; extern DrawEngineType draw_engine_workbench_transparent; -extern RenderEngineType DRW_engine_viewport_workbench_type; +extern RenderEngineType DRW_engine_viewport_opengl_type; #endif /* __WORKBENCH_ENGINE_H__ */ diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 13e9686aa85..99d1b7060fd 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -36,6 +36,7 @@ #include "DRW_render.h" +#include "workbench_engine.h" #define WORKBENCH_ENGINE "BLENDER_WORKBENCH" #define M_GOLDEN_RATION_CONJUGATE 0.618033988749895 @@ -51,7 +52,7 @@ #define CAVITY_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_CAVITY) #define SHADOW_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_SHADOW) -#define IS_NAVIGATING(wpd) (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING) +#define IS_NAVIGATING(wpd) ((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING)) #define FXAA_ENABLED(wpd) ((!DRW_state_is_opengl_render()) && (IN_RANGE(wpd->user_preferences->gpu_viewport_quality, GPU_VIEWPORT_QUALITY_FXAA, GPU_VIEWPORT_QUALITY_TAA8) || ((wpd->user_preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8) && IS_NAVIGATING(wpd)))) #define TAA_ENABLED(wpd) (wpd->user_preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 && !IS_NAVIGATING(wpd)) #define SPECULAR_HIGHLIGHT_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && (!STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd))) @@ -61,6 +62,11 @@ #define NORMAL_ENCODING_ENABLED() (true) +struct RenderEngine; +struct RenderLayer; +struct rcti; + + typedef struct WORKBENCH_FramebufferList { /* Deferred render buffers */ struct GPUFrameBuffer *prepass_fb; @@ -231,6 +237,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata); void workbench_deferred_engine_free(void); void workbench_deferred_draw_background(WORKBENCH_Data *vedata); void workbench_deferred_draw_scene(WORKBENCH_Data *vedata); +void workbench_deferred_draw_finish(WORKBENCH_Data *vedata); void workbench_deferred_cache_init(WORKBENCH_Data *vedata); void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob); void workbench_deferred_cache_finish(WORKBENCH_Data *vedata); @@ -293,8 +300,8 @@ void workbench_volume_cache_init(WORKBENCH_Data *vedata); void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Object *ob, struct ModifierData *md); void workbench_volume_smoke_textures_free(WORKBENCH_PrivateData *wpd); - -extern DrawEngineType draw_engine_workbench_solid; -extern DrawEngineType draw_engine_workbench_transparent; +/* workbench_render.c */ +void workbench_render(WORKBENCH_Data *vedata, struct RenderEngine *engine, struct RenderLayer *render_layer, const struct rcti *rect); +void workbench_render_update_passes(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer); #endif diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c new file mode 100644 index 00000000000..1b25d4c875c --- /dev/null +++ b/source/blender/draw/engines/workbench/workbench_render.c @@ -0,0 +1,172 @@ +/* + * Copyright 2016, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Institute + * + */ + +/** \file workbench_render.c + * \ingroup draw_engine + * + * Render functions for final render output. + */ + +#include "BLI_rect.h" + +#include "BKE_report.h" + +#include "DRW_render.h" + +#include "GPU_shader.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + +#include "RE_pipeline.h" + +#include "workbench_private.h" + +static void workbench_render_cache( + void *vedata, struct Object *ob, + struct RenderEngine *UNUSED(engine), struct Depsgraph *UNUSED(depsgraph)) +{ + workbench_deferred_solid_cache_populate(vedata, ob); +} + +static void workbench_render_matrices_init(RenderEngine *engine, Depsgraph *depsgraph) +{ + /* TODO(sergey): Shall render hold pointer to an evaluated camera instead? */ + Scene *scene = DEG_get_evaluated_scene(depsgraph); + struct Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, RE_GetCamera(engine->re)); + float frame = BKE_scene_frame_get(scene); + + /* Set the persective, view and window matrix. */ + float winmat[4][4], wininv[4][4]; + float viewmat[4][4], viewinv[4][4]; + float persmat[4][4], persinv[4][4]; + + RE_GetCameraWindow(engine->re, ob_camera_eval, frame, winmat); + RE_GetCameraModelMatrix(engine->re, ob_camera_eval, viewinv); + + invert_m4_m4(viewmat, viewinv); + mul_m4_m4m4(persmat, winmat, viewmat); + invert_m4_m4(persinv, persmat); + invert_m4_m4(wininv, winmat); + + DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS); + DRW_viewport_matrix_override_set(persinv, DRW_MAT_PERSINV); + DRW_viewport_matrix_override_set(winmat, DRW_MAT_WIN); + DRW_viewport_matrix_override_set(wininv, DRW_MAT_WININV); + DRW_viewport_matrix_override_set(viewmat, DRW_MAT_VIEW); + DRW_viewport_matrix_override_set(viewinv, DRW_MAT_VIEWINV); +} + +static bool workbench_render_framebuffers_init(void) +{ + /* For image render, allocate own buffers because we don't have a viewport. */ + const float *viewport_size = DRW_viewport_size_get(); + const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]}; + + DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + dtxl->color = GPU_texture_create_2D(size[0], size[1], GPU_RGBA8, NULL, NULL); + dtxl->depth = GPU_texture_create_2D(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL); + + if (!(dtxl->depth && dtxl->color)) { + return false; + } + + DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); + + GPU_framebuffer_ensure_config(&dfbl->default_fb, { + GPU_ATTACHMENT_TEXTURE(dtxl->depth), + GPU_ATTACHMENT_TEXTURE(dtxl->color) + }); + + GPU_framebuffer_ensure_config(&dfbl->depth_only_fb, { + GPU_ATTACHMENT_TEXTURE(dtxl->depth), + GPU_ATTACHMENT_NONE + }); + + GPU_framebuffer_ensure_config(&dfbl->color_only_fb, { + GPU_ATTACHMENT_NONE, + GPU_ATTACHMENT_TEXTURE(dtxl->color) + }); + + bool ok = true; + ok = ok && GPU_framebuffer_check_valid(dfbl->default_fb, NULL); + ok = ok && GPU_framebuffer_check_valid(dfbl->color_only_fb, NULL); + ok = ok && GPU_framebuffer_check_valid(dfbl->depth_only_fb, NULL); + + return ok; +} + +static void workbench_render_framebuffers_finish(void) +{ +} + +void workbench_render(WORKBENCH_Data *data, RenderEngine *engine, RenderLayer *render_layer, const rcti *rect) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + + Depsgraph *depsgraph = draw_ctx->depsgraph; + workbench_render_matrices_init(engine, depsgraph); + + if (!workbench_render_framebuffers_init()) { + RE_engine_report(engine, RPT_ERROR, "Failed to allocate OpenGL buffers"); + return; + } + + /* Init engine. */ + workbench_deferred_engine_init(data); + + /* Init objects. */ + workbench_deferred_cache_init(data); + DRW_render_object_iter(data, engine, depsgraph, workbench_render_cache); + workbench_deferred_cache_finish(data); + DRW_render_instance_buffer_finish(); + + /* Draw. */ + int num_samples = workbench_taa_calculate_num_iterations(data); + for (int sample = 0; sample < num_samples; sample++) { + if (RE_engine_test_break(engine)) { + break; + } + + workbench_deferred_draw_background(data); + workbench_deferred_draw_scene(data); + } + + workbench_deferred_draw_finish(data); + + /* Write render output. */ + const char *viewname = RE_GetActiveRenderView(engine->re); + RenderPass *rp = RE_pass_find_by_name(render_layer, RE_PASSNAME_COMBINED, viewname); + + DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); + GPU_framebuffer_bind(dfbl->color_only_fb); + GPU_framebuffer_read_color(dfbl->color_only_fb, + rect->xmin, rect->ymin, + BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), + 4, 0, rp->rect); + + workbench_render_framebuffers_finish(); +} + +void workbench_render_update_passes(RenderEngine *engine, Scene *scene, ViewLayer *view_layer) +{ + RE_engine_register_pass(engine, scene, view_layer, RE_PASSNAME_COMBINED, 4, "RGBA", SOCK_RGBA); +} diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index a4a933250c9..16a17f4f21d 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -226,6 +226,7 @@ void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo); } while (0) void DRW_transform_to_display(struct GPUTexture *tex); +void DRW_transform_none(struct GPUTexture *tex); void DRW_multisamples_resolve( struct GPUTexture *src_depth, struct GPUTexture *src_color); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 707aadbc229..d23b9e693ce 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -51,6 +51,7 @@ static struct DRWShapeCache { Gwn_Batch *drw_cursor; Gwn_Batch *drw_cursor_only_circle; Gwn_Batch *drw_fullscreen_quad; + Gwn_Batch *drw_fullscreen_quad_texcoord; Gwn_Batch *drw_quad; Gwn_Batch *drw_sphere; Gwn_Batch *drw_screenspace_circle; @@ -287,6 +288,35 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void) return SHC.drw_fullscreen_quad; } +Gwn_Batch *DRW_cache_fullscreen_quad_texcoord_get(void) +{ + if (!SHC.drw_fullscreen_quad_texcoord) { + /* Use a triangle instead of a real quad */ + /* https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau - slide 14 */ + float pos[3][2] = {{-1.0f, -1.0f}, { 3.0f, -1.0f}, {-1.0f, 3.0f}}; + float texCoord[3][2] = {{ 0.0f, 0.0f}, { 2.0f, 0.0f}, { 0.0f, 2.0f}}; + + /* Position Only 2D format */ + static Gwn_VertFormat format = { 0 }; + static struct { uint pos, texCoord; } attr_id; + if (format.attr_len == 0) { + attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.texCoord = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + } + + Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GWN_vertbuf_data_alloc(vbo, 3); + + for (int i = 0; i < 3; ++i) { + GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); + GWN_vertbuf_attr_set(vbo, attr_id.texCoord, i, texCoord[i]); + } + + SHC.drw_fullscreen_quad_texcoord = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + } + return SHC.drw_fullscreen_quad_texcoord; +} + /* Just a regular quad with 4 vertices. */ Gwn_Batch *DRW_cache_quad_get(void) { diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index c1c80d2c5bf..07c8a571256 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -40,6 +40,7 @@ struct Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines); /* Common Shapes */ struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void); +struct Gwn_Batch *DRW_cache_fullscreen_quad_texcoord_get(void); struct Gwn_Batch *DRW_cache_quad_get(void); struct Gwn_Batch *DRW_cache_cube_get(void); struct Gwn_Batch *DRW_cache_sphere_get(void); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 556f02c2899..58ce9dd5218 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -283,6 +283,29 @@ void DRW_transform_to_display(GPUTexture *tex) } } +/* Draw texture to framebuffer without any color transforms */ +void DRW_transform_none(GPUTexture *tex) +{ + /* Draw as texture for final render (without immediate mode). */ + Gwn_Batch *geom = DRW_cache_fullscreen_quad_texcoord_get(); + GWN_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR); + + GPU_texture_bind(tex, 0); + + const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + GWN_batch_uniform_4fv(geom, "color", white); + + float mat[4][4]; + unit_m4(mat); + GWN_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); + + GWN_batch_program_use_begin(geom); + GWN_batch_draw_range_ex(geom, 0, 0, false); + GWN_batch_program_use_end(geom); + + GPU_texture_unbind(tex); +} + /** \} */ @@ -2217,8 +2240,8 @@ void DRW_engine_register(DrawEngineType *draw_engine_type) void DRW_engines_register(void) { + RE_engines_register(&DRW_engine_viewport_opengl_type); RE_engines_register(&DRW_engine_viewport_eevee_type); - RE_engines_register(&DRW_engine_viewport_workbench_type); DRW_engine_register(&draw_engine_workbench_solid); DRW_engine_register(&draw_engine_workbench_transparent); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 188ee928f3c..71bdd2e20c2 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -324,15 +324,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->grid = 1.0f; v3d->gridlines = 16; v3d->gridsubdiv = 10; - v3d->shading.type = OB_SOLID; - v3d->shading.prev_type = OB_SOLID; - v3d->shading.flag = V3D_SHADING_SPECULAR_HIGHLIGHT; - v3d->shading.light = V3D_LIGHTING_STUDIO; - v3d->shading.shadow_intensity = 0.5f; - v3d->shading.xray_alpha = 0.5f; - v3d->shading.cavity_valley_factor = 1.0f; - v3d->shading.cavity_ridge_factor = 1.0f; - copy_v3_fl(v3d->shading.single_color, 0.8f); + BKE_screen_view3d_shading_init(&v3d->shading); v3d->overlay.wireframe_threshold = 0.5f; v3d->overlay.bone_select_alpha = 0.5f; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 0c4c0a00f1a..16c8d8875c7 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1381,6 +1381,9 @@ typedef struct SceneDisplay { float matcap_ssao_attenuation; int matcap_ssao_samples; int pad; + + /* OpenGL render engine settings. */ + View3DShading shading; } SceneDisplay; typedef struct SceneEEVEE { @@ -1707,7 +1710,7 @@ enum { /* RenderData.engine (scene.c) */ extern const char *RE_engine_id_BLENDER_EEVEE; -extern const char *RE_engine_id_BLENDER_WORKBENCH; +extern const char *RE_engine_id_BLENDER_OPENGL; extern const char *RE_engine_id_CYCLES; /* **************** SCENE ********************* */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f8d6757c601..339d3841b30 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -5753,6 +5753,10 @@ static void rna_def_scene_display(BlenderRNA *brna) RNA_def_property_int_default(prop, 16); RNA_def_property_ui_text(prop, "Samples", "Number of samples"); RNA_def_property_range(prop, 1, 500); + + /* OpenGL render engine settings. */ + prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Shading Settings", "Shading settings for OpenGL render engine"); } static void rna_def_scene_eevee(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 66ff29a8c16..e670d3c31a5 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -679,8 +679,12 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - bScreen *screen = ptr->id.data; + ID *id = ptr->id.data; + if (GS(id->name) == ID_SCE) { + return; + } + bScreen *screen = ptr->id.data; for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { @@ -694,20 +698,40 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), Poi } } +static Scene *rna_3DViewShading_scene(PointerRNA *ptr) +{ + /* Get scene, depends if using 3D view or OpenGL render settings. */ + ID *id = ptr->id.data; + if (GS(id->name) == ID_SCE) { + return (Scene *)id; + } + else { + bScreen *screen = ptr->id.data; + return WM_windows_scene_get_from_screen(G_MAIN->wm.first, screen); + } +} + static int rna_3DViewShading_type_get(PointerRNA *ptr) { - bScreen *screen = ptr->id.data; - Scene *scene = WM_windows_scene_get_from_screen(G_MAIN->wm.first, screen); + /* Available shading types depend on render engine. */ + Scene *scene = rna_3DViewShading_scene(ptr); RenderEngineType *type = RE_engines_find(scene->r.engine); View3DShading *shading = (View3DShading *)ptr->data; - if (!BKE_scene_uses_blender_eevee(scene) && shading->type == OB_RENDER) { - if (!(type && type->view_draw)) { + if (BKE_scene_uses_blender_eevee(scene)) { + return shading->type; + } + else if (BKE_scene_uses_blender_opengl(scene)) { + return (shading->type == OB_MATERIAL) ? OB_RENDER : shading->type; + } + else { + if (shading->type == OB_RENDER && !(type && type->view_draw)) { return OB_MATERIAL; } + else { + return shading->type; + } } - - return shading->type; } static void rna_3DViewShading_type_set(PointerRNA *ptr, int value) @@ -720,11 +744,10 @@ static void rna_3DViewShading_type_set(PointerRNA *ptr, int value) } static const EnumPropertyItem *rna_3DViewShading_type_itemf( - bContext *C, PointerRNA *UNUSED(ptr), + bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - wmWindow *win = CTX_wm_window(C); - Scene *scene = WM_window_get_active_scene(win); + Scene *scene = rna_3DViewShading_scene(ptr); RenderEngineType *type = RE_engines_find(scene->r.engine); EnumPropertyItem *item = NULL; @@ -736,6 +759,9 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf( RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL); RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER); } + else if (BKE_scene_uses_blender_opengl(scene)) { + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER); + } else { RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL); if (type && type->view_draw) { @@ -2401,6 +2427,8 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + /* Note these settings are used for both 3D viewport and the OpenGL render + * engine in the scene, so can't assume to always be part of a screen. */ srna = RNA_def_struct(brna, "View3DShading", NULL); RNA_def_struct_path_func(srna, "rna_View3DShading_path"); RNA_def_struct_ui_text(srna, "3D View Shading Settings", "Settings for shading in the 3D viewport"); -- cgit v1.2.3 From 41045478ab7fd3efc989952bfd7a83c5cbb88dbc Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Tue, 17 Jul 2018 14:44:47 -0600 Subject: make.bat: remove msvc2013 support. --- build_files/windows/autodetect_msvc.cmd | 5 +-- build_files/windows/check_libraries.cmd | 1 - build_files/windows/detect_msvc2013.cmd | 3 -- build_files/windows/detect_msvc_classic.cmd | 69 ----------------------------- build_files/windows/parse_arguments.cmd | 2 - build_files/windows/show_help.cmd | 8 ++-- 6 files changed, 5 insertions(+), 83 deletions(-) delete mode 100644 build_files/windows/detect_msvc2013.cmd delete mode 100644 build_files/windows/detect_msvc_classic.cmd diff --git a/build_files/windows/autodetect_msvc.cmd b/build_files/windows/autodetect_msvc.cmd index 6fce3829e7b..77dc005cd18 100644 --- a/build_files/windows/autodetect_msvc.cmd +++ b/build_files/windows/autodetect_msvc.cmd @@ -1,14 +1,11 @@ echo No explicit msvc version requested, autodetecting version. -call "%~dp0\detect_msvc2013.cmd" +call "%~dp0\detect_msvc2017.cmd" if %ERRORLEVEL% EQU 0 goto DetectionComplete call "%~dp0\detect_msvc2015.cmd" if %ERRORLEVEL% EQU 0 goto DetectionComplete -call "%~dp0\detect_msvc2017.cmd" -if %ERRORLEVEL% EQU 0 goto DetectionComplete - echo Compiler Detection failed. Use verbose switch for more information. exit /b 1 diff --git a/build_files/windows/check_libraries.cmd b/build_files/windows/check_libraries.cmd index c8aad7c9adb..6ad1d1749c3 100644 --- a/build_files/windows/check_libraries.cmd +++ b/build_files/windows/check_libraries.cmd @@ -1,4 +1,3 @@ -if "%BUILD_VS_YEAR%"=="2013" set BUILD_VS_LIBDIRPOST=vc12 if "%BUILD_VS_YEAR%"=="2015" set BUILD_VS_LIBDIRPOST=vc14 if "%BUILD_VS_YEAR%"=="2017" set BUILD_VS_LIBDIRPOST=vc14 diff --git a/build_files/windows/detect_msvc2013.cmd b/build_files/windows/detect_msvc2013.cmd deleted file mode 100644 index 5688d31c4b6..00000000000 --- a/build_files/windows/detect_msvc2013.cmd +++ /dev/null @@ -1,3 +0,0 @@ -set BUILD_VS_VER=12 -set BUILD_VS_YEAR=2013 -call "%~dp0\detect_msvc_classic.cmd" \ No newline at end of file diff --git a/build_files/windows/detect_msvc_classic.cmd b/build_files/windows/detect_msvc_classic.cmd deleted file mode 100644 index 61bfcf92ddf..00000000000 --- a/build_files/windows/detect_msvc_classic.cmd +++ /dev/null @@ -1,69 +0,0 @@ -if NOT "%verbose%" == "" ( - echo Detecting msvc %BUILD_VS_YEAR% -) -set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC" -for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v ProductDir 2^>nul`) DO set MSVC_VC_DIR=%%C -if DEFINED MSVC_VC_DIR ( - if NOT "%verbose%" == "" ( - echo Visual Studio %BUILD_VS_YEAR% on Win64 detected at "%MSVC_VC_DIR%" - ) - goto msvc_detect_finally -) - -REM Check 32 bits -set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC" -for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v ProductDir 2^>nul`) DO set MSVC_VC_DIR=%%C -if DEFINED MSVC_VC_DIR ( - if NOT "%verbose%" == "" ( - echo Visual Studio %BUILD_VS_YEAR% on Win32 detected at "%MSVC_VC_DIR%" - ) - goto msvc_detect_finally -) -if NOT "%verbose%" == "" ( - echo Visual Studio %BUILD_VS_YEAR% not found. -) -goto FAIL -:msvc_detect_finally -set VCVARS=%MSVC_VC_DIR%\vcvarsall.bat -if not exist "%VCVARS%" ( - echo "%VCVARS%" not found. - goto FAIL -) - -call "%vcvars%" %BUILD_ARCH% - -rem try msbuild -msbuild /version > NUL -if errorlevel 1 ( - if NOT "%verbose%" == "" ( - echo Visual Studio %BUILD_VS_YEAR% msbuild not found - ) - goto FAIL -) - -if NOT "%verbose%" == "" ( - echo Visual Studio %BUILD_VS_YEAR% msbuild found -) - -REM try the c++ compiler -cl 2> NUL 1>&2 -if errorlevel 1 ( - if NOT "%verbose%" == "" ( - echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler not found - ) - goto FAIL -) - -if NOT "%verbose%" == "" ( - echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler found -) -goto DetectionComplete - -:FAIL -exit /b 1 - -:DetectionComplete -if NOT "%verbose%" == "" ( - echo Visual Studio %BUILD_VS_YEAR% Detected successfuly -) -exit /b 0 diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd index 8a6d743978d..e8caddaf4ea 100644 --- a/build_files/windows/parse_arguments.cmd +++ b/build_files/windows/parse_arguments.cmd @@ -59,8 +59,6 @@ if NOT "%1" == "" ( set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools ) else if "%1" == "2015" ( set BUILD_VS_YEAR=2015 - ) else if "%1" == "2013" ( - set BUILD_VS_YEAR=2013 ) else if "%1" == "packagename" ( set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2" shift /1 diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd index 2b297120f4b..694b28c88ed 100644 --- a/build_files/windows/show_help.cmd +++ b/build_files/windows/show_help.cmd @@ -22,13 +22,13 @@ echo - packagename [newname] ^(override default cpack package name^) echo - buildir [newdir] ^(override default build folder^) echo - x86 ^(override host auto-detect and build 32 bit code^) echo - x64 ^(override host auto-detect and build 64 bit code^) -echo - 2013 ^(build with visual studio 2013^) -echo. -echo Experimental options -echo - 2015 ^(build with visual studio 2015^) echo - 2017 ^(build with visual studio 2017^) echo - 2017pre ^(build with visual studio 2017 pre-release^) echo - 2017b ^(build with visual studio 2017 Build Tools^) + +echo. +echo Experimental options +echo - 2015 ^(build with visual studio 2015^) echo - clang ^(enable building with clang^) echo - asan ^(enable asan when building with clang^) echo - ninja ^(enable building with ninja instead of msbuild^) -- cgit v1.2.3 From 6329629bb9eab86a989367a148154a7ebfa074df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 17 Jul 2018 14:46:44 +0200 Subject: GWN: Port to GPU module: codestyle & licence --- intern/gawain/gawain/gwn_attr_binding.h | 47 +- intern/gawain/gawain/gwn_attr_binding_private.h | 43 +- intern/gawain/gawain/gwn_batch.h | 126 +++-- intern/gawain/gawain/gwn_batch_private.h | 44 +- intern/gawain/gawain/gwn_buffer_id.h | 51 +- intern/gawain/gawain/gwn_common.h | 48 +- intern/gawain/gawain/gwn_context.h | 49 +- intern/gawain/gawain/gwn_element.h | 87 +-- intern/gawain/gawain/gwn_imm_util.h | 58 +- intern/gawain/gawain/gwn_immediate.h | 150 +++--- intern/gawain/gawain/gwn_primitive.h | 47 +- intern/gawain/gawain/gwn_primitive_private.h | 43 +- intern/gawain/gawain/gwn_shader_interface.h | 103 ++-- intern/gawain/gawain/gwn_vertex_array_id.h | 55 +- intern/gawain/gawain/gwn_vertex_buffer.h | 143 ++--- intern/gawain/gawain/gwn_vertex_format.h | 73 ++- intern/gawain/gawain/gwn_vertex_format_private.h | 47 +- intern/gawain/src/gwn_attr_binding.c | 77 +-- intern/gawain/src/gwn_batch.c | 507 +++++++++--------- intern/gawain/src/gwn_buffer_id.cpp | 71 ++- intern/gawain/src/gwn_element.c | 265 ++++----- intern/gawain/src/gwn_imm_util.c | 72 ++- intern/gawain/src/gwn_immediate.c | 650 ++++++++++------------- intern/gawain/src/gwn_primitive.c | 65 ++- intern/gawain/src/gwn_shader_interface.c | 323 ++++++----- intern/gawain/src/gwn_vertex_array_id.cpp | 160 +++--- intern/gawain/src/gwn_vertex_buffer.c | 222 ++++---- intern/gawain/src/gwn_vertex_format.c | 233 ++++---- 28 files changed, 2155 insertions(+), 1704 deletions(-) diff --git a/intern/gawain/gawain/gwn_attr_binding.h b/intern/gawain/gawain/gwn_attr_binding.h index a209e1c4f0f..8030e86ea92 100644 --- a/intern/gawain/gawain/gwn_attr_binding.h +++ b/intern/gawain/gawain/gwn_attr_binding.h @@ -1,19 +1,42 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain vertex attribute binding -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_attr_binding.h + * \ingroup gpu + * + * Gawain vertex attribute binding + */ -#pragma once +#ifndef __GWN_ATTR_BINDING_H__ +#define __GWN_ATTR_BINDING_H__ #include "gwn_common.h" typedef struct Gwn_AttrBinding { - uint64_t loc_bits; // store 4 bits for each of the 16 attribs - uint16_t enabled_bits; // 1 bit for each attrib + uint64_t loc_bits; /* store 4 bits for each of the 16 attribs */ + uint16_t enabled_bits; /* 1 bit for each attrib */ } Gwn_AttrBinding; + +#endif /* __GWN_ATTR_BINDING_H__ */ diff --git a/intern/gawain/gawain/gwn_attr_binding_private.h b/intern/gawain/gawain/gwn_attr_binding_private.h index 300945d464b..cead1896ec7 100644 --- a/intern/gawain/gawain/gwn_attr_binding_private.h +++ b/intern/gawain/gawain/gwn_attr_binding_private.h @@ -1,15 +1,36 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain vertex attribute binding -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2017 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_attr_binding_private.h + * \ingroup gpu + * + * Gawain vertex attribute binding + */ -#pragma once +#ifndef __GWN_ATTR_BINDING_PRIVATE_H__ +#define __GWN_ATTR_BINDING_PRIVATE_H__ #include "gwn_vertex_format.h" #include "gwn_shader_interface.h" @@ -18,3 +39,5 @@ void AttribBinding_clear(Gwn_AttrBinding*); void get_attrib_locations(const Gwn_VertFormat*, Gwn_AttrBinding*, const Gwn_ShaderInterface*); unsigned read_attrib_location(const Gwn_AttrBinding*, unsigned a_idx); + +#endif /* __GWN_ATTR_BINDING_PRIVATE_H__ */ diff --git a/intern/gawain/gawain/gwn_batch.h b/intern/gawain/gawain/gwn_batch.h index 734df3c91b6..a7a54502cc0 100644 --- a/intern/gawain/gawain/gwn_batch.h +++ b/intern/gawain/gawain/gwn_batch.h @@ -1,15 +1,37 @@ - -// Gawain geometry batch -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#pragma once +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_batch.h + * \ingroup gpu + * + * Gawain geometry batch + * Contains VAOs + VBOs + Shader representing a drawable entity. + */ + +#ifndef __GWN_BATCH_H__ +#define __GWN_BATCH_H__ #include "gwn_vertex_buffer.h" #include "gwn_element.h" @@ -27,43 +49,43 @@ typedef enum { #define GWN_BATCH_VAO_DYN_ALLOC_COUNT 16 typedef struct Gwn_Batch { - // geometry - Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; // verts[0] is required, others can be NULL - Gwn_VertBuf* inst; // instance attribs - Gwn_IndexBuf* elem; // NULL if element list not needed + /* geometry */ + Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ + Gwn_VertBuf* inst; /* instance attribs */ + Gwn_IndexBuf* elem; /* NULL if element list not needed */ uint32_t gl_prim_type; - // cached values (avoid dereferencing later) + /* cached values (avoid dereferencing later) */ uint32_t vao_id; uint32_t program; const struct Gwn_ShaderInterface* interface; - // book-keeping - unsigned owns_flag; - struct Gwn_Context *context; // used to free all vaos. this implies all vaos were created under the same context. + /* book-keeping */ + uint owns_flag; + struct Gwn_Context *context; /* used to free all vaos. this implies all vaos were created under the same context. */ Gwn_BatchPhase phase; bool program_in_use; - // Vao management: remembers all geometry state (vertex attrib bindings & element buffer) - // for each shader interface. Start with a static number of vaos and fallback to dynamic count - // if necessary. Once a batch goes dynamic it does not go back. + /* Vao management: remembers all geometry state (vertex attrib bindings & element buffer) + * for each shader interface. Start with a static number of vaos and fallback to dynamic count + * if necessary. Once a batch goes dynamic it does not go back. */ bool is_dynamic_vao_count; union { - // Static handle count + /* Static handle count */ struct { const struct Gwn_ShaderInterface* interfaces[GWN_BATCH_VAO_STATIC_LEN]; uint32_t vao_ids[GWN_BATCH_VAO_STATIC_LEN]; } static_vaos; - // Dynamic handle count + /* Dynamic handle count */ struct { - unsigned count; + uint count; const struct Gwn_ShaderInterface** interfaces; uint32_t* vao_ids; } dynamic_vaos; }; - // XXX This is the only solution if we want to have some data structure using - // batches as key to identify nodes. We must destroy these nodes with this callback. + /* XXX This is the only solution if we want to have some data structure using + * batches as key to identify nodes. We must destroy these nodes with this callback. */ void (*free_callback)(struct Gwn_Batch*, void*); void* callback_data; } Gwn_Batch; @@ -75,8 +97,8 @@ enum { GWN_BATCH_OWNS_INDEX = (1 << 31), }; -Gwn_Batch* GWN_batch_create_ex(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, unsigned owns_flag); -void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, unsigned owns_flag); +Gwn_Batch* GWN_batch_create_ex(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); +void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src); #define GWN_batch_create(prim, verts, elem) \ @@ -84,11 +106,11 @@ Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src); #define GWN_batch_init(batch, prim, verts, elem) \ GWN_batch_init_ex(batch, prim, verts, elem, 0) -void GWN_batch_discard(Gwn_Batch*); // verts & elem are not discarded +void GWN_batch_discard(Gwn_Batch*); /* verts & elem are not discarded */ void GWN_batch_callback_free_set(Gwn_Batch*, void (*callback)(Gwn_Batch*, void*), void*); -void GWN_batch_instbuf_set(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); // Instancing +void GWN_batch_instbuf_set(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); /* Instancing */ int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); @@ -97,10 +119,10 @@ int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); void GWN_batch_program_set_no_use(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); void GWN_batch_program_set(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); -// Entire batch draws with one shader program, but can be redrawn later with another program. -// Vertex shader's inputs must be compatible with the batch's vertex format. +/* Entire batch draws with one shader program, but can be redrawn later with another program. */ +/* Vertex shader's inputs must be compatible with the batch's vertex format. */ -void GWN_batch_program_use_begin(Gwn_Batch*); // call before Batch_Uniform (temp hack?) +void GWN_batch_program_use_begin(Gwn_Batch*); /* call before Batch_Uniform (temp hack?) */ void GWN_batch_program_use_end(Gwn_Batch*); void GWN_batch_uniform_1ui(Gwn_Batch*, const char* name, int value); @@ -119,44 +141,44 @@ void GWN_batch_uniform_mat4(Gwn_Batch*, const char* name, const float data[4][4] void GWN_batch_draw(Gwn_Batch*); -// This does not bind/unbind shader and does not call GPU_matrix_bind() +/* This does not bind/unbind shader and does not call GPU_matrix_bind() */ void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance); -// Does not even need batch +/* Does not even need batch */ void GWN_draw_primitive(Gwn_PrimType, int v_count); -#if 0 // future plans +#if 0 /* future plans */ -// Can multiple batches share a Gwn_VertBuf? Use ref count? +/* Can multiple batches share a Gwn_VertBuf? Use ref count? */ -// We often need a batch with its own data, to be created and discarded together. -// WithOwn variants reduce number of system allocations. +/* We often need a batch with its own data, to be created and discarded together. */ +/* WithOwn variants reduce number of system allocations. */ typedef struct BatchWithOwnVertexBuffer { Gwn_Batch batch; - Gwn_VertBuf verts; // link batch.verts to this + Gwn_VertBuf verts; /* link batch.verts to this */ } BatchWithOwnVertexBuffer; typedef struct BatchWithOwnElementList { Gwn_Batch batch; - Gwn_IndexBuf elem; // link batch.elem to this + Gwn_IndexBuf elem; /* link batch.elem to this */ } BatchWithOwnElementList; typedef struct BatchWithOwnVertexBufferAndElementList { Gwn_Batch batch; - Gwn_IndexBuf elem; // link batch.elem to this - Gwn_VertBuf verts; // link batch.verts to this + Gwn_IndexBuf elem; /* link batch.elem to this */ + Gwn_VertBuf verts; /* link batch.verts to this */ } BatchWithOwnVertexBufferAndElementList; -Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, unsigned v_len, Gwn_IndexBuf*); -Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, unsigned prim_len); -Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, unsigned v_len, unsigned prim_len); -// verts: shared, own -// elem: none, shared, own +Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, uint v_len, Gwn_IndexBuf*); +Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, uint prim_len); +Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, uint v_len, uint prim_len); +/* verts: shared, own */ +/* elem: none, shared, own */ Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff); -#endif // future plans +#endif /* future plans */ /* Macros */ @@ -167,3 +189,5 @@ Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStu batch = NULL; \ } \ } while (0) + +#endif /* __GWN_BATCH_H__ */ diff --git a/intern/gawain/gawain/gwn_batch_private.h b/intern/gawain/gawain/gwn_batch_private.h index 6503429c237..e7d42ff0249 100644 --- a/intern/gawain/gawain/gwn_batch_private.h +++ b/intern/gawain/gawain/gwn_batch_private.h @@ -1,15 +1,37 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain context -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2018 Mike Erwin, Clément Foucault -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_batch_private.h + * \ingroup gpu + * + * Gawain geometry batch + * Contains VAOs + VBOs + Shader representing a drawable entity. + */ -#pragma once +#ifndef __GWN_BATCH_PRIVATE_H__ +#define __GWN_BATCH_PRIVATE_H__ #ifdef __cplusplus extern "C" { @@ -28,3 +50,5 @@ void gwn_context_remove_batch(Gwn_Context*, Gwn_Batch*); #ifdef __cplusplus } #endif + +#endif /* __GWN_BATCH_PRIVATE_H__ */ diff --git a/intern/gawain/gawain/gwn_buffer_id.h b/intern/gawain/gawain/gwn_buffer_id.h index 6f51ca6905d..0c2537a5d5a 100644 --- a/intern/gawain/gawain/gwn_buffer_id.h +++ b/intern/gawain/gawain/gwn_buffer_id.h @@ -1,20 +1,41 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain buffer IDs -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_buffer_id.h + * \ingroup gpu + * + * Gawain buffer IDs + */ -#pragma once +#ifndef __GWN_BUFFER_ID_H__ +#define __GWN_BUFFER_ID_H__ -// Manage GL buffer IDs in a thread-safe way -// Use these instead of glGenBuffers & its friends -// - alloc must be called from main thread -// - free can be called from any thread +/* Manage GL buffer IDs in a thread-safe way + * Use these instead of glGenBuffers & its friends + * - alloc must be called from main thread + * - free can be called from any thread */ #ifdef __cplusplus extern "C" { @@ -28,3 +49,5 @@ void GWN_buf_id_free(GLuint buffer_id); #ifdef __cplusplus } #endif + +#endif /* __GWN_BUFFER_ID_H__ */ diff --git a/intern/gawain/gawain/gwn_common.h b/intern/gawain/gawain/gwn_common.h index 6a56543da40..2587e8670a9 100644 --- a/intern/gawain/gawain/gwn_common.h +++ b/intern/gawain/gawain/gwn_common.h @@ -1,22 +1,41 @@ - -// Gawain common #defines and #includes -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#pragma once +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_common.h + * \ingroup gpu + */ + +#ifndef __GWN_COMMON_H__ +#define __GWN_COMMON_H__ #define PROGRAM_NO_OPTI 0 #if defined(NDEBUG) #define TRUST_NO_ONE 0 #else - // strict error checking, enabled for debug builds during early development + /* strict error checking, enabled for debug builds during early development */ #define TRUST_NO_ONE 1 #endif @@ -24,6 +43,7 @@ #include #endif +#include #include #include @@ -37,3 +57,5 @@ #else # define GWN_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) #endif + +#endif /* __GWN_COMMON_H__ */ diff --git a/intern/gawain/gawain/gwn_context.h b/intern/gawain/gawain/gwn_context.h index 3addce762b3..7784fc30562 100644 --- a/intern/gawain/gawain/gwn_context.h +++ b/intern/gawain/gawain/gwn_context.h @@ -1,17 +1,36 @@ - -// Gawain context -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2018 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#pragma once - -// This interface allow Gawain to manage VAOs for mutiple context and threads. +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_context.h + * \ingroup gpu + * + * This interface allow Gawain to manage VAOs for mutiple context and threads. + */ + +#ifndef __GWN_CONTEXT_H__ +#define __GWN_CONTEXT_H__ #ifdef __cplusplus extern "C" { @@ -32,3 +51,5 @@ Gwn_Context* GWN_context_active_get(void); #ifdef __cplusplus } #endif + +#endif /* __GWN_CONTEXT_H__ */ diff --git a/intern/gawain/gawain/gwn_element.h b/intern/gawain/gawain/gwn_element.h index 53a54cdfd76..2d5b6bb692b 100644 --- a/intern/gawain/gawain/gwn_element.h +++ b/intern/gawain/gawain/gwn_element.h @@ -1,15 +1,36 @@ - -// Gawain element list (AKA index buffer) -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#pragma once +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_element.h + * \ingroup gpu + * + * Gawain element list (AKA index buffer) + */ + +#ifndef __GWN_ELEMENT_H__ +#define __GWN_ELEMENT_H__ #include "gwn_primitive.h" @@ -18,50 +39,50 @@ #define GWN_PRIM_RESTART 0xFFFFFFFF typedef enum { - GWN_INDEX_U8, // GL has this, Vulkan does not + GWN_INDEX_U8, /* GL has this, Vulkan does not */ GWN_INDEX_U16, GWN_INDEX_U32 } Gwn_IndexBufType; typedef struct Gwn_IndexBuf { - unsigned index_len; + uint index_len; #if GWN_TRACK_INDEX_RANGE Gwn_IndexBufType index_type; uint32_t gl_index_type; - unsigned min_index; - unsigned max_index; - unsigned base_index; + uint min_index; + uint max_index; + uint base_index; #endif - uint32_t vbo_id; // 0 indicates not yet sent to VRAM + uint32_t vbo_id; /* 0 indicates not yet sent to VRAM */ bool use_prim_restart; } Gwn_IndexBuf; void GWN_indexbuf_use(Gwn_IndexBuf*); -unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf*); +uint GWN_indexbuf_size_get(const Gwn_IndexBuf*); typedef struct Gwn_IndexBufBuilder { - unsigned max_allowed_index; - unsigned max_index_len; - unsigned index_len; + uint max_allowed_index; + uint max_index_len; + uint index_len; Gwn_PrimType prim_type; - unsigned* data; + uint* data; bool use_prim_restart; } Gwn_IndexBufBuilder; -// supports all primitive types. -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned index_len, unsigned vertex_len, bool use_prim_restart); +/* supports all primitive types. */ +void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, uint index_len, uint vertex_len, bool use_prim_restart); -// supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS. -void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned prim_len, unsigned vertex_len); +/* supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS. */ +void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, uint prim_len, uint vertex_len); -void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, unsigned v); +void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, uint v); void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*); -void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, unsigned v); -void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2); -void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2, unsigned v3); -void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2, unsigned v3, unsigned v4); +void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, uint v); +void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, uint v1, uint v2); +void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3); +void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3, uint v4); Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*); void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*); @@ -77,3 +98,5 @@ void GWN_indexbuf_discard(Gwn_IndexBuf*); elem = NULL; \ } \ } while (0) + +#endif /* __GWN_ELEMENT_H__ */ diff --git a/intern/gawain/gawain/gwn_imm_util.h b/intern/gawain/gawain/gwn_imm_util.h index 5d17ec50669..e512d071dca 100644 --- a/intern/gawain/gawain/gwn_imm_util.h +++ b/intern/gawain/gawain/gwn_imm_util.h @@ -1,22 +1,46 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain immediate mode drawing utilities -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_imm_util.h + * \ingroup gpu + * + * Gawain element list (AKA index buffer) + */ -#pragma once +#ifndef __GWN_IMM_UTIL_H__ +#define __GWN_IMM_UTIL_H__ +#include -// Draw 2D rectangles (replaces glRect functions) -// caller is reponsible for vertex format & shader -void immRectf(unsigned pos, float x1, float y1, float x2, float y2); -void immRecti(unsigned pos, int x1, int y1, int x2, int y2); +/* Draw 2D rectangles (replaces glRect functions) */ +/* caller is reponsible for vertex format & shader */ +void immRectf(uint pos, float x1, float y1, float x2, float y2); +void immRecti(uint pos, int x1, int y1, int x2, int y2); -// Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS. -void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, float x2, float y2, const float color[4]); -void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2, int y2, const float color[4]); +/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS. */ +void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]); +void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]); + +#endif /* __GWN_IMM_UTIL_H__ */ diff --git a/intern/gawain/gawain/gwn_immediate.h b/intern/gawain/gawain/gwn_immediate.h index c3ea2b911a0..8231942d735 100644 --- a/intern/gawain/gawain/gwn_immediate.h +++ b/intern/gawain/gawain/gwn_immediate.h @@ -1,88 +1,101 @@ - -// Gawain immediate mode work-alike -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#pragma once +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_immediate.h + * \ingroup gpu + * + * Gawain immediate mode work-alike + */ + +#ifndef __GWN_IMMEDIATE_H__ +#define __GWN_IMMEDIATE_H__ #include "gwn_vertex_format.h" #include "gwn_primitive.h" #include "gwn_shader_interface.h" - -#define IMM_BATCH_COMBO 1 - - -Gwn_VertFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib - -void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first -void immUnbindProgram(void); // call after your last immEnd, or before binding another program - -void immBegin(Gwn_PrimType, unsigned vertex_len); // must supply exactly vertex_len vertices -void immBeginAtMost(Gwn_PrimType, unsigned max_vertex_len); // can supply fewer vertices -void immEnd(void); // finishes and draws - -#if IMM_BATCH_COMBO #include "gwn_batch.h" -// immBegin a batch, then use standard immFunctions as usual. -// immEnd will finalize the batch instead of drawing. -// Then you can draw it as many times as you like! Partially replaces the need for display lists. -Gwn_Batch* immBeginBatch(Gwn_PrimType, unsigned vertex_len); -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, unsigned vertex_len); -#endif +Gwn_VertFormat* immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ + +void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); /* every immBegin must have a program bound first. */ +void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */ -// provide attribute values that can change per vertex -// first vertex after immBegin must have all its attributes specified -// skipped attributes will continue using the previous value for that attrib_id -void immAttrib1f(unsigned attrib_id, float x); -void immAttrib2f(unsigned attrib_id, float x, float y); -void immAttrib3f(unsigned attrib_id, float x, float y, float z); -void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w); +void immBegin(Gwn_PrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */ +void immBeginAtMost(Gwn_PrimType, uint max_vertex_len); /* can supply fewer vertices. */ +void immEnd(void); /* finishes and draws. */ -void immAttrib2i(unsigned attrib_id, int x, int y); +/* ImmBegin a batch, then use standard immFunctions as usual. */ +/* ImmEnd will finalize the batch instead of drawing. */ +/* Then you can draw it as many times as you like! Partially replaces the need for display lists. */ +Gwn_Batch* immBeginBatch(Gwn_PrimType, uint vertex_len); +Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, uint vertex_len); -void immAttrib1u(unsigned attrib_id, unsigned x); +/* Provide attribute values that can change per vertex. */ +/* First vertex after immBegin must have all its attributes specified. */ +/* Skipped attributes will continue using the previous value for that attrib_id. */ +void immAttrib1f(uint attrib_id, float x); +void immAttrib2f(uint attrib_id, float x, float y); +void immAttrib3f(uint attrib_id, float x, float y, float z); +void immAttrib4f(uint attrib_id, float x, float y, float z, float w); -void immAttrib2s(unsigned attrib_id, short x, short y); +void immAttrib2i(uint attrib_id, int x, int y); -void immAttrib2fv(unsigned attrib_id, const float data[2]); -void immAttrib3fv(unsigned attrib_id, const float data[3]); -void immAttrib4fv(unsigned attrib_id, const float data[4]); +void immAttrib1u(uint attrib_id, uint x); -void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b); -void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a); +void immAttrib2s(uint attrib_id, short x, short y); -void immAttrib3ubv(unsigned attrib_id, const unsigned char data[4]); -void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]); +void immAttrib2fv(uint attrib_id, const float data[2]); +void immAttrib3fv(uint attrib_id, const float data[3]); +void immAttrib4fv(uint attrib_id, const float data[4]); -// explicitly skip an attribute -// this advanced option kills automatic value copying for this attrib_id -void immSkipAttrib(unsigned attrib_id); +void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b); +void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a); +void immAttrib3ubv(uint attrib_id, const unsigned char data[4]); +void immAttrib4ubv(uint attrib_id, const unsigned char data[4]); -// provide one last attribute value & end the current vertex -// this is most often used for 2D or 3D position (similar to glVertex) -void immVertex2f(unsigned attrib_id, float x, float y); -void immVertex3f(unsigned attrib_id, float x, float y, float z); -void immVertex4f(unsigned attrib_id, float x, float y, float z, float w); +/* Explicitly skip an attribute. */ +/* This advanced option kills automatic value copying for this attrib_id. */ +void immSkipAttrib(uint attrib_id); -void immVertex2i(unsigned attrib_id, int x, int y); +/* Provide one last attribute value & end the current vertex. */ +/* This is most often used for 2D or 3D position (similar to glVertex). */ +void immVertex2f(uint attrib_id, float x, float y); +void immVertex3f(uint attrib_id, float x, float y, float z); +void immVertex4f(uint attrib_id, float x, float y, float z, float w); -void immVertex2s(unsigned attrib_id, short x, short y); +void immVertex2i(uint attrib_id, int x, int y); -void immVertex2fv(unsigned attrib_id, const float data[2]); -void immVertex3fv(unsigned attrib_id, const float data[3]); +void immVertex2s(uint attrib_id, short x, short y); -void immVertex2iv(unsigned attrib_id, const int data[2]); +void immVertex2fv(uint attrib_id, const float data[2]); +void immVertex3fv(uint attrib_id, const float data[3]); +void immVertex2iv(uint attrib_id, const int data[2]); -// provide uniform values that don't change for the entire draw call +/* Provide uniform values that don't change for the entire draw call. */ void immUniform1i(const char* name, int x); void immUniform4iv(const char* name, const int data[4]); void immUniform1f(const char* name, float x); @@ -96,9 +109,8 @@ void immUniform4fv(const char* name, const float data[4]); void immUniformArray4fv(const char* bare_name, const float *data, int count); void immUniformMatrix4fv(const char* name, const float data[4][4]); - -// convenience functions for setting "uniform vec4 color" -// the rgb functions have implicit alpha = 1.0 +/* Convenience functions for setting "uniform vec4 color". */ +/* The rgb functions have implicit alpha = 1.0. */ void immUniformColor4f(float r, float g, float b, float a); void immUniformColor4fv(const float rgba[4]); void immUniformColor3f(float r, float g, float b); @@ -111,10 +123,10 @@ void immUniformColor3ubv(const unsigned char rgb[3]); void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a); void immUniformColor4ubv(const unsigned char rgba[4]); - -// these are called by the system -- not part of drawing API - +/* These are called by the system -- not part of drawing API. */ void immInit(void); void immActivate(void); void immDeactivate(void); void immDestroy(void); + +#endif /* __GWN_IMMEDIATE_H__ */ diff --git a/intern/gawain/gawain/gwn_primitive.h b/intern/gawain/gawain/gwn_primitive.h index 3359b3582bb..346f77441d3 100644 --- a/intern/gawain/gawain/gwn_primitive.h +++ b/intern/gawain/gawain/gwn_primitive.h @@ -1,15 +1,36 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain geometric primitives -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2017 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_primitive.h + * \ingroup gpu + * + * Gawain geometric primitives + */ -#pragma once +#ifndef __GWN_PRIMITIVE_H__ +#define __GWN_PRIMITIVE_H__ #include "gwn_common.h" @@ -18,7 +39,7 @@ typedef enum { GWN_PRIM_LINES, GWN_PRIM_TRIS, GWN_PRIM_LINE_STRIP, - GWN_PRIM_LINE_LOOP, // GL has this, Vulkan does not + GWN_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */ GWN_PRIM_TRI_STRIP, GWN_PRIM_TRI_FAN, @@ -29,7 +50,7 @@ typedef enum { GWN_PRIM_NONE } Gwn_PrimType; -// what types of primitives does each shader expect? +/* what types of primitives does each shader expect? */ typedef enum { GWN_PRIM_CLASS_NONE = 0, GWN_PRIM_CLASS_POINT = (1 << 0), @@ -40,3 +61,5 @@ typedef enum { Gwn_PrimClass GWN_primtype_class(Gwn_PrimType); bool GWN_primtype_belongs_to_class(Gwn_PrimType, Gwn_PrimClass); + +#endif /* __GWN_PRIMITIVE_H__ */ diff --git a/intern/gawain/gawain/gwn_primitive_private.h b/intern/gawain/gawain/gwn_primitive_private.h index d959cd89852..6d3f1e20da7 100644 --- a/intern/gawain/gawain/gwn_primitive_private.h +++ b/intern/gawain/gawain/gwn_primitive_private.h @@ -1,14 +1,37 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain geometric primitives (private interface for use inside Gawain) -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2017 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_primitive_private.h + * \ingroup gpu + * + * Gawain geometric primitives + */ -#pragma once +#ifndef __GWN_PRIMITIVE_PRIVATE_H__ +#define __GWN_PRIMITIVE_PRIVATE_H__ GLenum convert_prim_type_to_gl(Gwn_PrimType); + +#endif /* __GWN_PRIMITIVE_PRIVATE_H__ */ diff --git a/intern/gawain/gawain/gwn_shader_interface.h b/intern/gawain/gawain/gwn_shader_interface.h index b27b12c18d8..4b20719b329 100644 --- a/intern/gawain/gawain/gwn_shader_interface.h +++ b/intern/gawain/gawain/gwn_shader_interface.h @@ -1,55 +1,76 @@ - -// Gawain shader interface (C --> GLSL) -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2017 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#pragma once +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_shader_interface.h + * \ingroup gpu + * + * Gawain shader interface (C --> GLSL) + */ + +#ifndef __GWN_SHADER_INTERFACE_H__ +#define __GWN_SHADER_INTERFACE_H__ #include "gwn_common.h" typedef enum { - GWN_UNIFORM_NONE = 0, // uninitialized/unknown + GWN_UNIFORM_NONE = 0, /* uninitialized/unknown */ - GWN_UNIFORM_MODEL, // mat4 ModelMatrix - GWN_UNIFORM_VIEW, // mat4 ViewMatrix - GWN_UNIFORM_MODELVIEW, // mat4 ModelViewMatrix - GWN_UNIFORM_PROJECTION, // mat4 ProjectionMatrix - GWN_UNIFORM_VIEWPROJECTION, // mat4 ViewProjectionMatrix - GWN_UNIFORM_MVP, // mat4 ModelViewProjectionMatrix + GWN_UNIFORM_MODEL, /* mat4 ModelMatrix */ + GWN_UNIFORM_VIEW, /* mat4 ViewMatrix */ + GWN_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */ + GWN_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */ + GWN_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */ + GWN_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */ - GWN_UNIFORM_MODEL_INV, // mat4 ModelMatrixInverse - GWN_UNIFORM_VIEW_INV, // mat4 ViewMatrixInverse - GWN_UNIFORM_MODELVIEW_INV, // mat4 ModelViewMatrixInverse - GWN_UNIFORM_PROJECTION_INV, // mat4 ProjectionMatrixInverse - GWN_UNIFORM_VIEWPROJECTION_INV, // mat4 ViewProjectionMatrixInverse + GWN_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */ + GWN_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */ + GWN_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */ + GWN_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */ + GWN_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */ - GWN_UNIFORM_NORMAL, // mat3 NormalMatrix - GWN_UNIFORM_WORLDNORMAL, // mat3 WorldNormalMatrix - GWN_UNIFORM_CAMERATEXCO, // vec4 CameraTexCoFactors - GWN_UNIFORM_ORCO, // vec3 OrcoTexCoFactors[] + GWN_UNIFORM_NORMAL, /* mat3 NormalMatrix */ + GWN_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */ + GWN_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ + GWN_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ - GWN_UNIFORM_COLOR, // vec4 color - GWN_UNIFORM_EYE, // vec3 eye - GWN_UNIFORM_CALLID, // int callId + GWN_UNIFORM_COLOR, /* vec4 color */ + GWN_UNIFORM_EYE, /* vec3 eye */ + GWN_UNIFORM_CALLID, /* int callId */ - GWN_UNIFORM_CUSTOM, // custom uniform, not one of the above built-ins + GWN_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ - GWN_NUM_UNIFORMS, // Special value, denotes number of builtin uniforms. + GWN_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ } Gwn_UniformBuiltin; typedef struct Gwn_ShaderInput { struct Gwn_ShaderInput* next; uint32_t name_offset; - unsigned name_hash; - Gwn_UniformBuiltin builtin_type; // only for uniform inputs - uint32_t gl_type; // only for attrib inputs - int32_t size; // only for attrib inputs + uint name_hash; + Gwn_UniformBuiltin builtin_type; /* only for uniform inputs */ + uint32_t gl_type; /* only for attrib inputs */ + int32_t size; /* only for attrib inputs */ int32_t location; } Gwn_ShaderInput; @@ -64,8 +85,8 @@ typedef struct Gwn_ShaderInterface { Gwn_ShaderInput* ubo_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS]; char* name_buffer; - struct Gwn_Batch** batches; // references to batches using this interface - unsigned batches_len; + struct Gwn_Batch** batches; /* references to batches using this interface */ + uint batches_len; } Gwn_ShaderInterface; Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id); @@ -76,6 +97,8 @@ const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInter const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface*, const char* name); const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name); -// keep track of batches using this interface +/* keep track of batches using this interface */ void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); + +#endif /* __GWN_SHADER_INTERFACE_H__ */ diff --git a/intern/gawain/gawain/gwn_vertex_array_id.h b/intern/gawain/gawain/gwn_vertex_array_id.h index 1c093d428ce..6ba26612b4e 100644 --- a/intern/gawain/gawain/gwn_vertex_array_id.h +++ b/intern/gawain/gawain/gwn_vertex_array_id.h @@ -1,22 +1,41 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain buffer IDs -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2018 Mike Erwin, Clément Foucault -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_vertex_array_id.h + * \ingroup gpu + * + * Manage GL vertex array IDs in a thread-safe way + * Use these instead of glGenBuffers & its friends + * - alloc must be called from a thread that is bound + * to the context that will be used for drawing with + * this vao. + * - free can be called from any thread + */ -#pragma once - -// Manage GL vertex array IDs in a thread-safe way -// Use these instead of glGenBuffers & its friends -// - alloc must be called from a thread that is bound -// to the context that will be used for drawing with -// this vao. -// - free can be called from any thread +#ifndef __GWN_VERTEX_ARRAY_ID_H__ +#define __GWN_VERTEX_ARRAY_ID_H__ #ifdef __cplusplus extern "C" { @@ -32,3 +51,5 @@ void GWN_vao_free(GLuint vao_id, Gwn_Context*); #ifdef __cplusplus } #endif + +#endif /* __GWN_VERTEX_ARRAY_ID_H__ */ diff --git a/intern/gawain/gawain/gwn_vertex_buffer.h b/intern/gawain/gawain/gwn_vertex_buffer.h index 0eac4838e65..84ea12f86d1 100644 --- a/intern/gawain/gawain/gwn_vertex_buffer.h +++ b/intern/gawain/gawain/gwn_vertex_buffer.h @@ -1,42 +1,63 @@ - -// Gawain vertex buffer -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#pragma once +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_vertex_buffer.h + * \ingroup gpu + * + * Gawain vertex buffer + */ + +#ifndef __GWN_VERTEX_BUFFER_H__ +#define __GWN_VERTEX_BUFFER_H__ #include "gwn_vertex_format.h" #define VRAM_USAGE 1 -// How to create a Gwn_VertBuf: -// 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts) -// 2) GWN_vertformat_attr_add(verts->format, ...) -// 3) GWN_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format -// 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer) +/* How to create a Gwn_VertBuf: */ +/* 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts) */ +/* 2) GWN_vertformat_attr_add(verts->format, ...) */ +/* 3) GWN_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format */ +/* 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer) */ -// Is Gwn_VertBuf always used as part of a Gwn_Batch? +/* Is Gwn_VertBuf always used as part of a Gwn_Batch? */ typedef enum { - // can be extended to support more types + /* can be extended to support more types */ GWN_USAGE_STREAM, - GWN_USAGE_STATIC, // do not keep data in memory + GWN_USAGE_STATIC, /* do not keep data in memory */ GWN_USAGE_DYNAMIC } Gwn_UsageType; typedef struct Gwn_VertBuf { Gwn_VertFormat format; - unsigned vertex_len; /* number of verts we want to draw */ - unsigned vertex_alloc; /* number of verts data */ + uint vertex_len; /* number of verts we want to draw */ + uint vertex_alloc; /* number of verts data */ bool dirty; - unsigned char* data; // NULL indicates data in VRAM (unmapped) - uint32_t vbo_id; // 0 indicates not yet allocated - Gwn_UsageType usage; // usage hint for GL optimisation + unsigned char* data; /* NULL indicates data in VRAM (unmapped) */ + uint32_t vbo_id; /* 0 indicates not yet allocated */ + Gwn_UsageType usage; /* usage hint for GL optimisation */ } Gwn_VertBuf; Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType); @@ -53,73 +74,71 @@ void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf*, const Gwn_VertFormat*, Gwn_Us #define GWN_vertbuf_init_with_format(verts, format) \ GWN_vertbuf_init_with_format_ex(verts, format, GWN_USAGE_STATIC) -unsigned GWN_vertbuf_size_get(const Gwn_VertBuf*); -void GWN_vertbuf_data_alloc(Gwn_VertBuf*, unsigned v_len); -void GWN_vertbuf_data_resize(Gwn_VertBuf*, unsigned v_len); -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, unsigned v_len); +uint GWN_vertbuf_size_get(const Gwn_VertBuf*); +void GWN_vertbuf_data_alloc(Gwn_VertBuf*, uint v_len); +void GWN_vertbuf_data_resize(Gwn_VertBuf*, uint v_len); +void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, uint v_len); -// The most important set_attrib variant is the untyped one. Get it right first. -// It takes a void* so the app developer is responsible for matching their app data types -// to the vertex attribute's type and component count. They're in control of both, so this -// should not be a problem. +/* The most important set_attrib variant is the untyped one. Get it right first. */ +/* It takes a void* so the app developer is responsible for matching their app data types */ +/* to the vertex attribute's type and component count. They're in control of both, so this */ +/* should not be a problem. */ -void GWN_vertbuf_attr_set(Gwn_VertBuf*, unsigned a_idx, unsigned v_idx, const void* data); -void GWN_vertbuf_attr_fill(Gwn_VertBuf*, unsigned a_idx, const void* data); // tightly packed, non interleaved input data -void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, unsigned a_idx, unsigned stride, const void* data); +void GWN_vertbuf_attr_set(Gwn_VertBuf*, uint a_idx, uint v_idx, const void* data); +void GWN_vertbuf_attr_fill(Gwn_VertBuf*, uint a_idx, const void* data); /* tightly packed, non interleaved input data */ +void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, uint a_idx, uint stride, const void* data); -// For low level access only +/* For low level access only */ typedef struct Gwn_VertBufRaw { - unsigned size; - unsigned stride; + uint size; + uint stride; unsigned char* data; unsigned char* data_init; #if TRUST_NO_ONE - // Only for overflow check + /* Only for overflow check */ unsigned char* _data_end; #endif } Gwn_VertBufRaw; GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a) - { +{ unsigned char* data = a->data; a->data += a->stride; #if TRUST_NO_ONE assert(data < a->_data_end); #endif return (void *)data; - } +} -GWN_INLINE unsigned GWN_vertbuf_raw_used(Gwn_VertBufRaw *a) - { +GWN_INLINE uint GWN_vertbuf_raw_used(Gwn_VertBufRaw *a) +{ return ((a->data - a->data_init) / a->stride); - } - -void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, unsigned a_idx, Gwn_VertBufRaw *access); - -// TODO: decide whether to keep the functions below -// doesn't immediate mode satisfy these needs? +} -// void setAttrib1f(unsigned a_idx, unsigned v_idx, float x); -// void setAttrib2f(unsigned a_idx, unsigned v_idx, float x, float y); -// void setAttrib3f(unsigned a_idx, unsigned v_idx, float x, float y, float z); -// void setAttrib4f(unsigned a_idx, unsigned v_idx, float x, float y, float z, float w); -// -// void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b); -// void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a); - -void GWN_vertbuf_use(Gwn_VertBuf*); +void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, uint a_idx, Gwn_VertBufRaw *access); +/* TODO: decide whether to keep the functions below */ +/* doesn't immediate mode satisfy these needs? */ -// Metrics +/* void setAttrib1f(uint a_idx, uint v_idx, float x); */ +/* void setAttrib2f(uint a_idx, unsigned v_idx, float x, float y); */ +/* void setAttrib3f(unsigned a_idx, unsigned v_idx, float x, float y, float z); */ +/* void setAttrib4f(unsigned a_idx, unsigned v_idx, float x, float y, float z, float w); */ -unsigned GWN_vertbuf_get_memory_usage(void); +/* void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b); */ +/* void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a); */ +void GWN_vertbuf_use(Gwn_VertBuf*); -// Macros +/* Metrics */ +uint GWN_vertbuf_get_memory_usage(void); +/* Macros */ #define GWN_VERTBUF_DISCARD_SAFE(verts) do { \ if (verts != NULL) { \ GWN_vertbuf_discard(verts); \ verts = NULL; \ } \ } while (0) + +#endif /* __GWN_VERTEX_BUFFER_H__ */ diff --git a/intern/gawain/gawain/gwn_vertex_format.h b/intern/gawain/gawain/gwn_vertex_format.h index a4593e4615b..1197a8ef842 100644 --- a/intern/gawain/gawain/gwn_vertex_format.h +++ b/intern/gawain/gawain/gwn_vertex_format.h @@ -1,15 +1,36 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain vertex format -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_vertex_format.h + * \ingroup gpu + * + * Gawain vertex format + */ -#pragma once +#ifndef __GWN_VERTEX_FORMAT_H__ +#define __GWN_VERTEX_FORMAT_H__ #include "gwn_common.h" @@ -34,45 +55,47 @@ typedef enum { typedef enum { GWN_FETCH_FLOAT, GWN_FETCH_INT, - GWN_FETCH_INT_TO_FLOAT_UNIT, // 127 (ubyte) -> 0.5 (and so on for other int types) - GWN_FETCH_INT_TO_FLOAT // 127 (any int type) -> 127.0 + GWN_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */ + GWN_FETCH_INT_TO_FLOAT /* 127 (any int type) -> 127.0 */ } Gwn_VertFetchMode; typedef struct Gwn_VertAttr { Gwn_VertFetchMode fetch_mode; Gwn_VertCompType comp_type; - unsigned gl_comp_type; - unsigned comp_len; // 1 to 4 or 8 or 12 or 16 - unsigned sz; // size in bytes, 1 to 64 - unsigned offset; // from beginning of vertex, in bytes - unsigned name_len; // up to GWN_VERT_ATTR_MAX_NAMES + uint gl_comp_type; + uint comp_len; /* 1 to 4 or 8 or 12 or 16 */ + uint sz; /* size in bytes, 1 to 64 */ + uint offset; /* from beginning of vertex, in bytes */ + uint name_len; /* up to GWN_VERT_ATTR_MAX_NAMES */ const char* name[GWN_VERT_ATTR_MAX_NAMES]; } Gwn_VertAttr; typedef struct Gwn_VertFormat { - unsigned attr_len; // 0 to 16 (GWN_VERT_ATTR_MAX_LEN) - unsigned name_len; // total count of active vertex attrib - unsigned stride; // stride in bytes, 1 to 256 - unsigned name_offset; + uint attr_len; /* 0 to 16 (GWN_VERT_ATTR_MAX_LEN) */ + uint name_len; /* total count of active vertex attrib */ + uint stride; /* stride in bytes, 1 to 256 */ + uint name_offset; bool packed; char names[GWN_VERT_ATTR_NAMES_BUF_LEN]; - Gwn_VertAttr attribs[GWN_VERT_ATTR_MAX_LEN]; // TODO: variable-size attribs array + Gwn_VertAttr attribs[GWN_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */ } Gwn_VertFormat; void GWN_vertformat_clear(Gwn_VertFormat*); void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src); -unsigned GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, unsigned comp_len, Gwn_VertFetchMode); +uint GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, uint comp_len, Gwn_VertFetchMode); void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias); -// format conversion +/* format conversion */ typedef struct Gwn_PackedNormal { int x : 10; int y : 10; int z : 10; - int w : 2; // 0 by default, can manually set to { -2, -1, 0, 1 } + int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */ } Gwn_PackedNormal; Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]); Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]); + +#endif /* __GWN_VERTEX_FORMAT_H__ */ diff --git a/intern/gawain/gawain/gwn_vertex_format_private.h b/intern/gawain/gawain/gwn_vertex_format_private.h index 90cd8412e53..3cae9969fd8 100644 --- a/intern/gawain/gawain/gwn_vertex_format_private.h +++ b/intern/gawain/gawain/gwn_vertex_format_private.h @@ -1,16 +1,39 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain vertex format (private interface for use inside Gawain) -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016-2017 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/gwn_vertex_format_private.h + * \ingroup gpu + * + * Gawain vertex format + */ -#pragma once +#ifndef __GWN_VERTEX_FORMAT_PRIVATE_H__ +#define __GWN_VERTEX_FORMAT_PRIVATE_H__ void VertexFormat_pack(Gwn_VertFormat*); -unsigned padding(unsigned offset, unsigned alignment); -unsigned vertex_buffer_size(const Gwn_VertFormat*, unsigned vertex_len); +uint padding(uint offset, uint alignment); +uint vertex_buffer_size(const Gwn_VertFormat*, uint vertex_len); + +#endif /* __GWN_VERTEX_FORMAT_PRIVATE_H__ */ diff --git a/intern/gawain/src/gwn_attr_binding.c b/intern/gawain/src/gwn_attr_binding.c index c702a0ae99d..727aceb0140 100644 --- a/intern/gawain/src/gwn_attr_binding.c +++ b/intern/gawain/src/gwn_attr_binding.c @@ -1,70 +1,85 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain vertex attribute binding -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/intern/gwn_attr_binding.c + * \ingroup gpu + * + * Gawain vertex attribute binding + */ #include "gwn_attr_binding.h" #include "gwn_attr_binding_private.h" #include +#include #if GWN_VERT_ATTR_MAX_LEN != 16 #error "attrib binding code assumes GWN_VERT_ATTR_MAX_LEN = 16" #endif void AttribBinding_clear(Gwn_AttrBinding* binding) - { +{ binding->loc_bits = 0; binding->enabled_bits = 0; - } +} -unsigned read_attrib_location(const Gwn_AttrBinding* binding, unsigned a_idx) - { +uint read_attrib_location(const Gwn_AttrBinding* binding, uint a_idx) +{ #if TRUST_NO_ONE assert(a_idx < GWN_VERT_ATTR_MAX_LEN); assert(binding->enabled_bits & (1 << a_idx)); #endif - return (binding->loc_bits >> (4 * a_idx)) & 0xF; - } +} -static void write_attrib_location(Gwn_AttrBinding* binding, unsigned a_idx, unsigned location) - { +static void write_attrib_location(Gwn_AttrBinding* binding, uint a_idx, uint location) +{ #if TRUST_NO_ONE assert(a_idx < GWN_VERT_ATTR_MAX_LEN); assert(location < GWN_VERT_ATTR_MAX_LEN); #endif - - const unsigned shift = 4 * a_idx; + const uint shift = 4 * a_idx; const uint64_t mask = ((uint64_t)0xF) << shift; - // overwrite this attrib's previous location + /* overwrite this attrib's previous location */ binding->loc_bits = (binding->loc_bits & ~mask) | (location << shift); - // mark this attrib as enabled + /* mark this attrib as enabled */ binding->enabled_bits |= 1 << a_idx; - } +} void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding, const Gwn_ShaderInterface* shaderface) - { +{ AttribBinding_clear(binding); - for (unsigned a_idx = 0; a_idx < format->attr_len; ++a_idx) - { + for (uint a_idx = 0; a_idx < format->attr_len; ++a_idx) { const Gwn_VertAttr* a = format->attribs + a_idx; - for (unsigned n_idx = 0; n_idx < a->name_len; ++n_idx) - { + for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]); - #if TRUST_NO_ONE assert(input != NULL); - // TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program + /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */ #endif - write_attrib_location(binding, a_idx, input->location); - } } } +} diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c index 4979d93b15e..5daf0e87aec 100644 --- a/intern/gawain/src/gwn_batch.c +++ b/intern/gawain/src/gwn_batch.c @@ -1,13 +1,34 @@ - -// Gawain geometry batch -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_batch.c + * \ingroup gpu + * + * Gawain geometry batch + * Contains VAOs + VBOs + Shader representing a drawable entity. + */ #include "gwn_batch.h" #include "gwn_batch_private.h" @@ -17,72 +38,68 @@ #include #include -// necessary functions from matrix API +/* necessary functions from matrix API */ extern void GPU_matrix_bind(const Gwn_ShaderInterface* shaderface); -static void batch_update_program_bindings(Gwn_Batch* batch, unsigned int v_first); +static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first); void gwn_batch_vao_cache_clear(Gwn_Batch* batch) - { - if (batch->context == NULL) +{ + if (batch->context == NULL) { return; - - if (batch->is_dynamic_vao_count) - { - for (int i = 0; i < batch->dynamic_vaos.count; ++i) - { - if (batch->dynamic_vaos.vao_ids[i]) + } + if (batch->is_dynamic_vao_count) { + for (int i = 0; i < batch->dynamic_vaos.count; ++i) { + if (batch->dynamic_vaos.vao_ids[i]) { GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); - if (batch->dynamic_vaos.interfaces[i]) + } + if (batch->dynamic_vaos.interfaces[i]) { GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->dynamic_vaos.interfaces[i], batch); } + } free(batch->dynamic_vaos.interfaces); free(batch->dynamic_vaos.vao_ids); - } - else - { - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) - { - if (batch->static_vaos.vao_ids[i]) + } + else { + for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + if (batch->static_vaos.vao_ids[i]) { GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); - if (batch->static_vaos.interfaces[i]) + } + if (batch->static_vaos.interfaces[i]) { GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->static_vaos.interfaces[i], batch); } } - + } batch->is_dynamic_vao_count = false; - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) - { + for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { batch->static_vaos.vao_ids[i] = 0; batch->static_vaos.interfaces[i] = NULL; - } - + } gwn_context_remove_batch(batch->context, batch); batch->context = NULL; - } +} Gwn_Batch* GWN_batch_create_ex( Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, - unsigned owns_flag) - { + uint owns_flag) +{ Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch)); - GWN_batch_init_ex(batch, prim_type, verts, elem, owns_flag); - return batch; - } +} void GWN_batch_init_ex( Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, - unsigned owns_flag) - { + uint owns_flag) +{ #if TRUST_NO_ONE assert(verts != NULL); #endif batch->verts[0] = verts; - for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) + for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { batch->verts[v] = NULL; + } batch->inst = NULL; batch->elem = elem; batch->gl_prim_type = convert_prim_type_to_gl(prim_type); @@ -90,184 +107,175 @@ void GWN_batch_init_ex( batch->is_dynamic_vao_count = false; batch->owns_flag = owns_flag; batch->free_callback = NULL; - } +} -// This will share the VBOs with the new batch +/* This will share the VBOs with the new batch. */ Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src) - { +{ Gwn_Batch* batch = GWN_batch_create_ex(GWN_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); batch->gl_prim_type = batch_src->gl_prim_type; - for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) + for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { batch->verts[v] = batch_src->verts[v]; - - return batch; } + return batch; +} void GWN_batch_discard(Gwn_Batch* batch) - { - if (batch->owns_flag & GWN_BATCH_OWNS_INDEX) +{ + if (batch->owns_flag & GWN_BATCH_OWNS_INDEX) { GWN_indexbuf_discard(batch->elem); - - if (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES) + } + if (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES) { GWN_vertbuf_discard(batch->inst); - - if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0) - { - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) - { - if (batch->verts[v] == NULL) + } + if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0) { + for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + if (batch->verts[v] == NULL) { break; - if (batch->owns_flag & (1 << v)) + } + if (batch->owns_flag & (1 << v)) { GWN_vertbuf_discard(batch->verts[v]); } } - + } gwn_batch_vao_cache_clear(batch); - if (batch->free_callback) + if (batch->free_callback) { batch->free_callback(batch, batch->callback_data); - - free(batch); } + free(batch); +} void GWN_batch_callback_free_set(Gwn_Batch* batch, void (*callback)(Gwn_Batch*, void*), void* user_data) - { +{ batch->free_callback = callback; batch->callback_data = user_data; - } +} void GWN_batch_instbuf_set(Gwn_Batch* batch, Gwn_VertBuf* inst, bool own_vbo) - { +{ #if TRUST_NO_ONE assert(inst != NULL); #endif - // redo the bindings + /* redo the bindings */ gwn_batch_vao_cache_clear(batch); - if (batch->inst != NULL && (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES)) + if (batch->inst != NULL && (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES)) { GWN_vertbuf_discard(batch->inst); - + } batch->inst = inst; - if (own_vbo) + if (own_vbo) { batch->owns_flag |= GWN_BATCH_OWNS_INSTANCES; - else + } + else { batch->owns_flag &= ~GWN_BATCH_OWNS_INSTANCES; } +} +/* Returns the index of verts in the batch. */ int GWN_batch_vertbuf_add_ex( Gwn_Batch* batch, Gwn_VertBuf* verts, bool own_vbo) - { - // redo the bindings +{ + /* redo the bindings */ gwn_batch_vao_cache_clear(batch); - for (unsigned v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) - { - if (batch->verts[v] == NULL) - { + for (uint v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + if (batch->verts[v] == NULL) { #if TRUST_NO_ONE - // for now all VertexBuffers must have same vertex_len + /* for now all VertexBuffers must have same vertex_len */ assert(verts->vertex_len == batch->verts[0]->vertex_len); - // in the near future we will enable instanced attribs which have their own vertex_len #endif batch->verts[v] = verts; - // TODO: mark dirty so we can keep attrib bindings up-to-date + /* TODO: mark dirty so we can keep attrib bindings up-to-date */ if (own_vbo) batch->owns_flag |= (1 << v); return v; - } } + } - // we only make it this far if there is no room for another Gwn_VertBuf + /* we only make it this far if there is no room for another Gwn_VertBuf */ #if TRUST_NO_ONE assert(false); #endif return -1; - } +} static GLuint batch_vao_get(Gwn_Batch *batch) - { - // Search through cache - if (batch->is_dynamic_vao_count) - { +{ + /* Search through cache */ + if (batch->is_dynamic_vao_count) { for (int i = 0; i < batch->dynamic_vaos.count; ++i) if (batch->dynamic_vaos.interfaces[i] == batch->interface) return batch->dynamic_vaos.vao_ids[i]; - } - else - { + } + else { for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) if (batch->static_vaos.interfaces[i] == batch->interface) return batch->static_vaos.vao_ids[i]; - } + } - // Set context of this batch. - // It will be bound to it until gwn_batch_vao_cache_clear is called. - // Until then it can only be drawn with this context. - if (batch->context == NULL) - { + /* Set context of this batch. + * It will be bound to it until gwn_batch_vao_cache_clear is called. + * Until then it can only be drawn with this context. */ + if (batch->context == NULL) { batch->context = GWN_context_active_get(); gwn_context_add_batch(batch->context, batch); - } + } #if TRUST_NO_ONE - else // Make sure you are not trying to draw this batch in another context. + else { + /* Make sure you are not trying to draw this batch in another context. */ assert(batch->context == GWN_context_active_get()); + } #endif - // Cache miss, time to add a new entry! + /* Cache miss, time to add a new entry! */ GLuint new_vao = 0; - if (!batch->is_dynamic_vao_count) - { - int i; // find first unused slot - for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) + if (!batch->is_dynamic_vao_count) { + int i; /* find first unused slot */ + for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) if (batch->static_vaos.vao_ids[i] == 0) break; - if (i < GWN_BATCH_VAO_STATIC_LEN) - { + if (i < GWN_BATCH_VAO_STATIC_LEN) { batch->static_vaos.interfaces[i] = batch->interface; batch->static_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); - } - else - { - // Not enough place switch to dynamic. + } + else { + /* Not enough place switch to dynamic. */ batch->is_dynamic_vao_count = true; - // Erase previous entries, they will be added back if drawn again. - for (int j = 0; j < GWN_BATCH_VAO_STATIC_LEN; ++j) - { + /* Erase previous entries, they will be added back if drawn again. */ + for (int j = 0; j < GWN_BATCH_VAO_STATIC_LEN; ++j) { GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface*)batch->static_vaos.interfaces[j], batch); GWN_vao_free(batch->static_vaos.vao_ids[j], batch->context); - } - // Init dynamic arrays and let the branch below set the values. + } + /* Init dynamic arrays and let the branch below set the values. */ batch->dynamic_vaos.count = GWN_BATCH_VAO_DYN_ALLOC_COUNT; batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(Gwn_ShaderInterface*)); batch->dynamic_vaos.vao_ids = calloc(batch->dynamic_vaos.count, sizeof(GLuint)); - } } + } - if (batch->is_dynamic_vao_count) - { - int i; // find first unused slot + if (batch->is_dynamic_vao_count) { + int i; /* find first unused slot */ for (i = 0; i < batch->dynamic_vaos.count; ++i) if (batch->dynamic_vaos.vao_ids[i] == 0) break; - if (i == batch->dynamic_vaos.count) - { - // Not enough place, realloc the array. + if (i == batch->dynamic_vaos.count) { + /* Not enough place, realloc the array. */ i = batch->dynamic_vaos.count; batch->dynamic_vaos.count += GWN_BATCH_VAO_DYN_ALLOC_COUNT; batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(Gwn_ShaderInterface*) * batch->dynamic_vaos.count); batch->dynamic_vaos.vao_ids = realloc(batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count); memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(Gwn_ShaderInterface*) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); - } - + } batch->dynamic_vaos.interfaces[i] = batch->interface; batch->dynamic_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); - } + } GWN_shaderinterface_add_batch_ref((Gwn_ShaderInterface*)batch->interface, batch); @@ -275,105 +283,94 @@ static GLuint batch_vao_get(Gwn_Batch *batch) assert(new_vao != 0); #endif - // We just got a fresh VAO we need to initialize it. + /* We just got a fresh VAO we need to initialize it. */ glBindVertexArray(new_vao); batch_update_program_bindings(batch, 0); glBindVertexArray(0); return new_vao; - } +} void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) - { +{ #if TRUST_NO_ONE assert(glIsProgram(shaderface->program)); assert(batch->program_in_use == 0); #endif - batch->interface = shaderface; batch->program = program; batch->vao_id = batch_vao_get(batch); - } +} void GWN_batch_program_set(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) - { +{ GWN_batch_program_set_no_use(batch, program, shaderface); - GWN_batch_program_use_begin(batch); // hack! to make Batch_Uniform* simpler - } + GWN_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */ +} void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* interface) - { - if (batch->is_dynamic_vao_count) - { - for (int i = 0; i < batch->dynamic_vaos.count; ++i) - { - if (batch->dynamic_vaos.interfaces[i] == interface) - { +{ + if (batch->is_dynamic_vao_count) { + for (int i = 0; i < batch->dynamic_vaos.count; ++i) { + if (batch->dynamic_vaos.interfaces[i] == interface) { GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); batch->dynamic_vaos.vao_ids[i] = 0; batch->dynamic_vaos.interfaces[i] = NULL; - break; // cannot have duplicates - } + break; /* cannot have duplicates */ } } - else - { + } + else { int i; - for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) - { - if (batch->static_vaos.interfaces[i] == interface) - { + for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + if (batch->static_vaos.interfaces[i] == interface) { GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); batch->static_vaos.vao_ids[i] = 0; batch->static_vaos.interfaces[i] = NULL; - break; // cannot have duplicates - } + break; /* cannot have duplicates */ } } } +} -static void create_bindings(Gwn_VertBuf* verts, const Gwn_ShaderInterface* interface, unsigned int v_first, const bool use_instancing) - { +static void create_bindings( + Gwn_VertBuf* verts, const Gwn_ShaderInterface* interface, + uint v_first, const bool use_instancing) +{ const Gwn_VertFormat* format = &verts->format; - const unsigned attr_len = format->attr_len; - const unsigned stride = format->stride; + const uint attr_len = format->attr_len; + const uint stride = format->stride; GWN_vertbuf_use(verts); - for (unsigned a_idx = 0; a_idx < attr_len; ++a_idx) - { + for (uint a_idx = 0; a_idx < attr_len; ++a_idx) { const Gwn_VertAttr* a = format->attribs + a_idx; - const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride; - for (unsigned n_idx = 0; n_idx < a->name_len; ++n_idx) - { + for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { const Gwn_ShaderInput* input = GWN_shaderinterface_attr(interface, a->name[n_idx]); if (input == NULL) continue; - if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) - { + if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { #if TRUST_NO_ONE assert(a->fetch_mode == GWN_FETCH_FLOAT); assert(a->gl_comp_type == GL_FLOAT); #endif - for (int i = 0; i < a->comp_len / 4; ++i) - { + for (int i = 0; i < a->comp_len / 4; ++i) { glEnableVertexAttribArray(input->location + i); glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0); glVertexAttribPointer(input->location + i, 4, a->gl_comp_type, GL_FALSE, stride, (const GLubyte*)pointer + i * 16); - } } + } else { glEnableVertexAttribArray(input->location); glVertexAttribDivisor(input->location, (use_instancing) ? 1 : 0); - switch (a->fetch_mode) - { + switch (a->fetch_mode) { case GWN_FETCH_FLOAT: case GWN_FETCH_INT_TO_FLOAT: glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); @@ -383,47 +380,47 @@ static void create_bindings(Gwn_VertBuf* verts, const Gwn_ShaderInterface* inter break; case GWN_FETCH_INT: glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer); - } + break; } } } } +} -static void batch_update_program_bindings(Gwn_Batch* batch, unsigned int v_first) - { - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) +static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first) +{ + for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false); - - if (batch->inst) + } + if (batch->inst) { create_bindings(batch->inst, batch->interface, v_first, true); - - if (batch->elem) + } + if (batch->elem) { GWN_indexbuf_use(batch->elem); } +} void GWN_batch_program_use_begin(Gwn_Batch* batch) - { - // NOTE: use_program & done_using_program are fragile, depend on staying in sync with - // the GL context's active program. use_program doesn't mark other programs as "not used". - // TODO: make not fragile (somehow) +{ + /* NOTE: use_program & done_using_program are fragile, depend on staying in sync with + * the GL context's active program. use_program doesn't mark other programs as "not used". */ + /* TODO: make not fragile (somehow) */ - if (!batch->program_in_use) - { + if (!batch->program_in_use) { glUseProgram(batch->program); batch->program_in_use = true; - } } +} void GWN_batch_program_use_end(Gwn_Batch* batch) - { - if (batch->program_in_use) - { +{ + if (batch->program_in_use) { #if PROGRAM_NO_OPTI glUseProgram(0); #endif batch->program_in_use = false; - } } +} #if TRUST_NO_ONE #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); assert(uniform); @@ -432,82 +429,82 @@ void GWN_batch_program_use_end(Gwn_Batch* batch) #endif void GWN_batch_uniform_1ui(Gwn_Batch* batch, const char* name, int value) - { +{ GET_UNIFORM glUniform1ui(uniform->location, value); - } +} void GWN_batch_uniform_1i(Gwn_Batch* batch, const char* name, int value) - { +{ GET_UNIFORM glUniform1i(uniform->location, value); - } +} void GWN_batch_uniform_1b(Gwn_Batch* batch, const char* name, bool value) - { +{ GET_UNIFORM glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE); - } +} void GWN_batch_uniform_2f(Gwn_Batch* batch, const char* name, float x, float y) - { +{ GET_UNIFORM glUniform2f(uniform->location, x, y); - } +} void GWN_batch_uniform_3f(Gwn_Batch* batch, const char* name, float x, float y, float z) - { +{ GET_UNIFORM glUniform3f(uniform->location, x, y, z); - } +} void GWN_batch_uniform_4f(Gwn_Batch* batch, const char* name, float x, float y, float z, float w) - { +{ GET_UNIFORM glUniform4f(uniform->location, x, y, z, w); - } +} void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x) - { +{ GET_UNIFORM glUniform1f(uniform->location, x); - } +} void GWN_batch_uniform_2fv(Gwn_Batch* batch, const char* name, const float data[2]) - { +{ GET_UNIFORM glUniform2fv(uniform->location, 1, data); - } +} void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3]) - { +{ GET_UNIFORM glUniform3fv(uniform->location, 1, data); - } +} void GWN_batch_uniform_4fv(Gwn_Batch* batch, const char* name, const float data[4]) - { +{ GET_UNIFORM glUniform4fv(uniform->location, 1, data); - } +} void GWN_batch_uniform_2fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) - { +{ GET_UNIFORM glUniform2fv(uniform->location, len, data); - } +} void GWN_batch_uniform_4fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) - { +{ GET_UNIFORM glUniform4fv(uniform->location, len, data); - } +} void GWN_batch_uniform_mat4(Gwn_Batch* batch, const char* name, const float data[4][4]) - { +{ GET_UNIFORM glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (const float *)data); - } +} static void primitive_restart_enable(const Gwn_IndexBuf *el) { @@ -531,7 +528,7 @@ static void primitive_restart_disable(void) } void GWN_batch_draw(Gwn_Batch* batch) - { +{ #if TRUST_NO_ONE assert(batch->phase == GWN_BATCH_READY_TO_DRAW); assert(batch->verts[0]->vbo_id != 0); @@ -542,91 +539,107 @@ void GWN_batch_draw(Gwn_Batch* batch) GWN_batch_draw_range_ex(batch, 0, 0, false); GWN_batch_program_use_end(batch); - } +} void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool force_instance) - { +{ #if TRUST_NO_ONE assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance #endif const bool do_instance = (force_instance || batch->inst); // If using offset drawing, use the default VAO and redo bindings. - if (v_first != 0 && (do_instance || batch->elem)) - { + if (v_first != 0 && (do_instance || batch->elem)) { glBindVertexArray(GWN_vao_default()); batch_update_program_bindings(batch, v_first); - } - else + } + else { glBindVertexArray(batch->vao_id); + } - if (do_instance) - { - // Infer length if vertex count is not given - if (v_count == 0) + if (do_instance) { + /* Infer length if vertex count is not given */ + if (v_count == 0) { v_count = batch->inst->vertex_len; + } - if (batch->elem) - { + if (batch->elem) { const Gwn_IndexBuf* el = batch->elem; - if (el->use_prim_restart) + if (el->use_prim_restart) { primitive_restart_enable(el); - + } #if GWN_TRACK_INDEX_RANGE - glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_len, el->gl_index_type, 0, v_count, el->base_index); + glDrawElementsInstancedBaseVertex(batch->gl_prim_type, + el->index_len, + el->gl_index_type, + 0, + v_count, + el->base_index); #else glDrawElementsInstanced(batch->gl_prim_type, el->index_len, GL_UNSIGNED_INT, 0, v_count); #endif - if (el->use_prim_restart) + if (el->use_prim_restart) { primitive_restart_disable(); } - else + } + else { glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_len, v_count); } - else - { - // Infer length if vertex count is not given - if (v_count == 0) + } + else { + /* Infer length if vertex count is not given */ + if (v_count == 0) { v_count = (batch->elem) ? batch->elem->index_len : batch->verts[0]->vertex_len; + } - if (batch->elem) - { + if (batch->elem) { const Gwn_IndexBuf* el = batch->elem; - if (el->use_prim_restart) + if (el->use_prim_restart) { primitive_restart_enable(el); + } #if GWN_TRACK_INDEX_RANGE - if (el->base_index) - glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, el->max_index, v_count, el->gl_index_type, 0, el->base_index); - else + if (el->base_index) { + glDrawRangeElementsBaseVertex(batch->gl_prim_type, + el->min_index, + el->max_index, + v_count, + el->gl_index_type, + 0, + el->base_index); + } + else { glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, v_count, el->gl_index_type, 0); + } #else glDrawElements(batch->gl_prim_type, v_count, GL_UNSIGNED_INT, 0); #endif - if (el->use_prim_restart) + if (el->use_prim_restart) { primitive_restart_disable(); } - else + } + else { glDrawArrays(batch->gl_prim_type, v_first, v_count); } + } - // Performance hog if you are drawing with the same vao multiple time. - // Only activate for debugging. + /* Performance hog if you are drawing with the same vao multiple time. + * Only activate for debugging. */ // glBindVertexArray(0); - } +} -// just draw some vertices and let shader place them where we want. +/* just draw some vertices and let shader place them where we want. */ void GWN_draw_primitive(Gwn_PrimType prim_type, int v_count) { - // we cannot draw without vao ... annoying ... + /* we cannot draw without vao ... annoying ... */ glBindVertexArray(GWN_vao_default()); GLenum type = convert_prim_type_to_gl(prim_type); glDrawArrays(type, 0, v_count); - // Performance hog if you are drawing with the same vao multiple time. - // Only activate for debugging. + /* Performance hog if you are drawing with the same vao multiple time. + * Only activate for debugging.*/ // glBindVertexArray(0); } diff --git a/intern/gawain/src/gwn_buffer_id.cpp b/intern/gawain/src/gwn_buffer_id.cpp index 13473f1f28d..2c267682f65 100644 --- a/intern/gawain/src/gwn_buffer_id.cpp +++ b/intern/gawain/src/gwn_buffer_id.cpp @@ -1,13 +1,33 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain buffer IDs -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.#include "buffer_id.h" +/** \file blender/gpu/intern/gwn_buffer_id.cpp + * \ingroup gpu + * + * Gawain buffer IDs + */ #include "gwn_buffer_id.h" #include @@ -24,47 +44,46 @@ static std::vector orphaned_buffer_ids; static std::mutex orphan_mutex; extern "C" { -extern int BLI_thread_is_main(void); // Blender-specific function +extern int BLI_thread_is_main(void); /* Blender-specific function */ } static bool thread_is_main() - { - // "main" here means the GL context's thread +{ + /* "main" here means the GL context's thread */ return BLI_thread_is_main(); - } +} GLuint GWN_buf_id_alloc() - { - // delete orphaned IDs +{ + /* delete orphaned IDs */ orphan_mutex.lock(); - if (!orphaned_buffer_ids.empty()) - { - const auto orphaned_buffer_len = (unsigned)orphaned_buffer_ids.size(); + if (!orphaned_buffer_ids.empty()) { + const auto orphaned_buffer_len = (uint)orphaned_buffer_ids.size(); #if ORPHAN_DEBUG printf("deleting %u orphaned VBO%s\n", orphaned_buffer_len, orphaned_buffer_len == 1 ? "" : "s"); #endif glDeleteBuffers(orphaned_buffer_len, orphaned_buffer_ids.data()); orphaned_buffer_ids.clear(); - } + } orphan_mutex.unlock(); GLuint new_buffer_id = 0; glGenBuffers(1, &new_buffer_id); return new_buffer_id; - } +} void GWN_buf_id_free(GLuint buffer_id) - { - if (thread_is_main()) +{ + if (thread_is_main()) { glDeleteBuffers(1, &buffer_id); - else - { - // add this ID to the orphaned list + } + else { + /* add this ID to the orphaned list */ orphan_mutex.lock(); #if ORPHAN_DEBUG printf("orphaning VBO %u\n", buffer_id); #endif orphaned_buffer_ids.emplace_back(buffer_id); orphan_mutex.unlock(); - } } +} diff --git a/intern/gawain/src/gwn_element.c b/intern/gawain/src/gwn_element.c index 257338fe089..a8c99f20860 100644 --- a/intern/gawain/src/gwn_element.c +++ b/intern/gawain/src/gwn_element.c @@ -1,13 +1,33 @@ - -// Gawain element list (AKA index buffer) -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_element.c + * \ingroup gpu + * + * Gawain element list (AKA index buffer) + */ #include "gwn_element.h" #include "gwn_buffer_id.h" @@ -16,44 +36,45 @@ #define KEEP_SINGLE_COPY 1 static GLenum convert_index_type_to_gl(Gwn_IndexBufType type) - { +{ static const GLenum table[] = { - [GWN_INDEX_U8] = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not + [GWN_INDEX_U8] = GL_UNSIGNED_BYTE, /* GL has this, Vulkan does not */ [GWN_INDEX_U16] = GL_UNSIGNED_SHORT, [GWN_INDEX_U32] = GL_UNSIGNED_INT - }; + }; return table[type]; - } +} -unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) - { +uint GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) +{ #if GWN_TRACK_INDEX_RANGE - static const unsigned table[] = { - [GWN_INDEX_U8] = sizeof(GLubyte), // GL has this, Vulkan does not + static const uint table[] = { + [GWN_INDEX_U8] = sizeof(GLubyte), /* GL has this, Vulkan does not */ [GWN_INDEX_U16] = sizeof(GLushort), [GWN_INDEX_U32] = sizeof(GLuint) - }; + }; return elem->index_len * table[elem->index_type]; #else return elem->index_len * sizeof(GLuint); #endif - } +} -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned index_len, unsigned vertex_len, bool use_prim_restart) - { +void GWN_indexbuf_init_ex( + Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, + uint index_len, uint vertex_len, bool use_prim_restart) +{ builder->use_prim_restart = use_prim_restart; builder->max_allowed_index = vertex_len - 1; builder->max_index_len = index_len; builder->index_len = 0; // start empty builder->prim_type = prim_type; - builder->data = calloc(builder->max_index_len, sizeof(unsigned)); - } + builder->data = calloc(builder->max_index_len, sizeof(uint)); +} -void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned prim_len, unsigned vertex_len) - { - unsigned verts_per_prim = 0; - switch (prim_type) - { +void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uint prim_len, uint vertex_len) +{ + uint verts_per_prim = 0; + switch (prim_type) { case GWN_PRIM_POINTS: verts_per_prim = 1; break; @@ -71,234 +92,216 @@ void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uns assert(false); #endif return; - } + } GWN_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); - } +} -void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, unsigned v) - { +void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, uint v) +{ #if TRUST_NO_ONE assert(builder->data != NULL); assert(builder->index_len < builder->max_index_len); assert(v <= builder->max_allowed_index); #endif - builder->data[builder->index_len++] = v; - } +} void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder* builder) - { +{ #if TRUST_NO_ONE assert(builder->data != NULL); assert(builder->index_len < builder->max_index_len); assert(builder->use_prim_restart); #endif - builder->data[builder->index_len++] = GWN_PRIM_RESTART; - } +} -void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, unsigned v) - { +void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, uint v) +{ #if TRUST_NO_ONE assert(builder->prim_type == GWN_PRIM_POINTS); #endif - GWN_indexbuf_add_generic_vert(builder, v); - } +} -void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2) - { +void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2) +{ #if TRUST_NO_ONE assert(builder->prim_type == GWN_PRIM_LINES); assert(v1 != v2); #endif - GWN_indexbuf_add_generic_vert(builder, v1); GWN_indexbuf_add_generic_vert(builder, v2); - } +} -void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2, unsigned v3) - { +void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3) +{ #if TRUST_NO_ONE assert(builder->prim_type == GWN_PRIM_TRIS); assert(v1 != v2 && v2 != v3 && v3 != v1); #endif - GWN_indexbuf_add_generic_vert(builder, v1); GWN_indexbuf_add_generic_vert(builder, v2); GWN_indexbuf_add_generic_vert(builder, v3); - } +} -void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2, unsigned v3, unsigned v4) - { +void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3, uint v4) +{ #if TRUST_NO_ONE assert(builder->prim_type == GWN_PRIM_LINES_ADJ); assert(v2 != v3); /* only the line need diff indices */ #endif - GWN_indexbuf_add_generic_vert(builder, v1); GWN_indexbuf_add_generic_vert(builder, v2); GWN_indexbuf_add_generic_vert(builder, v3); GWN_indexbuf_add_generic_vert(builder, v4); - } +} #if GWN_TRACK_INDEX_RANGE -// Everything remains 32 bit while building to keep things simple. -// Find min/max after, then convert to smallest index type possible. +/* Everything remains 32 bit while building to keep things simple. + * Find min/max after, then convert to smallest index type possible. */ -static unsigned index_range(const unsigned values[], unsigned value_len, unsigned* min_out, unsigned* max_out) - { - if (value_len == 0) - { +static uint index_range(const uint values[], uint value_len, uint* min_out, uint* max_out) +{ + if (value_len == 0) { *min_out = 0; *max_out = 0; return 0; - } - unsigned min_value = values[0]; - unsigned max_value = values[0]; - for (unsigned i = 1; i < value_len; ++i) - { - const unsigned value = values[i]; + } + uint min_value = values[0]; + uint max_value = values[0]; + for (uint i = 1; i < value_len; ++i) { + const uint value = values[i]; if (value == GWN_PRIM_RESTART) continue; else if (value < min_value) min_value = value; else if (value > max_value) max_value = value; - } + } *min_out = min_value; *max_out = max_value; return max_value - min_value; - } +} static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) - { - const unsigned *values = builder->data; - const unsigned index_len = elem->index_len; +{ + const uint *values = builder->data; + const uint index_len = elem->index_len; - // data will never be *larger* than builder->data... - // converting in place to avoid extra allocation + /* data will never be *larger* than builder->data... + * converting in place to avoid extra allocation */ GLubyte *data = (GLubyte *)builder->data; - if (elem->max_index > 0xFF) - { - const unsigned base = elem->min_index; - + if (elem->max_index > 0xFF) { + const uint base = elem->min_index; elem->base_index = base; elem->min_index = 0; elem->max_index -= base; - - for (unsigned i = 0; i < index_len; ++i) + for (uint i = 0; i < index_len; ++i) { data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); } - else - { + } + else { elem->base_index = 0; - - for (unsigned i = 0; i < index_len; ++i) + for (uint i = 0; i < index_len; ++i) { data[i] = (GLubyte)(values[i]); } } +} static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) - { - const unsigned *values = builder->data; - const unsigned index_len = elem->index_len; +{ + const uint *values = builder->data; + const uint index_len = elem->index_len; - // data will never be *larger* than builder->data... - // converting in place to avoid extra allocation + /* data will never be *larger* than builder->data... + * converting in place to avoid extra allocation */ GLushort *data = (GLushort *)builder->data; - if (elem->max_index > 0xFFFF) - { - const unsigned base = elem->min_index; - + if (elem->max_index > 0xFFFF) { + const uint base = elem->min_index; elem->base_index = base; elem->min_index = 0; elem->max_index -= base; - - for (unsigned i = 0; i < index_len; ++i) + for (uint i = 0; i < index_len; ++i) { data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); } - else - { + } + else { elem->base_index = 0; - - for (unsigned i = 0; i < index_len; ++i) + for (uint i = 0; i < index_len; ++i) { data[i] = (GLushort)(values[i]); } } +} -#endif // GWN_TRACK_INDEX_RANGE +#endif /* GWN_TRACK_INDEX_RANGE */ Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder* builder) - { +{ Gwn_IndexBuf* elem = calloc(1, sizeof(Gwn_IndexBuf)); GWN_indexbuf_build_in_place(builder, elem); return elem; - } +} void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* elem) - { +{ #if TRUST_NO_ONE assert(builder->data != NULL); #endif - elem->index_len = builder->index_len; elem->use_prim_restart = builder->use_prim_restart; #if GWN_TRACK_INDEX_RANGE - unsigned range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index); + uint range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index); - // count the primitive restart index. - if (elem->use_prim_restart) + /* count the primitive restart index. */ + if (elem->use_prim_restart) { range += 1; + } - if (range <= 0xFF) - { + if (range <= 0xFF) { elem->index_type = GWN_INDEX_U8; squeeze_indices_byte(builder, elem); - } - else if (range <= 0xFFFF) - { + } + else if (range <= 0xFFFF) { elem->index_type = GWN_INDEX_U16; squeeze_indices_short(builder, elem); - } - else - { + } + else { elem->index_type = GWN_INDEX_U32; elem->base_index = 0; - } - + } elem->gl_index_type = convert_index_type_to_gl(elem->index_type); #endif - if (elem->vbo_id == 0) + if (elem->vbo_id == 0) { elem->vbo_id = GWN_buf_id_alloc(); - - // send data to GPU - // GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound, - // so we use the GL_ARRAY_BUFFER here to create a buffer without - // interfering in the VAO state. + } + /* send data to GPU */ + /* GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound, + * so we use the GL_ARRAY_BUFFER here to create a buffer without + * interfering in the VAO state. */ glBindBuffer(GL_ARRAY_BUFFER, elem->vbo_id); glBufferData(GL_ARRAY_BUFFER, GWN_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW); - // discard builder (one-time use) + /* discard builder (one-time use) */ free(builder->data); builder->data = NULL; - // other fields are safe to leave - } + /* other fields are safe to leave */ +} void GWN_indexbuf_use(Gwn_IndexBuf* elem) - { +{ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id); - } +} void GWN_indexbuf_discard(Gwn_IndexBuf* elem) - { - if (elem->vbo_id) +{ + if (elem->vbo_id) { GWN_buf_id_free(elem->vbo_id); - - free(elem); } + free(elem); +} diff --git a/intern/gawain/src/gwn_imm_util.c b/intern/gawain/src/gwn_imm_util.c index a8d2b05c8a3..cdf55c3dfc4 100644 --- a/intern/gawain/src/gwn_imm_util.c +++ b/intern/gawain/src/gwn_imm_util.c @@ -1,40 +1,60 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain immediate mode drawing utilities -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/intern/gwn_imm_util.c + * \ingroup gpu + * + * Gawain immediate mode drawing utilities + */ #include "gwn_imm_util.h" #include "gwn_immediate.h" +#include - -void immRectf(unsigned pos, float x1, float y1, float x2, float y2) - { +void immRectf(uint pos, float x1, float y1, float x2, float y2) +{ immBegin(GWN_PRIM_TRI_FAN, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y1); immVertex2f(pos, x2, y2); immVertex2f(pos, x1, y2); immEnd(); - } +} -void immRecti(unsigned pos, int x1, int y1, int x2, int y2) - { +void immRecti(uint pos, int x1, int y1, int x2, int y2) +{ immBegin(GWN_PRIM_TRI_FAN, 4); immVertex2i(pos, x1, y1); immVertex2i(pos, x2, y1); immVertex2i(pos, x2, y2); immVertex2i(pos, x1, y2); immEnd(); - } +} -void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, float x2, float y2, const float color[4]) - { +void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]) +{ immAttrib4fv(col, color); immVertex2f(pos, x1, y1); immAttrib4fv(col, color); @@ -48,10 +68,10 @@ void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, fl immVertex2f(pos, x2, y2); immAttrib4fv(col, color); immVertex2f(pos, x1, y2); - } +} -void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2, int y2, const float color[4]) - { +void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]) +{ immAttrib4fv(col, color); immVertex2i(pos, x1, y1); immAttrib4fv(col, color); @@ -65,16 +85,16 @@ void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2 immVertex2i(pos, x2, y2); immAttrib4fv(col, color); immVertex2i(pos, x1, y2); - } +} -#if 0 // more complete version in case we want that +#if 0 /* more complete version in case we want that */ void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4]) - { +{ Gwn_VertFormat *format = immVertexFormat(); - unsigned pos = add_attrib(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = add_attrib(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); immRecti(pos, x1, y1, x2, y2); immUnbindProgram(); - } +} #endif diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c index f6760b0e9da..442aa85ece4 100644 --- a/intern/gawain/src/gwn_immediate.c +++ b/intern/gawain/src/gwn_immediate.c @@ -1,13 +1,33 @@ - -// Gawain immediate mode work-alike -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_immediate.c + * \ingroup gpu + * + * Gawain immediate mode work-alike + */ #include "gwn_immediate.h" #include "gwn_buffer_id.h" @@ -17,33 +37,32 @@ #include "gwn_vertex_array_id.h" #include "gwn_primitive_private.h" #include +#include -// necessary functions from matrix API +/* necessary functions from matrix API */ extern void GPU_matrix_bind(const Gwn_ShaderInterface*); extern bool GPU_matrix_dirty_get(void); typedef struct { - // TODO: organize this struct by frequency of change (run-time) + /* TODO: organize this struct by frequency of change (run-time) */ -#if IMM_BATCH_COMBO Gwn_Batch* batch; -#endif Gwn_Context* context; - // current draw call + /* current draw call */ GLubyte* buffer_data; - unsigned buffer_offset; - unsigned buffer_bytes_mapped; - unsigned vertex_len; + uint buffer_offset; + uint buffer_bytes_mapped; + uint vertex_len; bool strict_vertex_len; Gwn_PrimType prim_type; Gwn_VertFormat vertex_format; - // current vertex - unsigned vertex_idx; + /* current vertex */ + uint vertex_idx; GLubyte* vertex_data; - uint16_t unassigned_attrib_bits; // which attributes of current vertex have not been given values? + uint16_t unassigned_attrib_bits; /* which attributes of current vertex have not been given values? */ GLuint vbo_id; GLuint vao_id; @@ -51,21 +70,20 @@ typedef struct { GLuint bound_program; const Gwn_ShaderInterface* shader_interface; Gwn_AttrBinding attrib_binding; - uint16_t prev_enabled_attrib_bits; // <-- only affects this VAO, so we're ok + uint16_t prev_enabled_attrib_bits; /* <-- only affects this VAO, so we're ok */ } Immediate; -// size of internal buffer -- make this adjustable? +/* size of internal buffer -- make this adjustable? */ #define IMM_BUFFER_SIZE (4 * 1024 * 1024) static bool initialized = false; static Immediate imm; void immInit(void) - { +{ #if TRUST_NO_ONE assert(!initialized); #endif - memset(&imm, 0, sizeof(Immediate)); imm.vbo_id = GWN_buf_id_alloc(); @@ -77,45 +95,45 @@ void immInit(void) glBindBuffer(GL_ARRAY_BUFFER, 0); initialized = true; - } +} void immActivate(void) - { +{ #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair + assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ assert(imm.vao_id == 0); #endif imm.vao_id = GWN_vao_alloc(); imm.context = GWN_context_active_get(); - } +} void immDeactivate(void) - { +{ #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair + assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ assert(imm.vao_id != 0); #endif GWN_vao_free(imm.vao_id, imm.context); imm.vao_id = 0; imm.prev_enabled_attrib_bits = 0; - } +} void immDestroy(void) - { +{ GWN_buf_id_free(imm.vbo_id); initialized = false; - } +} Gwn_VertFormat* immVertexFormat(void) - { +{ GWN_vertformat_clear(&imm.vertex_format); return &imm.vertex_format; - } +} void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface) - { +{ #if TRUST_NO_ONE assert(imm.bound_program == 0); assert(glIsProgram(program)); @@ -130,10 +148,10 @@ void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface) glUseProgram(program); get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface); GPU_matrix_bind(shaderface); - } +} void immUnbindProgram(void) - { +{ #if TRUST_NO_ONE assert(imm.bound_program != 0); #endif @@ -141,17 +159,17 @@ void immUnbindProgram(void) glUseProgram(0); #endif imm.bound_program = 0; - } +} #if TRUST_NO_ONE -static bool vertex_count_makes_sense_for_primitive(unsigned vertex_len, Gwn_PrimType prim_type) - { - // does vertex_len make sense for this primitive type? - if (vertex_len == 0) +static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType prim_type) +{ + /* does vertex_len make sense for this primitive type? */ + if (vertex_len == 0) { return false; + } - switch (prim_type) - { + switch (prim_type) { case GWN_PRIM_POINTS: return true; case GWN_PRIM_LINES: @@ -168,25 +186,24 @@ static bool vertex_count_makes_sense_for_primitive(unsigned vertex_len, Gwn_Prim return vertex_len >= 3; default: return false; - } } +} #endif -void immBegin(Gwn_PrimType prim_type, unsigned vertex_len) - { +void immBegin(Gwn_PrimType prim_type, uint vertex_len) +{ #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun + assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif - imm.prim_type = prim_type; imm.vertex_len = vertex_len; imm.vertex_idx = 0; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; - // how many bytes do we need for this draw call? - const unsigned bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_len); + /* how many bytes do we need for this draw call? */ + const uint bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_len); #if TRUST_NO_ONE assert(bytes_needed <= IMM_BUFFER_SIZE); @@ -194,41 +211,22 @@ void immBegin(Gwn_PrimType prim_type, unsigned vertex_len) glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); - // does the current buffer have enough room? - const unsigned available_bytes = IMM_BUFFER_SIZE - imm.buffer_offset; - // ensure vertex data is aligned - const unsigned pre_padding = padding(imm.buffer_offset, imm.vertex_format.stride); // might waste a little space, but it's safe - if ((bytes_needed + pre_padding) <= available_bytes) + /* does the current buffer have enough room? */ + const uint available_bytes = IMM_BUFFER_SIZE - imm.buffer_offset; + /* ensure vertex data is aligned */ + const uint pre_padding = padding(imm.buffer_offset, imm.vertex_format.stride); /* might waste a little space, but it's safe */ + if ((bytes_needed + pre_padding) <= available_bytes) { imm.buffer_offset += pre_padding; - else - { - // orphan this buffer & start with a fresh one -#if 1 - // this method works on all platforms, old & new + } + else { + /* orphan this buffer & start with a fresh one */ + /* this method works on all platforms, old & new */ glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); -#else - // TODO: use other (more recent) methods after thorough testing - if (GLEW_VERSION_4_3 || GLEW_ARB_invalidate_subdata) - glInvalidateBufferData(imm.vbo_id); - else - { - // glitches! -// glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, GL_MAP_INVALIDATE_BUFFER_BIT); - - // works -// glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, -// GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); -// glUnmapBuffer(GL_ARRAY_BUFFER); - - // also works - glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); - } -#endif imm.buffer_offset = 0; - } + } -// printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1); +/* printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1); */ imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, bytes_needed, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_len ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)); @@ -239,28 +237,26 @@ void immBegin(Gwn_PrimType prim_type, unsigned vertex_len) imm.buffer_bytes_mapped = bytes_needed; imm.vertex_data = imm.buffer_data; - } +} -void immBeginAtMost(Gwn_PrimType prim_type, unsigned vertex_len) - { +void immBeginAtMost(Gwn_PrimType prim_type, uint vertex_len) +{ #if TRUST_NO_ONE assert(vertex_len > 0); #endif imm.strict_vertex_len = false; immBegin(prim_type, vertex_len); - } +} -#if IMM_BATCH_COMBO -Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_len) - { +Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, uint vertex_len) +{ #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun + assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif - imm.prim_type = prim_type; imm.vertex_len = vertex_len; imm.vertex_idx = 0; @@ -276,59 +272,47 @@ Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_len) imm.batch->phase = GWN_BATCH_BUILDING; return imm.batch; - } +} -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, unsigned vertex_len) - { +Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, uint vertex_len) +{ imm.strict_vertex_len = false; return immBeginBatch(prim_type, vertex_len); - } - -#endif // IMM_BATCH_COMBO +} static void immDrawSetup(void) - { - // set up VAO -- can be done during Begin or End really +{ + /* set up VAO -- can be done during Begin or End really */ glBindVertexArray(imm.vao_id); - // enable/disable vertex attribs as needed - if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits) - { - for (unsigned loc = 0; loc < GWN_VERT_ATTR_MAX_LEN; ++loc) - { + /* enable/disable vertex attribs as needed */ + if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits) { + for (uint loc = 0; loc < GWN_VERT_ATTR_MAX_LEN; ++loc) { bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc); bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc); - if (is_enabled && !was_enabled) - { -// printf("enabling attrib %u\n", loc); + if (is_enabled && !was_enabled) { glEnableVertexAttribArray(loc); - } - else if (was_enabled && !is_enabled) - { -// printf("disabling attrib %u\n", loc); + } + else if (was_enabled && !is_enabled) { glDisableVertexAttribArray(loc); - } } + } imm.prev_enabled_attrib_bits = imm.attrib_binding.enabled_bits; - } + } - const unsigned stride = imm.vertex_format.stride; + const uint stride = imm.vertex_format.stride; - for (unsigned a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) - { + for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; - const unsigned offset = imm.buffer_offset + a->offset; + const uint offset = imm.buffer_offset + a->offset; const GLvoid* pointer = (const GLubyte*)0 + offset; - const unsigned loc = read_attrib_location(&imm.attrib_binding, a_idx); - -// printf("specifying attrib %u '%s' with offset %u, stride %u\n", loc, a->name, offset, stride); + const uint loc = read_attrib_location(&imm.attrib_binding, a_idx); - switch (a->fetch_mode) - { + switch (a->fetch_mode) { case GWN_FETCH_FLOAT: case GWN_FETCH_INT_TO_FLOAT: glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); @@ -338,414 +322,372 @@ static void immDrawSetup(void) break; case GWN_FETCH_INT: glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer); - } } + } - if (GPU_matrix_dirty_get()) + if (GPU_matrix_dirty_get()) { GPU_matrix_bind(imm.shader_interface); } +} void immEnd(void) - { +{ #if TRUST_NO_ONE - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - unsigned buffer_bytes_used; - if (imm.strict_vertex_len) - { + uint buffer_bytes_used; + if (imm.strict_vertex_len) { #if TRUST_NO_ONE - assert(imm.vertex_idx == imm.vertex_len); // with all vertices defined + assert(imm.vertex_idx == imm.vertex_len); /* with all vertices defined */ #endif buffer_bytes_used = imm.buffer_bytes_mapped; - } - else - { + } + else { #if TRUST_NO_ONE assert(imm.vertex_idx <= imm.vertex_len); #endif - // printf("used %u of %u verts,", imm.vertex_idx, imm.vertex_len); - if (imm.vertex_idx == imm.vertex_len) - { + if (imm.vertex_idx == imm.vertex_len) { buffer_bytes_used = imm.buffer_bytes_mapped; - } - else - { + } + else { #if TRUST_NO_ONE assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type)); #endif imm.vertex_len = imm.vertex_idx; buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_len); - // unused buffer bytes are available to the next immBegin - // printf(" %u of %u bytes\n", buffer_bytes_used, imm.buffer_bytes_mapped); - } - - // tell OpenGL what range was modified so it doesn't copy the whole mapped range - // printf("flushing %u to %u\n", imm.buffer_offset, imm.buffer_offset + buffer_bytes_used - 1); - glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, buffer_bytes_used); + /* unused buffer bytes are available to the next immBegin */ } + /* tell OpenGL what range was modified so it doesn't copy the whole mapped range */ + glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, buffer_bytes_used); + } -#if IMM_BATCH_COMBO - if (imm.batch) - { - if (buffer_bytes_used != imm.buffer_bytes_mapped) - { + if (imm.batch) { + if (buffer_bytes_used != imm.buffer_bytes_mapped) { GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); - // TODO: resize only if vertex count is much smaller - } - + /* TODO: resize only if vertex count is much smaller */ + } GWN_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface); imm.batch->phase = GWN_BATCH_READY_TO_DRAW; - imm.batch = NULL; // don't free, batch belongs to caller - } - else -#endif - { + imm.batch = NULL; /* don't free, batch belongs to caller */ + } + else { glUnmapBuffer(GL_ARRAY_BUFFER); - - if (imm.vertex_len > 0) - { + if (imm.vertex_len > 0) { immDrawSetup(); glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_len); - } - + } glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); - - // prep for next immBegin + /* prep for next immBegin */ imm.buffer_offset += buffer_bytes_used; - } + } - // prep for next immBegin + /* prep for next immBegin */ imm.prim_type = GWN_PRIM_NONE; imm.strict_vertex_len = true; - } +} -static void setAttribValueBit(unsigned attrib_id) - { +static void setAttribValueBit(uint attrib_id) +{ uint16_t mask = 1 << attrib_id; - #if TRUST_NO_ONE - assert(imm.unassigned_attrib_bits & mask); // not already set + assert(imm.unassigned_attrib_bits & mask); /* not already set */ #endif - imm.unassigned_attrib_bits &= ~mask; - } +} -// --- generic attribute functions --- +/* --- generic attribute functions --- */ -void immAttrib1f(unsigned attrib_id, float x) - { +void immAttrib1f(uint attrib_id, float x) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); assert(attrib->comp_len == 1); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); float* data = (float*)(imm.vertex_data + attrib->offset); -// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); +/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ data[0] = x; - } +} -void immAttrib2f(unsigned attrib_id, float x, float y) - { +void immAttrib2f(uint attrib_id, float x, float y) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); float* data = (float*)(imm.vertex_data + attrib->offset); -// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); +/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ data[0] = x; data[1] = y; - } +} -void immAttrib3f(unsigned attrib_id, float x, float y, float z) - { +void immAttrib3f(uint attrib_id, float x, float y, float z) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); assert(attrib->comp_len == 3); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); float* data = (float*)(imm.vertex_data + attrib->offset); -// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); +/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ data[0] = x; data[1] = y; data[2] = z; - } +} -void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w) - { +void immAttrib4f(uint attrib_id, float x, float y, float z, float w) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); assert(attrib->comp_len == 4); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); float* data = (float*)(imm.vertex_data + attrib->offset); -// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); +/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ data[0] = x; data[1] = y; data[2] = z; data[3] = w; - } +} -void immAttrib1u(unsigned attrib_id, unsigned x) - { +void immAttrib1u(uint attrib_id, uint x) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U32); assert(attrib->comp_len == 1); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); - unsigned* data = (unsigned*)(imm.vertex_data + attrib->offset); + uint* data = (uint*)(imm.vertex_data + attrib->offset); data[0] = x; - } +} -void immAttrib2i(unsigned attrib_id, int x, int y) - { +void immAttrib2i(uint attrib_id, int x, int y) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_I32); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); int* data = (int*)(imm.vertex_data + attrib->offset); data[0] = x; data[1] = y; - } +} -void immAttrib2s(unsigned attrib_id, short x, short y) - { +void immAttrib2s(uint attrib_id, short x, short y) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_I16); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); short* data = (short*)(imm.vertex_data + attrib->offset); data[0] = x; data[1] = y; - } +} -void immAttrib2fv(unsigned attrib_id, const float data[2]) - { +void immAttrib2fv(uint attrib_id, const float data[2]) +{ immAttrib2f(attrib_id, data[0], data[1]); - } +} -void immAttrib3fv(unsigned attrib_id, const float data[3]) - { +void immAttrib3fv(uint attrib_id, const float data[3]) +{ immAttrib3f(attrib_id, data[0], data[1], data[2]); - } +} -void immAttrib4fv(unsigned attrib_id, const float data[4]) - { +void immAttrib4fv(uint attrib_id, const float data[4]) +{ immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]); - } +} -void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b) - { +void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U8); assert(attrib->comp_len == 3); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); GLubyte* data = imm.vertex_data + attrib->offset; -// printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); +/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */ data[0] = r; data[1] = g; data[2] = b; - } +} -void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a) - { +void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a) +{ Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; - #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U8); assert(attrib->comp_len == 4); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); GLubyte* data = imm.vertex_data + attrib->offset; -// printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); +/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */ data[0] = r; data[1] = g; data[2] = b; data[3] = a; - } +} -void immAttrib3ubv(unsigned attrib_id, const unsigned char data[3]) - { +void immAttrib3ubv(uint attrib_id, const unsigned char data[3]) +{ immAttrib3ub(attrib_id, data[0], data[1], data[2]); - } +} -void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]) - { +void immAttrib4ubv(uint attrib_id, const unsigned char data[4]) +{ immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]); - } +} -void immSkipAttrib(unsigned attrib_id) - { +void immSkipAttrib(uint attrib_id) +{ #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif - setAttribValueBit(attrib_id); - } +} -static void immEndVertex(void) // and move on to the next vertex - { +static void immEndVertex(void) /* and move on to the next vertex */ +{ #if TRUST_NO_ONE - assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ assert(imm.vertex_idx < imm.vertex_len); #endif - // have all attribs been assigned values? - // if not, copy value from previous vertex - if (imm.unassigned_attrib_bits) - { + /* have all attribs been assigned values? + * if not, copy value from previous vertex */ + if (imm.unassigned_attrib_bits) { #if TRUST_NO_ONE - assert(imm.vertex_idx > 0); // first vertex must have all attribs specified + assert(imm.vertex_idx > 0); /* first vertex must have all attribs specified */ #endif - - for (unsigned a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) - { - if ((imm.unassigned_attrib_bits >> a_idx) & 1) - { + for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { + if ((imm.unassigned_attrib_bits >> a_idx) & 1) { const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; -// printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); +/* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */ GLubyte* data = imm.vertex_data + a->offset; memcpy(data, data - imm.vertex_format.stride, a->sz); - // TODO: consolidate copy of adjacent attributes - } + /* TODO: consolidate copy of adjacent attributes */ } } + } imm.vertex_idx++; imm.vertex_data += imm.vertex_format.stride; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; - } +} -void immVertex2f(unsigned attrib_id, float x, float y) - { +void immVertex2f(uint attrib_id, float x, float y) +{ immAttrib2f(attrib_id, x, y); immEndVertex(); - } +} -void immVertex3f(unsigned attrib_id, float x, float y, float z) - { +void immVertex3f(uint attrib_id, float x, float y, float z) +{ immAttrib3f(attrib_id, x, y, z); immEndVertex(); - } +} -void immVertex4f(unsigned attrib_id, float x, float y, float z, float w) - { +void immVertex4f(uint attrib_id, float x, float y, float z, float w) +{ immAttrib4f(attrib_id, x, y, z, w); immEndVertex(); - } +} -void immVertex2i(unsigned attrib_id, int x, int y) - { +void immVertex2i(uint attrib_id, int x, int y) +{ immAttrib2i(attrib_id, x, y); immEndVertex(); - } +} -void immVertex2s(unsigned attrib_id, short x, short y) - { +void immVertex2s(uint attrib_id, short x, short y) +{ immAttrib2s(attrib_id, x, y); immEndVertex(); - } +} -void immVertex2fv(unsigned attrib_id, const float data[2]) - { +void immVertex2fv(uint attrib_id, const float data[2]) +{ immAttrib2f(attrib_id, data[0], data[1]); immEndVertex(); - } +} -void immVertex3fv(unsigned attrib_id, const float data[3]) - { +void immVertex3fv(uint attrib_id, const float data[3]) +{ immAttrib3f(attrib_id, data[0], data[1], data[2]); immEndVertex(); - } +} -void immVertex2iv(unsigned attrib_id, const int data[2]) - { +void immVertex2iv(uint attrib_id, const int data[2]) +{ immAttrib2i(attrib_id, data[0], data[1]); immEndVertex(); - } +} -// --- generic uniform functions --- +/* --- generic uniform functions --- */ #if 0 #if TRUST_NO_ONE @@ -754,49 +696,49 @@ void immVertex2iv(unsigned attrib_id, const int data[2]) #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); #endif #else - // NOTE: It is possible to have uniform fully optimized out from the shader. - // In this case we can't assert failure or allow NULL-pointer dereference. - // TODO(sergey): How can we detect existing-but-optimized-out uniform but still - // catch typos in uniform names passed to immUniform*() functions? + /* NOTE: It is possible to have uniform fully optimized out from the shader. + * In this case we can't assert failure or allow NULL-pointer dereference. + * TODO(sergey): How can we detect existing-but-optimized-out uniform but still + * catch typos in uniform names passed to immUniform*() functions? */ #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; #endif void immUniform1f(const char* name, float x) - { +{ GET_UNIFORM glUniform1f(uniform->location, x); - } +} void immUniform2f(const char* name, float x, float y) - { +{ GET_UNIFORM glUniform2f(uniform->location, x, y); - } +} void immUniform2fv(const char* name, const float data[2]) - { +{ GET_UNIFORM glUniform2fv(uniform->location, 1, data); - } +} void immUniform3f(const char* name, float x, float y, float z) - { +{ GET_UNIFORM glUniform3f(uniform->location, x, y, z); - } +} void immUniform3fv(const char* name, const float data[3]) - { +{ GET_UNIFORM glUniform3fv(uniform->location, 1, data); - } +} -// can increase this limit or move to another file +/* can increase this limit or move to another file */ #define MAX_UNIFORM_NAME_LEN 60 void immUniformArray3fv(const char* bare_name, const float *data, int count) - { - // look up "name[0]" when given "name" +{ + /* look up "name[0]" when given "name" */ const size_t len = strlen(bare_name); #if TRUST_NO_ONE assert(len <= MAX_UNIFORM_NAME_LEN); @@ -810,23 +752,23 @@ void immUniformArray3fv(const char* bare_name, const float *data, int count) GET_UNIFORM glUniform3fv(uniform->location, count, data); - } +} void immUniform4f(const char* name, float x, float y, float z, float w) - { +{ GET_UNIFORM glUniform4f(uniform->location, x, y, z, w); - } +} void immUniform4fv(const char* name, const float data[4]) - { +{ GET_UNIFORM glUniform4fv(uniform->location, 1, data); - } +} void immUniformArray4fv(const char* bare_name, const float *data, int count) - { - // look up "name[0]" when given "name" +{ + /* look up "name[0]" when given "name" */ const size_t len = strlen(bare_name); #if TRUST_NO_ONE assert(len <= MAX_UNIFORM_NAME_LEN); @@ -840,84 +782,82 @@ void immUniformArray4fv(const char* bare_name, const float *data, int count) GET_UNIFORM glUniform4fv(uniform->location, count, data); - } +} void immUniformMatrix4fv(const char* name, const float data[4][4]) - { +{ GET_UNIFORM glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (float *)data); - } +} void immUniform1i(const char* name, int x) - { +{ GET_UNIFORM glUniform1i(uniform->location, x); - } +} void immUniform4iv(const char* name, const int data[4]) - { +{ GET_UNIFORM glUniform4iv(uniform->location, 1, data); - } +} -// --- convenience functions for setting "uniform vec4 color" --- +/* --- convenience functions for setting "uniform vec4 color" --- */ void immUniformColor4f(float r, float g, float b, float a) - { +{ const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform_builtin(imm.shader_interface, GWN_UNIFORM_COLOR); - #if TRUST_NO_ONE assert(uniform != NULL); #endif - glUniform4f(uniform->location, r, g, b, a); - } +} void immUniformColor4fv(const float rgba[4]) - { +{ immUniformColor4f(rgba[0], rgba[1], rgba[2], rgba[3]); - } +} void immUniformColor3f(float r, float g, float b) - { +{ immUniformColor4f(r, g, b, 1.0f); - } +} void immUniformColor3fv(const float rgb[3]) - { +{ immUniformColor4f(rgb[0], rgb[1], rgb[2], 1.0f); - } +} void immUniformColor3fvAlpha(const float rgb[3], float a) - { +{ immUniformColor4f(rgb[0], rgb[1], rgb[2], a); - } +} -// TODO: v-- treat as sRGB? --v +/* TODO: v-- treat as sRGB? --v */ void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b) - { +{ const float scale = 1.0f / 255.0f; immUniformColor4f(scale * r, scale * g, scale * b, 1.0f); - } +} void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) - { +{ const float scale = 1.0f / 255.0f; immUniformColor4f(scale * r, scale * g, scale * b, scale * a); - } +} void immUniformColor3ubv(const unsigned char rgb[3]) - { +{ immUniformColor3ub(rgb[0], rgb[1], rgb[2]); - } +} void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char alpha) - { +{ immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha); - } +} void immUniformColor4ubv(const unsigned char rgba[4]) - { +{ immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]); - } +} diff --git a/intern/gawain/src/gwn_primitive.c b/intern/gawain/src/gwn_primitive.c index c2638bcc8c8..bec638a4972 100644 --- a/intern/gawain/src/gwn_primitive.c +++ b/intern/gawain/src/gwn_primitive.c @@ -1,21 +1,40 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ -// Gawain geometric primitives -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2017 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/** \file blender/gpu/intern/gwn_primitive.c + * \ingroup gpu + * + * Gawain geometric primitives + */ #include "gwn_primitive.h" #include "gwn_primitive_private.h" Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type) - { - static const Gwn_PrimClass classes[] = - { +{ + static const Gwn_PrimClass classes[] = { [GWN_PRIM_POINTS] = GWN_PRIM_CLASS_POINT, [GWN_PRIM_LINES] = GWN_PRIM_CLASS_LINE, [GWN_PRIM_LINE_STRIP] = GWN_PRIM_CLASS_LINE, @@ -29,27 +48,25 @@ Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type) [GWN_PRIM_TRIS_ADJ] = GWN_PRIM_CLASS_SURFACE, [GWN_PRIM_NONE] = GWN_PRIM_CLASS_NONE - }; + }; return classes[prim_type]; - } +} bool GWN_primtype_belongs_to_class(Gwn_PrimType prim_type, Gwn_PrimClass prim_class) - { - if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE) +{ + if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE) { return true; - - return prim_class & GWN_primtype_class(prim_type); } + return prim_class & GWN_primtype_class(prim_type); +} GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type) - { +{ #if TRUST_NO_ONE assert(prim_type != GWN_PRIM_NONE); #endif - - static const GLenum table[] = - { + static const GLenum table[] = { [GWN_PRIM_POINTS] = GL_POINTS, [GWN_PRIM_LINES] = GL_LINES, [GWN_PRIM_LINE_STRIP] = GL_LINE_STRIP, @@ -61,7 +78,7 @@ GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type) [GWN_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY, [GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY, [GWN_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY, - }; + }; return table[prim_type]; - } +} diff --git a/intern/gawain/src/gwn_shader_interface.c b/intern/gawain/src/gwn_shader_interface.c index d18af234fb0..997d5215d5b 100644 --- a/intern/gawain/src/gwn_shader_interface.c +++ b/intern/gawain/src/gwn_shader_interface.c @@ -1,13 +1,33 @@ - -// Gawain shader interface (C --> GLSL) -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2017 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_shader_interface.c + * \ingroup gpu + * + * Gawain shader interface (C --> GLSL) + */ #include "gwn_batch_private.h" #include "gwn_shader_interface.h" @@ -23,9 +43,8 @@ #endif static const char* BuiltinUniform_name(Gwn_UniformBuiltin u) - { - static const char* names[] = - { +{ + static const char* names[] = { [GWN_UNIFORM_NONE] = NULL, [GWN_UNIFORM_MODEL] = "ModelMatrix", @@ -52,154 +71,142 @@ static const char* BuiltinUniform_name(Gwn_UniformBuiltin u) [GWN_UNIFORM_CUSTOM] = NULL, [GWN_NUM_UNIFORMS] = NULL, - }; + }; return names[u]; - } +} GWN_INLINE bool match(const char* a, const char* b) - { +{ return strcmp(a, b) == 0; - } +} -GWN_INLINE unsigned hash_string(const char *str) - { - unsigned i = 0, c; - - while ((c = *str++)) - { +GWN_INLINE uint hash_string(const char *str) +{ + uint i = 0, c; + while ((c = *str++)) { i = i * 37 + c; - } - - return i; } + return i; +} GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* input, const char* name, uint32_t name_len) - { +{ input->name_offset = shaderface->name_buffer_offset; input->name_hash = hash_string(name); - shaderface->name_buffer_offset += name_len + 1; // include NULL terminator - } + shaderface->name_buffer_offset += name_len + 1; /* include NULL terminator */ +} GWN_INLINE void shader_input_to_bucket(Gwn_ShaderInput* input, Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) - { - const unsigned bucket_index = input->name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; +{ + const uint bucket_index = input->name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; input->next = buckets[bucket_index]; buckets[bucket_index] = input; - } +} GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[GWN_NUM_SHADERINTERFACE_BUCKETS], const char *name_buffer, const char *name) - { - const unsigned name_hash = hash_string(name); - const unsigned bucket_index = name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; +{ + const uint name_hash = hash_string(name); + const uint bucket_index = name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; const Gwn_ShaderInput* input = buckets[bucket_index]; - if (input == NULL) - { - // Requested uniform is not found at all. - return NULL; - } - // Optimization bit: if there is no hash collision detected when constructing shader interface - // it means we can only request the single possible uniform. Surely, it's possible we request - // uniform which causes hash collision, but that will be detected in debug builds. - if (input->next == NULL) - { - if (name_hash == input->name_hash) - { + if (input == NULL) { + /* Requested uniform is not found at all. */ + return NULL; + } + /* Optimization bit: if there is no hash collision detected when constructing shader interface + * it means we can only request the single possible uniform. Surely, it's possible we request + * uniform which causes hash collision, but that will be detected in debug builds. */ + if (input->next == NULL) { + if (name_hash == input->name_hash) { #if TRUST_NO_ONE - assert(match(name_buffer + input->name_offset, name)); + assert(match(name_buffer + input->name_offset, name)); #endif - return input; - } - return NULL; + return input; } - // Work through possible collisions. + return NULL; + } + /* Work through possible collisions. */ const Gwn_ShaderInput* next = input; - while (next != NULL) - { + while (next != NULL) { input = next; next = input->next; - - if (input->name_hash != name_hash) - { + if (input->name_hash != name_hash) { continue; - } - if (match(name_buffer + input->name_offset, name)) - { + } + if (match(name_buffer + input->name_offset, name)) { return input; - } } - return NULL; // not found } + return NULL; /* not found */ +} GWN_INLINE void buckets_free(Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) - { - for (unsigned bucket_index = 0; bucket_index < GWN_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) - { +{ + for (uint bucket_index = 0; bucket_index < GWN_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) { Gwn_ShaderInput *input = buckets[bucket_index]; - while (input != NULL) - { + while (input != NULL) { Gwn_ShaderInput *input_next = input->next; free(input); input = input_next; - } } } +} static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name) - { - // TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types +{ + /* TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types */ - // detect built-in uniforms (name must match) - for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) - { + /* detect built-in uniforms (name must match) */ + for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { const char* builtin_name = BuiltinUniform_name(u); - if (match(name, builtin_name)) - { + if (match(name, builtin_name)) { input->builtin_type = u; return true; - } } - + } input->builtin_type = GWN_UNIFORM_CUSTOM; return false; - } +} static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const char* name) - { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); +{ + Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); - input->location = glGetUniformLocation(shaderface->program, name); + input->location = glGetUniformLocation(shaderface->program, name); - unsigned name_len = strlen(name); - shaderface->name_buffer = realloc(shaderface->name_buffer, shaderface->name_buffer_offset + name_len + 1); // include NULL terminator - char* name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset; - strcpy(name_buffer, name); + uint name_len = strlen(name); + shaderface->name_buffer = realloc(shaderface->name_buffer, shaderface->name_buffer_offset + name_len + 1); /* include NULL terminator */ + char* name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset; + strcpy(name_buffer, name); - set_input_name(shaderface, input, name, name_len); - setup_builtin_uniform(input, name); - - shader_input_to_bucket(input, shaderface->uniform_buckets); - if (input->builtin_type != GWN_UNIFORM_NONE && - input->builtin_type != GWN_UNIFORM_CUSTOM) - { - shaderface->builtin_uniforms[input->builtin_type] = input; - } + set_input_name(shaderface, input, name, name_len); + setup_builtin_uniform(input, name); + + shader_input_to_bucket(input, shaderface->uniform_buckets); + if (input->builtin_type != GWN_UNIFORM_NONE && + input->builtin_type != GWN_UNIFORM_CUSTOM) + { + shaderface->builtin_uniforms[input->builtin_type] = input; + } #if DEBUG_SHADER_INTERFACE - printf("Gwn_ShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, shaderface->program, name, input->location); + printf("Gwn_ShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, + shaderface->program, + name, + input->location); #endif - return input; - } + return input; +} Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) - { +{ Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface)); shaderface->program = program; #if DEBUG_SHADER_INTERFACE - printf("%s {\n", __func__); // enter function + printf("%s {\n", __func__); /* enter function */ printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program); #endif @@ -214,9 +221,8 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) const uint32_t name_buffer_len = attr_len * max_attrib_name_len + ubo_len * max_ubo_name_len; shaderface->name_buffer = malloc(name_buffer_len); - // Attributes - for (uint32_t i = 0; i < attr_len; ++i) - { + /* Attributes */ + for (uint32_t i = 0; i < attr_len; ++i) { Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; char* name = shaderface->name_buffer + shaderface->name_buffer_offset; @@ -224,14 +230,13 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name); - // remove "[0]" from array name - if (name[name_len-1] == ']') - { + /* remove "[0]" from array name */ + if (name[name_len-1] == ']') { name[name_len-3] = '\0'; name_len -= 3; - } + } - // TODO: reject DOUBLE gl_types + /* TODO: reject DOUBLE gl_types */ input->location = glGetAttribLocation(program, name); @@ -242,11 +247,9 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) #if DEBUG_SHADER_INTERFACE printf("attrib[%u] '%s' at location %d\n", i, name, input->location); #endif - } - - // Uniform Blocks - for (uint32_t i = 0; i < ubo_len; ++i) - { + } + /* Uniform Blocks */ + for (uint32_t i = 0; i < ubo_len; ++i) { Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; char* name = shaderface->name_buffer + shaderface->name_buffer_offset; @@ -263,100 +266,96 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) #if DEBUG_SHADER_INTERFACE printf("ubo '%s' at location %d\n", name, input->location); #endif - } - - // Builtin Uniforms - for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) - { + } + /* Builtin Uniforms */ + for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { const char* builtin_name = BuiltinUniform_name(u); - if (glGetUniformLocation(program, builtin_name) != -1) + if (glGetUniformLocation(program, builtin_name) != -1) { add_uniform((Gwn_ShaderInterface*)shaderface, builtin_name); } - - // Batches ref buffer + } + /* Batches ref buffer */ shaderface->batches_len = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; shaderface->batches = calloc(shaderface->batches_len, sizeof(Gwn_Batch*)); return shaderface; - } +} void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) - { - // Free memory used by buckets and has entries. +{ + /* Free memory used by buckets and has entries. */ buckets_free(shaderface->uniform_buckets); buckets_free(shaderface->attrib_buckets); buckets_free(shaderface->ubo_buckets); - // Free memory used by name_buffer. + /* Free memory used by name_buffer. */ free(shaderface->name_buffer); - // Remove this interface from all linked Batches vao cache. - for (int i = 0; i < shaderface->batches_len; ++i) - if (shaderface->batches[i] != NULL) + /* Remove this interface from all linked Batches vao cache. */ + for (int i = 0; i < shaderface->batches_len; ++i) { + if (shaderface->batches[i] != NULL) { gwn_batch_remove_interface_ref(shaderface->batches[i], shaderface); - + } + } free(shaderface->batches); - // Free memory used by shader interface by its self. + /* Free memory used by shader interface by its self. */ free(shaderface); - } +} const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name) - { - // TODO: Warn if we find a matching builtin, since these can be looked up much quicker. +{ + /* TODO: Warn if we find a matching builtin, since these can be looked up much quicker. */ const Gwn_ShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); - - // If input is not found add it so it's found next time. - if (input == NULL) + /* If input is not found add it so it's found next time. */ + if (input == NULL) { input = add_uniform((Gwn_ShaderInterface*)shaderface, name); - - return (input->location != -1) ? input : NULL; } + return (input->location != -1) ? input : NULL; +} -const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin) - { +const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin( + const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin) +{ #if TRUST_NO_ONE assert(builtin != GWN_UNIFORM_NONE); assert(builtin != GWN_UNIFORM_CUSTOM); assert(builtin != GWN_NUM_UNIFORMS); #endif return shaderface->builtin_uniforms[builtin]; - } +} const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface* shaderface, const char* name) - { +{ return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name); - } +} const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name) - { +{ return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name); - } +} void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) - { - int i; // find first unused slot - for (i = 0; i < shaderface->batches_len; ++i) - if (shaderface->batches[i] == NULL) +{ + int i; /* find first unused slot */ + for (i = 0; i < shaderface->batches_len; ++i) { + if (shaderface->batches[i] == NULL) { break; - - if (i == shaderface->batches_len) - { - // Not enough place, realloc the array. + } + } + if (i == shaderface->batches_len) { + /* Not enough place, realloc the array. */ i = shaderface->batches_len; shaderface->batches_len += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_len); memset(shaderface->batches + i, 0, sizeof(Gwn_Batch*) * GWN_SHADERINTERFACE_REF_ALLOC_COUNT); - } - - shaderface->batches[i] = batch; } + shaderface->batches[i] = batch; +} void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) - { - for (int i = 0; i < shaderface->batches_len; ++i) - { - if (shaderface->batches[i] == batch) - { +{ + for (int i = 0; i < shaderface->batches_len; ++i) { + if (shaderface->batches[i] == batch) { shaderface->batches[i] = NULL; - break; // cannot have duplicates - } + break; /* cannot have duplicates */ } } +} diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp index 70294565e6a..04470bf6844 100644 --- a/intern/gawain/src/gwn_vertex_array_id.cpp +++ b/intern/gawain/src/gwn_vertex_array_id.cpp @@ -1,13 +1,38 @@ - -// Gawain vertex array IDs -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin, Clément Foucault -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.#include "buffer_id.h" +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation, Clément Foucault + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_vertex_array_id.cpp + * \ingroup gpu + * + * Manage GL vertex array IDs in a thread-safe way + * Use these instead of glGenBuffers & its friends + * - alloc must be called from a thread that is bound + * to the context that will be used for drawing with + * this vao. + * - free can be called from any thread + */ #include "gwn_batch_private.h" #include "gwn_vertex_array_id.h" @@ -21,30 +46,28 @@ #if TRUST_NO_ONE #if 0 extern "C" { -extern int BLI_thread_is_main(void); // Blender-specific function +extern int BLI_thread_is_main(void); /* Blender-specific function */ } -static bool thread_is_main() - { - // "main" here means the GL context's thread +static bool thread_is_main() { + /* "main" here means the GL context's thread */ return BLI_thread_is_main(); - } +} #endif #endif struct Gwn_Context { GLuint default_vao; - std::unordered_set batches; // Batches that have VAOs from this context + std::unordered_set batches; /* Batches that have VAOs from this context */ std::vector orphaned_vertarray_ids; - std::mutex orphans_mutex; // todo: try spinlock instead + std::mutex orphans_mutex; /* todo: try spinlock instead */ #if TRUST_NO_ONE - pthread_t thread; // Thread on which this context is active. + pthread_t thread; /* Thread on which this context is active. */ bool thread_is_used; - Gwn_Context() - { + Gwn_Context() { thread_is_used = false; - } + } #endif }; @@ -56,119 +79,118 @@ static thread_local Gwn_Context* active_ctx = NULL; #endif static void clear_orphans(Gwn_Context* ctx) - { +{ ctx->orphans_mutex.lock(); - if (!ctx->orphaned_vertarray_ids.empty()) - { - unsigned orphan_len = (unsigned)ctx->orphaned_vertarray_ids.size(); + if (!ctx->orphaned_vertarray_ids.empty()) { + uint orphan_len = (uint)ctx->orphaned_vertarray_ids.size(); glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data()); ctx->orphaned_vertarray_ids.clear(); - } - ctx->orphans_mutex.unlock(); } + ctx->orphans_mutex.unlock(); +} Gwn_Context* GWN_context_create(void) - { +{ #if TRUST_NO_ONE - // assert(thread_is_main()); + /* assert(thread_is_main()); */ #endif Gwn_Context* ctx = new Gwn_Context; glGenVertexArrays(1, &ctx->default_vao); GWN_context_active_set(ctx); return ctx; - } +} -// to be called after GWN_context_active_set(ctx_to_destroy) +/* to be called after GWN_context_active_set(ctx_to_destroy) */ void GWN_context_discard(Gwn_Context* ctx) - { +{ #if TRUST_NO_ONE - // Make sure no other thread has locked it. + /* Make sure no other thread has locked it. */ assert(ctx == active_ctx); assert(pthread_equal(pthread_self(), ctx->thread)); assert(ctx->orphaned_vertarray_ids.empty()); #endif - // delete remaining vaos - while (!ctx->batches.empty()) - { - // this removes the array entry + /* delete remaining vaos */ + while (!ctx->batches.empty()) { + /* this removes the array entry */ gwn_batch_vao_cache_clear(*ctx->batches.begin()); - } + } glDeleteVertexArrays(1, &ctx->default_vao); delete ctx; active_ctx = NULL; - } +} -// ctx can be NULL +/* ctx can be NULL */ void GWN_context_active_set(Gwn_Context* ctx) - { +{ #if TRUST_NO_ONE - if (active_ctx) + if (active_ctx) { active_ctx->thread_is_used = false; - // Make sure no other context is already bound to this thread. - if (ctx) - { - // Make sure no other thread has locked it. + } + /* Make sure no other context is already bound to this thread. */ + if (ctx) { + /* Make sure no other thread has locked it. */ assert(ctx->thread_is_used == false); ctx->thread = pthread_self(); ctx->thread_is_used = true; - } + } #endif - if (ctx) + if (ctx) { clear_orphans(ctx); - active_ctx = ctx; } + active_ctx = ctx; +} Gwn_Context* GWN_context_active_get(void) - { +{ return active_ctx; - } +} GLuint GWN_vao_default(void) - { +{ #if TRUST_NO_ONE - assert(active_ctx); // need at least an active context - assert(pthread_equal(pthread_self(), active_ctx->thread)); // context has been activated by another thread! + assert(active_ctx); /* need at least an active context */ + assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ #endif return active_ctx->default_vao; - } +} GLuint GWN_vao_alloc(void) - { +{ #if TRUST_NO_ONE - assert(active_ctx); // need at least an active context - assert(pthread_equal(pthread_self(), active_ctx->thread)); // context has been activated by another thread! + assert(active_ctx); /* need at least an active context */ + assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ #endif clear_orphans(active_ctx); GLuint new_vao_id = 0; glGenVertexArrays(1, &new_vao_id); return new_vao_id; - } +} -// this can be called from multiple thread +/* this can be called from multiple thread */ void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx) - { +{ #if TRUST_NO_ONE assert(ctx); #endif - if (ctx == active_ctx) + if (ctx == active_ctx) { glDeleteVertexArrays(1, &vao_id); - else - { + } + else { ctx->orphans_mutex.lock(); ctx->orphaned_vertarray_ids.emplace_back(vao_id); ctx->orphans_mutex.unlock(); - } } +} void gwn_context_add_batch(Gwn_Context* ctx, Gwn_Batch* batch) - { +{ ctx->batches.emplace(batch); - } +} void gwn_context_remove_batch(Gwn_Context* ctx, Gwn_Batch* batch) - { +{ ctx->orphans_mutex.lock(); ctx->batches.erase(batch); ctx->orphans_mutex.unlock(); - } +} diff --git a/intern/gawain/src/gwn_vertex_buffer.c b/intern/gawain/src/gwn_vertex_buffer.c index a372c62bd0a..c3440b25da2 100644 --- a/intern/gawain/src/gwn_vertex_buffer.c +++ b/intern/gawain/src/gwn_vertex_buffer.c @@ -1,13 +1,33 @@ - -// Gawain vertex buffer -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation, Clément Foucault + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_vertex_buffer.c + * \ingroup gpu + * + * Gawain vertex buffer + */ #include "gwn_vertex_buffer.h" #include "gwn_buffer_id.h" @@ -17,141 +37,137 @@ #define KEEP_SINGLE_COPY 1 -static unsigned vbo_memory_usage; +static uint vbo_memory_usage; static GLenum convert_usage_type_to_gl(Gwn_UsageType type) - { +{ static const GLenum table[] = { [GWN_USAGE_STREAM] = GL_STREAM_DRAW, [GWN_USAGE_STATIC] = GL_STATIC_DRAW, [GWN_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW - }; + }; return table[type]; - } +} Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType usage) - { +{ Gwn_VertBuf* verts = malloc(sizeof(Gwn_VertBuf)); GWN_vertbuf_init(verts, usage); return verts; - } +} Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat* format, Gwn_UsageType usage) - { +{ Gwn_VertBuf* verts = GWN_vertbuf_create(usage); GWN_vertformat_copy(&verts->format, format); - if (!format->packed) + if (!format->packed) { VertexFormat_pack(&verts->format); + } return verts; - // this function might seem redundant, but there is potential for memory savings here... - // TODO: implement those memory savings - } + /* this function might seem redundant, but there is potential for memory savings here... */ + /* TODO: implement those memory savings */ +} void GWN_vertbuf_init(Gwn_VertBuf* verts, Gwn_UsageType usage) - { +{ memset(verts, 0, sizeof(Gwn_VertBuf)); verts->usage = usage; verts->dirty = true; - } +} void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf* verts, const Gwn_VertFormat* format, Gwn_UsageType usage) - { +{ GWN_vertbuf_init(verts, usage); GWN_vertformat_copy(&verts->format, format); - if (!format->packed) + if (!format->packed) { VertexFormat_pack(&verts->format); } +} void GWN_vertbuf_discard(Gwn_VertBuf* verts) - { - if (verts->vbo_id) - { +{ + if (verts->vbo_id) { GWN_buf_id_free(verts->vbo_id); #if VRAM_USAGE vbo_memory_usage -= GWN_vertbuf_size_get(verts); #endif - } - - if (verts->data) + } + if (verts->data) { free(verts->data); - - free(verts); } + free(verts); +} -unsigned GWN_vertbuf_size_get(const Gwn_VertBuf* verts) - { +uint GWN_vertbuf_size_get(const Gwn_VertBuf* verts) +{ return vertex_buffer_size(&verts->format, verts->vertex_len); - } +} -// create a new allocation, discarding any existing data -void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_len) - { +/* create a new allocation, discarding any existing data */ +void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) +{ Gwn_VertFormat* format = &verts->format; - if (!format->packed) + if (!format->packed) { VertexFormat_pack(format); - + } #if TRUST_NO_ONE - // catch any unnecessary use + /* catch any unnecessary use */ assert(verts->vertex_alloc != v_len || verts->data == NULL); #endif - - // only create the buffer the 1st time - if (verts->vbo_id == 0) + /* only create the buffer the 1st time */ + if (verts->vbo_id == 0) { verts->vbo_id = GWN_buf_id_alloc(); - - // discard previous data if any - if (verts->data) + } + /* discard previous data if any */ + if (verts->data) { free(verts->data); - + } #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_len); + uint new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif - verts->dirty = true; verts->vertex_len = verts->vertex_alloc = v_len; verts->data = malloc(sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); - } +} -// resize buffer keeping existing data -void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, unsigned v_len) - { +/* resize buffer keeping existing data */ +void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, uint v_len) +{ #if TRUST_NO_ONE assert(verts->data != NULL); assert(verts->vertex_alloc != v_len); #endif #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_len); + uint new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif - verts->dirty = true; verts->vertex_len = verts->vertex_alloc = v_len; verts->data = realloc(verts->data, sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); - } +} -// set vertex count but does not change allocation -// only this many verts will be uploaded to the GPU and rendered -// this is usefull for streaming data -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, unsigned v_len) - { +/* Set vertex count but does not change allocation. + * Only this many verts will be uploaded to the GPU and rendered. + * This is usefull for streaming data. */ +void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, uint v_len) +{ #if TRUST_NO_ONE - assert(verts->data != NULL); // only for dynamic data + assert(verts->data != NULL); /* only for dynamic data */ assert(v_len <= verts->vertex_alloc); #endif #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_len); + uint new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif - verts->vertex_len = v_len; - } +} -void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, unsigned a_idx, unsigned v_idx, const void* data) - { +void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, uint a_idx, uint v_idx, const void* data) +{ const Gwn_VertFormat* format = &verts->format; const Gwn_VertAttr* a = format->attribs + a_idx; @@ -160,27 +176,25 @@ void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, unsigned a_idx, unsigned v_idx, co assert(v_idx < verts->vertex_alloc); assert(verts->data != NULL); #endif - verts->dirty = true; memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz); - } +} -void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, unsigned a_idx, const void* data) - { +void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, uint a_idx, const void* data) +{ const Gwn_VertFormat* format = &verts->format; const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); #endif - - const unsigned stride = a->sz; // tightly packed input data + const uint stride = a->sz; /* tightly packed input data */ GWN_vertbuf_attr_fill_stride(verts, a_idx, stride, data); - } +} -void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, unsigned a_idx, unsigned stride, const void* data) - { +void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, uint a_idx, uint stride, const void* data) +{ const Gwn_VertFormat* format = &verts->format; const Gwn_VertAttr* a = format->attribs + a_idx; @@ -188,25 +202,23 @@ void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, unsigned a_idx, unsigned s assert(a_idx < format->attr_len); assert(verts->data != NULL); #endif - verts->dirty = true; - const unsigned vertex_len = verts->vertex_len; + const uint vertex_len = verts->vertex_len; - if (format->attr_len == 1 && stride == format->stride) - { - // we can copy it all at once + if (format->attr_len == 1 && stride == format->stride) { + /* we can copy it all at once */ memcpy(verts->data, data, vertex_len * a->sz); - } - else - { - // we must copy it per vertex - for (unsigned v = 0; v < vertex_len; ++v) + } + else { + /* we must copy it per vertex */ + for (uint v = 0; v < vertex_len; ++v) { memcpy((GLubyte*)verts->data + a->offset + v * format->stride, (const GLubyte*)data + v * stride, a->sz); } } +} -void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, unsigned a_idx, Gwn_VertBufRaw *access) - { +void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, uint a_idx, Gwn_VertBufRaw *access) +{ const Gwn_VertFormat* format = &verts->format; const Gwn_VertAttr* a = format->attribs + a_idx; @@ -224,35 +236,33 @@ void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, unsigned a_idx, Gwn_VertB #if TRUST_NO_ONE access->_data_end = access->data_init + (size_t)(verts->vertex_alloc * format->stride); #endif - } +} static void VertBuffer_upload_data(Gwn_VertBuf* verts) - { - unsigned buffer_sz = GWN_vertbuf_size_get(verts); +{ + uint buffer_sz = GWN_vertbuf_size_get(verts); - // orphan the vbo to avoid sync + /* orphan the vbo to avoid sync */ glBufferData(GL_ARRAY_BUFFER, buffer_sz, NULL, convert_usage_type_to_gl(verts->usage)); - // upload data + /* upload data */ glBufferSubData(GL_ARRAY_BUFFER, 0, buffer_sz, verts->data); - if (verts->usage == GWN_USAGE_STATIC) - { + if (verts->usage == GWN_USAGE_STATIC) { free(verts->data); verts->data = NULL; - } - - verts->dirty = false; } + verts->dirty = false; +} void GWN_vertbuf_use(Gwn_VertBuf* verts) - { +{ glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id); - - if (verts->dirty) + if (verts->dirty) { VertBuffer_upload_data(verts); } +} -unsigned GWN_vertbuf_get_memory_usage(void) - { +uint GWN_vertbuf_get_memory_usage(void) +{ return vbo_memory_usage; - } +} diff --git a/intern/gawain/src/gwn_vertex_format.c b/intern/gawain/src/gwn_vertex_format.c index 122de12ec6e..41179ae21eb 100644 --- a/intern/gawain/src/gwn_vertex_format.c +++ b/intern/gawain/src/gwn_vertex_format.c @@ -1,13 +1,33 @@ - -// Gawain vertex format -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation, Clément Foucault + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_vertex_format.c + * \ingroup gpu + * + * Gawain vertex format + */ #include "gwn_vertex_format.h" #include "gwn_vertex_format_private.h" @@ -21,7 +41,7 @@ #endif void GWN_vertformat_clear(Gwn_VertFormat* format) - { +{ #if TRUST_NO_ONE memset(format, 0, sizeof(Gwn_VertFormat)); #else @@ -30,23 +50,26 @@ void GWN_vertformat_clear(Gwn_VertFormat* format) format->name_offset = 0; format->name_len = 0; - for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++) + for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++) { format->attribs[i].name_len = 0; -#endif } +#endif +} void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) - { - // copy regular struct fields +{ + /* copy regular struct fields */ memcpy(dest, src, sizeof(Gwn_VertFormat)); - for (unsigned i = 0; i < dest->attr_len; i++) - for (unsigned j = 0; j < dest->attribs[i].name_len; j++) + for (unsigned i = 0; i < dest->attr_len; i++) { + for (unsigned j = 0; j < dest->attribs[i].name_len; j++) { dest->attribs[i].name[j] = (char *)dest + (src->attribs[i].name[j] - ((char *)src)); + } } +} static GLenum convert_comp_type_to_gl(Gwn_VertCompType type) - { +{ static const GLenum table[] = { [GWN_COMP_I8] = GL_BYTE, [GWN_COMP_U8] = GL_UNSIGNED_BYTE, @@ -58,105 +81,101 @@ static GLenum convert_comp_type_to_gl(Gwn_VertCompType type) [GWN_COMP_F32] = GL_FLOAT, [GWN_COMP_I10] = GL_INT_2_10_10_10_REV - }; + }; return table[type]; - } +} static unsigned comp_sz(Gwn_VertCompType type) - { +{ #if TRUST_NO_ONE - assert(type <= GWN_COMP_F32); // other types have irregular sizes (not bytes) + assert(type <= GWN_COMP_F32); /* other types have irregular sizes (not bytes) */ #endif - const GLubyte sizes[] = {1,1,2,2,4,4,4}; return sizes[type]; - } +} static unsigned attrib_sz(const Gwn_VertAttr *a) - { - if (a->comp_type == GWN_COMP_I10) - return 4; // always packed as 10_10_10_2 - - return a->comp_len * comp_sz(a->comp_type); +{ + if (a->comp_type == GWN_COMP_I10) { + return 4; /* always packed as 10_10_10_2 */ } + return a->comp_len * comp_sz(a->comp_type); +} static unsigned attrib_align(const Gwn_VertAttr *a) - { - if (a->comp_type == GWN_COMP_I10) - return 4; // always packed as 10_10_10_2 - +{ + if (a->comp_type == GWN_COMP_I10) { + return 4; /* always packed as 10_10_10_2 */ + } unsigned c = comp_sz(a->comp_type); - if (a->comp_len == 3 && c <= 2) - return 4 * c; // AMD HW can't fetch these well, so pad it out (other vendors too?) - else - return c; // most fetches are ok if components are naturally aligned + if (a->comp_len == 3 && c <= 2) { + return 4 * c; /* AMD HW can't fetch these well, so pad it out (other vendors too?) */ + } + else { + return c; /* most fetches are ok if components are naturally aligned */ } +} unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) - { +{ #if TRUST_NO_ONE assert(format->packed && format->stride > 0); #endif - return format->stride * vertex_len; - } +} static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) - { - // strncpy does 110% of what we need; let's do exactly 100% +{ + /* strncpy does 110% of what we need; let's do exactly 100% */ char* name_copy = format->names + format->name_offset; unsigned available = GWN_VERT_ATTR_NAMES_BUF_LEN - format->name_offset; bool terminated = false; - for (unsigned i = 0; i < available; ++i) - { + for (unsigned i = 0; i < available; ++i) { const char c = name[i]; name_copy[i] = c; - if (c == '\0') - { + if (c == '\0') { terminated = true; format->name_offset += (i + 1); break; - } } - + } #if TRUST_NO_ONE assert(terminated); assert(format->name_offset <= GWN_VERT_ATTR_NAMES_BUF_LEN); #else (void)terminated; #endif - return name_copy; - } +} unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_len, Gwn_VertFetchMode fetch_mode) - { +{ #if TRUST_NO_ONE - assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more - assert(format->attr_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more - assert(!format->packed); // packed means frozen/locked + assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(format->attr_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(!format->packed); /* packed means frozen/locked */ assert((comp_len >= 1 && comp_len <= 4) || comp_len == 8 || comp_len == 12 || comp_len == 16); - switch (comp_type) - { + + switch (comp_type) { case GWN_COMP_F32: - // float type can only kept as float + /* float type can only kept as float */ assert(fetch_mode == GWN_FETCH_FLOAT); break; case GWN_COMP_I10: - // 10_10_10 format intended for normals (xyz) or colors (rgb) - // extra component packed.w can be manually set to { -2, -1, 0, 1 } + /* 10_10_10 format intended for normals (xyz) or colors (rgb) + * extra component packed.w can be manually set to { -2, -1, 0, 1 } */ assert(comp_len == 3 || comp_len == 4); - assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); // not strictly required, may relax later + assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); /* not strictly required, may relax later */ break; default: - // integer types can be kept as int or converted/normalized to float + /* integer types can be kept as int or converted/normalized to float */ assert(fetch_mode != GWN_FETCH_FLOAT); - // only support float matrices (see Batch_update_program_bindings) + /* only support float matrices (see Batch_update_program_bindings) */ assert(comp_len != 8 && comp_len != 12 && comp_len != 16); - } + } #endif - format->name_len++; // multiname support + format->name_len++; /* multiname support */ const unsigned attrib_id = format->attr_len++; Gwn_VertAttr* attrib = format->attribs + attrib_id; @@ -164,53 +183,53 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V attrib->name[attrib->name_len++] = copy_attrib_name(format, name); attrib->comp_type = comp_type; attrib->gl_comp_type = convert_comp_type_to_gl(comp_type); - attrib->comp_len = (comp_type == GWN_COMP_I10) ? 4 : comp_len; // system needs 10_10_10_2 to be 4 or BGRA + attrib->comp_len = (comp_type == GWN_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */ attrib->sz = attrib_sz(attrib); - attrib->offset = 0; // offsets & stride are calculated later (during pack) + attrib->offset = 0; /* offsets & stride are calculated later (during pack) */ attrib->fetch_mode = fetch_mode; return attrib_id; - } +} void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias) - { +{ Gwn_VertAttr* attrib = format->attribs + (format->attr_len - 1); #if TRUST_NO_ONE - assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more + assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ assert(attrib->name_len < GWN_VERT_ATTR_MAX_NAMES); #endif - format->name_len++; // multiname support + format->name_len++; /* multiname support */ attrib->name[attrib->name_len++] = copy_attrib_name(format, alias); - } +} unsigned padding(unsigned offset, unsigned alignment) - { +{ const unsigned mod = offset % alignment; return (mod == 0) ? 0 : (alignment - mod); - } +} #if PACK_DEBUG static void show_pack(unsigned a_idx, unsigned sz, unsigned pad) - { +{ const char c = 'A' + a_idx; - for (unsigned i = 0; i < pad; ++i) + for (unsigned i = 0; i < pad; ++i) { putchar('-'); - for (unsigned i = 0; i < sz; ++i) + } + for (unsigned i = 0; i < sz; ++i) { putchar(c); } +} #endif void VertexFormat_pack(Gwn_VertFormat* format) - { - // for now, attributes are packed in the order they were added, - // making sure each attrib is naturally aligned (add padding where necessary) - - // later we can implement more efficient packing w/ reordering - // (keep attrib ID order, adjust their offsets to reorder in buffer) +{ + /* For now, attributes are packed in the order they were added, + * making sure each attrib is naturally aligned (add padding where necessary) + * Later we can implement more efficient packing w/ reordering + * (keep attrib ID order, adjust their offsets to reorder in buffer). */ - // TODO: - // realloc just enough to hold the final combo string. And just enough to - // hold used attribs, not all 16. + /* TODO: realloc just enough to hold the final combo string. And just enough to + * hold used attribs, not all 16. */ Gwn_VertAttr* a0 = format->attribs + 0; a0->offset = 0; @@ -220,8 +239,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) show_pack(0, a0->sz, 0); #endif - for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) - { + for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) { Gwn_VertAttr* a = format->attribs + a_idx; unsigned mid_padding = padding(offset, attrib_align(a)); offset += mid_padding; @@ -231,7 +249,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) #if PACK_DEBUG show_pack(a_idx, a->sz, mid_padding); #endif - } + } unsigned end_padding = padding(offset, attrib_align(a0)); @@ -239,53 +257,54 @@ void VertexFormat_pack(Gwn_VertFormat* format) show_pack(0, 0, end_padding); putchar('\n'); #endif - format->stride = offset + end_padding; format->packed = true; - } +} -// OpenGL ES packs in a different order as desktop GL but component conversion is the same. -// Of the code here, only struct Gwn_PackedNormal needs to change. +/* OpenGL ES packs in a different order as desktop GL but component conversion is the same. + * Of the code here, only struct Gwn_PackedNormal needs to change. */ #define SIGNED_INT_10_MAX 511 #define SIGNED_INT_10_MIN -512 static int clampi(int x, int min_allowed, int max_allowed) - { +{ #if TRUST_NO_ONE assert(min_allowed <= max_allowed); #endif - - if (x < min_allowed) + if (x < min_allowed) { return min_allowed; - else if (x > max_allowed) + } + else if (x > max_allowed) { return max_allowed; - else + } + else { return x; } +} static int quantize(float x) - { +{ int qx = x * 511.0f; return clampi(qx, SIGNED_INT_10_MIN, SIGNED_INT_10_MAX); - } +} static int convert_i16(short x) - { - // 16-bit signed --> 10-bit signed +{ + /* 16-bit signed --> 10-bit signed */ + /* TODO: round? */ return x >> 6; - // TODO: round? - } +} Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]) - { +{ Gwn_PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) }; return n; - } +} Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]) - { +{ Gwn_PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) }; return n; - } +} -- cgit v1.2.3 From 247ad2034de2c33a6d9cb7d3b6f1ef7ffa5b859d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 17 Jul 2018 21:11:23 +0200 Subject: GWN: Port to GPU module: Move files to GPU This does not include all the struct and type renaming. Only files were renamed. gwn_batch.c/h was fusioned with GPU_batch.c/h gwn_immediate.c/h was fusioned with GPU_immediate.c/h gwn_imm_util.c/h was fusioned with GPU_immediate_util.c/h --- intern/CMakeLists.txt | 1 - intern/gawain/CMakeLists.txt | 50 -- intern/gawain/gawain/gwn_attr_binding.h | 42 - intern/gawain/gawain/gwn_attr_binding_private.h | 43 - intern/gawain/gawain/gwn_batch.h | 193 ----- intern/gawain/gawain/gwn_batch_private.h | 54 -- intern/gawain/gawain/gwn_buffer_id.h | 53 -- intern/gawain/gawain/gwn_common.h | 61 -- intern/gawain/gawain/gwn_context.h | 55 -- intern/gawain/gawain/gwn_element.h | 102 --- intern/gawain/gawain/gwn_imm_util.h | 46 -- intern/gawain/gawain/gwn_immediate.h | 132 ---- intern/gawain/gawain/gwn_primitive.h | 65 -- intern/gawain/gawain/gwn_primitive_private.h | 37 - intern/gawain/gawain/gwn_shader_interface.h | 104 --- intern/gawain/gawain/gwn_vertex_array_id.h | 55 -- intern/gawain/gawain/gwn_vertex_buffer.h | 144 ---- intern/gawain/gawain/gwn_vertex_format.h | 101 --- intern/gawain/gawain/gwn_vertex_format_private.h | 39 - intern/gawain/src/gwn_attr_binding.c | 85 -- intern/gawain/src/gwn_batch.c | 645 --------------- intern/gawain/src/gwn_buffer_id.cpp | 89 --- intern/gawain/src/gwn_element.c | 307 -------- intern/gawain/src/gwn_imm_util.c | 100 --- intern/gawain/src/gwn_immediate.c | 863 --------------------- intern/gawain/src/gwn_primitive.c | 84 -- intern/gawain/src/gwn_shader_interface.c | 361 --------- intern/gawain/src/gwn_vertex_array_id.cpp | 196 ----- intern/gawain/src/gwn_vertex_buffer.c | 268 ------- intern/gawain/src/gwn_vertex_format.c | 310 -------- intern/opencolorio/CMakeLists.txt | 2 +- intern/opencolorio/ocio_impl_glsl.cc | 2 +- .../blender/blenfont/intern/blf_internal_types.h | 2 +- .../blender/draw/engines/eevee/eevee_lightcache.c | 2 +- source/blender/draw/intern/draw_manager.c | 2 +- source/blender/draw/intern/draw_manager.h | 1 + source/blender/gpu/CMakeLists.txt | 22 +- source/blender/gpu/GPU_attr_binding.h | 42 + source/blender/gpu/GPU_batch.h | 182 ++++- source/blender/gpu/GPU_buffer_id.h | 53 ++ source/blender/gpu/GPU_common.h | 61 ++ source/blender/gpu/GPU_context.h | 55 ++ source/blender/gpu/GPU_element.h | 102 +++ source/blender/gpu/GPU_immediate.h | 112 ++- source/blender/gpu/GPU_immediate_util.h | 9 + source/blender/gpu/GPU_primitive.h | 65 ++ source/blender/gpu/GPU_shader_interface.h | 104 +++ source/blender/gpu/GPU_vertex_array_id.h | 55 ++ source/blender/gpu/GPU_vertex_buffer.h | 144 ++++ source/blender/gpu/GPU_vertex_format.h | 101 +++ source/blender/gpu/intern/gpu_attr_binding.c | 85 ++ .../blender/gpu/intern/gpu_attr_binding_private.h | 43 + source/blender/gpu/intern/gpu_batch.c | 637 ++++++++++++++- source/blender/gpu/intern/gpu_batch_private.h | 53 ++ source/blender/gpu/intern/gpu_buffer_id.cpp | 90 +++ source/blender/gpu/intern/gpu_element.c | 308 ++++++++ source/blender/gpu/intern/gpu_immediate.c | 849 +++++++++++++++++++- source/blender/gpu/intern/gpu_immediate_util.c | 70 +- source/blender/gpu/intern/gpu_matrix.c | 2 +- source/blender/gpu/intern/gpu_primitive.c | 84 ++ source/blender/gpu/intern/gpu_primitive_private.h | 37 + source/blender/gpu/intern/gpu_shader_interface.c | 361 +++++++++ source/blender/gpu/intern/gpu_shader_private.h | 2 +- source/blender/gpu/intern/gpu_vertex_array_id.cpp | 196 +++++ source/blender/gpu/intern/gpu_vertex_buffer.c | 268 +++++++ source/blender/gpu/intern/gpu_vertex_format.c | 310 ++++++++ .../blender/gpu/intern/gpu_vertex_format_private.h | 39 + source/blender/python/gawain/gwn_py_api.c | 4 +- source/blender/python/gawain/gwn_py_types.c | 4 +- source/blender/render/CMakeLists.txt | 1 + source/blender/render/intern/source/pipeline.c | 2 +- source/blender/windowmanager/intern/wm_playanim.c | 2 +- source/blender/windowmanager/intern/wm_window.c | 3 +- 73 files changed, 4501 insertions(+), 4752 deletions(-) delete mode 100644 intern/gawain/CMakeLists.txt delete mode 100644 intern/gawain/gawain/gwn_attr_binding.h delete mode 100644 intern/gawain/gawain/gwn_attr_binding_private.h delete mode 100644 intern/gawain/gawain/gwn_batch.h delete mode 100644 intern/gawain/gawain/gwn_batch_private.h delete mode 100644 intern/gawain/gawain/gwn_buffer_id.h delete mode 100644 intern/gawain/gawain/gwn_common.h delete mode 100644 intern/gawain/gawain/gwn_context.h delete mode 100644 intern/gawain/gawain/gwn_element.h delete mode 100644 intern/gawain/gawain/gwn_imm_util.h delete mode 100644 intern/gawain/gawain/gwn_immediate.h delete mode 100644 intern/gawain/gawain/gwn_primitive.h delete mode 100644 intern/gawain/gawain/gwn_primitive_private.h delete mode 100644 intern/gawain/gawain/gwn_shader_interface.h delete mode 100644 intern/gawain/gawain/gwn_vertex_array_id.h delete mode 100644 intern/gawain/gawain/gwn_vertex_buffer.h delete mode 100644 intern/gawain/gawain/gwn_vertex_format.h delete mode 100644 intern/gawain/gawain/gwn_vertex_format_private.h delete mode 100644 intern/gawain/src/gwn_attr_binding.c delete mode 100644 intern/gawain/src/gwn_batch.c delete mode 100644 intern/gawain/src/gwn_buffer_id.cpp delete mode 100644 intern/gawain/src/gwn_element.c delete mode 100644 intern/gawain/src/gwn_imm_util.c delete mode 100644 intern/gawain/src/gwn_immediate.c delete mode 100644 intern/gawain/src/gwn_primitive.c delete mode 100644 intern/gawain/src/gwn_shader_interface.c delete mode 100644 intern/gawain/src/gwn_vertex_array_id.cpp delete mode 100644 intern/gawain/src/gwn_vertex_buffer.c delete mode 100644 intern/gawain/src/gwn_vertex_format.c create mode 100644 source/blender/gpu/GPU_attr_binding.h create mode 100644 source/blender/gpu/GPU_buffer_id.h create mode 100644 source/blender/gpu/GPU_common.h create mode 100644 source/blender/gpu/GPU_context.h create mode 100644 source/blender/gpu/GPU_element.h create mode 100644 source/blender/gpu/GPU_primitive.h create mode 100644 source/blender/gpu/GPU_shader_interface.h create mode 100644 source/blender/gpu/GPU_vertex_array_id.h create mode 100644 source/blender/gpu/GPU_vertex_buffer.h create mode 100644 source/blender/gpu/GPU_vertex_format.h create mode 100644 source/blender/gpu/intern/gpu_attr_binding.c create mode 100644 source/blender/gpu/intern/gpu_attr_binding_private.h create mode 100644 source/blender/gpu/intern/gpu_batch_private.h create mode 100644 source/blender/gpu/intern/gpu_buffer_id.cpp create mode 100644 source/blender/gpu/intern/gpu_element.c create mode 100644 source/blender/gpu/intern/gpu_primitive.c create mode 100644 source/blender/gpu/intern/gpu_primitive_private.h create mode 100644 source/blender/gpu/intern/gpu_shader_interface.c create mode 100644 source/blender/gpu/intern/gpu_vertex_array_id.cpp create mode 100644 source/blender/gpu/intern/gpu_vertex_buffer.c create mode 100644 source/blender/gpu/intern/gpu_vertex_format.c create mode 100644 source/blender/gpu/intern/gpu_vertex_format_private.h diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt index 1a050892836..1459100d415 100644 --- a/intern/CMakeLists.txt +++ b/intern/CMakeLists.txt @@ -34,7 +34,6 @@ add_subdirectory(opencolorio) add_subdirectory(mikktspace) add_subdirectory(glew-mx) add_subdirectory(eigen) -add_subdirectory(gawain) if(WITH_AUDASPACE) add_subdirectory(audaspace) diff --git a/intern/gawain/CMakeLists.txt b/intern/gawain/CMakeLists.txt deleted file mode 100644 index 7ebd3ee7622..00000000000 --- a/intern/gawain/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# WITH_OPENGL limits the visibility of the opengl headers to just gawain and bg_gpu, -# to more easily highlight codepadths in other libraries that need to be refactored, -# bf_intern_gawain is allowed to have opengl regardless of this option. - -if(NOT WITH_OPENGL) - add_definitions(-DWITH_OPENGL) -endif() - -set(INC - gawain -) - -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - -set(SRC - src/gwn_attr_binding.c - src/gwn_batch.c - src/gwn_element.c - src/gwn_buffer_id.cpp - src/gwn_immediate.c - src/gwn_imm_util.c - src/gwn_primitive.c - src/gwn_shader_interface.c - src/gwn_vertex_array_id.cpp - src/gwn_vertex_buffer.c - src/gwn_vertex_format.c - - gawain/gwn_attr_binding.h - gawain/gwn_attr_binding_private.h - gawain/gwn_batch.h - gawain/gwn_batch_private.h - gawain/gwn_buffer_id.h - gawain/gwn_common.h - gawain/gwn_element.h - gawain/gwn_imm_util.h - gawain/gwn_immediate.h - gawain/gwn_primitive.h - gawain/gwn_primitive_private.h - gawain/gwn_shader_interface.h - gawain/gwn_vertex_array_id.h - gawain/gwn_vertex_buffer.h - gawain/gwn_vertex_format.h - gawain/gwn_vertex_format_private.h -) - -add_definitions(${GL_DEFINITIONS}) - -blender_add_lib(bf_intern_gawain "${SRC}" "${INC}" "${INC_SYS}") diff --git a/intern/gawain/gawain/gwn_attr_binding.h b/intern/gawain/gawain/gwn_attr_binding.h deleted file mode 100644 index 8030e86ea92..00000000000 --- a/intern/gawain/gawain/gwn_attr_binding.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_attr_binding.h - * \ingroup gpu - * - * Gawain vertex attribute binding - */ - -#ifndef __GWN_ATTR_BINDING_H__ -#define __GWN_ATTR_BINDING_H__ - -#include "gwn_common.h" - -typedef struct Gwn_AttrBinding { - uint64_t loc_bits; /* store 4 bits for each of the 16 attribs */ - uint16_t enabled_bits; /* 1 bit for each attrib */ -} Gwn_AttrBinding; - -#endif /* __GWN_ATTR_BINDING_H__ */ diff --git a/intern/gawain/gawain/gwn_attr_binding_private.h b/intern/gawain/gawain/gwn_attr_binding_private.h deleted file mode 100644 index cead1896ec7..00000000000 --- a/intern/gawain/gawain/gwn_attr_binding_private.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_attr_binding_private.h - * \ingroup gpu - * - * Gawain vertex attribute binding - */ - -#ifndef __GWN_ATTR_BINDING_PRIVATE_H__ -#define __GWN_ATTR_BINDING_PRIVATE_H__ - -#include "gwn_vertex_format.h" -#include "gwn_shader_interface.h" - -void AttribBinding_clear(Gwn_AttrBinding*); - -void get_attrib_locations(const Gwn_VertFormat*, Gwn_AttrBinding*, const Gwn_ShaderInterface*); -unsigned read_attrib_location(const Gwn_AttrBinding*, unsigned a_idx); - -#endif /* __GWN_ATTR_BINDING_PRIVATE_H__ */ diff --git a/intern/gawain/gawain/gwn_batch.h b/intern/gawain/gawain/gwn_batch.h deleted file mode 100644 index a7a54502cc0..00000000000 --- a/intern/gawain/gawain/gwn_batch.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_batch.h - * \ingroup gpu - * - * Gawain geometry batch - * Contains VAOs + VBOs + Shader representing a drawable entity. - */ - -#ifndef __GWN_BATCH_H__ -#define __GWN_BATCH_H__ - -#include "gwn_vertex_buffer.h" -#include "gwn_element.h" -#include "gwn_shader_interface.h" - -typedef enum { - GWN_BATCH_READY_TO_FORMAT, - GWN_BATCH_READY_TO_BUILD, - GWN_BATCH_BUILDING, - GWN_BATCH_READY_TO_DRAW -} Gwn_BatchPhase; - -#define GWN_BATCH_VBO_MAX_LEN 3 -#define GWN_BATCH_VAO_STATIC_LEN 3 -#define GWN_BATCH_VAO_DYN_ALLOC_COUNT 16 - -typedef struct Gwn_Batch { - /* geometry */ - Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ - Gwn_VertBuf* inst; /* instance attribs */ - Gwn_IndexBuf* elem; /* NULL if element list not needed */ - uint32_t gl_prim_type; - - /* cached values (avoid dereferencing later) */ - uint32_t vao_id; - uint32_t program; - const struct Gwn_ShaderInterface* interface; - - /* book-keeping */ - uint owns_flag; - struct Gwn_Context *context; /* used to free all vaos. this implies all vaos were created under the same context. */ - Gwn_BatchPhase phase; - bool program_in_use; - - /* Vao management: remembers all geometry state (vertex attrib bindings & element buffer) - * for each shader interface. Start with a static number of vaos and fallback to dynamic count - * if necessary. Once a batch goes dynamic it does not go back. */ - bool is_dynamic_vao_count; - union { - /* Static handle count */ - struct { - const struct Gwn_ShaderInterface* interfaces[GWN_BATCH_VAO_STATIC_LEN]; - uint32_t vao_ids[GWN_BATCH_VAO_STATIC_LEN]; - } static_vaos; - /* Dynamic handle count */ - struct { - uint count; - const struct Gwn_ShaderInterface** interfaces; - uint32_t* vao_ids; - } dynamic_vaos; - }; - - /* XXX This is the only solution if we want to have some data structure using - * batches as key to identify nodes. We must destroy these nodes with this callback. */ - void (*free_callback)(struct Gwn_Batch*, void*); - void* callback_data; -} Gwn_Batch; - -enum { - GWN_BATCH_OWNS_VBO = (1 << 0), - /* each vbo index gets bit-shifted */ - GWN_BATCH_OWNS_INSTANCES = (1 << 30), - GWN_BATCH_OWNS_INDEX = (1 << 31), -}; - -Gwn_Batch* GWN_batch_create_ex(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); -void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); -Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src); - -#define GWN_batch_create(prim, verts, elem) \ - GWN_batch_create_ex(prim, verts, elem, 0) -#define GWN_batch_init(batch, prim, verts, elem) \ - GWN_batch_init_ex(batch, prim, verts, elem, 0) - -void GWN_batch_discard(Gwn_Batch*); /* verts & elem are not discarded */ - -void GWN_batch_callback_free_set(Gwn_Batch*, void (*callback)(Gwn_Batch*, void*), void*); - -void GWN_batch_instbuf_set(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); /* Instancing */ - -int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); - -#define GWN_batch_vertbuf_add(batch, verts) \ - GWN_batch_vertbuf_add_ex(batch, verts, false) - -void GWN_batch_program_set_no_use(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); -void GWN_batch_program_set(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); -/* Entire batch draws with one shader program, but can be redrawn later with another program. */ -/* Vertex shader's inputs must be compatible with the batch's vertex format. */ - -void GWN_batch_program_use_begin(Gwn_Batch*); /* call before Batch_Uniform (temp hack?) */ -void GWN_batch_program_use_end(Gwn_Batch*); - -void GWN_batch_uniform_1ui(Gwn_Batch*, const char* name, int value); -void GWN_batch_uniform_1i(Gwn_Batch*, const char* name, int value); -void GWN_batch_uniform_1b(Gwn_Batch*, const char* name, bool value); -void GWN_batch_uniform_1f(Gwn_Batch*, const char* name, float value); -void GWN_batch_uniform_2f(Gwn_Batch*, const char* name, float x, float y); -void GWN_batch_uniform_3f(Gwn_Batch*, const char* name, float x, float y, float z); -void GWN_batch_uniform_4f(Gwn_Batch*, const char* name, float x, float y, float z, float w); -void GWN_batch_uniform_2fv(Gwn_Batch*, const char* name, const float data[2]); -void GWN_batch_uniform_3fv(Gwn_Batch*, const char* name, const float data[3]); -void GWN_batch_uniform_4fv(Gwn_Batch*, const char* name, const float data[4]); -void GWN_batch_uniform_2fv_array(Gwn_Batch*, const char* name, int len, const float *data); -void GWN_batch_uniform_4fv_array(Gwn_Batch*, const char* name, int len, const float *data); -void GWN_batch_uniform_mat4(Gwn_Batch*, const char* name, const float data[4][4]); - -void GWN_batch_draw(Gwn_Batch*); - -/* This does not bind/unbind shader and does not call GPU_matrix_bind() */ -void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance); - -/* Does not even need batch */ -void GWN_draw_primitive(Gwn_PrimType, int v_count); - -#if 0 /* future plans */ - -/* Can multiple batches share a Gwn_VertBuf? Use ref count? */ - - -/* We often need a batch with its own data, to be created and discarded together. */ -/* WithOwn variants reduce number of system allocations. */ - -typedef struct BatchWithOwnVertexBuffer { - Gwn_Batch batch; - Gwn_VertBuf verts; /* link batch.verts to this */ -} BatchWithOwnVertexBuffer; - -typedef struct BatchWithOwnElementList { - Gwn_Batch batch; - Gwn_IndexBuf elem; /* link batch.elem to this */ -} BatchWithOwnElementList; - -typedef struct BatchWithOwnVertexBufferAndElementList { - Gwn_Batch batch; - Gwn_IndexBuf elem; /* link batch.elem to this */ - Gwn_VertBuf verts; /* link batch.verts to this */ -} BatchWithOwnVertexBufferAndElementList; - -Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, uint v_len, Gwn_IndexBuf*); -Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, uint prim_len); -Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, uint v_len, uint prim_len); -/* verts: shared, own */ -/* elem: none, shared, own */ -Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff); - -#endif /* future plans */ - - -/* Macros */ - -#define GWN_BATCH_DISCARD_SAFE(batch) do { \ - if (batch != NULL) { \ - GWN_batch_discard(batch); \ - batch = NULL; \ - } \ -} while (0) - -#endif /* __GWN_BATCH_H__ */ diff --git a/intern/gawain/gawain/gwn_batch_private.h b/intern/gawain/gawain/gwn_batch_private.h deleted file mode 100644 index e7d42ff0249..00000000000 --- a/intern/gawain/gawain/gwn_batch_private.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_batch_private.h - * \ingroup gpu - * - * Gawain geometry batch - * Contains VAOs + VBOs + Shader representing a drawable entity. - */ - -#ifndef __GWN_BATCH_PRIVATE_H__ -#define __GWN_BATCH_PRIVATE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "gwn_batch.h" -#include "gwn_context.h" -#include "gwn_shader_interface.h" - -void gwn_batch_remove_interface_ref(Gwn_Batch*, const Gwn_ShaderInterface*); -void gwn_batch_vao_cache_clear(Gwn_Batch*); - -void gwn_context_add_batch(Gwn_Context*, Gwn_Batch*); -void gwn_context_remove_batch(Gwn_Context*, Gwn_Batch*); - -#ifdef __cplusplus -} -#endif - -#endif /* __GWN_BATCH_PRIVATE_H__ */ diff --git a/intern/gawain/gawain/gwn_buffer_id.h b/intern/gawain/gawain/gwn_buffer_id.h deleted file mode 100644 index 0c2537a5d5a..00000000000 --- a/intern/gawain/gawain/gwn_buffer_id.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_buffer_id.h - * \ingroup gpu - * - * Gawain buffer IDs - */ - -#ifndef __GWN_BUFFER_ID_H__ -#define __GWN_BUFFER_ID_H__ - -/* Manage GL buffer IDs in a thread-safe way - * Use these instead of glGenBuffers & its friends - * - alloc must be called from main thread - * - free can be called from any thread */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "gwn_common.h" - -GLuint GWN_buf_id_alloc(void); -void GWN_buf_id_free(GLuint buffer_id); - -#ifdef __cplusplus -} -#endif - -#endif /* __GWN_BUFFER_ID_H__ */ diff --git a/intern/gawain/gawain/gwn_common.h b/intern/gawain/gawain/gwn_common.h deleted file mode 100644 index 2587e8670a9..00000000000 --- a/intern/gawain/gawain/gwn_common.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_common.h - * \ingroup gpu - */ - -#ifndef __GWN_COMMON_H__ -#define __GWN_COMMON_H__ - -#define PROGRAM_NO_OPTI 0 - -#if defined(NDEBUG) - #define TRUST_NO_ONE 0 -#else - /* strict error checking, enabled for debug builds during early development */ - #define TRUST_NO_ONE 1 -#endif - -#if defined(WITH_OPENGL) - #include -#endif - -#include -#include -#include - -#if TRUST_NO_ONE - #include -#endif - -/* GWN_INLINE */ -#if defined(_MSC_VER) -# define GWN_INLINE static __forceinline -#else -# define GWN_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) -#endif - -#endif /* __GWN_COMMON_H__ */ diff --git a/intern/gawain/gawain/gwn_context.h b/intern/gawain/gawain/gwn_context.h deleted file mode 100644 index 7784fc30562..00000000000 --- a/intern/gawain/gawain/gwn_context.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_context.h - * \ingroup gpu - * - * This interface allow Gawain to manage VAOs for mutiple context and threads. - */ - -#ifndef __GWN_CONTEXT_H__ -#define __GWN_CONTEXT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "gwn_common.h" -#include "gwn_batch.h" -#include "gwn_shader_interface.h" - -typedef struct Gwn_Context Gwn_Context; - -Gwn_Context* GWN_context_create(void); -void GWN_context_discard(Gwn_Context*); - -void GWN_context_active_set(Gwn_Context*); -Gwn_Context* GWN_context_active_get(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __GWN_CONTEXT_H__ */ diff --git a/intern/gawain/gawain/gwn_element.h b/intern/gawain/gawain/gwn_element.h deleted file mode 100644 index 2d5b6bb692b..00000000000 --- a/intern/gawain/gawain/gwn_element.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_element.h - * \ingroup gpu - * - * Gawain element list (AKA index buffer) - */ - -#ifndef __GWN_ELEMENT_H__ -#define __GWN_ELEMENT_H__ - -#include "gwn_primitive.h" - -#define GWN_TRACK_INDEX_RANGE 1 - -#define GWN_PRIM_RESTART 0xFFFFFFFF - -typedef enum { - GWN_INDEX_U8, /* GL has this, Vulkan does not */ - GWN_INDEX_U16, - GWN_INDEX_U32 -} Gwn_IndexBufType; - -typedef struct Gwn_IndexBuf { - uint index_len; -#if GWN_TRACK_INDEX_RANGE - Gwn_IndexBufType index_type; - uint32_t gl_index_type; - uint min_index; - uint max_index; - uint base_index; -#endif - uint32_t vbo_id; /* 0 indicates not yet sent to VRAM */ - bool use_prim_restart; -} Gwn_IndexBuf; - -void GWN_indexbuf_use(Gwn_IndexBuf*); -uint GWN_indexbuf_size_get(const Gwn_IndexBuf*); - -typedef struct Gwn_IndexBufBuilder { - uint max_allowed_index; - uint max_index_len; - uint index_len; - Gwn_PrimType prim_type; - uint* data; - bool use_prim_restart; -} Gwn_IndexBufBuilder; - - -/* supports all primitive types. */ -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, uint index_len, uint vertex_len, bool use_prim_restart); - -/* supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS. */ -void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, uint prim_len, uint vertex_len); - -void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, uint v); -void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*); - -void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, uint v); -void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, uint v1, uint v2); -void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3); -void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3, uint v4); - -Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*); -void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*); - -void GWN_indexbuf_discard(Gwn_IndexBuf*); - - -/* Macros */ - -#define GWN_INDEXBUF_DISCARD_SAFE(elem) do { \ - if (elem != NULL) { \ - GWN_indexbuf_discard(elem); \ - elem = NULL; \ - } \ -} while (0) - -#endif /* __GWN_ELEMENT_H__ */ diff --git a/intern/gawain/gawain/gwn_imm_util.h b/intern/gawain/gawain/gwn_imm_util.h deleted file mode 100644 index e512d071dca..00000000000 --- a/intern/gawain/gawain/gwn_imm_util.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_imm_util.h - * \ingroup gpu - * - * Gawain element list (AKA index buffer) - */ - -#ifndef __GWN_IMM_UTIL_H__ -#define __GWN_IMM_UTIL_H__ - -#include - -/* Draw 2D rectangles (replaces glRect functions) */ -/* caller is reponsible for vertex format & shader */ -void immRectf(uint pos, float x1, float y1, float x2, float y2); -void immRecti(uint pos, int x1, int y1, int x2, int y2); - -/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS. */ -void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]); -void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]); - -#endif /* __GWN_IMM_UTIL_H__ */ diff --git a/intern/gawain/gawain/gwn_immediate.h b/intern/gawain/gawain/gwn_immediate.h deleted file mode 100644 index 8231942d735..00000000000 --- a/intern/gawain/gawain/gwn_immediate.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_immediate.h - * \ingroup gpu - * - * Gawain immediate mode work-alike - */ - -#ifndef __GWN_IMMEDIATE_H__ -#define __GWN_IMMEDIATE_H__ - -#include "gwn_vertex_format.h" -#include "gwn_primitive.h" -#include "gwn_shader_interface.h" -#include "gwn_batch.h" - -Gwn_VertFormat* immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ - -void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); /* every immBegin must have a program bound first. */ -void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */ - -void immBegin(Gwn_PrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */ -void immBeginAtMost(Gwn_PrimType, uint max_vertex_len); /* can supply fewer vertices. */ -void immEnd(void); /* finishes and draws. */ - -/* ImmBegin a batch, then use standard immFunctions as usual. */ -/* ImmEnd will finalize the batch instead of drawing. */ -/* Then you can draw it as many times as you like! Partially replaces the need for display lists. */ -Gwn_Batch* immBeginBatch(Gwn_PrimType, uint vertex_len); -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, uint vertex_len); - -/* Provide attribute values that can change per vertex. */ -/* First vertex after immBegin must have all its attributes specified. */ -/* Skipped attributes will continue using the previous value for that attrib_id. */ -void immAttrib1f(uint attrib_id, float x); -void immAttrib2f(uint attrib_id, float x, float y); -void immAttrib3f(uint attrib_id, float x, float y, float z); -void immAttrib4f(uint attrib_id, float x, float y, float z, float w); - -void immAttrib2i(uint attrib_id, int x, int y); - -void immAttrib1u(uint attrib_id, uint x); - -void immAttrib2s(uint attrib_id, short x, short y); - -void immAttrib2fv(uint attrib_id, const float data[2]); -void immAttrib3fv(uint attrib_id, const float data[3]); -void immAttrib4fv(uint attrib_id, const float data[4]); - -void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b); -void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a); - -void immAttrib3ubv(uint attrib_id, const unsigned char data[4]); -void immAttrib4ubv(uint attrib_id, const unsigned char data[4]); - -/* Explicitly skip an attribute. */ -/* This advanced option kills automatic value copying for this attrib_id. */ -void immSkipAttrib(uint attrib_id); - -/* Provide one last attribute value & end the current vertex. */ -/* This is most often used for 2D or 3D position (similar to glVertex). */ -void immVertex2f(uint attrib_id, float x, float y); -void immVertex3f(uint attrib_id, float x, float y, float z); -void immVertex4f(uint attrib_id, float x, float y, float z, float w); - -void immVertex2i(uint attrib_id, int x, int y); - -void immVertex2s(uint attrib_id, short x, short y); - -void immVertex2fv(uint attrib_id, const float data[2]); -void immVertex3fv(uint attrib_id, const float data[3]); - -void immVertex2iv(uint attrib_id, const int data[2]); - -/* Provide uniform values that don't change for the entire draw call. */ -void immUniform1i(const char* name, int x); -void immUniform4iv(const char* name, const int data[4]); -void immUniform1f(const char* name, float x); -void immUniform2f(const char* name, float x, float y); -void immUniform2fv(const char* name, const float data[2]); -void immUniform3f(const char* name, float x, float y, float z); -void immUniform3fv(const char* name, const float data[3]); -void immUniformArray3fv(const char* name, const float *data, int count); -void immUniform4f(const char* name, float x, float y, float z, float w); -void immUniform4fv(const char* name, const float data[4]); -void immUniformArray4fv(const char* bare_name, const float *data, int count); -void immUniformMatrix4fv(const char* name, const float data[4][4]); - -/* Convenience functions for setting "uniform vec4 color". */ -/* The rgb functions have implicit alpha = 1.0. */ -void immUniformColor4f(float r, float g, float b, float a); -void immUniformColor4fv(const float rgba[4]); -void immUniformColor3f(float r, float g, float b); -void immUniformColor3fv(const float rgb[3]); -void immUniformColor3fvAlpha(const float rgb[3], float a); - -void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b); -void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void immUniformColor3ubv(const unsigned char rgb[3]); -void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a); -void immUniformColor4ubv(const unsigned char rgba[4]); - -/* These are called by the system -- not part of drawing API. */ -void immInit(void); -void immActivate(void); -void immDeactivate(void); -void immDestroy(void); - -#endif /* __GWN_IMMEDIATE_H__ */ diff --git a/intern/gawain/gawain/gwn_primitive.h b/intern/gawain/gawain/gwn_primitive.h deleted file mode 100644 index 346f77441d3..00000000000 --- a/intern/gawain/gawain/gwn_primitive.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_primitive.h - * \ingroup gpu - * - * Gawain geometric primitives - */ - -#ifndef __GWN_PRIMITIVE_H__ -#define __GWN_PRIMITIVE_H__ - -#include "gwn_common.h" - -typedef enum { - GWN_PRIM_POINTS, - GWN_PRIM_LINES, - GWN_PRIM_TRIS, - GWN_PRIM_LINE_STRIP, - GWN_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */ - GWN_PRIM_TRI_STRIP, - GWN_PRIM_TRI_FAN, - - GWN_PRIM_LINES_ADJ, - GWN_PRIM_TRIS_ADJ, - GWN_PRIM_LINE_STRIP_ADJ, - - GWN_PRIM_NONE -} Gwn_PrimType; - -/* what types of primitives does each shader expect? */ -typedef enum { - GWN_PRIM_CLASS_NONE = 0, - GWN_PRIM_CLASS_POINT = (1 << 0), - GWN_PRIM_CLASS_LINE = (1 << 1), - GWN_PRIM_CLASS_SURFACE = (1 << 2), - GWN_PRIM_CLASS_ANY = GWN_PRIM_CLASS_POINT | GWN_PRIM_CLASS_LINE | GWN_PRIM_CLASS_SURFACE -} Gwn_PrimClass; - -Gwn_PrimClass GWN_primtype_class(Gwn_PrimType); -bool GWN_primtype_belongs_to_class(Gwn_PrimType, Gwn_PrimClass); - -#endif /* __GWN_PRIMITIVE_H__ */ diff --git a/intern/gawain/gawain/gwn_primitive_private.h b/intern/gawain/gawain/gwn_primitive_private.h deleted file mode 100644 index 6d3f1e20da7..00000000000 --- a/intern/gawain/gawain/gwn_primitive_private.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_primitive_private.h - * \ingroup gpu - * - * Gawain geometric primitives - */ - -#ifndef __GWN_PRIMITIVE_PRIVATE_H__ -#define __GWN_PRIMITIVE_PRIVATE_H__ - -GLenum convert_prim_type_to_gl(Gwn_PrimType); - -#endif /* __GWN_PRIMITIVE_PRIVATE_H__ */ diff --git a/intern/gawain/gawain/gwn_shader_interface.h b/intern/gawain/gawain/gwn_shader_interface.h deleted file mode 100644 index 4b20719b329..00000000000 --- a/intern/gawain/gawain/gwn_shader_interface.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_shader_interface.h - * \ingroup gpu - * - * Gawain shader interface (C --> GLSL) - */ - -#ifndef __GWN_SHADER_INTERFACE_H__ -#define __GWN_SHADER_INTERFACE_H__ - -#include "gwn_common.h" - -typedef enum { - GWN_UNIFORM_NONE = 0, /* uninitialized/unknown */ - - GWN_UNIFORM_MODEL, /* mat4 ModelMatrix */ - GWN_UNIFORM_VIEW, /* mat4 ViewMatrix */ - GWN_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */ - GWN_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */ - GWN_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */ - GWN_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */ - - GWN_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */ - GWN_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */ - GWN_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */ - GWN_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */ - GWN_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */ - - GWN_UNIFORM_NORMAL, /* mat3 NormalMatrix */ - GWN_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */ - GWN_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ - GWN_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ - - GWN_UNIFORM_COLOR, /* vec4 color */ - GWN_UNIFORM_EYE, /* vec3 eye */ - GWN_UNIFORM_CALLID, /* int callId */ - - GWN_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ - - GWN_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ -} Gwn_UniformBuiltin; - -typedef struct Gwn_ShaderInput { - struct Gwn_ShaderInput* next; - uint32_t name_offset; - uint name_hash; - Gwn_UniformBuiltin builtin_type; /* only for uniform inputs */ - uint32_t gl_type; /* only for attrib inputs */ - int32_t size; /* only for attrib inputs */ - int32_t location; -} Gwn_ShaderInput; - -#define GWN_NUM_SHADERINTERFACE_BUCKETS 257 -#define GWN_SHADERINTERFACE_REF_ALLOC_COUNT 16 - -typedef struct Gwn_ShaderInterface { - int32_t program; - uint32_t name_buffer_offset; - Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* ubo_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS]; - char* name_buffer; - struct Gwn_Batch** batches; /* references to batches using this interface */ - uint batches_len; -} Gwn_ShaderInterface; - -Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id); -void GWN_shaderinterface_discard(Gwn_ShaderInterface*); - -const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name); -const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin); -const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface*, const char* name); -const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name); - -/* keep track of batches using this interface */ -void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); -void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); - -#endif /* __GWN_SHADER_INTERFACE_H__ */ diff --git a/intern/gawain/gawain/gwn_vertex_array_id.h b/intern/gawain/gawain/gwn_vertex_array_id.h deleted file mode 100644 index 6ba26612b4e..00000000000 --- a/intern/gawain/gawain/gwn_vertex_array_id.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_vertex_array_id.h - * \ingroup gpu - * - * Manage GL vertex array IDs in a thread-safe way - * Use these instead of glGenBuffers & its friends - * - alloc must be called from a thread that is bound - * to the context that will be used for drawing with - * this vao. - * - free can be called from any thread - */ - -#ifndef __GWN_VERTEX_ARRAY_ID_H__ -#define __GWN_VERTEX_ARRAY_ID_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "gwn_common.h" -#include "gwn_context.h" - -GLuint GWN_vao_default(void); -GLuint GWN_vao_alloc(void); -void GWN_vao_free(GLuint vao_id, Gwn_Context*); - -#ifdef __cplusplus -} -#endif - -#endif /* __GWN_VERTEX_ARRAY_ID_H__ */ diff --git a/intern/gawain/gawain/gwn_vertex_buffer.h b/intern/gawain/gawain/gwn_vertex_buffer.h deleted file mode 100644 index 84ea12f86d1..00000000000 --- a/intern/gawain/gawain/gwn_vertex_buffer.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_vertex_buffer.h - * \ingroup gpu - * - * Gawain vertex buffer - */ - -#ifndef __GWN_VERTEX_BUFFER_H__ -#define __GWN_VERTEX_BUFFER_H__ - -#include "gwn_vertex_format.h" - -#define VRAM_USAGE 1 -/* How to create a Gwn_VertBuf: */ -/* 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts) */ -/* 2) GWN_vertformat_attr_add(verts->format, ...) */ -/* 3) GWN_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format */ -/* 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer) */ - -/* Is Gwn_VertBuf always used as part of a Gwn_Batch? */ - -typedef enum { - /* can be extended to support more types */ - GWN_USAGE_STREAM, - GWN_USAGE_STATIC, /* do not keep data in memory */ - GWN_USAGE_DYNAMIC -} Gwn_UsageType; - -typedef struct Gwn_VertBuf { - Gwn_VertFormat format; - uint vertex_len; /* number of verts we want to draw */ - uint vertex_alloc; /* number of verts data */ - bool dirty; - unsigned char* data; /* NULL indicates data in VRAM (unmapped) */ - uint32_t vbo_id; /* 0 indicates not yet allocated */ - Gwn_UsageType usage; /* usage hint for GL optimisation */ -} Gwn_VertBuf; - -Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType); -Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat*, Gwn_UsageType); - -#define GWN_vertbuf_create_with_format(format) \ - GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_STATIC) - -void GWN_vertbuf_discard(Gwn_VertBuf*); - -void GWN_vertbuf_init(Gwn_VertBuf*, Gwn_UsageType); -void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf*, const Gwn_VertFormat*, Gwn_UsageType); - -#define GWN_vertbuf_init_with_format(verts, format) \ - GWN_vertbuf_init_with_format_ex(verts, format, GWN_USAGE_STATIC) - -uint GWN_vertbuf_size_get(const Gwn_VertBuf*); -void GWN_vertbuf_data_alloc(Gwn_VertBuf*, uint v_len); -void GWN_vertbuf_data_resize(Gwn_VertBuf*, uint v_len); -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, uint v_len); - -/* The most important set_attrib variant is the untyped one. Get it right first. */ -/* It takes a void* so the app developer is responsible for matching their app data types */ -/* to the vertex attribute's type and component count. They're in control of both, so this */ -/* should not be a problem. */ - -void GWN_vertbuf_attr_set(Gwn_VertBuf*, uint a_idx, uint v_idx, const void* data); -void GWN_vertbuf_attr_fill(Gwn_VertBuf*, uint a_idx, const void* data); /* tightly packed, non interleaved input data */ -void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, uint a_idx, uint stride, const void* data); - -/* For low level access only */ -typedef struct Gwn_VertBufRaw { - uint size; - uint stride; - unsigned char* data; - unsigned char* data_init; -#if TRUST_NO_ONE - /* Only for overflow check */ - unsigned char* _data_end; -#endif -} Gwn_VertBufRaw; - -GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a) -{ - unsigned char* data = a->data; - a->data += a->stride; -#if TRUST_NO_ONE - assert(data < a->_data_end); -#endif - return (void *)data; -} - -GWN_INLINE uint GWN_vertbuf_raw_used(Gwn_VertBufRaw *a) -{ - return ((a->data - a->data_init) / a->stride); -} - -void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, uint a_idx, Gwn_VertBufRaw *access); - -/* TODO: decide whether to keep the functions below */ -/* doesn't immediate mode satisfy these needs? */ - -/* void setAttrib1f(uint a_idx, uint v_idx, float x); */ -/* void setAttrib2f(uint a_idx, unsigned v_idx, float x, float y); */ -/* void setAttrib3f(unsigned a_idx, unsigned v_idx, float x, float y, float z); */ -/* void setAttrib4f(unsigned a_idx, unsigned v_idx, float x, float y, float z, float w); */ - -/* void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b); */ -/* void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a); */ - -void GWN_vertbuf_use(Gwn_VertBuf*); - -/* Metrics */ -uint GWN_vertbuf_get_memory_usage(void); - -/* Macros */ -#define GWN_VERTBUF_DISCARD_SAFE(verts) do { \ - if (verts != NULL) { \ - GWN_vertbuf_discard(verts); \ - verts = NULL; \ - } \ -} while (0) - -#endif /* __GWN_VERTEX_BUFFER_H__ */ diff --git a/intern/gawain/gawain/gwn_vertex_format.h b/intern/gawain/gawain/gwn_vertex_format.h deleted file mode 100644 index 1197a8ef842..00000000000 --- a/intern/gawain/gawain/gwn_vertex_format.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_vertex_format.h - * \ingroup gpu - * - * Gawain vertex format - */ - -#ifndef __GWN_VERTEX_FORMAT_H__ -#define __GWN_VERTEX_FORMAT_H__ - -#include "gwn_common.h" - -#define GWN_VERT_ATTR_MAX_LEN 16 -#define GWN_VERT_ATTR_MAX_NAMES 3 -#define GWN_VERT_ATTR_NAME_AVERAGE_LEN 11 -#define GWN_VERT_ATTR_NAMES_BUF_LEN ((GWN_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GWN_VERT_ATTR_MAX_LEN) - -typedef enum { - GWN_COMP_I8, - GWN_COMP_U8, - GWN_COMP_I16, - GWN_COMP_U16, - GWN_COMP_I32, - GWN_COMP_U32, - - GWN_COMP_F32, - - GWN_COMP_I10 -} Gwn_VertCompType; - -typedef enum { - GWN_FETCH_FLOAT, - GWN_FETCH_INT, - GWN_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */ - GWN_FETCH_INT_TO_FLOAT /* 127 (any int type) -> 127.0 */ -} Gwn_VertFetchMode; - -typedef struct Gwn_VertAttr { - Gwn_VertFetchMode fetch_mode; - Gwn_VertCompType comp_type; - uint gl_comp_type; - uint comp_len; /* 1 to 4 or 8 or 12 or 16 */ - uint sz; /* size in bytes, 1 to 64 */ - uint offset; /* from beginning of vertex, in bytes */ - uint name_len; /* up to GWN_VERT_ATTR_MAX_NAMES */ - const char* name[GWN_VERT_ATTR_MAX_NAMES]; -} Gwn_VertAttr; - -typedef struct Gwn_VertFormat { - uint attr_len; /* 0 to 16 (GWN_VERT_ATTR_MAX_LEN) */ - uint name_len; /* total count of active vertex attrib */ - uint stride; /* stride in bytes, 1 to 256 */ - uint name_offset; - bool packed; - char names[GWN_VERT_ATTR_NAMES_BUF_LEN]; - Gwn_VertAttr attribs[GWN_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */ -} Gwn_VertFormat; - -void GWN_vertformat_clear(Gwn_VertFormat*); -void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src); - -uint GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, uint comp_len, Gwn_VertFetchMode); -void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias); - -/* format conversion */ - -typedef struct Gwn_PackedNormal { - int x : 10; - int y : 10; - int z : 10; - int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */ -} Gwn_PackedNormal; - -Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]); -Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]); - -#endif /* __GWN_VERTEX_FORMAT_H__ */ diff --git a/intern/gawain/gawain/gwn_vertex_format_private.h b/intern/gawain/gawain/gwn_vertex_format_private.h deleted file mode 100644 index 3cae9969fd8..00000000000 --- a/intern/gawain/gawain/gwn_vertex_format_private.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_vertex_format_private.h - * \ingroup gpu - * - * Gawain vertex format - */ - -#ifndef __GWN_VERTEX_FORMAT_PRIVATE_H__ -#define __GWN_VERTEX_FORMAT_PRIVATE_H__ - -void VertexFormat_pack(Gwn_VertFormat*); -uint padding(uint offset, uint alignment); -uint vertex_buffer_size(const Gwn_VertFormat*, uint vertex_len); - -#endif /* __GWN_VERTEX_FORMAT_PRIVATE_H__ */ diff --git a/intern/gawain/src/gwn_attr_binding.c b/intern/gawain/src/gwn_attr_binding.c deleted file mode 100644 index 727aceb0140..00000000000 --- a/intern/gawain/src/gwn_attr_binding.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_attr_binding.c - * \ingroup gpu - * - * Gawain vertex attribute binding - */ - -#include "gwn_attr_binding.h" -#include "gwn_attr_binding_private.h" -#include -#include - -#if GWN_VERT_ATTR_MAX_LEN != 16 - #error "attrib binding code assumes GWN_VERT_ATTR_MAX_LEN = 16" -#endif - -void AttribBinding_clear(Gwn_AttrBinding* binding) -{ - binding->loc_bits = 0; - binding->enabled_bits = 0; -} - -uint read_attrib_location(const Gwn_AttrBinding* binding, uint a_idx) -{ -#if TRUST_NO_ONE - assert(a_idx < GWN_VERT_ATTR_MAX_LEN); - assert(binding->enabled_bits & (1 << a_idx)); -#endif - return (binding->loc_bits >> (4 * a_idx)) & 0xF; -} - -static void write_attrib_location(Gwn_AttrBinding* binding, uint a_idx, uint location) -{ -#if TRUST_NO_ONE - assert(a_idx < GWN_VERT_ATTR_MAX_LEN); - assert(location < GWN_VERT_ATTR_MAX_LEN); -#endif - const uint shift = 4 * a_idx; - const uint64_t mask = ((uint64_t)0xF) << shift; - /* overwrite this attrib's previous location */ - binding->loc_bits = (binding->loc_bits & ~mask) | (location << shift); - /* mark this attrib as enabled */ - binding->enabled_bits |= 1 << a_idx; -} - -void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding, const Gwn_ShaderInterface* shaderface) -{ - AttribBinding_clear(binding); - - for (uint a_idx = 0; a_idx < format->attr_len; ++a_idx) { - const Gwn_VertAttr* a = format->attribs + a_idx; - for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { - const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]); -#if TRUST_NO_ONE - assert(input != NULL); - /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */ -#endif - write_attrib_location(binding, a_idx, input->location); - } - } -} diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c deleted file mode 100644 index 5daf0e87aec..00000000000 --- a/intern/gawain/src/gwn_batch.c +++ /dev/null @@ -1,645 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_batch.c - * \ingroup gpu - * - * Gawain geometry batch - * Contains VAOs + VBOs + Shader representing a drawable entity. - */ - -#include "gwn_batch.h" -#include "gwn_batch_private.h" -#include "gwn_buffer_id.h" -#include "gwn_vertex_array_id.h" -#include "gwn_primitive_private.h" -#include -#include - -/* necessary functions from matrix API */ -extern void GPU_matrix_bind(const Gwn_ShaderInterface* shaderface); - -static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first); - -void gwn_batch_vao_cache_clear(Gwn_Batch* batch) -{ - if (batch->context == NULL) { - return; - } - if (batch->is_dynamic_vao_count) { - for (int i = 0; i < batch->dynamic_vaos.count; ++i) { - if (batch->dynamic_vaos.vao_ids[i]) { - GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); - } - if (batch->dynamic_vaos.interfaces[i]) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->dynamic_vaos.interfaces[i], batch); - } - } - free(batch->dynamic_vaos.interfaces); - free(batch->dynamic_vaos.vao_ids); - } - else { - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { - if (batch->static_vaos.vao_ids[i]) { - GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); - } - if (batch->static_vaos.interfaces[i]) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->static_vaos.interfaces[i], batch); - } - } - } - batch->is_dynamic_vao_count = false; - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { - batch->static_vaos.vao_ids[i] = 0; - batch->static_vaos.interfaces[i] = NULL; - } - gwn_context_remove_batch(batch->context, batch); - batch->context = NULL; -} - -Gwn_Batch* GWN_batch_create_ex( - Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, - uint owns_flag) -{ - Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch)); - GWN_batch_init_ex(batch, prim_type, verts, elem, owns_flag); - return batch; -} - -void GWN_batch_init_ex( - Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, - uint owns_flag) -{ -#if TRUST_NO_ONE - assert(verts != NULL); -#endif - - batch->verts[0] = verts; - for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { - batch->verts[v] = NULL; - } - batch->inst = NULL; - batch->elem = elem; - batch->gl_prim_type = convert_prim_type_to_gl(prim_type); - batch->phase = GWN_BATCH_READY_TO_DRAW; - batch->is_dynamic_vao_count = false; - batch->owns_flag = owns_flag; - batch->free_callback = NULL; -} - -/* This will share the VBOs with the new batch. */ -Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src) -{ - Gwn_Batch* batch = GWN_batch_create_ex(GWN_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); - - batch->gl_prim_type = batch_src->gl_prim_type; - for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { - batch->verts[v] = batch_src->verts[v]; - } - return batch; -} - -void GWN_batch_discard(Gwn_Batch* batch) -{ - if (batch->owns_flag & GWN_BATCH_OWNS_INDEX) { - GWN_indexbuf_discard(batch->elem); - } - if (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES) { - GWN_vertbuf_discard(batch->inst); - } - if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0) { - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { - if (batch->verts[v] == NULL) { - break; - } - if (batch->owns_flag & (1 << v)) { - GWN_vertbuf_discard(batch->verts[v]); - } - } - } - gwn_batch_vao_cache_clear(batch); - - if (batch->free_callback) { - batch->free_callback(batch, batch->callback_data); - } - free(batch); -} - -void GWN_batch_callback_free_set(Gwn_Batch* batch, void (*callback)(Gwn_Batch*, void*), void* user_data) -{ - batch->free_callback = callback; - batch->callback_data = user_data; -} - -void GWN_batch_instbuf_set(Gwn_Batch* batch, Gwn_VertBuf* inst, bool own_vbo) -{ -#if TRUST_NO_ONE - assert(inst != NULL); -#endif - /* redo the bindings */ - gwn_batch_vao_cache_clear(batch); - - if (batch->inst != NULL && (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES)) { - GWN_vertbuf_discard(batch->inst); - } - batch->inst = inst; - - if (own_vbo) { - batch->owns_flag |= GWN_BATCH_OWNS_INSTANCES; - } - else { - batch->owns_flag &= ~GWN_BATCH_OWNS_INSTANCES; - } -} - -/* Returns the index of verts in the batch. */ -int GWN_batch_vertbuf_add_ex( - Gwn_Batch* batch, Gwn_VertBuf* verts, - bool own_vbo) -{ - /* redo the bindings */ - gwn_batch_vao_cache_clear(batch); - - for (uint v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { - if (batch->verts[v] == NULL) { -#if TRUST_NO_ONE - /* for now all VertexBuffers must have same vertex_len */ - assert(verts->vertex_len == batch->verts[0]->vertex_len); -#endif - batch->verts[v] = verts; - /* TODO: mark dirty so we can keep attrib bindings up-to-date */ - if (own_vbo) - batch->owns_flag |= (1 << v); - return v; - } - } - - /* we only make it this far if there is no room for another Gwn_VertBuf */ -#if TRUST_NO_ONE - assert(false); -#endif - return -1; -} - -static GLuint batch_vao_get(Gwn_Batch *batch) -{ - /* Search through cache */ - if (batch->is_dynamic_vao_count) { - for (int i = 0; i < batch->dynamic_vaos.count; ++i) - if (batch->dynamic_vaos.interfaces[i] == batch->interface) - return batch->dynamic_vaos.vao_ids[i]; - } - else { - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) - if (batch->static_vaos.interfaces[i] == batch->interface) - return batch->static_vaos.vao_ids[i]; - } - - /* Set context of this batch. - * It will be bound to it until gwn_batch_vao_cache_clear is called. - * Until then it can only be drawn with this context. */ - if (batch->context == NULL) { - batch->context = GWN_context_active_get(); - gwn_context_add_batch(batch->context, batch); - } -#if TRUST_NO_ONE - else { - /* Make sure you are not trying to draw this batch in another context. */ - assert(batch->context == GWN_context_active_get()); - } -#endif - - /* Cache miss, time to add a new entry! */ - GLuint new_vao = 0; - if (!batch->is_dynamic_vao_count) { - int i; /* find first unused slot */ - for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) - if (batch->static_vaos.vao_ids[i] == 0) - break; - - if (i < GWN_BATCH_VAO_STATIC_LEN) { - batch->static_vaos.interfaces[i] = batch->interface; - batch->static_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); - } - else { - /* Not enough place switch to dynamic. */ - batch->is_dynamic_vao_count = true; - /* Erase previous entries, they will be added back if drawn again. */ - for (int j = 0; j < GWN_BATCH_VAO_STATIC_LEN; ++j) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface*)batch->static_vaos.interfaces[j], batch); - GWN_vao_free(batch->static_vaos.vao_ids[j], batch->context); - } - /* Init dynamic arrays and let the branch below set the values. */ - batch->dynamic_vaos.count = GWN_BATCH_VAO_DYN_ALLOC_COUNT; - batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(Gwn_ShaderInterface*)); - batch->dynamic_vaos.vao_ids = calloc(batch->dynamic_vaos.count, sizeof(GLuint)); - } - } - - if (batch->is_dynamic_vao_count) { - int i; /* find first unused slot */ - for (i = 0; i < batch->dynamic_vaos.count; ++i) - if (batch->dynamic_vaos.vao_ids[i] == 0) - break; - - if (i == batch->dynamic_vaos.count) { - /* Not enough place, realloc the array. */ - i = batch->dynamic_vaos.count; - batch->dynamic_vaos.count += GWN_BATCH_VAO_DYN_ALLOC_COUNT; - batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(Gwn_ShaderInterface*) * batch->dynamic_vaos.count); - batch->dynamic_vaos.vao_ids = realloc(batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count); - memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(Gwn_ShaderInterface*) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); - memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); - } - batch->dynamic_vaos.interfaces[i] = batch->interface; - batch->dynamic_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); - } - - GWN_shaderinterface_add_batch_ref((Gwn_ShaderInterface*)batch->interface, batch); - -#if TRUST_NO_ONE - assert(new_vao != 0); -#endif - - /* We just got a fresh VAO we need to initialize it. */ - glBindVertexArray(new_vao); - batch_update_program_bindings(batch, 0); - glBindVertexArray(0); - - return new_vao; -} - -void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) -{ -#if TRUST_NO_ONE - assert(glIsProgram(shaderface->program)); - assert(batch->program_in_use == 0); -#endif - batch->interface = shaderface; - batch->program = program; - batch->vao_id = batch_vao_get(batch); -} - -void GWN_batch_program_set(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) -{ - GWN_batch_program_set_no_use(batch, program, shaderface); - GWN_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */ -} - -void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* interface) -{ - if (batch->is_dynamic_vao_count) { - for (int i = 0; i < batch->dynamic_vaos.count; ++i) { - if (batch->dynamic_vaos.interfaces[i] == interface) { - GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); - batch->dynamic_vaos.vao_ids[i] = 0; - batch->dynamic_vaos.interfaces[i] = NULL; - break; /* cannot have duplicates */ - } - } - } - else { - int i; - for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { - if (batch->static_vaos.interfaces[i] == interface) { - GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); - batch->static_vaos.vao_ids[i] = 0; - batch->static_vaos.interfaces[i] = NULL; - break; /* cannot have duplicates */ - } - } - } -} - -static void create_bindings( - Gwn_VertBuf* verts, const Gwn_ShaderInterface* interface, - uint v_first, const bool use_instancing) -{ - const Gwn_VertFormat* format = &verts->format; - - const uint attr_len = format->attr_len; - const uint stride = format->stride; - - GWN_vertbuf_use(verts); - - for (uint a_idx = 0; a_idx < attr_len; ++a_idx) { - const Gwn_VertAttr* a = format->attribs + a_idx; - const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride; - - for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { - const Gwn_ShaderInput* input = GWN_shaderinterface_attr(interface, a->name[n_idx]); - - if (input == NULL) continue; - - if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { -#if TRUST_NO_ONE - assert(a->fetch_mode == GWN_FETCH_FLOAT); - assert(a->gl_comp_type == GL_FLOAT); -#endif - for (int i = 0; i < a->comp_len / 4; ++i) { - glEnableVertexAttribArray(input->location + i); - glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0); - glVertexAttribPointer(input->location + i, 4, a->gl_comp_type, GL_FALSE, stride, - (const GLubyte*)pointer + i * 16); - } - } - else - { - glEnableVertexAttribArray(input->location); - glVertexAttribDivisor(input->location, (use_instancing) ? 1 : 0); - - switch (a->fetch_mode) { - case GWN_FETCH_FLOAT: - case GWN_FETCH_INT_TO_FLOAT: - glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); - break; - case GWN_FETCH_INT_TO_FLOAT_UNIT: - glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); - break; - case GWN_FETCH_INT: - glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer); - break; - } - } - } - } -} - -static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first) -{ - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { - create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false); - } - if (batch->inst) { - create_bindings(batch->inst, batch->interface, v_first, true); - } - if (batch->elem) { - GWN_indexbuf_use(batch->elem); - } -} - -void GWN_batch_program_use_begin(Gwn_Batch* batch) -{ - /* NOTE: use_program & done_using_program are fragile, depend on staying in sync with - * the GL context's active program. use_program doesn't mark other programs as "not used". */ - /* TODO: make not fragile (somehow) */ - - if (!batch->program_in_use) { - glUseProgram(batch->program); - batch->program_in_use = true; - } -} - -void GWN_batch_program_use_end(Gwn_Batch* batch) -{ - if (batch->program_in_use) { -#if PROGRAM_NO_OPTI - glUseProgram(0); -#endif - batch->program_in_use = false; - } -} - -#if TRUST_NO_ONE - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); assert(uniform); -#else - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); -#endif - -void GWN_batch_uniform_1ui(Gwn_Batch* batch, const char* name, int value) -{ - GET_UNIFORM - glUniform1ui(uniform->location, value); -} - -void GWN_batch_uniform_1i(Gwn_Batch* batch, const char* name, int value) -{ - GET_UNIFORM - glUniform1i(uniform->location, value); -} - -void GWN_batch_uniform_1b(Gwn_Batch* batch, const char* name, bool value) -{ - GET_UNIFORM - glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE); -} - -void GWN_batch_uniform_2f(Gwn_Batch* batch, const char* name, float x, float y) -{ - GET_UNIFORM - glUniform2f(uniform->location, x, y); -} - -void GWN_batch_uniform_3f(Gwn_Batch* batch, const char* name, float x, float y, float z) -{ - GET_UNIFORM - glUniform3f(uniform->location, x, y, z); -} - -void GWN_batch_uniform_4f(Gwn_Batch* batch, const char* name, float x, float y, float z, float w) -{ - GET_UNIFORM - glUniform4f(uniform->location, x, y, z, w); -} - -void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x) -{ - GET_UNIFORM - glUniform1f(uniform->location, x); -} - -void GWN_batch_uniform_2fv(Gwn_Batch* batch, const char* name, const float data[2]) -{ - GET_UNIFORM - glUniform2fv(uniform->location, 1, data); -} - -void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3]) -{ - GET_UNIFORM - glUniform3fv(uniform->location, 1, data); -} - -void GWN_batch_uniform_4fv(Gwn_Batch* batch, const char* name, const float data[4]) -{ - GET_UNIFORM - glUniform4fv(uniform->location, 1, data); -} - -void GWN_batch_uniform_2fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) -{ - GET_UNIFORM - glUniform2fv(uniform->location, len, data); -} - -void GWN_batch_uniform_4fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) -{ - GET_UNIFORM - glUniform4fv(uniform->location, len, data); -} - -void GWN_batch_uniform_mat4(Gwn_Batch* batch, const char* name, const float data[4][4]) -{ - GET_UNIFORM - glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (const float *)data); -} - -static void primitive_restart_enable(const Gwn_IndexBuf *el) -{ - // TODO(fclem) Replace by GL_PRIMITIVE_RESTART_FIXED_INDEX when we have ogl 4.3 - glEnable(GL_PRIMITIVE_RESTART); - GLuint restart_index = (GLuint)0xFFFFFFFF; - -#if GWN_TRACK_INDEX_RANGE - if (el->index_type == GWN_INDEX_U8) - restart_index = (GLuint)0xFF; - else if (el->index_type == GWN_INDEX_U16) - restart_index = (GLuint)0xFFFF; -#endif - - glPrimitiveRestartIndex(restart_index); -} - -static void primitive_restart_disable(void) -{ - glDisable(GL_PRIMITIVE_RESTART); -} - -void GWN_batch_draw(Gwn_Batch* batch) -{ -#if TRUST_NO_ONE - assert(batch->phase == GWN_BATCH_READY_TO_DRAW); - assert(batch->verts[0]->vbo_id != 0); -#endif - GWN_batch_program_use_begin(batch); - GPU_matrix_bind(batch->interface); // external call. - - GWN_batch_draw_range_ex(batch, 0, 0, false); - - GWN_batch_program_use_end(batch); -} - -void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool force_instance) -{ -#if TRUST_NO_ONE - assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance -#endif - const bool do_instance = (force_instance || batch->inst); - - // If using offset drawing, use the default VAO and redo bindings. - if (v_first != 0 && (do_instance || batch->elem)) { - glBindVertexArray(GWN_vao_default()); - batch_update_program_bindings(batch, v_first); - } - else { - glBindVertexArray(batch->vao_id); - } - - if (do_instance) { - /* Infer length if vertex count is not given */ - if (v_count == 0) { - v_count = batch->inst->vertex_len; - } - - if (batch->elem) { - const Gwn_IndexBuf* el = batch->elem; - - if (el->use_prim_restart) { - primitive_restart_enable(el); - } -#if GWN_TRACK_INDEX_RANGE - glDrawElementsInstancedBaseVertex(batch->gl_prim_type, - el->index_len, - el->gl_index_type, - 0, - v_count, - el->base_index); -#else - glDrawElementsInstanced(batch->gl_prim_type, el->index_len, GL_UNSIGNED_INT, 0, v_count); -#endif - if (el->use_prim_restart) { - primitive_restart_disable(); - } - } - else { - glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_len, v_count); - } - } - else { - /* Infer length if vertex count is not given */ - if (v_count == 0) { - v_count = (batch->elem) ? batch->elem->index_len : batch->verts[0]->vertex_len; - } - - if (batch->elem) { - const Gwn_IndexBuf* el = batch->elem; - - if (el->use_prim_restart) { - primitive_restart_enable(el); - } - -#if GWN_TRACK_INDEX_RANGE - if (el->base_index) { - glDrawRangeElementsBaseVertex(batch->gl_prim_type, - el->min_index, - el->max_index, - v_count, - el->gl_index_type, - 0, - el->base_index); - } - else { - glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, v_count, el->gl_index_type, 0); - } -#else - glDrawElements(batch->gl_prim_type, v_count, GL_UNSIGNED_INT, 0); -#endif - if (el->use_prim_restart) { - primitive_restart_disable(); - } - } - else { - glDrawArrays(batch->gl_prim_type, v_first, v_count); - } - } - - /* Performance hog if you are drawing with the same vao multiple time. - * Only activate for debugging. */ - // glBindVertexArray(0); -} - -/* just draw some vertices and let shader place them where we want. */ -void GWN_draw_primitive(Gwn_PrimType prim_type, int v_count) - { - /* we cannot draw without vao ... annoying ... */ - glBindVertexArray(GWN_vao_default()); - - GLenum type = convert_prim_type_to_gl(prim_type); - glDrawArrays(type, 0, v_count); - - /* Performance hog if you are drawing with the same vao multiple time. - * Only activate for debugging.*/ - // glBindVertexArray(0); - } diff --git a/intern/gawain/src/gwn_buffer_id.cpp b/intern/gawain/src/gwn_buffer_id.cpp deleted file mode 100644 index 2c267682f65..00000000000 --- a/intern/gawain/src/gwn_buffer_id.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_buffer_id.cpp - * \ingroup gpu - * - * Gawain buffer IDs - */ - -#include "gwn_buffer_id.h" -#include -#include - -#define ORPHAN_DEBUG 0 - -#if ORPHAN_DEBUG - #include -#endif - -static std::vector orphaned_buffer_ids; - -static std::mutex orphan_mutex; - -extern "C" { -extern int BLI_thread_is_main(void); /* Blender-specific function */ -} - -static bool thread_is_main() -{ - /* "main" here means the GL context's thread */ - return BLI_thread_is_main(); -} - -GLuint GWN_buf_id_alloc() -{ - /* delete orphaned IDs */ - orphan_mutex.lock(); - if (!orphaned_buffer_ids.empty()) { - const auto orphaned_buffer_len = (uint)orphaned_buffer_ids.size(); -#if ORPHAN_DEBUG - printf("deleting %u orphaned VBO%s\n", orphaned_buffer_len, orphaned_buffer_len == 1 ? "" : "s"); -#endif - glDeleteBuffers(orphaned_buffer_len, orphaned_buffer_ids.data()); - orphaned_buffer_ids.clear(); - } - orphan_mutex.unlock(); - - GLuint new_buffer_id = 0; - glGenBuffers(1, &new_buffer_id); - return new_buffer_id; -} - -void GWN_buf_id_free(GLuint buffer_id) -{ - if (thread_is_main()) { - glDeleteBuffers(1, &buffer_id); - } - else { - /* add this ID to the orphaned list */ - orphan_mutex.lock(); -#if ORPHAN_DEBUG - printf("orphaning VBO %u\n", buffer_id); -#endif - orphaned_buffer_ids.emplace_back(buffer_id); - orphan_mutex.unlock(); - } -} diff --git a/intern/gawain/src/gwn_element.c b/intern/gawain/src/gwn_element.c deleted file mode 100644 index a8c99f20860..00000000000 --- a/intern/gawain/src/gwn_element.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_element.c - * \ingroup gpu - * - * Gawain element list (AKA index buffer) - */ - -#include "gwn_element.h" -#include "gwn_buffer_id.h" -#include - -#define KEEP_SINGLE_COPY 1 - -static GLenum convert_index_type_to_gl(Gwn_IndexBufType type) -{ - static const GLenum table[] = { - [GWN_INDEX_U8] = GL_UNSIGNED_BYTE, /* GL has this, Vulkan does not */ - [GWN_INDEX_U16] = GL_UNSIGNED_SHORT, - [GWN_INDEX_U32] = GL_UNSIGNED_INT - }; - return table[type]; -} - -uint GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) -{ -#if GWN_TRACK_INDEX_RANGE - static const uint table[] = { - [GWN_INDEX_U8] = sizeof(GLubyte), /* GL has this, Vulkan does not */ - [GWN_INDEX_U16] = sizeof(GLushort), - [GWN_INDEX_U32] = sizeof(GLuint) - }; - return elem->index_len * table[elem->index_type]; -#else - return elem->index_len * sizeof(GLuint); -#endif -} - -void GWN_indexbuf_init_ex( - Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, - uint index_len, uint vertex_len, bool use_prim_restart) -{ - builder->use_prim_restart = use_prim_restart; - builder->max_allowed_index = vertex_len - 1; - builder->max_index_len = index_len; - builder->index_len = 0; // start empty - builder->prim_type = prim_type; - builder->data = calloc(builder->max_index_len, sizeof(uint)); -} - -void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uint prim_len, uint vertex_len) -{ - uint verts_per_prim = 0; - switch (prim_type) { - case GWN_PRIM_POINTS: - verts_per_prim = 1; - break; - case GWN_PRIM_LINES: - verts_per_prim = 2; - break; - case GWN_PRIM_TRIS: - verts_per_prim = 3; - break; - case GWN_PRIM_LINES_ADJ: - verts_per_prim = 4; - break; - default: -#if TRUST_NO_ONE - assert(false); -#endif - return; - } - - GWN_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); -} - -void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, uint v) -{ -#if TRUST_NO_ONE - assert(builder->data != NULL); - assert(builder->index_len < builder->max_index_len); - assert(v <= builder->max_allowed_index); -#endif - builder->data[builder->index_len++] = v; -} - -void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder* builder) -{ -#if TRUST_NO_ONE - assert(builder->data != NULL); - assert(builder->index_len < builder->max_index_len); - assert(builder->use_prim_restart); -#endif - builder->data[builder->index_len++] = GWN_PRIM_RESTART; -} - -void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, uint v) -{ -#if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_POINTS); -#endif - GWN_indexbuf_add_generic_vert(builder, v); -} - -void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2) -{ -#if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_LINES); - assert(v1 != v2); -#endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); -} - -void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3) -{ -#if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_TRIS); - assert(v1 != v2 && v2 != v3 && v3 != v1); -#endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); - GWN_indexbuf_add_generic_vert(builder, v3); -} - -void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3, uint v4) -{ -#if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_LINES_ADJ); - assert(v2 != v3); /* only the line need diff indices */ -#endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); - GWN_indexbuf_add_generic_vert(builder, v3); - GWN_indexbuf_add_generic_vert(builder, v4); -} - -#if GWN_TRACK_INDEX_RANGE -/* Everything remains 32 bit while building to keep things simple. - * Find min/max after, then convert to smallest index type possible. */ - -static uint index_range(const uint values[], uint value_len, uint* min_out, uint* max_out) -{ - if (value_len == 0) { - *min_out = 0; - *max_out = 0; - return 0; - } - uint min_value = values[0]; - uint max_value = values[0]; - for (uint i = 1; i < value_len; ++i) { - const uint value = values[i]; - if (value == GWN_PRIM_RESTART) - continue; - else if (value < min_value) - min_value = value; - else if (value > max_value) - max_value = value; - } - *min_out = min_value; - *max_out = max_value; - return max_value - min_value; -} - -static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) -{ - const uint *values = builder->data; - const uint index_len = elem->index_len; - - /* data will never be *larger* than builder->data... - * converting in place to avoid extra allocation */ - GLubyte *data = (GLubyte *)builder->data; - - if (elem->max_index > 0xFF) { - const uint base = elem->min_index; - elem->base_index = base; - elem->min_index = 0; - elem->max_index -= base; - for (uint i = 0; i < index_len; ++i) { - data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); - } - } - else { - elem->base_index = 0; - for (uint i = 0; i < index_len; ++i) { - data[i] = (GLubyte)(values[i]); - } - } -} - -static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) -{ - const uint *values = builder->data; - const uint index_len = elem->index_len; - - /* data will never be *larger* than builder->data... - * converting in place to avoid extra allocation */ - GLushort *data = (GLushort *)builder->data; - - if (elem->max_index > 0xFFFF) { - const uint base = elem->min_index; - elem->base_index = base; - elem->min_index = 0; - elem->max_index -= base; - for (uint i = 0; i < index_len; ++i) { - data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); - } - } - else { - elem->base_index = 0; - for (uint i = 0; i < index_len; ++i) { - data[i] = (GLushort)(values[i]); - } - } -} - -#endif /* GWN_TRACK_INDEX_RANGE */ - -Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder* builder) -{ - Gwn_IndexBuf* elem = calloc(1, sizeof(Gwn_IndexBuf)); - GWN_indexbuf_build_in_place(builder, elem); - return elem; -} - -void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* elem) -{ -#if TRUST_NO_ONE - assert(builder->data != NULL); -#endif - elem->index_len = builder->index_len; - elem->use_prim_restart = builder->use_prim_restart; - -#if GWN_TRACK_INDEX_RANGE - uint range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index); - - /* count the primitive restart index. */ - if (elem->use_prim_restart) { - range += 1; - } - - if (range <= 0xFF) { - elem->index_type = GWN_INDEX_U8; - squeeze_indices_byte(builder, elem); - } - else if (range <= 0xFFFF) { - elem->index_type = GWN_INDEX_U16; - squeeze_indices_short(builder, elem); - } - else { - elem->index_type = GWN_INDEX_U32; - elem->base_index = 0; - } - elem->gl_index_type = convert_index_type_to_gl(elem->index_type); -#endif - - if (elem->vbo_id == 0) { - elem->vbo_id = GWN_buf_id_alloc(); - } - /* send data to GPU */ - /* GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound, - * so we use the GL_ARRAY_BUFFER here to create a buffer without - * interfering in the VAO state. */ - glBindBuffer(GL_ARRAY_BUFFER, elem->vbo_id); - glBufferData(GL_ARRAY_BUFFER, GWN_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW); - - /* discard builder (one-time use) */ - free(builder->data); - builder->data = NULL; - /* other fields are safe to leave */ -} - -void GWN_indexbuf_use(Gwn_IndexBuf* elem) -{ - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id); -} - -void GWN_indexbuf_discard(Gwn_IndexBuf* elem) -{ - if (elem->vbo_id) { - GWN_buf_id_free(elem->vbo_id); - } - free(elem); -} diff --git a/intern/gawain/src/gwn_imm_util.c b/intern/gawain/src/gwn_imm_util.c deleted file mode 100644 index cdf55c3dfc4..00000000000 --- a/intern/gawain/src/gwn_imm_util.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_imm_util.c - * \ingroup gpu - * - * Gawain immediate mode drawing utilities - */ - -#include "gwn_imm_util.h" -#include "gwn_immediate.h" -#include - -void immRectf(uint pos, float x1, float y1, float x2, float y2) -{ - immBegin(GWN_PRIM_TRI_FAN, 4); - immVertex2f(pos, x1, y1); - immVertex2f(pos, x2, y1); - immVertex2f(pos, x2, y2); - immVertex2f(pos, x1, y2); - immEnd(); -} - -void immRecti(uint pos, int x1, int y1, int x2, int y2) -{ - immBegin(GWN_PRIM_TRI_FAN, 4); - immVertex2i(pos, x1, y1); - immVertex2i(pos, x2, y1); - immVertex2i(pos, x2, y2); - immVertex2i(pos, x1, y2); - immEnd(); -} - -void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]) -{ - immAttrib4fv(col, color); - immVertex2f(pos, x1, y1); - immAttrib4fv(col, color); - immVertex2f(pos, x2, y1); - immAttrib4fv(col, color); - immVertex2f(pos, x2, y2); - - immAttrib4fv(col, color); - immVertex2f(pos, x1, y1); - immAttrib4fv(col, color); - immVertex2f(pos, x2, y2); - immAttrib4fv(col, color); - immVertex2f(pos, x1, y2); -} - -void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]) -{ - immAttrib4fv(col, color); - immVertex2i(pos, x1, y1); - immAttrib4fv(col, color); - immVertex2i(pos, x2, y1); - immAttrib4fv(col, color); - immVertex2i(pos, x2, y2); - - immAttrib4fv(col, color); - immVertex2i(pos, x1, y1); - immAttrib4fv(col, color); - immVertex2i(pos, x2, y2); - immAttrib4fv(col, color); - immVertex2i(pos, x1, y2); -} - -#if 0 /* more complete version in case we want that */ -void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4]) -{ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = add_attrib(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4fv(color); - immRecti(pos, x1, y1, x2, y2); - immUnbindProgram(); -} -#endif diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c deleted file mode 100644 index 442aa85ece4..00000000000 --- a/intern/gawain/src/gwn_immediate.c +++ /dev/null @@ -1,863 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_immediate.c - * \ingroup gpu - * - * Gawain immediate mode work-alike - */ - -#include "gwn_immediate.h" -#include "gwn_buffer_id.h" -#include "gwn_attr_binding.h" -#include "gwn_attr_binding_private.h" -#include "gwn_vertex_format_private.h" -#include "gwn_vertex_array_id.h" -#include "gwn_primitive_private.h" -#include -#include - -/* necessary functions from matrix API */ -extern void GPU_matrix_bind(const Gwn_ShaderInterface*); -extern bool GPU_matrix_dirty_get(void); - -typedef struct { - /* TODO: organize this struct by frequency of change (run-time) */ - - Gwn_Batch* batch; - Gwn_Context* context; - - /* current draw call */ - GLubyte* buffer_data; - uint buffer_offset; - uint buffer_bytes_mapped; - uint vertex_len; - bool strict_vertex_len; - Gwn_PrimType prim_type; - - Gwn_VertFormat vertex_format; - - /* current vertex */ - uint vertex_idx; - GLubyte* vertex_data; - uint16_t unassigned_attrib_bits; /* which attributes of current vertex have not been given values? */ - - GLuint vbo_id; - GLuint vao_id; - - GLuint bound_program; - const Gwn_ShaderInterface* shader_interface; - Gwn_AttrBinding attrib_binding; - uint16_t prev_enabled_attrib_bits; /* <-- only affects this VAO, so we're ok */ -} Immediate; - -/* size of internal buffer -- make this adjustable? */ -#define IMM_BUFFER_SIZE (4 * 1024 * 1024) - -static bool initialized = false; -static Immediate imm; - -void immInit(void) -{ -#if TRUST_NO_ONE - assert(!initialized); -#endif - memset(&imm, 0, sizeof(Immediate)); - - imm.vbo_id = GWN_buf_id_alloc(); - glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); - glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); - - imm.prim_type = GWN_PRIM_NONE; - imm.strict_vertex_len = true; - - glBindBuffer(GL_ARRAY_BUFFER, 0); - initialized = true; -} - -void immActivate(void) -{ -#if TRUST_NO_ONE - assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ - assert(imm.vao_id == 0); -#endif - imm.vao_id = GWN_vao_alloc(); - imm.context = GWN_context_active_get(); -} - -void immDeactivate(void) -{ -#if TRUST_NO_ONE - assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ - assert(imm.vao_id != 0); -#endif - GWN_vao_free(imm.vao_id, imm.context); - imm.vao_id = 0; - imm.prev_enabled_attrib_bits = 0; -} - -void immDestroy(void) -{ - GWN_buf_id_free(imm.vbo_id); - initialized = false; -} - -Gwn_VertFormat* immVertexFormat(void) -{ - GWN_vertformat_clear(&imm.vertex_format); - return &imm.vertex_format; -} - -void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface) -{ -#if TRUST_NO_ONE - assert(imm.bound_program == 0); - assert(glIsProgram(program)); -#endif - - imm.bound_program = program; - imm.shader_interface = shaderface; - - if (!imm.vertex_format.packed) - VertexFormat_pack(&imm.vertex_format); - - glUseProgram(program); - get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface); - GPU_matrix_bind(shaderface); -} - -void immUnbindProgram(void) -{ -#if TRUST_NO_ONE - assert(imm.bound_program != 0); -#endif -#if PROGRAM_NO_OPTI - glUseProgram(0); -#endif - imm.bound_program = 0; -} - -#if TRUST_NO_ONE -static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType prim_type) -{ - /* does vertex_len make sense for this primitive type? */ - if (vertex_len == 0) { - return false; - } - - switch (prim_type) { - case GWN_PRIM_POINTS: - return true; - case GWN_PRIM_LINES: - return vertex_len % 2 == 0; - case GWN_PRIM_LINE_STRIP: - case GWN_PRIM_LINE_LOOP: - return vertex_len >= 2; - case GWN_PRIM_LINE_STRIP_ADJ: - return vertex_len >= 4; - case GWN_PRIM_TRIS: - return vertex_len % 3 == 0; - case GWN_PRIM_TRI_STRIP: - case GWN_PRIM_TRI_FAN: - return vertex_len >= 3; - default: - return false; - } -} -#endif - -void immBegin(Gwn_PrimType prim_type, uint vertex_len) -{ -#if TRUST_NO_ONE - assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ - assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); -#endif - imm.prim_type = prim_type; - imm.vertex_len = vertex_len; - imm.vertex_idx = 0; - imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; - - /* how many bytes do we need for this draw call? */ - const uint bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_len); - -#if TRUST_NO_ONE - assert(bytes_needed <= IMM_BUFFER_SIZE); -#endif - - glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); - - /* does the current buffer have enough room? */ - const uint available_bytes = IMM_BUFFER_SIZE - imm.buffer_offset; - /* ensure vertex data is aligned */ - const uint pre_padding = padding(imm.buffer_offset, imm.vertex_format.stride); /* might waste a little space, but it's safe */ - if ((bytes_needed + pre_padding) <= available_bytes) { - imm.buffer_offset += pre_padding; - } - else { - /* orphan this buffer & start with a fresh one */ - /* this method works on all platforms, old & new */ - glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); - - imm.buffer_offset = 0; - } - -/* printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1); */ - - imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, bytes_needed, - GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_len ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)); - -#if TRUST_NO_ONE - assert(imm.buffer_data != NULL); -#endif - - imm.buffer_bytes_mapped = bytes_needed; - imm.vertex_data = imm.buffer_data; -} - -void immBeginAtMost(Gwn_PrimType prim_type, uint vertex_len) -{ -#if TRUST_NO_ONE - assert(vertex_len > 0); -#endif - - imm.strict_vertex_len = false; - immBegin(prim_type, vertex_len); -} - - -Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, uint vertex_len) -{ -#if TRUST_NO_ONE - assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ - assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); -#endif - imm.prim_type = prim_type; - imm.vertex_len = vertex_len; - imm.vertex_idx = 0; - imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; - - Gwn_VertBuf* verts = GWN_vertbuf_create_with_format(&imm.vertex_format); - GWN_vertbuf_data_alloc(verts, vertex_len); - - imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts); - imm.vertex_data = verts->data; - - imm.batch = GWN_batch_create_ex(prim_type, verts, NULL, GWN_BATCH_OWNS_VBO); - imm.batch->phase = GWN_BATCH_BUILDING; - - return imm.batch; -} - -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, uint vertex_len) -{ - imm.strict_vertex_len = false; - return immBeginBatch(prim_type, vertex_len); -} - -static void immDrawSetup(void) -{ - /* set up VAO -- can be done during Begin or End really */ - glBindVertexArray(imm.vao_id); - - /* enable/disable vertex attribs as needed */ - if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits) { - for (uint loc = 0; loc < GWN_VERT_ATTR_MAX_LEN; ++loc) { - bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc); - bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc); - - if (is_enabled && !was_enabled) { - glEnableVertexAttribArray(loc); - } - else if (was_enabled && !is_enabled) { - glDisableVertexAttribArray(loc); - } - } - - imm.prev_enabled_attrib_bits = imm.attrib_binding.enabled_bits; - } - - const uint stride = imm.vertex_format.stride; - - for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { - const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; - - const uint offset = imm.buffer_offset + a->offset; - const GLvoid* pointer = (const GLubyte*)0 + offset; - - const uint loc = read_attrib_location(&imm.attrib_binding, a_idx); - - switch (a->fetch_mode) { - case GWN_FETCH_FLOAT: - case GWN_FETCH_INT_TO_FLOAT: - glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); - break; - case GWN_FETCH_INT_TO_FLOAT_UNIT: - glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); - break; - case GWN_FETCH_INT: - glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer); - } - } - - if (GPU_matrix_dirty_get()) { - GPU_matrix_bind(imm.shader_interface); - } -} - -void immEnd(void) -{ -#if TRUST_NO_ONE - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - - uint buffer_bytes_used; - if (imm.strict_vertex_len) { -#if TRUST_NO_ONE - assert(imm.vertex_idx == imm.vertex_len); /* with all vertices defined */ -#endif - buffer_bytes_used = imm.buffer_bytes_mapped; - } - else { -#if TRUST_NO_ONE - assert(imm.vertex_idx <= imm.vertex_len); -#endif - if (imm.vertex_idx == imm.vertex_len) { - buffer_bytes_used = imm.buffer_bytes_mapped; - } - else { -#if TRUST_NO_ONE - assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type)); -#endif - imm.vertex_len = imm.vertex_idx; - buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_len); - /* unused buffer bytes are available to the next immBegin */ - } - /* tell OpenGL what range was modified so it doesn't copy the whole mapped range */ - glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, buffer_bytes_used); - } - - if (imm.batch) { - if (buffer_bytes_used != imm.buffer_bytes_mapped) { - GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); - /* TODO: resize only if vertex count is much smaller */ - } - GWN_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface); - imm.batch->phase = GWN_BATCH_READY_TO_DRAW; - imm.batch = NULL; /* don't free, batch belongs to caller */ - } - else { - glUnmapBuffer(GL_ARRAY_BUFFER); - if (imm.vertex_len > 0) { - immDrawSetup(); - glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_len); - } - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); - /* prep for next immBegin */ - imm.buffer_offset += buffer_bytes_used; - } - - /* prep for next immBegin */ - imm.prim_type = GWN_PRIM_NONE; - imm.strict_vertex_len = true; -} - -static void setAttribValueBit(uint attrib_id) -{ - uint16_t mask = 1 << attrib_id; -#if TRUST_NO_ONE - assert(imm.unassigned_attrib_bits & mask); /* not already set */ -#endif - imm.unassigned_attrib_bits &= ~mask; -} - - -/* --- generic attribute functions --- */ - -void immAttrib1f(uint attrib_id, float x) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_len == 1); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - float* data = (float*)(imm.vertex_data + attrib->offset); -/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ - - data[0] = x; -} - -void immAttrib2f(uint attrib_id, float x, float y) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_len == 2); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - float* data = (float*)(imm.vertex_data + attrib->offset); -/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ - - data[0] = x; - data[1] = y; -} - -void immAttrib3f(uint attrib_id, float x, float y, float z) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_len == 3); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - float* data = (float*)(imm.vertex_data + attrib->offset); -/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ - - data[0] = x; - data[1] = y; - data[2] = z; -} - -void immAttrib4f(uint attrib_id, float x, float y, float z, float w) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_len == 4); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - float* data = (float*)(imm.vertex_data + attrib->offset); -/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ - - data[0] = x; - data[1] = y; - data[2] = z; - data[3] = w; -} - -void immAttrib1u(uint attrib_id, uint x) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U32); - assert(attrib->comp_len == 1); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - uint* data = (uint*)(imm.vertex_data + attrib->offset); - - data[0] = x; -} - -void immAttrib2i(uint attrib_id, int x, int y) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_I32); - assert(attrib->comp_len == 2); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - int* data = (int*)(imm.vertex_data + attrib->offset); - - data[0] = x; - data[1] = y; -} - -void immAttrib2s(uint attrib_id, short x, short y) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_I16); - assert(attrib->comp_len == 2); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - short* data = (short*)(imm.vertex_data + attrib->offset); - - data[0] = x; - data[1] = y; -} - -void immAttrib2fv(uint attrib_id, const float data[2]) -{ - immAttrib2f(attrib_id, data[0], data[1]); -} - -void immAttrib3fv(uint attrib_id, const float data[3]) -{ - immAttrib3f(attrib_id, data[0], data[1], data[2]); -} - -void immAttrib4fv(uint attrib_id, const float data[4]) -{ - immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]); -} - -void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U8); - assert(attrib->comp_len == 3); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - GLubyte* data = imm.vertex_data + attrib->offset; -/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */ - - data[0] = r; - data[1] = g; - data[2] = b; -} - -void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a) -{ - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U8); - assert(attrib->comp_len == 4); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); - - GLubyte* data = imm.vertex_data + attrib->offset; -/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */ - - data[0] = r; - data[1] = g; - data[2] = b; - data[3] = a; -} - -void immAttrib3ubv(uint attrib_id, const unsigned char data[3]) -{ - immAttrib3ub(attrib_id, data[0], data[1], data[2]); -} - -void immAttrib4ubv(uint attrib_id, const unsigned char data[4]) -{ - immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]); -} - -void immSkipAttrib(uint attrib_id) -{ -#if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attr_len); - assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ -#endif - setAttribValueBit(attrib_id); -} - -static void immEndVertex(void) /* and move on to the next vertex */ -{ -#if TRUST_NO_ONE - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ - assert(imm.vertex_idx < imm.vertex_len); -#endif - - /* have all attribs been assigned values? - * if not, copy value from previous vertex */ - if (imm.unassigned_attrib_bits) { -#if TRUST_NO_ONE - assert(imm.vertex_idx > 0); /* first vertex must have all attribs specified */ -#endif - for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { - if ((imm.unassigned_attrib_bits >> a_idx) & 1) { - const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; - -/* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */ - - GLubyte* data = imm.vertex_data + a->offset; - memcpy(data, data - imm.vertex_format.stride, a->sz); - /* TODO: consolidate copy of adjacent attributes */ - } - } - } - - imm.vertex_idx++; - imm.vertex_data += imm.vertex_format.stride; - imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; -} - -void immVertex2f(uint attrib_id, float x, float y) -{ - immAttrib2f(attrib_id, x, y); - immEndVertex(); -} - -void immVertex3f(uint attrib_id, float x, float y, float z) -{ - immAttrib3f(attrib_id, x, y, z); - immEndVertex(); -} - -void immVertex4f(uint attrib_id, float x, float y, float z, float w) -{ - immAttrib4f(attrib_id, x, y, z, w); - immEndVertex(); -} - -void immVertex2i(uint attrib_id, int x, int y) -{ - immAttrib2i(attrib_id, x, y); - immEndVertex(); -} - -void immVertex2s(uint attrib_id, short x, short y) -{ - immAttrib2s(attrib_id, x, y); - immEndVertex(); -} - -void immVertex2fv(uint attrib_id, const float data[2]) -{ - immAttrib2f(attrib_id, data[0], data[1]); - immEndVertex(); -} - -void immVertex3fv(uint attrib_id, const float data[3]) -{ - immAttrib3f(attrib_id, data[0], data[1], data[2]); - immEndVertex(); -} - -void immVertex2iv(uint attrib_id, const int data[2]) -{ - immAttrib2i(attrib_id, data[0], data[1]); - immEndVertex(); -} - - -/* --- generic uniform functions --- */ - -#if 0 - #if TRUST_NO_ONE - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); assert(uniform); - #else - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); - #endif -#else - /* NOTE: It is possible to have uniform fully optimized out from the shader. - * In this case we can't assert failure or allow NULL-pointer dereference. - * TODO(sergey): How can we detect existing-but-optimized-out uniform but still - * catch typos in uniform names passed to immUniform*() functions? */ - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; -#endif - -void immUniform1f(const char* name, float x) -{ - GET_UNIFORM - glUniform1f(uniform->location, x); -} - -void immUniform2f(const char* name, float x, float y) -{ - GET_UNIFORM - glUniform2f(uniform->location, x, y); -} - -void immUniform2fv(const char* name, const float data[2]) -{ - GET_UNIFORM - glUniform2fv(uniform->location, 1, data); -} - -void immUniform3f(const char* name, float x, float y, float z) -{ - GET_UNIFORM - glUniform3f(uniform->location, x, y, z); -} - -void immUniform3fv(const char* name, const float data[3]) -{ - GET_UNIFORM - glUniform3fv(uniform->location, 1, data); -} - -/* can increase this limit or move to another file */ -#define MAX_UNIFORM_NAME_LEN 60 - -void immUniformArray3fv(const char* bare_name, const float *data, int count) -{ - /* look up "name[0]" when given "name" */ - const size_t len = strlen(bare_name); -#if TRUST_NO_ONE - assert(len <= MAX_UNIFORM_NAME_LEN); -#endif - char name[MAX_UNIFORM_NAME_LEN]; - strcpy(name, bare_name); - name[len + 0] = '['; - name[len + 1] = '0'; - name[len + 2] = ']'; - name[len + 3] = '\0'; - - GET_UNIFORM - glUniform3fv(uniform->location, count, data); -} - -void immUniform4f(const char* name, float x, float y, float z, float w) -{ - GET_UNIFORM - glUniform4f(uniform->location, x, y, z, w); -} - -void immUniform4fv(const char* name, const float data[4]) -{ - GET_UNIFORM - glUniform4fv(uniform->location, 1, data); -} - -void immUniformArray4fv(const char* bare_name, const float *data, int count) -{ - /* look up "name[0]" when given "name" */ - const size_t len = strlen(bare_name); -#if TRUST_NO_ONE - assert(len <= MAX_UNIFORM_NAME_LEN); -#endif - char name[MAX_UNIFORM_NAME_LEN]; - strcpy(name, bare_name); - name[len + 0] = '['; - name[len + 1] = '0'; - name[len + 2] = ']'; - name[len + 3] = '\0'; - - GET_UNIFORM - glUniform4fv(uniform->location, count, data); -} - -void immUniformMatrix4fv(const char* name, const float data[4][4]) -{ - GET_UNIFORM - glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (float *)data); -} - -void immUniform1i(const char* name, int x) -{ - GET_UNIFORM - glUniform1i(uniform->location, x); -} - -void immUniform4iv(const char* name, const int data[4]) -{ - GET_UNIFORM - glUniform4iv(uniform->location, 1, data); -} - -/* --- convenience functions for setting "uniform vec4 color" --- */ - -void immUniformColor4f(float r, float g, float b, float a) -{ - const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform_builtin(imm.shader_interface, GWN_UNIFORM_COLOR); -#if TRUST_NO_ONE - assert(uniform != NULL); -#endif - glUniform4f(uniform->location, r, g, b, a); -} - -void immUniformColor4fv(const float rgba[4]) -{ - immUniformColor4f(rgba[0], rgba[1], rgba[2], rgba[3]); -} - -void immUniformColor3f(float r, float g, float b) -{ - immUniformColor4f(r, g, b, 1.0f); -} - -void immUniformColor3fv(const float rgb[3]) -{ - immUniformColor4f(rgb[0], rgb[1], rgb[2], 1.0f); -} - -void immUniformColor3fvAlpha(const float rgb[3], float a) -{ - immUniformColor4f(rgb[0], rgb[1], rgb[2], a); -} - -/* TODO: v-- treat as sRGB? --v */ - -void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b) -{ - const float scale = 1.0f / 255.0f; - immUniformColor4f(scale * r, scale * g, scale * b, 1.0f); -} - -void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) -{ - const float scale = 1.0f / 255.0f; - immUniformColor4f(scale * r, scale * g, scale * b, scale * a); -} - -void immUniformColor3ubv(const unsigned char rgb[3]) -{ - immUniformColor3ub(rgb[0], rgb[1], rgb[2]); -} - -void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char alpha) -{ - immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha); -} - -void immUniformColor4ubv(const unsigned char rgba[4]) -{ - immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]); -} diff --git a/intern/gawain/src/gwn_primitive.c b/intern/gawain/src/gwn_primitive.c deleted file mode 100644 index bec638a4972..00000000000 --- a/intern/gawain/src/gwn_primitive.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_primitive.c - * \ingroup gpu - * - * Gawain geometric primitives - */ - -#include "gwn_primitive.h" -#include "gwn_primitive_private.h" - -Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type) -{ - static const Gwn_PrimClass classes[] = { - [GWN_PRIM_POINTS] = GWN_PRIM_CLASS_POINT, - [GWN_PRIM_LINES] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_STRIP] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_LOOP] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_TRIS] = GWN_PRIM_CLASS_SURFACE, - [GWN_PRIM_TRI_STRIP] = GWN_PRIM_CLASS_SURFACE, - [GWN_PRIM_TRI_FAN] = GWN_PRIM_CLASS_SURFACE, - - [GWN_PRIM_LINES_ADJ] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_TRIS_ADJ] = GWN_PRIM_CLASS_SURFACE, - - [GWN_PRIM_NONE] = GWN_PRIM_CLASS_NONE - }; - - return classes[prim_type]; -} - -bool GWN_primtype_belongs_to_class(Gwn_PrimType prim_type, Gwn_PrimClass prim_class) -{ - if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE) { - return true; - } - return prim_class & GWN_primtype_class(prim_type); -} - -GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type) -{ -#if TRUST_NO_ONE - assert(prim_type != GWN_PRIM_NONE); -#endif - static const GLenum table[] = { - [GWN_PRIM_POINTS] = GL_POINTS, - [GWN_PRIM_LINES] = GL_LINES, - [GWN_PRIM_LINE_STRIP] = GL_LINE_STRIP, - [GWN_PRIM_LINE_LOOP] = GL_LINE_LOOP, - [GWN_PRIM_TRIS] = GL_TRIANGLES, - [GWN_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP, - [GWN_PRIM_TRI_FAN] = GL_TRIANGLE_FAN, - - [GWN_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY, - [GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY, - [GWN_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY, - }; - - return table[prim_type]; -} diff --git a/intern/gawain/src/gwn_shader_interface.c b/intern/gawain/src/gwn_shader_interface.c deleted file mode 100644 index 997d5215d5b..00000000000 --- a/intern/gawain/src/gwn_shader_interface.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_shader_interface.c - * \ingroup gpu - * - * Gawain shader interface (C --> GLSL) - */ - -#include "gwn_batch_private.h" -#include "gwn_shader_interface.h" -#include "gwn_vertex_array_id.h" -#include -#include -#include - -#define DEBUG_SHADER_INTERFACE 0 - -#if DEBUG_SHADER_INTERFACE - #include -#endif - -static const char* BuiltinUniform_name(Gwn_UniformBuiltin u) -{ - static const char* names[] = { - [GWN_UNIFORM_NONE] = NULL, - - [GWN_UNIFORM_MODEL] = "ModelMatrix", - [GWN_UNIFORM_VIEW] = "ViewMatrix", - [GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix", - [GWN_UNIFORM_PROJECTION] = "ProjectionMatrix", - [GWN_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix", - [GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix", - - [GWN_UNIFORM_MODEL_INV] = "ModelMatrixInverse", - [GWN_UNIFORM_VIEW_INV] = "ViewMatrixInverse", - [GWN_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse", - [GWN_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse", - [GWN_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse", - - [GWN_UNIFORM_NORMAL] = "NormalMatrix", - [GWN_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix", - [GWN_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors", - [GWN_UNIFORM_ORCO] = "OrcoTexCoFactors", - - [GWN_UNIFORM_COLOR] = "color", - [GWN_UNIFORM_EYE] = "eye", - [GWN_UNIFORM_CALLID] = "callId", - - [GWN_UNIFORM_CUSTOM] = NULL, - [GWN_NUM_UNIFORMS] = NULL, - }; - - return names[u]; -} - -GWN_INLINE bool match(const char* a, const char* b) -{ - return strcmp(a, b) == 0; -} - -GWN_INLINE uint hash_string(const char *str) -{ - uint i = 0, c; - while ((c = *str++)) { - i = i * 37 + c; - } - return i; -} - -GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* input, - const char* name, uint32_t name_len) -{ - input->name_offset = shaderface->name_buffer_offset; - input->name_hash = hash_string(name); - shaderface->name_buffer_offset += name_len + 1; /* include NULL terminator */ -} - -GWN_INLINE void shader_input_to_bucket(Gwn_ShaderInput* input, - Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) -{ - const uint bucket_index = input->name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; - input->next = buckets[bucket_index]; - buckets[bucket_index] = input; -} - -GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[GWN_NUM_SHADERINTERFACE_BUCKETS], - const char *name_buffer, const char *name) -{ - const uint name_hash = hash_string(name); - const uint bucket_index = name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; - const Gwn_ShaderInput* input = buckets[bucket_index]; - if (input == NULL) { - /* Requested uniform is not found at all. */ - return NULL; - } - /* Optimization bit: if there is no hash collision detected when constructing shader interface - * it means we can only request the single possible uniform. Surely, it's possible we request - * uniform which causes hash collision, but that will be detected in debug builds. */ - if (input->next == NULL) { - if (name_hash == input->name_hash) { -#if TRUST_NO_ONE - assert(match(name_buffer + input->name_offset, name)); -#endif - return input; - } - return NULL; - } - /* Work through possible collisions. */ - const Gwn_ShaderInput* next = input; - while (next != NULL) { - input = next; - next = input->next; - if (input->name_hash != name_hash) { - continue; - } - if (match(name_buffer + input->name_offset, name)) { - return input; - } - } - return NULL; /* not found */ -} - -GWN_INLINE void buckets_free(Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) -{ - for (uint bucket_index = 0; bucket_index < GWN_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) { - Gwn_ShaderInput *input = buckets[bucket_index]; - while (input != NULL) { - Gwn_ShaderInput *input_next = input->next; - free(input); - input = input_next; - } - } -} - -static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name) -{ - /* TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types */ - - /* detect built-in uniforms (name must match) */ - for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { - const char* builtin_name = BuiltinUniform_name(u); - if (match(name, builtin_name)) { - input->builtin_type = u; - return true; - } - } - input->builtin_type = GWN_UNIFORM_CUSTOM; - return false; -} - -static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const char* name) -{ - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); - - input->location = glGetUniformLocation(shaderface->program, name); - - uint name_len = strlen(name); - shaderface->name_buffer = realloc(shaderface->name_buffer, shaderface->name_buffer_offset + name_len + 1); /* include NULL terminator */ - char* name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset; - strcpy(name_buffer, name); - - set_input_name(shaderface, input, name, name_len); - setup_builtin_uniform(input, name); - - shader_input_to_bucket(input, shaderface->uniform_buckets); - if (input->builtin_type != GWN_UNIFORM_NONE && - input->builtin_type != GWN_UNIFORM_CUSTOM) - { - shaderface->builtin_uniforms[input->builtin_type] = input; - } -#if DEBUG_SHADER_INTERFACE - printf("Gwn_ShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, - shaderface->program, - name, - input->location); -#endif - return input; -} - -Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) -{ - Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface)); - shaderface->program = program; - -#if DEBUG_SHADER_INTERFACE - printf("%s {\n", __func__); /* enter function */ - printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program); -#endif - - GLint max_attrib_name_len, attr_len; - glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len); - glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attr_len); - - GLint max_ubo_name_len, ubo_len; - glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len); - glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_len); - - const uint32_t name_buffer_len = attr_len * max_attrib_name_len + ubo_len * max_ubo_name_len; - shaderface->name_buffer = malloc(name_buffer_len); - - /* Attributes */ - for (uint32_t i = 0; i < attr_len; ++i) { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); - GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; - char* name = shaderface->name_buffer + shaderface->name_buffer_offset; - GLsizei name_len = 0; - - glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name); - - /* remove "[0]" from array name */ - if (name[name_len-1] == ']') { - name[name_len-3] = '\0'; - name_len -= 3; - } - - /* TODO: reject DOUBLE gl_types */ - - input->location = glGetAttribLocation(program, name); - - set_input_name(shaderface, input, name, name_len); - - shader_input_to_bucket(input, shaderface->attrib_buckets); - -#if DEBUG_SHADER_INTERFACE - printf("attrib[%u] '%s' at location %d\n", i, name, input->location); -#endif - } - /* Uniform Blocks */ - for (uint32_t i = 0; i < ubo_len; ++i) { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); - GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; - char* name = shaderface->name_buffer + shaderface->name_buffer_offset; - GLsizei name_len = 0; - - glGetActiveUniformBlockName(program, i, remaining_buffer, &name_len, name); - - input->location = i; - - set_input_name(shaderface, input, name, name_len); - - shader_input_to_bucket(input, shaderface->ubo_buckets); - -#if DEBUG_SHADER_INTERFACE - printf("ubo '%s' at location %d\n", name, input->location); -#endif - } - /* Builtin Uniforms */ - for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { - const char* builtin_name = BuiltinUniform_name(u); - if (glGetUniformLocation(program, builtin_name) != -1) { - add_uniform((Gwn_ShaderInterface*)shaderface, builtin_name); - } - } - /* Batches ref buffer */ - shaderface->batches_len = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = calloc(shaderface->batches_len, sizeof(Gwn_Batch*)); - - return shaderface; -} - -void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) -{ - /* Free memory used by buckets and has entries. */ - buckets_free(shaderface->uniform_buckets); - buckets_free(shaderface->attrib_buckets); - buckets_free(shaderface->ubo_buckets); - /* Free memory used by name_buffer. */ - free(shaderface->name_buffer); - /* Remove this interface from all linked Batches vao cache. */ - for (int i = 0; i < shaderface->batches_len; ++i) { - if (shaderface->batches[i] != NULL) { - gwn_batch_remove_interface_ref(shaderface->batches[i], shaderface); - } - } - free(shaderface->batches); - /* Free memory used by shader interface by its self. */ - free(shaderface); -} - -const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name) -{ - /* TODO: Warn if we find a matching builtin, since these can be looked up much quicker. */ - const Gwn_ShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); - /* If input is not found add it so it's found next time. */ - if (input == NULL) { - input = add_uniform((Gwn_ShaderInterface*)shaderface, name); - } - return (input->location != -1) ? input : NULL; -} - -const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin( - const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin) -{ -#if TRUST_NO_ONE - assert(builtin != GWN_UNIFORM_NONE); - assert(builtin != GWN_UNIFORM_CUSTOM); - assert(builtin != GWN_NUM_UNIFORMS); -#endif - return shaderface->builtin_uniforms[builtin]; -} - -const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface* shaderface, const char* name) -{ - return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name); -} - -const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name) -{ - return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name); -} - -void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) -{ - int i; /* find first unused slot */ - for (i = 0; i < shaderface->batches_len; ++i) { - if (shaderface->batches[i] == NULL) { - break; - } - } - if (i == shaderface->batches_len) { - /* Not enough place, realloc the array. */ - i = shaderface->batches_len; - shaderface->batches_len += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_len); - memset(shaderface->batches + i, 0, sizeof(Gwn_Batch*) * GWN_SHADERINTERFACE_REF_ALLOC_COUNT); - } - shaderface->batches[i] = batch; -} - -void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) -{ - for (int i = 0; i < shaderface->batches_len; ++i) { - if (shaderface->batches[i] == batch) { - shaderface->batches[i] = NULL; - break; /* cannot have duplicates */ - } - } -} diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp deleted file mode 100644 index 04470bf6844..00000000000 --- a/intern/gawain/src/gwn_vertex_array_id.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation, Clément Foucault - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/gwn_vertex_array_id.cpp - * \ingroup gpu - * - * Manage GL vertex array IDs in a thread-safe way - * Use these instead of glGenBuffers & its friends - * - alloc must be called from a thread that is bound - * to the context that will be used for drawing with - * this vao. - * - free can be called from any thread - */ - -#include "gwn_batch_private.h" -#include "gwn_vertex_array_id.h" -#include "gwn_context.h" -#include -#include -#include -#include -#include - -#if TRUST_NO_ONE -#if 0 -extern "C" { -extern int BLI_thread_is_main(void); /* Blender-specific function */ -} - -static bool thread_is_main() { - /* "main" here means the GL context's thread */ - return BLI_thread_is_main(); -} -#endif -#endif - -struct Gwn_Context { - GLuint default_vao; - std::unordered_set batches; /* Batches that have VAOs from this context */ - std::vector orphaned_vertarray_ids; - std::mutex orphans_mutex; /* todo: try spinlock instead */ -#if TRUST_NO_ONE - pthread_t thread; /* Thread on which this context is active. */ - bool thread_is_used; - - Gwn_Context() { - thread_is_used = false; - } -#endif -}; - -#if defined(_MSC_VER) && (_MSC_VER == 1800) -#define thread_local __declspec(thread) -thread_local Gwn_Context* active_ctx = NULL; -#else -static thread_local Gwn_Context* active_ctx = NULL; -#endif - -static void clear_orphans(Gwn_Context* ctx) -{ - ctx->orphans_mutex.lock(); - if (!ctx->orphaned_vertarray_ids.empty()) { - uint orphan_len = (uint)ctx->orphaned_vertarray_ids.size(); - glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data()); - ctx->orphaned_vertarray_ids.clear(); - } - ctx->orphans_mutex.unlock(); -} - -Gwn_Context* GWN_context_create(void) -{ -#if TRUST_NO_ONE - /* assert(thread_is_main()); */ -#endif - Gwn_Context* ctx = new Gwn_Context; - glGenVertexArrays(1, &ctx->default_vao); - GWN_context_active_set(ctx); - return ctx; -} - -/* to be called after GWN_context_active_set(ctx_to_destroy) */ -void GWN_context_discard(Gwn_Context* ctx) -{ -#if TRUST_NO_ONE - /* Make sure no other thread has locked it. */ - assert(ctx == active_ctx); - assert(pthread_equal(pthread_self(), ctx->thread)); - assert(ctx->orphaned_vertarray_ids.empty()); -#endif - /* delete remaining vaos */ - while (!ctx->batches.empty()) { - /* this removes the array entry */ - gwn_batch_vao_cache_clear(*ctx->batches.begin()); - } - glDeleteVertexArrays(1, &ctx->default_vao); - delete ctx; - active_ctx = NULL; -} - -/* ctx can be NULL */ -void GWN_context_active_set(Gwn_Context* ctx) -{ -#if TRUST_NO_ONE - if (active_ctx) { - active_ctx->thread_is_used = false; - } - /* Make sure no other context is already bound to this thread. */ - if (ctx) { - /* Make sure no other thread has locked it. */ - assert(ctx->thread_is_used == false); - ctx->thread = pthread_self(); - ctx->thread_is_used = true; - } -#endif - if (ctx) { - clear_orphans(ctx); - } - active_ctx = ctx; -} - -Gwn_Context* GWN_context_active_get(void) -{ - return active_ctx; -} - -GLuint GWN_vao_default(void) -{ -#if TRUST_NO_ONE - assert(active_ctx); /* need at least an active context */ - assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ -#endif - return active_ctx->default_vao; -} - -GLuint GWN_vao_alloc(void) -{ -#if TRUST_NO_ONE - assert(active_ctx); /* need at least an active context */ - assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ -#endif - clear_orphans(active_ctx); - - GLuint new_vao_id = 0; - glGenVertexArrays(1, &new_vao_id); - return new_vao_id; -} - -/* this can be called from multiple thread */ -void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx) -{ -#if TRUST_NO_ONE - assert(ctx); -#endif - if (ctx == active_ctx) { - glDeleteVertexArrays(1, &vao_id); - } - else { - ctx->orphans_mutex.lock(); - ctx->orphaned_vertarray_ids.emplace_back(vao_id); - ctx->orphans_mutex.unlock(); - } -} - -void gwn_context_add_batch(Gwn_Context* ctx, Gwn_Batch* batch) -{ - ctx->batches.emplace(batch); -} - -void gwn_context_remove_batch(Gwn_Context* ctx, Gwn_Batch* batch) -{ - ctx->orphans_mutex.lock(); - ctx->batches.erase(batch); - ctx->orphans_mutex.unlock(); -} diff --git a/intern/gawain/src/gwn_vertex_buffer.c b/intern/gawain/src/gwn_vertex_buffer.c deleted file mode 100644 index c3440b25da2..00000000000 --- a/intern/gawain/src/gwn_vertex_buffer.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation, Clément Foucault - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_vertex_buffer.c - * \ingroup gpu - * - * Gawain vertex buffer - */ - -#include "gwn_vertex_buffer.h" -#include "gwn_buffer_id.h" -#include "gwn_vertex_format_private.h" -#include -#include - -#define KEEP_SINGLE_COPY 1 - -static uint vbo_memory_usage; - -static GLenum convert_usage_type_to_gl(Gwn_UsageType type) -{ - static const GLenum table[] = { - [GWN_USAGE_STREAM] = GL_STREAM_DRAW, - [GWN_USAGE_STATIC] = GL_STATIC_DRAW, - [GWN_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW - }; - return table[type]; -} - -Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType usage) -{ - Gwn_VertBuf* verts = malloc(sizeof(Gwn_VertBuf)); - GWN_vertbuf_init(verts, usage); - return verts; -} - -Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat* format, Gwn_UsageType usage) -{ - Gwn_VertBuf* verts = GWN_vertbuf_create(usage); - GWN_vertformat_copy(&verts->format, format); - if (!format->packed) { - VertexFormat_pack(&verts->format); - } - return verts; - - /* this function might seem redundant, but there is potential for memory savings here... */ - /* TODO: implement those memory savings */ -} - -void GWN_vertbuf_init(Gwn_VertBuf* verts, Gwn_UsageType usage) -{ - memset(verts, 0, sizeof(Gwn_VertBuf)); - verts->usage = usage; - verts->dirty = true; -} - -void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf* verts, const Gwn_VertFormat* format, Gwn_UsageType usage) -{ - GWN_vertbuf_init(verts, usage); - GWN_vertformat_copy(&verts->format, format); - if (!format->packed) { - VertexFormat_pack(&verts->format); - } -} - -void GWN_vertbuf_discard(Gwn_VertBuf* verts) -{ - if (verts->vbo_id) { - GWN_buf_id_free(verts->vbo_id); -#if VRAM_USAGE - vbo_memory_usage -= GWN_vertbuf_size_get(verts); -#endif - } - if (verts->data) { - free(verts->data); - } - free(verts); -} - -uint GWN_vertbuf_size_get(const Gwn_VertBuf* verts) -{ - return vertex_buffer_size(&verts->format, verts->vertex_len); -} - -/* create a new allocation, discarding any existing data */ -void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) -{ - Gwn_VertFormat* format = &verts->format; - if (!format->packed) { - VertexFormat_pack(format); - } -#if TRUST_NO_ONE - /* catch any unnecessary use */ - assert(verts->vertex_alloc != v_len || verts->data == NULL); -#endif - /* only create the buffer the 1st time */ - if (verts->vbo_id == 0) { - verts->vbo_id = GWN_buf_id_alloc(); - } - /* discard previous data if any */ - if (verts->data) { - free(verts->data); - } -#if VRAM_USAGE - uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); -#endif - verts->dirty = true; - verts->vertex_len = verts->vertex_alloc = v_len; - verts->data = malloc(sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); -} - -/* resize buffer keeping existing data */ -void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, uint v_len) -{ -#if TRUST_NO_ONE - assert(verts->data != NULL); - assert(verts->vertex_alloc != v_len); -#endif - -#if VRAM_USAGE - uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); -#endif - verts->dirty = true; - verts->vertex_len = verts->vertex_alloc = v_len; - verts->data = realloc(verts->data, sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); -} - -/* Set vertex count but does not change allocation. - * Only this many verts will be uploaded to the GPU and rendered. - * This is usefull for streaming data. */ -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, uint v_len) -{ -#if TRUST_NO_ONE - assert(verts->data != NULL); /* only for dynamic data */ - assert(v_len <= verts->vertex_alloc); -#endif - -#if VRAM_USAGE - uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); -#endif - verts->vertex_len = v_len; -} - -void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, uint a_idx, uint v_idx, const void* data) -{ - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; - -#if TRUST_NO_ONE - assert(a_idx < format->attr_len); - assert(v_idx < verts->vertex_alloc); - assert(verts->data != NULL); -#endif - verts->dirty = true; - memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz); -} - -void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, uint a_idx, const void* data) -{ - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; - -#if TRUST_NO_ONE - assert(a_idx < format->attr_len); -#endif - const uint stride = a->sz; /* tightly packed input data */ - - GWN_vertbuf_attr_fill_stride(verts, a_idx, stride, data); -} - -void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, uint a_idx, uint stride, const void* data) -{ - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; - -#if TRUST_NO_ONE - assert(a_idx < format->attr_len); - assert(verts->data != NULL); -#endif - verts->dirty = true; - const uint vertex_len = verts->vertex_len; - - if (format->attr_len == 1 && stride == format->stride) { - /* we can copy it all at once */ - memcpy(verts->data, data, vertex_len * a->sz); - } - else { - /* we must copy it per vertex */ - for (uint v = 0; v < vertex_len; ++v) { - memcpy((GLubyte*)verts->data + a->offset + v * format->stride, (const GLubyte*)data + v * stride, a->sz); - } - } -} - -void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, uint a_idx, Gwn_VertBufRaw *access) -{ - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; - -#if TRUST_NO_ONE - assert(a_idx < format->attr_len); - assert(verts->data != NULL); -#endif - - verts->dirty = true; - - access->size = a->sz; - access->stride = format->stride; - access->data = (GLubyte*)verts->data + a->offset; - access->data_init = access->data; -#if TRUST_NO_ONE - access->_data_end = access->data_init + (size_t)(verts->vertex_alloc * format->stride); -#endif -} - -static void VertBuffer_upload_data(Gwn_VertBuf* verts) -{ - uint buffer_sz = GWN_vertbuf_size_get(verts); - - /* orphan the vbo to avoid sync */ - glBufferData(GL_ARRAY_BUFFER, buffer_sz, NULL, convert_usage_type_to_gl(verts->usage)); - /* upload data */ - glBufferSubData(GL_ARRAY_BUFFER, 0, buffer_sz, verts->data); - - if (verts->usage == GWN_USAGE_STATIC) { - free(verts->data); - verts->data = NULL; - } - verts->dirty = false; -} - -void GWN_vertbuf_use(Gwn_VertBuf* verts) -{ - glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id); - if (verts->dirty) { - VertBuffer_upload_data(verts); - } -} - -uint GWN_vertbuf_get_memory_usage(void) -{ - return vbo_memory_usage; -} diff --git a/intern/gawain/src/gwn_vertex_format.c b/intern/gawain/src/gwn_vertex_format.c deleted file mode 100644 index 41179ae21eb..00000000000 --- a/intern/gawain/src/gwn_vertex_format.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation, Clément Foucault - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gwn_vertex_format.c - * \ingroup gpu - * - * Gawain vertex format - */ - -#include "gwn_vertex_format.h" -#include "gwn_vertex_format_private.h" -#include -#include - -#define PACK_DEBUG 0 - -#if PACK_DEBUG - #include -#endif - -void GWN_vertformat_clear(Gwn_VertFormat* format) -{ -#if TRUST_NO_ONE - memset(format, 0, sizeof(Gwn_VertFormat)); -#else - format->attr_len = 0; - format->packed = false; - format->name_offset = 0; - format->name_len = 0; - - for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++) { - format->attribs[i].name_len = 0; - } -#endif -} - -void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) -{ - /* copy regular struct fields */ - memcpy(dest, src, sizeof(Gwn_VertFormat)); - - for (unsigned i = 0; i < dest->attr_len; i++) { - for (unsigned j = 0; j < dest->attribs[i].name_len; j++) { - dest->attribs[i].name[j] = (char *)dest + (src->attribs[i].name[j] - ((char *)src)); - } - } -} - -static GLenum convert_comp_type_to_gl(Gwn_VertCompType type) -{ - static const GLenum table[] = { - [GWN_COMP_I8] = GL_BYTE, - [GWN_COMP_U8] = GL_UNSIGNED_BYTE, - [GWN_COMP_I16] = GL_SHORT, - [GWN_COMP_U16] = GL_UNSIGNED_SHORT, - [GWN_COMP_I32] = GL_INT, - [GWN_COMP_U32] = GL_UNSIGNED_INT, - - [GWN_COMP_F32] = GL_FLOAT, - - [GWN_COMP_I10] = GL_INT_2_10_10_10_REV - }; - return table[type]; -} - -static unsigned comp_sz(Gwn_VertCompType type) -{ -#if TRUST_NO_ONE - assert(type <= GWN_COMP_F32); /* other types have irregular sizes (not bytes) */ -#endif - const GLubyte sizes[] = {1,1,2,2,4,4,4}; - return sizes[type]; -} - -static unsigned attrib_sz(const Gwn_VertAttr *a) -{ - if (a->comp_type == GWN_COMP_I10) { - return 4; /* always packed as 10_10_10_2 */ - } - return a->comp_len * comp_sz(a->comp_type); -} - -static unsigned attrib_align(const Gwn_VertAttr *a) -{ - if (a->comp_type == GWN_COMP_I10) { - return 4; /* always packed as 10_10_10_2 */ - } - unsigned c = comp_sz(a->comp_type); - if (a->comp_len == 3 && c <= 2) { - return 4 * c; /* AMD HW can't fetch these well, so pad it out (other vendors too?) */ - } - else { - return c; /* most fetches are ok if components are naturally aligned */ - } -} - -unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) -{ -#if TRUST_NO_ONE - assert(format->packed && format->stride > 0); -#endif - return format->stride * vertex_len; -} - -static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) -{ - /* strncpy does 110% of what we need; let's do exactly 100% */ - char* name_copy = format->names + format->name_offset; - unsigned available = GWN_VERT_ATTR_NAMES_BUF_LEN - format->name_offset; - bool terminated = false; - - for (unsigned i = 0; i < available; ++i) { - const char c = name[i]; - name_copy[i] = c; - if (c == '\0') { - terminated = true; - format->name_offset += (i + 1); - break; - } - } -#if TRUST_NO_ONE - assert(terminated); - assert(format->name_offset <= GWN_VERT_ATTR_NAMES_BUF_LEN); -#else - (void)terminated; -#endif - return name_copy; -} - -unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_len, Gwn_VertFetchMode fetch_mode) -{ -#if TRUST_NO_ONE - assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ - assert(format->attr_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ - assert(!format->packed); /* packed means frozen/locked */ - assert((comp_len >= 1 && comp_len <= 4) || comp_len == 8 || comp_len == 12 || comp_len == 16); - - switch (comp_type) { - case GWN_COMP_F32: - /* float type can only kept as float */ - assert(fetch_mode == GWN_FETCH_FLOAT); - break; - case GWN_COMP_I10: - /* 10_10_10 format intended for normals (xyz) or colors (rgb) - * extra component packed.w can be manually set to { -2, -1, 0, 1 } */ - assert(comp_len == 3 || comp_len == 4); - assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); /* not strictly required, may relax later */ - break; - default: - /* integer types can be kept as int or converted/normalized to float */ - assert(fetch_mode != GWN_FETCH_FLOAT); - /* only support float matrices (see Batch_update_program_bindings) */ - assert(comp_len != 8 && comp_len != 12 && comp_len != 16); - } -#endif - format->name_len++; /* multiname support */ - - const unsigned attrib_id = format->attr_len++; - Gwn_VertAttr* attrib = format->attribs + attrib_id; - - attrib->name[attrib->name_len++] = copy_attrib_name(format, name); - attrib->comp_type = comp_type; - attrib->gl_comp_type = convert_comp_type_to_gl(comp_type); - attrib->comp_len = (comp_type == GWN_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */ - attrib->sz = attrib_sz(attrib); - attrib->offset = 0; /* offsets & stride are calculated later (during pack) */ - attrib->fetch_mode = fetch_mode; - - return attrib_id; -} - -void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias) -{ - Gwn_VertAttr* attrib = format->attribs + (format->attr_len - 1); -#if TRUST_NO_ONE - assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ - assert(attrib->name_len < GWN_VERT_ATTR_MAX_NAMES); -#endif - format->name_len++; /* multiname support */ - attrib->name[attrib->name_len++] = copy_attrib_name(format, alias); -} - -unsigned padding(unsigned offset, unsigned alignment) -{ - const unsigned mod = offset % alignment; - return (mod == 0) ? 0 : (alignment - mod); -} - -#if PACK_DEBUG -static void show_pack(unsigned a_idx, unsigned sz, unsigned pad) -{ - const char c = 'A' + a_idx; - for (unsigned i = 0; i < pad; ++i) { - putchar('-'); - } - for (unsigned i = 0; i < sz; ++i) { - putchar(c); - } -} -#endif - -void VertexFormat_pack(Gwn_VertFormat* format) -{ - /* For now, attributes are packed in the order they were added, - * making sure each attrib is naturally aligned (add padding where necessary) - * Later we can implement more efficient packing w/ reordering - * (keep attrib ID order, adjust their offsets to reorder in buffer). */ - - /* TODO: realloc just enough to hold the final combo string. And just enough to - * hold used attribs, not all 16. */ - - Gwn_VertAttr* a0 = format->attribs + 0; - a0->offset = 0; - unsigned offset = a0->sz; - -#if PACK_DEBUG - show_pack(0, a0->sz, 0); -#endif - - for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) { - Gwn_VertAttr* a = format->attribs + a_idx; - unsigned mid_padding = padding(offset, attrib_align(a)); - offset += mid_padding; - a->offset = offset; - offset += a->sz; - -#if PACK_DEBUG - show_pack(a_idx, a->sz, mid_padding); -#endif - } - - unsigned end_padding = padding(offset, attrib_align(a0)); - -#if PACK_DEBUG - show_pack(0, 0, end_padding); - putchar('\n'); -#endif - format->stride = offset + end_padding; - format->packed = true; -} - - -/* OpenGL ES packs in a different order as desktop GL but component conversion is the same. - * Of the code here, only struct Gwn_PackedNormal needs to change. */ - -#define SIGNED_INT_10_MAX 511 -#define SIGNED_INT_10_MIN -512 - -static int clampi(int x, int min_allowed, int max_allowed) -{ -#if TRUST_NO_ONE - assert(min_allowed <= max_allowed); -#endif - if (x < min_allowed) { - return min_allowed; - } - else if (x > max_allowed) { - return max_allowed; - } - else { - return x; - } -} - -static int quantize(float x) -{ - int qx = x * 511.0f; - return clampi(qx, SIGNED_INT_10_MIN, SIGNED_INT_10_MAX); -} - -static int convert_i16(short x) -{ - /* 16-bit signed --> 10-bit signed */ - /* TODO: round? */ - return x >> 6; -} - -Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]) -{ - Gwn_PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) }; - return n; -} - -Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]) -{ - Gwn_PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) }; - return n; -} diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt index 2611477252a..10898e4239b 100644 --- a/intern/opencolorio/CMakeLists.txt +++ b/intern/opencolorio/CMakeLists.txt @@ -27,8 +27,8 @@ set(INC . ../glew-mx ../guardedalloc - ../gawain ../../source/blender/blenlib + ../../source/blender/gpu ) set(INC_SYS diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc index 090422ff795..10acdb9d281 100644 --- a/intern/opencolorio/ocio_impl_glsl.cc +++ b/intern/opencolorio/ocio_impl_glsl.cc @@ -49,7 +49,7 @@ #endif extern "C" { -#include "gawain/gwn_immediate.h" +#include "GPU_immediate.h" } using namespace OCIO_NAMESPACE; diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 999773d0212..03bf7fa67d8 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -31,7 +31,7 @@ #ifndef __BLF_INTERNAL_TYPES_H__ #define __BLF_INTERNAL_TYPES_H__ -#include "../../../intern/gawain/gawain/gwn_vertex_buffer.h" +#include "GPU_vertex_buffer.h" #include "GPU_texture.h" #define BLF_BATCH_DRAW_LEN_MAX 2048 /* in glyph */ diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index bf3ee34a03e..a6d11f1edac 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -45,7 +45,7 @@ #include "eevee_lightcache.h" #include "eevee_private.h" -#include "../../../intern/gawain/gawain/gwn_context.h" +#include "GPU_context.h" #include "WM_api.h" #include "WM_types.h" diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 58ce9dd5218..4c6f8962d82 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -82,7 +82,7 @@ #include "engines/workbench/workbench_engine.h" #include "engines/external/external_engine.h" -#include "../../../intern/gawain/gawain/gwn_context.h" +#include "GPU_context.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index d25e372c26e..2d44fb5b6d8 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -35,6 +35,7 @@ #include "BLI_threads.h" #include "GPU_batch.h" +#include "GPU_context.h" #include "GPU_framebuffer.h" #include "GPU_shader.h" #include "GPU_uniformbuffer.h" diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 716e00164ce..3d207b85760 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -50,7 +50,6 @@ set(INC ../../../intern/glew-mx ../../../intern/guardedalloc ../../../intern/smoke/extern - ../../../intern/gawain ) set(INC_SYS @@ -58,14 +57,17 @@ set(INC_SYS ) set(SRC + intern/gpu_attr_binding.c intern/gpu_basic_shader.c intern/gpu_batch.c intern/gpu_batch_presets.c intern/gpu_batch_utils.c + intern/gpu_buffer_id.cpp intern/gpu_buffers.c intern/gpu_codegen.c intern/gpu_debug.c intern/gpu_draw.c + intern/gpu_element.c intern/gpu_extensions.c intern/gpu_framebuffer.c intern/gpu_immediate.c @@ -73,13 +75,18 @@ set(SRC intern/gpu_init_exit.c intern/gpu_material.c intern/gpu_matrix.c + intern/gpu_primitive.c intern/gpu_select.c intern/gpu_select_pick.c intern/gpu_select_sample_query.c intern/gpu_shader.c + intern/gpu_shader_interface.c intern/gpu_state.c intern/gpu_texture.c intern/gpu_uniformbuffer.c + intern/gpu_vertex_array_id.cpp + intern/gpu_vertex_buffer.c + intern/gpu_vertex_format.c intern/gpu_viewport.c shaders/gpu_shader_fx_lib.glsl @@ -103,11 +110,15 @@ set(SRC shaders/gpu_shader_smoke_frag.glsl shaders/gpu_shader_smoke_vert.glsl + GPU_attr_binding.h GPU_basic_shader.h GPU_batch.h + GPU_buffer_id.h GPU_buffers.h + GPU_common.h GPU_debug.h GPU_draw.h + GPU_element.h GPU_extensions.h GPU_framebuffer.h GPU_glew.h @@ -117,17 +128,26 @@ set(SRC GPU_legacy_stubs.h GPU_material.h GPU_matrix.h + GPU_primitive.h GPU_select.h GPU_shader.h + GPU_shader_interface.h GPU_state.h GPU_texture.h GPU_uniformbuffer.h + GPU_vertex_array_id.h + GPU_vertex_buffer.h + GPU_vertex_format.h GPU_viewport.h + intern/gpu_attr_binding_private.h + intern/gpu_batch_private.h intern/gpu_codegen.h + intern/gpu_primitive_private.h intern/gpu_private.h intern/gpu_select_private.h intern/gpu_shader_private.h + intern/gpu_vertex_format_private.h ) data_to_c_simple(shaders/gpu_shader_depth_only_frag.glsl SRC) diff --git a/source/blender/gpu/GPU_attr_binding.h b/source/blender/gpu/GPU_attr_binding.h new file mode 100644 index 00000000000..41050a095cd --- /dev/null +++ b/source/blender/gpu/GPU_attr_binding.h @@ -0,0 +1,42 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_attr_binding.h + * \ingroup gpu + * + * Gawain vertex attribute binding + */ + +#ifndef __GWN_ATTR_BINDING_H__ +#define __GWN_ATTR_BINDING_H__ + +#include "GPU_common.h" + +typedef struct Gwn_AttrBinding { + uint64_t loc_bits; /* store 4 bits for each of the 16 attribs */ + uint16_t enabled_bits; /* 1 bit for each attrib */ +} Gwn_AttrBinding; + +#endif /* __GWN_ATTR_BINDING_H__ */ diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index f73968eda54..4c98eb8f537 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -15,37 +15,185 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2016 Blender Foundation. + * The Original Code is Copyright (C) 2016 by Mike Erwin. * All rights reserved. * - * - * Contributor(s): Mike Erwin + * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** */ -/* Batched geometry rendering is powered by the Gawain library. - * This file contains any additions or modifications specific to Blender. +/** \file blender/gpu/gwn_batch.h + * \ingroup gpu + * + * Gawain geometry batch + * Contains VAOs + VBOs + Shader representing a drawable entity. */ -#ifndef __GPU_BATCH_H__ -#define __GPU_BATCH_H__ +#ifndef __GWN_BATCH_H__ +#define __GWN_BATCH_H__ -#include "../../../intern/gawain/gawain/gwn_batch.h" -#include "../../../intern/gawain/gawain/gwn_batch_private.h" +#include "GPU_vertex_buffer.h" +#include "GPU_element.h" +#include "GPU_shader_interface.h" +#include "GPU_shader.h" -// TODO: CMake magic to do this: -// #include "gawain/batch.h" +typedef enum { + GWN_BATCH_READY_TO_FORMAT, + GWN_BATCH_READY_TO_BUILD, + GWN_BATCH_BUILDING, + GWN_BATCH_READY_TO_DRAW +} Gwn_BatchPhase; -#include "BLI_compiler_attrs.h" -#include "BLI_sys_types.h" +#define GWN_BATCH_VBO_MAX_LEN 3 +#define GWN_BATCH_VAO_STATIC_LEN 3 +#define GWN_BATCH_VAO_DYN_ALLOC_COUNT 16 -#include "GPU_shader.h" +typedef struct Gwn_Batch { + /* geometry */ + Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ + Gwn_VertBuf* inst; /* instance attribs */ + Gwn_IndexBuf* elem; /* NULL if element list not needed */ + uint32_t gl_prim_type; + + /* cached values (avoid dereferencing later) */ + uint32_t vao_id; + uint32_t program; + const struct Gwn_ShaderInterface* interface; + + /* book-keeping */ + uint owns_flag; + struct Gwn_Context *context; /* used to free all vaos. this implies all vaos were created under the same context. */ + Gwn_BatchPhase phase; + bool program_in_use; + + /* Vao management: remembers all geometry state (vertex attrib bindings & element buffer) + * for each shader interface. Start with a static number of vaos and fallback to dynamic count + * if necessary. Once a batch goes dynamic it does not go back. */ + bool is_dynamic_vao_count; + union { + /* Static handle count */ + struct { + const struct Gwn_ShaderInterface* interfaces[GWN_BATCH_VAO_STATIC_LEN]; + uint32_t vao_ids[GWN_BATCH_VAO_STATIC_LEN]; + } static_vaos; + /* Dynamic handle count */ + struct { + uint count; + const struct Gwn_ShaderInterface** interfaces; + uint32_t* vao_ids; + } dynamic_vaos; + }; + + /* XXX This is the only solution if we want to have some data structure using + * batches as key to identify nodes. We must destroy these nodes with this callback. */ + void (*free_callback)(struct Gwn_Batch*, void*); + void* callback_data; +} Gwn_Batch; + +enum { + GWN_BATCH_OWNS_VBO = (1 << 0), + /* each vbo index gets bit-shifted */ + GWN_BATCH_OWNS_INSTANCES = (1 << 30), + GWN_BATCH_OWNS_INDEX = (1 << 31), +}; + +Gwn_Batch* GWN_batch_create_ex(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); +void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); +Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src); + +#define GWN_batch_create(prim, verts, elem) \ + GWN_batch_create_ex(prim, verts, elem, 0) +#define GWN_batch_init(batch, prim, verts, elem) \ + GWN_batch_init_ex(batch, prim, verts, elem, 0) + +void GWN_batch_discard(Gwn_Batch*); /* verts & elem are not discarded */ + +void gwn_batch_vao_cache_clear(Gwn_Batch*); + +void GWN_batch_callback_free_set(Gwn_Batch*, void (*callback)(Gwn_Batch*, void*), void*); + +void GWN_batch_instbuf_set(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); /* Instancing */ + +int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); + +#define GWN_batch_vertbuf_add(batch, verts) \ + GWN_batch_vertbuf_add_ex(batch, verts, false) -/* gpu_batch.c */ -void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id) ATTR_NONNULL(1); +void GWN_batch_program_set_no_use(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); +void GWN_batch_program_set(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); +void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id); +/* Entire batch draws with one shader program, but can be redrawn later with another program. */ +/* Vertex shader's inputs must be compatible with the batch's vertex format. */ + +void GWN_batch_program_use_begin(Gwn_Batch*); /* call before Batch_Uniform (temp hack?) */ +void GWN_batch_program_use_end(Gwn_Batch*); + +void GWN_batch_uniform_1ui(Gwn_Batch*, const char* name, int value); +void GWN_batch_uniform_1i(Gwn_Batch*, const char* name, int value); +void GWN_batch_uniform_1b(Gwn_Batch*, const char* name, bool value); +void GWN_batch_uniform_1f(Gwn_Batch*, const char* name, float value); +void GWN_batch_uniform_2f(Gwn_Batch*, const char* name, float x, float y); +void GWN_batch_uniform_3f(Gwn_Batch*, const char* name, float x, float y, float z); +void GWN_batch_uniform_4f(Gwn_Batch*, const char* name, float x, float y, float z, float w); +void GWN_batch_uniform_2fv(Gwn_Batch*, const char* name, const float data[2]); +void GWN_batch_uniform_3fv(Gwn_Batch*, const char* name, const float data[3]); +void GWN_batch_uniform_4fv(Gwn_Batch*, const char* name, const float data[4]); +void GWN_batch_uniform_2fv_array(Gwn_Batch*, const char* name, int len, const float *data); +void GWN_batch_uniform_4fv_array(Gwn_Batch*, const char* name, int len, const float *data); +void GWN_batch_uniform_mat4(Gwn_Batch*, const char* name, const float data[4][4]); + +void GWN_batch_draw(Gwn_Batch*); + +/* This does not bind/unbind shader and does not call GPU_matrix_bind() */ +void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance); + +/* Does not even need batch */ +void GWN_draw_primitive(Gwn_PrimType, int v_count); + +#if 0 /* future plans */ + +/* Can multiple batches share a Gwn_VertBuf? Use ref count? */ + + +/* We often need a batch with its own data, to be created and discarded together. */ +/* WithOwn variants reduce number of system allocations. */ + +typedef struct BatchWithOwnVertexBuffer { + Gwn_Batch batch; + Gwn_VertBuf verts; /* link batch.verts to this */ +} BatchWithOwnVertexBuffer; + +typedef struct BatchWithOwnElementList { + Gwn_Batch batch; + Gwn_IndexBuf elem; /* link batch.elem to this */ +} BatchWithOwnElementList; + +typedef struct BatchWithOwnVertexBufferAndElementList { + Gwn_Batch batch; + Gwn_IndexBuf elem; /* link batch.elem to this */ + Gwn_VertBuf verts; /* link batch.verts to this */ +} BatchWithOwnVertexBufferAndElementList; + +Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, uint v_len, Gwn_IndexBuf*); +Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, uint prim_len); +Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, uint v_len, uint prim_len); +/* verts: shared, own */ +/* elem: none, shared, own */ +Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff); + +#endif /* future plans */ void gpu_batch_init(void); void gpu_batch_exit(void); -#endif /* __GPU_BATCH_H__ */ +/* Macros */ + +#define GWN_BATCH_DISCARD_SAFE(batch) do { \ + if (batch != NULL) { \ + GWN_batch_discard(batch); \ + batch = NULL; \ + } \ +} while (0) + +#endif /* __GWN_BATCH_H__ */ diff --git a/source/blender/gpu/GPU_buffer_id.h b/source/blender/gpu/GPU_buffer_id.h new file mode 100644 index 00000000000..fd680ff31f5 --- /dev/null +++ b/source/blender/gpu/GPU_buffer_id.h @@ -0,0 +1,53 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_buffer_id.h + * \ingroup gpu + * + * Gawain buffer IDs + */ + +#ifndef __GWN_BUFFER_ID_H__ +#define __GWN_BUFFER_ID_H__ + +/* Manage GL buffer IDs in a thread-safe way + * Use these instead of glGenBuffers & its friends + * - alloc must be called from main thread + * - free can be called from any thread */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "GPU_common.h" + +GLuint GWN_buf_id_alloc(void); +void GWN_buf_id_free(GLuint buffer_id); + +#ifdef __cplusplus +} +#endif + +#endif /* __GWN_BUFFER_ID_H__ */ diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h new file mode 100644 index 00000000000..2587e8670a9 --- /dev/null +++ b/source/blender/gpu/GPU_common.h @@ -0,0 +1,61 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_common.h + * \ingroup gpu + */ + +#ifndef __GWN_COMMON_H__ +#define __GWN_COMMON_H__ + +#define PROGRAM_NO_OPTI 0 + +#if defined(NDEBUG) + #define TRUST_NO_ONE 0 +#else + /* strict error checking, enabled for debug builds during early development */ + #define TRUST_NO_ONE 1 +#endif + +#if defined(WITH_OPENGL) + #include +#endif + +#include +#include +#include + +#if TRUST_NO_ONE + #include +#endif + +/* GWN_INLINE */ +#if defined(_MSC_VER) +# define GWN_INLINE static __forceinline +#else +# define GWN_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) +#endif + +#endif /* __GWN_COMMON_H__ */ diff --git a/source/blender/gpu/GPU_context.h b/source/blender/gpu/GPU_context.h new file mode 100644 index 00000000000..0cedc109645 --- /dev/null +++ b/source/blender/gpu/GPU_context.h @@ -0,0 +1,55 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_context.h + * \ingroup gpu + * + * This interface allow Gawain to manage VAOs for mutiple context and threads. + */ + +#ifndef __GWN_CONTEXT_H__ +#define __GWN_CONTEXT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "GPU_common.h" +#include "GPU_batch.h" +#include "GPU_shader_interface.h" + +typedef struct Gwn_Context Gwn_Context; + +Gwn_Context* GWN_context_create(void); +void GWN_context_discard(Gwn_Context*); + +void GWN_context_active_set(Gwn_Context*); +Gwn_Context* GWN_context_active_get(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __GWN_CONTEXT_H__ */ diff --git a/source/blender/gpu/GPU_element.h b/source/blender/gpu/GPU_element.h new file mode 100644 index 00000000000..0c23e90569b --- /dev/null +++ b/source/blender/gpu/GPU_element.h @@ -0,0 +1,102 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_element.h + * \ingroup gpu + * + * Gawain element list (AKA index buffer) + */ + +#ifndef __GWN_ELEMENT_H__ +#define __GWN_ELEMENT_H__ + +#include "GPU_primitive.h" + +#define GWN_TRACK_INDEX_RANGE 1 + +#define GWN_PRIM_RESTART 0xFFFFFFFF + +typedef enum { + GWN_INDEX_U8, /* GL has this, Vulkan does not */ + GWN_INDEX_U16, + GWN_INDEX_U32 +} Gwn_IndexBufType; + +typedef struct Gwn_IndexBuf { + uint index_len; +#if GWN_TRACK_INDEX_RANGE + Gwn_IndexBufType index_type; + uint32_t gl_index_type; + uint min_index; + uint max_index; + uint base_index; +#endif + uint32_t vbo_id; /* 0 indicates not yet sent to VRAM */ + bool use_prim_restart; +} Gwn_IndexBuf; + +void GWN_indexbuf_use(Gwn_IndexBuf*); +uint GWN_indexbuf_size_get(const Gwn_IndexBuf*); + +typedef struct Gwn_IndexBufBuilder { + uint max_allowed_index; + uint max_index_len; + uint index_len; + Gwn_PrimType prim_type; + uint* data; + bool use_prim_restart; +} Gwn_IndexBufBuilder; + + +/* supports all primitive types. */ +void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, uint index_len, uint vertex_len, bool use_prim_restart); + +/* supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS. */ +void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, uint prim_len, uint vertex_len); + +void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, uint v); +void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*); + +void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, uint v); +void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, uint v1, uint v2); +void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3); +void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3, uint v4); + +Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*); +void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*); + +void GWN_indexbuf_discard(Gwn_IndexBuf*); + + +/* Macros */ + +#define GWN_INDEXBUF_DISCARD_SAFE(elem) do { \ + if (elem != NULL) { \ + GWN_indexbuf_discard(elem); \ + elem = NULL; \ + } \ +} while (0) + +#endif /* __GWN_ELEMENT_H__ */ diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h index 2a2692e6baf..c5892886825 100644 --- a/source/blender/gpu/GPU_immediate.h +++ b/source/blender/gpu/GPU_immediate.h @@ -24,29 +24,113 @@ * ***** END GPL LICENSE BLOCK ***** */ -/* Immediate mode rendering is powered by the Gawain library. - * This file contains any additions or modifications specific to Blender. +/** \file blender/gpu/GPU_immediate.h + * \ingroup gpu + * + * Gawain immediate mode work-alike */ #ifndef __GPU_IMMEDIATE_H__ #define __GPU_IMMEDIATE_H__ -#include "../../../intern/gawain/gawain/gwn_immediate.h" -#include "../../../intern/gawain/gawain/gwn_imm_util.h" +#include "GPU_vertex_format.h" +#include "GPU_primitive.h" +#include "GPU_shader_interface.h" +#include "GPU_batch.h" +#include "GPU_immediate_util.h" +#include "GPU_shader.h" -// TODO: CMake magic to do this: -// #include "gawain/gwn_immediate.h" -// #include "gawain/gwn_imm_util.h" +Gwn_VertFormat* immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ -#include "GPU_shader.h" +void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); /* every immBegin must have a program bound first. */ +void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */ + +void immBegin(Gwn_PrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */ +void immBeginAtMost(Gwn_PrimType, uint max_vertex_len); /* can supply fewer vertices. */ +void immEnd(void); /* finishes and draws. */ + +/* ImmBegin a batch, then use standard immFunctions as usual. */ +/* ImmEnd will finalize the batch instead of drawing. */ +/* Then you can draw it as many times as you like! Partially replaces the need for display lists. */ +Gwn_Batch* immBeginBatch(Gwn_PrimType, uint vertex_len); +Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, uint vertex_len); + +/* Provide attribute values that can change per vertex. */ +/* First vertex after immBegin must have all its attributes specified. */ +/* Skipped attributes will continue using the previous value for that attrib_id. */ +void immAttrib1f(uint attrib_id, float x); +void immAttrib2f(uint attrib_id, float x, float y); +void immAttrib3f(uint attrib_id, float x, float y, float z); +void immAttrib4f(uint attrib_id, float x, float y, float z, float w); + +void immAttrib2i(uint attrib_id, int x, int y); + +void immAttrib1u(uint attrib_id, uint x); + +void immAttrib2s(uint attrib_id, short x, short y); + +void immAttrib2fv(uint attrib_id, const float data[2]); +void immAttrib3fv(uint attrib_id, const float data[3]); +void immAttrib4fv(uint attrib_id, const float data[4]); + +void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b); +void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a); + +void immAttrib3ubv(uint attrib_id, const unsigned char data[4]); +void immAttrib4ubv(uint attrib_id, const unsigned char data[4]); + +/* Explicitly skip an attribute. */ +/* This advanced option kills automatic value copying for this attrib_id. */ +void immSkipAttrib(uint attrib_id); + +/* Provide one last attribute value & end the current vertex. */ +/* This is most often used for 2D or 3D position (similar to glVertex). */ +void immVertex2f(uint attrib_id, float x, float y); +void immVertex3f(uint attrib_id, float x, float y, float z); +void immVertex4f(uint attrib_id, float x, float y, float z, float w); + +void immVertex2i(uint attrib_id, int x, int y); + +void immVertex2s(uint attrib_id, short x, short y); + +void immVertex2fv(uint attrib_id, const float data[2]); +void immVertex3fv(uint attrib_id, const float data[3]); + +void immVertex2iv(uint attrib_id, const int data[2]); + +/* Provide uniform values that don't change for the entire draw call. */ +void immUniform1i(const char* name, int x); +void immUniform4iv(const char* name, const int data[4]); +void immUniform1f(const char* name, float x); +void immUniform2f(const char* name, float x, float y); +void immUniform2fv(const char* name, const float data[2]); +void immUniform3f(const char* name, float x, float y, float z); +void immUniform3fv(const char* name, const float data[3]); +void immUniformArray3fv(const char* name, const float *data, int count); +void immUniform4f(const char* name, float x, float y, float z, float w); +void immUniform4fv(const char* name, const float data[4]); +void immUniformArray4fv(const char* bare_name, const float *data, int count); +void immUniformMatrix4fv(const char* name, const float data[4][4]); + +/* Convenience functions for setting "uniform vec4 color". */ +/* The rgb functions have implicit alpha = 1.0. */ +void immUniformColor4f(float r, float g, float b, float a); +void immUniformColor4fv(const float rgba[4]); +void immUniformColor3f(float r, float g, float b); +void immUniformColor3fv(const float rgb[3]); +void immUniformColor3fvAlpha(const float rgb[3], float a); + +void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b); +void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a); +void immUniformColor3ubv(const unsigned char rgb[3]); +void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a); +void immUniformColor4ubv(const unsigned char rgba[4]); /* Extend immBindProgram to use Blender’s library of built-in shader programs. * Use immUnbindProgram() when done. */ void immBindBuiltinProgram(GPUBuiltinShader shader_id); -/* - * Extend immUniformColor to take Blender's themes - */ +/* Extend immUniformColor to take Blender's themes */ void immUniformThemeColor(int color_id); void immUniformThemeColor3(int color_id); void immUniformThemeColorShade(int color_id, int offset); @@ -55,4 +139,10 @@ void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int void immUniformThemeColorBlend(int color_id1, int color_id2, float fac); void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset); +/* These are called by the system -- not part of drawing API. */ +void immInit(void); +void immActivate(void); +void immDeactivate(void); +void immDestroy(void); + #endif /* __GPU_IMMEDIATE_H__ */ diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h index c31d477ff5b..0a5c9805509 100644 --- a/source/blender/gpu/GPU_immediate_util.h +++ b/source/blender/gpu/GPU_immediate_util.h @@ -27,6 +27,15 @@ #ifndef __GPU_IMMEDIATE_UTIL_H__ #define __GPU_IMMEDIATE_UTIL_H__ +/* Draw 2D rectangles (replaces glRect functions) */ +/* caller is reponsible for vertex format & shader */ +void immRectf(uint pos, float x1, float y1, float x2, float y2); +void immRecti(uint pos, int x1, int y1, int x2, int y2); + +/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS. */ +void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]); +void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]); + void imm_cpack(uint x); void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments); diff --git a/source/blender/gpu/GPU_primitive.h b/source/blender/gpu/GPU_primitive.h new file mode 100644 index 00000000000..44348b9b593 --- /dev/null +++ b/source/blender/gpu/GPU_primitive.h @@ -0,0 +1,65 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_primitive.h + * \ingroup gpu + * + * Gawain geometric primitives + */ + +#ifndef __GWN_PRIMITIVE_H__ +#define __GWN_PRIMITIVE_H__ + +#include "GPU_common.h" + +typedef enum { + GWN_PRIM_POINTS, + GWN_PRIM_LINES, + GWN_PRIM_TRIS, + GWN_PRIM_LINE_STRIP, + GWN_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */ + GWN_PRIM_TRI_STRIP, + GWN_PRIM_TRI_FAN, + + GWN_PRIM_LINES_ADJ, + GWN_PRIM_TRIS_ADJ, + GWN_PRIM_LINE_STRIP_ADJ, + + GWN_PRIM_NONE +} Gwn_PrimType; + +/* what types of primitives does each shader expect? */ +typedef enum { + GWN_PRIM_CLASS_NONE = 0, + GWN_PRIM_CLASS_POINT = (1 << 0), + GWN_PRIM_CLASS_LINE = (1 << 1), + GWN_PRIM_CLASS_SURFACE = (1 << 2), + GWN_PRIM_CLASS_ANY = GWN_PRIM_CLASS_POINT | GWN_PRIM_CLASS_LINE | GWN_PRIM_CLASS_SURFACE +} Gwn_PrimClass; + +Gwn_PrimClass GWN_primtype_class(Gwn_PrimType); +bool GWN_primtype_belongs_to_class(Gwn_PrimType, Gwn_PrimClass); + +#endif /* __GWN_PRIMITIVE_H__ */ diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h new file mode 100644 index 00000000000..36842e9847a --- /dev/null +++ b/source/blender/gpu/GPU_shader_interface.h @@ -0,0 +1,104 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_shader_interface.h + * \ingroup gpu + * + * Gawain shader interface (C --> GLSL) + */ + +#ifndef __GWN_SHADER_INTERFACE_H__ +#define __GWN_SHADER_INTERFACE_H__ + +#include "GPU_common.h" + +typedef enum { + GWN_UNIFORM_NONE = 0, /* uninitialized/unknown */ + + GWN_UNIFORM_MODEL, /* mat4 ModelMatrix */ + GWN_UNIFORM_VIEW, /* mat4 ViewMatrix */ + GWN_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */ + GWN_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */ + GWN_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */ + GWN_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */ + + GWN_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */ + GWN_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */ + GWN_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */ + GWN_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */ + GWN_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */ + + GWN_UNIFORM_NORMAL, /* mat3 NormalMatrix */ + GWN_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */ + GWN_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ + GWN_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ + + GWN_UNIFORM_COLOR, /* vec4 color */ + GWN_UNIFORM_EYE, /* vec3 eye */ + GWN_UNIFORM_CALLID, /* int callId */ + + GWN_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ + + GWN_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ +} Gwn_UniformBuiltin; + +typedef struct Gwn_ShaderInput { + struct Gwn_ShaderInput* next; + uint32_t name_offset; + uint name_hash; + Gwn_UniformBuiltin builtin_type; /* only for uniform inputs */ + uint32_t gl_type; /* only for attrib inputs */ + int32_t size; /* only for attrib inputs */ + int32_t location; +} Gwn_ShaderInput; + +#define GWN_NUM_SHADERINTERFACE_BUCKETS 257 +#define GWN_SHADERINTERFACE_REF_ALLOC_COUNT 16 + +typedef struct Gwn_ShaderInterface { + int32_t program; + uint32_t name_buffer_offset; + Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; + Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; + Gwn_ShaderInput* ubo_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; + Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS]; + char* name_buffer; + struct Gwn_Batch** batches; /* references to batches using this interface */ + uint batches_len; +} Gwn_ShaderInterface; + +Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id); +void GWN_shaderinterface_discard(Gwn_ShaderInterface*); + +const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name); +const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin); +const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface*, const char* name); +const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name); + +/* keep track of batches using this interface */ +void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); +void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); + +#endif /* __GWN_SHADER_INTERFACE_H__ */ diff --git a/source/blender/gpu/GPU_vertex_array_id.h b/source/blender/gpu/GPU_vertex_array_id.h new file mode 100644 index 00000000000..925cd74511d --- /dev/null +++ b/source/blender/gpu/GPU_vertex_array_id.h @@ -0,0 +1,55 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_vertex_array_id.h + * \ingroup gpu + * + * Manage GL vertex array IDs in a thread-safe way + * Use these instead of glGenBuffers & its friends + * - alloc must be called from a thread that is bound + * to the context that will be used for drawing with + * this vao. + * - free can be called from any thread + */ + +#ifndef __GWN_VERTEX_ARRAY_ID_H__ +#define __GWN_VERTEX_ARRAY_ID_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "GPU_common.h" +#include "GPU_context.h" + +GLuint GWN_vao_default(void); +GLuint GWN_vao_alloc(void); +void GWN_vao_free(GLuint vao_id, Gwn_Context*); + +#ifdef __cplusplus +} +#endif + +#endif /* __GWN_VERTEX_ARRAY_ID_H__ */ diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h new file mode 100644 index 00000000000..7e4aa24ff2c --- /dev/null +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -0,0 +1,144 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_vertex_buffer.h + * \ingroup gpu + * + * Gawain vertex buffer + */ + +#ifndef __GWN_VERTEX_BUFFER_H__ +#define __GWN_VERTEX_BUFFER_H__ + +#include "GPU_vertex_format.h" + +#define VRAM_USAGE 1 +/* How to create a Gwn_VertBuf: */ +/* 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts) */ +/* 2) GWN_vertformat_attr_add(verts->format, ...) */ +/* 3) GWN_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format */ +/* 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer) */ + +/* Is Gwn_VertBuf always used as part of a Gwn_Batch? */ + +typedef enum { + /* can be extended to support more types */ + GWN_USAGE_STREAM, + GWN_USAGE_STATIC, /* do not keep data in memory */ + GWN_USAGE_DYNAMIC +} Gwn_UsageType; + +typedef struct Gwn_VertBuf { + Gwn_VertFormat format; + uint vertex_len; /* number of verts we want to draw */ + uint vertex_alloc; /* number of verts data */ + bool dirty; + unsigned char* data; /* NULL indicates data in VRAM (unmapped) */ + uint32_t vbo_id; /* 0 indicates not yet allocated */ + Gwn_UsageType usage; /* usage hint for GL optimisation */ +} Gwn_VertBuf; + +Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType); +Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat*, Gwn_UsageType); + +#define GWN_vertbuf_create_with_format(format) \ + GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_STATIC) + +void GWN_vertbuf_discard(Gwn_VertBuf*); + +void GWN_vertbuf_init(Gwn_VertBuf*, Gwn_UsageType); +void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf*, const Gwn_VertFormat*, Gwn_UsageType); + +#define GWN_vertbuf_init_with_format(verts, format) \ + GWN_vertbuf_init_with_format_ex(verts, format, GWN_USAGE_STATIC) + +uint GWN_vertbuf_size_get(const Gwn_VertBuf*); +void GWN_vertbuf_data_alloc(Gwn_VertBuf*, uint v_len); +void GWN_vertbuf_data_resize(Gwn_VertBuf*, uint v_len); +void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, uint v_len); + +/* The most important set_attrib variant is the untyped one. Get it right first. */ +/* It takes a void* so the app developer is responsible for matching their app data types */ +/* to the vertex attribute's type and component count. They're in control of both, so this */ +/* should not be a problem. */ + +void GWN_vertbuf_attr_set(Gwn_VertBuf*, uint a_idx, uint v_idx, const void* data); +void GWN_vertbuf_attr_fill(Gwn_VertBuf*, uint a_idx, const void* data); /* tightly packed, non interleaved input data */ +void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, uint a_idx, uint stride, const void* data); + +/* For low level access only */ +typedef struct Gwn_VertBufRaw { + uint size; + uint stride; + unsigned char* data; + unsigned char* data_init; +#if TRUST_NO_ONE + /* Only for overflow check */ + unsigned char* _data_end; +#endif +} Gwn_VertBufRaw; + +GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a) +{ + unsigned char* data = a->data; + a->data += a->stride; +#if TRUST_NO_ONE + assert(data < a->_data_end); +#endif + return (void *)data; +} + +GWN_INLINE uint GWN_vertbuf_raw_used(Gwn_VertBufRaw *a) +{ + return ((a->data - a->data_init) / a->stride); +} + +void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, uint a_idx, Gwn_VertBufRaw *access); + +/* TODO: decide whether to keep the functions below */ +/* doesn't immediate mode satisfy these needs? */ + +/* void setAttrib1f(uint a_idx, uint v_idx, float x); */ +/* void setAttrib2f(uint a_idx, unsigned v_idx, float x, float y); */ +/* void setAttrib3f(unsigned a_idx, unsigned v_idx, float x, float y, float z); */ +/* void setAttrib4f(unsigned a_idx, unsigned v_idx, float x, float y, float z, float w); */ + +/* void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b); */ +/* void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a); */ + +void GWN_vertbuf_use(Gwn_VertBuf*); + +/* Metrics */ +uint GWN_vertbuf_get_memory_usage(void); + +/* Macros */ +#define GWN_VERTBUF_DISCARD_SAFE(verts) do { \ + if (verts != NULL) { \ + GWN_vertbuf_discard(verts); \ + verts = NULL; \ + } \ +} while (0) + +#endif /* __GWN_VERTEX_BUFFER_H__ */ diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h new file mode 100644 index 00000000000..91e31b5ece4 --- /dev/null +++ b/source/blender/gpu/GPU_vertex_format.h @@ -0,0 +1,101 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_vertex_format.h + * \ingroup gpu + * + * Gawain vertex format + */ + +#ifndef __GWN_VERTEX_FORMAT_H__ +#define __GWN_VERTEX_FORMAT_H__ + +#include "GPU_common.h" + +#define GWN_VERT_ATTR_MAX_LEN 16 +#define GWN_VERT_ATTR_MAX_NAMES 3 +#define GWN_VERT_ATTR_NAME_AVERAGE_LEN 11 +#define GWN_VERT_ATTR_NAMES_BUF_LEN ((GWN_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GWN_VERT_ATTR_MAX_LEN) + +typedef enum { + GWN_COMP_I8, + GWN_COMP_U8, + GWN_COMP_I16, + GWN_COMP_U16, + GWN_COMP_I32, + GWN_COMP_U32, + + GWN_COMP_F32, + + GWN_COMP_I10 +} Gwn_VertCompType; + +typedef enum { + GWN_FETCH_FLOAT, + GWN_FETCH_INT, + GWN_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */ + GWN_FETCH_INT_TO_FLOAT /* 127 (any int type) -> 127.0 */ +} Gwn_VertFetchMode; + +typedef struct Gwn_VertAttr { + Gwn_VertFetchMode fetch_mode; + Gwn_VertCompType comp_type; + uint gl_comp_type; + uint comp_len; /* 1 to 4 or 8 or 12 or 16 */ + uint sz; /* size in bytes, 1 to 64 */ + uint offset; /* from beginning of vertex, in bytes */ + uint name_len; /* up to GWN_VERT_ATTR_MAX_NAMES */ + const char* name[GWN_VERT_ATTR_MAX_NAMES]; +} Gwn_VertAttr; + +typedef struct Gwn_VertFormat { + uint attr_len; /* 0 to 16 (GWN_VERT_ATTR_MAX_LEN) */ + uint name_len; /* total count of active vertex attrib */ + uint stride; /* stride in bytes, 1 to 256 */ + uint name_offset; + bool packed; + char names[GWN_VERT_ATTR_NAMES_BUF_LEN]; + Gwn_VertAttr attribs[GWN_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */ +} Gwn_VertFormat; + +void GWN_vertformat_clear(Gwn_VertFormat*); +void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src); + +uint GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, uint comp_len, Gwn_VertFetchMode); +void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias); + +/* format conversion */ + +typedef struct Gwn_PackedNormal { + int x : 10; + int y : 10; + int z : 10; + int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */ +} Gwn_PackedNormal; + +Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]); +Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]); + +#endif /* __GWN_VERTEX_FORMAT_H__ */ diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c new file mode 100644 index 00000000000..e7eba369335 --- /dev/null +++ b/source/blender/gpu/intern/gpu_attr_binding.c @@ -0,0 +1,85 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_attr_binding.c + * \ingroup gpu + * + * Gawain vertex attribute binding + */ + +#include "GPU_attr_binding.h" +#include "gpu_attr_binding_private.h" +#include +#include + +#if GWN_VERT_ATTR_MAX_LEN != 16 + #error "attrib binding code assumes GWN_VERT_ATTR_MAX_LEN = 16" +#endif + +void AttribBinding_clear(Gwn_AttrBinding* binding) +{ + binding->loc_bits = 0; + binding->enabled_bits = 0; +} + +uint read_attrib_location(const Gwn_AttrBinding* binding, uint a_idx) +{ +#if TRUST_NO_ONE + assert(a_idx < GWN_VERT_ATTR_MAX_LEN); + assert(binding->enabled_bits & (1 << a_idx)); +#endif + return (binding->loc_bits >> (4 * a_idx)) & 0xF; +} + +static void write_attrib_location(Gwn_AttrBinding* binding, uint a_idx, uint location) +{ +#if TRUST_NO_ONE + assert(a_idx < GWN_VERT_ATTR_MAX_LEN); + assert(location < GWN_VERT_ATTR_MAX_LEN); +#endif + const uint shift = 4 * a_idx; + const uint64_t mask = ((uint64_t)0xF) << shift; + /* overwrite this attrib's previous location */ + binding->loc_bits = (binding->loc_bits & ~mask) | (location << shift); + /* mark this attrib as enabled */ + binding->enabled_bits |= 1 << a_idx; +} + +void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding, const Gwn_ShaderInterface* shaderface) +{ + AttribBinding_clear(binding); + + for (uint a_idx = 0; a_idx < format->attr_len; ++a_idx) { + const Gwn_VertAttr* a = format->attribs + a_idx; + for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { + const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]); +#if TRUST_NO_ONE + assert(input != NULL); + /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */ +#endif + write_attrib_location(binding, a_idx, input->location); + } + } +} diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h new file mode 100644 index 00000000000..0e0bf89178a --- /dev/null +++ b/source/blender/gpu/intern/gpu_attr_binding_private.h @@ -0,0 +1,43 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_attr_binding_private.h + * \ingroup gpu + * + * Gawain vertex attribute binding + */ + +#ifndef __GWN_ATTR_BINDING_PRIVATE_H__ +#define __GWN_ATTR_BINDING_PRIVATE_H__ + +#include "GPU_vertex_format.h" +#include "GPU_shader_interface.h" + +void AttribBinding_clear(Gwn_AttrBinding*); + +void get_attrib_locations(const Gwn_VertFormat*, Gwn_AttrBinding*, const Gwn_ShaderInterface*); +unsigned read_attrib_location(const Gwn_AttrBinding*, unsigned a_idx); + +#endif /* __GWN_ATTR_BINDING_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 5bfd20e3c8b..90f30930884 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -15,32 +15,639 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2016 Blender Foundation. + * The Original Code is Copyright (C) 2016 by Mike Erwin. * All rights reserved. * - * The Original Code is: all of this file. - * - * Contributor(s): Mike Erwin + * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gpu_batch.c +/** \file blender/gpu/intern/gwn_batch.c * \ingroup gpu + * + * Gawain geometry batch + * Contains VAOs + VBOs + Shader representing a drawable entity. */ -#include "MEM_guardedalloc.h" - -#include "BLI_utildefines.h" -#include "BLI_rect.h" -#include "BLI_math.h" -#include "BLI_polyfill_2d.h" -#include "BLI_sort_utils.h" - -#include "GPU_batch.h" /* own include */ +#include "GPU_batch.h" #include "GPU_batch_presets.h" +#include "GPU_buffer_id.h" +#include "GPU_matrix.h" +#include "GPU_shader.h" +#include "GPU_vertex_array_id.h" + +#include "gpu_batch_private.h" +#include "gpu_primitive_private.h" #include "gpu_shader_private.h" +#include +#include + +static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first); + +void gwn_batch_vao_cache_clear(Gwn_Batch* batch) +{ + if (batch->context == NULL) { + return; + } + if (batch->is_dynamic_vao_count) { + for (int i = 0; i < batch->dynamic_vaos.count; ++i) { + if (batch->dynamic_vaos.vao_ids[i]) { + GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); + } + if (batch->dynamic_vaos.interfaces[i]) { + GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->dynamic_vaos.interfaces[i], batch); + } + } + free(batch->dynamic_vaos.interfaces); + free(batch->dynamic_vaos.vao_ids); + } + else { + for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + if (batch->static_vaos.vao_ids[i]) { + GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); + } + if (batch->static_vaos.interfaces[i]) { + GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->static_vaos.interfaces[i], batch); + } + } + } + batch->is_dynamic_vao_count = false; + for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + batch->static_vaos.vao_ids[i] = 0; + batch->static_vaos.interfaces[i] = NULL; + } + gwn_context_remove_batch(batch->context, batch); + batch->context = NULL; +} + +Gwn_Batch* GWN_batch_create_ex( + Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, + uint owns_flag) +{ + Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch)); + GWN_batch_init_ex(batch, prim_type, verts, elem, owns_flag); + return batch; +} + +void GWN_batch_init_ex( + Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, + uint owns_flag) +{ +#if TRUST_NO_ONE + assert(verts != NULL); +#endif + + batch->verts[0] = verts; + for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + batch->verts[v] = NULL; + } + batch->inst = NULL; + batch->elem = elem; + batch->gl_prim_type = convert_prim_type_to_gl(prim_type); + batch->phase = GWN_BATCH_READY_TO_DRAW; + batch->is_dynamic_vao_count = false; + batch->owns_flag = owns_flag; + batch->free_callback = NULL; +} + +/* This will share the VBOs with the new batch. */ +Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src) +{ + Gwn_Batch* batch = GWN_batch_create_ex(GWN_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); + + batch->gl_prim_type = batch_src->gl_prim_type; + for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + batch->verts[v] = batch_src->verts[v]; + } + return batch; +} + +void GWN_batch_discard(Gwn_Batch* batch) +{ + if (batch->owns_flag & GWN_BATCH_OWNS_INDEX) { + GWN_indexbuf_discard(batch->elem); + } + if (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES) { + GWN_vertbuf_discard(batch->inst); + } + if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0) { + for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + if (batch->verts[v] == NULL) { + break; + } + if (batch->owns_flag & (1 << v)) { + GWN_vertbuf_discard(batch->verts[v]); + } + } + } + gwn_batch_vao_cache_clear(batch); + + if (batch->free_callback) { + batch->free_callback(batch, batch->callback_data); + } + free(batch); +} + +void GWN_batch_callback_free_set(Gwn_Batch* batch, void (*callback)(Gwn_Batch*, void*), void* user_data) +{ + batch->free_callback = callback; + batch->callback_data = user_data; +} + +void GWN_batch_instbuf_set(Gwn_Batch* batch, Gwn_VertBuf* inst, bool own_vbo) +{ +#if TRUST_NO_ONE + assert(inst != NULL); +#endif + /* redo the bindings */ + gwn_batch_vao_cache_clear(batch); + + if (batch->inst != NULL && (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES)) { + GWN_vertbuf_discard(batch->inst); + } + batch->inst = inst; + + if (own_vbo) { + batch->owns_flag |= GWN_BATCH_OWNS_INSTANCES; + } + else { + batch->owns_flag &= ~GWN_BATCH_OWNS_INSTANCES; + } +} + +/* Returns the index of verts in the batch. */ +int GWN_batch_vertbuf_add_ex( + Gwn_Batch* batch, Gwn_VertBuf* verts, + bool own_vbo) +{ + /* redo the bindings */ + gwn_batch_vao_cache_clear(batch); + + for (uint v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + if (batch->verts[v] == NULL) { +#if TRUST_NO_ONE + /* for now all VertexBuffers must have same vertex_len */ + assert(verts->vertex_len == batch->verts[0]->vertex_len); +#endif + batch->verts[v] = verts; + /* TODO: mark dirty so we can keep attrib bindings up-to-date */ + if (own_vbo) + batch->owns_flag |= (1 << v); + return v; + } + } + + /* we only make it this far if there is no room for another Gwn_VertBuf */ +#if TRUST_NO_ONE + assert(false); +#endif + return -1; +} + +static GLuint batch_vao_get(Gwn_Batch *batch) +{ + /* Search through cache */ + if (batch->is_dynamic_vao_count) { + for (int i = 0; i < batch->dynamic_vaos.count; ++i) + if (batch->dynamic_vaos.interfaces[i] == batch->interface) + return batch->dynamic_vaos.vao_ids[i]; + } + else { + for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) + if (batch->static_vaos.interfaces[i] == batch->interface) + return batch->static_vaos.vao_ids[i]; + } + + /* Set context of this batch. + * It will be bound to it until gwn_batch_vao_cache_clear is called. + * Until then it can only be drawn with this context. */ + if (batch->context == NULL) { + batch->context = GWN_context_active_get(); + gwn_context_add_batch(batch->context, batch); + } +#if TRUST_NO_ONE + else { + /* Make sure you are not trying to draw this batch in another context. */ + assert(batch->context == GWN_context_active_get()); + } +#endif + + /* Cache miss, time to add a new entry! */ + GLuint new_vao = 0; + if (!batch->is_dynamic_vao_count) { + int i; /* find first unused slot */ + for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) + if (batch->static_vaos.vao_ids[i] == 0) + break; + + if (i < GWN_BATCH_VAO_STATIC_LEN) { + batch->static_vaos.interfaces[i] = batch->interface; + batch->static_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); + } + else { + /* Not enough place switch to dynamic. */ + batch->is_dynamic_vao_count = true; + /* Erase previous entries, they will be added back if drawn again. */ + for (int j = 0; j < GWN_BATCH_VAO_STATIC_LEN; ++j) { + GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface*)batch->static_vaos.interfaces[j], batch); + GWN_vao_free(batch->static_vaos.vao_ids[j], batch->context); + } + /* Init dynamic arrays and let the branch below set the values. */ + batch->dynamic_vaos.count = GWN_BATCH_VAO_DYN_ALLOC_COUNT; + batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(Gwn_ShaderInterface*)); + batch->dynamic_vaos.vao_ids = calloc(batch->dynamic_vaos.count, sizeof(GLuint)); + } + } + + if (batch->is_dynamic_vao_count) { + int i; /* find first unused slot */ + for (i = 0; i < batch->dynamic_vaos.count; ++i) + if (batch->dynamic_vaos.vao_ids[i] == 0) + break; + + if (i == batch->dynamic_vaos.count) { + /* Not enough place, realloc the array. */ + i = batch->dynamic_vaos.count; + batch->dynamic_vaos.count += GWN_BATCH_VAO_DYN_ALLOC_COUNT; + batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(Gwn_ShaderInterface*) * batch->dynamic_vaos.count); + batch->dynamic_vaos.vao_ids = realloc(batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count); + memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(Gwn_ShaderInterface*) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); + memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); + } + batch->dynamic_vaos.interfaces[i] = batch->interface; + batch->dynamic_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); + } + + GWN_shaderinterface_add_batch_ref((Gwn_ShaderInterface*)batch->interface, batch); + +#if TRUST_NO_ONE + assert(new_vao != 0); +#endif + + /* We just got a fresh VAO we need to initialize it. */ + glBindVertexArray(new_vao); + batch_update_program_bindings(batch, 0); + glBindVertexArray(0); + + return new_vao; +} + +void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) +{ +#if TRUST_NO_ONE + assert(glIsProgram(shaderface->program)); + assert(batch->program_in_use == 0); +#endif + batch->interface = shaderface; + batch->program = program; + batch->vao_id = batch_vao_get(batch); +} + +void GWN_batch_program_set(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) +{ + GWN_batch_program_set_no_use(batch, program, shaderface); + GWN_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */ +} + +void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* interface) +{ + if (batch->is_dynamic_vao_count) { + for (int i = 0; i < batch->dynamic_vaos.count; ++i) { + if (batch->dynamic_vaos.interfaces[i] == interface) { + GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); + batch->dynamic_vaos.vao_ids[i] = 0; + batch->dynamic_vaos.interfaces[i] = NULL; + break; /* cannot have duplicates */ + } + } + } + else { + int i; + for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + if (batch->static_vaos.interfaces[i] == interface) { + GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); + batch->static_vaos.vao_ids[i] = 0; + batch->static_vaos.interfaces[i] = NULL; + break; /* cannot have duplicates */ + } + } + } +} + +static void create_bindings( + Gwn_VertBuf* verts, const Gwn_ShaderInterface* interface, + uint v_first, const bool use_instancing) +{ + const Gwn_VertFormat* format = &verts->format; + + const uint attr_len = format->attr_len; + const uint stride = format->stride; + + GWN_vertbuf_use(verts); + + for (uint a_idx = 0; a_idx < attr_len; ++a_idx) { + const Gwn_VertAttr* a = format->attribs + a_idx; + const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride; + + for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { + const Gwn_ShaderInput* input = GWN_shaderinterface_attr(interface, a->name[n_idx]); + + if (input == NULL) continue; + + if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { +#if TRUST_NO_ONE + assert(a->fetch_mode == GWN_FETCH_FLOAT); + assert(a->gl_comp_type == GL_FLOAT); +#endif + for (int i = 0; i < a->comp_len / 4; ++i) { + glEnableVertexAttribArray(input->location + i); + glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0); + glVertexAttribPointer(input->location + i, 4, a->gl_comp_type, GL_FALSE, stride, + (const GLubyte*)pointer + i * 16); + } + } + else + { + glEnableVertexAttribArray(input->location); + glVertexAttribDivisor(input->location, (use_instancing) ? 1 : 0); + + switch (a->fetch_mode) { + case GWN_FETCH_FLOAT: + case GWN_FETCH_INT_TO_FLOAT: + glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); + break; + case GWN_FETCH_INT_TO_FLOAT_UNIT: + glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); + break; + case GWN_FETCH_INT: + glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer); + break; + } + } + } + } +} + +static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first) +{ + for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { + create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false); + } + if (batch->inst) { + create_bindings(batch->inst, batch->interface, v_first, true); + } + if (batch->elem) { + GWN_indexbuf_use(batch->elem); + } +} + +void GWN_batch_program_use_begin(Gwn_Batch* batch) +{ + /* NOTE: use_program & done_using_program are fragile, depend on staying in sync with + * the GL context's active program. use_program doesn't mark other programs as "not used". */ + /* TODO: make not fragile (somehow) */ + + if (!batch->program_in_use) { + glUseProgram(batch->program); + batch->program_in_use = true; + } +} + +void GWN_batch_program_use_end(Gwn_Batch* batch) +{ + if (batch->program_in_use) { +#if PROGRAM_NO_OPTI + glUseProgram(0); +#endif + batch->program_in_use = false; + } +} + +#if TRUST_NO_ONE + #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); assert(uniform); +#else + #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); +#endif + +void GWN_batch_uniform_1ui(Gwn_Batch* batch, const char* name, int value) +{ + GET_UNIFORM + glUniform1ui(uniform->location, value); +} + +void GWN_batch_uniform_1i(Gwn_Batch* batch, const char* name, int value) +{ + GET_UNIFORM + glUniform1i(uniform->location, value); +} + +void GWN_batch_uniform_1b(Gwn_Batch* batch, const char* name, bool value) +{ + GET_UNIFORM + glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE); +} + +void GWN_batch_uniform_2f(Gwn_Batch* batch, const char* name, float x, float y) +{ + GET_UNIFORM + glUniform2f(uniform->location, x, y); +} + +void GWN_batch_uniform_3f(Gwn_Batch* batch, const char* name, float x, float y, float z) +{ + GET_UNIFORM + glUniform3f(uniform->location, x, y, z); +} + +void GWN_batch_uniform_4f(Gwn_Batch* batch, const char* name, float x, float y, float z, float w) +{ + GET_UNIFORM + glUniform4f(uniform->location, x, y, z, w); +} + +void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x) +{ + GET_UNIFORM + glUniform1f(uniform->location, x); +} + +void GWN_batch_uniform_2fv(Gwn_Batch* batch, const char* name, const float data[2]) +{ + GET_UNIFORM + glUniform2fv(uniform->location, 1, data); +} + +void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3]) +{ + GET_UNIFORM + glUniform3fv(uniform->location, 1, data); +} + +void GWN_batch_uniform_4fv(Gwn_Batch* batch, const char* name, const float data[4]) +{ + GET_UNIFORM + glUniform4fv(uniform->location, 1, data); +} + +void GWN_batch_uniform_2fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) +{ + GET_UNIFORM + glUniform2fv(uniform->location, len, data); +} + +void GWN_batch_uniform_4fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) +{ + GET_UNIFORM + glUniform4fv(uniform->location, len, data); +} + +void GWN_batch_uniform_mat4(Gwn_Batch* batch, const char* name, const float data[4][4]) +{ + GET_UNIFORM + glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (const float *)data); +} + +static void primitive_restart_enable(const Gwn_IndexBuf *el) +{ + // TODO(fclem) Replace by GL_PRIMITIVE_RESTART_FIXED_INDEX when we have ogl 4.3 + glEnable(GL_PRIMITIVE_RESTART); + GLuint restart_index = (GLuint)0xFFFFFFFF; + +#if GWN_TRACK_INDEX_RANGE + if (el->index_type == GWN_INDEX_U8) + restart_index = (GLuint)0xFF; + else if (el->index_type == GWN_INDEX_U16) + restart_index = (GLuint)0xFFFF; +#endif + + glPrimitiveRestartIndex(restart_index); +} + +static void primitive_restart_disable(void) +{ + glDisable(GL_PRIMITIVE_RESTART); +} + +void GWN_batch_draw(Gwn_Batch* batch) +{ +#if TRUST_NO_ONE + assert(batch->phase == GWN_BATCH_READY_TO_DRAW); + assert(batch->verts[0]->vbo_id != 0); +#endif + GWN_batch_program_use_begin(batch); + GPU_matrix_bind(batch->interface); // external call. + + GWN_batch_draw_range_ex(batch, 0, 0, false); + + GWN_batch_program_use_end(batch); +} + +void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool force_instance) +{ +#if TRUST_NO_ONE + assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance +#endif + const bool do_instance = (force_instance || batch->inst); + + // If using offset drawing, use the default VAO and redo bindings. + if (v_first != 0 && (do_instance || batch->elem)) { + glBindVertexArray(GWN_vao_default()); + batch_update_program_bindings(batch, v_first); + } + else { + glBindVertexArray(batch->vao_id); + } + + if (do_instance) { + /* Infer length if vertex count is not given */ + if (v_count == 0) { + v_count = batch->inst->vertex_len; + } + + if (batch->elem) { + const Gwn_IndexBuf* el = batch->elem; + + if (el->use_prim_restart) { + primitive_restart_enable(el); + } +#if GWN_TRACK_INDEX_RANGE + glDrawElementsInstancedBaseVertex(batch->gl_prim_type, + el->index_len, + el->gl_index_type, + 0, + v_count, + el->base_index); +#else + glDrawElementsInstanced(batch->gl_prim_type, el->index_len, GL_UNSIGNED_INT, 0, v_count); +#endif + if (el->use_prim_restart) { + primitive_restart_disable(); + } + } + else { + glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_len, v_count); + } + } + else { + /* Infer length if vertex count is not given */ + if (v_count == 0) { + v_count = (batch->elem) ? batch->elem->index_len : batch->verts[0]->vertex_len; + } + + if (batch->elem) { + const Gwn_IndexBuf* el = batch->elem; + + if (el->use_prim_restart) { + primitive_restart_enable(el); + } + +#if GWN_TRACK_INDEX_RANGE + if (el->base_index) { + glDrawRangeElementsBaseVertex(batch->gl_prim_type, + el->min_index, + el->max_index, + v_count, + el->gl_index_type, + 0, + el->base_index); + } + else { + glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, v_count, el->gl_index_type, 0); + } +#else + glDrawElements(batch->gl_prim_type, v_count, GL_UNSIGNED_INT, 0); +#endif + if (el->use_prim_restart) { + primitive_restart_disable(); + } + } + else { + glDrawArrays(batch->gl_prim_type, v_first, v_count); + } + } + + /* Performance hog if you are drawing with the same vao multiple time. + * Only activate for debugging. */ + // glBindVertexArray(0); +} + +/* just draw some vertices and let shader place them where we want. */ +void GWN_draw_primitive(Gwn_PrimType prim_type, int v_count) + { + /* we cannot draw without vao ... annoying ... */ + glBindVertexArray(GWN_vao_default()); + + GLenum type = convert_prim_type_to_gl(prim_type); + glDrawArrays(type, 0, v_count); + + /* Performance hog if you are drawing with the same vao multiple time. + * Only activate for debugging.*/ + // glBindVertexArray(0); + } + + /* -------------------------------------------------------------------- */ /** \name Utilities * \{ */ @@ -67,4 +674,4 @@ void gpu_batch_exit(void) gpu_batch_presets_exit(); } -/** \} */ +/** \} */ \ No newline at end of file diff --git a/source/blender/gpu/intern/gpu_batch_private.h b/source/blender/gpu/intern/gpu_batch_private.h new file mode 100644 index 00000000000..1e72bae503f --- /dev/null +++ b/source/blender/gpu/intern/gpu_batch_private.h @@ -0,0 +1,53 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_batch_private.h + * \ingroup gpu + * + * Gawain geometry batch + * Contains VAOs + VBOs + Shader representing a drawable entity. + */ + +#ifndef __GWN_BATCH_PRIVATE_H__ +#define __GWN_BATCH_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "GPU_batch.h" +#include "GPU_context.h" +#include "GPU_shader_interface.h" + +void gwn_batch_remove_interface_ref(Gwn_Batch*, const Gwn_ShaderInterface*); + +void gwn_context_add_batch(Gwn_Context*, Gwn_Batch*); +void gwn_context_remove_batch(Gwn_Context*, Gwn_Batch*); + +#ifdef __cplusplus +} +#endif + +#endif /* __GWN_BATCH_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_buffer_id.cpp b/source/blender/gpu/intern/gpu_buffer_id.cpp new file mode 100644 index 00000000000..0c442f687a0 --- /dev/null +++ b/source/blender/gpu/intern/gpu_buffer_id.cpp @@ -0,0 +1,90 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_buffer_id.cpp + * \ingroup gpu + * + * Gawain buffer IDs + */ + +#include "GPU_buffer_id.h" + +#include +#include + +#define ORPHAN_DEBUG 0 + +#if ORPHAN_DEBUG + #include +#endif + +static std::vector orphaned_buffer_ids; + +static std::mutex orphan_mutex; + +extern "C" { +extern int BLI_thread_is_main(void); /* Blender-specific function */ +} + +static bool thread_is_main() +{ + /* "main" here means the GL context's thread */ + return BLI_thread_is_main(); +} + +GLuint GWN_buf_id_alloc() +{ + /* delete orphaned IDs */ + orphan_mutex.lock(); + if (!orphaned_buffer_ids.empty()) { + const auto orphaned_buffer_len = (uint)orphaned_buffer_ids.size(); +#if ORPHAN_DEBUG + printf("deleting %u orphaned VBO%s\n", orphaned_buffer_len, orphaned_buffer_len == 1 ? "" : "s"); +#endif + glDeleteBuffers(orphaned_buffer_len, orphaned_buffer_ids.data()); + orphaned_buffer_ids.clear(); + } + orphan_mutex.unlock(); + + GLuint new_buffer_id = 0; + glGenBuffers(1, &new_buffer_id); + return new_buffer_id; +} + +void GWN_buf_id_free(GLuint buffer_id) +{ + if (thread_is_main()) { + glDeleteBuffers(1, &buffer_id); + } + else { + /* add this ID to the orphaned list */ + orphan_mutex.lock(); +#if ORPHAN_DEBUG + printf("orphaning VBO %u\n", buffer_id); +#endif + orphaned_buffer_ids.emplace_back(buffer_id); + orphan_mutex.unlock(); + } +} diff --git a/source/blender/gpu/intern/gpu_element.c b/source/blender/gpu/intern/gpu_element.c new file mode 100644 index 00000000000..596530a6ff4 --- /dev/null +++ b/source/blender/gpu/intern/gpu_element.c @@ -0,0 +1,308 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_element.c + * \ingroup gpu + * + * Gawain element list (AKA index buffer) + */ + +#include "GPU_element.h" +#include "GPU_buffer_id.h" + +#include + +#define KEEP_SINGLE_COPY 1 + +static GLenum convert_index_type_to_gl(Gwn_IndexBufType type) +{ + static const GLenum table[] = { + [GWN_INDEX_U8] = GL_UNSIGNED_BYTE, /* GL has this, Vulkan does not */ + [GWN_INDEX_U16] = GL_UNSIGNED_SHORT, + [GWN_INDEX_U32] = GL_UNSIGNED_INT + }; + return table[type]; +} + +uint GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) +{ +#if GWN_TRACK_INDEX_RANGE + static const uint table[] = { + [GWN_INDEX_U8] = sizeof(GLubyte), /* GL has this, Vulkan does not */ + [GWN_INDEX_U16] = sizeof(GLushort), + [GWN_INDEX_U32] = sizeof(GLuint) + }; + return elem->index_len * table[elem->index_type]; +#else + return elem->index_len * sizeof(GLuint); +#endif +} + +void GWN_indexbuf_init_ex( + Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, + uint index_len, uint vertex_len, bool use_prim_restart) +{ + builder->use_prim_restart = use_prim_restart; + builder->max_allowed_index = vertex_len - 1; + builder->max_index_len = index_len; + builder->index_len = 0; // start empty + builder->prim_type = prim_type; + builder->data = calloc(builder->max_index_len, sizeof(uint)); +} + +void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uint prim_len, uint vertex_len) +{ + uint verts_per_prim = 0; + switch (prim_type) { + case GWN_PRIM_POINTS: + verts_per_prim = 1; + break; + case GWN_PRIM_LINES: + verts_per_prim = 2; + break; + case GWN_PRIM_TRIS: + verts_per_prim = 3; + break; + case GWN_PRIM_LINES_ADJ: + verts_per_prim = 4; + break; + default: +#if TRUST_NO_ONE + assert(false); +#endif + return; + } + + GWN_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); +} + +void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, uint v) +{ +#if TRUST_NO_ONE + assert(builder->data != NULL); + assert(builder->index_len < builder->max_index_len); + assert(v <= builder->max_allowed_index); +#endif + builder->data[builder->index_len++] = v; +} + +void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder* builder) +{ +#if TRUST_NO_ONE + assert(builder->data != NULL); + assert(builder->index_len < builder->max_index_len); + assert(builder->use_prim_restart); +#endif + builder->data[builder->index_len++] = GWN_PRIM_RESTART; +} + +void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, uint v) +{ +#if TRUST_NO_ONE + assert(builder->prim_type == GWN_PRIM_POINTS); +#endif + GWN_indexbuf_add_generic_vert(builder, v); +} + +void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2) +{ +#if TRUST_NO_ONE + assert(builder->prim_type == GWN_PRIM_LINES); + assert(v1 != v2); +#endif + GWN_indexbuf_add_generic_vert(builder, v1); + GWN_indexbuf_add_generic_vert(builder, v2); +} + +void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3) +{ +#if TRUST_NO_ONE + assert(builder->prim_type == GWN_PRIM_TRIS); + assert(v1 != v2 && v2 != v3 && v3 != v1); +#endif + GWN_indexbuf_add_generic_vert(builder, v1); + GWN_indexbuf_add_generic_vert(builder, v2); + GWN_indexbuf_add_generic_vert(builder, v3); +} + +void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3, uint v4) +{ +#if TRUST_NO_ONE + assert(builder->prim_type == GWN_PRIM_LINES_ADJ); + assert(v2 != v3); /* only the line need diff indices */ +#endif + GWN_indexbuf_add_generic_vert(builder, v1); + GWN_indexbuf_add_generic_vert(builder, v2); + GWN_indexbuf_add_generic_vert(builder, v3); + GWN_indexbuf_add_generic_vert(builder, v4); +} + +#if GWN_TRACK_INDEX_RANGE +/* Everything remains 32 bit while building to keep things simple. + * Find min/max after, then convert to smallest index type possible. */ + +static uint index_range(const uint values[], uint value_len, uint* min_out, uint* max_out) +{ + if (value_len == 0) { + *min_out = 0; + *max_out = 0; + return 0; + } + uint min_value = values[0]; + uint max_value = values[0]; + for (uint i = 1; i < value_len; ++i) { + const uint value = values[i]; + if (value == GWN_PRIM_RESTART) + continue; + else if (value < min_value) + min_value = value; + else if (value > max_value) + max_value = value; + } + *min_out = min_value; + *max_out = max_value; + return max_value - min_value; +} + +static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) +{ + const uint *values = builder->data; + const uint index_len = elem->index_len; + + /* data will never be *larger* than builder->data... + * converting in place to avoid extra allocation */ + GLubyte *data = (GLubyte *)builder->data; + + if (elem->max_index > 0xFF) { + const uint base = elem->min_index; + elem->base_index = base; + elem->min_index = 0; + elem->max_index -= base; + for (uint i = 0; i < index_len; ++i) { + data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); + } + } + else { + elem->base_index = 0; + for (uint i = 0; i < index_len; ++i) { + data[i] = (GLubyte)(values[i]); + } + } +} + +static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) +{ + const uint *values = builder->data; + const uint index_len = elem->index_len; + + /* data will never be *larger* than builder->data... + * converting in place to avoid extra allocation */ + GLushort *data = (GLushort *)builder->data; + + if (elem->max_index > 0xFFFF) { + const uint base = elem->min_index; + elem->base_index = base; + elem->min_index = 0; + elem->max_index -= base; + for (uint i = 0; i < index_len; ++i) { + data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); + } + } + else { + elem->base_index = 0; + for (uint i = 0; i < index_len; ++i) { + data[i] = (GLushort)(values[i]); + } + } +} + +#endif /* GWN_TRACK_INDEX_RANGE */ + +Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder* builder) +{ + Gwn_IndexBuf* elem = calloc(1, sizeof(Gwn_IndexBuf)); + GWN_indexbuf_build_in_place(builder, elem); + return elem; +} + +void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* elem) +{ +#if TRUST_NO_ONE + assert(builder->data != NULL); +#endif + elem->index_len = builder->index_len; + elem->use_prim_restart = builder->use_prim_restart; + +#if GWN_TRACK_INDEX_RANGE + uint range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index); + + /* count the primitive restart index. */ + if (elem->use_prim_restart) { + range += 1; + } + + if (range <= 0xFF) { + elem->index_type = GWN_INDEX_U8; + squeeze_indices_byte(builder, elem); + } + else if (range <= 0xFFFF) { + elem->index_type = GWN_INDEX_U16; + squeeze_indices_short(builder, elem); + } + else { + elem->index_type = GWN_INDEX_U32; + elem->base_index = 0; + } + elem->gl_index_type = convert_index_type_to_gl(elem->index_type); +#endif + + if (elem->vbo_id == 0) { + elem->vbo_id = GWN_buf_id_alloc(); + } + /* send data to GPU */ + /* GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound, + * so we use the GL_ARRAY_BUFFER here to create a buffer without + * interfering in the VAO state. */ + glBindBuffer(GL_ARRAY_BUFFER, elem->vbo_id); + glBufferData(GL_ARRAY_BUFFER, GWN_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW); + + /* discard builder (one-time use) */ + free(builder->data); + builder->data = NULL; + /* other fields are safe to leave */ +} + +void GWN_indexbuf_use(Gwn_IndexBuf* elem) +{ + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id); +} + +void GWN_indexbuf_discard(Gwn_IndexBuf* elem) +{ + if (elem->vbo_id) { + GWN_buf_id_free(elem->vbo_id); + } + free(elem); +} diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index 5f22b7f9279..661594faf39 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -15,22 +15,145 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2016 Blender Foundation. + * The Original Code is Copyright (C) 2016 by Mike Erwin. * All rights reserved. * - * The Original Code is: all of this file. - * - * Contributor(s): Mike Erwin + * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** */ -#include "GPU_immediate.h" -#include "GPU_matrix.h" +/** \file blender/gpu/intern/gwn_immediate.c + * \ingroup gpu + * + * Gawain immediate mode work-alike + */ + #include "UI_resources.h" -#include "BLI_utildefines.h" +#include "GPU_attr_binding.h" +#include "GPU_buffer_id.h" +#include "GPU_immediate.h" +#include "GPU_vertex_array_id.h" + +#include "gpu_attr_binding_private.h" +#include "gpu_primitive_private.h" #include "gpu_shader_private.h" +#include "gpu_vertex_format_private.h" + +#include +#include + +/* necessary functions from matrix API */ +extern void GPU_matrix_bind(const Gwn_ShaderInterface*); +extern bool GPU_matrix_dirty_get(void); + +typedef struct { + /* TODO: organize this struct by frequency of change (run-time) */ + + Gwn_Batch* batch; + Gwn_Context* context; + + /* current draw call */ + GLubyte* buffer_data; + uint buffer_offset; + uint buffer_bytes_mapped; + uint vertex_len; + bool strict_vertex_len; + Gwn_PrimType prim_type; + + Gwn_VertFormat vertex_format; + + /* current vertex */ + uint vertex_idx; + GLubyte* vertex_data; + uint16_t unassigned_attrib_bits; /* which attributes of current vertex have not been given values? */ + + GLuint vbo_id; + GLuint vao_id; + + GLuint bound_program; + const Gwn_ShaderInterface* shader_interface; + Gwn_AttrBinding attrib_binding; + uint16_t prev_enabled_attrib_bits; /* <-- only affects this VAO, so we're ok */ +} Immediate; + +/* size of internal buffer -- make this adjustable? */ +#define IMM_BUFFER_SIZE (4 * 1024 * 1024) + +static bool initialized = false; +static Immediate imm; + +void immInit(void) +{ +#if TRUST_NO_ONE + assert(!initialized); +#endif + memset(&imm, 0, sizeof(Immediate)); + + imm.vbo_id = GWN_buf_id_alloc(); + glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); + glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); + + imm.prim_type = GWN_PRIM_NONE; + imm.strict_vertex_len = true; + + glBindBuffer(GL_ARRAY_BUFFER, 0); + initialized = true; +} + +void immActivate(void) +{ +#if TRUST_NO_ONE + assert(initialized); + assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ + assert(imm.vao_id == 0); +#endif + imm.vao_id = GWN_vao_alloc(); + imm.context = GWN_context_active_get(); +} + +void immDeactivate(void) +{ +#if TRUST_NO_ONE + assert(initialized); + assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ + assert(imm.vao_id != 0); +#endif + GWN_vao_free(imm.vao_id, imm.context); + imm.vao_id = 0; + imm.prev_enabled_attrib_bits = 0; +} + +void immDestroy(void) +{ + GWN_buf_id_free(imm.vbo_id); + initialized = false; +} + +Gwn_VertFormat* immVertexFormat(void) +{ + GWN_vertformat_clear(&imm.vertex_format); + return &imm.vertex_format; +} + +void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface) +{ +#if TRUST_NO_ONE + assert(imm.bound_program == 0); + assert(glIsProgram(program)); +#endif + + imm.bound_program = program; + imm.shader_interface = shaderface; + + if (!imm.vertex_format.packed) + VertexFormat_pack(&imm.vertex_format); + + glUseProgram(program); + get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, shaderface); + GPU_matrix_bind(shaderface); +} void immBindBuiltinProgram(GPUBuiltinShader shader_id) { @@ -38,6 +161,718 @@ void immBindBuiltinProgram(GPUBuiltinShader shader_id) immBindProgram(shader->program, shader->interface); } +void immUnbindProgram(void) +{ +#if TRUST_NO_ONE + assert(imm.bound_program != 0); +#endif +#if PROGRAM_NO_OPTI + glUseProgram(0); +#endif + imm.bound_program = 0; +} + +#if TRUST_NO_ONE +static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType prim_type) +{ + /* does vertex_len make sense for this primitive type? */ + if (vertex_len == 0) { + return false; + } + + switch (prim_type) { + case GWN_PRIM_POINTS: + return true; + case GWN_PRIM_LINES: + return vertex_len % 2 == 0; + case GWN_PRIM_LINE_STRIP: + case GWN_PRIM_LINE_LOOP: + return vertex_len >= 2; + case GWN_PRIM_LINE_STRIP_ADJ: + return vertex_len >= 4; + case GWN_PRIM_TRIS: + return vertex_len % 3 == 0; + case GWN_PRIM_TRI_STRIP: + case GWN_PRIM_TRI_FAN: + return vertex_len >= 3; + default: + return false; + } +} +#endif + +void immBegin(Gwn_PrimType prim_type, uint vertex_len) +{ +#if TRUST_NO_ONE + assert(initialized); + assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ + assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); +#endif + imm.prim_type = prim_type; + imm.vertex_len = vertex_len; + imm.vertex_idx = 0; + imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; + + /* how many bytes do we need for this draw call? */ + const uint bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_len); + +#if TRUST_NO_ONE + assert(bytes_needed <= IMM_BUFFER_SIZE); +#endif + + glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); + + /* does the current buffer have enough room? */ + const uint available_bytes = IMM_BUFFER_SIZE - imm.buffer_offset; + /* ensure vertex data is aligned */ + const uint pre_padding = padding(imm.buffer_offset, imm.vertex_format.stride); /* might waste a little space, but it's safe */ + if ((bytes_needed + pre_padding) <= available_bytes) { + imm.buffer_offset += pre_padding; + } + else { + /* orphan this buffer & start with a fresh one */ + /* this method works on all platforms, old & new */ + glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); + + imm.buffer_offset = 0; + } + +/* printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1); */ + + imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, bytes_needed, + GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_len ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)); + +#if TRUST_NO_ONE + assert(imm.buffer_data != NULL); +#endif + + imm.buffer_bytes_mapped = bytes_needed; + imm.vertex_data = imm.buffer_data; +} + +void immBeginAtMost(Gwn_PrimType prim_type, uint vertex_len) +{ +#if TRUST_NO_ONE + assert(vertex_len > 0); +#endif + + imm.strict_vertex_len = false; + immBegin(prim_type, vertex_len); +} + + +Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, uint vertex_len) +{ +#if TRUST_NO_ONE + assert(initialized); + assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ + assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); +#endif + imm.prim_type = prim_type; + imm.vertex_len = vertex_len; + imm.vertex_idx = 0; + imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; + + Gwn_VertBuf* verts = GWN_vertbuf_create_with_format(&imm.vertex_format); + GWN_vertbuf_data_alloc(verts, vertex_len); + + imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts); + imm.vertex_data = verts->data; + + imm.batch = GWN_batch_create_ex(prim_type, verts, NULL, GWN_BATCH_OWNS_VBO); + imm.batch->phase = GWN_BATCH_BUILDING; + + return imm.batch; +} + +Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, uint vertex_len) +{ + imm.strict_vertex_len = false; + return immBeginBatch(prim_type, vertex_len); +} + +static void immDrawSetup(void) +{ + /* set up VAO -- can be done during Begin or End really */ + glBindVertexArray(imm.vao_id); + + /* enable/disable vertex attribs as needed */ + if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits) { + for (uint loc = 0; loc < GWN_VERT_ATTR_MAX_LEN; ++loc) { + bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc); + bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc); + + if (is_enabled && !was_enabled) { + glEnableVertexAttribArray(loc); + } + else if (was_enabled && !is_enabled) { + glDisableVertexAttribArray(loc); + } + } + + imm.prev_enabled_attrib_bits = imm.attrib_binding.enabled_bits; + } + + const uint stride = imm.vertex_format.stride; + + for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { + const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; + + const uint offset = imm.buffer_offset + a->offset; + const GLvoid* pointer = (const GLubyte*)0 + offset; + + const uint loc = read_attrib_location(&imm.attrib_binding, a_idx); + + switch (a->fetch_mode) { + case GWN_FETCH_FLOAT: + case GWN_FETCH_INT_TO_FLOAT: + glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); + break; + case GWN_FETCH_INT_TO_FLOAT_UNIT: + glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); + break; + case GWN_FETCH_INT: + glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer); + } + } + + if (GPU_matrix_dirty_get()) { + GPU_matrix_bind(imm.shader_interface); + } +} + +void immEnd(void) +{ +#if TRUST_NO_ONE + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + + uint buffer_bytes_used; + if (imm.strict_vertex_len) { +#if TRUST_NO_ONE + assert(imm.vertex_idx == imm.vertex_len); /* with all vertices defined */ +#endif + buffer_bytes_used = imm.buffer_bytes_mapped; + } + else { +#if TRUST_NO_ONE + assert(imm.vertex_idx <= imm.vertex_len); +#endif + if (imm.vertex_idx == imm.vertex_len) { + buffer_bytes_used = imm.buffer_bytes_mapped; + } + else { +#if TRUST_NO_ONE + assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type)); +#endif + imm.vertex_len = imm.vertex_idx; + buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_len); + /* unused buffer bytes are available to the next immBegin */ + } + /* tell OpenGL what range was modified so it doesn't copy the whole mapped range */ + glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, buffer_bytes_used); + } + + if (imm.batch) { + if (buffer_bytes_used != imm.buffer_bytes_mapped) { + GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); + /* TODO: resize only if vertex count is much smaller */ + } + GWN_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface); + imm.batch->phase = GWN_BATCH_READY_TO_DRAW; + imm.batch = NULL; /* don't free, batch belongs to caller */ + } + else { + glUnmapBuffer(GL_ARRAY_BUFFER); + if (imm.vertex_len > 0) { + immDrawSetup(); + glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_len); + } + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); + /* prep for next immBegin */ + imm.buffer_offset += buffer_bytes_used; + } + + /* prep for next immBegin */ + imm.prim_type = GWN_PRIM_NONE; + imm.strict_vertex_len = true; +} + +static void setAttribValueBit(uint attrib_id) +{ + uint16_t mask = 1 << attrib_id; +#if TRUST_NO_ONE + assert(imm.unassigned_attrib_bits & mask); /* not already set */ +#endif + imm.unassigned_attrib_bits &= ~mask; +} + + +/* --- generic attribute functions --- */ + +void immAttrib1f(uint attrib_id, float x) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_len == 1); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + float* data = (float*)(imm.vertex_data + attrib->offset); +/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ + + data[0] = x; +} + +void immAttrib2f(uint attrib_id, float x, float y) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + float* data = (float*)(imm.vertex_data + attrib->offset); +/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ + + data[0] = x; + data[1] = y; +} + +void immAttrib3f(uint attrib_id, float x, float y, float z) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_len == 3); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + float* data = (float*)(imm.vertex_data + attrib->offset); +/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ + + data[0] = x; + data[1] = y; + data[2] = z; +} + +void immAttrib4f(uint attrib_id, float x, float y, float z, float w) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_len == 4); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + float* data = (float*)(imm.vertex_data + attrib->offset); +/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ + + data[0] = x; + data[1] = y; + data[2] = z; + data[3] = w; +} + +void immAttrib1u(uint attrib_id, uint x) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_U32); + assert(attrib->comp_len == 1); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + uint* data = (uint*)(imm.vertex_data + attrib->offset); + + data[0] = x; +} + +void immAttrib2i(uint attrib_id, int x, int y) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_I32); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + int* data = (int*)(imm.vertex_data + attrib->offset); + + data[0] = x; + data[1] = y; +} + +void immAttrib2s(uint attrib_id, short x, short y) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_I16); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + short* data = (short*)(imm.vertex_data + attrib->offset); + + data[0] = x; + data[1] = y; +} + +void immAttrib2fv(uint attrib_id, const float data[2]) +{ + immAttrib2f(attrib_id, data[0], data[1]); +} + +void immAttrib3fv(uint attrib_id, const float data[3]) +{ + immAttrib3f(attrib_id, data[0], data[1], data[2]); +} + +void immAttrib4fv(uint attrib_id, const float data[4]) +{ + immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]); +} + +void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_U8); + assert(attrib->comp_len == 3); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + GLubyte* data = imm.vertex_data + attrib->offset; +/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */ + + data[0] = r; + data[1] = g; + data[2] = b; +} + +void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a) +{ + Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(attrib->comp_type == GWN_COMP_U8); + assert(attrib->comp_len == 4); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); + + GLubyte* data = imm.vertex_data + attrib->offset; +/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */ + + data[0] = r; + data[1] = g; + data[2] = b; + data[3] = a; +} + +void immAttrib3ubv(uint attrib_id, const unsigned char data[3]) +{ + immAttrib3ub(attrib_id, data[0], data[1], data[2]); +} + +void immAttrib4ubv(uint attrib_id, const unsigned char data[4]) +{ + immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]); +} + +void immSkipAttrib(uint attrib_id) +{ +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attr_len); + assert(imm.vertex_idx < imm.vertex_len); + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ +#endif + setAttribValueBit(attrib_id); +} + +static void immEndVertex(void) /* and move on to the next vertex */ +{ +#if TRUST_NO_ONE + assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.vertex_idx < imm.vertex_len); +#endif + + /* have all attribs been assigned values? + * if not, copy value from previous vertex */ + if (imm.unassigned_attrib_bits) { +#if TRUST_NO_ONE + assert(imm.vertex_idx > 0); /* first vertex must have all attribs specified */ +#endif + for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { + if ((imm.unassigned_attrib_bits >> a_idx) & 1) { + const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; + +/* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */ + + GLubyte* data = imm.vertex_data + a->offset; + memcpy(data, data - imm.vertex_format.stride, a->sz); + /* TODO: consolidate copy of adjacent attributes */ + } + } + } + + imm.vertex_idx++; + imm.vertex_data += imm.vertex_format.stride; + imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; +} + +void immVertex2f(uint attrib_id, float x, float y) +{ + immAttrib2f(attrib_id, x, y); + immEndVertex(); +} + +void immVertex3f(uint attrib_id, float x, float y, float z) +{ + immAttrib3f(attrib_id, x, y, z); + immEndVertex(); +} + +void immVertex4f(uint attrib_id, float x, float y, float z, float w) +{ + immAttrib4f(attrib_id, x, y, z, w); + immEndVertex(); +} + +void immVertex2i(uint attrib_id, int x, int y) +{ + immAttrib2i(attrib_id, x, y); + immEndVertex(); +} + +void immVertex2s(uint attrib_id, short x, short y) +{ + immAttrib2s(attrib_id, x, y); + immEndVertex(); +} + +void immVertex2fv(uint attrib_id, const float data[2]) +{ + immAttrib2f(attrib_id, data[0], data[1]); + immEndVertex(); +} + +void immVertex3fv(uint attrib_id, const float data[3]) +{ + immAttrib3f(attrib_id, data[0], data[1], data[2]); + immEndVertex(); +} + +void immVertex2iv(uint attrib_id, const int data[2]) +{ + immAttrib2i(attrib_id, data[0], data[1]); + immEndVertex(); +} + + +/* --- generic uniform functions --- */ + +#if 0 + #if TRUST_NO_ONE + #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); assert(uniform); + #else + #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); + #endif +#else + /* NOTE: It is possible to have uniform fully optimized out from the shader. + * In this case we can't assert failure or allow NULL-pointer dereference. + * TODO(sergey): How can we detect existing-but-optimized-out uniform but still + * catch typos in uniform names passed to immUniform*() functions? */ + #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; +#endif + +void immUniform1f(const char* name, float x) +{ + GET_UNIFORM + glUniform1f(uniform->location, x); +} + +void immUniform2f(const char* name, float x, float y) +{ + GET_UNIFORM + glUniform2f(uniform->location, x, y); +} + +void immUniform2fv(const char* name, const float data[2]) +{ + GET_UNIFORM + glUniform2fv(uniform->location, 1, data); +} + +void immUniform3f(const char* name, float x, float y, float z) +{ + GET_UNIFORM + glUniform3f(uniform->location, x, y, z); +} + +void immUniform3fv(const char* name, const float data[3]) +{ + GET_UNIFORM + glUniform3fv(uniform->location, 1, data); +} + +/* can increase this limit or move to another file */ +#define MAX_UNIFORM_NAME_LEN 60 + +void immUniformArray3fv(const char* bare_name, const float *data, int count) +{ + /* look up "name[0]" when given "name" */ + const size_t len = strlen(bare_name); +#if TRUST_NO_ONE + assert(len <= MAX_UNIFORM_NAME_LEN); +#endif + char name[MAX_UNIFORM_NAME_LEN]; + strcpy(name, bare_name); + name[len + 0] = '['; + name[len + 1] = '0'; + name[len + 2] = ']'; + name[len + 3] = '\0'; + + GET_UNIFORM + glUniform3fv(uniform->location, count, data); +} + +void immUniform4f(const char* name, float x, float y, float z, float w) +{ + GET_UNIFORM + glUniform4f(uniform->location, x, y, z, w); +} + +void immUniform4fv(const char* name, const float data[4]) +{ + GET_UNIFORM + glUniform4fv(uniform->location, 1, data); +} + +void immUniformArray4fv(const char* bare_name, const float *data, int count) +{ + /* look up "name[0]" when given "name" */ + const size_t len = strlen(bare_name); +#if TRUST_NO_ONE + assert(len <= MAX_UNIFORM_NAME_LEN); +#endif + char name[MAX_UNIFORM_NAME_LEN]; + strcpy(name, bare_name); + name[len + 0] = '['; + name[len + 1] = '0'; + name[len + 2] = ']'; + name[len + 3] = '\0'; + + GET_UNIFORM + glUniform4fv(uniform->location, count, data); +} + +void immUniformMatrix4fv(const char* name, const float data[4][4]) +{ + GET_UNIFORM + glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (float *)data); +} + +void immUniform1i(const char* name, int x) +{ + GET_UNIFORM + glUniform1i(uniform->location, x); +} + +void immUniform4iv(const char* name, const int data[4]) +{ + GET_UNIFORM + glUniform4iv(uniform->location, 1, data); +} + +/* --- convenience functions for setting "uniform vec4 color" --- */ + +void immUniformColor4f(float r, float g, float b, float a) +{ + const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform_builtin(imm.shader_interface, GWN_UNIFORM_COLOR); +#if TRUST_NO_ONE + assert(uniform != NULL); +#endif + glUniform4f(uniform->location, r, g, b, a); +} + +void immUniformColor4fv(const float rgba[4]) +{ + immUniformColor4f(rgba[0], rgba[1], rgba[2], rgba[3]); +} + +void immUniformColor3f(float r, float g, float b) +{ + immUniformColor4f(r, g, b, 1.0f); +} + +void immUniformColor3fv(const float rgb[3]) +{ + immUniformColor4f(rgb[0], rgb[1], rgb[2], 1.0f); +} + +void immUniformColor3fvAlpha(const float rgb[3], float a) +{ + immUniformColor4f(rgb[0], rgb[1], rgb[2], a); +} + +/* TODO: v-- treat as sRGB? --v */ + +void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b) +{ + const float scale = 1.0f / 255.0f; + immUniformColor4f(scale * r, scale * g, scale * b, 1.0f); +} + +void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) +{ + const float scale = 1.0f / 255.0f; + immUniformColor4f(scale * r, scale * g, scale * b, scale * a); +} + +void immUniformColor3ubv(const unsigned char rgb[3]) +{ + immUniformColor3ub(rgb[0], rgb[1], rgb[2]); +} + +void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char alpha) +{ + immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha); +} + +void immUniformColor4ubv(const unsigned char rgba[4]) +{ + immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]); +} + void immUniformThemeColor(int color_id) { float color[4]; diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index 30672af9c02..4b2fb1b8e8a 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -18,8 +18,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file source/blender/gpu/intern/gpu_immediate_util.c +/** \file blender/gpu/intern/gwn_imm_util.c * \ingroup gpu + * + * Gawain immediate mode drawing utilities */ #include @@ -66,6 +68,72 @@ static const int cube_line_index[12][2] = { {6, 7}, }; +void immRectf(uint pos, float x1, float y1, float x2, float y2) +{ + immBegin(GWN_PRIM_TRI_FAN, 4); + immVertex2f(pos, x1, y1); + immVertex2f(pos, x2, y1); + immVertex2f(pos, x2, y2); + immVertex2f(pos, x1, y2); + immEnd(); +} + +void immRecti(uint pos, int x1, int y1, int x2, int y2) +{ + immBegin(GWN_PRIM_TRI_FAN, 4); + immVertex2i(pos, x1, y1); + immVertex2i(pos, x2, y1); + immVertex2i(pos, x2, y2); + immVertex2i(pos, x1, y2); + immEnd(); +} + +void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]) +{ + immAttrib4fv(col, color); + immVertex2f(pos, x1, y1); + immAttrib4fv(col, color); + immVertex2f(pos, x2, y1); + immAttrib4fv(col, color); + immVertex2f(pos, x2, y2); + + immAttrib4fv(col, color); + immVertex2f(pos, x1, y1); + immAttrib4fv(col, color); + immVertex2f(pos, x2, y2); + immAttrib4fv(col, color); + immVertex2f(pos, x1, y2); +} + +void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]) +{ + immAttrib4fv(col, color); + immVertex2i(pos, x1, y1); + immAttrib4fv(col, color); + immVertex2i(pos, x2, y1); + immAttrib4fv(col, color); + immVertex2i(pos, x2, y2); + + immAttrib4fv(col, color); + immVertex2i(pos, x1, y1); + immAttrib4fv(col, color); + immVertex2i(pos, x2, y2); + immAttrib4fv(col, color); + immVertex2i(pos, x1, y2); +} + +#if 0 /* more complete version in case we want that */ +void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4]) +{ + Gwn_VertFormat *format = immVertexFormat(); + uint pos = add_attrib(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor4fv(color); + immRecti(pos, x1, y1, x2, y2); + immUnbindProgram(); +} +#endif + /** * Pack color into 3 bytes * diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c index 2af1375a620..13c6fbea1c6 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.c @@ -29,7 +29,7 @@ * \ingroup gpu */ -#include "../../../intern/gawain/gawain/gwn_shader_interface.h" +#include "GPU_shader_interface.h" #define SUPPRESS_GENERIC_MATRIX_API #define USE_GPU_PY_MATRIX_API /* only so values are declared */ diff --git a/source/blender/gpu/intern/gpu_primitive.c b/source/blender/gpu/intern/gpu_primitive.c new file mode 100644 index 00000000000..0f0c28c05dc --- /dev/null +++ b/source/blender/gpu/intern/gpu_primitive.c @@ -0,0 +1,84 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_primitive.c + * \ingroup gpu + * + * Gawain geometric primitives + */ + +#include "GPU_primitive.h" +#include "gpu_primitive_private.h" + +Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type) +{ + static const Gwn_PrimClass classes[] = { + [GWN_PRIM_POINTS] = GWN_PRIM_CLASS_POINT, + [GWN_PRIM_LINES] = GWN_PRIM_CLASS_LINE, + [GWN_PRIM_LINE_STRIP] = GWN_PRIM_CLASS_LINE, + [GWN_PRIM_LINE_LOOP] = GWN_PRIM_CLASS_LINE, + [GWN_PRIM_TRIS] = GWN_PRIM_CLASS_SURFACE, + [GWN_PRIM_TRI_STRIP] = GWN_PRIM_CLASS_SURFACE, + [GWN_PRIM_TRI_FAN] = GWN_PRIM_CLASS_SURFACE, + + [GWN_PRIM_LINES_ADJ] = GWN_PRIM_CLASS_LINE, + [GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE, + [GWN_PRIM_TRIS_ADJ] = GWN_PRIM_CLASS_SURFACE, + + [GWN_PRIM_NONE] = GWN_PRIM_CLASS_NONE + }; + + return classes[prim_type]; +} + +bool GWN_primtype_belongs_to_class(Gwn_PrimType prim_type, Gwn_PrimClass prim_class) +{ + if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE) { + return true; + } + return prim_class & GWN_primtype_class(prim_type); +} + +GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type) +{ +#if TRUST_NO_ONE + assert(prim_type != GWN_PRIM_NONE); +#endif + static const GLenum table[] = { + [GWN_PRIM_POINTS] = GL_POINTS, + [GWN_PRIM_LINES] = GL_LINES, + [GWN_PRIM_LINE_STRIP] = GL_LINE_STRIP, + [GWN_PRIM_LINE_LOOP] = GL_LINE_LOOP, + [GWN_PRIM_TRIS] = GL_TRIANGLES, + [GWN_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP, + [GWN_PRIM_TRI_FAN] = GL_TRIANGLE_FAN, + + [GWN_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY, + [GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY, + [GWN_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY, + }; + + return table[prim_type]; +} diff --git a/source/blender/gpu/intern/gpu_primitive_private.h b/source/blender/gpu/intern/gpu_primitive_private.h new file mode 100644 index 00000000000..6d3f1e20da7 --- /dev/null +++ b/source/blender/gpu/intern/gpu_primitive_private.h @@ -0,0 +1,37 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_primitive_private.h + * \ingroup gpu + * + * Gawain geometric primitives + */ + +#ifndef __GWN_PRIMITIVE_PRIVATE_H__ +#define __GWN_PRIMITIVE_PRIVATE_H__ + +GLenum convert_prim_type_to_gl(Gwn_PrimType); + +#endif /* __GWN_PRIMITIVE_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c new file mode 100644 index 00000000000..56b25726a84 --- /dev/null +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -0,0 +1,361 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_shader_interface.c + * \ingroup gpu + * + * Gawain shader interface (C --> GLSL) + */ + +#include "gpu_batch_private.h" +#include "GPU_shader_interface.h" +#include "GPU_vertex_array_id.h" +#include +#include +#include + +#define DEBUG_SHADER_INTERFACE 0 + +#if DEBUG_SHADER_INTERFACE + #include +#endif + +static const char* BuiltinUniform_name(Gwn_UniformBuiltin u) +{ + static const char* names[] = { + [GWN_UNIFORM_NONE] = NULL, + + [GWN_UNIFORM_MODEL] = "ModelMatrix", + [GWN_UNIFORM_VIEW] = "ViewMatrix", + [GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix", + [GWN_UNIFORM_PROJECTION] = "ProjectionMatrix", + [GWN_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix", + [GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix", + + [GWN_UNIFORM_MODEL_INV] = "ModelMatrixInverse", + [GWN_UNIFORM_VIEW_INV] = "ViewMatrixInverse", + [GWN_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse", + [GWN_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse", + [GWN_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse", + + [GWN_UNIFORM_NORMAL] = "NormalMatrix", + [GWN_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix", + [GWN_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors", + [GWN_UNIFORM_ORCO] = "OrcoTexCoFactors", + + [GWN_UNIFORM_COLOR] = "color", + [GWN_UNIFORM_EYE] = "eye", + [GWN_UNIFORM_CALLID] = "callId", + + [GWN_UNIFORM_CUSTOM] = NULL, + [GWN_NUM_UNIFORMS] = NULL, + }; + + return names[u]; +} + +GWN_INLINE bool match(const char* a, const char* b) +{ + return strcmp(a, b) == 0; +} + +GWN_INLINE uint hash_string(const char *str) +{ + uint i = 0, c; + while ((c = *str++)) { + i = i * 37 + c; + } + return i; +} + +GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* input, + const char* name, uint32_t name_len) +{ + input->name_offset = shaderface->name_buffer_offset; + input->name_hash = hash_string(name); + shaderface->name_buffer_offset += name_len + 1; /* include NULL terminator */ +} + +GWN_INLINE void shader_input_to_bucket(Gwn_ShaderInput* input, + Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) +{ + const uint bucket_index = input->name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; + input->next = buckets[bucket_index]; + buckets[bucket_index] = input; +} + +GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[GWN_NUM_SHADERINTERFACE_BUCKETS], + const char *name_buffer, const char *name) +{ + const uint name_hash = hash_string(name); + const uint bucket_index = name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; + const Gwn_ShaderInput* input = buckets[bucket_index]; + if (input == NULL) { + /* Requested uniform is not found at all. */ + return NULL; + } + /* Optimization bit: if there is no hash collision detected when constructing shader interface + * it means we can only request the single possible uniform. Surely, it's possible we request + * uniform which causes hash collision, but that will be detected in debug builds. */ + if (input->next == NULL) { + if (name_hash == input->name_hash) { +#if TRUST_NO_ONE + assert(match(name_buffer + input->name_offset, name)); +#endif + return input; + } + return NULL; + } + /* Work through possible collisions. */ + const Gwn_ShaderInput* next = input; + while (next != NULL) { + input = next; + next = input->next; + if (input->name_hash != name_hash) { + continue; + } + if (match(name_buffer + input->name_offset, name)) { + return input; + } + } + return NULL; /* not found */ +} + +GWN_INLINE void buckets_free(Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) +{ + for (uint bucket_index = 0; bucket_index < GWN_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) { + Gwn_ShaderInput *input = buckets[bucket_index]; + while (input != NULL) { + Gwn_ShaderInput *input_next = input->next; + free(input); + input = input_next; + } + } +} + +static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name) +{ + /* TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types */ + + /* detect built-in uniforms (name must match) */ + for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { + const char* builtin_name = BuiltinUniform_name(u); + if (match(name, builtin_name)) { + input->builtin_type = u; + return true; + } + } + input->builtin_type = GWN_UNIFORM_CUSTOM; + return false; +} + +static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const char* name) +{ + Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + + input->location = glGetUniformLocation(shaderface->program, name); + + uint name_len = strlen(name); + shaderface->name_buffer = realloc(shaderface->name_buffer, shaderface->name_buffer_offset + name_len + 1); /* include NULL terminator */ + char* name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset; + strcpy(name_buffer, name); + + set_input_name(shaderface, input, name, name_len); + setup_builtin_uniform(input, name); + + shader_input_to_bucket(input, shaderface->uniform_buckets); + if (input->builtin_type != GWN_UNIFORM_NONE && + input->builtin_type != GWN_UNIFORM_CUSTOM) + { + shaderface->builtin_uniforms[input->builtin_type] = input; + } +#if DEBUG_SHADER_INTERFACE + printf("Gwn_ShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, + shaderface->program, + name, + input->location); +#endif + return input; +} + +Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) +{ + Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface)); + shaderface->program = program; + +#if DEBUG_SHADER_INTERFACE + printf("%s {\n", __func__); /* enter function */ + printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program); +#endif + + GLint max_attrib_name_len, attr_len; + glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len); + glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attr_len); + + GLint max_ubo_name_len, ubo_len; + glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len); + glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_len); + + const uint32_t name_buffer_len = attr_len * max_attrib_name_len + ubo_len * max_ubo_name_len; + shaderface->name_buffer = malloc(name_buffer_len); + + /* Attributes */ + for (uint32_t i = 0; i < attr_len; ++i) { + Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; + char* name = shaderface->name_buffer + shaderface->name_buffer_offset; + GLsizei name_len = 0; + + glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name); + + /* remove "[0]" from array name */ + if (name[name_len-1] == ']') { + name[name_len-3] = '\0'; + name_len -= 3; + } + + /* TODO: reject DOUBLE gl_types */ + + input->location = glGetAttribLocation(program, name); + + set_input_name(shaderface, input, name, name_len); + + shader_input_to_bucket(input, shaderface->attrib_buckets); + +#if DEBUG_SHADER_INTERFACE + printf("attrib[%u] '%s' at location %d\n", i, name, input->location); +#endif + } + /* Uniform Blocks */ + for (uint32_t i = 0; i < ubo_len; ++i) { + Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; + char* name = shaderface->name_buffer + shaderface->name_buffer_offset; + GLsizei name_len = 0; + + glGetActiveUniformBlockName(program, i, remaining_buffer, &name_len, name); + + input->location = i; + + set_input_name(shaderface, input, name, name_len); + + shader_input_to_bucket(input, shaderface->ubo_buckets); + +#if DEBUG_SHADER_INTERFACE + printf("ubo '%s' at location %d\n", name, input->location); +#endif + } + /* Builtin Uniforms */ + for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { + const char* builtin_name = BuiltinUniform_name(u); + if (glGetUniformLocation(program, builtin_name) != -1) { + add_uniform((Gwn_ShaderInterface*)shaderface, builtin_name); + } + } + /* Batches ref buffer */ + shaderface->batches_len = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = calloc(shaderface->batches_len, sizeof(Gwn_Batch*)); + + return shaderface; +} + +void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) +{ + /* Free memory used by buckets and has entries. */ + buckets_free(shaderface->uniform_buckets); + buckets_free(shaderface->attrib_buckets); + buckets_free(shaderface->ubo_buckets); + /* Free memory used by name_buffer. */ + free(shaderface->name_buffer); + /* Remove this interface from all linked Batches vao cache. */ + for (int i = 0; i < shaderface->batches_len; ++i) { + if (shaderface->batches[i] != NULL) { + gwn_batch_remove_interface_ref(shaderface->batches[i], shaderface); + } + } + free(shaderface->batches); + /* Free memory used by shader interface by its self. */ + free(shaderface); +} + +const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name) +{ + /* TODO: Warn if we find a matching builtin, since these can be looked up much quicker. */ + const Gwn_ShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); + /* If input is not found add it so it's found next time. */ + if (input == NULL) { + input = add_uniform((Gwn_ShaderInterface*)shaderface, name); + } + return (input->location != -1) ? input : NULL; +} + +const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin( + const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin) +{ +#if TRUST_NO_ONE + assert(builtin != GWN_UNIFORM_NONE); + assert(builtin != GWN_UNIFORM_CUSTOM); + assert(builtin != GWN_NUM_UNIFORMS); +#endif + return shaderface->builtin_uniforms[builtin]; +} + +const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface* shaderface, const char* name) +{ + return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name); +} + +const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name) +{ + return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name); +} + +void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) +{ + int i; /* find first unused slot */ + for (i = 0; i < shaderface->batches_len; ++i) { + if (shaderface->batches[i] == NULL) { + break; + } + } + if (i == shaderface->batches_len) { + /* Not enough place, realloc the array. */ + i = shaderface->batches_len; + shaderface->batches_len += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_len); + memset(shaderface->batches + i, 0, sizeof(Gwn_Batch*) * GWN_SHADERINTERFACE_REF_ALLOC_COUNT); + } + shaderface->batches[i] = batch; +} + +void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) +{ + for (int i = 0; i < shaderface->batches_len; ++i) { + if (shaderface->batches[i] == batch) { + shaderface->batches[i] = NULL; + break; /* cannot have duplicates */ + } + } +} diff --git a/source/blender/gpu/intern/gpu_shader_private.h b/source/blender/gpu/intern/gpu_shader_private.h index de5439c5638..bf54d269fb5 100644 --- a/source/blender/gpu/intern/gpu_shader_private.h +++ b/source/blender/gpu/intern/gpu_shader_private.h @@ -26,7 +26,7 @@ #define __GPU_SHADER_PRIVATE_H__ #include "GPU_glew.h" -#include "gawain/gwn_shader_interface.h" +#include "GPU_shader_interface.h" struct GPUShader { GLuint program; /* handle for full program (links shader stages below) */ diff --git a/source/blender/gpu/intern/gpu_vertex_array_id.cpp b/source/blender/gpu/intern/gpu_vertex_array_id.cpp new file mode 100644 index 00000000000..de5be15ec19 --- /dev/null +++ b/source/blender/gpu/intern/gpu_vertex_array_id.cpp @@ -0,0 +1,196 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation, Clément Foucault + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_vertex_array_id.cpp + * \ingroup gpu + * + * Manage GL vertex array IDs in a thread-safe way + * Use these instead of glGenBuffers & its friends + * - alloc must be called from a thread that is bound + * to the context that will be used for drawing with + * this vao. + * - free can be called from any thread + */ + +#include "gpu_batch_private.h" +#include "GPU_vertex_array_id.h" +#include "GPU_context.h" +#include +#include +#include +#include +#include + +#if TRUST_NO_ONE +#if 0 +extern "C" { +extern int BLI_thread_is_main(void); /* Blender-specific function */ +} + +static bool thread_is_main() { + /* "main" here means the GL context's thread */ + return BLI_thread_is_main(); +} +#endif +#endif + +struct Gwn_Context { + GLuint default_vao; + std::unordered_set batches; /* Batches that have VAOs from this context */ + std::vector orphaned_vertarray_ids; + std::mutex orphans_mutex; /* todo: try spinlock instead */ +#if TRUST_NO_ONE + pthread_t thread; /* Thread on which this context is active. */ + bool thread_is_used; + + Gwn_Context() { + thread_is_used = false; + } +#endif +}; + +#if defined(_MSC_VER) && (_MSC_VER == 1800) +#define thread_local __declspec(thread) +thread_local Gwn_Context* active_ctx = NULL; +#else +static thread_local Gwn_Context* active_ctx = NULL; +#endif + +static void clear_orphans(Gwn_Context* ctx) +{ + ctx->orphans_mutex.lock(); + if (!ctx->orphaned_vertarray_ids.empty()) { + uint orphan_len = (uint)ctx->orphaned_vertarray_ids.size(); + glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data()); + ctx->orphaned_vertarray_ids.clear(); + } + ctx->orphans_mutex.unlock(); +} + +Gwn_Context* GWN_context_create(void) +{ +#if TRUST_NO_ONE + /* assert(thread_is_main()); */ +#endif + Gwn_Context* ctx = new Gwn_Context; + glGenVertexArrays(1, &ctx->default_vao); + GWN_context_active_set(ctx); + return ctx; +} + +/* to be called after GWN_context_active_set(ctx_to_destroy) */ +void GWN_context_discard(Gwn_Context* ctx) +{ +#if TRUST_NO_ONE + /* Make sure no other thread has locked it. */ + assert(ctx == active_ctx); + assert(pthread_equal(pthread_self(), ctx->thread)); + assert(ctx->orphaned_vertarray_ids.empty()); +#endif + /* delete remaining vaos */ + while (!ctx->batches.empty()) { + /* this removes the array entry */ + gwn_batch_vao_cache_clear(*ctx->batches.begin()); + } + glDeleteVertexArrays(1, &ctx->default_vao); + delete ctx; + active_ctx = NULL; +} + +/* ctx can be NULL */ +void GWN_context_active_set(Gwn_Context* ctx) +{ +#if TRUST_NO_ONE + if (active_ctx) { + active_ctx->thread_is_used = false; + } + /* Make sure no other context is already bound to this thread. */ + if (ctx) { + /* Make sure no other thread has locked it. */ + assert(ctx->thread_is_used == false); + ctx->thread = pthread_self(); + ctx->thread_is_used = true; + } +#endif + if (ctx) { + clear_orphans(ctx); + } + active_ctx = ctx; +} + +Gwn_Context* GWN_context_active_get(void) +{ + return active_ctx; +} + +GLuint GWN_vao_default(void) +{ +#if TRUST_NO_ONE + assert(active_ctx); /* need at least an active context */ + assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ +#endif + return active_ctx->default_vao; +} + +GLuint GWN_vao_alloc(void) +{ +#if TRUST_NO_ONE + assert(active_ctx); /* need at least an active context */ + assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ +#endif + clear_orphans(active_ctx); + + GLuint new_vao_id = 0; + glGenVertexArrays(1, &new_vao_id); + return new_vao_id; +} + +/* this can be called from multiple thread */ +void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx) +{ +#if TRUST_NO_ONE + assert(ctx); +#endif + if (ctx == active_ctx) { + glDeleteVertexArrays(1, &vao_id); + } + else { + ctx->orphans_mutex.lock(); + ctx->orphaned_vertarray_ids.emplace_back(vao_id); + ctx->orphans_mutex.unlock(); + } +} + +void gwn_context_add_batch(Gwn_Context* ctx, Gwn_Batch* batch) +{ + ctx->batches.emplace(batch); +} + +void gwn_context_remove_batch(Gwn_Context* ctx, Gwn_Batch* batch) +{ + ctx->orphans_mutex.lock(); + ctx->batches.erase(batch); + ctx->orphans_mutex.unlock(); +} diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c new file mode 100644 index 00000000000..32f3d494015 --- /dev/null +++ b/source/blender/gpu/intern/gpu_vertex_buffer.c @@ -0,0 +1,268 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation, Clément Foucault + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_vertex_buffer.c + * \ingroup gpu + * + * Gawain vertex buffer + */ + +#include "GPU_vertex_buffer.h" +#include "GPU_buffer_id.h" +#include "gpu_vertex_format_private.h" +#include +#include + +#define KEEP_SINGLE_COPY 1 + +static uint vbo_memory_usage; + +static GLenum convert_usage_type_to_gl(Gwn_UsageType type) +{ + static const GLenum table[] = { + [GWN_USAGE_STREAM] = GL_STREAM_DRAW, + [GWN_USAGE_STATIC] = GL_STATIC_DRAW, + [GWN_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW + }; + return table[type]; +} + +Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType usage) +{ + Gwn_VertBuf* verts = malloc(sizeof(Gwn_VertBuf)); + GWN_vertbuf_init(verts, usage); + return verts; +} + +Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat* format, Gwn_UsageType usage) +{ + Gwn_VertBuf* verts = GWN_vertbuf_create(usage); + GWN_vertformat_copy(&verts->format, format); + if (!format->packed) { + VertexFormat_pack(&verts->format); + } + return verts; + + /* this function might seem redundant, but there is potential for memory savings here... */ + /* TODO: implement those memory savings */ +} + +void GWN_vertbuf_init(Gwn_VertBuf* verts, Gwn_UsageType usage) +{ + memset(verts, 0, sizeof(Gwn_VertBuf)); + verts->usage = usage; + verts->dirty = true; +} + +void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf* verts, const Gwn_VertFormat* format, Gwn_UsageType usage) +{ + GWN_vertbuf_init(verts, usage); + GWN_vertformat_copy(&verts->format, format); + if (!format->packed) { + VertexFormat_pack(&verts->format); + } +} + +void GWN_vertbuf_discard(Gwn_VertBuf* verts) +{ + if (verts->vbo_id) { + GWN_buf_id_free(verts->vbo_id); +#if VRAM_USAGE + vbo_memory_usage -= GWN_vertbuf_size_get(verts); +#endif + } + if (verts->data) { + free(verts->data); + } + free(verts); +} + +uint GWN_vertbuf_size_get(const Gwn_VertBuf* verts) +{ + return vertex_buffer_size(&verts->format, verts->vertex_len); +} + +/* create a new allocation, discarding any existing data */ +void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) +{ + Gwn_VertFormat* format = &verts->format; + if (!format->packed) { + VertexFormat_pack(format); + } +#if TRUST_NO_ONE + /* catch any unnecessary use */ + assert(verts->vertex_alloc != v_len || verts->data == NULL); +#endif + /* only create the buffer the 1st time */ + if (verts->vbo_id == 0) { + verts->vbo_id = GWN_buf_id_alloc(); + } + /* discard previous data if any */ + if (verts->data) { + free(verts->data); + } +#if VRAM_USAGE + uint new_size = vertex_buffer_size(&verts->format, v_len); + vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); +#endif + verts->dirty = true; + verts->vertex_len = verts->vertex_alloc = v_len; + verts->data = malloc(sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); +} + +/* resize buffer keeping existing data */ +void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, uint v_len) +{ +#if TRUST_NO_ONE + assert(verts->data != NULL); + assert(verts->vertex_alloc != v_len); +#endif + +#if VRAM_USAGE + uint new_size = vertex_buffer_size(&verts->format, v_len); + vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); +#endif + verts->dirty = true; + verts->vertex_len = verts->vertex_alloc = v_len; + verts->data = realloc(verts->data, sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); +} + +/* Set vertex count but does not change allocation. + * Only this many verts will be uploaded to the GPU and rendered. + * This is usefull for streaming data. */ +void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, uint v_len) +{ +#if TRUST_NO_ONE + assert(verts->data != NULL); /* only for dynamic data */ + assert(v_len <= verts->vertex_alloc); +#endif + +#if VRAM_USAGE + uint new_size = vertex_buffer_size(&verts->format, v_len); + vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); +#endif + verts->vertex_len = v_len; +} + +void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, uint a_idx, uint v_idx, const void* data) +{ + const Gwn_VertFormat* format = &verts->format; + const Gwn_VertAttr* a = format->attribs + a_idx; + +#if TRUST_NO_ONE + assert(a_idx < format->attr_len); + assert(v_idx < verts->vertex_alloc); + assert(verts->data != NULL); +#endif + verts->dirty = true; + memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz); +} + +void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, uint a_idx, const void* data) +{ + const Gwn_VertFormat* format = &verts->format; + const Gwn_VertAttr* a = format->attribs + a_idx; + +#if TRUST_NO_ONE + assert(a_idx < format->attr_len); +#endif + const uint stride = a->sz; /* tightly packed input data */ + + GWN_vertbuf_attr_fill_stride(verts, a_idx, stride, data); +} + +void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, uint a_idx, uint stride, const void* data) +{ + const Gwn_VertFormat* format = &verts->format; + const Gwn_VertAttr* a = format->attribs + a_idx; + +#if TRUST_NO_ONE + assert(a_idx < format->attr_len); + assert(verts->data != NULL); +#endif + verts->dirty = true; + const uint vertex_len = verts->vertex_len; + + if (format->attr_len == 1 && stride == format->stride) { + /* we can copy it all at once */ + memcpy(verts->data, data, vertex_len * a->sz); + } + else { + /* we must copy it per vertex */ + for (uint v = 0; v < vertex_len; ++v) { + memcpy((GLubyte*)verts->data + a->offset + v * format->stride, (const GLubyte*)data + v * stride, a->sz); + } + } +} + +void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, uint a_idx, Gwn_VertBufRaw *access) +{ + const Gwn_VertFormat* format = &verts->format; + const Gwn_VertAttr* a = format->attribs + a_idx; + +#if TRUST_NO_ONE + assert(a_idx < format->attr_len); + assert(verts->data != NULL); +#endif + + verts->dirty = true; + + access->size = a->sz; + access->stride = format->stride; + access->data = (GLubyte*)verts->data + a->offset; + access->data_init = access->data; +#if TRUST_NO_ONE + access->_data_end = access->data_init + (size_t)(verts->vertex_alloc * format->stride); +#endif +} + +static void VertBuffer_upload_data(Gwn_VertBuf* verts) +{ + uint buffer_sz = GWN_vertbuf_size_get(verts); + + /* orphan the vbo to avoid sync */ + glBufferData(GL_ARRAY_BUFFER, buffer_sz, NULL, convert_usage_type_to_gl(verts->usage)); + /* upload data */ + glBufferSubData(GL_ARRAY_BUFFER, 0, buffer_sz, verts->data); + + if (verts->usage == GWN_USAGE_STATIC) { + free(verts->data); + verts->data = NULL; + } + verts->dirty = false; +} + +void GWN_vertbuf_use(Gwn_VertBuf* verts) +{ + glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id); + if (verts->dirty) { + VertBuffer_upload_data(verts); + } +} + +uint GWN_vertbuf_get_memory_usage(void) +{ + return vbo_memory_usage; +} diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c new file mode 100644 index 00000000000..bd9f9250564 --- /dev/null +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -0,0 +1,310 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation, Clément Foucault + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gwn_vertex_format.c + * \ingroup gpu + * + * Gawain vertex format + */ + +#include "GPU_vertex_format.h" +#include "gpu_vertex_format_private.h" +#include +#include + +#define PACK_DEBUG 0 + +#if PACK_DEBUG + #include +#endif + +void GWN_vertformat_clear(Gwn_VertFormat* format) +{ +#if TRUST_NO_ONE + memset(format, 0, sizeof(Gwn_VertFormat)); +#else + format->attr_len = 0; + format->packed = false; + format->name_offset = 0; + format->name_len = 0; + + for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++) { + format->attribs[i].name_len = 0; + } +#endif +} + +void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) +{ + /* copy regular struct fields */ + memcpy(dest, src, sizeof(Gwn_VertFormat)); + + for (unsigned i = 0; i < dest->attr_len; i++) { + for (unsigned j = 0; j < dest->attribs[i].name_len; j++) { + dest->attribs[i].name[j] = (char *)dest + (src->attribs[i].name[j] - ((char *)src)); + } + } +} + +static GLenum convert_comp_type_to_gl(Gwn_VertCompType type) +{ + static const GLenum table[] = { + [GWN_COMP_I8] = GL_BYTE, + [GWN_COMP_U8] = GL_UNSIGNED_BYTE, + [GWN_COMP_I16] = GL_SHORT, + [GWN_COMP_U16] = GL_UNSIGNED_SHORT, + [GWN_COMP_I32] = GL_INT, + [GWN_COMP_U32] = GL_UNSIGNED_INT, + + [GWN_COMP_F32] = GL_FLOAT, + + [GWN_COMP_I10] = GL_INT_2_10_10_10_REV + }; + return table[type]; +} + +static unsigned comp_sz(Gwn_VertCompType type) +{ +#if TRUST_NO_ONE + assert(type <= GWN_COMP_F32); /* other types have irregular sizes (not bytes) */ +#endif + const GLubyte sizes[] = {1,1,2,2,4,4,4}; + return sizes[type]; +} + +static unsigned attrib_sz(const Gwn_VertAttr *a) +{ + if (a->comp_type == GWN_COMP_I10) { + return 4; /* always packed as 10_10_10_2 */ + } + return a->comp_len * comp_sz(a->comp_type); +} + +static unsigned attrib_align(const Gwn_VertAttr *a) +{ + if (a->comp_type == GWN_COMP_I10) { + return 4; /* always packed as 10_10_10_2 */ + } + unsigned c = comp_sz(a->comp_type); + if (a->comp_len == 3 && c <= 2) { + return 4 * c; /* AMD HW can't fetch these well, so pad it out (other vendors too?) */ + } + else { + return c; /* most fetches are ok if components are naturally aligned */ + } +} + +unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) +{ +#if TRUST_NO_ONE + assert(format->packed && format->stride > 0); +#endif + return format->stride * vertex_len; +} + +static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) +{ + /* strncpy does 110% of what we need; let's do exactly 100% */ + char* name_copy = format->names + format->name_offset; + unsigned available = GWN_VERT_ATTR_NAMES_BUF_LEN - format->name_offset; + bool terminated = false; + + for (unsigned i = 0; i < available; ++i) { + const char c = name[i]; + name_copy[i] = c; + if (c == '\0') { + terminated = true; + format->name_offset += (i + 1); + break; + } + } +#if TRUST_NO_ONE + assert(terminated); + assert(format->name_offset <= GWN_VERT_ATTR_NAMES_BUF_LEN); +#else + (void)terminated; +#endif + return name_copy; +} + +unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_len, Gwn_VertFetchMode fetch_mode) +{ +#if TRUST_NO_ONE + assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(format->attr_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(!format->packed); /* packed means frozen/locked */ + assert((comp_len >= 1 && comp_len <= 4) || comp_len == 8 || comp_len == 12 || comp_len == 16); + + switch (comp_type) { + case GWN_COMP_F32: + /* float type can only kept as float */ + assert(fetch_mode == GWN_FETCH_FLOAT); + break; + case GWN_COMP_I10: + /* 10_10_10 format intended for normals (xyz) or colors (rgb) + * extra component packed.w can be manually set to { -2, -1, 0, 1 } */ + assert(comp_len == 3 || comp_len == 4); + assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); /* not strictly required, may relax later */ + break; + default: + /* integer types can be kept as int or converted/normalized to float */ + assert(fetch_mode != GWN_FETCH_FLOAT); + /* only support float matrices (see Batch_update_program_bindings) */ + assert(comp_len != 8 && comp_len != 12 && comp_len != 16); + } +#endif + format->name_len++; /* multiname support */ + + const unsigned attrib_id = format->attr_len++; + Gwn_VertAttr* attrib = format->attribs + attrib_id; + + attrib->name[attrib->name_len++] = copy_attrib_name(format, name); + attrib->comp_type = comp_type; + attrib->gl_comp_type = convert_comp_type_to_gl(comp_type); + attrib->comp_len = (comp_type == GWN_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */ + attrib->sz = attrib_sz(attrib); + attrib->offset = 0; /* offsets & stride are calculated later (during pack) */ + attrib->fetch_mode = fetch_mode; + + return attrib_id; +} + +void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias) +{ + Gwn_VertAttr* attrib = format->attribs + (format->attr_len - 1); +#if TRUST_NO_ONE + assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(attrib->name_len < GWN_VERT_ATTR_MAX_NAMES); +#endif + format->name_len++; /* multiname support */ + attrib->name[attrib->name_len++] = copy_attrib_name(format, alias); +} + +unsigned padding(unsigned offset, unsigned alignment) +{ + const unsigned mod = offset % alignment; + return (mod == 0) ? 0 : (alignment - mod); +} + +#if PACK_DEBUG +static void show_pack(unsigned a_idx, unsigned sz, unsigned pad) +{ + const char c = 'A' + a_idx; + for (unsigned i = 0; i < pad; ++i) { + putchar('-'); + } + for (unsigned i = 0; i < sz; ++i) { + putchar(c); + } +} +#endif + +void VertexFormat_pack(Gwn_VertFormat* format) +{ + /* For now, attributes are packed in the order they were added, + * making sure each attrib is naturally aligned (add padding where necessary) + * Later we can implement more efficient packing w/ reordering + * (keep attrib ID order, adjust their offsets to reorder in buffer). */ + + /* TODO: realloc just enough to hold the final combo string. And just enough to + * hold used attribs, not all 16. */ + + Gwn_VertAttr* a0 = format->attribs + 0; + a0->offset = 0; + unsigned offset = a0->sz; + +#if PACK_DEBUG + show_pack(0, a0->sz, 0); +#endif + + for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) { + Gwn_VertAttr* a = format->attribs + a_idx; + unsigned mid_padding = padding(offset, attrib_align(a)); + offset += mid_padding; + a->offset = offset; + offset += a->sz; + +#if PACK_DEBUG + show_pack(a_idx, a->sz, mid_padding); +#endif + } + + unsigned end_padding = padding(offset, attrib_align(a0)); + +#if PACK_DEBUG + show_pack(0, 0, end_padding); + putchar('\n'); +#endif + format->stride = offset + end_padding; + format->packed = true; +} + + +/* OpenGL ES packs in a different order as desktop GL but component conversion is the same. + * Of the code here, only struct Gwn_PackedNormal needs to change. */ + +#define SIGNED_INT_10_MAX 511 +#define SIGNED_INT_10_MIN -512 + +static int clampi(int x, int min_allowed, int max_allowed) +{ +#if TRUST_NO_ONE + assert(min_allowed <= max_allowed); +#endif + if (x < min_allowed) { + return min_allowed; + } + else if (x > max_allowed) { + return max_allowed; + } + else { + return x; + } +} + +static int quantize(float x) +{ + int qx = x * 511.0f; + return clampi(qx, SIGNED_INT_10_MIN, SIGNED_INT_10_MAX); +} + +static int convert_i16(short x) +{ + /* 16-bit signed --> 10-bit signed */ + /* TODO: round? */ + return x >> 6; +} + +Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]) +{ + Gwn_PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) }; + return n; +} + +Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]) +{ + Gwn_PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) }; + return n; +} diff --git a/source/blender/gpu/intern/gpu_vertex_format_private.h b/source/blender/gpu/intern/gpu_vertex_format_private.h new file mode 100644 index 00000000000..3cae9969fd8 --- /dev/null +++ b/source/blender/gpu/intern/gpu_vertex_format_private.h @@ -0,0 +1,39 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/gwn_vertex_format_private.h + * \ingroup gpu + * + * Gawain vertex format + */ + +#ifndef __GWN_VERTEX_FORMAT_PRIVATE_H__ +#define __GWN_VERTEX_FORMAT_PRIVATE_H__ + +void VertexFormat_pack(Gwn_VertFormat*); +uint padding(uint offset, uint alignment); +uint vertex_buffer_size(const Gwn_VertFormat*, uint vertex_len); + +#endif /* __GWN_VERTEX_FORMAT_PRIVATE_H__ */ diff --git a/source/blender/python/gawain/gwn_py_api.c b/source/blender/python/gawain/gwn_py_api.c index d79ef070649..1f7a1297448 100644 --- a/source/blender/python/gawain/gwn_py_api.c +++ b/source/blender/python/gawain/gwn_py_api.c @@ -27,8 +27,8 @@ #include -#include "gawain/gwn_batch.h" -#include "gawain/gwn_vertex_format.h" +#include "GPU_batch.h" +#include "GPU_vertex_format.h" #include "gwn_py_api.h" #include "gwn_py_types.h" diff --git a/source/blender/python/gawain/gwn_py_types.c b/source/blender/python/gawain/gwn_py_types.c index bdf0be9f7e1..04c50ac0784 100644 --- a/source/blender/python/gawain/gwn_py_types.c +++ b/source/blender/python/gawain/gwn_py_types.c @@ -27,8 +27,8 @@ #include -#include "gawain/gwn_batch.h" -#include "gawain/gwn_vertex_format.h" +#include "GPU_batch.h" +#include "GPU_vertex_format.h" #include "BLI_math.h" diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index d3fef51e9e9..8f921d7850a 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -37,6 +37,7 @@ set(INC ../nodes ../physics ../draw + ../gpu ../../../intern/atomic ../../../intern/guardedalloc ../../../intern/mikktspace diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 82595527d30..af8746a4734 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -97,7 +97,7 @@ #include "../../../windowmanager/WM_api.h" /* XXX */ #include "../../../windowmanager/wm_window.h" /* XXX */ -#include "../../../intern/gawain/gawain/gwn_context.h" +#include "GPU_context.h" #ifdef WITH_FREESTYLE # include "FRS_freestyle.h" diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index d1a7f4ffea1..00e7f77569b 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -69,7 +69,7 @@ #include "GPU_matrix.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" -#include "GPU_batch.h" +#include "GPU_context.h" #include "GPU_init_exit.h" #include "DNA_scene_types.h" diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index f55fc5703f4..669480bf098 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -90,12 +90,11 @@ #include "GPU_immediate.h" #include "GPU_material.h" #include "GPU_texture.h" +#include "GPU_context.h" #include "BLF_api.h" #include "UI_resources.h" -#include "../../../intern/gawain/gawain/gwn_context.h" - /* for assert */ #ifndef NDEBUG # include "BLI_threads.h" -- cgit v1.2.3 From 8cd7828792419fb4eac9a2a477968535b4c71535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 18 Jul 2018 00:12:21 +0200 Subject: GWN: Port to GPU module: Replace GWN prefix by GPU --- build_files/cmake/macros.cmake | 2 +- intern/opencolorio/ocio_impl_glsl.cc | 14 +- release/scripts/modules/bpy_types.py | 16 +- source/blender/blenfont/intern/blf_font.c | 40 +- source/blender/blenfont/intern/blf_glyph.c | 6 +- .../blender/blenfont/intern/blf_internal_types.h | 6 +- source/blender/blenkernel/BKE_animsys.h | 2 +- source/blender/blenkernel/BKE_pbvh.h | 4 +- source/blender/blenkernel/intern/anim.c | 12 +- source/blender/blenkernel/intern/cloth.c | 4 +- source/blender/blenkernel/intern/pbvh.c | 6 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/draw/DRW_engine.h | 4 +- source/blender/draw/engines/basic/basic_engine.c | 4 +- source/blender/draw/engines/eevee/eevee_bloom.c | 2 +- .../draw/engines/eevee/eevee_depth_of_field.c | 2 +- source/blender/draw/engines/eevee/eevee_effects.c | 2 +- .../blender/draw/engines/eevee/eevee_lightcache.c | 26 +- .../blender/draw/engines/eevee/eevee_lightprobes.c | 12 +- source/blender/draw/engines/eevee/eevee_lights.c | 4 +- source/blender/draw/engines/eevee/eevee_lookdev.c | 2 +- .../blender/draw/engines/eevee/eevee_materials.c | 10 +- .../blender/draw/engines/eevee/eevee_motion_blur.c | 2 +- .../blender/draw/engines/eevee/eevee_occlusion.c | 2 +- source/blender/draw/engines/eevee/eevee_private.h | 4 +- .../draw/engines/eevee/eevee_screen_raytrace.c | 2 +- .../blender/draw/engines/eevee/eevee_subsurface.c | 2 +- .../draw/engines/external/external_engine.c | 2 +- .../draw/engines/workbench/workbench_deferred.c | 8 +- .../draw/engines/workbench/workbench_forward.c | 6 +- source/blender/draw/intern/DRW_render.h | 30 +- source/blender/draw/intern/draw_anim_viz.c | 26 +- source/blender/draw/intern/draw_armature.c | 16 +- source/blender/draw/intern/draw_cache.c | 1546 ++++++++++---------- source/blender/draw/intern/draw_cache.h | 209 ++- source/blender/draw/intern/draw_cache_impl.h | 104 +- source/blender/draw/intern/draw_cache_impl_curve.c | 260 ++-- .../blender/draw/intern/draw_cache_impl_displist.c | 98 +- .../blender/draw/intern/draw_cache_impl_lattice.c | 86 +- source/blender/draw/intern/draw_cache_impl_mesh.c | 1160 +++++++-------- .../blender/draw/intern/draw_cache_impl_metaball.c | 20 +- .../draw/intern/draw_cache_impl_particles.c | 304 ++-- source/blender/draw/intern/draw_common.c | 64 +- source/blender/draw/intern/draw_common.h | 30 +- source/blender/draw/intern/draw_debug.c | 38 +- source/blender/draw/intern/draw_hair_private.h | 18 +- source/blender/draw/intern/draw_instance_data.c | 68 +- source/blender/draw/intern/draw_instance_data.h | 8 +- source/blender/draw/intern/draw_manager.c | 76 +- source/blender/draw/intern/draw_manager.h | 24 +- source/blender/draw/intern/draw_manager_data.c | 126 +- source/blender/draw/intern/draw_manager_exec.c | 18 +- .../blender/draw/intern/draw_manager_profiling.c | 2 +- source/blender/draw/intern/draw_view.c | 44 +- source/blender/draw/modes/edit_curve_mode.c | 2 +- source/blender/draw/modes/edit_lattice_mode.c | 2 +- source/blender/draw/modes/edit_mesh_mode.c | 8 +- source/blender/draw/modes/edit_surface_mode.c | 2 +- source/blender/draw/modes/edit_text_mode.c | 2 +- source/blender/draw/modes/object_mode.c | 38 +- source/blender/draw/modes/overlay_mode.c | 2 +- source/blender/draw/modes/paint_texture_mode.c | 10 +- source/blender/draw/modes/paint_vertex_mode.c | 2 +- source/blender/draw/modes/paint_weight_mode.c | 2 +- source/blender/draw/modes/particle_mode.c | 6 +- source/blender/draw/modes/pose_mode.c | 2 +- .../editors/animation/anim_channels_defines.c | 12 +- source/blender/editors/animation/anim_draw.c | 16 +- source/blender/editors/animation/anim_markers.c | 8 +- source/blender/editors/animation/keyframes_draw.c | 20 +- source/blender/editors/curve/editcurve_paint.c | 16 +- .../editors/gizmo_library/gizmo_draw_utils.c | 34 +- .../gizmo_library/gizmo_types/arrow2d_gizmo.c | 6 +- .../gizmo_library/gizmo_types/arrow3d_gizmo.c | 8 +- .../gizmo_library/gizmo_types/button2d_gizmo.c | 18 +- .../gizmo_library/gizmo_types/cage2d_gizmo.c | 76 +- .../gizmo_library/gizmo_types/cage3d_gizmo.c | 12 +- .../gizmo_library/gizmo_types/dial3d_gizmo.c | 12 +- .../gizmo_library/gizmo_types/grab3d_gizmo.c | 6 +- .../gizmo_library/gizmo_types/primitive3d_gizmo.c | 6 +- source/blender/editors/gpencil/drawgpencil.c | 92 +- source/blender/editors/gpencil/gpencil_brush.c | 4 +- source/blender/editors/gpencil/gpencil_paint.c | 4 +- source/blender/editors/include/ED_keyframes_draw.h | 2 +- source/blender/editors/interface/interface_draw.c | 238 +-- source/blender/editors/interface/interface_icons.c | 26 +- .../editors/interface/interface_icons_event.c | 6 +- .../blender/editors/interface/interface_intern.h | 6 +- source/blender/editors/interface/interface_panel.c | 36 +- .../blender/editors/interface/interface_widgets.c | 168 +-- source/blender/editors/interface/view2d.c | 24 +- source/blender/editors/mask/mask_draw.c | 32 +- source/blender/editors/mesh/editmesh_knife.c | 26 +- source/blender/editors/mesh/editmesh_loopcut.c | 6 +- source/blender/editors/physics/particle_edit.c | 2 +- source/blender/editors/screen/area.c | 50 +- source/blender/editors/screen/glutil.c | 16 +- source/blender/editors/screen/screen_draw.c | 30 +- source/blender/editors/sculpt_paint/paint_cursor.c | 34 +- source/blender/editors/sculpt_paint/paint_image.c | 8 +- source/blender/editors/sculpt_paint/paint_stroke.c | 8 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 2 +- source/blender/editors/space_action/action_draw.c | 10 +- .../editors/space_clip/clip_dopesheet_draw.c | 18 +- source/blender/editors/space_clip/clip_draw.c | 74 +- .../blender/editors/space_clip/clip_graph_draw.c | 12 +- source/blender/editors/space_clip/clip_utils.c | 4 +- .../blender/editors/space_console/console_draw.c | 4 +- source/blender/editors/space_file/file_draw.c | 14 +- source/blender/editors/space_graph/graph_draw.c | 46 +- source/blender/editors/space_graph/space_graph.c | 6 +- source/blender/editors/space_image/image_draw.c | 16 +- source/blender/editors/space_info/textview.c | 12 +- source/blender/editors/space_nla/nla_draw.c | 38 +- source/blender/editors/space_node/drawnode.c | 124 +- source/blender/editors/space_node/node_draw.c | 22 +- .../blender/editors/space_outliner/outliner_draw.c | 42 +- .../editors/space_sequencer/sequencer_draw.c | 40 +- source/blender/editors/space_text/text_draw.c | 22 +- source/blender/editors/space_view3d/drawobject.c | 98 +- source/blender/editors/space_view3d/view3d_draw.c | 32 +- source/blender/editors/space_view3d/view3d_fly.c | 6 +- .../space_view3d/view3d_gizmo_navigate_type.c | 20 +- .../editors/space_view3d/view3d_gizmo_ruler.c | 14 +- .../blender/editors/space_view3d/view3d_intern.h | 2 +- source/blender/editors/space_view3d/view3d_ruler.c | 14 +- source/blender/editors/space_view3d/view3d_walk.c | 6 +- source/blender/editors/transform/transform.c | 32 +- .../editors/transform/transform_constraints.c | 6 +- .../blender/editors/transform/transform_generics.c | 4 +- source/blender/editors/transform/transform_snap.c | 6 +- source/blender/editors/util/ed_util.c | 4 +- source/blender/editors/uvedit/uvedit_draw.c | 124 +- .../blender/editors/uvedit/uvedit_smart_stitch.c | 88 +- source/blender/gpu/CMakeLists.txt | 2 +- source/blender/gpu/GPU_attr_binding.h | 14 +- source/blender/gpu/GPU_batch.h | 158 +- source/blender/gpu/GPU_batch_presets.h | 12 +- source/blender/gpu/GPU_batch_utils.h | 6 +- source/blender/gpu/GPU_buffer_id.h | 14 +- source/blender/gpu/GPU_buffers.h | 2 +- source/blender/gpu/GPU_common.h | 14 +- source/blender/gpu/GPU_context.h | 20 +- source/blender/gpu/GPU_element.h | 68 +- source/blender/gpu/GPU_immediate.h | 14 +- source/blender/gpu/GPU_immediate_util.h | 4 +- source/blender/gpu/GPU_matrix.h | 4 +- source/blender/gpu/GPU_primitive.h | 50 +- source/blender/gpu/GPU_shader_interface.h | 96 +- source/blender/gpu/GPU_texture.h | 4 +- source/blender/gpu/GPU_vertex_array_id.h | 14 +- source/blender/gpu/GPU_vertex_buffer.h | 88 +- source/blender/gpu/GPU_vertex_format.h | 86 +- source/blender/gpu/intern/gpu_attr_binding.c | 26 +- .../blender/gpu/intern/gpu_attr_binding_private.h | 16 +- source/blender/gpu/intern/gpu_batch.c | 240 +-- source/blender/gpu/intern/gpu_batch_presets.c | 76 +- source/blender/gpu/intern/gpu_batch_private.h | 16 +- source/blender/gpu/intern/gpu_batch_utils.c | 54 +- source/blender/gpu/intern/gpu_buffer_id.cpp | 8 +- source/blender/gpu/intern/gpu_buffers.c | 154 +- source/blender/gpu/intern/gpu_codegen.c | 2 +- source/blender/gpu/intern/gpu_element.c | 120 +- source/blender/gpu/intern/gpu_immediate.c | 170 +-- source/blender/gpu/intern/gpu_immediate_util.c | 50 +- source/blender/gpu/intern/gpu_matrix.c | 14 +- source/blender/gpu/intern/gpu_primitive.c | 60 +- source/blender/gpu/intern/gpu_primitive_private.h | 12 +- source/blender/gpu/intern/gpu_shader.c | 20 +- source/blender/gpu/intern/gpu_shader_interface.c | 154 +- source/blender/gpu/intern/gpu_shader_private.h | 2 +- source/blender/gpu/intern/gpu_texture.c | 20 +- source/blender/gpu/intern/gpu_vertex_array_id.cpp | 40 +- source/blender/gpu/intern/gpu_vertex_buffer.c | 98 +- source/blender/gpu/intern/gpu_vertex_format.c | 96 +- .../blender/gpu/intern/gpu_vertex_format_private.h | 14 +- source/blender/gpu/intern/gpu_viewport.c | 4 +- source/blender/makesdna/DNA_action_types.h | 6 +- source/blender/makesdna/DNA_windowmanager_types.h | 2 +- source/blender/python/CMakeLists.txt | 2 +- source/blender/python/gawain/CMakeLists.txt | 47 - source/blender/python/gawain/gwn_py_api.c | 63 - source/blender/python/gawain/gwn_py_api.h | 30 - source/blender/python/gawain/gwn_py_types.c | 847 ----------- source/blender/python/gawain/gwn_py_types.h | 67 - source/blender/python/gpu/CMakeLists.txt | 46 + source/blender/python/gpu/gpu_py_api.c | 63 + source/blender/python/gpu/gpu_py_api.h | 30 + source/blender/python/gpu/gpu_py_types.c | 847 +++++++++++ source/blender/python/gpu/gpu_py_types.h | 67 + source/blender/python/intern/bpy_interface.c | 4 +- source/blender/render/extern/include/RE_pipeline.h | 2 +- .../blender/render/intern/include/render_types.h | 2 +- source/blender/render/intern/source/pipeline.c | 16 +- source/blender/windowmanager/intern/wm_draw.c | 4 +- source/blender/windowmanager/intern/wm_files.c | 4 +- source/blender/windowmanager/intern/wm_gesture.c | 18 +- source/blender/windowmanager/intern/wm_operators.c | 16 +- source/blender/windowmanager/intern/wm_playanim.c | 16 +- source/blender/windowmanager/intern/wm_stereo.c | 24 +- source/blender/windowmanager/intern/wm_window.c | 12 +- 201 files changed, 5517 insertions(+), 5547 deletions(-) delete mode 100644 source/blender/python/gawain/CMakeLists.txt delete mode 100644 source/blender/python/gawain/gwn_py_api.c delete mode 100644 source/blender/python/gawain/gwn_py_api.h delete mode 100644 source/blender/python/gawain/gwn_py_types.c delete mode 100644 source/blender/python/gawain/gwn_py_types.h create mode 100644 source/blender/python/gpu/CMakeLists.txt create mode 100644 source/blender/python/gpu/gpu_py_api.c create mode 100644 source/blender/python/gpu/gpu_py_api.h create mode 100644 source/blender/python/gpu/gpu_py_types.c create mode 100644 source/blender/python/gpu/gpu_py_types.h diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index b2ec8f6e7a9..0ceaee08e64 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -621,7 +621,7 @@ function(SETUP_BLENDER_SORTED_LIBS) bf_python bf_python_ext bf_python_mathutils - bf_python_gawain + bf_python_gpu bf_python_bmesh bf_freestyle bf_ikplugin diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc index 10acdb9d281..78c73a6e3bf 100644 --- a/intern/opencolorio/ocio_impl_glsl.cc +++ b/intern/opencolorio/ocio_impl_glsl.cc @@ -98,7 +98,7 @@ typedef struct OCIO_GLSLShader { GLuint ocio_shader; GLuint vert_shader; GLuint program; - Gwn_ShaderInterface *shader_interface; + GPUShaderInterface *shader_interface; } GLSLDrawState; typedef struct OCIO_GLSLDrawState { @@ -251,7 +251,7 @@ static void freeGLSLShader(OCIO_GLSLShader *shader) } if (shader->shader_interface) { - GWN_shaderinterface_discard(shader->shader_interface); + GPU_shaderinterface_discard(shader->shader_interface); } if (shader->ocio_shader) { @@ -424,9 +424,9 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc if (shader->program) { if (shader->shader_interface) { - GWN_shaderinterface_discard(shader->shader_interface); + GPU_shaderinterface_discard(shader->shader_interface); } - shader->shader_interface = GWN_shaderinterface_create(shader->program); + shader->shader_interface = GPU_shaderinterface_create(shader->program); } } } @@ -461,9 +461,9 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc * * TODO(sergey): Look into some nicer solution. */ - Gwn_VertFormat *format = immVertexFormat(); - GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindProgram(shader->program, shader->shader_interface); immUniform1i("image_texture", 0); diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index f4fd188c641..d6d4ecd6fce 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -587,7 +587,7 @@ class Gizmo(StructRNA): _rna_gizmo_target_get_range as target_get_range, ) - # Convenience wrappers around private `_gawain` module. + # Convenience wrappers around private `_gpu` module. def draw_custom_shape(self, shape, *, matrix=None, select_id=None): """ Draw a shape created form :class:`bpy.types.Gizmo.draw_custom_shape`. @@ -638,19 +638,19 @@ class Gizmo(StructRNA): :return: The newly created shape. :rtype: Undefined (it may change). """ - from _gawain.types import ( - Gwn_Batch, - Gwn_VertBuf, - Gwn_VertFormat, + from _gpu.types import ( + GPUBatch, + GPUVertBuf, + GPUVertFormat, ) dims = len(verts[0]) if dims not in {2, 3}: raise ValueError("Expected 2D or 3D vertex") - fmt = Gwn_VertFormat() + fmt = GPUVertFormat() pos_id = fmt.attr_add(id="pos", comp_type='F32', len=dims, fetch_mode='FLOAT') - vbo = Gwn_VertBuf(len=len(verts), format=fmt) + vbo = GPUVertBuf(len=len(verts), format=fmt) vbo.fill(id=pos_id, data=verts) - batch = Gwn_Batch(type=type, buf=vbo) + batch = GPUBatch(type=type, buf=vbo) return (batch, dims) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3f4c430ee4b..ea81106e60f 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -91,31 +91,31 @@ static SpinLock ft_lib_mutex; **/ static void blf_batch_draw_init(void) { - Gwn_VertFormat format = {0}; - g_batch.pos_loc = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - g_batch.tex_loc = GWN_vertformat_attr_add(&format, "tex", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - g_batch.col_loc = GWN_vertformat_attr_add(&format, "col", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat format = {0}; + g_batch.pos_loc = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + g_batch.tex_loc = GPU_vertformat_attr_add(&format, "tex", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + g_batch.col_loc = GPU_vertformat_attr_add(&format, "col", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); - g_batch.verts = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STREAM); - GWN_vertbuf_data_alloc(g_batch.verts, BLF_BATCH_DRAW_LEN_MAX); + g_batch.verts = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STREAM); + GPU_vertbuf_data_alloc(g_batch.verts, BLF_BATCH_DRAW_LEN_MAX); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step); g_batch.glyph_len = 0; - g_batch.batch = GWN_batch_create_ex(GWN_PRIM_POINTS, g_batch.verts, NULL, GWN_BATCH_OWNS_VBO); + g_batch.batch = GPU_batch_create_ex(GPU_PRIM_POINTS, g_batch.verts, NULL, GPU_BATCH_OWNS_VBO); } static void blf_batch_draw_exit(void) { - GWN_BATCH_DISCARD_SAFE(g_batch.batch); + GPU_BATCH_DISCARD_SAFE(g_batch.batch); } void blf_batch_draw_vao_clear(void) { if (g_batch.batch) { - gwn_batch_vao_cache_clear(g_batch.batch); + GPU_batch_vao_cache_clear(g_batch.batch); } } @@ -190,20 +190,20 @@ void blf_batch_draw(void) UI_widgetbase_draw_cache_flush(); GPU_texture_bind(g_batch.tex_bind_state, 0); - GWN_vertbuf_vertex_count_set(g_batch.verts, g_batch.glyph_len); - GWN_vertbuf_use(g_batch.verts); /* send data */ + GPU_vertbuf_vertex_count_set(g_batch.verts, g_batch.glyph_len); + GPU_vertbuf_use(g_batch.verts); /* send data */ GPUBuiltinShader shader = (g_batch.simple_shader) ? GPU_SHADER_TEXT_SIMPLE : GPU_SHADER_TEXT; - GWN_batch_program_set_builtin(g_batch.batch, shader); - GWN_batch_uniform_1i(g_batch.batch, "glyph", 0); - GWN_batch_draw(g_batch.batch); + GPU_batch_program_set_builtin(g_batch.batch, shader); + GPU_batch_uniform_1i(g_batch.batch, "glyph", 0); + GPU_batch_draw(g_batch.batch); GPU_blend(false); /* restart to 1st vertex data pointers */ - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step); g_batch.glyph_len = 0; } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 8dc11443124..30e31bb2580 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -382,10 +382,10 @@ static void blf_texture_draw(const unsigned char color[4], const float uv[2][2], { /* Only one vertex per glyph, geometry shader expand it into a quad. */ /* TODO Get rid of Geom Shader because it's not optimal AT ALL for the GPU */ - copy_v4_fl4(GWN_vertbuf_raw_step(&g_batch.pos_step), x1 + g_batch.ofs[0], y1 + g_batch.ofs[1], + copy_v4_fl4(GPU_vertbuf_raw_step(&g_batch.pos_step), x1 + g_batch.ofs[0], y1 + g_batch.ofs[1], x2 + g_batch.ofs[0], y2 + g_batch.ofs[1]); - copy_v4_v4(GWN_vertbuf_raw_step(&g_batch.tex_step), (float *)uv); - copy_v4_v4_uchar(GWN_vertbuf_raw_step(&g_batch.col_step), color); + copy_v4_v4(GPU_vertbuf_raw_step(&g_batch.tex_step), (float *)uv); + copy_v4_v4_uchar(GPU_vertbuf_raw_step(&g_batch.col_step), color); g_batch.glyph_len++; /* Flush cache if it's full. */ if (g_batch.glyph_len == BLF_BATCH_DRAW_LEN_MAX) { diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 03bf7fa67d8..265835f4c75 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -38,9 +38,9 @@ typedef struct BatchBLF { struct FontBLF *font; /* can only batch glyph from the same font */ - struct Gwn_Batch *batch; - struct Gwn_VertBuf *verts; - struct Gwn_VertBufRaw pos_step, tex_step, col_step; + struct GPUBatch *batch; + struct GPUVertBuf *verts; + struct GPUVertBufRaw pos_step, tex_step, col_step; unsigned int pos_loc, tex_loc, col_loc; unsigned int glyph_len; float ofs[2]; /* copy of font->pos */ diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index b16e8c17a12..9e8e7f7b724 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -153,7 +153,7 @@ char *BKE_animdata_driver_path_hack(struct bContext *C, struct PointerRNA *ptr, char *base_path); /* ************************************* */ -/* Gwn_Batch AnimData API */ +/* GPUBatch AnimData API */ /* Define for callback looper used in BKE_animdata_main_cb */ typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data); diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 78c766f6115..095f442ca50 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -30,7 +30,7 @@ #include "BLI_ghash.h" #include "BLI_utildefines.h" -struct Gwn_Batch; +struct GPUBatch; struct CCGElem; struct CCGKey; struct CCGDerivedMesh; @@ -131,7 +131,7 @@ bool BKE_pbvh_node_find_nearest_to_ray( void BKE_pbvh_draw_cb( PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, - void (*draw_fn)(void *user_data, struct Gwn_Batch *batch), void *user_data); + void (*draw_fn)(void *user_data, struct GPUBatch *batch), void *user_data); /* PBVH Access */ typedef enum { diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 07b8b69bc70..eed8943cd5b 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -114,9 +114,9 @@ void animviz_free_motionpath_cache(bMotionPath *mpath) if (mpath->points) MEM_freeN(mpath->points); - GWN_VERTBUF_DISCARD_SAFE(mpath->points_vbo); - GWN_BATCH_DISCARD_SAFE(mpath->batch_line); - GWN_BATCH_DISCARD_SAFE(mpath->batch_points); + GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo); + GPU_BATCH_DISCARD_SAFE(mpath->batch_line); + GPU_BATCH_DISCARD_SAFE(mpath->batch_points); /* reset the relevant parameters */ mpath->points = NULL; @@ -495,9 +495,9 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) BLI_dlrbTree_free(&mpt->keys); /* Free previous batches to force update. */ - GWN_VERTBUF_DISCARD_SAFE(mpath->points_vbo); - GWN_BATCH_DISCARD_SAFE(mpath->batch_line); - GWN_BATCH_DISCARD_SAFE(mpath->batch_points); + GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo); + GPU_BATCH_DISCARD_SAFE(mpath->batch_line); + GPU_BATCH_DISCARD_SAFE(mpath->batch_points); } } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index ccef747a31c..caf5b94b30e 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -924,7 +924,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, Mesh *mesh ) } /*************************************************************************************** - * SPRING NETWORK GWN_BATCH_BUILDING IMPLEMENTATION BEGIN + * SPRING NETWORK GPU_BATCH_BUILDING IMPLEMENTATION BEGIN ***************************************************************************************/ BLI_INLINE void spring_verts_ordered_set(ClothSpring *spring, int v0, int v1) @@ -1506,5 +1506,5 @@ static int cloth_build_springs ( ClothModifierData *clmd, Mesh *mesh ) } /* cloth_build_springs */ /*************************************************************************************** - * SPRING NETWORK GWN_BATCH_BUILDING IMPLEMENTATION END + * SPRING NETWORK GPU_BATCH_BUILDING IMPLEMENTATION END ***************************************************************************************/ diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 0a4cd3ec3c1..3e7a9b7ce24 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2077,7 +2077,7 @@ static void pbvh_node_check_mask_changed(PBVH *bvh, PBVHNode *node) struct PBVHNodeDrawCallbackData { - void (*draw_fn)(void *user_data, Gwn_Batch *batch); + void (*draw_fn)(void *user_data, GPUBatch *batch); void *user_data; bool fast; }; @@ -2087,7 +2087,7 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) struct PBVHNodeDrawCallbackData *data = data_v; if (!(node->flag & PBVH_FullyHidden)) { - Gwn_Batch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast); + GPUBatch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast); if (triangles != NULL) { data->draw_fn(data->user_data, triangles); } @@ -2099,7 +2099,7 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) */ void BKE_pbvh_draw_cb( PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, - void (*draw_fn)(void *user_data, Gwn_Batch *batch), void *user_data) + void (*draw_fn)(void *user_data, GPUBatch *batch), void *user_data) { struct PBVHNodeDrawCallbackData draw_data = { .fast = fast, diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 18a6198254e..ab94b5334bd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7018,7 +7018,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) direct_link_area_map(fd, &win->global_areas); win->ghostwin = NULL; - win->gwnctx = NULL; + win->gpuctx = NULL; win->eventstate = NULL; win->cursor_keymap_status = NULL; win->tweak = NULL; diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index ab2001dcb6a..eb037d081e1 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -138,8 +138,8 @@ void DRW_opengl_context_disable(void); void DRW_opengl_render_context_enable(void *re_gl_context); void DRW_opengl_render_context_disable(void *re_gl_context); -void DRW_gawain_render_context_enable(void *re_gwn_context); -void DRW_gawain_render_context_disable(void *re_gwn_context); +void DRW_gawain_render_context_enable(void *re_gpu_context); +void DRW_gawain_render_context_disable(void *re_gpu_context); void DRW_deferred_shader_remove(struct GPUMaterial *mat); diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 5a315cde2b5..a9c758d5b6f 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -160,13 +160,13 @@ static void basic_cache_populate(void *vedata, Object *ob) ParticleSettings *part = psys->part; const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as; if (draw_as == PART_DRAW_PATH) { - struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL); + struct GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL); DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL); } } } - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { bool do_cull = false; /* TODO (we probably wan't to take this from the viewport?) */ #ifdef USE_DEPTH diff --git a/source/blender/draw/engines/eevee/eevee_bloom.c b/source/blender/draw/engines/eevee/eevee_bloom.c index 2ec6f841409..d111c28b256 100644 --- a/source/blender/draw/engines/eevee/eevee_bloom.c +++ b/source/blender/draw/engines/eevee/eevee_bloom.c @@ -196,7 +196,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) static DRWShadingGroup *eevee_create_bloom_pass( const char *name, EEVEE_EffectsInfo *effects, struct GPUShader *sh, DRWPass **pass, bool upsample) { - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); *pass = DRW_pass_create(name, DRW_STATE_WRITE_COLOR); diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c index b9f7624552c..cb54ad3a164 100644 --- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c +++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c @@ -192,7 +192,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_ * - Finally composite the 2 blurred buffers with the original render. **/ DRWShadingGroup *grp; - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); psl->dof_down = DRW_pass_create("DoF Downsample", DRW_STATE_WRITE_COLOR); diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index d7a978066d5..28658d5126c 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -302,7 +302,7 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) downsample_write = DRW_STATE_WRITE_COLOR; } - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); { psl->color_downsample_ps = DRW_pass_create( diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index a6d11f1edac..4f5ad5159cf 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -83,8 +83,8 @@ extern void DRW_opengl_context_disable(void); extern void DRW_opengl_render_context_enable(void *re_gl_context); extern void DRW_opengl_render_context_disable(void *re_gl_context); -extern void DRW_gawain_render_context_enable(void *re_gwn_context); -extern void DRW_gawain_render_context_disable(void *re_gwn_context); +extern void DRW_gawain_render_context_enable(void *re_gpu_context); +extern void DRW_gawain_render_context_disable(void *re_gpu_context); typedef struct EEVEE_LightBake { Depsgraph *depsgraph; @@ -144,7 +144,7 @@ typedef struct EEVEE_LightBake { bool own_light_cache; /* If the lightcache was created for baking, it's first owned by the baker. */ int delay; /* ms. delay the start of the baking to not slowdown interactions (TODO remove) */ - void *gl_context, *gwn_context; /* If running in parallel (in a separate thread), use this context. */ + void *gl_context, *gpu_context; /* If running in parallel (in a separate thread), use this context. */ } EEVEE_LightBake; /* -------------------------------------------------------------------- */ @@ -369,10 +369,10 @@ static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake) { if (lbake->gl_context) { DRW_opengl_render_context_enable(lbake->gl_context); - if (lbake->gwn_context == NULL) { - lbake->gwn_context = GWN_context_create(); + if (lbake->gpu_context == NULL) { + lbake->gpu_context = GPU_context_create(); } - DRW_gawain_render_context_enable(lbake->gwn_context); + DRW_gawain_render_context_enable(lbake->gpu_context); } else { DRW_opengl_context_enable(); @@ -382,7 +382,7 @@ static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake) static void eevee_lightbake_context_disable(EEVEE_LightBake *lbake) { if (lbake->gl_context) { - DRW_gawain_render_context_disable(lbake->gwn_context); + DRW_gawain_render_context_disable(lbake->gpu_context); DRW_opengl_render_context_disable(lbake->gl_context); } else { @@ -586,7 +586,7 @@ static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake) { if (lbake->gl_context) { DRW_opengl_render_context_enable(lbake->gl_context); - DRW_gawain_render_context_enable(lbake->gwn_context); + DRW_gawain_render_context_enable(lbake->gpu_context); } else if (!lbake->resource_only) { DRW_opengl_context_enable(); @@ -605,17 +605,17 @@ static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake) GPU_FRAMEBUFFER_FREE_SAFE(lbake->rt_fb[i]); } - if (lbake->gwn_context) { - DRW_gawain_render_context_disable(lbake->gwn_context); - DRW_gawain_render_context_enable(lbake->gwn_context); - GWN_context_discard(lbake->gwn_context); + if (lbake->gpu_context) { + DRW_gawain_render_context_disable(lbake->gpu_context); + DRW_gawain_render_context_enable(lbake->gpu_context); + GPU_context_discard(lbake->gpu_context); } if (lbake->gl_context && lbake->own_resources) { /* Delete the baking context. */ DRW_opengl_render_context_disable(lbake->gl_context); WM_opengl_context_dispose(lbake->gl_context); - lbake->gwn_context = NULL; + lbake->gpu_context = NULL; lbake->gl_context = NULL; } else if (lbake->gl_context) { diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 1b341aced07..691d6ffe6eb 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -74,8 +74,8 @@ static struct { struct GPUTexture *depth_array_placeholder; struct GPUTexture *cube_face_minmaxz; - struct Gwn_VertFormat *format_probe_display_cube; - struct Gwn_VertFormat *format_probe_display_planar; + struct GPUVertFormat *format_probe_display_cube; + struct GPUVertFormat *format_probe_display_planar; } e_data = {NULL}; /* Engine data */ extern char datatoc_background_vert_glsl[]; @@ -395,7 +395,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1); DRW_shgroup_uniform_texture(grp, "probeHdr", rt_color); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); } @@ -414,7 +414,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); DRW_shgroup_uniform_texture(grp, "probeDepth", rt_depth); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); } @@ -424,7 +424,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_grid_fill_sh, psl->probe_grid_fill); DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &light_cache->grid_tx.tex); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); } } @@ -447,7 +447,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat { psl->probe_background = DRW_pass_create("World Probe Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRWShadingGroup *grp = NULL; Scene *scene = draw_ctx->scene; diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index dc9ce29a148..2c970fa5285 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -425,7 +425,7 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob) /* Add a shadow caster to the shadowpasses */ void EEVEE_lights_cache_shcaster_add( - EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob) + EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl, struct GPUBatch *geom, Object *ob) { DRW_shgroup_call_object_add( stl->g_data->shadow_shgrp, @@ -434,7 +434,7 @@ void EEVEE_lights_cache_shcaster_add( void EEVEE_lights_cache_shcaster_material_add( EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_PassList *psl, struct GPUMaterial *gpumat, - struct Gwn_Batch *geom, struct Object *ob, float *alpha_threshold) + struct GPUBatch *geom, struct Object *ob, float *alpha_threshold) { /* TODO / PERF : reuse the same shading group for objects with the same material */ DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, psl->shadow_pass); diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 2e568d97c07..345a28590c6 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -60,7 +60,7 @@ void EEVEE_lookdev_cache_init( if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) { StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE); if (sl && (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) { - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); GPUTexture *tex = NULL; /* If one of the component is missing we start from scratch. */ diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 20d755d2245..39f7443145f 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -135,7 +135,7 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h)) DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut"); @@ -197,7 +197,7 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h) DRW_shgroup_uniform_texture(grp, "texHammersley", hammersley); DRW_shgroup_uniform_texture(grp, "utilTex", e_data.util_tex); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut"); @@ -946,7 +946,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) { psl->background_pass = DRW_pass_create("Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRWShadingGroup *grp = NULL; const DRWContextState *draw_ctx = DRW_context_state_get(); @@ -1477,7 +1477,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld char *auto_layer_names; int *auto_layer_is_srgb; int auto_layer_count; - struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get( + struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get( ob, gpumat_array, materials_len, &auto_layer_names, &auto_layer_is_srgb, @@ -1690,7 +1690,7 @@ void EEVEE_materials_cache_finish(EEVEE_Data *vedata) if (LOOK_DEV_OVERLAY_ENABLED(v3d)) { EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); EEVEE_LampsInfo *linfo = sldata->lamps; - struct Gwn_Batch *sphere = DRW_cache_sphere_get(); + struct GPUBatch *sphere = DRW_cache_sphere_get(); static float mat1[4][4]; static float color[3] = {0.8f, 0.8f, 0.8f}; static float metallic_on = 1.0f; diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index 6dabc8f91cb..08745850bd4 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -178,7 +178,7 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat EEVEE_EffectsInfo *effects = stl->effects; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); if ((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0) { psl->motion_blur = DRW_pass_create("Motion Blur", DRW_STATE_WRITE_COLOR); diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c index f39fbe33a71..8ede22cda5a 100644 --- a/source/blender/draw/engines/eevee/eevee_occlusion.c +++ b/source/blender/draw/engines/eevee/eevee_occlusion.c @@ -183,7 +183,7 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) EEVEE_EffectsInfo *effects = stl->effects; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); if ((effects->enabled_effects & EFFECT_GTAO) != 0) { /** Occlusion algorithm overview diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 1e43d6fba08..6ef24d03df8 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -815,10 +815,10 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata); void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, struct Object *ob); void EEVEE_lights_cache_shcaster_add( - EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob); + EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, struct GPUBatch *geom, Object *ob); void EEVEE_lights_cache_shcaster_material_add( EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl, - struct GPUMaterial *gpumat, struct Gwn_Batch *geom, struct Object *ob, + struct GPUMaterial *gpumat, struct GPUBatch *geom, struct Object *ob, float *alpha_threshold); void EEVEE_lights_cache_shcaster_object_add(EEVEE_ViewLayerData *sldata, struct Object *ob); void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata); diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c index ef949c32eed..204b730f8da 100644 --- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c +++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c @@ -189,7 +189,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v EEVEE_EffectsInfo *effects = stl->effects; LightCache *lcache = stl->g_data->light_cache; - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); if ((effects->enabled_effects & EFFECT_SSR) != 0) { int options = (effects->reflection_trace_full) ? SSR_FULL_TRACE : 0; diff --git a/source/blender/draw/engines/eevee/eevee_subsurface.c b/source/blender/draw/engines/eevee/eevee_subsurface.c index 6ee3b9cc286..9667f2ac9d7 100644 --- a/source/blender/draw/engines/eevee/eevee_subsurface.c +++ b/source/blender/draw/engines/eevee/eevee_subsurface.c @@ -204,7 +204,7 @@ void EEVEE_subsurface_add_pass( EEVEE_PassList *psl = vedata->psl; EEVEE_StorageList *stl = vedata->stl; EEVEE_EffectsInfo *effects = stl->effects; - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[0], psl->sss_blur_ps); DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex()); diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c index 35ff777b885..b2c30ba723c 100644 --- a/source/blender/draw/engines/external/external_engine.c +++ b/source/blender/draw/engines/external/external_engine.c @@ -128,7 +128,7 @@ static void external_cache_populate(void *vedata, Object *ob) if (!DRW_object_is_renderable(ob)) return; - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { /* Depth Prepass */ DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat); diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 0ad755049b1..cf53004e126 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -678,7 +678,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (me->mloopuv) { const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len); - struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; + struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; if (materials_len > 0 && geom_array) { for (int i = 0; i < materials_len; i++) { if (geom_array[i] == NULL) { @@ -701,7 +701,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (!is_drawn) { if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) { /* No material split needed */ - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type); if (is_sculpt_mode) { @@ -719,7 +719,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) gpumat_array[i] = NULL; } - struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get( + struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get( ob, gpumat_array, materials_len, NULL, NULL, NULL); if (mat_geom) { for (int i = 0; i < materials_len; ++i) { @@ -742,7 +742,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (SHADOW_ENABLED(wpd) && (ob->display.flag & OB_SHOW_SHADOW)) { bool is_manifold; - struct Gwn_Batch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold); + struct GPUBatch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold); if (geom_shadow) { if (is_sculpt_mode) { /* Currently unsupported in sculpt mode. We could revert to the slow diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index e0e0bdea0f5..2a65feeb28c 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -483,7 +483,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (me->mloopuv) { const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len); - struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; + struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; if (materials_len > 0 && geom_array) { for (int i = 0; i < materials_len; i++) { if (geom_array[i] == NULL) { @@ -516,7 +516,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (!is_drawn) { if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) { /* No material split needed */ - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type); if (is_sculpt_mode) { @@ -536,7 +536,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) gpumat_array[i] = NULL; } - struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get( + struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get( ob, gpumat_array, materials_len, NULL, NULL, NULL); if (mat_geom) { for (int i = 0; i < materials_len; ++i) { diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 16a17f4f21d..adcfe2524c7 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -71,7 +71,7 @@ struct GPUMaterial; struct GPUTexture; struct GPUUniformBuffer; struct Object; -struct Gwn_Batch; +struct GPUBatch; struct DefaultFramebufferList; struct DefaultTextureList; struct DRWTextStore; @@ -306,7 +306,7 @@ typedef struct DRWInstanceAttribFormat { int components; } DRWInstanceAttribFormat; -struct Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize); +struct GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize); #define DRW_shgroup_instance_format(format, ...) do { \ if (format == NULL) { \ DRWInstanceAttribFormat drw_format[] = __VA_ARGS__;\ @@ -317,25 +317,25 @@ struct Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrib DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass); DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass); DRWShadingGroup *DRW_shgroup_material_instance_create( - struct GPUMaterial *material, DRWPass *pass, struct Gwn_Batch *geom, struct Object *ob, - struct Gwn_VertFormat *format); + struct GPUMaterial *material, DRWPass *pass, struct GPUBatch *geom, struct Object *ob, + struct GPUVertFormat *format); DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create(struct GPUMaterial *material, DRWPass *pass, int size); DRWShadingGroup *DRW_shgroup_instance_create( - struct GPUShader *shader, DRWPass *pass, struct Gwn_Batch *geom, struct Gwn_VertFormat *format); + struct GPUShader *shader, DRWPass *pass, struct GPUBatch *geom, struct GPUVertFormat *format); DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass); DRWShadingGroup *DRW_shgroup_line_batch_create_with_format( - struct GPUShader *shader, DRWPass *pass, struct Gwn_VertFormat *format); + struct GPUShader *shader, DRWPass *pass, struct GPUVertFormat *format); DRWShadingGroup *DRW_shgroup_line_batch_create( struct GPUShader *shader, DRWPass *pass); DRWShadingGroup *DRW_shgroup_empty_tri_batch_create( struct GPUShader *shader, DRWPass *pass, int size); DRWShadingGroup *DRW_shgroup_transform_feedback_create( - struct GPUShader *shader, DRWPass *pass, struct Gwn_VertBuf *tf_target); + struct GPUShader *shader, DRWPass *pass, struct GPUVertBuf *tf_target); typedef void (DRWCallGenerateFn)( DRWShadingGroup *shgroup, - void (*draw_fn)(DRWShadingGroup *shgroup, struct Gwn_Batch *geom), + void (*draw_fn)(DRWShadingGroup *shgroup, struct GPUBatch *geom), void *user_data); /* return final visibility */ @@ -343,27 +343,27 @@ typedef bool (DRWCallVisibilityFn)( bool vis_in, void *user_data); -void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batch); +void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch); void DRW_shgroup_free(struct DRWShadingGroup *shgroup); -void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]); +void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4]); void DRW_shgroup_call_range_add( - DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count); + DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_count); void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]); void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]); void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]); void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, struct Object *ob); -void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, bool bypass_culling); +void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, bool bypass_culling); #define DRW_shgroup_call_object_add(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, false) #define DRW_shgroup_call_object_add_no_cull(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, true) void DRW_shgroup_call_object_add_with_callback( - DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, + DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, DRWCallVisibilityFn *callback, void *user_data); /* Used for drawing a batch with instancing without instance attribs. */ void DRW_shgroup_call_instances_add( - DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint *count); + DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint *count); void DRW_shgroup_call_object_instances_add( - DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, uint *count); + DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, uint *count); void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shgroup, struct Object *ob, float (*obmat)[4]); void DRW_shgroup_call_generate_add( DRWShadingGroup *shgroup, DRWCallGenerateFn *geometry_fn, void *user_data, float (*obmat)[4]); diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c index e634710980a..95894783cfe 100644 --- a/source/blender/draw/intern/draw_anim_viz.c +++ b/source/blender/draw/intern/draw_anim_viz.c @@ -98,36 +98,36 @@ struct { /* *************************** Path Cache *********************************** */ /* Just convert the CPU cache to GPU cache. */ -static Gwn_VertBuf *mpath_vbo_get(bMotionPath *mpath) +static GPUVertBuf *mpath_vbo_get(bMotionPath *mpath) { if (!mpath->points_vbo) { - Gwn_VertFormat format = {0}; + GPUVertFormat format = {0}; /* Match structure of bMotionPathVert. */ - uint pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - GWN_vertformat_attr_add(&format, "flag", GWN_COMP_I32, 1, GWN_FETCH_INT); - mpath->points_vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(mpath->points_vbo, mpath->length); + uint pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + GPU_vertformat_attr_add(&format, "flag", GPU_COMP_I32, 1, GPU_FETCH_INT); + mpath->points_vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(mpath->points_vbo, mpath->length); /* meh... a useless memcpy. */ - Gwn_VertBufRaw raw_data; - GWN_vertbuf_attr_get_raw_data(mpath->points_vbo, pos, &raw_data); - memcpy(GWN_vertbuf_raw_step(&raw_data), mpath->points, sizeof(bMotionPathVert) * mpath->length); + GPUVertBufRaw raw_data; + GPU_vertbuf_attr_get_raw_data(mpath->points_vbo, pos, &raw_data); + memcpy(GPU_vertbuf_raw_step(&raw_data), mpath->points, sizeof(bMotionPathVert) * mpath->length); } return mpath->points_vbo; } -static Gwn_Batch *mpath_batch_line_get(bMotionPath *mpath) +static GPUBatch *mpath_batch_line_get(bMotionPath *mpath) { if (!mpath->batch_line) { - mpath->batch_line = GWN_batch_create(GWN_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL); + mpath->batch_line = GPU_batch_create(GPU_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL); } return mpath->batch_line; } -static Gwn_Batch *mpath_batch_points_get(bMotionPath *mpath) +static GPUBatch *mpath_batch_points_get(bMotionPath *mpath) { if (!mpath->batch_points) { - mpath->batch_points = GWN_batch_create(GWN_PRIM_POINTS, mpath_vbo_get(mpath), NULL); + mpath->batch_points = GPU_batch_create(GPU_PRIM_POINTS, mpath_vbo_get(mpath), NULL); } return mpath->batch_points; } diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index 9bc8b70b67c..b49ca4d0d00 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -134,11 +134,11 @@ static void drw_shgroup_bone_octahedral( const float bone_color[4], const float hint_color[4], const float outline_color[4]) { if (g_data.bone_octahedral_outline == NULL) { - struct Gwn_Batch *geom = DRW_cache_bone_octahedral_wire_get(); + struct GPUBatch *geom = DRW_cache_bone_octahedral_wire_get(); g_data.bone_octahedral_outline = shgroup_instance_bone_shape_outline(g_data.passes.bone_outline, geom); } if (g_data.bone_octahedral_solid == NULL) { - struct Gwn_Batch *geom = DRW_cache_bone_octahedral_get(); + struct GPUBatch *geom = DRW_cache_bone_octahedral_get(); g_data.bone_octahedral_solid = shgroup_instance_bone_shape_solid(g_data.passes.bone_solid, geom); } float final_bonemat[4][4]; @@ -155,11 +155,11 @@ static void drw_shgroup_bone_box( const float bone_color[4], const float hint_color[4], const float outline_color[4]) { if (g_data.bone_box_wire == NULL) { - struct Gwn_Batch *geom = DRW_cache_bone_box_wire_get(); + struct GPUBatch *geom = DRW_cache_bone_box_wire_get(); g_data.bone_box_outline = shgroup_instance_bone_shape_outline(g_data.passes.bone_outline, geom); } if (g_data.bone_box_solid == NULL) { - struct Gwn_Batch *geom = DRW_cache_bone_box_get(); + struct GPUBatch *geom = DRW_cache_bone_box_get(); g_data.bone_box_solid = shgroup_instance_bone_shape_solid(g_data.passes.bone_solid, geom); } float final_bonemat[4][4]; @@ -319,9 +319,9 @@ static void drw_shgroup_bone_custom_solid( Object *custom) { /* grr, not re-using instances! */ - struct Gwn_Batch *surf = DRW_cache_object_surface_get(custom); - struct Gwn_Batch *edges = DRW_cache_object_edge_detection_get(custom, NULL); - struct Gwn_Batch *ledges = DRW_cache_object_loose_edges_get(custom); + struct GPUBatch *surf = DRW_cache_object_surface_get(custom); + struct GPUBatch *edges = DRW_cache_object_edge_detection_get(custom, NULL); + struct GPUBatch *ledges = DRW_cache_object_loose_edges_get(custom); float final_bonemat[4][4]; if (surf || edges || ledges) { @@ -352,7 +352,7 @@ static void drw_shgroup_bone_custom_wire( const float color[4], Object *custom) { /* grr, not re-using instances! */ - struct Gwn_Batch *geom = DRW_cache_object_wire_outline_get(custom); + struct GPUBatch *geom = DRW_cache_object_wire_outline_get(custom); if (geom) { DRWShadingGroup *shgrp_geom_wire = shgroup_instance_wire(g_data.passes.bone_wire, geom); float final_bonemat[4][4], final_color[4]; diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index d23b9e693ce..bb73a8c1b19 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -47,85 +47,85 @@ /* Batch's only (free'd as an array) */ static struct DRWShapeCache { - Gwn_Batch *drw_single_vertice; - Gwn_Batch *drw_cursor; - Gwn_Batch *drw_cursor_only_circle; - Gwn_Batch *drw_fullscreen_quad; - Gwn_Batch *drw_fullscreen_quad_texcoord; - Gwn_Batch *drw_quad; - Gwn_Batch *drw_sphere; - Gwn_Batch *drw_screenspace_circle; - Gwn_Batch *drw_plain_axes; - Gwn_Batch *drw_single_arrow; - Gwn_Batch *drw_cube; - Gwn_Batch *drw_circle; - Gwn_Batch *drw_square; - Gwn_Batch *drw_line; - Gwn_Batch *drw_line_endpoints; - Gwn_Batch *drw_empty_cube; - Gwn_Batch *drw_empty_sphere; - Gwn_Batch *drw_empty_cylinder; - Gwn_Batch *drw_empty_capsule_body; - Gwn_Batch *drw_empty_capsule_cap; - Gwn_Batch *drw_empty_cone; - Gwn_Batch *drw_arrows; - Gwn_Batch *drw_axis_names; - Gwn_Batch *drw_image_plane; - Gwn_Batch *drw_image_plane_wire; - Gwn_Batch *drw_field_wind; - Gwn_Batch *drw_field_force; - Gwn_Batch *drw_field_vortex; - Gwn_Batch *drw_field_tube_limit; - Gwn_Batch *drw_field_cone_limit; - Gwn_Batch *drw_lamp; - Gwn_Batch *drw_lamp_shadows; - Gwn_Batch *drw_lamp_sunrays; - Gwn_Batch *drw_lamp_area_square; - Gwn_Batch *drw_lamp_area_disk; - Gwn_Batch *drw_lamp_hemi; - Gwn_Batch *drw_lamp_spot; - Gwn_Batch *drw_lamp_spot_square; - Gwn_Batch *drw_speaker; - Gwn_Batch *drw_lightprobe_cube; - Gwn_Batch *drw_lightprobe_planar; - Gwn_Batch *drw_lightprobe_grid; - Gwn_Batch *drw_bone_octahedral; - Gwn_Batch *drw_bone_octahedral_wire; - Gwn_Batch *drw_bone_box; - Gwn_Batch *drw_bone_box_wire; - Gwn_Batch *drw_bone_wire_wire; - Gwn_Batch *drw_bone_envelope; - Gwn_Batch *drw_bone_envelope_outline; - Gwn_Batch *drw_bone_point; - Gwn_Batch *drw_bone_point_wire; - Gwn_Batch *drw_bone_stick; - Gwn_Batch *drw_bone_arrows; - Gwn_Batch *drw_camera; - Gwn_Batch *drw_camera_frame; - Gwn_Batch *drw_camera_tria; - Gwn_Batch *drw_camera_focus; - Gwn_Batch *drw_particle_cross; - Gwn_Batch *drw_particle_circle; - Gwn_Batch *drw_particle_axis; + GPUBatch *drw_single_vertice; + GPUBatch *drw_cursor; + GPUBatch *drw_cursor_only_circle; + GPUBatch *drw_fullscreen_quad; + GPUBatch *drw_fullscreen_quad_texcoord; + GPUBatch *drw_quad; + GPUBatch *drw_sphere; + GPUBatch *drw_screenspace_circle; + GPUBatch *drw_plain_axes; + GPUBatch *drw_single_arrow; + GPUBatch *drw_cube; + GPUBatch *drw_circle; + GPUBatch *drw_square; + GPUBatch *drw_line; + GPUBatch *drw_line_endpoints; + GPUBatch *drw_empty_cube; + GPUBatch *drw_empty_sphere; + GPUBatch *drw_empty_cylinder; + GPUBatch *drw_empty_capsule_body; + GPUBatch *drw_empty_capsule_cap; + GPUBatch *drw_empty_cone; + GPUBatch *drw_arrows; + GPUBatch *drw_axis_names; + GPUBatch *drw_image_plane; + GPUBatch *drw_image_plane_wire; + GPUBatch *drw_field_wind; + GPUBatch *drw_field_force; + GPUBatch *drw_field_vortex; + GPUBatch *drw_field_tube_limit; + GPUBatch *drw_field_cone_limit; + GPUBatch *drw_lamp; + GPUBatch *drw_lamp_shadows; + GPUBatch *drw_lamp_sunrays; + GPUBatch *drw_lamp_area_square; + GPUBatch *drw_lamp_area_disk; + GPUBatch *drw_lamp_hemi; + GPUBatch *drw_lamp_spot; + GPUBatch *drw_lamp_spot_square; + GPUBatch *drw_speaker; + GPUBatch *drw_lightprobe_cube; + GPUBatch *drw_lightprobe_planar; + GPUBatch *drw_lightprobe_grid; + GPUBatch *drw_bone_octahedral; + GPUBatch *drw_bone_octahedral_wire; + GPUBatch *drw_bone_box; + GPUBatch *drw_bone_box_wire; + GPUBatch *drw_bone_wire_wire; + GPUBatch *drw_bone_envelope; + GPUBatch *drw_bone_envelope_outline; + GPUBatch *drw_bone_point; + GPUBatch *drw_bone_point_wire; + GPUBatch *drw_bone_stick; + GPUBatch *drw_bone_arrows; + GPUBatch *drw_camera; + GPUBatch *drw_camera_frame; + GPUBatch *drw_camera_tria; + GPUBatch *drw_camera_focus; + GPUBatch *drw_particle_cross; + GPUBatch *drw_particle_circle; + GPUBatch *drw_particle_axis; } SHC = {NULL}; void DRW_shape_cache_free(void) { - uint i = sizeof(SHC) / sizeof(Gwn_Batch *); - Gwn_Batch **batch = (Gwn_Batch **)&SHC; + uint i = sizeof(SHC) / sizeof(GPUBatch *); + GPUBatch **batch = (GPUBatch **)&SHC; while (i--) { - GWN_BATCH_DISCARD_SAFE(*batch); + GPU_BATCH_DISCARD_SAFE(*batch); batch++; } } void DRW_shape_cache_reset(void) { - uint i = sizeof(SHC) / sizeof(Gwn_Batch *); - Gwn_Batch **batch = (Gwn_Batch **)&SHC; + uint i = sizeof(SHC) / sizeof(GPUBatch *); + GPUBatch **batch = (GPUBatch **)&SHC; while (i--) { if (*batch) { - gwn_batch_vao_cache_clear(*batch); + GPU_batch_vao_cache_clear(*batch); } batch++; } @@ -137,22 +137,22 @@ void DRW_shape_cache_reset(void) * \{ */ static void UNUSED_FUNCTION(add_fancy_edge)( - Gwn_VertBuf *vbo, uint pos_id, uint n1_id, uint n2_id, + GPUVertBuf *vbo, uint pos_id, uint n1_id, uint n2_id, uint *v_idx, const float co1[3], const float co2[3], const float n1[3], const float n2[3]) { - GWN_vertbuf_attr_set(vbo, n1_id, *v_idx, n1); - GWN_vertbuf_attr_set(vbo, n2_id, *v_idx, n2); - GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co1); + GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1); + GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2); + GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co1); - GWN_vertbuf_attr_set(vbo, n1_id, *v_idx, n1); - GWN_vertbuf_attr_set(vbo, n2_id, *v_idx, n2); - GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co2); + GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1); + GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2); + GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co2); } #if 0 /* UNUSED */ static void add_lat_lon_vert( - Gwn_VertBuf *vbo, uint pos_id, uint nor_id, + GPUVertBuf *vbo, uint pos_id, uint nor_id, uint *v_idx, const float rad, const float lat, const float lon) { float pos[3], nor[3]; @@ -161,23 +161,23 @@ static void add_lat_lon_vert( nor[2] = sinf(lat) * sinf(lon); mul_v3_v3fl(pos, nor, rad); - GWN_vertbuf_attr_set(vbo, nor_id, *v_idx, nor); - GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, pos); + GPU_vertbuf_attr_set(vbo, nor_id, *v_idx, nor); + GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, pos); } #endif -static Gwn_VertBuf *fill_arrows_vbo(const float scale) +static GPUVertBuf *fill_arrows_vbo(const float scale) { /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Line */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 6 * 3); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 6 * 3); float v1[3] = {0.0, 0.0, 0.0}; float v2[3] = {0.0, 0.0, 0.0}; @@ -189,21 +189,21 @@ static Gwn_VertBuf *fill_arrows_vbo(const float scale) v2[axis] = 1.0f; mul_v3_v3fl(vtmp1, v1, scale); mul_v3_v3fl(vtmp2, v2, scale); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 0, vtmp1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 1, vtmp2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 0, vtmp1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 1, vtmp2); v1[axis] = 0.85f; v1[arrow_axis] = -0.08f; mul_v3_v3fl(vtmp1, v1, scale); mul_v3_v3fl(vtmp2, v2, scale); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 2, vtmp1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 3, vtmp2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 2, vtmp1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 3, vtmp2); v1[arrow_axis] = 0.08f; mul_v3_v3fl(vtmp1, v1, scale); mul_v3_v3fl(vtmp2, v2, scale); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 4, vtmp1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 5, vtmp2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 4, vtmp1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 5, vtmp2); /* reset v1 & v2 to zero */ v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f; @@ -212,18 +212,18 @@ static Gwn_VertBuf *fill_arrows_vbo(const float scale) return vbo; } -static Gwn_VertBuf *sphere_wire_vbo(const float rad) +static GPUVertBuf *sphere_wire_vbo(const float rad) { #define NSEGMENTS 32 /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2 * 3); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2 * 3); /* a single ring of vertices */ float p[NSEGMENTS][2]; @@ -248,7 +248,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad) else v[0] = 0.0f, v[1] = cv[0], v[2] = cv[1]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + j + (NSEGMENTS * 2 * axis), v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + j + (NSEGMENTS * 2 * axis), v); } } } @@ -259,7 +259,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad) /* Quads */ /* Use this one for rendering fullscreen passes. For 3D objects use DRW_cache_quad_get(). */ -Gwn_Batch *DRW_cache_fullscreen_quad_get(void) +GPUBatch *DRW_cache_fullscreen_quad_get(void) { if (!SHC.drw_fullscreen_quad) { /* Use a triangle instead of a real quad */ @@ -268,85 +268,57 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void) float uvs[3][2] = {{ 0.0f, 0.0f}, { 2.0f, 0.0f}, { 0.0f, 2.0f}}; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, uvs; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.uvs = GPU_vertformat_attr_add(&format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + GPU_vertformat_alias_add(&format, "texCoord"); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 3); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 3); for (int i = 0; i < 3; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); - GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); + GPU_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); } - SHC.drw_fullscreen_quad = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_fullscreen_quad = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_fullscreen_quad; } -Gwn_Batch *DRW_cache_fullscreen_quad_texcoord_get(void) -{ - if (!SHC.drw_fullscreen_quad_texcoord) { - /* Use a triangle instead of a real quad */ - /* https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau - slide 14 */ - float pos[3][2] = {{-1.0f, -1.0f}, { 3.0f, -1.0f}, {-1.0f, 3.0f}}; - float texCoord[3][2] = {{ 0.0f, 0.0f}, { 2.0f, 0.0f}, { 0.0f, 2.0f}}; - - /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; - static struct { uint pos, texCoord; } attr_id; - if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.texCoord = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - } - - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 3); - - for (int i = 0; i < 3; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); - GWN_vertbuf_attr_set(vbo, attr_id.texCoord, i, texCoord[i]); - } - - SHC.drw_fullscreen_quad_texcoord = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); - } - return SHC.drw_fullscreen_quad_texcoord; -} - /* Just a regular quad with 4 vertices. */ -Gwn_Batch *DRW_cache_quad_get(void) +GPUBatch *DRW_cache_quad_get(void) { if (!SHC.drw_quad) { float pos[4][2] = {{-1.0f, -1.0f}, { 1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}}; float uvs[4][2] = {{ 0.0f, 0.0f}, { 1.0f, 0.0f}, {1.0f, 1.0f}, { 0.0f, 1.0f}}; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, uvs; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.uvs = GPU_vertformat_attr_add(&format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 4); for (int i = 0; i < 4; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); - GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); + GPU_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); } - SHC.drw_quad = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_quad = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_quad; } /* Sphere */ -Gwn_Batch *DRW_cache_sphere_get(void) +GPUBatch *DRW_cache_sphere_get(void) { if (!SHC.drw_sphere) { SHC.drw_sphere = gpu_batch_sphere(32, 24); @@ -361,7 +333,7 @@ Gwn_Batch *DRW_cache_sphere_get(void) /** \name Common * \{ */ -Gwn_Batch *DRW_cache_cube_get(void) +GPUBatch *DRW_cache_cube_get(void) { if (!SHC.drw_cube) { const GLfloat verts[8][3] = { @@ -391,25 +363,25 @@ Gwn_Batch *DRW_cache_cube_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 36); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 36); for (int i = 0; i < 36; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); } - SHC.drw_cube = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_cube = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_cube; } -Gwn_Batch *DRW_cache_empty_cube_get(void) +GPUBatch *DRW_cache_empty_cube_get(void) { if (!SHC.drw_empty_cube) { const GLfloat verts[8][3] = { @@ -426,54 +398,54 @@ Gwn_Batch *DRW_cache_empty_cube_get(void) const GLubyte indices[24] = {0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5, 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 24); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 24); for (int i = 0; i < 24; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); } - SHC.drw_empty_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_cube = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_cube; } -Gwn_Batch *DRW_cache_circle_get(void) +GPUBatch *DRW_cache_circle_get(void) { #define CIRCLE_RESOL 64 if (!SHC.drw_circle) { float v[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL); for (int a = 0; a < CIRCLE_RESOL; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); } - SHC.drw_circle = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_circle = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_circle; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_square_get(void) +GPUBatch *DRW_cache_square_get(void) { if (!SHC.drw_square) { float p[4][3] = {{ 1.0f, 0.0f, 1.0f}, @@ -482,26 +454,26 @@ Gwn_Batch *DRW_cache_square_get(void) {-1.0f, 0.0f, 1.0f}}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 8); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 8); for (int i = 0; i < 4; i++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2, p[i % 4]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i + 1) % 4]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2, p[i % 4]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i + 1) % 4]); } - SHC.drw_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_square; } -Gwn_Batch *DRW_cache_single_line_get(void) +GPUBatch *DRW_cache_single_line_get(void) { /* Z axis line */ if (!SHC.drw_line) { @@ -509,24 +481,24 @@ Gwn_Batch *DRW_cache_single_line_get(void) float v2[3] = {0.0f, 0.0f, 1.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); - SHC.drw_line = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_line = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_line; } -Gwn_Batch *DRW_cache_single_line_endpoints_get(void) +GPUBatch *DRW_cache_single_line_endpoints_get(void) { /* Z axis line */ if (!SHC.drw_line_endpoints) { @@ -534,46 +506,46 @@ Gwn_Batch *DRW_cache_single_line_endpoints_get(void) float v2[3] = {0.0f, 0.0f, 1.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); - SHC.drw_line_endpoints = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_line_endpoints = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_line_endpoints; } -Gwn_Batch *DRW_cache_screenspace_circle_get(void) +GPUBatch *DRW_cache_screenspace_circle_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_screenspace_circle) { float v[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL + 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL + 1); for (int a = 0; a <= CIRCLE_RESOL; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); } - SHC.drw_screenspace_circle = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_screenspace_circle = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_screenspace_circle; #undef CIRCLE_RESOL @@ -586,7 +558,7 @@ Gwn_Batch *DRW_cache_screenspace_circle_get(void) /** \name Common Object API * \{ */ -Gwn_Batch *DRW_cache_object_wire_outline_get(Object *ob) +GPUBatch *DRW_cache_object_wire_outline_get(Object *ob) { switch (ob->type) { case OB_MESH: @@ -598,7 +570,7 @@ Gwn_Batch *DRW_cache_object_wire_outline_get(Object *ob) } } -Gwn_Batch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold) +GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold) { switch (ob->type) { case OB_MESH: @@ -622,7 +594,7 @@ void DRW_cache_object_face_wireframe_get( } } -Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob) +GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob) { switch (ob->type) { case OB_MESH: @@ -634,7 +606,7 @@ Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob) } } -Gwn_Batch *DRW_cache_object_surface_get(Object *ob) +GPUBatch *DRW_cache_object_surface_get(Object *ob) { switch (ob->type) { case OB_MESH: @@ -652,7 +624,7 @@ Gwn_Batch *DRW_cache_object_surface_get(Object *ob) } } -Gwn_Batch **DRW_cache_object_surface_material_get( +GPUBatch **DRW_cache_object_surface_material_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { @@ -687,7 +659,7 @@ Gwn_Batch **DRW_cache_object_surface_material_get( /** \name Empties * \{ */ -Gwn_Batch *DRW_cache_plain_axes_get(void) +GPUBatch *DRW_cache_plain_axes_get(void) { if (!SHC.drw_plain_axes) { int axis; @@ -695,46 +667,46 @@ Gwn_Batch *DRW_cache_plain_axes_get(void) float v2[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 6); for (axis = 0; axis < 3; axis++) { v1[axis] = 1.0f; v2[axis] = -1.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 2, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 2 + 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 2, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 2 + 1, v2); /* reset v1 & v2 to zero for next axis */ v1[axis] = v2[axis] = 0.0f; } - SHC.drw_plain_axes = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_plain_axes = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_plain_axes; } -Gwn_Batch *DRW_cache_single_arrow_get(void) +GPUBatch *DRW_cache_single_arrow_get(void) { if (!SHC.drw_single_arrow) { float v1[3] = {0.0f, 0.0f, 1.0f}, v2[3], v3[3]; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Square Pyramid */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 12); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 12); v2[0] = 0.035f; v2[1] = 0.035f; v3[0] = -0.035f; v3[1] = 0.035f; @@ -750,26 +722,26 @@ Gwn_Batch *DRW_cache_single_arrow_get(void) v3[0] = -v3[0]; } - GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 0, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 1, v2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 2, v3); + GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 2, v3); } - SHC.drw_single_arrow = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_single_arrow = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_single_arrow; } -Gwn_Batch *DRW_cache_empty_sphere_get(void) +GPUBatch *DRW_cache_empty_sphere_get(void) { if (!SHC.drw_empty_sphere) { - Gwn_VertBuf *vbo = sphere_wire_vbo(1.0f); - SHC.drw_empty_sphere = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + GPUVertBuf *vbo = sphere_wire_vbo(1.0f); + SHC.drw_empty_sphere = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_sphere; } -Gwn_Batch *DRW_cache_empty_cone_get(void) +GPUBatch *DRW_cache_empty_cone_get(void) { #define NSEGMENTS 8 if (!SHC.drw_empty_cone) { @@ -782,14 +754,14 @@ Gwn_Batch *DRW_cache_empty_cone_get(void) } /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 4); for (int i = 0; i < NSEGMENTS; ++i) { float cv[2], v[3]; @@ -798,26 +770,26 @@ Gwn_Batch *DRW_cache_empty_cone_get(void) /* cone sides */ v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v); v[0] = 0.0f, v[1] = 2.0f, v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v); /* end ring */ v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v); cv[0] = p[(i + 1) % NSEGMENTS][0]; cv[1] = p[(i + 1) % NSEGMENTS][1]; v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); } - SHC.drw_empty_cone = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_cone = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_cone; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_empty_cylinder_get(void) +GPUBatch *DRW_cache_empty_cylinder_get(void) { #define NSEGMENTS 12 if (!SHC.drw_empty_cylinder) { @@ -830,14 +802,14 @@ Gwn_Batch *DRW_cache_empty_cylinder_get(void) } /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 6); for (int i = 0; i < NSEGMENTS; ++i) { float cv[2], pv[2], v[3]; @@ -848,30 +820,30 @@ Gwn_Batch *DRW_cache_empty_cylinder_get(void) /* cylinder sides */ copy_v3_fl3(v, cv[0], cv[1], -1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6, v); copy_v3_fl3(v, cv[0], cv[1], 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 1, v); /* top ring */ copy_v3_fl3(v, cv[0], cv[1], 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 2, v); copy_v3_fl3(v, pv[0], pv[1], 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 3, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 3, v); /* bottom ring */ copy_v3_fl3(v, cv[0], cv[1], -1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 4, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 4, v); copy_v3_fl3(v, pv[0], pv[1], -1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 5, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 5, v); } - SHC.drw_empty_cylinder = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_cylinder = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_cylinder; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_empty_capsule_body_get(void) +GPUBatch *DRW_cache_empty_capsule_body_get(void) { if (!SHC.drw_empty_capsule_body) { const float pos[8][3] = { @@ -886,22 +858,22 @@ Gwn_Batch *DRW_cache_empty_capsule_body_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 8); - GWN_vertbuf_attr_fill(vbo, attr_id.pos, pos); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 8); + GPU_vertbuf_attr_fill(vbo, attr_id.pos, pos); - SHC.drw_empty_capsule_body = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_capsule_body = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_capsule_body; } -Gwn_Batch *DRW_cache_empty_capsule_cap_get(void) +GPUBatch *DRW_cache_empty_capsule_cap_get(void) { #define NSEGMENTS 24 /* Must be multiple of 2. */ if (!SHC.drw_empty_capsule_cap) { @@ -914,23 +886,23 @@ Gwn_Batch *DRW_cache_empty_capsule_cap_get(void) } /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (NSEGMENTS * 2) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (NSEGMENTS * 2) * 2); /* Base circle */ int vidx = 0; for (int i = 0; i < NSEGMENTS; ++i) { float v[3] = {0.0f, 0.0f, 0.0f}; copy_v2_v2(v, p[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); copy_v2_v2(v, p[(i+1) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } for (int i = 0; i < NSEGMENTS / 2; ++i) { @@ -939,149 +911,149 @@ Gwn_Batch *DRW_cache_empty_capsule_cap_get(void) int pi = (i + 1) % NSEGMENTS; /* Y half circle */ copy_v3_fl3(v, p[ci][0], 0.0f, p[ci][1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); copy_v3_fl3(v, p[pi][0], 0.0f, p[pi][1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); /* X half circle */ copy_v3_fl3(v, 0.0f, p[ci][0], p[ci][1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); copy_v3_fl3(v, 0.0f, p[pi][0], p[pi][1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } - SHC.drw_empty_capsule_cap = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_capsule_cap = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_capsule_cap; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_arrows_get(void) +GPUBatch *DRW_cache_arrows_get(void) { if (!SHC.drw_arrows) { - Gwn_VertBuf *vbo = fill_arrows_vbo(1.0f); + GPUVertBuf *vbo = fill_arrows_vbo(1.0f); - SHC.drw_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_arrows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_arrows; } -Gwn_Batch *DRW_cache_axis_names_get(void) +GPUBatch *DRW_cache_axis_names_get(void) { if (!SHC.drw_axis_names) { const float size = 0.1f; float v1[3], v2[3]; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { /* Using 3rd component as axis indicator */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Line */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 14); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 14); /* X */ copy_v3_fl3(v1, -size, size, 0.0f); copy_v3_fl3(v2, size, -size, 0.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); copy_v3_fl3(v1, size, size, 0.0f); copy_v3_fl3(v2, -size, -size, 0.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 3, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 3, v2); /* Y */ copy_v3_fl3(v1, -size + 0.25f * size, size, 1.0f); copy_v3_fl3(v2, 0.0f, 0.0f, 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 4, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 5, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 4, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 5, v2); copy_v3_fl3(v1, size - 0.25f * size, size, 1.0f); copy_v3_fl3(v2, -size + 0.25f * size, -size, 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 6, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 7, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 6, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 7, v2); /* Z */ copy_v3_fl3(v1, -size, size, 2.0f); copy_v3_fl3(v2, size, size, 2.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 8, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 9, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 8, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 9, v2); copy_v3_fl3(v1, size, size, 2.0f); copy_v3_fl3(v2, -size, -size, 2.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 10, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 11, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 10, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 11, v2); copy_v3_fl3(v1, -size, -size, 2.0f); copy_v3_fl3(v2, size, -size, 2.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 12, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 13, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 12, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 13, v2); - SHC.drw_axis_names = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_axis_names = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_axis_names; } -Gwn_Batch *DRW_cache_image_plane_get(void) +GPUBatch *DRW_cache_image_plane_get(void) { if (!SHC.drw_image_plane) { const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, texCoords; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.texCoords = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.texCoords = GPU_vertformat_attr_add(&format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 4); for (uint j = 0; j < 4; j++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); - GWN_vertbuf_attr_set(vbo, attr_id.texCoords, j, quad[j]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); + GPU_vertbuf_attr_set(vbo, attr_id.texCoords, j, quad[j]); } - SHC.drw_image_plane = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_image_plane = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_image_plane; } -Gwn_Batch *DRW_cache_image_plane_wire_get(void) +GPUBatch *DRW_cache_image_plane_wire_get(void) { if (!SHC.drw_image_plane_wire) { const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 4); for (uint j = 0; j < 4; j++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); } - SHC.drw_image_plane_wire = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_image_plane_wire = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_image_plane_wire; } /* Force Field */ -Gwn_Batch *DRW_cache_field_wind_get(void) +GPUBatch *DRW_cache_field_wind_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_field_wind) { float v[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 4); for (int i = 0; i < 4; i++) { float z = 0.05f * (float)i; @@ -1089,36 +1061,36 @@ Gwn_Batch *DRW_cache_field_wind_get(void) v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v); } } - SHC.drw_field_wind = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_wind = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_wind; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_field_force_get(void) +GPUBatch *DRW_cache_field_force_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_field_force) { float v[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 3); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 3); for (int i = 0; i < 3; i++) { float radius = 1.0f + 0.5f * (float)i; @@ -1126,22 +1098,22 @@ Gwn_Batch *DRW_cache_field_force_get(void) v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v); v[0] = radius * sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[1] = radius * cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v); } } - SHC.drw_field_force = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_force = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_force; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_field_vortex_get(void) +GPUBatch *DRW_cache_field_vortex_get(void) { #define SPIRAL_RESOL 32 if (!SHC.drw_field_vortex) { @@ -1149,36 +1121,36 @@ Gwn_Batch *DRW_cache_field_vortex_get(void) uint v_idx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, SPIRAL_RESOL * 2 + 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, SPIRAL_RESOL * 2 + 1); for (int a = SPIRAL_RESOL; a > -1; a--) { v[0] = sinf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL); v[1] = cosf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } for (int a = 1; a <= SPIRAL_RESOL; a++) { v[0] = -sinf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL); v[1] = -cosf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } - SHC.drw_field_vortex = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_vortex = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_vortex; #undef SPIRAL_RESOL } -Gwn_Batch *DRW_cache_field_tube_limit_get(void) +GPUBatch *DRW_cache_field_tube_limit_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_field_tube_limit) { @@ -1186,14 +1158,14 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) uint v_idx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8); /* Caps */ for (int i = 0; i < 2; i++) { @@ -1202,12 +1174,12 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } } /* Side Edges */ @@ -1217,17 +1189,17 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) v[0] = sinf((2.0f * M_PI * a) / 4.0f); v[1] = cosf((2.0f * M_PI * a) / 4.0f); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } } - SHC.drw_field_tube_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_tube_limit = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_tube_limit; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_field_cone_limit_get(void) +GPUBatch *DRW_cache_field_cone_limit_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_field_cone_limit) { @@ -1235,14 +1207,14 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) uint v_idx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8); /* Caps */ for (int i = 0; i < 2; i++) { @@ -1251,12 +1223,12 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } } /* Side Edges */ @@ -1266,11 +1238,11 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) v[0] = z * sinf((2.0f * M_PI * a) / 4.0f); v[1] = z * cosf((2.0f * M_PI * a) / 4.0f); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } } - SHC.drw_field_cone_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_cone_limit = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_cone_limit; #undef CIRCLE_RESOL @@ -1283,84 +1255,84 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) /** \name Lamps * \{ */ -Gwn_Batch *DRW_cache_lamp_get(void) +GPUBatch *DRW_cache_lamp_get(void) { #define NSEGMENTS 8 if (!SHC.drw_lamp) { float v[2]; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2); for (int a = 0; a < NSEGMENTS * 2; a += 2) { v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2)); v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v); } - SHC.drw_lamp = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_lamp_shadows_get(void) +GPUBatch *DRW_cache_lamp_shadows_get(void) { #define NSEGMENTS 10 if (!SHC.drw_lamp_shadows) { float v[2]; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2); for (int a = 0; a < NSEGMENTS * 2; a += 2) { v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2)); v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v); } - SHC.drw_lamp_shadows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_shadows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_shadows; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_lamp_sunrays_get(void) +GPUBatch *DRW_cache_lamp_sunrays_get(void) { if (!SHC.drw_lamp_sunrays) { float v[2], v1[2], v2[2]; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 32); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 32); for (int a = 0; a < 8; a++) { v[0] = sinf((2.0f * M_PI * a) / 8.0f); @@ -1368,86 +1340,86 @@ Gwn_Batch *DRW_cache_lamp_sunrays_get(void) mul_v2_v2fl(v1, v, 1.6f); mul_v2_v2fl(v2, v, 1.9f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 1, v2); mul_v2_v2fl(v1, v, 2.2f); mul_v2_v2fl(v2, v, 2.5f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 2, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 3, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 2, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 3, v2); } - SHC.drw_lamp_sunrays = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_sunrays = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_sunrays; } -Gwn_Batch *DRW_cache_lamp_area_square_get(void) +GPUBatch *DRW_cache_lamp_area_square_get(void) { if (!SHC.drw_lamp_area_square) { float v1[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 8); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 8); v1[0] = v1[1] = 0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); v1[0] = -0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2, v1); v1[1] = -0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 3, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 4, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 3, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 4, v1); v1[0] = 0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 5, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 6, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 5, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 6, v1); v1[1] = 0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 7, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 7, v1); - SHC.drw_lamp_area_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_area_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_area_square; } -Gwn_Batch *DRW_cache_lamp_area_disk_get(void) +GPUBatch *DRW_cache_lamp_area_disk_get(void) { #define NSEGMENTS 32 if (!SHC.drw_lamp_area_disk) { /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 2 * NSEGMENTS); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 2 * NSEGMENTS); float v[3] = {0.0f, 0.5f, 0.0f}; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v); for (int a = 1; a < NSEGMENTS; a++) { v[0] = 0.5f * sinf(2.0f * (float)M_PI * a / NSEGMENTS); v[1] = 0.5f * cosf(2.0f * (float)M_PI * a / NSEGMENTS); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * a - 1, v); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * a - 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * a, v); } copy_v3_fl3(v, 0.0f, 0.5f, 0.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, (2 * NSEGMENTS) - 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, (2 * NSEGMENTS) - 1, v); - SHC.drw_lamp_area_disk = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_area_disk = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_area_disk; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_lamp_hemi_get(void) +GPUBatch *DRW_cache_lamp_hemi_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_lamp_hemi) { @@ -1455,26 +1427,26 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) int vidx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 - 6 * 2 * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 - 6 * 2 * 2); /* XZ plane */ for (int a = 3; a < CIRCLE_RESOL / 2 - 3; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL) - M_PI / 2); v[2] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL) - M_PI / 2) - 1.0f; v[1] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL) - M_PI / 2); v[2] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL) - M_PI / 2) - 1.0f; v[1] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } /* XY plane */ @@ -1482,12 +1454,12 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) v[2] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)) - 1.0f; v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[0] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); v[2] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)) - 1.0f; v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[0] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } /* YZ plane full circle */ @@ -1496,22 +1468,22 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) for (int a = 0; a < CIRCLE_RESOL; a++) { v[1] = rad * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[0] = rad * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); v[1] = rad * sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[0] = rad * cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } - SHC.drw_lamp_hemi = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_hemi = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_hemi; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_lamp_spot_get(void) +GPUBatch *DRW_cache_lamp_spot_get(void) { #define NSEGMENTS 32 if (!SHC.drw_lamp_spot) { @@ -1533,16 +1505,16 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void) } /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, n1, n2; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.n1 = GPU_vertformat_attr_add(&format, "N1", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.n2 = GPU_vertformat_attr_add(&format, "N2", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 4); for (int i = 0; i < NSEGMENTS; ++i) { float cv[2], v[3]; @@ -1551,36 +1523,36 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void) /* cone sides */ v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v); v[0] = 0.0f, v[1] = 0.0f, v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v); - GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4, n[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 1, n[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4, n[(i + 1) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 1, n[(i + 1) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4, n[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 1, n[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4, n[(i + 1) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 1, n[(i + 1) % NSEGMENTS]); /* end ring */ v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v); cv[0] = p[(i + 1) % NSEGMENTS][0]; cv[1] = p[(i + 1) % NSEGMENTS][1]; v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); - GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 2, n[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 3, n[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 2, neg[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 2, n[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 3, n[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 2, neg[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]); } - SHC.drw_lamp_spot = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_spot = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_spot; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_lamp_spot_square_get(void) +GPUBatch *DRW_cache_lamp_spot_square_get(void) { if (!SHC.drw_lamp_spot_square) { float p[5][3] = {{ 0.0f, 0.0f, 0.0f}, @@ -1592,25 +1564,25 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void) uint v_idx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 16); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 16); /* piramid sides */ for (int i = 1; i <= 4; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[0]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[0]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[i]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[(i % 4) + 1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i + 1) % 4) + 1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[(i % 4) + 1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i + 1) % 4) + 1]); } - SHC.drw_lamp_spot_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_spot_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_spot_square; } @@ -1622,7 +1594,7 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void) /** \name Speaker * \{ */ -Gwn_Batch *DRW_cache_speaker_get(void) +GPUBatch *DRW_cache_speaker_get(void) { if (!SHC.drw_speaker) { float v[3]; @@ -1630,30 +1602,30 @@ Gwn_Batch *DRW_cache_speaker_get(void) int vidx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 3 * segments * 2 + 4 * 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 3 * segments * 2 + 4 * 4); for (int j = 0; j < 3; j++) { float z = 0.25f * j - 0.125f; float r = (j == 0 ? 0.5f : 0.25f); copy_v3_fl3(v, r, 0.0f, z); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); for (int i = 1; i < segments; i++) { float x = cosf(2.f * (float)M_PI * i / segments) * r; float y = sinf(2.f * (float)M_PI * i / segments) * r; copy_v3_fl3(v, x, y, z); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } copy_v3_fl3(v, r, 0.0f, z); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } for (int j = 0; j < 4; j++) { @@ -1667,14 +1639,14 @@ Gwn_Batch *DRW_cache_speaker_get(void) float z = 0.25f * i - 0.125f; copy_v3_fl3(v, x, y, z); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); if (i == 1) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } } } - SHC.drw_speaker = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_speaker = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_speaker; } @@ -1686,7 +1658,7 @@ Gwn_Batch *DRW_cache_speaker_get(void) /** \name Probe * \{ */ -Gwn_Batch *DRW_cache_lightprobe_cube_get(void) +GPUBatch *DRW_cache_lightprobe_cube_get(void) { if (!SHC.drw_lightprobe_cube) { int v_idx = 0; @@ -1703,35 +1675,35 @@ Gwn_Batch *DRW_cache_lightprobe_cube_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (6 + 3) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (6 + 3) * 2); for (int i = 0; i < 6; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]); } - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - SHC.drw_lightprobe_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lightprobe_cube = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_cube; } -Gwn_Batch *DRW_cache_lightprobe_grid_get(void) +GPUBatch *DRW_cache_lightprobe_grid_get(void) { if (!SHC.drw_lightprobe_grid) { int v_idx = 0; @@ -1748,47 +1720,47 @@ Gwn_Batch *DRW_cache_lightprobe_grid_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (6 * 2 + 3) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (6 * 2 + 3) * 2); for (int i = 0; i < 6; ++i) { float tmp_v1[3], tmp_v2[3], tmp_tr[3]; copy_v3_v3(tmp_v1, v[i]); copy_v3_v3(tmp_v2, v[(i + 1) % 6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2); /* Internal wires. */ for (int j = 1; j < 2; ++j) { mul_v3_v3fl(tmp_tr, v[(i / 2) * 2 + 1], -0.5f * j); add_v3_v3v3(tmp_v1, v[i], tmp_tr); add_v3_v3v3(tmp_v2, v[(i + 1) % 6], tmp_tr); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2); } } - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - SHC.drw_lightprobe_grid = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lightprobe_grid = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_grid; } -Gwn_Batch *DRW_cache_lightprobe_planar_get(void) +GPUBatch *DRW_cache_lightprobe_planar_get(void) { if (!SHC.drw_lightprobe_planar) { int v_idx = 0; @@ -1801,21 +1773,21 @@ Gwn_Batch *DRW_cache_lightprobe_planar_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 4 * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 4 * 2); for (int i = 0; i < 4; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 4]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 4]); } - SHC.drw_lightprobe_planar = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lightprobe_planar = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_planar; } @@ -1924,45 +1896,45 @@ static const float bone_octahedral_solid_normals[8][3] = { { 0.00000000f, 0.11043154f, 0.99388373f} }; -Gwn_Batch *DRW_cache_bone_octahedral_get(void) +GPUBatch *DRW_cache_bone_octahedral_get(void) { if (!SHC.drw_bone_octahedral) { uint v_idx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor, snor; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.snor = GPU_vertformat_attr_add(&format, "snor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 24); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 24); for (int i = 0; i < 8; i++) { for (int j = 0; j < 3; ++j) { - GWN_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]); - GWN_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_octahedral_smooth_normals[bone_octahedral_solid_tris[i][j]]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][j]]); + GPU_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]); + GPU_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_octahedral_smooth_normals[bone_octahedral_solid_tris[i][j]]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][j]]); } } - SHC.drw_bone_octahedral = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, - GWN_BATCH_OWNS_VBO); + SHC.drw_bone_octahedral = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, + GPU_BATCH_OWNS_VBO); } return SHC.drw_bone_octahedral; } -Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void) +GPUBatch *DRW_cache_bone_octahedral_wire_get(void) { if (!SHC.drw_bone_octahedral_wire) { - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, 12, 24); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 24); for (int i = 0; i < 12; i++) { - GWN_indexbuf_add_line_adj_verts(&elb, + GPU_indexbuf_add_line_adj_verts(&elb, bone_octahedral_wire_lines_adjacency[i][0], bone_octahedral_wire_lines_adjacency[i][1], bone_octahedral_wire_lines_adjacency[i][2], @@ -1970,10 +1942,10 @@ Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void) } /* HACK Reuse vertex buffer. */ - Gwn_Batch *pos_nor_batch = DRW_cache_bone_octahedral_get(); + GPUBatch *pos_nor_batch = DRW_cache_bone_octahedral_get(); - SHC.drw_bone_octahedral_wire = GWN_batch_create_ex(GWN_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GWN_indexbuf_build(&elb), - GWN_BATCH_OWNS_INDEX); + SHC.drw_bone_octahedral_wire = GPU_batch_create_ex(GPU_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GPU_indexbuf_build(&elb), + GPU_BATCH_OWNS_INDEX); } return SHC.drw_bone_octahedral_wire; } @@ -2090,45 +2062,45 @@ static const float bone_box_solid_normals[12][3] = { { 0.0f, 1.0f, 0.0f}, }; -Gwn_Batch *DRW_cache_bone_box_get(void) +GPUBatch *DRW_cache_bone_box_get(void) { if (!SHC.drw_bone_box) { uint v_idx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor, snor; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.snor = GPU_vertformat_attr_add(&format, "snor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 36); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 36); for (int i = 0; i < 12; i++) { for (int j = 0; j < 3; j++) { - GWN_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_box_solid_normals[i]); - GWN_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_box_smooth_normals[bone_box_solid_tris[i][j]]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_box_verts[bone_box_solid_tris[i][j]]); + GPU_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_box_solid_normals[i]); + GPU_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_box_smooth_normals[bone_box_solid_tris[i][j]]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_box_verts[bone_box_solid_tris[i][j]]); } } - SHC.drw_bone_box = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, - GWN_BATCH_OWNS_VBO); + SHC.drw_bone_box = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, + GPU_BATCH_OWNS_VBO); } return SHC.drw_bone_box; } -Gwn_Batch *DRW_cache_bone_box_wire_get(void) +GPUBatch *DRW_cache_bone_box_wire_get(void) { if (!SHC.drw_bone_box_wire) { - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, 12, 36); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 36); for (int i = 0; i < 12; i++) { - GWN_indexbuf_add_line_adj_verts(&elb, + GPU_indexbuf_add_line_adj_verts(&elb, bone_box_wire_lines_adjacency[i][0], bone_box_wire_lines_adjacency[i][1], bone_box_wire_lines_adjacency[i][2], @@ -2136,10 +2108,10 @@ Gwn_Batch *DRW_cache_bone_box_wire_get(void) } /* HACK Reuse vertex buffer. */ - Gwn_Batch *pos_nor_batch = DRW_cache_bone_box_get(); + GPUBatch *pos_nor_batch = DRW_cache_bone_box_get(); - SHC.drw_bone_box_wire = GWN_batch_create_ex(GWN_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GWN_indexbuf_build(&elb), - GWN_BATCH_OWNS_INDEX); + SHC.drw_bone_box_wire = GPU_batch_create_ex(GPU_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GPU_indexbuf_build(&elb), + GPU_BATCH_OWNS_INDEX); } return SHC.drw_bone_box_wire; } @@ -2153,7 +2125,7 @@ static void benv_lat_lon_to_co(const float lat, const float lon, float r_nor[3]) r_nor[2] = cosf(lat); } -Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) +GPUBatch *DRW_cache_bone_envelope_solid_get(void) { if (!SHC.drw_bone_envelope) { const int lon_res = 24; @@ -2162,15 +2134,15 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) const float lat_inc = M_PI / lat_res; uint v_idx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, ((lat_res + 1) * 2) * lon_res * 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, ((lat_res + 1) * 2) * lon_res * 1); float lon = 0.0f; for (int i = 0; i < lon_res; i++, lon += lon_inc) { @@ -2184,24 +2156,24 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) benv_lat_lon_to_co(lat, lon, co1); benv_lat_lon_to_co(lat, lon + lon_inc, co2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2); } /* Closing the loop */ benv_lat_lon_to_co(M_PI, lon, co1); benv_lat_lon_to_co(M_PI, lon + lon_inc, co2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2); } - SHC.drw_bone_envelope = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_envelope = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_bone_envelope; } -Gwn_Batch *DRW_cache_bone_envelope_outline_get(void) +GPUBatch *DRW_cache_bone_envelope_outline_get(void) { if (!SHC.drw_bone_envelope_outline) { # define CIRCLE_RESOL 64 @@ -2209,16 +2181,16 @@ Gwn_Batch *DRW_cache_bone_envelope_outline_get(void) const float radius = 1.0f; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos0, pos1, pos2; } attr_id; if (format.attr_len == 0) { - attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.pos2 = GWN_vertformat_attr_add(&format, "pos2", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos0 = GPU_vertformat_attr_add(&format, "pos0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.pos1 = GPU_vertformat_attr_add(&format, "pos1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.pos2 = GPU_vertformat_attr_add(&format, "pos2", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2); v0[0] = radius * sinf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL)); v0[1] = radius * cosf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL)); @@ -2230,31 +2202,31 @@ Gwn_Batch *DRW_cache_bone_envelope_outline_get(void) for (int a = 0; a < CIRCLE_RESOL; a++) { v2[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v2[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); copy_v2_v2(v0, v1); copy_v2_v2(v1, v2); } v2[0] = 0.0f; v2[1] = radius; - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); - - SHC.drw_bone_envelope_outline = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); + + SHC.drw_bone_envelope_outline = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); # undef CIRCLE_RESOL } return SHC.drw_bone_envelope_outline; } -Gwn_Batch *DRW_cache_bone_point_get(void) +GPUBatch *DRW_cache_bone_point_get(void) { if (!SHC.drw_bone_point) { #if 0 /* old style geometry sphere */ @@ -2265,16 +2237,16 @@ Gwn_Batch *DRW_cache_bone_point_get(void) const float lat_inc = M_PI / lat_res; uint v_idx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (lat_res - 1) * lon_res * 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (lat_res - 1) * lon_res * 6); float lon = 0.0f; for (int i = 0; i < lon_res; i++, lon += lon_inc) { @@ -2294,56 +2266,56 @@ Gwn_Batch *DRW_cache_bone_point_get(void) } } - SHC.drw_bone_point = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_point = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); #else # define CIRCLE_RESOL 64 float v[2]; const float radius = 0.05f; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL); for (int a = 0; a < CIRCLE_RESOL; a++) { v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); } - SHC.drw_bone_point = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_point = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); # undef CIRCLE_RESOL #endif } return SHC.drw_bone_point; } -Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) +GPUBatch *DRW_cache_bone_point_wire_outline_get(void) { if (!SHC.drw_bone_point_wire) { #if 0 /* old style geometry sphere */ - Gwn_VertBuf *vbo = sphere_wire_vbo(0.05f); - SHC.drw_bone_point_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + GPUVertBuf *vbo = sphere_wire_vbo(0.05f); + SHC.drw_bone_point_wire = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); #else # define CIRCLE_RESOL 64 float v0[2], v1[2]; const float radius = 0.05f; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos0, pos1; } attr_id; if (format.attr_len == 0) { - attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos0 = GPU_vertformat_attr_add(&format, "pos0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.pos1 = GPU_vertformat_attr_add(&format, "pos1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2); v0[0] = radius * sinf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL)); v0[1] = radius * cosf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL)); @@ -2352,20 +2324,20 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) for (int a = 0; a < CIRCLE_RESOL; a++) { v1[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v1[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); copy_v2_v2(v0, v1); } v1[0] = 0.0f; v1[1] = radius; - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); - SHC.drw_bone_point_wire = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_point_wire = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); # undef CIRCLE_RESOL #endif } @@ -2382,7 +2354,7 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) #define POS_TAIL (1 << 5) #define POS_BONE (1 << 6) -Gwn_Batch *DRW_cache_bone_stick_get(void) +GPUBatch *DRW_cache_bone_stick_get(void) { if (!SHC.drw_bone_stick) { #define CIRCLE_RESOL 12 @@ -2392,20 +2364,20 @@ Gwn_Batch *DRW_cache_bone_stick_get(void) float pos[2]; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, flag; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.flag = GWN_vertformat_attr_add(&format, "flag", GWN_COMP_U32, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.flag = GPU_vertformat_attr_add(&format, "flag", GPU_COMP_U32, 1, GPU_FETCH_INT); } const uint vcount = (CIRCLE_RESOL + 1) * 2 + 6; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vcount); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vcount); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, GWN_PRIM_TRI_FAN, (CIRCLE_RESOL + 2) * 2 + 6 + 2, vcount, true); + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex(&elb, GPU_PRIM_TRI_FAN, (CIRCLE_RESOL + 2) * 2 + 6 + 2, vcount, true); /* head/tail points */ for (int i = 0; i < 2; ++i) { @@ -2413,22 +2385,22 @@ Gwn_Batch *DRW_cache_bone_stick_get(void) copy_v2_fl(pos, 0.0f); flag = (i == 0) ? POS_HEAD : POS_TAIL; flag |= (i == 0) ? COL_HEAD : COL_TAIL; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos); - GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos); + GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); + GPU_indexbuf_add_generic_vert(&elb, v++); /* circle vertices */ flag |= COL_WIRE; for (int a = 0; a < CIRCLE_RESOL; a++) { pos[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); pos[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos); - GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos); + GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); + GPU_indexbuf_add_generic_vert(&elb, v++); } /* Close the circle */ - GWN_indexbuf_add_generic_vert(&elb, v - CIRCLE_RESOL); + GPU_indexbuf_add_generic_vert(&elb, v - CIRCLE_RESOL); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); } /* Bone rectangle */ @@ -2437,25 +2409,25 @@ Gwn_Batch *DRW_cache_bone_stick_get(void) pos[1] = (i == 0 || i == 3) ? 0.0f : ((i < 3) ? 1.0f : -1.0f); flag = ((i < 2 || i > 4) ? POS_HEAD : POS_TAIL) | ((i == 0 || i == 3) ? 0 : COL_WIRE) | COL_BONE | POS_BONE; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos); - GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos); + GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); + GPU_indexbuf_add_generic_vert(&elb, v++); } - SHC.drw_bone_stick = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, GWN_indexbuf_build(&elb), - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + SHC.drw_bone_stick = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, GPU_indexbuf_build(&elb), + GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); #undef CIRCLE_RESOL } return SHC.drw_bone_stick; } static void set_bone_axis_vert( - Gwn_VertBuf *vbo, uint axis, uint pos, uint col, + GPUVertBuf *vbo, uint axis, uint pos, uint col, uint *v, const float *a, const float *p, const float *c) { - GWN_vertbuf_attr_set(vbo, axis, *v, a); - GWN_vertbuf_attr_set(vbo, pos, *v, p); - GWN_vertbuf_attr_set(vbo, col, *v, c); + GPU_vertbuf_attr_set(vbo, axis, *v, a); + GPU_vertbuf_attr_set(vbo, pos, *v, p); + GPU_vertbuf_attr_set(vbo, col, *v, c); *v += 1; } @@ -2530,21 +2502,21 @@ static float axis_name_shadow[8][2] = { #undef S_X #undef S_Y -Gwn_Batch *DRW_cache_bone_arrows_get(void) +GPUBatch *DRW_cache_bone_arrows_get(void) { if (!SHC.drw_bone_arrows) { /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint axis, pos, col; } attr_id; if (format.attr_len == 0) { - attr_id.axis = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - attr_id.pos = GWN_vertformat_attr_add(&format, "screenPos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.col = GWN_vertformat_attr_add(&format, "colorAxis", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.axis = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "screenPos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.col = GPU_vertformat_attr_add(&format, "colorAxis", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Line */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (2 + MARKER_LEN * MARKER_FILL_LAYER) * 3 + + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (2 + MARKER_LEN * MARKER_FILL_LAYER) * 3 + (X_LEN + Y_LEN + Z_LEN) * (1 + SHADOW_RES)); uint v = 0; @@ -2607,7 +2579,7 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) } } - SHC.drw_bone_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_arrows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_bone_arrows; } @@ -2642,52 +2614,52 @@ static const float camera_coords_frame_tri[3] = { /** Draw a loop of lines. */ static void camera_fill_lines_loop_fl_v1( - Gwn_VertBufRaw *pos_step, + GPUVertBufRaw *pos_step, const float *coords, const uint coords_len) { for (uint i = 0, i_prev = coords_len - 1; i < coords_len; i_prev = i++) { - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i_prev]; - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i_prev]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i]; } } /** Fan lines out from the first vertex. */ static void camera_fill_lines_fan_fl_v1( - Gwn_VertBufRaw *pos_step, + GPUVertBufRaw *pos_step, const float *coords, const uint coords_len) { for (uint i = 1; i < coords_len; i++) { - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[0]; - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[0]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i]; } } /** Simply fill the array. */ static void camera_fill_array_fl_v1( - Gwn_VertBufRaw *pos_step, + GPUVertBufRaw *pos_step, const float *coords, const uint coords_len) { for (uint i = 0; i < coords_len; i++) { - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i]; } } -Gwn_Batch *DRW_cache_camera_get(void) +GPUBatch *DRW_cache_camera_get(void) { if (!SHC.drw_camera) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = 22; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); /* camera cone (from center to frame) */ camera_fill_lines_fan_fl_v1(&pos_step, camera_coords_frame_bounds, ARRAY_SIZE(camera_coords_frame_bounds)); @@ -2698,62 +2670,62 @@ Gwn_Batch *DRW_cache_camera_get(void) /* camera triangle (above the frame) */ camera_fill_lines_loop_fl_v1(&pos_step, camera_coords_frame_tri, ARRAY_SIZE(camera_coords_frame_tri)); - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step)); - SHC.drw_camera = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_camera = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_camera; } -Gwn_Batch *DRW_cache_camera_frame_get(void) +GPUBatch *DRW_cache_camera_frame_get(void) { if (!SHC.drw_camera_frame) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = 8; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); /* camera frame (skip center) */ camera_fill_lines_loop_fl_v1(&pos_step, &camera_coords_frame_bounds[1], ARRAY_SIZE(camera_coords_frame_bounds) - 1); - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step)); - SHC.drw_camera_frame = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_camera_frame = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_camera_frame; } -Gwn_Batch *DRW_cache_camera_tria_get(void) +GPUBatch *DRW_cache_camera_tria_get(void) { if (!SHC.drw_camera_tria) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = 3; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); /* camera triangle (above the frame) */ camera_fill_array_fl_v1(&pos_step, camera_coords_frame_tri, ARRAY_SIZE(camera_coords_frame_tri)); - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step)); - SHC.drw_camera_tria = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_camera_tria = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_camera_tria; } @@ -2766,24 +2738,24 @@ Gwn_Batch *DRW_cache_camera_tria_get(void) * \{ */ /* Object Center */ -Gwn_Batch *DRW_cache_single_vert_get(void) +GPUBatch *DRW_cache_single_vert_get(void) { if (!SHC.drw_single_vertice) { float v1[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - SHC.drw_single_vertice = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_single_vertice = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_single_vertice; } @@ -2795,7 +2767,7 @@ Gwn_Batch *DRW_cache_single_vert_get(void) /** \name Meshes * \{ */ -Gwn_Batch *DRW_cache_mesh_surface_overlay_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_overlay_get(Object *ob) { BLI_assert(ob->type == OB_MESH); Mesh *me = ob->data; @@ -2804,7 +2776,7 @@ Gwn_Batch *DRW_cache_mesh_surface_overlay_get(Object *ob) void DRW_cache_mesh_wire_overlay_get( Object *ob, - Gwn_Batch **r_tris, Gwn_Batch **r_ledges, Gwn_Batch **r_lverts) + GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts) { BLI_assert(ob->type == OB_MESH); @@ -2817,7 +2789,7 @@ void DRW_cache_mesh_wire_overlay_get( void DRW_cache_mesh_normals_overlay_get( Object *ob, - Gwn_Batch **r_tris, Gwn_Batch **r_ledges, Gwn_Batch **r_lverts) + GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts) { BLI_assert(ob->type == OB_MESH); @@ -2828,7 +2800,7 @@ void DRW_cache_mesh_normals_overlay_get( *r_lverts = DRW_mesh_batch_cache_get_overlay_loose_verts(me); } -Gwn_Batch *DRW_cache_face_centers_get(Object *ob) +GPUBatch *DRW_cache_face_centers_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2837,7 +2809,7 @@ Gwn_Batch *DRW_cache_face_centers_get(Object *ob) return DRW_mesh_batch_cache_get_overlay_facedots(me); } -Gwn_Batch *DRW_cache_mesh_wire_outline_get(Object *ob) +GPUBatch *DRW_cache_mesh_wire_outline_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2845,7 +2817,7 @@ Gwn_Batch *DRW_cache_mesh_wire_outline_get(Object *ob) return DRW_mesh_batch_cache_get_fancy_edges(me); } -Gwn_Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold) +GPUBatch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold) { BLI_assert(ob->type == OB_MESH); @@ -2853,7 +2825,7 @@ Gwn_Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold) return DRW_mesh_batch_cache_get_edge_detection(me, r_is_manifold); } -Gwn_Batch *DRW_cache_mesh_surface_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2861,7 +2833,7 @@ Gwn_Batch *DRW_cache_mesh_surface_get(Object *ob) return DRW_mesh_batch_cache_get_triangles_with_normals(me); } -Gwn_Batch *DRW_cache_mesh_loose_edges_get(Object *ob) +GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2869,7 +2841,7 @@ Gwn_Batch *DRW_cache_mesh_loose_edges_get(Object *ob) return DRW_mesh_batch_cache_get_loose_edges_with_normals(me); } -Gwn_Batch *DRW_cache_mesh_surface_weights_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2877,7 +2849,7 @@ Gwn_Batch *DRW_cache_mesh_surface_weights_get(Object *ob) return DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me, ob->actdef - 1); } -Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_vert_colors_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2886,7 +2858,7 @@ Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob) } /* Return list of batches */ -Gwn_Batch **DRW_cache_mesh_surface_shaded_get( +GPUBatch **DRW_cache_mesh_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { @@ -2898,7 +2870,7 @@ Gwn_Batch **DRW_cache_mesh_surface_shaded_get( } /* Return list of batches */ -Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(Object *ob) +GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2906,7 +2878,7 @@ Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(Object *ob) return DRW_mesh_batch_cache_get_surface_texpaint(me); } -Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2914,7 +2886,7 @@ Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob) return DRW_mesh_batch_cache_get_surface_texpaint_single(me); } -Gwn_Batch *DRW_cache_mesh_surface_verts_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_verts_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2922,7 +2894,7 @@ Gwn_Batch *DRW_cache_mesh_surface_verts_get(Object *ob) return DRW_mesh_batch_cache_get_points_with_normals(me); } -Gwn_Batch *DRW_cache_mesh_edges_get(Object *ob) +GPUBatch *DRW_cache_mesh_edges_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2930,7 +2902,7 @@ Gwn_Batch *DRW_cache_mesh_edges_get(Object *ob) return DRW_mesh_batch_cache_get_all_edges(me); } -Gwn_Batch *DRW_cache_mesh_verts_get(Object *ob) +GPUBatch *DRW_cache_mesh_verts_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2938,7 +2910,7 @@ Gwn_Batch *DRW_cache_mesh_verts_get(Object *ob) return DRW_mesh_batch_cache_get_all_verts(me); } -Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool use_sel) +GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool use_sel) { BLI_assert(ob->type == OB_MESH); @@ -2946,7 +2918,7 @@ Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, boo return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel); } -Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob) +GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2954,7 +2926,7 @@ Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob) return DRW_mesh_batch_cache_get_weight_overlay_faces(me); } -Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob) +GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2977,7 +2949,7 @@ void DRW_cache_mesh_sculpt_coords_ensure(Object *ob) /** \name Curve * \{ */ -Gwn_Batch *DRW_cache_curve_edge_wire_get(Object *ob) +GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob) { BLI_assert(ob->type == OB_CURVE); @@ -2985,7 +2957,7 @@ Gwn_Batch *DRW_cache_curve_edge_wire_get(Object *ob) return DRW_curve_batch_cache_get_wire_edge(cu, ob->curve_cache); } -Gwn_Batch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size) +GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size) { BLI_assert(ob->type == OB_CURVE); @@ -2993,7 +2965,7 @@ Gwn_Batch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size) return DRW_curve_batch_cache_get_normal_edge(cu, ob->curve_cache, normal_size); } -Gwn_Batch *DRW_cache_curve_edge_overlay_get(Object *ob) +GPUBatch *DRW_cache_curve_edge_overlay_get(Object *ob) { BLI_assert(ob->type == OB_CURVE); @@ -3001,7 +2973,7 @@ Gwn_Batch *DRW_cache_curve_edge_overlay_get(Object *ob) return DRW_curve_batch_cache_get_overlay_edges(cu); } -Gwn_Batch *DRW_cache_curve_vert_overlay_get(Object *ob) +GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob) { BLI_assert(ob->type == OB_CURVE); @@ -3009,7 +2981,7 @@ Gwn_Batch *DRW_cache_curve_vert_overlay_get(Object *ob) return DRW_curve_batch_cache_get_overlay_verts(cu); } -Gwn_Batch *DRW_cache_curve_surface_get(Object *ob) +GPUBatch *DRW_cache_curve_surface_get(Object *ob) { BLI_assert(ob->type == OB_CURVE); @@ -3018,7 +2990,7 @@ Gwn_Batch *DRW_cache_curve_surface_get(Object *ob) } /* Return list of batches */ -Gwn_Batch **DRW_cache_curve_surface_shaded_get( +GPUBatch **DRW_cache_curve_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) { BLI_assert(ob->type == OB_CURVE); @@ -3034,13 +3006,13 @@ Gwn_Batch **DRW_cache_curve_surface_shaded_get( /** \name MetaBall * \{ */ -Gwn_Batch *DRW_cache_mball_surface_get(Object *ob) +GPUBatch *DRW_cache_mball_surface_get(Object *ob) { BLI_assert(ob->type == OB_MBALL); return DRW_metaball_batch_cache_get_triangles_with_normals(ob); } -Gwn_Batch **DRW_cache_mball_surface_shaded_get( +GPUBatch **DRW_cache_mball_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) { BLI_assert(ob->type == OB_MBALL); @@ -3055,7 +3027,7 @@ Gwn_Batch **DRW_cache_mball_surface_shaded_get( /** \name Font * \{ */ -Gwn_Batch *DRW_cache_text_edge_wire_get(Object *ob) +GPUBatch *DRW_cache_text_edge_wire_get(Object *ob) { BLI_assert(ob->type == OB_FONT); @@ -3063,7 +3035,7 @@ Gwn_Batch *DRW_cache_text_edge_wire_get(Object *ob) return DRW_curve_batch_cache_get_wire_edge(cu, ob->curve_cache); } -Gwn_Batch *DRW_cache_text_surface_get(Object *ob) +GPUBatch *DRW_cache_text_surface_get(Object *ob) { BLI_assert(ob->type == OB_FONT); struct Curve *cu = ob->data; @@ -3073,7 +3045,7 @@ Gwn_Batch *DRW_cache_text_surface_get(Object *ob) return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->curve_cache); } -Gwn_Batch **DRW_cache_text_surface_shaded_get( +GPUBatch **DRW_cache_text_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) { BLI_assert(ob->type == OB_FONT); @@ -3084,14 +3056,14 @@ Gwn_Batch **DRW_cache_text_surface_shaded_get( return DRW_curve_batch_cache_get_surface_shaded(cu, ob->curve_cache, gpumat_array, gpumat_array_len); } -Gwn_Batch *DRW_cache_text_cursor_overlay_get(Object *ob) +GPUBatch *DRW_cache_text_cursor_overlay_get(Object *ob) { BLI_assert(ob->type == OB_FONT); struct Curve *cu = ob->data; return DRW_curve_batch_cache_get_overlay_cursor(cu); } -Gwn_Batch *DRW_cache_text_select_overlay_get(Object *ob) +GPUBatch *DRW_cache_text_select_overlay_get(Object *ob) { BLI_assert(ob->type == OB_FONT); struct Curve *cu = ob->data; @@ -3105,7 +3077,7 @@ Gwn_Batch *DRW_cache_text_select_overlay_get(Object *ob) /** \name Surface * \{ */ -Gwn_Batch *DRW_cache_surf_surface_get(Object *ob) +GPUBatch *DRW_cache_surf_surface_get(Object *ob) { BLI_assert(ob->type == OB_SURF); @@ -3114,7 +3086,7 @@ Gwn_Batch *DRW_cache_surf_surface_get(Object *ob) } /* Return list of batches */ -Gwn_Batch **DRW_cache_surf_surface_shaded_get( +GPUBatch **DRW_cache_surf_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) { BLI_assert(ob->type == OB_SURF); @@ -3130,7 +3102,7 @@ Gwn_Batch **DRW_cache_surf_surface_shaded_get( /** \name Lattice * \{ */ -Gwn_Batch *DRW_cache_lattice_verts_get(Object *ob) +GPUBatch *DRW_cache_lattice_verts_get(Object *ob) { BLI_assert(ob->type == OB_LATTICE); @@ -3138,7 +3110,7 @@ Gwn_Batch *DRW_cache_lattice_verts_get(Object *ob) return DRW_lattice_batch_cache_get_all_verts(lt); } -Gwn_Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight) +GPUBatch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight) { BLI_assert(ob->type == OB_LATTICE); @@ -3152,7 +3124,7 @@ Gwn_Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight) return DRW_lattice_batch_cache_get_all_edges(lt, use_weight, actdef); } -Gwn_Batch *DRW_cache_lattice_vert_overlay_get(Object *ob) +GPUBatch *DRW_cache_lattice_vert_overlay_get(Object *ob) { BLI_assert(ob->type == OB_LATTICE); @@ -3167,17 +3139,17 @@ Gwn_Batch *DRW_cache_lattice_vert_overlay_get(Object *ob) /** \name Particles * \{ */ -Gwn_Batch *DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md) +GPUBatch *DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md) { return DRW_particles_batch_cache_get_hair(object, psys, md); } -Gwn_Batch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys) +GPUBatch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys) { return DRW_particles_batch_cache_get_dots(object, psys); } -Gwn_Batch *DRW_cache_particles_get_edit_strands( +GPUBatch *DRW_cache_particles_get_edit_strands( Object *object, ParticleSystem *psys, struct PTCacheEdit *edit) @@ -3185,7 +3157,7 @@ Gwn_Batch *DRW_cache_particles_get_edit_strands( return DRW_particles_batch_cache_get_edit_strands(object, psys, edit); } -Gwn_Batch *DRW_cache_particles_get_edit_inner_points( +GPUBatch *DRW_cache_particles_get_edit_inner_points( Object *object, ParticleSystem *psys, struct PTCacheEdit *edit) @@ -3193,7 +3165,7 @@ Gwn_Batch *DRW_cache_particles_get_edit_inner_points( return DRW_particles_batch_cache_get_edit_inner_points(object, psys, edit); } -Gwn_Batch *DRW_cache_particles_get_edit_tip_points( +GPUBatch *DRW_cache_particles_get_edit_tip_points( Object *object, ParticleSystem *psys, struct PTCacheEdit *edit) @@ -3201,100 +3173,100 @@ Gwn_Batch *DRW_cache_particles_get_edit_tip_points( return DRW_particles_batch_cache_get_edit_tip_points(object, psys, edit); } -Gwn_Batch *DRW_cache_particles_get_prim(int type) +GPUBatch *DRW_cache_particles_get_prim(int type) { switch (type) { case PART_DRAW_CROSS: if (!SHC.drw_particle_cross) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, axis_id; if (format.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); + pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 6); /* X axis */ float co[3] = {-1.0f, 0.0f, 0.0f}; int axis = -1; - GWN_vertbuf_attr_set(vbo, pos_id, 0, co); - GWN_vertbuf_attr_set(vbo, axis_id, 0, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 0, co); + GPU_vertbuf_attr_set(vbo, axis_id, 0, &axis); co[0] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 1, co); - GWN_vertbuf_attr_set(vbo, axis_id, 1, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 1, co); + GPU_vertbuf_attr_set(vbo, axis_id, 1, &axis); /* Y axis */ co[0] = 0.0f; co[1] = -1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 2, co); - GWN_vertbuf_attr_set(vbo, axis_id, 2, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 2, co); + GPU_vertbuf_attr_set(vbo, axis_id, 2, &axis); co[1] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 3, co); - GWN_vertbuf_attr_set(vbo, axis_id, 3, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 3, co); + GPU_vertbuf_attr_set(vbo, axis_id, 3, &axis); /* Z axis */ co[1] = 0.0f; co[2] = -1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 4, co); - GWN_vertbuf_attr_set(vbo, axis_id, 4, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 4, co); + GPU_vertbuf_attr_set(vbo, axis_id, 4, &axis); co[2] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 5, co); - GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 5, co); + GPU_vertbuf_attr_set(vbo, axis_id, 5, &axis); - SHC.drw_particle_cross = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_particle_cross = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_particle_cross; case PART_DRAW_AXIS: if (!SHC.drw_particle_axis) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, axis_id; if (format.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); + pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 6); /* X axis */ float co[3] = {0.0f, 0.0f, 0.0f}; int axis = 0; - GWN_vertbuf_attr_set(vbo, pos_id, 0, co); - GWN_vertbuf_attr_set(vbo, axis_id, 0, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 0, co); + GPU_vertbuf_attr_set(vbo, axis_id, 0, &axis); co[0] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 1, co); - GWN_vertbuf_attr_set(vbo, axis_id, 1, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 1, co); + GPU_vertbuf_attr_set(vbo, axis_id, 1, &axis); /* Y axis */ co[0] = 0.0f; axis = 1; - GWN_vertbuf_attr_set(vbo, pos_id, 2, co); - GWN_vertbuf_attr_set(vbo, axis_id, 2, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 2, co); + GPU_vertbuf_attr_set(vbo, axis_id, 2, &axis); co[1] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 3, co); - GWN_vertbuf_attr_set(vbo, axis_id, 3, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 3, co); + GPU_vertbuf_attr_set(vbo, axis_id, 3, &axis); /* Z axis */ co[1] = 0.0f; axis = 2; - GWN_vertbuf_attr_set(vbo, pos_id, 4, co); - GWN_vertbuf_attr_set(vbo, axis_id, 4, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 4, co); + GPU_vertbuf_attr_set(vbo, axis_id, 4, &axis); co[2] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 5, co); - GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 5, co); + GPU_vertbuf_attr_set(vbo, axis_id, 5, &axis); - SHC.drw_particle_axis = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_particle_axis = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_particle_axis; @@ -3304,26 +3276,26 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) float v[3] = {0.0f, 0.0f, 0.0f}; int axis = -1; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, axis_id; if (format.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); + pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL); for (int a = 0; a < CIRCLE_RESOL; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, pos_id, a, v); - GWN_vertbuf_attr_set(vbo, axis_id, a, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, a, v); + GPU_vertbuf_attr_set(vbo, axis_id, a, &axis); } - SHC.drw_particle_circle = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_particle_circle = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_particle_circle; @@ -3337,9 +3309,9 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) } /* 3D cursor */ -Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) +GPUBatch *DRW_cache_cursor_get(bool crosshair_lines) { - Gwn_Batch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle; + GPUBatch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle; if (*drw_cursor == NULL) { const float f5 = 0.25f; @@ -3353,18 +3325,18 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) uchar red[3] = {255, 0, 0}; uchar white[3] = {255, 255, 255}; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, color; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.color = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.color = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, GWN_PRIM_LINE_STRIP, index_len, vert_len, true); + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len, true); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_len); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vert_len); int v = 0; for (int i = 0; i < segments; ++i) { @@ -3373,59 +3345,59 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) float y = f10 * sinf(angle); if (i % 2 == 0) - GWN_vertbuf_attr_set(vbo, attr_id.color, v, red); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, red); else - GWN_vertbuf_attr_set(vbo, attr_id.color, v, white); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, white); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){x, y}); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){x, y}); + GPU_indexbuf_add_generic_vert(&elb, v++); } - GWN_indexbuf_add_generic_vert(&elb, 0); + GPU_indexbuf_add_generic_vert(&elb, 0); if (crosshair_lines) { uchar crosshair_color[3]; UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); } - Gwn_IndexBuf *ibo = GWN_indexbuf_build(&elb); + GPUIndexBuf *ibo = GPU_indexbuf_build(&elb); - *drw_cursor = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, ibo, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + *drw_cursor = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, ibo, GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); } return *drw_cursor; } diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 07c8a571256..129c0252f30 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -26,7 +26,7 @@ #ifndef __DRAW_CACHE_H__ #define __DRAW_CACHE_H__ -struct Gwn_Batch; +struct GPUBatch; struct GPUMaterial; struct ModifierData; struct Object; @@ -36,163 +36,162 @@ void DRW_shape_cache_free(void); void DRW_shape_cache_reset(void); /* 3D cursor */ -struct Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines); +struct GPUBatch *DRW_cache_cursor_get(bool crosshair_lines); /* Common Shapes */ -struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void); -struct Gwn_Batch *DRW_cache_fullscreen_quad_texcoord_get(void); -struct Gwn_Batch *DRW_cache_quad_get(void); -struct Gwn_Batch *DRW_cache_cube_get(void); -struct Gwn_Batch *DRW_cache_sphere_get(void); -struct Gwn_Batch *DRW_cache_single_vert_get(void); -struct Gwn_Batch *DRW_cache_single_line_get(void); -struct Gwn_Batch *DRW_cache_single_line_endpoints_get(void); -struct Gwn_Batch *DRW_cache_screenspace_circle_get(void); +struct GPUBatch *DRW_cache_fullscreen_quad_get(void); +struct GPUBatch *DRW_cache_quad_get(void); +struct GPUBatch *DRW_cache_cube_get(void); +struct GPUBatch *DRW_cache_sphere_get(void); +struct GPUBatch *DRW_cache_single_vert_get(void); +struct GPUBatch *DRW_cache_single_line_get(void); +struct GPUBatch *DRW_cache_single_line_endpoints_get(void); +struct GPUBatch *DRW_cache_screenspace_circle_get(void); /* Common Object */ -struct Gwn_Batch *DRW_cache_object_wire_outline_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold); -struct Gwn_Batch *DRW_cache_object_surface_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_object_surface_material_get( +struct GPUBatch *DRW_cache_object_wire_outline_get(struct Object *ob); +struct GPUBatch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold); +struct GPUBatch *DRW_cache_object_surface_get(struct Object *ob); +struct GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob); +struct GPUBatch **DRW_cache_object_surface_material_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); void DRW_cache_object_face_wireframe_get( Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count); /* Empties */ -struct Gwn_Batch *DRW_cache_plain_axes_get(void); -struct Gwn_Batch *DRW_cache_single_arrow_get(void); -struct Gwn_Batch *DRW_cache_empty_cube_get(void); -struct Gwn_Batch *DRW_cache_circle_get(void); -struct Gwn_Batch *DRW_cache_square_get(void); -struct Gwn_Batch *DRW_cache_empty_sphere_get(void); -struct Gwn_Batch *DRW_cache_empty_cylinder_get(void); -struct Gwn_Batch *DRW_cache_empty_cone_get(void); -struct Gwn_Batch *DRW_cache_empty_capsule_cap_get(void); -struct Gwn_Batch *DRW_cache_empty_capsule_body_get(void); -struct Gwn_Batch *DRW_cache_arrows_get(void); -struct Gwn_Batch *DRW_cache_axis_names_get(void); -struct Gwn_Batch *DRW_cache_image_plane_get(void); -struct Gwn_Batch *DRW_cache_image_plane_wire_get(void); +struct GPUBatch *DRW_cache_plain_axes_get(void); +struct GPUBatch *DRW_cache_single_arrow_get(void); +struct GPUBatch *DRW_cache_empty_cube_get(void); +struct GPUBatch *DRW_cache_circle_get(void); +struct GPUBatch *DRW_cache_square_get(void); +struct GPUBatch *DRW_cache_empty_sphere_get(void); +struct GPUBatch *DRW_cache_empty_cylinder_get(void); +struct GPUBatch *DRW_cache_empty_cone_get(void); +struct GPUBatch *DRW_cache_empty_capsule_cap_get(void); +struct GPUBatch *DRW_cache_empty_capsule_body_get(void); +struct GPUBatch *DRW_cache_arrows_get(void); +struct GPUBatch *DRW_cache_axis_names_get(void); +struct GPUBatch *DRW_cache_image_plane_get(void); +struct GPUBatch *DRW_cache_image_plane_wire_get(void); /* Force Field */ -struct Gwn_Batch *DRW_cache_field_wind_get(void); -struct Gwn_Batch *DRW_cache_field_force_get(void); -struct Gwn_Batch *DRW_cache_field_vortex_get(void); -struct Gwn_Batch *DRW_cache_field_tube_limit_get(void); -struct Gwn_Batch *DRW_cache_field_cone_limit_get(void); +struct GPUBatch *DRW_cache_field_wind_get(void); +struct GPUBatch *DRW_cache_field_force_get(void); +struct GPUBatch *DRW_cache_field_vortex_get(void); +struct GPUBatch *DRW_cache_field_tube_limit_get(void); +struct GPUBatch *DRW_cache_field_cone_limit_get(void); /* Lamps */ -struct Gwn_Batch *DRW_cache_lamp_get(void); -struct Gwn_Batch *DRW_cache_lamp_shadows_get(void); -struct Gwn_Batch *DRW_cache_lamp_sunrays_get(void); -struct Gwn_Batch *DRW_cache_lamp_area_square_get(void); -struct Gwn_Batch *DRW_cache_lamp_area_disk_get(void); -struct Gwn_Batch *DRW_cache_lamp_hemi_get(void); -struct Gwn_Batch *DRW_cache_lamp_spot_get(void); -struct Gwn_Batch *DRW_cache_lamp_spot_square_get(void); +struct GPUBatch *DRW_cache_lamp_get(void); +struct GPUBatch *DRW_cache_lamp_shadows_get(void); +struct GPUBatch *DRW_cache_lamp_sunrays_get(void); +struct GPUBatch *DRW_cache_lamp_area_square_get(void); +struct GPUBatch *DRW_cache_lamp_area_disk_get(void); +struct GPUBatch *DRW_cache_lamp_hemi_get(void); +struct GPUBatch *DRW_cache_lamp_spot_get(void); +struct GPUBatch *DRW_cache_lamp_spot_square_get(void); /* Camera */ -struct Gwn_Batch *DRW_cache_camera_get(void); -struct Gwn_Batch *DRW_cache_camera_frame_get(void); -struct Gwn_Batch *DRW_cache_camera_tria_get(void); +struct GPUBatch *DRW_cache_camera_get(void); +struct GPUBatch *DRW_cache_camera_frame_get(void); +struct GPUBatch *DRW_cache_camera_tria_get(void); /* Speaker */ -struct Gwn_Batch *DRW_cache_speaker_get(void); +struct GPUBatch *DRW_cache_speaker_get(void); /* Probe */ -struct Gwn_Batch *DRW_cache_lightprobe_cube_get(void); -struct Gwn_Batch *DRW_cache_lightprobe_grid_get(void); -struct Gwn_Batch *DRW_cache_lightprobe_planar_get(void); +struct GPUBatch *DRW_cache_lightprobe_cube_get(void); +struct GPUBatch *DRW_cache_lightprobe_grid_get(void); +struct GPUBatch *DRW_cache_lightprobe_planar_get(void); /* Bones */ -struct Gwn_Batch *DRW_cache_bone_octahedral_get(void); -struct Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void); -struct Gwn_Batch *DRW_cache_bone_box_get(void); -struct Gwn_Batch *DRW_cache_bone_box_wire_get(void); -struct Gwn_Batch *DRW_cache_bone_envelope_solid_get(void); -struct Gwn_Batch *DRW_cache_bone_envelope_outline_get(void); -struct Gwn_Batch *DRW_cache_bone_envelope_head_wire_outline_get(void); -struct Gwn_Batch *DRW_cache_bone_point_get(void); -struct Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void); -struct Gwn_Batch *DRW_cache_bone_stick_get(void); -struct Gwn_Batch *DRW_cache_bone_arrows_get(void); +struct GPUBatch *DRW_cache_bone_octahedral_get(void); +struct GPUBatch *DRW_cache_bone_octahedral_wire_get(void); +struct GPUBatch *DRW_cache_bone_box_get(void); +struct GPUBatch *DRW_cache_bone_box_wire_get(void); +struct GPUBatch *DRW_cache_bone_envelope_solid_get(void); +struct GPUBatch *DRW_cache_bone_envelope_outline_get(void); +struct GPUBatch *DRW_cache_bone_envelope_head_wire_outline_get(void); +struct GPUBatch *DRW_cache_bone_point_get(void); +struct GPUBatch *DRW_cache_bone_point_wire_outline_get(void); +struct GPUBatch *DRW_cache_bone_stick_get(void); +struct GPUBatch *DRW_cache_bone_arrows_get(void); /* Meshes */ -struct Gwn_Batch *DRW_cache_mesh_surface_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_overlay_get(struct Object *ob); void DRW_cache_mesh_wire_overlay_get( struct Object *ob, - struct Gwn_Batch **r_tris, struct Gwn_Batch **r_ledges, struct Gwn_Batch **r_lverts); + struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts); void DRW_cache_mesh_normals_overlay_get( struct Object *ob, - struct Gwn_Batch **r_tris, struct Gwn_Batch **r_ledges, struct Gwn_Batch **r_lverts); -struct Gwn_Batch *DRW_cache_face_centers_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold); -struct Gwn_Batch *DRW_cache_mesh_surface_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_loose_edges_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_surface_weights_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_edges_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_verts_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel); -struct Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_mesh_surface_shaded_get( + struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts); +struct GPUBatch *DRW_cache_face_centers_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_wire_outline_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold); +struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_verts_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_edges_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_verts_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel); +struct GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob); +struct GPUBatch **DRW_cache_mesh_surface_shaded_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); -struct Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob); +struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob); void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob); /* Curve */ -struct Gwn_Batch *DRW_cache_curve_surface_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_curve_surface_shaded_get( +struct GPUBatch *DRW_cache_curve_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_curve_surface_shaded_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); -struct Gwn_Batch *DRW_cache_curve_surface_verts_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_curve_edge_wire_get(struct Object *ob); +struct GPUBatch *DRW_cache_curve_surface_verts_get(struct Object *ob); +struct GPUBatch *DRW_cache_curve_edge_wire_get(struct Object *ob); /* edit-mode */ -struct Gwn_Batch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size); -struct Gwn_Batch *DRW_cache_curve_edge_overlay_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_curve_vert_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size); +struct GPUBatch *DRW_cache_curve_edge_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob); /* Font */ -struct Gwn_Batch *DRW_cache_text_edge_wire_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_text_surface_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_text_surface_shaded_get( +struct GPUBatch *DRW_cache_text_edge_wire_get(struct Object *ob); +struct GPUBatch *DRW_cache_text_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_text_surface_shaded_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); /* edit-mode */ -struct Gwn_Batch *DRW_cache_text_cursor_overlay_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_text_select_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_text_cursor_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_text_select_overlay_get(struct Object *ob); /* Surface */ -struct Gwn_Batch *DRW_cache_surf_surface_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_surf_surface_shaded_get( +struct GPUBatch *DRW_cache_surf_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_surf_surface_shaded_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); /* Lattice */ -struct Gwn_Batch *DRW_cache_lattice_verts_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_lattice_wire_get(struct Object *ob, bool use_weight); -struct Gwn_Batch *DRW_cache_lattice_vert_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_lattice_verts_get(struct Object *ob); +struct GPUBatch *DRW_cache_lattice_wire_get(struct Object *ob, bool use_weight); +struct GPUBatch *DRW_cache_lattice_vert_overlay_get(struct Object *ob); /* Particles */ -struct Gwn_Batch *DRW_cache_particles_get_hair( +struct GPUBatch *DRW_cache_particles_get_hair( struct Object *object, struct ParticleSystem *psys, struct ModifierData *md); -struct Gwn_Batch *DRW_cache_particles_get_dots( +struct GPUBatch *DRW_cache_particles_get_dots( struct Object *object, struct ParticleSystem *psys); -struct Gwn_Batch *DRW_cache_particles_get_edit_strands( +struct GPUBatch *DRW_cache_particles_get_edit_strands( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_cache_particles_get_edit_inner_points( +struct GPUBatch *DRW_cache_particles_get_edit_inner_points( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_cache_particles_get_edit_tip_points( +struct GPUBatch *DRW_cache_particles_get_edit_tip_points( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_cache_particles_get_prim(int type); +struct GPUBatch *DRW_cache_particles_get_prim(int type); /* Metaball */ -struct Gwn_Batch *DRW_cache_mball_surface_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); +struct GPUBatch *DRW_cache_mball_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); #endif /* __DRAW_CACHE_H__ */ diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 5773daf8e96..eeb7b1c41ee 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -29,9 +29,9 @@ struct CurveCache; struct GPUMaterial; struct GPUTexture; -struct Gwn_Batch; -struct Gwn_IndexBuf; -struct Gwn_VertBuf; +struct GPUBatch; +struct GPUIndexBuf; +struct GPUVertBuf; struct ListBase; struct ModifierData; struct ParticleSystem; @@ -59,71 +59,71 @@ void DRW_particle_batch_cache_dirty(struct ParticleSystem *psys, int mode); void DRW_particle_batch_cache_free(struct ParticleSystem *psys); /* Curve */ -struct Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu, struct CurveCache *ob_curve_cache); -struct Gwn_Batch *DRW_curve_batch_cache_get_normal_edge( +struct GPUBatch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu, struct CurveCache *ob_curve_cache); +struct GPUBatch *DRW_curve_batch_cache_get_normal_edge( struct Curve *cu, struct CurveCache *ob_curve_cache, float normal_size); -struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(struct Curve *cu); -struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(struct Curve *cu); +struct GPUBatch *DRW_curve_batch_cache_get_overlay_edges(struct Curve *cu); +struct GPUBatch *DRW_curve_batch_cache_get_overlay_verts(struct Curve *cu); -struct Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals( +struct GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals( struct Curve *cu, struct CurveCache *ob_curve_cache); -struct Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( +struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded( struct Curve *cu, struct CurveCache *ob_curve_cache, struct GPUMaterial **gpumat_array, uint gpumat_array_len); /* Metaball */ -struct Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob); -struct Gwn_Batch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len); +struct GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob); +struct GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len); /* Curve (Font) */ -struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu); -struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu); +struct GPUBatch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu); +struct GPUBatch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu); /* DispList */ -struct Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(struct ListBase *lb); -struct Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(struct ListBase *lb); -struct Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material( +struct GPUVertBuf *DRW_displist_vertbuf_calc_pos_with_normals(struct ListBase *lb); +struct GPUIndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(struct ListBase *lb); +struct GPUIndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material( struct ListBase *lb, uint gpumat_array_len); -struct Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material( +struct GPUBatch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material( struct ListBase *lb, uint gpumat_array_len); /* Lattice */ -struct Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef); -struct Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt); -struct Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt); +struct GPUBatch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef); +struct GPUBatch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt); +struct GPUBatch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt); /* Mesh */ -struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( +struct GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); -struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel); -struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide); -struct Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me); +struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel); +struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide); +struct GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me); /* edit-mesh selection (use generic function for faces) */ -struct Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset); -struct Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset); -struct Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset); +struct GPUBatch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset); +struct GPUBatch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset); +struct GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset); /* Object mode Wireframe overlays */ void DRW_mesh_batch_cache_get_wireframes_face_texbuf( struct Mesh *me, struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count); @@ -131,15 +131,15 @@ void DRW_mesh_batch_cache_get_wireframes_face_texbuf( void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me); /* Particles */ -struct Gwn_Batch *DRW_particles_batch_cache_get_hair( +struct GPUBatch *DRW_particles_batch_cache_get_hair( struct Object *object, struct ParticleSystem *psys, struct ModifierData *md); -struct Gwn_Batch *DRW_particles_batch_cache_get_dots( +struct GPUBatch *DRW_particles_batch_cache_get_dots( struct Object *object, struct ParticleSystem *psys); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_strands( +struct GPUBatch *DRW_particles_batch_cache_get_edit_strands( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points( +struct GPUBatch *DRW_particles_batch_cache_get_edit_inner_points( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points( +struct GPUBatch *DRW_particles_batch_cache_get_edit_tip_points( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); #endif /* __DRAW_CACHE_IMPL_H__ */ diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 4de1dfd24f5..cfaa3c6914f 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -298,43 +298,43 @@ enum { }; /* ---------------------------------------------------------------------- */ -/* Curve Gwn_Batch Cache */ +/* Curve GPUBatch Cache */ typedef struct CurveBatchCache { /* center-line */ struct { - Gwn_VertBuf *verts; - Gwn_VertBuf *edges; - Gwn_Batch *batch; - Gwn_IndexBuf *elem; + GPUVertBuf *verts; + GPUVertBuf *edges; + GPUBatch *batch; + GPUIndexBuf *elem; } wire; /* normals */ struct { - Gwn_VertBuf *verts; - Gwn_VertBuf *edges; - Gwn_Batch *batch; - Gwn_IndexBuf *elem; + GPUVertBuf *verts; + GPUVertBuf *edges; + GPUBatch *batch; + GPUIndexBuf *elem; } normal; /* control handles and vertices */ struct { - Gwn_Batch *edges; - Gwn_Batch *verts; + GPUBatch *edges; + GPUBatch *verts; } overlay; struct { - Gwn_VertBuf *verts; - Gwn_IndexBuf *triangles_in_order; - Gwn_Batch **shaded_triangles; - Gwn_Batch *batch; + GPUVertBuf *verts; + GPUIndexBuf *triangles_in_order; + GPUBatch **shaded_triangles; + GPUBatch *batch; int mat_len; } surface; /* 3d text */ struct { - Gwn_Batch *select; - Gwn_Batch *cursor; + GPUBatch *select; + GPUBatch *cursor; } text; /* settings to determine if cache is invalid */ @@ -348,7 +348,7 @@ typedef struct CurveBatchCache { bool is_editmode; } CurveBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ static bool curve_batch_cache_valid(Curve *cu) { @@ -434,12 +434,12 @@ void DRW_curve_batch_cache_dirty(Curve *cu, int mode) break; case BKE_CURVE_BATCH_DIRTY_SELECT: /* editnurb */ - GWN_BATCH_DISCARD_SAFE(cache->overlay.verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay.edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay.verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay.edges); /* editfont */ - GWN_BATCH_DISCARD_SAFE(cache->text.select); - GWN_BATCH_DISCARD_SAFE(cache->text.cursor); + GPU_BATCH_DISCARD_SAFE(cache->text.select); + GPU_BATCH_DISCARD_SAFE(cache->text.cursor); break; default: BLI_assert(0); @@ -453,34 +453,34 @@ static void curve_batch_cache_clear(Curve *cu) return; } - GWN_BATCH_DISCARD_SAFE(cache->overlay.verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay.edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay.verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay.edges); - GWN_VERTBUF_DISCARD_SAFE(cache->surface.verts); - GWN_INDEXBUF_DISCARD_SAFE(cache->surface.triangles_in_order); + GPU_VERTBUF_DISCARD_SAFE(cache->surface.verts); + GPU_INDEXBUF_DISCARD_SAFE(cache->surface.triangles_in_order); if (cache->surface.shaded_triangles) { for (int i = 0; i < cache->surface.mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); } } MEM_SAFE_FREE(cache->surface.shaded_triangles); - GWN_BATCH_DISCARD_SAFE(cache->surface.batch); + GPU_BATCH_DISCARD_SAFE(cache->surface.batch); /* don't own vbo & elems */ - GWN_BATCH_DISCARD_SAFE(cache->wire.batch); - GWN_VERTBUF_DISCARD_SAFE(cache->wire.verts); - GWN_VERTBUF_DISCARD_SAFE(cache->wire.edges); - GWN_INDEXBUF_DISCARD_SAFE(cache->wire.elem); + GPU_BATCH_DISCARD_SAFE(cache->wire.batch); + GPU_VERTBUF_DISCARD_SAFE(cache->wire.verts); + GPU_VERTBUF_DISCARD_SAFE(cache->wire.edges); + GPU_INDEXBUF_DISCARD_SAFE(cache->wire.elem); /* don't own vbo & elems */ - GWN_BATCH_DISCARD_SAFE(cache->normal.batch); - GWN_VERTBUF_DISCARD_SAFE(cache->normal.verts); - GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges); - GWN_INDEXBUF_DISCARD_SAFE(cache->normal.elem); + GPU_BATCH_DISCARD_SAFE(cache->normal.batch); + GPU_VERTBUF_DISCARD_SAFE(cache->normal.verts); + GPU_VERTBUF_DISCARD_SAFE(cache->normal.edges); + GPU_INDEXBUF_DISCARD_SAFE(cache->normal.elem); /* 3d text */ - GWN_BATCH_DISCARD_SAFE(cache->text.cursor); - GWN_BATCH_DISCARD_SAFE(cache->text.select); + GPU_BATCH_DISCARD_SAFE(cache->text.cursor); + GPU_BATCH_DISCARD_SAFE(cache->text.select); } void DRW_curve_batch_cache_free(Curve *cu) @@ -494,30 +494,30 @@ void DRW_curve_batch_cache_free(Curve *cu) /** \name Private Curve Cache API * \{ */ -/* Gwn_Batch cache usage. */ -static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, CurveBatchCache *cache) +/* GPUBatch cache usage. */ +static GPUVertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_WIRE); BLI_assert(rdata->ob_curve_cache != NULL); if (cache->wire.verts == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } const int vert_len = curve_render_data_wire_verts_len_get(rdata); - Gwn_VertBuf *vbo = cache->wire.verts = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_len); + GPUVertBuf *vbo = cache->wire.verts = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vert_len); int vbo_len_used = 0; for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) { if (bl->nr > 0) { const int i_end = vbo_len_used + bl->nr; for (const BevPoint *bevp = bl->bevpoints; vbo_len_used < i_end; vbo_len_used++, bevp++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bevp->vec); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bevp->vec); } } } @@ -527,7 +527,7 @@ static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, Cur return cache->wire.verts; } -static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUIndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_WIRE); BLI_assert(rdata->ob_curve_cache != NULL); @@ -537,8 +537,8 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu const int edge_len = curve_render_data_wire_edges_len_get(rdata); int edge_len_used = 0; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); int i = 0; for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) { @@ -554,7 +554,7 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu i += 1; } for (; i < i_end; i_prev = i++) { - GWN_indexbuf_add_line_verts(&elb, i_prev, i); + GPU_indexbuf_add_line_verts(&elb, i_prev, i); edge_len_used += 1; } } @@ -567,30 +567,30 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu BLI_assert(edge_len_used == edge_len); } - cache->wire.elem = GWN_indexbuf_build(&elb); + cache->wire.elem = GPU_indexbuf_build(&elb); } return cache->wire.elem; } -static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUVertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_NORMAL); BLI_assert(rdata->ob_curve_cache != NULL); if (cache->normal.verts == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } const int normal_len = curve_render_data_normal_len_get(rdata); const int vert_len = normal_len * 3; - Gwn_VertBuf *vbo = cache->normal.verts = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_len); + GPUVertBuf *vbo = cache->normal.verts = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vert_len); int vbo_len_used = 0; const BevList *bl; @@ -622,9 +622,9 @@ static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, C add_v3_v3(vec_a, bevp->vec); add_v3_v3(vec_b, bevp->vec); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_a); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, bevp->vec); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_b); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_a); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, bevp->vec); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_b); bevp += skip + 1; nr -= skip; @@ -636,7 +636,7 @@ static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, C return cache->normal.verts; } -static Gwn_IndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUIndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_NORMAL); BLI_assert(rdata->ob_curve_cache != NULL); @@ -646,19 +646,19 @@ static Gwn_IndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, const int vert_len = normal_len * 3; const int edge_len = normal_len * 2; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); int vbo_len_used = 0; for (int i = 0; i < normal_len; i++) { - GWN_indexbuf_add_line_verts(&elb, vbo_len_used + 0, vbo_len_used + 1); - GWN_indexbuf_add_line_verts(&elb, vbo_len_used + 1, vbo_len_used + 2); + GPU_indexbuf_add_line_verts(&elb, vbo_len_used + 0, vbo_len_used + 1); + GPU_indexbuf_add_line_verts(&elb, vbo_len_used + 1, vbo_len_used + 2); vbo_len_used += 3; } BLI_assert(vbo_len_used == vert_len); - cache->normal.elem = GWN_indexbuf_build(&elb); + cache->normal.elem = GPU_indexbuf_build(&elb); } return cache->normal.elem; @@ -673,18 +673,18 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) CurveRenderData *rdata = curve_render_data_create(cu, NULL, options); if (cache->overlay.verts == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = curve_render_data_overlay_verts_len_get(rdata); int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); int i = 0; for (Nurb *nu = rdata->nurbs->first; nu; nu = nu->next) { if (nu->bezt) { @@ -697,16 +697,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) if (rdata->hide_handles) { vflag = (bezt->f2 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); vbo_len_used += 1; } else { for (int j = 0; j < 3; j++) { vflag = ((&bezt->f1)[j] & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); vbo_len_used += 1; } } @@ -721,8 +721,8 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) const bool is_active = (i == rdata->actvert); char vflag; vflag = (bp->f1 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp->vec); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp->vec); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); vbo_len_used += 1; } i += 1; @@ -731,29 +731,29 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) i += nu->pntsu; } if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } - cache->overlay.verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->overlay.verts = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); } if ((cache->overlay.edges == NULL) && (rdata->hide_handles == false)) { /* Note: we could reference indices to vertices (above) */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int edge_len = curve_render_data_overlay_edges_len_get(rdata); const int vbo_len_capacity = edge_len * 2; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); int i = 0; for (Nurb *nu = rdata->nurbs->first; nu; nu = nu->next, i++) { const bool is_active_nurb = (i == cu->actnu); @@ -766,7 +766,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) for (int j = 0; j < 2; j += 1) { /* same vertex twice, only check different selection */ - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]); vbo_len_used += 1; col_id = (&bezt->h1)[j]; @@ -777,8 +777,8 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) col_id |= ACTIVE_NURB; } - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j * 2]); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j * 2]); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id); vbo_len_used += 1; } } @@ -794,11 +794,11 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) col_id |= ACTIVE_NURB; } - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_prev->vec); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_prev->vec); vbo_len_used += 1; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_curr->vec); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_curr->vec); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id); vbo_len_used += 1; } @@ -806,16 +806,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) } } if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } - cache->overlay.edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->overlay.edges = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } curve_render_data_free(rdata); } -static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUBatch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_SURFACE); if (cache->surface.batch == NULL) { @@ -827,8 +827,8 @@ static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, if (cache->surface.triangles_in_order == NULL) { cache->surface.triangles_in_order = DRW_displist_indexbuf_calc_triangles_in_order(lb); } - cache->surface.batch = GWN_batch_create( - GWN_PRIM_TRIS, cache->surface.verts, cache->surface.triangles_in_order); + cache->surface.batch = GPU_batch_create( + GPU_PRIM_TRIS, cache->surface.verts, cache->surface.triangles_in_order); } return cache->surface.batch; @@ -843,21 +843,21 @@ static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, * \{ */ -static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUBatch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT); if (cache->text.select == NULL) { EditFont *ef = rdata->text.edit_font; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = ef->selboxes_len * 6; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); float box[4][3]; @@ -904,37 +904,37 @@ static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, C add_v2_v2(box[3], &sb->x); } - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]); } BLI_assert(vbo_len_used == vbo_len_capacity); - cache->text.select = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->text.select = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return cache->text.select; } -static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUBatch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT); if (cache->text.cursor == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = 4; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); for (int i = 0; i < 4; i++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]); } - cache->text.cursor = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->text.cursor = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); } return cache->text.cursor; } @@ -946,7 +946,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, C /** \name Public Object/Curve API * \{ */ -Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache) +GPUBatch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -954,8 +954,8 @@ Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_c /* create batch from Curve */ CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_WIRE); - cache->wire.batch = GWN_batch_create( - GWN_PRIM_LINES, + cache->wire.batch = GPU_batch_create( + GPU_PRIM_LINES, curve_batch_cache_get_wire_verts(rdata, cache), curve_batch_cache_get_wire_edges(rdata, cache)); @@ -964,15 +964,15 @@ Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_c return cache->wire.batch; } -Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cache, float normal_size) +GPUBatch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cache, float normal_size) { CurveBatchCache *cache = curve_batch_cache_get(cu); if (cache->normal.batch != NULL) { cache->normal_size = normal_size; if (cache->normal_size != normal_size) { - GWN_BATCH_DISCARD_SAFE(cache->normal.batch); - GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges); + GPU_BATCH_DISCARD_SAFE(cache->normal.batch); + GPU_VERTBUF_DISCARD_SAFE(cache->normal.edges); } } cache->normal_size = normal_size; @@ -981,8 +981,8 @@ Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve /* create batch from Curve */ CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_NORMAL); - cache->normal.batch = GWN_batch_create( - GWN_PRIM_LINES, + cache->normal.batch = GPU_batch_create( + GPU_PRIM_LINES, curve_batch_cache_get_normal_verts(rdata, cache), curve_batch_cache_get_normal_edges(rdata, cache)); @@ -992,7 +992,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve return cache->normal.batch; } -Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu) +GPUBatch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -1003,7 +1003,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu) return cache->overlay.edges; } -Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu) +GPUBatch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -1014,7 +1014,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu) return cache->overlay.verts; } -Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals( +GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals( struct Curve *cu, struct CurveCache *ob_curve_cache) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -1030,7 +1030,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals( return cache->surface.batch; } -Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( +GPUBatch **DRW_curve_batch_cache_get_surface_shaded( struct Curve *cu, struct CurveCache *ob_curve_cache, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len) { @@ -1040,7 +1040,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( /* TODO: deduplicate code */ if (cache->surface.shaded_triangles) { for (int i = 0; i < cache->surface.mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); } } MEM_SAFE_FREE(cache->surface.shaded_triangles); @@ -1058,7 +1058,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( else { cache->surface.shaded_triangles = MEM_mallocN( sizeof(*cache->surface.shaded_triangles) * gpumat_array_len, __func__); - Gwn_IndexBuf **el = DRW_displist_indexbuf_calc_triangles_in_order_split_by_material( + GPUIndexBuf **el = DRW_displist_indexbuf_calc_triangles_in_order_split_by_material( lb, gpumat_array_len); if (cache->surface.verts == NULL) { @@ -1066,8 +1066,8 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( } for (int i = 0; i < gpumat_array_len; ++i) { - cache->surface.shaded_triangles[i] = GWN_batch_create_ex( - GWN_PRIM_TRIS, cache->surface.verts, el[i], GWN_BATCH_OWNS_INDEX); + cache->surface.shaded_triangles[i] = GPU_batch_create_ex( + GPU_PRIM_TRIS, cache->surface.verts, el[i], GPU_BATCH_OWNS_INDEX); } MEM_freeN(el); /* Save `el` in cache? */ @@ -1085,7 +1085,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( /** \name Public Object/Font API * \{ */ -Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu) +GPUBatch *DRW_curve_batch_cache_get_overlay_select(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -1100,7 +1100,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu) return cache->text.select; } -Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(Curve *cu) +GPUBatch *DRW_curve_batch_cache_get_overlay_cursor(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index 8d187af0501..5ea0f6fb05d 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -87,49 +87,49 @@ static int curve_render_surface_tri_len_get(const ListBase *lb) return tri_len; } -static void displist_indexbufbuilder_set(Gwn_IndexBufBuilder *elb, const DispList *dl, const int ofs) +static void displist_indexbufbuilder_set(GPUIndexBufBuilder *elb, const DispList *dl, const int ofs) { if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { const int *idx = dl->index; if (dl->type == DL_INDEX3) { const int i_end = dl->parts; for (int i = 0; i < i_end; i++, idx += 3) { - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs); } } else if (dl->type == DL_SURF) { const int i_end = dl->totindex; for (int i = 0; i < i_end; i++, idx += 4) { - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs); - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[3] + ofs, idx[2] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[3] + ofs, idx[2] + ofs); } } else { BLI_assert(dl->type == DL_INDEX4); const int i_end = dl->parts; for (int i = 0; i < i_end; i++, idx += 4) { - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); if (idx[2] != idx[3]) { - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs); } } } } } -Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) +GPUVertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, curve_render_surface_vert_len_get(lb)); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, curve_render_surface_vert_len_get(lb)); BKE_displist_normals_add(lb); @@ -141,9 +141,9 @@ Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) const float *fp_no = dl->nors; const int vbo_end = vbo_len_used + dl_vert_len(dl); while (vbo_len_used < vbo_end) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co); if (fp_no) { - GWN_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, fp_no); + GPU_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, fp_no); if (ndata_is_single == false) { fp_no += 3; } @@ -157,13 +157,13 @@ Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) return vbo; } -Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb) +GPUIndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb) { const int tri_len = curve_render_surface_tri_len_get(lb); const int vert_len = curve_render_surface_vert_len_get(lb); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); int ofs = 0; for (const DispList *dl = lb->first; dl; dl = dl->next) { @@ -171,14 +171,14 @@ Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb) ofs += dl_vert_len(dl); } - return GWN_indexbuf_build(&elb); + return GPU_indexbuf_build(&elb); } -Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(ListBase *lb, uint gpumat_array_len) +GPUIndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(ListBase *lb, uint gpumat_array_len) { - Gwn_IndexBuf **shaded_triangles_in_order = MEM_callocN( + GPUIndexBuf **shaded_triangles_in_order = MEM_callocN( sizeof(*shaded_triangles_in_order) * gpumat_array_len, __func__); - Gwn_IndexBufBuilder *elb = BLI_array_alloca(elb, gpumat_array_len); + GPUIndexBufBuilder *elb = BLI_array_alloca(elb, gpumat_array_len); const int tri_len = curve_render_surface_tri_len_get(lb); const int vert_len = curve_render_surface_vert_len_get(lb); @@ -186,7 +186,7 @@ Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(L /* Init each index buffer builder */ for (i = 0; i < gpumat_array_len; i++) { - GWN_indexbuf_init(&elb[i], GWN_PRIM_TRIS, tri_len, vert_len); + GPU_indexbuf_init(&elb[i], GPU_PRIM_TRIS, tri_len, vert_len); } /* calc each index buffer builder */ @@ -198,56 +198,56 @@ Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(L /* build each indexbuf */ for (i = 0; i < gpumat_array_len; i++) { - shaded_triangles_in_order[i] = GWN_indexbuf_build(&elb[i]); + shaded_triangles_in_order[i] = GPU_indexbuf_build(&elb[i]); } return shaded_triangles_in_order; } static void displist_vertbuf_attr_set_tri_pos_normals_and_uv( - Gwn_VertBufRaw *pos_step, Gwn_VertBufRaw *nor_step, Gwn_VertBufRaw *uv_step, + GPUVertBufRaw *pos_step, GPUVertBufRaw *nor_step, GPUVertBufRaw *uv_step, const float v1[3], const float v2[3], const float v3[3], const float n1[3], const float n2[3], const float n3[3], const float uv1[2], const float uv2[2], const float uv3[2]) { - copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v1); - copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n1); - copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv1); + copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v1); + copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n1); + copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv1); - copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v2); - copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n2); - copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv2); + copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v2); + copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n2); + copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv2); - copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v3); - copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n3); - copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv3); + copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v3); + copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n3); + copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv3); } -Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(ListBase *lb, uint gpumat_array_len) +GPUBatch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(ListBase *lb, uint gpumat_array_len) { - static Gwn_VertFormat shaded_triangles_format = { 0 }; + static GPUVertFormat shaded_triangles_format = { 0 }; static struct { uint pos, nor, uv; } attr_id; if (shaded_triangles_format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&shaded_triangles_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&shaded_triangles_format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.uv = GWN_vertformat_attr_add(&shaded_triangles_format, "u", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&shaded_triangles_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&shaded_triangles_format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.uv = GPU_vertformat_attr_add(&shaded_triangles_format, "u", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_Batch **shaded_triangles = MEM_mallocN(sizeof(*shaded_triangles) * gpumat_array_len, __func__); + GPUBatch **shaded_triangles = MEM_mallocN(sizeof(*shaded_triangles) * gpumat_array_len, __func__); - Gwn_VertBuf **vbo = BLI_array_alloca(vbo, gpumat_array_len); + GPUVertBuf **vbo = BLI_array_alloca(vbo, gpumat_array_len); uint *vbo_len_capacity = BLI_array_alloca(vbo_len_capacity, gpumat_array_len); - Gwn_VertBufRaw *pos_step, *nor_step, *uv_step; + GPUVertBufRaw *pos_step, *nor_step, *uv_step; pos_step = BLI_array_alloca(pos_step, gpumat_array_len); nor_step = BLI_array_alloca(nor_step, gpumat_array_len); uv_step = BLI_array_alloca(uv_step, gpumat_array_len); /* Create each vertex buffer */ for (int i = 0; i < gpumat_array_len; i++) { - vbo[i] = GWN_vertbuf_create_with_format(&shaded_triangles_format); + vbo[i] = GPU_vertbuf_create_with_format(&shaded_triangles_format); vbo_len_capacity[i] = 0; } @@ -258,10 +258,10 @@ Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(Lis /* Alloc each vertex buffer and get each raw data */ for (int i = 0; i < gpumat_array_len; i++) { - GWN_vertbuf_data_alloc(vbo[i], vbo_len_capacity[i]); - GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.pos, &pos_step[i]); - GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.nor, &nor_step[i]); - GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.uv, &uv_step[i]); + GPU_vertbuf_data_alloc(vbo[i], vbo_len_capacity[i]); + GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.pos, &pos_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.nor, &nor_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.uv, &uv_step[i]); } BKE_displist_normals_add(lb); @@ -388,11 +388,11 @@ Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(Lis } for (int i = 0; i < gpumat_array_len; i++) { - uint vbo_len_used = GWN_vertbuf_raw_used(&pos_step[i]); + uint vbo_len_used = GPU_vertbuf_raw_used(&pos_step[i]); if (vbo_len_capacity[i] != vbo_len_used) { - GWN_vertbuf_data_resize(vbo[i], vbo_len_used); + GPU_vertbuf_data_resize(vbo[i], vbo_len_used); } - shaded_triangles[i] = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo[i], NULL, GWN_BATCH_OWNS_VBO); + shaded_triangles[i] = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo[i], NULL, GPU_BATCH_OWNS_VBO); } return shaded_triangles; diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 99dce2d7343..d6acc4112d6 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -279,16 +279,16 @@ enum { }; /* ---------------------------------------------------------------------- */ -/* Lattice Gwn_Batch Cache */ +/* Lattice GPUBatch Cache */ typedef struct LatticeBatchCache { - Gwn_VertBuf *pos; - Gwn_IndexBuf *edges; + GPUVertBuf *pos; + GPUIndexBuf *edges; - Gwn_Batch *all_verts; - Gwn_Batch *all_edges; + GPUBatch *all_verts; + GPUBatch *all_edges; - Gwn_Batch *overlay_verts; + GPUBatch *overlay_verts; /* settings to determine if cache is invalid */ bool is_dirty; @@ -301,7 +301,7 @@ typedef struct LatticeBatchCache { bool is_editmode; } LatticeBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ static bool lattice_batch_cache_valid(Lattice *lt) { @@ -373,7 +373,7 @@ void DRW_lattice_batch_cache_dirty(Lattice *lt, int mode) break; case BKE_LATTICE_BATCH_DIRTY_SELECT: /* TODO Separate Flag vbo */ - GWN_BATCH_DISCARD_SAFE(cache->overlay_verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay_verts); break; default: BLI_assert(0); @@ -387,12 +387,12 @@ static void lattice_batch_cache_clear(Lattice *lt) return; } - GWN_BATCH_DISCARD_SAFE(cache->all_verts); - GWN_BATCH_DISCARD_SAFE(cache->all_edges); - GWN_BATCH_DISCARD_SAFE(cache->overlay_verts); + GPU_BATCH_DISCARD_SAFE(cache->all_verts); + GPU_BATCH_DISCARD_SAFE(cache->all_edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay_verts); - GWN_VERTBUF_DISCARD_SAFE(cache->pos); - GWN_INDEXBUF_DISCARD_SAFE(cache->edges); + GPU_VERTBUF_DISCARD_SAFE(cache->pos); + GPU_INDEXBUF_DISCARD_SAFE(cache->edges); } void DRW_lattice_batch_cache_free(Lattice *lt) @@ -401,38 +401,38 @@ void DRW_lattice_batch_cache_free(Lattice *lt) MEM_SAFE_FREE(lt->batch_cache); } -/* Gwn_Batch cache usage. */ -static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache, +/* GPUBatch cache usage. */ +static GPUVertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache, bool use_weight, const int actdef) { BLI_assert(rdata->types & LR_DATATYPE_VERT); if (cache->pos == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, col; } attr_id; - GWN_vertformat_clear(&format); + GPU_vertformat_clear(&format); /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); if (use_weight) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); } const int vert_len = lattice_render_data_verts_len_get(rdata); - cache->pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->pos, vert_len); + cache->pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->pos, vert_len); for (int i = 0; i < vert_len; ++i) { const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i); - GWN_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec); + GPU_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec); if (use_weight) { float w_col[4]; lattice_render_data_weight_col_get(rdata, i, actdef, w_col); - GWN_vertbuf_attr_set(cache->pos, attr_id.col, i, w_col); + GPU_vertbuf_attr_set(cache->pos, attr_id.col, i, w_col); } } } @@ -440,7 +440,7 @@ static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, Lattic return cache->pos; } -static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, LatticeBatchCache *cache) +static GPUIndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, LatticeBatchCache *cache) { BLI_assert(rdata->types & (LR_DATATYPE_VERT | LR_DATATYPE_EDGE)); @@ -449,8 +449,8 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat const int edge_len = lattice_render_data_edges_len_get(rdata); int edge_len_real = 0; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); #define LATT_INDEX(u, v, w) \ ((((w) * rdata->dims.v_len + (v)) * rdata->dims.u_len) + (u)) @@ -463,17 +463,17 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat int uxt = (u == 0 || u == rdata->dims.u_len - 1); if (w && ((uxt || vxt) || !rdata->show_only_outside)) { - GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w)); + GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w)); BLI_assert(edge_len_real <= edge_len); edge_len_real++; } if (v && ((uxt || wxt) || !rdata->show_only_outside)) { - GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v - 1, w), LATT_INDEX(u, v, w)); + GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v - 1, w), LATT_INDEX(u, v, w)); BLI_assert(edge_len_real <= edge_len); edge_len_real++; } if (u && ((vxt || wxt) || !rdata->show_only_outside)) { - GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u - 1, v, w), LATT_INDEX(u, v, w)); + GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u - 1, v, w), LATT_INDEX(u, v, w)); BLI_assert(edge_len_real <= edge_len); edge_len_real++; } @@ -490,7 +490,7 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat BLI_assert(edge_len_real == edge_len); } - cache->edges = GWN_indexbuf_build(&elb); + cache->edges = GPU_indexbuf_build(&elb); } return cache->edges; @@ -505,18 +505,18 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt) LatticeRenderData *rdata = lattice_render_data_create(lt, options); if (cache->overlay_verts == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT); } const int vert_len = lattice_render_data_verts_len_get(rdata); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_len); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vert_len); for (int i = 0; i < vert_len; ++i) { const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i); @@ -530,17 +530,17 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt) } } - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, bp->vec); - GWN_vertbuf_attr_set(vbo, attr_id.data, i, &vflag); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, bp->vec); + GPU_vertbuf_attr_set(vbo, attr_id.data, i, &vflag); } - cache->overlay_verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->overlay_verts = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); } lattice_render_data_free(rdata); } -Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, const int actdef) +GPUBatch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, const int actdef) { LatticeBatchCache *cache = lattice_batch_cache_get(lt); @@ -548,7 +548,7 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, c /* create batch from Lattice */ LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT | LR_DATATYPE_EDGE); - cache->all_edges = GWN_batch_create(GWN_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache, use_weight, actdef), + cache->all_edges = GPU_batch_create(GPU_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache, use_weight, actdef), lattice_batch_cache_get_edges(rdata, cache)); lattice_render_data_free(rdata); @@ -557,14 +557,14 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, c return cache->all_edges; } -Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt) +GPUBatch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt) { LatticeBatchCache *cache = lattice_batch_cache_get(lt); if (cache->all_verts == NULL) { LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT); - cache->all_verts = GWN_batch_create(GWN_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache, false, -1), NULL); + cache->all_verts = GPU_batch_create(GPU_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache, false, -1), NULL); lattice_render_data_free(rdata); } @@ -572,7 +572,7 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt) return cache->all_verts; } -Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(Lattice *lt) +GPUBatch *DRW_lattice_batch_cache_get_overlay_verts(Lattice *lt) { LatticeBatchCache *cache = lattice_batch_cache_get(lt); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 7a72622cb9e..5ca1c65054c 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -202,8 +202,8 @@ typedef struct MeshRenderData { float (*poly_normals)[3]; float (*vert_weight_color)[3]; char (*vert_color)[3]; - Gwn_PackedNormal *poly_normals_pack; - Gwn_PackedNormal *vert_normals_pack; + GPUPackedNormal *poly_normals_pack; + GPUPackedNormal *vert_normals_pack; bool *edge_select_bool; } MeshRenderData; @@ -952,7 +952,7 @@ static int mesh_render_data_polys_len_get(const MeshRenderData *rdata) /** Ensure #MeshRenderData.poly_normals_pack */ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata) { - Gwn_PackedNormal *pnors_pack = rdata->poly_normals_pack; + GPUPackedNormal *pnors_pack = rdata->poly_normals_pack; if (pnors_pack == NULL) { if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; @@ -962,7 +962,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata) pnors_pack = rdata->poly_normals_pack = MEM_mallocN(sizeof(*pnors_pack) * rdata->poly_len, __func__); BM_ITER_MESH_INDEX(efa, &fiter, bm, BM_FACES_OF_MESH, i) { - pnors_pack[i] = GWN_normal_convert_i10_v3(efa->no); + pnors_pack[i] = GPU_normal_convert_i10_v3(efa->no); } } else { @@ -977,7 +977,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata) pnors_pack = rdata->poly_normals_pack = MEM_mallocN(sizeof(*pnors_pack) * rdata->poly_len, __func__); for (int i = 0; i < rdata->poly_len; i++) { - pnors_pack[i] = GWN_normal_convert_i10_v3(pnors[i]); + pnors_pack[i] = GPU_normal_convert_i10_v3(pnors[i]); } } } @@ -986,7 +986,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata) /** Ensure #MeshRenderData.vert_normals_pack */ static void mesh_render_data_ensure_vert_normals_pack(MeshRenderData *rdata) { - Gwn_PackedNormal *vnors_pack = rdata->vert_normals_pack; + GPUPackedNormal *vnors_pack = rdata->vert_normals_pack; if (vnors_pack == NULL) { if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; @@ -996,7 +996,7 @@ static void mesh_render_data_ensure_vert_normals_pack(MeshRenderData *rdata) vnors_pack = rdata->vert_normals_pack = MEM_mallocN(sizeof(*vnors_pack) * rdata->vert_len, __func__); BM_ITER_MESH_INDEX(eve, &viter, bm, BM_VERT, i) { - vnors_pack[i] = GWN_normal_convert_i10_v3(eve->no); + vnors_pack[i] = GPU_normal_convert_i10_v3(eve->no); } } else { @@ -1413,7 +1413,7 @@ static uchar mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *e } static void add_overlay_tri( - MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data, + MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data, const uint pos_id, const uint vnor_id, const uint lnor_id, const uint data_id, const BMLoop **bm_looptri, const int base_vert_idx) { @@ -1426,24 +1426,24 @@ static void add_overlay_tri( for (uint i = 0; i < 3; i++) { int vidx = BM_elem_index_get(bm_looptri[i]->v); const float *pos = rdata->edit_data->vertexCos[vidx]; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); } } else { for (uint i = 0; i < 3; i++) { const float *pos = bm_looptri[i]->v->co; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); } } } if (vbo_nor) { /* TODO real loop normal */ - Gwn_PackedNormal lnor = GWN_normal_convert_i10_v3(bm_looptri[0]->f->no); + GPUPackedNormal lnor = GPU_normal_convert_i10_v3(bm_looptri[0]->f->no); for (uint i = 0; i < 3; i++) { - Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(bm_looptri[i]->v->no); - GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor); - GWN_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor); + GPUPackedNormal vnor = GPU_normal_convert_i10_v3(bm_looptri[i]->v->no); + GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor); + GPU_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor); } } @@ -1457,7 +1457,7 @@ static void add_overlay_tri( mesh_render_data_edge_flag(rdata, bm_looptri[i_next]->e, &eattr); } eattr.v_flag = fflag | vflag; - GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr); + GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr); i_prev = i; i = i_next; @@ -1466,7 +1466,7 @@ static void add_overlay_tri( } static void add_overlay_loose_edge( - MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data, + MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data, const uint pos_id, const uint vnor_id, const uint data_id, const BMEdge *eed, const int base_vert_idx) { @@ -1476,21 +1476,21 @@ static void add_overlay_loose_edge( for (uint i = 0; i < 2; i++) { int vidx = BM_elem_index_get((&eed->v1)[i]); const float *pos = rdata->edit_data->vertexCos[vidx]; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); } } else { for (int i = 0; i < 2; ++i) { const float *pos = (&eed->v1)[i]->co; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); } } } if (vbo_nor) { for (int i = 0; i < 2; ++i) { - Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3((&eed->v1)[i]->no); - GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor); + GPUPackedNormal vnor = GPU_normal_convert_i10_v3((&eed->v1)[i]->no); + GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor); } } @@ -1499,13 +1499,13 @@ static void add_overlay_loose_edge( mesh_render_data_edge_flag(rdata, eed, &eattr); for (int i = 0; i < 2; ++i) { eattr.v_flag = mesh_render_data_vertex_flag(rdata, (&eed->v1)[i]); - GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr); + GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr); } } } static void add_overlay_loose_vert( - MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data, + MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data, const uint pos_id, const uint vnor_id, const uint data_id, const BMVert *eve, const int base_vert_idx) { @@ -1514,23 +1514,23 @@ static void add_overlay_loose_vert( if (rdata->edit_data && rdata->edit_data->vertexCos) { int vidx = BM_elem_index_get(eve); const float *pos = rdata->edit_data->vertexCos[vidx]; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos); } else { const float *pos = eve->co; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos); } } if (vbo_nor) { - Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(eve->no); - GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx, &vnor); + GPUPackedNormal vnor = GPU_normal_convert_i10_v3(eve->no); + GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx, &vnor); } if (vbo_data) { uchar vflag[4] = {0, 0, 0, 0}; vflag[0] = mesh_render_data_vertex_flag(rdata, eve); - GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx, vflag); + GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx, vflag); } } @@ -1539,96 +1539,96 @@ static void add_overlay_loose_vert( /* ---------------------------------------------------------------------- */ -/** \name Mesh Gwn_Batch Cache +/** \name Mesh GPUBatch Cache * \{ */ typedef struct MeshBatchCache { - Gwn_VertBuf *pos_in_order; - Gwn_IndexBuf *edges_in_order; - Gwn_IndexBuf *edges_adjacency; /* Store edges with adjacent vertices. */ - Gwn_IndexBuf *triangles_in_order; - Gwn_IndexBuf *ledges_in_order; + GPUVertBuf *pos_in_order; + GPUIndexBuf *edges_in_order; + GPUIndexBuf *edges_adjacency; /* Store edges with adjacent vertices. */ + GPUIndexBuf *triangles_in_order; + GPUIndexBuf *ledges_in_order; GPUTexture *pos_in_order_tx; /* Depending on pos_in_order */ - Gwn_Batch *all_verts; - Gwn_Batch *all_edges; - Gwn_Batch *all_triangles; + GPUBatch *all_verts; + GPUBatch *all_edges; + GPUBatch *all_triangles; - Gwn_VertBuf *pos_with_normals; - Gwn_VertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */ + GPUVertBuf *pos_with_normals; + GPUVertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */ /** * Other uses are all positions or loose elements. * This stores all visible elements, needed for selection. */ - Gwn_VertBuf *ed_fcenter_pos_with_nor_and_sel; - Gwn_VertBuf *ed_edge_pos; - Gwn_VertBuf *ed_vert_pos; + GPUVertBuf *ed_fcenter_pos_with_nor_and_sel; + GPUVertBuf *ed_edge_pos; + GPUVertBuf *ed_vert_pos; - Gwn_Batch *triangles_with_normals; - Gwn_Batch *ledges_with_normals; + GPUBatch *triangles_with_normals; + GPUBatch *ledges_with_normals; /* Skip hidden (depending on paint select mode) */ - Gwn_Batch *triangles_with_weights; - Gwn_Batch *triangles_with_vert_colors; + GPUBatch *triangles_with_weights; + GPUBatch *triangles_with_vert_colors; /* Always skip hidden */ - Gwn_Batch *triangles_with_select_mask; - Gwn_Batch *triangles_with_select_id; + GPUBatch *triangles_with_select_mask; + GPUBatch *triangles_with_select_id; uint triangles_with_select_id_offset; - Gwn_Batch *facedot_with_select_id; /* shares vbo with 'overlay_facedots' */ - Gwn_Batch *edges_with_select_id; - Gwn_Batch *verts_with_select_id; + GPUBatch *facedot_with_select_id; /* shares vbo with 'overlay_facedots' */ + GPUBatch *edges_with_select_id; + GPUBatch *verts_with_select_id; uint facedot_with_select_id_offset; uint edges_with_select_id_offset; uint verts_with_select_id_offset; - Gwn_Batch *points_with_normals; - Gwn_Batch *fancy_edges; /* owns its vertex buffer (not shared) */ + GPUBatch *points_with_normals; + GPUBatch *fancy_edges; /* owns its vertex buffer (not shared) */ - Gwn_Batch *edge_detection; + GPUBatch *edge_detection; - Gwn_VertBuf *edges_face_overlay; + GPUVertBuf *edges_face_overlay; GPUTexture *edges_face_overlay_tx; int edges_face_overlay_tri_count; /* Number of tri in edges_face_overlay(_adj)_tx */ /* Maybe have shaded_triangles_data split into pos_nor and uv_tangent * to minimize data transfer for skinned mesh. */ - Gwn_VertFormat shaded_triangles_format; - Gwn_VertBuf *shaded_triangles_data; - Gwn_IndexBuf **shaded_triangles_in_order; - Gwn_Batch **shaded_triangles; + GPUVertFormat shaded_triangles_format; + GPUVertBuf *shaded_triangles_data; + GPUIndexBuf **shaded_triangles_in_order; + GPUBatch **shaded_triangles; /* Texture Paint.*/ /* per-texture batch */ - Gwn_Batch **texpaint_triangles; - Gwn_Batch *texpaint_triangles_single; + GPUBatch **texpaint_triangles; + GPUBatch *texpaint_triangles_single; /* Edit Cage Mesh buffers */ - Gwn_VertBuf *ed_tri_pos; - Gwn_VertBuf *ed_tri_nor; /* LoopNor, VertNor */ - Gwn_VertBuf *ed_tri_data; + GPUVertBuf *ed_tri_pos; + GPUVertBuf *ed_tri_nor; /* LoopNor, VertNor */ + GPUVertBuf *ed_tri_data; - Gwn_VertBuf *ed_ledge_pos; - Gwn_VertBuf *ed_ledge_nor; /* VertNor */ - Gwn_VertBuf *ed_ledge_data; + GPUVertBuf *ed_ledge_pos; + GPUVertBuf *ed_ledge_nor; /* VertNor */ + GPUVertBuf *ed_ledge_data; - Gwn_VertBuf *ed_lvert_pos; - Gwn_VertBuf *ed_lvert_nor; /* VertNor */ - Gwn_VertBuf *ed_lvert_data; + GPUVertBuf *ed_lvert_pos; + GPUVertBuf *ed_lvert_nor; /* VertNor */ + GPUVertBuf *ed_lvert_data; - Gwn_Batch *overlay_triangles; - Gwn_Batch *overlay_triangles_nor; /* GWN_PRIM_POINTS */ - Gwn_Batch *overlay_loose_edges; - Gwn_Batch *overlay_loose_edges_nor; /* GWN_PRIM_POINTS */ - Gwn_Batch *overlay_loose_verts; - Gwn_Batch *overlay_facedots; + GPUBatch *overlay_triangles; + GPUBatch *overlay_triangles_nor; /* GPU_PRIM_POINTS */ + GPUBatch *overlay_loose_edges; + GPUBatch *overlay_loose_edges_nor; /* GPU_PRIM_POINTS */ + GPUBatch *overlay_loose_verts; + GPUBatch *overlay_facedots; - Gwn_Batch *overlay_weight_faces; - Gwn_Batch *overlay_weight_verts; - Gwn_Batch *overlay_paint_edges; + GPUBatch *overlay_weight_faces; + GPUBatch *overlay_weight_verts; + GPUBatch *overlay_paint_edges; /* arrays of bool uniform names (and value) that will be use to * set srgb conversion for auto attribs.*/ @@ -1653,7 +1653,7 @@ typedef struct MeshBatchCache { bool is_manifold; } MeshBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ static bool mesh_batch_cache_valid(Mesh *me) { @@ -1742,21 +1742,21 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode) cache->is_maybe_dirty = true; break; case BKE_MESH_BATCH_DIRTY_SELECT: - GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); /* Contains select flag */ - GWN_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos); - - GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges); - GWN_BATCH_DISCARD_SAFE(cache->overlay_facedots); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); /* Contains select flag */ + GPU_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos); + + GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay_facedots); /* Edit mode selection. */ - GWN_BATCH_DISCARD_SAFE(cache->facedot_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->facedot_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id); break; case BKE_MESH_BATCH_DIRTY_ALL: cache->is_dirty = true; @@ -1777,7 +1777,7 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode) /** * This only clear the batches associated to the given vertex buffer. **/ -static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert) +static void mesh_batch_cache_clear_selective(Mesh *me, GPUVertBuf *vert) { MeshBatchCache *cache = me->runtime.batch_cache; if (!cache) { @@ -1787,26 +1787,26 @@ static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert) BLI_assert(vert != NULL); if (cache->pos_with_normals == vert) { - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_weights); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask); - GWN_BATCH_DISCARD_SAFE(cache->points_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->ledges_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask); + GPU_BATCH_DISCARD_SAFE(cache->points_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->ledges_with_normals); if (cache->shaded_triangles) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]); } } MEM_SAFE_FREE(cache->shaded_triangles); if (cache->texpaint_triangles) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]); } } MEM_SAFE_FREE(cache->texpaint_triangles); - GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single); + GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single); } /* TODO: add the other ones if needed. */ else { @@ -1822,69 +1822,69 @@ static void mesh_batch_cache_clear(Mesh *me) return; } - GWN_BATCH_DISCARD_SAFE(cache->all_verts); - GWN_BATCH_DISCARD_SAFE(cache->all_edges); - GWN_BATCH_DISCARD_SAFE(cache->all_triangles); + GPU_BATCH_DISCARD_SAFE(cache->all_verts); + GPU_BATCH_DISCARD_SAFE(cache->all_edges); + GPU_BATCH_DISCARD_SAFE(cache->all_triangles); - GWN_VERTBUF_DISCARD_SAFE(cache->pos_in_order); + GPU_VERTBUF_DISCARD_SAFE(cache->pos_in_order); DRW_TEXTURE_FREE_SAFE(cache->pos_in_order_tx); - GWN_INDEXBUF_DISCARD_SAFE(cache->edges_in_order); - GWN_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order); - GWN_INDEXBUF_DISCARD_SAFE(cache->ledges_in_order); - - GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_nor); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_nor); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_nor); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data); - GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles); - GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor); - - GWN_BATCH_DISCARD_SAFE(cache->overlay_weight_faces); - GWN_BATCH_DISCARD_SAFE(cache->overlay_weight_verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay_paint_edges); - GWN_BATCH_DISCARD_SAFE(cache->overlay_facedots); - - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->points_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->ledges_with_normals); - GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_weights); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); - GWN_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->facedot_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id); - - GWN_BATCH_DISCARD_SAFE(cache->fancy_edges); - - GWN_INDEXBUF_DISCARD_SAFE(cache->edges_adjacency); - GWN_BATCH_DISCARD_SAFE(cache->edge_detection); - - GWN_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay); + GPU_INDEXBUF_DISCARD_SAFE(cache->edges_in_order); + GPU_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order); + GPU_INDEXBUF_DISCARD_SAFE(cache->ledges_in_order); + + GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_nor); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_nor); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_nor); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data); + GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles); + GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor); + + GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_faces); + GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay_paint_edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay_facedots); + + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->points_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->ledges_with_normals); + GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); + GPU_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->facedot_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id); + + GPU_BATCH_DISCARD_SAFE(cache->fancy_edges); + + GPU_INDEXBUF_DISCARD_SAFE(cache->edges_adjacency); + GPU_BATCH_DISCARD_SAFE(cache->edge_detection); + + GPU_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay); DRW_TEXTURE_FREE_SAFE(cache->edges_face_overlay_tx); - GWN_VERTBUF_DISCARD_SAFE(cache->shaded_triangles_data); + GPU_VERTBUF_DISCARD_SAFE(cache->shaded_triangles_data); if (cache->shaded_triangles_in_order) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_INDEXBUF_DISCARD_SAFE(cache->shaded_triangles_in_order[i]); + GPU_INDEXBUF_DISCARD_SAFE(cache->shaded_triangles_in_order[i]); } } if (cache->shaded_triangles) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]); } } @@ -1896,12 +1896,12 @@ static void mesh_batch_cache_clear(Mesh *me) if (cache->texpaint_triangles) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]); } } MEM_SAFE_FREE(cache->texpaint_triangles); - GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single); + GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single); } @@ -1911,9 +1911,9 @@ void DRW_mesh_batch_cache_free(Mesh *me) MEM_SAFE_FREE(me->runtime.batch_cache); } -/* Gwn_Batch cache usage. */ +/* GPUBatch cache usage. */ -static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUVertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); #define USE_COMP_MESH_DATA @@ -1928,9 +1928,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, return NULL; } - Gwn_VertFormat *format = &cache->shaded_triangles_format; + GPUVertFormat *format = &cache->shaded_triangles_format; - GWN_vertformat_clear(format); + GPU_vertformat_clear(format); /* initialize vertex format */ uint *layers_combined_id = BLI_array_alloca(layers_combined_id, layers_combined_len); @@ -1968,14 +1968,14 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, /* UV */ const char *attrib_name = mesh_render_data_uv_layer_uuid_get(rdata, i); #if defined(USE_COMP_MESH_DATA) && 0 /* these are clamped. Maybe use them as an option in the future */ - uv_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_I16, 2, GWN_FETCH_INT_TO_FLOAT_UNIT); + uv_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT); #else - uv_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uv_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); #endif /* Auto Name */ attrib_name = mesh_render_data_uv_auto_layer_uuid_get(rdata, i); - GWN_vertformat_alias_add(format, attrib_name); + GPU_vertformat_alias_add(format, attrib_name); /* +1 include null terminator. */ auto_ofs += 1 + BLI_snprintf_rlen( @@ -1983,7 +1983,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, cache->auto_layer_is_srgb[auto_id++] = 0; /* tag as not srgb */ if (i == rdata->cd.layers.uv_active) { - GWN_vertformat_alias_add(format, "u"); + GPU_vertformat_alias_add(format, "u"); } } @@ -1993,25 +1993,25 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, * That may cause some problem but I could not make it to fail (fclem) */ #ifdef USE_COMP_MESH_DATA /* Tangents need more precision than 10_10_10 */ - tangent_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + tangent_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); #else - tangent_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + tangent_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_F32, 3, GPU_FETCH_FLOAT); #endif if (i == rdata->cd.layers.tangent_active) { - GWN_vertformat_alias_add(format, "t"); + GPU_vertformat_alias_add(format, "t"); } } for (uint i = 0; i < vcol_len; i++) { const char *attrib_name = mesh_render_data_vcol_layer_uuid_get(rdata, i); - vcol_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + vcol_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); /* Auto layer */ if (rdata->cd.layers.auto_vcol[i]) { attrib_name = mesh_render_data_vcol_auto_layer_uuid_get(rdata, i); - GWN_vertformat_alias_add(format, attrib_name); + GPU_vertformat_alias_add(format, attrib_name); /* +1 include null terminator. */ auto_ofs += 1 + BLI_snprintf_rlen( @@ -2020,23 +2020,23 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, } if (i == rdata->cd.layers.vcol_active) { - GWN_vertformat_alias_add(format, "c"); + GPU_vertformat_alias_add(format, "c"); } } const uint tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_VertBuf *vbo = cache->shaded_triangles_data = GWN_vertbuf_create_with_format(format); + GPUVertBuf *vbo = cache->shaded_triangles_data = GPU_vertbuf_create_with_format(format); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw *layers_combined_step = BLI_array_alloca(layers_combined_step, layers_combined_len); + GPUVertBufRaw *layers_combined_step = BLI_array_alloca(layers_combined_step, layers_combined_len); - Gwn_VertBufRaw *uv_step = layers_combined_step; - Gwn_VertBufRaw *tangent_step = uv_step + uv_len; - Gwn_VertBufRaw *vcol_step = tangent_step + tangent_len; + GPUVertBufRaw *uv_step = layers_combined_step; + GPUVertBufRaw *tangent_step = uv_step + uv_len; + GPUVertBufRaw *vcol_step = tangent_step + tangent_len; /* Not needed, just for sanity. */ if (uv_len == 0) { uv_step = NULL; } @@ -2044,16 +2044,16 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, if (vcol_len == 0) { vcol_step = NULL; } for (uint i = 0; i < uv_len; i++) { - GWN_vertbuf_attr_get_raw_data(vbo, uv_id[i], &uv_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo, uv_id[i], &uv_step[i]); } for (uint i = 0; i < tangent_len; i++) { - GWN_vertbuf_attr_get_raw_data(vbo, tangent_id[i], &tangent_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo, tangent_id[i], &tangent_step[i]); } for (uint i = 0; i < vcol_len; i++) { - GWN_vertbuf_attr_get_raw_data(vbo, vcol_id[i], &vcol_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo, vcol_id[i], &vcol_step[i]); } - /* TODO deduplicate all verts and make use of Gwn_IndexBuf in + /* TODO deduplicate all verts and make use of GPUIndexBuf in * mesh_batch_cache_get_triangles_in_order_split_by_material. */ if (rdata->edit_bmesh) { for (uint i = 0; i < tri_len; i++) { @@ -2066,7 +2066,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, const uint layer_offset = rdata->cd.offset.uv[j]; for (uint t = 0; t < 3; t++) { const float *elem = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(bm_looptri[t], layer_offset))->uv; - copy_v2_v2(GWN_vertbuf_raw_step(&uv_step[j]), elem); + copy_v2_v2(GPU_vertbuf_raw_step(&uv_step[j]), elem); } } /* TANGENTs */ @@ -2074,7 +2074,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, float (*layer_data)[4] = rdata->cd.layers.tangent[j]; for (uint t = 0; t < 3; t++) { const float *elem = layer_data[BM_elem_index_get(bm_looptri[t])]; - normal_float_to_short_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem); + normal_float_to_short_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem); } } /* VCOLs */ @@ -2082,7 +2082,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, const uint layer_offset = rdata->cd.offset.vcol[j]; for (uint t = 0; t < 3; t++) { const uchar *elem = &((MLoopCol *)BM_ELEM_CD_GET_VOID_P(bm_looptri[t], layer_offset))->r; - copy_v3_v3_uchar(GWN_vertbuf_raw_step(&vcol_step[j]), elem); + copy_v3_v3_uchar(GPU_vertbuf_raw_step(&vcol_step[j]), elem); } } } @@ -2096,7 +2096,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, const MLoopUV *layer_data = rdata->cd.layers.uv[j]; for (uint t = 0; t < 3; t++) { const float *elem = layer_data[mlt->tri[t]].uv; - copy_v2_v2(GWN_vertbuf_raw_step(&uv_step[j]), elem); + copy_v2_v2(GPU_vertbuf_raw_step(&uv_step[j]), elem); } } /* TANGENTs */ @@ -2105,9 +2105,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, for (uint t = 0; t < 3; t++) { const float *elem = layer_data[mlt->tri[t]]; #ifdef USE_COMP_MESH_DATA - normal_float_to_short_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem); + normal_float_to_short_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem); #else - copy_v3_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem); + copy_v3_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem); #endif } } @@ -2116,25 +2116,25 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, const MLoopCol *layer_data = rdata->cd.layers.vcol[j]; for (uint t = 0; t < 3; t++) { const uchar *elem = &layer_data[mlt->tri[t]].r; - copy_v3_v3_uchar(GWN_vertbuf_raw_step(&vcol_step[j]), elem); + copy_v3_v3_uchar(GPU_vertbuf_raw_step(&vcol_step[j]), elem); } } } } - vbo_len_used = GWN_vertbuf_raw_used(&layers_combined_step[0]); + vbo_len_used = GPU_vertbuf_raw_used(&layers_combined_step[0]); #ifndef NDEBUG /* Check all layers are write aligned. */ if (layers_combined_len > 1) { for (uint i = 1; i < layers_combined_len; i++) { - BLI_assert(vbo_len_used == GWN_vertbuf_raw_used(&layers_combined_step[i])); + BLI_assert(vbo_len_used == GPU_vertbuf_raw_used(&layers_combined_step[i])); } } #endif if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } @@ -2143,7 +2143,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, return cache->shaded_triangles_data; } -static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( +static GPUVertBuf *mesh_batch_cache_get_tri_uv_active( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPUV)); @@ -2157,19 +2157,19 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( uint vidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint uv; } attr_id; if (format.attr_len == 0) { - attr_id.uv = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.uv = GPU_vertformat_attr_add(&format, "uv", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_VertBuf *vbo = cache->tri_aligned_uv = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = cache->tri_aligned_uv = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); BMEditMesh *embm = rdata->edit_bmesh; @@ -2189,7 +2189,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( const int index = BM_elem_index_get(loop); if (index != -1) { const float *elem = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(loop, layer_offset))->uv; - GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, elem); + GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, elem); } } } @@ -2198,9 +2198,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( /* object mode */ for (int i = 0; i < tri_len; i++) { const MLoopTri *mlt = &rdata->mlooptri[i]; - GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[0]].uv); - GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[1]].uv); - GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[2]].uv); + GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[0]].uv); + GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[1]].uv); + GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[2]].uv); } } @@ -2213,36 +2213,36 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( return cache->tri_aligned_uv; } -static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( +static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( MeshRenderData *rdata, const bool use_hide, - Gwn_VertBuf **r_vbo) + GPUVertBuf **r_vbo) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); if (*r_vbo == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_VertBuf *vbo = *r_vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = *r_vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step, nor_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.nor, &nor_step); + GPUVertBufRaw pos_step, nor_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.nor, &nor_step); float (*lnors)[3] = rdata->loop_normals; if (rdata->edit_bmesh) { - Gwn_PackedNormal *pnors_pack, *vnors_pack; + GPUPackedNormal *pnors_pack, *vnors_pack; if (lnors == NULL) { mesh_render_data_ensure_poly_normals_pack(rdata); @@ -2264,18 +2264,18 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( if (lnors) { for (uint t = 0; t < 3; t++) { const float *nor = lnors[BM_elem_index_get(bm_looptri[t])]; - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_v3(nor); + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_v3(nor); } } else if (BM_elem_flag_test(bm_face, BM_ELEM_SMOOTH)) { for (uint t = 0; t < 3; t++) { - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = vnors_pack[BM_elem_index_get(bm_looptri[t]->v)]; + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = vnors_pack[BM_elem_index_get(bm_looptri[t]->v)]; } } else { - const Gwn_PackedNormal *snor_pack = &pnors_pack[BM_elem_index_get(bm_face)]; + const GPUPackedNormal *snor_pack = &pnors_pack[BM_elem_index_get(bm_face)]; for (uint t = 0; t < 3; t++) { - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = *snor_pack; + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = *snor_pack; } } @@ -2284,12 +2284,12 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( for (uint t = 0; t < 3; t++) { int vidx = BM_elem_index_get(bm_looptri[t]->v); const float *pos = rdata->edit_data->vertexCos[vidx]; - copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), pos); + copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), pos); } } else { for (uint t = 0; t < 3; t++) { - copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), bm_looptri[t]->v->co); + copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), bm_looptri[t]->v->co); } } } @@ -2317,85 +2317,85 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( if (lnors) { for (uint t = 0; t < 3; t++) { const float *nor = lnors[mlt->tri[t]]; - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_v3(nor); + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_v3(nor); } } else if (mp->flag & ME_SMOOTH) { for (uint t = 0; t < 3; t++) { const MVert *mv = &rdata->mvert[vtri[t]]; - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_s3(mv->no); + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_s3(mv->no); } } else { - const Gwn_PackedNormal *pnors_pack = &rdata->poly_normals_pack[mlt->poly]; + const GPUPackedNormal *pnors_pack = &rdata->poly_normals_pack[mlt->poly]; for (uint t = 0; t < 3; t++) { - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = *pnors_pack; + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = *pnors_pack; } } for (uint t = 0; t < 3; t++) { const MVert *mv = &rdata->mvert[vtri[t]]; - copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), mv->co); + copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), mv->co); } } } - vbo_len_used = GWN_vertbuf_raw_used(&pos_step); - BLI_assert(vbo_len_used == GWN_vertbuf_raw_used(&nor_step)); + vbo_len_used = GPU_vertbuf_raw_used(&pos_step); + BLI_assert(vbo_len_used == GPU_vertbuf_raw_used(&nor_step)); if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return *r_vbo; } -static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals( +static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals( MeshRenderData *rdata, MeshBatchCache *cache) { return mesh_batch_cache_get_tri_pos_and_normals_ex( rdata, false, &cache->pos_with_normals); } -static Gwn_VertBuf *mesh_create_tri_pos_and_normals_visible_only( +static GPUVertBuf *mesh_create_tri_pos_and_normals_visible_only( MeshRenderData *rdata) { - Gwn_VertBuf *vbo_dummy = NULL; + GPUVertBuf *vbo_dummy = NULL; return mesh_batch_cache_get_tri_pos_and_normals_ex( rdata, true, &vbo_dummy); } -static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( +static GPUVertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); if (cache->ed_fcenter_pos_with_nor_and_sel == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.data = GWN_vertformat_attr_add(&format, "norAndFlag", GWN_COMP_I10, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.data = GPU_vertformat_attr_add(&format, "norAndFlag", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); } const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata); int vidx = 0; - Gwn_VertBuf *vbo = cache->ed_fcenter_pos_with_nor_and_sel = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBuf *vbo = cache->ed_fcenter_pos_with_nor_and_sel = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); for (int i = 0; i < vbo_len_capacity; ++i) { float pcenter[3], pnor[3]; bool selected = false; if (mesh_render_data_pnors_pcenter_select_get(rdata, i, pnor, pcenter, &selected)) { - Gwn_PackedNormal nor = { .x = 0, .y = 0, .z = -511 }; - nor = GWN_normal_convert_i10_v3(pnor); + GPUPackedNormal nor = { .x = 0, .y = 0, .z = -511 }; + nor = GPU_normal_convert_i10_v3(pnor); nor.w = selected ? 1 : 0; - GWN_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor); + GPU_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, pcenter); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, pcenter); vidx += 1; } @@ -2403,30 +2403,30 @@ static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( const int vbo_len_used = vidx; BLI_assert(vbo_len_used <= vbo_len_capacity); if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return cache->ed_fcenter_pos_with_nor_and_sel; } -static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( +static GPUVertBuf *mesh_batch_cache_get_edges_visible( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE)); if (cache->ed_edge_pos == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } const int vbo_len_capacity = mesh_render_data_edges_len_get(rdata) * 2; int vidx = 0; - Gwn_VertBuf *vbo = cache->ed_edge_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBuf *vbo = cache->ed_edge_pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; BMIter iter; @@ -2434,9 +2434,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v1->co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v1->co); vidx += 1; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v2->co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v2->co); vidx += 1; } } @@ -2447,7 +2447,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } UNUSED_VARS_NDEBUG(vbo_len_used); } @@ -2455,23 +2455,23 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( return cache->ed_edge_pos; } -static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( +static GPUVertBuf *mesh_batch_cache_get_verts_visible( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); if (cache->ed_vert_pos == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata); uint vidx = 0; - Gwn_VertBuf *vbo = cache->ed_vert_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBuf *vbo = cache->ed_vert_pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; BMIter iter; @@ -2479,7 +2479,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eve->co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eve->co); vidx += 1; } } @@ -2488,14 +2488,14 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( for (int i = 0; i < vbo_len_capacity; i++) { const MVert *mv = &rdata->mvert[i]; if (!(mv->flag & ME_HIDE)) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, mv->co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, mv->co); vidx += 1; } } } const uint vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } UNUSED_VARS_NDEBUG(vbo_len_used); @@ -2504,24 +2504,24 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( return cache->ed_vert_pos; } -static Gwn_VertBuf *mesh_create_facedot_select_id( +static GPUVertBuf *mesh_create_facedot_select_id( MeshRenderData *rdata, uint select_id_offset) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT); } const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata); int vidx = 0; - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); uint select_index = select_id_offset; if (rdata->edit_bmesh) { @@ -2533,7 +2533,7 @@ static Gwn_VertBuf *mesh_create_facedot_select_id( if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { int select_id; GPU_select_index_get(select_index, &select_id); - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; } select_index += 1; @@ -2545,31 +2545,31 @@ static Gwn_VertBuf *mesh_create_facedot_select_id( } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_edges_select_id( +static GPUVertBuf *mesh_create_edges_select_id( MeshRenderData *rdata, uint select_id_offset) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT); } const int vbo_len_capacity = mesh_render_data_edges_len_get(rdata) * 2; int vidx = 0; - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); uint select_index = select_id_offset; if (rdata->edit_bmesh) { @@ -2581,9 +2581,9 @@ static Gwn_VertBuf *mesh_create_edges_select_id( if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { int select_id; GPU_select_index_get(select_index, &select_id); - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; } select_index += 1; @@ -2595,31 +2595,31 @@ static Gwn_VertBuf *mesh_create_edges_select_id( } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_verts_select_id( +static GPUVertBuf *mesh_create_verts_select_id( MeshRenderData *rdata, uint select_id_offset) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT); } const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata); int vidx = 0; - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); uint select_index = select_id_offset; if (rdata->edit_bmesh) { @@ -2631,7 +2631,7 @@ static Gwn_VertBuf *mesh_create_verts_select_id( if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { int select_id; GPU_select_index_get(select_index, &select_id); - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; } select_index += 1; @@ -2643,7 +2643,7 @@ static Gwn_VertBuf *mesh_create_verts_select_id( if (!(mv->flag & ME_HIDE)) { int select_id; GPU_select_index_get(select_index, &select_id); - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; } select_index += 1; @@ -2651,36 +2651,36 @@ static Gwn_VertBuf *mesh_create_verts_select_id( } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_tri_weights( +static GPUVertBuf *mesh_create_tri_weights( MeshRenderData *rdata, bool use_hide, int defgroup) { BLI_assert( rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_DVERT)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const int tri_len = mesh_render_data_looptri_len_get(rdata); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); mesh_render_data_ensure_vert_weight_color(rdata, defgroup); const float (*vert_weight_color)[3] = rdata->vert_weight_color; @@ -2692,7 +2692,7 @@ static Gwn_VertBuf *mesh_create_tri_weights( if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { const int v_index = BM_elem_index_get(ltri[tri_corner]->v); - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]); } } } @@ -2703,7 +2703,7 @@ static Gwn_VertBuf *mesh_create_tri_weights( if (!(use_hide && (rdata->mpoly[mlt->poly].flag & ME_HIDE))) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { const uint v_index = rdata->mloop[mlt->tri[tri_corner]].v; - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]); } } } @@ -2711,36 +2711,36 @@ static Gwn_VertBuf *mesh_create_tri_weights( vbo_len_used = cidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_tri_vert_colors( +static GPUVertBuf *mesh_create_tri_vert_colors( MeshRenderData *rdata, bool use_hide) { BLI_assert( rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } const int tri_len = mesh_render_data_looptri_len_get(rdata); - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const uint vbo_len_capacity = tri_len * 3; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); mesh_render_data_ensure_vert_color(rdata); const char (*vert_color)[3] = rdata->vert_color; @@ -2752,7 +2752,7 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors( if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { const int l_index = BM_elem_index_get(ltri[tri_corner]); - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]); } } } @@ -2763,7 +2763,7 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors( if (!(use_hide && (rdata->mpoly[mlt->poly].flag & ME_HIDE))) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { const uint l_index = mlt->tri[tri_corner]; - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]); } } } @@ -2771,37 +2771,37 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors( const uint vbo_len_used = cidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_tri_select_id( +static GPUVertBuf *mesh_create_tri_select_id( MeshRenderData *rdata, bool use_hide, uint select_id_offset) { BLI_assert( rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT); } const int tri_len = mesh_render_data_looptri_len_get(rdata); - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (rdata->edit_bmesh) { for (int i = 0; i < tri_len; i++) { @@ -2812,7 +2812,7 @@ static Gwn_VertBuf *mesh_create_tri_select_id( int select_id; GPU_select_index_get(poly_index + select_id_offset, &select_id); for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id); } } } @@ -2825,7 +2825,7 @@ static Gwn_VertBuf *mesh_create_tri_select_id( int select_id; GPU_select_index_get(poly_index + select_id_offset, &select_id); for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id); } } } @@ -2833,29 +2833,29 @@ static Gwn_VertBuf *mesh_create_tri_select_id( vbo_len_used = cidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( +static GPUVertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); if (cache->pos_in_order == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; if (format.attr_len == 0) { /* Normal is padded so that the vbo can be used as a buffer texture */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); } - Gwn_VertBuf *vbo = cache->pos_in_order = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = cache->pos_in_order = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; @@ -2867,15 +2867,15 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( static short no_short[4]; normal_float_to_short_v3(no_short, eve->no); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, eve->co); - GWN_vertbuf_attr_set(vbo, attr_id.nor, i, no_short); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, eve->co); + GPU_vertbuf_attr_set(vbo, attr_id.nor, i, no_short); } BLI_assert(i == vbo_len_capacity); } else { for (int i = 0; i < vbo_len_capacity; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->mvert[i].co); - GWN_vertbuf_attr_set(vbo, attr_id.nor, i, rdata->mvert[i].no); /* XXX actually reading 4 shorts */ + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->mvert[i].co); + GPU_vertbuf_attr_set(vbo, attr_id.nor, i, rdata->mvert[i].no); /* XXX actually reading 4 shorts */ } } } @@ -2883,26 +2883,26 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( return cache->pos_in_order; } -static Gwn_VertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id) +static GPUVertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id) { - static Gwn_VertFormat format_pos = { 0 }; + static GPUVertFormat format_pos = { 0 }; static uint pos_id; if (format_pos.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format_pos, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format_pos, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } *r_pos_id = pos_id; return &format_pos; } -static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lnor_id) +static GPUVertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lnor_id) { - static Gwn_VertFormat format_nor = { 0 }; - static Gwn_VertFormat format_nor_loop = { 0 }; + static GPUVertFormat format_nor = { 0 }; + static GPUVertFormat format_nor_loop = { 0 }; static uint vnor_id, vnor_loop_id, lnor_id; if (format_nor.attr_len == 0) { - vnor_id = GWN_vertformat_attr_add(&format_nor, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - vnor_loop_id = GWN_vertformat_attr_add(&format_nor_loop, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - lnor_id = GWN_vertformat_attr_add(&format_nor_loop, "lnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + vnor_id = GPU_vertformat_attr_add(&format_nor, "vnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + vnor_loop_id = GPU_vertformat_attr_add(&format_nor_loop, "vnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + lnor_id = GPU_vertformat_attr_add(&format_nor_loop, "lnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } if (r_lnor_id) { *r_vnor_id = vnor_loop_id; @@ -2915,12 +2915,12 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno } } -static Gwn_VertFormat *edit_mesh_overlay_data_format(uint *r_data_id) +static GPUVertFormat *edit_mesh_overlay_data_format(uint *r_data_id) { - static Gwn_VertFormat format_flag = { 0 }; + static GPUVertFormat format_flag = { 0 }; static uint data_id; if (format_flag.attr_len == 0) { - data_id = GWN_vertformat_attr_add(&format_flag, "data", GWN_COMP_U8, 4, GWN_FETCH_INT); + data_id = GPU_vertformat_attr_add(&format_flag, "data", GPU_COMP_U8, 4, GPU_FETCH_INT); } *r_data_id = data_id; return &format_flag; @@ -2937,28 +2937,28 @@ static void mesh_batch_cache_create_overlay_tri_buffers( int vbo_len_used = 0; /* Positions */ - Gwn_VertBuf *vbo_pos = NULL; + GPUVertBuf *vbo_pos = NULL; static struct { uint pos, vnor, lnor, data; } attr_id; if (cache->ed_tri_pos == NULL) { vbo_pos = cache->ed_tri_pos = - GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); - GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); + GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); } /* Normals */ - Gwn_VertBuf *vbo_nor = NULL; + GPUVertBuf *vbo_nor = NULL; if (cache->ed_tri_nor == NULL) { vbo_nor = cache->ed_tri_nor = - GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, &attr_id.lnor)); - GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, &attr_id.lnor)); + GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); } /* Data */ - Gwn_VertBuf *vbo_data = NULL; + GPUVertBuf *vbo_data = NULL; if (cache->ed_tri_data == NULL) { vbo_data = cache->ed_tri_data = - GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); - GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); + GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity); } for (int i = 0; i < tri_len; i++) { @@ -2976,13 +2976,13 @@ static void mesh_batch_cache_create_overlay_tri_buffers( /* Finish */ if (vbo_len_used != vbo_len_capacity) { if (vbo_pos != NULL) { - GWN_vertbuf_data_resize(vbo_pos, vbo_len_used); + GPU_vertbuf_data_resize(vbo_pos, vbo_len_used); } if (vbo_nor != NULL) { - GWN_vertbuf_data_resize(vbo_nor, vbo_len_used); + GPU_vertbuf_data_resize(vbo_nor, vbo_len_used); } if (vbo_data != NULL) { - GWN_vertbuf_data_resize(vbo_data, vbo_len_used); + GPU_vertbuf_data_resize(vbo_data, vbo_len_used); } } } @@ -2998,28 +2998,28 @@ static void mesh_batch_cache_create_overlay_ledge_buffers( int vbo_len_used = 0; /* Positions */ - Gwn_VertBuf *vbo_pos = NULL; + GPUVertBuf *vbo_pos = NULL; static struct { uint pos, vnor, data; } attr_id; if (cache->ed_ledge_pos == NULL) { vbo_pos = cache->ed_ledge_pos = - GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); - GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); + GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); } /* Normals */ - Gwn_VertBuf *vbo_nor = NULL; + GPUVertBuf *vbo_nor = NULL; if (cache->ed_ledge_nor == NULL) { vbo_nor = cache->ed_ledge_nor = - GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL)); - GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL)); + GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); } /* Data */ - Gwn_VertBuf *vbo_data = NULL; + GPUVertBuf *vbo_data = NULL; if (cache->ed_ledge_data == NULL) { vbo_data = cache->ed_ledge_data = - GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); - GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); + GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity); } if (rdata->edit_bmesh) { @@ -3039,13 +3039,13 @@ static void mesh_batch_cache_create_overlay_ledge_buffers( /* Finish */ if (vbo_len_used != vbo_len_capacity) { if (vbo_pos != NULL) { - GWN_vertbuf_data_resize(vbo_pos, vbo_len_used); + GPU_vertbuf_data_resize(vbo_pos, vbo_len_used); } if (vbo_nor != NULL) { - GWN_vertbuf_data_resize(vbo_nor, vbo_len_used); + GPU_vertbuf_data_resize(vbo_nor, vbo_len_used); } if (vbo_data != NULL) { - GWN_vertbuf_data_resize(vbo_data, vbo_len_used); + GPU_vertbuf_data_resize(vbo_data, vbo_len_used); } } } @@ -3064,27 +3064,27 @@ static void mesh_batch_cache_create_overlay_lvert_buffers( static struct { uint pos, vnor, data; } attr_id; /* Positions */ - Gwn_VertBuf *vbo_pos = NULL; + GPUVertBuf *vbo_pos = NULL; if (cache->ed_lvert_pos == NULL) { vbo_pos = cache->ed_lvert_pos = - GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); - GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); + GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); } /* Normals */ - Gwn_VertBuf *vbo_nor = NULL; + GPUVertBuf *vbo_nor = NULL; if (cache->ed_lvert_nor == NULL) { vbo_nor = cache->ed_lvert_nor = - GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL)); - GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL)); + GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); } /* Data */ - Gwn_VertBuf *vbo_data = NULL; + GPUVertBuf *vbo_data = NULL; if (cache->ed_lvert_data == NULL) { vbo_data = cache->ed_lvert_data = - GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); - GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); + GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity); } for (uint i = 0; i < lvert_len; i++) { @@ -3099,19 +3099,19 @@ static void mesh_batch_cache_create_overlay_lvert_buffers( /* Finish */ if (vbo_len_used != vbo_len_capacity) { if (vbo_pos != NULL) { - GWN_vertbuf_data_resize(vbo_pos, vbo_len_used); + GPU_vertbuf_data_resize(vbo_pos, vbo_len_used); } if (vbo_nor != NULL) { - GWN_vertbuf_data_resize(vbo_nor, vbo_len_used); + GPU_vertbuf_data_resize(vbo_nor, vbo_len_used); } if (vbo_data != NULL) { - GWN_vertbuf_data_resize(vbo_data, vbo_len_used); + GPU_vertbuf_data_resize(vbo_data, vbo_len_used); } } } /* Position */ -static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_pos( +static GPUVertBuf *mesh_batch_cache_get_edit_tri_pos( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3123,7 +3123,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_pos( return cache->ed_tri_pos; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_pos( +static GPUVertBuf *mesh_batch_cache_get_edit_ledge_pos( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3135,7 +3135,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_pos( return cache->ed_ledge_pos; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_pos( +static GPUVertBuf *mesh_batch_cache_get_edit_lvert_pos( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3148,7 +3148,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_pos( } /* Normal */ -static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_nor( +static GPUVertBuf *mesh_batch_cache_get_edit_tri_nor( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3160,7 +3160,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_nor( return cache->ed_tri_nor; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_nor( +static GPUVertBuf *mesh_batch_cache_get_edit_ledge_nor( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3172,7 +3172,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_nor( return cache->ed_ledge_nor; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_nor( +static GPUVertBuf *mesh_batch_cache_get_edit_lvert_nor( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3185,7 +3185,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_nor( } /* Data */ -static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_data( +static GPUVertBuf *mesh_batch_cache_get_edit_tri_data( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3197,7 +3197,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_data( return cache->ed_tri_data; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_data( +static GPUVertBuf *mesh_batch_cache_get_edit_ledge_data( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3209,7 +3209,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_data( return cache->ed_ledge_data; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_data( +static GPUVertBuf *mesh_batch_cache_get_edit_lvert_data( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3221,7 +3221,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_data( return cache->ed_lvert_data; } -static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUIndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE)); @@ -3229,8 +3229,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, const int vert_len = mesh_render_data_verts_len_get(rdata); const int edge_len = mesh_render_data_edges_len_get(rdata); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); BLI_assert(rdata->types & MR_DATATYPE_EDGE); @@ -3240,24 +3240,24 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, BMEdge *eed; BM_ITER_MESH(eed, &eiter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - GWN_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2)); + GPU_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2)); } } } else { const MEdge *ed = rdata->medge; for (int i = 0; i < edge_len; i++, ed++) { - GWN_indexbuf_add_line_verts(&elb, ed->v1, ed->v2); + GPU_indexbuf_add_line_verts(&elb, ed->v1, ed->v2); } } - cache->edges_in_order = GWN_indexbuf_build(&elb); + cache->edges_in_order = GPU_indexbuf_build(&elb); } return cache->edges_in_order; } #define NO_EDGE INT_MAX -static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUIndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI)); @@ -3268,8 +3268,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, cache->is_manifold = true; /* Allocate max but only used indices are sent to GPU. */ - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, tri_len * 3, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, tri_len * 3, vert_len); EdgeHash *eh = BLI_edgehash_new_ex(__func__, tri_len * 3); /* Create edges for each pair of triangles sharing an edge. */ @@ -3310,12 +3310,12 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, if (inv_opposite == inv_indices) { /* Don't share edge if triangles have non matching winding. */ - GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0); - GWN_indexbuf_add_line_adj_verts(&elb, v_opposite, v1, v2, v_opposite); + GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0); + GPU_indexbuf_add_line_adj_verts(&elb, v_opposite, v1, v2, v_opposite); cache->is_manifold = false; } else { - GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v_opposite); + GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v_opposite); } } } @@ -3336,13 +3336,13 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, if (v_data < 0) { /* inv_opposite */ SWAP(uint, v1, v2); } - GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0); + GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0); cache->is_manifold = false; } BLI_edgehashIterator_free(ehi); BLI_edgehash_free(eh, NULL); - cache->edges_adjacency = GWN_indexbuf_build(&elb); + cache->edges_adjacency = GPU_indexbuf_build(&elb); } return cache->edges_adjacency; @@ -3395,16 +3395,16 @@ static EdgeHash *create_looptri_edge_adjacency_hash(MeshRenderData *rdata) return eh; } -static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderData *rdata) +static GPUVertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderData *rdata) { const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_VertFormat format = {0}; - uint index_id = GWN_vertformat_attr_add(&format, "index", GWN_COMP_U32, 1, GWN_FETCH_INT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertFormat format = {0}; + uint index_id = GPU_vertformat_attr_add(&format, "index", GPU_COMP_U32, 1, GPU_FETCH_INT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); int vbo_len_capacity = tri_len * 3; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); int vidx = 0; EdgeHash *eh = NULL; @@ -3442,7 +3442,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender if (eav->vert_index[1] == -1) { value |= (1 << 31); } - GWN_vertbuf_attr_set(vbo, index_id, vidx++, &value); + GPU_vertbuf_attr_set(vbo, index_id, vidx++, &value); } } @@ -3451,7 +3451,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender int vbo_len_used = vidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } return vbo; @@ -3467,10 +3467,10 @@ static GPUTexture *mesh_batch_cache_get_edges_overlay_texture_buf(MeshRenderData return cache->edges_face_overlay_tx; } - Gwn_VertBuf *vbo = cache->edges_face_overlay = mesh_batch_cache_create_edges_overlay_texture_buf(rdata); + GPUVertBuf *vbo = cache->edges_face_overlay = mesh_batch_cache_create_edges_overlay_texture_buf(rdata); /* Upload data early because we need to create the texture for it. */ - GWN_vertbuf_use(vbo); + GPU_vertbuf_use(vbo); cache->edges_face_overlay_tx = GPU_texture_create_from_vertbuf(vbo); cache->edges_face_overlay_tri_count = vbo->vertex_alloc / 3; @@ -3482,15 +3482,15 @@ static GPUTexture *mesh_batch_cache_get_vert_pos_and_nor_in_order_buf(MeshRender BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI)); if (cache->pos_in_order_tx == NULL) { - Gwn_VertBuf *pos_in_order = mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache); - GWN_vertbuf_use(pos_in_order); /* Upload early for buffer texture creation. */ + GPUVertBuf *pos_in_order = mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache); + GPU_vertbuf_use(pos_in_order); /* Upload early for buffer texture creation. */ cache->pos_in_order_tx = GPU_texture_create_buffer(GPU_R32F, pos_in_order->vbo_id); } return cache->pos_in_order_tx; } -static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUIndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI)); @@ -3498,15 +3498,15 @@ static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rda const int vert_len = mesh_render_data_verts_len_get(rdata); const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); if (rdata->edit_bmesh) { for (int i = 0; i < tri_len; ++i) { const BMLoop **ltri = (const BMLoop **)rdata->edit_bmesh->looptris[i]; if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_indexbuf_add_generic_vert(&elb, BM_elem_index_get(ltri[tri_corner]->v)); + GPU_indexbuf_add_generic_vert(&elb, BM_elem_index_get(ltri[tri_corner]->v)); } } } @@ -3515,18 +3515,18 @@ static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rda for (int i = 0; i < tri_len; ++i) { const MLoopTri *mlt = &rdata->mlooptri[i]; for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_indexbuf_add_generic_vert(&elb, mlt->tri[tri_corner]); + GPU_indexbuf_add_generic_vert(&elb, mlt->tri[tri_corner]); } } } - cache->triangles_in_order = GWN_indexbuf_build(&elb); + cache->triangles_in_order = GPU_indexbuf_build(&elb); } return cache->triangles_in_order; } -static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUIndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI)); @@ -3535,8 +3535,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes const int edge_len = mesh_render_data_edges_len_get(rdata); /* Alloc max (edge_len) and upload only needed range. */ - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); if (rdata->edit_bmesh) { /* No need to support since edit mesh already draw them. @@ -3546,7 +3546,7 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes BMEdge *eed; BM_ITER_MESH(eed, &eiter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_edge_is_wire(eed)) { - GWN_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2)); + GPU_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2)); } } } @@ -3554,17 +3554,17 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes for (int i = 0; i < edge_len; ++i) { const MEdge *medge = &rdata->medge[i]; if (medge->flag & ME_LOOSEEDGE) { - GWN_indexbuf_add_line_verts(&elb, medge->v1, medge->v2); + GPU_indexbuf_add_line_verts(&elb, medge->v1, medge->v2); } } } - cache->ledges_in_order = GWN_indexbuf_build(&elb); + cache->ledges_in_order = GPU_indexbuf_build(&elb); } return cache->ledges_in_order; } -static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( +static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_POLY)); @@ -3576,7 +3576,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( int *mat_tri_len = MEM_callocN(sizeof(*mat_tri_len) * mat_len, __func__); cache->shaded_triangles_in_order = MEM_callocN(sizeof(*cache->shaded_triangles) * mat_len, __func__); - Gwn_IndexBufBuilder *elb = MEM_callocN(sizeof(*elb) * mat_len, __func__); + GPUIndexBufBuilder *elb = MEM_callocN(sizeof(*elb) * mat_len, __func__); /* Note that polygons (not triangles) are used here. * This OK because result is _guaranteed_ to be the same. */ @@ -3602,7 +3602,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( /* Init ELBs. */ for (int i = 0; i < mat_len; ++i) { - GWN_indexbuf_init(&elb[i], GWN_PRIM_TRIS, mat_tri_len[i], tri_len * 3); + GPU_indexbuf_init(&elb[i], GPU_PRIM_TRIS, mat_tri_len[i], tri_len * 3); } /* Populate ELBs. */ @@ -3616,7 +3616,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { const short ma_id = efa->mat_nr < mat_len ? efa->mat_nr : 0; for (int j = 2; j < efa->len; j++) { - GWN_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); + GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); nidx += 3; } } @@ -3627,7 +3627,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( const MPoly *mp = &rdata->mpoly[i]; ; const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0; for (int j = 2; j < mp->totloop; j++) { - GWN_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); + GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); nidx += 3; } } @@ -3635,7 +3635,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( /* Build ELBs. */ for (int i = 0; i < mat_len; ++i) { - cache->shaded_triangles_in_order[i] = GWN_indexbuf_build(&elb[i]); + cache->shaded_triangles_in_order[i] = GPU_indexbuf_build(&elb[i]); } MEM_freeN(mat_tri_len); @@ -3645,30 +3645,30 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( return cache->shaded_triangles_in_order; } -static Gwn_VertBuf *mesh_create_edge_pos_with_sel( +static GPUVertBuf *mesh_create_edge_pos_with_sel( MeshRenderData *rdata, bool use_wire, bool use_select_bool) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP)); BLI_assert(rdata->edit_bmesh == NULL); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint vidx = 0, cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, sel; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.sel = GWN_vertformat_attr_add(&format, "select", GWN_COMP_U8, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.sel = GPU_vertformat_attr_add(&format, "select", GPU_COMP_U8, 1, GPU_FETCH_INT); } const int edge_len = mesh_render_data_edges_len_get(rdata); - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = edge_len * 2; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (use_select_bool) { mesh_render_data_ensure_edge_select_bool(rdata, use_wire); @@ -3689,23 +3689,23 @@ static Gwn_VertBuf *mesh_create_edge_pos_with_sel( continue; } - GWN_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel); - GWN_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel); + GPU_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel); + GPU_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v1].co); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v2].co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v1].co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v2].co); } vbo_len_used = vidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_IndexBuf *mesh_create_tri_overlay_weight_faces( +static GPUIndexBuf *mesh_create_tri_overlay_weight_faces( MeshRenderData *rdata) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI)); @@ -3714,57 +3714,57 @@ static Gwn_IndexBuf *mesh_create_tri_overlay_weight_faces( const int vert_len = mesh_render_data_verts_len_get(rdata); const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); for (int i = 0; i < tri_len; ++i) { const MLoopTri *mlt = &rdata->mlooptri[i]; if (!(rdata->mpoly[mlt->poly].flag & (ME_FACE_SEL | ME_HIDE))) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_indexbuf_add_generic_vert(&elb, rdata->mloop[mlt->tri[tri_corner]].v); + GPU_indexbuf_add_generic_vert(&elb, rdata->mloop[mlt->tri[tri_corner]].v); } } } - return GWN_indexbuf_build(&elb); + return GPU_indexbuf_build(&elb); } } /** * Non-edit mode vertices (only used for weight-paint mode). */ -static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data( +static GPUVertBuf *mesh_create_vert_pos_with_overlay_data( MeshRenderData *rdata) { BLI_assert(rdata->types & (MR_DATATYPE_VERT)); BLI_assert(rdata->edit_bmesh == NULL); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint data; } attr_id; if (format.attr_len == 0) { - attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_I8, 1, GWN_FETCH_INT); + attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_I8, 1, GPU_FETCH_INT); } const int vert_len = mesh_render_data_verts_len_get(rdata); - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = vert_len; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); for (int i = 0; i < vert_len; i++) { const MVert *mv = &rdata->mvert[i]; const char data = mv->flag & (SELECT | ME_HIDE); - GWN_vertbuf_attr_set(vbo, attr_id.data, cidx++, &data); + GPU_vertbuf_attr_set(vbo, attr_id.data, cidx++, &data); } vbo_len_used = cidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; @@ -3778,7 +3778,7 @@ static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data( /** \name Public API * \{ */ -Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_all_edges(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3787,8 +3787,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->all_edges = GWN_batch_create( - GWN_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + cache->all_edges = GPU_batch_create( + GPU_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), mesh_batch_cache_get_edges_in_order(rdata, cache)); mesh_render_data_free(rdata); @@ -3797,7 +3797,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me) return cache->all_edges; } -Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3806,8 +3806,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->all_triangles = GWN_batch_create( - GWN_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + cache->all_triangles = GPU_batch_create( + GPU_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), mesh_batch_cache_get_triangles_in_order(rdata, cache)); mesh_render_data_free(rdata); @@ -3816,7 +3816,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) return cache->all_triangles; } -Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3824,8 +3824,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->triangles_with_normals = GWN_batch_create( - GWN_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); + cache->triangles_with_normals = GPU_batch_create( + GPU_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); mesh_render_data_free(rdata); } @@ -3833,7 +3833,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) return cache->triangles_with_normals; } -Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3841,8 +3841,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->ledges_with_normals = GWN_batch_create( - GWN_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + cache->ledges_with_normals = GPU_batch_create( + GPU_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), mesh_batch_cache_get_loose_edges(rdata, cache)); mesh_render_data_free(rdata); @@ -3851,7 +3851,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me) return cache->ledges_with_normals; } -Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, int defgroup) +GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, int defgroup) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3861,14 +3861,14 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_DVERT; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->triangles_with_weights = GWN_batch_create_ex( - GWN_PRIM_TRIS, mesh_create_tri_weights(rdata, use_hide, defgroup), NULL, GWN_BATCH_OWNS_VBO); + cache->triangles_with_weights = GPU_batch_create_ex( + GPU_PRIM_TRIS, mesh_create_tri_weights(rdata, use_hide, defgroup), NULL, GPU_BATCH_OWNS_VBO); - Gwn_VertBuf *vbo_tris = use_hide ? + GPUVertBuf *vbo_tris = use_hide ? mesh_create_tri_pos_and_normals_visible_only(rdata) : mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - GWN_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide); + GPU_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide); mesh_render_data_free(rdata); } @@ -3876,7 +3876,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, return cache->triangles_with_weights; } -Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3886,13 +3886,13 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->triangles_with_vert_colors = GWN_batch_create_ex( - GWN_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GWN_BATCH_OWNS_VBO); + cache->triangles_with_vert_colors = GPU_batch_create_ex( + GPU_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GPU_BATCH_OWNS_VBO); - Gwn_VertBuf *vbo_tris = use_hide ? + GPUVertBuf *vbo_tris = use_hide ? mesh_create_tri_pos_and_normals_visible_only(rdata) : mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - GWN_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide); + GPU_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide); mesh_render_data_free(rdata); } @@ -3901,14 +3901,14 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh } -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id( +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id( struct Mesh *me, bool use_hide, uint select_id_offset) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->triangles_with_select_id_offset != select_id_offset) { cache->triangles_with_select_id_offset = select_id_offset; - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); } if (cache->triangles_with_select_id == NULL) { @@ -3916,13 +3916,13 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id( MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->triangles_with_select_id = GWN_batch_create_ex( - GWN_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GWN_BATCH_OWNS_VBO); + cache->triangles_with_select_id = GPU_batch_create_ex( + GPU_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GPU_BATCH_OWNS_VBO); - Gwn_VertBuf *vbo_tris = use_hide ? + GPUVertBuf *vbo_tris = use_hide ? mesh_create_tri_pos_and_normals_visible_only(rdata) : mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - GWN_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide); + GPU_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide); mesh_render_data_free(rdata); } @@ -3934,7 +3934,7 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id( * Same as #DRW_mesh_batch_cache_get_triangles_with_select_id * without the ID's, use to mask out geometry, eg - dont select face-dots behind other faces. */ -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide) +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->triangles_with_select_mask == NULL) { @@ -3942,12 +3942,12 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mes MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - Gwn_VertBuf *vbo_tris = use_hide ? + GPUVertBuf *vbo_tris = use_hide ? mesh_create_tri_pos_and_normals_visible_only(rdata) : mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - cache->triangles_with_select_mask = GWN_batch_create_ex( - GWN_PRIM_TRIS, vbo_tris, NULL, use_hide ? GWN_BATCH_OWNS_VBO : 0); + cache->triangles_with_select_mask = GPU_batch_create_ex( + GPU_PRIM_TRIS, vbo_tris, NULL, use_hide ? GPU_BATCH_OWNS_VBO : 0); mesh_render_data_free(rdata); } @@ -3955,7 +3955,7 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mes return cache->triangles_with_select_mask; } -Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3963,8 +3963,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->points_with_normals = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); + cache->points_with_normals = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); mesh_render_data_free(rdata); } @@ -3972,7 +3972,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) return cache->points_with_normals; } -Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_all_verts(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3980,8 +3980,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me) /* create batch from DM */ MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT); - cache->all_verts = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL); + cache->all_verts = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL); mesh_render_data_free(rdata); } @@ -3989,21 +3989,21 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me) return cache->all_verts; } -Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->fancy_edges == NULL) { /* create batch from DM */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, n1, n2; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.n1 = GPU_vertformat_attr_add(&format, "N1", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + attr_id.n2 = GPU_vertformat_attr_add(&format, "N2", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); MeshRenderData *rdata = mesh_render_data_create( me, MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_POLY); @@ -4012,7 +4012,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) const int vbo_len_capacity = edge_len * 2; /* these are PRIM_LINE verts, not mesh verts */ int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); for (int i = 0; i < edge_len; ++i) { float *vcos1, *vcos2; float *pnor1 = NULL, *pnor2 = NULL; @@ -4020,33 +4020,33 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) if (mesh_render_data_edge_vcos_manifold_pnors(rdata, i, &vcos1, &vcos2, &pnor1, &pnor2, &is_manifold)) { - Gwn_PackedNormal n1value = { .x = 0, .y = 0, .z = +511 }; - Gwn_PackedNormal n2value = { .x = 0, .y = 0, .z = -511 }; + GPUPackedNormal n1value = { .x = 0, .y = 0, .z = +511 }; + GPUPackedNormal n2value = { .x = 0, .y = 0, .z = -511 }; if (is_manifold) { - n1value = GWN_normal_convert_i10_v3(pnor1); - n2value = GWN_normal_convert_i10_v3(pnor2); + n1value = GPU_normal_convert_i10_v3(pnor1); + n2value = GPU_normal_convert_i10_v3(pnor2); } - const Gwn_PackedNormal *n1 = &n1value; - const Gwn_PackedNormal *n2 = &n2value; + const GPUPackedNormal *n1 = &n1value; + const GPUPackedNormal *n2 = &n2value; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1); - GWN_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1); - GWN_vertbuf_attr_set(vbo, attr_id.n2, 2 * i, n2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1); + GPU_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1); + GPU_vertbuf_attr_set(vbo, attr_id.n2, 2 * i, n2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * i + 1, vcos2); - GWN_vertbuf_attr_set(vbo, attr_id.n1, 2 * i + 1, n1); - GWN_vertbuf_attr_set(vbo, attr_id.n2, 2 * i + 1, n2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * i + 1, vcos2); + GPU_vertbuf_attr_set(vbo, attr_id.n1, 2 * i + 1, n1); + GPU_vertbuf_attr_set(vbo, attr_id.n2, 2 * i + 1, n2); vbo_len_used += 2; } } if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } - cache->fancy_edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->fancy_edges = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); mesh_render_data_free(rdata); } @@ -4054,7 +4054,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) return cache->fancy_edges; } -Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold) +GPUBatch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4063,8 +4063,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold MeshRenderData *rdata = mesh_render_data_create(me, options); - cache->edge_detection = GWN_batch_create_ex( - GWN_PRIM_LINES_ADJ, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + cache->edge_detection = GPU_batch_create_ex( + GPU_PRIM_LINES_ADJ, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), mesh_batch_cache_get_edges_adjacency(rdata, cache), 0); mesh_render_data_free(rdata); @@ -4111,42 +4111,42 @@ static void mesh_batch_cache_create_overlay_batches(Mesh *me) MeshRenderData *rdata = mesh_render_data_create(me, options); if (cache->overlay_triangles == NULL) { - cache->overlay_triangles = GWN_batch_create( - GWN_PRIM_TRIS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_nor(rdata, cache)); - GWN_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_data(rdata, cache)); + cache->overlay_triangles = GPU_batch_create( + GPU_PRIM_TRIS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_nor(rdata, cache)); + GPU_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_data(rdata, cache)); } if (cache->overlay_loose_edges == NULL) { - cache->overlay_loose_edges = GWN_batch_create( - GWN_PRIM_LINES, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_nor(rdata, cache)); - GWN_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_data(rdata, cache)); + cache->overlay_loose_edges = GPU_batch_create( + GPU_PRIM_LINES, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_nor(rdata, cache)); + GPU_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_data(rdata, cache)); } if (cache->overlay_loose_verts == NULL) { - cache->overlay_loose_verts = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_edit_lvert_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_nor(rdata, cache)); - GWN_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_data(rdata, cache)); + cache->overlay_loose_verts = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_edit_lvert_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_nor(rdata, cache)); + GPU_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_data(rdata, cache)); } if (cache->overlay_triangles_nor == NULL) { - cache->overlay_triangles_nor = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_triangles_nor, mesh_batch_cache_get_edit_tri_nor(rdata, cache)); + cache->overlay_triangles_nor = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_triangles_nor, mesh_batch_cache_get_edit_tri_nor(rdata, cache)); } if (cache->overlay_loose_edges_nor == NULL) { - cache->overlay_loose_edges_nor = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_loose_edges_nor, mesh_batch_cache_get_edit_ledge_nor(rdata, cache)); + cache->overlay_loose_edges_nor = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_loose_edges_nor, mesh_batch_cache_get_edit_ledge_nor(rdata, cache)); } mesh_render_data_free(rdata); } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4157,7 +4157,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me) return cache->overlay_triangles; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4168,7 +4168,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me) return cache->overlay_loose_edges; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4179,7 +4179,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me) return cache->overlay_loose_verts; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4190,7 +4190,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me) return cache->overlay_triangles_nor; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4201,15 +4201,15 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me) return cache->overlay_loose_edges_nor; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->overlay_facedots == NULL) { MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY); - cache->overlay_facedots = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL); + cache->overlay_facedots = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL); mesh_render_data_free(rdata); } @@ -4217,13 +4217,13 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me) return cache->overlay_facedots; } -Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint select_id_offset) +GPUBatch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint select_id_offset) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->facedot_with_select_id_offset != select_id_offset) { cache->facedot_with_select_id_offset = select_id_offset; - GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id); } if (cache->facedot_with_select_id == NULL) { @@ -4231,10 +4231,10 @@ Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint selec /* We only want the 'pos', not the normals or flag. * Use since this is almost certainly already created. */ - cache->facedot_with_select_id = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL); + cache->facedot_with_select_id = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL); - GWN_batch_vertbuf_add_ex( + GPU_batch_vertbuf_add_ex( cache->facedot_with_select_id, mesh_create_facedot_select_id(rdata, select_id_offset), true); @@ -4244,22 +4244,22 @@ Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint selec return cache->facedot_with_select_id; } -Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_id_offset) +GPUBatch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_id_offset) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->edges_with_select_id_offset != select_id_offset) { cache->edges_with_select_id_offset = select_id_offset; - GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id); } if (cache->edges_with_select_id == NULL) { MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_EDGE); - cache->edges_with_select_id = GWN_batch_create( - GWN_PRIM_LINES, mesh_batch_cache_get_edges_visible(rdata, cache), NULL); + cache->edges_with_select_id = GPU_batch_create( + GPU_PRIM_LINES, mesh_batch_cache_get_edges_visible(rdata, cache), NULL); - GWN_batch_vertbuf_add_ex( + GPU_batch_vertbuf_add_ex( cache->edges_with_select_id, mesh_create_edges_select_id(rdata, select_id_offset), true); @@ -4269,22 +4269,22 @@ Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_i return cache->edges_with_select_id; } -Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id_offset) +GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id_offset) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->verts_with_select_id_offset != select_id_offset) { cache->verts_with_select_id_offset = select_id_offset; - GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id); } if (cache->verts_with_select_id == NULL) { MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT); - cache->verts_with_select_id = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_verts_visible(rdata, cache), NULL); + cache->verts_with_select_id = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_verts_visible(rdata, cache), NULL); - GWN_batch_vertbuf_add_ex( + GPU_batch_vertbuf_add_ex( cache->verts_with_select_id, mesh_create_verts_select_id(rdata, select_id_offset), true); @@ -4294,7 +4294,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_i return cache->verts_with_select_id; } -Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( +GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { @@ -4311,16 +4311,16 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( cache->shaded_triangles = MEM_callocN(sizeof(*cache->shaded_triangles) * mat_len, __func__); - Gwn_IndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache); + GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache); - Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - Gwn_VertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache); + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache); for (int i = 0; i < mat_len; ++i) { - cache->shaded_triangles[i] = GWN_batch_create( - GWN_PRIM_TRIS, vbo, el[i]); + cache->shaded_triangles[i] = GPU_batch_create( + GPU_PRIM_TRIS, vbo, el[i]); if (vbo_shading) { - GWN_batch_vertbuf_add(cache->shaded_triangles[i], vbo_shading); + GPU_batch_vertbuf_add(cache->shaded_triangles[i], vbo_shading); } } @@ -4336,7 +4336,7 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( return cache->shaded_triangles; } -Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) +GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4350,15 +4350,15 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) cache->texpaint_triangles = MEM_callocN(sizeof(*cache->texpaint_triangles) * mat_len, __func__); - Gwn_IndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache); + GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache); - Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); for (int i = 0; i < mat_len; ++i) { - cache->texpaint_triangles[i] = GWN_batch_create( - GWN_PRIM_TRIS, vbo, el[i]); - Gwn_VertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache); + cache->texpaint_triangles[i] = GPU_batch_create( + GPU_PRIM_TRIS, vbo, el[i]); + GPUVertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache); if (vbo_uv) { - GWN_batch_vertbuf_add(cache->texpaint_triangles[i], vbo_uv); + GPU_batch_vertbuf_add(cache->texpaint_triangles[i], vbo_uv); } } mesh_render_data_free(rdata); @@ -4367,7 +4367,7 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) return cache->texpaint_triangles; } -Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4377,20 +4377,20 @@ Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me) MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOPUV; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - cache->texpaint_triangles_single = GWN_batch_create( - GWN_PRIM_TRIS, vbo, NULL); - Gwn_VertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache); + cache->texpaint_triangles_single = GPU_batch_create( + GPU_PRIM_TRIS, vbo, NULL); + GPUVertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache); if (vbo_uv) { - GWN_batch_vertbuf_add(cache->texpaint_triangles_single, vbo_uv); + GPU_batch_vertbuf_add(cache->texpaint_triangles_single, vbo_uv); } mesh_render_data_free(rdata); } return cache->texpaint_triangles_single; } -Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel) +GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4399,8 +4399,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->overlay_paint_edges = GWN_batch_create_ex( - GWN_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GWN_BATCH_OWNS_VBO); + cache->overlay_paint_edges = GPU_batch_create_ex( + GPU_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GPU_BATCH_OWNS_VBO); mesh_render_data_free(rdata); } @@ -4408,7 +4408,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire return cache->overlay_paint_edges; } -Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4417,9 +4417,9 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->overlay_weight_faces = GWN_batch_create_ex( - GWN_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), - mesh_create_tri_overlay_weight_faces(rdata), GWN_BATCH_OWNS_INDEX); + cache->overlay_weight_faces = GPU_batch_create_ex( + GPU_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + mesh_create_tri_overlay_weight_faces(rdata), GPU_BATCH_OWNS_INDEX); mesh_render_data_free(rdata); } @@ -4427,7 +4427,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me) return cache->overlay_weight_faces; } -Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4435,10 +4435,10 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me) /* create batch from Mesh */ MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT); - cache->overlay_weight_verts = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL); + cache->overlay_weight_verts = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL); - GWN_batch_vertbuf_add_ex( + GPU_batch_vertbuf_add_ex( cache->overlay_weight_verts, mesh_create_vert_pos_with_overlay_data(rdata), true); mesh_render_data_free(rdata); @@ -4458,7 +4458,7 @@ void DRW_mesh_cache_sculpt_coords_ensure(Mesh *me) /* XXX Force update of all the batches that contains the pos_with_normals buffer. * TODO(fclem): Ideally, Gawain should provide a way to update a buffer without destroying it. */ mesh_batch_cache_clear_selective(me, cache->pos_with_normals); - GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); + GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); } cache->is_sculpt_points_tag = false; } diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c index 24930921bee..375b0ba6bb2 100644 --- a/source/blender/draw/intern/draw_cache_impl_metaball.c +++ b/source/blender/draw/intern/draw_cache_impl_metaball.c @@ -45,18 +45,18 @@ static void metaball_batch_cache_clear(MetaBall *mb); /* ---------------------------------------------------------------------- */ -/* MetaBall Gwn_Batch Cache */ +/* MetaBall GPUBatch Cache */ typedef struct MetaBallBatchCache { - Gwn_Batch *batch; - Gwn_Batch **shaded_triangles; + GPUBatch *batch; + GPUBatch **shaded_triangles; int mat_len; /* settings to determine if cache is invalid */ bool is_dirty; } MetaBallBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ static bool metaball_batch_cache_valid(MetaBall *mb) { @@ -113,7 +113,7 @@ static void metaball_batch_cache_clear(MetaBall *mb) return; } - GWN_BATCH_DISCARD_SAFE(cache->batch); + GPU_BATCH_DISCARD_SAFE(cache->batch); /* Note: shaded_triangles[0] is already freed by cache->batch */ MEM_SAFE_FREE(cache->shaded_triangles); cache->mat_len = 0; @@ -130,7 +130,7 @@ void DRW_mball_batch_cache_free(MetaBall *mb) /** \name Public Object/MetaBall API * \{ */ -Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob) +GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob) { if (!BKE_mball_is_basis(ob)) { return NULL; @@ -141,17 +141,17 @@ Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob) if (cache->batch == NULL) { ListBase *lb = &ob->curve_cache->disp; - cache->batch = GWN_batch_create_ex( - GWN_PRIM_TRIS, + cache->batch = GPU_batch_create_ex( + GPU_PRIM_TRIS, DRW_displist_vertbuf_calc_pos_with_normals(lb), DRW_displist_indexbuf_calc_triangles_in_order(lb), - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); } return cache->batch; } -Gwn_Batch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len) +GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len) { if (!BKE_mball_is_basis(ob)) { return NULL; diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index df67d34d566..b56396261d3 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -61,11 +61,11 @@ static void particle_batch_cache_clear(ParticleSystem *psys); /* ---------------------------------------------------------------------- */ -/* Particle Gwn_Batch Cache */ +/* Particle GPUBatch Cache */ typedef struct ParticlePointCache { - Gwn_VertBuf *pos; - Gwn_Batch *points; + GPUVertBuf *pos; + GPUBatch *points; int elems_len; int point_len; } ParticlePointCache; @@ -80,19 +80,19 @@ typedef struct ParticleBatchCache { /* Control points when in edit mode. */ ParticleHairCache edit_hair; - Gwn_VertBuf *edit_inner_pos; - Gwn_Batch *edit_inner_points; + GPUVertBuf *edit_inner_pos; + GPUBatch *edit_inner_points; int edit_inner_point_len; - Gwn_VertBuf *edit_tip_pos; - Gwn_Batch *edit_tip_points; + GPUVertBuf *edit_tip_pos; + GPUBatch *edit_tip_points; int edit_tip_point_len; /* Settings to determine if cache is invalid. */ bool is_dirty; } ParticleBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ typedef struct HairAttributeID { uint pos; @@ -158,39 +158,39 @@ void DRW_particle_batch_cache_dirty(ParticleSystem *psys, int mode) static void particle_batch_cache_clear_point(ParticlePointCache *point_cache) { - GWN_BATCH_DISCARD_SAFE(point_cache->points); - GWN_VERTBUF_DISCARD_SAFE(point_cache->pos); + GPU_BATCH_DISCARD_SAFE(point_cache->points); + GPU_VERTBUF_DISCARD_SAFE(point_cache->pos); } static void particle_batch_cache_clear_hair(ParticleHairCache *hair_cache) { /* TODO more granular update tagging. */ - GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_point_buf); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_point_buf); DRW_TEXTURE_FREE_SAFE(hair_cache->point_tex); - GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_strand_buf); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_strand_buf); DRW_TEXTURE_FREE_SAFE(hair_cache->strand_tex); for (int i = 0; i < MAX_MTFACE; ++i) { - GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_uv_buf[i]); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_uv_buf[i]); DRW_TEXTURE_FREE_SAFE(hair_cache->uv_tex[i]); } for (int i = 0; i < MAX_MCOL; ++i) { - GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_col_buf[i]); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_col_buf[i]); DRW_TEXTURE_FREE_SAFE(hair_cache->col_tex[i]); } for (int i = 0; i < MAX_HAIR_SUBDIV; ++i) { - GWN_VERTBUF_DISCARD_SAFE(hair_cache->final[i].proc_buf); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->final[i].proc_buf); DRW_TEXTURE_FREE_SAFE(hair_cache->final[i].proc_tex); for (int j = 0; j < MAX_THICKRES; ++j) { - GWN_BATCH_DISCARD_SAFE(hair_cache->final[i].proc_hairs[j]); + GPU_BATCH_DISCARD_SAFE(hair_cache->final[i].proc_hairs[j]); } } /* "Normal" legacy hairs */ - GWN_BATCH_DISCARD_SAFE(hair_cache->hairs); - GWN_VERTBUF_DISCARD_SAFE(hair_cache->pos); - GWN_INDEXBUF_DISCARD_SAFE(hair_cache->indices); + GPU_BATCH_DISCARD_SAFE(hair_cache->hairs); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->pos); + GPU_INDEXBUF_DISCARD_SAFE(hair_cache->indices); } static void particle_batch_cache_clear(ParticleSystem *psys) @@ -205,10 +205,10 @@ static void particle_batch_cache_clear(ParticleSystem *psys) particle_batch_cache_clear_hair(&cache->edit_hair); - GWN_BATCH_DISCARD_SAFE(cache->edit_inner_points); - GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); - GWN_BATCH_DISCARD_SAFE(cache->edit_tip_points); - GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); + GPU_BATCH_DISCARD_SAFE(cache->edit_inner_points); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); + GPU_BATCH_DISCARD_SAFE(cache->edit_tip_points); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); } void DRW_particle_batch_cache_free(ParticleSystem *psys) @@ -514,7 +514,7 @@ static int particle_batch_cache_fill_segments( uint *col_id, float (***r_parent_uvs)[2], MCol ***r_parent_mcol, - Gwn_IndexBufBuilder *elb, + GPUIndexBufBuilder *elb, HairAttributeID *attr_id, ParticleHairCache *hair_cache) { @@ -561,12 +561,12 @@ static int particle_batch_cache_fill_segments( else { sub_v3_v3v3(tangent, path[j + 1].co, path[j - 1].co); } - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[j].co); - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent); - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &i); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[j].co); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &i); if (psmd != NULL) { for (int k = 0; k < num_uv_layers; k++) { - GWN_vertbuf_attr_set( + GPU_vertbuf_attr_set( hair_cache->pos, uv_id[k], curr_point, (is_simple && is_child) ? (*r_parent_uvs)[psys->child[i].parent][k] : uv[k]); @@ -578,22 +578,22 @@ static int particle_batch_cache_fill_segments( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], scol); - GWN_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol); + GPU_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol); } } - GWN_indexbuf_add_generic_vert(elb, curr_point); + GPU_indexbuf_add_generic_vert(elb, curr_point); curr_point++; } sub_v3_v3v3(tangent, path[path->segments].co, path[path->segments - 1].co); int global_index = i + global_offset; - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[path->segments].co); - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent); - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &global_index); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[path->segments].co); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &global_index); if (psmd != NULL) { for (int k = 0; k < num_uv_layers; k++) { - GWN_vertbuf_attr_set( + GPU_vertbuf_attr_set( hair_cache->pos, uv_id[k], curr_point, (is_simple && is_child) ? (*r_parent_uvs)[psys->child[i].parent][k] : uv[k]); @@ -605,7 +605,7 @@ static int particle_batch_cache_fill_segments( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], scol); - GWN_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol); + GPU_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol); } if (!is_simple) { MEM_freeN(uv); @@ -613,8 +613,8 @@ static int particle_batch_cache_fill_segments( } } /* Finish the segment and add restart primitive. */ - GWN_indexbuf_add_generic_vert(elb, curr_point); - GWN_indexbuf_add_primitive_restart(elb); + GPU_indexbuf_add_generic_vert(elb, curr_point); + GPU_indexbuf_add_primitive_restart(elb); curr_point++; } return curr_point; @@ -623,7 +623,7 @@ static int particle_batch_cache_fill_segments( static void particle_batch_cache_fill_segments_proc_pos( ParticleCacheKey **path_cache, const int num_path_keys, - Gwn_VertBufRaw *attr_step) + GPUVertBufRaw *attr_step) { for (int i = 0; i < num_path_keys; i++) { ParticleCacheKey *path = path_cache[i]; @@ -633,7 +633,7 @@ static void particle_batch_cache_fill_segments_proc_pos( float total_len = 0.0f; float *co_prev = NULL, *seg_data_first; for (int j = 0; j <= path->segments; j++) { - float *seg_data = (float *)GWN_vertbuf_raw_step(attr_step); + float *seg_data = (float *)GPU_vertbuf_raw_step(attr_step); copy_v3_v3(seg_data, path[j].co); if (co_prev) { total_len += len_v3v3(co_prev, path[j].co); @@ -658,7 +658,7 @@ static int particle_batch_cache_fill_segments_indices( const int start_index, const int num_path_keys, const int res, - Gwn_IndexBufBuilder *elb) + GPUIndexBufBuilder *elb) { int curr_point = start_index; for (int i = 0; i < num_path_keys; i++) { @@ -667,9 +667,9 @@ static int particle_batch_cache_fill_segments_indices( continue; } for (int k = 0; k < res; k++) { - GWN_indexbuf_add_generic_vert(elb, curr_point++); + GPU_indexbuf_add_generic_vert(elb, curr_point++); } - GWN_indexbuf_add_primitive_restart(elb); + GPU_indexbuf_add_primitive_restart(elb); } return curr_point; } @@ -681,9 +681,9 @@ static int particle_batch_cache_fill_strands_data( const ParticleSource particle_source, const int start_index, const int num_path_keys, - Gwn_VertBufRaw *data_step, - float (***r_parent_uvs)[2], Gwn_VertBufRaw *uv_step, MTFace **mtfaces, int num_uv_layers, - MCol ***r_parent_mcol, Gwn_VertBufRaw *col_step, MCol **mcols, int num_col_layers) + GPUVertBufRaw *data_step, + float (***r_parent_uvs)[2], GPUVertBufRaw *uv_step, MTFace **mtfaces, int num_uv_layers, + MCol ***r_parent_mcol, GPUVertBufRaw *col_step, MCol **mcols, int num_col_layers) { const bool is_simple = (psys->part->childtype == PART_CHILD_PARTICLES); const bool is_child = (particle_source == PARTICLE_SOURCE_CHILDREN); @@ -705,7 +705,7 @@ static int particle_batch_cache_fill_strands_data( continue; } - uint *seg_data = (uint *)GWN_vertbuf_raw_step(data_step); + uint *seg_data = (uint *)GPU_vertbuf_raw_step(data_step); *seg_data = (curr_point & 0xFFFFFF) | (path->segments << 24); curr_point += path->segments + 1; @@ -730,11 +730,11 @@ static int particle_batch_cache_fill_strands_data( *r_parent_mcol, &mcol); for (int k = 0; k < num_uv_layers; k++) { - float *t_uv = (float *)GWN_vertbuf_raw_step(uv_step + k); + float *t_uv = (float *)GPU_vertbuf_raw_step(uv_step + k); copy_v2_v2(t_uv, uv[k]); } for (int k = 0; k < num_col_layers; k++) { - ushort *scol = (ushort *)GWN_vertbuf_raw_step(col_step + k); + ushort *scol = (ushort *)GPU_vertbuf_raw_step(col_step + k); particle_pack_mcol( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], @@ -754,17 +754,17 @@ static void particle_batch_cache_ensure_procedural_final_points( int subdiv) { /* Same format as point_tex. */ - Gwn_VertFormat format = { 0 }; - GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat format = { 0 }; + GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - cache->final[subdiv].proc_buf = GWN_vertbuf_create_with_format(&format); + cache->final[subdiv].proc_buf = GPU_vertbuf_create_with_format(&format); /* Create a destination buffer for the tranform feedback. Sized appropriately */ /* Thoses are points! not line segments. */ - GWN_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_len); + GPU_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_len); /* Create vbo immediatly to bind to texture buffer. */ - GWN_vertbuf_use(cache->final[subdiv].proc_buf); + GPU_vertbuf_use(cache->final[subdiv].proc_buf); cache->final[subdiv].proc_tex = GPU_texture_create_from_vertbuf(cache->final[subdiv].proc_buf); } @@ -791,37 +791,37 @@ static void particle_batch_cache_ensure_procedural_strand_data( } } - Gwn_VertBufRaw data_step; - Gwn_VertBufRaw uv_step[MAX_MTFACE]; - Gwn_VertBufRaw col_step[MAX_MCOL]; + GPUVertBufRaw data_step; + GPUVertBufRaw uv_step[MAX_MTFACE]; + GPUVertBufRaw col_step[MAX_MCOL]; MTFace *mtfaces[MAX_MTFACE] = {NULL}; MCol *mcols[MAX_MCOL] = {NULL}; float (**parent_uvs)[2] = NULL; MCol **parent_mcol = NULL; - Gwn_VertFormat format_data = {0}; - uint data_id = GWN_vertformat_attr_add(&format_data, "data", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat format_data = {0}; + uint data_id = GPU_vertformat_attr_add(&format_data, "data", GPU_COMP_U32, 1, GPU_FETCH_INT); - Gwn_VertFormat format_uv = {0}; - uint uv_id = GWN_vertformat_attr_add(&format_uv, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat format_uv = {0}; + uint uv_id = GPU_vertformat_attr_add(&format_uv, "uv", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - Gwn_VertFormat format_col = {0}; - uint col_id = GWN_vertformat_attr_add(&format_col, "col", GWN_COMP_U16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat format_col = {0}; + uint col_id = GPU_vertformat_attr_add(&format_col, "col", GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); memset(cache->uv_layer_names, 0, sizeof(cache->uv_layer_names)); memset(cache->col_layer_names, 0, sizeof(cache->col_layer_names)); /* Strand Data */ - cache->proc_strand_buf = GWN_vertbuf_create_with_format(&format_data); - GWN_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len); - GWN_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step); + cache->proc_strand_buf = GPU_vertbuf_create_with_format(&format_data); + GPU_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len); + GPU_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step); /* UV layers */ for (int i = 0; i < cache->num_uv_layers; i++) { - cache->proc_uv_buf[i] = GWN_vertbuf_create_with_format(&format_uv); - GWN_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); - GWN_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); + cache->proc_uv_buf[i] = GPU_vertbuf_create_with_format(&format_uv); + GPU_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); + GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); uint hash = BLI_ghashutil_strhash_p(name); @@ -835,9 +835,9 @@ static void particle_batch_cache_ensure_procedural_strand_data( } /* Vertex colors */ for (int i = 0; i < cache->num_col_layers; i++) { - cache->proc_col_buf[i] = GWN_vertbuf_create_with_format(&format_col); - GWN_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); - GWN_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); + cache->proc_col_buf[i] = GPU_vertbuf_create_with_format(&format_col); + GPU_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); + GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); uint hash = BLI_ghashutil_strhash_p(name); @@ -914,15 +914,15 @@ static void particle_batch_cache_ensure_procedural_strand_data( } /* Create vbo immediatly to bind to texture buffer. */ - GWN_vertbuf_use(cache->proc_strand_buf); + GPU_vertbuf_use(cache->proc_strand_buf); cache->strand_tex = GPU_texture_create_from_vertbuf(cache->proc_strand_buf); for (int i = 0; i < cache->num_uv_layers; i++) { - GWN_vertbuf_use(cache->proc_uv_buf[i]); + GPU_vertbuf_use(cache->proc_uv_buf[i]); cache->uv_tex[i] = GPU_texture_create_from_vertbuf(cache->proc_uv_buf[i]); } for (int i = 0; i < cache->num_col_layers; i++) { - GWN_vertbuf_use(cache->proc_col_buf[i]); + GPU_vertbuf_use(cache->proc_col_buf[i]); cache->col_tex[i] = GPU_texture_create_from_vertbuf(cache->proc_col_buf[i]); } } @@ -943,19 +943,19 @@ static void particle_batch_cache_ensure_procedural_indices( int verts_per_hair = cache->final[subdiv].strands_res * thickness_res; /* +1 for primitive restart */ int element_count = (verts_per_hair + 1) * cache->strands_len; - Gwn_PrimType prim_type = (thickness_res == 1) ? GWN_PRIM_LINE_STRIP : GWN_PRIM_TRI_STRIP; + GPUPrimType prim_type = (thickness_res == 1) ? GPU_PRIM_LINE_STRIP : GPU_PRIM_TRI_STRIP; - static Gwn_VertFormat format = { 0 }; - GWN_vertformat_clear(&format); + static GPUVertFormat format = { 0 }; + GPU_vertformat_clear(&format); /* initialize vertex format */ - GWN_vertformat_attr_add(&format, "dummy", GWN_COMP_U8, 1, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 1); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, prim_type, element_count, element_count, true); + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex(&elb, prim_type, element_count, element_count, true); if (edit != NULL && edit->pathcache != NULL) { particle_batch_cache_fill_segments_indices( @@ -976,11 +976,11 @@ static void particle_batch_cache_ensure_procedural_indices( } } - cache->final[subdiv].proc_hairs[thickness_res - 1] = GWN_batch_create_ex( + cache->final[subdiv].proc_hairs[thickness_res - 1] = GPU_batch_create_ex( prim_type, vbo, - GWN_indexbuf_build(&elb), - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + GPU_indexbuf_build(&elb), + GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); } static void particle_batch_cache_ensure_procedural_pos( @@ -993,14 +993,14 @@ static void particle_batch_cache_ensure_procedural_pos( } /* initialize vertex format */ - Gwn_VertFormat format = {0}; - uint pos_id = GWN_vertformat_attr_add(&format, "posTime", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat format = {0}; + uint pos_id = GPU_vertformat_attr_add(&format, "posTime", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - cache->proc_point_buf = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len); + cache->proc_point_buf = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step); if (edit != NULL && edit->pathcache != NULL) { particle_batch_cache_fill_segments_proc_pos( @@ -1027,7 +1027,7 @@ static void particle_batch_cache_ensure_procedural_pos( } /* Create vbo immediatly to bind to texture buffer. */ - GWN_vertbuf_use(cache->proc_point_buf); + GPU_vertbuf_use(cache->proc_point_buf); cache->point_tex = GPU_texture_create_from_vertbuf(cache->proc_point_buf); } @@ -1045,10 +1045,10 @@ static void particle_batch_cache_ensure_pos_and_seg( int curr_point = 0; ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; - GWN_VERTBUF_DISCARD_SAFE(hair_cache->pos); - GWN_INDEXBUF_DISCARD_SAFE(hair_cache->indices); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->pos); + GPU_INDEXBUF_DISCARD_SAFE(hair_cache->indices); - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; HairAttributeID attr_id; uint *uv_id = NULL; uint *col_id = NULL; @@ -1072,12 +1072,12 @@ static void particle_batch_cache_ensure_pos_and_seg( } } - GWN_vertformat_clear(&format); + GPU_vertformat_clear(&format); /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.tan = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.ind = GWN_vertformat_attr_add(&format, "ind", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.tan = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.ind = GPU_vertformat_attr_add(&format, "ind", GPU_COMP_I32, 1, GPU_FETCH_INT); if (psmd) { uv_id = MEM_mallocN(sizeof(*uv_id) * num_uv_layers, "UV attrib format"); @@ -1088,10 +1088,10 @@ static void particle_batch_cache_ensure_pos_and_seg( char uuid[32]; BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(name)); - uv_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (i == active_uv) { - GWN_vertformat_alias_add(&format, "u"); + GPU_vertformat_alias_add(&format, "u"); } } @@ -1100,21 +1100,21 @@ static void particle_batch_cache_ensure_pos_and_seg( char uuid[32]; BLI_snprintf(uuid, sizeof(uuid), "c%u", BLI_ghashutil_strhash_p(name)); - col_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (i == active_col) { - GWN_vertformat_alias_add(&format, "c"); + GPU_vertformat_alias_add(&format, "c"); } } } - hair_cache->pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); + hair_cache->pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex( + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex( &elb, - GWN_PRIM_LINE_STRIP, + GPU_PRIM_LINE_STRIP, hair_cache->elems_len, hair_cache->point_len, true); @@ -1183,7 +1183,7 @@ static void particle_batch_cache_ensure_pos_and_seg( if (psmd != NULL) { MEM_freeN(uv_id); } - hair_cache->indices = GWN_indexbuf_build(&elb); + hair_cache->indices = GPU_indexbuf_build(&elb); } static void particle_batch_cache_ensure_pos( @@ -1195,7 +1195,7 @@ static void particle_batch_cache_ensure_pos( return; } - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, rot_id, val_id; int i, curr_point; ParticleData *pa; @@ -1217,17 +1217,17 @@ static void particle_batch_cache_ensure_pos( } } - GWN_VERTBUF_DISCARD_SAFE(point_cache->pos); + GPU_VERTBUF_DISCARD_SAFE(point_cache->pos); if (format.attr_len == 0) { /* initialize vertex format */ - pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - rot_id = GWN_vertformat_attr_add(&format, "rot", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - val_id = GWN_vertformat_attr_add(&format, "val", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + rot_id = GPU_vertformat_attr_add(&format, "rot", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + val_id = GPU_vertformat_attr_add(&format, "val", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } - point_cache->pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(point_cache->pos, psys->totpart); + point_cache->pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(point_cache->pos, psys->totpart); for (curr_point = 0, i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) { state.time = DEG_get_ctime(draw_ctx->depsgraph); @@ -1237,8 +1237,8 @@ static void particle_batch_cache_ensure_pos( float val; - GWN_vertbuf_attr_set(point_cache->pos, pos_id, curr_point, pa->state.co); - GWN_vertbuf_attr_set(point_cache->pos, rot_id, curr_point, pa->state.rot); + GPU_vertbuf_attr_set(point_cache->pos, pos_id, curr_point, pa->state.co); + GPU_vertbuf_attr_set(point_cache->pos, rot_id, curr_point, pa->state.rot); switch (psys->part->draw_col) { case PART_DRAW_COL_VEL: @@ -1254,13 +1254,13 @@ static void particle_batch_cache_ensure_pos( break; } - GWN_vertbuf_attr_set(point_cache->pos, val_id, curr_point, &val); + GPU_vertbuf_attr_set(point_cache->pos, val_id, curr_point, &val); curr_point++; } if (curr_point != psys->totpart) { - GWN_vertbuf_data_resize(point_cache->pos, curr_point); + GPU_vertbuf_data_resize(point_cache->pos, curr_point); } } @@ -1334,7 +1334,7 @@ static void drw_particle_get_hair_source( } } -Gwn_Batch *DRW_particles_batch_cache_get_hair( +GPUBatch *DRW_particles_batch_cache_get_hair( Object *object, ParticleSystem *psys, ModifierData *md) @@ -1346,27 +1346,27 @@ Gwn_Batch *DRW_particles_batch_cache_get_hair( drw_particle_get_hair_source(object, psys, md, NULL, &source); ensure_seg_pt_count(source.edit, source.psys, &cache->hair); particle_batch_cache_ensure_pos_and_seg(source.edit, source.psys, source.md, &cache->hair); - cache->hair.hairs = GWN_batch_create( - GWN_PRIM_LINE_STRIP, + cache->hair.hairs = GPU_batch_create( + GPU_PRIM_LINE_STRIP, cache->hair.pos, cache->hair.indices); } return cache->hair.hairs; } -Gwn_Batch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *psys) +GPUBatch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *psys) { ParticleBatchCache *cache = particle_batch_cache_get(psys); if (cache->point.points == NULL) { particle_batch_cache_ensure_pos(object, psys, &cache->point); - cache->point.points = GWN_batch_create(GWN_PRIM_POINTS, cache->point.pos, NULL); + cache->point.points = GPU_batch_create(GPU_PRIM_POINTS, cache->point.pos, NULL); } return cache->point.points; } -Gwn_Batch *DRW_particles_batch_cache_get_edit_strands( +GPUBatch *DRW_particles_batch_cache_get_edit_strands( Object *object, ParticleSystem *psys, PTCacheEdit *edit) @@ -1378,8 +1378,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_strands( drw_particle_update_ptcache_edit(object, psys, edit); ensure_seg_pt_count(edit, psys, &cache->edit_hair); particle_batch_cache_ensure_pos_and_seg(edit, psys, NULL, &cache->edit_hair); - cache->edit_hair.hairs = GWN_batch_create( - GWN_PRIM_LINE_STRIP, + cache->edit_hair.hairs = GPU_batch_create( + GPU_PRIM_LINE_STRIP, cache->edit_hair.pos, cache->edit_hair.indices); return cache->edit_hair.hairs; @@ -1419,19 +1419,19 @@ static void particle_batch_cache_ensure_edit_inner_pos( return; } - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, color_id; - GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); if (format.attr_len == 0) { /* initialize vertex format */ - pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); } - cache->edit_inner_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len); + cache->edit_inner_pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len); float selected_color[4], normal_color[4]; edit_colors_get(edit, selected_color, normal_color); @@ -1441,19 +1441,19 @@ static void particle_batch_cache_ensure_edit_inner_pos( const PTCacheEditPoint *point = &edit->points[point_index]; for (int key_index = 0; key_index < point->totkey - 1; key_index++) { PTCacheEditKey *key = &point->keys[key_index]; - GWN_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co); + GPU_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co); if (key->flag & PEK_SELECT) { - GWN_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, selected_color); + GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, selected_color); } else { - GWN_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, normal_color); + GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, normal_color); } global_key_index++; } } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points( +GPUBatch *DRW_particles_batch_cache_get_edit_inner_points( Object *object, ParticleSystem *psys, PTCacheEdit *edit) @@ -1465,8 +1465,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points( drw_particle_update_ptcache_edit(object, psys, edit); ensure_edit_inner_points_count(edit, cache); particle_batch_cache_ensure_edit_inner_pos(edit, cache); - cache->edit_inner_points = GWN_batch_create( - GWN_PRIM_POINTS, + cache->edit_inner_points = GPU_batch_create( + GPU_PRIM_POINTS, cache->edit_inner_pos, NULL); return cache->edit_inner_points; @@ -1490,19 +1490,19 @@ static void particle_batch_cache_ensure_edit_tip_pos( return; } - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, color_id; - GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); if (format.attr_len == 0) { /* initialize vertex format */ - pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); } - cache->edit_tip_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len); + cache->edit_tip_pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len); float selected_color[4], normal_color[4]; edit_colors_get(edit, selected_color, normal_color); @@ -1510,17 +1510,17 @@ static void particle_batch_cache_ensure_edit_tip_pos( for (int point_index = 0; point_index < edit->totpoint; point_index++) { const PTCacheEditPoint *point = &edit->points[point_index]; PTCacheEditKey *key = &point->keys[point->totkey - 1]; - GWN_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co); + GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co); if (key->flag & PEK_SELECT) { - GWN_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, selected_color); + GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, selected_color); } else { - GWN_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, normal_color); + GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, normal_color); } } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points( +GPUBatch *DRW_particles_batch_cache_get_edit_tip_points( Object *object, ParticleSystem *psys, PTCacheEdit *edit) @@ -1532,8 +1532,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points( drw_particle_update_ptcache_edit(object, psys, edit); ensure_edit_tip_points_count(edit, cache); particle_batch_cache_ensure_edit_tip_pos(edit, cache); - cache->edit_tip_points = GWN_batch_create( - GWN_PRIM_POINTS, + cache->edit_tip_points = GPU_batch_create( + GPU_PRIM_POINTS, cache->edit_tip_pos, NULL); return cache->edit_tip_points; diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index df80300417e..c9fc5eba079 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -208,29 +208,29 @@ static struct { } g_shaders = {NULL}; static struct { - struct Gwn_VertFormat *instance_screenspace; - struct Gwn_VertFormat *instance_color; - struct Gwn_VertFormat *instance_screen_aligned; - struct Gwn_VertFormat *instance_scaled; - struct Gwn_VertFormat *instance_sized; - struct Gwn_VertFormat *instance_outline; - struct Gwn_VertFormat *instance; - struct Gwn_VertFormat *instance_camera; - struct Gwn_VertFormat *instance_distance_lines; - struct Gwn_VertFormat *instance_spot; - struct Gwn_VertFormat *instance_bone; - struct Gwn_VertFormat *instance_bone_stick; - struct Gwn_VertFormat *instance_bone_outline; - struct Gwn_VertFormat *instance_bone_envelope; - struct Gwn_VertFormat *instance_bone_envelope_distance; - struct Gwn_VertFormat *instance_bone_envelope_outline; - struct Gwn_VertFormat *instance_mball_handles; - struct Gwn_VertFormat *dynlines_color; + struct GPUVertFormat *instance_screenspace; + struct GPUVertFormat *instance_color; + struct GPUVertFormat *instance_screen_aligned; + struct GPUVertFormat *instance_scaled; + struct GPUVertFormat *instance_sized; + struct GPUVertFormat *instance_outline; + struct GPUVertFormat *instance; + struct GPUVertFormat *instance_camera; + struct GPUVertFormat *instance_distance_lines; + struct GPUVertFormat *instance_spot; + struct GPUVertFormat *instance_bone; + struct GPUVertFormat *instance_bone_stick; + struct GPUVertFormat *instance_bone_outline; + struct GPUVertFormat *instance_bone_envelope; + struct GPUVertFormat *instance_bone_envelope_distance; + struct GPUVertFormat *instance_bone_envelope_outline; + struct GPUVertFormat *instance_mball_handles; + struct GPUVertFormat *dynlines_color; } g_formats = {NULL}; void DRW_globals_free(void) { - struct Gwn_VertFormat **format = &g_formats.instance_screenspace; + struct GPUVertFormat **format = &g_formats.instance_screenspace; for (int i = 0; i < sizeof(g_formats) / sizeof(void *); ++i, ++format) { MEM_SAFE_FREE(*format); } @@ -304,7 +304,7 @@ DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float color[4 return grp; } -DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *geom, float *size) +DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct GPUBatch *geom, float *size) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR); @@ -322,7 +322,7 @@ DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *g return grp; } -DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct GPUBatch *geom) { static float light[3] = {0.0f, 0.0f, 1.0f}; GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR); @@ -338,7 +338,7 @@ DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR); @@ -352,7 +352,7 @@ DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED); @@ -368,7 +368,7 @@ DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch return grp; } -DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS); @@ -384,7 +384,7 @@ DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *ge return grp; } -DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE); @@ -399,7 +399,7 @@ DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); @@ -414,7 +414,7 @@ DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct Gwn_Batch *geom, int *baseid) +DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct GPUBatch *geom, int *baseid) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE); @@ -430,7 +430,7 @@ DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct Gwn_Batch *geom, return grp; } -DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_CAMERA); @@ -447,7 +447,7 @@ DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_DISTANCE_LINES); static float point_size = 4.0f; @@ -465,7 +465,7 @@ DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch return grp; } -DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR); static const int True = true; @@ -600,7 +600,7 @@ DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass) } /* Only works with batches with adjacency infos. */ -DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct GPUBatch *geom) { if (g_shaders.shape_outline == NULL) { g_shaders.shape_outline = DRW_shader_create( @@ -623,7 +623,7 @@ DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_B return grp; } -DRWShadingGroup *shgroup_instance_bone_shape_solid(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_bone_shape_solid(DRWPass *pass, struct GPUBatch *geom) { if (g_shaders.shape_solid == NULL) { g_shaders.shape_solid = DRW_shader_create( diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index b4ae0600f02..80b2ec8db71 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -28,7 +28,7 @@ struct DRWPass; struct DRWShadingGroup; -struct Gwn_Batch; +struct GPUBatch; struct GPUMaterial; struct Object; struct ViewLayer; @@ -112,25 +112,25 @@ struct DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(struct DRWPass *pa struct DRWShadingGroup *shgroup_dynpoints_uniform_color(struct DRWPass *pass, float color[4], float *size); struct DRWShadingGroup *shgroup_groundlines_uniform_color(struct DRWPass *pass, float color[4]); struct DRWShadingGroup *shgroup_groundpoints_uniform_color(struct DRWPass *pass, float color[4]); -struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct Gwn_Batch *geom, float *size); -struct DRWShadingGroup *shgroup_instance_solid(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_wire(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct Gwn_Batch *geom, int *baseid); -struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Gwn_Batch *geom); +struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct GPUBatch *geom, float *size); +struct DRWShadingGroup *shgroup_instance_solid(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_wire(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct GPUBatch *geom, int *baseid); +struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct GPUBatch *geom); struct DRWShadingGroup *shgroup_instance_mball_handles(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_axes(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_envelope_distance(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_envelope_outline(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass); -struct DRWShadingGroup *shgroup_instance_bone_shape_outline(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_bone_shape_solid(struct DRWPass *pass, struct Gwn_Batch *geom); +struct DRWShadingGroup *shgroup_instance_bone_shape_outline(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_bone_shape_solid(struct DRWPass *pass, struct GPUBatch *geom); struct DRWShadingGroup *shgroup_instance_bone_sphere_outline(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_sphere_solid(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_stick(struct DRWPass *pass); diff --git a/source/blender/draw/intern/draw_debug.c b/source/blender/draw/intern/draw_debug.c index 64e76a339c1..8af13d66c28 100644 --- a/source/blender/draw/intern/draw_debug.c +++ b/source/blender/draw/intern/draw_debug.c @@ -147,13 +147,13 @@ static void drw_debug_draw_lines(void) return; } - Gwn_VertFormat *vert_format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(vert_format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *vert_format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(vert_format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, count * 2); + immBegin(GPU_PRIM_LINES, count * 2); while (DST.debug.lines) { void *next = DST.debug.lines->next; @@ -181,36 +181,36 @@ static void drw_debug_draw_spheres(void) } float one = 1.0f; - Gwn_VertFormat vert_format = {0}; - uint mat = GWN_vertformat_attr_add(&vert_format, "InstanceModelMatrix", GWN_COMP_F32, 16, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(&vert_format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint siz = GWN_vertformat_attr_add(&vert_format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + GPUVertFormat vert_format = {0}; + uint mat = GPU_vertformat_attr_add(&vert_format, "InstanceModelMatrix", GPU_COMP_F32, 16, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(&vert_format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint siz = GPU_vertformat_attr_add(&vert_format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); - Gwn_VertBuf *inst_vbo = GWN_vertbuf_create_with_format(&vert_format); + GPUVertBuf *inst_vbo = GPU_vertbuf_create_with_format(&vert_format); - GWN_vertbuf_data_alloc(inst_vbo, count); + GPU_vertbuf_data_alloc(inst_vbo, count); int v = 0; while (DST.debug.spheres) { void *next = DST.debug.spheres->next; - GWN_vertbuf_attr_set(inst_vbo, mat, v, DST.debug.spheres->mat[0]); - GWN_vertbuf_attr_set(inst_vbo, col, v, DST.debug.spheres->color); - GWN_vertbuf_attr_set(inst_vbo, siz, v, &one); + GPU_vertbuf_attr_set(inst_vbo, mat, v, DST.debug.spheres->mat[0]); + GPU_vertbuf_attr_set(inst_vbo, col, v, DST.debug.spheres->color); + GPU_vertbuf_attr_set(inst_vbo, siz, v, &one); v++; MEM_freeN(DST.debug.spheres); DST.debug.spheres = next; } - Gwn_Batch *empty_sphere = DRW_cache_empty_sphere_get(); + GPUBatch *empty_sphere = DRW_cache_empty_sphere_get(); - Gwn_Batch *draw_batch = GWN_batch_create(GWN_PRIM_LINES, empty_sphere->verts[0], NULL); - GWN_batch_instbuf_set(draw_batch, inst_vbo, true); - GWN_batch_program_set_builtin(draw_batch, GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); + GPUBatch *draw_batch = GPU_batch_create(GPU_PRIM_LINES, empty_sphere->verts[0], NULL); + GPU_batch_instbuf_set(draw_batch, inst_vbo, true); + GPU_batch_program_set_builtin(draw_batch, GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); - GWN_batch_draw(draw_batch); - GWN_batch_discard(draw_batch); + GPU_batch_draw(draw_batch); + GPU_batch_discard(draw_batch); } void drw_debug_draw(void) diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h index 17acd7e6259..41f91e02459 100644 --- a/source/blender/draw/intern/draw_hair_private.h +++ b/source/blender/draw/intern/draw_hair_private.h @@ -42,32 +42,32 @@ struct ParticleHairCache; typedef struct ParticleHairFinalCache { /* Output of the subdivision stage: vertex buff sized to subdiv level. */ - Gwn_VertBuf *proc_buf; + GPUVertBuf *proc_buf; GPUTexture *proc_tex; /* Just contains a huge index buffer used to draw the final hair. */ - Gwn_Batch *proc_hairs[MAX_THICKRES]; + GPUBatch *proc_hairs[MAX_THICKRES]; int strands_res; /* points per hair, at least 2 */ } ParticleHairFinalCache; typedef struct ParticleHairCache { - Gwn_VertBuf *pos; - Gwn_IndexBuf *indices; - Gwn_Batch *hairs; + GPUVertBuf *pos; + GPUIndexBuf *indices; + GPUBatch *hairs; /* Hair Procedural display: Interpolation is done on the GPU. */ - Gwn_VertBuf *proc_point_buf; /* Input control points */ + GPUVertBuf *proc_point_buf; /* Input control points */ GPUTexture *point_tex; - Gwn_VertBuf *proc_strand_buf; /* Infos of control points strands (segment count and base index) */ + GPUVertBuf *proc_strand_buf; /* Infos of control points strands (segment count and base index) */ GPUTexture *strand_tex; - Gwn_VertBuf *proc_uv_buf[MAX_MTFACE]; + GPUVertBuf *proc_uv_buf[MAX_MTFACE]; GPUTexture *uv_tex[MAX_MTFACE]; char uv_layer_names[MAX_MTFACE][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]; - Gwn_VertBuf *proc_col_buf[MAX_MCOL]; + GPUVertBuf *proc_col_buf[MAX_MCOL]; GPUTexture *col_tex[MAX_MCOL]; char col_layer_names[MAX_MCOL][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]; diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index e322d4780d5..89cffd6c19c 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -45,17 +45,17 @@ typedef struct DRWBatchingBuffer { struct DRWShadingGroup *shgroup; /* Link back to the owning shGroup. Also tells if it's used */ - Gwn_VertFormat *format; /* Identifier. */ - Gwn_VertBuf *vert; /* Gwn_VertBuf contained in the Gwn_Batch. */ - Gwn_Batch *batch; /* Gwn_Batch containing the Gwn_VertBuf. */ + GPUVertFormat *format; /* Identifier. */ + GPUVertBuf *vert; /* GPUVertBuf contained in the GPUBatch. */ + GPUBatch *batch; /* GPUBatch containing the GPUVertBuf. */ } DRWBatchingBuffer; typedef struct DRWInstancingBuffer { struct DRWShadingGroup *shgroup; /* Link back to the owning shGroup. Also tells if it's used */ - Gwn_VertFormat *format; /* Identifier. */ - Gwn_Batch *instance; /* Identifier. */ - Gwn_VertBuf *vert; /* Gwn_VertBuf contained in the Gwn_Batch. */ - Gwn_Batch *batch; /* Gwn_Batch containing the Gwn_VertBuf. */ + GPUVertFormat *format; /* Identifier. */ + GPUBatch *instance; /* Identifier. */ + GPUVertBuf *vert; /* GPUVertBuf contained in the GPUBatch. */ + GPUBatch *batch; /* GPUBatch containing the GPUVertBuf. */ } DRWInstancingBuffer; typedef struct DRWInstanceChunk { @@ -100,7 +100,7 @@ static ListBase g_idatalists = {NULL, NULL}; * that would be too slow]). **/ -static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data)) +static void instance_batch_free(GPUBatch *batch, void *UNUSED(user_data)) { /* Free all batches that have the same key before they are reused. */ /* TODO: Make it thread safe! Batch freeing can happen from another thread. */ @@ -111,8 +111,8 @@ static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data)) for (int i = 0; i < idatalist->instancing.alloc_size; i++, ibuf++) { if (ibuf->instance == batch) { BLI_assert(ibuf->shgroup == NULL); /* Make sure it has no other users. */ - GWN_VERTBUF_DISCARD_SAFE(ibuf->vert); - GWN_BATCH_DISCARD_SAFE(ibuf->batch); + GPU_VERTBUF_DISCARD_SAFE(ibuf->vert); + GPU_BATCH_DISCARD_SAFE(ibuf->batch); /* Tag as non alloced. */ ibuf->format = NULL; } @@ -121,8 +121,8 @@ static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data)) } void DRW_batching_buffer_request( - DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_PrimType type, struct DRWShadingGroup *shgroup, - Gwn_Batch **r_batch, Gwn_VertBuf **r_vert) + DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUPrimType type, struct DRWShadingGroup *shgroup, + GPUBatch **r_batch, GPUVertBuf **r_vert) { DRWInstanceChunk *chunk = &idatalist->batching; DRWBatchingBuffer *bbuf = idatalist->batching.bbufs; @@ -152,16 +152,16 @@ void DRW_batching_buffer_request( } /* Create the batch. */ bbuf = chunk->bbufs + new_id; - bbuf->vert = *r_vert = GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_DYNAMIC); - bbuf->batch = *r_batch = GWN_batch_create_ex(type, bbuf->vert, NULL, 0); + bbuf->vert = *r_vert = GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_DYNAMIC); + bbuf->batch = *r_batch = GPU_batch_create_ex(type, bbuf->vert, NULL, 0); bbuf->format = format; bbuf->shgroup = shgroup; - GWN_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK); + GPU_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK); } void DRW_instancing_buffer_request( - DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_Batch *instance, struct DRWShadingGroup *shgroup, - Gwn_Batch **r_batch, Gwn_VertBuf **r_vert) + DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUBatch *instance, struct DRWShadingGroup *shgroup, + GPUBatch **r_batch, GPUVertBuf **r_vert) { DRWInstanceChunk *chunk = &idatalist->instancing; DRWInstancingBuffer *ibuf = idatalist->instancing.ibufs; @@ -193,15 +193,15 @@ void DRW_instancing_buffer_request( } /* Create the batch. */ ibuf = chunk->ibufs + new_id; - ibuf->vert = *r_vert = GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_DYNAMIC); - ibuf->batch = *r_batch = GWN_batch_duplicate(instance); + ibuf->vert = *r_vert = GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_DYNAMIC); + ibuf->batch = *r_batch = GPU_batch_duplicate(instance); ibuf->format = format; ibuf->shgroup = shgroup; ibuf->instance = instance; - GWN_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK); - GWN_batch_instbuf_set(ibuf->batch, ibuf->vert, false); + GPU_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK); + GPU_batch_instbuf_set(ibuf->batch, ibuf->vert, false); /* Make sure to free this ibuf if the instance batch gets free. */ - GWN_batch_callback_free_set(instance, &instance_batch_free, NULL); + GPU_batch_callback_free_set(instance, &instance_batch_free, NULL); } void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) @@ -218,14 +218,14 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_len) { uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; - GWN_vertbuf_data_resize(bbuf->vert, size); + GPU_vertbuf_data_resize(bbuf->vert, size); } - GWN_vertbuf_use(bbuf->vert); /* Send data. */ + GPU_vertbuf_use(bbuf->vert); /* Send data. */ bbuf->shgroup = NULL; /* Set as non used for the next round. */ } else { - GWN_VERTBUF_DISCARD_SAFE(bbuf->vert); - GWN_BATCH_DISCARD_SAFE(bbuf->batch); + GPU_VERTBUF_DISCARD_SAFE(bbuf->vert); + GPU_BATCH_DISCARD_SAFE(bbuf->batch); bbuf->format = NULL; /* Tag as non alloced. */ } } @@ -250,14 +250,14 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_len) { uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; - GWN_vertbuf_data_resize(ibuf->vert, size); + GPU_vertbuf_data_resize(ibuf->vert, size); } - GWN_vertbuf_use(ibuf->vert); /* Send data. */ + GPU_vertbuf_use(ibuf->vert); /* Send data. */ ibuf->shgroup = NULL; /* Set as non used for the next round. */ } else { - GWN_VERTBUF_DISCARD_SAFE(ibuf->vert); - GWN_BATCH_DISCARD_SAFE(ibuf->batch); + GPU_VERTBUF_DISCARD_SAFE(ibuf->vert); + GPU_BATCH_DISCARD_SAFE(ibuf->batch); ibuf->format = NULL; /* Tag as non alloced. */ } } @@ -366,15 +366,15 @@ void DRW_instance_data_list_free(DRWInstanceDataList *idatalist) DRWBatchingBuffer *bbuf = idatalist->batching.bbufs; for (int i = 0; i < idatalist->batching.alloc_size; i++, bbuf++) { - GWN_VERTBUF_DISCARD_SAFE(bbuf->vert); - GWN_BATCH_DISCARD_SAFE(bbuf->batch); + GPU_VERTBUF_DISCARD_SAFE(bbuf->vert); + GPU_BATCH_DISCARD_SAFE(bbuf->batch); } MEM_freeN(idatalist->batching.bbufs); DRWInstancingBuffer *ibuf = idatalist->instancing.ibufs; for (int i = 0; i < idatalist->instancing.alloc_size; i++, ibuf++) { - GWN_VERTBUF_DISCARD_SAFE(ibuf->vert); - GWN_BATCH_DISCARD_SAFE(ibuf->batch); + GPU_VERTBUF_DISCARD_SAFE(ibuf->vert); + GPU_BATCH_DISCARD_SAFE(ibuf->batch); } MEM_freeN(idatalist->instancing.ibufs); diff --git a/source/blender/draw/intern/draw_instance_data.h b/source/blender/draw/intern/draw_instance_data.h index 0ea40a50a6b..174f03e3bc7 100644 --- a/source/blender/draw/intern/draw_instance_data.h +++ b/source/blender/draw/intern/draw_instance_data.h @@ -43,11 +43,11 @@ DRWInstanceData *DRW_instance_data_request( DRWInstanceDataList *idatalist, uint attrib_size); void DRW_batching_buffer_request( - DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_PrimType type, struct DRWShadingGroup *shgroup, - Gwn_Batch **r_batch, Gwn_VertBuf **r_vert); + DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUPrimType type, struct DRWShadingGroup *shgroup, + GPUBatch **r_batch, GPUVertBuf **r_vert); void DRW_instancing_buffer_request( - DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_Batch *instance, struct DRWShadingGroup *shgroup, - Gwn_Batch **r_batch, Gwn_VertBuf **r_vert); + DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUBatch *instance, struct DRWShadingGroup *shgroup, + GPUBatch **r_batch, GPUVertBuf **r_vert); /* Upload all instance data to the GPU as soon as possible. */ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 4c6f8962d82..92603a0ce53 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -228,9 +228,9 @@ void DRW_transform_to_display(GPUTexture *tex) { drw_state_set(DRW_STATE_WRITE_COLOR); - Gwn_VertFormat *vert_format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *vert_format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const float dither = 1.0f; @@ -262,7 +262,7 @@ void DRW_transform_to_display(GPUTexture *tex) immUniformMatrix4fv("ModelViewProjectionMatrix", mat); /* Full screen triangle */ - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immAttrib2f(texco, 0.0f, 0.0f); immVertex2f(pos, -1.0f, -1.0f); @@ -287,21 +287,21 @@ void DRW_transform_to_display(GPUTexture *tex) void DRW_transform_none(GPUTexture *tex) { /* Draw as texture for final render (without immediate mode). */ - Gwn_Batch *geom = DRW_cache_fullscreen_quad_texcoord_get(); - GWN_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR); + GPUBatch *geom = DRW_cache_fullscreen_quad_get(); + GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR); GPU_texture_bind(tex, 0); const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - GWN_batch_uniform_4fv(geom, "color", white); + GPU_batch_uniform_4fv(geom, "color", white); float mat[4][4]; unit_m4(mat); - GWN_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); + GPU_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); - GWN_batch_program_use_begin(geom); - GWN_batch_draw_range_ex(geom, 0, 0, false); - GWN_batch_program_use_end(geom); + GPU_batch_program_use_begin(geom); + GPU_batch_draw_range_ex(geom, 0, 0, false); + GPU_batch_program_use_end(geom); GPU_texture_unbind(tex); } @@ -327,7 +327,7 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color) BLI_assert(samples > 0); BLI_assert(GPU_texture_samples(src_color) == samples); - Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + GPUBatch *geom = DRW_cache_fullscreen_quad_get(); int builtin; switch (samples) { @@ -341,21 +341,21 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color) break; } - GWN_batch_program_set_builtin(geom, builtin); + GPU_batch_program_set_builtin(geom, builtin); GPU_texture_bind(src_depth, 0); GPU_texture_bind(src_color, 1); - GWN_batch_uniform_1i(geom, "depthMulti", 0); - GWN_batch_uniform_1i(geom, "colorMulti", 1); + GPU_batch_uniform_1i(geom, "depthMulti", 0); + GPU_batch_uniform_1i(geom, "colorMulti", 1); float mat[4][4]; unit_m4(mat); - GWN_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); + GPU_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); /* avoid gpuMatrix calls */ - GWN_batch_program_use_begin(geom); - GWN_batch_draw_range_ex(geom, 0, 0, false); - GWN_batch_program_use_end(geom); + GPU_batch_program_use_begin(geom); + GPU_batch_draw_range_ex(geom, 0, 0, false); + GPU_batch_program_use_end(geom); } /** \} */ @@ -1573,14 +1573,14 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) } void *re_gl_context = RE_gl_context_get(render); - void *re_gwn_context = NULL; + void *re_gpu_context = NULL; /* Changing Context */ if (re_gl_context != NULL) { DRW_opengl_render_context_enable(re_gl_context); - /* We need to query gwn context after a gl context has been bound. */ - re_gwn_context = RE_gwn_context_get(render); - DRW_gawain_render_context_enable(re_gwn_context); + /* We need to query gpu context after a gl context has been bound. */ + re_gpu_context = RE_gpu_context_get(render); + DRW_gawain_render_context_enable(re_gpu_context); } else { DRW_opengl_context_enable(); @@ -1659,7 +1659,7 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) /* Changing Context */ if (re_gl_context != NULL) { - DRW_gawain_render_context_disable(re_gwn_context); + DRW_gawain_render_context_disable(re_gpu_context); DRW_opengl_render_context_disable(re_gl_context); } else { @@ -1967,9 +1967,9 @@ static void draw_depth_texture_to_screen(GPUTexture *texture) const float w = (float)GPU_texture_width(texture); const float h = (float)GPU_texture_height(texture); - Gwn_VertFormat *format = immVertexFormat(); - uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_IMAGE_DEPTH_COPY); @@ -1977,7 +1977,7 @@ static void draw_depth_texture_to_screen(GPUTexture *texture) immUniform1i("image", 0); /* default GL_TEXTURE0 unit */ - immBegin(GWN_PRIM_TRI_STRIP, 4); + immBegin(GPU_PRIM_TRI_STRIP, 4); immAttrib2f(texcoord, 0.0f, 0.0f); immVertex2f(pos, 0.0f, 0.0f); @@ -2298,7 +2298,7 @@ void DRW_engines_register(void) } } -extern struct Gwn_VertFormat *g_pos_format; /* draw_shgroup.c */ +extern struct GPUVertFormat *g_pos_format; /* draw_shgroup.c */ extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */ extern struct GPUTexture *globals_ramp; /* draw_common.c */ void DRW_engines_free(void) @@ -2352,7 +2352,7 @@ void DRW_opengl_context_create(void) /* This changes the active context. */ DST.gl_context = WM_opengl_context_create(); /* Be sure to create gawain.context too. */ - DST.gwn_context = GWN_context_create(); + DST.gpu_context = GPU_context_create(); if (!G.background) { immActivate(); } @@ -2367,8 +2367,8 @@ void DRW_opengl_context_destroy(void) BLI_assert(BLI_thread_is_main()); if (DST.gl_context != NULL) { WM_opengl_context_activate(DST.gl_context); - GWN_context_active_set(DST.gwn_context); - GWN_context_discard(DST.gwn_context); + GPU_context_active_set(DST.gpu_context); + GPU_context_discard(DST.gpu_context); WM_opengl_context_dispose(DST.gl_context); BLI_ticket_mutex_free(DST.gl_context_mutex); } @@ -2387,7 +2387,7 @@ void DRW_opengl_context_enable(void) } } WM_opengl_context_activate(DST.gl_context); - GWN_context_active_set(DST.gwn_context); + GPU_context_active_set(DST.gpu_context); if (BLI_thread_is_main()) { if (!G.background) { immActivate(); @@ -2411,7 +2411,7 @@ void DRW_opengl_context_disable(void) } else { WM_opengl_context_release(DST.gl_context); - GWN_context_active_set(NULL); + GPU_context_active_set(NULL); } BLI_ticket_mutex_unlock(DST.gl_context_mutex); @@ -2437,20 +2437,20 @@ void DRW_opengl_render_context_disable(void *re_gl_context) } /* Needs to be called AFTER DRW_opengl_render_context_enable() */ -void DRW_gawain_render_context_enable(void *re_gwn_context) +void DRW_gawain_render_context_enable(void *re_gpu_context) { /* If thread is main you should use DRW_opengl_context_enable(). */ BLI_assert(!BLI_thread_is_main()); - GWN_context_active_set(re_gwn_context); + GPU_context_active_set(re_gpu_context); DRW_shape_cache_reset(); /* XXX fix that too. */ } /* Needs to be called BEFORE DRW_opengl_render_context_disable() */ -void DRW_gawain_render_context_disable(void *UNUSED(re_gwn_context)) +void DRW_gawain_render_context_disable(void *UNUSED(re_gpu_context)) { DRW_shape_cache_reset(); /* XXX fix that too. */ - GWN_context_active_set(NULL); + GPU_context_active_set(NULL); } /** \} */ diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 2d44fb5b6d8..9b01f17649c 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -130,7 +130,7 @@ typedef enum { DRW_CALL_RANGE, /* Like single but only draw a range of vertices/indices. */ DRW_CALL_INSTANCES, /* Draw instances without any instancing attribs. */ DRW_CALL_GENERATE, /* Uses a callback to draw with any number of batches. */ - DRW_CALL_PROCEDURAL, /* Generate a drawcall without any Gwn_Batch. */ + DRW_CALL_PROCEDURAL, /* Generate a drawcall without any GPUBatch. */ } DRWCallType; typedef struct DRWCall { @@ -139,14 +139,14 @@ typedef struct DRWCall { union { struct { /* type == DRW_CALL_SINGLE */ - Gwn_Batch *geometry; + GPUBatch *geometry; } single; struct { /* type == DRW_CALL_RANGE */ - Gwn_Batch *geometry; + GPUBatch *geometry; uint start, count; } range; struct { /* type == DRW_CALL_INSTANCES */ - Gwn_Batch *geometry; + GPUBatch *geometry; /* Count can be adjusted between redraw. If needed, we can add fixed count. */ uint *count; } instances; @@ -156,7 +156,7 @@ typedef struct DRWCall { } generate; struct { /* type == DRW_CALL_PROCEDURAL */ uint vert_count; - Gwn_PrimType prim_type; + GPUPrimType prim_type; } procedural; }; @@ -226,16 +226,16 @@ struct DRWShadingGroup { } calls; struct { /* DRW_SHG_FEEDBACK_TRANSFORM */ DRWCall *first, *last; /* Linked list of DRWCall or DRWCallDynamic depending of type */ - struct Gwn_VertBuf *tfeedback_target; /* Transform Feedback target. */ + struct GPUVertBuf *tfeedback_target; /* Transform Feedback target. */ }; struct { /* DRW_SHG_***_BATCH */ - struct Gwn_Batch *batch_geom; /* Result of call batching */ - struct Gwn_VertBuf *batch_vbo; + struct GPUBatch *batch_geom; /* Result of call batching */ + struct GPUVertBuf *batch_vbo; uint primitive_count; }; struct { /* DRW_SHG_INSTANCE[_EXTERNAL] */ - struct Gwn_Batch *instance_geom; - struct Gwn_VertBuf *instance_vbo; + struct GPUBatch *instance_geom; + struct GPUVertBuf *instance_vbo; uint instance_count; float instance_orcofac[2][3]; /* TODO find a better place. */ }; @@ -264,7 +264,7 @@ struct DRWShadingGroup { #endif #ifdef USE_GPU_SELECT - Gwn_VertBuf *inst_selectid; + GPUVertBuf *inst_selectid; DRWPass *pass_parent; /* backlink to pass we're in */ int override_selectid; /* Override for single object instances. */ #endif @@ -379,7 +379,7 @@ typedef struct DRWManager { /* gl_context serves as the offset for clearing only * the top portion of the struct so DO NOT MOVE IT! */ void *gl_context; /* Unique ghost context used by the draw manager. */ - Gwn_Context *gwn_context; + GPUContext *gpu_context; TicketMutex *gl_context_mutex; /* Mutex to lock the drw manager and avoid concurent context usage. */ /** GPU Resource State: Memory storage between drawing. */ diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index c259633982e..dccb869c133 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -41,7 +41,7 @@ #include "intern/gpu_codegen.h" -struct Gwn_VertFormat *g_pos_format = NULL; +struct GPUVertFormat *g_pos_format = NULL; extern struct GPUUniformBuffer *view_ubo; /* draw_manager_exec.c */ @@ -355,7 +355,7 @@ static DRWCallState *drw_call_state_object(DRWShadingGroup *shgroup, float (*obm return DST.ob_state; } -void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4]) +void DRW_shgroup_call_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4]) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -371,7 +371,7 @@ void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obm BLI_LINKS_APPEND(&shgroup->calls, call); } -void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count) +void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_count) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -391,7 +391,7 @@ void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float } static void drw_shgroup_call_procedural_add_ex( - DRWShadingGroup *shgroup, Gwn_PrimType prim_type, uint vert_count, float (*obmat)[4], Object *ob) + DRWShadingGroup *shgroup, GPUPrimType prim_type, uint vert_count, float (*obmat)[4], Object *ob) { BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -414,28 +414,28 @@ static void drw_shgroup_call_procedural_add_ex( void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS, point_len, obmat, NULL); + drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_POINTS, point_len, obmat, NULL); } void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_LINES, line_count * 2, obmat, NULL); + drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_LINES, line_count * 2, obmat, NULL); } void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count * 3, obmat, NULL); + drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, obmat, NULL); } /* TODO (fclem): this is a sign that the api is starting to be limiting. * Maybe add special function that general purpose for special cases. */ void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, Object *ob) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count * 3, NULL, ob); + drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, NULL, ob); } /* These calls can be culled and are optimized for redraw */ -void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, bool bypass_culling) +void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, bool bypass_culling) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -455,7 +455,7 @@ void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, Gwn_Batch *geom, O } void DRW_shgroup_call_object_add_with_callback( - DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, + DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, DRWCallVisibilityFn *callback, void *user_data) { BLI_assert(geom != NULL); @@ -474,7 +474,7 @@ void DRW_shgroup_call_object_add_with_callback( BLI_LINKS_APPEND(&shgroup->calls, call); } -void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4], uint *count) +void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4], uint *count) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -492,7 +492,7 @@ void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, f } /* These calls can be culled and are optimized for redraw */ -void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, uint *count) +void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, uint *count) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -531,7 +531,7 @@ void DRW_shgroup_call_generate_add( static void sculpt_draw_cb( DRWShadingGroup *shgroup, - void (*draw_fn)(DRWShadingGroup *shgroup, Gwn_Batch *geom), + void (*draw_fn)(DRWShadingGroup *shgroup, GPUBatch *geom), void *user_data) { Object *ob = user_data; @@ -540,7 +540,7 @@ static void sculpt_draw_cb( if (pbvh) { BKE_pbvh_draw_cb( pbvh, NULL, NULL, false, - (void (*)(void *, Gwn_Batch *))draw_fn, shgroup); + (void (*)(void *, GPUBatch *))draw_fn, shgroup); } } @@ -554,9 +554,9 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at #ifdef USE_GPU_SELECT if (G.f & G_PICKSEL) { if (shgroup->instance_count == shgroup->inst_selectid->vertex_len) { - GWN_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32); + GPU_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32); } - GWN_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id); + GPU_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id); } #endif @@ -565,9 +565,9 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at for (int i = 0; i < attr_len; ++i) { if (shgroup->instance_count == shgroup->instance_vbo->vertex_len) { - GWN_vertbuf_data_resize(shgroup->instance_vbo, shgroup->instance_count + 32); + GPU_vertbuf_data_resize(shgroup->instance_vbo, shgroup->instance_count + 32); } - GWN_vertbuf_attr_set(shgroup->instance_vbo, i, shgroup->instance_count, attr[i]); + GPU_vertbuf_attr_set(shgroup->instance_vbo, i, shgroup->instance_count, attr[i]); } shgroup->instance_count += 1; @@ -601,25 +601,25 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader) } else { /* Only here to support builtin shaders. This should not be used by engines. */ - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEW, DST.view_data.matstate.mat[DRW_MAT_VIEW], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEW_INV, DST.view_data.matstate.mat[DRW_MAT_VIEWINV], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEWPROJECTION, DST.view_data.matstate.mat[DRW_MAT_PERS], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEWPROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_PERSINV], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_PROJECTION, DST.view_data.matstate.mat[DRW_MAT_WIN], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_PROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_WININV], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_CAMERATEXCO, DST.view_data.viewcamtexcofac, 3, 2); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEW, DST.view_data.matstate.mat[DRW_MAT_VIEW], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEW_INV, DST.view_data.matstate.mat[DRW_MAT_VIEWINV], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEWPROJECTION, DST.view_data.matstate.mat[DRW_MAT_PERS], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEWPROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_PERSINV], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION, DST.view_data.matstate.mat[DRW_MAT_WIN], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_WININV], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_CAMERATEXCO, DST.view_data.viewcamtexcofac, 3, 2); } - shgroup->model = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODEL); - shgroup->modelinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODEL_INV); - shgroup->modelview = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODELVIEW); - shgroup->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODELVIEW_INV); - shgroup->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MVP); - shgroup->normalview = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_NORMAL); - shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_WORLDNORMAL); - shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_ORCO); - shgroup->eye = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_EYE); - shgroup->callid = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_CALLID); + shgroup->model = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODEL); + shgroup->modelinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODEL_INV); + shgroup->modelview = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW); + shgroup->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW_INV); + shgroup->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MVP); + shgroup->normalview = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_NORMAL); + shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_WORLDNORMAL); + shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_ORCO); + shgroup->eye = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_EYE); + shgroup->callid = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_CALLID); shgroup->matflag = 0; if (shgroup->modelinverse > -1) @@ -641,7 +641,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader) } static void drw_shgroup_instance_init( - DRWShadingGroup *shgroup, GPUShader *shader, Gwn_Batch *batch, Gwn_VertFormat *format) + DRWShadingGroup *shgroup, GPUShader *shader, GPUBatch *batch, GPUVertFormat *format) { BLI_assert(shgroup->type == DRW_SHG_INSTANCE); BLI_assert(batch != NULL); @@ -661,20 +661,20 @@ static void drw_shgroup_instance_init( if (G.f & G_PICKSEL) { /* Not actually used for rendering but alloced in one chunk. * Plus we don't have to care about ownership. */ - static Gwn_VertFormat inst_select_format = {0}; + static GPUVertFormat inst_select_format = {0}; if (inst_select_format.attr_len == 0) { - GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT); + GPU_vertformat_attr_add(&inst_select_format, "selectId", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_Batch *batch_dummy; /* Not used */ + GPUBatch *batch_dummy; /* Not used */ DRW_batching_buffer_request(DST.idatalist, &inst_select_format, - GWN_PRIM_POINTS, shgroup, + GPU_PRIM_POINTS, shgroup, &batch_dummy, &shgroup->inst_selectid); } #endif } static void drw_shgroup_batching_init( - DRWShadingGroup *shgroup, GPUShader *shader, Gwn_VertFormat *format) + DRWShadingGroup *shgroup, GPUShader *shader, GPUVertFormat *format) { drw_shgroup_init(shgroup, shader); @@ -683,12 +683,12 @@ static void drw_shgroup_batching_init( #endif BLI_assert(format != NULL); - Gwn_PrimType type; + GPUPrimType type; switch (shgroup->type) { - case DRW_SHG_POINT_BATCH: type = GWN_PRIM_POINTS; break; - case DRW_SHG_LINE_BATCH: type = GWN_PRIM_LINES; break; - case DRW_SHG_TRIANGLE_BATCH: type = GWN_PRIM_TRIS; break; - default: type = GWN_PRIM_NONE; BLI_assert(0); break; + case DRW_SHG_POINT_BATCH: type = GPU_PRIM_POINTS; break; + case DRW_SHG_LINE_BATCH: type = GPU_PRIM_LINES; break; + case DRW_SHG_TRIANGLE_BATCH: type = GPU_PRIM_TRIS; break; + default: type = GPU_PRIM_NONE; BLI_assert(0); break; } DRW_batching_buffer_request(DST.idatalist, format, type, shgroup, @@ -697,13 +697,13 @@ static void drw_shgroup_batching_init( #ifdef USE_GPU_SELECT if (G.f & G_PICKSEL) { /* Not actually used for rendering but alloced in one chunk. */ - static Gwn_VertFormat inst_select_format = {0}; + static GPUVertFormat inst_select_format = {0}; if (inst_select_format.attr_len == 0) { - GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT); + GPU_vertformat_attr_add(&inst_select_format, "selectId", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_Batch *batch; /* Not used */ + GPUBatch *batch; /* Not used */ DRW_batching_buffer_request(DST.idatalist, &inst_select_format, - GWN_PRIM_POINTS, shgroup, + GPU_PRIM_POINTS, shgroup, &batch, &shgroup->inst_selectid); } #endif @@ -807,15 +807,15 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct return grp; } -Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize) +GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize) { - Gwn_VertFormat *format = MEM_callocN(sizeof(Gwn_VertFormat), "Gwn_VertFormat"); + GPUVertFormat *format = MEM_callocN(sizeof(GPUVertFormat), "GPUVertFormat"); for (int i = 0; i < arraysize; ++i) { - GWN_vertformat_attr_add(format, attribs[i].name, - (attribs[i].type == DRW_ATTRIB_INT) ? GWN_COMP_I32 : GWN_COMP_F32, + GPU_vertformat_attr_add(format, attribs[i].name, + (attribs[i].type == DRW_ATTRIB_INT) ? GPU_COMP_I32 : GPU_COMP_F32, attribs[i].components, - (attribs[i].type == DRW_ATTRIB_INT) ? GWN_FETCH_INT : GWN_FETCH_FLOAT); + (attribs[i].type == DRW_ATTRIB_INT) ? GPU_FETCH_INT : GPU_FETCH_FLOAT); } return format; } @@ -835,7 +835,7 @@ DRWShadingGroup *DRW_shgroup_material_create( } DRWShadingGroup *DRW_shgroup_material_instance_create( - struct GPUMaterial *material, DRWPass *pass, Gwn_Batch *geom, Object *ob, Gwn_VertFormat *format) + struct GPUMaterial *material, DRWPass *pass, GPUBatch *geom, Object *ob, GPUVertFormat *format) { GPUPass *gpupass = GPU_material_get_pass(material); DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass); @@ -861,7 +861,7 @@ DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create( DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass); if (shgroup) { - /* Calling drw_shgroup_init will cause it to call GWN_draw_primitive(). */ + /* Calling drw_shgroup_init will cause it to call GPU_draw_primitive(). */ drw_shgroup_init(shgroup, GPU_pass_shader_get(gpupass)); shgroup->type = DRW_SHG_TRIANGLE_BATCH; shgroup->instance_count = tri_count * 3; @@ -879,7 +879,7 @@ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass) } DRWShadingGroup *DRW_shgroup_instance_create( - struct GPUShader *shader, DRWPass *pass, Gwn_Batch *geom, Gwn_VertFormat *format) + struct GPUShader *shader, DRWPass *pass, GPUBatch *geom, GPUVertFormat *format) { DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); shgroup->type = DRW_SHG_INSTANCE; @@ -903,7 +903,7 @@ DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPas } DRWShadingGroup *DRW_shgroup_line_batch_create_with_format( - struct GPUShader *shader, DRWPass *pass, Gwn_VertFormat *format) + struct GPUShader *shader, DRWPass *pass, GPUVertFormat *format) { DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); shgroup->type = DRW_SHG_LINE_BATCH; @@ -930,7 +930,7 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DR #endif DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); - /* Calling drw_shgroup_init will cause it to call GWN_draw_primitive(). */ + /* Calling drw_shgroup_init will cause it to call GPU_draw_primitive(). */ drw_shgroup_init(shgroup, shader); shgroup->type = DRW_SHG_TRIANGLE_BATCH; @@ -939,7 +939,7 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DR return shgroup; } -DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, Gwn_VertBuf *tf_target) +DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, GPUVertBuf *tf_target) { BLI_assert(tf_target != NULL); DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); @@ -953,7 +953,7 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, } /* Specify an external batch instead of adding each attrib one by one. */ -void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batch) +void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch) { BLI_assert(shgroup->type == DRW_SHG_INSTANCE); BLI_assert(shgroup->instance_count == 0); @@ -966,7 +966,7 @@ void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batc /* Note: This WILL break if batch->verts[0] is destroyed and reallocated * at the same adress. Bindings/VAOs would remain obsolete. */ //if (shgroup->instancing_geom->inst != batch->verts[0]) - GWN_batch_instbuf_set(shgroup->instance_geom, batch->verts[0], false); + GPU_batch_instbuf_set(shgroup->instance_geom, batch->verts[0], false); #ifdef USE_GPU_SELECT shgroup->override_selectid = DST.select_id; diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 5957643d090..1134f421c16 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -827,29 +827,29 @@ static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCallState *state) } static void draw_geometry_execute_ex( - DRWShadingGroup *shgroup, Gwn_Batch *geom, uint start, uint count, bool draw_instance) + DRWShadingGroup *shgroup, GPUBatch *geom, uint start, uint count, bool draw_instance) { /* Special case: empty drawcall, placement is done via shader, don't bind anything. */ /* TODO use DRW_CALL_PROCEDURAL instead */ if (geom == NULL) { BLI_assert(shgroup->type == DRW_SHG_TRIANGLE_BATCH); /* Add other type if needed. */ /* Shader is already bound. */ - GWN_draw_primitive(GWN_PRIM_TRIS, count); + GPU_draw_primitive(GPU_PRIM_TRIS, count); return; } /* step 2 : bind vertex array & draw */ - GWN_batch_program_set_no_use( + GPU_batch_program_set_no_use( geom, GPU_shader_get_program(shgroup->shader), GPU_shader_get_interface(shgroup->shader)); /* XXX hacking gawain. we don't want to call glUseProgram! (huge performance loss) */ geom->program_in_use = true; - GWN_batch_draw_range_ex(geom, start, count, draw_instance); + GPU_batch_draw_range_ex(geom, start, count, draw_instance); geom->program_in_use = false; /* XXX hacking gawain */ } -static void draw_geometry_execute(DRWShadingGroup *shgroup, Gwn_Batch *geom) +static void draw_geometry_execute(DRWShadingGroup *shgroup, GPUBatch *geom) { draw_geometry_execute_ex(shgroup, geom, 0, 0, false); } @@ -1055,9 +1055,9 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) if (G.f & G_PICKSEL) { \ if (_shgroup->override_selectid == -1) { \ /* Hack : get vbo data without actually drawing. */ \ - Gwn_VertBufRaw raw; \ - GWN_vertbuf_attr_get_raw_data(_shgroup->inst_selectid, 0, &raw); \ - select_id = GWN_vertbuf_raw_step(&raw); \ + GPUVertBufRaw raw; \ + GPU_vertbuf_attr_get_raw_data(_shgroup->inst_selectid, 0, &raw); \ + select_id = GPU_vertbuf_raw_step(&raw); \ switch (_shgroup->type) { \ case DRW_SHG_TRIANGLE_BATCH: _count = 3; break; \ case DRW_SHG_LINE_BATCH: _count = 2; break; \ @@ -1168,7 +1168,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) call->generate.geometry_fn(shgroup, draw_geometry_execute, call->generate.user_data); break; case DRW_CALL_PROCEDURAL: - GWN_draw_primitive(call->procedural.prim_type, call->procedural.vert_count); + GPU_draw_primitive(call->procedural.prim_type, call->procedural.vert_count); break; default: BLI_assert(0); diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c index e4c0877b907..edeb6c07733 100644 --- a/source/blender/draw/intern/draw_manager_profiling.c +++ b/source/blender/draw/intern/draw_manager_profiling.c @@ -305,7 +305,7 @@ void DRW_stats_draw(rcti *rect) /* Memory Stats */ uint tex_mem = GPU_texture_memory_usage_get(); - uint vbo_mem = GWN_vertbuf_get_memory_usage(); + uint vbo_mem = GPU_vertbuf_get_memory_usage(); sprintf(stat_string, "GPU Memory"); draw_stat(rect, 0, v, stat_string, sizeof(stat_string)); diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 688712a97b6..05aecea1d7a 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -214,9 +214,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** glDepthMask(GL_FALSE); /* disable write in zbuffer */ #endif - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); @@ -253,7 +253,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** if (gridline_len == 0) goto drawgrid_cleanup; /* nothing to draw */ - immBegin(GWN_PRIM_LINES, gridline_len * 2); + immBegin(GPU_PRIM_LINES, gridline_len * 2); } float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar); @@ -306,7 +306,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** if (gridline_len == 0) goto drawgrid_cleanup; /* nothing to draw */ - immBegin(GWN_PRIM_LINES, gridline_len * 2); + immBegin(GPU_PRIM_LINES, gridline_len * 2); if (grids_to_draw == 2) { UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2); @@ -381,13 +381,13 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3]; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_len); + immBegin(GPU_PRIM_LINES, vertex_len); /* draw normal grid lines */ UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10); @@ -469,12 +469,12 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) if (show_axis_x || show_axis_y || show_axis_z) { /* draw axis lines -- sometimes grid floor is off, other times we still need to draw the Z axis */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2); + immBegin(GPU_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2); if (show_axis_x) { UI_make_axis_color(col_grid, col_axis, 'X'); @@ -582,9 +582,9 @@ void DRW_draw_background(void) /* Gradient background Color */ glDisable(GL_DEPTH_TEST); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); uchar col_hi[3], col_lo[3]; GPU_matrix_push(); @@ -596,7 +596,7 @@ void DRW_draw_background(void) UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo); UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib3ubv(color, col_lo); immVertex2f(pos, -1.0f, -1.0f); immVertex2f(pos, 1.0f, -1.0f); @@ -689,10 +689,10 @@ void DRW_draw_cursor(void) /* Draw lines */ if (is_aligned == false) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor3(TH_VIEW_OVERLAY); - immBegin(GWN_PRIM_LINES, 12); + immBegin(GPU_PRIM_LINES, 12); const float scale = ED_view3d_pixel_size_no_ui_scale(rv3d, cursor->location) * U.widget_unit; @@ -727,11 +727,11 @@ void DRW_draw_cursor(void) GPU_matrix_translate_2f(co[0] + 0.5f, co[1] + 0.5f); GPU_matrix_scale_2f(U.widget_unit, U.widget_unit); - Gwn_Batch *cursor_batch = DRW_cache_cursor_get(is_aligned); + GPUBatch *cursor_batch = DRW_cache_cursor_get(is_aligned); GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR); - GWN_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader)); + GPU_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader)); - GWN_batch_draw(cursor_batch); + GPU_batch_draw(cursor_batch); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c index 50ce29b7b1a..c8b8f678ca6 100644 --- a/source/blender/draw/modes/edit_curve_mode.c +++ b/source/blender/draw/modes/edit_curve_mode.c @@ -244,7 +244,7 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob) { Curve *cu = ob->data; /* Get geometry cache */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; geom = DRW_cache_curve_edge_wire_get(ob); DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat); diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c index 870dd14d677..ca7903c555b 100644 --- a/source/blender/draw/modes/edit_lattice_mode.c +++ b/source/blender/draw/modes/edit_lattice_mode.c @@ -196,7 +196,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob) if (ob->type == OB_LATTICE) { if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) { /* Get geometry cache */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; geom = DRW_cache_lattice_wire_get(ob, true); DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat); diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index b402494dfb5..67a424b8081 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -432,7 +432,7 @@ static void EDIT_MESH_cache_init(void *vedata) DRW_shgroup_uniform_block(stl->g_data->facefill_occluded_shgrp, "globalsBlock", globals_ubo); /* we need a full screen pass to combine the result */ - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); psl->mix_occlude = DRW_pass_create( "Mix Occluded Wires", @@ -450,7 +450,7 @@ static void edit_mesh_add_ob_to_pass( Scene *scene, Object *ob, DRWShadingGroup *face_shgrp, DRWShadingGroup *ledges_shgrp, DRWShadingGroup *lverts_shgrp, DRWShadingGroup *facedot_shgrp, DRWShadingGroup *facefill_shgrp) { - struct Gwn_Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter; + struct GPUBatch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter; ToolSettings *tsettings = scene->toolsettings; DRW_cache_mesh_wire_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts); @@ -477,7 +477,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob) const DRWContextState *draw_ctx = DRW_context_state_get(); View3D *v3d = draw_ctx->v3d; Scene *scene = draw_ctx->scene; - struct Gwn_Batch *geom; + struct GPUBatch *geom; if (ob->type == OB_MESH) { if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) { @@ -512,7 +512,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob) } if (vnormals_do || lnormals_do) { - struct Gwn_Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts; + struct GPUBatch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts; DRW_cache_mesh_normals_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts); if (vnormals_do) { diff --git a/source/blender/draw/modes/edit_surface_mode.c b/source/blender/draw/modes/edit_surface_mode.c index 7074ba3d024..3c5d0dbf5a1 100644 --- a/source/blender/draw/modes/edit_surface_mode.c +++ b/source/blender/draw/modes/edit_surface_mode.c @@ -180,7 +180,7 @@ static void EDIT_SURFACE_cache_populate(void *vedata, Object *ob) if (ob->type == OB_MESH) { /* Get geometry cache */ - struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob); /* Add geom to a shading group */ DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat); diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c index 5750dc8a0b9..f21715ef399 100644 --- a/source/blender/draw/modes/edit_text_mode.c +++ b/source/blender/draw/modes/edit_text_mode.c @@ -197,7 +197,7 @@ static void EDIT_TEXT_cache_populate(void *vedata, Object *ob) if (ob == draw_ctx->object_edit) { const Curve *cu = ob->data; /* Get geometry cache */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; if (cu->flag & CU_FAST) { geom = DRW_cache_text_edge_wire_get(ob); diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 386261b64d7..dc499987c8a 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -255,9 +255,9 @@ typedef struct OBJECT_PrivateData { static struct { /* Instance Data format */ - struct Gwn_VertFormat *particle_format; - struct Gwn_VertFormat *empty_image_format; - struct Gwn_VertFormat *empty_image_wire_format; + struct GPUVertFormat *particle_format; + struct GPUVertFormat *empty_image_format; + struct GPUVertFormat *empty_image_wire_format; /* fullscreen shaders */ GPUShader *outline_prepass_sh; @@ -851,7 +851,7 @@ static void DRW_shgroup_empty_image( {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}, }); - struct Gwn_Batch *geom = DRW_cache_image_plane_get(); + struct GPUBatch *geom = DRW_cache_image_plane_get(); DRWShadingGroup *grp = DRW_shgroup_instance_create( e_data.object_empty_image_sh, psl->non_meshes, geom, e_data.empty_image_format); DRW_shgroup_uniform_texture(grp, "image", tex); @@ -871,7 +871,7 @@ static void DRW_shgroup_empty_image( {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16} }); - struct Gwn_Batch *geom = DRW_cache_image_plane_wire_get(); + struct GPUBatch *geom = DRW_cache_image_plane_wire_get(); DRWShadingGroup *grp = DRW_shgroup_instance_create( e_data.object_empty_image_wire_sh, psl->non_meshes, geom, e_data.empty_image_wire_format); DRW_shgroup_uniform_vec2(grp, "aspect", empty_image_data->image_aspect, 1); @@ -940,8 +940,8 @@ static void OBJECT_cache_init(void *vedata) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_POINT; DRWPass *pass = psl->lightprobes = DRW_pass_create("Object Probe Pass", state); - struct Gwn_Batch *sphere = DRW_cache_sphere_get(); - struct Gwn_Batch *quad = DRW_cache_quad_get(); + struct GPUBatch *sphere = DRW_cache_sphere_get(); + struct GPUBatch *quad = DRW_cache_quad_get(); /* Cubemap */ g_data->lightprobes_cube_select = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_select); @@ -960,7 +960,7 @@ static void OBJECT_cache_init(void *vedata) { DRWState state = DRW_STATE_WRITE_COLOR; - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); /* Don't occlude the "outline" detection pass if in xray mode (too much flickering). */ float alphaOcclu = (xray_enabled) ? 1.0f : 0.35f; /* Reminder : bool uniforms need to be 4 bytes. */ @@ -1000,7 +1000,7 @@ static void OBJECT_cache_init(void *vedata) DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND; psl->outlines_resolve = DRW_pass_create("Outlines Resolve Pass", state); - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); GPUTexture **outline_tx = (do_outline_expand) ? &e_data.outlines_blur_tx : &e_data.outlines_color_tx; DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_aa_sh, psl->outlines_resolve); @@ -1014,7 +1014,7 @@ static void OBJECT_cache_init(void *vedata) DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND; psl->grid = DRW_pass_create("Infinite Grid Pass", state); - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); static float mat[4][4]; unit_m4(mat); @@ -1075,7 +1075,7 @@ static void OBJECT_cache_init(void *vedata) { /* Non Meshes Pass (Camera, empties, lamps ...) */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | @@ -1221,7 +1221,7 @@ static void OBJECT_cache_init(void *vedata) /* TODO * for now we create multiple times the same VBO with only lamp center coordinates * but ideally we would only create it once */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; /* start with buflimit because we don't want stipples */ geom = DRW_cache_single_line_get(); @@ -1273,7 +1273,7 @@ static void OBJECT_cache_init(void *vedata) { /* -------- STIPPLES ------- */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; /* Relationship Lines */ stl->g_data->relationship_lines = shgroup_dynlines_dashed_uniform_color(psl->non_meshes, ts.colorWire); @@ -2252,7 +2252,7 @@ static void OBJECT_cache_populate_particles(Object *ob, unit_m4(mat); if (draw_as != PART_DRAW_PATH) { - struct Gwn_Batch *geom = DRW_cache_particles_get_dots(ob, psys); + struct GPUBatch *geom = DRW_cache_particles_get_dots(ob, psys); DRWShadingGroup *shgrp = NULL; static int screen_space[2] = {0, 1}; static float def_prim_col[3] = {0.5f, 0.5f, 0.5f}; @@ -2335,7 +2335,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (do_outlines) { if ((ob != draw_ctx->object_edit) && !((ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT))) { - struct Gwn_Batch *geom; + struct GPUBatch *geom; const bool xray_enabled = ((v3d->shading.flag & V3D_SHADING_XRAY) != 0) && (v3d->shading.type < OB_MATERIAL); if (xray_enabled) { @@ -2363,7 +2363,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (ob != draw_ctx->object_edit) { Mesh *me = ob->data; if (me->totedge == 0) { - struct Gwn_Batch *geom = DRW_cache_mesh_verts_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_verts_get(ob); if (geom) { if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); @@ -2374,7 +2374,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) } } else { - struct Gwn_Batch *geom = DRW_cache_mesh_loose_edges_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_loose_edges_get(ob); if (geom) { if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); @@ -2395,7 +2395,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (hide_object_extra) { break; } - struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false); + struct GPUBatch *geom = DRW_cache_lattice_wire_get(ob, false); if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } @@ -2411,7 +2411,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (hide_object_extra) { break; } - struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob); + struct GPUBatch *geom = DRW_cache_curve_edge_wire_get(ob); if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c index a67c7ffb131..e3c986bde5a 100644 --- a/source/blender/draw/modes/overlay_mode.c +++ b/source/blender/draw/modes/overlay_mode.c @@ -175,7 +175,7 @@ static void overlay_cache_populate(void *vedata, Object *ob) return; if (stl->g_data->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) { - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { DRW_shgroup_call_add(pd->face_orientation_shgrp, geom, ob->obmat); } diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c index 85cff28b313..8256bb4d0d7 100644 --- a/source/blender/draw/modes/paint_texture_mode.c +++ b/source/blender/draw/modes/paint_texture_mode.c @@ -293,9 +293,9 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) if (use_surface) { if (me->mloopuv != NULL) { if (use_material_slots) { - struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; + struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; if ((me->totcol == 0) || (geom_array == NULL)) { - struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob); DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat); ok = true; } @@ -312,7 +312,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) } } else { - struct Gwn_Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob); if (geom && stl->g_data->shgroup_image_array[0]) { DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat); ok = true; @@ -321,7 +321,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) } if (!ok) { - struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob); DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat); } } @@ -329,7 +329,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) /* Face Mask */ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; if (use_face_sel) { - struct Gwn_Batch *geom; + struct GPUBatch *geom; /* Note: ideally selected faces wouldn't show interior wire. */ const bool use_wire = true; geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, use_face_sel); diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c index 9cf6ea52d33..33af72e8616 100644 --- a/source/blender/draw/modes/paint_vertex_mode.c +++ b/source/blender/draw/modes/paint_vertex_mode.c @@ -150,7 +150,7 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob) const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; const bool use_surface = v3d->overlay.vertex_paint_mode_opacity != 0.0f; const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; - struct Gwn_Batch *geom; + struct GPUBatch *geom; if (use_surface) { geom = DRW_cache_mesh_surface_vert_colors_get(ob); diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index 14fae743d8c..d4fc73e7f88 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -190,7 +190,7 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob) const bool use_surface = v3d->overlay.weight_paint_mode_opacity != 0.0f; const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; - struct Gwn_Batch *geom; + struct GPUBatch *geom; if (use_surface) { geom = DRW_cache_mesh_surface_weights_get(ob); diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c index 19c3ddd4b50..f4879483540 100644 --- a/source/blender/draw/modes/particle_mode.c +++ b/source/blender/draw/modes/particle_mode.c @@ -148,17 +148,17 @@ static void particle_edit_cache_populate(void *vedata, const DRWContextState *draw_ctx = DRW_context_state_get(); ParticleEditSettings *pset = PE_settings(draw_ctx->scene); { - struct Gwn_Batch *strands = + struct GPUBatch *strands = DRW_cache_particles_get_edit_strands(object, psys, edit); DRW_shgroup_call_add(stl->g_data->strands_group, strands, NULL); } if (pset->selectmode == SCE_SELECT_POINT) { - struct Gwn_Batch *points = + struct GPUBatch *points = DRW_cache_particles_get_edit_inner_points(object, psys, edit); DRW_shgroup_call_add(stl->g_data->inner_points_group, points, NULL); } if (ELEM(pset->selectmode, SCE_SELECT_POINT, SCE_SELECT_END)) { - struct Gwn_Batch *points = + struct GPUBatch *points = DRW_cache_particles_get_edit_tip_points(object, psys, edit); DRW_shgroup_call_add(stl->g_data->tip_points_group, points, NULL); } diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index 57efc65542c..040195b889b 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -221,7 +221,7 @@ static void POSE_cache_populate(void *vedata, Object *ob) !DRW_state_is_select() && POSE_is_bone_selection_overlay_active()) { - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { if (POSE_is_driven_by_active_armature(ob)) { DRW_shgroup_call_object_add(stl->g_data->bone_selection_shgrp, geom, ob); diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index c70790e0550..3c10cda6456 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -146,7 +146,7 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); @@ -235,7 +235,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); @@ -3868,7 +3868,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* for F-Curves, draw color-preview of curve behind checkbox */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = (FCurve *)ale->data; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -3924,7 +3924,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* draw red underline if channel is disabled */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -3933,7 +3933,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float GPU_line_width(2.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, (float)offset, yminc); immVertex2f(pos, (float)v2d->cur.xmax, yminc); immEnd(); @@ -3952,7 +3952,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float short draw_sliders = 0; float ymin_ofs = 0.0f; float color[3]; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 129cf07b7c4..780e984f870 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -141,15 +141,15 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) GPU_line_width((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* Draw a light green line to indicate current frame */ immUniformThemeColor(TH_CFRAME); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */ immVertex2f(pos, x, v2d->cur.ymax); immEnd(); @@ -170,8 +170,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_ANIM_ACTIVE, -25, -30); @@ -203,8 +203,8 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -25, -100); @@ -222,7 +222,7 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d) /* thin lines where the actual frames are */ immUniformThemeColorShade(TH_BACK, -60); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, (float)SFRA, v2d->cur.ymin); immVertex2f(pos, (float)SFRA, v2d->cur.ymax); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index f809bff536f..e1f4092c494 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -400,8 +400,8 @@ static void draw_marker( if (flag & DRAW_MARKERS_LINES) #endif { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -418,7 +418,7 @@ static void draw_marker( immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, xpos + 0.5f, 12.0f); immVertex2f(pos, xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); immEnd(); @@ -486,7 +486,7 @@ void ED_markers_draw(const bContext *C, int flag) v2d = UI_view2d_fromcontext(C); if (flag & DRAW_MARKERS_MARGIN) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); const unsigned char shade[4] = {0, 0, 0, 16}; diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 78ce24db503..30130ce4dac 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -593,12 +593,12 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa } if (block_len > 0) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_TRIS, 6 * block_len); + immBegin(GPU_PRIM_TRIS, 6 * block_len); for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) { if (actkeyblock_is_valid(ab, keys)) { if (ab->flag & ACTKEYBLOCK_FLAG_MOVING_HOLD) { @@ -633,14 +633,14 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa if (key_len > 0) { /* draw keys */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, key_len); + immBegin(GPU_PRIM_POINTS, key_len); for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) { if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) { diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 927b8b8514d..dd0430f4f65 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -387,9 +387,9 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS float color[3]; UI_GetThemeColor3fv(TH_WIRE, color); - Gwn_Batch *sphere = GPU_batch_preset_sphere(0); - GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); - GWN_batch_uniform_3fv(sphere, "color", color); + GPUBatch *sphere = GPU_batch_preset_sphere(0); + GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); + GPU_batch_uniform_3fv(sphere, "color", color); /* scale to edit-mode space */ GPU_matrix_push(); @@ -407,7 +407,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS GPU_matrix_push(); GPU_matrix_scale_1f(radius); - GWN_batch_draw(sphere); + GPU_batch_draw(sphere); GPU_matrix_pop(); location_prev = selem->location_local; @@ -430,8 +430,8 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS } { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); GPU_depth_test(false); @@ -440,7 +440,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS GPU_line_width(3.0f); imm_cpack(0x0); - immBegin(GWN_PRIM_LINE_STRIP, stroke_len); + immBegin(GPU_PRIM_LINE_STRIP, stroke_len); for (int i = 0; i < stroke_len; i++) { immVertex3fv(pos, coord_array[i]); } @@ -449,7 +449,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS GPU_line_width(1.0f); imm_cpack(0xffffffff); - immBegin(GWN_PRIM_LINE_STRIP, stroke_len); + immBegin(GPU_PRIM_LINE_STRIP, stroke_len); for (int i = 0; i < stroke_len; i++) { immVertex3fv(pos, coord_array[i]); } diff --git a/source/blender/editors/gizmo_library/gizmo_draw_utils.c b/source/blender/editors/gizmo_library/gizmo_draw_utils.c index aaaee182c71..5ccb1fa1f6d 100644 --- a/source/blender/editors/gizmo_library/gizmo_draw_utils.c +++ b/source/blender/editors/gizmo_library/gizmo_draw_utils.c @@ -64,31 +64,31 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(sel /* TODO store the Batches inside the GizmoGeomInfo and updated it when geom changes * So we don't need to re-created and discard it every time */ - Gwn_VertBuf *vbo; - Gwn_IndexBuf *el; - Gwn_Batch *batch; - Gwn_IndexBufBuilder elb = {0}; + GPUVertBuf *vbo; + GPUIndexBuf *el; + GPUBatch *batch; + GPUIndexBufBuilder elb = {0}; - Gwn_VertFormat format = {0}; - uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat format = {0}; + uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); /* Elements */ - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, info->ntris, info->nverts); + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, info->ntris, info->nverts); for (int i = 0; i < info->ntris; ++i) { const unsigned short *idx = &info->indices[i * 3]; - GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]); + GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]); } - el = GWN_indexbuf_build(&elb); + el = GPU_indexbuf_build(&elb); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, info->nverts); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, info->nverts); - GWN_vertbuf_attr_fill(vbo, pos_id, info->verts); + GPU_vertbuf_attr_fill(vbo, pos_id, info->verts); - batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, el, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); + batch = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, el, GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); - GWN_batch_uniform_4fv(batch, "color", color); + GPU_batch_uniform_4fv(batch, "color", color); /* We may want to re-visit this, for now disable * since it causes issues leaving the GL state modified. */ @@ -97,7 +97,7 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(sel GPU_depth_test(true); #endif - GWN_batch_draw(batch); + GPU_batch_draw(batch); #if 0 GPU_depth_test(false); @@ -105,7 +105,7 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(sel #endif - GWN_batch_discard(batch); + GPU_batch_discard(batch); } void wm_gizmo_vec_draw( diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c index 673e38e4a1a..cb8e2a90b07 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c @@ -70,7 +70,7 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float const float arrow_length = RNA_float_get(gz->ptr, "length") - size_length; const float arrow_angle = RNA_float_get(gz->ptr, "angle"); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_matrix_push(); GPU_matrix_mul(matrix); @@ -80,12 +80,12 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float immUniformColor4fv(color); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, 0.0f, 0.0f); immVertex2f(pos, 0.0f, arrow_length); immEnd(); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2f(pos, size_breadth, arrow_length); immVertex2f(pos, -size_breadth, arrow_length); immVertex2f(pos, 0.0f, arrow_length + size_length); diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index da4bce680b8..0f8389af17d 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -90,7 +90,7 @@ static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4] static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4]) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); bool unbind_shader = true; const int draw_style = RNA_enum_get(arrow->gizmo.ptr, "draw_style"); const int draw_options = RNA_enum_get(arrow->gizmo.ptr, "draw_options"); @@ -100,7 +100,7 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) { immUniformColor4fv(color); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex3f(pos, -1.0f, 0.0f, 0.0f); immVertex3f(pos, 1.0f, 0.0f, 0.0f); immVertex3f(pos, 0.0f, -1.0f, 0.0f); @@ -120,7 +120,7 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const }; GPU_line_width(arrow->gizmo.line_width); - wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP); + wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_LOOP); } else { #ifdef USE_GIZMO_CUSTOM_ARROWS @@ -135,7 +135,7 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) { GPU_line_width(arrow->gizmo.line_width); - wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP); + wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_STRIP); } else { immUniformColor4fv(color); diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index 13711325038..d976adc06bf 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -72,7 +72,7 @@ typedef struct ButtonGizmo2D { bool is_init; /* Use an icon or shape */ int icon; - Gwn_Batch *shape_batch[2]; + GPUBatch *shape_batch[2]; } ButtonGizmo2D; #define CIRCLE_RESOLUTION 32 @@ -84,8 +84,8 @@ static void button2d_geom_draw_backdrop( { GPU_line_width(gz->line_width); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -137,12 +137,12 @@ static void button2d_draw_intern( if (draw_options & ED_GIZMO_BUTTON_SHOW_HELPLINE) { float matrix_final_no_offset[4][4]; WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); GPU_line_width(gz->line_width); immUniformColor4fv(color); - immBegin(GWN_PRIM_LINE_STRIP, 2); + immBegin(GPU_PRIM_LINE_STRIP, 2); immVertex3fv(pos, matrix_final[3]); immVertex3fv(pos, matrix_final_no_offset[3]); immEnd(); @@ -177,9 +177,9 @@ static void button2d_draw_intern( GPU_line_width(1.0f); for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) { /* Invert line color for wire. */ - GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR); - GWN_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color)); - GWN_batch_draw(button->shape_batch[i]); + GPU_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR); + GPU_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color)); + GPU_batch_draw(button->shape_batch[i]); if (draw_options & ED_GIZMO_BUTTON_SHOW_OUTLINE) { color[0] = 1.0f - color[0]; @@ -270,7 +270,7 @@ static void gizmo_button2d_free(wmGizmo *gz) ButtonGizmo2D *shape = (ButtonGizmo2D *)gz; for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) { - GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]); + GPU_BATCH_DISCARD_SAFE(shape->shape_batch[i]); } } diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index 5e3b7bb21c6..2869b93a790 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -136,12 +136,12 @@ static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_con static void cage2d_draw_box_corners( const rctf *r, const float margin[2], const float color[3]) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fv(color); - immBegin(GWN_PRIM_LINES, 16); + immBegin(GPU_PRIM_LINES, 16); immVertex2f(pos, r->xmin, r->ymin + margin[1]); immVertex2f(pos, r->xmin, r->ymin); @@ -176,7 +176,7 @@ static void cage2d_draw_box_interaction( /* 4 verts for translate, otherwise only 3 are used. */ float verts[4][2]; uint verts_len = 0; - Gwn_PrimType prim_type = GWN_PRIM_NONE; + GPUPrimType prim_type = GPU_PRIM_NONE; switch (highlighted) { case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X: @@ -192,10 +192,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin); verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -212,10 +212,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax); ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -232,10 +232,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax); verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -252,10 +252,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin); ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -272,10 +272,10 @@ static void cage2d_draw_box_interaction( if (is_solid) { ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -292,10 +292,10 @@ static void cage2d_draw_box_interaction( if (is_solid) { ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax); verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -312,10 +312,10 @@ static void cage2d_draw_box_interaction( if (is_solid) { ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin); verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -332,10 +332,10 @@ static void cage2d_draw_box_interaction( if (is_solid) { ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymax); verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -355,10 +355,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[3], r_rotate.xmax, r_rotate.ymin); verts_len = 4; if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -371,10 +371,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[3], margin[0] / 2, -margin[1] / 2); verts_len = 4; if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINES; + prim_type = GPU_PRIM_LINES; } } else { @@ -385,12 +385,12 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[3], size[0], -size[1]); verts_len = 4; if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { /* unreachable */ BLI_assert(0); - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } } break; @@ -398,20 +398,20 @@ static void cage2d_draw_box_interaction( return; } - BLI_assert(prim_type != GWN_PRIM_NONE); + BLI_assert(prim_type != GPU_PRIM_NONE); - Gwn_VertFormat *format = immVertexFormat(); + GPUVertFormat *format = immVertexFormat(); struct { uint pos, col; } attr_id = { - .pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT), - .col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT), + .pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT), + .col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT), }; immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); { if (is_solid) { - BLI_assert(ELEM(prim_type, GWN_PRIM_TRI_FAN)); + BLI_assert(ELEM(prim_type, GPU_PRIM_TRI_FAN)); immBegin(prim_type, verts_len); immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f); for (uint i = 0; i < verts_len; i++) { @@ -420,7 +420,7 @@ static void cage2d_draw_box_interaction( immEnd(); } else { - BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES)); + BLI_assert(ELEM(prim_type, GPU_PRIM_LINE_STRIP, GPU_PRIM_LINES)); GPU_line_width(line_width + 3.0f); immBegin(prim_type, verts_len); @@ -455,7 +455,7 @@ static void cage2d_draw_box_interaction( static void imm_draw_point_aspect_2d( uint pos, float x, float y, float rad_x, float rad_y, bool solid) { - immBegin(solid ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4); + immBegin(solid ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x - rad_x, y - rad_y); immVertex2f(pos, x - rad_x, y + rad_y); immVertex2f(pos, x + rad_x, y + rad_y); @@ -467,12 +467,12 @@ static void cage2d_draw_circle_wire( const rctf *r, const float margin[2], const float color[3], const int transform_flag, const int draw_options) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fv(color); - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, r->xmin, r->ymin); immVertex2f(pos, r->xmax, r->ymin); immVertex2f(pos, r->xmax, r->ymax); @@ -480,7 +480,7 @@ static void cage2d_draw_circle_wire( immEnd(); if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { - immBegin(GWN_PRIM_LINE_LOOP, 2); + immBegin(GPU_PRIM_LINE_LOOP, 2); immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax); immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax + margin[1]); immEnd(); @@ -491,7 +491,7 @@ static void cage2d_draw_circle_wire( const float rad[2] = {margin[0] / 2, margin[1] / 2}; const float center[2] = {BLI_rctf_cent_x(r), BLI_rctf_cent_y(r)}; - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]); immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]); immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]); @@ -508,7 +508,7 @@ static void cage2d_draw_circle_handles( const int transform_flag, bool solid) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); void (*circle_fn)(uint, float, float, float, float, int) = (solid) ? imm_draw_circle_fill_aspect_2d : imm_draw_circle_wire_aspect_2d; const int resolu = 12; @@ -560,7 +560,7 @@ static void gizmo_cage2d_draw_intern( /* Handy for quick testing draw (if it's outside bounds). */ if (false) { GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); float s = 0.5f; diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index 9cad82619ba..0f1d309c927 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -150,7 +150,7 @@ static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_con static void cage3d_draw_box_corners( const float r[3], const float margin[3], const float color[3]) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); UNUSED_VARS(margin); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -185,7 +185,7 @@ static void cage3d_draw_box_interaction( const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3}; { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3fv(color); imm_draw_cube_fill_3d(pos, co, rad); @@ -217,7 +217,7 @@ static void cage3d_draw_circle_wire( const float r[3], const float margin[3], const float color[3], const int transform_flag, const int draw_options) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3fv(color); @@ -230,7 +230,7 @@ static void cage3d_draw_circle_wire( const float rad[2] = {margin[0] / 2, margin[1] / 2}; const float center[2] = {0.0f, 0.0f}; - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]); immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]); immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]); @@ -251,7 +251,7 @@ static void cage3d_draw_circle_handles( const float r[3], const float margin[3], const float color[3], bool solid, float scale) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3}; immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -305,7 +305,7 @@ static void gizmo_cage3d_draw_intern( /* Handy for quick testing draw (if it's outside bounds). */ if (false) { GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); float s = 0.5f; diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c index 300ae222189..8e04703c14e 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -126,8 +126,8 @@ static void dial_geom_draw( GPU_line_width(gz->line_width); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (clip_plane) { immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR); @@ -164,13 +164,13 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[ GPU_matrix_push(); GPU_matrix_rotate_3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); - immBegin(GWN_PRIM_LINE_STRIP, 2); + immBegin(GPU_PRIM_LINE_STRIP, 2); immVertex3f(pos, 0.0f, 0.0f, 0.0f); immVertex3fv(pos, co_outer); immEnd(); @@ -185,8 +185,8 @@ static void dial_ghostarc_draw( { const float width_inner = DIAL_WIDTH - gz->line_width * 0.5f / U.gizmo_size; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); imm_draw_disk_partial_fill_2d( diff --git a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c index 840ea793b89..8d4db81c11f 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c @@ -105,8 +105,8 @@ static void grab_geom_draw( GPU_line_width(gz->line_width); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -121,7 +121,7 @@ static void grab_geom_draw( } } else if (draw_style == ED_GIZMO_GRAB_STYLE_CROSS_2D) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, 1.0f, 1.0f); immVertex2f(pos, -1.0f, -1.0f); diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c index b61c16b8d65..6443a6bf038 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c @@ -77,10 +77,10 @@ static void gizmo_primitive_draw_geom( } if (vert_count > 0) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - wm_gizmo_vec_draw(col_inner, verts, vert_count, pos, GWN_PRIM_TRI_FAN); - wm_gizmo_vec_draw(col_outer, verts, vert_count, pos, GWN_PRIM_LINE_LOOP); + wm_gizmo_vec_draw(col_inner, verts, vert_count, pos, GPU_PRIM_TRI_FAN); + wm_gizmo_vec_draw(col_outer, verts, vert_count, pos, GPU_PRIM_LINE_LOOP); immUnbindProgram(); } } diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index ec4310213ef..29b24886017 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -150,14 +150,14 @@ static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, f /* draw triangulation data */ if (tot_triangles > 0) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); /* Draw all triangles for filling the polygon */ - immBegin(GWN_PRIM_TRIS, tot_triangles * 3); + immBegin(GPU_PRIM_TRIS, tot_triangles * 3); /* TODO: use batch instead of immediate mode, to share vertices */ const tGPspoint *pt; @@ -208,9 +208,9 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short return; } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); const tGPspoint *pt = points; @@ -218,7 +218,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short /* if drawing a single point, draw it larger */ GPU_point_size((float)(thickness + 2) * points->pressure); immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); gp_set_tpoint_varying_color(pt, ink, color); immVertex2iv(pos, &pt->x); } @@ -228,7 +228,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short /* draw stroke curve */ GPU_line_width(max_ff(oldpressure * thickness, 1.0)); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints); /* TODO: implement this with a geometry shader to draw one continuous tapered stroke */ @@ -247,7 +247,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short draw_points = 0; GPU_line_width(max_ff(pt->pressure * thickness, 1.0f)); - immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1); /* need to roll-back one point to ensure that there are no gaps in the stroke */ if (i != 0) { @@ -319,14 +319,14 @@ static void gp_draw_stroke_volumetric_buffer(const tGPspoint *points, int totpoi if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) return; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, totpoints); + immBegin(GPU_PRIM_POINTS, totpoints); const tGPspoint *pt = points; for (int i = 0; i < totpoints; i++, pt++) { @@ -346,14 +346,14 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points, int totpoints int offsx, int offsy, int winx, int winy, const float diff_mat[4][4], const float ink[4]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, totpoints); + immBegin(GPU_PRIM_POINTS, totpoints); const bGPDspoint *pt = points; for (int i = 0; i < totpoints; i++, pt++) { @@ -379,14 +379,14 @@ static void gp_draw_stroke_volumetric_3d( const bGPDspoint *points, int totpoints, short thickness, const float ink[4]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, totpoints); + immBegin(GPU_PRIM_POINTS, totpoints); const bGPDspoint *pt = points; for (int i = 0; i < totpoints && pt; i++, pt++) { @@ -519,18 +519,18 @@ static void gp_draw_stroke_fill( uint pos; if (gps->flag & GP_STROKE_3DSPACE) { - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); } else { - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); } immUniformColor4fv(color); /* Draw all triangles for filling the polygon (cache must be calculated before) */ - immBegin(GWN_PRIM_TRIS, gps->tot_triangles * 3); + immBegin(GPU_PRIM_TRIS, gps->tot_triangles * 3); /* TODO: use batch instead of immediate mode, to share vertices */ bGPDtriangle *stroke_triangle = gps->triangles; @@ -575,8 +575,8 @@ static void gp_draw_stroke_point( float fpt[3]; mul_v3_m4v3(fpt, diff_mat, &pt->x); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); if (sflag & GP_STROKE_3DSPACE) { immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); @@ -594,7 +594,7 @@ static void gp_draw_stroke_point( /* set point thickness (since there's only one of these) */ immUniform1f("size", (float)(thickness + 2) * pt->pressure); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, fpt); immEnd(); @@ -617,9 +617,9 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR); @@ -627,7 +627,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi /* draw stroke curve */ GPU_line_width(max_ff(curpressure * thickness, 1.0f)); - immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints + cyclic_add); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints + cyclic_add); const bGPDspoint *pt = points; for (int i = 0; i < totpoints; i++, pt++) { gp_set_point_varying_color(pt, ink, color); @@ -648,7 +648,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi curpressure = pt->pressure; GPU_line_width(max_ff(curpressure * thickness, 1.0f)); - immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add); /* need to roll-back one point to ensure that there are no gaps in the stroke */ if (i != 0) { @@ -716,12 +716,12 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, int totpoints, short thi int i; float fpt[3]; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_TRI_STRIP, totpoints * 2 + 4); + immBegin(GPU_PRIM_TRI_STRIP, totpoints * 2 + 4); /* get x and y coordinates from first point */ mul_v3_m4v3(fpt, diff_mat, &points->x); @@ -1150,21 +1150,21 @@ static void gp_draw_strokes_edit( UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, selectColor); selectColor[3] = alpha; - Gwn_VertFormat *format = immVertexFormat(); + GPUVertFormat *format = immVertexFormat(); uint pos; /* specified later */ - uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); if (gps->flag & GP_STROKE_3DSPACE) { - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); } else { - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR); } - immBegin(GWN_PRIM_POINTS, gps->totpoints); + immBegin(GPU_PRIM_POINTS, gps->totpoints); /* Draw start and end point differently if enabled stroke direction hint */ bool show_direction_hint = (gpd->flag & GP_DATA_SHOW_DIRECTION) && (gps->totpoints > 1); diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index a8810df35ff..bd9bfcf7025 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -985,8 +985,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda GP_EditBrush_Data *brush = gpsculpt_get_brush(CTX_data_scene(C)); if (brush) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_smooth(true); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index ec8a213301f..789e9865ae4 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1875,8 +1875,8 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) tGPsdata *p = (tGPsdata *)p_ptr; if (p->paintmode == GP_PAINTMODE_ERASER) { - Gwn_VertFormat *format = immVertexFormat(); - const uint shdr_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + const uint shdr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_smooth(true); diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index 9b0b2c970b2..64dee410526 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -109,7 +109,7 @@ typedef enum eKeyframeShapeDrawOpts { } eKeyframeShapeDrawOpts; /* draw simple diamond-shape keyframe */ -/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(GWN_PRIM_POINTS, n), then call this n times */ +/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(GPU_PRIM_POINTS, n), then call this n times */ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type, short mode, float alpha, unsigned int pos_id, unsigned int size_id, unsigned int color_id, unsigned int outline_color_id); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index b1c3795b1af..6a304a8150e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -130,19 +130,19 @@ void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, float /* WATCH: This is assuming the ModelViewProjectionMatrix is area pixel space. * If it has been scaled, then it's no longer valid. */ - Gwn_Batch *batch = ui_batch_roundbox_get(filled, true); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, true); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } else { /* plain antialiased unfilled box */ GPU_line_smooth(true); - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); GPU_line_smooth(false); } @@ -159,8 +159,8 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float }; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* mult */ for (a = 0; a < 7; a++) { @@ -176,7 +176,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_len); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_len); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { immVertex2f(pos, maxx - rad, miny); @@ -244,10 +244,10 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } #if 0 @@ -280,9 +280,9 @@ void UI_draw_roundbox_shade_x( int vert_count = 0; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -304,7 +304,7 @@ void UI_draw_roundbox_shade_x( vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1; vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1; - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_count); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { @@ -404,10 +404,10 @@ void UI_draw_roundbox_shade_x( .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } #if 0 /* unused */ @@ -432,9 +432,9 @@ void UI_draw_roundbox_shade_y( mul_v2_fl(vec[a], rad); } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -452,7 +452,7 @@ void UI_draw_roundbox_shade_y( vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1; vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1; - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_count); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { @@ -535,8 +535,8 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo { int ofs_y = 4 * U.pixelsize; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); @@ -550,9 +550,9 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo /* based on UI_draw_roundbox_gl_mode, check on making a version which allows us to skip some sides */ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highlight[3], unsigned char highlight_fade[3]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); /* add a 1px offset, looks nicer */ const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - U.pixelsize; const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize; @@ -571,7 +571,7 @@ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highligh } immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBeginAtMost(GWN_PRIM_LINE_STRIP, 25); + immBeginAtMost(GPU_PRIM_LINE_STRIP, 25); immAttrib3ubv(col, highlight); @@ -685,8 +685,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w * * \Note This functionn is to be used with the 2D dashed shader enabled. * - * \param pos is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib - * \param line_origin is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib + * \param pos is a PRIM_FLOAT, 2, GPU_FETCH_FLOAT vertex attrib + * \param line_origin is a PRIM_FLOAT, 2, GPU_FETCH_FLOAT vertex attrib * * The next 4 parameters are the offsets for the view, not the zones. */ @@ -749,7 +749,7 @@ static void histogram_draw_one( /* curve outline */ GPU_line_width(1.5); - immBegin(GWN_PRIM_LINE_STRIP, res); + immBegin(GPU_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); immVertex2f(pos_attrib, x2, y + (data[i] * h)); @@ -758,7 +758,7 @@ static void histogram_draw_one( } else { /* under the curve */ - immBegin(GWN_PRIM_TRI_STRIP, res * 2); + immBegin(GPU_PRIM_TRI_STRIP, res * 2); immVertex2f(pos_attrib, x, y); immVertex2f(pos_attrib, x, y + (data[0] * h)); for (int i = 1; i < res; i++) { @@ -772,7 +772,7 @@ static void histogram_draw_one( immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - immBegin(GWN_PRIM_LINE_STRIP, res); + immBegin(GPU_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); immVertex2f(pos_attrib, x2, y + (data[i] * h)); @@ -818,8 +818,8 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -833,7 +833,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); } - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rect.xmin, rect.ymin + fac * h); immVertex2f(pos, rect.xmax, rect.ymin + fac * h); @@ -869,21 +869,21 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS static void waveform_draw_one(float *waveform, int nbr, const float col[3]) { - Gwn_VertFormat format = {0}; - uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat format = {0}; + uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, nbr); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, nbr); - GWN_vertbuf_attr_fill(vbo, pos_id, waveform); + GPU_vertbuf_attr_fill(vbo, pos_id, waveform); - /* TODO store the Gwn_Batch inside the scope */ - Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); - GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); - GWN_batch_draw(batch); + /* TODO store the GPUBatch inside the scope */ + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); + GPU_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); + GPU_batch_draw(batch); - GWN_batch_discard(batch); + GPU_batch_discard(batch); } void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti) @@ -957,15 +957,15 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); /* draw grid lines here */ - immBegin(GWN_PRIM_LINES, 12); + immBegin(GPU_PRIM_LINES, 12); for (int i = 0; i < 6; i++) { immVertex2f(pos, rect.xmin + 22, yofs + (i * 0.2f) * h); @@ -976,7 +976,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* 3 vertical separation */ if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); for (int i = 1; i < 3; i++) { immVertex2f(pos, rect.xmin + i * w3, rect.ymin); @@ -987,7 +987,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE } /* separate min max zone on the right */ - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin + w, rect.ymin); immVertex2f(pos, rect.xmin + w, rect.ymax); immEnd(); @@ -995,7 +995,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* 16-235-240 level in case of ITU-R BT601/709 */ immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f); if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) { - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(pos, rect.xmin + 22, yofs + h * 16.0f / 255.0f); immVertex2f(pos, rect.xmax + 1, yofs + h * 16.0f / 255.0f); @@ -1013,7 +1013,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE } /* 7.5 IRE black point level for NTSC */ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin, yofs + h * 0.075f); immVertex2f(pos, rect.xmax + 1, yofs + h * 0.075f); immEnd(); @@ -1042,7 +1042,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmax - 3, min); immVertex2f(pos, rect.xmax - 3, max); immEnd(); @@ -1096,7 +1096,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin + w + 2 + c * 2, min); immVertex2f(pos, rect.xmin + w + 2 + c * 2, max); immEnd(); @@ -1140,7 +1140,7 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente immUniformColor4f(1.0f, 1.0f, 1.0f, 0.12f); dangle = DEG2RADF(2.5f); dampli = 2.5f / 200.0f; - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle)); @@ -1152,22 +1152,22 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente dampli = 0.2f * tampli; dangle2 = DEG2RADF(5.0f); dampli2 = 0.5f * dampli; - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2)); @@ -1215,15 +1215,15 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); /* draw grid elements */ /* cross */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery); immVertex2f(pos, centerx + (diam * 0.5f) + 5, centery); @@ -1236,7 +1236,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN /* circles */ for (int j = 0; j < 5; j++) { const int increment = 15; - immBegin(GWN_PRIM_LINE_LOOP, (int)(360 / increment)); + immBegin(GPU_PRIM_LINE_LOOP, (int)(360 / increment)); for (int i = 0; i <= 360 - increment; i += increment) { const float a = DEG2RADF((float)i); const float r = (j + 1) * 0.1f; @@ -1247,7 +1247,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN /* skin tone line */ immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5f, skin_rad)); immVertex2f(pos, polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1f, skin_rad)); immEnd(); @@ -1284,7 +1284,7 @@ static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, floa { GPU_line_smooth(true); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, x1 + halfwidth, y1); immVertex2f(pos, x1, y1 + height); immVertex2f(pos, x1 - halfwidth, y1); @@ -1297,7 +1297,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f { glEnable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH); - immBegin(fill ? GWN_PRIM_TRIS : GWN_PRIM_LINE_LOOP, 3); + immBegin(fill ? GPU_PRIM_TRIS : GPU_PRIM_LINE_LOOP, 3); immVertex2f(pos, x1 + halfwidth, y1); immVertex2f(pos, x1, y1 + height); immVertex2f(pos, x1 - halfwidth, y1); @@ -1308,7 +1308,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f static void ui_draw_colorband_handle_box(unsigned int pos, float x1, float y1, float x2, float y2, bool fill) { - immBegin(fill ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4); + immBegin(fill ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x1, y2); immVertex2f(pos, x2, y2); @@ -1348,7 +1348,7 @@ static void ui_draw_colorband_handle( immUniformArray4fv("colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", active ? 4.0f : 2.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(shdr_pos, x, y1); immVertex2f(shdr_pos, x, y2); immEnd(); @@ -1419,8 +1419,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti float sizey_solid = sizey * 0.25f; float y1 = rect->ymin; - Gwn_VertFormat *format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); /* Drawing the checkerboard. */ @@ -1432,8 +1432,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti /* New format */ format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - col_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + col_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); /* layer: color ramp */ @@ -1447,7 +1447,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti v1[1] = y1 + sizey_solid; v2[1] = rect->ymax; - immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2); + immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2); for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; BKE_colorband_evaluate(coba, pos, colf); @@ -1466,7 +1466,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti v1[1] = y1; v2[1] = y1 + sizey_solid; - immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2); + immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2); for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; BKE_colorband_evaluate(coba, pos, colf); @@ -1487,7 +1487,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti /* New format */ format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* layer: box outline */ @@ -1498,14 +1498,14 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti GPU_blend(true); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos_id, x1, y1); immVertex2f(pos_id, x1 + sizex, y1); immEnd(); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos_id, x1, y1 - 1); immVertex2f(pos_id, x1 + sizex, y1 - 1); immEnd(); @@ -1558,18 +1558,18 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect)); GPU_matrix_scale_1f(size); - Gwn_Batch *sphere = GPU_batch_preset_sphere(2); - GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); - GWN_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f); - GWN_batch_uniform_3fv(sphere, "light", light); - GWN_batch_draw(sphere); + GPUBatch *sphere = GPU_batch_preset_sphere(2); + GPU_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); + GPU_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f); + GPU_batch_uniform_3fv(sphere, "light", light); + GPU_batch_draw(sphere); /* restore */ glDisable(GL_CULL_FACE); /* AA circle */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv((unsigned char *)wcol->inner); @@ -1599,7 +1599,7 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo floorf((rect->xmax - fx) / dx) + 1.0f + floorf((rect->ymax - fy) / dy) + 1.0f); - immBegin(GWN_PRIM_LINES, (int)line_count * 2); + immBegin(GPU_PRIM_LINES, (int)line_count * 2); while (fx < rect->xmax) { immVertex2f(pos, fx, rect->ymin); immVertex2f(pos, fx, rect->ymax); @@ -1675,8 +1675,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti GPU_line_width(1.0f); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* backdrop */ @@ -1712,7 +1712,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ gl_shaded_color((unsigned char *)wcol->inner, -50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (-offsy)); immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (-offsy)); immVertex2f(pos, rect->xmin + zoomx * (-offsx), rect->ymin); @@ -1725,7 +1725,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti #if 0 if (cumap->flag & CUMA_DRAW_CFRA) { immUniformColor3ub(0x60, 0xc0, 0x40); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin); immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax); immEnd(); @@ -1734,7 +1734,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* sample option */ if (cumap->flag & CUMA_DRAW_SAMPLE) { - immBegin(GWN_PRIM_LINES, 2); /* will draw one of the following 3 lines */ + immBegin(GPU_PRIM_LINES, 2); /* will draw one of the following 3 lines */ if (but->a1 == UI_GRAD_H) { float tsample[3]; float hsv[3]; @@ -1770,7 +1770,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti immUniformColor3ubv((unsigned char *)wcol->item); GPU_line_smooth(true); GPU_blend(true); - immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); + immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); if (cuma->table == NULL) curvemapping_changed(cumap, false); @@ -1807,13 +1807,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* the points, use aspect to make them visible on edges */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); cmp = cuma->curve; GPU_point_size(3.0f); - immBegin(GWN_PRIM_POINTS, cuma->totpoint); + immBegin(GPU_PRIM_POINTS, cuma->totpoint); for (int a = 0; a < cuma->totpoint; a++) { float color[4]; if (cmp[a].flag & CUMA_SELECT) @@ -1833,7 +1833,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* outline */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv((unsigned char *)wcol->outline); @@ -1926,16 +1926,16 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel); UI_GetThemeColor4fv(TH_MARKER_OUTLINE, col_outline); /* Do stipple cross with geometry */ - immBegin(GWN_PRIM_LINES, 7 * 2 * 2); + immBegin(GPU_PRIM_LINES, 7 * 2 * 2); float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f}; for (int axe = 0; axe < 2; ++axe) { for (int i = 0; i < 7; ++i) { @@ -2018,13 +2018,13 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol float x = 0.5f * (recti->xmin + recti->xmax); float y = 0.5f * (recti->ymin + recti->ymax); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(but->col); GPU_blend(true); - immBegin(GWN_PRIM_TRI_FAN, 16); + immBegin(GPU_PRIM_TRI_FAN, 16); for (int a = 0; a < 16; a++) immVertex2f(pos, x + size * si[a], y + size * co[a]); immEnd(); @@ -2032,7 +2032,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol immUniformColor4ub(0, 0, 0, 150); GPU_line_width(1); GPU_line_smooth(true); - immBegin(GWN_PRIM_LINE_LOOP, 16); + immBegin(GPU_PRIM_LINE_LOOP, 16); for (int a = 0; a < 16; a++) immVertex2f(pos, x + size * si[a], y + size * co[a]); immEnd(); @@ -2115,13 +2115,13 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, { GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRIS, 54); + immBegin(GPU_PRIM_TRIS, 54); /* accumulated outline boxes to make shade not linear, is more pleasant */ ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8); @@ -2186,11 +2186,11 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_shadow_get(); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW); - GWN_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params); - GWN_batch_uniform_1f(batch, "alpha", 1.0f - visibility); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_shadow_get(); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW); + GPU_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params); + GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility); + GPU_batch_draw(batch); /* outline emphasis */ GPU_line_smooth(true); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index b9183461b4c..22b82898288 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -250,11 +250,11 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float viconutil_set_point(pts[1], cx - d2, cy - d); viconutil_set_point(pts[2], cx + d2, cy); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.2f, 0.2f, 0.2f, alpha); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2iv(pos, pts[0]); immVertex2iv(pos, pts[1]); immVertex2iv(pos, pts[2]); @@ -280,15 +280,15 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, int xco = x + w / 2; int yco = y + h / 2; - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); /* draw keyframe * - size: 0.6 * h (found out experimentally... dunno why!) @@ -343,7 +343,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU const int b = x + w / 3 * 2; const int c = x + w; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* XXX: Include alpha into this... */ @@ -1262,7 +1262,7 @@ static void icon_draw_cache_flush_ex(void) glUniform1i(img_loc, 0); glUniform4fv(data_loc, ICON_DRAW_CACHE_SIZE * 3, (float *)g_icon_draw_cache.drawcall_cache); - GWN_draw_primitive(GWN_PRIM_TRIS, 6 * g_icon_draw_cache.calls); + GPU_draw_primitive(GPU_PRIM_TRIS, 6 * g_icon_draw_cache.calls); glBindTexture(GL_TEXTURE_2D, 0); @@ -1342,14 +1342,14 @@ static void icon_draw_texture( GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR); GPU_shader_bind(shader); - if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha); - else glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha); + if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha); + else glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha); glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), x1, y1, x2, y2); glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x, y, x + w, y + h); - GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4); + GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); glBindTexture(GL_TEXTURE_2D, 0); } diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c index dc444b98b2c..fabf5f9bf48 100644 --- a/source/blender/editors/interface/interface_icons_event.c +++ b/source/blender/editors/interface/interface_icons_event.c @@ -136,8 +136,8 @@ static void icon_draw_rect_input_line_prim( { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - BLI_assert(ELEM(prim, GWN_PRIM_LINE_LOOP, GWN_PRIM_LINE_STRIP)); - const uint pos_id = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + BLI_assert(ELEM(prim, GPU_PRIM_LINE_LOOP, GPU_PRIM_LINE_STRIP)); + const uint pos_id = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); immBegin(prim, lines_len); @@ -289,7 +289,7 @@ void icon_draw_rect_input( else if (event_type == SPACEKEY) { const uchar lines[] = {60, 118, 60, 60, 195, 60, 195, 118}; icon_draw_rect_input_line_prim( - &rect, color, GWN_PRIM_LINE_STRIP, + &rect, color, GPU_PRIM_LINE_STRIP, (const void *)lines, ARRAY_SIZE(lines) / 2); } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index ffc389c6dfd..f0060cd5758 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -752,9 +752,9 @@ enum { ROUNDBOX_TRIA_MAX, /* don't use */ }; -struct Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased); -struct Gwn_Batch *ui_batch_roundbox_widget_get(int tria); -struct Gwn_Batch *ui_batch_roundbox_shadow_get(void); +struct GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased); +struct GPUBatch *ui_batch_roundbox_widget_get(int tria); +struct GPUBatch *ui_batch_roundbox_shadow_get(void); void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4]); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 79d92eedfa3..59fdf7e672d 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -478,7 +478,7 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y2); @@ -519,7 +519,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) GPU_blend(true); immUniformColor4ub(255, 255, 255, 50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, xmin, ymin); immVertex2f(pos, xmax, ymax); @@ -531,7 +531,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) immUniformColor4ub(0, 0, 0, 50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, xmin, ymin + 1); immVertex2f(pos, xmax, ymax + 1); @@ -584,7 +584,7 @@ static void ui_draw_panel_dragwidget(unsigned int pos, unsigned int col, const r UI_GetThemeColorShade4fv(TH_PANEL_BACK, -col_tint, col_dark); /* draw multiple boxes */ - immBegin(GWN_PRIM_TRIS, 4 * 2 * (6 * 2)); + immBegin(GPU_PRIM_TRIS, 4 * 2 * (6 * 2)); for (i_x = 0; i_x < 4; i_x++) { for (i_y = 0; i_y < 2; i_y++) { const int x_co = (x_min + x_ofs) + (i_x * (box_size + box_margin)); @@ -677,7 +677,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con titlerect.xmin += 5.0f / block->aspect; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (!is_subpanel) { @@ -691,7 +691,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con immUniformThemeColor(TH_PANEL_HEADER); immRectf(pos, minx, headrect.ymin, maxx, y); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, minx, y); immVertex2f(pos, maxx, y); @@ -729,9 +729,9 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con if (show_drag) { uint col; - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); /* itemrect smaller */ itemrect.xmax = headrect.xmax - 5.0f / block->aspect; @@ -745,7 +745,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con immUnbindProgram(); /* Restore format for the following draws. */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } } @@ -758,7 +758,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con else if (is_closed_x) { /* draw vertical title */ ui_draw_aligned_panel_header(style, block, &headrect, 'v'); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } /* an open panel */ else { @@ -1700,9 +1700,9 @@ static void ui_panel_category_draw_tab( {0.98, 0.805}}; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); /* mult */ for (a = 0; a < 4; a++) { @@ -1724,7 +1724,7 @@ static void ui_panel_category_draw_tab( immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_STRIP, vert_len); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_STRIP, vert_len); /* start with corner right-top */ if (use_highlight) { @@ -1929,7 +1929,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* begin drawing */ GPU_line_smooth(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw the background */ @@ -1991,7 +1991,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* tab blackline */ if (!is_active) { - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(theme_col_tab_divider); @@ -2022,7 +2022,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) GPU_blend(false); /* tab blackline remaining (last tab) */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (pc_dyn->prev == NULL) { immUniformColor3ubv(theme_col_tab_divider); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index aa3106b135b..52e6e237a58 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -247,22 +247,22 @@ static const int tria_vcount[ROUNDBOX_TRIA_MAX] = { }; static struct { - Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX]; + GPUBatch *roundbox_widget[ROUNDBOX_TRIA_MAX]; - Gwn_Batch *roundbox_simple; - Gwn_Batch *roundbox_simple_aa; - Gwn_Batch *roundbox_simple_outline; - Gwn_Batch *roundbox_shadow; + GPUBatch *roundbox_simple; + GPUBatch *roundbox_simple_aa; + GPUBatch *roundbox_simple_outline; + GPUBatch *roundbox_shadow; - Gwn_VertFormat format; + GPUVertFormat format; uint vflag_id; } g_ui_batch_cache = {{0}}; -static Gwn_VertFormat *vflag_format(void) +static GPUVertFormat *vflag_format(void) { if (g_ui_batch_cache.format.attr_len == 0) { - Gwn_VertFormat *format = &g_ui_batch_cache.format; - g_ui_batch_cache.vflag_id = GWN_vertformat_attr_add(format, "vflag", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = &g_ui_batch_cache.format; + g_ui_batch_cache.vflag_id = GPU_vertformat_attr_add(format, "vflag", GPU_COMP_U32, 1, GPU_FETCH_INT); } return &g_ui_batch_cache.format; } @@ -273,17 +273,17 @@ static Gwn_VertFormat *vflag_format(void) #define NO_AA WIDGET_AA_JITTER static void set_roundbox_vertex_data( - Gwn_VertBufRaw *vflag_step, uint32_t d) + GPUVertBufRaw *vflag_step, uint32_t d) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); *data = d; } static uint32_t set_roundbox_vertex( - Gwn_VertBufRaw *vflag_step, + GPUVertBufRaw *vflag_step, int corner_id, int corner_v, int jit_v, bool inner, bool emboss, int color) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); *data = corner_id; *data |= corner_v << 2; *data |= jit_v << 6; @@ -294,10 +294,10 @@ static uint32_t set_roundbox_vertex( } static uint32_t set_tria_vertex( - Gwn_VertBufRaw *vflag_step, + GPUVertBufRaw *vflag_step, int tria_type, int tria_v, int tria_id, int jit_v) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); if (ELEM(tria_type, ROUNDBOX_TRIA_ARROWS)) { tria_v += tria_id * tria_vcount[ROUNDBOX_TRIA_ARROWS]; } @@ -308,7 +308,7 @@ static uint32_t set_tria_vertex( return *data; } -static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data) +static void roundbox_batch_add_tria(GPUVertBufRaw *vflag_step, int tria, uint32_t last_data) { const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW, ROUNDBOX_TRIA_MENU) ? 1 : 2; /* for each tria */ @@ -324,12 +324,12 @@ static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32 } } -Gwn_Batch *ui_batch_roundbox_widget_get(int tria) +GPUBatch *ui_batch_roundbox_widget_get(int tria) { if (g_ui_batch_cache.roundbox_widget[tria] == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = WIDGET_SIZE_MAX; /* inner */ vcount += 2; /* restart */ vcount += ((WIDGET_SIZE_MAX + 1) * 2) * WIDGET_AA_JITTER; /* outline (edges) */ @@ -341,8 +341,8 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria) vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */ } } - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); /* Inner */ for (int c1 = 0, c2 = 3; c1 < 2; c1++, c2--) { for (int a1 = 0, a2 = WIDGET_CURVE_RESOLU -1; a2 >= 0; a1++, a2--) { @@ -383,15 +383,15 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria) if (tria) { roundbox_batch_add_tria(&vflag_step, tria, last_data); } - g_ui_batch_cache.roundbox_widget[tria] = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + g_ui_batch_cache.roundbox_widget[tria] = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); gpu_batch_presets_register(g_ui_batch_cache.roundbox_widget[tria]); } return g_ui_batch_cache.roundbox_widget[tria]; } -Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) +GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased) { - Gwn_Batch **batch = NULL; + GPUBatch **batch = NULL; if (filled) { if (antialiased) @@ -408,13 +408,13 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) if (*batch == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = WIDGET_SIZE_MAX; vcount += (filled) ? 2 : 0; vcount *= (antialiased) ? WIDGET_AA_JITTER : 1; - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); if (filled) { for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -435,7 +435,7 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) break; } } - *batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + *batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } else { for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -451,7 +451,7 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) break; } } - *batch = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + *batch = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } gpu_batch_presets_register(*batch); @@ -459,15 +459,15 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) return *batch; } -Gwn_Batch *ui_batch_roundbox_shadow_get(void) +GPUBatch *ui_batch_roundbox_shadow_get(void) { if (g_ui_batch_cache.roundbox_shadow == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = (WIDGET_SIZE_MAX + 1) * 2 + 2 + WIDGET_SIZE_MAX; - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); for (int c = 0; c < 4; c++) { for (int a = 0; a < WIDGET_CURVE_RESOLU; a++) { @@ -488,7 +488,7 @@ Gwn_Batch *ui_batch_roundbox_shadow_get(void) set_roundbox_vertex(&vflag_step, c2, a2, NO_AA, true, false, INNER); } } - g_ui_batch_cache.roundbox_shadow = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + g_ui_batch_cache.roundbox_shadow = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow); } return g_ui_batch_cache.roundbox_shadow; @@ -513,11 +513,11 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(draw_color); - immBegin(GWN_PRIM_TRIS, 3 * WIDGET_AA_JITTER); + immBegin(GPU_PRIM_TRIS, 3 * WIDGET_AA_JITTER); /* for each AA step */ for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -556,14 +556,14 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(draw_color); /* for each AA step */ for (int j = 0; j < WIDGET_AA_JITTER; j++) { - immBegin(GWN_PRIM_TRI_FAN, length); + immBegin(GPU_PRIM_TRI_FAN, length); immVertex2f(pos, tri_array[0][0], tri_array[0][1]); immVertex2f(pos, tri_array[1][0], tri_array[1][1]); @@ -1084,7 +1084,7 @@ static void widgetbase_set_uniform_colors_ubv( #define MAX_WIDGET_PARAMETERS 11 struct { - Gwn_Batch *batch; /* Batch type */ + GPUBatch *batch; /* Batch type */ uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]; int count; bool enabled; @@ -1097,22 +1097,22 @@ void UI_widgetbase_draw_cache_flush(void) if (g_widget_base_batch.count == 0) return; - Gwn_Batch *batch = g_widget_base_batch.batch; + GPUBatch *batch = g_widget_base_batch.batch; if (g_widget_base_batch.count == 1) { /* draw single */ - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_batch_draw(batch); } else { - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST); - GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST); + GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, (float *)g_widget_base_batch.params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); GPU_matrix_bind(batch->interface); - GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true); - GWN_batch_program_use_end(batch); + GPU_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true); + GPU_batch_program_use_end(batch); } g_widget_base_batch.count = 0; } @@ -1135,7 +1135,7 @@ void UI_widgetbase_draw_cache_end(void) GPU_blend(false); } -static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb) +static void draw_widgetbase_batch(GPUBatch *batch, uiWidgetBase *wtb) { wtb->uniform_params.tria1_size = wtb->tria1.size; wtb->uniform_params.tria2_size = wtb->tria2.size; @@ -1171,10 +1171,10 @@ static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb) else { float checker_params[3] = {UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 8.0f}; /* draw single */ - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_batch_draw(batch); } } @@ -1228,7 +1228,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol) if (inner_col1[3] || inner_col2[3] || outline_col[3] || emboss_col[3] || tria_col[3] || alpha_check) { widgetbase_set_uniform_colors_ubv(wtb, inner_col1, inner_col2, outline_col, emboss_col, tria_col, alpha_check); - Gwn_Batch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type); + GPUBatch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type); draw_widgetbase_batch(roundbox_batch, wtb); } @@ -1836,7 +1836,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->item); @@ -1872,7 +1872,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b UI_widgetbase_draw_cache_flush(); GPU_blend(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(0.2f, 0.6f, 0.9f); @@ -2423,7 +2423,7 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r /* we draw a number of increasing size alpha quad strips */ alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2475,7 +2475,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir static void ui_hsv_cursor(float x, float y) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2571,13 +2571,13 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRI_FAN, tot + 2); + immBegin(GPU_PRIM_TRI_FAN, tot + 2); immAttrib3fv(color, colcent); immVertex2f(pos, centx, centy); @@ -2598,7 +2598,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * /* fully rounded outline */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2682,12 +2682,12 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons } /* old below */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRIS, steps * 3 * 6); + immBegin(GPU_PRIM_TRIS, steps * 3 * 6); for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */ const float dx_next = dx + color_step; @@ -2843,7 +2843,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) ui_hsv_cursor(x, y); /* outline */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(0, 0, 0); imm_draw_box_wire_2d(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); @@ -2940,14 +2940,14 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol) 30 }; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_blend(true); immUniformColor4ubv(col); GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect->xmin, y); immVertex2f(pos, rect->xmax, y); immEnd(); @@ -3402,11 +3402,11 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat UI_widgetbase_draw_cache_flush(); GPU_blend(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(bw, bw, bw); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.9f * height); immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.5f * height); immVertex2f(pos, rect->xmin + 0.5f * width, rect->ymin + 0.9f * height); @@ -3783,7 +3783,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * /* note: drawextra can change rect +1 or -1, to match round errors of existing previews */ but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* make mask to draw over image */ @@ -4420,11 +4420,11 @@ static void ui_draw_popover_back_impl( /* Draw popover arrow (top/bottom) */ if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->inner); GPU_blend(true); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); if (direction == UI_DIR_DOWN) { const float y = rect->ymax; immVertex2f(pos, cent_x - unit_half, y); @@ -4476,10 +4476,10 @@ static void draw_disk_shaded( unsigned char r_col[4]; unsigned int pos, col; - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (shaded) { - col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); } else { @@ -4487,7 +4487,7 @@ static void draw_disk_shaded( immUniformColor4ubv((unsigned char *)col1); } - immBegin(GWN_PRIM_TRI_STRIP, subd * 2); + immBegin(GPU_PRIM_TRI_STRIP, subd * 2); for (i = 0; i < subd; i++) { float a; @@ -4556,8 +4556,8 @@ void ui_draw_pie_center(uiBlock *block) } } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)btheme->tui.wcol_pie_menu.outline); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 7d9eb1181ed..3a527712367 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1338,12 +1338,12 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) if (vertex_count == 0) return; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_count); + immBegin(GPU_PRIM_LINES, vertex_count); /* vertical lines */ if (flag & V2D_VERTICAL_LINES) { @@ -1480,15 +1480,15 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) count_y = (v2d->cur.ymax - start_y) / step + 1; if (count_x > 0 || count_y > 0) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); float theme_color[3]; UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, count_x * 2 + count_y * 2 + 4); + immBegin(GPU_PRIM_LINES, count_x * 2 + count_y * 2 + 4); immAttrib3fv(color, theme_color); for (int i = 0; i < count_x ; start_x += step, i++) { @@ -1531,14 +1531,14 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s vertex_count += 2 * ((int)((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1); vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBeginAtMost(GWN_PRIM_LINES, vertex_count); + immBeginAtMost(GPU_PRIM_LINES, vertex_count); for (int level = 0; level < totlevels; ++level) { UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 14cec724168..506dec2aa3e 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -124,8 +124,8 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin return; } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff}; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -134,7 +134,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin /* this could be split into its own loop */ if (draw_type == MASK_DT_OUTLINE) { GPU_line_width(3.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(pos, point_pos); immVertex2fv(pos, handle_pos); immEnd(); @@ -154,7 +154,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin } GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(pos, point_pos); immVertex2fv(pos, handle_pos); immEnd(); @@ -178,7 +178,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin immUniform4fv("outlineColor", point_color); immUniformColor3fvAlpha(point_color, 0.25f); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2fv(pos, handle_pos); immEnd(); @@ -212,8 +212,8 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline mask_spline_color_get(masklay, spline, is_spline_sel, rgb_spline); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); immUniform1f("size", 0.7f * handle_size); @@ -251,7 +251,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline immUniformThemeColor(TH_HANDLE_VERTEX); } - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2fv(pos, feather_point); immEnd(); @@ -320,7 +320,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline else immUniformThemeColor(TH_HANDLE_VERTEX); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2fv(pos, vert); immEnd(); @@ -350,7 +350,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f); immUniform1f("size", 12.0f); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(pos, x, y); immEnd(); @@ -371,7 +371,7 @@ static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char r } } -static void mask_draw_array(unsigned int pos, Gwn_PrimType prim_type, const float (*points)[2], unsigned int vertex_len) +static void mask_draw_array(unsigned int pos, GPUPrimType prim_type, const float (*points)[2], unsigned int vertex_len) { immBegin(prim_type, vertex_len); for (unsigned int i = 0; i < vertex_len; ++i) { @@ -384,7 +384,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* const bool is_feather, const bool is_active, const unsigned char rgb_spline[4], const char draw_type) { - const Gwn_PrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GWN_PRIM_LINE_LOOP : GWN_PRIM_LINE_STRIP; + const GPUPrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GPU_PRIM_LINE_LOOP : GPU_PRIM_LINE_STRIP; const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff}; unsigned char rgb_tmp[4]; SpaceClip *sc = CTX_wm_space_clip(C); @@ -402,8 +402,8 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* } } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); switch (draw_type) { @@ -747,12 +747,12 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra unsigned int num_lines = BLI_listbase_count(&masklay->splines_shapes); if (num_lines > 0) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 175, 0, 255); - immBegin(GWN_PRIM_LINES, 2 * num_lines); + immBegin(GPU_PRIM_LINES, 2 * num_lines); for (MaskLayerShape *masklay_shape = masklay->splines_shapes.first; masklay_shape; diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index a2717e53358..99756269c1f 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1007,13 +1007,13 @@ static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd) copy_v3_v3(v2, ray_hit_best[1]); } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_TRANSFORM); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, v1); immVertex3fv(pos, v2); immEnd(); @@ -1048,7 +1048,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void GPU_matrix_push(); GPU_matrix_mul(kcd->ob->obmat); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -1059,7 +1059,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.line); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, kcd->prev.cage); immVertex3fv(pos, kcd->curr.cage); immEnd(); @@ -1069,7 +1069,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.point); GPU_point_size(11); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->prev.cage); immEnd(); } @@ -1078,7 +1078,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.curpoint); GPU_point_size(9); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->prev.cage); immEnd(); } @@ -1087,7 +1087,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.edge); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, kcd->curr.edge->v1->cageco); immVertex3fv(pos, kcd->curr.edge->v2->cageco); immEnd(); @@ -1096,7 +1096,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.point); GPU_point_size(11); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->curr.cage); immEnd(); } @@ -1105,7 +1105,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.curpoint); GPU_point_size(9); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->curr.cage); immEnd(); } @@ -1121,7 +1121,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor4ubv(kcd->colors.point_a); GPU_point_size(11); - immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit); + immBeginAtMost(GPU_PRIM_POINTS, kcd->totlinehit); lh = kcd->linehits; for (i = 0; i < kcd->totlinehit; i++, lh++) { @@ -1136,7 +1136,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor4ubv(kcd->colors.curpoint_a); GPU_point_size(7); - immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit); + immBeginAtMost(GPU_PRIM_POINTS, kcd->totlinehit); lh = kcd->linehits; for (i = 0; i < kcd->totlinehit; i++, lh++) { @@ -1157,7 +1157,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.line); GPU_line_width(1.0); - immBeginAtMost(GWN_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2); + immBeginAtMost(GPU_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2); BLI_mempool_iternew(kcd->kedges, &iter); for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) { @@ -1178,7 +1178,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.point); GPU_point_size(5.0); - immBeginAtMost(GWN_PRIM_POINTS, BLI_mempool_len(kcd->kverts)); + immBeginAtMost(GPU_PRIM_POINTS, BLI_mempool_len(kcd->kverts)); BLI_mempool_iternew(kcd->kverts, &iter); for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) { diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 9a58f1dcd08..95c94c146e4 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -116,13 +116,13 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a GPU_matrix_push(); GPU_matrix_mul(lcd->ob->obmat); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ub(255, 0, 255); if (lcd->totedge > 0) { - immBegin(GWN_PRIM_LINES, lcd->totedge * 2); + immBegin(GPU_PRIM_LINES, lcd->totedge * 2); for (int i = 0; i < lcd->totedge; i++) { immVertex3fv(pos, lcd->edges[i][0]); @@ -135,7 +135,7 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a if (lcd->totpoint > 0) { GPU_point_size(3.0f); - immBegin(GWN_PRIM_POINTS, lcd->totpoint); + immBegin(GPU_PRIM_POINTS, lcd->totpoint); for (int i = 0; i < lcd->totpoint; i++) { immVertex3fv(pos, lcd->points[i]); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 10d9c90aeb3..1b82e60b986 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2892,7 +2892,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) brush = &pset->brush[pset->brushtype]; if (brush) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 255, 255, 128); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index cb8fdba0ae1..1a63bc1cd53 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -105,12 +105,12 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides) float color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); - immBeginAtMost(GWN_PRIM_LINES, 8); + immBeginAtMost(GPU_PRIM_LINES, 8); /* right */ if (sides & REGION_EMBOSS_RIGHT) { @@ -262,8 +262,8 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -271,7 +271,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f imm_draw_box_wire_2d(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax); immUniformColor4f(0.0f, 1.0f, 1.0f, alpha); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, click_rect.xmin, click_rect.ymin); immVertex2f(pos, click_rect.xmax, click_rect.ymax); immVertex2f(pos, click_rect.xmin, click_rect.ymax); @@ -295,8 +295,8 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) float width = 0.1f * U.widget_unit; float pad = 0.2f * U.widget_unit; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_blend(true); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -500,8 +500,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* for debugging unneeded area redraws and partial redraw */ #if 0 GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(drand48(), drand48(), drand48(), 0.1f); immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin, @@ -2472,8 +2472,8 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(fill_color); immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1); @@ -2691,8 +2691,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, /* set up rect */ BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y); /* draw top box */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_METADATA_BG); immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -2716,8 +2716,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, /* set up box rect */ BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin); /* draw top box */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_METADATA_BG); immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -2745,8 +2745,8 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x1, &y1); UI_view2d_view_to_region(&ar->v2d, 1.0f, 1.0f, &x2, &y2); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, 20); @@ -2778,12 +2778,12 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) int count_large = 1.0f / (4.0f * gridstep); if (count_fine > 0) { - GWN_vertformat_clear(format); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPU_vertformat_clear(format); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + unsigned color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, 4 * count_fine + 4 * count_large); + immBegin(GPU_PRIM_LINES, 4 * count_fine + 4 * count_large); float theme_color[3]; UI_GetThemeColorShade3fv(TH_BACK, (int)(20.0f * (1.0f - blendfac)), theme_color); @@ -2877,7 +2877,7 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect) void ED_region_cache_draw_background(const ARegion *ar) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(128, 128, 255, 64); immRecti(pos, 0, 0, ar->winx, 8 * UI_DPI_FAC); @@ -2897,7 +2897,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_CFRAME); immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); @@ -2911,7 +2911,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segments, const int *points, const int sfra, const int efra) { if (num_segments) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(128, 128, 255, 128); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 41404aee9c9..7fa093106df 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -140,9 +140,9 @@ static int get_cached_work_texture(int *r_w, int *r_h) static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state) { - Gwn_VertFormat *vert_format = immVertexFormat(); - state->pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - state->texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *vert_format = immVertexFormat(); + state->pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + state->texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } /* To be used before calling immDrawPixelsTex @@ -297,7 +297,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_UNSIGNED_BYTE, &uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]); } - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texco, (float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h); immVertex2f(pos, rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * yzoom); @@ -551,28 +551,28 @@ void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, flo delta_y = min_ff(delta_y, border->ymax - border->ymin); /* left bottom corner */ - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, border->xmin, border->ymin + delta_y); immVertex2f(pos, border->xmin, border->ymin); immVertex2f(pos, border->xmin + delta_x, border->ymin); immEnd(); /* left top corner */ - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, border->xmin, border->ymax - delta_y); immVertex2f(pos, border->xmin, border->ymax); immVertex2f(pos, border->xmin + delta_x, border->ymax); immEnd(); /* right bottom corner */ - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, border->xmax - delta_x, border->ymin); immVertex2f(pos, border->xmax, border->ymin); immVertex2f(pos, border->xmax, border->ymin + delta_y); immEnd(); /* right top corner */ - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, border->xmax - delta_x, border->ymax); immVertex2f(pos, border->xmax, border->ymax); immVertex2f(pos, border->xmax, border->ymax - delta_y); diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index 6e512d6d4df..10d72d74b22 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -99,7 +99,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) } } - immBegin(GWN_PRIM_TRI_FAN, 5); + immBegin(GPU_PRIM_TRI_FAN, 5); for (i = 0; i < 5; i++) { immVertex2f(pos, points[i].x, points[i].y); @@ -107,7 +107,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) immEnd(); - immBegin(GWN_PRIM_TRI_FAN, 5); + immBegin(GPU_PRIM_TRI_FAN, 5); for (i = 4; i < 8; i++) { immVertex2f(pos, points[i].x, points[i].y); @@ -180,7 +180,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos) } } - immBegin(GWN_PRIM_TRI_FAN, 5); + immBegin(GPU_PRIM_TRI_FAN, 5); for (i = 0; i < 5; i++) { immVertex2f(pos, points[i].x, points[i].y); @@ -188,7 +188,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos) immEnd(); - immBegin(GWN_PRIM_TRI_FAN, 5); + immBegin(GPU_PRIM_TRI_FAN, 5); for (i = 4; i < 8; i++) { immVertex2f(pos, points[i].x, points[i].y); @@ -323,11 +323,11 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) /* Wrap up the corners with a nice embossing. */ rcti rect = sa->totrct; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); - immBeginAtMost(GWN_PRIM_LINES, 8); + immBeginAtMost(GPU_PRIM_LINES, 8); /* Right. */ immVertex2f(pos, rect.xmax, rect.ymax); @@ -386,7 +386,7 @@ static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, shor return; } - immBegin(GWN_PRIM_LINES, count); + immBegin(GPU_PRIM_LINES, count); /* right border area */ if (x2 < sizex - 1) { @@ -439,7 +439,7 @@ void ED_screen_draw_edges(wmWindow *win) ScrArea *sa; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* Note: first loop only draws if U.pixelsize > 1, skip otherwise */ @@ -477,7 +477,7 @@ void ED_screen_draw_edges(wmWindow *win) */ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_width(1); @@ -518,14 +518,14 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* splitpoint */ GPU_blend(true); immUniformColor4ub(255, 255, 255, 100); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); if (dir == 'h') { const float y = (1 - fac) * sa->totrct.ymin + fac * sa->totrct.ymax; @@ -537,7 +537,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immUniformColor4ub(0, 0, 0, 100); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, sa->totrct.xmin, y + 1); immVertex2f(pos, sa->totrct.xmax, y + 1); @@ -555,7 +555,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immUniformColor4ub(0, 0, 0, 100); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x + 1, sa->totrct.ymin); immVertex2f(pos, x + 1, sa->totrct.ymax); @@ -594,7 +594,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2 const float ofs_between_areas) { const float ofs_h = ofs_between_areas * 0.5f; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); @@ -607,7 +607,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2 .ymax = sa->totrct.ymax * scale[1] - ofs_h }; - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immVertex2f(pos, rect.xmin, rect.ymin); immVertex2f(pos, rect.xmax, rect.ymin); immVertex2f(pos, rect.xmax, rect.ymax); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index e1de86910ff..997fe1282f9 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -680,9 +680,9 @@ static void paint_draw_tex_overlay( } /* set quad color. Colored overlay does not get blending */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (col) { immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); @@ -696,7 +696,7 @@ static void paint_draw_tex_overlay( /* draw textured quad */ immUniform1i("image", GL_TEXTURE0); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texCoord, 0.0f, 0.0f); immVertex2f(pos, quad.xmin, quad.ymin); immAttrib2f(texCoord, 1.0f, 0.0f); @@ -769,9 +769,9 @@ static void paint_draw_cursor_overlay( GPU_matrix_translate_2f(-center[0], -center[1]); } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); @@ -782,7 +782,7 @@ static void paint_draw_cursor_overlay( /* draw textured quad */ immUniform1i("image", 0); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texCoord, 0.0f, 0.0f); immVertex2f(pos, quad.xmin, quad.ymin); immAttrib2f(texCoord, 1.0f, 0.0f); @@ -844,7 +844,7 @@ BLI_INLINE void draw_tri_point( {co[0] + w, co[1] - w}, }; - immBegin(GWN_PRIM_LINE_LOOP, 3); + immBegin(GPU_PRIM_LINE_LOOP, 3); immVertex2fv(pos, tri[0]); immVertex2fv(pos, tri[1]); immVertex2fv(pos, tri[2]); @@ -853,7 +853,7 @@ BLI_INLINE void draw_tri_point( immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINE_LOOP, 3); + immBegin(GPU_PRIM_LINE_LOOP, 3); immVertex2fv(pos, tri[0]); immVertex2fv(pos, tri[1]); immVertex2fv(pos, tri[2]); @@ -888,7 +888,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); GPU_line_width(3.0f); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2fv(pos, bez->vec[0]); immVertex2fv(pos, bez->vec[1]); immVertex2fv(pos, bez->vec[2]); @@ -902,7 +902,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez else { immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); } - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(pos, bez->vec[0]); immVertex2fv(pos, bez->vec[1]); immEnd(); @@ -913,7 +913,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez else { immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); } - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(pos, bez->vec[1]); immVertex2fv(pos, bez->vec[2]); immEnd(); @@ -930,7 +930,7 @@ static void paint_draw_curve_cursor(Brush *brush) GPU_blend(true); /* draw the bezier handles and the curve segment between the current and next point */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -961,7 +961,7 @@ static void paint_draw_curve_cursor(Brush *brush) immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); GPU_line_width(3.0f); - immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); + immBegin(GPU_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) { immVertex2fv(pos, v[j]); } @@ -969,7 +969,7 @@ static void paint_draw_curve_cursor(Brush *brush) immUniformColor4f(0.9f, 0.9f, 1.0f, 0.5f); GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); + immBegin(GPU_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) { immVertex2fv(pos, v[j]); } @@ -1118,7 +1118,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) GPU_blend(true); /* TODO: also set blend mode? */ GPU_line_smooth(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* set brush color */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 6276a2838f5..897a74eb497 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -419,15 +419,15 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda GPU_line_smooth(true); GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_width(4.0); immUniformColor4ub(0, 0, 0, 255); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2i(pos, x, y); immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]); immEnd(); @@ -435,7 +435,7 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda GPU_line_width(2.0); immUniformColor4ub(255, 255, 255, 255); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2i(pos, x, y); immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]); immEnd(); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 0ef25eb63a1..fc008213ae0 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -155,11 +155,11 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata ARegion *ar = stroke->vc.ar; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(paint->paint_cursor_col); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x, y); immVertex2f(pos, stroke->last_mouse_position[0] + ar->winrct.xmin, @@ -181,7 +181,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) GPU_line_smooth(true); - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -194,7 +194,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) immUniformArray4fv("colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); ARegion *ar = stroke->vc.ar; diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index a0ef753e200..8fafc545fa9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -215,7 +215,7 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN); } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fvAlpha(brush->add_col, alpha); diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 6ebb04fafc4..e679688f887 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -211,8 +211,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* first backdrop strips */ y = (float)(-ACHANNEL_HEIGHT(ac)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -326,7 +326,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (saction->flag & SACTION_MOVING) { immUniformColor3f(0.0f, 0.0f, 0.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD); immVertex2f(pos, saction->timeslide, v2d->cur.ymax); immEnd(); @@ -404,7 +404,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* iterate over pointcaches on the active object, and draw each one's range */ @@ -492,7 +492,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) immUniformColor4fv(col); if (len > 0) { - immBeginAtMost(GWN_PRIM_TRIS, len); + immBeginAtMost(GPU_PRIM_TRIS, len); /* draw a quad for each cached frame */ for (int i = sta; i <= end; i++) { diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 76450cba3cb..2aa0a3e2b9a 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -130,8 +130,8 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) uint keyframe_len = 0; - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* don't use totrect set, as the width stays the same @@ -215,14 +215,14 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) if (keyframe_len > 0) { /* draw keyframe markers */ format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, keyframe_len); + immBegin(GPU_PRIM_POINTS, keyframe_len); /* all same size with black outline */ immAttrib1f(size_id, 2.0f * STRIP_HEIGHT_HALF); @@ -315,8 +315,8 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) */ float y = (float) CHANNEL_FIRST; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 29bc0543426..ebdf5342172 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -80,7 +80,7 @@ static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int wid int x = (frame - sfra) * framelen; if (width == 1) { - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2i(pos, x, 0); immVertex2i(pos, x, height * UI_DPI_FAC); immEnd(); @@ -167,7 +167,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points); ED_region_cache_draw_cached_segments(ar, totseg, points, sfra, efra); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* track */ @@ -248,7 +248,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc ED_region_cache_draw_curfra_label(sc->user.framenr, x, 8.0f * UI_DPI_FAC); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* solver keyframes */ @@ -290,7 +290,7 @@ static void draw_movieclip_muted(ARegion *ar, int width, int height, float zoomx { int x, y; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* find window pixel coordinates of origin */ @@ -349,7 +349,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int /* draw boundary border for frame if stabilization is enabled */ if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* Exclusive OR allows to get orig value when second operand is 0, * and negative of orig value when second operand is 1. */ @@ -452,7 +452,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin i++; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -463,7 +463,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((b - a - 1) >= 1) { GPU_point_size(5.0f); - immBegin(GWN_PRIM_POINTS, b - a - 1); + immBegin(GPU_PRIM_POINTS, b - a - 1); for (i = a; i < b; i++) { if (i != curindex) { @@ -478,7 +478,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((b - a) >= 2) { GPU_line_width(3.0f); - immBegin(GWN_PRIM_LINE_STRIP, b - a); + immBegin(GPU_PRIM_LINE_STRIP, b - a); for (i = a; i < b; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -494,7 +494,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((curindex - a) >= 1) { immUniformThemeColor(TH_PATH_BEFORE); - immBegin(GWN_PRIM_POINTS, curindex - a); + immBegin(GPU_PRIM_POINTS, curindex - a); for (i = a; i < curindex; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -506,7 +506,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((b - curindex - 1) >= 1) { immUniformThemeColor(TH_PATH_AFTER); - immBegin(GWN_PRIM_POINTS, b - curindex - 1); + immBegin(GPU_PRIM_POINTS, b - curindex - 1); for (i = curindex + 1; i < b; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -521,7 +521,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((curindex - a + 1) >= 2) { immUniformThemeColor(TH_PATH_BEFORE); - immBegin(GWN_PRIM_LINE_STRIP, curindex - a + 1); + immBegin(GPU_PRIM_LINE_STRIP, curindex - a + 1); for (i = a; i <= curindex; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -533,7 +533,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((b - curindex) >= 2) { immUniformThemeColor(TH_PATH_AFTER); - immBegin(GWN_PRIM_LINE_STRIP, b - curindex); + immBegin(GPU_PRIM_LINE_STRIP, b - curindex); for (i = curindex; i < b; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -579,12 +579,12 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT { GPU_point_size(tiny ? 3.0f : 4.0f); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(position, pos[0], pos[1]); immEnd(); } else { - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(position, pos[0] + px[0] * 2, pos[1]); immVertex2f(position, pos[0] + px[0] * 8, pos[1]); @@ -607,7 +607,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT GPU_matrix_translate_2fv(marker_pos); if (sc->flag & SC_SHOW_MARKER_PATTERN) { - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2fv(position, marker->pattern_corners[0]); immVertex2fv(position, marker->pattern_corners[1]); immVertex2fv(position, marker->pattern_corners[2]); @@ -705,14 +705,14 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra immUniform1f("dash_factor", 2.0f); /* Solid "line" */ - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(shdr_pos, pos[0], pos[1]); immEnd(); } else { immUniform1f("dash_factor", 2.0f); /* Solid line */ - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(shdr_pos, pos[0] + px[0] * 3, pos[1]); immVertex2f(shdr_pos, pos[0] + px[0] * 7, pos[1]); @@ -735,7 +735,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_pos, pos); immVertex2fv(shdr_pos, marker_pos); immEnd(); @@ -783,7 +783,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra } if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) { - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2fv(shdr_pos, marker->pattern_corners[0]); immVertex2fv(shdr_pos, marker->pattern_corners[1]); immVertex2fv(shdr_pos, marker->pattern_corners[2]); @@ -805,7 +805,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra /* Restore default shader */ immUnbindProgram(); - const uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); BLI_assert(pos == shdr_pos); UNUSED_VARS_NDEBUG(pos); @@ -857,7 +857,7 @@ static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int tdy += px[1]; } - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2f(pos, x, y); immVertex2f(pos, x - tdx, y); immVertex2f(pos, x, y + tdy); @@ -935,7 +935,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo GPU_line_width(outline ? 3.0f : 1.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, 0.0f, 0.0f); immVertex2fv(pos, tilt_ctrl); immEnd(); @@ -1144,15 +1144,15 @@ static void draw_plane_marker_image(Scene *scene, GPU_matrix_push(); GPU_matrix_mul(gl_matrix); - Gwn_VertFormat *imm_format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *imm_format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, plane_track->image_opacity); immUniform1i("image", 0); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texCoord, 0.0f, 0.0f); immVertex2f(pos, 0.0f, 0.0f); @@ -1206,7 +1206,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane } if (draw_plane_quad || is_selected_track) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -1239,7 +1239,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane } /* Draw rectangle itself. */ - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2fv(shdr_pos, plane_marker->corners[0]); immVertex2fv(shdr_pos, plane_marker->corners[1]); immVertex2fv(shdr_pos, plane_marker->corners[2]); @@ -1252,7 +1252,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane immUniformColor3f(1.0f, 0.0f, 0.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point); immVertex2fv(shdr_pos, plane_marker->corners[0]); @@ -1262,7 +1262,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane immUniformColor3f(0.0f, 1.0f, 0.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point); immVertex2fv(shdr_pos, plane_marker->corners[0]); @@ -1414,7 +1414,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie } } - uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint position = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1519,7 +1519,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie immUniformColor3f(1.0f, 0.0f, 0.0f); } - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); if (undistort) { immVertex2f(position, pos[0] / width, pos[1] / (height * aspy)); @@ -1598,7 +1598,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, GPU_matrix_mul(sc->stabmat); GPU_matrix_scale_2f(width, height); - uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint position = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1675,7 +1675,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, immUniformColor3f(1.0f, 0.0f, 0.0f); for (i = 0; i <= n; i++) { - immBegin(GWN_PRIM_LINE_STRIP, n + 1); + immBegin(GPU_PRIM_LINE_STRIP, n + 1); for (j = 0; j <= n; j++) { immVertex2fv(position, grid[i][j]); @@ -1685,7 +1685,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, } for (j = 0; j <= n; j++) { - immBegin(GWN_PRIM_LINE_STRIP, n + 1); + immBegin(GPU_PRIM_LINE_STRIP, n + 1); for (i = 0; i <= n; i++) { immVertex2fv(position, grid[i][j]); @@ -1743,7 +1743,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, sub_v2_v2v2(dpos, npos, pos); mul_v2_fl(dpos, 1.0f / steps); - immBegin(GWN_PRIM_LINE_STRIP, steps + 1); + immBegin(GPU_PRIM_LINE_STRIP, steps + 1); for (j = 0; j <= steps; j++) { BKE_tracking_distort_v2(tracking, pos, tpos); @@ -1756,7 +1756,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, } } else if (stroke->totpoints == 1) { - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(position, stroke->points[0].x + offsx, stroke->points[0].y + offsy); immEnd(); } diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 0bc9c74cd8c..cc8541d9fd7 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -91,11 +91,11 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, immUniformColor4fv(col); if (is_point) { - immBeginAtMost(GWN_PRIM_POINTS, 1); + immBeginAtMost(GPU_PRIM_POINTS, 1); } else { /* Graph can be composed of smaller segments, if any marker is disabled */ - immBeginAtMost(GWN_PRIM_LINE_STRIP, track->markersnr); + immBeginAtMost(GPU_PRIM_LINE_STRIP, track->markersnr); } } @@ -237,11 +237,11 @@ static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack * immUniformColor4fv(col); if (is_point) { /* This probably never happens here, but just in case... */ - immBeginAtMost(GWN_PRIM_POINTS, 1); + immBeginAtMost(GPU_PRIM_POINTS, 1); } else { /* Graph can be composed of smaller segments, if any marker is disabled */ - immBeginAtMost(GWN_PRIM_LINE_STRIP, track->markersnr); + immBeginAtMost(GPU_PRIM_LINE_STRIP, track->markersnr); } } } @@ -300,7 +300,7 @@ static void draw_frame_curves(SpaceClip *sc, unsigned int pos) } if (!lines) { - immBeginAtMost(GWN_PRIM_LINE_STRIP, reconstruction->camnr); + immBeginAtMost(GPU_PRIM_LINE_STRIP, reconstruction->camnr); lines = 1; } @@ -328,7 +328,7 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) UI_view2d_grid_free(grid); if (clip) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_point_size(3.0f); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index c94853d4233..19d321a53bf 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -273,7 +273,7 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); @@ -287,7 +287,7 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) /* thin lines where the actual frames are */ GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, (float)SFRA, v2d->cur.ymin); immVertex2f(pos, (float)SFRA, v2d->cur.ymax); immVertex2f(pos, (float)EFRA, v2d->cur.ymin); diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 0ffbe451042..789194c21b9 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -158,8 +158,8 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha int offl = 0, offc = 0; int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN}; int pen[2]; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); xy[1] += tvc->lheight / 6; console_cursor_wrap_offset(sc->prompt, tvc->console_width, &offl, &offc, NULL); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 42ad34b659b..4a71afbcf4a 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -402,8 +402,8 @@ static void file_draw_preview( /* border */ if (use_dropshadow) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); @@ -466,7 +466,7 @@ static void draw_background(FileLayout *layout, View2D *v2d) int i; int sy; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, -7); @@ -503,12 +503,12 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) v1[1] = v2d->cur.ymax - layout->tile_border_y; v2[1] = v2d->cur.ymin; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_len); + immBegin(GPU_PRIM_LINES, vertex_len); sx = (int)v2d->tot.xmin; while (sx < v2d->cur.xmax) { diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 2b2d404168f..ad9af8cb948 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -86,7 +86,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur); int i; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_line_width(1.0f); @@ -103,7 +103,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) /* draw two black lines showing the standard reference levels */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(shdr_pos, v2d->cur.xmin, env->midval + env->min); immVertex2f(shdr_pos, v2d->cur.xmax, env->midval + env->min); @@ -122,7 +122,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) /* for now, point color is fixed, and is white */ immUniformColor3f(1.0f, 1.0f, 1.0f); - immBeginAtMost(GWN_PRIM_POINTS, env->totvert * 2); + immBeginAtMost(GPU_PRIM_POINTS, env->totvert * 2); for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* only draw if visible @@ -178,7 +178,7 @@ static void draw_fcurve_selected_keyframe_vertices(FCurve *fcu, View2D *v2d, boo set_fcurve_vertex_color(fcu, sel); - immBeginAtMost(GWN_PRIM_POINTS, fcu->totvert); + immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert); BezTriple *bezt = fcu->bezt; for (int i = 0; i < fcu->totvert; i++, bezt++) { @@ -230,7 +230,7 @@ static void draw_fcurve_selected_handle_vertices(FCurve *fcu, View2D *v2d, bool immUniform4f("outlineColor", hcolor[0], hcolor[1], hcolor[2], 1.0f); immUniformColor3fvAlpha(hcolor, 0.01f); /* almost invisible - only keep for smoothness */ - immBeginAtMost(GWN_PRIM_POINTS, fcu->totvert * 2); + immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert * 2); BezTriple *bezt = fcu->bezt; BezTriple *prevbezt = NULL; @@ -286,7 +286,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users) */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_blend(true); GPU_enable_program_point_size(); @@ -330,12 +330,12 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) { int sel, b; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBeginAtMost(GWN_PRIM_LINES, 4 * 2 * fcu->totvert); + immBeginAtMost(GPU_PRIM_LINES, 4 * 2 * fcu->totvert); /* slightly hacky, but we want to draw unselected points before selected ones * so that selected points are clearly visible @@ -427,7 +427,7 @@ static void draw_fcurve_sample_control(float x, float y, float xscale, float ysc GPU_matrix_scale_2f(1.0f / xscale * hsize, 1.0f / yscale * hsize); /* draw X shape */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, -0.7f, -0.7f); immVertex2f(pos, +0.7f, +0.7f); @@ -459,7 +459,7 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu) if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) GPU_line_smooth(true); GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor((fcu->flag & FCURVE_SELECTED) ? TH_TEXT_HI : TH_TEXT); @@ -551,7 +551,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d n = (etime - stime) / samplefreq + 0.5f; if (n > 0) { - immBegin(GWN_PRIM_LINE_STRIP, (n + 1)); + immBegin(GPU_PRIM_LINE_STRIP, (n + 1)); for (i = 0; i <= n; i++) { float ctime = stime + i * samplefreq; @@ -590,7 +590,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie GPU_matrix_scale_2f(1.0f, unit_scale); GPU_matrix_translate_2f(0.0f, offset); - immBegin(GWN_PRIM_LINE_STRIP, count); + immBegin(GPU_PRIM_LINE_STRIP, count); /* extrapolate to left? - left-side of view comes before first keyframe? */ if (prevfpt->vec[0] > v2d->cur.xmin) { @@ -687,7 +687,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 /* For now, this assumes the worst case scenario, where all the keyframes have * bezier interpolation, and are drawn at full res. * This is tricky to optimize, but maybe can be improved at some point... */ - immBeginAtMost(GWN_PRIM_LINE_STRIP, (b * 32 + 3)); + immBeginAtMost(GPU_PRIM_LINE_STRIP, (b * 32 + 3)); /* extrapolate to left? */ if (prevbezt->vec[1][0] > v2d->cur.xmin) { @@ -849,7 +849,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) //if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0) // return; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; @@ -874,7 +874,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) /* draw 1-1 line, stretching just past the screen limits * NOTE: we need to scale the y-values to be valid for the units */ - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); t = v2d->cur.xmin; immVertex2f(shdr_pos, t, (t + offset) * unitfac); @@ -900,7 +900,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUniform1f("dash_width", 10.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, (y >= v2d->cur.ymin) ? 4 : 2); + immBegin(GPU_PRIM_LINES, (y >= v2d->cur.ymin) ? 4 : 2); /* x-axis lookup */ co[0] = x; @@ -926,7 +926,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUnbindProgram(); - /* GWN_PRIM_POINTS do not survive dashed line geometry shader... */ + /* GPU_PRIM_POINTS do not survive dashed line geometry shader... */ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* x marks the spot .................................................... */ @@ -934,7 +934,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUniformColor3f(0.9f, 0.9f, 0.9f); GPU_point_size(7.0); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(shdr_pos, x, y); immEnd(); @@ -942,7 +942,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUniformColor3f(0.9f, 0.0f, 0.0f); GPU_point_size(3.0); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(shdr_pos, x, y); immEnd(); } @@ -969,7 +969,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) } GPU_blend(true); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -1055,7 +1055,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid } GPU_blend(true); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 699dc29ff47..fa57df0393a 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -279,7 +279,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_grid_free(grid); if (((sipo->flag & SIPO_NODRAWCURSOR) == 0) || (sipo->mode == SIPO_MODE_DRIVERS)) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -292,7 +292,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) GPU_blend(true); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, v2d->cur.xmin, y); immVertex2f(pos, v2d->cur.xmax, y); immEnd(); @@ -310,7 +310,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) GPU_blend(true); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x, v2d->cur.ymin); immVertex2f(pos, x, v2d->cur.ymax); immEnd(); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ff90e59540e..4cbe25462af 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -127,7 +127,7 @@ static void draw_render_info(const bContext *C, (int)(-rd->border.ymin * rd->ysch * rd->size * 0.01f)); } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_FACE_SELECT); @@ -174,7 +174,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* noisy, high contrast make impossible to read if lower alpha is used. */ @@ -330,7 +330,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLI_rcti_init(&color_rect, dx, dx + (1.5f * UI_UNIT_X), 0.15f * UI_UNIT_Y, 0.85f * UI_UNIT_Y); /* BLF uses immediate mode too, so we must reset our vertex format */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (channels == 4) { @@ -367,7 +367,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d immUnbindProgram(); /* draw outline */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(128, 128, 128); imm_draw_box_wire_2d(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); @@ -573,8 +573,8 @@ void draw_image_sample_line(SpaceImage *sima) if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) { Histogram *hist = &sima->sample_line_hist; - Gwn_VertFormat *format = immVertexFormat(); - uint shdr_dashed_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint shdr_dashed_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -586,7 +586,7 @@ void draw_image_sample_line(SpaceImage *sima) immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", 2.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_dashed_pos, hist->co[0]); immVertex2fv(shdr_dashed_pos, hist->co[1]); immEnd(); @@ -779,7 +779,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) /* Draw current frame. */ x = (cfra - sfra) / (efra - sfra + 1) * ar->winx; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_CFRAME); immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC); diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 5c1b23e140c..c94aaf6e861 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -85,8 +85,8 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2], GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(bg_sel); @@ -191,8 +191,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str cdc->sel[1] = str_len - sel_orig[0]; if (bg) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(bg); @@ -242,8 +242,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str else { /* simple, no wrap */ if (bg) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(bg); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 5b68c7b6bb7..7dd8c7f2eed 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -120,8 +120,8 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa nla_action_get_color(adt, act, color); color[3] *= 2.5f; - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -142,13 +142,13 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa if (key_len > 0) { format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, key_len); + immBegin(GPU_PRIM_POINTS, key_len); /* - disregard the selection status of keyframes so they draw a certain way * - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction @@ -177,7 +177,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax if (ELEM(NULL, act, act->markers.first)) return; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (dashed) { immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -194,7 +194,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax } immUniformThemeColorShade(TH_STRIP_SELECT, shade); - immBeginAtMost(GWN_PRIM_LINES, BLI_listbase_count(&act->markers) * 2); + immBeginAtMost(GPU_PRIM_LINES, BLI_listbase_count(&act->markers) * 2); for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) { float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP); @@ -318,7 +318,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns /* plot the curve (over the strip's main region) */ if (fcu) { - immBegin(GWN_PRIM_LINE_STRIP, abs((int)(strip->end - strip->start) + 1)); + immBegin(GPU_PRIM_LINE_STRIP, abs((int)(strip->end - strip->start) + 1)); /* sample at 1 frame intervals, and draw * - min y-val is yminc, max is y-maxc, so clamp in those regions @@ -335,7 +335,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns else { /* use blend in/out values only if both aren't zero */ if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f)) == 0) { - immBeginAtMost(GWN_PRIM_LINE_STRIP, 4); + immBeginAtMost(GPU_PRIM_LINE_STRIP, 4); /* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */ if (IS_EQF(strip->blendin, 0.0f) == 0) { @@ -366,7 +366,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns static uint nla_draw_use_dashed_outlines(float color[4], bool muted) { /* Note that we use dashed shader here, and make it draw solid lines if not muted... */ - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; @@ -403,7 +403,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri /* get color of strip */ nla_strip_get_color_inside(adt, strip, color); - shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw extrapolation info first (as backdrop) @@ -456,7 +456,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri UI_draw_roundbox_shade_x(true, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1, color); /* restore current vertex format & program (roundbox trashes it) */ - shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); } else { @@ -518,7 +518,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri /* only draw lines for whole-numbered repeats, starting from the first full-repeat * up to the last full repeat (but not if it lies on the end of the strip) */ - immBeginAtMost(GWN_PRIM_LINES, 2 * floorf(strip->repeat)); + immBeginAtMost(GPU_PRIM_LINES, 2 * floorf(strip->repeat)); for (int i = 1; i < strip->repeat; i++) { float repeatPos = strip->start + (repeatLen * i); @@ -534,7 +534,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) { const float y = (ymaxc - yminc) * 0.5f + yminc; - immBeginAtMost(GWN_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* up to 2 lines per strip */ + immBeginAtMost(GPU_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* up to 2 lines per strip */ /* only draw first-level of child-strips, but don't draw any lines on the endpoints */ for (NlaStrip *cs = strip->strips.first; cs; cs = cs->next) { @@ -706,7 +706,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) { AnimData *adt = ale->adt; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, @@ -729,7 +729,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* white base-lines */ GPU_line_width(2.0f); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP); immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP); @@ -739,7 +739,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* black top-lines */ GPU_line_width(1.0f); immUniformColor3f(0.0f, 0.0f, 0.0f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP); immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index dfb85d3c8a4..10532f3ac7d 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2184,14 +2184,14 @@ static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNo const float cy = y + snode->zoom * backdropHeight * node->custom4; const float cross_size = 12 * U.pixelsize; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(1.0f, 1.0f, 1.0f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, cx - cross_size, cy - cross_size); immVertex2f(pos, cx + cross_size, cy + cross_size); immVertex2f(pos, cx + cross_size, cy - cross_size); @@ -2229,14 +2229,14 @@ static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bN y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(1.0f, 1.0f, 1.0f); - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y2); immVertex2f(pos, x3, y3); @@ -2273,14 +2273,14 @@ static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(1.0f, 1.0f, 1.0f); - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y2); immVertex2f(pos, x3, y3); @@ -3267,7 +3267,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b y + snode->zoom * viewer_border->ymin * ibuf->y, y + snode->zoom * viewer_border->ymax * ibuf->y); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_ACTIVE); @@ -3392,50 +3392,50 @@ static float arrow_verts[3][2] = {{-1.0f, 1.0f}, {0.0f, 0.0f}, {-1.0f, -1.0f}}; static float arrow_expand_axis[3][2] = {{0.7071f, 0.7071f}, {M_SQRT2, 0.0f}, {0.7071f, -0.7071f}}; struct { - Gwn_Batch *batch; /* for batching line together */ - Gwn_Batch *batch_single; /* for single line */ - Gwn_VertBuf *inst_vbo; + GPUBatch *batch; /* for batching line together */ + GPUBatch *batch_single; /* for single line */ + GPUVertBuf *inst_vbo; unsigned int p0_id, p1_id, p2_id, p3_id; unsigned int colid_id; - Gwn_VertBufRaw p0_step, p1_step, p2_step, p3_step; - Gwn_VertBufRaw colid_step; + GPUVertBufRaw p0_step, p1_step, p2_step, p3_step; + GPUVertBufRaw colid_step; unsigned int count; bool enabled; } g_batch_link = {0}; static void nodelink_batch_reset(void) { - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p0_id, &g_batch_link.p0_step); - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p1_id, &g_batch_link.p1_step); - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p2_id, &g_batch_link.p2_step); - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p3_id, &g_batch_link.p3_step); - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p0_id, &g_batch_link.p0_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p1_id, &g_batch_link.p1_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p2_id, &g_batch_link.p2_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p3_id, &g_batch_link.p3_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step); g_batch_link.count = 0; } static void set_nodelink_vertex( - Gwn_VertBuf *vbo, + GPUVertBuf *vbo, unsigned int uv_id, unsigned int pos_id, unsigned int exp_id, unsigned int v, const unsigned char uv[2], const float pos[2], const float exp[2]) { - GWN_vertbuf_attr_set(vbo, uv_id, v, uv); - GWN_vertbuf_attr_set(vbo, pos_id, v, pos); - GWN_vertbuf_attr_set(vbo, exp_id, v, exp); + GPU_vertbuf_attr_set(vbo, uv_id, v, uv); + GPU_vertbuf_attr_set(vbo, pos_id, v, pos); + GPU_vertbuf_attr_set(vbo, exp_id, v, exp); } static void nodelink_batch_init(void) { - Gwn_VertFormat format = {0}; - uint uv_id = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_U8, 2, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint expand_id = GWN_vertformat_attr_add(&format, "expand", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC); + GPUVertFormat format = {0}; + uint uv_id = GPU_vertformat_attr_add(&format, "uv", GPU_COMP_U8, 2, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint expand_id = GPU_vertformat_attr_add(&format, "expand", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC); int vcount = LINK_RESOL * 2; /* curve */ vcount += 2; /* restart strip */ vcount += 3 * 2; /* arrow */ vcount *= 2; /* shadow */ vcount += 2; /* restart strip */ - GWN_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_data_alloc(vbo, vcount); int v = 0; for (int k = 0; k < 2; ++k) { @@ -3479,23 +3479,23 @@ static void nodelink_batch_init(void) set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp); } - g_batch_link.batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + g_batch_link.batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); gpu_batch_presets_register(g_batch_link.batch); - g_batch_link.batch_single = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, 0); + g_batch_link.batch_single = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, 0); gpu_batch_presets_register(g_batch_link.batch_single); /* Instances data */ - Gwn_VertFormat format_inst = {0}; - g_batch_link.p0_id = GWN_vertformat_attr_add(&format_inst, "P0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - g_batch_link.p1_id = GWN_vertformat_attr_add(&format_inst, "P1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - g_batch_link.p2_id = GWN_vertformat_attr_add(&format_inst, "P2", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - g_batch_link.p3_id = GWN_vertformat_attr_add(&format_inst, "P3", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - g_batch_link.colid_id = GWN_vertformat_attr_add(&format_inst, "colid_doarrow", GWN_COMP_U8, 4, GWN_FETCH_INT); - g_batch_link.inst_vbo = GWN_vertbuf_create_with_format_ex(&format_inst, GWN_USAGE_STREAM); - GWN_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); /* Alloc max count but only draw the range we need. */ + GPUVertFormat format_inst = {0}; + g_batch_link.p0_id = GPU_vertformat_attr_add(&format_inst, "P0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + g_batch_link.p1_id = GPU_vertformat_attr_add(&format_inst, "P1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + g_batch_link.p2_id = GPU_vertformat_attr_add(&format_inst, "P2", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + g_batch_link.p3_id = GPU_vertformat_attr_add(&format_inst, "P3", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + g_batch_link.colid_id = GPU_vertformat_attr_add(&format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT); + g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM); + GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); /* Alloc max count but only draw the range we need. */ - GWN_batch_instbuf_set(g_batch_link.batch, g_batch_link.inst_vbo, true); + GPU_batch_instbuf_set(g_batch_link.batch, g_batch_link.inst_vbo, true); nodelink_batch_reset(); } @@ -3526,14 +3526,14 @@ static void nodelink_batch_draw(SpaceNode *snode) UI_GetThemeColor4fv(TH_EDGE_SELECT, colors[nodelink_get_color_id(TH_EDGE_SELECT)]); UI_GetThemeColor4fv(TH_REDALERT, colors[nodelink_get_color_id(TH_REDALERT)]); - GWN_vertbuf_vertex_count_set(g_batch_link.inst_vbo, g_batch_link.count); - GWN_vertbuf_use(g_batch_link.inst_vbo); /* force update. */ + GPU_vertbuf_vertex_count_set(g_batch_link.inst_vbo, g_batch_link.count); + GPU_vertbuf_use(g_batch_link.inst_vbo); /* force update. */ - GWN_batch_program_set_builtin(g_batch_link.batch, GPU_SHADER_2D_NODELINK_INST); - GWN_batch_uniform_4fv_array(g_batch_link.batch, "colors", 6, (float *)colors); - GWN_batch_uniform_1f(g_batch_link.batch, "expandSize", snode->aspect * LINK_WIDTH); - GWN_batch_uniform_1f(g_batch_link.batch, "arrowSize", ARROW_SIZE); - GWN_batch_draw(g_batch_link.batch); + GPU_batch_program_set_builtin(g_batch_link.batch, GPU_SHADER_2D_NODELINK_INST); + GPU_batch_uniform_4fv_array(g_batch_link.batch, "colors", 6, (float *)colors); + GPU_batch_uniform_1f(g_batch_link.batch, "expandSize", snode->aspect * LINK_WIDTH); + GPU_batch_uniform_1f(g_batch_link.batch, "arrowSize", ARROW_SIZE); + GPU_batch_draw(g_batch_link.batch); nodelink_batch_reset(); @@ -3562,11 +3562,11 @@ static void nodelink_batch_add_link( BLI_assert(ELEM(th_col3, TH_WIRE, -1)); g_batch_link.count++; - copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p0_step), p0); - copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p1_step), p1); - copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p2_step), p2); - copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p3_step), p3); - char *colid = GWN_vertbuf_raw_step(&g_batch_link.colid_step); + copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p0_step), p0); + copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p1_step), p1); + copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p2_step), p2); + copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p3_step), p3); + char *colid = GPU_vertbuf_raw_step(&g_batch_link.colid_step); colid[0] = nodelink_get_color_id(th_col1); colid[1] = nodelink_get_color_id(th_col2); colid[2] = nodelink_get_color_id(th_col3); @@ -3604,14 +3604,14 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, UI_GetThemeColor4fv(th_col1, colors[1]); UI_GetThemeColor4fv(th_col2, colors[2]); - Gwn_Batch *batch = g_batch_link.batch_single; - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK); - GWN_batch_uniform_2fv_array(batch, "bezierPts", 4, (float *)vec); - GWN_batch_uniform_4fv_array(batch, "colors", 3, (float *)colors); - GWN_batch_uniform_1f(batch, "expandSize", snode->aspect * LINK_WIDTH); - GWN_batch_uniform_1f(batch, "arrowSize", ARROW_SIZE); - GWN_batch_uniform_1i(batch, "doArrow", drawarrow); - GWN_batch_draw(batch); + GPUBatch *batch = g_batch_link.batch_single; + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK); + GPU_batch_uniform_2fv_array(batch, "bezierPts", 4, (float *)vec); + GPU_batch_uniform_4fv_array(batch, "colors", 3, (float *)colors); + GPU_batch_uniform_1f(batch, "expandSize", snode->aspect * LINK_WIDTH); + GPU_batch_uniform_1f(batch, "arrowSize", ARROW_SIZE); + GPU_batch_uniform_1i(batch, "doArrow", drawarrow); + GPU_batch_draw(batch); } } } @@ -3660,7 +3660,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, unsigned pos) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); if (border & (NODE_LEFT | NODE_RIGHT)) { immVertex2f(pos, cent[0], v2d->cur.ymin); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 6976edce563..4b3a3abc642 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -648,8 +648,8 @@ static void node_draw_preview_background(float tile, rctf *rect) { float x, y; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -721,7 +721,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) GPU_blend(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, +100); imm_draw_box_wire_2d(pos, draw_rect.xmin, draw_rect.ymin, draw_rect.xmax, draw_rect.ymax); @@ -771,9 +771,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * float scale; UI_view2d_scale_get(v2d, &scale, NULL); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); GPU_blend(true); GPU_enable_program_point_size(); @@ -788,7 +788,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * immUniform1f("outlineWidth", 1.0f); immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 0.6f); - immBeginAtMost(GWN_PRIM_POINTS, total_input_len + total_output_len); + immBeginAtMost(GPU_PRIM_POINTS, total_input_len + total_output_len); } /* socket inputs */ @@ -832,7 +832,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * immUniform4f("outlineColor", c[0], c[1], c[2], 1.0f); immUniform1f("outlineWidth", 1.5f); - immBegin(GWN_PRIM_POINTS, selected_input_len + selected_output_len); + immBegin(GPU_PRIM_POINTS, selected_input_len + selected_output_len); if (selected_input_len) { /* socket inputs */ @@ -1102,13 +1102,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b } /* scale widget thing */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(color_id, -10); dx = 10.0f; - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rct->xmax - dx, centy - 4.0f); immVertex2f(pos, rct->xmax - dx, centy + 4.0f); @@ -1119,7 +1119,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b immUniformThemeColorShade(color_id, 30); dx -= snode->aspect; - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rct->xmax - dx, centy - 4.0f); immVertex2f(pos, rct->xmax - dx, centy + 4.0f); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 8a8f4715ea3..783a03f3993 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -742,11 +742,11 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex) GPU_line_width(1.0f); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, sizex, v2d->cur.ymax); immVertex2f(pos, sizex, miny); @@ -1739,8 +1739,8 @@ static void outliner_draw_tree_element( /* divider */ { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); unsigned char col[4]; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1797,7 +1797,7 @@ static void outliner_draw_tree_element_floating( const TreeElement *te_insert = te_floating->drag_data->insert_handle; const int line_width = 2; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); int coord_y = te_insert->ys; int coord_x = te_insert->xs; float col[4]; @@ -1818,7 +1818,7 @@ static void outliner_draw_tree_element_floating( immUniformColor4fv(col); GPU_line_width(line_width); - immBegin(GWN_PRIM_LINE_STRIP, 2); + immBegin(GPU_PRIM_LINE_STRIP, 2); immVertex2f(pos, coord_x, coord_y); immVertex2f(pos, ar->v2d.cur.xmax, coord_y); immEnd(); @@ -1827,7 +1827,7 @@ static void outliner_draw_tree_element_floating( BLI_assert(te_floating->drag_data->insert_type == TE_INSERT_INTO); immUniformColor3fvAlpha(col, col[3] * 0.5f); - immBegin(GWN_PRIM_TRI_STRIP, 4); + immBegin(GPU_PRIM_TRI_STRIP, 4); immVertex2f(pos, coord_x, coord_y + UI_UNIT_Y); immVertex2f(pos, coord_x, coord_y); immVertex2f(pos, ar->v2d.cur.xmax, coord_y + UI_UNIT_Y); @@ -1901,8 +1901,8 @@ static void outliner_draw_hierarchy_lines_recursive( static void outliner_draw_hierarchy_lines(SpaceOops *soops, ListBase *lb, int startx, int *starty) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); unsigned char col[4]; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1924,8 +1924,8 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * /* selection status */ if (TSELEM_OPEN(tselem, soops)) { if (tselem->type == TSE_RNA_STRUCT) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immThemeColorShadeAlpha(TH_BACK, -15, -200); immRecti(pos, 0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); @@ -1937,12 +1937,12 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * if (TSELEM_OPEN(tselem, soops)) { outliner_draw_struct_marks(ar, soops, &te->subtree, starty); if (tselem->type == TSE_RNA_STRUCT) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, 0, (float)*starty + UI_UNIT_Y); immVertex2f(pos, ar->v2d.cur.xmax, (float)*starty + UI_UNIT_Y); immEnd(); @@ -2007,8 +2007,8 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx, col_searchmatch[3] = 0.5f; GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); outliner_draw_highlights_recursive( pos, ar, soops, &soops->tree, col_selection, col_highlight, col_searchmatch, @@ -2082,8 +2082,8 @@ static void outliner_back(ARegion *ar) ystart = (int)ar->v2d.tot.ymax; ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, 6); @@ -2093,7 +2093,7 @@ static void outliner_back(ARegion *ar) int tot = (int)floor(ystart - ar->v2d.cur.ymin + 2 * UI_UNIT_Y) / (2 * UI_UNIT_Y); if (tot > 0) { - immBegin(GWN_PRIM_TRIS, 6 * tot); + immBegin(GPU_PRIM_TRIS, 6 * tot); while (tot--) { y1 -= 2 * UI_UNIT_Y; y2 = y1 + UI_UNIT_Y; @@ -2114,10 +2114,10 @@ static void outliner_draw_restrictcols(ARegion *ar) { GPU_line_width(1.0f); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymax); immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymin); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 204559ebf4f..47059d65945 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -267,7 +267,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s GPU_blend(true); - immBegin(GWN_PRIM_TRI_STRIP, length * 2); + immBegin(GPU_PRIM_TRI_STRIP, length * 2); for (i = 0; i < length; i++) { float sampleoffset = startsample + ((x1_offset - x1) / stepsize + i) * samplestep; @@ -343,7 +343,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, col[3] = 196; /* alpha, used for all meta children */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -457,7 +457,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla immUniformColor4ub(0, 0, 0, 50); } - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2fv(pos, v1); immVertex2fv(pos, v2); immVertex2fv(pos, v3); @@ -719,7 +719,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp; y2 = seq->machine + SEQ_STRIP_OFSTOP; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -781,7 +781,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg if (seq->flag & SEQ_LOCK) { GPU_blend(true); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES); immUniform4f("color1", 1.0f, 1.0f, 1.0f, 0.125f); @@ -799,7 +799,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg if (!BKE_sequence_is_valid_check(seq)) { GPU_blend(true); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES); immUniform4f("color1", 1.0f, 0.0f, 0.0f, 1.0f); @@ -834,7 +834,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg drawmeta_contents(scene, seq, x1, y1, x2, y2); } - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* TODO: add back stippled line for muted strips? */ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1040,7 +1040,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons GPU_line_width(1.0f); /* border */ - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -1230,9 +1230,9 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq /* Format needs to be created prior to any immBindProgram call. * Do it here because OCIO binds it's own shader. */ - Gwn_VertFormat *imm_format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *imm_format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (scope) { IMB_freeImBuf(ibuf); @@ -1331,7 +1331,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq immUniform1i("image", 0); } - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); if (draw_overlay) { if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) { @@ -1514,7 +1514,7 @@ static void draw_seq_backdrop(View2D *v2d) { int i; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* darker gray overlay over the view backdrop */ @@ -1541,7 +1541,7 @@ static void draw_seq_backdrop(View2D *v2d) i = max_ii(1, ((int)v2d->cur.ymin) - 1); int line_len = (int)v2d->cur.ymax - i + 1; immUniformThemeColor(TH_GRID); - immBegin(GWN_PRIM_LINES, line_len * 2); + immBegin(GPU_PRIM_LINES, line_len * 2); while (line_len--) { immVertex2f(pos, v2d->cur.xmax, i); immVertex2f(pos, v2d->cur.xmin, i); @@ -1593,7 +1593,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) const Sequence *seq = special_seq_update; GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 255, 255, 48); @@ -1613,7 +1613,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw darkened area outside of active timeline @@ -1631,7 +1631,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) immUniformThemeColorShade(TH_BACK, -60); /* thin lines where the actual frames are */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, frame_sta, v2d->cur.ymin); immVertex2f(pos, frame_sta, v2d->cur.ymax); @@ -1649,7 +1649,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) immUniformThemeColorShade(TH_BACK, -40); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, ms->disp_range[0], v2d->cur.ymin); immVertex2f(pos, ms->disp_range[0], v2d->cur.ymax); @@ -1735,12 +1735,12 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) { int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(0.2f, 0.2f, 0.2f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, cfra_over, v2d->cur.ymin); immVertex2f(pos, cfra_over, v2d->cur.ymax); immEnd(); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 748a5c05ef1..aa499d52589 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -913,7 +913,7 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back) float rad; /* background so highlights don't go behind the scrollbar */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_BACK); immRecti(pos, back->xmin, back->ymin, back->xmax, back->ymax); @@ -967,24 +967,24 @@ static void draw_documentation(const SpaceText *st, ARegion *ar) boxh = (DOC_HEIGHT + 1) * (st->lheight_dpi + TXT_LINE_SPACING); /* Draw panel */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_BACK); immRecti(pos, x, y, x + boxw, y - boxh); immUniformThemeColor(TH_SHADE1); - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2i(pos, x, y); immVertex2i(pos, x + boxw, y); immVertex2i(pos, x + boxw, y - boxh); immVertex2i(pos, x, y - boxh); immEnd(); - immBegin(GWN_PRIM_LINE_LOOP, 3); + immBegin(GPU_PRIM_LINE_LOOP, 3); immVertex2i(pos, x + boxw - 10, y - 7); immVertex2i(pos, x + boxw - 4, y - 7); immVertex2i(pos, x + boxw - 7, y - 2); immEnd(); - immBegin(GWN_PRIM_LINE_LOOP, 3); + immBegin(GPU_PRIM_LINE_LOOP, 3); immVertex2i(pos, x + boxw - 10, y - boxh + 7); immVertex2i(pos, x + boxw - 4, y - boxh + 7); immVertex2i(pos, x + boxw - 7, y - boxh + 2); @@ -1066,7 +1066,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc /* not needed but stands out nicer */ UI_draw_box_shadow(220, x, y - boxh, x + boxw, y); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_SHADE1); @@ -1089,7 +1089,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc w = st->cwidth * text_get_char_pos(st, str, len); if (item == sel) { - uint posi = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint posi = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_SHADE2); @@ -1130,7 +1130,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar) return; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* Draw the selection */ @@ -1443,7 +1443,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) if (st->showlinenrs) { x = TXT_OFFSET + TEXTXLOC; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_GRID); immRecti(pos, (TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2); @@ -1502,7 +1502,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) margin_column_x = x + st->cwidth * (st->margin_column - st->left); if (margin_column_x >= x) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -1515,7 +1515,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) immUniform1f("dash_width", 2.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2i(shdr_pos, margin_column_x, 0); immVertex2i(shdr_pos, margin_column_x, ar->winy - 2); immEnd(); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index a6714927249..c0abbe636c3 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -244,7 +244,7 @@ void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], un circball_array_fill(verts, cent, rad, tmat); - immBegin(GWN_PRIM_LINE_LOOP, CIRCLE_RESOL); + immBegin(GPU_PRIM_LINE_LOOP, CIRCLE_RESOL); for (int i = 0; i < CIRCLE_RESOL; ++i) { immVertex3fv(pos, verts[i]); } @@ -285,15 +285,15 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset) if (imm_len == 0) return; - Gwn_VertFormat *format = immVertexFormat(); - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = immVertexFormat(); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); - immBeginAtMost(GWN_PRIM_POINTS, imm_len); + immBeginAtMost(GPU_PRIM_POINTS, imm_len); dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data, DM_FOREACH_NOP); immEnd(); @@ -303,9 +303,9 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset) static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *UNUSED(dm), int offset) { Mesh *me = ob->data; - Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPUBatch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } #endif @@ -328,15 +328,15 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset) drawBMOffset_userData data; data.bm = em->bm; data.offset = offset; - Gwn_VertFormat *format = immVertexFormat(); - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = immVertexFormat(); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); - immBeginAtMost(GWN_PRIM_POINTS, em->bm->totvert); + immBeginAtMost(GPU_PRIM_POINTS, em->bm->totvert); dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, &data, DM_FOREACH_NOP); immEnd(); @@ -348,9 +348,9 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset) GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); Mesh *me = em->ob->data; - Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPUBatch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } #endif @@ -375,20 +375,20 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) data.bm = em->bm; data.offset = offset; - Gwn_VertFormat *format = immVertexFormat(); + GPUVertFormat *format = immVertexFormat(); const int imm_len = dm->getNumEdges(dm) * 2; if (imm_len == 0) return; - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); GPU_line_width(1.0f); - immBeginAtMost(GWN_PRIM_LINES, imm_len); + immBeginAtMost(GPU_PRIM_LINES, imm_len); dm->foreachMappedEdge(dm, bbs_mesh_wire__mapFunc, &data); immEnd(); @@ -400,9 +400,9 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset) GPU_line_width(1.0f); Mesh *me = em->ob->data; - Gwn_Batch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPUBatch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } #endif @@ -420,13 +420,13 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select if (imm_len == 0) return; - Gwn_VertFormat *format = immVertexFormat(); - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = immVertexFormat(); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); - immBeginAtMost(GWN_PRIM_TRIS, imm_len); + immBeginAtMost(GPU_PRIM_TRIS, imm_len); if (use_select == false) { int selcol; @@ -463,20 +463,20 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *UNUSED(dm), const bool use_select) { Mesh *me = em->ob->data; - Gwn_Batch *batch; + GPUBatch *batch; if (use_select) { batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } else { int selcol; GPU_select_index_get(0, &selcol); batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); - GWN_batch_uniform_1ui(batch, "color", selcol); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); + GPU_batch_uniform_1ui(batch, "color", selcol); + GPU_batch_draw(batch); } } #endif @@ -499,15 +499,15 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm) { drawBMOffset_userData data; /* don't use offset */ data.bm = em->bm; - Gwn_VertFormat *format = immVertexFormat(); - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = immVertexFormat(); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); GPU_point_size(UI_GetThemeValuef(TH_FACEDOT_SIZE)); - immBeginAtMost(GWN_PRIM_POINTS, em->bm->totface); + immBeginAtMost(GPU_PRIM_POINTS, em->bm->totface); dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, &data, DM_FOREACH_NOP); immEnd(); @@ -517,9 +517,9 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm) static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *UNUSED(dm)) { Mesh *me = em->ob->data; - Gwn_Batch *batch = DRW_mesh_batch_cache_get_facedots_with_select_id(me, 1); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPUBatch *batch = DRW_mesh_batch_cache_get_facedots_with_select_id(me, 1); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } #endif @@ -583,12 +583,12 @@ static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(sce { int selcol; - Gwn_Batch *batch; + GPUBatch *batch; GPU_select_index_get(0, &selcol); batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); - GWN_batch_uniform_1ui(batch, "color", selcol); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); + GPU_batch_uniform_1ui(batch, "color", selcol); + GPU_batch_draw(batch); } G.f |= (G_f_orig & G_BACKBUFSEL); @@ -601,15 +601,15 @@ static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(sce static void bbs_mesh_solid_faces(Scene *UNUSED(scene), Object *ob) { Mesh *me = ob->data; - Gwn_Batch *batch; + GPUBatch *batch; if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) { batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1); } else { batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, false, 1); } - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } void draw_object_backbufsel( @@ -747,8 +747,8 @@ void ED_draw_object_facemap( Mesh *me = ob->data; const int *facemap_data = CustomData_get_layer(&me->pdata, CD_FACEMAP); if (facemap_data) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(col); @@ -788,7 +788,7 @@ void ED_draw_object_facemap( /* use gawain immediate mode fore now */ const int looptris_len = poly_to_tri_count(mpoly_len, mloop_len); - immBeginAtMost(GWN_PRIM_TRIS, looptris_len * 3); + immBeginAtMost(GPU_PRIM_TRIS, looptris_len * 3); MPoly *mp; int i; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e03fe149af6..552d84ebb39 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -365,7 +365,7 @@ static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, fl x4 = x1 + (1.0f - fac) * (x2 - x1); y4 = y1 + (1.0f - fac) * (y2 - y1); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(shdr_pos, x1, y3); immVertex2f(shdr_pos, x2, y3); @@ -390,7 +390,7 @@ static void drawviewborder_triangle( float w = x2 - x1; float h = y2 - y1; - immBegin(GWN_PRIM_LINES, 6); + immBegin(GPU_PRIM_LINES, 6); if (w > h) { if (golden) { @@ -467,7 +467,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View x2i = (int)(x2 + (1.0f - 0.0001f)); y2i = (int)(y2 + (1.0f - 0.0001f)); - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* First, solid lines. */ { @@ -559,7 +559,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View x3 = x1 + 0.5f * (x2 - x1); y3 = y1 + 0.5f * (y2 - y1); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(shdr_pos, x1, y3); immVertex2f(shdr_pos, x2, y3); @@ -571,7 +571,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View } if (ca->dtx & CAM_DTX_CENTER_DIAG) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(shdr_pos, x1, y1); immVertex2f(shdr_pos, x2, y2); @@ -674,7 +674,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View static void drawrenderborder(ARegion *ar, View3D *v3d) { /* use the same program for everything */ - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_line_width(1.0f); @@ -814,12 +814,12 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, 6); + immBegin(GPU_PRIM_LINES, 6); for (int axis_i = 0; axis_i < 3; axis_i++) { int i = axis_order[axis_i]; @@ -859,9 +859,9 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_FALSE); /* don't overwrite zbuf */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR); @@ -872,7 +872,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); color[3] = 0; /* more transparent toward the ends */ immAttrib4ubv(col, color); add_v3_v3v3(end, o, scaled_axis); @@ -911,7 +911,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) axis_angle_to_quat(q, vis_axis, vis_angle); } - immBegin(GWN_PRIM_LINE_LOOP, ROT_AXIS_DETAIL); + immBegin(GPU_PRIM_LINE_LOOP, ROT_AXIS_DETAIL); color[3] = 63; /* somewhat faint */ immAttrib4ubv(col, color); float angle = 0.0f; @@ -940,7 +940,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) /* -- draw rotation center -- */ immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR); GPU_point_size(5.0f); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immAttrib4ubv(col, color); immVertex3fv(pos, o); immEnd(); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index d1b9f95ca2a..3cf036e1ce1 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -263,14 +263,14 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), x2 = xoff + 0.55f * fly->width; y2 = yoff + 0.55f * fly->height; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_VIEW_OVERLAY); - immBegin(GWN_PRIM_LINES, 16); + immBegin(GPU_PRIM_LINES, 16); /* bottom left */ immVertex2f(pos, x1, y1); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 6040e21aacb..238a956cf26 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -84,7 +84,7 @@ static void draw_xyz_wire( switch (axis) { case 0: /* x axis */ - line_type = GWN_PRIM_LINES; + line_type = GPU_PRIM_LINES; /* bottom left to top right */ negate_v3_v3(v1, dx); @@ -105,7 +105,7 @@ static void draw_xyz_wire( break; case 1: /* y axis */ - line_type = GWN_PRIM_LINES; + line_type = GPU_PRIM_LINES; /* bottom left to top right */ mul_v3_fl(dx, 0.75f); @@ -127,7 +127,7 @@ static void draw_xyz_wire( break; case 2: /* z axis */ - line_type = GWN_PRIM_LINE_STRIP; + line_type = GPU_PRIM_LINE_STRIP; /* start at top left */ negate_v3_v3(v1, dx); @@ -172,8 +172,8 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U { GPU_line_width(gz->line_width); - Gwn_VertFormat *format = immVertexFormat(); - const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); struct { @@ -257,7 +257,7 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U float v_start[3]; GPU_line_width(2.0f); immUniformColor4fv(color_current); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); if (axis_align == -1) { zero_v3(v_start); } @@ -280,10 +280,10 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U GPU_matrix_translate_3fv(v_final); GPU_matrix_scale_1f(is_pos ? 0.22f : 0.18f); - Gwn_Batch *sphere = GPU_batch_preset_sphere(0); - GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); - GWN_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade); - GWN_batch_draw(sphere); + GPUBatch *sphere = GPU_batch_preset_sphere(0); + GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); + GPU_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade); + GPU_batch_draw(sphere); GPU_matrix_pop(); } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index e9a8dd5ee08..c716692eb9b 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -548,7 +548,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) GPU_blend(true); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (ruler_item->flag & RULERITEM_USE_ANGLE) { immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -562,7 +562,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2fv(shdr_pos, co_ss[0]); immVertex2fv(shdr_pos, co_ss[1]); @@ -604,7 +604,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINE_STRIP, arc_steps + 1); + immBegin(GPU_PRIM_LINE_STRIP, arc_steps + 1); for (j = 0; j <= arc_steps; j++) { madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale); @@ -637,7 +637,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size); immVertex2fv(shdr_pos, cap); @@ -702,7 +702,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_pos, co_ss[0]); immVertex2fv(shdr_pos, co_ss[2]); @@ -726,7 +726,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size); immVertex2fv(shdr_pos, cap); @@ -793,7 +793,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) float co_ss_snap[3]; ED_view3d_project_float_global(ar, ruler_item->co[inter->co_index], co_ss_snap, V3D_PROJ_TEST_NOP); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color_act); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 5796014571a..855ee7bb9fc 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -39,7 +39,7 @@ struct ARegion; struct ARegionType; struct Base; struct BoundBox; -struct Gwn_Batch; +struct GPUBatch; struct Depsgraph; struct Object; struct SmokeDomainSettings; diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 133af8e6da7..690fc5e3bdb 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -461,7 +461,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a GPU_blend(true); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (ruler_item->flag & RULERITEM_USE_ANGLE) { immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -475,7 +475,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2fv(shdr_pos, co_ss[0]); immVertex2fv(shdr_pos, co_ss[1]); @@ -517,7 +517,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINE_STRIP, arc_steps + 1); + immBegin(GPU_PRIM_LINE_STRIP, arc_steps + 1); for (j = 0; j <= arc_steps; j++) { madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale); @@ -550,7 +550,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size); immVertex2fv(shdr_pos, cap); @@ -614,7 +614,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_pos, co_ss[0]); immVertex2fv(shdr_pos, co_ss[2]); @@ -638,7 +638,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size); immVertex2fv(shdr_pos, cap); @@ -703,7 +703,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a float co_ss[3]; ED_view3d_project_float_global(ar, ruler_item->co[ruler_item->co_index], co_ss, V3D_PROJ_TEST_NOP); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color_act); diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 4c5150fabdd..e4e12cc3686 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -343,14 +343,14 @@ static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *a yoff = walk->ar->winy / 2; } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_VIEW_OVERLAY); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); /* North */ immVertex2i(pos, xoff, yoff + inner_length); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e9abdd80d20..dab53c04806 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1689,13 +1689,13 @@ typedef enum { } ArrowDirection; #define POS_INDEX 0 -/* NOTE: this --^ is a bit hackish, but simplifies Gwn_VertFormat usage among functions +/* NOTE: this --^ is a bit hackish, but simplifies GPUVertFormat usage among functions * private to this file - merwin */ static void drawArrow(ArrowDirection d, short offset, short length, short size) { - immBegin(GWN_PRIM_LINES, 6); + immBegin(GPU_PRIM_LINES, 6); switch (d) { case LEFT: @@ -1732,7 +1732,7 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size) static void drawArrowHead(ArrowDirection d, short size) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); switch (d) { case LEFT: @@ -1765,7 +1765,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments float angle; int a; - immBegin(GWN_PRIM_LINE_STRIP, segments + 1); + immBegin(GPU_PRIM_LINE_STRIP, segments + 1); for (angle = angle_start, a = 0; a < segments; angle += delta, a++) { immVertex2f(POS_INDEX, cosf(angle) * size, sinf(angle) * size); @@ -1817,7 +1817,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) /* Dashed lines first. */ if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE)) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); UNUSED_VARS_NDEBUG(shdr_pos); /* silence warning */ BLI_assert(shdr_pos == POS_INDEX); @@ -1835,7 +1835,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(POS_INDEX, cent); immVertex2f(POS_INDEX, tmval[0], tmval[1]); immEnd(); @@ -1844,7 +1844,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) } /* And now, solid lines. */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); UNUSED_VARS_NDEBUG(pos); /* silence warning */ BLI_assert(pos == POS_INDEX); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -7052,7 +7052,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_matrix_push(); GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -7069,7 +7069,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_line_width(line_size); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBeginAtMost(GWN_PRIM_LINES, 4); + immBeginAtMost(GPU_PRIM_LINES, 4); if (curr_sv->v_side[0]) { immVertex3fv(pos, curr_sv->v_side[0]->co); immVertex3fv(pos, curr_sv->v_co_orig); @@ -7082,7 +7082,7 @@ static void drawEdgeSlide(TransInfo *t) immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade); GPU_point_size(ctrl_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); if (slp->flipped) { if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co); } @@ -7093,7 +7093,7 @@ static void drawEdgeSlide(TransInfo *t) immUniformThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); GPU_point_size(guide_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac); immVertex3fv(pos, co_mark); immEnd(); @@ -7107,7 +7107,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_line_width(line_size); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBegin(GWN_PRIM_LINES, sld->totsv * 2); + immBegin(GPU_PRIM_LINES, sld->totsv * 2); /* TODO(campbell): Loop over all verts */ sv = sld->sv; @@ -7687,12 +7687,12 @@ static void drawVertSlide(TransInfo *t) GPU_line_width(line_size); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBegin(GWN_PRIM_LINES, sld->totsv * 2); + immBegin(GPU_PRIM_LINES, sld->totsv * 2); if (is_clamp) { sv = sld->sv; for (i = 0; i < sld->totsv; i++, sv++) { @@ -7718,7 +7718,7 @@ static void drawVertSlide(TransInfo *t) GPU_point_size(ctrl_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(shdr_pos, (slp->flipped && slp->use_even) ? curr_sv->co_link_orig_3d[curr_sv->co_link_curr] : curr_sv->co_orig_3d); @@ -7761,7 +7761,7 @@ static void drawVertSlide(TransInfo *t) immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(shdr_pos, curr_sv->co_orig_3d); immVertex3fv(shdr_pos, co_dest_3d); immEnd(); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index a02948a9951..c8f74cbcd4f 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -747,7 +747,7 @@ void drawConstraint(TransInfo *t) if (depth_test_enabled) GPU_depth_test(false); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); @@ -760,7 +760,7 @@ void drawConstraint(TransInfo *t) immUniform1f("dash_width", 2.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(shdr_pos, t->center_global); immVertex3fv(shdr_pos, vec); immEnd(); @@ -823,7 +823,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) if (depth_test_enabled) GPU_depth_test(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_GRID); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index c1aa0263ef8..3618d57b3ed 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1132,12 +1132,12 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis } UI_make_axis_color(col, col2, axis); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ubv(col2); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, v1); immVertex3fv(pos, v2); immEnd(); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index dc922b5c9ba..b67fd22dbff 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -165,7 +165,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) invert_m4_m4(imat, rv3d->viewmat); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -190,7 +190,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) if (usingSnappingNormal(t) && validSnappingNormal(t)) { immUniformColor4ubv(activeCol); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3f(pos, t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); immVertex3f(pos, t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1], @@ -219,7 +219,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 65147d53b5d..35a77fcd4c0 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -342,7 +342,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info const float mval_dst[2] = {win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin}; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -355,7 +355,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_pos, mval_src); immVertex2fv(shdr_pos, mval_dst); immEnd(); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 5ff008e1de2..616f4eac2ad 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -92,7 +92,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) GPU_matrix_translate_2fv(cursor); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -104,7 +104,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2); immUniform1f("dash_width", 8.0f); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(shdr_pos, -0.05f * x_fac, 0.0f); immVertex2f(shdr_pos, 0.0f, 0.05f * y_fac); @@ -123,7 +123,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", 2.0f); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(shdr_pos, -0.020f * x_fac, 0.0f); immVertex2f(shdr_pos, -0.1f * x_fac, 0.0f); @@ -168,7 +168,7 @@ static void draw_uvs_shadow(Object *obedit) const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -229,7 +229,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME } } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -241,7 +241,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { - immBegin(GWN_PRIM_TRI_FAN, efa->len); + immBegin(GPU_PRIM_TRI_FAN, efa->len); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -281,7 +281,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME immUniformColor3fv(col); /* TODO: use editmesh tessface */ - immBegin(GWN_PRIM_TRI_FAN, efa->len); + immBegin(GPU_PRIM_TRI_FAN, efa->len); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -308,9 +308,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME col[3] = 0.5f; /* hard coded alpha, not that nice */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -353,7 +353,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME } /* TODO: use editmesh tessface */ - immBegin(GWN_PRIM_TRI_FAN, efa->len); + immBegin(GPU_PRIM_TRI_FAN, efa->len); BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); a = fabsf(uvang[i] - ang[i]) / (float)M_PI; @@ -393,7 +393,7 @@ static void draw_uvs_lineloop_bmfaces(BMesh *bm, const int cd_loop_uv_offset, co MLoopUV *luv; /* For more efficiency first transfer the entire buffer to vram. */ - Gwn_Batch *loop_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop); + GPUBatch *loop_batch = immBeginBatchAtMost(GPU_PRIM_LINE_LOOP, bm->totloop); BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -407,17 +407,17 @@ static void draw_uvs_lineloop_bmfaces(BMesh *bm, const int cd_loop_uv_offset, co immEnd(); /* Then draw each face contour separately. */ - GWN_batch_program_use_begin(loop_batch); + GPU_batch_program_use_begin(loop_batch); unsigned int index = 0; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - GWN_batch_draw_range_ex(loop_batch, index, efa->len, false); + GPU_batch_draw_range_ex(loop_batch, index, efa->len, false); index += efa->len; } - GWN_batch_program_use_end(loop_batch); - GWN_batch_discard(loop_batch); + GPU_batch_program_use_end(loop_batch); + GPU_batch_discard(loop_batch); } static void draw_uvs_lineloop_mpoly(Mesh *me, MPoly *mpoly, unsigned int pos) @@ -425,7 +425,7 @@ static void draw_uvs_lineloop_mpoly(Mesh *me, MPoly *mpoly, unsigned int pos) MLoopUV *mloopuv; int i; - immBegin(GWN_PRIM_LINE_LOOP, mpoly->totloop); + immBegin(GPU_PRIM_LINE_LOOP, mpoly->totloop); mloopuv = &me->mloopuv[mpoly->loopstart]; for (i = mpoly->totloop; i != 0; i--, mloopuv++) { @@ -495,7 +495,7 @@ static void draw_uvs_other_mesh(Object *ob, const Image *curimage, static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *curimage, const int other_uv_filter) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -536,7 +536,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, ViewLayer *view_la mloopuv = me->mloopuv; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -548,7 +548,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, ViewLayer *view_la if ((scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE) && mpoly->mat_nr != ob->actcol - 1) continue; - immBegin(GWN_PRIM_LINE_LOOP, mpoly->totloop); + immBegin(GPU_PRIM_LINE_LOOP, mpoly->totloop); mloopuv = mloopuv_base + mpoly->loopstart; for (b = 0; b < mpoly->totloop; b++, mloopuv++) { @@ -658,13 +658,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - Gwn_Batch *face_batch = immBeginBatch(GWN_PRIM_TRIS, tri_count * 3); + GPUBatch *face_batch = immBeginBatch(GPU_PRIM_TRIS, tri_count * 3); for (unsigned int i = 0; i < em->tottri; i++) { efa = em->looptris[i][0]->f; if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { @@ -686,9 +686,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immEnd(); /* XXX performance: we should not create and throw away result. */ - GWN_batch_draw(face_batch); - GWN_batch_program_use_end(face_batch); - GWN_batch_discard(face_batch); + GPU_batch_draw(face_batch); + GPU_batch_program_use_end(face_batch); + GPU_batch_discard(face_batch); immUnbindProgram(); @@ -712,7 +712,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); switch (sima->dt_uv) { case SI_UVDT_DASH: @@ -751,8 +751,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } /* For more efficiency first transfer the entire buffer to vram. */ - Gwn_Batch *loop_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop); - Gwn_VertBuf *loop_vbo = loop_batch->verts[0]; + GPUBatch *loop_batch = immBeginBatchAtMost(GPU_PRIM_LINE_LOOP, bm->totloop); + GPUVertBuf *loop_vbo = loop_batch->verts[0]; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; @@ -766,17 +766,17 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* Then draw each face contour separately. */ if (loop_vbo->vertex_len != 0) { - GWN_batch_program_use_begin(loop_batch); + GPU_batch_program_use_begin(loop_batch); unsigned int index = 0, loop_vbo_count; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - GWN_batch_draw_range_ex(loop_batch, index, efa->len, false); + GPU_batch_draw_range_ex(loop_batch, index, efa->len, false); index += efa->len; } loop_vbo_count = index; - GWN_batch_program_use_end(loop_batch); + GPU_batch_program_use_end(loop_batch); immUnbindProgram(); @@ -790,14 +790,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje if (interpedges) { /* Create a color buffer. */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint shdr_col; if (format.attr_len == 0) { - shdr_col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + shdr_col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo_col = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo_col, loop_vbo_count); + GPUVertBuf *vbo_col = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo_col, loop_vbo_count); index = 0; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { @@ -806,36 +806,36 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) { sel = uvedit_uv_select_test(scene, l, cd_loop_uv_offset); - GWN_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2); + GPU_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2); } } /* Reuse the UV buffer and add the color buffer. */ - GWN_batch_vertbuf_add_ex(loop_batch, vbo_col, true); + GPU_batch_vertbuf_add_ex(loop_batch, vbo_col, true); /* Now draw each face contour separately with another builtin program. */ - GWN_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR); + GPU_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR); GPU_matrix_bind(loop_batch->interface); - GWN_batch_program_use_begin(loop_batch); + GPU_batch_program_use_begin(loop_batch); index = 0; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - GWN_batch_draw_range_ex(loop_batch, index, efa->len, false); + GPU_batch_draw_range_ex(loop_batch, index, efa->len, false); index += efa->len; } - GWN_batch_program_use_end(loop_batch); + GPU_batch_program_use_end(loop_batch); } else { - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); /* Use batch here to avoid problems with `IMM_BUFFER_SIZE`. */ - Gwn_Batch *flat_edges_batch = immBeginBatchAtMost(GWN_PRIM_LINES, loop_vbo_count * 2); + GPUBatch *flat_edges_batch = immBeginBatchAtMost(GPU_PRIM_LINES, loop_vbo_count * 2); BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; @@ -852,27 +852,27 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } immEnd(); - GWN_batch_draw(flat_edges_batch); - GWN_batch_discard(flat_edges_batch); + GPU_batch_draw(flat_edges_batch); + GPU_batch_discard(flat_edges_batch); immUnbindProgram(); } } else { - GWN_batch_uniform_4fv(loop_batch, "color", col2); + GPU_batch_uniform_4fv(loop_batch, "color", col2); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* no nice edges */ - GWN_batch_program_use_begin(loop_batch); + GPU_batch_program_use_begin(loop_batch); index = 0; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - GWN_batch_draw_range_ex(loop_batch, index, efa->len, false); + GPU_batch_draw_range_ex(loop_batch, index, efa->len, false); index += efa->len; } - GWN_batch_program_use_end(loop_batch); + GPU_batch_program_use_end(loop_batch); immUnbindProgram(); } } @@ -881,7 +881,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immUnbindProgram(); } - GWN_batch_discard(loop_batch); + GPU_batch_discard(loop_batch); if (sima->flag & SI_SMOOTH_UV) { GPU_line_smooth(false); @@ -894,16 +894,16 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje float cent[2]; bool col_set = false; - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); GPU_point_size(pointsize); - immBeginAtMost(GWN_PRIM_POINTS, bm->totface); + immBeginAtMost(GPU_PRIM_POINTS, bm->totface); /* unselected faces */ @@ -955,7 +955,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* 6. draw uv vertices */ if (drawfaces != 2) { /* 2 means Mesh Face Mode */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -964,7 +964,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE); GPU_point_size(pointsize); - immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); + immBeginAtMost(GPU_PRIM_POINTS, bm->totloop); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -984,7 +984,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje GPU_point_size(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0)); imm_cpack(0xFF); - immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); + immBeginAtMost(GPU_PRIM_POINTS, bm->totloop); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -1004,7 +1004,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immUniformThemeColor(TH_VERTEX_SELECT); GPU_point_size(pointsize); - immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); + immBeginAtMost(GPU_PRIM_POINTS, bm->totloop); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 9265bc05154..18f1bc872c0 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1547,13 +1547,13 @@ static void stitch_calculate_edge_normal(BMEditMesh *em, UvEdge *edge, float *no /** */ -static void stitch_draw_vbo(Gwn_VertBuf *vbo, Gwn_PrimType prim_type, const float col[4]) +static void stitch_draw_vbo(GPUVertBuf *vbo, GPUPrimType prim_type, const float col[4]) { - Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); - GWN_batch_uniform_4fv(batch, "color", col); - GWN_batch_draw(batch); - GWN_batch_discard(batch); + GPUBatch *batch = GPU_batch_create_ex(prim_type, vbo, NULL, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); + GPU_batch_uniform_4fv(batch, "color", col); + GPU_batch_draw(batch); + GPU_batch_discard(batch); } /* TODO make things pretier : store batches inside StitchPreviewer instead of the bare verts pos */ @@ -1563,25 +1563,25 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar unsigned int num_line = 0, num_tri, tri_idx = 0, line_idx = 0; StitchState *state = (StitchState *)arg; StitchPreviewer *stitch_preview = state->stitch_preview; - Gwn_VertBuf *vbo, *vbo_line; + GPUVertBuf *vbo, *vbo_line; float col[4]; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static unsigned int pos_id; if (format.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } GPU_blend(true); /* Static Tris */ UI_GetThemeColor4fv(TH_STITCH_PREVIEW_ACTIVE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_static_tris * 3); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_static_tris * 3); for (int i = 0; i < stitch_preview->num_static_tris * 3; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->static_tris[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->static_tris[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_TRIS, col); + stitch_draw_vbo(vbo, GPU_PRIM_TRIS, col); /* Preview Polys */ @@ -1591,39 +1591,39 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar num_tri = num_line - 2 * stitch_preview->num_polys; /* we need to convert the polys into triangles / lines */ - vbo = GWN_vertbuf_create_with_format(&format); - vbo_line = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); + vbo_line = GPU_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, num_tri * 3); - GWN_vertbuf_data_alloc(vbo_line, num_line * 2); + GPU_vertbuf_data_alloc(vbo, num_tri * 3); + GPU_vertbuf_data_alloc(vbo_line, num_line * 2); for (int i = 0; i < stitch_preview->num_polys; i++) { BLI_assert(stitch_preview->uvs_per_polygon[i] >= 3); /* Start line */ - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]); - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + 2]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + 2]); for (j = 1; j < stitch_preview->uvs_per_polygon[i] - 1; ++j) { - GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index]); - GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]); - GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index]); + GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]); - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]); - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]); } /* Closing line */ - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]); /* j = uvs_per_polygon[i] - 1*/ - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j * 2]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j * 2]); index += stitch_preview->uvs_per_polygon[i] * 2; } UI_GetThemeColor4fv(TH_STITCH_PREVIEW_FACE, col); - stitch_draw_vbo(vbo, GWN_PRIM_TRIS, col); + stitch_draw_vbo(vbo, GPU_PRIM_TRIS, col); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_EDGE, col); - stitch_draw_vbo(vbo_line, GWN_PRIM_LINES, col); + stitch_draw_vbo(vbo_line, GPU_PRIM_LINES, col); GPU_blend(false); @@ -1633,37 +1633,37 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE) * 2.0f); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable); for (int i = 0; i < stitch_preview->num_stitchable; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_POINTS, col); + stitch_draw_vbo(vbo, GPU_PRIM_POINTS, col); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_UNSTITCHABLE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable); for (int i = 0; i < stitch_preview->num_unstitchable; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_POINTS, col); + stitch_draw_vbo(vbo, GPU_PRIM_POINTS, col); } else { UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable * 2); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable * 2); for (int i = 0; i < stitch_preview->num_stitchable * 2; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_LINES, col); + stitch_draw_vbo(vbo, GPU_PRIM_LINES, col); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_UNSTITCHABLE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable * 2); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable * 2); for (int i = 0; i < stitch_preview->num_unstitchable * 2; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_LINES, col); + stitch_draw_vbo(vbo, GPU_PRIM_LINES, col); } } diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 3d207b85760..58295ae9329 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -23,7 +23,7 @@ # # ***** END GPL LICENSE BLOCK ***** -# WITH_OPENGL limits the visibility of the opengl headers to just gawain and bg_gpu, +# WITH_OPENGL limits the visibility of the opengl headers to just GPU and bg_gpu, # to more easily highlight codepadths in other libraries that need to be refactored, # bf_gpu is allowed to have opengl regardless of this option. diff --git a/source/blender/gpu/GPU_attr_binding.h b/source/blender/gpu/GPU_attr_binding.h index 41050a095cd..186acacb71d 100644 --- a/source/blender/gpu/GPU_attr_binding.h +++ b/source/blender/gpu/GPU_attr_binding.h @@ -23,20 +23,20 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_attr_binding.h +/** \file blender/gpu/GPU_attr_binding.h * \ingroup gpu * - * Gawain vertex attribute binding + * GPU vertex attribute binding */ -#ifndef __GWN_ATTR_BINDING_H__ -#define __GWN_ATTR_BINDING_H__ +#ifndef __GPU_ATTR_BINDING_H__ +#define __GPU_ATTR_BINDING_H__ #include "GPU_common.h" -typedef struct Gwn_AttrBinding { +typedef struct GPUAttrBinding { uint64_t loc_bits; /* store 4 bits for each of the 16 attribs */ uint16_t enabled_bits; /* 1 bit for each attrib */ -} Gwn_AttrBinding; +} GPUAttrBinding; -#endif /* __GWN_ATTR_BINDING_H__ */ +#endif /* __GPU_ATTR_BINDING_H__ */ diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index 4c98eb8f537..bd0e3b43e6c 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -23,15 +23,15 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_batch.h +/** \file blender/gpu/GPU_batch.h * \ingroup gpu * - * Gawain geometry batch + * GPU geometry batch * Contains VAOs + VBOs + Shader representing a drawable entity. */ -#ifndef __GWN_BATCH_H__ -#define __GWN_BATCH_H__ +#ifndef __GPU_BATCH_H__ +#define __GPU_BATCH_H__ #include "GPU_vertex_buffer.h" #include "GPU_element.h" @@ -39,32 +39,32 @@ #include "GPU_shader.h" typedef enum { - GWN_BATCH_READY_TO_FORMAT, - GWN_BATCH_READY_TO_BUILD, - GWN_BATCH_BUILDING, - GWN_BATCH_READY_TO_DRAW -} Gwn_BatchPhase; + GPU_BATCH_READY_TO_FORMAT, + GPU_BATCH_READY_TO_BUILD, + GPU_BATCH_BUILDING, + GPU_BATCH_READY_TO_DRAW +} GPUBatchPhase; -#define GWN_BATCH_VBO_MAX_LEN 3 -#define GWN_BATCH_VAO_STATIC_LEN 3 -#define GWN_BATCH_VAO_DYN_ALLOC_COUNT 16 +#define GPU_BATCH_VBO_MAX_LEN 3 +#define GPU_BATCH_VAO_STATIC_LEN 3 +#define GPU_BATCH_VAO_DYN_ALLOC_COUNT 16 -typedef struct Gwn_Batch { +typedef struct GPUBatch { /* geometry */ - Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ - Gwn_VertBuf* inst; /* instance attribs */ - Gwn_IndexBuf* elem; /* NULL if element list not needed */ + GPUVertBuf* verts[GPU_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ + GPUVertBuf* inst; /* instance attribs */ + GPUIndexBuf* elem; /* NULL if element list not needed */ uint32_t gl_prim_type; /* cached values (avoid dereferencing later) */ uint32_t vao_id; uint32_t program; - const struct Gwn_ShaderInterface* interface; + const struct GPUShaderInterface* interface; /* book-keeping */ uint owns_flag; - struct Gwn_Context *context; /* used to free all vaos. this implies all vaos were created under the same context. */ - Gwn_BatchPhase phase; + struct GPUContext *context; /* used to free all vaos. this implies all vaos were created under the same context. */ + GPUBatchPhase phase; bool program_in_use; /* Vao management: remembers all geometry state (vertex attrib bindings & element buffer) @@ -74,113 +74,113 @@ typedef struct Gwn_Batch { union { /* Static handle count */ struct { - const struct Gwn_ShaderInterface* interfaces[GWN_BATCH_VAO_STATIC_LEN]; - uint32_t vao_ids[GWN_BATCH_VAO_STATIC_LEN]; + const struct GPUShaderInterface* interfaces[GPU_BATCH_VAO_STATIC_LEN]; + uint32_t vao_ids[GPU_BATCH_VAO_STATIC_LEN]; } static_vaos; /* Dynamic handle count */ struct { uint count; - const struct Gwn_ShaderInterface** interfaces; + const struct GPUShaderInterface** interfaces; uint32_t* vao_ids; } dynamic_vaos; }; /* XXX This is the only solution if we want to have some data structure using * batches as key to identify nodes. We must destroy these nodes with this callback. */ - void (*free_callback)(struct Gwn_Batch*, void*); + void (*free_callback)(struct GPUBatch*, void*); void* callback_data; -} Gwn_Batch; +} GPUBatch; enum { - GWN_BATCH_OWNS_VBO = (1 << 0), + GPU_BATCH_OWNS_VBO = (1 << 0), /* each vbo index gets bit-shifted */ - GWN_BATCH_OWNS_INSTANCES = (1 << 30), - GWN_BATCH_OWNS_INDEX = (1 << 31), + GPU_BATCH_OWNS_INSTANCES = (1 << 30), + GPU_BATCH_OWNS_INDEX = (1 << 31), }; -Gwn_Batch* GWN_batch_create_ex(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); -void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); -Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src); +GPUBatch* GPU_batch_create_ex(GPUPrimType, GPUVertBuf*, GPUIndexBuf*, uint owns_flag); +void GPU_batch_init_ex(GPUBatch*, GPUPrimType, GPUVertBuf*, GPUIndexBuf*, uint owns_flag); +GPUBatch* GPU_batch_duplicate(GPUBatch* batch_src); -#define GWN_batch_create(prim, verts, elem) \ - GWN_batch_create_ex(prim, verts, elem, 0) -#define GWN_batch_init(batch, prim, verts, elem) \ - GWN_batch_init_ex(batch, prim, verts, elem, 0) +#define GPU_batch_create(prim, verts, elem) \ + GPU_batch_create_ex(prim, verts, elem, 0) +#define GPU_batch_init(batch, prim, verts, elem) \ + GPU_batch_init_ex(batch, prim, verts, elem, 0) -void GWN_batch_discard(Gwn_Batch*); /* verts & elem are not discarded */ +void GPU_batch_discard(GPUBatch*); /* verts & elem are not discarded */ -void gwn_batch_vao_cache_clear(Gwn_Batch*); +void GPU_batch_vao_cache_clear(GPUBatch*); -void GWN_batch_callback_free_set(Gwn_Batch*, void (*callback)(Gwn_Batch*, void*), void*); +void GPU_batch_callback_free_set(GPUBatch*, void (*callback)(GPUBatch*, void*), void*); -void GWN_batch_instbuf_set(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); /* Instancing */ +void GPU_batch_instbuf_set(GPUBatch*, GPUVertBuf*, bool own_vbo); /* Instancing */ -int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); +int GPU_batch_vertbuf_add_ex(GPUBatch*, GPUVertBuf*, bool own_vbo); -#define GWN_batch_vertbuf_add(batch, verts) \ - GWN_batch_vertbuf_add_ex(batch, verts, false) +#define GPU_batch_vertbuf_add(batch, verts) \ + GPU_batch_vertbuf_add_ex(batch, verts, false) -void GWN_batch_program_set_no_use(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); -void GWN_batch_program_set(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); -void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id); +void GPU_batch_program_set_no_use(GPUBatch*, uint32_t program, const GPUShaderInterface*); +void GPU_batch_program_set(GPUBatch*, uint32_t program, const GPUShaderInterface*); +void GPU_batch_program_set_builtin(GPUBatch *batch, GPUBuiltinShader shader_id); /* Entire batch draws with one shader program, but can be redrawn later with another program. */ /* Vertex shader's inputs must be compatible with the batch's vertex format. */ -void GWN_batch_program_use_begin(Gwn_Batch*); /* call before Batch_Uniform (temp hack?) */ -void GWN_batch_program_use_end(Gwn_Batch*); - -void GWN_batch_uniform_1ui(Gwn_Batch*, const char* name, int value); -void GWN_batch_uniform_1i(Gwn_Batch*, const char* name, int value); -void GWN_batch_uniform_1b(Gwn_Batch*, const char* name, bool value); -void GWN_batch_uniform_1f(Gwn_Batch*, const char* name, float value); -void GWN_batch_uniform_2f(Gwn_Batch*, const char* name, float x, float y); -void GWN_batch_uniform_3f(Gwn_Batch*, const char* name, float x, float y, float z); -void GWN_batch_uniform_4f(Gwn_Batch*, const char* name, float x, float y, float z, float w); -void GWN_batch_uniform_2fv(Gwn_Batch*, const char* name, const float data[2]); -void GWN_batch_uniform_3fv(Gwn_Batch*, const char* name, const float data[3]); -void GWN_batch_uniform_4fv(Gwn_Batch*, const char* name, const float data[4]); -void GWN_batch_uniform_2fv_array(Gwn_Batch*, const char* name, int len, const float *data); -void GWN_batch_uniform_4fv_array(Gwn_Batch*, const char* name, int len, const float *data); -void GWN_batch_uniform_mat4(Gwn_Batch*, const char* name, const float data[4][4]); - -void GWN_batch_draw(Gwn_Batch*); +void GPU_batch_program_use_begin(GPUBatch*); /* call before Batch_Uniform (temp hack?) */ +void GPU_batch_program_use_end(GPUBatch*); + +void GPU_batch_uniform_1ui(GPUBatch*, const char* name, int value); +void GPU_batch_uniform_1i(GPUBatch*, const char* name, int value); +void GPU_batch_uniform_1b(GPUBatch*, const char* name, bool value); +void GPU_batch_uniform_1f(GPUBatch*, const char* name, float value); +void GPU_batch_uniform_2f(GPUBatch*, const char* name, float x, float y); +void GPU_batch_uniform_3f(GPUBatch*, const char* name, float x, float y, float z); +void GPU_batch_uniform_4f(GPUBatch*, const char* name, float x, float y, float z, float w); +void GPU_batch_uniform_2fv(GPUBatch*, const char* name, const float data[2]); +void GPU_batch_uniform_3fv(GPUBatch*, const char* name, const float data[3]); +void GPU_batch_uniform_4fv(GPUBatch*, const char* name, const float data[4]); +void GPU_batch_uniform_2fv_array(GPUBatch*, const char* name, int len, const float *data); +void GPU_batch_uniform_4fv_array(GPUBatch*, const char* name, int len, const float *data); +void GPU_batch_uniform_mat4(GPUBatch*, const char* name, const float data[4][4]); + +void GPU_batch_draw(GPUBatch*); /* This does not bind/unbind shader and does not call GPU_matrix_bind() */ -void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance); +void GPU_batch_draw_range_ex(GPUBatch*, int v_first, int v_count, bool force_instance); /* Does not even need batch */ -void GWN_draw_primitive(Gwn_PrimType, int v_count); +void GPU_draw_primitive(GPUPrimType, int v_count); #if 0 /* future plans */ -/* Can multiple batches share a Gwn_VertBuf? Use ref count? */ +/* Can multiple batches share a GPUVertBuf? Use ref count? */ /* We often need a batch with its own data, to be created and discarded together. */ /* WithOwn variants reduce number of system allocations. */ typedef struct BatchWithOwnVertexBuffer { - Gwn_Batch batch; - Gwn_VertBuf verts; /* link batch.verts to this */ + GPUBatch batch; + GPUVertBuf verts; /* link batch.verts to this */ } BatchWithOwnVertexBuffer; typedef struct BatchWithOwnElementList { - Gwn_Batch batch; - Gwn_IndexBuf elem; /* link batch.elem to this */ + GPUBatch batch; + GPUIndexBuf elem; /* link batch.elem to this */ } BatchWithOwnElementList; typedef struct BatchWithOwnVertexBufferAndElementList { - Gwn_Batch batch; - Gwn_IndexBuf elem; /* link batch.elem to this */ - Gwn_VertBuf verts; /* link batch.verts to this */ + GPUBatch batch; + GPUIndexBuf elem; /* link batch.elem to this */ + GPUVertBuf verts; /* link batch.verts to this */ } BatchWithOwnVertexBufferAndElementList; -Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, uint v_len, Gwn_IndexBuf*); -Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, uint prim_len); -Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, uint v_len, uint prim_len); +GPUBatch* create_BatchWithOwnVertexBuffer(GPUPrimType, GPUVertFormat*, uint v_len, GPUIndexBuf*); +GPUBatch* create_BatchWithOwnElementList(GPUPrimType, GPUVertBuf*, uint prim_len); +GPUBatch* create_BatchWithOwnVertexBufferAndElementList(GPUPrimType, GPUVertFormat*, uint v_len, uint prim_len); /* verts: shared, own */ /* elem: none, shared, own */ -Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff); +GPUBatch* create_BatchInGeneral(GPUPrimType, VertexBufferStuff, ElementListStuff); #endif /* future plans */ @@ -189,11 +189,11 @@ void gpu_batch_exit(void); /* Macros */ -#define GWN_BATCH_DISCARD_SAFE(batch) do { \ +#define GPU_BATCH_DISCARD_SAFE(batch) do { \ if (batch != NULL) { \ - GWN_batch_discard(batch); \ + GPU_batch_discard(batch); \ batch = NULL; \ } \ } while (0) -#endif /* __GWN_BATCH_H__ */ +#endif /* __GPU_BATCH_H__ */ diff --git a/source/blender/gpu/GPU_batch_presets.h b/source/blender/gpu/GPU_batch_presets.h index 2450a1760c3..a33b864c5b9 100644 --- a/source/blender/gpu/GPU_batch_presets.h +++ b/source/blender/gpu/GPU_batch_presets.h @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/* Batched geometry rendering is powered by the Gawain library. +/* Batched geometry rendering is powered by the GPU library. * This file contains any additions or modifications specific to Blender. */ @@ -32,20 +32,20 @@ #define __GPU_BATCH_PRESETS_H__ struct rctf; -struct Gwn_VertFormat; +struct GPUVertFormat; #include "BLI_compiler_attrs.h" #include "BLI_sys_types.h" /* gpu_batch_presets.c */ -struct Gwn_VertFormat *GPU_batch_preset_format_3d(void); +struct GPUVertFormat *GPU_batch_preset_format_3d(void); /* Replacement for gluSphere */ -struct Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT; -struct Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT; +struct GPUBatch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT; +struct GPUBatch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT; void gpu_batch_presets_init(void); -void gpu_batch_presets_register(struct Gwn_Batch *preset_batch); +void gpu_batch_presets_register(struct GPUBatch *preset_batch); void gpu_batch_presets_reset(void); void gpu_batch_presets_exit(void); diff --git a/source/blender/gpu/GPU_batch_utils.h b/source/blender/gpu/GPU_batch_utils.h index b23b7723dc0..d558b7a1097 100644 --- a/source/blender/gpu/GPU_batch_utils.h +++ b/source/blender/gpu/GPU_batch_utils.h @@ -27,14 +27,14 @@ struct rctf; #include "BLI_sys_types.h" /* gpu_batch_utils.c */ -struct Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( +struct GPUBatch *GPU_batch_tris_from_poly_2d_encoded( const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); -struct Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( +struct GPUBatch *GPU_batch_wire_from_poly_2d_encoded( const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /* Only use by draw manager. Use the presets function instead for interface. */ -struct Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT; +struct GPUBatch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT; #endif /* __GPU_BATCH_UTILS_H__ */ diff --git a/source/blender/gpu/GPU_buffer_id.h b/source/blender/gpu/GPU_buffer_id.h index fd680ff31f5..4615e9e2c66 100644 --- a/source/blender/gpu/GPU_buffer_id.h +++ b/source/blender/gpu/GPU_buffer_id.h @@ -23,14 +23,14 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_buffer_id.h +/** \file blender/gpu/GPU_buffer_id.h * \ingroup gpu * - * Gawain buffer IDs + * GPU buffer IDs */ -#ifndef __GWN_BUFFER_ID_H__ -#define __GWN_BUFFER_ID_H__ +#ifndef __GPU_BUFFER_ID_H__ +#define __GPU_BUFFER_ID_H__ /* Manage GL buffer IDs in a thread-safe way * Use these instead of glGenBuffers & its friends @@ -43,11 +43,11 @@ extern "C" { #include "GPU_common.h" -GLuint GWN_buf_id_alloc(void); -void GWN_buf_id_free(GLuint buffer_id); +GLuint GPU_buf_id_alloc(void); +void GPU_buf_id_free(GLuint buffer_id); #ifdef __cplusplus } #endif -#endif /* __GWN_BUFFER_ID_H__ */ +#endif /* __GPU_BUFFER_ID_H__ */ diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index f496c92f283..77801256463 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -91,7 +91,7 @@ void GPU_pbvh_grid_buffers_update( const int update_flags); /* draw */ -struct Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast); +struct GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast); /* debug PBVH draw */ void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos); diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h index 2587e8670a9..cb506c6b0bc 100644 --- a/source/blender/gpu/GPU_common.h +++ b/source/blender/gpu/GPU_common.h @@ -23,12 +23,12 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_common.h +/** \file blender/gpu/GPU_common.h * \ingroup gpu */ -#ifndef __GWN_COMMON_H__ -#define __GWN_COMMON_H__ +#ifndef __GPU_COMMON_H__ +#define __GPU_COMMON_H__ #define PROGRAM_NO_OPTI 0 @@ -51,11 +51,11 @@ #include #endif -/* GWN_INLINE */ +/* GPU_INLINE */ #if defined(_MSC_VER) -# define GWN_INLINE static __forceinline +# define GPU_INLINE static __forceinline #else -# define GWN_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) +# define GPU_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) #endif -#endif /* __GWN_COMMON_H__ */ +#endif /* __GPU_COMMON_H__ */ diff --git a/source/blender/gpu/GPU_context.h b/source/blender/gpu/GPU_context.h index 0cedc109645..5f63c408801 100644 --- a/source/blender/gpu/GPU_context.h +++ b/source/blender/gpu/GPU_context.h @@ -23,14 +23,14 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_context.h +/** \file blender/gpu/GPU_context.h * \ingroup gpu * - * This interface allow Gawain to manage VAOs for mutiple context and threads. + * This interface allow GPU to manage VAOs for mutiple context and threads. */ -#ifndef __GWN_CONTEXT_H__ -#define __GWN_CONTEXT_H__ +#ifndef __GPU_CONTEXT_H__ +#define __GPU_CONTEXT_H__ #ifdef __cplusplus extern "C" { @@ -40,16 +40,16 @@ extern "C" { #include "GPU_batch.h" #include "GPU_shader_interface.h" -typedef struct Gwn_Context Gwn_Context; +typedef struct GPUContext GPUContext; -Gwn_Context* GWN_context_create(void); -void GWN_context_discard(Gwn_Context*); +GPUContext* GPU_context_create(void); +void GPU_context_discard(GPUContext*); -void GWN_context_active_set(Gwn_Context*); -Gwn_Context* GWN_context_active_get(void); +void GPU_context_active_set(GPUContext*); +GPUContext* GPU_context_active_get(void); #ifdef __cplusplus } #endif -#endif /* __GWN_CONTEXT_H__ */ +#endif /* __GPU_CONTEXT_H__ */ diff --git a/source/blender/gpu/GPU_element.h b/source/blender/gpu/GPU_element.h index 0c23e90569b..508c079fcd3 100644 --- a/source/blender/gpu/GPU_element.h +++ b/source/blender/gpu/GPU_element.h @@ -23,31 +23,31 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_element.h +/** \file blender/gpu/GPU_element.h * \ingroup gpu * - * Gawain element list (AKA index buffer) + * GPU element list (AKA index buffer) */ -#ifndef __GWN_ELEMENT_H__ -#define __GWN_ELEMENT_H__ +#ifndef __GPU_ELEMENT_H__ +#define __GPU_ELEMENT_H__ #include "GPU_primitive.h" -#define GWN_TRACK_INDEX_RANGE 1 +#define GPU_TRACK_INDEX_RANGE 1 -#define GWN_PRIM_RESTART 0xFFFFFFFF +#define GPU_PRIM_RESTART 0xFFFFFFFF typedef enum { - GWN_INDEX_U8, /* GL has this, Vulkan does not */ - GWN_INDEX_U16, - GWN_INDEX_U32 -} Gwn_IndexBufType; + GPU_INDEX_U8, /* GL has this, Vulkan does not */ + GPU_INDEX_U16, + GPU_INDEX_U32 +} GPUIndexBufType; -typedef struct Gwn_IndexBuf { +typedef struct GPUIndexBuf { uint index_len; -#if GWN_TRACK_INDEX_RANGE - Gwn_IndexBufType index_type; +#if GPU_TRACK_INDEX_RANGE + GPUIndexBufType index_type; uint32_t gl_index_type; uint min_index; uint max_index; @@ -55,48 +55,48 @@ typedef struct Gwn_IndexBuf { #endif uint32_t vbo_id; /* 0 indicates not yet sent to VRAM */ bool use_prim_restart; -} Gwn_IndexBuf; +} GPUIndexBuf; -void GWN_indexbuf_use(Gwn_IndexBuf*); -uint GWN_indexbuf_size_get(const Gwn_IndexBuf*); +void GPU_indexbuf_use(GPUIndexBuf*); +uint GPU_indexbuf_size_get(const GPUIndexBuf*); -typedef struct Gwn_IndexBufBuilder { +typedef struct GPUIndexBufBuilder { uint max_allowed_index; uint max_index_len; uint index_len; - Gwn_PrimType prim_type; + GPUPrimType prim_type; uint* data; bool use_prim_restart; -} Gwn_IndexBufBuilder; +} GPUIndexBufBuilder; /* supports all primitive types. */ -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, uint index_len, uint vertex_len, bool use_prim_restart); +void GPU_indexbuf_init_ex(GPUIndexBufBuilder*, GPUPrimType, uint index_len, uint vertex_len, bool use_prim_restart); -/* supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS. */ -void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, uint prim_len, uint vertex_len); +/* supports only GPU_PRIM_POINTS, GPU_PRIM_LINES and GPU_PRIM_TRIS. */ +void GPU_indexbuf_init(GPUIndexBufBuilder*, GPUPrimType, uint prim_len, uint vertex_len); -void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, uint v); -void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*); +void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder*, uint v); +void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder*); -void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, uint v); -void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, uint v1, uint v2); -void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3); -void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3, uint v4); +void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder*, uint v); +void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder*, uint v1, uint v2); +void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder*, uint v1, uint v2, uint v3); +void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder*, uint v1, uint v2, uint v3, uint v4); -Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*); -void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*); +GPUIndexBuf* GPU_indexbuf_build(GPUIndexBufBuilder*); +void GPU_indexbuf_build_in_place(GPUIndexBufBuilder*, GPUIndexBuf*); -void GWN_indexbuf_discard(Gwn_IndexBuf*); +void GPU_indexbuf_discard(GPUIndexBuf*); /* Macros */ -#define GWN_INDEXBUF_DISCARD_SAFE(elem) do { \ +#define GPU_INDEXBUF_DISCARD_SAFE(elem) do { \ if (elem != NULL) { \ - GWN_indexbuf_discard(elem); \ + GPU_indexbuf_discard(elem); \ elem = NULL; \ } \ } while (0) -#endif /* __GWN_ELEMENT_H__ */ +#endif /* __GPU_ELEMENT_H__ */ diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h index c5892886825..a756687b557 100644 --- a/source/blender/gpu/GPU_immediate.h +++ b/source/blender/gpu/GPU_immediate.h @@ -27,7 +27,7 @@ /** \file blender/gpu/GPU_immediate.h * \ingroup gpu * - * Gawain immediate mode work-alike + * GPU immediate mode work-alike */ #ifndef __GPU_IMMEDIATE_H__ @@ -40,20 +40,20 @@ #include "GPU_immediate_util.h" #include "GPU_shader.h" -Gwn_VertFormat* immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ +GPUVertFormat* immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ -void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); /* every immBegin must have a program bound first. */ +void immBindProgram(uint32_t program, const GPUShaderInterface*); /* every immBegin must have a program bound first. */ void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */ -void immBegin(Gwn_PrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */ -void immBeginAtMost(Gwn_PrimType, uint max_vertex_len); /* can supply fewer vertices. */ +void immBegin(GPUPrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */ +void immBeginAtMost(GPUPrimType, uint max_vertex_len); /* can supply fewer vertices. */ void immEnd(void); /* finishes and draws. */ /* ImmBegin a batch, then use standard immFunctions as usual. */ /* ImmEnd will finalize the batch instead of drawing. */ /* Then you can draw it as many times as you like! Partially replaces the need for display lists. */ -Gwn_Batch* immBeginBatch(Gwn_PrimType, uint vertex_len); -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, uint vertex_len); +GPUBatch* immBeginBatch(GPUPrimType, uint vertex_len); +GPUBatch* immBeginBatchAtMost(GPUPrimType, uint vertex_len); /* Provide attribute values that can change per vertex. */ /* First vertex after immBegin must have all its attributes specified. */ diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h index 0a5c9805509..58555e287b0 100644 --- a/source/blender/gpu/GPU_immediate_util.h +++ b/source/blender/gpu/GPU_immediate_util.h @@ -32,7 +32,7 @@ void immRectf(uint pos, float x1, float y1, float x2, float y2); void immRecti(uint pos, int x1, int y1, int x2, int y2); -/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS. */ +/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GPU_PRIM_TRIS. */ void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]); void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]); @@ -44,7 +44,7 @@ void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments); void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments); -/* use this version when Gwn_VertFormat has a vec3 position */ +/* use this version when GPUVertFormat has a vec3 position */ void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments); void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments); diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h index f5e34bd4c90..23f19ed19cd 100644 --- a/source/blender/gpu/GPU_matrix.h +++ b/source/blender/gpu/GPU_matrix.h @@ -38,7 +38,7 @@ extern "C" { #endif -struct Gwn_ShaderInterface; +struct GPUShaderInterface; void GPU_matrix_reset(void); /* to Identity transform & empty stack */ @@ -111,7 +111,7 @@ const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]; /* set uniform values for currently bound shader */ -void GPU_matrix_bind(const struct Gwn_ShaderInterface *); +void GPU_matrix_bind(const struct GPUShaderInterface *); bool GPU_matrix_dirty_get(void); /* since last bind */ diff --git a/source/blender/gpu/GPU_primitive.h b/source/blender/gpu/GPU_primitive.h index 44348b9b593..bcedfa56ab1 100644 --- a/source/blender/gpu/GPU_primitive.h +++ b/source/blender/gpu/GPU_primitive.h @@ -23,43 +23,43 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_primitive.h +/** \file blender/gpu/GPU_primitive.h * \ingroup gpu * - * Gawain geometric primitives + * GPU geometric primitives */ -#ifndef __GWN_PRIMITIVE_H__ -#define __GWN_PRIMITIVE_H__ +#ifndef __GPU_PRIMITIVE_H__ +#define __GPU_PRIMITIVE_H__ #include "GPU_common.h" typedef enum { - GWN_PRIM_POINTS, - GWN_PRIM_LINES, - GWN_PRIM_TRIS, - GWN_PRIM_LINE_STRIP, - GWN_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */ - GWN_PRIM_TRI_STRIP, - GWN_PRIM_TRI_FAN, + GPU_PRIM_POINTS, + GPU_PRIM_LINES, + GPU_PRIM_TRIS, + GPU_PRIM_LINE_STRIP, + GPU_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */ + GPU_PRIM_TRI_STRIP, + GPU_PRIM_TRI_FAN, - GWN_PRIM_LINES_ADJ, - GWN_PRIM_TRIS_ADJ, - GWN_PRIM_LINE_STRIP_ADJ, + GPU_PRIM_LINES_ADJ, + GPU_PRIM_TRIS_ADJ, + GPU_PRIM_LINE_STRIP_ADJ, - GWN_PRIM_NONE -} Gwn_PrimType; + GPU_PRIM_NONE +} GPUPrimType; /* what types of primitives does each shader expect? */ typedef enum { - GWN_PRIM_CLASS_NONE = 0, - GWN_PRIM_CLASS_POINT = (1 << 0), - GWN_PRIM_CLASS_LINE = (1 << 1), - GWN_PRIM_CLASS_SURFACE = (1 << 2), - GWN_PRIM_CLASS_ANY = GWN_PRIM_CLASS_POINT | GWN_PRIM_CLASS_LINE | GWN_PRIM_CLASS_SURFACE -} Gwn_PrimClass; + GPU_PRIM_CLASS_NONE = 0, + GPU_PRIM_CLASS_POINT = (1 << 0), + GPU_PRIM_CLASS_LINE = (1 << 1), + GPU_PRIM_CLASS_SURFACE = (1 << 2), + GPU_PRIM_CLASS_ANY = GPU_PRIM_CLASS_POINT | GPU_PRIM_CLASS_LINE | GPU_PRIM_CLASS_SURFACE +} GPUPrimClass; -Gwn_PrimClass GWN_primtype_class(Gwn_PrimType); -bool GWN_primtype_belongs_to_class(Gwn_PrimType, Gwn_PrimClass); +GPUPrimClass GPU_primtype_class(GPUPrimType); +bool GPU_primtype_belongs_to_class(GPUPrimType, GPUPrimClass); -#endif /* __GWN_PRIMITIVE_H__ */ +#endif /* __GPU_PRIMITIVE_H__ */ diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index 36842e9847a..c80cc1021ec 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -23,82 +23,82 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_shader_interface.h +/** \file blender/gpu/GPU_shader_interface.h * \ingroup gpu * - * Gawain shader interface (C --> GLSL) + * GPU shader interface (C --> GLSL) */ -#ifndef __GWN_SHADER_INTERFACE_H__ -#define __GWN_SHADER_INTERFACE_H__ +#ifndef __GPU_SHADER_INTERFACE_H__ +#define __GPU_SHADER_INTERFACE_H__ #include "GPU_common.h" typedef enum { - GWN_UNIFORM_NONE = 0, /* uninitialized/unknown */ + GPU_UNIFORM_NONE = 0, /* uninitialized/unknown */ - GWN_UNIFORM_MODEL, /* mat4 ModelMatrix */ - GWN_UNIFORM_VIEW, /* mat4 ViewMatrix */ - GWN_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */ - GWN_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */ - GWN_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */ - GWN_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */ + GPU_UNIFORM_MODEL, /* mat4 ModelMatrix */ + GPU_UNIFORM_VIEW, /* mat4 ViewMatrix */ + GPU_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */ + GPU_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */ + GPU_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */ + GPU_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */ - GWN_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */ - GWN_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */ - GWN_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */ - GWN_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */ - GWN_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */ + GPU_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */ + GPU_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */ + GPU_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */ + GPU_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */ + GPU_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */ - GWN_UNIFORM_NORMAL, /* mat3 NormalMatrix */ - GWN_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */ - GWN_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ - GWN_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ + GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */ + GPU_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */ + GPU_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ + GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ - GWN_UNIFORM_COLOR, /* vec4 color */ - GWN_UNIFORM_EYE, /* vec3 eye */ - GWN_UNIFORM_CALLID, /* int callId */ + GPU_UNIFORM_COLOR, /* vec4 color */ + GPU_UNIFORM_EYE, /* vec3 eye */ + GPU_UNIFORM_CALLID, /* int callId */ - GWN_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ + GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ - GWN_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ -} Gwn_UniformBuiltin; + GPU_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ +} GPUUniformBuiltin; -typedef struct Gwn_ShaderInput { - struct Gwn_ShaderInput* next; +typedef struct GPUShaderInput { + struct GPUShaderInput* next; uint32_t name_offset; uint name_hash; - Gwn_UniformBuiltin builtin_type; /* only for uniform inputs */ + GPUUniformBuiltin builtin_type; /* only for uniform inputs */ uint32_t gl_type; /* only for attrib inputs */ int32_t size; /* only for attrib inputs */ int32_t location; -} Gwn_ShaderInput; +} GPUShaderInput; -#define GWN_NUM_SHADERINTERFACE_BUCKETS 257 -#define GWN_SHADERINTERFACE_REF_ALLOC_COUNT 16 +#define GPU_NUM_SHADERINTERFACE_BUCKETS 257 +#define GPU_SHADERINTERFACE_REF_ALLOC_COUNT 16 -typedef struct Gwn_ShaderInterface { +typedef struct GPUShaderInterface { int32_t program; uint32_t name_buffer_offset; - Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* ubo_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS]; + GPUShaderInput* attrib_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput* uniform_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput* ubo_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput* builtin_uniforms[GPU_NUM_UNIFORMS]; char* name_buffer; - struct Gwn_Batch** batches; /* references to batches using this interface */ + struct GPUBatch** batches; /* references to batches using this interface */ uint batches_len; -} Gwn_ShaderInterface; +} GPUShaderInterface; -Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id); -void GWN_shaderinterface_discard(Gwn_ShaderInterface*); +GPUShaderInterface* GPU_shaderinterface_create(int32_t program_id); +void GPU_shaderinterface_discard(GPUShaderInterface*); -const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name); -const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin); -const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface*, const char* name); -const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name); +const GPUShaderInput* GPU_shaderinterface_uniform(const GPUShaderInterface*, const char* name); +const GPUShaderInput* GPU_shaderinterface_uniform_builtin(const GPUShaderInterface*, GPUUniformBuiltin); +const GPUShaderInput* GPU_shaderinterface_ubo(const GPUShaderInterface*, const char* name); +const GPUShaderInput* GPU_shaderinterface_attr(const GPUShaderInterface*, const char* name); /* keep track of batches using this interface */ -void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); -void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); +void GPU_shaderinterface_add_batch_ref(GPUShaderInterface*, struct GPUBatch*); +void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface*, struct GPUBatch*); -#endif /* __GWN_SHADER_INTERFACE_H__ */ +#endif /* __GPU_SHADER_INTERFACE_H__ */ diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 3ed9014d431..e3db18f1358 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -41,7 +41,7 @@ extern "C" { struct Image; struct ImageUser; struct PreviewImage; -struct Gwn_VertBuf; +struct GPUVertBuf; struct GPUFrameBuffer; typedef struct GPUTexture GPUTexture; @@ -174,7 +174,7 @@ GPUTexture *GPU_texture_create_3D( GPUTexture *GPU_texture_create_cube( int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]); GPUTexture *GPU_texture_create_from_vertbuf( - struct Gwn_VertBuf *vert); + struct GPUVertBuf *vert); GPUTexture *GPU_texture_create_buffer( GPUTextureFormat data_type, const uint buffer); diff --git a/source/blender/gpu/GPU_vertex_array_id.h b/source/blender/gpu/GPU_vertex_array_id.h index 925cd74511d..3b3fdc1709d 100644 --- a/source/blender/gpu/GPU_vertex_array_id.h +++ b/source/blender/gpu/GPU_vertex_array_id.h @@ -23,7 +23,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_array_id.h +/** \file blender/gpu/GPU_vertex_array_id.h * \ingroup gpu * * Manage GL vertex array IDs in a thread-safe way @@ -34,8 +34,8 @@ * - free can be called from any thread */ -#ifndef __GWN_VERTEX_ARRAY_ID_H__ -#define __GWN_VERTEX_ARRAY_ID_H__ +#ifndef __GPU_VERTEX_ARRAY_ID_H__ +#define __GPU_VERTEX_ARRAY_ID_H__ #ifdef __cplusplus extern "C" { @@ -44,12 +44,12 @@ extern "C" { #include "GPU_common.h" #include "GPU_context.h" -GLuint GWN_vao_default(void); -GLuint GWN_vao_alloc(void); -void GWN_vao_free(GLuint vao_id, Gwn_Context*); +GLuint GPU_vao_default(void); +GLuint GPU_vao_alloc(void); +void GPU_vao_free(GLuint vao_id, GPUContext*); #ifdef __cplusplus } #endif -#endif /* __GWN_VERTEX_ARRAY_ID_H__ */ +#endif /* __GPU_VERTEX_ARRAY_ID_H__ */ diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h index 7e4aa24ff2c..896de387065 100644 --- a/source/blender/gpu/GPU_vertex_buffer.h +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -23,73 +23,73 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_buffer.h +/** \file blender/gpu/GPU_vertex_buffer.h * \ingroup gpu * - * Gawain vertex buffer + * GPU vertex buffer */ -#ifndef __GWN_VERTEX_BUFFER_H__ -#define __GWN_VERTEX_BUFFER_H__ +#ifndef __GPU_VERTEX_BUFFER_H__ +#define __GPU_VERTEX_BUFFER_H__ #include "GPU_vertex_format.h" #define VRAM_USAGE 1 -/* How to create a Gwn_VertBuf: */ -/* 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts) */ -/* 2) GWN_vertformat_attr_add(verts->format, ...) */ -/* 3) GWN_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format */ -/* 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer) */ +/* How to create a GPUVertBuf: */ +/* 1) verts = GPU_vertbuf_create() or GPU_vertbuf_init(verts) */ +/* 2) GPU_vertformat_attr_add(verts->format, ...) */ +/* 3) GPU_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format */ +/* 4) GPU_vertbuf_attr_fill(verts, pos, application_pos_buffer) */ -/* Is Gwn_VertBuf always used as part of a Gwn_Batch? */ +/* Is GPUVertBuf always used as part of a GPUBatch? */ typedef enum { /* can be extended to support more types */ - GWN_USAGE_STREAM, - GWN_USAGE_STATIC, /* do not keep data in memory */ - GWN_USAGE_DYNAMIC -} Gwn_UsageType; + GPU_USAGE_STREAM, + GPU_USAGE_STATIC, /* do not keep data in memory */ + GPU_USAGE_DYNAMIC +} GPUUsageType; -typedef struct Gwn_VertBuf { - Gwn_VertFormat format; +typedef struct GPUVertBuf { + GPUVertFormat format; uint vertex_len; /* number of verts we want to draw */ uint vertex_alloc; /* number of verts data */ bool dirty; unsigned char* data; /* NULL indicates data in VRAM (unmapped) */ uint32_t vbo_id; /* 0 indicates not yet allocated */ - Gwn_UsageType usage; /* usage hint for GL optimisation */ -} Gwn_VertBuf; + GPUUsageType usage; /* usage hint for GL optimisation */ +} GPUVertBuf; -Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType); -Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat*, Gwn_UsageType); +GPUVertBuf* GPU_vertbuf_create(GPUUsageType); +GPUVertBuf* GPU_vertbuf_create_with_format_ex(const GPUVertFormat*, GPUUsageType); -#define GWN_vertbuf_create_with_format(format) \ - GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_STATIC) +#define GPU_vertbuf_create_with_format(format) \ + GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_STATIC) -void GWN_vertbuf_discard(Gwn_VertBuf*); +void GPU_vertbuf_discard(GPUVertBuf*); -void GWN_vertbuf_init(Gwn_VertBuf*, Gwn_UsageType); -void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf*, const Gwn_VertFormat*, Gwn_UsageType); +void GPU_vertbuf_init(GPUVertBuf*, GPUUsageType); +void GPU_vertbuf_init_with_format_ex(GPUVertBuf*, const GPUVertFormat*, GPUUsageType); -#define GWN_vertbuf_init_with_format(verts, format) \ - GWN_vertbuf_init_with_format_ex(verts, format, GWN_USAGE_STATIC) +#define GPU_vertbuf_init_with_format(verts, format) \ + GPU_vertbuf_init_with_format_ex(verts, format, GPU_USAGE_STATIC) -uint GWN_vertbuf_size_get(const Gwn_VertBuf*); -void GWN_vertbuf_data_alloc(Gwn_VertBuf*, uint v_len); -void GWN_vertbuf_data_resize(Gwn_VertBuf*, uint v_len); -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, uint v_len); +uint GPU_vertbuf_size_get(const GPUVertBuf*); +void GPU_vertbuf_data_alloc(GPUVertBuf*, uint v_len); +void GPU_vertbuf_data_resize(GPUVertBuf*, uint v_len); +void GPU_vertbuf_vertex_count_set(GPUVertBuf*, uint v_len); /* The most important set_attrib variant is the untyped one. Get it right first. */ /* It takes a void* so the app developer is responsible for matching their app data types */ /* to the vertex attribute's type and component count. They're in control of both, so this */ /* should not be a problem. */ -void GWN_vertbuf_attr_set(Gwn_VertBuf*, uint a_idx, uint v_idx, const void* data); -void GWN_vertbuf_attr_fill(Gwn_VertBuf*, uint a_idx, const void* data); /* tightly packed, non interleaved input data */ -void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, uint a_idx, uint stride, const void* data); +void GPU_vertbuf_attr_set(GPUVertBuf*, uint a_idx, uint v_idx, const void* data); +void GPU_vertbuf_attr_fill(GPUVertBuf*, uint a_idx, const void* data); /* tightly packed, non interleaved input data */ +void GPU_vertbuf_attr_fill_stride(GPUVertBuf*, uint a_idx, uint stride, const void* data); /* For low level access only */ -typedef struct Gwn_VertBufRaw { +typedef struct GPUVertBufRaw { uint size; uint stride; unsigned char* data; @@ -98,9 +98,9 @@ typedef struct Gwn_VertBufRaw { /* Only for overflow check */ unsigned char* _data_end; #endif -} Gwn_VertBufRaw; +} GPUVertBufRaw; -GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a) +GPU_INLINE void *GPU_vertbuf_raw_step(GPUVertBufRaw *a) { unsigned char* data = a->data; a->data += a->stride; @@ -110,12 +110,12 @@ GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a) return (void *)data; } -GWN_INLINE uint GWN_vertbuf_raw_used(Gwn_VertBufRaw *a) +GPU_INLINE uint GPU_vertbuf_raw_used(GPUVertBufRaw *a) { return ((a->data - a->data_init) / a->stride); } -void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, uint a_idx, Gwn_VertBufRaw *access); +void GPU_vertbuf_attr_get_raw_data(GPUVertBuf*, uint a_idx, GPUVertBufRaw *access); /* TODO: decide whether to keep the functions below */ /* doesn't immediate mode satisfy these needs? */ @@ -128,17 +128,17 @@ void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, uint a_idx, Gwn_VertBufRaw *acc /* void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b); */ /* void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a); */ -void GWN_vertbuf_use(Gwn_VertBuf*); +void GPU_vertbuf_use(GPUVertBuf*); /* Metrics */ -uint GWN_vertbuf_get_memory_usage(void); +uint GPU_vertbuf_get_memory_usage(void); /* Macros */ -#define GWN_VERTBUF_DISCARD_SAFE(verts) do { \ +#define GPU_VERTBUF_DISCARD_SAFE(verts) do { \ if (verts != NULL) { \ - GWN_vertbuf_discard(verts); \ + GPU_vertbuf_discard(verts); \ verts = NULL; \ } \ } while (0) -#endif /* __GWN_VERTEX_BUFFER_H__ */ +#endif /* __GPU_VERTEX_BUFFER_H__ */ diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 91e31b5ece4..7ae8118a928 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -23,79 +23,79 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_format.h +/** \file blender/gpu/GPU_vertex_format.h * \ingroup gpu * - * Gawain vertex format + * GPU vertex format */ -#ifndef __GWN_VERTEX_FORMAT_H__ -#define __GWN_VERTEX_FORMAT_H__ +#ifndef __GPU_VERTEX_FORMAT_H__ +#define __GPU_VERTEX_FORMAT_H__ #include "GPU_common.h" -#define GWN_VERT_ATTR_MAX_LEN 16 -#define GWN_VERT_ATTR_MAX_NAMES 3 -#define GWN_VERT_ATTR_NAME_AVERAGE_LEN 11 -#define GWN_VERT_ATTR_NAMES_BUF_LEN ((GWN_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GWN_VERT_ATTR_MAX_LEN) +#define GPU_VERT_ATTR_MAX_LEN 16 +#define GPU_VERT_ATTR_MAX_NAMES 3 +#define GPU_VERT_ATTR_NAME_AVERAGE_LEN 11 +#define GPU_VERT_ATTR_NAMES_BUF_LEN ((GPU_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GPU_VERT_ATTR_MAX_LEN) typedef enum { - GWN_COMP_I8, - GWN_COMP_U8, - GWN_COMP_I16, - GWN_COMP_U16, - GWN_COMP_I32, - GWN_COMP_U32, + GPU_COMP_I8, + GPU_COMP_U8, + GPU_COMP_I16, + GPU_COMP_U16, + GPU_COMP_I32, + GPU_COMP_U32, - GWN_COMP_F32, + GPU_COMP_F32, - GWN_COMP_I10 -} Gwn_VertCompType; + GPU_COMP_I10 +} GPUVertCompType; typedef enum { - GWN_FETCH_FLOAT, - GWN_FETCH_INT, - GWN_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */ - GWN_FETCH_INT_TO_FLOAT /* 127 (any int type) -> 127.0 */ -} Gwn_VertFetchMode; - -typedef struct Gwn_VertAttr { - Gwn_VertFetchMode fetch_mode; - Gwn_VertCompType comp_type; + GPU_FETCH_FLOAT, + GPU_FETCH_INT, + GPU_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */ + GPU_FETCH_INT_TO_FLOAT /* 127 (any int type) -> 127.0 */ +} GPUVertFetchMode; + +typedef struct GPUVertAttr { + GPUVertFetchMode fetch_mode; + GPUVertCompType comp_type; uint gl_comp_type; uint comp_len; /* 1 to 4 or 8 or 12 or 16 */ uint sz; /* size in bytes, 1 to 64 */ uint offset; /* from beginning of vertex, in bytes */ - uint name_len; /* up to GWN_VERT_ATTR_MAX_NAMES */ - const char* name[GWN_VERT_ATTR_MAX_NAMES]; -} Gwn_VertAttr; + uint name_len; /* up to GPU_VERT_ATTR_MAX_NAMES */ + const char* name[GPU_VERT_ATTR_MAX_NAMES]; +} GPUVertAttr; -typedef struct Gwn_VertFormat { - uint attr_len; /* 0 to 16 (GWN_VERT_ATTR_MAX_LEN) */ +typedef struct GPUVertFormat { + uint attr_len; /* 0 to 16 (GPU_VERT_ATTR_MAX_LEN) */ uint name_len; /* total count of active vertex attrib */ uint stride; /* stride in bytes, 1 to 256 */ uint name_offset; bool packed; - char names[GWN_VERT_ATTR_NAMES_BUF_LEN]; - Gwn_VertAttr attribs[GWN_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */ -} Gwn_VertFormat; + char names[GPU_VERT_ATTR_NAMES_BUF_LEN]; + GPUVertAttr attribs[GPU_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */ +} GPUVertFormat; -void GWN_vertformat_clear(Gwn_VertFormat*); -void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src); +void GPU_vertformat_clear(GPUVertFormat*); +void GPU_vertformat_copy(GPUVertFormat* dest, const GPUVertFormat* src); -uint GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, uint comp_len, Gwn_VertFetchMode); -void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias); +uint GPU_vertformat_attr_add(GPUVertFormat*, const char* name, GPUVertCompType, uint comp_len, GPUVertFetchMode); +void GPU_vertformat_alias_add(GPUVertFormat*, const char* alias); /* format conversion */ -typedef struct Gwn_PackedNormal { +typedef struct GPUPackedNormal { int x : 10; int y : 10; int z : 10; int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */ -} Gwn_PackedNormal; +} GPUPackedNormal; -Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]); -Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]); +GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3]); +GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3]); -#endif /* __GWN_VERTEX_FORMAT_H__ */ +#endif /* __GPU_VERTEX_FORMAT_H__ */ diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c index e7eba369335..9ac38578792 100644 --- a/source/blender/gpu/intern/gpu_attr_binding.c +++ b/source/blender/gpu/intern/gpu_attr_binding.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_attr_binding.c +/** \file blender/gpu/intern/gpu_attr_binding.c * \ingroup gpu * - * Gawain vertex attribute binding + * GPU vertex attribute binding */ #include "GPU_attr_binding.h" @@ -34,30 +34,30 @@ #include #include -#if GWN_VERT_ATTR_MAX_LEN != 16 - #error "attrib binding code assumes GWN_VERT_ATTR_MAX_LEN = 16" +#if GPU_VERT_ATTR_MAX_LEN != 16 + #error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16" #endif -void AttribBinding_clear(Gwn_AttrBinding* binding) +void AttribBinding_clear(GPUAttrBinding* binding) { binding->loc_bits = 0; binding->enabled_bits = 0; } -uint read_attrib_location(const Gwn_AttrBinding* binding, uint a_idx) +uint read_attrib_location(const GPUAttrBinding* binding, uint a_idx) { #if TRUST_NO_ONE - assert(a_idx < GWN_VERT_ATTR_MAX_LEN); + assert(a_idx < GPU_VERT_ATTR_MAX_LEN); assert(binding->enabled_bits & (1 << a_idx)); #endif return (binding->loc_bits >> (4 * a_idx)) & 0xF; } -static void write_attrib_location(Gwn_AttrBinding* binding, uint a_idx, uint location) +static void write_attrib_location(GPUAttrBinding* binding, uint a_idx, uint location) { #if TRUST_NO_ONE - assert(a_idx < GWN_VERT_ATTR_MAX_LEN); - assert(location < GWN_VERT_ATTR_MAX_LEN); + assert(a_idx < GPU_VERT_ATTR_MAX_LEN); + assert(location < GPU_VERT_ATTR_MAX_LEN); #endif const uint shift = 4 * a_idx; const uint64_t mask = ((uint64_t)0xF) << shift; @@ -67,14 +67,14 @@ static void write_attrib_location(Gwn_AttrBinding* binding, uint a_idx, uint loc binding->enabled_bits |= 1 << a_idx; } -void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding, const Gwn_ShaderInterface* shaderface) +void get_attrib_locations(const GPUVertFormat* format, GPUAttrBinding* binding, const GPUShaderInterface* shaderface) { AttribBinding_clear(binding); for (uint a_idx = 0; a_idx < format->attr_len; ++a_idx) { - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertAttr* a = format->attribs + a_idx; for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { - const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]); + const GPUShaderInput* input = GPU_shaderinterface_attr(shaderface, a->name[n_idx]); #if TRUST_NO_ONE assert(input != NULL); /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */ diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h index 0e0bf89178a..240509de0d4 100644 --- a/source/blender/gpu/intern/gpu_attr_binding_private.h +++ b/source/blender/gpu/intern/gpu_attr_binding_private.h @@ -23,21 +23,21 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_attr_binding_private.h +/** \file blender/gpu/intern/gpu_attr_binding_private.h * \ingroup gpu * - * Gawain vertex attribute binding + * GPU vertex attribute binding */ -#ifndef __GWN_ATTR_BINDING_PRIVATE_H__ -#define __GWN_ATTR_BINDING_PRIVATE_H__ +#ifndef __GPU_ATTR_BINDING_PRIVATE_H__ +#define __GPU_ATTR_BINDING_PRIVATE_H__ #include "GPU_vertex_format.h" #include "GPU_shader_interface.h" -void AttribBinding_clear(Gwn_AttrBinding*); +void AttribBinding_clear(GPUAttrBinding*); -void get_attrib_locations(const Gwn_VertFormat*, Gwn_AttrBinding*, const Gwn_ShaderInterface*); -unsigned read_attrib_location(const Gwn_AttrBinding*, unsigned a_idx); +void get_attrib_locations(const GPUVertFormat*, GPUAttrBinding*, const GPUShaderInterface*); +unsigned read_attrib_location(const GPUAttrBinding*, unsigned a_idx); -#endif /* __GWN_ATTR_BINDING_PRIVATE_H__ */ +#endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 90f30930884..4d455f6f464 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_batch.c +/** \file blender/gpu/intern/gpu_batch.c * \ingroup gpu * - * Gawain geometry batch + * GPU geometry batch * Contains VAOs + VBOs + Shader representing a drawable entity. */ @@ -44,9 +44,9 @@ #include #include -static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first); +static void batch_update_program_bindings(GPUBatch* batch, uint v_first); -void gwn_batch_vao_cache_clear(Gwn_Batch* batch) +void GPU_batch_vao_cache_clear(GPUBatch* batch) { if (batch->context == NULL) { return; @@ -54,45 +54,45 @@ void gwn_batch_vao_cache_clear(Gwn_Batch* batch) if (batch->is_dynamic_vao_count) { for (int i = 0; i < batch->dynamic_vaos.count; ++i) { if (batch->dynamic_vaos.vao_ids[i]) { - GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); + GPU_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); } if (batch->dynamic_vaos.interfaces[i]) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->dynamic_vaos.interfaces[i], batch); + GPU_shaderinterface_remove_batch_ref((GPUShaderInterface *)batch->dynamic_vaos.interfaces[i], batch); } } free(batch->dynamic_vaos.interfaces); free(batch->dynamic_vaos.vao_ids); } else { - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) { if (batch->static_vaos.vao_ids[i]) { - GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); + GPU_vao_free(batch->static_vaos.vao_ids[i], batch->context); } if (batch->static_vaos.interfaces[i]) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->static_vaos.interfaces[i], batch); + GPU_shaderinterface_remove_batch_ref((GPUShaderInterface *)batch->static_vaos.interfaces[i], batch); } } } batch->is_dynamic_vao_count = false; - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) { batch->static_vaos.vao_ids[i] = 0; batch->static_vaos.interfaces[i] = NULL; } - gwn_context_remove_batch(batch->context, batch); + gpu_context_remove_batch(batch->context, batch); batch->context = NULL; } -Gwn_Batch* GWN_batch_create_ex( - Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, +GPUBatch* GPU_batch_create_ex( + GPUPrimType prim_type, GPUVertBuf* verts, GPUIndexBuf* elem, uint owns_flag) { - Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch)); - GWN_batch_init_ex(batch, prim_type, verts, elem, owns_flag); + GPUBatch* batch = calloc(1, sizeof(GPUBatch)); + GPU_batch_init_ex(batch, prim_type, verts, elem, owns_flag); return batch; } -void GWN_batch_init_ex( - Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, +void GPU_batch_init_ex( + GPUBatch* batch, GPUPrimType prim_type, GPUVertBuf* verts, GPUIndexBuf* elem, uint owns_flag) { #if TRUST_NO_ONE @@ -100,49 +100,49 @@ void GWN_batch_init_ex( #endif batch->verts[0] = verts; - for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; ++v) { batch->verts[v] = NULL; } batch->inst = NULL; batch->elem = elem; batch->gl_prim_type = convert_prim_type_to_gl(prim_type); - batch->phase = GWN_BATCH_READY_TO_DRAW; + batch->phase = GPU_BATCH_READY_TO_DRAW; batch->is_dynamic_vao_count = false; batch->owns_flag = owns_flag; batch->free_callback = NULL; } /* This will share the VBOs with the new batch. */ -Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src) +GPUBatch* GPU_batch_duplicate(GPUBatch* batch_src) { - Gwn_Batch* batch = GWN_batch_create_ex(GWN_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); + GPUBatch* batch = GPU_batch_create_ex(GPU_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); batch->gl_prim_type = batch_src->gl_prim_type; - for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; ++v) { batch->verts[v] = batch_src->verts[v]; } return batch; } -void GWN_batch_discard(Gwn_Batch* batch) +void GPU_batch_discard(GPUBatch* batch) { - if (batch->owns_flag & GWN_BATCH_OWNS_INDEX) { - GWN_indexbuf_discard(batch->elem); + if (batch->owns_flag & GPU_BATCH_OWNS_INDEX) { + GPU_indexbuf_discard(batch->elem); } - if (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES) { - GWN_vertbuf_discard(batch->inst); + if (batch->owns_flag & GPU_BATCH_OWNS_INSTANCES) { + GPU_vertbuf_discard(batch->inst); } - if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0) { - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + if ((batch->owns_flag & ~GPU_BATCH_OWNS_INDEX) != 0) { + for (int v = 0; v < GPU_BATCH_VBO_MAX_LEN; ++v) { if (batch->verts[v] == NULL) { break; } if (batch->owns_flag & (1 << v)) { - GWN_vertbuf_discard(batch->verts[v]); + GPU_vertbuf_discard(batch->verts[v]); } } } - gwn_batch_vao_cache_clear(batch); + GPU_batch_vao_cache_clear(batch); if (batch->free_callback) { batch->free_callback(batch, batch->callback_data); @@ -150,42 +150,42 @@ void GWN_batch_discard(Gwn_Batch* batch) free(batch); } -void GWN_batch_callback_free_set(Gwn_Batch* batch, void (*callback)(Gwn_Batch*, void*), void* user_data) +void GPU_batch_callback_free_set(GPUBatch* batch, void (*callback)(GPUBatch*, void*), void* user_data) { batch->free_callback = callback; batch->callback_data = user_data; } -void GWN_batch_instbuf_set(Gwn_Batch* batch, Gwn_VertBuf* inst, bool own_vbo) +void GPU_batch_instbuf_set(GPUBatch* batch, GPUVertBuf* inst, bool own_vbo) { #if TRUST_NO_ONE assert(inst != NULL); #endif /* redo the bindings */ - gwn_batch_vao_cache_clear(batch); + GPU_batch_vao_cache_clear(batch); - if (batch->inst != NULL && (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES)) { - GWN_vertbuf_discard(batch->inst); + if (batch->inst != NULL && (batch->owns_flag & GPU_BATCH_OWNS_INSTANCES)) { + GPU_vertbuf_discard(batch->inst); } batch->inst = inst; if (own_vbo) { - batch->owns_flag |= GWN_BATCH_OWNS_INSTANCES; + batch->owns_flag |= GPU_BATCH_OWNS_INSTANCES; } else { - batch->owns_flag &= ~GWN_BATCH_OWNS_INSTANCES; + batch->owns_flag &= ~GPU_BATCH_OWNS_INSTANCES; } } /* Returns the index of verts in the batch. */ -int GWN_batch_vertbuf_add_ex( - Gwn_Batch* batch, Gwn_VertBuf* verts, +int GPU_batch_vertbuf_add_ex( + GPUBatch* batch, GPUVertBuf* verts, bool own_vbo) { /* redo the bindings */ - gwn_batch_vao_cache_clear(batch); + GPU_batch_vao_cache_clear(batch); - for (uint v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + for (uint v = 0; v < GPU_BATCH_VBO_MAX_LEN; ++v) { if (batch->verts[v] == NULL) { #if TRUST_NO_ONE /* for now all VertexBuffers must have same vertex_len */ @@ -199,14 +199,14 @@ int GWN_batch_vertbuf_add_ex( } } - /* we only make it this far if there is no room for another Gwn_VertBuf */ + /* we only make it this far if there is no room for another GPUVertBuf */ #if TRUST_NO_ONE assert(false); #endif return -1; } -static GLuint batch_vao_get(Gwn_Batch *batch) +static GLuint batch_vao_get(GPUBatch *batch) { /* Search through cache */ if (batch->is_dynamic_vao_count) { @@ -215,22 +215,22 @@ static GLuint batch_vao_get(Gwn_Batch *batch) return batch->dynamic_vaos.vao_ids[i]; } else { - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) + for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) if (batch->static_vaos.interfaces[i] == batch->interface) return batch->static_vaos.vao_ids[i]; } /* Set context of this batch. - * It will be bound to it until gwn_batch_vao_cache_clear is called. + * It will be bound to it until GPU_batch_vao_cache_clear is called. * Until then it can only be drawn with this context. */ if (batch->context == NULL) { - batch->context = GWN_context_active_get(); - gwn_context_add_batch(batch->context, batch); + batch->context = GPU_context_active_get(); + gpu_context_add_batch(batch->context, batch); } #if TRUST_NO_ONE else { /* Make sure you are not trying to draw this batch in another context. */ - assert(batch->context == GWN_context_active_get()); + assert(batch->context == GPU_context_active_get()); } #endif @@ -238,25 +238,25 @@ static GLuint batch_vao_get(Gwn_Batch *batch) GLuint new_vao = 0; if (!batch->is_dynamic_vao_count) { int i; /* find first unused slot */ - for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) + for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) if (batch->static_vaos.vao_ids[i] == 0) break; - if (i < GWN_BATCH_VAO_STATIC_LEN) { + if (i < GPU_BATCH_VAO_STATIC_LEN) { batch->static_vaos.interfaces[i] = batch->interface; - batch->static_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); + batch->static_vaos.vao_ids[i] = new_vao = GPU_vao_alloc(); } else { /* Not enough place switch to dynamic. */ batch->is_dynamic_vao_count = true; /* Erase previous entries, they will be added back if drawn again. */ - for (int j = 0; j < GWN_BATCH_VAO_STATIC_LEN; ++j) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface*)batch->static_vaos.interfaces[j], batch); - GWN_vao_free(batch->static_vaos.vao_ids[j], batch->context); + for (int j = 0; j < GPU_BATCH_VAO_STATIC_LEN; ++j) { + GPU_shaderinterface_remove_batch_ref((GPUShaderInterface*)batch->static_vaos.interfaces[j], batch); + GPU_vao_free(batch->static_vaos.vao_ids[j], batch->context); } /* Init dynamic arrays and let the branch below set the values. */ - batch->dynamic_vaos.count = GWN_BATCH_VAO_DYN_ALLOC_COUNT; - batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(Gwn_ShaderInterface*)); + batch->dynamic_vaos.count = GPU_BATCH_VAO_DYN_ALLOC_COUNT; + batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(GPUShaderInterface*)); batch->dynamic_vaos.vao_ids = calloc(batch->dynamic_vaos.count, sizeof(GLuint)); } } @@ -270,17 +270,17 @@ static GLuint batch_vao_get(Gwn_Batch *batch) if (i == batch->dynamic_vaos.count) { /* Not enough place, realloc the array. */ i = batch->dynamic_vaos.count; - batch->dynamic_vaos.count += GWN_BATCH_VAO_DYN_ALLOC_COUNT; - batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(Gwn_ShaderInterface*) * batch->dynamic_vaos.count); + batch->dynamic_vaos.count += GPU_BATCH_VAO_DYN_ALLOC_COUNT; + batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(GPUShaderInterface*) * batch->dynamic_vaos.count); batch->dynamic_vaos.vao_ids = realloc(batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count); - memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(Gwn_ShaderInterface*) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); - memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); + memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(GPUShaderInterface*) * GPU_BATCH_VAO_DYN_ALLOC_COUNT); + memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GPU_BATCH_VAO_DYN_ALLOC_COUNT); } batch->dynamic_vaos.interfaces[i] = batch->interface; - batch->dynamic_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); + batch->dynamic_vaos.vao_ids[i] = new_vao = GPU_vao_alloc(); } - GWN_shaderinterface_add_batch_ref((Gwn_ShaderInterface*)batch->interface, batch); + GPU_shaderinterface_add_batch_ref((GPUShaderInterface*)batch->interface, batch); #if TRUST_NO_ONE assert(new_vao != 0); @@ -294,7 +294,7 @@ static GLuint batch_vao_get(Gwn_Batch *batch) return new_vao; } -void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) +void GPU_batch_program_set_no_use(GPUBatch* batch, uint32_t program, const GPUShaderInterface* shaderface) { #if TRUST_NO_ONE assert(glIsProgram(shaderface->program)); @@ -305,18 +305,18 @@ void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ batch->vao_id = batch_vao_get(batch); } -void GWN_batch_program_set(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) +void GPU_batch_program_set(GPUBatch* batch, uint32_t program, const GPUShaderInterface* shaderface) { - GWN_batch_program_set_no_use(batch, program, shaderface); - GWN_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */ + GPU_batch_program_set_no_use(batch, program, shaderface); + GPU_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */ } -void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* interface) +void gpu_batch_remove_interface_ref(GPUBatch* batch, const GPUShaderInterface* interface) { if (batch->is_dynamic_vao_count) { for (int i = 0; i < batch->dynamic_vaos.count; ++i) { if (batch->dynamic_vaos.interfaces[i] == interface) { - GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); + GPU_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); batch->dynamic_vaos.vao_ids[i] = 0; batch->dynamic_vaos.interfaces[i] = NULL; break; /* cannot have duplicates */ @@ -325,9 +325,9 @@ void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* } else { int i; - for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) { if (batch->static_vaos.interfaces[i] == interface) { - GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); + GPU_vao_free(batch->static_vaos.vao_ids[i], batch->context); batch->static_vaos.vao_ids[i] = 0; batch->static_vaos.interfaces[i] = NULL; break; /* cannot have duplicates */ @@ -337,28 +337,28 @@ void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* } static void create_bindings( - Gwn_VertBuf* verts, const Gwn_ShaderInterface* interface, + GPUVertBuf* verts, const GPUShaderInterface* interface, uint v_first, const bool use_instancing) { - const Gwn_VertFormat* format = &verts->format; + const GPUVertFormat* format = &verts->format; const uint attr_len = format->attr_len; const uint stride = format->stride; - GWN_vertbuf_use(verts); + GPU_vertbuf_use(verts); for (uint a_idx = 0; a_idx < attr_len; ++a_idx) { - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertAttr* a = format->attribs + a_idx; const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride; for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { - const Gwn_ShaderInput* input = GWN_shaderinterface_attr(interface, a->name[n_idx]); + const GPUShaderInput* input = GPU_shaderinterface_attr(interface, a->name[n_idx]); if (input == NULL) continue; if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { #if TRUST_NO_ONE - assert(a->fetch_mode == GWN_FETCH_FLOAT); + assert(a->fetch_mode == GPU_FETCH_FLOAT); assert(a->gl_comp_type == GL_FLOAT); #endif for (int i = 0; i < a->comp_len / 4; ++i) { @@ -374,14 +374,14 @@ static void create_bindings( glVertexAttribDivisor(input->location, (use_instancing) ? 1 : 0); switch (a->fetch_mode) { - case GWN_FETCH_FLOAT: - case GWN_FETCH_INT_TO_FLOAT: + case GPU_FETCH_FLOAT: + case GPU_FETCH_INT_TO_FLOAT: glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); break; - case GWN_FETCH_INT_TO_FLOAT_UNIT: + case GPU_FETCH_INT_TO_FLOAT_UNIT: glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); break; - case GWN_FETCH_INT: + case GPU_FETCH_INT: glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer); break; } @@ -390,20 +390,20 @@ static void create_bindings( } } -static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first) +static void batch_update_program_bindings(GPUBatch* batch, uint v_first) { - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { + for (int v = 0; v < GPU_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false); } if (batch->inst) { create_bindings(batch->inst, batch->interface, v_first, true); } if (batch->elem) { - GWN_indexbuf_use(batch->elem); + GPU_indexbuf_use(batch->elem); } } -void GWN_batch_program_use_begin(Gwn_Batch* batch) +void GPU_batch_program_use_begin(GPUBatch* batch) { /* NOTE: use_program & done_using_program are fragile, depend on staying in sync with * the GL context's active program. use_program doesn't mark other programs as "not used". */ @@ -415,7 +415,7 @@ void GWN_batch_program_use_begin(Gwn_Batch* batch) } } -void GWN_batch_program_use_end(Gwn_Batch* batch) +void GPU_batch_program_use_end(GPUBatch* batch) { if (batch->program_in_use) { #if PROGRAM_NO_OPTI @@ -426,99 +426,99 @@ void GWN_batch_program_use_end(Gwn_Batch* batch) } #if TRUST_NO_ONE - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); assert(uniform); + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(batch->interface, name); assert(uniform); #else - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(batch->interface, name); #endif -void GWN_batch_uniform_1ui(Gwn_Batch* batch, const char* name, int value) +void GPU_batch_uniform_1ui(GPUBatch* batch, const char* name, int value) { GET_UNIFORM glUniform1ui(uniform->location, value); } -void GWN_batch_uniform_1i(Gwn_Batch* batch, const char* name, int value) +void GPU_batch_uniform_1i(GPUBatch* batch, const char* name, int value) { GET_UNIFORM glUniform1i(uniform->location, value); } -void GWN_batch_uniform_1b(Gwn_Batch* batch, const char* name, bool value) +void GPU_batch_uniform_1b(GPUBatch* batch, const char* name, bool value) { GET_UNIFORM glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE); } -void GWN_batch_uniform_2f(Gwn_Batch* batch, const char* name, float x, float y) +void GPU_batch_uniform_2f(GPUBatch* batch, const char* name, float x, float y) { GET_UNIFORM glUniform2f(uniform->location, x, y); } -void GWN_batch_uniform_3f(Gwn_Batch* batch, const char* name, float x, float y, float z) +void GPU_batch_uniform_3f(GPUBatch* batch, const char* name, float x, float y, float z) { GET_UNIFORM glUniform3f(uniform->location, x, y, z); } -void GWN_batch_uniform_4f(Gwn_Batch* batch, const char* name, float x, float y, float z, float w) +void GPU_batch_uniform_4f(GPUBatch* batch, const char* name, float x, float y, float z, float w) { GET_UNIFORM glUniform4f(uniform->location, x, y, z, w); } -void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x) +void GPU_batch_uniform_1f(GPUBatch* batch, const char* name, float x) { GET_UNIFORM glUniform1f(uniform->location, x); } -void GWN_batch_uniform_2fv(Gwn_Batch* batch, const char* name, const float data[2]) +void GPU_batch_uniform_2fv(GPUBatch* batch, const char* name, const float data[2]) { GET_UNIFORM glUniform2fv(uniform->location, 1, data); } -void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3]) +void GPU_batch_uniform_3fv(GPUBatch* batch, const char* name, const float data[3]) { GET_UNIFORM glUniform3fv(uniform->location, 1, data); } -void GWN_batch_uniform_4fv(Gwn_Batch* batch, const char* name, const float data[4]) +void GPU_batch_uniform_4fv(GPUBatch* batch, const char* name, const float data[4]) { GET_UNIFORM glUniform4fv(uniform->location, 1, data); } -void GWN_batch_uniform_2fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) +void GPU_batch_uniform_2fv_array(GPUBatch* batch, const char* name, const int len, const float *data) { GET_UNIFORM glUniform2fv(uniform->location, len, data); } -void GWN_batch_uniform_4fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) +void GPU_batch_uniform_4fv_array(GPUBatch* batch, const char* name, const int len, const float *data) { GET_UNIFORM glUniform4fv(uniform->location, len, data); } -void GWN_batch_uniform_mat4(Gwn_Batch* batch, const char* name, const float data[4][4]) +void GPU_batch_uniform_mat4(GPUBatch* batch, const char* name, const float data[4][4]) { GET_UNIFORM glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (const float *)data); } -static void primitive_restart_enable(const Gwn_IndexBuf *el) +static void primitive_restart_enable(const GPUIndexBuf *el) { // TODO(fclem) Replace by GL_PRIMITIVE_RESTART_FIXED_INDEX when we have ogl 4.3 glEnable(GL_PRIMITIVE_RESTART); GLuint restart_index = (GLuint)0xFFFFFFFF; -#if GWN_TRACK_INDEX_RANGE - if (el->index_type == GWN_INDEX_U8) +#if GPU_TRACK_INDEX_RANGE + if (el->index_type == GPU_INDEX_U8) restart_index = (GLuint)0xFF; - else if (el->index_type == GWN_INDEX_U16) + else if (el->index_type == GPU_INDEX_U16) restart_index = (GLuint)0xFFFF; #endif @@ -530,21 +530,21 @@ static void primitive_restart_disable(void) glDisable(GL_PRIMITIVE_RESTART); } -void GWN_batch_draw(Gwn_Batch* batch) +void GPU_batch_draw(GPUBatch* batch) { #if TRUST_NO_ONE - assert(batch->phase == GWN_BATCH_READY_TO_DRAW); + assert(batch->phase == GPU_BATCH_READY_TO_DRAW); assert(batch->verts[0]->vbo_id != 0); #endif - GWN_batch_program_use_begin(batch); + GPU_batch_program_use_begin(batch); GPU_matrix_bind(batch->interface); // external call. - GWN_batch_draw_range_ex(batch, 0, 0, false); + GPU_batch_draw_range_ex(batch, 0, 0, false); - GWN_batch_program_use_end(batch); + GPU_batch_program_use_end(batch); } -void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool force_instance) +void GPU_batch_draw_range_ex(GPUBatch* batch, int v_first, int v_count, bool force_instance) { #if TRUST_NO_ONE assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance @@ -553,7 +553,7 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo // If using offset drawing, use the default VAO and redo bindings. if (v_first != 0 && (do_instance || batch->elem)) { - glBindVertexArray(GWN_vao_default()); + glBindVertexArray(GPU_vao_default()); batch_update_program_bindings(batch, v_first); } else { @@ -567,12 +567,12 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo } if (batch->elem) { - const Gwn_IndexBuf* el = batch->elem; + const GPUIndexBuf* el = batch->elem; if (el->use_prim_restart) { primitive_restart_enable(el); } -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_len, el->gl_index_type, @@ -597,13 +597,13 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo } if (batch->elem) { - const Gwn_IndexBuf* el = batch->elem; + const GPUIndexBuf* el = batch->elem; if (el->use_prim_restart) { primitive_restart_enable(el); } -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE if (el->base_index) { glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, @@ -634,10 +634,10 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo } /* just draw some vertices and let shader place them where we want. */ -void GWN_draw_primitive(Gwn_PrimType prim_type, int v_count) +void GPU_draw_primitive(GPUPrimType prim_type, int v_count) { /* we cannot draw without vao ... annoying ... */ - glBindVertexArray(GWN_vao_default()); + glBindVertexArray(GPU_vao_default()); GLenum type = convert_prim_type_to_gl(prim_type); glDrawArrays(type, 0, v_count); @@ -652,10 +652,10 @@ void GWN_draw_primitive(Gwn_PrimType prim_type, int v_count) /** \name Utilities * \{ */ -void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id) +void GPU_batch_program_set_builtin(GPUBatch *batch, GPUBuiltinShader shader_id) { GPUShader *shader = GPU_shader_get_builtin_shader(shader_id); - GWN_batch_program_set(batch, shader->program, shader->interface); + GPU_batch_program_set(batch, shader->program, shader->interface); } /** \} */ diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c index fb696fd09a5..83287c57441 100644 --- a/source/blender/gpu/intern/gpu_batch_presets.c +++ b/source/blender/gpu/intern/gpu_batch_presets.c @@ -45,14 +45,14 @@ /* Struct to store 3D Batches and their format */ static struct { struct { - Gwn_Batch *sphere_high; - Gwn_Batch *sphere_med; - Gwn_Batch *sphere_low; - Gwn_Batch *sphere_wire_low; - Gwn_Batch *sphere_wire_med; + GPUBatch *sphere_high; + GPUBatch *sphere_med; + GPUBatch *sphere_low; + GPUBatch *sphere_wire_low; + GPUBatch *sphere_wire_med; } batch; - Gwn_VertFormat format; + GPUVertFormat format; struct { uint pos, nor; @@ -66,28 +66,28 @@ static ListBase presets_list = {NULL, NULL}; /** \name 3D Primitives * \{ */ -static Gwn_VertFormat *preset_3d_format(void) +static GPUVertFormat *preset_3d_format(void) { if (g_presets_3d.format.attr_len == 0) { - Gwn_VertFormat *format = &g_presets_3d.format; - g_presets_3d.attr_id.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - g_presets_3d.attr_id.nor = GWN_vertformat_attr_add(format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = &g_presets_3d.format; + g_presets_3d.attr_id.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + g_presets_3d.attr_id.nor = GPU_vertformat_attr_add(format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } return &g_presets_3d.format; } static void batch_sphere_lat_lon_vert( - Gwn_VertBufRaw *pos_step, Gwn_VertBufRaw *nor_step, + GPUVertBufRaw *pos_step, GPUVertBufRaw *nor_step, float lat, float lon) { float pos[3]; pos[0] = sinf(lat) * cosf(lon); pos[1] = cosf(lat); pos[2] = sinf(lat) * sinf(lon); - copy_v3_v3(GWN_vertbuf_raw_step(pos_step), pos); - copy_v3_v3(GWN_vertbuf_raw_step(nor_step), pos); + copy_v3_v3(GPU_vertbuf_raw_step(pos_step), pos); + copy_v3_v3(GPU_vertbuf_raw_step(nor_step), pos); } -Gwn_Batch *GPU_batch_preset_sphere(int lod) +GPUBatch *GPU_batch_preset_sphere(int lod) { BLI_assert(lod >= 0 && lod <= 2); BLI_assert(BLI_thread_is_main()); @@ -103,7 +103,7 @@ Gwn_Batch *GPU_batch_preset_sphere(int lod) } } -Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) +GPUBatch *GPU_batch_preset_sphere_wire(int lod) { BLI_assert(lod >= 0 && lod <= 1); BLI_assert(BLI_thread_is_main()); @@ -123,19 +123,19 @@ Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) * \{ */ /* Replacement for gluSphere */ -Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) +GPUBatch *gpu_batch_sphere(int lat_res, int lon_res) { const float lon_inc = 2 * M_PI / lon_res; const float lat_inc = M_PI / lat_res; float lon, lat; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3d_format()); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(preset_3d_format()); const uint vbo_len = (lat_res - 1) * lon_res * 6; - GWN_vertbuf_data_alloc(vbo, vbo_len); + GPU_vertbuf_data_alloc(vbo, vbo_len); - Gwn_VertBufRaw pos_step, nor_step; - GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step); - GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step); + GPUVertBufRaw pos_step, nor_step; + GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step); + GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step); lon = 0.0f; for (int i = 0; i < lon_res; i++, lon += lon_inc) { @@ -155,25 +155,25 @@ Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) } } - BLI_assert(vbo_len == GWN_vertbuf_raw_used(&pos_step)); - BLI_assert(vbo_len == GWN_vertbuf_raw_used(&nor_step)); + BLI_assert(vbo_len == GPU_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len == GPU_vertbuf_raw_used(&nor_step)); - return GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + return GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } -static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res) +static GPUBatch *batch_sphere_wire(int lat_res, int lon_res) { const float lon_inc = 2 * M_PI / lon_res; const float lat_inc = M_PI / lat_res; float lon, lat; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3d_format()); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(preset_3d_format()); const uint vbo_len = (lat_res * lon_res * 2) + ((lat_res - 1) * lon_res * 2); - GWN_vertbuf_data_alloc(vbo, vbo_len); + GPU_vertbuf_data_alloc(vbo, vbo_len); - Gwn_VertBufRaw pos_step, nor_step; - GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step); - GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step); + GPUVertBufRaw pos_step, nor_step; + GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step); + GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step); lon = 0.0f; for (int i = 0; i < lon_res; i++, lon += lon_inc) { @@ -189,10 +189,10 @@ static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res) } } - BLI_assert(vbo_len == GWN_vertbuf_raw_used(&pos_step)); - BLI_assert(vbo_len == GWN_vertbuf_raw_used(&nor_step)); + BLI_assert(vbo_len == GPU_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len == GPU_vertbuf_raw_used(&nor_step)); - return GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + return GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } /** \} */ @@ -216,7 +216,7 @@ void gpu_batch_presets_init(void) gpu_batch_presets_register(g_presets_3d.batch.sphere_wire_med); } -void gpu_batch_presets_register(Gwn_Batch *preset_batch) +void gpu_batch_presets_register(GPUBatch *preset_batch) { BLI_addtail(&presets_list, BLI_genericNodeN(preset_batch)); } @@ -227,8 +227,8 @@ void gpu_batch_presets_reset(void) * This way they will draw correctly for each window. */ LinkData *link = presets_list.first; for (link = presets_list.first; link; link = link->next) { - Gwn_Batch *preset = link->data; - gwn_batch_vao_cache_clear(preset); + GPUBatch *preset = link->data; + GPU_batch_vao_cache_clear(preset); } } @@ -236,8 +236,8 @@ void gpu_batch_presets_exit(void) { LinkData *link; while ((link = BLI_pophead(&presets_list))) { - Gwn_Batch *preset = link->data; - GWN_batch_discard(preset); + GPUBatch *preset = link->data; + GPU_batch_discard(preset); MEM_freeN(link); } } diff --git a/source/blender/gpu/intern/gpu_batch_private.h b/source/blender/gpu/intern/gpu_batch_private.h index 1e72bae503f..0b25c0aef05 100644 --- a/source/blender/gpu/intern/gpu_batch_private.h +++ b/source/blender/gpu/intern/gpu_batch_private.h @@ -23,15 +23,15 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_batch_private.h +/** \file blender/gpu/intern/gpu_batch_private.h * \ingroup gpu * - * Gawain geometry batch + * GPU geometry batch * Contains VAOs + VBOs + Shader representing a drawable entity. */ -#ifndef __GWN_BATCH_PRIVATE_H__ -#define __GWN_BATCH_PRIVATE_H__ +#ifndef __GPU_BATCH_PRIVATE_H__ +#define __GPU_BATCH_PRIVATE_H__ #ifdef __cplusplus extern "C" { @@ -41,13 +41,13 @@ extern "C" { #include "GPU_context.h" #include "GPU_shader_interface.h" -void gwn_batch_remove_interface_ref(Gwn_Batch*, const Gwn_ShaderInterface*); +void gpu_batch_remove_interface_ref(GPUBatch*, const GPUShaderInterface*); -void gwn_context_add_batch(Gwn_Context*, Gwn_Batch*); -void gwn_context_remove_batch(Gwn_Context*, Gwn_Batch*); +void gpu_context_add_batch(GPUContext*, GPUBatch*); +void gpu_context_remove_batch(GPUContext*, GPUBatch*); #ifdef __cplusplus } #endif -#endif /* __GWN_BATCH_PRIVATE_H__ */ +#endif /* __GPU_BATCH_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch_utils.c b/source/blender/gpu/intern/gpu_batch_utils.c index d6d82ac18b6..0a7f1ca901d 100644 --- a/source/blender/gpu/intern/gpu_batch_utils.c +++ b/source/blender/gpu/intern/gpu_batch_utils.c @@ -47,7 +47,7 @@ * \param polys_flat_len: Length of the array (must be an even number). * \param rect: Optional region to map the byte 0..255 coords to. When not set use -1..1. */ -Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( +GPUBatch *GPU_batch_tris_from_poly_2d_encoded( const uchar *polys_flat, uint polys_flat_len, const rctf *rect) { const uchar (*polys)[2] = (const void *)polys_flat; @@ -103,41 +103,41 @@ Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( } /* We have vertices and tris, make a batch from this. */ - static Gwn_VertFormat format = {0}; + static GPUVertFormat format = {0}; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } const uint verts_len = (verts_step - verts); const uint tris_len = (tris_step - tris); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, verts_len); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, verts_len); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); for (uint i = 0; i < verts_len; i++) { - copy_v2_v2(GWN_vertbuf_raw_step(&pos_step), verts[i]); + copy_v2_v2(GPU_vertbuf_raw_step(&pos_step), verts[i]); } - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tris_len, verts_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tris_len, verts_len); for (uint i = 0; i < tris_len; i++) { - GWN_indexbuf_add_tri_verts(&elb, UNPACK3(tris[i])); + GPU_indexbuf_add_tri_verts(&elb, UNPACK3(tris[i])); } - Gwn_IndexBuf *indexbuf = GWN_indexbuf_build(&elb); + GPUIndexBuf *indexbuf = GPU_indexbuf_build(&elb); MEM_freeN(tris); MEM_freeN(verts); - return GWN_batch_create_ex( - GWN_PRIM_TRIS, vbo, + return GPU_batch_create_ex( + GPU_PRIM_TRIS, vbo, indexbuf, - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); } -Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( +GPUBatch *GPU_batch_wire_from_poly_2d_encoded( const uchar *polys_flat, uint polys_flat_len, const rctf *rect) { const uchar (*polys)[2] = (const void *)polys_flat; @@ -206,18 +206,18 @@ Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( } /* We have vertices and tris, make a batch from this. */ - static Gwn_VertFormat format = {0}; + static GPUVertFormat format = {0}; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const uint vbo_len_capacity = lines_len * 2; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); for (uint i = 0; i < lines_len; i++) { union { @@ -226,18 +226,18 @@ Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( } data; data.as_u32 = lines[i]; for (uint k = 0; k < 2; k++) { - float *pos_v2 = GWN_vertbuf_raw_step(&pos_step); + float *pos_v2 = GPU_vertbuf_raw_step(&pos_step); for (uint j = 0; j < 2; j++) { pos_v2[j] = min_uchar[j] + ((float)data.as_u8_pair[k][j] * range_uchar[j]); } } } - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step)); MEM_freeN(lines); - return GWN_batch_create_ex( - GWN_PRIM_LINES, vbo, + return GPU_batch_create_ex( + GPU_PRIM_LINES, vbo, NULL, - GWN_BATCH_OWNS_VBO); + GPU_BATCH_OWNS_VBO); } /** \} */ diff --git a/source/blender/gpu/intern/gpu_buffer_id.cpp b/source/blender/gpu/intern/gpu_buffer_id.cpp index 0c442f687a0..c1aaf1945aa 100644 --- a/source/blender/gpu/intern/gpu_buffer_id.cpp +++ b/source/blender/gpu/intern/gpu_buffer_id.cpp @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_buffer_id.cpp +/** \file blender/gpu/intern/gpu_buffer_id.cpp * \ingroup gpu * - * Gawain buffer IDs + * GPU buffer IDs */ #include "GPU_buffer_id.h" @@ -54,7 +54,7 @@ static bool thread_is_main() return BLI_thread_is_main(); } -GLuint GWN_buf_id_alloc() +GLuint GPU_buf_id_alloc() { /* delete orphaned IDs */ orphan_mutex.lock(); @@ -73,7 +73,7 @@ GLuint GWN_buf_id_alloc() return new_buffer_id; } -void GWN_buf_id_free(GLuint buffer_id) +void GPU_buf_id_free(GLuint buffer_id) { if (thread_is_main()) { glDeleteBuffers(1, &buffer_id); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 1a4750652cc..d466fa87388 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -62,7 +62,7 @@ static ThreadMutex buffer_mutex = BLI_MUTEX_INITIALIZER; /* multires global buffer, can be used for many grids having the same grid size */ typedef struct GridCommonGPUBuffer { - Gwn_IndexBuf *mres_buffer; + GPUIndexBuf *mres_buffer; int mres_prev_gridsize; unsigned mres_prev_totquad; } GridCommonGPUBuffer; @@ -71,11 +71,11 @@ typedef struct GridCommonGPUBuffer { * drawing and doesn't interact at all with the buffer code above */ struct GPU_PBVH_Buffers { - Gwn_IndexBuf *index_buf, *index_buf_fast; - Gwn_VertBuf *vert_buf; + GPUIndexBuf *index_buf, *index_buf_fast; + GPUVertBuf *vert_buf; - Gwn_Batch *triangles; - Gwn_Batch *triangles_fast; + GPUBatch *triangles; + GPUBatch *triangles_fast; /* mesh pointers in case buffer allocation fails */ const MPoly *mpoly; @@ -132,23 +132,23 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int v /* Initialize vertex buffer */ /* match 'VertexBufferFormat' */ - static Gwn_VertFormat format = {0}; + static GPUVertFormat format = {0}; if (format.attr_len == 0) { - g_vbo_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - g_vbo_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - g_vbo_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + g_vbo_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + g_vbo_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + g_vbo_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } #if 0 - buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_DYNAMIC); - GWN_vertbuf_data_alloc(buffers->vert_buf, vert_len); + buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_DYNAMIC); + GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len); } else if (vert_len != buffers->vert_buf->vertex_len) { - GWN_vertbuf_data_resize(buffers->vert_buf, vert_len); + GPU_vertbuf_data_resize(buffers->vert_buf, vert_len); } #else - buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC); + buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC); } - GWN_vertbuf_data_alloc(buffers->vert_buf, vert_len); + GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len); #endif return buffers->vert_buf->data != NULL; } @@ -157,19 +157,19 @@ static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers) { /* force flushing to the GPU */ if (buffers->vert_buf->data) { - GWN_vertbuf_use(buffers->vert_buf); + GPU_vertbuf_use(buffers->vert_buf); } if (buffers->triangles == NULL) { - buffers->triangles = GWN_batch_create( - GWN_PRIM_TRIS, buffers->vert_buf, + buffers->triangles = GPU_batch_create( + GPU_PRIM_TRIS, buffers->vert_buf, /* can be NULL */ buffers->index_buf); } if ((buffers->triangles_fast == NULL) && buffers->index_buf_fast) { - buffers->triangles_fast = GWN_batch_create( - GWN_PRIM_TRIS, buffers->vert_buf, + buffers->triangles_fast = GPU_batch_create( + GPU_PRIM_TRIS, buffers->vert_buf, /* can be NULL */ buffers->index_buf_fast); } @@ -245,8 +245,8 @@ void GPU_pbvh_mesh_buffers_update( if (buffers->smooth) { for (uint i = 0; i < totvert; ++i) { const MVert *v = &mvert[vert_indices[i]]; - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, i, v->co); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, i, v->co); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no); } for (uint i = 0; i < buffers->face_indices_len; i++) { @@ -257,10 +257,10 @@ void GPU_pbvh_mesh_buffers_update( int v_index = buffers->mloop[lt->tri[j]].v; uchar color_ub[3]; gpu_color_from_mask_copy(vmask[v_index], diffuse_color, color_ub); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, color_ub); } else { - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, diffuse_color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, diffuse_color_ub); } } } @@ -303,9 +303,9 @@ void GPU_pbvh_mesh_buffers_update( for (uint j = 0; j < 3; j++) { const MVert *v = &mvert[vtri[j]]; - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); vbo_index++; } @@ -367,8 +367,8 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build( if (buffers->smooth) { /* Fill the triangle buffer */ buffers->index_buf = NULL; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tottri, INT_MAX); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX); for (i = 0; i < face_indices_len; ++i) { const MLoopTri *lt = &looptri[face_indices[i]]; @@ -377,13 +377,13 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build( if (paint_is_face_hidden(lt, mvert, mloop)) continue; - GWN_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i])); + GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i])); } - buffers->index_buf = GWN_indexbuf_build(&elb); + buffers->index_buf = GPU_indexbuf_build(&elb); } else { if (!buffers->is_index_buf_global) { - GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf); } buffers->index_buf = NULL; buffers->is_index_buf_global = false; @@ -438,12 +438,12 @@ void GPU_pbvh_grid_buffers_update( for (y = 0; y < key->grid_size; y++) { for (x = 0; x < key->grid_size; x++) { CCGElem *elem = CCG_grid_elem(key, grid, x, y); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem)); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem)); if (buffers->smooth) { short no_short[3]; normal_float_to_short_v3(no_short, CCG_elem_no(key, elem)); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); if (has_mask) { uchar color_ub[3]; @@ -454,7 +454,7 @@ void GPU_pbvh_grid_buffers_update( else { unit_float_to_uchar_clamp_v3(color_ub, diffuse_color); } - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); } } vbo_index += 1; @@ -481,7 +481,7 @@ void GPU_pbvh_grid_buffers_update( vbo_index = vbo_index_offset + ((j + 1) * key->grid_size + k); short no_short[3]; normal_float_to_short_v3(no_short, fno); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); if (has_mask) { uchar color_ub[3]; @@ -497,7 +497,7 @@ void GPU_pbvh_grid_buffers_update( else { unit_float_to_uchar_clamp_v3(color_ub, diffuse_color); } - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); } } } @@ -526,9 +526,9 @@ void GPU_pbvh_grid_buffers_update( int offset = 0; \ int i, j, k; \ \ - Gwn_IndexBufBuilder elb; \ - GWN_indexbuf_init( \ - &elb, GWN_PRIM_TRIS, tot_quad_ * 2, max_vert_); \ + GPUIndexBufBuilder elb; \ + GPU_indexbuf_init( \ + &elb, GPU_PRIM_TRIS, tot_quad_ * 2, max_vert_); \ \ /* Fill the buffer */ \ for (i = 0; i < totgrid; ++i) { \ @@ -544,25 +544,25 @@ void GPU_pbvh_grid_buffers_update( { \ continue; \ } \ - GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ - GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k); \ - GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k); \ + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ \ - GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k + 1); \ - GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ - GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ } \ } \ \ offset += gridsize * gridsize; \ } \ - buffer_ = GWN_indexbuf_build(&elb); \ + buffer_ = GPU_indexbuf_build(&elb); \ } (void)0 /* end FILL_QUAD_BUFFER */ -static Gwn_IndexBuf *gpu_get_grid_buffer( +static GPUIndexBuf *gpu_get_grid_buffer( int gridsize, unsigned *totquad, GridCommonGPUBuffer **grid_common_gpu_buffer, - /* remove this arg when gawain gets base-vertex support! */ + /* remove this arg when GPU gets base-vertex support! */ int totgrid) { /* used in the FILL_QUAD_BUFFER macro */ @@ -586,7 +586,7 @@ static Gwn_IndexBuf *gpu_get_grid_buffer( } /* we can't reuse old, delete the existing buffer */ else if (gridbuff->mres_buffer) { - GWN_indexbuf_discard(gridbuff->mres_buffer); + GPU_indexbuf_discard(gridbuff->mres_buffer); gridbuff->mres_buffer = NULL; } @@ -603,17 +603,17 @@ static Gwn_IndexBuf *gpu_get_grid_buffer( #define FILL_FAST_BUFFER() \ { \ - Gwn_IndexBufBuilder elb; \ - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, 6 * totgrid, INT_MAX); \ + GPUIndexBufBuilder elb; \ + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, 6 * totgrid, INT_MAX); \ for (int i = 0; i < totgrid; i++) { \ - GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \ - GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize); \ - GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \ - GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - 1); \ - GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \ - GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \ + GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \ + GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize); \ + GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \ + GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - 1); \ + GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \ + GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \ } \ - buffers->index_buf_fast = GWN_indexbuf_build(&elb); \ + buffers->index_buf_fast = GPU_indexbuf_build(&elb); \ } (void)0 GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build( @@ -684,7 +684,7 @@ GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build( */ static void gpu_bmesh_vert_to_buffer_copy__gwn( BMVert *v, - Gwn_VertBuf *vert_buf, + GPUVertBuf *vert_buf, int *v_index, const float fno[3], const float *fmask, @@ -695,12 +695,12 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn( if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) { /* Set coord, normal, and mask */ - GWN_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co); + GPU_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co); { short no_short[3]; normal_float_to_short_v3(no_short, fno ? fno : v->no); - GWN_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short); + GPU_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short); } { @@ -718,7 +718,7 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn( effective_mask, diffuse_color, color_ub); - GWN_vertbuf_attr_set(vert_buf, g_vbo_id.col, *v_index, color_ub); + GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col, *v_index, color_ub); } /* Assign index for use in the triangle index buffer */ @@ -792,7 +792,7 @@ void GPU_pbvh_bmesh_buffers_update( if (buffers->smooth) { /* Smooth needs to recreate index buffer, so we have to invalidate the batch. */ - GWN_BATCH_DISCARD_SAFE(buffers->triangles); + GPU_BATCH_DISCARD_SAFE(buffers->triangles); /* Count visible vertices */ totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts); } @@ -893,8 +893,8 @@ void GPU_pbvh_bmesh_buffers_update( if (buffers->smooth) { /* Fill the triangle buffer */ buffers->index_buf = NULL; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tottri, maxvert); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, maxvert); /* Initialize triangle index buffer */ buffers->is_index_buf_global = false; @@ -911,7 +911,7 @@ void GPU_pbvh_bmesh_buffers_update( BMVert *v[3]; BM_face_as_array_vert_tri(f, v); - GWN_indexbuf_add_tri_verts( + GPU_indexbuf_add_tri_verts( &elb, BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2])); } } @@ -919,16 +919,16 @@ void GPU_pbvh_bmesh_buffers_update( buffers->tot_tri = tottri; if (buffers->index_buf == NULL) { - buffers->index_buf = GWN_indexbuf_build(&elb); + buffers->index_buf = GPU_indexbuf_build(&elb); } else { - GWN_indexbuf_build_in_place(&elb, buffers->index_buf); + GPU_indexbuf_build_in_place(&elb, buffers->index_buf); } } } else if (buffers->index_buf) { if (!buffers->is_index_buf_global) { - GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf); } buffers->index_buf = NULL; buffers->is_index_buf_global = false; @@ -950,7 +950,7 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading) return buffers; } -Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast) +GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast) { return (fast && buffers->triangles_fast) ? buffers->triangles_fast : buffers->triangles; @@ -1003,13 +1003,13 @@ bool GPU_pbvh_buffers_mask_changed(GPU_PBVH_Buffers *buffers, bool show_mask) void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers) { if (buffers) { - GWN_BATCH_DISCARD_SAFE(buffers->triangles); - GWN_BATCH_DISCARD_SAFE(buffers->triangles_fast); + GPU_BATCH_DISCARD_SAFE(buffers->triangles); + GPU_BATCH_DISCARD_SAFE(buffers->triangles_fast); if (!buffers->is_index_buf_global) { - GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf); } - GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast); - GWN_VERTBUF_DISCARD_SAFE(buffers->vert_buf); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast); + GPU_VERTBUF_DISCARD_SAFE(buffers->vert_buf); #ifdef USE_BASE_ELEM if (buffers->baseelemarray) @@ -1029,7 +1029,7 @@ void GPU_pbvh_multires_buffers_free(GridCommonGPUBuffer **grid_common_gpu_buffer if (gridbuff) { if (gridbuff->mres_buffer) { BLI_mutex_lock(&buffer_mutex); - GWN_INDEXBUF_DISCARD_SAFE(gridbuff->mres_buffer); + GPU_INDEXBUF_DISCARD_SAFE(gridbuff->mres_buffer); BLI_mutex_unlock(&buffer_mutex); } MEM_freeN(gridbuff); @@ -1049,7 +1049,7 @@ void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos) * could keep a static batch & index buffer, change the VBO contents per draw */ - immBegin(GWN_PRIM_LINES, 24); + immBegin(GPU_PRIM_LINES, 24); /* top */ immVertex3f(pos, min[0], min[1], max[2]); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index a450b551d4a..51f21d01a9f 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -917,7 +917,7 @@ static const char *attrib_prefix_get(CustomDataType type) case CD_TANGENT: return "t"; case CD_MCOL: return "c"; case CD_AUTO_FROM_NAME: return "a"; - default: BLI_assert(false && "Gwn_VertAttr Prefix type not found : This should not happen!"); return ""; + default: BLI_assert(false && "GPUVertAttr Prefix type not found : This should not happen!"); return ""; } } diff --git a/source/blender/gpu/intern/gpu_element.c b/source/blender/gpu/intern/gpu_element.c index 596530a6ff4..1b5a08ac35c 100644 --- a/source/blender/gpu/intern/gpu_element.c +++ b/source/blender/gpu/intern/gpu_element.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_element.c +/** \file blender/gpu/intern/gpu_element.c * \ingroup gpu * - * Gawain element list (AKA index buffer) + * GPU element list (AKA index buffer) */ #include "GPU_element.h" @@ -36,23 +36,23 @@ #define KEEP_SINGLE_COPY 1 -static GLenum convert_index_type_to_gl(Gwn_IndexBufType type) +static GLenum convert_index_type_to_gl(GPUIndexBufType type) { static const GLenum table[] = { - [GWN_INDEX_U8] = GL_UNSIGNED_BYTE, /* GL has this, Vulkan does not */ - [GWN_INDEX_U16] = GL_UNSIGNED_SHORT, - [GWN_INDEX_U32] = GL_UNSIGNED_INT + [GPU_INDEX_U8] = GL_UNSIGNED_BYTE, /* GL has this, Vulkan does not */ + [GPU_INDEX_U16] = GL_UNSIGNED_SHORT, + [GPU_INDEX_U32] = GL_UNSIGNED_INT }; return table[type]; } -uint GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) +uint GPU_indexbuf_size_get(const GPUIndexBuf* elem) { -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE static const uint table[] = { - [GWN_INDEX_U8] = sizeof(GLubyte), /* GL has this, Vulkan does not */ - [GWN_INDEX_U16] = sizeof(GLushort), - [GWN_INDEX_U32] = sizeof(GLuint) + [GPU_INDEX_U8] = sizeof(GLubyte), /* GL has this, Vulkan does not */ + [GPU_INDEX_U16] = sizeof(GLushort), + [GPU_INDEX_U32] = sizeof(GLuint) }; return elem->index_len * table[elem->index_type]; #else @@ -60,8 +60,8 @@ uint GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) #endif } -void GWN_indexbuf_init_ex( - Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, +void GPU_indexbuf_init_ex( + GPUIndexBufBuilder* builder, GPUPrimType prim_type, uint index_len, uint vertex_len, bool use_prim_restart) { builder->use_prim_restart = use_prim_restart; @@ -72,20 +72,20 @@ void GWN_indexbuf_init_ex( builder->data = calloc(builder->max_index_len, sizeof(uint)); } -void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uint prim_len, uint vertex_len) +void GPU_indexbuf_init(GPUIndexBufBuilder* builder, GPUPrimType prim_type, uint prim_len, uint vertex_len) { uint verts_per_prim = 0; switch (prim_type) { - case GWN_PRIM_POINTS: + case GPU_PRIM_POINTS: verts_per_prim = 1; break; - case GWN_PRIM_LINES: + case GPU_PRIM_LINES: verts_per_prim = 2; break; - case GWN_PRIM_TRIS: + case GPU_PRIM_TRIS: verts_per_prim = 3; break; - case GWN_PRIM_LINES_ADJ: + case GPU_PRIM_LINES_ADJ: verts_per_prim = 4; break; default: @@ -95,10 +95,10 @@ void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uin return; } - GWN_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); + GPU_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); } -void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, uint v) +void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder* builder, uint v) { #if TRUST_NO_ONE assert(builder->data != NULL); @@ -108,58 +108,58 @@ void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, uint v) builder->data[builder->index_len++] = v; } -void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder* builder) +void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder* builder) { #if TRUST_NO_ONE assert(builder->data != NULL); assert(builder->index_len < builder->max_index_len); assert(builder->use_prim_restart); #endif - builder->data[builder->index_len++] = GWN_PRIM_RESTART; + builder->data[builder->index_len++] = GPU_PRIM_RESTART; } -void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, uint v) +void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder* builder, uint v) { #if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_POINTS); + assert(builder->prim_type == GPU_PRIM_POINTS); #endif - GWN_indexbuf_add_generic_vert(builder, v); + GPU_indexbuf_add_generic_vert(builder, v); } -void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2) +void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder* builder, uint v1, uint v2) { #if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_LINES); + assert(builder->prim_type == GPU_PRIM_LINES); assert(v1 != v2); #endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); + GPU_indexbuf_add_generic_vert(builder, v1); + GPU_indexbuf_add_generic_vert(builder, v2); } -void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3) +void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder* builder, uint v1, uint v2, uint v3) { #if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_TRIS); + assert(builder->prim_type == GPU_PRIM_TRIS); assert(v1 != v2 && v2 != v3 && v3 != v1); #endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); - GWN_indexbuf_add_generic_vert(builder, v3); + GPU_indexbuf_add_generic_vert(builder, v1); + GPU_indexbuf_add_generic_vert(builder, v2); + GPU_indexbuf_add_generic_vert(builder, v3); } -void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3, uint v4) +void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder* builder, uint v1, uint v2, uint v3, uint v4) { #if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_LINES_ADJ); + assert(builder->prim_type == GPU_PRIM_LINES_ADJ); assert(v2 != v3); /* only the line need diff indices */ #endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); - GWN_indexbuf_add_generic_vert(builder, v3); - GWN_indexbuf_add_generic_vert(builder, v4); + GPU_indexbuf_add_generic_vert(builder, v1); + GPU_indexbuf_add_generic_vert(builder, v2); + GPU_indexbuf_add_generic_vert(builder, v3); + GPU_indexbuf_add_generic_vert(builder, v4); } -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE /* Everything remains 32 bit while building to keep things simple. * Find min/max after, then convert to smallest index type possible. */ @@ -174,7 +174,7 @@ static uint index_range(const uint values[], uint value_len, uint* min_out, uint uint max_value = values[0]; for (uint i = 1; i < value_len; ++i) { const uint value = values[i]; - if (value == GWN_PRIM_RESTART) + if (value == GPU_PRIM_RESTART) continue; else if (value < min_value) min_value = value; @@ -186,7 +186,7 @@ static uint index_range(const uint values[], uint value_len, uint* min_out, uint return max_value - min_value; } -static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) +static void squeeze_indices_byte(GPUIndexBufBuilder *builder, GPUIndexBuf* elem) { const uint *values = builder->data; const uint index_len = elem->index_len; @@ -201,7 +201,7 @@ static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* ele elem->min_index = 0; elem->max_index -= base; for (uint i = 0; i < index_len; ++i) { - data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); + data[i] = (values[i] == GPU_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); } } else { @@ -212,7 +212,7 @@ static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* ele } } -static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) +static void squeeze_indices_short(GPUIndexBufBuilder *builder, GPUIndexBuf* elem) { const uint *values = builder->data; const uint index_len = elem->index_len; @@ -227,7 +227,7 @@ static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* el elem->min_index = 0; elem->max_index -= base; for (uint i = 0; i < index_len; ++i) { - data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); + data[i] = (values[i] == GPU_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); } } else { @@ -238,16 +238,16 @@ static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* el } } -#endif /* GWN_TRACK_INDEX_RANGE */ +#endif /* GPU_TRACK_INDEX_RANGE */ -Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder* builder) +GPUIndexBuf* GPU_indexbuf_build(GPUIndexBufBuilder* builder) { - Gwn_IndexBuf* elem = calloc(1, sizeof(Gwn_IndexBuf)); - GWN_indexbuf_build_in_place(builder, elem); + GPUIndexBuf* elem = calloc(1, sizeof(GPUIndexBuf)); + GPU_indexbuf_build_in_place(builder, elem); return elem; } -void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* elem) +void GPU_indexbuf_build_in_place(GPUIndexBufBuilder* builder, GPUIndexBuf* elem) { #if TRUST_NO_ONE assert(builder->data != NULL); @@ -255,7 +255,7 @@ void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* ele elem->index_len = builder->index_len; elem->use_prim_restart = builder->use_prim_restart; -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE uint range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index); /* count the primitive restart index. */ @@ -264,29 +264,29 @@ void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* ele } if (range <= 0xFF) { - elem->index_type = GWN_INDEX_U8; + elem->index_type = GPU_INDEX_U8; squeeze_indices_byte(builder, elem); } else if (range <= 0xFFFF) { - elem->index_type = GWN_INDEX_U16; + elem->index_type = GPU_INDEX_U16; squeeze_indices_short(builder, elem); } else { - elem->index_type = GWN_INDEX_U32; + elem->index_type = GPU_INDEX_U32; elem->base_index = 0; } elem->gl_index_type = convert_index_type_to_gl(elem->index_type); #endif if (elem->vbo_id == 0) { - elem->vbo_id = GWN_buf_id_alloc(); + elem->vbo_id = GPU_buf_id_alloc(); } /* send data to GPU */ /* GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound, * so we use the GL_ARRAY_BUFFER here to create a buffer without * interfering in the VAO state. */ glBindBuffer(GL_ARRAY_BUFFER, elem->vbo_id); - glBufferData(GL_ARRAY_BUFFER, GWN_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, GPU_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW); /* discard builder (one-time use) */ free(builder->data); @@ -294,15 +294,15 @@ void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* ele /* other fields are safe to leave */ } -void GWN_indexbuf_use(Gwn_IndexBuf* elem) +void GPU_indexbuf_use(GPUIndexBuf* elem) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id); } -void GWN_indexbuf_discard(Gwn_IndexBuf* elem) +void GPU_indexbuf_discard(GPUIndexBuf* elem) { if (elem->vbo_id) { - GWN_buf_id_free(elem->vbo_id); + GPU_buf_id_free(elem->vbo_id); } free(elem); } diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index 661594faf39..a320935919a 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_immediate.c +/** \file blender/gpu/intern/gpu_immediate.c * \ingroup gpu * - * Gawain immediate mode work-alike + * GPU immediate mode work-alike */ #include "UI_resources.h" @@ -45,14 +45,14 @@ #include /* necessary functions from matrix API */ -extern void GPU_matrix_bind(const Gwn_ShaderInterface*); +extern void GPU_matrix_bind(const GPUShaderInterface*); extern bool GPU_matrix_dirty_get(void); typedef struct { /* TODO: organize this struct by frequency of change (run-time) */ - Gwn_Batch* batch; - Gwn_Context* context; + GPUBatch* batch; + GPUContext* context; /* current draw call */ GLubyte* buffer_data; @@ -60,9 +60,9 @@ typedef struct { uint buffer_bytes_mapped; uint vertex_len; bool strict_vertex_len; - Gwn_PrimType prim_type; + GPUPrimType prim_type; - Gwn_VertFormat vertex_format; + GPUVertFormat vertex_format; /* current vertex */ uint vertex_idx; @@ -73,8 +73,8 @@ typedef struct { GLuint vao_id; GLuint bound_program; - const Gwn_ShaderInterface* shader_interface; - Gwn_AttrBinding attrib_binding; + const GPUShaderInterface* shader_interface; + GPUAttrBinding attrib_binding; uint16_t prev_enabled_attrib_bits; /* <-- only affects this VAO, so we're ok */ } Immediate; @@ -91,11 +91,11 @@ void immInit(void) #endif memset(&imm, 0, sizeof(Immediate)); - imm.vbo_id = GWN_buf_id_alloc(); + imm.vbo_id = GPU_buf_id_alloc(); glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); - imm.prim_type = GWN_PRIM_NONE; + imm.prim_type = GPU_PRIM_NONE; imm.strict_vertex_len = true; glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -106,38 +106,38 @@ void immActivate(void) { #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ + assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we're not between a Begin/End pair */ assert(imm.vao_id == 0); #endif - imm.vao_id = GWN_vao_alloc(); - imm.context = GWN_context_active_get(); + imm.vao_id = GPU_vao_alloc(); + imm.context = GPU_context_active_get(); } void immDeactivate(void) { #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ + assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we're not between a Begin/End pair */ assert(imm.vao_id != 0); #endif - GWN_vao_free(imm.vao_id, imm.context); + GPU_vao_free(imm.vao_id, imm.context); imm.vao_id = 0; imm.prev_enabled_attrib_bits = 0; } void immDestroy(void) { - GWN_buf_id_free(imm.vbo_id); + GPU_buf_id_free(imm.vbo_id); initialized = false; } -Gwn_VertFormat* immVertexFormat(void) +GPUVertFormat* immVertexFormat(void) { - GWN_vertformat_clear(&imm.vertex_format); + GPU_vertformat_clear(&imm.vertex_format); return &imm.vertex_format; } -void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface) +void immBindProgram(GLuint program, const GPUShaderInterface* shaderface) { #if TRUST_NO_ONE assert(imm.bound_program == 0); @@ -173,7 +173,7 @@ void immUnbindProgram(void) } #if TRUST_NO_ONE -static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType prim_type) +static bool vertex_count_makes_sense_for_primitive(uint vertex_len, GPUPrimType prim_type) { /* does vertex_len make sense for this primitive type? */ if (vertex_len == 0) { @@ -181,19 +181,19 @@ static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType } switch (prim_type) { - case GWN_PRIM_POINTS: + case GPU_PRIM_POINTS: return true; - case GWN_PRIM_LINES: + case GPU_PRIM_LINES: return vertex_len % 2 == 0; - case GWN_PRIM_LINE_STRIP: - case GWN_PRIM_LINE_LOOP: + case GPU_PRIM_LINE_STRIP: + case GPU_PRIM_LINE_LOOP: return vertex_len >= 2; - case GWN_PRIM_LINE_STRIP_ADJ: + case GPU_PRIM_LINE_STRIP_ADJ: return vertex_len >= 4; - case GWN_PRIM_TRIS: + case GPU_PRIM_TRIS: return vertex_len % 3 == 0; - case GWN_PRIM_TRI_STRIP: - case GWN_PRIM_TRI_FAN: + case GPU_PRIM_TRI_STRIP: + case GPU_PRIM_TRI_FAN: return vertex_len >= 3; default: return false; @@ -201,11 +201,11 @@ static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType } #endif -void immBegin(Gwn_PrimType prim_type, uint vertex_len) +void immBegin(GPUPrimType prim_type, uint vertex_len) { #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ + assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we haven't already begun */ assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif imm.prim_type = prim_type; @@ -250,7 +250,7 @@ void immBegin(Gwn_PrimType prim_type, uint vertex_len) imm.vertex_data = imm.buffer_data; } -void immBeginAtMost(Gwn_PrimType prim_type, uint vertex_len) +void immBeginAtMost(GPUPrimType prim_type, uint vertex_len) { #if TRUST_NO_ONE assert(vertex_len > 0); @@ -261,11 +261,11 @@ void immBeginAtMost(Gwn_PrimType prim_type, uint vertex_len) } -Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, uint vertex_len) +GPUBatch* immBeginBatch(GPUPrimType prim_type, uint vertex_len) { #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ + assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we haven't already begun */ assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif imm.prim_type = prim_type; @@ -273,19 +273,19 @@ Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, uint vertex_len) imm.vertex_idx = 0; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; - Gwn_VertBuf* verts = GWN_vertbuf_create_with_format(&imm.vertex_format); - GWN_vertbuf_data_alloc(verts, vertex_len); + GPUVertBuf* verts = GPU_vertbuf_create_with_format(&imm.vertex_format); + GPU_vertbuf_data_alloc(verts, vertex_len); - imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts); + imm.buffer_bytes_mapped = GPU_vertbuf_size_get(verts); imm.vertex_data = verts->data; - imm.batch = GWN_batch_create_ex(prim_type, verts, NULL, GWN_BATCH_OWNS_VBO); - imm.batch->phase = GWN_BATCH_BUILDING; + imm.batch = GPU_batch_create_ex(prim_type, verts, NULL, GPU_BATCH_OWNS_VBO); + imm.batch->phase = GPU_BATCH_BUILDING; return imm.batch; } -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, uint vertex_len) +GPUBatch* immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len) { imm.strict_vertex_len = false; return immBeginBatch(prim_type, vertex_len); @@ -298,7 +298,7 @@ static void immDrawSetup(void) /* enable/disable vertex attribs as needed */ if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits) { - for (uint loc = 0; loc < GWN_VERT_ATTR_MAX_LEN; ++loc) { + for (uint loc = 0; loc < GPU_VERT_ATTR_MAX_LEN; ++loc) { bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc); bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc); @@ -316,7 +316,7 @@ static void immDrawSetup(void) const uint stride = imm.vertex_format.stride; for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { - const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; + const GPUVertAttr* a = imm.vertex_format.attribs + a_idx; const uint offset = imm.buffer_offset + a->offset; const GLvoid* pointer = (const GLubyte*)0 + offset; @@ -324,14 +324,14 @@ static void immDrawSetup(void) const uint loc = read_attrib_location(&imm.attrib_binding, a_idx); switch (a->fetch_mode) { - case GWN_FETCH_FLOAT: - case GWN_FETCH_INT_TO_FLOAT: + case GPU_FETCH_FLOAT: + case GPU_FETCH_INT_TO_FLOAT: glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); break; - case GWN_FETCH_INT_TO_FLOAT_UNIT: + case GPU_FETCH_INT_TO_FLOAT_UNIT: glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); break; - case GWN_FETCH_INT: + case GPU_FETCH_INT: glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer); } } @@ -344,7 +344,7 @@ static void immDrawSetup(void) void immEnd(void) { #if TRUST_NO_ONE - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif uint buffer_bytes_used; @@ -375,11 +375,11 @@ void immEnd(void) if (imm.batch) { if (buffer_bytes_used != imm.buffer_bytes_mapped) { - GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); + GPU_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); /* TODO: resize only if vertex count is much smaller */ } - GWN_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface); - imm.batch->phase = GWN_BATCH_READY_TO_DRAW; + GPU_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface); + imm.batch->phase = GPU_BATCH_READY_TO_DRAW; imm.batch = NULL; /* don't free, batch belongs to caller */ } else { @@ -395,7 +395,7 @@ void immEnd(void) } /* prep for next immBegin */ - imm.prim_type = GWN_PRIM_NONE; + imm.prim_type = GPU_PRIM_NONE; imm.strict_vertex_len = true; } @@ -413,13 +413,13 @@ static void setAttribValueBit(uint attrib_id) void immAttrib1f(uint attrib_id, float x) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_type == GPU_COMP_F32); assert(attrib->comp_len == 1); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -431,13 +431,13 @@ void immAttrib1f(uint attrib_id, float x) void immAttrib2f(uint attrib_id, float x, float y) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_type == GPU_COMP_F32); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -450,13 +450,13 @@ void immAttrib2f(uint attrib_id, float x, float y) void immAttrib3f(uint attrib_id, float x, float y, float z) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_type == GPU_COMP_F32); assert(attrib->comp_len == 3); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -470,13 +470,13 @@ void immAttrib3f(uint attrib_id, float x, float y, float z) void immAttrib4f(uint attrib_id, float x, float y, float z, float w) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_type == GPU_COMP_F32); assert(attrib->comp_len == 4); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -491,13 +491,13 @@ void immAttrib4f(uint attrib_id, float x, float y, float z, float w) void immAttrib1u(uint attrib_id, uint x) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U32); + assert(attrib->comp_type == GPU_COMP_U32); assert(attrib->comp_len == 1); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -508,13 +508,13 @@ void immAttrib1u(uint attrib_id, uint x) void immAttrib2i(uint attrib_id, int x, int y) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_I32); + assert(attrib->comp_type == GPU_COMP_I32); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -526,13 +526,13 @@ void immAttrib2i(uint attrib_id, int x, int y) void immAttrib2s(uint attrib_id, short x, short y) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_I16); + assert(attrib->comp_type == GPU_COMP_I16); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -559,13 +559,13 @@ void immAttrib4fv(uint attrib_id, const float data[4]) void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U8); + assert(attrib->comp_type == GPU_COMP_U8); assert(attrib->comp_len == 3); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -579,13 +579,13 @@ void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned cha void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U8); + assert(attrib->comp_type == GPU_COMP_U8); assert(attrib->comp_len == 4); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -613,7 +613,7 @@ void immSkipAttrib(uint attrib_id) #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); } @@ -621,7 +621,7 @@ void immSkipAttrib(uint attrib_id) static void immEndVertex(void) /* and move on to the next vertex */ { #if TRUST_NO_ONE - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ assert(imm.vertex_idx < imm.vertex_len); #endif @@ -633,7 +633,7 @@ static void immEndVertex(void) /* and move on to the next vertex */ #endif for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { if ((imm.unassigned_attrib_bits >> a_idx) & 1) { - const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; + const GPUVertAttr* a = imm.vertex_format.attribs + a_idx; /* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */ @@ -702,16 +702,16 @@ void immVertex2iv(uint attrib_id, const int data[2]) #if 0 #if TRUST_NO_ONE - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); assert(uniform); + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform); #else - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); #endif #else /* NOTE: It is possible to have uniform fully optimized out from the shader. * In this case we can't assert failure or allow NULL-pointer dereference. * TODO(sergey): How can we detect existing-but-optimized-out uniform but still * catch typos in uniform names passed to immUniform*() functions? */ - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; #endif void immUniform1f(const char* name, float x) @@ -817,7 +817,7 @@ void immUniform4iv(const char* name, const int data[4]) void immUniformColor4f(float r, float g, float b, float a) { - const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform_builtin(imm.shader_interface, GWN_UNIFORM_COLOR); + const GPUShaderInput* uniform = GPU_shaderinterface_uniform_builtin(imm.shader_interface, GPU_UNIFORM_COLOR); #if TRUST_NO_ONE assert(uniform != NULL); #endif diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index 4b2fb1b8e8a..b794048087a 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -18,10 +18,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_imm_util.c +/** \file blender/gpu/intern/gpu_imm_util.c * \ingroup gpu * - * Gawain immediate mode drawing utilities + * GPU immediate mode drawing utilities */ #include @@ -70,7 +70,7 @@ static const int cube_line_index[12][2] = { void immRectf(uint pos, float x1, float y1, float x2, float y2) { - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y1); immVertex2f(pos, x2, y2); @@ -80,7 +80,7 @@ void immRectf(uint pos, float x1, float y1, float x2, float y2) void immRecti(uint pos, int x1, int y1, int x2, int y2) { - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immVertex2i(pos, x1, y1); immVertex2i(pos, x2, y1); immVertex2i(pos, x2, y2); @@ -125,8 +125,8 @@ void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2 #if 0 /* more complete version in case we want that */ void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = add_attrib(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = add_attrib(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); immRecti(pos, x1, y1, x2, y2); @@ -153,7 +153,7 @@ void imm_cpack(unsigned int x) } static void imm_draw_circle( - Gwn_PrimType prim_type, const uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments) + GPUPrimType prim_type, const uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments) { immBegin(prim_type, nsegments); for (int i = 0; i < nsegments; ++i) { @@ -175,7 +175,7 @@ static void imm_draw_circle( */ void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nsegments) { - imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad, rad, nsegments); + imm_draw_circle(GPU_PRIM_LINE_LOOP, shdr_pos, x, y, rad, rad, nsegments); } /** @@ -190,23 +190,23 @@ void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nse */ void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float rad, int nsegments) { - imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad, rad, nsegments); + imm_draw_circle(GPU_PRIM_TRI_FAN, shdr_pos, x, y, rad, rad, nsegments); } void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments) { - imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad_x, rad_y, nsegments); + imm_draw_circle(GPU_PRIM_LINE_LOOP, shdr_pos, x, y, rad_x, rad_y, nsegments); } void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments) { - imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad_x, rad_y, nsegments); + imm_draw_circle(GPU_PRIM_TRI_FAN, shdr_pos, x, y, rad_x, rad_y, nsegments); } /** * \note We could have `imm_draw_lined_disk_partial` but currently there is no need. */ static void imm_draw_disk_partial( - Gwn_PrimType prim_type, unsigned pos, float x, float y, + GPUPrimType prim_type, unsigned pos, float x, float y, float rad_inner, float rad_outer, int nsegments, float start, float sweep) { /* shift & reverse angle, increase 'nsegments' to match gluPartialDisk */ @@ -243,11 +243,11 @@ void imm_draw_disk_partial_fill_2d( unsigned pos, float x, float y, float rad_inner, float rad_outer, int nsegments, float start, float sweep) { - imm_draw_disk_partial(GWN_PRIM_TRI_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep); + imm_draw_disk_partial(GPU_PRIM_TRI_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep); } static void imm_draw_circle_3D( - Gwn_PrimType prim_type, unsigned pos, float x, float y, + GPUPrimType prim_type, unsigned pos, float x, float y, float rad, int nsegments) { immBegin(prim_type, nsegments); @@ -260,12 +260,12 @@ static void imm_draw_circle_3D( void imm_draw_circle_wire_3d(unsigned pos, float x, float y, float rad, int nsegments) { - imm_draw_circle_3D(GWN_PRIM_LINE_LOOP, pos, x, y, rad, nsegments); + imm_draw_circle_3D(GPU_PRIM_LINE_LOOP, pos, x, y, rad, nsegments); } void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nsegments) { - imm_draw_circle_3D(GWN_PRIM_TRI_FAN, pos, x, y, rad, nsegments); + imm_draw_circle_3D(GPU_PRIM_TRI_FAN, pos, x, y, rad, nsegments); } /** @@ -279,7 +279,7 @@ void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nseg */ void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2) { - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x1, y2); immVertex2f(pos, x2, y2); @@ -289,8 +289,8 @@ void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2) void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2) { - /* use this version when Gwn_VertFormat has a vec3 position */ - immBegin(GWN_PRIM_LINE_LOOP, 4); + /* use this version when GPUVertFormat has a vec3 position */ + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex3f(pos, x1, y1, 0.0f); immVertex3f(pos, x1, y2, 0.0f); immVertex3f(pos, x2, y2, 0.0f); @@ -303,7 +303,7 @@ void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2) */ void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); immUniform4f("color1", 0.15f, 0.15f, 0.15f, 1.0f); @@ -323,7 +323,7 @@ void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3]) madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect); } - immBegin(GWN_PRIM_TRIS, ARRAY_SIZE(cube_quad_index) * 3 * 2); + immBegin(GPU_PRIM_TRIS, ARRAY_SIZE(cube_quad_index) * 3 * 2); for (int i = 0; i < ARRAY_SIZE(cube_quad_index); i++) { immVertex3fv(pos, coords[cube_quad_index[i][0]]); immVertex3fv(pos, coords[cube_quad_index[i][1]]); @@ -344,7 +344,7 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3]) madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect); } - immBegin(GWN_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 2); + immBegin(GPU_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 2); for (int i = 0; i < ARRAY_SIZE(cube_line_index); i++) { immVertex3fv(pos, coords[cube_line_index[i][0]]); immVertex3fv(pos, coords[cube_line_index[i][1]]); @@ -367,7 +367,7 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3]) void imm_draw_cylinder_fill_normal_3d( unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks) { - immBegin(GWN_PRIM_TRIS, 6 * slices * stacks); + immBegin(GPU_PRIM_TRIS, 6 * slices * stacks); for (int i = 0; i < slices; ++i) { const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices); const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices); @@ -418,7 +418,7 @@ void imm_draw_cylinder_fill_normal_3d( void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks) { - immBegin(GWN_PRIM_LINES, 6 * slices * stacks); + immBegin(GPU_PRIM_LINES, 6 * slices * stacks); for (int i = 0; i < slices; ++i) { const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices); const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices); @@ -455,7 +455,7 @@ void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float he void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks) { - immBegin(GWN_PRIM_TRIS, 6 * slices * stacks); + immBegin(GPU_PRIM_TRIS, 6 * slices * stacks); for (int i = 0; i < slices; ++i) { const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices); const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices); diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c index 13c6fbea1c6..87fcc5f25a3 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.c @@ -558,20 +558,20 @@ const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3] return m; } -void GPU_matrix_bind(const Gwn_ShaderInterface *shaderface) +void GPU_matrix_bind(const GPUShaderInterface *shaderface) { /* set uniform values to matrix stack values * call this before a draw call if desired matrices are dirty * call glUseProgram before this, as glUniform expects program to be bound */ - const Gwn_ShaderInput *MV = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MODELVIEW); - const Gwn_ShaderInput *P = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_PROJECTION); - const Gwn_ShaderInput *MVP = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MVP); + const GPUShaderInput *MV = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MODELVIEW); + const GPUShaderInput *P = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_PROJECTION); + const GPUShaderInput *MVP = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MVP); - const Gwn_ShaderInput *N = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_NORMAL); - const Gwn_ShaderInput *MV_inv = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MODELVIEW_INV); - const Gwn_ShaderInput *P_inv = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_PROJECTION_INV); + const GPUShaderInput *N = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_NORMAL); + const GPUShaderInput *MV_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MODELVIEW_INV); + const GPUShaderInput *P_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_PROJECTION_INV); if (MV) { #if DEBUG_MATRIX_BIND diff --git a/source/blender/gpu/intern/gpu_primitive.c b/source/blender/gpu/intern/gpu_primitive.c index 0f0c28c05dc..189d17f2dd2 100644 --- a/source/blender/gpu/intern/gpu_primitive.c +++ b/source/blender/gpu/intern/gpu_primitive.c @@ -23,61 +23,61 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_primitive.c +/** \file blender/gpu/intern/gpu_primitive.c * \ingroup gpu * - * Gawain geometric primitives + * GPU geometric primitives */ #include "GPU_primitive.h" #include "gpu_primitive_private.h" -Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type) +GPUPrimClass GPU_primtype_class(GPUPrimType prim_type) { - static const Gwn_PrimClass classes[] = { - [GWN_PRIM_POINTS] = GWN_PRIM_CLASS_POINT, - [GWN_PRIM_LINES] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_STRIP] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_LOOP] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_TRIS] = GWN_PRIM_CLASS_SURFACE, - [GWN_PRIM_TRI_STRIP] = GWN_PRIM_CLASS_SURFACE, - [GWN_PRIM_TRI_FAN] = GWN_PRIM_CLASS_SURFACE, + static const GPUPrimClass classes[] = { + [GPU_PRIM_POINTS] = GPU_PRIM_CLASS_POINT, + [GPU_PRIM_LINES] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_LINE_STRIP] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_LINE_LOOP] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_TRIS] = GPU_PRIM_CLASS_SURFACE, + [GPU_PRIM_TRI_STRIP] = GPU_PRIM_CLASS_SURFACE, + [GPU_PRIM_TRI_FAN] = GPU_PRIM_CLASS_SURFACE, - [GWN_PRIM_LINES_ADJ] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_TRIS_ADJ] = GWN_PRIM_CLASS_SURFACE, + [GPU_PRIM_LINES_ADJ] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_LINE_STRIP_ADJ] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_TRIS_ADJ] = GPU_PRIM_CLASS_SURFACE, - [GWN_PRIM_NONE] = GWN_PRIM_CLASS_NONE + [GPU_PRIM_NONE] = GPU_PRIM_CLASS_NONE }; return classes[prim_type]; } -bool GWN_primtype_belongs_to_class(Gwn_PrimType prim_type, Gwn_PrimClass prim_class) +bool GPU_primtype_belongs_to_class(GPUPrimType prim_type, GPUPrimClass prim_class) { - if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE) { + if (prim_class == GPU_PRIM_CLASS_NONE && prim_type == GPU_PRIM_NONE) { return true; } - return prim_class & GWN_primtype_class(prim_type); + return prim_class & GPU_primtype_class(prim_type); } -GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type) +GLenum convert_prim_type_to_gl(GPUPrimType prim_type) { #if TRUST_NO_ONE - assert(prim_type != GWN_PRIM_NONE); + assert(prim_type != GPU_PRIM_NONE); #endif static const GLenum table[] = { - [GWN_PRIM_POINTS] = GL_POINTS, - [GWN_PRIM_LINES] = GL_LINES, - [GWN_PRIM_LINE_STRIP] = GL_LINE_STRIP, - [GWN_PRIM_LINE_LOOP] = GL_LINE_LOOP, - [GWN_PRIM_TRIS] = GL_TRIANGLES, - [GWN_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP, - [GWN_PRIM_TRI_FAN] = GL_TRIANGLE_FAN, + [GPU_PRIM_POINTS] = GL_POINTS, + [GPU_PRIM_LINES] = GL_LINES, + [GPU_PRIM_LINE_STRIP] = GL_LINE_STRIP, + [GPU_PRIM_LINE_LOOP] = GL_LINE_LOOP, + [GPU_PRIM_TRIS] = GL_TRIANGLES, + [GPU_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP, + [GPU_PRIM_TRI_FAN] = GL_TRIANGLE_FAN, - [GWN_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY, - [GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY, - [GWN_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY, + [GPU_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY, + [GPU_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY, + [GPU_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY, }; return table[prim_type]; diff --git a/source/blender/gpu/intern/gpu_primitive_private.h b/source/blender/gpu/intern/gpu_primitive_private.h index 6d3f1e20da7..d057f29fdc5 100644 --- a/source/blender/gpu/intern/gpu_primitive_private.h +++ b/source/blender/gpu/intern/gpu_primitive_private.h @@ -23,15 +23,15 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_primitive_private.h +/** \file blender/gpu/intern/gpu_primitive_private.h * \ingroup gpu * - * Gawain geometric primitives + * GPU geometric primitives */ -#ifndef __GWN_PRIMITIVE_PRIVATE_H__ -#define __GWN_PRIMITIVE_PRIVATE_H__ +#ifndef __GPU_PRIMITIVE_PRIVATE_H__ +#define __GPU_PRIMITIVE_PRIVATE_H__ -GLenum convert_prim_type_to_gl(Gwn_PrimType); +GLenum convert_prim_type_to_gl(GPUPrimType); -#endif /* __GWN_PRIMITIVE_PRIVATE_H__ */ +#endif /* __GPU_PRIMITIVE_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 99baaa1164f..c5325b6ff21 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -496,24 +496,24 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode, return NULL; } - shader->interface = GWN_shaderinterface_create(shader->program); + shader->interface = GPU_shaderinterface_create(shader->program); #ifdef WITH_OPENSUBDIV /* TODO(sergey): Find a better place for this. */ if (use_opensubdiv) { if (GLEW_VERSION_4_1) { glProgramUniform1i(shader->program, - GWN_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, + GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30); /* GL_TEXTURE30 */ glProgramUniform1i(shader->program, - GWN_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, + GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31); /* GL_TEXTURE31 */ } else { glUseProgram(shader->program); - glUniform1i(GWN_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30); - glUniform1i(GWN_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31); + glUniform1i(GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30); + glUniform1i(GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31); glUseProgram(0); } } @@ -575,7 +575,7 @@ void GPU_shader_free(GPUShader *shader) glDeleteProgram(shader->program); if (shader->interface) - GWN_shaderinterface_discard(shader->interface); + GPU_shaderinterface_discard(shader->interface); MEM_freeN(shader); } @@ -583,14 +583,14 @@ void GPU_shader_free(GPUShader *shader) int GPU_shader_get_uniform(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); - const Gwn_ShaderInput *uniform = GWN_shaderinterface_uniform(shader->interface, name); + const GPUShaderInput *uniform = GPU_shaderinterface_uniform(shader->interface, name); return uniform ? uniform->location : -1; } int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin) { BLI_assert(shader && shader->program); - const Gwn_ShaderInput *uniform = GWN_shaderinterface_uniform_builtin(shader->interface, builtin); + const GPUShaderInput *uniform = GPU_shaderinterface_uniform_builtin(shader->interface, builtin); return uniform ? uniform->location : -1; } @@ -598,7 +598,7 @@ int GPU_shader_get_uniform_block(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); - const Gwn_ShaderInput *ubo = GWN_shaderinterface_ubo(shader->interface, name); + const GPUShaderInput *ubo = GPU_shaderinterface_ubo(shader->interface, name); return ubo ? ubo->location : -1; } @@ -675,7 +675,7 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText int GPU_shader_get_attribute(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); - const Gwn_ShaderInput *attrib = GWN_shaderinterface_attr(shader->interface, name); + const GPUShaderInput *attrib = GPU_shaderinterface_attr(shader->interface, name); return attrib ? attrib->location : -1; } diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 56b25726a84..ec2f52a2a2d 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_shader_interface.c +/** \file blender/gpu/intern/gpu_shader_interface.c * \ingroup gpu * - * Gawain shader interface (C --> GLSL) + * GPU shader interface (C --> GLSL) */ #include "gpu_batch_private.h" @@ -42,46 +42,46 @@ #include #endif -static const char* BuiltinUniform_name(Gwn_UniformBuiltin u) +static const char* BuiltinUniform_name(GPUUniformBuiltin u) { static const char* names[] = { - [GWN_UNIFORM_NONE] = NULL, - - [GWN_UNIFORM_MODEL] = "ModelMatrix", - [GWN_UNIFORM_VIEW] = "ViewMatrix", - [GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix", - [GWN_UNIFORM_PROJECTION] = "ProjectionMatrix", - [GWN_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix", - [GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix", - - [GWN_UNIFORM_MODEL_INV] = "ModelMatrixInverse", - [GWN_UNIFORM_VIEW_INV] = "ViewMatrixInverse", - [GWN_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse", - [GWN_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse", - [GWN_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse", - - [GWN_UNIFORM_NORMAL] = "NormalMatrix", - [GWN_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix", - [GWN_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors", - [GWN_UNIFORM_ORCO] = "OrcoTexCoFactors", - - [GWN_UNIFORM_COLOR] = "color", - [GWN_UNIFORM_EYE] = "eye", - [GWN_UNIFORM_CALLID] = "callId", - - [GWN_UNIFORM_CUSTOM] = NULL, - [GWN_NUM_UNIFORMS] = NULL, + [GPU_UNIFORM_NONE] = NULL, + + [GPU_UNIFORM_MODEL] = "ModelMatrix", + [GPU_UNIFORM_VIEW] = "ViewMatrix", + [GPU_UNIFORM_MODELVIEW] = "ModelViewMatrix", + [GPU_UNIFORM_PROJECTION] = "ProjectionMatrix", + [GPU_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix", + [GPU_UNIFORM_MVP] = "ModelViewProjectionMatrix", + + [GPU_UNIFORM_MODEL_INV] = "ModelMatrixInverse", + [GPU_UNIFORM_VIEW_INV] = "ViewMatrixInverse", + [GPU_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse", + [GPU_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse", + [GPU_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse", + + [GPU_UNIFORM_NORMAL] = "NormalMatrix", + [GPU_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix", + [GPU_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors", + [GPU_UNIFORM_ORCO] = "OrcoTexCoFactors", + + [GPU_UNIFORM_COLOR] = "color", + [GPU_UNIFORM_EYE] = "eye", + [GPU_UNIFORM_CALLID] = "callId", + + [GPU_UNIFORM_CUSTOM] = NULL, + [GPU_NUM_UNIFORMS] = NULL, }; return names[u]; } -GWN_INLINE bool match(const char* a, const char* b) +GPU_INLINE bool match(const char* a, const char* b) { return strcmp(a, b) == 0; } -GWN_INLINE uint hash_string(const char *str) +GPU_INLINE uint hash_string(const char *str) { uint i = 0, c; while ((c = *str++)) { @@ -90,7 +90,7 @@ GWN_INLINE uint hash_string(const char *str) return i; } -GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* input, +GPU_INLINE void set_input_name(GPUShaderInterface* shaderface, GPUShaderInput* input, const char* name, uint32_t name_len) { input->name_offset = shaderface->name_buffer_offset; @@ -98,20 +98,20 @@ GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* shaderface->name_buffer_offset += name_len + 1; /* include NULL terminator */ } -GWN_INLINE void shader_input_to_bucket(Gwn_ShaderInput* input, - Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) +GPU_INLINE void shader_input_to_bucket(GPUShaderInput* input, + GPUShaderInput* buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]) { - const uint bucket_index = input->name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; + const uint bucket_index = input->name_hash % GPU_NUM_SHADERINTERFACE_BUCKETS; input->next = buckets[bucket_index]; buckets[bucket_index] = input; } -GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[GWN_NUM_SHADERINTERFACE_BUCKETS], +GPU_INLINE const GPUShaderInput* buckets_lookup(GPUShaderInput* const buckets[GPU_NUM_SHADERINTERFACE_BUCKETS], const char *name_buffer, const char *name) { const uint name_hash = hash_string(name); - const uint bucket_index = name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; - const Gwn_ShaderInput* input = buckets[bucket_index]; + const uint bucket_index = name_hash % GPU_NUM_SHADERINTERFACE_BUCKETS; + const GPUShaderInput* input = buckets[bucket_index]; if (input == NULL) { /* Requested uniform is not found at all. */ return NULL; @@ -129,7 +129,7 @@ GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[ return NULL; } /* Work through possible collisions. */ - const Gwn_ShaderInput* next = input; + const GPUShaderInput* next = input; while (next != NULL) { input = next; next = input->next; @@ -143,37 +143,37 @@ GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[ return NULL; /* not found */ } -GWN_INLINE void buckets_free(Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) +GPU_INLINE void buckets_free(GPUShaderInput* buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]) { - for (uint bucket_index = 0; bucket_index < GWN_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) { - Gwn_ShaderInput *input = buckets[bucket_index]; + for (uint bucket_index = 0; bucket_index < GPU_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) { + GPUShaderInput *input = buckets[bucket_index]; while (input != NULL) { - Gwn_ShaderInput *input_next = input->next; + GPUShaderInput *input_next = input->next; free(input); input = input_next; } } } -static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name) +static bool setup_builtin_uniform(GPUShaderInput* input, const char* name) { /* TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types */ /* detect built-in uniforms (name must match) */ - for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { + for (GPUUniformBuiltin u = GPU_UNIFORM_NONE + 1; u < GPU_UNIFORM_CUSTOM; ++u) { const char* builtin_name = BuiltinUniform_name(u); if (match(name, builtin_name)) { input->builtin_type = u; return true; } } - input->builtin_type = GWN_UNIFORM_CUSTOM; + input->builtin_type = GPU_UNIFORM_CUSTOM; return false; } -static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const char* name) +static const GPUShaderInput* add_uniform(GPUShaderInterface* shaderface, const char* name) { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); input->location = glGetUniformLocation(shaderface->program, name); @@ -186,13 +186,13 @@ static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const setup_builtin_uniform(input, name); shader_input_to_bucket(input, shaderface->uniform_buckets); - if (input->builtin_type != GWN_UNIFORM_NONE && - input->builtin_type != GWN_UNIFORM_CUSTOM) + if (input->builtin_type != GPU_UNIFORM_NONE && + input->builtin_type != GPU_UNIFORM_CUSTOM) { shaderface->builtin_uniforms[input->builtin_type] = input; } #if DEBUG_SHADER_INTERFACE - printf("Gwn_ShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, + printf("GPUShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, shaderface->program, name, input->location); @@ -200,14 +200,14 @@ static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const return input; } -Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) +GPUShaderInterface* GPU_shaderinterface_create(int32_t program) { - Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface)); + GPUShaderInterface* shaderface = calloc(1, sizeof(GPUShaderInterface)); shaderface->program = program; #if DEBUG_SHADER_INTERFACE printf("%s {\n", __func__); /* enter function */ - printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program); + printf("GPUShaderInterface %p, program %d\n", shaderface, program); #endif GLint max_attrib_name_len, attr_len; @@ -223,7 +223,7 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) /* Attributes */ for (uint32_t i = 0; i < attr_len; ++i) { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; char* name = shaderface->name_buffer + shaderface->name_buffer_offset; GLsizei name_len = 0; @@ -250,7 +250,7 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) } /* Uniform Blocks */ for (uint32_t i = 0; i < ubo_len; ++i) { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; char* name = shaderface->name_buffer + shaderface->name_buffer_offset; GLsizei name_len = 0; @@ -268,20 +268,20 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) #endif } /* Builtin Uniforms */ - for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { + for (GPUUniformBuiltin u = GPU_UNIFORM_NONE + 1; u < GPU_UNIFORM_CUSTOM; ++u) { const char* builtin_name = BuiltinUniform_name(u); if (glGetUniformLocation(program, builtin_name) != -1) { - add_uniform((Gwn_ShaderInterface*)shaderface, builtin_name); + add_uniform((GPUShaderInterface*)shaderface, builtin_name); } } /* Batches ref buffer */ - shaderface->batches_len = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = calloc(shaderface->batches_len, sizeof(Gwn_Batch*)); + shaderface->batches_len = GPU_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = calloc(shaderface->batches_len, sizeof(GPUBatch*)); return shaderface; } -void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) +void GPU_shaderinterface_discard(GPUShaderInterface* shaderface) { /* Free memory used by buckets and has entries. */ buckets_free(shaderface->uniform_buckets); @@ -292,7 +292,7 @@ void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) /* Remove this interface from all linked Batches vao cache. */ for (int i = 0; i < shaderface->batches_len; ++i) { if (shaderface->batches[i] != NULL) { - gwn_batch_remove_interface_ref(shaderface->batches[i], shaderface); + gpu_batch_remove_interface_ref(shaderface->batches[i], shaderface); } } free(shaderface->batches); @@ -300,39 +300,39 @@ void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) free(shaderface); } -const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name) +const GPUShaderInput* GPU_shaderinterface_uniform(const GPUShaderInterface* shaderface, const char* name) { /* TODO: Warn if we find a matching builtin, since these can be looked up much quicker. */ - const Gwn_ShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); + const GPUShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); /* If input is not found add it so it's found next time. */ if (input == NULL) { - input = add_uniform((Gwn_ShaderInterface*)shaderface, name); + input = add_uniform((GPUShaderInterface*)shaderface, name); } return (input->location != -1) ? input : NULL; } -const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin( - const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin) +const GPUShaderInput* GPU_shaderinterface_uniform_builtin( + const GPUShaderInterface* shaderface, GPUUniformBuiltin builtin) { #if TRUST_NO_ONE - assert(builtin != GWN_UNIFORM_NONE); - assert(builtin != GWN_UNIFORM_CUSTOM); - assert(builtin != GWN_NUM_UNIFORMS); + assert(builtin != GPU_UNIFORM_NONE); + assert(builtin != GPU_UNIFORM_CUSTOM); + assert(builtin != GPU_NUM_UNIFORMS); #endif return shaderface->builtin_uniforms[builtin]; } -const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface* shaderface, const char* name) +const GPUShaderInput* GPU_shaderinterface_ubo(const GPUShaderInterface* shaderface, const char* name) { return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name); } -const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name) +const GPUShaderInput* GPU_shaderinterface_attr(const GPUShaderInterface* shaderface, const char* name) { return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name); } -void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) +void GPU_shaderinterface_add_batch_ref(GPUShaderInterface* shaderface, GPUBatch* batch) { int i; /* find first unused slot */ for (i = 0; i < shaderface->batches_len; ++i) { @@ -343,14 +343,14 @@ void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batc if (i == shaderface->batches_len) { /* Not enough place, realloc the array. */ i = shaderface->batches_len; - shaderface->batches_len += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_len); - memset(shaderface->batches + i, 0, sizeof(Gwn_Batch*) * GWN_SHADERINTERFACE_REF_ALLOC_COUNT); + shaderface->batches_len += GPU_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = realloc(shaderface->batches, sizeof(GPUBatch*) * shaderface->batches_len); + memset(shaderface->batches + i, 0, sizeof(GPUBatch*) * GPU_SHADERINTERFACE_REF_ALLOC_COUNT); } shaderface->batches[i] = batch; } -void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) +void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface* shaderface, GPUBatch* batch) { for (int i = 0; i < shaderface->batches_len; ++i) { if (shaderface->batches[i] == batch) { diff --git a/source/blender/gpu/intern/gpu_shader_private.h b/source/blender/gpu/intern/gpu_shader_private.h index bf54d269fb5..d16aae79aae 100644 --- a/source/blender/gpu/intern/gpu_shader_private.h +++ b/source/blender/gpu/intern/gpu_shader_private.h @@ -35,7 +35,7 @@ struct GPUShader { GLuint geometry; /* handle for geometry shader */ GLuint fragment; /* handle for fragment shader */ - Gwn_ShaderInterface *interface; /* cached uniform & attrib interface for shader */ + GPUShaderInterface *interface; /* cached uniform & attrib interface for shader */ int feedback_transform_type; }; diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index d9248e06dfb..52afe17d885 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -911,28 +911,28 @@ GPUTexture *GPU_texture_create_cube( tex_format, GPU_DATA_FLOAT, err_out); } -GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) +GPUTexture *GPU_texture_create_from_vertbuf(GPUVertBuf *vert) { - Gwn_VertFormat *format = &vert->format; - Gwn_VertAttr *attr = &format->attribs[0]; + GPUVertFormat *format = &vert->format; + GPUVertAttr *attr = &format->attribs[0]; /* Detect incompatible cases (not supported by texture buffers) */ BLI_assert(format->attr_len == 1 && vert->vbo_id != 0); BLI_assert(attr->comp_len != 3); /* Not until OGL 4.0 */ - BLI_assert(attr->comp_type != GWN_COMP_I10); - BLI_assert(attr->fetch_mode != GWN_FETCH_INT_TO_FLOAT); + BLI_assert(attr->comp_type != GPU_COMP_I10); + BLI_assert(attr->fetch_mode != GPU_FETCH_INT_TO_FLOAT); unsigned int byte_per_comp = attr->sz / attr->comp_len; - bool is_uint = ELEM(attr->comp_type, GWN_COMP_U8, GWN_COMP_U16, GWN_COMP_U32); + bool is_uint = ELEM(attr->comp_type, GPU_COMP_U8, GPU_COMP_U16, GPU_COMP_U32); /* Cannot fetch signed int or 32bit ints as normalized float. */ - if (attr->fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT) { + if (attr->fetch_mode == GPU_FETCH_INT_TO_FLOAT_UNIT) { BLI_assert(is_uint || byte_per_comp <= 2); } GPUTextureFormat data_type; switch (attr->fetch_mode) { - case GWN_FETCH_FLOAT: + case GPU_FETCH_FLOAT: switch (attr->comp_len) { case 1: data_type = GPU_R32F; break; case 2: data_type = GPU_RG32F; break; @@ -940,7 +940,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) default: data_type = GPU_RGBA32F; break; } break; - case GWN_FETCH_INT: + case GPU_FETCH_INT: switch (attr->comp_len) { case 1: switch (byte_per_comp) { @@ -965,7 +965,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) break; } break; - case GWN_FETCH_INT_TO_FLOAT_UNIT: + case GPU_FETCH_INT_TO_FLOAT_UNIT: switch (attr->comp_len) { case 1: data_type = (byte_per_comp == 1) ? GPU_R8 : GPU_R16; break; case 2: data_type = (byte_per_comp == 1) ? GPU_RG8 : GPU_RG16; break; diff --git a/source/blender/gpu/intern/gpu_vertex_array_id.cpp b/source/blender/gpu/intern/gpu_vertex_array_id.cpp index de5be15ec19..2f29bbfbc33 100644 --- a/source/blender/gpu/intern/gpu_vertex_array_id.cpp +++ b/source/blender/gpu/intern/gpu_vertex_array_id.cpp @@ -23,7 +23,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_array_id.cpp +/** \file blender/gpu/gpu_vertex_array_id.cpp * \ingroup gpu * * Manage GL vertex array IDs in a thread-safe way @@ -56,16 +56,16 @@ static bool thread_is_main() { #endif #endif -struct Gwn_Context { +struct GPUContext { GLuint default_vao; - std::unordered_set batches; /* Batches that have VAOs from this context */ + std::unordered_set batches; /* Batches that have VAOs from this context */ std::vector orphaned_vertarray_ids; std::mutex orphans_mutex; /* todo: try spinlock instead */ #if TRUST_NO_ONE pthread_t thread; /* Thread on which this context is active. */ bool thread_is_used; - Gwn_Context() { + GPUContext() { thread_is_used = false; } #endif @@ -73,12 +73,12 @@ struct Gwn_Context { #if defined(_MSC_VER) && (_MSC_VER == 1800) #define thread_local __declspec(thread) -thread_local Gwn_Context* active_ctx = NULL; +thread_local GPUContext* active_ctx = NULL; #else -static thread_local Gwn_Context* active_ctx = NULL; +static thread_local GPUContext* active_ctx = NULL; #endif -static void clear_orphans(Gwn_Context* ctx) +static void clear_orphans(GPUContext* ctx) { ctx->orphans_mutex.lock(); if (!ctx->orphaned_vertarray_ids.empty()) { @@ -89,19 +89,19 @@ static void clear_orphans(Gwn_Context* ctx) ctx->orphans_mutex.unlock(); } -Gwn_Context* GWN_context_create(void) +GPUContext* GPU_context_create(void) { #if TRUST_NO_ONE /* assert(thread_is_main()); */ #endif - Gwn_Context* ctx = new Gwn_Context; + GPUContext* ctx = new GPUContext; glGenVertexArrays(1, &ctx->default_vao); - GWN_context_active_set(ctx); + GPU_context_active_set(ctx); return ctx; } -/* to be called after GWN_context_active_set(ctx_to_destroy) */ -void GWN_context_discard(Gwn_Context* ctx) +/* to be called after GPU_context_active_set(ctx_to_destroy) */ +void GPU_context_discard(GPUContext* ctx) { #if TRUST_NO_ONE /* Make sure no other thread has locked it. */ @@ -112,7 +112,7 @@ void GWN_context_discard(Gwn_Context* ctx) /* delete remaining vaos */ while (!ctx->batches.empty()) { /* this removes the array entry */ - gwn_batch_vao_cache_clear(*ctx->batches.begin()); + GPU_batch_vao_cache_clear(*ctx->batches.begin()); } glDeleteVertexArrays(1, &ctx->default_vao); delete ctx; @@ -120,7 +120,7 @@ void GWN_context_discard(Gwn_Context* ctx) } /* ctx can be NULL */ -void GWN_context_active_set(Gwn_Context* ctx) +void GPU_context_active_set(GPUContext* ctx) { #if TRUST_NO_ONE if (active_ctx) { @@ -140,12 +140,12 @@ void GWN_context_active_set(Gwn_Context* ctx) active_ctx = ctx; } -Gwn_Context* GWN_context_active_get(void) +GPUContext* GPU_context_active_get(void) { return active_ctx; } -GLuint GWN_vao_default(void) +GLuint GPU_vao_default(void) { #if TRUST_NO_ONE assert(active_ctx); /* need at least an active context */ @@ -154,7 +154,7 @@ GLuint GWN_vao_default(void) return active_ctx->default_vao; } -GLuint GWN_vao_alloc(void) +GLuint GPU_vao_alloc(void) { #if TRUST_NO_ONE assert(active_ctx); /* need at least an active context */ @@ -168,7 +168,7 @@ GLuint GWN_vao_alloc(void) } /* this can be called from multiple thread */ -void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx) +void GPU_vao_free(GLuint vao_id, GPUContext* ctx) { #if TRUST_NO_ONE assert(ctx); @@ -183,12 +183,12 @@ void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx) } } -void gwn_context_add_batch(Gwn_Context* ctx, Gwn_Batch* batch) +void gpu_context_add_batch(GPUContext* ctx, GPUBatch* batch) { ctx->batches.emplace(batch); } -void gwn_context_remove_batch(Gwn_Context* ctx, Gwn_Batch* batch) +void gpu_context_remove_batch(GPUContext* ctx, GPUBatch* batch) { ctx->orphans_mutex.lock(); ctx->batches.erase(batch); diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c index 32f3d494015..5b29913800d 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.c +++ b/source/blender/gpu/intern/gpu_vertex_buffer.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_vertex_buffer.c +/** \file blender/gpu/intern/gpu_vertex_buffer.c * \ingroup gpu * - * Gawain vertex buffer + * GPU vertex buffer */ #include "GPU_vertex_buffer.h" @@ -39,27 +39,27 @@ static uint vbo_memory_usage; -static GLenum convert_usage_type_to_gl(Gwn_UsageType type) +static GLenum convert_usage_type_to_gl(GPUUsageType type) { static const GLenum table[] = { - [GWN_USAGE_STREAM] = GL_STREAM_DRAW, - [GWN_USAGE_STATIC] = GL_STATIC_DRAW, - [GWN_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW + [GPU_USAGE_STREAM] = GL_STREAM_DRAW, + [GPU_USAGE_STATIC] = GL_STATIC_DRAW, + [GPU_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW }; return table[type]; } -Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType usage) +GPUVertBuf* GPU_vertbuf_create(GPUUsageType usage) { - Gwn_VertBuf* verts = malloc(sizeof(Gwn_VertBuf)); - GWN_vertbuf_init(verts, usage); + GPUVertBuf* verts = malloc(sizeof(GPUVertBuf)); + GPU_vertbuf_init(verts, usage); return verts; } -Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat* format, Gwn_UsageType usage) +GPUVertBuf* GPU_vertbuf_create_with_format_ex(const GPUVertFormat* format, GPUUsageType usage) { - Gwn_VertBuf* verts = GWN_vertbuf_create(usage); - GWN_vertformat_copy(&verts->format, format); + GPUVertBuf* verts = GPU_vertbuf_create(usage); + GPU_vertformat_copy(&verts->format, format); if (!format->packed) { VertexFormat_pack(&verts->format); } @@ -69,28 +69,28 @@ Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat* format, Gwn /* TODO: implement those memory savings */ } -void GWN_vertbuf_init(Gwn_VertBuf* verts, Gwn_UsageType usage) +void GPU_vertbuf_init(GPUVertBuf* verts, GPUUsageType usage) { - memset(verts, 0, sizeof(Gwn_VertBuf)); + memset(verts, 0, sizeof(GPUVertBuf)); verts->usage = usage; verts->dirty = true; } -void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf* verts, const Gwn_VertFormat* format, Gwn_UsageType usage) +void GPU_vertbuf_init_with_format_ex(GPUVertBuf* verts, const GPUVertFormat* format, GPUUsageType usage) { - GWN_vertbuf_init(verts, usage); - GWN_vertformat_copy(&verts->format, format); + GPU_vertbuf_init(verts, usage); + GPU_vertformat_copy(&verts->format, format); if (!format->packed) { VertexFormat_pack(&verts->format); } } -void GWN_vertbuf_discard(Gwn_VertBuf* verts) +void GPU_vertbuf_discard(GPUVertBuf* verts) { if (verts->vbo_id) { - GWN_buf_id_free(verts->vbo_id); + GPU_buf_id_free(verts->vbo_id); #if VRAM_USAGE - vbo_memory_usage -= GWN_vertbuf_size_get(verts); + vbo_memory_usage -= GPU_vertbuf_size_get(verts); #endif } if (verts->data) { @@ -99,15 +99,15 @@ void GWN_vertbuf_discard(Gwn_VertBuf* verts) free(verts); } -uint GWN_vertbuf_size_get(const Gwn_VertBuf* verts) +uint GPU_vertbuf_size_get(const GPUVertBuf* verts) { return vertex_buffer_size(&verts->format, verts->vertex_len); } /* create a new allocation, discarding any existing data */ -void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) +void GPU_vertbuf_data_alloc(GPUVertBuf* verts, uint v_len) { - Gwn_VertFormat* format = &verts->format; + GPUVertFormat* format = &verts->format; if (!format->packed) { VertexFormat_pack(format); } @@ -117,7 +117,7 @@ void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) #endif /* only create the buffer the 1st time */ if (verts->vbo_id == 0) { - verts->vbo_id = GWN_buf_id_alloc(); + verts->vbo_id = GPU_buf_id_alloc(); } /* discard previous data if any */ if (verts->data) { @@ -125,15 +125,15 @@ void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) } #if VRAM_USAGE uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); + vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts); #endif verts->dirty = true; verts->vertex_len = verts->vertex_alloc = v_len; - verts->data = malloc(sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); + verts->data = malloc(sizeof(GLubyte) * GPU_vertbuf_size_get(verts)); } /* resize buffer keeping existing data */ -void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, uint v_len) +void GPU_vertbuf_data_resize(GPUVertBuf* verts, uint v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); @@ -142,17 +142,17 @@ void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, uint v_len) #if VRAM_USAGE uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); + vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts); #endif verts->dirty = true; verts->vertex_len = verts->vertex_alloc = v_len; - verts->data = realloc(verts->data, sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); + verts->data = realloc(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts)); } /* Set vertex count but does not change allocation. * Only this many verts will be uploaded to the GPU and rendered. * This is usefull for streaming data. */ -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, uint v_len) +void GPU_vertbuf_vertex_count_set(GPUVertBuf* verts, uint v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); /* only for dynamic data */ @@ -161,15 +161,15 @@ void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, uint v_len) #if VRAM_USAGE uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); + vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts); #endif verts->vertex_len = v_len; } -void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, uint a_idx, uint v_idx, const void* data) +void GPU_vertbuf_attr_set(GPUVertBuf* verts, uint a_idx, uint v_idx, const void* data) { - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertFormat* format = &verts->format; + const GPUVertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -180,23 +180,23 @@ void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, uint a_idx, uint v_idx, const void memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz); } -void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, uint a_idx, const void* data) +void GPU_vertbuf_attr_fill(GPUVertBuf* verts, uint a_idx, const void* data) { - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertFormat* format = &verts->format; + const GPUVertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); #endif const uint stride = a->sz; /* tightly packed input data */ - GWN_vertbuf_attr_fill_stride(verts, a_idx, stride, data); + GPU_vertbuf_attr_fill_stride(verts, a_idx, stride, data); } -void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, uint a_idx, uint stride, const void* data) +void GPU_vertbuf_attr_fill_stride(GPUVertBuf* verts, uint a_idx, uint stride, const void* data) { - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertFormat* format = &verts->format; + const GPUVertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -217,10 +217,10 @@ void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, uint a_idx, uint stride, c } } -void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, uint a_idx, Gwn_VertBufRaw *access) +void GPU_vertbuf_attr_get_raw_data(GPUVertBuf* verts, uint a_idx, GPUVertBufRaw *access) { - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertFormat* format = &verts->format; + const GPUVertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -238,23 +238,23 @@ void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, uint a_idx, Gwn_VertBufRa #endif } -static void VertBuffer_upload_data(Gwn_VertBuf* verts) +static void VertBuffer_upload_data(GPUVertBuf* verts) { - uint buffer_sz = GWN_vertbuf_size_get(verts); + uint buffer_sz = GPU_vertbuf_size_get(verts); /* orphan the vbo to avoid sync */ glBufferData(GL_ARRAY_BUFFER, buffer_sz, NULL, convert_usage_type_to_gl(verts->usage)); /* upload data */ glBufferSubData(GL_ARRAY_BUFFER, 0, buffer_sz, verts->data); - if (verts->usage == GWN_USAGE_STATIC) { + if (verts->usage == GPU_USAGE_STATIC) { free(verts->data); verts->data = NULL; } verts->dirty = false; } -void GWN_vertbuf_use(Gwn_VertBuf* verts) +void GPU_vertbuf_use(GPUVertBuf* verts) { glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id); if (verts->dirty) { @@ -262,7 +262,7 @@ void GWN_vertbuf_use(Gwn_VertBuf* verts) } } -uint GWN_vertbuf_get_memory_usage(void) +uint GPU_vertbuf_get_memory_usage(void) { return vbo_memory_usage; } diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index bd9f9250564..d0a907bcd0d 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_vertex_format.c +/** \file blender/gpu/intern/gpu_vertex_format.c * \ingroup gpu * - * Gawain vertex format + * GPU vertex format */ #include "GPU_vertex_format.h" @@ -40,26 +40,26 @@ #include #endif -void GWN_vertformat_clear(Gwn_VertFormat* format) +void GPU_vertformat_clear(GPUVertFormat* format) { #if TRUST_NO_ONE - memset(format, 0, sizeof(Gwn_VertFormat)); + memset(format, 0, sizeof(GPUVertFormat)); #else format->attr_len = 0; format->packed = false; format->name_offset = 0; format->name_len = 0; - for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++) { + for (unsigned i = 0; i < GPU_VERT_ATTR_MAX_LEN; i++) { format->attribs[i].name_len = 0; } #endif } -void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) +void GPU_vertformat_copy(GPUVertFormat* dest, const GPUVertFormat* src) { /* copy regular struct fields */ - memcpy(dest, src, sizeof(Gwn_VertFormat)); + memcpy(dest, src, sizeof(GPUVertFormat)); for (unsigned i = 0; i < dest->attr_len; i++) { for (unsigned j = 0; j < dest->attribs[i].name_len; j++) { @@ -68,43 +68,43 @@ void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) } } -static GLenum convert_comp_type_to_gl(Gwn_VertCompType type) +static GLenum convert_comp_type_to_gl(GPUVertCompType type) { static const GLenum table[] = { - [GWN_COMP_I8] = GL_BYTE, - [GWN_COMP_U8] = GL_UNSIGNED_BYTE, - [GWN_COMP_I16] = GL_SHORT, - [GWN_COMP_U16] = GL_UNSIGNED_SHORT, - [GWN_COMP_I32] = GL_INT, - [GWN_COMP_U32] = GL_UNSIGNED_INT, + [GPU_COMP_I8] = GL_BYTE, + [GPU_COMP_U8] = GL_UNSIGNED_BYTE, + [GPU_COMP_I16] = GL_SHORT, + [GPU_COMP_U16] = GL_UNSIGNED_SHORT, + [GPU_COMP_I32] = GL_INT, + [GPU_COMP_U32] = GL_UNSIGNED_INT, - [GWN_COMP_F32] = GL_FLOAT, + [GPU_COMP_F32] = GL_FLOAT, - [GWN_COMP_I10] = GL_INT_2_10_10_10_REV + [GPU_COMP_I10] = GL_INT_2_10_10_10_REV }; return table[type]; } -static unsigned comp_sz(Gwn_VertCompType type) +static unsigned comp_sz(GPUVertCompType type) { #if TRUST_NO_ONE - assert(type <= GWN_COMP_F32); /* other types have irregular sizes (not bytes) */ + assert(type <= GPU_COMP_F32); /* other types have irregular sizes (not bytes) */ #endif const GLubyte sizes[] = {1,1,2,2,4,4,4}; return sizes[type]; } -static unsigned attrib_sz(const Gwn_VertAttr *a) +static unsigned attrib_sz(const GPUVertAttr *a) { - if (a->comp_type == GWN_COMP_I10) { + if (a->comp_type == GPU_COMP_I10) { return 4; /* always packed as 10_10_10_2 */ } return a->comp_len * comp_sz(a->comp_type); } -static unsigned attrib_align(const Gwn_VertAttr *a) +static unsigned attrib_align(const GPUVertAttr *a) { - if (a->comp_type == GWN_COMP_I10) { + if (a->comp_type == GPU_COMP_I10) { return 4; /* always packed as 10_10_10_2 */ } unsigned c = comp_sz(a->comp_type); @@ -116,7 +116,7 @@ static unsigned attrib_align(const Gwn_VertAttr *a) } } -unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) +unsigned vertex_buffer_size(const GPUVertFormat* format, unsigned vertex_len) { #if TRUST_NO_ONE assert(format->packed && format->stride > 0); @@ -124,11 +124,11 @@ unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) return format->stride * vertex_len; } -static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) +static const char* copy_attrib_name(GPUVertFormat* format, const char* name) { /* strncpy does 110% of what we need; let's do exactly 100% */ char* name_copy = format->names + format->name_offset; - unsigned available = GWN_VERT_ATTR_NAMES_BUF_LEN - format->name_offset; + unsigned available = GPU_VERT_ATTR_NAMES_BUF_LEN - format->name_offset; bool terminated = false; for (unsigned i = 0; i < available; ++i) { @@ -142,35 +142,35 @@ static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) } #if TRUST_NO_ONE assert(terminated); - assert(format->name_offset <= GWN_VERT_ATTR_NAMES_BUF_LEN); + assert(format->name_offset <= GPU_VERT_ATTR_NAMES_BUF_LEN); #else (void)terminated; #endif return name_copy; } -unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_len, Gwn_VertFetchMode fetch_mode) +unsigned GPU_vertformat_attr_add(GPUVertFormat* format, const char* name, GPUVertCompType comp_type, unsigned comp_len, GPUVertFetchMode fetch_mode) { #if TRUST_NO_ONE - assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ - assert(format->attr_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(format->attr_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */ assert(!format->packed); /* packed means frozen/locked */ assert((comp_len >= 1 && comp_len <= 4) || comp_len == 8 || comp_len == 12 || comp_len == 16); switch (comp_type) { - case GWN_COMP_F32: + case GPU_COMP_F32: /* float type can only kept as float */ - assert(fetch_mode == GWN_FETCH_FLOAT); + assert(fetch_mode == GPU_FETCH_FLOAT); break; - case GWN_COMP_I10: + case GPU_COMP_I10: /* 10_10_10 format intended for normals (xyz) or colors (rgb) * extra component packed.w can be manually set to { -2, -1, 0, 1 } */ assert(comp_len == 3 || comp_len == 4); - assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); /* not strictly required, may relax later */ + assert(fetch_mode == GPU_FETCH_INT_TO_FLOAT_UNIT); /* not strictly required, may relax later */ break; default: /* integer types can be kept as int or converted/normalized to float */ - assert(fetch_mode != GWN_FETCH_FLOAT); + assert(fetch_mode != GPU_FETCH_FLOAT); /* only support float matrices (see Batch_update_program_bindings) */ assert(comp_len != 8 && comp_len != 12 && comp_len != 16); } @@ -178,12 +178,12 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V format->name_len++; /* multiname support */ const unsigned attrib_id = format->attr_len++; - Gwn_VertAttr* attrib = format->attribs + attrib_id; + GPUVertAttr* attrib = format->attribs + attrib_id; attrib->name[attrib->name_len++] = copy_attrib_name(format, name); attrib->comp_type = comp_type; attrib->gl_comp_type = convert_comp_type_to_gl(comp_type); - attrib->comp_len = (comp_type == GWN_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */ + attrib->comp_len = (comp_type == GPU_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */ attrib->sz = attrib_sz(attrib); attrib->offset = 0; /* offsets & stride are calculated later (during pack) */ attrib->fetch_mode = fetch_mode; @@ -191,12 +191,12 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V return attrib_id; } -void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias) +void GPU_vertformat_alias_add(GPUVertFormat* format, const char* alias) { - Gwn_VertAttr* attrib = format->attribs + (format->attr_len - 1); + GPUVertAttr* attrib = format->attribs + (format->attr_len - 1); #if TRUST_NO_ONE - assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ - assert(attrib->name_len < GWN_VERT_ATTR_MAX_NAMES); + assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(attrib->name_len < GPU_VERT_ATTR_MAX_NAMES); #endif format->name_len++; /* multiname support */ attrib->name[attrib->name_len++] = copy_attrib_name(format, alias); @@ -221,7 +221,7 @@ static void show_pack(unsigned a_idx, unsigned sz, unsigned pad) } #endif -void VertexFormat_pack(Gwn_VertFormat* format) +void VertexFormat_pack(GPUVertFormat* format) { /* For now, attributes are packed in the order they were added, * making sure each attrib is naturally aligned (add padding where necessary) @@ -231,7 +231,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) /* TODO: realloc just enough to hold the final combo string. And just enough to * hold used attribs, not all 16. */ - Gwn_VertAttr* a0 = format->attribs + 0; + GPUVertAttr* a0 = format->attribs + 0; a0->offset = 0; unsigned offset = a0->sz; @@ -240,7 +240,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) #endif for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) { - Gwn_VertAttr* a = format->attribs + a_idx; + GPUVertAttr* a = format->attribs + a_idx; unsigned mid_padding = padding(offset, attrib_align(a)); offset += mid_padding; a->offset = offset; @@ -263,7 +263,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) /* OpenGL ES packs in a different order as desktop GL but component conversion is the same. - * Of the code here, only struct Gwn_PackedNormal needs to change. */ + * Of the code here, only struct GPUPackedNormal needs to change. */ #define SIGNED_INT_10_MAX 511 #define SIGNED_INT_10_MIN -512 @@ -297,14 +297,14 @@ static int convert_i16(short x) return x >> 6; } -Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]) +GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3]) { - Gwn_PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) }; + GPUPackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) }; return n; } -Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]) +GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3]) { - Gwn_PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) }; + GPUPackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) }; return n; } diff --git a/source/blender/gpu/intern/gpu_vertex_format_private.h b/source/blender/gpu/intern/gpu_vertex_format_private.h index 3cae9969fd8..4ce3ebba714 100644 --- a/source/blender/gpu/intern/gpu_vertex_format_private.h +++ b/source/blender/gpu/intern/gpu_vertex_format_private.h @@ -23,17 +23,17 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_format_private.h +/** \file blender/gpu/intern/gpu_vertex_format_private.h * \ingroup gpu * - * Gawain vertex format + * GPU vertex format */ -#ifndef __GWN_VERTEX_FORMAT_PRIVATE_H__ -#define __GWN_VERTEX_FORMAT_PRIVATE_H__ +#ifndef __GPU_VERTEX_FORMAT_PRIVATE_H__ +#define __GPU_VERTEX_FORMAT_PRIVATE_H__ -void VertexFormat_pack(Gwn_VertFormat*); +void VertexFormat_pack(GPUVertFormat*); uint padding(uint offset, uint alignment); -uint vertex_buffer_size(const Gwn_VertFormat*, uint vertex_len); +uint vertex_buffer_size(const GPUVertFormat*, uint vertex_len); -#endif /* __GWN_VERTEX_FORMAT_PRIVATE_H__ */ +#endif /* __GPU_VERTEX_FORMAT_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 0bf215f31a8..5d495779ba1 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -539,9 +539,9 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect) glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), halfx, halfy, 1.0f + halfx, 1.0f + halfy); glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x1, y1, x2, y2); - glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), 1.0f, 1.0f, 1.0f, 1.0f); + glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), 1.0f, 1.0f, 1.0f, 1.0f); - GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4); + GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); GPU_texture_unbind(color); } diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 0546dcb1a6c..55e1a43925d 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -82,9 +82,9 @@ typedef struct bMotionPath { int flag; /* baking settings - eMotionPath_Flag */ /* Used for drawing. */ - struct Gwn_VertBuf *points_vbo; - struct Gwn_Batch *batch_line; - struct Gwn_Batch *batch_points; + struct GPUVertBuf *points_vbo; + struct GPUBatch *batch_line; + struct GPUBatch *batch_points; void *pad; } bMotionPath; diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 80ad3840a8f..25d9e50ff7a 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -184,7 +184,7 @@ typedef struct wmWindow { struct wmWindow *next, *prev; void *ghostwin; /* don't want to include ghost.h stuff */ - void *gwnctx; /* don't want to include gawin stuff */ + void *gpuctx; /* don't want to include gpu stuff */ struct wmWindow *parent; /* Parent window */ diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt index 8d26fee0abd..030576fefd1 100644 --- a/source/blender/python/CMakeLists.txt +++ b/source/blender/python/CMakeLists.txt @@ -17,7 +17,7 @@ # ***** END GPL LICENSE BLOCK ***** add_subdirectory(intern) -add_subdirectory(gawain) add_subdirectory(generic) +add_subdirectory(gpu) add_subdirectory(mathutils) add_subdirectory(bmesh) diff --git a/source/blender/python/gawain/CMakeLists.txt b/source/blender/python/gawain/CMakeLists.txt deleted file mode 100644 index 9eab323a0fe..00000000000 --- a/source/blender/python/gawain/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributor(s): Campbell Barton -# -# ***** END GPL LICENSE BLOCK ***** - -set(INC - . - ../../blenkernel - ../../blenlib - ../../gpu - ../../makesdna - ../../../../intern/gawain - ../../../../intern/guardedalloc - ../../../../intern/glew-mx -) - -set(INC_SYS - ${GLEW_INCLUDE_PATH} - ${PYTHON_INCLUDE_DIRS} -) - -set(SRC - gwn_py_api.c - gwn_py_types.c - - gwn_py_api.h - gwn_py_types.h -) - -add_definitions(${GL_DEFINITIONS}) - -blender_add_lib(bf_python_gawain "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/python/gawain/gwn_py_api.c b/source/blender/python/gawain/gwn_py_api.c deleted file mode 100644 index 1f7a1297448..00000000000 --- a/source/blender/python/gawain/gwn_py_api.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/gawain/gwn_py_api.c - * \ingroup pygawain - * - * Experimental Python API, not considered public yet (called '_gawain'), - * we may re-expose as public later. - */ - -#include - -#include "GPU_batch.h" -#include "GPU_vertex_format.h" - -#include "gwn_py_api.h" -#include "gwn_py_types.h" - -#include "BLI_utildefines.h" - -#include "../generic/python_utildefines.h" - -PyDoc_STRVAR(GWN_doc, -"This module provides access to gawain drawing functions." -); -static struct PyModuleDef GWN_module_def = { - PyModuleDef_HEAD_INIT, - .m_name = "_gawain", /* m_name */ - .m_doc = GWN_doc, /* m_doc */ -}; - -PyObject *BPyInit_gawain(void) -{ - PyObject *sys_modules = PyThreadState_GET()->interp->modules; - PyObject *submodule; - PyObject *mod; - - mod = PyModule_Create(&GWN_module_def); - - /* _gawain.types */ - PyModule_AddObject(mod, "types", (submodule = BPyInit_gawain_types())); - PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); - Py_INCREF(submodule); - - return mod; -} diff --git a/source/blender/python/gawain/gwn_py_api.h b/source/blender/python/gawain/gwn_py_api.h deleted file mode 100644 index 3ef85e8ae0f..00000000000 --- a/source/blender/python/gawain/gwn_py_api.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __GWN_PY_API_H__ -#define __GWN_PY_API_H__ - -/** \file blender/python/gawain/gwn_py_api.h - * \ingroup pygawain - */ - -PyObject *BPyInit_gawain(void); - -#endif /* __GWN_PY_API_H__ */ diff --git a/source/blender/python/gawain/gwn_py_types.c b/source/blender/python/gawain/gwn_py_types.c deleted file mode 100644 index 04c50ac0784..00000000000 --- a/source/blender/python/gawain/gwn_py_types.c +++ /dev/null @@ -1,847 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/gawain/gwn_py_types.c - * \ingroup pygawain - * - * - Use ``bpygwn_`` for local API. - * - Use ``BPyGwn_`` for public API. - */ - -#include - -#include "GPU_batch.h" -#include "GPU_vertex_format.h" - -#include "BLI_math.h" - -#include "GPU_batch.h" - -#include "MEM_guardedalloc.h" - -#include "../generic/py_capi_utils.h" -#include "../generic/python_utildefines.h" - -#include "gwn_py_types.h" /* own include */ - -#ifdef __BIG_ENDIAN__ - /* big endian */ -# define MAKE_ID2(c, d) ((c) << 8 | (d)) -# define MAKE_ID3(a, b, c) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 ) -# define MAKE_ID4(a, b, c, d) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d) ) -#else - /* little endian */ -# define MAKE_ID2(c, d) ((d) << 8 | (c)) -# define MAKE_ID3(a, b, c) ( (int)(c) << 16 | (b) << 8 | (a) ) -# define MAKE_ID4(a, b, c, d) ( (int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a) ) -#endif - -/* -------------------------------------------------------------------- */ - -/** \name Enum Conversion - * - * Use with PyArg_ParseTuple's "O&" formatting. - * \{ */ - -static int bpygwn_ParseVertCompType(PyObject *o, void *p) -{ - Py_ssize_t comp_type_id_len; - const char *comp_type_id = _PyUnicode_AsStringAndSize(o, &comp_type_id_len); - if (comp_type_id == NULL) { - PyErr_Format(PyExc_ValueError, - "expected a string, got %s", - Py_TYPE(o)->tp_name); - return 0; - } - - Gwn_VertCompType comp_type; - if (comp_type_id_len == 2) { - switch (*((ushort *)comp_type_id)) { - case MAKE_ID2('I', '8'): { comp_type = GWN_COMP_I8; goto success; } - case MAKE_ID2('U', '8'): { comp_type = GWN_COMP_U8; goto success; } - } - } - else if (comp_type_id_len == 3) { - switch (*((uint *)comp_type_id)) { - case MAKE_ID3('I', '1', '6'): { comp_type = GWN_COMP_I16; goto success; } - case MAKE_ID3('U', '1', '6'): { comp_type = GWN_COMP_U16; goto success; } - case MAKE_ID3('I', '3', '2'): { comp_type = GWN_COMP_I32; goto success; } - case MAKE_ID3('U', '3', '2'): { comp_type = GWN_COMP_U32; goto success; } - case MAKE_ID3('F', '3', '2'): { comp_type = GWN_COMP_F32; goto success; } - case MAKE_ID3('I', '1', '0'): { comp_type = GWN_COMP_I10; goto success; } - } - } - - PyErr_Format(PyExc_ValueError, - "unknown type literal: '%s'", - comp_type_id); - return 0; - -success: - *((Gwn_VertCompType *)p) = comp_type; - return 1; -} - -static int bpygwn_ParseVertFetchMode(PyObject *o, void *p) -{ - Py_ssize_t mode_id_len; - const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len); - if (mode_id == NULL) { - PyErr_Format(PyExc_ValueError, - "expected a string, got %s", - Py_TYPE(o)->tp_name); - return 0; - } -#define MATCH_ID(id) \ - if (mode_id_len == strlen(STRINGIFY(id))) { \ - if (STREQ(mode_id, STRINGIFY(id))) { \ - mode = GWN_FETCH_##id; \ - goto success; \ - } \ - } ((void)0) - - Gwn_VertFetchMode mode; - MATCH_ID(FLOAT); - MATCH_ID(INT); - MATCH_ID(INT_TO_FLOAT_UNIT); - MATCH_ID(INT_TO_FLOAT); -#undef MATCH_ID - PyErr_Format(PyExc_ValueError, - "unknown type literal: '%s'", - mode_id); - return 0; - -success: - (*(Gwn_VertFetchMode *)p) = mode; - return 1; -} - -static int bpygwn_ParsePrimType(PyObject *o, void *p) -{ - Py_ssize_t mode_id_len; - const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len); - if (mode_id == NULL) { - PyErr_Format(PyExc_ValueError, - "expected a string, got %s", - Py_TYPE(o)->tp_name); - return 0; - } -#define MATCH_ID(id) \ - if (mode_id_len == strlen(STRINGIFY(id))) { \ - if (STREQ(mode_id, STRINGIFY(id))) { \ - mode = GWN_PRIM_##id; \ - goto success; \ - } \ - } ((void)0) - - Gwn_PrimType mode; - MATCH_ID(POINTS); - MATCH_ID(LINES); - MATCH_ID(TRIS); - MATCH_ID(LINE_STRIP); - MATCH_ID(LINE_LOOP); - MATCH_ID(TRI_STRIP); - MATCH_ID(TRI_FAN); - MATCH_ID(LINE_STRIP_ADJ); - -#undef MATCH_ID - PyErr_Format(PyExc_ValueError, - "unknown type literal: '%s'", - mode_id); - return 0; - -success: - (*(Gwn_PrimType *)p) = mode; - return 1; -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Utility Functions - * \{ */ - -#define PY_AS_NATIVE_SWITCH(attr) \ - switch (attr->comp_type) { \ - case GWN_COMP_I8: { PY_AS_NATIVE(int8_t, PyC_Long_AsI8); break; } \ - case GWN_COMP_U8: { PY_AS_NATIVE(uint8_t, PyC_Long_AsU8); break; } \ - case GWN_COMP_I16: { PY_AS_NATIVE(int16_t, PyC_Long_AsI16); break; } \ - case GWN_COMP_U16: { PY_AS_NATIVE(uint16_t, PyC_Long_AsU16); break; } \ - case GWN_COMP_I32: { PY_AS_NATIVE(int32_t, PyC_Long_AsI32); break; } \ - case GWN_COMP_U32: { PY_AS_NATIVE(uint32_t, PyC_Long_AsU32); break; } \ - case GWN_COMP_F32: { PY_AS_NATIVE(float, PyFloat_AsDouble); break; } \ - default: \ - BLI_assert(0); \ - } ((void)0) - -/* No error checking, callers must run PyErr_Occurred */ -static void fill_format_elem(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr) -{ -#define PY_AS_NATIVE(ty_dst, py_as_native) \ -{ \ - ty_dst *data_dst = data_dst_void; \ - *data_dst = py_as_native(py_src); \ -} ((void)0) - - PY_AS_NATIVE_SWITCH(attr); - -#undef PY_AS_NATIVE -} - -/* No error checking, callers must run PyErr_Occurred */ -static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr) -{ - const uint len = attr->comp_len; - -/** - * Args are constants, so range checks will be optimized out if they're nop's. - */ -#define PY_AS_NATIVE(ty_dst, py_as_native) \ - ty_dst *data_dst = data_dst_void; \ - for (uint i = 0; i < len; i++) { \ - data_dst[i] = py_as_native(PyTuple_GET_ITEM(py_src, i)); \ - } ((void)0) - - PY_AS_NATIVE_SWITCH(attr); - -#undef PY_AS_NATIVE -} - -#undef PY_AS_NATIVE_SWITCH -#undef WARN_TYPE_LIMIT_PUSH -#undef WARN_TYPE_LIMIT_POP - -static bool bpygwn_vertbuf_fill_impl( - Gwn_VertBuf *vbo, - uint data_id, PyObject *seq) -{ - bool ok = true; - const Gwn_VertAttr *attr = &vbo->format.attribs[data_id]; - - Gwn_VertBufRaw data_step; - GWN_vertbuf_attr_get_raw_data(vbo, data_id, &data_step); - - PyObject *seq_fast = PySequence_Fast(seq, "Vertex buffer fill"); - if (seq_fast == NULL) { - goto finally; - } - - const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast); - - if (seq_len != vbo->vertex_len) { - PyErr_Format(PyExc_ValueError, - "Expected a sequence of size %d, got %d", - vbo->vertex_len, seq_len); - } - - PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast); - - if (attr->comp_len == 1) { - for (uint i = 0; i < seq_len; i++) { - uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step); - PyObject *item = seq_items[i]; - fill_format_elem(data, item, attr); - } - } - else { - for (uint i = 0; i < seq_len; i++) { - uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step); - PyObject *item = seq_items[i]; - if (!PyTuple_CheckExact(item)) { - PyErr_Format(PyExc_ValueError, - "expected a tuple, got %s", - Py_TYPE(item)->tp_name); - ok = false; - goto finally; - } - if (PyTuple_GET_SIZE(item) != attr->comp_len) { - PyErr_Format(PyExc_ValueError, - "expected a tuple of size %d, got %d", - attr->comp_len, PyTuple_GET_SIZE(item)); - ok = false; - goto finally; - } - - /* May trigger error, check below */ - fill_format_tuple(data, item, attr); - } - } - - if (PyErr_Occurred()) { - ok = false; - } - -finally: - - Py_DECREF(seq_fast); - return ok; -} - -/* handy, but not used just now */ -#if 0 -static int bpygwn_find_id(const Gwn_VertFormat *fmt, const char *id) -{ - for (int i = 0; i < fmt->attr_len; i++) { - for (uint j = 0; j < fmt->name_len; j++) { - if (STREQ(fmt->attribs[i].name[j], id)) { - return i; - } - } - } - return -1; -} -#endif - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name VertFormat Type - * \{ */ - -static PyObject *bpygwn_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) -{ - if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) { - PyErr_SetString(PyExc_TypeError, - "VertFormat(): takes no arguments"); - return NULL; - } - - BPyGwn_VertFormat *ret = (BPyGwn_VertFormat *)BPyGwn_VertFormat_CreatePyObject(NULL); - - return (PyObject *)ret; -} - -PyDoc_STRVAR(bpygwn_VertFormat_attr_add_doc, -"TODO" -); -static PyObject *bpygwn_VertFormat_attr_add(BPyGwn_VertFormat *self, PyObject *args, PyObject *kwds) -{ - static const char *kwlist[] = {"id", "comp_type", "len", "fetch_mode", NULL}; - - struct { - const char *id; - Gwn_VertCompType comp_type; - uint len; - Gwn_VertFetchMode fetch_mode; - } params; - - if (self->fmt.attr_len == GWN_VERT_ATTR_MAX_LEN) { - PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GWN_VERT_ATTR_MAX_LEN)); - return NULL; - } - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "$sO&IO&:attr_add", (char **)kwlist, - ¶ms.id, - bpygwn_ParseVertCompType, ¶ms.comp_type, - ¶ms.len, - bpygwn_ParseVertFetchMode, ¶ms.fetch_mode)) - { - return NULL; - } - - uint attr_id = GWN_vertformat_attr_add(&self->fmt, params.id, params.comp_type, params.len, params.fetch_mode); - return PyLong_FromLong(attr_id); -} - -static struct PyMethodDef bpygwn_VertFormat_methods[] = { - {"attr_add", (PyCFunction)bpygwn_VertFormat_attr_add, - METH_VARARGS | METH_KEYWORDS, bpygwn_VertFormat_attr_add_doc}, - {NULL, NULL, 0, NULL} -}; - - -static void bpygwn_VertFormat_dealloc(BPyGwn_VertFormat *self) -{ - Py_TYPE(self)->tp_free(self); -} - -PyTypeObject BPyGwn_VertFormat_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "Gwn_VertFormat", - .tp_basicsize = sizeof(BPyGwn_VertFormat), - .tp_dealloc = (destructor)bpygwn_VertFormat_dealloc, - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_methods = bpygwn_VertFormat_methods, - .tp_new = bpygwn_VertFormat_new, -}; - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name VertBuf Type - * \{ */ - -static PyObject *bpygwn_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) -{ - const char * const keywords[] = {"len", "format", NULL}; - - struct { - BPyGwn_VertFormat *py_fmt; - uint len; - } params; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, - "$IO!:Gwn_VertBuf.__new__", (char **)keywords, - ¶ms.len, - &BPyGwn_VertFormat_Type, ¶ms.py_fmt)) - { - return NULL; - } - - struct Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(¶ms.py_fmt->fmt); - - GWN_vertbuf_data_alloc(vbo, params.len); - - return BPyGwn_VertBuf_CreatePyObject(vbo); -} - -PyDoc_STRVAR(bpygwn_VertBuf_fill_doc, -"TODO" -); -static PyObject *bpygwn_VertBuf_fill(BPyGwn_VertBuf *self, PyObject *args, PyObject *kwds) -{ - static const char *kwlist[] = {"id", "data", NULL}; - - struct { - uint id; - PyObject *py_seq_data; - } params; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "$IO:fill", (char **)kwlist, - ¶ms.id, - ¶ms.py_seq_data)) - { - return NULL; - } - - if (params.id >= self->buf->format.attr_len) { - PyErr_Format(PyExc_ValueError, - "Format id %d out of range", - params.id); - return NULL; - } - - if (self->buf->data == NULL) { - PyErr_SetString(PyExc_ValueError, - "Can't fill, static buffer already in use"); - return NULL; - } - - if (!bpygwn_vertbuf_fill_impl(self->buf, params.id, params.py_seq_data)) { - return NULL; - } - Py_RETURN_NONE; -} - -static struct PyMethodDef bpygwn_VertBuf_methods[] = { - {"fill", (PyCFunction) bpygwn_VertBuf_fill, - METH_VARARGS | METH_KEYWORDS, bpygwn_VertBuf_fill_doc}, - {NULL, NULL, 0, NULL} -}; - -static void bpygwn_VertBuf_dealloc(BPyGwn_VertBuf *self) -{ - GWN_vertbuf_discard(self->buf); - Py_TYPE(self)->tp_free(self); -} - -PyTypeObject BPyGwn_VertBuf_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "Gwn_VertBuf", - .tp_basicsize = sizeof(BPyGwn_VertBuf), - .tp_dealloc = (destructor)bpygwn_VertBuf_dealloc, - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_methods = bpygwn_VertBuf_methods, - .tp_new = bpygwn_VertBuf_new, -}; - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name VertBatch Type - * \{ */ - -static PyObject *bpygwn_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) -{ - const char * const keywords[] = {"type", "buf", NULL}; - - struct { - Gwn_PrimType type_id; - BPyGwn_VertBuf *py_buf; - } params; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, - "$O&O!:Gwn_Batch.__new__", (char **)keywords, - bpygwn_ParsePrimType, ¶ms.type_id, - &BPyGwn_VertBuf_Type, ¶ms.py_buf)) - { - return NULL; - } - - Gwn_Batch *batch = GWN_batch_create(params.type_id, params.py_buf->buf, NULL); - BPyGwn_Batch *ret = (BPyGwn_Batch *)BPyGwn_Batch_CreatePyObject(batch); - -#ifdef USE_GWN_PY_REFERENCES - ret->references = PyList_New(1); - PyList_SET_ITEM(ret->references, 0, (PyObject *)params.py_buf); - Py_INCREF(params.py_buf); - PyObject_GC_Track(ret); -#endif - - return (PyObject *)ret; -} - -PyDoc_STRVAR(bpygwn_VertBatch_vertbuf_add_doc, -"TODO" -); -static PyObject *bpygwn_VertBatch_vertbuf_add(BPyGwn_Batch *self, BPyGwn_VertBuf *py_buf) -{ - if (!BPyGwn_VertBuf_Check(py_buf)) { - PyErr_Format(PyExc_TypeError, - "Expected a Gwn_VertBuf, got %s", - Py_TYPE(py_buf)->tp_name); - return NULL; - } - - if (self->batch->verts[0]->vertex_len != py_buf->buf->vertex_len) { - PyErr_Format(PyExc_TypeError, - "Expected %d length, got %d", - self->batch->verts[0]->vertex_len, py_buf->buf->vertex_len); - return NULL; - } - -#ifdef USE_GWN_PY_REFERENCES - /* Hold user */ - PyList_Append(self->references, (PyObject *)py_buf); -#endif - - GWN_batch_vertbuf_add(self->batch, py_buf->buf); - Py_RETURN_NONE; -} - -/* Currently magic number from Py perspective. */ -PyDoc_STRVAR(bpygwn_VertBatch_program_set_builtin_doc, -"TODO" -); -static PyObject *bpygwn_VertBatch_program_set_builtin(BPyGwn_Batch *self, PyObject *args, PyObject *kwds) -{ - static const char *kwlist[] = {"id", NULL}; - - struct { - const char *shader; - } params; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "s:program_set_builtin", (char **)kwlist, - ¶ms.shader)) - { - return NULL; - } - - GPUBuiltinShader shader; - -#define MATCH_ID(id) \ - if (STREQ(params.shader, STRINGIFY(id))) { \ - shader = GPU_SHADER_##id; \ - goto success; \ - } ((void)0) - - MATCH_ID(2D_FLAT_COLOR); - MATCH_ID(2D_SMOOTH_COLOR); - MATCH_ID(2D_UNIFORM_COLOR); - - MATCH_ID(3D_FLAT_COLOR); - MATCH_ID(3D_SMOOTH_COLOR); - MATCH_ID(3D_UNIFORM_COLOR); - -#undef MATCH_ID - - PyErr_SetString(PyExc_ValueError, - "shader name not known"); - return NULL; - -success: - GWN_batch_program_set_builtin(self->batch, shader); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_uniform_bool(BPyGwn_Batch *self, PyObject *args) -{ - struct { - const char *id; - bool values[1]; - } params; - - if (!PyArg_ParseTuple( - args, "sO&:uniform_bool", - ¶ms.id, - PyC_ParseBool, ¶ms.values[0])) - { - return NULL; - } - - GWN_batch_uniform_1b(self->batch, params.id, params.values[0]); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_uniform_i32(BPyGwn_Batch *self, PyObject *args) -{ - struct { - const char *id; - int values[1]; - } params; - - if (!PyArg_ParseTuple( - args, "si:uniform_i32", - ¶ms.id, - ¶ms.values[0])) - { - return NULL; - } - - GWN_batch_uniform_1i(self->batch, params.id, params.values[0]); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args) -{ - struct { - const char *id; - float values[4]; - } params; - - if (!PyArg_ParseTuple( - args, "sf|fff:uniform_f32", - ¶ms.id, - ¶ms.values[0], ¶ms.values[1], ¶ms.values[2], ¶ms.values[3])) - { - return NULL; - } - - switch (PyTuple_GET_SIZE(args)) { - case 2: GWN_batch_uniform_1f(self->batch, params.id, params.values[0]); break; - case 3: GWN_batch_uniform_2f(self->batch, params.id, UNPACK2(params.values)); break; - case 4: GWN_batch_uniform_3f(self->batch, params.id, UNPACK3(params.values)); break; - case 5: GWN_batch_uniform_4f(self->batch, params.id, UNPACK4(params.values)); break; - default: - BLI_assert(0); - } - Py_RETURN_NONE; -} - -PyDoc_STRVAR(bpygwn_VertBatch_draw_doc, -"TODO" -); -static PyObject *bpygwn_VertBatch_draw(BPyGwn_Batch *self) -{ - if (!glIsProgram(self->batch->program)) { - PyErr_SetString(PyExc_ValueError, - "batch program has not not set"); - } - GWN_batch_draw(self->batch); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_program_use_begin(BPyGwn_Batch *self) -{ - if (!glIsProgram(self->batch->program)) { - PyErr_SetString(PyExc_ValueError, - "batch program has not not set"); - } - GWN_batch_program_use_begin(self->batch); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_program_use_end(BPyGwn_Batch *self) -{ - if (!glIsProgram(self->batch->program)) { - PyErr_SetString(PyExc_ValueError, - "batch program has not not set"); - } - GWN_batch_program_use_end(self->batch); - Py_RETURN_NONE; -} - -static struct PyMethodDef bpygwn_VertBatch_methods[] = { - {"vertbuf_add", (PyCFunction)bpygwn_VertBatch_vertbuf_add, - METH_O, bpygwn_VertBatch_vertbuf_add_doc}, - {"program_set_builtin", (PyCFunction)bpygwn_VertBatch_program_set_builtin, - METH_VARARGS | METH_KEYWORDS, bpygwn_VertBatch_program_set_builtin_doc}, - {"uniform_bool", (PyCFunction)bpygwn_VertBatch_uniform_bool, - METH_VARARGS, NULL}, - {"uniform_i32", (PyCFunction)bpygwn_VertBatch_uniform_i32, - METH_VARARGS, NULL}, - {"uniform_f32", (PyCFunction)bpygwn_VertBatch_uniform_f32, - METH_VARARGS, NULL}, - {"draw", (PyCFunction) bpygwn_VertBatch_draw, - METH_NOARGS, bpygwn_VertBatch_draw_doc}, - {"program_use_begin", (PyCFunction)bpygwn_VertBatch_program_use_begin, - METH_NOARGS, ""}, - {"program_use_end", (PyCFunction)bpygwn_VertBatch_program_use_end, - METH_NOARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -#ifdef USE_GWN_PY_REFERENCES - -static int bpygwn_Batch_traverse(BPyGwn_Batch *self, visitproc visit, void *arg) -{ - Py_VISIT(self->references); - return 0; -} - -static int bpygwn_Batch_clear(BPyGwn_Batch *self) -{ - Py_CLEAR(self->references); - return 0; -} - -#endif - -static void bpygwn_Batch_dealloc(BPyGwn_Batch *self) -{ - GWN_batch_discard(self->batch); - -#ifdef USE_GWN_PY_REFERENCES - if (self->references) { - PyObject_GC_UnTrack(self); - bpygwn_Batch_clear(self); - Py_XDECREF(self->references); - } -#endif - - Py_TYPE(self)->tp_free(self); -} - -PyTypeObject BPyGwn_Batch_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "Gwn_Batch", - .tp_basicsize = sizeof(BPyGwn_Batch), - .tp_dealloc = (destructor)bpygwn_Batch_dealloc, -#ifdef USE_GWN_PY_REFERENCES - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, - .tp_traverse = (traverseproc)bpygwn_Batch_traverse, - .tp_clear = (inquiry)bpygwn_Batch_clear, -#else - .tp_flags = Py_TPFLAGS_DEFAULT, -#endif - .tp_methods = bpygwn_VertBatch_methods, - .tp_new = bpygwn_Batch_new, -}; - -/* -------------------------------------------------------------------- */ - - -/** \name Gawain Types Module - * \{ */ - -static struct PyModuleDef BPy_BM_types_module_def = { - PyModuleDef_HEAD_INIT, - .m_name = "_gawain.types", -}; - -PyObject *BPyInit_gawain_types(void) -{ - PyObject *submodule; - - submodule = PyModule_Create(&BPy_BM_types_module_def); - - if (PyType_Ready(&BPyGwn_VertFormat_Type) < 0) - return NULL; - if (PyType_Ready(&BPyGwn_VertBuf_Type) < 0) - return NULL; - if (PyType_Ready(&BPyGwn_Batch_Type) < 0) - return NULL; - -#define MODULE_TYPE_ADD(s, t) \ - PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t) - - MODULE_TYPE_ADD(submodule, BPyGwn_VertFormat_Type); - MODULE_TYPE_ADD(submodule, BPyGwn_VertBuf_Type); - MODULE_TYPE_ADD(submodule, BPyGwn_Batch_Type); - -#undef MODULE_TYPE_ADD - - return submodule; -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Public API - * \{ */ - -PyObject *BPyGwn_VertFormat_CreatePyObject(Gwn_VertFormat *fmt) -{ - BPyGwn_VertFormat *self; - - self = PyObject_New(BPyGwn_VertFormat, &BPyGwn_VertFormat_Type); - if (fmt) { - self->fmt = *fmt; - } - else { - memset(&self->fmt, 0, sizeof(self->fmt)); - } - - return (PyObject *)self; -} - -PyObject *BPyGwn_VertBuf_CreatePyObject(Gwn_VertBuf *buf) -{ - BPyGwn_VertBuf *self; - - self = PyObject_New(BPyGwn_VertBuf, &BPyGwn_VertBuf_Type); - self->buf = buf; - - return (PyObject *)self; -} - - -PyObject *BPyGwn_Batch_CreatePyObject(Gwn_Batch *batch) -{ - BPyGwn_Batch *self; - -#ifdef USE_GWN_PY_REFERENCES - self = (BPyGwn_Batch *)_PyObject_GC_New(&BPyGwn_Batch_Type); - self->references = NULL; -#else - self = PyObject_New(BPyGwn_Batch, &BPyGwn_Batch_Type); -#endif - - self->batch = batch; - - return (PyObject *)self; -} - -/** \} */ diff --git a/source/blender/python/gawain/gwn_py_types.h b/source/blender/python/gawain/gwn_py_types.h deleted file mode 100644 index dde6cf98827..00000000000 --- a/source/blender/python/gawain/gwn_py_types.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/gawain/gwn_py_types.h - * \ingroup pygawain - */ - -#ifndef __GWN_PY_TYPES_H__ -#define __GWN_PY_TYPES_H__ - -#include "BLI_compiler_attrs.h" - -#define USE_GWN_PY_REFERENCES - -extern PyTypeObject BPyGwn_VertFormat_Type; -extern PyTypeObject BPyGwn_VertBuf_Type; -extern PyTypeObject BPyGwn_Batch_Type; - -#define BPyGwn_VertFormat_Check(v) (Py_TYPE(v) == &BPyGwn_VertFormat_Type) -#define BPyGwn_VertBuf_Check(v) (Py_TYPE(v) == &BPyGwn_VertBuf_Type) -#define BPyGwn_Batch_Check(v) (Py_TYPE(v) == &BPyGwn_Batch_Type) - -typedef struct BPyGwn_VertFormat { - PyObject_VAR_HEAD - struct Gwn_VertFormat fmt; -} BPyGwn_VertFormat; - -typedef struct BPyGwn_VertBuf { - PyObject_VAR_HEAD - /* The buf is owned, we may support thin wrapped batches later. */ - struct Gwn_VertBuf *buf; -} BPyGwn_VertBuf; - -typedef struct BPyGwn_Batch { - PyObject_VAR_HEAD - /* The batch is owned, we may support thin wrapped batches later. */ - struct Gwn_Batch *batch; -#ifdef USE_GWN_PY_REFERENCES - /* Just to keep a user to prevent freeing buf's we're using */ - PyObject *references; -#endif -} BPyGwn_Batch; - -PyObject *BPyInit_gawain_types(void); - -PyObject *BPyGwn_VertFormat_CreatePyObject(struct Gwn_VertFormat *fmt); -PyObject *BPyGwn_VertBuf_CreatePyObject(struct Gwn_VertBuf *vbo) ATTR_NONNULL(1); -PyObject *BPyGwn_Batch_CreatePyObject(struct Gwn_Batch *batch) ATTR_NONNULL(1); - -#endif /* __GWN_PY_TYPES_H__ */ diff --git a/source/blender/python/gpu/CMakeLists.txt b/source/blender/python/gpu/CMakeLists.txt new file mode 100644 index 00000000000..141a36bbcc2 --- /dev/null +++ b/source/blender/python/gpu/CMakeLists.txt @@ -0,0 +1,46 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Campbell Barton +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + . + ../../blenkernel + ../../blenlib + ../../gpu + ../../makesdna + ../../../../intern/guardedalloc + ../../../../intern/glew-mx +) + +set(INC_SYS + ${GLEW_INCLUDE_PATH} + ${PYTHON_INCLUDE_DIRS} +) + +set(SRC + gpu_py_api.c + gpu_py_types.c + + gpu_py_api.h + gpu_py_types.h +) + +add_definitions(${GL_DEFINITIONS}) + +blender_add_lib(bf_python_gpu "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c new file mode 100644 index 00000000000..53285b372d8 --- /dev/null +++ b/source/blender/python/gpu/gpu_py_api.c @@ -0,0 +1,63 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/gpu/gpu_py_api.c + * \ingroup pygpu + * + * Experimental Python API, not considered public yet (called '_gpu'), + * we may re-expose as public later. + */ + +#include + +#include "GPU_batch.h" +#include "GPU_vertex_format.h" + +#include "gpu_py_api.h" +#include "gpu_py_types.h" + +#include "BLI_utildefines.h" + +#include "../generic/python_utildefines.h" + +PyDoc_STRVAR(GPU_doc, +"This module provides access to gpu drawing functions." +); +static struct PyModuleDef GPU_module_def = { + PyModuleDef_HEAD_INIT, + .m_name = "_gpu", /* m_name */ + .m_doc = GPU_doc, /* m_doc */ +}; + +PyObject *BPyInit_gpu(void) +{ + PyObject *sys_modules = PyThreadState_GET()->interp->modules; + PyObject *submodule; + PyObject *mod; + + mod = PyModule_Create(&GPU_module_def); + + /* _gpu.types */ + PyModule_AddObject(mod, "types", (submodule = BPyInit_gpu_types())); + PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); + Py_INCREF(submodule); + + return mod; +} diff --git a/source/blender/python/gpu/gpu_py_api.h b/source/blender/python/gpu/gpu_py_api.h new file mode 100644 index 00000000000..387bfcab950 --- /dev/null +++ b/source/blender/python/gpu/gpu_py_api.h @@ -0,0 +1,30 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __GPU_PY_API_H__ +#define __GPU_PY_API_H__ + +/** \file blender/python/gpu/gpu_py_api.h + * \ingroup pygpu + */ + +PyObject *BPyInit_gpu(void); + +#endif /* __GPU_PY_API_H__ */ diff --git a/source/blender/python/gpu/gpu_py_types.c b/source/blender/python/gpu/gpu_py_types.c new file mode 100644 index 00000000000..0a21da5682b --- /dev/null +++ b/source/blender/python/gpu/gpu_py_types.c @@ -0,0 +1,847 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/gpu/gpu_py_types.c + * \ingroup pygpu + * + * - Use ``bpygpu_`` for local API. + * - Use ``BPyGPU`` for public API. + */ + +#include + +#include "GPU_batch.h" +#include "GPU_vertex_format.h" + +#include "BLI_math.h" + +#include "GPU_batch.h" + +#include "MEM_guardedalloc.h" + +#include "../generic/py_capi_utils.h" +#include "../generic/python_utildefines.h" + +#include "gpu_py_types.h" /* own include */ + +#ifdef __BIG_ENDIAN__ + /* big endian */ +# define MAKE_ID2(c, d) ((c) << 8 | (d)) +# define MAKE_ID3(a, b, c) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 ) +# define MAKE_ID4(a, b, c, d) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d) ) +#else + /* little endian */ +# define MAKE_ID2(c, d) ((d) << 8 | (c)) +# define MAKE_ID3(a, b, c) ( (int)(c) << 16 | (b) << 8 | (a) ) +# define MAKE_ID4(a, b, c, d) ( (int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a) ) +#endif + +/* -------------------------------------------------------------------- */ + +/** \name Enum Conversion + * + * Use with PyArg_ParseTuple's "O&" formatting. + * \{ */ + +static int bpygpu_ParseVertCompType(PyObject *o, void *p) +{ + Py_ssize_t comp_type_id_len; + const char *comp_type_id = _PyUnicode_AsStringAndSize(o, &comp_type_id_len); + if (comp_type_id == NULL) { + PyErr_Format(PyExc_ValueError, + "expected a string, got %s", + Py_TYPE(o)->tp_name); + return 0; + } + + GPUVertCompType comp_type; + if (comp_type_id_len == 2) { + switch (*((ushort *)comp_type_id)) { + case MAKE_ID2('I', '8'): { comp_type = GPU_COMP_I8; goto success; } + case MAKE_ID2('U', '8'): { comp_type = GPU_COMP_U8; goto success; } + } + } + else if (comp_type_id_len == 3) { + switch (*((uint *)comp_type_id)) { + case MAKE_ID3('I', '1', '6'): { comp_type = GPU_COMP_I16; goto success; } + case MAKE_ID3('U', '1', '6'): { comp_type = GPU_COMP_U16; goto success; } + case MAKE_ID3('I', '3', '2'): { comp_type = GPU_COMP_I32; goto success; } + case MAKE_ID3('U', '3', '2'): { comp_type = GPU_COMP_U32; goto success; } + case MAKE_ID3('F', '3', '2'): { comp_type = GPU_COMP_F32; goto success; } + case MAKE_ID3('I', '1', '0'): { comp_type = GPU_COMP_I10; goto success; } + } + } + + PyErr_Format(PyExc_ValueError, + "unknown type literal: '%s'", + comp_type_id); + return 0; + +success: + *((GPUVertCompType *)p) = comp_type; + return 1; +} + +static int bpygpu_ParseVertFetchMode(PyObject *o, void *p) +{ + Py_ssize_t mode_id_len; + const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len); + if (mode_id == NULL) { + PyErr_Format(PyExc_ValueError, + "expected a string, got %s", + Py_TYPE(o)->tp_name); + return 0; + } +#define MATCH_ID(id) \ + if (mode_id_len == strlen(STRINGIFY(id))) { \ + if (STREQ(mode_id, STRINGIFY(id))) { \ + mode = GPU_FETCH_##id; \ + goto success; \ + } \ + } ((void)0) + + GPUVertFetchMode mode; + MATCH_ID(FLOAT); + MATCH_ID(INT); + MATCH_ID(INT_TO_FLOAT_UNIT); + MATCH_ID(INT_TO_FLOAT); +#undef MATCH_ID + PyErr_Format(PyExc_ValueError, + "unknown type literal: '%s'", + mode_id); + return 0; + +success: + (*(GPUVertFetchMode *)p) = mode; + return 1; +} + +static int bpygpu_ParsePrimType(PyObject *o, void *p) +{ + Py_ssize_t mode_id_len; + const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len); + if (mode_id == NULL) { + PyErr_Format(PyExc_ValueError, + "expected a string, got %s", + Py_TYPE(o)->tp_name); + return 0; + } +#define MATCH_ID(id) \ + if (mode_id_len == strlen(STRINGIFY(id))) { \ + if (STREQ(mode_id, STRINGIFY(id))) { \ + mode = GPU_PRIM_##id; \ + goto success; \ + } \ + } ((void)0) + + GPUPrimType mode; + MATCH_ID(POINTS); + MATCH_ID(LINES); + MATCH_ID(TRIS); + MATCH_ID(LINE_STRIP); + MATCH_ID(LINE_LOOP); + MATCH_ID(TRI_STRIP); + MATCH_ID(TRI_FAN); + MATCH_ID(LINE_STRIP_ADJ); + +#undef MATCH_ID + PyErr_Format(PyExc_ValueError, + "unknown type literal: '%s'", + mode_id); + return 0; + +success: + (*(GPUPrimType *)p) = mode; + return 1; +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Utility Functions + * \{ */ + +#define PY_AS_NATIVE_SWITCH(attr) \ + switch (attr->comp_type) { \ + case GPU_COMP_I8: { PY_AS_NATIVE(int8_t, PyC_Long_AsI8); break; } \ + case GPU_COMP_U8: { PY_AS_NATIVE(uint8_t, PyC_Long_AsU8); break; } \ + case GPU_COMP_I16: { PY_AS_NATIVE(int16_t, PyC_Long_AsI16); break; } \ + case GPU_COMP_U16: { PY_AS_NATIVE(uint16_t, PyC_Long_AsU16); break; } \ + case GPU_COMP_I32: { PY_AS_NATIVE(int32_t, PyC_Long_AsI32); break; } \ + case GPU_COMP_U32: { PY_AS_NATIVE(uint32_t, PyC_Long_AsU32); break; } \ + case GPU_COMP_F32: { PY_AS_NATIVE(float, PyFloat_AsDouble); break; } \ + default: \ + BLI_assert(0); \ + } ((void)0) + +/* No error checking, callers must run PyErr_Occurred */ +static void fill_format_elem(void *data_dst_void, PyObject *py_src, const GPUVertAttr *attr) +{ +#define PY_AS_NATIVE(ty_dst, py_as_native) \ +{ \ + ty_dst *data_dst = data_dst_void; \ + *data_dst = py_as_native(py_src); \ +} ((void)0) + + PY_AS_NATIVE_SWITCH(attr); + +#undef PY_AS_NATIVE +} + +/* No error checking, callers must run PyErr_Occurred */ +static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const GPUVertAttr *attr) +{ + const uint len = attr->comp_len; + +/** + * Args are constants, so range checks will be optimized out if they're nop's. + */ +#define PY_AS_NATIVE(ty_dst, py_as_native) \ + ty_dst *data_dst = data_dst_void; \ + for (uint i = 0; i < len; i++) { \ + data_dst[i] = py_as_native(PyTuple_GET_ITEM(py_src, i)); \ + } ((void)0) + + PY_AS_NATIVE_SWITCH(attr); + +#undef PY_AS_NATIVE +} + +#undef PY_AS_NATIVE_SWITCH +#undef WARN_TYPE_LIMIT_PUSH +#undef WARN_TYPE_LIMIT_POP + +static bool bpygpu_vertbuf_fill_impl( + GPUVertBuf *vbo, + uint data_id, PyObject *seq) +{ + bool ok = true; + const GPUVertAttr *attr = &vbo->format.attribs[data_id]; + + GPUVertBufRaw data_step; + GPU_vertbuf_attr_get_raw_data(vbo, data_id, &data_step); + + PyObject *seq_fast = PySequence_Fast(seq, "Vertex buffer fill"); + if (seq_fast == NULL) { + goto finally; + } + + const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast); + + if (seq_len != vbo->vertex_len) { + PyErr_Format(PyExc_ValueError, + "Expected a sequence of size %d, got %d", + vbo->vertex_len, seq_len); + } + + PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast); + + if (attr->comp_len == 1) { + for (uint i = 0; i < seq_len; i++) { + uchar *data = (uchar *)GPU_vertbuf_raw_step(&data_step); + PyObject *item = seq_items[i]; + fill_format_elem(data, item, attr); + } + } + else { + for (uint i = 0; i < seq_len; i++) { + uchar *data = (uchar *)GPU_vertbuf_raw_step(&data_step); + PyObject *item = seq_items[i]; + if (!PyTuple_CheckExact(item)) { + PyErr_Format(PyExc_ValueError, + "expected a tuple, got %s", + Py_TYPE(item)->tp_name); + ok = false; + goto finally; + } + if (PyTuple_GET_SIZE(item) != attr->comp_len) { + PyErr_Format(PyExc_ValueError, + "expected a tuple of size %d, got %d", + attr->comp_len, PyTuple_GET_SIZE(item)); + ok = false; + goto finally; + } + + /* May trigger error, check below */ + fill_format_tuple(data, item, attr); + } + } + + if (PyErr_Occurred()) { + ok = false; + } + +finally: + + Py_DECREF(seq_fast); + return ok; +} + +/* handy, but not used just now */ +#if 0 +static int bpygpu_find_id(const GPUVertFormat *fmt, const char *id) +{ + for (int i = 0; i < fmt->attr_len; i++) { + for (uint j = 0; j < fmt->name_len; j++) { + if (STREQ(fmt->attribs[i].name[j], id)) { + return i; + } + } + } + return -1; +} +#endif + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name VertFormat Type + * \{ */ + +static PyObject *bpygpu_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) +{ + if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) { + PyErr_SetString(PyExc_TypeError, + "VertFormat(): takes no arguments"); + return NULL; + } + + BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(NULL); + + return (PyObject *)ret; +} + +PyDoc_STRVAR(bpygpu_VertFormat_attr_add_doc, +"TODO" +); +static PyObject *bpygpu_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"id", "comp_type", "len", "fetch_mode", NULL}; + + struct { + const char *id; + GPUVertCompType comp_type; + uint len; + GPUVertFetchMode fetch_mode; + } params; + + if (self->fmt.attr_len == GPU_VERT_ATTR_MAX_LEN) { + PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GPU_VERT_ATTR_MAX_LEN)); + return NULL; + } + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "$sO&IO&:attr_add", (char **)kwlist, + ¶ms.id, + bpygpu_ParseVertCompType, ¶ms.comp_type, + ¶ms.len, + bpygpu_ParseVertFetchMode, ¶ms.fetch_mode)) + { + return NULL; + } + + uint attr_id = GPU_vertformat_attr_add(&self->fmt, params.id, params.comp_type, params.len, params.fetch_mode); + return PyLong_FromLong(attr_id); +} + +static struct PyMethodDef bpygpu_VertFormat_methods[] = { + {"attr_add", (PyCFunction)bpygpu_VertFormat_attr_add, + METH_VARARGS | METH_KEYWORDS, bpygpu_VertFormat_attr_add_doc}, + {NULL, NULL, 0, NULL} +}; + + +static void bpygpu_VertFormat_dealloc(BPyGPUVertFormat *self) +{ + Py_TYPE(self)->tp_free(self); +} + +PyTypeObject BPyGPUVertFormat_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "GPUVertFormat", + .tp_basicsize = sizeof(BPyGPUVertFormat), + .tp_dealloc = (destructor)bpygpu_VertFormat_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_methods = bpygpu_VertFormat_methods, + .tp_new = bpygpu_VertFormat_new, +}; + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name VertBuf Type + * \{ */ + +static PyObject *bpygpu_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) +{ + const char * const keywords[] = {"len", "format", NULL}; + + struct { + BPyGPUVertFormat *py_fmt; + uint len; + } params; + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, + "$IO!:GPUVertBuf.__new__", (char **)keywords, + ¶ms.len, + &BPyGPUVertFormat_Type, ¶ms.py_fmt)) + { + return NULL; + } + + struct GPUVertBuf *vbo = GPU_vertbuf_create_with_format(¶ms.py_fmt->fmt); + + GPU_vertbuf_data_alloc(vbo, params.len); + + return BPyGPUVertBuf_CreatePyObject(vbo); +} + +PyDoc_STRVAR(bpygpu_VertBuf_fill_doc, +"TODO" +); +static PyObject *bpygpu_VertBuf_fill(BPyGPUVertBuf *self, PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"id", "data", NULL}; + + struct { + uint id; + PyObject *py_seq_data; + } params; + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "$IO:fill", (char **)kwlist, + ¶ms.id, + ¶ms.py_seq_data)) + { + return NULL; + } + + if (params.id >= self->buf->format.attr_len) { + PyErr_Format(PyExc_ValueError, + "Format id %d out of range", + params.id); + return NULL; + } + + if (self->buf->data == NULL) { + PyErr_SetString(PyExc_ValueError, + "Can't fill, static buffer already in use"); + return NULL; + } + + if (!bpygpu_vertbuf_fill_impl(self->buf, params.id, params.py_seq_data)) { + return NULL; + } + Py_RETURN_NONE; +} + +static struct PyMethodDef bpygpu_VertBuf_methods[] = { + {"fill", (PyCFunction) bpygpu_VertBuf_fill, + METH_VARARGS | METH_KEYWORDS, bpygpu_VertBuf_fill_doc}, + {NULL, NULL, 0, NULL} +}; + +static void bpygpu_VertBuf_dealloc(BPyGPUVertBuf *self) +{ + GPU_vertbuf_discard(self->buf); + Py_TYPE(self)->tp_free(self); +} + +PyTypeObject BPyGPUVertBuf_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "GPUVertBuf", + .tp_basicsize = sizeof(BPyGPUVertBuf), + .tp_dealloc = (destructor)bpygpu_VertBuf_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_methods = bpygpu_VertBuf_methods, + .tp_new = bpygpu_VertBuf_new, +}; + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name VertBatch Type + * \{ */ + +static PyObject *bpygpu_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) +{ + const char * const keywords[] = {"type", "buf", NULL}; + + struct { + GPUPrimType type_id; + BPyGPUVertBuf *py_buf; + } params; + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, + "$O&O!:GPUBatch.__new__", (char **)keywords, + bpygpu_ParsePrimType, ¶ms.type_id, + &BPyGPUVertBuf_Type, ¶ms.py_buf)) + { + return NULL; + } + + GPUBatch *batch = GPU_batch_create(params.type_id, params.py_buf->buf, NULL); + BPyGPUBatch *ret = (BPyGPUBatch *)BPyGPUBatch_CreatePyObject(batch); + +#ifdef USE_GPU_PY_REFERENCES + ret->references = PyList_New(1); + PyList_SET_ITEM(ret->references, 0, (PyObject *)params.py_buf); + Py_INCREF(params.py_buf); + PyObject_GC_Track(ret); +#endif + + return (PyObject *)ret; +} + +PyDoc_STRVAR(bpygpu_VertBatch_vertbuf_add_doc, +"TODO" +); +static PyObject *bpygpu_VertBatch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf) +{ + if (!BPyGPUVertBuf_Check(py_buf)) { + PyErr_Format(PyExc_TypeError, + "Expected a GPUVertBuf, got %s", + Py_TYPE(py_buf)->tp_name); + return NULL; + } + + if (self->batch->verts[0]->vertex_len != py_buf->buf->vertex_len) { + PyErr_Format(PyExc_TypeError, + "Expected %d length, got %d", + self->batch->verts[0]->vertex_len, py_buf->buf->vertex_len); + return NULL; + } + +#ifdef USE_GPU_PY_REFERENCES + /* Hold user */ + PyList_Append(self->references, (PyObject *)py_buf); +#endif + + GPU_batch_vertbuf_add(self->batch, py_buf->buf); + Py_RETURN_NONE; +} + +/* Currently magic number from Py perspective. */ +PyDoc_STRVAR(bpygpu_VertBatch_program_set_builtin_doc, +"TODO" +); +static PyObject *bpygpu_VertBatch_program_set_builtin(BPyGPUBatch *self, PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"id", NULL}; + + struct { + const char *shader; + } params; + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "s:program_set_builtin", (char **)kwlist, + ¶ms.shader)) + { + return NULL; + } + + GPUBuiltinShader shader; + +#define MATCH_ID(id) \ + if (STREQ(params.shader, STRINGIFY(id))) { \ + shader = GPU_SHADER_##id; \ + goto success; \ + } ((void)0) + + MATCH_ID(2D_FLAT_COLOR); + MATCH_ID(2D_SMOOTH_COLOR); + MATCH_ID(2D_UNIFORM_COLOR); + + MATCH_ID(3D_FLAT_COLOR); + MATCH_ID(3D_SMOOTH_COLOR); + MATCH_ID(3D_UNIFORM_COLOR); + +#undef MATCH_ID + + PyErr_SetString(PyExc_ValueError, + "shader name not known"); + return NULL; + +success: + GPU_batch_program_set_builtin(self->batch, shader); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_uniform_bool(BPyGPUBatch *self, PyObject *args) +{ + struct { + const char *id; + bool values[1]; + } params; + + if (!PyArg_ParseTuple( + args, "sO&:uniform_bool", + ¶ms.id, + PyC_ParseBool, ¶ms.values[0])) + { + return NULL; + } + + GPU_batch_uniform_1b(self->batch, params.id, params.values[0]); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_uniform_i32(BPyGPUBatch *self, PyObject *args) +{ + struct { + const char *id; + int values[1]; + } params; + + if (!PyArg_ParseTuple( + args, "si:uniform_i32", + ¶ms.id, + ¶ms.values[0])) + { + return NULL; + } + + GPU_batch_uniform_1i(self->batch, params.id, params.values[0]); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_uniform_f32(BPyGPUBatch *self, PyObject *args) +{ + struct { + const char *id; + float values[4]; + } params; + + if (!PyArg_ParseTuple( + args, "sf|fff:uniform_f32", + ¶ms.id, + ¶ms.values[0], ¶ms.values[1], ¶ms.values[2], ¶ms.values[3])) + { + return NULL; + } + + switch (PyTuple_GET_SIZE(args)) { + case 2: GPU_batch_uniform_1f(self->batch, params.id, params.values[0]); break; + case 3: GPU_batch_uniform_2f(self->batch, params.id, UNPACK2(params.values)); break; + case 4: GPU_batch_uniform_3f(self->batch, params.id, UNPACK3(params.values)); break; + case 5: GPU_batch_uniform_4f(self->batch, params.id, UNPACK4(params.values)); break; + default: + BLI_assert(0); + } + Py_RETURN_NONE; +} + +PyDoc_STRVAR(bpygpu_VertBatch_draw_doc, +"TODO" +); +static PyObject *bpygpu_VertBatch_draw(BPyGPUBatch *self) +{ + if (!glIsProgram(self->batch->program)) { + PyErr_SetString(PyExc_ValueError, + "batch program has not not set"); + } + GPU_batch_draw(self->batch); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_program_use_begin(BPyGPUBatch *self) +{ + if (!glIsProgram(self->batch->program)) { + PyErr_SetString(PyExc_ValueError, + "batch program has not not set"); + } + GPU_batch_program_use_begin(self->batch); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_program_use_end(BPyGPUBatch *self) +{ + if (!glIsProgram(self->batch->program)) { + PyErr_SetString(PyExc_ValueError, + "batch program has not not set"); + } + GPU_batch_program_use_end(self->batch); + Py_RETURN_NONE; +} + +static struct PyMethodDef bpygpu_VertBatch_methods[] = { + {"vertbuf_add", (PyCFunction)bpygpu_VertBatch_vertbuf_add, + METH_O, bpygpu_VertBatch_vertbuf_add_doc}, + {"program_set_builtin", (PyCFunction)bpygpu_VertBatch_program_set_builtin, + METH_VARARGS | METH_KEYWORDS, bpygpu_VertBatch_program_set_builtin_doc}, + {"uniform_bool", (PyCFunction)bpygpu_VertBatch_uniform_bool, + METH_VARARGS, NULL}, + {"uniform_i32", (PyCFunction)bpygpu_VertBatch_uniform_i32, + METH_VARARGS, NULL}, + {"uniform_f32", (PyCFunction)bpygpu_VertBatch_uniform_f32, + METH_VARARGS, NULL}, + {"draw", (PyCFunction) bpygpu_VertBatch_draw, + METH_NOARGS, bpygpu_VertBatch_draw_doc}, + {"program_use_begin", (PyCFunction)bpygpu_VertBatch_program_use_begin, + METH_NOARGS, ""}, + {"program_use_end", (PyCFunction)bpygpu_VertBatch_program_use_end, + METH_NOARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +#ifdef USE_GPU_PY_REFERENCES + +static int bpygpu_Batch_traverse(BPyGPUBatch *self, visitproc visit, void *arg) +{ + Py_VISIT(self->references); + return 0; +} + +static int bpygpu_Batch_clear(BPyGPUBatch *self) +{ + Py_CLEAR(self->references); + return 0; +} + +#endif + +static void bpygpu_Batch_dealloc(BPyGPUBatch *self) +{ + GPU_batch_discard(self->batch); + +#ifdef USE_GPU_PY_REFERENCES + if (self->references) { + PyObject_GC_UnTrack(self); + bpygpu_Batch_clear(self); + Py_XDECREF(self->references); + } +#endif + + Py_TYPE(self)->tp_free(self); +} + +PyTypeObject BPyGPUBatch_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "GPUBatch", + .tp_basicsize = sizeof(BPyGPUBatch), + .tp_dealloc = (destructor)bpygpu_Batch_dealloc, +#ifdef USE_GPU_PY_REFERENCES + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + .tp_traverse = (traverseproc)bpygpu_Batch_traverse, + .tp_clear = (inquiry)bpygpu_Batch_clear, +#else + .tp_flags = Py_TPFLAGS_DEFAULT, +#endif + .tp_methods = bpygpu_VertBatch_methods, + .tp_new = bpygpu_Batch_new, +}; + +/* -------------------------------------------------------------------- */ + + +/** \name GPU Types Module + * \{ */ + +static struct PyModuleDef BPy_BM_types_module_def = { + PyModuleDef_HEAD_INIT, + .m_name = "_gpu.types", +}; + +PyObject *BPyInit_gpu_types(void) +{ + PyObject *submodule; + + submodule = PyModule_Create(&BPy_BM_types_module_def); + + if (PyType_Ready(&BPyGPUVertFormat_Type) < 0) + return NULL; + if (PyType_Ready(&BPyGPUVertBuf_Type) < 0) + return NULL; + if (PyType_Ready(&BPyGPUBatch_Type) < 0) + return NULL; + +#define MODULE_TYPE_ADD(s, t) \ + PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t) + + MODULE_TYPE_ADD(submodule, BPyGPUVertFormat_Type); + MODULE_TYPE_ADD(submodule, BPyGPUVertBuf_Type); + MODULE_TYPE_ADD(submodule, BPyGPUBatch_Type); + +#undef MODULE_TYPE_ADD + + return submodule; +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Public API + * \{ */ + +PyObject *BPyGPUVertFormat_CreatePyObject(GPUVertFormat *fmt) +{ + BPyGPUVertFormat *self; + + self = PyObject_New(BPyGPUVertFormat, &BPyGPUVertFormat_Type); + if (fmt) { + self->fmt = *fmt; + } + else { + memset(&self->fmt, 0, sizeof(self->fmt)); + } + + return (PyObject *)self; +} + +PyObject *BPyGPUVertBuf_CreatePyObject(GPUVertBuf *buf) +{ + BPyGPUVertBuf *self; + + self = PyObject_New(BPyGPUVertBuf, &BPyGPUVertBuf_Type); + self->buf = buf; + + return (PyObject *)self; +} + + +PyObject *BPyGPUBatch_CreatePyObject(GPUBatch *batch) +{ + BPyGPUBatch *self; + +#ifdef USE_GPU_PY_REFERENCES + self = (BPyGPUBatch *)_PyObject_GC_New(&BPyGPUBatch_Type); + self->references = NULL; +#else + self = PyObject_New(BPyGPUBatch, &BPyGPUBatch_Type); +#endif + + self->batch = batch; + + return (PyObject *)self; +} + +/** \} */ diff --git a/source/blender/python/gpu/gpu_py_types.h b/source/blender/python/gpu/gpu_py_types.h new file mode 100644 index 00000000000..f736a8f749a --- /dev/null +++ b/source/blender/python/gpu/gpu_py_types.h @@ -0,0 +1,67 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/gpu/gpu_py_types.h + * \ingroup pygpu + */ + +#ifndef __GPU_PY_TYPES_H__ +#define __GPU_PY_TYPES_H__ + +#include "BLI_compiler_attrs.h" + +#define USE_GPU_PY_REFERENCES + +extern PyTypeObject BPyGPUVertFormat_Type; +extern PyTypeObject BPyGPUVertBuf_Type; +extern PyTypeObject BPyGPUBatch_Type; + +#define BPyGPUVertFormat_Check(v) (Py_TYPE(v) == &BPyGPUVertFormat_Type) +#define BPyGPUVertBuf_Check(v) (Py_TYPE(v) == &BPyGPUVertBuf_Type) +#define BPyGPUBatch_Check(v) (Py_TYPE(v) == &BPyGPUBatch_Type) + +typedef struct BPyGPUVertFormat { + PyObject_VAR_HEAD + struct GPUVertFormat fmt; +} BPyGPUVertFormat; + +typedef struct BPyGPUVertBuf { + PyObject_VAR_HEAD + /* The buf is owned, we may support thin wrapped batches later. */ + struct GPUVertBuf *buf; +} BPyGPUVertBuf; + +typedef struct BPyGPUBatch { + PyObject_VAR_HEAD + /* The batch is owned, we may support thin wrapped batches later. */ + struct GPUBatch *batch; +#ifdef USE_GPU_PY_REFERENCES + /* Just to keep a user to prevent freeing buf's we're using */ + PyObject *references; +#endif +} BPyGPUBatch; + +PyObject *BPyInit_gpu_types(void); + +PyObject *BPyGPUVertFormat_CreatePyObject(struct GPUVertFormat *fmt); +PyObject *BPyGPUVertBuf_CreatePyObject(struct GPUVertBuf *vbo) ATTR_NONNULL(1); +PyObject *BPyGPUBatch_CreatePyObject(struct GPUBatch *batch) ATTR_NONNULL(1); + +#endif /* __GPU_PY_TYPES_H__ */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 0d7b0c92a90..64bc54c6221 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -75,7 +75,7 @@ #include "../generic/blf_py_api.h" #include "../generic/idprop_py_api.h" #include "../generic/imbuf_py_api.h" -#include "../gawain/gwn_py_api.h" +#include "../gpu/gpu_py_api.h" #include "../bmesh/bmesh_py_api.h" #include "../mathutils/mathutils.h" @@ -219,7 +219,7 @@ static struct _inittab bpy_internal_modules[] = { {"mathutils.kdtree", PyInit_mathutils_kdtree}, #endif {"_bpy_path", BPyInit__bpy_path}, - {"_gawain", BPyInit_gawain}, + {"_gpu", BPyInit_gpu}, {"bgl", BPyInit_bgl}, {"blf", BPyInit_blf}, {"imbuf", BPyInit_imbuf}, diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index cb32efb0b0f..df8953857ee 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -315,7 +315,7 @@ void RE_current_scene_update_cb(struct Render *re, void *handle, void (*f)(void void RE_gl_context_create(Render *re); void RE_gl_context_destroy(Render *re); void *RE_gl_context_get(Render *re); -void *RE_gwn_context_get(Render *re); +void *RE_gpu_context_get(Render *re); /* should move to kernel once... still unsure on how/where */ float RE_filter_value(int type, float x); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 117b82570e7..5d5d12f028a 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -160,7 +160,7 @@ struct Render { /* TODO replace by a whole draw manager. */ void *gl_context; - void *gwn_context; + void *gpu_context; }; /* **************** defines ********************* */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index af8746a4734..510a4aa4685 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1043,10 +1043,10 @@ void RE_gl_context_create(Render *re) void RE_gl_context_destroy(Render *re) { /* Needs to be called from the thread which used the ogl context for rendering. */ - if (re->gwn_context) { - GWN_context_active_set(re->gwn_context); - GWN_context_discard(re->gwn_context); - re->gwn_context = NULL; + if (re->gpu_context) { + GPU_context_active_set(re->gpu_context); + GPU_context_discard(re->gpu_context); + re->gpu_context = NULL; } if (re->gl_context) { WM_opengl_context_dispose(re->gl_context); @@ -1059,12 +1059,12 @@ void *RE_gl_context_get(Render *re) return re->gl_context; } -void *RE_gwn_context_get(Render *re) +void *RE_gpu_context_get(Render *re) { - if (re->gwn_context == NULL) { - re->gwn_context = GWN_context_create(); + if (re->gpu_context == NULL) { + re->gpu_context = GPU_context_create(); } - return re->gwn_context; + return re->gpu_context; } /* ********* add object data (later) ******** */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5314c434c4c..160aeb6671b 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -456,9 +456,9 @@ void wm_draw_region_blend(ARegion *ar, int view, bool blend) glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), halfx, halfy, 1.0f + halfx, 1.0f + halfy); glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), ar->winrct.xmin, ar->winrct.ymin, ar->winrct.xmax + 1, ar->winrct.ymax + 1); - glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha); + glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha); - GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4); + GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 84dcf30e63c..c191255cd21 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -188,7 +188,7 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) static void wm_window_substitute_old(wmWindowManager *oldwm, wmWindowManager *wm, wmWindow *oldwin, wmWindow *win) { win->ghostwin = oldwin->ghostwin; - win->gwnctx = oldwin->gwnctx; + win->gpuctx = oldwin->gpuctx; win->active = oldwin->active; if (win->active) { wm->winactive = win; @@ -202,7 +202,7 @@ static void wm_window_substitute_old(wmWindowManager *oldwm, wmWindowManager *wm GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ oldwin->ghostwin = NULL; - oldwin->gwnctx = NULL; + oldwin->gpuctx = NULL; win->eventstate = oldwin->eventstate; oldwin->eventstate = NULL; diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 4366013084c..06a7f3528c5 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -166,7 +166,7 @@ static void wm_gesture_draw_line(wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -181,7 +181,7 @@ static void wm_gesture_draw_line(wmGesture *gt) float xmin = (float)rect->xmin; float ymin = (float)rect->ymin; - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(shdr_pos, xmin, ymin); immVertex2f(shdr_pos, (float)rect->xmax, (float)rect->ymax); immEnd(); @@ -193,7 +193,7 @@ static void wm_gesture_draw_rect(wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); glEnable(GL_BLEND); @@ -206,7 +206,7 @@ static void wm_gesture_draw_rect(wmGesture *gt) glDisable(GL_BLEND); - shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -231,7 +231,7 @@ static void wm_gesture_draw_circle(wmGesture *gt) glEnable(GL_BLEND); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -346,7 +346,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled) return; } - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -358,7 +358,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled) immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2); immUniform1f("dash_width", 2.0f); - immBegin((gt->type == WM_GESTURE_LASSO) ? GWN_PRIM_LINE_LOOP : GWN_PRIM_LINE_STRIP, numverts); + immBegin((gt->type == WM_GESTURE_LASSO) ? GPU_PRIM_LINE_LOOP : GPU_PRIM_LINE_STRIP, numverts); for (i = 0; i < gt->points; i++, lasso += 2) { immVertex2f(shdr_pos, (float)lasso[0], (float)lasso[1]); @@ -377,7 +377,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) float x1, x2, y1, y2; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -389,7 +389,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2); immUniform1f("dash_width", 8.0f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); x1 = (float)(rect->xmin - winsize_x); y1 = (float)rect->ymin; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 64aa64e1478..e757c7bee52 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2094,12 +2094,12 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph RNA_property_float_get_array(fill_ptr, fill_prop, col); } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (rc->gltex) { - uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, rc->gltex); @@ -2123,7 +2123,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph } /* draw textured quad */ - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texCoord, 0, 0); immVertex2f(pos, -radius, -radius); @@ -2226,8 +2226,8 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void if (rc->col_prop) RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fvAlpha(col, 0.5f); @@ -2237,14 +2237,14 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void /* draw original angle line */ GPU_matrix_rotate_2d(RAD2DEGF(rc->initial_value)); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immEnd(); /* draw new angle line */ GPU_matrix_rotate_2d(RAD2DEGF(rc->current_value - rc->initial_value)); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immEnd(); diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 00e7f77569b..6317cca8094 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -187,7 +187,7 @@ typedef enum eWS_Qual { static struct WindowStateGlobal { GHOST_SystemHandle ghost_system; void *ghost_window; - Gwn_Context *gwn_context; + GPUContext *gpu_context; /* events */ eWS_Qual qual; @@ -374,12 +374,12 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf GPU_matrix_push(); GPU_matrix_identity_set(); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(0, 255, 0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, fac, -1.0f); immVertex2f(pos, fac, 1.0f); immEnd(); @@ -1284,7 +1284,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) //GHOST_ActivateWindowDrawingContext(g_WS.ghost_window); /* initialize OpenGL immediate mode */ - g_WS.gwn_context = GWN_context_create(); + g_WS.gpu_context = GPU_context_create(); GPU_init(); immActivate(); @@ -1555,10 +1555,10 @@ static char *wm_main_playanim_intern(int argc, const char **argv) GPU_shader_free_builtin_shaders(); - if (g_WS.gwn_context) { - GWN_context_active_set(g_WS.gwn_context); - GWN_context_discard(g_WS.gwn_context); - g_WS.gwn_context = NULL; + if (g_WS.gpu_context) { + GPU_context_active_set(g_WS.gpu_context); + GPU_context_discard(g_WS.gpu_context); + g_WS.gpu_context = NULL; } BLF_exit(); diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c index 1e9f6d6231b..577145aff95 100644 --- a/source/blender/windowmanager/intern/wm_stereo.c +++ b/source/blender/windowmanager/intern/wm_stereo.c @@ -87,9 +87,9 @@ void wm_stereo3d_draw_interlace(wmWindow *win, ARegion *ar) float halfx = GLA_PIXEL_OFS / ar->winx; float halfy = GLA_PIXEL_OFS / ar->winy; - Gwn_VertFormat *format = immVertexFormat(); - uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* leave GL_TEXTURE0 as the latest active texture */ for (int view = 1; view >= 0; view--) { @@ -104,7 +104,7 @@ void wm_stereo3d_draw_interlace(wmWindow *win, ARegion *ar) immUniform1i("interlace_id", interlace_gpu_id_from_type(interlace_type)); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texcoord, halfx, halfy); immVertex2f(pos, ar->winrct.xmin, ar->winrct.ymin); @@ -163,9 +163,9 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) { bool cross_eyed = (win->stereo3d_format->flag & S3D_SIDEBYSIDE_CROSSEYED) != 0; - Gwn_VertFormat *format = immVertexFormat(); - uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE); @@ -188,7 +188,7 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */ - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texcoord, halfx, halfy); immVertex2f(pos, soffx, 0.0f); @@ -209,9 +209,9 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) void wm_stereo3d_draw_topbottom(wmWindow *win, int view) { - Gwn_VertFormat *format = immVertexFormat(); - uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE); @@ -232,7 +232,7 @@ void wm_stereo3d_draw_topbottom(wmWindow *win, int view) immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */ - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texcoord, halfx, halfy); immVertex2f(pos, 0.0f, soffy); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 669480bf098..b87ae7e076c 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -194,14 +194,14 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win) /* We need this window's opengl context active to discard it. */ GHOST_ActivateWindowDrawingContext(win->ghostwin); - GWN_context_active_set(win->gwnctx); + GPU_context_active_set(win->gpuctx); - /* Delete local gawain objects. */ - GWN_context_discard(win->gwnctx); + /* Delete local gpu context. */ + GPU_context_discard(win->gpuctx); GHOST_DisposeWindow(g_system, win->ghostwin); win->ghostwin = NULL; - win->gwnctx = NULL; + win->gpuctx = NULL; } } @@ -645,7 +645,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm /* Clear drawable so we can set the new window. */ wm_window_clear_drawable(wm); - win->gwnctx = GWN_context_create(); + win->gpuctx = GPU_context_create(); /* needed so we can detect the graphics card below */ GPU_init(); @@ -1099,7 +1099,7 @@ static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool acti if (activate) { GHOST_ActivateWindowDrawingContext(win->ghostwin); } - GWN_context_active_set(win->gwnctx); + GPU_context_active_set(win->gpuctx); immActivate(); } -- cgit v1.2.3 From bdda0964e0a5180bd0bc4fb8e38dbe2198bd9a9a Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 18 Jul 2018 13:03:09 +0200 Subject: Compositor: Cryptomatte compositing node. This patch adds a new matte node that implements the Cryptomatte specification. It also incluces a custom eye dropper that works outside of a color picker. Cryptomatte export for the Cycles render engine will be in a separate patch. Reviewers: brecht Reviewed By: brecht Subscribers: brecht Tags: #compositing Differential Revision: https://developer.blender.org/D3531 --- release/scripts/startup/nodeitems_builtins.py | 1 + source/blender/blenkernel/BKE_node.h | 6 + source/blender/blenkernel/intern/node.c | 1 + source/blender/blenlib/BLI_hash_mm3.h | 40 +++ source/blender/blenlib/CMakeLists.txt | 2 + source/blender/blenlib/intern/hash_mm3.c | 147 ++++++++++ source/blender/blenloader/intern/readfile.c | 4 + source/blender/blenloader/intern/writefile.c | 7 + source/blender/compositor/CMakeLists.txt | 5 + source/blender/compositor/intern/COM_Converter.cpp | 4 + .../compositor/nodes/COM_CryptomatteNode.cpp | 120 ++++++++ .../blender/compositor/nodes/COM_CryptomatteNode.h | 38 +++ .../operations/COM_CryptomatteOperation.cpp | 75 +++++ .../operations/COM_CryptomatteOperation.h | 40 +++ source/blender/editors/include/UI_interface.h | 1 + .../editors/interface/interface_eyedropper.c | 1 + .../editors/interface/interface_eyedropper_color.c | 89 +++--- .../blender/editors/interface/interface_intern.h | 1 + source/blender/editors/interface/interface_ops.c | 1 + .../editors/interface/interface_templates.c | 18 ++ source/blender/editors/space_node/drawnode.c | 23 ++ source/blender/editors/space_node/node_edit.c | 90 ++++++ source/blender/editors/space_node/node_intern.h | 3 + source/blender/editors/space_node/node_ops.c | 3 + source/blender/makesdna/DNA_node_types.h | 8 + source/blender/makesrna/intern/rna_nodetree.c | 68 +++++ source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_composite.h | 1 + source/blender/nodes/NOD_static_types.h | 1 + .../composite/nodes/node_composite_cryptomatte.c | 309 +++++++++++++++++++++ 30 files changed, 1066 insertions(+), 42 deletions(-) create mode 100644 source/blender/blenlib/BLI_hash_mm3.h create mode 100644 source/blender/blenlib/intern/hash_mm3.c create mode 100644 source/blender/compositor/nodes/COM_CryptomatteNode.cpp create mode 100644 source/blender/compositor/nodes/COM_CryptomatteNode.h create mode 100644 source/blender/compositor/operations/COM_CryptomatteOperation.cpp create mode 100644 source/blender/compositor/operations/COM_CryptomatteOperation.h create mode 100644 source/blender/nodes/composite/nodes/node_composite_cryptomatte.c diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 92411aeb0ef..c9a15f12f7c 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -394,6 +394,7 @@ compositor_node_categories = [ NodeItem("CompositorNodeChromaMatte"), NodeItem("CompositorNodeColorMatte"), NodeItem("CompositorNodeDoubleEdgeMask"), + NodeItem("CompositorNodeCryptomatte"), ]), CompositorNodeCategory("CMP_DISTORT", "Distort", items=[ NodeItem("CompositorNodeScale"), diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index eca7f82541f..8e54c6a87c4 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -945,6 +945,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria #define CMP_NODE_PLANETRACKDEFORM 320 #define CMP_NODE_CORNERPIN 321 #define CMP_NODE_SWITCH_VIEW 322 +#define CMP_NODE_CRYPTOMATTE 323 /* channel toggles */ #define CMP_CHAN_RGB 1 @@ -997,6 +998,11 @@ void ntreeCompositOutputFileUniqueLayer(struct ListBase *list, struct bNodeSocke void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *ntree, bNode *node); void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *ntree, bNode *node); +void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *ntree, bNode *node); +void ntreeCompositCryptomatteSyncFromRemove(bNodeTree *ntree, bNode *node); +struct bNodeSocket *ntreeCompositCryptomatteAddSocket(struct bNodeTree *ntree, struct bNode *node); +int ntreeCompositCryptomatteRemoveSocket(struct bNodeTree *ntree, struct bNode *node); + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 499f92b3878..f15d90100d2 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3528,6 +3528,7 @@ static void registerCompositNodes(void) register_node_type_cmp_doubleedgemask(); register_node_type_cmp_keyingscreen(); register_node_type_cmp_keying(); + register_node_type_cmp_cryptomatte(); register_node_type_cmp_translate(); register_node_type_cmp_rotate(); diff --git a/source/blender/blenlib/BLI_hash_mm3.h b/source/blender/blenlib/BLI_hash_mm3.h new file mode 100644 index 00000000000..93bf963c9a4 --- /dev/null +++ b/source/blender/blenlib/BLI_hash_mm3.h @@ -0,0 +1,40 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BLI_HASH_MM3_H__ +#define __BLI_HASH_MM3_H__ + +/** \file BLI_hash_mm3.h + * \ingroup bli + */ + +#include "BLI_sys_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t BLI_hash_mm3(const unsigned char *data, size_t len, uint32_t seed); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLI_HASH_MM2A_H__ */ diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 16497c12022..e3f5773b1e4 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -74,6 +74,7 @@ set(SRC intern/gsqueue.c intern/hash_md5.c intern/hash_mm2a.c + intern/hash_mm3.c intern/jitter_2d.c intern/lasso_2d.c intern/list_sort_impl.h @@ -159,6 +160,7 @@ set(SRC BLI_hash.h BLI_hash_md5.h BLI_hash_mm2a.h + BLI_hash_mm3.h BLI_heap.h BLI_jitter_2d.h BLI_kdopbvh.h diff --git a/source/blender/blenlib/intern/hash_mm3.c b/source/blender/blenlib/intern/hash_mm3.c new file mode 100644 index 00000000000..ac483795e45 --- /dev/null +++ b/source/blender/blenlib/intern/hash_mm3.c @@ -0,0 +1,147 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + * + * Copyright (C) 2018 Blender Foundation. + * + */ + +/** \file blender/blenlib/intern/hash_mm3.c + * \ingroup bli + * + * Functions to compute Murmur3 hash key. + * + * This Code is based on alShaders/Cryptomatte/MurmurHash3.h: + * + * MurmurHash3 was written by Austin Appleby, and is placed in the public + * domain. The author hereby disclaims copyright to this source code. + * + */ + +#include "BLI_compiler_compat.h" +#include "BLI_compiler_attrs.h" +#include "BLI_hash_mm3.h" /* own include */ + +#if defined(_MSC_VER) +# include +# define ROTL32(x,y) _rotl(x,y) +# define BIG_CONSTANT(x) (x) + +/* Other compilers */ +#else /* defined(_MSC_VER) */ +static inline uint32_t rotl32(uint32_t x, int8_t r) +{ + return (x << r) | (x >> (32 - r)); +} +# define ROTL32(x,y) rotl32(x,y) +# define BIG_CONSTANT(x) (x##LLU) +#endif /* !defined(_MSC_VER) */ + +/* Block read - if your platform needs to do endian-swapping or can only + * handle aligned reads, do the conversion here + */ + +BLI_INLINE uint32_t getblock32(const uint32_t * p, int i) +{ + return p[i]; +} + +BLI_INLINE uint64_t getblock64(const uint64_t * p, int i) +{ + return p[i]; +} + +/* Finalization mix - force all bits of a hash block to avalanche */ + +BLI_INLINE uint32_t fmix32(uint32_t h) +{ + h ^= h >> 16; + h *= 0x85ebca6b; + h ^= h >> 13; + h *= 0xc2b2ae35; + h ^= h >> 16; + + return h; +} + +BLI_INLINE uint64_t fmix64(uint64_t k) +{ + k ^= k >> 33; + k *= BIG_CONSTANT(0xff51afd7ed558ccd); + k ^= k >> 33; + k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53); + k ^= k >> 33; + + return k; +} + +uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed) +{ + const uint8_t *data = (const uint8_t*)in; + const int nblocks = len / 4; + + uint32_t h1 = seed; + + const uint32_t c1 = 0xcc9e2d51; + const uint32_t c2 = 0x1b873593; + + /* body */ + + const uint32_t *blocks = (const uint32_t *)(data + nblocks*4); + + for (int i = -nblocks; i; i++) { + uint32_t k1 = getblock32(blocks,i); + + k1 *= c1; + k1 = ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = ROTL32(h1,13); + h1 = h1*5+0xe6546b64; + } + + /* tail */ + + const uint8_t *tail = (const uint8_t*)(data + nblocks*4); + + uint32_t k1 = 0; + + switch (len & 3) { + case 3: + k1 ^= tail[2] << 16; + ATTR_FALLTHROUGH; + case 2: + k1 ^= tail[1] << 8; + ATTR_FALLTHROUGH; + case 1: + k1 ^= tail[0]; + k1 *= c1; + k1 = ROTL32(k1,15); + k1 *= c2; + h1 ^= k1; + }; + + /* finalization */ + + h1 ^= len; + + h1 = fmix32(h1); + + return h1; +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 4e845b9a60d..1def462b1ca 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3161,6 +3161,10 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) direct_link_curvemapping(fd, node->storage); else if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) ((ImageUser *)node->storage)->ok = 1; + else if (node->type==CMP_NODE_CRYPTOMATTE) { + NodeCryptomatte *nc = (NodeCryptomatte *) node->storage; + nc->matte_id = newdataadr(fd, nc->matte_id); + } } else if ( ntree->type==NTREE_TEXTURE) { if (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index e3a901f4211..4b64d0a3d3f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1077,6 +1077,13 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree) } writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage); } + else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_CRYPTOMATTE)) { + NodeCryptomatte *nc = (NodeCryptomatte *)node->storage; + if (nc->matte_id) { + writedata(wd, DATA, strlen(nc->matte_id) + 1, nc->matte_id); + } + writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage); + } else { writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage); } diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index 3e1dd83112a..0ad53d3ab80 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -182,6 +182,11 @@ set(SRC operations/COM_SunBeamsOperation.cpp operations/COM_SunBeamsOperation.h + nodes/COM_CryptomatteNode.cpp + nodes/COM_CryptomatteNode.h + operations/COM_CryptomatteOperation.cpp + operations/COM_CryptomatteOperation.h + nodes/COM_CornerPinNode.cpp nodes/COM_CornerPinNode.h nodes/COM_PlaneTrackDeformNode.cpp diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 58e0da04e5e..c9181905908 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -55,6 +55,7 @@ extern "C" { #include "COM_Converter.h" #include "COM_CornerPinNode.h" #include "COM_CropNode.h" +#include "COM_CryptomatteNode.h" #include "COM_DefocusNode.h" #include "COM_DespeckleNode.h" #include "COM_DifferenceMatteNode.h" @@ -406,6 +407,9 @@ Node *Converter::convert(bNode *b_node) case CMP_NODE_SUNBEAMS: node = new SunBeamsNode(b_node); break; + case CMP_NODE_CRYPTOMATTE: + node = new CryptomatteNode(b_node); + break; } return node; } diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp new file mode 100644 index 00000000000..c8134068543 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp @@ -0,0 +1,120 @@ +/* + * Copyright 2018, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Lukas Stockner + * Stefan Werner + */ + +#include "COM_CryptomatteNode.h" +#include "COM_CryptomatteOperation.h" +#include "COM_SetAlphaOperation.h" +#include "COM_ConvertOperation.h" +#include "BLI_string.h" +#include "BLI_hash_mm3.h" +#include "BLI_assert.h" +#include + +CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +/* This is taken from the Cryptomatte specification 1.0. */ +static inline float hash_to_float(uint32_t hash) { + uint32_t mantissa = hash & (( 1 << 23) - 1); + uint32_t exponent = (hash >> 23) & ((1 << 8) - 1); + exponent = max(exponent, (uint32_t) 1); + exponent = min(exponent, (uint32_t) 254); + exponent = exponent << 23; + uint32_t sign = (hash >> 31); + sign = sign << 31; + uint32_t float_bits = sign | exponent | mantissa; + float f; + /* Bit casting relies on equal size for both types. */ + BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "float and uint32_t are not the same size") + ::memcpy(&f, &float_bits, sizeof(float)); + return f; +} + +void CryptomatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const +{ + NodeInput *inputSocketImage = this->getInputSocket(0); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + NodeOutput *outputSocketMatte = this->getOutputSocket(1); + NodeOutput *outputSocketPick = this->getOutputSocket(2); + + bNode *node = this->getbNode(); + NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage; + + CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets()-1); + if (cryptoMatteSettings) { + if (cryptoMatteSettings->matte_id) { + /* Split the string by commas, ignoring white space. */ + std::string input = cryptoMatteSettings->matte_id; + std::istringstream ss(input); + while (ss.good()) { + std::string token; + getline(ss, token, ','); + /* Ignore empty tokens. */ + if (token.length() > 0) { + size_t first = token.find_first_not_of(' '); + size_t last = token.find_last_not_of(' '); + if (first == std::string::npos || last == std::string::npos) { + break; + } + token = token.substr(first, (last - first + 1)); + if (*token.begin() == '<' && *(--token.end()) == '>') { + operation->addObjectIndex(atof(token.substr(1, token.length() - 2).c_str())); + } + else { + uint32_t hash = BLI_hash_mm3((const unsigned char*)token.c_str(), token.length(), 0); + operation->addObjectIndex(hash_to_float(hash)); + } + } + } + } + } + + converter.addOperation(operation); + + for (int i = 0; i < getNumberOfInputSockets()-1; ++i) { + converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i)); + } + + SeparateChannelOperation *separateOperation = new SeparateChannelOperation; + separateOperation->setChannel(3); + converter.addOperation(separateOperation); + + SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + converter.addOperation(operationAlpha); + + converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0)); + converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1)); + + SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation(); + converter.addOperation(clearAlphaOperation); + converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f); + + converter.addLink(operation->getOutputSocket(0), clearAlphaOperation->getInputSocket(0)); + + converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); + converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0)); + converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0)); + converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0)); + +} diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.h b/source/blender/compositor/nodes/COM_CryptomatteNode.h new file mode 100644 index 00000000000..5251b57d8af --- /dev/null +++ b/source/blender/compositor/nodes/COM_CryptomatteNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2018, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Lukas Stockner + */ + +#ifndef _COM_CryptomatteNode_h_ +#define _COM_CryptomatteNode_h_ + +#include "COM_Node.h" + +/** + * @brief CryptomatteNode + * @ingroup Node + */ +class CryptomatteNode : public Node { +public: + CryptomatteNode(bNode *editorNode); + void convertToOperations(NodeConverter &converter, const CompositorContext &context) const; +}; + +#endif + diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp new file mode 100644 index 00000000000..9dd36863d37 --- /dev/null +++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp @@ -0,0 +1,75 @@ +/* + * Copyright 2018, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: Lukas Stockner, Stefan Werner + */ + +#include "COM_CryptomatteOperation.h" + +CryptomatteOperation::CryptomatteOperation(size_t num_inputs) : NodeOperation() +{ + for(size_t i = 0; i < num_inputs; i++) { + this->addInputSocket(COM_DT_COLOR); + } + inputs.resize(num_inputs); + this->addOutputSocket(COM_DT_COLOR); + this->setComplex(true); +} + +void CryptomatteOperation::initExecution() +{ + for (size_t i = 0; i < inputs.size(); i++) { + inputs[i] = this->getInputSocketReader(i); + } +} + +void CryptomatteOperation::addObjectIndex(float objectIndex) +{ + if (objectIndex != 0.0f) { + m_objectIndex.push_back(objectIndex); + } +} + +void CryptomatteOperation::executePixel(float output[4], + int x, + int y, + void *data) +{ + float input[4]; + output[0] = output[1] = output[2] = output[3] = 0.0f; + for (size_t i = 0; i < inputs.size(); i++) { + inputs[i]->read(input, x, y, data); + if (i == 0) { + /* Write the frontmost object as false color for picking. */ + output[0] = input[0]; + uint32_t m3hash; + ::memcpy(&m3hash, &input[0], sizeof(uint32_t)); + /* Since the red channel is likely to be out of display range, + * setting green and blue gives more meaningful images. */ + output[1] = ((float) ((m3hash << 8)) / (float) UINT32_MAX); + output[2] = ((float) ((m3hash << 16)) / (float) UINT32_MAX); + } + for(size_t i = 0; i < m_objectIndex.size(); i++) { + if (m_objectIndex[i] == input[0]) { + output[3] += input[1]; + } + if (m_objectIndex[i] == input[2]) { + output[3] += input[3]; + } + } + } +} diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.h b/source/blender/compositor/operations/COM_CryptomatteOperation.h new file mode 100644 index 00000000000..9ce02c048b3 --- /dev/null +++ b/source/blender/compositor/operations/COM_CryptomatteOperation.h @@ -0,0 +1,40 @@ +/* + * Copyright 2018, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: Lukas Stockner, Stefan Werner + */ + +#ifndef _COM_CryptomatteOperation_h +#define _COM_CryptomatteOperation_h +#include "COM_NodeOperation.h" + + +class CryptomatteOperation : public NodeOperation { +private: + std::vector m_objectIndex; +public: + std::vector inputs; + + CryptomatteOperation(size_t num_inputs = 6); + + void initExecution(); + void executePixel(float output[4], int x, int y, void *data); + + void addObjectIndex(float objectIndex); + +}; +#endif diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 51f79e05bf9..eefbeee6336 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -969,6 +969,7 @@ void uiTemplateCurveMapping( bool levels, bool brush, bool neg_slope); void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic); void uiTemplatePalette(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool color); +void uiTemplateCryptoPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname); void uiTemplateLayers( uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer); diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index fafe5f48f75..67486f38760 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -82,6 +82,7 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf) /* assign to operators */ WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorband"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color"); + WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color_crypto"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_id"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_depth"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_driver"); diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index 7dd7de0817e..bcb60013eda 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -36,6 +36,7 @@ #include "DNA_screen_types.h" #include "BLI_math_vector.h" +#include "BLI_string.h" #include "BKE_context.h" #include "BKE_main.h" @@ -72,6 +73,8 @@ typedef struct Eyedropper { bool accum_start; /* has mouse been pressed */ float accum_col[3]; int accum_tot; + + bool accumulate; /* Color picking for cryptomatte, without accumulation. */ } Eyedropper; static bool eyedropper_init(bContext *C, wmOperator *op) @@ -80,6 +83,7 @@ static bool eyedropper_init(bContext *C, wmOperator *op) Eyedropper *eye; op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper"); + eye->accumulate = !STREQ(op->type->idname, "UI_OT_eyedropper_color_crypto"); UI_context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index); @@ -207,29 +211,30 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3 RNA_property_update(C, &eye->ptr, eye->prop); } -/* set sample from accumulated values */ -static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye) -{ - float col[3]; - mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot); - eyedropper_color_set(C, eye, col); -} - -/* single point sample & set */ static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my) { + /* Accumulate color. */ float col[3]; eyedropper_color_sample_fl(C, mx, my, col); - eyedropper_color_set(C, eye, col); -} -static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, int my) -{ - float col[3]; - eyedropper_color_sample_fl(C, mx, my, col); - /* delay linear conversion */ - add_v3_v3(eye->accum_col, col); - eye->accum_tot++; + if (eye->accumulate) { + add_v3_v3(eye->accum_col, col); + eye->accum_tot++; + } + else { + copy_v3_v3(eye->accum_col, col); + eye->accum_tot = 1; + } + + /* Apply to property. */ + float accum_col[3]; + if (eye->accum_tot > 1) { + mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / (float)eye->accum_tot); + } + else { + copy_v3_v3(accum_col, eye->accum_col); + } + eyedropper_color_set(C, eye, accum_col); } static void eyedropper_cancel(bContext *C, wmOperator *op) @@ -254,29 +259,24 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event) if (eye->accum_tot == 0) { eyedropper_color_sample(C, eye, event->x, event->y); } - else { - eyedropper_color_set_accum(C, eye); - } eyedropper_exit(C, op); return OPERATOR_FINISHED; case EYE_MODAL_SAMPLE_BEGIN: /* enable accum and make first sample */ eye->accum_start = true; - eyedropper_color_sample_accum(C, eye, event->x, event->y); + eyedropper_color_sample(C, eye, event->x, event->y); break; case EYE_MODAL_SAMPLE_RESET: eye->accum_tot = 0; zero_v3(eye->accum_col); - eyedropper_color_sample_accum(C, eye, event->x, event->y); - eyedropper_color_set_accum(C, eye); + eyedropper_color_sample(C, eye, event->x, event->y); break; } } - else if (event->type == MOUSEMOVE) { + else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { if (eye->accum_start) { /* button is pressed so keep sampling */ - eyedropper_color_sample_accum(C, eye, event->x, event->y); - eyedropper_color_set_accum(C, eye); + eyedropper_color_sample(C, eye, event->x, event->y); } } @@ -321,20 +321,9 @@ static int eyedropper_exec(bContext *C, wmOperator *op) static bool eyedropper_poll(bContext *C) { - PointerRNA ptr; - PropertyRNA *prop; - int index_dummy; - uiBut *but; - - /* Only color buttons */ - if ((CTX_wm_window(C) != NULL) && - (but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) && - (but->type == UI_BTYPE_COLOR)) - { - return 1; - } - - return 0; + /* Actual test for active button happens later, since we don't + * know which one is active until mouse over. */ + return (CTX_wm_window(C) != NULL); } void UI_OT_eyedropper_color(wmOperatorType *ot) @@ -353,6 +342,22 @@ void UI_OT_eyedropper_color(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; +} + +void UI_OT_eyedropper_color_crypto(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Cryptomatte Eyedropper"; + ot->idname = "UI_OT_eyedropper_color_crypto"; + ot->description = "Pick a color from Cryptomatte node Pick output image"; - /* properties */ + /* api callbacks */ + ot->invoke = eyedropper_invoke; + ot->modal = eyedropper_modal; + ot->cancel = eyedropper_cancel; + ot->exec = eyedropper_exec; + ot->poll = eyedropper_poll; + + /* flags */ + ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index cc86530871d..dc5e100b5f2 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -763,6 +763,7 @@ struct wmKeyMap *eyedropper_colorband_modal_keymap(struct wmKeyConfig *keyconf); /* interface_eyedropper_color.c */ void UI_OT_eyedropper_color(struct wmOperatorType *ot); +void UI_OT_eyedropper_color_crypto(struct wmOperatorType *ot); /* interface_eyedropper_colorband.c */ void UI_OT_eyedropper_colorband(struct wmOperatorType *ot); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 9a4ea41141a..1e67ecdfc90 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1138,6 +1138,7 @@ void ED_operatortypes_ui(void) /* external */ WM_operatortype_append(UI_OT_eyedropper_color); + WM_operatortype_append(UI_OT_eyedropper_color_crypto); WM_operatortype_append(UI_OT_eyedropper_colorband); WM_operatortype_append(UI_OT_eyedropper_colorband_point); WM_operatortype_append(UI_OT_eyedropper_id); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index bd4bb032717..daee0d3af3f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2572,6 +2572,24 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, } } +void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propname) +{ + PropertyRNA *prop = RNA_struct_find_property(ptr, propname); + uiBlock *block; + uiBut *but; + + if (!prop) { + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); + return; + } + + block = uiLayoutGetBlock(layout); + + but = uiDefIconTextButO(block, UI_BTYPE_BUT, "UI_OT_eyedropper_color_crypto", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, RNA_property_ui_name(prop), 0, 0, UI_UNIT_X, UI_UNIT_Y, RNA_property_ui_description(prop)); + but->rnapoin = *ptr; + but->rnaprop = prop; + but->rnaindex = -1; +} /********************* Layer Buttons Template ************************/ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index b0440b39823..23df1b72c37 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2544,6 +2544,25 @@ static void node_composit_buts_sunbeams(uiLayout *layout, bContext *UNUSED(C), P uiItemR(layout, ptr, "ray_length", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } +static void node_composit_buts_cryptomatte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *col = uiLayoutColumn(layout, true); + + uiItemL(col, IFACE_("Matte Objects:"), ICON_NONE); + + uiLayout *row = uiLayoutRow(col, true); + uiTemplateCryptoPicker(row, ptr, "add"); + uiTemplateCryptoPicker(row, ptr, "remove"); + + uiItemR(col, ptr, "matte_id", 0, "", ICON_NONE); +} + +static void node_composit_buts_cryptomatte_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *UNUSED(ptr)) +{ + uiItemO(layout, IFACE_("Add Crypto Layer"), ICON_ZOOMIN, "NODE_OT_cryptomatte_layer_add"); + uiItemO(layout, IFACE_("Remove Crypto Layer"), ICON_ZOOMOUT, "NODE_OT_cryptomatte_layer_remove"); +} + static void node_composit_buts_brightcontrast(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "use_premultiply", 0, NULL, ICON_NONE); @@ -2776,6 +2795,10 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_SUNBEAMS: ntype->draw_buttons = node_composit_buts_sunbeams; break; + case CMP_NODE_CRYPTOMATTE: + ntype->draw_buttons = node_composit_buts_cryptomatte; + ntype->draw_buttons_ex = node_composit_buts_cryptomatte_ex; + break; case CMP_NODE_BRIGHTCONTRAST: ntype->draw_buttons = node_composit_buts_brightcontrast; } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index c49c8c201c4..97c5157486d 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2611,3 +2611,93 @@ void NODE_OT_clear_viewer_border(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + +/* ****************** Cryptomatte Add Socket ******************* */ + +static int node_cryptomatte_add_socket_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceNode *snode = CTX_wm_space_node(C); + PointerRNA ptr = CTX_data_pointer_get(C, "node"); + bNodeTree *ntree = NULL; + bNode *node = NULL; + + if (ptr.data) { + node = ptr.data; + ntree = ptr.id.data; + } + else if (snode && snode->edittree) { + ntree = snode->edittree; + node = nodeGetActive(snode->edittree); + } + + if (!node || node->type != CMP_NODE_CRYPTOMATTE) { + return OPERATOR_CANCELLED; + } + + ntreeCompositCryptomatteAddSocket(ntree, node); + + snode_notify(C, snode); + + return OPERATOR_FINISHED; +} + +void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Cryptomatte Socket"; + ot->description = "Add a new input layer to a Cryptomatte node"; + ot->idname = "NODE_OT_cryptomatte_layer_add"; + + /* callbacks */ + ot->exec = node_cryptomatte_add_socket_exec; + ot->poll = composite_node_editable; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/* ****************** Cryptomatte Remove Socket ******************* */ + +static int node_cryptomatte_remove_socket_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceNode *snode = CTX_wm_space_node(C); + PointerRNA ptr = CTX_data_pointer_get(C, "node"); + bNodeTree *ntree = NULL; + bNode *node = NULL; + + if (ptr.data) { + node = ptr.data; + ntree = ptr.id.data; + } + else if (snode && snode->edittree) { + ntree = snode->edittree; + node = nodeGetActive(snode->edittree); + } + + if (!node || node->type != CMP_NODE_CRYPTOMATTE) { + return OPERATOR_CANCELLED; + } + + if (!ntreeCompositCryptomatteRemoveSocket(ntree, node)) { + return OPERATOR_CANCELLED; + } + + snode_notify(C, snode); + + return OPERATOR_FINISHED; +} + +void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Cryptomatte Socket"; + ot->description = "Remove layer from a Crytpomatte node"; + ot->idname = "NODE_OT_cryptomatte_layer_remove"; + + /* callbacks */ + ot->exec = node_cryptomatte_remove_socket_exec; + ot->poll = composite_node_editable; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index fd62c52bd5a..9b396aa9642 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -222,6 +222,9 @@ void NODE_OT_shader_script_update(struct wmOperatorType *ot); void NODE_OT_viewer_border(struct wmOperatorType *ot); void NODE_OT_clear_viewer_border(struct wmOperatorType *ot); +void NODE_OT_cryptomatte_layer_add(struct wmOperatorType *ot); +void NODE_OT_cryptomatte_layer_remove(struct wmOperatorType *ot); + extern const char *node_context_dir[]; // XXXXXX diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index d7ded62a988..ea07341beb9 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -130,6 +130,9 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_tree_socket_add); WM_operatortype_append(NODE_OT_tree_socket_remove); WM_operatortype_append(NODE_OT_tree_socket_move); + + WM_operatortype_append(NODE_OT_cryptomatte_layer_add); + WM_operatortype_append(NODE_OT_cryptomatte_layer_remove); } void ED_operatormacros_node(void) diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 129172315dd..00758bd1379 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -907,6 +907,14 @@ typedef struct NodeSunBeams { float ray_length; } NodeSunBeams; +typedef struct NodeCryptomatte { + float add[3]; + float remove[3]; + char *matte_id; + int num_inputs; + int pad; +} NodeCryptomatte; + /* script node mode */ #define NODE_SCRIPT_INTERNAL 0 #define NODE_SCRIPT_EXTERNAL 1 diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index e66c1e937e6..52fbadd0f54 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2880,6 +2880,48 @@ static void rna_NodeColorBalance_update_cdl(Main *bmain, Scene *scene, PointerRN rna_Node_update(bmain, scene, ptr); } +static void rna_NodeCryptomatte_matte_get(PointerRNA *ptr, char *value) +{ + bNode *node = (bNode *)ptr->data; + NodeCryptomatte *nc = node->storage; + + strcpy(value, (nc->matte_id) ? nc->matte_id : ""); +} + +static int rna_NodeCryptomatte_matte_length(PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + NodeCryptomatte *nc = node->storage; + + return (nc->matte_id) ? strlen(nc->matte_id) : 0; +} + +static void rna_NodeCryptomatte_matte_set(PointerRNA *ptr, const char *value) +{ + bNode *node = (bNode *)ptr->data; + NodeCryptomatte *nc = node->storage; + + if (nc->matte_id) + MEM_freeN(nc->matte_id); + + if (value && value[0]) + nc->matte_id = BLI_strdup(value); + else + nc->matte_id = NULL; +} + +static void rna_NodeCryptomatte_update_add(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + ntreeCompositCryptomatteSyncFromAdd(ptr->id.data, ptr->data); + rna_Node_update(bmain, scene, ptr); +} + +static void rna_NodeCryptomatte_update_remove(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + ntreeCompositCryptomatteSyncFromRemove(ptr->id.data, ptr->data); + rna_Node_update(bmain, scene, ptr); +} + /* ******** Node Socket Types ******** */ static PointerRNA rna_NodeOutputFile_slot_layer_get(CollectionPropertyIterator *iter) @@ -6977,6 +7019,32 @@ static void def_cmp_sunbeams(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_cmp_cryptomatte(StructRNA *srna) +{ + PropertyRNA *prop; + static float default_1[3] = {1.f, 1.f, 1.f}; + + RNA_def_struct_sdna_from(srna, "NodeCryptomatte", "storage"); + prop = RNA_def_property(srna, "matte_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_NodeCryptomatte_matte_get", "rna_NodeCryptomatte_matte_length", + "rna_NodeCryptomatte_matte_set"); + RNA_def_property_ui_text(prop, "Matte Objects", "List of object and material crypto IDs to include in matte"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + + prop = RNA_def_property(srna, "add", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_array_default(prop, default_1); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_text(prop, "Add", "Add object or material to matte, by picking a color from the Pick output"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_add"); + + prop = RNA_def_property(srna, "remove", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_array_default(prop, default_1); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_text(prop, "Remove", "Remove object or material from matte, by picking a color from the Pick output"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_remove"); +} + /* -- Texture Nodes --------------------------------------------------------- */ static void def_tex_output(StructRNA *srna) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index cc0bef30047..5a5d5997878 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -59,6 +59,7 @@ set(SRC composite/nodes/node_composite_composite.c composite/nodes/node_composite_cornerpin.c composite/nodes/node_composite_crop.c + composite/nodes/node_composite_cryptomatte.c composite/nodes/node_composite_curves.c composite/nodes/node_composite_despeckle.c composite/nodes/node_composite_doubleEdgeMask.c diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h index a5c2e604f46..2a82b706de5 100644 --- a/source/blender/nodes/NOD_composite.h +++ b/source/blender/nodes/NOD_composite.h @@ -109,6 +109,7 @@ void register_node_type_cmp_luma_matte(void); void register_node_type_cmp_doubleedgemask(void); void register_node_type_cmp_keyingscreen(void); void register_node_type_cmp_keying(void); +void register_node_type_cmp_cryptomatte(void); void register_node_type_cmp_translate(void); void register_node_type_cmp_rotate(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 5217c7dc6e7..a4f8a798576 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -219,6 +219,7 @@ DefNode( CompositorNode, CMP_NODE_PIXELATE, 0, "PIXEL DefNode( CompositorNode, CMP_NODE_PLANETRACKDEFORM,def_cmp_planetrackdeform,"PLANETRACKDEFORM",PlaneTrackDeform,"Plane Track Deform","" ) DefNode( CompositorNode, CMP_NODE_CORNERPIN, 0, "CORNERPIN", CornerPin, "Corner Pin", "" ) DefNode( CompositorNode, CMP_NODE_SUNBEAMS, def_cmp_sunbeams, "SUNBEAMS", SunBeams, "Sun Beams", "" ) +DefNode( CompositorNode, CMP_NODE_CRYPTOMATTE, def_cmp_cryptomatte, "CRYPTOMATTE", Cryptomatte, "Cryptomatte", "" ) DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c new file mode 100644 index 00000000000..488dfa6756e --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c @@ -0,0 +1,309 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Lukas Stockner, Stefan Werner + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_cryptomatte.c + * \ingroup cmpnodes + */ + +#include "node_composite_util.h" +#include "BLI_dynstr.h" +#include "BLI_hash_mm3.h" +#include "BLI_assert.h" + +#ifndef max + #define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min + #define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +/* this is taken from the cryptomatte specification 1.0 */ + +static inline float hash_to_float(uint32_t hash) +{ + uint32_t mantissa = hash & (( 1 << 23) - 1); + uint32_t exponent = (hash >> 23) & ((1 << 8) - 1); + exponent = max(exponent, (uint32_t) 1); + exponent = min(exponent, (uint32_t) 254); + exponent = exponent << 23; + uint32_t sign = (hash >> 31); + sign = sign << 31; + uint32_t float_bits = sign | exponent | mantissa; + float f; + /* Bit casting relies on equal size for both types. */ + BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "float and uint32_t are not the same size") + memcpy(&f, &float_bits, sizeof(float)); + return f; +} + +static void cryptomatte_add(NodeCryptomatte* n, float f) +{ + /* Turn the number into a string. */ + char number[32]; + BLI_snprintf(number, sizeof(number), "<%.9g>", f); + + /* Search if we already have the number. */ + if (n->matte_id && strlen(n->matte_id) != 0) { + size_t start = 0; + const size_t end = strlen(n->matte_id); + size_t token_len = 0; + while (start < end) { + /* Ignore leading whitespace. */ + while (start < end && n->matte_id[start] == ' ') { + ++start; + } + + /* Find the next seprator. */ + char* token_end = strchr(n->matte_id+start, ','); + if (token_end == NULL || token_end == n->matte_id+start) { + token_end = n->matte_id+end; + } + /* Be aware that token_len still contains any trailing white space. */ + token_len = token_end - (n->matte_id + start); + + /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */ + if (n->matte_id[start] == '<') { + if (strncmp(n->matte_id+start, number, strlen(number)) == 0) { + /* This number is already there, so continue. */ + return; + } + } + else { + /* Remove trailing white space */ + size_t name_len = token_len; + while (n->matte_id[start+name_len] == ' ' && name_len > 0) { + name_len--; + } + /* Calculate the hash of the token and compare. */ + uint32_t hash = BLI_hash_mm3((const unsigned char*)(n->matte_id+start), name_len, 0); + if (f == hash_to_float(hash)) { + return; + } + } + start += token_len+1; + } + } + + DynStr *new_matte = BLI_dynstr_new(); + if (!new_matte) { + return; + } + + if(n->matte_id) { + BLI_dynstr_append(new_matte, n->matte_id); + MEM_freeN(n->matte_id); + } + + if(BLI_dynstr_get_len(new_matte) > 0) { + BLI_dynstr_append(new_matte, ","); + } + BLI_dynstr_append(new_matte, number); + n->matte_id = BLI_dynstr_get_cstring(new_matte); + BLI_dynstr_free(new_matte); +} + +static void cryptomatte_remove(NodeCryptomatte*n, float f) +{ + if (n->matte_id == NULL || strlen(n->matte_id) == 0) { + /* Empty string, nothing to remove. */ + return; + } + + /* This will be the new string without the removed key. */ + DynStr *new_matte = BLI_dynstr_new(); + if (!new_matte) { + return; + } + + /* Turn the number into a string. */ + static char number[32]; + BLI_snprintf(number, sizeof(number), "<%.9g>", f); + + /* Search if we already have the number. */ + size_t start = 0; + const size_t end = strlen(n->matte_id); + size_t token_len = 0; + bool is_first = true; + while (start < end) { + bool skip = false; + /* Ignore leading whitespace or commas. */ + while (start < end && ((n->matte_id[start] == ' ') || (n->matte_id[start] == ','))) { + ++start; + } + + /* Find the next seprator. */ + char* token_end = strchr(n->matte_id+start+1, ','); + if (token_end == NULL || token_end == n->matte_id+start) { + token_end = n->matte_id+end; + } + /* Be aware that token_len still contains any trailing white space. */ + token_len = token_end - (n->matte_id + start); + + if (token_len == 1) { + skip = true; + } + /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */ + else if (n->matte_id[start] == '<') { + if (strncmp(n->matte_id+start, number, strlen(number)) == 0) { + /* This number is already there, so skip it. */ + skip = true; + } + } + else { + /* Remove trailing white space */ + size_t name_len = token_len; + while (n->matte_id[start+name_len] == ' ' && name_len > 0) { + name_len--; + } + /* Calculate the hash of the token and compare. */ + uint32_t hash = BLI_hash_mm3((const unsigned char*)(n->matte_id+start), name_len, 0); + if (f == hash_to_float(hash)) { + skip = true; + } + } + if (!skip) { + if (is_first) { + is_first = false; + } + else { + BLI_dynstr_append(new_matte, ", "); + } + BLI_dynstr_nappend(new_matte, n->matte_id+start, token_len); + } + start += token_len+1; + } + + if(n->matte_id) { + MEM_freeN(n->matte_id); + n->matte_id = NULL; + } + if(BLI_dynstr_get_len(new_matte) > 0) { + n->matte_id = BLI_dynstr_get_cstring(new_matte); + } + BLI_dynstr_free(new_matte); +} + +static bNodeSocketTemplate outputs[] = { + { SOCK_RGBA, 0, N_("Image")}, + { SOCK_FLOAT, 0, N_("Matte")}, + { SOCK_RGBA, 0, N_("Pick")}, + { -1, 0, "" } +}; + +void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *UNUSED(ntree), bNode *node) +{ + NodeCryptomatte *n = node->storage; + if (n->add[0] != 0.0f) { + cryptomatte_add(n, n->add[0]); + n->add[0] = 0.0f; + n->add[1] = 0.0f; + n->add[2] = 0.0f; + } +} + +void ntreeCompositCryptomatteSyncFromRemove(bNodeTree *UNUSED(ntree), bNode *node) +{ + NodeCryptomatte *n = node->storage; + if (n->remove[0] != 0.0f) { + cryptomatte_remove(n, n->remove[0]); + n->remove[0] = 0.0f; + n->remove[1] = 0.0f; + n->remove[2] = 0.0f; + } +} + +bNodeSocket *ntreeCompositCryptomatteAddSocket(bNodeTree *ntree, bNode *node) +{ + NodeCryptomatte *n = node->storage; + char sockname[32]; + n->num_inputs++; + BLI_snprintf(sockname, sizeof(sockname), "Crypto %.2d", n->num_inputs-1); + bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, sockname); + return sock; +} + +int ntreeCompositCryptomatteRemoveSocket(bNodeTree *ntree, bNode *node) +{ + NodeCryptomatte *n = node->storage; + if (n->num_inputs < 2) { + return 0; + } + bNodeSocket *sock = node->inputs.last; + nodeRemoveSocket(ntree, node, sock); + n->num_inputs--; + return 1; +} + +static void init(bNodeTree *ntree, bNode *node) +{ + NodeCryptomatte *user = MEM_callocN(sizeof(NodeCryptomatte), "cryptomatte user"); + node->storage = user; + + + nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, "image", "Image"); + + /* Add three inputs by default, as recommended by the Cryptomatte specification. */ + ntreeCompositCryptomatteAddSocket(ntree, node); + ntreeCompositCryptomatteAddSocket(ntree, node); + ntreeCompositCryptomatteAddSocket(ntree, node); +} + +static void node_free_cryptomatte(bNode *node) +{ + NodeCryptomatte *nc = node->storage; + + if (nc) { + if (nc->matte_id) { + MEM_freeN(nc->matte_id); + } + + MEM_freeN(nc); + } +} + +static void node_copy_cryptomatte(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node) +{ + NodeCryptomatte *src_nc = src_node->storage; + NodeCryptomatte *dest_nc = MEM_dupallocN(src_nc); + + if (src_nc->matte_id) + dest_nc->matte_id = MEM_dupallocN(src_nc->matte_id); + + dest_node->storage = dest_nc; +} + +void register_node_type_cmp_cryptomatte(void) +{ + static bNodeType ntype; + + cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE, "Cryptomatte", NODE_CLASS_CONVERTOR, 0); + node_type_socket_templates(&ntype, NULL, outputs); + node_type_init(&ntype, init); + node_type_storage(&ntype, "NodeCryptomatte", node_free_cryptomatte, node_copy_cryptomatte); + nodeRegisterType(&ntype); +} -- cgit v1.2.3 From 566b319335563888e252b2186c93606ad41ff216 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 18 Jul 2018 13:34:22 +0200 Subject: Cleanup: Cryptomatte node style tweaks. --- source/blender/blenlib/intern/hash_mm3.c | 2 +- source/blender/compositor/nodes/COM_CryptomatteNode.cpp | 5 +++-- .../nodes/composite/nodes/node_composite_cryptomatte.c | 17 +++++------------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/source/blender/blenlib/intern/hash_mm3.c b/source/blender/blenlib/intern/hash_mm3.c index ac483795e45..5ead9ceca63 100644 --- a/source/blender/blenlib/intern/hash_mm3.c +++ b/source/blender/blenlib/intern/hash_mm3.c @@ -49,7 +49,7 @@ static inline uint32_t rotl32(uint32_t x, int8_t r) return (x << r) | (x >> (32 - r)); } # define ROTL32(x,y) rotl32(x,y) -# define BIG_CONSTANT(x) (x##LLU) +# define BIG_CONSTANT(x) (x##LLU) #endif /* !defined(_MSC_VER) */ /* Block read - if your platform needs to do endian-swapping or can only diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp index c8134068543..bc115e66c20 100644 --- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp +++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp @@ -35,7 +35,8 @@ CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode) } /* This is taken from the Cryptomatte specification 1.0. */ -static inline float hash_to_float(uint32_t hash) { +static inline float hash_to_float(uint32_t hash) +{ uint32_t mantissa = hash & (( 1 << 23) - 1); uint32_t exponent = (hash >> 23) & ((1 << 8) - 1); exponent = max(exponent, (uint32_t) 1); @@ -95,7 +96,7 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos for (int i = 0; i < getNumberOfInputSockets()-1; ++i) { converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i)); } - + SeparateChannelOperation *separateOperation = new SeparateChannelOperation; separateOperation->setChannel(3); converter.addOperation(separateOperation); diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c index 488dfa6756e..0231e4717b2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,17 +30,10 @@ */ #include "node_composite_util.h" +#include "BLI_assert.h" #include "BLI_dynstr.h" #include "BLI_hash_mm3.h" -#include "BLI_assert.h" - -#ifndef max - #define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "BLI_utildefines.h" /* this is taken from the cryptomatte specification 1.0 */ @@ -48,8 +41,8 @@ static inline float hash_to_float(uint32_t hash) { uint32_t mantissa = hash & (( 1 << 23) - 1); uint32_t exponent = (hash >> 23) & ((1 << 8) - 1); - exponent = max(exponent, (uint32_t) 1); - exponent = min(exponent, (uint32_t) 254); + exponent = MAX2(exponent, (uint32_t) 1); + exponent = MIN2(exponent, (uint32_t) 254); exponent = exponent << 23; uint32_t sign = (hash >> 31); sign = sign << 31; -- cgit v1.2.3 From 5078b9d2d08a34ae3786100c2301ea960165e7f2 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Wed, 18 Jul 2018 11:14:43 +0200 Subject: Cycles: add Principled Hair BSDF. This is a physically-based, easy-to-use shader for rendering hair and fur, with controls for melanin, roughness and randomization. Based on the paper "A Practical and Controllable Hair and Fur Model for Production Path Tracing". Implemented by Leonardo E. Segovia and Lukas Stockner, part of Google Summer of Code 2018. --- intern/cycles/blender/blender_shader.cpp | 6 + intern/cycles/kernel/CMakeLists.txt | 1 + intern/cycles/kernel/closure/bsdf.h | 14 + .../cycles/kernel/closure/bsdf_hair_principled.h | 502 +++++++++++++++++++++ intern/cycles/kernel/geom/geom_curve.h | 27 ++ intern/cycles/kernel/geom/geom_curve_intersect.h | 25 - intern/cycles/kernel/kernel_compat_opencl.h | 1 + intern/cycles/kernel/kernel_volume.h | 6 +- intern/cycles/kernel/osl/osl_closures.cpp | 61 ++- intern/cycles/kernel/osl/osl_closures.h | 1 + intern/cycles/kernel/shaders/CMakeLists.txt | 1 + .../kernel/shaders/node_principled_hair_bsdf.osl | 105 +++++ intern/cycles/kernel/shaders/stdosl.h | 1 + intern/cycles/kernel/svm/svm_closure.h | 120 ++++- intern/cycles/kernel/svm/svm_types.h | 10 +- intern/cycles/render/graph.cpp | 3 + intern/cycles/render/nodes.cpp | 133 ++++++ intern/cycles/render/nodes.h | 39 ++ intern/cycles/util/util_math.h | 19 + intern/cycles/util/util_math_float3.h | 10 + release/scripts/startup/nodeitems_builtins.py | 1 + source/blender/blenkernel/BKE_node.h | 2 + source/blender/blenkernel/intern/node.c | 1 + source/blender/editors/space_node/drawnode.c | 8 + source/blender/makesdna/DNA_node_types.h | 5 + source/blender/makesrna/intern/rna_nodetree.c | 22 + source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_shader.h | 1 + source/blender/nodes/NOD_static_types.h | 1 + .../nodes/node_shader_bsdf_hair_principled.c | 133 ++++++ 30 files changed, 1228 insertions(+), 32 deletions(-) create mode 100644 intern/cycles/kernel/closure/bsdf_hair_principled.h create mode 100644 intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl create mode 100644 source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 956f8f767a6..25e6db18588 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -524,6 +524,12 @@ static ShaderNode *add_node(Scene *scene, } node = hair; } + else if(b_node.is_a(&RNA_ShaderNodeBsdfHairPrincipled)) { + BL::ShaderNodeBsdfHairPrincipled b_principled_hair_node(b_node); + PrincipledHairBsdfNode *principled_hair = new PrincipledHairBsdfNode(); + principled_hair->parametrization = (NodePrincipledHairParametrization) get_enum(b_principled_hair_node.ptr, "parametrization", NODE_PRINCIPLED_HAIR_NUM, NODE_PRINCIPLED_HAIR_REFLECTANCE); + node = principled_hair; + } else if(b_node.is_a(&RNA_ShaderNodeBsdfPrincipled)) { BL::ShaderNodeBsdfPrincipled b_principled_node(b_node); PrincipledBsdfNode *principled = new PrincipledBsdfNode(); diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 092bec08a51..c4cad17429d 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -156,6 +156,7 @@ set(SRC_CLOSURE_HEADERS closure/volume.h closure/bsdf_principled_diffuse.h closure/bsdf_principled_sheen.h + closure/bsdf_hair_principled.h ) set(SRC_SVM_HEADERS diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h index f191b812f11..3a9629ea9d7 100644 --- a/intern/cycles/kernel/closure/bsdf.h +++ b/intern/cycles/kernel/closure/bsdf.h @@ -27,6 +27,7 @@ #include "kernel/closure/bsdf_ashikhmin_shirley.h" #include "kernel/closure/bsdf_toon.h" #include "kernel/closure/bsdf_hair.h" +#include "kernel/closure/bsdf_hair_principled.h" #include "kernel/closure/bsdf_principled_diffuse.h" #include "kernel/closure/bsdf_principled_sheen.h" #include "kernel/closure/bssrdf.h" @@ -171,6 +172,10 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg, label = bsdf_hair_transmission_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf); break; + case CLOSURE_BSDF_HAIR_PRINCIPLED_ID: + label = bsdf_principled_hair_sample(kg, sc, sd, randu, randv, + eval, omega_in, &domega_in->dx, &domega_in->dy, pdf); + break; #ifdef __PRINCIPLED__ case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID: case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID: @@ -284,6 +289,9 @@ float3 bsdf_eval(KernelGlobals *kg, case CLOSURE_BSDF_GLOSSY_TOON_ID: eval = bsdf_glossy_toon_eval_reflect(sc, sd->I, omega_in, pdf); break; + case CLOSURE_BSDF_HAIR_PRINCIPLED_ID: + eval = bsdf_principled_hair_eval(kg, sd, sc, omega_in, pdf); + break; case CLOSURE_BSDF_HAIR_REFLECTION_ID: eval = bsdf_hair_reflection_eval_reflect(sc, sd->I, omega_in, pdf); break; @@ -366,6 +374,9 @@ float3 bsdf_eval(KernelGlobals *kg, case CLOSURE_BSDF_GLOSSY_TOON_ID: eval = bsdf_glossy_toon_eval_transmit(sc, sd->I, omega_in, pdf); break; + case CLOSURE_BSDF_HAIR_PRINCIPLED_ID: + eval = bsdf_principled_hair_eval(kg, sd, sc, omega_in, pdf); + break; case CLOSURE_BSDF_HAIR_REFLECTION_ID: eval = bsdf_hair_reflection_eval_transmit(sc, sd->I, omega_in, pdf); break; @@ -424,6 +435,9 @@ ccl_device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness) case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID: bsdf_ashikhmin_shirley_blur(sc, roughness); break; + case CLOSURE_BSDF_HAIR_PRINCIPLED_ID: + bsdf_principled_hair_blur(sc, roughness); + break; default: break; } diff --git a/intern/cycles/kernel/closure/bsdf_hair_principled.h b/intern/cycles/kernel/closure/bsdf_hair_principled.h new file mode 100644 index 00000000000..4ee58089384 --- /dev/null +++ b/intern/cycles/kernel/closure/bsdf_hair_principled.h @@ -0,0 +1,502 @@ +/* + * Copyright 2018 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef __KERNEL_CPU__ +#include +#endif + +#include "kernel/kernel_color.h" + +#ifndef __BSDF_HAIR_PRINCIPLED_H__ +#define __BSDF_HAIR_PRINCIPLED_H__ + +CCL_NAMESPACE_BEGIN + +typedef ccl_addr_space struct PrincipledHairExtra { + /* Geometry data. */ + float4 geom; +} PrincipledHairExtra; + +typedef ccl_addr_space struct PrincipledHairBSDF { + SHADER_CLOSURE_BASE; + + /* Absorption coefficient. */ + float3 sigma; + /* Variance of the underlying logistic distribution. */ + float v; + /* Scale factor of the underlying logistic distribution. */ + float s; + /* Cuticle tilt angle. */ + float alpha; + /* IOR. */ + float eta; + /* Effective variance for the diffuse bounce only. */ + float m0_roughness; + + /* Extra closure. */ + PrincipledHairExtra *extra; +} PrincipledHairBSDF; + +static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledHairBSDF), "PrincipledHairBSDF is too large!"); +static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledHairExtra), "PrincipledHairExtra is too large!"); + +ccl_device_inline float cos_from_sin(const float s) +{ + return safe_sqrtf(1.0f - s*s); +} + +/* Gives the change in direction in the normal plane for the given angles and p-th-order scattering. */ +ccl_device_inline float delta_phi(int p, float gamma_o, float gamma_t) +{ + return 2.0f * p * gamma_t - 2.0f * gamma_o + p * M_PI_F; +} + +/* Remaps the given angle to [-pi, pi]. */ +ccl_device_inline float wrap_angle(float a) +{ + while(a > M_PI_F) { + a -= M_2PI_F; + } + while(a < -M_PI_F) { + a += M_2PI_F; + } + return a; +} + +/* Logistic distribution function. */ +ccl_device_inline float logistic(float x, float s) +{ + float v = expf(-fabsf(x)/s); + return v / (s * sqr(1.0f + v)); +} + +/* Logistic cumulative density function. */ +ccl_device_inline float logistic_cdf(float x, float s) +{ + float arg = -x/s; + /* expf() overflows if arg >= 89.0. */ + if(arg > 88.0f) { + return 0.0f; + } + else { + return 1.0f / (1.0f + expf(arg)); + } +} + +/* Numerical approximation to the Bessel function of the first kind. */ +ccl_device_inline float bessel_I0(float x) +{ + x = sqr(x); + float val = 1.0f + 0.25f*x; + float pow_x_2i = sqr(x); + uint64_t i_fac_2 = 1; + int pow_4_i = 16; + for(int i = 2; i < 10; i++) { + i_fac_2 *= i*i; + float newval = val + pow_x_2i / (pow_4_i * i_fac_2); + if(val == newval) { + return val; + } + val = newval; + pow_x_2i *= x; + pow_4_i *= 4; + } + return val; +} + +/* Logarithm of the Bessel function of the first kind. */ +ccl_device_inline float log_bessel_I0(float x) +{ + if (x > 12.0f) { + /* log(1/x) == -log(x) iff x > 0. + * This is only used with positive cosines */ + return x + 0.5f * (1.f / (8.0f * x) - M_LN_2PI_F - logf(x)); + } + else { + return logf(bessel_I0(x)); + } +} + +/* Logistic distribution limited to the interval [-pi, pi]. */ +ccl_device_inline float trimmed_logistic(float x, float s) +{ + /* The logistic distribution is symmetric and centered around zero, + * so logistic_cdf(x, s) = 1 - logistic_cdf(-x, s). + * Therefore, logistic_cdf(x, s)-logistic_cdf(-x, s) = 1 - 2*logistic_cdf(-x, s) */ + float scaling_fac = 1.0f - 2.0f*logistic_cdf(-M_PI_F, s); + float val = logistic(x, s); + return safe_divide(val, scaling_fac); +} + +/* Sampling function for the trimmed logistic function. */ +ccl_device_inline float sample_trimmed_logistic(float u, float s) +{ + float cdf_minuspi = logistic_cdf(-M_PI_F, s); + float x = -s*logf(1.0f / (u*(1.0f - 2.0f*cdf_minuspi) + cdf_minuspi) - 1.0f); + return clamp(x, -M_PI_F, M_PI_F); +} + +/* Azimuthal scattering function Np. */ +ccl_device_inline float azimuthal_scattering(float phi, + int p, + float s, + float gamma_o, + float gamma_t) +{ + float phi_o = wrap_angle(phi - delta_phi(p, gamma_o, gamma_t)); + float val = trimmed_logistic(phi_o, s); + return val; +} + +/* Longitudinal scattering function Mp. */ +ccl_device_inline float longitudinal_scattering(float sin_theta_i, + float cos_theta_i, + float sin_theta_o, + float cos_theta_o, + float v) +{ + float inv_v = 1.0f/v; + float cos_arg = cos_theta_i * cos_theta_o * inv_v; + float sin_arg = sin_theta_i * sin_theta_o * inv_v; + if(v <= 0.1f) { + float i0 = log_bessel_I0(cos_arg); + float val = expf(i0 - sin_arg - inv_v + 0.6931f + logf(0.5f*inv_v)); + return val; + } + else { + float i0 = bessel_I0(cos_arg); + float val = (expf(-sin_arg) * i0) / (sinhf(inv_v) * 2.0f * v); + return val; + } +} + +/* Combine the three values using their luminances. */ +ccl_device_inline float4 combine_with_energy(KernelGlobals *kg, float3 c) +{ + return make_float4(c.x, c.y, c.z, linear_rgb_to_gray(kg, c)); +} + +#ifdef __HAIR__ +/* Set up the hair closure. */ +ccl_device int bsdf_principled_hair_setup(ShaderData *sd, PrincipledHairBSDF *bsdf) +{ + bsdf->type = CLOSURE_BSDF_HAIR_PRINCIPLED_ID; + bsdf->v = clamp(bsdf->v, 0.001f, 1.0f); + bsdf->s = clamp(bsdf->s, 0.001f, 1.0f); + /* Apply Primary Reflection Roughness modifier. */ + bsdf->m0_roughness = clamp(bsdf->m0_roughness*bsdf->v, 0.001f, 1.0f); + + /* Map from roughness_u and roughness_v to variance and scale factor. */ + bsdf->v = sqr(0.726f*bsdf->v + 0.812f*sqr(bsdf->v) + 3.700f*pow20(bsdf->v)); + bsdf->s = (0.265f*bsdf->s + 1.194f*sqr(bsdf->s) + 5.372f*pow22(bsdf->s))*M_SQRT_PI_8_F; + bsdf->m0_roughness = sqr(0.726f*bsdf->m0_roughness + 0.812f*sqr(bsdf->m0_roughness) + 3.700f*pow20(bsdf->m0_roughness)); + + /* Compute local frame, aligned to curve tangent and ray direction. */ + float3 X = safe_normalize(sd->dPdu); + float3 Y = safe_normalize(cross(X, sd->I)); + float3 Z = safe_normalize(cross(X, Y)); + /* TODO: the solution below works where sd->Ng is the normal + * pointing from the center of the curve to the shading point. + * It doesn't work for triangles, see https://developer.blender.org/T43625 */ + + /* h -1..0..1 means the rays goes from grazing the hair, to hitting it at + * the center, to grazing the other edge. This is the sine of the angle + * between sd->Ng and Z, as seen from the tangent X. */ + + /* TODO: we convert this value to a cosine later and discard the sign, so + * we could probably save some operations. */ + float h = dot(cross(sd->Ng, X), Z); + + kernel_assert(fabsf(h) < 1.0f + 1e-4f); + kernel_assert(isfinite3_safe(Y)); + kernel_assert(isfinite_safe(h)); + + bsdf->extra->geom = make_float4(Y.x, Y.y, Y.z, h); + + return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_NEEDS_LCG; +} + +#endif /* __HAIR__ */ + +/* Given the Fresnel term and transmittance, generate the attenuation terms for each bounce. */ +ccl_device_inline void hair_attenuation(KernelGlobals *kg, + float f, + float3 T, + float4 *Ap) +{ + /* Primary specular (R). */ + Ap[0] = make_float4(f, f, f, f); + + /* Transmission (TT). */ + float3 col = sqr(1.0f - f) * T; + Ap[1] = combine_with_energy(kg, col); + + /* Secondary specular (TRT). */ + col *= T*f; + Ap[2] = combine_with_energy(kg, col); + + /* Residual component (TRRT+). */ + col *= safe_divide_color(T*f, make_float3(1.0f, 1.0f, 1.0f) - T*f); + Ap[3] = combine_with_energy(kg, col); + + /* Normalize sampling weights. */ + float totweight = Ap[0].w + Ap[1].w + Ap[2].w + Ap[3].w; + float fac = safe_divide(1.0f, totweight); + + Ap[0].w *= fac; + Ap[1].w *= fac; + Ap[2].w *= fac; + Ap[3].w *= fac; +} + +/* Given the tilt angle, generate the rotated theta_i for the different bounces. */ +ccl_device_inline void hair_alpha_angles(float sin_theta_i, + float cos_theta_i, + float alpha, + float *angles) +{ + float sin_1alpha = sinf(alpha); + float cos_1alpha = cos_from_sin(sin_1alpha); + float sin_2alpha = 2.0f*sin_1alpha*cos_1alpha; + float cos_2alpha = sqr(cos_1alpha) - sqr(sin_1alpha); + float sin_4alpha = 2.0f*sin_2alpha*cos_2alpha; + float cos_4alpha = sqr(cos_2alpha) - sqr(sin_2alpha); + + angles[0] = sin_theta_i*cos_2alpha + cos_theta_i*sin_2alpha; + angles[1] = fabsf(cos_theta_i*cos_2alpha - sin_theta_i*sin_2alpha); + angles[2] = sin_theta_i*cos_1alpha - cos_theta_i*sin_1alpha; + angles[3] = fabsf(cos_theta_i*cos_1alpha + sin_theta_i*sin_1alpha); + angles[4] = sin_theta_i*cos_4alpha - cos_theta_i*sin_4alpha; + angles[5] = fabsf(cos_theta_i*cos_4alpha + sin_theta_i*sin_4alpha); +} + +/* Evaluation function for our shader. */ +ccl_device float3 bsdf_principled_hair_eval(KernelGlobals *kg, + const ShaderData *sd, + const ShaderClosure *sc, + const float3 omega_in, + float *pdf) +{ + kernel_assert(isfinite3_safe(sd->P) && isfinite_safe(sd->ray_length)); + + const PrincipledHairBSDF *bsdf = (const PrincipledHairBSDF*) sc; + float3 Y = float4_to_float3(bsdf->extra->geom); + + float3 X = safe_normalize(sd->dPdu); + kernel_assert(fabsf(dot(X, Y)) < 1e-4f); + float3 Z = safe_normalize(cross(X, Y)); + + float3 wo = make_float3(dot(sd->I, X), dot(sd->I, Y), dot(sd->I, Z)); + float3 wi = make_float3(dot(omega_in, X), dot(omega_in, Y), dot(omega_in, Z)); + + float sin_theta_o = wo.x; + float cos_theta_o = cos_from_sin(sin_theta_o); + float phi_o = atan2f(wo.z, wo.y); + + float sin_theta_t = sin_theta_o / bsdf->eta; + float cos_theta_t = cos_from_sin(sin_theta_t); + + float sin_gamma_o = bsdf->extra->geom.w; + float cos_gamma_o = cos_from_sin(sin_gamma_o); + float gamma_o = safe_asinf(sin_gamma_o); + + float sin_gamma_t = sin_gamma_o * cos_theta_o / sqrtf(sqr(bsdf->eta) - sqr(sin_theta_o)); + float cos_gamma_t = cos_from_sin(sin_gamma_t); + float gamma_t = safe_asinf(sin_gamma_t); + + float3 T = exp3(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t)); + float4 Ap[4]; + hair_attenuation(kg, fresnel_dielectric_cos(cos_theta_o * cos_gamma_o, bsdf->eta), T, Ap); + + float sin_theta_i = wi.x; + float cos_theta_i = cos_from_sin(sin_theta_i); + float phi_i = atan2f(wi.z, wi.y); + + float phi = phi_i - phi_o; + + float angles[6]; + hair_alpha_angles(sin_theta_i, cos_theta_i, bsdf->alpha, angles); + + float4 F; + float Mp, Np; + + /* Primary specular (R). */ + Mp = longitudinal_scattering(angles[0], angles[1], sin_theta_o, cos_theta_o, bsdf->m0_roughness); + Np = azimuthal_scattering(phi, 0, bsdf->s, gamma_o, gamma_t); + F = Ap[0] * Mp * Np; + kernel_assert(isfinite3_safe(float4_to_float3(F))); + + /* Transmission (TT). */ + Mp = longitudinal_scattering(angles[2], angles[3], sin_theta_o, cos_theta_o, 0.25f*bsdf->v); + Np = azimuthal_scattering(phi, 1, bsdf->s, gamma_o, gamma_t); + F += Ap[1] * Mp * Np; + kernel_assert(isfinite3_safe(float4_to_float3(F))); + + /* Secondary specular (TRT). */ + Mp = longitudinal_scattering(angles[4], angles[5], sin_theta_o, cos_theta_o, 4.0f*bsdf->v); + Np = azimuthal_scattering(phi, 2, bsdf->s, gamma_o, gamma_t); + F += Ap[2] * Mp * Np; + kernel_assert(isfinite3_safe(float4_to_float3(F))); + + /* Residual component (TRRT+). */ + Mp = longitudinal_scattering(sin_theta_i, cos_theta_i, sin_theta_o, cos_theta_o, 4.0f*bsdf->v); + Np = M_1_2PI_F; + F += Ap[3] * Mp * Np; + kernel_assert(isfinite3_safe(float4_to_float3(F))); + + *pdf = F.w; + return float4_to_float3(F); +} + +/* Sampling function for the hair shader. */ +ccl_device int bsdf_principled_hair_sample(KernelGlobals *kg, + const ShaderClosure *sc, + ShaderData *sd, + float randu, + float randv, + float3 *eval, + float3 *omega_in, + float3 *domega_in_dx, + float3 *domega_in_dy, + float *pdf) +{ + PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*) sc; + + float3 Y = float4_to_float3(bsdf->extra->geom); + + float3 X = safe_normalize(sd->dPdu); + kernel_assert(fabsf(dot(X, Y)) < 1e-4f); + float3 Z = safe_normalize(cross(X, Y)); + + float3 wo = make_float3(dot(sd->I, X), dot(sd->I, Y), dot(sd->I, Z)); + + float2 u[2]; + u[0] = make_float2(randu, randv); + u[1].x = lcg_step_float_addrspace(&sd->lcg_state); + u[1].y = lcg_step_float_addrspace(&sd->lcg_state); + + float sin_theta_o = wo.x; + float cos_theta_o = cos_from_sin(sin_theta_o); + float phi_o = atan2f(wo.z, wo.y); + + float sin_theta_t = sin_theta_o / bsdf->eta; + float cos_theta_t = cos_from_sin(sin_theta_t); + + float sin_gamma_o = bsdf->extra->geom.w; + float cos_gamma_o = cos_from_sin(sin_gamma_o); + float gamma_o = safe_asinf(sin_gamma_o); + + float sin_gamma_t = sin_gamma_o * cos_theta_o / sqrtf(sqr(bsdf->eta) - sqr(sin_theta_o)); + float cos_gamma_t = cos_from_sin(sin_gamma_t); + float gamma_t = safe_asinf(sin_gamma_t); + + float3 T = exp3(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t)); + float4 Ap[4]; + hair_attenuation(kg, fresnel_dielectric_cos(cos_theta_o * cos_gamma_o, bsdf->eta), T, Ap); + + int p = 0; + for(; p < 3; p++) { + if(u[0].x < Ap[p].w) { + break; + } + u[0].x -= Ap[p].w; + } + + float v = bsdf->v; + if(p == 1) { + v *= 0.25f; + } + if(p >= 2) { + v *= 4.0f; + } + + u[1].x = max(u[1].x, 1e-5f); + float fac = 1.0f + v*logf(u[1].x + (1.0f - u[1].x)*expf(-2.0f/v)); + float sin_theta_i = -fac * sin_theta_o + cos_from_sin(fac) * cosf(M_2PI_F * u[1].y) * cos_theta_o; + float cos_theta_i = cos_from_sin(sin_theta_i); + + float angles[6]; + if(p < 3) { + hair_alpha_angles(sin_theta_i, cos_theta_i, -bsdf->alpha, angles); + sin_theta_i = angles[2*p]; + cos_theta_i = angles[2*p+1]; + } + + float phi; + if(p < 3) { + phi = delta_phi(p, gamma_o, gamma_t) + sample_trimmed_logistic(u[0].y, bsdf->s); + } + else { + phi = M_2PI_F*u[0].y; + } + float phi_i = phi_o + phi; + + hair_alpha_angles(sin_theta_i, cos_theta_i, bsdf->alpha, angles); + + float4 F; + float Mp, Np; + + /* Primary specular (R). */ + Mp = longitudinal_scattering(angles[0], angles[1], sin_theta_o, cos_theta_o, bsdf->m0_roughness); + Np = azimuthal_scattering(phi, 0, bsdf->s, gamma_o, gamma_t); + F = Ap[0] * Mp * Np; + kernel_assert(isfinite3_safe(float4_to_float3(F))); + + /* Transmission (TT). */ + Mp = longitudinal_scattering(angles[2], angles[3], sin_theta_o, cos_theta_o, 0.25f*bsdf->v); + Np = azimuthal_scattering(phi, 1, bsdf->s, gamma_o, gamma_t); + F += Ap[1] * Mp * Np; + kernel_assert(isfinite3_safe(float4_to_float3(F))); + + /* Secondary specular (TRT). */ + Mp = longitudinal_scattering(angles[4], angles[5], sin_theta_o, cos_theta_o, 4.0f*bsdf->v); + Np = azimuthal_scattering(phi, 2, bsdf->s, gamma_o, gamma_t); + F += Ap[2] * Mp * Np; + kernel_assert(isfinite3_safe(float4_to_float3(F))); + + /* Residual component (TRRT+). */ + Mp = longitudinal_scattering(sin_theta_i, cos_theta_i, sin_theta_o, cos_theta_o, 4.0f*bsdf->v); + Np = M_1_2PI_F; + F += Ap[3] * Mp * Np; + kernel_assert(isfinite3_safe(float4_to_float3(F))); + + *eval = float4_to_float3(F); + *pdf = F.w; + + *omega_in = X*sin_theta_i + Y*cos_theta_i*cosf(phi_i) + Z*cos_theta_i*sinf(phi_i); + +#ifdef __RAY_DIFFERENTIALS__ + float3 N = safe_normalize(sd->I + *omega_in); + *domega_in_dx = (2 * dot(N, sd->dI.dx)) * N - sd->dI.dx; + *domega_in_dy = (2 * dot(N, sd->dI.dy)) * N - sd->dI.dy; +#endif + + return LABEL_GLOSSY|((p == 0)? LABEL_REFLECT : LABEL_TRANSMIT); +} + +/* Implements Filter Glossy by capping the effective roughness. */ +ccl_device void bsdf_principled_hair_blur(ShaderClosure *sc, float roughness) +{ + PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)sc; + + bsdf->v = fmaxf(roughness, bsdf->v); + bsdf->s = fmaxf(roughness, bsdf->s); + bsdf->m0_roughness = fmaxf(roughness, bsdf->m0_roughness); +} + +CCL_NAMESPACE_END + +#endif /* __BSDF_HAIR_PRINCIPLED_H__ */ diff --git a/intern/cycles/kernel/geom/geom_curve.h b/intern/cycles/kernel/geom/geom_curve.h index e35267f02bf..dea0c742ed7 100644 --- a/intern/cycles/kernel/geom/geom_curve.h +++ b/intern/cycles/kernel/geom/geom_curve.h @@ -23,6 +23,33 @@ CCL_NAMESPACE_BEGIN #ifdef __HAIR__ +/* Interpolation of curve geometry */ + +ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3) +{ + float fc = 0.71f; + float data[4]; + float t2 = t * t; + data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc; + data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t; + data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc; + data[3] = 3.0f * fc * t2 - 2.0f * fc * t; + return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; +} + +ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3) +{ + float data[4]; + float fc = 0.71f; + float t2 = t * t; + float t3 = t2 * t; + data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t; + data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f; + data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t; + data[3] = fc * t3 - fc * t2; + return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; +} + /* Reading attributes on various curve elements */ ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy) diff --git a/intern/cycles/kernel/geom/geom_curve_intersect.h b/intern/cycles/kernel/geom/geom_curve_intersect.h index 46c3f408f0b..4cfbe21685c 100644 --- a/intern/cycles/kernel/geom/geom_curve_intersect.h +++ b/intern/cycles/kernel/geom/geom_curve_intersect.h @@ -752,31 +752,6 @@ ccl_device_forceinline bool curve_intersect(KernelGlobals *kg, #endif } -ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3) -{ - float fc = 0.71f; - float data[4]; - float t2 = t * t; - data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc; - data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t; - data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc; - data[3] = 3.0f * fc * t2 - 2.0f * fc * t; - return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; -} - -ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3) -{ - float data[4]; - float fc = 0.71f; - float t2 = t * t; - float t3 = t2 * t; - data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t; - data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f; - data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t; - data[3] = fc * t3 - fc * t2; - return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; -} - ccl_device_inline float3 curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h index d1ae10a0384..3f7e264fbee 100644 --- a/intern/cycles/kernel/kernel_compat_opencl.h +++ b/intern/cycles/kernel/kernel_compat_opencl.h @@ -123,6 +123,7 @@ #define fmaxf(x, y) fmax(((float)(x)), ((float)(y))) #define fminf(x, y) fmin(((float)(x)), ((float)(y))) #define fmodf(x, y) fmod((float)(x), (float)(y)) +#define sinhf(x) sinh(((float)(x))) #ifndef __CL_USE_NATIVE__ # define sinf(x) native_sin(((float)(x))) diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h index a7072c3ad03..d71761a97bc 100644 --- a/intern/cycles/kernel/kernel_volume.h +++ b/intern/cycles/kernel/kernel_volume.h @@ -91,7 +91,7 @@ ccl_device_inline bool volume_shader_sample(KernelGlobals *kg, ccl_device float3 volume_color_transmittance(float3 sigma, float t) { - return make_float3(expf(-sigma.x * t), expf(-sigma.y * t), expf(-sigma.z * t)); + return exp3(-sigma * t); } ccl_device float kernel_volume_channel_get(float3 value, int channel) @@ -234,7 +234,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg, sum += (-sigma_t * (new_t - t)); if((i & 0x07) == 0) { /* ToDo: Other interval? */ - tp = *throughput * make_float3(expf(sum.x), expf(sum.y), expf(sum.z)); + tp = *throughput * exp3(sum); /* stop if nearly all light is blocked */ if(tp.x < tp_eps && tp.y < tp_eps && tp.z < tp_eps) @@ -246,7 +246,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg, t = new_t; if(t == ray->t) { /* Update throughput in case we haven't done it above */ - tp = *throughput * make_float3(expf(sum.x), expf(sum.y), expf(sum.z)); + tp = *throughput * exp3(sum); break; } } diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp index 581b38e65c0..8c7ae30725c 100644 --- a/intern/cycles/kernel/osl/osl_closures.cpp +++ b/intern/cycles/kernel/osl/osl_closures.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. * All Rights Reserved. * - * Modifications Copyright 2011, Blender Foundation. + * Modifications Copyright 2011-2018, Blender Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -59,6 +59,7 @@ #include "kernel/closure/bsdf_ashikhmin_shirley.h" #include "kernel/closure/bsdf_toon.h" #include "kernel/closure/bsdf_hair.h" +#include "kernel/closure/bsdf_hair_principled.h" #include "kernel/closure/bsdf_principled_diffuse.h" #include "kernel/closure/bsdf_principled_sheen.h" #include "kernel/closure/volume.h" @@ -176,6 +177,61 @@ BSDF_CLOSURE_CLASS_BEGIN(PrincipledSheen, principled_sheen, PrincipledSheenBsdf, CLOSURE_FLOAT3_PARAM(PrincipledSheenClosure, params.N), BSDF_CLOSURE_CLASS_END(PrincipledSheen, principled_sheen) +/* PRINCIPLED HAIR BSDF */ +class PrincipledHairClosure : public CBSDFClosure { +public: + PrincipledHairBSDF params; + + PrincipledHairBSDF *alloc(ShaderData *sd, int path_flag, float3 weight) + { + PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)bsdf_alloc_osl(sd, sizeof(PrincipledHairBSDF), weight, ¶ms); + if(!bsdf) { + return NULL; + } + + PrincipledHairExtra *extra = (PrincipledHairExtra*)closure_alloc_extra(sd, sizeof(PrincipledHairExtra)); + if(!extra) { + return NULL; + } + + bsdf->extra = extra; + return bsdf; + } + + void setup(ShaderData *sd, int path_flag, float3 weight) + { + if(!skip(sd, path_flag, LABEL_GLOSSY)) + { + PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)alloc(sd, path_flag, weight); + if (!bsdf) + { + return; + } + + sd->flag |= (bsdf) ? bsdf_principled_hair_setup(sd, bsdf) : 0; + } + } +}; + +static ClosureParam *closure_bsdf_principled_hair_params() +{ + static ClosureParam params[] = { + CLOSURE_FLOAT3_PARAM(PrincipledHairClosure, params.N), + CLOSURE_FLOAT3_PARAM(PrincipledHairClosure, params.sigma), + CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.v), + CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.s), + CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.m0_roughness), + CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.alpha), + CLOSURE_FLOAT_PARAM(PrincipledHairClosure, params.eta), + CLOSURE_STRING_KEYPARAM(PrincipledHairClosure, label, "label"), + CLOSURE_FINISH_PARAM(PrincipledHairClosure) + }; + + return params; +} + +CCLOSURE_PREPARE(closure_bsdf_principled_hair_prepare, PrincipledHairClosure) + /* DISNEY PRINCIPLED CLEARCOAT */ class PrincipledClearcoatClosure : public CBSDFClosure { public: @@ -322,6 +378,9 @@ void OSLShader::register_closures(OSLShadingSystem *ss_) register_closure(ss, "hair_transmission", id++, bsdf_hair_transmission_params(), bsdf_hair_transmission_prepare); + register_closure(ss, "principled_hair", id++, + closure_bsdf_principled_hair_params(), closure_bsdf_principled_hair_prepare); + register_closure(ss, "henyey_greenstein", id++, closure_henyey_greenstein_params(), closure_henyey_greenstein_prepare); register_closure(ss, "absorption", id++, diff --git a/intern/cycles/kernel/osl/osl_closures.h b/intern/cycles/kernel/osl/osl_closures.h index 857cc84afd2..d9aeb9ab9fb 100644 --- a/intern/cycles/kernel/osl/osl_closures.h +++ b/intern/cycles/kernel/osl/osl_closures.h @@ -79,6 +79,7 @@ void closure_bsdf_microfacet_multi_ggx_fresnel_prepare(OSL::RendererServices *, void closure_bsdf_microfacet_multi_ggx_glass_fresnel_prepare(OSL::RendererServices *, int id, void *data); void closure_bsdf_microfacet_multi_ggx_aniso_fresnel_prepare(OSL::RendererServices *, int id, void *data); void closure_bsdf_principled_clearcoat_prepare(OSL::RendererServices *, int id, void *data); +void closure_bsdf_principled_hair_prepare(OSL::RendererServices *, int id, void *data); #define CCLOSURE_PREPARE(name, classname) \ void name(RendererServices *, int id, void *data) \ diff --git a/intern/cycles/kernel/shaders/CMakeLists.txt b/intern/cycles/kernel/shaders/CMakeLists.txt index 9ee78d160a4..4740db27d4e 100644 --- a/intern/cycles/kernel/shaders/CMakeLists.txt +++ b/intern/cycles/kernel/shaders/CMakeLists.txt @@ -85,6 +85,7 @@ set(SRC_OSL node_wave_texture.osl node_wireframe.osl node_hair_bsdf.osl + node_principled_hair_bsdf.osl node_uv_map.osl node_principled_bsdf.osl node_rgb_to_bw.osl diff --git a/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl b/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl new file mode 100644 index 00000000000..757a88f8ece --- /dev/null +++ b/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl @@ -0,0 +1,105 @@ +/* + * Copyright 2018 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "stdosl.h" + +color log3(color a) +{ + return color(log(a[0]), log(a[1]), log(a[2])); +} + +color sigma_from_concentration(float eumelanin, float pheomelanin) +{ + return eumelanin*color(0.506, 0.841, 1.653) + pheomelanin*color(0.343, 0.733, 1.924); +} + +color sigma_from_reflectance(color c, float azimuthal_roughness) +{ + float x = azimuthal_roughness; + float roughness_fac = (((((0.245*x) + 5.574)*x - 10.73)*x + 2.532)*x - 0.215)*x + 5.969; + color sigma = log3(c) / roughness_fac; + return sigma * sigma; +} + +shader node_principled_hair_bsdf( + color Color = color(0.017513, 0.005763, 0.002059), + float Melanin = 0.8, + float MelaninRedness = 1.0, + float RandomColor = 0.0, + color Tint = 1.0, + color AbsorptionCoefficient = color(0.245531, 0.52, 1.365), + normal Normal = Ng, + string parametrization = "Absorption coefficient", + float Offset = radians(2), + float Roughness = 0.3, + float RadialRoughness = 0.3, + float RandomRoughness = 0.0, + float Coat = 0.0, + float IOR = 1.55, + string AttrRandom = "geom:curve_random", + float Random = 0.0, + + output closure color BSDF = 0) +{ + /* Get random value from curve in none is specified. */ + float random_value = 0.0; + + if (isconnected(Random)) { + random_value = Random; + } + else { + getattribute(AttrRandom, random_value); + } + + /* Compute roughness. */ + float factor_random_roughness = 1.0 + 2.0*(random_value - 0.5)*RandomRoughness; + float m0_roughness = 1.0 - clamp(Coat, 0.0, 1.0); + float roughness = Roughness*factor_random_roughness; + float radial_roughness = RadialRoughness*factor_random_roughness; + + /* Compute absorption. */ + color sigma; + + if (parametrization == "Absorption coefficient") { + sigma = AbsorptionCoefficient; + } + else if (parametrization == "Melanin concentration") { + /* Randomize melanin. */ + float factor_random_color = 1.0 + 2.0*(random_value - 0.5) * RandomColor; + float melanin = Melanin * factor_random_color; + + /* Map melanin 0..inf from more perceptually linear 0..1. */ + melanin = -log(max(1.0 - melanin, 0.0001)); + + /* Benedikt Bitterli's melanin ratio remapping. */ + float eumelanin = melanin * (1.0 - MelaninRedness); + float pheomelanin = melanin * MelaninRedness; + color melanin_sigma = sigma_from_concentration(eumelanin, pheomelanin); + + /* Optional tint. */ + color tint_sigma = sigma_from_reflectance(Tint, radial_roughness); + sigma = melanin_sigma + tint_sigma; + } + else if (parametrization == "Direct coloring"){ + sigma = sigma_from_reflectance(Color, radial_roughness); + } + else { + /* Fallback to brownish hair, same as defaults for melanin. */ + sigma = sigma_from_concentration(0.0, 0.8054375); + } + + BSDF = principled_hair(Normal, sigma, roughness, radial_roughness, m0_roughness, Offset, IOR); +} diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h index 82223ca0219..df9c2010872 100644 --- a/intern/cycles/kernel/shaders/stdosl.h +++ b/intern/cycles/kernel/shaders/stdosl.h @@ -554,6 +554,7 @@ closure color bssrdf(string method, normal N, vector radius, color albedo) BUILT // Hair closure color hair_reflection(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN; closure color hair_transmission(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN; +closure color principled_hair(normal N, color sigma, float roughnessu, float roughnessv, float coat, float alpha, float eta) BUILTIN; // Volume closure color henyey_greenstein(float g) BUILTIN; diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index 4de9cfb88db..aa253223c93 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -16,6 +16,21 @@ CCL_NAMESPACE_BEGIN +/* Hair Melanin */ + +ccl_device_inline float3 sigma_from_concentration(float eumelanin, float pheomelanin) +{ + return eumelanin*make_float3(0.506f, 0.841f, 1.653f) + pheomelanin*make_float3(0.343f, 0.733f, 1.924f); +} + +ccl_device_inline float3 sigma_from_reflectance(float3 color, float azimuthal_roughness) +{ + float x = azimuthal_roughness; + float roughness_fac = (((((0.245f*x) + 5.574f)*x - 10.73f)*x + 2.532f)*x - 0.215f)*x + 5.969f; + float3 sigma = log3(color) / roughness_fac; + return sigma * sigma; +} + /* Closure Nodes */ ccl_device void svm_node_glass_setup(ShaderData *sd, MicrofacetBsdf *bsdf, int type, float eta, float roughness, bool refract) @@ -243,7 +258,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * float3 spec_weight = weight * specular_weight; MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), spec_weight); - if(!bsdf){ + if(!bsdf) { break; } @@ -722,6 +737,107 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * break; } #ifdef __HAIR__ + case CLOSURE_BSDF_HAIR_PRINCIPLED_ID: { + uint4 data_node2 = read_node(kg, offset); + uint4 data_node3 = read_node(kg, offset); + uint4 data_node4 = read_node(kg, offset); + + float3 weight = sd->svm_closure_weight * mix_weight; + + uint offset_ofs, ior_ofs, color_ofs, parametrization; + decode_node_uchar4(data_node.y, &offset_ofs, &ior_ofs, &color_ofs, ¶metrization); + float alpha = stack_load_float_default(stack, offset_ofs, data_node.z); + float ior = stack_load_float_default(stack, ior_ofs, data_node.w); + + uint coat_ofs, melanin_ofs, melanin_redness_ofs, absorption_coefficient_ofs; + decode_node_uchar4(data_node2.x, &coat_ofs, &melanin_ofs, &melanin_redness_ofs, &absorption_coefficient_ofs); + + uint tint_ofs, random_ofs, random_color_ofs, random_roughness_ofs; + decode_node_uchar4(data_node3.x, &tint_ofs, &random_ofs, &random_color_ofs, &random_roughness_ofs); + + const AttributeDescriptor attr_descr_random = find_attribute(kg, sd, data_node4.y); + float random = 0.0f; + if (attr_descr_random.offset != ATTR_STD_NOT_FOUND) { + random = primitive_attribute_float(kg, sd, attr_descr_random, NULL, NULL); + } + else { + random = stack_load_float_default(stack, random_ofs, data_node3.y); + } + + + PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)bsdf_alloc(sd, sizeof(PrincipledHairBSDF), weight); + if(bsdf) { + PrincipledHairExtra *extra = (PrincipledHairExtra*)closure_alloc_extra(sd, sizeof(PrincipledHairExtra)); + + if (!extra) + break; + + /* Random factors range: [-randomization/2, +randomization/2]. */ + float random_roughness = stack_load_float_default(stack, random_roughness_ofs, data_node3.w); + float factor_random_roughness = 1.0f + 2.0f*(random - 0.5f)*random_roughness; + float roughness = param1 * factor_random_roughness; + float radial_roughness = param2 * factor_random_roughness; + + /* Remap Coat value to [0, 100]% of Roughness. */ + float coat = stack_load_float_default(stack, coat_ofs, data_node2.y); + float m0_roughness = 1.0f - clamp(coat, 0.0f, 1.0f); + + bsdf->N = N; + bsdf->v = roughness; + bsdf->s = radial_roughness; + bsdf->m0_roughness = m0_roughness; + bsdf->alpha = alpha; + bsdf->eta = ior; + bsdf->extra = extra; + + switch(parametrization) { + case NODE_PRINCIPLED_HAIR_DIRECT_ABSORPTION: { + float3 absorption_coefficient = stack_load_float3(stack, absorption_coefficient_ofs); + bsdf->sigma = absorption_coefficient; + break; + } + case NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION: { + float melanin = stack_load_float_default(stack, melanin_ofs, data_node2.z); + float melanin_redness = stack_load_float_default(stack, melanin_redness_ofs, data_node2.w); + + /* Randomize melanin. */ + float random_color = stack_load_float_default(stack, random_color_ofs, data_node3.z); + random_color = clamp(random_color, 0.0f, 1.0f); + float factor_random_color = 1.0f + 2.0f * (random - 0.5f) * random_color; + melanin *= factor_random_color; + + /* Map melanin 0..inf from more perceptually linear 0..1. */ + melanin = -logf(fmaxf(1.0f - melanin, 0.0001f)); + + /* Benedikt Bitterli's melanin ratio remapping. */ + float eumelanin = melanin * (1.0f - melanin_redness); + float pheomelanin = melanin * melanin_redness; + float3 melanin_sigma = sigma_from_concentration(eumelanin, pheomelanin); + + /* Optional tint. */ + float3 tint = stack_load_float3(stack, tint_ofs); + float3 tint_sigma = sigma_from_reflectance(tint, radial_roughness); + + bsdf->sigma = melanin_sigma + tint_sigma; + break; + } + case NODE_PRINCIPLED_HAIR_REFLECTANCE: { + float3 color = stack_load_float3(stack, color_ofs); + bsdf->sigma = sigma_from_reflectance(color, radial_roughness); + break; + } + default: { + /* Fallback to brownish hair, same as defaults for melanin. */ + kernel_assert(!"Invalid Principled Hair parametrization!"); + bsdf->sigma = sigma_from_concentration(0.0f, 0.8054375f); + break; + } + } + + sd->flag |= bsdf_principled_hair_setup(sd, bsdf); + } + break; + } case CLOSURE_BSDF_HAIR_REFLECTION_ID: case CLOSURE_BSDF_HAIR_TRANSMISSION_ID: { float3 weight = sd->svm_closure_weight * mix_weight; @@ -764,7 +880,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * break; } -#endif +#endif /* __HAIR__ */ #ifdef __SUBSURFACE__ case CLOSURE_BSSRDF_CUBIC_ID: diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index e03ad3a0cfe..910537a2539 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -418,6 +418,13 @@ typedef enum ShaderType { SHADER_TYPE_BUMP, } ShaderType; +typedef enum NodePrincipledHairParametrization { + NODE_PRINCIPLED_HAIR_REFLECTANCE = 0, + NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION = 1, + NODE_PRINCIPLED_HAIR_DIRECT_ABSORPTION = 2, + NODE_PRINCIPLED_HAIR_NUM, +} NodePrincipledHairParametrization; + /* Closure */ typedef enum ClosureType { @@ -464,6 +471,7 @@ typedef enum ClosureType { CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID, CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID, CLOSURE_BSDF_SHARP_GLASS_ID, + CLOSURE_BSDF_HAIR_PRINCIPLED_ID, CLOSURE_BSDF_HAIR_TRANSMISSION_ID, /* Special cases */ @@ -495,7 +503,7 @@ typedef enum ClosureType { /* watch this, being lazy with memory usage */ #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID) #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_DIFFUSE_TOON_ID) -#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_HAIR_REFLECTION_ID) +#define CLOSURE_IS_BSDF_GLOSSY(type) ((type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_HAIR_REFLECTION_ID )|| (type == CLOSURE_BSDF_HAIR_PRINCIPLED_ID)) #define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_HAIR_TRANSMISSION_ID) #define CLOSURE_IS_BSDF_BSSRDF(type) (type == CLOSURE_BSDF_BSSRDF_ID || type == CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID) #define CLOSURE_IS_BSDF_SINGULAR(type) (type == CLOSURE_BSDF_REFLECTION_ID || \ diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 78a2039c423..3a9e2981418 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -1091,6 +1091,9 @@ int ShaderGraph::get_num_closures() else if(CLOSURE_IS_VOLUME(closure_type)) { num_closures += VOLUME_STACK_SIZE; } + else if(closure_type == CLOSURE_BSDF_HAIR_PRINCIPLED_ID) { + num_closures += 4; + } else { ++num_closures; } diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 986004433e4..96e7459a48c 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3092,6 +3092,139 @@ void PrincipledVolumeNode::compile(OSLCompiler& compiler) compiler.add(this, "node_principled_volume"); } +/* Principled Hair BSDF Closure */ + +NODE_DEFINE(PrincipledHairBsdfNode) +{ + NodeType* type = NodeType::add("principled_hair_bsdf", create, NodeType::SHADER); + + /* Color parametrization specified as enum. */ + static NodeEnum parametrization_enum; + parametrization_enum.insert("Direct coloring", NODE_PRINCIPLED_HAIR_REFLECTANCE); + parametrization_enum.insert("Melanin concentration", NODE_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION); + parametrization_enum.insert("Absorption coefficient", NODE_PRINCIPLED_HAIR_DIRECT_ABSORPTION); + SOCKET_ENUM(parametrization, "Parametrization", parametrization_enum, NODE_PRINCIPLED_HAIR_REFLECTANCE); + + /* Initialize sockets to their default values. */ + SOCKET_IN_COLOR(color, "Color", make_float3(0.017513f, 0.005763f, 0.002059f)); + SOCKET_IN_FLOAT(melanin, "Melanin", 0.8f); + SOCKET_IN_FLOAT(melanin_redness, "Melanin Redness", 1.0f); + SOCKET_IN_COLOR(tint, "Tint", make_float3(1.f, 1.f, 1.f)); + SOCKET_IN_VECTOR(absorption_coefficient, "Absorption Coefficient", make_float3(0.245531f, 0.52f, 1.365f), SocketType::VECTOR); + + SOCKET_IN_FLOAT(offset, "Offset", 2.f*M_PI_F/180.f); + SOCKET_IN_FLOAT(roughness, "Roughness", 0.3f); + SOCKET_IN_FLOAT(radial_roughness, "Radial Roughness", 0.3f); + SOCKET_IN_FLOAT(coat, "Coat", 0.0f); + SOCKET_IN_FLOAT(ior, "IOR", 1.55f); + + SOCKET_IN_FLOAT(random_roughness, "Random Roughness", 0.0f); + SOCKET_IN_FLOAT(random_color, "Random Color", 0.0f); + SOCKET_IN_FLOAT(random, "Random", 0.0f); + + SOCKET_IN_NORMAL(normal, "Normal", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL); + SOCKET_IN_FLOAT(surface_mix_weight, "SurfaceMixWeight", 0.0f, SocketType::SVM_INTERNAL); + + SOCKET_OUT_CLOSURE(BSDF, "BSDF"); + + return type; +} + +PrincipledHairBsdfNode::PrincipledHairBsdfNode() +: BsdfBaseNode(node_type) +{ + closure = CLOSURE_BSDF_HAIR_PRINCIPLED_ID; +} + +/* Enable retrieving Hair Info -> Random if Random isn't linked. */ +void PrincipledHairBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes) +{ + if(!input("Random")->link) { + attributes->add(ATTR_STD_CURVE_RANDOM); + } + ShaderNode::attributes(shader, attributes); +} + +/* Prepares the input data for the SVM shader. */ +void PrincipledHairBsdfNode::compile(SVMCompiler& compiler) +{ + compiler.add_node(NODE_CLOSURE_SET_WEIGHT, make_float3(1.0f, 1.0f, 1.0f)); + + ShaderInput *roughness_in = input("Roughness"); + ShaderInput *radial_roughness_in = input("Radial Roughness"); + ShaderInput *random_roughness_in = input("Random Roughness"); + ShaderInput *offset_in = input("Offset"); + ShaderInput *coat_in = input("Coat"); + ShaderInput *ior_in = input("IOR"); + ShaderInput *melanin_in = input("Melanin"); + ShaderInput *melanin_redness_in = input("Melanin Redness"); + ShaderInput *random_color_in = input("Random Color"); + + int color_ofs = compiler.stack_assign(input("Color")); + int tint_ofs = compiler.stack_assign(input("Tint")); + int absorption_coefficient_ofs = compiler.stack_assign(input("Absorption Coefficient")); + + ShaderInput *random_in = input("Random"); + int attr_random = random_in->link ? SVM_STACK_INVALID : compiler.attribute(ATTR_STD_CURVE_RANDOM); + + /* Encode all parameters into data nodes. */ + compiler.add_node(NODE_CLOSURE_BSDF, + /* Socket IDs can be packed 4 at a time into a single data packet */ + compiler.encode_uchar4(closure, + compiler.stack_assign_if_linked(roughness_in), + compiler.stack_assign_if_linked(radial_roughness_in), + compiler.closure_mix_weight_offset()), + /* The rest are stored as unsigned integers */ + __float_as_uint(roughness), + __float_as_uint(radial_roughness)); + + compiler.add_node(compiler.stack_assign_if_linked(input("Normal")), + compiler.encode_uchar4( + compiler.stack_assign_if_linked(offset_in), + compiler.stack_assign_if_linked(ior_in), + color_ofs, + parametrization), + __float_as_uint(offset), + __float_as_uint(ior)); + + compiler.add_node( + compiler.encode_uchar4( + compiler.stack_assign_if_linked(coat_in), + compiler.stack_assign_if_linked(melanin_in), + compiler.stack_assign_if_linked(melanin_redness_in), + absorption_coefficient_ofs), + __float_as_uint(coat), + __float_as_uint(melanin), + __float_as_uint(melanin_redness)); + + compiler.add_node( + compiler.encode_uchar4( + tint_ofs, + compiler.stack_assign_if_linked(random_in), + compiler.stack_assign_if_linked(random_color_in), + compiler.stack_assign_if_linked(random_roughness_in)), + __float_as_uint(random), + __float_as_uint(random_color), + __float_as_uint(random_roughness)); + + compiler.add_node( + compiler.encode_uchar4( + SVM_STACK_INVALID, + SVM_STACK_INVALID, + SVM_STACK_INVALID, + SVM_STACK_INVALID), + attr_random, + SVM_STACK_INVALID, + SVM_STACK_INVALID); +} + +/* Prepares the input data for the OSL shader. */ +void PrincipledHairBsdfNode::compile(OSLCompiler& compiler) +{ + compiler.parameter(this, "parametrization"); + compiler.add(this, "node_principled_hair_bsdf"); +} + /* Hair BSDF Closure */ NODE_DEFINE(HairBsdfNode) diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index ebe6db6e362..28bbe2de05a 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -608,6 +608,45 @@ public: float temperature; }; +/* Interface between the I/O sockets and the SVM/OSL backend. */ +class PrincipledHairBsdfNode : public BsdfBaseNode { +public: + SHADER_NODE_CLASS(PrincipledHairBsdfNode) + void attributes(Shader *shader, AttributeRequestSet *attributes); + + /* Longitudinal roughness. */ + float roughness; + /* Azimuthal roughness. */ + float radial_roughness; + /* Randomization factor for roughnesses. */ + float random_roughness; + /* Longitudinal roughness factor for only the diffuse bounce (shiny undercoat). */ + float coat; + /* Index of reflection. */ + float ior; + /* Cuticle tilt angle. */ + float offset; + /* Direct coloring's color. */ + float3 color; + /* Melanin concentration. */ + float melanin; + /* Melanin redness ratio. */ + float melanin_redness; + /* Dye color. */ + float3 tint; + /* Randomization factor for melanin quantities. */ + float random_color; + /* Absorption coefficient (unfiltered). */ + float3 absorption_coefficient; + + float3 normal; + float surface_mix_weight; + /* If linked, here will be the given random number. */ + float random; + /* Selected coloring parametrization. */ + NodePrincipledHairParametrization parametrization; +}; + class HairBsdfNode : public BsdfNode { public: SHADER_NODE_CLASS(HairBsdfNode) diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 85cbd18b7ba..52aeb8d8599 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -55,6 +55,15 @@ CCL_NAMESPACE_BEGIN #ifndef M_2_PI_F # define M_2_PI_F (0.6366197723675813f) /* 2/pi */ #endif +#ifndef M_1_2PI_F +# define M_1_2PI_F (0.1591549430918953f) /* 1/(2*pi) */ +#endif +#ifndef M_SQRT_PI_8_F +# define M_SQRT_PI_8_F (0.6266570686577501f) /* sqrt(pi/8) */ +#endif +#ifndef M_LN_2PI_F +# define M_LN_2PI_F (1.8378770664093454f) /* ln(2*pi) */ +#endif /* Multiplication */ #ifndef M_2PI_F @@ -541,6 +550,16 @@ ccl_device_inline float sqr(float a) return a * a; } +ccl_device_inline float pow20(float a) +{ + return sqr(sqr(sqr(sqr(a))*a)); +} + +ccl_device_inline float pow22(float a) +{ + return sqr(a*sqr(sqr(sqr(a))*a)); +} + ccl_device_inline float beta(float x, float y) { #ifndef __KERNEL_OPENCL__ diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h index 3a5a2ab2244..ba1c117cdea 100644 --- a/intern/cycles/util/util_math_float3.h +++ b/intern/cycles/util/util_math_float3.h @@ -382,6 +382,16 @@ ccl_device_inline bool isequal_float3(const float3 a, const float3 b) #endif } +ccl_device_inline float3 exp3(float3 v) +{ + return make_float3(expf(v.x), expf(v.y), expf(v.z)); +} + +ccl_device_inline float3 log3(float3 v) +{ + return make_float3(logf(v.x), logf(v.y), logf(v.z)); +} + ccl_device_inline int3 quick_floor_to_int3(const float3 a) { #ifdef __KERNEL_SSE__ diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index c9a15f12f7c..4f4190da30b 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -246,6 +246,7 @@ shader_node_categories = [ NodeItem("ShaderNodeVolumeAbsorption"), NodeItem("ShaderNodeVolumeScatter"), NodeItem("ShaderNodeVolumePrincipled"), + NodeItem("ShaderNodeBsdfHairPrincipled", poll=object_shader_nodes_poll) ]), ShaderNewNodeCategory("SH_NEW_TEXTURE", "Texture", items=[ NodeItem("ShaderNodeTexImage"), diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 8e54c6a87c4..23ef45416f7 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -794,6 +794,8 @@ struct ShadeResult; #define SH_NODE_DISPLACEMENT 198 #define SH_NODE_VECTOR_DISPLACEMENT 199 #define SH_NODE_VOLUME_PRINCIPLED 200 +/* 201..700 occupied by other node types, continue from 701 */ +#define SH_NODE_BSDF_HAIR_PRINCIPLED 701 /* custom defines options for Material node */ #define SH_NODE_MAT_DIFF 1 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f15d90100d2..c830917a547 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3622,6 +3622,7 @@ static void registerShaderNodes(void) register_node_type_sh_bsdf_velvet(); register_node_type_sh_bsdf_toon(); register_node_type_sh_bsdf_hair(); + register_node_type_sh_bsdf_hair_principled(); register_node_type_sh_emission(); register_node_type_sh_holdout(); register_node_type_sh_volume_absorption(); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 23df1b72c37..6e52af2898e 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1111,6 +1111,11 @@ static void node_shader_buts_hair(uiLayout *layout, bContext *UNUSED(C), Pointer uiItemR(layout, ptr, "component", 0, "", ICON_NONE); } +static void node_shader_buts_principled_hair(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "parametrization", 0, "", ICON_NONE); +} + static void node_shader_buts_ies(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; @@ -1301,6 +1306,9 @@ static void node_shader_set_butfunc(bNodeType *ntype) case SH_NODE_BSDF_HAIR: ntype->draw_buttons = node_shader_buts_hair; break; + case SH_NODE_BSDF_HAIR_PRINCIPLED: + ntype->draw_buttons = node_shader_buts_principled_hair; + break; case SH_NODE_SCRIPT: ntype->draw_buttons = node_shader_buts_script; ntype->draw_buttons_ex = node_shader_buts_script_ex; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 00758bd1379..5c692cf85da 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -963,6 +963,11 @@ typedef struct NodeCryptomatte { #define SHD_HAIR_REFLECTION 0 #define SHD_HAIR_TRANSMISSION 1 +/* principled hair parametrization */ +#define SHD_PRINCIPLED_HAIR_REFLECTANCE 0 +#define SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION 1 +#define SHD_PRINCIPLED_HAIR_DIRECT_ABSORPTION 2 + /* blend texture */ #define SHD_BLEND_LINEAR 0 #define SHD_BLEND_QUADRATIC 1 diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 52fbadd0f54..b41e9b1c4e5 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3350,6 +3350,13 @@ static const EnumPropertyItem node_hair_items[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem node_principled_hair_items[] = { + {SHD_PRINCIPLED_HAIR_DIRECT_ABSORPTION, "ABSORPTION", 0, "Absorption coefficient", "Directly set the absorption coefficient sigma_a. This is not the most intuitive way to color hair."}, + {SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION, "MELANIN", 0, "Melanin concentration", "Define the melanin concentrations below to get the most realistic-looking hair. You can get the concentrations for different types of hair online."}, + {SHD_PRINCIPLED_HAIR_REFLECTANCE, "COLOR", 0, "Direct coloring", "Choose the color of your preference, and the shader will approximate the absorption coefficient to render lookalike hair."}, + {0, NULL, 0, NULL, NULL} +}; + static const EnumPropertyItem node_script_mode_items[] = { {NODE_SCRIPT_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text data-block"}, {NODE_SCRIPT_EXTERNAL, "EXTERNAL", 0, "External", "Use external .osl or .oso file"}, @@ -4409,6 +4416,21 @@ static void def_hair(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +/* RNA initialization for the custom property. */ +static void def_hair_principled(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "parametrization", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_ui_text(prop, "Color parametrization", "Select the shader's color parametrization"); + RNA_def_property_enum_items(prop, node_principled_hair_items); + RNA_def_property_enum_default(prop, SHD_PRINCIPLED_HAIR_REFLECTANCE); + /* Upon editing, update both the node data AND the UI representation */ + /* (This effectively shows/hides the relevant sockets) */ + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); +} + static void def_sh_uvmap(StructRNA *srna) { PropertyRNA *prop; diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 5a5d5997878..7ef41b25de8 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -173,6 +173,7 @@ set(SRC shader/nodes/node_shader_bsdf_transparent.c shader/nodes/node_shader_bsdf_velvet.c shader/nodes/node_shader_bsdf_hair.c + shader/nodes/node_shader_bsdf_hair_principled.c shader/nodes/node_shader_bump.c shader/nodes/node_shader_emission.c shader/nodes/node_shader_fresnel.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index ca604363e35..d4134f09597 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -116,6 +116,7 @@ void register_node_type_sh_volume_absorption(void); void register_node_type_sh_volume_scatter(void); void register_node_type_sh_volume_principled(void); void register_node_type_sh_bsdf_hair(void); +void register_node_type_sh_bsdf_hair_principled(void); void register_node_type_sh_subsurface_scattering(void); void register_node_type_sh_mix_shader(void); void register_node_type_sh_add_shader(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index a4f8a798576..2fa8cda56a5 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -89,6 +89,7 @@ DefNode( ShaderNode, SH_NODE_BSDF_TRANSPARENT, 0, "BS DefNode( ShaderNode, SH_NODE_BSDF_VELVET, 0, "BSDF_VELVET", BsdfVelvet, "Velvet BSDF", "" ) DefNode( ShaderNode, SH_NODE_BSDF_TOON, def_toon, "BSDF_TOON", BsdfToon, "Toon BSDF", "" ) DefNode( ShaderNode, SH_NODE_BSDF_HAIR, def_hair, "BSDF_HAIR", BsdfHair, "Hair BSDF", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_HAIR_PRINCIPLED, def_hair_principled, "BSDF_HAIR_PRINCIPLED", BsdfHairPrincipled, "Principled Hair BSDF", "") DefNode( ShaderNode, SH_NODE_SUBSURFACE_SCATTERING, def_sh_subsurface, "SUBSURFACE_SCATTERING",SubsurfaceScattering,"Subsurface Scattering","") DefNode( ShaderNode, SH_NODE_VOLUME_ABSORPTION, 0, "VOLUME_ABSORPTION", VolumeAbsorption, "Volume Absorption", "" ) DefNode( ShaderNode, SH_NODE_VOLUME_SCATTER, 0, "VOLUME_SCATTER", VolumeScatter, "Volume Scatter", "" ) diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c new file mode 100644 index 00000000000..c5029852033 --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c @@ -0,0 +1,133 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Lukas Stockner, L. E. Segovia + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../node_shader_util.h" + +/* **************** OUTPUT ******************** */ + +/* Color, melanin and absorption coefficient default to approximately same brownish hair. */ +static bNodeSocketTemplate sh_node_bsdf_hair_principled_in[] = { + { SOCK_RGBA, 1, N_("Color"), 0.017513f, 0.005763f, 0.002059f, 1.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 1, N_("Melanin"), 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Melanin Redness"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_RGBA, 1, N_("Tint"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_VECTOR, 1, N_("Absorption Coefficient"), 0.245531f, 0.52f, 1.365f, 0.0f, 0.0f, 1000.0f}, + { SOCK_FLOAT, 1, N_("Roughness"), 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Radial Roughness"), 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("IOR"), 1.55f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, + { SOCK_FLOAT, 1, N_("Offset"), 2.f*((float)M_PI)/180.f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE}, + { SOCK_FLOAT, 1, N_("Random Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Random Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Random"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { -1, 0, "" }, +}; + +static bNodeSocketTemplate sh_node_bsdf_hair_principled_out[] = { + { SOCK_SHADER, 0, N_("BSDF")}, + { -1, 0, "" } +}; + +/* Initialize the custom Parametrization property to Color. */ +static void node_shader_init_hair_principled(bNodeTree *UNUSED(ntree), bNode *node) +{ + node->custom1 = SHD_PRINCIPLED_HAIR_REFLECTANCE; +} + +/* Triggers (in)visibility of some sockets when changing Parametrization. */ +static void node_shader_update_hair_principled(bNodeTree *UNUSED(ntree), bNode *node) +{ + bNodeSocket *sock; + int parametrization = node->custom1; + + for (sock = node->inputs.first; sock; sock = sock->next) { + if (STREQ(sock->name, "Color")) { + if (parametrization == SHD_PRINCIPLED_HAIR_REFLECTANCE) { + sock->flag &= ~SOCK_UNAVAIL; + } + else { + sock->flag |= SOCK_UNAVAIL; + } + } + else if (STREQ(sock->name, "Melanin")) { + if (parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION) { + sock->flag &= ~SOCK_UNAVAIL; + } + else { + sock->flag |= SOCK_UNAVAIL; + } + } + else if (STREQ(sock->name, "Melanin Redness")) { + if (parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION) { + sock->flag &= ~SOCK_UNAVAIL; + } + else { + sock->flag |= SOCK_UNAVAIL; + } + } + else if (STREQ(sock->name, "Tint")) { + if (parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION) { + sock->flag &= ~SOCK_UNAVAIL; + } + else { + sock->flag |= SOCK_UNAVAIL; + } + } + else if (STREQ(sock->name, "Absorption Coefficient")) { + if (parametrization == SHD_PRINCIPLED_HAIR_DIRECT_ABSORPTION) { + sock->flag &= ~SOCK_UNAVAIL; + } + else { + sock->flag |= SOCK_UNAVAIL; + } + } + else if (STREQ(sock->name, "Random Color")) { + if (parametrization == SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION) { + sock->flag &= ~SOCK_UNAVAIL; + } + else { + sock->flag |= SOCK_UNAVAIL; + } + } + } +} + +/* node type definition */ +void register_node_type_sh_bsdf_hair_principled(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_BSDF_HAIR_PRINCIPLED, "Principled Hair BSDF", NODE_CLASS_SHADER, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_bsdf_hair_principled_in, sh_node_bsdf_hair_principled_out); + node_type_size_preset(&ntype, NODE_SIZE_LARGE); + node_type_init(&ntype, node_shader_init_hair_principled); + node_type_storage(&ntype, "", NULL, NULL); + node_type_update(&ntype, node_shader_update_hair_principled, NULL); + + nodeRegisterType(&ntype); +} -- cgit v1.2.3 From 257d072317f21861cdb7c168a60497bcb74d73d4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Jul 2018 22:03:52 +1000 Subject: 3D View: show 3D axis-letter when pointing away While only the positive axis is shown, account for an exception when axis aligned. --- source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 238a956cf26..93617f22490 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -241,6 +241,9 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U ok = false; } if (ok) { + /* Check aligned, since the front axis won't display in this case, + * and we want to make sure all 3 axes have a character at all times. */ + const bool show_axis_char = (is_pos || (axis == axis_align)); const float v[3] = {0, 0, 3 * (is_pos ? 1 : -1)}; const float v_final[3] = { v[index_x] * scale_axis, @@ -278,7 +281,7 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U { GPU_matrix_push(); GPU_matrix_translate_3fv(v_final); - GPU_matrix_scale_1f(is_pos ? 0.22f : 0.18f); + GPU_matrix_scale_1f(show_axis_char ? 0.22f : 0.18f); GPUBatch *sphere = GPU_batch_preset_sphere(0); GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); @@ -288,7 +291,7 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U } /* Axis XYZ Character. */ - if (is_pos) { + if (show_axis_char) { GPU_line_width(1.0f); float m3[3][3]; copy_m3_m4(m3, gz->matrix_offset); -- cgit v1.2.3 From f882df9e0f9de99c37558ce375ce681c148eac82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 18 Jul 2018 14:58:32 +0200 Subject: GPU: Fix build error on Mac and Windows. --- source/blender/gpu/GPU_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h index cb506c6b0bc..7d86a6ec8a5 100644 --- a/source/blender/gpu/GPU_common.h +++ b/source/blender/gpu/GPU_common.h @@ -43,9 +43,9 @@ #include #endif -#include #include #include +#include "BLI_sys_types.h" #if TRUST_NO_ONE #include -- cgit v1.2.3 From 428743a9b06cc09b4eb4dd3e7794d45d13457fb8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Jul 2018 23:09:31 +1000 Subject: Cleanup: style for GPU module --- source/blender/gpu/GPU_batch.h | 84 ++++----- source/blender/gpu/GPU_context.h | 8 +- source/blender/gpu/GPU_element.h | 28 +-- source/blender/gpu/GPU_framebuffer.h | 3 +- source/blender/gpu/GPU_immediate.h | 32 ++-- source/blender/gpu/GPU_material.h | 7 +- source/blender/gpu/GPU_shader.h | 12 +- source/blender/gpu/GPU_shader_interface.h | 30 ++-- source/blender/gpu/GPU_state.h | 2 +- source/blender/gpu/GPU_vertex_array_id.h | 2 +- source/blender/gpu/GPU_vertex_buffer.h | 38 ++--- source/blender/gpu/GPU_vertex_format.h | 14 +- source/blender/gpu/intern/gpu_attr_binding.c | 12 +- source/blender/gpu/intern/gpu_basic_shader.c | 18 +- source/blender/gpu/intern/gpu_batch.c | 124 +++++++------- source/blender/gpu/intern/gpu_buffers.c | 66 ++++---- source/blender/gpu/intern/gpu_codegen.c | 207 +++++++++++++---------- source/blender/gpu/intern/gpu_draw.c | 138 ++++++++------- source/blender/gpu/intern/gpu_element.c | 34 ++-- source/blender/gpu/intern/gpu_framebuffer.c | 47 ++--- source/blender/gpu/intern/gpu_immediate.c | 92 +++++----- source/blender/gpu/intern/gpu_immediate_util.c | 46 ++--- source/blender/gpu/intern/gpu_material.c | 17 +- source/blender/gpu/intern/gpu_matrix.c | 2 +- source/blender/gpu/intern/gpu_select.c | 2 +- source/blender/gpu/intern/gpu_shader.c | 104 +++++++----- source/blender/gpu/intern/gpu_shader_interface.c | 92 +++++----- source/blender/gpu/intern/gpu_state.c | 9 +- source/blender/gpu/intern/gpu_texture.c | 26 +-- source/blender/gpu/intern/gpu_vertex_buffer.c | 58 +++---- source/blender/gpu/intern/gpu_vertex_format.c | 28 +-- 31 files changed, 739 insertions(+), 643 deletions(-) diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index bd0e3b43e6c..bb67a90d619 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -51,15 +51,15 @@ typedef enum { typedef struct GPUBatch { /* geometry */ - GPUVertBuf* verts[GPU_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ - GPUVertBuf* inst; /* instance attribs */ - GPUIndexBuf* elem; /* NULL if element list not needed */ + GPUVertBuf *verts[GPU_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ + GPUVertBuf *inst; /* instance attribs */ + GPUIndexBuf *elem; /* NULL if element list not needed */ uint32_t gl_prim_type; /* cached values (avoid dereferencing later) */ uint32_t vao_id; uint32_t program; - const struct GPUShaderInterface* interface; + const struct GPUShaderInterface *interface; /* book-keeping */ uint owns_flag; @@ -74,21 +74,21 @@ typedef struct GPUBatch { union { /* Static handle count */ struct { - const struct GPUShaderInterface* interfaces[GPU_BATCH_VAO_STATIC_LEN]; + const struct GPUShaderInterface *interfaces[GPU_BATCH_VAO_STATIC_LEN]; uint32_t vao_ids[GPU_BATCH_VAO_STATIC_LEN]; } static_vaos; /* Dynamic handle count */ struct { uint count; - const struct GPUShaderInterface** interfaces; - uint32_t* vao_ids; + const struct GPUShaderInterface **interfaces; + uint32_t *vao_ids; } dynamic_vaos; }; /* XXX This is the only solution if we want to have some data structure using * batches as key to identify nodes. We must destroy these nodes with this callback. */ - void (*free_callback)(struct GPUBatch*, void*); - void* callback_data; + void (*free_callback)(struct GPUBatch *, void *); + void *callback_data; } GPUBatch; enum { @@ -98,55 +98,55 @@ enum { GPU_BATCH_OWNS_INDEX = (1 << 31), }; -GPUBatch* GPU_batch_create_ex(GPUPrimType, GPUVertBuf*, GPUIndexBuf*, uint owns_flag); -void GPU_batch_init_ex(GPUBatch*, GPUPrimType, GPUVertBuf*, GPUIndexBuf*, uint owns_flag); -GPUBatch* GPU_batch_duplicate(GPUBatch* batch_src); +GPUBatch *GPU_batch_create_ex(GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag); +void GPU_batch_init_ex(GPUBatch *, GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag); +GPUBatch *GPU_batch_duplicate(GPUBatch *batch_src); #define GPU_batch_create(prim, verts, elem) \ GPU_batch_create_ex(prim, verts, elem, 0) #define GPU_batch_init(batch, prim, verts, elem) \ GPU_batch_init_ex(batch, prim, verts, elem, 0) -void GPU_batch_discard(GPUBatch*); /* verts & elem are not discarded */ +void GPU_batch_discard(GPUBatch *); /* verts & elem are not discarded */ -void GPU_batch_vao_cache_clear(GPUBatch*); +void GPU_batch_vao_cache_clear(GPUBatch *); -void GPU_batch_callback_free_set(GPUBatch*, void (*callback)(GPUBatch*, void*), void*); +void GPU_batch_callback_free_set(GPUBatch *, void (*callback)(GPUBatch *, void *), void *); -void GPU_batch_instbuf_set(GPUBatch*, GPUVertBuf*, bool own_vbo); /* Instancing */ +void GPU_batch_instbuf_set(GPUBatch *, GPUVertBuf *, bool own_vbo); /* Instancing */ -int GPU_batch_vertbuf_add_ex(GPUBatch*, GPUVertBuf*, bool own_vbo); +int GPU_batch_vertbuf_add_ex(GPUBatch *, GPUVertBuf *, bool own_vbo); #define GPU_batch_vertbuf_add(batch, verts) \ GPU_batch_vertbuf_add_ex(batch, verts, false) -void GPU_batch_program_set_no_use(GPUBatch*, uint32_t program, const GPUShaderInterface*); -void GPU_batch_program_set(GPUBatch*, uint32_t program, const GPUShaderInterface*); +void GPU_batch_program_set_no_use(GPUBatch *, uint32_t program, const GPUShaderInterface *); +void GPU_batch_program_set(GPUBatch *, uint32_t program, const GPUShaderInterface *); void GPU_batch_program_set_builtin(GPUBatch *batch, GPUBuiltinShader shader_id); /* Entire batch draws with one shader program, but can be redrawn later with another program. */ /* Vertex shader's inputs must be compatible with the batch's vertex format. */ -void GPU_batch_program_use_begin(GPUBatch*); /* call before Batch_Uniform (temp hack?) */ -void GPU_batch_program_use_end(GPUBatch*); - -void GPU_batch_uniform_1ui(GPUBatch*, const char* name, int value); -void GPU_batch_uniform_1i(GPUBatch*, const char* name, int value); -void GPU_batch_uniform_1b(GPUBatch*, const char* name, bool value); -void GPU_batch_uniform_1f(GPUBatch*, const char* name, float value); -void GPU_batch_uniform_2f(GPUBatch*, const char* name, float x, float y); -void GPU_batch_uniform_3f(GPUBatch*, const char* name, float x, float y, float z); -void GPU_batch_uniform_4f(GPUBatch*, const char* name, float x, float y, float z, float w); -void GPU_batch_uniform_2fv(GPUBatch*, const char* name, const float data[2]); -void GPU_batch_uniform_3fv(GPUBatch*, const char* name, const float data[3]); -void GPU_batch_uniform_4fv(GPUBatch*, const char* name, const float data[4]); -void GPU_batch_uniform_2fv_array(GPUBatch*, const char* name, int len, const float *data); -void GPU_batch_uniform_4fv_array(GPUBatch*, const char* name, int len, const float *data); -void GPU_batch_uniform_mat4(GPUBatch*, const char* name, const float data[4][4]); - -void GPU_batch_draw(GPUBatch*); +void GPU_batch_program_use_begin(GPUBatch *); /* call before Batch_Uniform (temp hack?) */ +void GPU_batch_program_use_end(GPUBatch *); + +void GPU_batch_uniform_1ui(GPUBatch *, const char *name, int value); +void GPU_batch_uniform_1i(GPUBatch *, const char *name, int value); +void GPU_batch_uniform_1b(GPUBatch *, const char *name, bool value); +void GPU_batch_uniform_1f(GPUBatch *, const char *name, float value); +void GPU_batch_uniform_2f(GPUBatch *, const char *name, float x, float y); +void GPU_batch_uniform_3f(GPUBatch *, const char *name, float x, float y, float z); +void GPU_batch_uniform_4f(GPUBatch *, const char *name, float x, float y, float z, float w); +void GPU_batch_uniform_2fv(GPUBatch *, const char *name, const float data[2]); +void GPU_batch_uniform_3fv(GPUBatch *, const char *name, const float data[3]); +void GPU_batch_uniform_4fv(GPUBatch *, const char *name, const float data[4]); +void GPU_batch_uniform_2fv_array(GPUBatch *, const char *name, int len, const float *data); +void GPU_batch_uniform_4fv_array(GPUBatch *, const char *name, int len, const float *data); +void GPU_batch_uniform_mat4(GPUBatch *, const char *name, const float data[4][4]); + +void GPU_batch_draw(GPUBatch *); /* This does not bind/unbind shader and does not call GPU_matrix_bind() */ -void GPU_batch_draw_range_ex(GPUBatch*, int v_first, int v_count, bool force_instance); +void GPU_batch_draw_range_ex(GPUBatch *, int v_first, int v_count, bool force_instance); /* Does not even need batch */ void GPU_draw_primitive(GPUPrimType, int v_count); @@ -175,12 +175,12 @@ typedef struct BatchWithOwnVertexBufferAndElementList { GPUVertBuf verts; /* link batch.verts to this */ } BatchWithOwnVertexBufferAndElementList; -GPUBatch* create_BatchWithOwnVertexBuffer(GPUPrimType, GPUVertFormat*, uint v_len, GPUIndexBuf*); -GPUBatch* create_BatchWithOwnElementList(GPUPrimType, GPUVertBuf*, uint prim_len); -GPUBatch* create_BatchWithOwnVertexBufferAndElementList(GPUPrimType, GPUVertFormat*, uint v_len, uint prim_len); +GPUBatch *create_BatchWithOwnVertexBuffer(GPUPrimType, GPUVertFormat *, uint v_len, GPUIndexBuf *); +GPUBatch *create_BatchWithOwnElementList(GPUPrimType, GPUVertBuf *, uint prim_len); +GPUBatch *create_BatchWithOwnVertexBufferAndElementList(GPUPrimType, GPUVertFormat *, uint v_len, uint prim_len); /* verts: shared, own */ /* elem: none, shared, own */ -GPUBatch* create_BatchInGeneral(GPUPrimType, VertexBufferStuff, ElementListStuff); +GPUBatch *create_BatchInGeneral(GPUPrimType, VertexBufferStuff, ElementListStuff); #endif /* future plans */ diff --git a/source/blender/gpu/GPU_context.h b/source/blender/gpu/GPU_context.h index 5f63c408801..3e32b64b281 100644 --- a/source/blender/gpu/GPU_context.h +++ b/source/blender/gpu/GPU_context.h @@ -42,11 +42,11 @@ extern "C" { typedef struct GPUContext GPUContext; -GPUContext* GPU_context_create(void); -void GPU_context_discard(GPUContext*); +GPUContext *GPU_context_create(void); +void GPU_context_discard(GPUContext *); -void GPU_context_active_set(GPUContext*); -GPUContext* GPU_context_active_get(void); +void GPU_context_active_set(GPUContext *); +GPUContext *GPU_context_active_get(void); #ifdef __cplusplus } diff --git a/source/blender/gpu/GPU_element.h b/source/blender/gpu/GPU_element.h index 508c079fcd3..adc705ab641 100644 --- a/source/blender/gpu/GPU_element.h +++ b/source/blender/gpu/GPU_element.h @@ -57,37 +57,37 @@ typedef struct GPUIndexBuf { bool use_prim_restart; } GPUIndexBuf; -void GPU_indexbuf_use(GPUIndexBuf*); -uint GPU_indexbuf_size_get(const GPUIndexBuf*); +void GPU_indexbuf_use(GPUIndexBuf *); +uint GPU_indexbuf_size_get(const GPUIndexBuf *); typedef struct GPUIndexBufBuilder { uint max_allowed_index; uint max_index_len; uint index_len; GPUPrimType prim_type; - uint* data; + uint *data; bool use_prim_restart; } GPUIndexBufBuilder; /* supports all primitive types. */ -void GPU_indexbuf_init_ex(GPUIndexBufBuilder*, GPUPrimType, uint index_len, uint vertex_len, bool use_prim_restart); +void GPU_indexbuf_init_ex(GPUIndexBufBuilder *, GPUPrimType, uint index_len, uint vertex_len, bool use_prim_restart); /* supports only GPU_PRIM_POINTS, GPU_PRIM_LINES and GPU_PRIM_TRIS. */ -void GPU_indexbuf_init(GPUIndexBufBuilder*, GPUPrimType, uint prim_len, uint vertex_len); +void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len); -void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder*, uint v); -void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder*); +void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *, uint v); +void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *); -void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder*, uint v); -void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder*, uint v1, uint v2); -void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder*, uint v1, uint v2, uint v3); -void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder*, uint v1, uint v2, uint v3, uint v4); +void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder *, uint v); +void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder *, uint v1, uint v2); +void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3); +void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3, uint v4); -GPUIndexBuf* GPU_indexbuf_build(GPUIndexBufBuilder*); -void GPU_indexbuf_build_in_place(GPUIndexBufBuilder*, GPUIndexBuf*); +GPUIndexBuf *GPU_indexbuf_build(GPUIndexBufBuilder *); +void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *, GPUIndexBuf *); -void GPU_indexbuf_discard(GPUIndexBuf*); +void GPU_indexbuf_discard(GPUIndexBuf *); /* Macros */ diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h index ddf485c3c21..04357d6a927 100644 --- a/source/blender/gpu/GPU_framebuffer.h +++ b/source/blender/gpu/GPU_framebuffer.h @@ -179,7 +179,8 @@ void GPU_framebuffer_recursive_downsample( * - wrapper around framebuffer and texture for simple offscreen drawing */ -GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, +GPUOffScreen *GPU_offscreen_create( + int width, int height, int samples, bool depth, bool high_bitdepth, char err_out[256]); void GPU_offscreen_free(GPUOffScreen *ofs); void GPU_offscreen_bind(GPUOffScreen *ofs, bool save); diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h index a756687b557..c8a4ea6a837 100644 --- a/source/blender/gpu/GPU_immediate.h +++ b/source/blender/gpu/GPU_immediate.h @@ -40,9 +40,9 @@ #include "GPU_immediate_util.h" #include "GPU_shader.h" -GPUVertFormat* immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ +GPUVertFormat *immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ -void immBindProgram(uint32_t program, const GPUShaderInterface*); /* every immBegin must have a program bound first. */ +void immBindProgram(uint32_t program, const GPUShaderInterface *); /* every immBegin must have a program bound first. */ void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */ void immBegin(GPUPrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */ @@ -52,8 +52,8 @@ void immEnd(void); /* finishes and draws. */ /* ImmBegin a batch, then use standard immFunctions as usual. */ /* ImmEnd will finalize the batch instead of drawing. */ /* Then you can draw it as many times as you like! Partially replaces the need for display lists. */ -GPUBatch* immBeginBatch(GPUPrimType, uint vertex_len); -GPUBatch* immBeginBatchAtMost(GPUPrimType, uint vertex_len); +GPUBatch *immBeginBatch(GPUPrimType, uint vertex_len); +GPUBatch *immBeginBatchAtMost(GPUPrimType, uint vertex_len); /* Provide attribute values that can change per vertex. */ /* First vertex after immBegin must have all its attributes specified. */ @@ -99,18 +99,18 @@ void immVertex3fv(uint attrib_id, const float data[3]); void immVertex2iv(uint attrib_id, const int data[2]); /* Provide uniform values that don't change for the entire draw call. */ -void immUniform1i(const char* name, int x); -void immUniform4iv(const char* name, const int data[4]); -void immUniform1f(const char* name, float x); -void immUniform2f(const char* name, float x, float y); -void immUniform2fv(const char* name, const float data[2]); -void immUniform3f(const char* name, float x, float y, float z); -void immUniform3fv(const char* name, const float data[3]); -void immUniformArray3fv(const char* name, const float *data, int count); -void immUniform4f(const char* name, float x, float y, float z, float w); -void immUniform4fv(const char* name, const float data[4]); -void immUniformArray4fv(const char* bare_name, const float *data, int count); -void immUniformMatrix4fv(const char* name, const float data[4][4]); +void immUniform1i(const char *name, int x); +void immUniform4iv(const char *name, const int data[4]); +void immUniform1f(const char *name, float x); +void immUniform2f(const char *name, float x, float y); +void immUniform2fv(const char *name, const float data[2]); +void immUniform3f(const char *name, float x, float y, float z); +void immUniform3fv(const char *name, const float data[3]); +void immUniformArray3fv(const char *name, const float *data, int count); +void immUniform4f(const char *name, float x, float y, float z, float w); +void immUniform4fv(const char *name, const float data[4]); +void immUniformArray4fv(const char *bare_name, const float *data, int count); +void immUniformMatrix4fv(const char *name, const float data[4][4]); /* Convenience functions for setting "uniform vec4 color". */ /* The rgb functions have implicit alpha = 1.0. */ diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 8ddb7b87c4a..4e264defbd4 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -104,7 +104,7 @@ typedef enum GPUBuiltin { GPU_AUTO_BUMPSCALE = (1 << 7), GPU_CAMERA_TEXCO_FACTORS = (1 << 8), GPU_PARTICLE_SCALAR_PROPS = (1 << 9), - GPU_PARTICLE_LOCATION = (1 << 10), + GPU_PARTICLE_LOCATION = (1 << 10), GPU_PARTICLE_VELOCITY = (1 << 11), GPU_PARTICLE_ANG_VELOCITY = (1 << 12), GPU_LOC_TO_VIEW_MATRIX = (1 << 13), @@ -268,8 +268,9 @@ GPUMaterialStatus GPU_material_status(GPUMaterial *mat); struct GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material); void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs); -void GPU_material_vertex_attributes(GPUMaterial *material, - struct GPUVertexAttribs *attrib); +void GPU_material_vertex_attributes( + GPUMaterial *material, + struct GPUVertexAttribs *attrib); bool GPU_material_do_color_management(GPUMaterial *mat); bool GPU_material_use_domain_surface(GPUMaterial *mat); diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index f831d495ad0..b1a05faf863 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -89,10 +89,12 @@ void *GPU_shader_get_interface(GPUShader *shader); int GPU_shader_get_uniform(GPUShader *shader, const char *name); int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin); int GPU_shader_get_uniform_block(GPUShader *shader, const char *name); -void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, - int arraysize, const float *value); -void GPU_shader_uniform_vector_int(GPUShader *shader, int location, int length, - int arraysize, const int *value); +void GPU_shader_uniform_vector( + GPUShader *shader, int location, int length, + int arraysize, const float *value); +void GPU_shader_uniform_vector_int( + GPUShader *shader, int location, int length, + int arraysize, const int *value); void GPU_shader_uniform_buffer(GPUShader *shader, int location, struct GPUUniformBuffer *ubo); void GPU_shader_uniform_texture(GPUShader *shader, int location, struct GPUTexture *tex); @@ -375,7 +377,7 @@ typedef struct GPUVertexAttribs { int glinfoindoex; int gltexco; int attribid; - char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ + char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ } layer[GPU_MAX_ATTRIB]; int totlayer; diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index c80cc1021ec..458a49a366b 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -65,7 +65,7 @@ typedef enum { } GPUUniformBuiltin; typedef struct GPUShaderInput { - struct GPUShaderInput* next; + struct GPUShaderInput *next; uint32_t name_offset; uint name_hash; GPUUniformBuiltin builtin_type; /* only for uniform inputs */ @@ -80,25 +80,25 @@ typedef struct GPUShaderInput { typedef struct GPUShaderInterface { int32_t program; uint32_t name_buffer_offset; - GPUShaderInput* attrib_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; - GPUShaderInput* uniform_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; - GPUShaderInput* ubo_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; - GPUShaderInput* builtin_uniforms[GPU_NUM_UNIFORMS]; - char* name_buffer; - struct GPUBatch** batches; /* references to batches using this interface */ + GPUShaderInput *attrib_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput *uniform_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput *ubo_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput *builtin_uniforms[GPU_NUM_UNIFORMS]; + char *name_buffer; + struct GPUBatch **batches; /* references to batches using this interface */ uint batches_len; } GPUShaderInterface; -GPUShaderInterface* GPU_shaderinterface_create(int32_t program_id); -void GPU_shaderinterface_discard(GPUShaderInterface*); +GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id); +void GPU_shaderinterface_discard(GPUShaderInterface *); -const GPUShaderInput* GPU_shaderinterface_uniform(const GPUShaderInterface*, const char* name); -const GPUShaderInput* GPU_shaderinterface_uniform_builtin(const GPUShaderInterface*, GPUUniformBuiltin); -const GPUShaderInput* GPU_shaderinterface_ubo(const GPUShaderInterface*, const char* name); -const GPUShaderInput* GPU_shaderinterface_attr(const GPUShaderInterface*, const char* name); +const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *, const char *name); +const GPUShaderInput *GPU_shaderinterface_uniform_builtin(const GPUShaderInterface *, GPUUniformBuiltin); +const GPUShaderInput *GPU_shaderinterface_ubo(const GPUShaderInterface *, const char *name); +const GPUShaderInput *GPU_shaderinterface_attr(const GPUShaderInterface *, const char *name); /* keep track of batches using this interface */ -void GPU_shaderinterface_add_batch_ref(GPUShaderInterface*, struct GPUBatch*); -void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface*, struct GPUBatch*); +void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *, struct GPUBatch *); +void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface *, struct GPUBatch *); #endif /* __GPU_SHADER_INTERFACE_H__ */ diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index 2d7ab6cd54c..16627fec42b 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -27,7 +27,7 @@ #ifndef __GPU_STATE_H__ #define __GPU_STATE_H__ - /* These map directly to the GL_ blend functions, to minimize API add as needed*/ +/* These map directly to the GL_ blend functions, to minimize API add as needed*/ typedef enum GPUBlendFunction { GPU_ONE, GPU_SRC_ALPHA, diff --git a/source/blender/gpu/GPU_vertex_array_id.h b/source/blender/gpu/GPU_vertex_array_id.h index 3b3fdc1709d..ff84a290a5a 100644 --- a/source/blender/gpu/GPU_vertex_array_id.h +++ b/source/blender/gpu/GPU_vertex_array_id.h @@ -46,7 +46,7 @@ extern "C" { GLuint GPU_vao_default(void); GLuint GPU_vao_alloc(void); -void GPU_vao_free(GLuint vao_id, GPUContext*); +void GPU_vao_free(GLuint vao_id, GPUContext *); #ifdef __cplusplus } diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h index 896de387065..db1309bcede 100644 --- a/source/blender/gpu/GPU_vertex_buffer.h +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -55,54 +55,54 @@ typedef struct GPUVertBuf { uint vertex_len; /* number of verts we want to draw */ uint vertex_alloc; /* number of verts data */ bool dirty; - unsigned char* data; /* NULL indicates data in VRAM (unmapped) */ + unsigned char *data; /* NULL indicates data in VRAM (unmapped) */ uint32_t vbo_id; /* 0 indicates not yet allocated */ GPUUsageType usage; /* usage hint for GL optimisation */ } GPUVertBuf; -GPUVertBuf* GPU_vertbuf_create(GPUUsageType); -GPUVertBuf* GPU_vertbuf_create_with_format_ex(const GPUVertFormat*, GPUUsageType); +GPUVertBuf *GPU_vertbuf_create(GPUUsageType); +GPUVertBuf *GPU_vertbuf_create_with_format_ex(const GPUVertFormat *, GPUUsageType); #define GPU_vertbuf_create_with_format(format) \ GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_STATIC) -void GPU_vertbuf_discard(GPUVertBuf*); +void GPU_vertbuf_discard(GPUVertBuf *); -void GPU_vertbuf_init(GPUVertBuf*, GPUUsageType); -void GPU_vertbuf_init_with_format_ex(GPUVertBuf*, const GPUVertFormat*, GPUUsageType); +void GPU_vertbuf_init(GPUVertBuf *, GPUUsageType); +void GPU_vertbuf_init_with_format_ex(GPUVertBuf *, const GPUVertFormat *, GPUUsageType); #define GPU_vertbuf_init_with_format(verts, format) \ GPU_vertbuf_init_with_format_ex(verts, format, GPU_USAGE_STATIC) -uint GPU_vertbuf_size_get(const GPUVertBuf*); -void GPU_vertbuf_data_alloc(GPUVertBuf*, uint v_len); -void GPU_vertbuf_data_resize(GPUVertBuf*, uint v_len); -void GPU_vertbuf_vertex_count_set(GPUVertBuf*, uint v_len); +uint GPU_vertbuf_size_get(const GPUVertBuf *); +void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len); +void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len); +void GPU_vertbuf_vertex_count_set(GPUVertBuf *, uint v_len); /* The most important set_attrib variant is the untyped one. Get it right first. */ /* It takes a void* so the app developer is responsible for matching their app data types */ /* to the vertex attribute's type and component count. They're in control of both, so this */ /* should not be a problem. */ -void GPU_vertbuf_attr_set(GPUVertBuf*, uint a_idx, uint v_idx, const void* data); -void GPU_vertbuf_attr_fill(GPUVertBuf*, uint a_idx, const void* data); /* tightly packed, non interleaved input data */ -void GPU_vertbuf_attr_fill_stride(GPUVertBuf*, uint a_idx, uint stride, const void* data); +void GPU_vertbuf_attr_set(GPUVertBuf *, uint a_idx, uint v_idx, const void *data); +void GPU_vertbuf_attr_fill(GPUVertBuf *, uint a_idx, const void *data); /* tightly packed, non interleaved input data */ +void GPU_vertbuf_attr_fill_stride(GPUVertBuf *, uint a_idx, uint stride, const void *data); /* For low level access only */ typedef struct GPUVertBufRaw { uint size; uint stride; - unsigned char* data; - unsigned char* data_init; + unsigned char *data; + unsigned char *data_init; #if TRUST_NO_ONE /* Only for overflow check */ - unsigned char* _data_end; + unsigned char *_data_end; #endif } GPUVertBufRaw; GPU_INLINE void *GPU_vertbuf_raw_step(GPUVertBufRaw *a) { - unsigned char* data = a->data; + unsigned char *data = a->data; a->data += a->stride; #if TRUST_NO_ONE assert(data < a->_data_end); @@ -115,7 +115,7 @@ GPU_INLINE uint GPU_vertbuf_raw_used(GPUVertBufRaw *a) return ((a->data - a->data_init) / a->stride); } -void GPU_vertbuf_attr_get_raw_data(GPUVertBuf*, uint a_idx, GPUVertBufRaw *access); +void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *, uint a_idx, GPUVertBufRaw *access); /* TODO: decide whether to keep the functions below */ /* doesn't immediate mode satisfy these needs? */ @@ -128,7 +128,7 @@ void GPU_vertbuf_attr_get_raw_data(GPUVertBuf*, uint a_idx, GPUVertBufRaw *acces /* void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b); */ /* void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a); */ -void GPU_vertbuf_use(GPUVertBuf*); +void GPU_vertbuf_use(GPUVertBuf *); /* Metrics */ uint GPU_vertbuf_get_memory_usage(void); diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 7ae8118a928..7e0038e3473 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -67,7 +67,7 @@ typedef struct GPUVertAttr { uint sz; /* size in bytes, 1 to 64 */ uint offset; /* from beginning of vertex, in bytes */ uint name_len; /* up to GPU_VERT_ATTR_MAX_NAMES */ - const char* name[GPU_VERT_ATTR_MAX_NAMES]; + const char *name[GPU_VERT_ATTR_MAX_NAMES]; } GPUVertAttr; typedef struct GPUVertFormat { @@ -80,11 +80,13 @@ typedef struct GPUVertFormat { GPUVertAttr attribs[GPU_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */ } GPUVertFormat; -void GPU_vertformat_clear(GPUVertFormat*); -void GPU_vertformat_copy(GPUVertFormat* dest, const GPUVertFormat* src); +void GPU_vertformat_clear(GPUVertFormat *); +void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src); -uint GPU_vertformat_attr_add(GPUVertFormat*, const char* name, GPUVertCompType, uint comp_len, GPUVertFetchMode); -void GPU_vertformat_alias_add(GPUVertFormat*, const char* alias); +uint GPU_vertformat_attr_add( + GPUVertFormat *, const char *name, + GPUVertCompType, uint comp_len, GPUVertFetchMode); +void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias); /* format conversion */ @@ -92,7 +94,7 @@ typedef struct GPUPackedNormal { int x : 10; int y : 10; int z : 10; - int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */ + int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */ } GPUPackedNormal; GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3]); diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c index 9ac38578792..e66fac390f1 100644 --- a/source/blender/gpu/intern/gpu_attr_binding.c +++ b/source/blender/gpu/intern/gpu_attr_binding.c @@ -38,13 +38,13 @@ #error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16" #endif -void AttribBinding_clear(GPUAttrBinding* binding) +void AttribBinding_clear(GPUAttrBinding *binding) { binding->loc_bits = 0; binding->enabled_bits = 0; } -uint read_attrib_location(const GPUAttrBinding* binding, uint a_idx) +uint read_attrib_location(const GPUAttrBinding *binding, uint a_idx) { #if TRUST_NO_ONE assert(a_idx < GPU_VERT_ATTR_MAX_LEN); @@ -53,7 +53,7 @@ uint read_attrib_location(const GPUAttrBinding* binding, uint a_idx) return (binding->loc_bits >> (4 * a_idx)) & 0xF; } -static void write_attrib_location(GPUAttrBinding* binding, uint a_idx, uint location) +static void write_attrib_location(GPUAttrBinding *binding, uint a_idx, uint location) { #if TRUST_NO_ONE assert(a_idx < GPU_VERT_ATTR_MAX_LEN); @@ -67,14 +67,14 @@ static void write_attrib_location(GPUAttrBinding* binding, uint a_idx, uint loca binding->enabled_bits |= 1 << a_idx; } -void get_attrib_locations(const GPUVertFormat* format, GPUAttrBinding* binding, const GPUShaderInterface* shaderface) +void get_attrib_locations(const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface) { AttribBinding_clear(binding); for (uint a_idx = 0; a_idx < format->attr_len; ++a_idx) { - const GPUVertAttr* a = format->attribs + a_idx; + const GPUVertAttr *a = format->attribs + a_idx; for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { - const GPUShaderInput* input = GPU_shaderinterface_attr(shaderface, a->name[n_idx]); + const GPUShaderInput *input = GPU_shaderinterface_attr(shaderface, a->name[n_idx]); #if TRUST_NO_ONE assert(input != NULL); /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */ diff --git a/source/blender/gpu/intern/gpu_basic_shader.c b/source/blender/gpu/intern/gpu_basic_shader.c index b720bed2d0c..61e8cf87038 100644 --- a/source/blender/gpu/intern/gpu_basic_shader.c +++ b/source/blender/gpu/intern/gpu_basic_shader.c @@ -82,7 +82,8 @@ const GLubyte stipple_halftone[128] = { 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55}; + 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, +}; const GLubyte stipple_quarttone[128] = { 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, @@ -92,7 +93,8 @@ const GLubyte stipple_quarttone[128] = { 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0}; + 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, +}; const GLubyte stipple_diag_stripes_pos[128] = { 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, @@ -110,7 +112,8 @@ const GLubyte stipple_diag_stripes_pos[128] = { 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07, 0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f, - 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f}; + 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f, +}; const GLubyte stipple_diag_stripes_neg[128] = { 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, @@ -128,7 +131,8 @@ const GLubyte stipple_diag_stripes_neg[128] = { 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, 0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8, 0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0, - 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80}; + 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, +}; const GLubyte stipple_checker_8px[128] = { 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, @@ -138,7 +142,8 @@ const GLubyte stipple_checker_8px[128] = { 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, - 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255}; + 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, +}; const GLubyte stipple_hexagon[128] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, @@ -156,7 +161,8 @@ const GLubyte stipple_hexagon[128] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22}; + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, +}; /* ********************************************* */ /* Init / exit */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 4d455f6f464..a11eefee078 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -44,9 +44,9 @@ #include #include -static void batch_update_program_bindings(GPUBatch* batch, uint v_first); +static void batch_update_program_bindings(GPUBatch *batch, uint v_first); -void GPU_batch_vao_cache_clear(GPUBatch* batch) +void GPU_batch_vao_cache_clear(GPUBatch *batch) { if (batch->context == NULL) { return; @@ -82,17 +82,17 @@ void GPU_batch_vao_cache_clear(GPUBatch* batch) batch->context = NULL; } -GPUBatch* GPU_batch_create_ex( - GPUPrimType prim_type, GPUVertBuf* verts, GPUIndexBuf* elem, +GPUBatch *GPU_batch_create_ex( + GPUPrimType prim_type, GPUVertBuf *verts, GPUIndexBuf *elem, uint owns_flag) { - GPUBatch* batch = calloc(1, sizeof(GPUBatch)); + GPUBatch *batch = calloc(1, sizeof(GPUBatch)); GPU_batch_init_ex(batch, prim_type, verts, elem, owns_flag); return batch; } void GPU_batch_init_ex( - GPUBatch* batch, GPUPrimType prim_type, GPUVertBuf* verts, GPUIndexBuf* elem, + GPUBatch *batch, GPUPrimType prim_type, GPUVertBuf *verts, GPUIndexBuf *elem, uint owns_flag) { #if TRUST_NO_ONE @@ -113,9 +113,9 @@ void GPU_batch_init_ex( } /* This will share the VBOs with the new batch. */ -GPUBatch* GPU_batch_duplicate(GPUBatch* batch_src) +GPUBatch *GPU_batch_duplicate(GPUBatch *batch_src) { - GPUBatch* batch = GPU_batch_create_ex(GPU_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); batch->gl_prim_type = batch_src->gl_prim_type; for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; ++v) { @@ -124,7 +124,7 @@ GPUBatch* GPU_batch_duplicate(GPUBatch* batch_src) return batch; } -void GPU_batch_discard(GPUBatch* batch) +void GPU_batch_discard(GPUBatch *batch) { if (batch->owns_flag & GPU_BATCH_OWNS_INDEX) { GPU_indexbuf_discard(batch->elem); @@ -150,13 +150,13 @@ void GPU_batch_discard(GPUBatch* batch) free(batch); } -void GPU_batch_callback_free_set(GPUBatch* batch, void (*callback)(GPUBatch*, void*), void* user_data) +void GPU_batch_callback_free_set(GPUBatch *batch, void (*callback)(GPUBatch *, void *), void *user_data) { batch->free_callback = callback; batch->callback_data = user_data; } -void GPU_batch_instbuf_set(GPUBatch* batch, GPUVertBuf* inst, bool own_vbo) +void GPU_batch_instbuf_set(GPUBatch *batch, GPUVertBuf *inst, bool own_vbo) { #if TRUST_NO_ONE assert(inst != NULL); @@ -179,7 +179,7 @@ void GPU_batch_instbuf_set(GPUBatch* batch, GPUVertBuf* inst, bool own_vbo) /* Returns the index of verts in the batch. */ int GPU_batch_vertbuf_add_ex( - GPUBatch* batch, GPUVertBuf* verts, + GPUBatch *batch, GPUVertBuf *verts, bool own_vbo) { /* redo the bindings */ @@ -238,7 +238,7 @@ static GLuint batch_vao_get(GPUBatch *batch) GLuint new_vao = 0; if (!batch->is_dynamic_vao_count) { int i; /* find first unused slot */ - for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) + for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) if (batch->static_vaos.vao_ids[i] == 0) break; @@ -251,12 +251,12 @@ static GLuint batch_vao_get(GPUBatch *batch) batch->is_dynamic_vao_count = true; /* Erase previous entries, they will be added back if drawn again. */ for (int j = 0; j < GPU_BATCH_VAO_STATIC_LEN; ++j) { - GPU_shaderinterface_remove_batch_ref((GPUShaderInterface*)batch->static_vaos.interfaces[j], batch); + GPU_shaderinterface_remove_batch_ref((GPUShaderInterface *)batch->static_vaos.interfaces[j], batch); GPU_vao_free(batch->static_vaos.vao_ids[j], batch->context); } /* Init dynamic arrays and let the branch below set the values. */ batch->dynamic_vaos.count = GPU_BATCH_VAO_DYN_ALLOC_COUNT; - batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(GPUShaderInterface*)); + batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(GPUShaderInterface *)); batch->dynamic_vaos.vao_ids = calloc(batch->dynamic_vaos.count, sizeof(GLuint)); } } @@ -271,16 +271,16 @@ static GLuint batch_vao_get(GPUBatch *batch) /* Not enough place, realloc the array. */ i = batch->dynamic_vaos.count; batch->dynamic_vaos.count += GPU_BATCH_VAO_DYN_ALLOC_COUNT; - batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(GPUShaderInterface*) * batch->dynamic_vaos.count); + batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(GPUShaderInterface *) * batch->dynamic_vaos.count); batch->dynamic_vaos.vao_ids = realloc(batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count); - memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(GPUShaderInterface*) * GPU_BATCH_VAO_DYN_ALLOC_COUNT); + memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(GPUShaderInterface *) * GPU_BATCH_VAO_DYN_ALLOC_COUNT); memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GPU_BATCH_VAO_DYN_ALLOC_COUNT); } batch->dynamic_vaos.interfaces[i] = batch->interface; batch->dynamic_vaos.vao_ids[i] = new_vao = GPU_vao_alloc(); } - GPU_shaderinterface_add_batch_ref((GPUShaderInterface*)batch->interface, batch); + GPU_shaderinterface_add_batch_ref((GPUShaderInterface *)batch->interface, batch); #if TRUST_NO_ONE assert(new_vao != 0); @@ -294,7 +294,7 @@ static GLuint batch_vao_get(GPUBatch *batch) return new_vao; } -void GPU_batch_program_set_no_use(GPUBatch* batch, uint32_t program, const GPUShaderInterface* shaderface) +void GPU_batch_program_set_no_use(GPUBatch *batch, uint32_t program, const GPUShaderInterface *shaderface) { #if TRUST_NO_ONE assert(glIsProgram(shaderface->program)); @@ -305,13 +305,13 @@ void GPU_batch_program_set_no_use(GPUBatch* batch, uint32_t program, const GPUSh batch->vao_id = batch_vao_get(batch); } -void GPU_batch_program_set(GPUBatch* batch, uint32_t program, const GPUShaderInterface* shaderface) +void GPU_batch_program_set(GPUBatch *batch, uint32_t program, const GPUShaderInterface *shaderface) { GPU_batch_program_set_no_use(batch, program, shaderface); GPU_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */ } -void gpu_batch_remove_interface_ref(GPUBatch* batch, const GPUShaderInterface* interface) +void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface) { if (batch->is_dynamic_vao_count) { for (int i = 0; i < batch->dynamic_vaos.count; ++i) { @@ -337,10 +337,10 @@ void gpu_batch_remove_interface_ref(GPUBatch* batch, const GPUShaderInterface* i } static void create_bindings( - GPUVertBuf* verts, const GPUShaderInterface* interface, - uint v_first, const bool use_instancing) + GPUVertBuf *verts, const GPUShaderInterface *interface, + uint v_first, const bool use_instancing) { - const GPUVertFormat* format = &verts->format; + const GPUVertFormat *format = &verts->format; const uint attr_len = format->attr_len; const uint stride = format->stride; @@ -348,11 +348,11 @@ static void create_bindings( GPU_vertbuf_use(verts); for (uint a_idx = 0; a_idx < attr_len; ++a_idx) { - const GPUVertAttr* a = format->attribs + a_idx; - const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride; + const GPUVertAttr *a = format->attribs + a_idx; + const GLvoid *pointer = (const GLubyte *)0 + a->offset + v_first * stride; for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { - const GPUShaderInput* input = GPU_shaderinterface_attr(interface, a->name[n_idx]); + const GPUShaderInput *input = GPU_shaderinterface_attr(interface, a->name[n_idx]); if (input == NULL) continue; @@ -365,11 +365,10 @@ static void create_bindings( glEnableVertexAttribArray(input->location + i); glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0); glVertexAttribPointer(input->location + i, 4, a->gl_comp_type, GL_FALSE, stride, - (const GLubyte*)pointer + i * 16); + (const GLubyte *)pointer + i * 16); } } - else - { + else { glEnableVertexAttribArray(input->location); glVertexAttribDivisor(input->location, (use_instancing) ? 1 : 0); @@ -390,7 +389,7 @@ static void create_bindings( } } -static void batch_update_program_bindings(GPUBatch* batch, uint v_first) +static void batch_update_program_bindings(GPUBatch *batch, uint v_first) { for (int v = 0; v < GPU_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false); @@ -403,7 +402,7 @@ static void batch_update_program_bindings(GPUBatch* batch, uint v_first) } } -void GPU_batch_program_use_begin(GPUBatch* batch) +void GPU_batch_program_use_begin(GPUBatch *batch) { /* NOTE: use_program & done_using_program are fragile, depend on staying in sync with * the GL context's active program. use_program doesn't mark other programs as "not used". */ @@ -415,7 +414,7 @@ void GPU_batch_program_use_begin(GPUBatch* batch) } } -void GPU_batch_program_use_end(GPUBatch* batch) +void GPU_batch_program_use_end(GPUBatch *batch) { if (batch->program_in_use) { #if PROGRAM_NO_OPTI @@ -426,84 +425,84 @@ void GPU_batch_program_use_end(GPUBatch* batch) } #if TRUST_NO_ONE - #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(batch->interface, name); assert(uniform); +# define GET_UNIFORM const GPUShaderInput *uniform = GPU_shaderinterface_uniform(batch->interface, name); assert(uniform); #else - #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(batch->interface, name); +# define GET_UNIFORM const GPUShaderInput *uniform = GPU_shaderinterface_uniform(batch->interface, name); #endif -void GPU_batch_uniform_1ui(GPUBatch* batch, const char* name, int value) +void GPU_batch_uniform_1ui(GPUBatch *batch, const char *name, int value) { GET_UNIFORM glUniform1ui(uniform->location, value); } -void GPU_batch_uniform_1i(GPUBatch* batch, const char* name, int value) +void GPU_batch_uniform_1i(GPUBatch *batch, const char *name, int value) { GET_UNIFORM glUniform1i(uniform->location, value); } -void GPU_batch_uniform_1b(GPUBatch* batch, const char* name, bool value) +void GPU_batch_uniform_1b(GPUBatch *batch, const char *name, bool value) { GET_UNIFORM glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE); } -void GPU_batch_uniform_2f(GPUBatch* batch, const char* name, float x, float y) +void GPU_batch_uniform_2f(GPUBatch *batch, const char *name, float x, float y) { GET_UNIFORM glUniform2f(uniform->location, x, y); } -void GPU_batch_uniform_3f(GPUBatch* batch, const char* name, float x, float y, float z) +void GPU_batch_uniform_3f(GPUBatch *batch, const char *name, float x, float y, float z) { GET_UNIFORM glUniform3f(uniform->location, x, y, z); } -void GPU_batch_uniform_4f(GPUBatch* batch, const char* name, float x, float y, float z, float w) +void GPU_batch_uniform_4f(GPUBatch *batch, const char *name, float x, float y, float z, float w) { GET_UNIFORM glUniform4f(uniform->location, x, y, z, w); } -void GPU_batch_uniform_1f(GPUBatch* batch, const char* name, float x) +void GPU_batch_uniform_1f(GPUBatch *batch, const char *name, float x) { GET_UNIFORM glUniform1f(uniform->location, x); } -void GPU_batch_uniform_2fv(GPUBatch* batch, const char* name, const float data[2]) +void GPU_batch_uniform_2fv(GPUBatch *batch, const char *name, const float data[2]) { GET_UNIFORM glUniform2fv(uniform->location, 1, data); } -void GPU_batch_uniform_3fv(GPUBatch* batch, const char* name, const float data[3]) +void GPU_batch_uniform_3fv(GPUBatch *batch, const char *name, const float data[3]) { GET_UNIFORM glUniform3fv(uniform->location, 1, data); } -void GPU_batch_uniform_4fv(GPUBatch* batch, const char* name, const float data[4]) +void GPU_batch_uniform_4fv(GPUBatch *batch, const char *name, const float data[4]) { GET_UNIFORM glUniform4fv(uniform->location, 1, data); } -void GPU_batch_uniform_2fv_array(GPUBatch* batch, const char* name, const int len, const float *data) +void GPU_batch_uniform_2fv_array(GPUBatch *batch, const char *name, const int len, const float *data) { GET_UNIFORM glUniform2fv(uniform->location, len, data); } -void GPU_batch_uniform_4fv_array(GPUBatch* batch, const char* name, const int len, const float *data) +void GPU_batch_uniform_4fv_array(GPUBatch *batch, const char *name, const int len, const float *data) { GET_UNIFORM glUniform4fv(uniform->location, len, data); } -void GPU_batch_uniform_mat4(GPUBatch* batch, const char* name, const float data[4][4]) +void GPU_batch_uniform_mat4(GPUBatch *batch, const char *name, const float data[4][4]) { GET_UNIFORM glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (const float *)data); @@ -530,7 +529,7 @@ static void primitive_restart_disable(void) glDisable(GL_PRIMITIVE_RESTART); } -void GPU_batch_draw(GPUBatch* batch) +void GPU_batch_draw(GPUBatch *batch) { #if TRUST_NO_ONE assert(batch->phase == GPU_BATCH_READY_TO_DRAW); @@ -544,7 +543,7 @@ void GPU_batch_draw(GPUBatch* batch) GPU_batch_program_use_end(batch); } -void GPU_batch_draw_range_ex(GPUBatch* batch, int v_first, int v_count, bool force_instance) +void GPU_batch_draw_range_ex(GPUBatch *batch, int v_first, int v_count, bool force_instance) { #if TRUST_NO_ONE assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance @@ -567,7 +566,7 @@ void GPU_batch_draw_range_ex(GPUBatch* batch, int v_first, int v_count, bool for } if (batch->elem) { - const GPUIndexBuf* el = batch->elem; + const GPUIndexBuf *el = batch->elem; if (el->use_prim_restart) { primitive_restart_enable(el); @@ -597,7 +596,7 @@ void GPU_batch_draw_range_ex(GPUBatch* batch, int v_first, int v_count, bool for } if (batch->elem) { - const GPUIndexBuf* el = batch->elem; + const GPUIndexBuf *el = batch->elem; if (el->use_prim_restart) { primitive_restart_enable(el); @@ -605,13 +604,14 @@ void GPU_batch_draw_range_ex(GPUBatch* batch, int v_first, int v_count, bool for #if GPU_TRACK_INDEX_RANGE if (el->base_index) { - glDrawRangeElementsBaseVertex(batch->gl_prim_type, - el->min_index, - el->max_index, - v_count, - el->gl_index_type, - 0, - el->base_index); + glDrawRangeElementsBaseVertex( + batch->gl_prim_type, + el->min_index, + el->max_index, + v_count, + el->gl_index_type, + 0, + el->base_index); } else { glDrawRangeElements(batch->gl_prim_type, el->min_index, el->max_index, v_count, el->gl_index_type, 0); @@ -635,7 +635,7 @@ void GPU_batch_draw_range_ex(GPUBatch* batch, int v_first, int v_count, bool for /* just draw some vertices and let shader place them where we want. */ void GPU_draw_primitive(GPUPrimType prim_type, int v_count) - { +{ /* we cannot draw without vao ... annoying ... */ glBindVertexArray(GPU_vao_default()); @@ -645,7 +645,7 @@ void GPU_draw_primitive(GPUPrimType prim_type, int v_count) /* Performance hog if you are drawing with the same vao multiple time. * Only activate for debugging.*/ // glBindVertexArray(0); - } +} /* -------------------------------------------------------------------- */ @@ -674,4 +674,4 @@ void gpu_batch_exit(void) gpu_batch_presets_exit(); } -/** \} */ \ No newline at end of file +/** \} */ diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index d466fa87388..16590785af6 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -522,42 +522,42 @@ void GPU_pbvh_grid_buffers_update( /* Build the element array buffer of grid indices using either * unsigned shorts or unsigned ints. */ #define FILL_QUAD_BUFFER(max_vert_, tot_quad_, buffer_) \ - { \ - int offset = 0; \ - int i, j, k; \ + { \ + int offset = 0; \ + int i, j, k; \ \ - GPUIndexBufBuilder elb; \ - GPU_indexbuf_init( \ - &elb, GPU_PRIM_TRIS, tot_quad_ * 2, max_vert_); \ + GPUIndexBufBuilder elb; \ + GPU_indexbuf_init( \ + &elb, GPU_PRIM_TRIS, tot_quad_ * 2, max_vert_); \ \ - /* Fill the buffer */ \ - for (i = 0; i < totgrid; ++i) { \ - BLI_bitmap *gh = NULL; \ - if (grid_hidden) \ - gh = grid_hidden[(grid_indices)[i]]; \ + /* Fill the buffer */ \ + for (i = 0; i < totgrid; ++i) { \ + BLI_bitmap *gh = NULL; \ + if (grid_hidden) \ + gh = grid_hidden[(grid_indices)[i]]; \ \ - for (j = 0; j < gridsize - 1; ++j) { \ - for (k = 0; k < gridsize - 1; ++k) { \ - /* Skip hidden grid face */ \ - if (gh && paint_is_grid_face_hidden( \ - gh, gridsize, k, j)) \ - { \ - continue; \ - } \ - GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ - GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k); \ - GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ - \ - GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k + 1); \ - GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ - GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ - } \ - } \ + for (j = 0; j < gridsize - 1; ++j) { \ + for (k = 0; k < gridsize - 1; ++k) { \ + /* Skip hidden grid face */ \ + if (gh && paint_is_grid_face_hidden( \ + gh, gridsize, k, j)) \ + { \ + continue; \ + } \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k); \ + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ \ - offset += gridsize * gridsize; \ - } \ - buffer_ = GPU_indexbuf_build(&elb); \ - } (void)0 + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ + } \ + } \ + \ + offset += gridsize * gridsize; \ + } \ + buffer_ = GPU_indexbuf_build(&elb); \ + } (void)0 /* end FILL_QUAD_BUFFER */ static GPUIndexBuf *gpu_get_grid_buffer( @@ -912,7 +912,7 @@ void GPU_pbvh_bmesh_buffers_update( BM_face_as_array_vert_tri(f, v); GPU_indexbuf_add_tri_verts( - &elb, BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2])); + &elb, BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2])); } } diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 51f21d01a9f..3b9d2e08769 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -615,10 +615,11 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds, if ((input->source == GPU_SOURCE_TEX) || (input->source == GPU_SOURCE_TEX_PIXEL)) { /* create exactly one sampler for each texture */ if (codegen_input_has_texture(input) && input->bindtex) { - BLI_dynstr_appendf(ds, "uniform %s samp%d;\n", - (input->textype == GPU_TEX2D) ? "sampler2D" : - (input->textype == GPU_TEXCUBE) ? "samplerCube" : "sampler2DShadow", - input->texid); + BLI_dynstr_appendf( + ds, "uniform %s samp%d;\n", + (input->textype == GPU_TEX2D) ? "sampler2D" : + (input->textype == GPU_TEXCUBE) ? "samplerCube" : "sampler2DShadow", + input->texid); } } else if (input->source == GPU_SOURCE_BUILTIN) { @@ -635,13 +636,15 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds, } } else if (gpu_str_prefix(name, "unf")) { - BLI_dynstr_appendf(ds, "uniform %s %s;\n", - GPU_DATATYPE_STR[input->type], name); + BLI_dynstr_appendf( + ds, "uniform %s %s;\n", + GPU_DATATYPE_STR[input->type], name); } else { - BLI_dynstr_appendf(ds, "%s %s %s;\n", - GLEW_VERSION_3_0 ? "in" : "varying", - GPU_DATATYPE_STR[input->type], name); + BLI_dynstr_appendf( + ds, "%s %s %s;\n", + GLEW_VERSION_3_0 ? "in" : "varying", + GPU_DATATYPE_STR[input->type], name); } } } @@ -658,12 +661,14 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds, } else if (input->dynamicvec) { /* only create uniforms for dynamic vectors */ - BLI_dynstr_appendf(ds, "uniform %s unf%d;\n", - GPU_DATATYPE_STR[input->type], input->id); + BLI_dynstr_appendf( + ds, "uniform %s unf%d;\n", + GPU_DATATYPE_STR[input->type], input->id); } else { - BLI_dynstr_appendf(ds, "const %s cons%d = ", - GPU_DATATYPE_STR[input->type], input->id); + BLI_dynstr_appendf( + ds, "const %s cons%d = ", + GPU_DATATYPE_STR[input->type], input->id); codegen_print_datatype(ds, input->type, input->vec); BLI_dynstr_append(ds, ";\n"); } @@ -675,9 +680,10 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds, BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n"); } #endif - BLI_dynstr_appendf(ds, "%s %s var%d;\n", - GLEW_VERSION_3_0 ? "in" : "varying", - GPU_DATATYPE_STR[input->type], input->attribid); + BLI_dynstr_appendf( + ds, "%s %s var%d;\n", + GLEW_VERSION_3_0 ? "in" : "varying", + GPU_DATATYPE_STR[input->type], input->attribid); #ifdef WITH_OPENSUBDIV if (skip_opensubdiv) { BLI_dynstr_appendf(ds, "#endif\n"); @@ -696,8 +702,9 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds, for (LinkData *link = ubo_inputs.first; link; link = link->next) { input = link->data; - BLI_dynstr_appendf(ds, "\t%s unf%d;\n", - GPU_DATATYPE_STR[input->type], input->id); + BLI_dynstr_appendf( + ds, "\t%s unf%d;\n", + GPU_DATATYPE_STR[input->type], input->id); } BLI_dynstr_append(ds, "};\n"); BLI_freelistN(&ubo_inputs); @@ -719,9 +726,11 @@ static void codegen_declare_tmps(DynStr *ds, ListBase *nodes) for (input = node->inputs.first; input; input = input->next) { if (input->source == GPU_SOURCE_TEX_PIXEL) { if (codegen_input_has_texture(input) && input->definetex) { - BLI_dynstr_appendf(ds, "\tvec4 tex%d = texture2D(", input->texid); - BLI_dynstr_appendf(ds, "samp%d, gl_TexCoord[%d].st);\n", - input->texid, input->texid); + BLI_dynstr_appendf( + ds, "\tvec4 tex%d = texture2D(", input->texid); + BLI_dynstr_appendf( + ds, "samp%d, gl_TexCoord[%d].st);\n", + input->texid, input->texid); } } } @@ -729,11 +738,13 @@ static void codegen_declare_tmps(DynStr *ds, ListBase *nodes) /* declare temporary variables for node output storage */ for (output = node->outputs.first; output; output = output->next) { if (output->type == GPU_CLOSURE) { - BLI_dynstr_appendf(ds, "\tClosure tmp%d;\n", output->id); + BLI_dynstr_appendf( + ds, "\tClosure tmp%d;\n", output->id); } else { - BLI_dynstr_appendf(ds, "\t%s tmp%d;\n", - GPU_DATATYPE_STR[output->type], output->id); + BLI_dynstr_appendf( + ds, "\t%s tmp%d;\n", + GPU_DATATYPE_STR[output->type], output->id); } } } @@ -757,8 +768,9 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final BLI_dynstr_appendf(ds, ", gl_TexCoord[%d].st", input->texid); } else if (input->source == GPU_SOURCE_TEX_PIXEL) { - codegen_convert_datatype(ds, input->link->output->type, input->type, - "tmp", input->link->output->id); + codegen_convert_datatype( + ds, input->link->output->type, input->type, + "tmp", input->link->output->id); } else if (input->source == GPU_SOURCE_BUILTIN) { if (input->builtin == GPU_INVERSE_VIEW_MATRIX) @@ -862,10 +874,12 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO for (input = node->inputs.first; input; input = input->next) { if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { if (input->attribtype == CD_TANGENT) { - BLI_dynstr_appendf(ds, "#ifdef USE_OPENSUBDIV\n"); - BLI_dynstr_appendf(ds, "\t%s var%d;\n", - GPU_DATATYPE_STR[input->type], - input->attribid); + BLI_dynstr_appendf( + ds, "#ifdef USE_OPENSUBDIV\n"); + BLI_dynstr_appendf( + ds, "\t%s var%d;\n", + GPU_DATATYPE_STR[input->type], + input->attribid); if (has_tangent == false) { BLI_dynstr_appendf(ds, "\tvec3 Q1 = dFdx(inpt.v.position.xyz);\n"); BLI_dynstr_appendf(ds, "\tvec3 Q2 = dFdy(inpt.v.position.xyz);\n"); @@ -929,12 +943,13 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u char *code; /* Hairs uv and col attribs are passed by bufferTextures. */ - BLI_dynstr_append(ds, - "#ifdef HAIR_SHADER\n" - "#define DEFINE_ATTRIB(type, attr) uniform samplerBuffer attr\n" - "#else\n" - "#define DEFINE_ATTRIB(type, attr) in type attr\n" - "#endif\n" + BLI_dynstr_append( + ds, + "#ifdef HAIR_SHADER\n" + "#define DEFINE_ATTRIB(type, attr) uniform samplerBuffer attr\n" + "#else\n" + "#define DEFINE_ATTRIB(type, attr) in type attr\n" + "#endif\n" ); for (node = nodes->first; node; node = node->next) { @@ -952,10 +967,12 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u } else { unsigned int hash = BLI_ghashutil_strhash_p(input->attribname); - BLI_dynstr_appendf(ds, "DEFINE_ATTRIB(%s, %s%u);\n", - GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype), hash); - BLI_dynstr_appendf(ds, "#define att%d %s%u\n", - input->attribid, attrib_prefix_get(input->attribtype), hash); + BLI_dynstr_appendf( + ds, "DEFINE_ATTRIB(%s, %s%u);\n", + GPU_DATATYPE_STR[input->type], attrib_prefix_get(input->attribtype), hash); + BLI_dynstr_appendf( + ds, "#define att%d %s%u\n", + input->attribid, attrib_prefix_get(input->attribtype), hash); /* Auto attrib can be vertex color byte buffer. * We need to know and convert them to linear space in VS. */ if (!use_geom && input->attribtype == CD_AUTO_FROM_NAME) { @@ -963,33 +980,36 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u BLI_dynstr_appendf(ds, "#define att%d_is_srgb ba%u\n", input->attribid, hash); } } - BLI_dynstr_appendf(ds, "out %s var%d%s;\n", - GPU_DATATYPE_STR[input->type], input->attribid, use_geom ? "g" : ""); + BLI_dynstr_appendf( + ds, "out %s var%d%s;\n", + GPU_DATATYPE_STR[input->type], input->attribid, use_geom ? "g" : ""); } } } BLI_dynstr_append(ds, "\n"); - BLI_dynstr_append(ds, - "#define ATTRIB\n" - "uniform mat3 NormalMatrix;\n" - "uniform mat4 ModelMatrixInverse;\n" - "vec3 srgb_to_linear_attrib(vec3 c) {\n" - "\tc = max(c, vec3(0.0));\n" - "\tvec3 c1 = c * (1.0 / 12.92);\n" - "\tvec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4));\n" - "\treturn mix(c1, c2, step(vec3(0.04045), c));\n" - "}\n\n" + BLI_dynstr_append( + ds, + "#define ATTRIB\n" + "uniform mat3 NormalMatrix;\n" + "uniform mat4 ModelMatrixInverse;\n" + "vec3 srgb_to_linear_attrib(vec3 c) {\n" + "\tc = max(c, vec3(0.0));\n" + "\tvec3 c1 = c * (1.0 / 12.92);\n" + "\tvec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4));\n" + "\treturn mix(c1, c2, step(vec3(0.04045), c));\n" + "}\n\n" ); /* Prototype because defined later. */ - BLI_dynstr_append(ds, - "vec2 hair_get_customdata_vec2(const samplerBuffer);\n" - "vec3 hair_get_customdata_vec3(const samplerBuffer);\n" - "vec4 hair_get_customdata_vec4(const samplerBuffer);\n" - "vec3 hair_get_strand_pos(void);\n" - "\n" + BLI_dynstr_append( + ds, + "vec2 hair_get_customdata_vec2(const samplerBuffer);\n" + "vec3 hair_get_customdata_vec3(const samplerBuffer);\n" + "vec4 hair_get_customdata_vec4(const samplerBuffer);\n" + "vec3 hair_get_strand_pos(void);\n" + "\n" ); BLI_dynstr_append(ds, "void pass_attrib(in vec3 position) {\n"); @@ -1001,16 +1021,19 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { if (input->attribtype == CD_TANGENT) { /* Not supported by hairs */ - BLI_dynstr_appendf(ds, "\tvar%d%s = vec4(0.0);\n", - input->attribid, use_geom ? "g" : ""); + BLI_dynstr_appendf( + ds, "\tvar%d%s = vec4(0.0);\n", + input->attribid, use_geom ? "g" : ""); } else if (input->attribtype == CD_ORCO) { - BLI_dynstr_appendf(ds, "\tvar%d%s = OrcoTexCoFactors[0] + (ModelMatrixInverse * vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1];\n", - input->attribid, use_geom ? "g" : ""); + BLI_dynstr_appendf( + ds, "\tvar%d%s = OrcoTexCoFactors[0] + (ModelMatrixInverse * vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1];\n", + input->attribid, use_geom ? "g" : ""); } else { - BLI_dynstr_appendf(ds, "\tvar%d%s = hair_get_customdata_%s(att%d);\n", - input->attribid, use_geom ? "g" : "", GPU_DATATYPE_STR[input->type], input->attribid); + BLI_dynstr_appendf( + ds, "\tvar%d%s = hair_get_customdata_%s(att%d);\n", + input->attribid, use_geom ? "g" : "", GPU_DATATYPE_STR[input->type], input->attribid); } } } @@ -1030,21 +1053,25 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u input->attribid, use_geom ? "g" : "", input->attribid); } else if (input->attribtype == CD_ORCO) { - BLI_dynstr_appendf(ds, "\tvar%d%s = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n", - input->attribid, use_geom ? "g" : ""); + BLI_dynstr_appendf( + ds, "\tvar%d%s = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n", + input->attribid, use_geom ? "g" : ""); } else if (input->attribtype == CD_MCOL) { - BLI_dynstr_appendf(ds, "\tvar%d%s = srgb_to_linear_attrib(att%d);\n", - input->attribid, use_geom ? "g" : "", input->attribid); + BLI_dynstr_appendf( + ds, "\tvar%d%s = srgb_to_linear_attrib(att%d);\n", + input->attribid, use_geom ? "g" : "", input->attribid); } else if (input->attribtype == CD_AUTO_FROM_NAME) { - BLI_dynstr_appendf(ds, "\tvar%d%s = (att%d_is_srgb) ? srgb_to_linear_attrib(att%d) : att%d;\n", - input->attribid, use_geom ? "g" : "", - input->attribid, input->attribid, input->attribid); + BLI_dynstr_appendf( + ds, "\tvar%d%s = (att%d_is_srgb) ? srgb_to_linear_attrib(att%d) : att%d;\n", + input->attribid, use_geom ? "g" : "", + input->attribid, input->attribid, input->attribid); } else { - BLI_dynstr_appendf(ds, "\tvar%d%s = att%d;\n", - input->attribid, use_geom ? "g" : "", input->attribid); + BLI_dynstr_appendf( + ds, "\tvar%d%s = att%d;\n", + input->attribid, use_geom ? "g" : "", input->attribid); } } } @@ -1083,12 +1110,14 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code) for (node = nodes->first; node; node = node->next) { for (input = node->inputs.first; input; input = input->next) { if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { - BLI_dynstr_appendf(ds, "in %s var%dg[];\n", - GPU_DATATYPE_STR[input->type], - input->attribid); - BLI_dynstr_appendf(ds, "out %s var%d;\n", - GPU_DATATYPE_STR[input->type], - input->attribid); + BLI_dynstr_appendf( + ds, "in %s var%dg[];\n", + GPU_DATATYPE_STR[input->type], + input->attribid); + BLI_dynstr_appendf( + ds, "out %s var%d;\n", + GPU_DATATYPE_STR[input->type], + input->attribid); } } } @@ -1382,8 +1411,8 @@ static const char *gpu_uniform_set_function_from_type(eNodeSocketDatatype type) case SOCK_RGBA: return "set_rgba"; default: - BLI_assert(!"No gpu function for non-supported eNodeSocketDatatype"); - return NULL; + BLI_assert(!"No gpu function for non-supported eNodeSocketDatatype"); + return NULL; } } @@ -1553,8 +1582,9 @@ void GPU_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *attribs) attribs->layer[a].type = input->attribtype; attribs->layer[a].attribid = input->attribid; - BLI_strncpy(attribs->layer[a].name, input->attribname, - sizeof(attribs->layer[a].name)); + BLI_strncpy( + attribs->layer[a].name, input->attribname, + sizeof(attribs->layer[a].name)); } else { input->attribid = attribs->layer[a].attribid; @@ -1966,11 +1996,12 @@ GPUPass *GPU_generate_pass_new( void GPU_pass_compile(GPUPass *pass) { if (!pass->compiled) { - pass->shader = GPU_shader_create(pass->vertexcode, - pass->fragmentcode, - pass->geometrycode, - NULL, - pass->defines); + pass->shader = GPU_shader_create( + pass->vertexcode, + pass->fragmentcode, + pass->geometrycode, + NULL, + pass->defines); pass->compiled = true; } } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index e2c83d6fadf..965caba0955 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -107,7 +107,7 @@ static bool is_over_resolution_limit(GLenum textarget, int w, int h) int size = (textarget == GL_TEXTURE_2D) ? GPU_max_texture_size() : GPU_max_cube_map_size(); int reslimit = (U.glreslimit != 0) ? - min_ii(U.glreslimit, size) : size; + min_ii(U.glreslimit, size) : size; return (w > reslimit || h > reslimit); } @@ -239,42 +239,48 @@ typedef struct VerifyThreadData { float *srgb_frect; } VerifyThreadData; -static void gpu_verify_high_bit_srgb_buffer_slice(float *srgb_frect, - ImBuf *ibuf, - const int start_line, - const int height) +static void gpu_verify_high_bit_srgb_buffer_slice( + float *srgb_frect, + ImBuf *ibuf, + const int start_line, + const int height) { size_t offset = ibuf->channels * start_line * ibuf->x; float *current_srgb_frect = srgb_frect + offset; float *current_rect_float = ibuf->rect_float + offset; - IMB_buffer_float_from_float(current_srgb_frect, - current_rect_float, - ibuf->channels, - IB_PROFILE_SRGB, - IB_PROFILE_LINEAR_RGB, true, - ibuf->x, height, - ibuf->x, ibuf->x); + IMB_buffer_float_from_float( + current_srgb_frect, + current_rect_float, + ibuf->channels, + IB_PROFILE_SRGB, + IB_PROFILE_LINEAR_RGB, true, + ibuf->x, height, + ibuf->x, ibuf->x); IMB_buffer_float_unpremultiply(current_srgb_frect, ibuf->x, height); } -static void verify_thread_do(void *data_v, - int start_scanline, - int num_scanlines) +static void verify_thread_do( + void *data_v, + int start_scanline, + int num_scanlines) { VerifyThreadData *data = (VerifyThreadData *)data_v; - gpu_verify_high_bit_srgb_buffer_slice(data->srgb_frect, - data->ibuf, - start_scanline, - num_scanlines); + gpu_verify_high_bit_srgb_buffer_slice( + data->srgb_frect, + data->ibuf, + start_scanline, + num_scanlines); } -static void gpu_verify_high_bit_srgb_buffer(float *srgb_frect, - ImBuf *ibuf) +static void gpu_verify_high_bit_srgb_buffer( + float *srgb_frect, + ImBuf *ibuf) { if (ibuf->y < 64) { - gpu_verify_high_bit_srgb_buffer_slice(srgb_frect, - ibuf, - 0, ibuf->y); + gpu_verify_high_bit_srgb_buffer_slice( + srgb_frect, + ibuf, + 0, ibuf->y); } else { VerifyThreadData data; @@ -284,11 +290,12 @@ static void gpu_verify_high_bit_srgb_buffer(float *srgb_frect, } } -GPUTexture *GPU_texture_from_blender(Image *ima, - ImageUser *iuser, - int textarget, - bool is_data, - double UNUSED(time)) +GPUTexture *GPU_texture_from_blender( + Image *ima, + ImageUser *iuser, + int textarget, + bool is_data, + double UNUSED(time)) { if (ima == NULL) { return NULL; @@ -363,11 +370,14 @@ GPUTexture *GPU_texture_from_blender(Image *ima, const bool mipmap = GPU_get_mipmap(); #ifdef WITH_DDS - if (ibuf->ftype == IMB_FTYPE_DDS) + if (ibuf->ftype == IMB_FTYPE_DDS) { GPU_create_gl_tex_compressed(&bindcode, rect, rectw, recth, textarget, mipmap, ima, ibuf); + } else #endif + { GPU_create_gl_tex(&bindcode, rect, frect, rectw, recth, textarget, mipmap, use_high_bit_depth, ima); + } /* mark as non-color data texture */ if (bindcode) { @@ -556,8 +566,9 @@ void GPU_create_gl_tex( if (mip_cube_map) { for (int j = 0; j < 6; j++) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, i, - informat, mipw, miph, 0, GL_RGBA, type, mip_cube_map[j]); + glTexImage2D( + GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, i, + informat, mipw, miph, 0, GL_RGBA, type, mip_cube_map[j]); } } gpu_del_cube_map(mip_cube_map); @@ -639,8 +650,9 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf) size = ((width + 3) / 4) * ((height + 3) / 4) * blocksize; - glCompressedTexImage2D(GL_TEXTURE_2D, i, format, width, height, - 0, size, ibuf->dds_data.data + offset); + glCompressedTexImage2D( + GL_TEXTURE_2D, i, format, width, height, + 0, size, ibuf->dds_data.data + offset); offset += size; width >>= 1; @@ -755,8 +767,9 @@ static bool gpu_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x, ImBuf *ibuf_scale = IMB_allocFromBuffer(NULL, frect, w, h); IMB_scaleImBuf(ibuf_scale, rectw, recth); - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA, - GL_FLOAT, ibuf_scale->rect_float); + glTexSubImage2D( + GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA, + GL_FLOAT, ibuf_scale->rect_float); IMB_freeImBuf(ibuf_scale); } @@ -775,8 +788,9 @@ static bool gpu_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x, } } - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA, - GL_UNSIGNED_BYTE, scalerect); + glTexSubImage2D( + GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA, + GL_UNSIGNED_BYTE, scalerect); MEM_freeN(scalerect); } @@ -860,8 +874,9 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); glPixelStorei(GL_UNPACK_SKIP_ROWS, y); - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, - GL_UNSIGNED_BYTE, ibuf->rect); + glTexSubImage2D( + GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, + GL_UNSIGNED_BYTE, ibuf->rect); glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); @@ -913,8 +928,9 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres) } /* density only */ else { - sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], - GPU_R8, smoke_get_density(sds->fluid), NULL); + sds->tex = GPU_texture_create_3D( + sds->res[0], sds->res[1], sds->res[2], + GPU_R8, smoke_get_density(sds->fluid), NULL); /* Swizzle the RGBA components to read the Red channel so * that the shader stay the same for colored and non color @@ -926,10 +942,12 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres) glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED); GPU_texture_unbind(sds->tex); } - sds->tex_flame = (smoke_has_fuel(sds->fluid)) ? - GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], - GPU_R8, smoke_get_flame(sds->fluid), NULL) : - NULL; + sds->tex_flame = ( + smoke_has_fuel(sds->fluid) ? + GPU_texture_create_3D( + sds->res[0], sds->res[1], sds->res[2], + GPU_R8, smoke_get_flame(sds->fluid), NULL) : + NULL); } else if (!sds->tex && highres) { /* rgba texture for color + density */ @@ -941,8 +959,9 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres) } /* density only */ else { - sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], - GPU_R8, smoke_turbulence_get_density(sds->wt), NULL); + sds->tex = GPU_texture_create_3D( + sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], + GPU_R8, smoke_turbulence_get_density(sds->wt), NULL); /* Swizzle the RGBA components to read the Red channel so * that the shader stay the same for colored and non color @@ -954,14 +973,17 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres) glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED); GPU_texture_unbind(sds->tex); } - sds->tex_flame = (smoke_turbulence_has_fuel(sds->wt)) ? - GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], - GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL) : - NULL; + sds->tex_flame = ( + smoke_turbulence_has_fuel(sds->wt) ? + GPU_texture_create_3D( + sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], + GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL) : + NULL); } - sds->tex_shadow = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], - GPU_R8, sds->shadow, NULL); + sds->tex_shadow = GPU_texture_create_3D( + sds->res[0], sds->res[1], sds->res[2], + GPU_R8, sds->shadow, NULL); } #else // WITH_SMOKE (void)highres; @@ -1301,10 +1323,10 @@ void GPU_select_to_index_array(unsigned int *col, const unsigned int size) { #define INDEX_BUF_ARRAY(INDEX_FROM_BUF_BITS) \ for (i = size; i--; col++) { \ - if ((c = *col)) { \ - *col = INDEX_FROM_BUF_BITS(c); \ - } \ - } ((void)0) + if ((c = *col)) { \ + *col = INDEX_FROM_BUF_BITS(c); \ + } \ + } ((void)0) if (size > 0) { unsigned int i, c; diff --git a/source/blender/gpu/intern/gpu_element.c b/source/blender/gpu/intern/gpu_element.c index 1b5a08ac35c..9abfed2db05 100644 --- a/source/blender/gpu/intern/gpu_element.c +++ b/source/blender/gpu/intern/gpu_element.c @@ -46,7 +46,7 @@ static GLenum convert_index_type_to_gl(GPUIndexBufType type) return table[type]; } -uint GPU_indexbuf_size_get(const GPUIndexBuf* elem) +uint GPU_indexbuf_size_get(const GPUIndexBuf *elem) { #if GPU_TRACK_INDEX_RANGE static const uint table[] = { @@ -61,7 +61,7 @@ uint GPU_indexbuf_size_get(const GPUIndexBuf* elem) } void GPU_indexbuf_init_ex( - GPUIndexBufBuilder* builder, GPUPrimType prim_type, + GPUIndexBufBuilder *builder, GPUPrimType prim_type, uint index_len, uint vertex_len, bool use_prim_restart) { builder->use_prim_restart = use_prim_restart; @@ -72,7 +72,7 @@ void GPU_indexbuf_init_ex( builder->data = calloc(builder->max_index_len, sizeof(uint)); } -void GPU_indexbuf_init(GPUIndexBufBuilder* builder, GPUPrimType prim_type, uint prim_len, uint vertex_len) +void GPU_indexbuf_init(GPUIndexBufBuilder *builder, GPUPrimType prim_type, uint prim_len, uint vertex_len) { uint verts_per_prim = 0; switch (prim_type) { @@ -98,7 +98,7 @@ void GPU_indexbuf_init(GPUIndexBufBuilder* builder, GPUPrimType prim_type, uint GPU_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); } -void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder* builder, uint v) +void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *builder, uint v) { #if TRUST_NO_ONE assert(builder->data != NULL); @@ -108,7 +108,7 @@ void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder* builder, uint v) builder->data[builder->index_len++] = v; } -void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder* builder) +void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *builder) { #if TRUST_NO_ONE assert(builder->data != NULL); @@ -118,7 +118,7 @@ void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder* builder) builder->data[builder->index_len++] = GPU_PRIM_RESTART; } -void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder* builder, uint v) +void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder *builder, uint v) { #if TRUST_NO_ONE assert(builder->prim_type == GPU_PRIM_POINTS); @@ -126,7 +126,7 @@ void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder* builder, uint v) GPU_indexbuf_add_generic_vert(builder, v); } -void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder* builder, uint v1, uint v2) +void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder *builder, uint v1, uint v2) { #if TRUST_NO_ONE assert(builder->prim_type == GPU_PRIM_LINES); @@ -136,7 +136,7 @@ void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder* builder, uint v1, uint v2) GPU_indexbuf_add_generic_vert(builder, v2); } -void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder* builder, uint v1, uint v2, uint v3) +void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *builder, uint v1, uint v2, uint v3) { #if TRUST_NO_ONE assert(builder->prim_type == GPU_PRIM_TRIS); @@ -147,7 +147,7 @@ void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder* builder, uint v1, uint v2, u GPU_indexbuf_add_generic_vert(builder, v3); } -void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder* builder, uint v1, uint v2, uint v3, uint v4) +void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder *builder, uint v1, uint v2, uint v3, uint v4) { #if TRUST_NO_ONE assert(builder->prim_type == GPU_PRIM_LINES_ADJ); @@ -163,7 +163,7 @@ void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder* builder, uint v1, uint /* Everything remains 32 bit while building to keep things simple. * Find min/max after, then convert to smallest index type possible. */ -static uint index_range(const uint values[], uint value_len, uint* min_out, uint* max_out) +static uint index_range(const uint values[], uint value_len, uint *min_out, uint *max_out) { if (value_len == 0) { *min_out = 0; @@ -186,7 +186,7 @@ static uint index_range(const uint values[], uint value_len, uint* min_out, uint return max_value - min_value; } -static void squeeze_indices_byte(GPUIndexBufBuilder *builder, GPUIndexBuf* elem) +static void squeeze_indices_byte(GPUIndexBufBuilder *builder, GPUIndexBuf *elem) { const uint *values = builder->data; const uint index_len = elem->index_len; @@ -212,7 +212,7 @@ static void squeeze_indices_byte(GPUIndexBufBuilder *builder, GPUIndexBuf* elem) } } -static void squeeze_indices_short(GPUIndexBufBuilder *builder, GPUIndexBuf* elem) +static void squeeze_indices_short(GPUIndexBufBuilder *builder, GPUIndexBuf *elem) { const uint *values = builder->data; const uint index_len = elem->index_len; @@ -240,14 +240,14 @@ static void squeeze_indices_short(GPUIndexBufBuilder *builder, GPUIndexBuf* elem #endif /* GPU_TRACK_INDEX_RANGE */ -GPUIndexBuf* GPU_indexbuf_build(GPUIndexBufBuilder* builder) +GPUIndexBuf *GPU_indexbuf_build(GPUIndexBufBuilder *builder) { - GPUIndexBuf* elem = calloc(1, sizeof(GPUIndexBuf)); + GPUIndexBuf *elem = calloc(1, sizeof(GPUIndexBuf)); GPU_indexbuf_build_in_place(builder, elem); return elem; } -void GPU_indexbuf_build_in_place(GPUIndexBufBuilder* builder, GPUIndexBuf* elem) +void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *builder, GPUIndexBuf *elem) { #if TRUST_NO_ONE assert(builder->data != NULL); @@ -294,12 +294,12 @@ void GPU_indexbuf_build_in_place(GPUIndexBufBuilder* builder, GPUIndexBuf* elem) /* other fields are safe to leave */ } -void GPU_indexbuf_use(GPUIndexBuf* elem) +void GPU_indexbuf_use(GPUIndexBuf *elem) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id); } -void GPU_indexbuf_discard(GPUIndexBuf* elem) +void GPU_indexbuf_discard(GPUIndexBuf *elem) { if (elem->vbo_id) { GPU_buf_id_free(elem->vbo_id); diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index ffc72718e42..d28b82ac3cd 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -121,7 +121,7 @@ static GPUTexture *framebuffer_get_depth_tex(GPUFrameBuffer *fb) if (fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex) return fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex; else - return fb->attachments[GPU_FB_DEPTH_STENCIL_ATTACHMENT].tex;; + return fb->attachments[GPU_FB_DEPTH_STENCIL_ATTACHMENT].tex; } static GPUTexture *framebuffer_get_color_tex(GPUFrameBuffer *fb, int slot) @@ -167,12 +167,12 @@ static void gpu_print_framebuffer_error(GLenum status, char err_out[256]) void gpu_framebuffer_module_init(void) { - BLI_thread_local_create(g_currentfb); + BLI_thread_local_create(g_currentfb); } void gpu_framebuffer_module_exit(void) { - BLI_thread_local_delete(g_currentfb); + BLI_thread_local_delete(g_currentfb); } static uint gpu_framebuffer_current_get(void) @@ -340,8 +340,9 @@ static void gpu_framebuffer_attachment_attach(GPUAttachment *attach, GPUAttachme if (attach->layer > -1) { if (GPU_texture_cube(attach->tex)) { - glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + attach->layer, - tex_bind, attach->mip); + glFramebufferTexture2D( + GL_FRAMEBUFFER, gl_attachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + attach->layer, + tex_bind, attach->mip); } else { glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_attachment, tex_bind, attach->mip, attach->layer); @@ -518,7 +519,7 @@ void GPU_framebuffer_read_color( case 1: type = GL_RED; break; case 2: type = GL_RG; break; case 3: type = GL_RGB; break; - case 4: type = GL_RGBA; break; + case 4: type = GL_RGBA; break; default: BLI_assert(false && "wrong number of read channels"); return; @@ -549,12 +550,14 @@ void GPU_framebuffer_blit( const bool do_depth = (blit_buffers & GPU_DEPTH_BIT); const bool do_stencil = (blit_buffers & GPU_STENCIL_BIT); - GPUTexture *read_tex = (do_depth || do_stencil) - ? framebuffer_get_depth_tex(fb_read) - : framebuffer_get_color_tex(fb_read, read_slot); - GPUTexture *write_tex = (do_depth || do_stencil) - ? framebuffer_get_depth_tex(fb_write) - : framebuffer_get_color_tex(fb_write, read_slot); + GPUTexture *read_tex = ( + (do_depth || do_stencil) ? + framebuffer_get_depth_tex(fb_read) : + framebuffer_get_color_tex(fb_read, read_slot)); + GPUTexture *write_tex = ( + (do_depth || do_stencil) ? + framebuffer_get_depth_tex(fb_write) : + framebuffer_get_color_tex(fb_write, read_slot)); if (do_depth) { BLI_assert(GPU_texture_depth(read_tex) && GPU_texture_depth(write_tex)); @@ -585,9 +588,10 @@ void GPU_framebuffer_blit( GLbitfield mask = convert_buffer_bits_to_gl(blit_buffers); - glBlitFramebuffer(0, 0, fb_read->width, fb_read->height, - 0, 0, fb_write->width, fb_write->height, - mask, GL_NEAREST); + glBlitFramebuffer( + 0, 0, fb_read->width, fb_read->height, + 0, 0, fb_write->width, fb_write->height, + mask, GL_NEAREST); /* Restore previous framebuffer */ if (fb_write->object == prev_fb) { @@ -679,7 +683,8 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept ofs = MEM_callocN(sizeof(GPUOffScreen), "GPUOffScreen"); - ofs->color = GPU_texture_create_2D_multisample(width, height, + ofs->color = GPU_texture_create_2D_multisample( + width, height, (high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, NULL, samples, err_out); if (depth) { @@ -776,14 +781,16 @@ void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels) /* create texture for new 'fbo_blit' */ glGenTextures(1, &tex_blit); glBindTexture(GL_TEXTURE_2D, tex_blit); - glTexImage2D(GL_TEXTURE_2D, 0, (type == GL_FLOAT) ? GL_RGBA16F : GL_RGBA8, - w, h, 0, GL_RGBA, type, 0); + glTexImage2D( + GL_TEXTURE_2D, 0, (type == GL_FLOAT) ? GL_RGBA16F : GL_RGBA8, + w, h, 0, GL_RGBA, type, 0); /* write into new single-sample buffer */ glGenFramebuffers(1, &fbo_blit); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_blit); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, tex_blit, 0); + glFramebufferTexture2D( + GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, tex_blit, 0); GLenum status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index a320935919a..06b487fbb25 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -45,17 +45,17 @@ #include /* necessary functions from matrix API */ -extern void GPU_matrix_bind(const GPUShaderInterface*); +extern void GPU_matrix_bind(const GPUShaderInterface *); extern bool GPU_matrix_dirty_get(void); typedef struct { /* TODO: organize this struct by frequency of change (run-time) */ - GPUBatch* batch; - GPUContext* context; + GPUBatch *batch; + GPUContext *context; /* current draw call */ - GLubyte* buffer_data; + GLubyte *buffer_data; uint buffer_offset; uint buffer_bytes_mapped; uint vertex_len; @@ -66,14 +66,14 @@ typedef struct { /* current vertex */ uint vertex_idx; - GLubyte* vertex_data; + GLubyte *vertex_data; uint16_t unassigned_attrib_bits; /* which attributes of current vertex have not been given values? */ GLuint vbo_id; GLuint vao_id; GLuint bound_program; - const GPUShaderInterface* shader_interface; + const GPUShaderInterface *shader_interface; GPUAttrBinding attrib_binding; uint16_t prev_enabled_attrib_bits; /* <-- only affects this VAO, so we're ok */ } Immediate; @@ -131,13 +131,13 @@ void immDestroy(void) initialized = false; } -GPUVertFormat* immVertexFormat(void) +GPUVertFormat *immVertexFormat(void) { GPU_vertformat_clear(&imm.vertex_format); return &imm.vertex_format; } -void immBindProgram(GLuint program, const GPUShaderInterface* shaderface) +void immBindProgram(GLuint program, const GPUShaderInterface *shaderface) { #if TRUST_NO_ONE assert(imm.bound_program == 0); @@ -261,7 +261,7 @@ void immBeginAtMost(GPUPrimType prim_type, uint vertex_len) } -GPUBatch* immBeginBatch(GPUPrimType prim_type, uint vertex_len) +GPUBatch *immBeginBatch(GPUPrimType prim_type, uint vertex_len) { #if TRUST_NO_ONE assert(initialized); @@ -273,7 +273,7 @@ GPUBatch* immBeginBatch(GPUPrimType prim_type, uint vertex_len) imm.vertex_idx = 0; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; - GPUVertBuf* verts = GPU_vertbuf_create_with_format(&imm.vertex_format); + GPUVertBuf *verts = GPU_vertbuf_create_with_format(&imm.vertex_format); GPU_vertbuf_data_alloc(verts, vertex_len); imm.buffer_bytes_mapped = GPU_vertbuf_size_get(verts); @@ -285,7 +285,7 @@ GPUBatch* immBeginBatch(GPUPrimType prim_type, uint vertex_len) return imm.batch; } -GPUBatch* immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len) +GPUBatch *immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len) { imm.strict_vertex_len = false; return immBeginBatch(prim_type, vertex_len); @@ -316,10 +316,10 @@ static void immDrawSetup(void) const uint stride = imm.vertex_format.stride; for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { - const GPUVertAttr* a = imm.vertex_format.attribs + a_idx; + const GPUVertAttr *a = imm.vertex_format.attribs + a_idx; const uint offset = imm.buffer_offset + a->offset; - const GLvoid* pointer = (const GLubyte*)0 + offset; + const GLvoid *pointer = (const GLubyte *)0 + offset; const uint loc = read_attrib_location(&imm.attrib_binding, a_idx); @@ -413,7 +413,7 @@ static void setAttribValueBit(uint attrib_id) void immAttrib1f(uint attrib_id, float x) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_F32); @@ -423,7 +423,7 @@ void immAttrib1f(uint attrib_id, float x) #endif setAttribValueBit(attrib_id); - float* data = (float*)(imm.vertex_data + attrib->offset); + float *data = (float *)(imm.vertex_data + attrib->offset); /* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ data[0] = x; @@ -431,7 +431,7 @@ void immAttrib1f(uint attrib_id, float x) void immAttrib2f(uint attrib_id, float x, float y) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_F32); @@ -441,7 +441,7 @@ void immAttrib2f(uint attrib_id, float x, float y) #endif setAttribValueBit(attrib_id); - float* data = (float*)(imm.vertex_data + attrib->offset); + float *data = (float *)(imm.vertex_data + attrib->offset); /* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ data[0] = x; @@ -450,7 +450,7 @@ void immAttrib2f(uint attrib_id, float x, float y) void immAttrib3f(uint attrib_id, float x, float y, float z) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_F32); @@ -460,7 +460,7 @@ void immAttrib3f(uint attrib_id, float x, float y, float z) #endif setAttribValueBit(attrib_id); - float* data = (float*)(imm.vertex_data + attrib->offset); + float *data = (float *)(imm.vertex_data + attrib->offset); /* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ data[0] = x; @@ -470,7 +470,7 @@ void immAttrib3f(uint attrib_id, float x, float y, float z) void immAttrib4f(uint attrib_id, float x, float y, float z, float w) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_F32); @@ -480,7 +480,7 @@ void immAttrib4f(uint attrib_id, float x, float y, float z, float w) #endif setAttribValueBit(attrib_id); - float* data = (float*)(imm.vertex_data + attrib->offset); + float *data = (float *)(imm.vertex_data + attrib->offset); /* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */ data[0] = x; @@ -491,7 +491,7 @@ void immAttrib4f(uint attrib_id, float x, float y, float z, float w) void immAttrib1u(uint attrib_id, uint x) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_U32); @@ -501,14 +501,14 @@ void immAttrib1u(uint attrib_id, uint x) #endif setAttribValueBit(attrib_id); - uint* data = (uint*)(imm.vertex_data + attrib->offset); + uint *data = (uint *)(imm.vertex_data + attrib->offset); data[0] = x; } void immAttrib2i(uint attrib_id, int x, int y) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_I32); @@ -518,7 +518,7 @@ void immAttrib2i(uint attrib_id, int x, int y) #endif setAttribValueBit(attrib_id); - int* data = (int*)(imm.vertex_data + attrib->offset); + int *data = (int *)(imm.vertex_data + attrib->offset); data[0] = x; data[1] = y; @@ -526,7 +526,7 @@ void immAttrib2i(uint attrib_id, int x, int y) void immAttrib2s(uint attrib_id, short x, short y) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_I16); @@ -536,7 +536,7 @@ void immAttrib2s(uint attrib_id, short x, short y) #endif setAttribValueBit(attrib_id); - short* data = (short*)(imm.vertex_data + attrib->offset); + short *data = (short *)(imm.vertex_data + attrib->offset); data[0] = x; data[1] = y; @@ -559,7 +559,7 @@ void immAttrib4fv(uint attrib_id, const float data[4]) void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_U8); @@ -569,7 +569,7 @@ void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned cha #endif setAttribValueBit(attrib_id); - GLubyte* data = imm.vertex_data + attrib->offset; + GLubyte *data = imm.vertex_data + attrib->offset; /* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */ data[0] = r; @@ -579,7 +579,7 @@ void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned cha void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GPU_COMP_U8); @@ -589,7 +589,7 @@ void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned cha #endif setAttribValueBit(attrib_id); - GLubyte* data = imm.vertex_data + attrib->offset; + GLubyte *data = imm.vertex_data + attrib->offset; /* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */ data[0] = r; @@ -633,11 +633,11 @@ static void immEndVertex(void) /* and move on to the next vertex */ #endif for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { if ((imm.unassigned_attrib_bits >> a_idx) & 1) { - const GPUVertAttr* a = imm.vertex_format.attribs + a_idx; + const GPUVertAttr *a = imm.vertex_format.attribs + a_idx; /* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */ - GLubyte* data = imm.vertex_data + a->offset; + GLubyte *data = imm.vertex_data + a->offset; memcpy(data, data - imm.vertex_format.stride, a->sz); /* TODO: consolidate copy of adjacent attributes */ } @@ -714,31 +714,31 @@ void immVertex2iv(uint attrib_id, const int data[2]) #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; #endif -void immUniform1f(const char* name, float x) +void immUniform1f(const char *name, float x) { GET_UNIFORM glUniform1f(uniform->location, x); } -void immUniform2f(const char* name, float x, float y) +void immUniform2f(const char *name, float x, float y) { GET_UNIFORM glUniform2f(uniform->location, x, y); } -void immUniform2fv(const char* name, const float data[2]) +void immUniform2fv(const char *name, const float data[2]) { GET_UNIFORM glUniform2fv(uniform->location, 1, data); } -void immUniform3f(const char* name, float x, float y, float z) +void immUniform3f(const char *name, float x, float y, float z) { GET_UNIFORM glUniform3f(uniform->location, x, y, z); } -void immUniform3fv(const char* name, const float data[3]) +void immUniform3fv(const char *name, const float data[3]) { GET_UNIFORM glUniform3fv(uniform->location, 1, data); @@ -747,7 +747,7 @@ void immUniform3fv(const char* name, const float data[3]) /* can increase this limit or move to another file */ #define MAX_UNIFORM_NAME_LEN 60 -void immUniformArray3fv(const char* bare_name, const float *data, int count) +void immUniformArray3fv(const char *bare_name, const float *data, int count) { /* look up "name[0]" when given "name" */ const size_t len = strlen(bare_name); @@ -765,19 +765,19 @@ void immUniformArray3fv(const char* bare_name, const float *data, int count) glUniform3fv(uniform->location, count, data); } -void immUniform4f(const char* name, float x, float y, float z, float w) +void immUniform4f(const char *name, float x, float y, float z, float w) { GET_UNIFORM glUniform4f(uniform->location, x, y, z, w); } -void immUniform4fv(const char* name, const float data[4]) +void immUniform4fv(const char *name, const float data[4]) { GET_UNIFORM glUniform4fv(uniform->location, 1, data); } -void immUniformArray4fv(const char* bare_name, const float *data, int count) +void immUniformArray4fv(const char *bare_name, const float *data, int count) { /* look up "name[0]" when given "name" */ const size_t len = strlen(bare_name); @@ -795,19 +795,19 @@ void immUniformArray4fv(const char* bare_name, const float *data, int count) glUniform4fv(uniform->location, count, data); } -void immUniformMatrix4fv(const char* name, const float data[4][4]) +void immUniformMatrix4fv(const char *name, const float data[4][4]) { GET_UNIFORM glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (float *)data); } -void immUniform1i(const char* name, int x) +void immUniform1i(const char *name, int x) { GET_UNIFORM glUniform1i(uniform->location, x); } -void immUniform4iv(const char* name, const int data[4]) +void immUniform4iv(const char *name, const int data[4]) { GET_UNIFORM glUniform4iv(uniform->location, 1, data); @@ -817,7 +817,7 @@ void immUniform4iv(const char* name, const int data[4]) void immUniformColor4f(float r, float g, float b, float a) { - const GPUShaderInput* uniform = GPU_shaderinterface_uniform_builtin(imm.shader_interface, GPU_UNIFORM_COLOR); + const GPUShaderInput *uniform = GPU_shaderinterface_uniform_builtin(imm.shader_interface, GPU_UNIFORM_COLOR); #if TRUST_NO_ONE assert(uniform != NULL); #endif diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index b794048087a..cf594367bdf 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -269,14 +269,14 @@ void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nseg } /** -* Draw a lined box. -* -* \param pos The vertex attribute number for position. -* \param x1 left. -* \param y1 bottom. -* \param x2 right. -* \param y2 top. -*/ + * Draw a lined box. + * + * \param pos The vertex attribute number for position. + * \param x1 left. + * \param y1 bottom. + * \param x2 right. + * \param y2 top. + */ void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2) { immBegin(GPU_PRIM_LINE_LOOP, 4); @@ -353,17 +353,17 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3]) } /** -* Draw a cylinder. Replacement for gluCylinder. -* _warning_ : Slow, better use it only if you no other choices. -* -* \param pos The vertex attribute number for position. -* \param nor The vertex attribute number for normal. -* \param base Specifies the radius of the cylinder at z = 0. -* \param top Specifies the radius of the cylinder at z = height. -* \param height Specifies the height of the cylinder. -* \param slices Specifies the number of subdivisions around the z axis. -* \param stacks Specifies the number of subdivisions along the z axis. -*/ + * Draw a cylinder. Replacement for gluCylinder. + * _warning_ : Slow, better use it only if you no other choices. + * + * \param pos The vertex attribute number for position. + * \param nor The vertex attribute number for normal. + * \param base Specifies the radius of the cylinder at z = 0. + * \param top Specifies the radius of the cylinder at z = height. + * \param height Specifies the height of the cylinder. + * \param slices Specifies the number of subdivisions around the z axis. + * \param stacks Specifies the number of subdivisions along the z axis. + */ void imm_draw_cylinder_fill_normal_3d( unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks) { @@ -384,10 +384,10 @@ void imm_draw_cylinder_fill_normal_3d( float h1 = height * ((float)j / (float)stacks); float h2 = height * ((float)(j + 1) / (float)stacks); - float v1[3] = {r1 *cos2, r1 * sin2, h1}; - float v2[3] = {r2 *cos2, r2 * sin2, h2}; - float v3[3] = {r2 *cos1, r2 * sin1, h2}; - float v4[3] = {r1 *cos1, r1 * sin1, h1}; + float v1[3] = {r1 * cos2, r1 * sin2, h1}; + float v2[3] = {r2 * cos2, r2 * sin2, h2}; + float v3[3] = {r2 * cos1, r2 * sin1, h2}; + float v4[3] = {r1 * cos1, r1 * sin1, h1}; float n1[3], n2[3]; /* calc normals */ diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index bd0e35f5ab6..9566f091ada 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -659,14 +659,15 @@ GPUMaterial *GPU_material_from_nodetree( GPU_nodes_prune(&mat->nodes, mat->outlink); GPU_nodes_get_vertex_attributes(&mat->nodes, &mat->attribs); /* Create source code and search pass cache for an already compiled version. */ - mat->pass = GPU_generate_pass_new(mat, - mat->outlink, - &mat->attribs, - &mat->nodes, - vert_code, - geom_code, - frag_lib, - defines); + mat->pass = GPU_generate_pass_new( + mat, + mat->outlink, + &mat->attribs, + &mat->nodes, + vert_code, + geom_code, + frag_lib, + defines); if (mat->pass == NULL) { /* We had a cache hit and the shader has already failed to compile. */ diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c index 87fcc5f25a3..0fa4a158c00 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.c @@ -110,7 +110,7 @@ static void checkmat(cosnt float *m) } } -#define CHECKMAT(m) checkmat((const float*)m) +#define CHECKMAT(m) checkmat((const float *)m) #else diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 7023e44d289..1c0e7ed4c1c 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -242,7 +242,7 @@ bool GPU_select_is_cached(void) const uint *GPU_select_buffer_near(const uint *buffer, int hits) { const uint *buffer_near = NULL; - uint depth_min = (uint)-1; + uint depth_min = (uint) - 1; for (int i = 0; i < hits; i++) { if (buffer[1] < depth_min) { BLI_assert(buffer[3] != -1); diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index c5325b6ff21..1eae073d9c0 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -214,8 +214,9 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH]) } } -static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH], - bool use_opensubdiv) +static void gpu_shader_standard_defines( + char defines[MAX_DEFINE_LENGTH], + bool use_opensubdiv) { /* some useful defines to detect GPU type */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) { @@ -244,11 +245,12 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH], * a global typedef which we don't have better place to define * in yet. */ - strcat(defines, "struct VertexData {\n" - " vec4 position;\n" - " vec3 normal;\n" - " vec2 uv;" - "};\n"); + strcat(defines, + "struct VertexData {\n" + " vec4 position;\n" + " vec3 normal;\n" + " vec2 uv;" + "};\n"); } #else UNUSED_VARS(use_opensubdiv); @@ -257,21 +259,23 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH], return; } -GPUShader *GPU_shader_create(const char *vertexcode, - const char *fragcode, - const char *geocode, - const char *libcode, - const char *defines) +GPUShader *GPU_shader_create( + const char *vertexcode, + const char *fragcode, + const char *geocode, + const char *libcode, + const char *defines) { - return GPU_shader_create_ex(vertexcode, - fragcode, - geocode, - libcode, - defines, - GPU_SHADER_FLAGS_NONE, - GPU_SHADER_TFB_NONE, - NULL, - 0); + return GPU_shader_create_ex( + vertexcode, + fragcode, + geocode, + libcode, + defines, + GPU_SHADER_FLAGS_NONE, + GPU_SHADER_TFB_NONE, + NULL, + 0); } #define DEBUG_SHADER_NONE "" @@ -321,15 +325,16 @@ static void gpu_dump_shaders(const char **code, const int num_shaders, const cha printf("Shader file written to disk: %s\n", shader_path); } -GPUShader *GPU_shader_create_ex(const char *vertexcode, - const char *fragcode, - const char *geocode, - const char *libcode, - const char *defines, - const int flags, - const GPUShaderTFBType tf_type, - const char **tf_names, - const int tf_count) +GPUShader *GPU_shader_create_ex( + const char *vertexcode, + const char *fragcode, + const char *geocode, + const char *libcode, + const char *defines, + const int flags, + const GPUShaderTFBType tf_type, + const char **tf_names, + const int tf_count) { #ifdef WITH_OPENSUBDIV bool use_opensubdiv = (flags & GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV) != 0; @@ -366,8 +371,9 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode, return NULL; } - gpu_shader_standard_defines(standard_defines, - use_opensubdiv); + gpu_shader_standard_defines( + standard_defines, + use_opensubdiv); gpu_shader_standard_extensions(standard_extensions); if (vertexcode) { @@ -410,12 +416,13 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode, #ifdef WITH_OPENSUBDIV /* TODO(sergey): Move to fragment shader source code generation. */ if (use_opensubdiv) { - source[num_source++] = + source[num_source++] = ( "#ifdef USE_OPENSUBDIV\n" "in block {\n" " VertexData v;\n" "} inpt;\n" - "#endif\n"; + "#endif\n" + ); } #endif @@ -502,13 +509,15 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode, /* TODO(sergey): Find a better place for this. */ if (use_opensubdiv) { if (GLEW_VERSION_4_1) { - glProgramUniform1i(shader->program, - GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, - 30); /* GL_TEXTURE30 */ - - glProgramUniform1i(shader->program, - GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, - 31); /* GL_TEXTURE31 */ + glProgramUniform1i( + shader->program, + GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, + 30); /* GL_TEXTURE30 */ + + glProgramUniform1i( + shader->program, + GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, + 31); /* GL_TEXTURE31 */ } else { glUseProgram(shader->program); @@ -903,17 +912,20 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) if (shader == GPU_SHADER_EDGES_FRONT_BACK_PERSP && !GLEW_VERSION_3_2) { /* TODO: remove after switch to core profile (maybe) */ - static const GPUShaderStages legacy_fancy_edges = - { datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl, - datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl }; + static const GPUShaderStages legacy_fancy_edges = { + datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl, + datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl, + }; stages = &legacy_fancy_edges; } if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR && !GLEW_VERSION_3_2) { /* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */ /* TODO: remove after switch to core profile (maybe) */ - static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl, - datatoc_gpu_shader_2D_line_dashed_frag_glsl }; + static const GPUShaderStages legacy_dashed_lines = { + datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl, + datatoc_gpu_shader_2D_line_dashed_frag_glsl, + }; stages = &legacy_dashed_lines; } diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index ec2f52a2a2d..7e1d942da2d 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -42,9 +42,9 @@ #include #endif -static const char* BuiltinUniform_name(GPUUniformBuiltin u) +static const char *BuiltinUniform_name(GPUUniformBuiltin u) { - static const char* names[] = { + static const char *names[] = { [GPU_UNIFORM_NONE] = NULL, [GPU_UNIFORM_MODEL] = "ModelMatrix", @@ -76,7 +76,7 @@ static const char* BuiltinUniform_name(GPUUniformBuiltin u) return names[u]; } -GPU_INLINE bool match(const char* a, const char* b) +GPU_INLINE bool match(const char *a, const char *b) { return strcmp(a, b) == 0; } @@ -90,28 +90,31 @@ GPU_INLINE uint hash_string(const char *str) return i; } -GPU_INLINE void set_input_name(GPUShaderInterface* shaderface, GPUShaderInput* input, - const char* name, uint32_t name_len) +GPU_INLINE void set_input_name( + GPUShaderInterface *shaderface, GPUShaderInput *input, + const char *name, uint32_t name_len) { input->name_offset = shaderface->name_buffer_offset; input->name_hash = hash_string(name); shaderface->name_buffer_offset += name_len + 1; /* include NULL terminator */ } -GPU_INLINE void shader_input_to_bucket(GPUShaderInput* input, - GPUShaderInput* buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]) +GPU_INLINE void shader_input_to_bucket( + GPUShaderInput *input, + GPUShaderInput *buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]) { const uint bucket_index = input->name_hash % GPU_NUM_SHADERINTERFACE_BUCKETS; input->next = buckets[bucket_index]; buckets[bucket_index] = input; } -GPU_INLINE const GPUShaderInput* buckets_lookup(GPUShaderInput* const buckets[GPU_NUM_SHADERINTERFACE_BUCKETS], - const char *name_buffer, const char *name) +GPU_INLINE const GPUShaderInput *buckets_lookup( + GPUShaderInput *const buckets[GPU_NUM_SHADERINTERFACE_BUCKETS], + const char *name_buffer, const char *name) { const uint name_hash = hash_string(name); const uint bucket_index = name_hash % GPU_NUM_SHADERINTERFACE_BUCKETS; - const GPUShaderInput* input = buckets[bucket_index]; + const GPUShaderInput *input = buckets[bucket_index]; if (input == NULL) { /* Requested uniform is not found at all. */ return NULL; @@ -129,7 +132,7 @@ GPU_INLINE const GPUShaderInput* buckets_lookup(GPUShaderInput* const buckets[GP return NULL; } /* Work through possible collisions. */ - const GPUShaderInput* next = input; + const GPUShaderInput *next = input; while (next != NULL) { input = next; next = input->next; @@ -143,7 +146,7 @@ GPU_INLINE const GPUShaderInput* buckets_lookup(GPUShaderInput* const buckets[GP return NULL; /* not found */ } -GPU_INLINE void buckets_free(GPUShaderInput* buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]) +GPU_INLINE void buckets_free(GPUShaderInput *buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]) { for (uint bucket_index = 0; bucket_index < GPU_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) { GPUShaderInput *input = buckets[bucket_index]; @@ -155,13 +158,13 @@ GPU_INLINE void buckets_free(GPUShaderInput* buckets[GPU_NUM_SHADERINTERFACE_BUC } } -static bool setup_builtin_uniform(GPUShaderInput* input, const char* name) +static bool setup_builtin_uniform(GPUShaderInput *input, const char *name) { /* TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types */ /* detect built-in uniforms (name must match) */ for (GPUUniformBuiltin u = GPU_UNIFORM_NONE + 1; u < GPU_UNIFORM_CUSTOM; ++u) { - const char* builtin_name = BuiltinUniform_name(u); + const char *builtin_name = BuiltinUniform_name(u); if (match(name, builtin_name)) { input->builtin_type = u; return true; @@ -171,15 +174,15 @@ static bool setup_builtin_uniform(GPUShaderInput* input, const char* name) return false; } -static const GPUShaderInput* add_uniform(GPUShaderInterface* shaderface, const char* name) +static const GPUShaderInput *add_uniform(GPUShaderInterface *shaderface, const char *name) { - GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); + GPUShaderInput *input = malloc(sizeof(GPUShaderInput)); input->location = glGetUniformLocation(shaderface->program, name); uint name_len = strlen(name); shaderface->name_buffer = realloc(shaderface->name_buffer, shaderface->name_buffer_offset + name_len + 1); /* include NULL terminator */ - char* name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset; + char *name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset; strcpy(name_buffer, name); set_input_name(shaderface, input, name, name_len); @@ -192,17 +195,18 @@ static const GPUShaderInput* add_uniform(GPUShaderInterface* shaderface, const c shaderface->builtin_uniforms[input->builtin_type] = input; } #if DEBUG_SHADER_INTERFACE - printf("GPUShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, - shaderface->program, - name, - input->location); + printf("GPUShaderInterface %p, program %d, uniform[] '%s' at location %d\n", + shaderface, + shaderface->program, + name, + input->location); #endif return input; } -GPUShaderInterface* GPU_shaderinterface_create(int32_t program) +GPUShaderInterface *GPU_shaderinterface_create(int32_t program) { - GPUShaderInterface* shaderface = calloc(1, sizeof(GPUShaderInterface)); + GPUShaderInterface *shaderface = calloc(1, sizeof(GPUShaderInterface)); shaderface->program = program; #if DEBUG_SHADER_INTERFACE @@ -223,16 +227,16 @@ GPUShaderInterface* GPU_shaderinterface_create(int32_t program) /* Attributes */ for (uint32_t i = 0; i < attr_len; ++i) { - GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); + GPUShaderInput *input = malloc(sizeof(GPUShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; - char* name = shaderface->name_buffer + shaderface->name_buffer_offset; + char *name = shaderface->name_buffer + shaderface->name_buffer_offset; GLsizei name_len = 0; glGetActiveAttrib(program, i, remaining_buffer, &name_len, &input->size, &input->gl_type, name); /* remove "[0]" from array name */ - if (name[name_len-1] == ']') { - name[name_len-3] = '\0'; + if (name[name_len - 1] == ']') { + name[name_len - 3] = '\0'; name_len -= 3; } @@ -250,9 +254,9 @@ GPUShaderInterface* GPU_shaderinterface_create(int32_t program) } /* Uniform Blocks */ for (uint32_t i = 0; i < ubo_len; ++i) { - GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); + GPUShaderInput *input = malloc(sizeof(GPUShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; - char* name = shaderface->name_buffer + shaderface->name_buffer_offset; + char *name = shaderface->name_buffer + shaderface->name_buffer_offset; GLsizei name_len = 0; glGetActiveUniformBlockName(program, i, remaining_buffer, &name_len, name); @@ -269,19 +273,19 @@ GPUShaderInterface* GPU_shaderinterface_create(int32_t program) } /* Builtin Uniforms */ for (GPUUniformBuiltin u = GPU_UNIFORM_NONE + 1; u < GPU_UNIFORM_CUSTOM; ++u) { - const char* builtin_name = BuiltinUniform_name(u); + const char *builtin_name = BuiltinUniform_name(u); if (glGetUniformLocation(program, builtin_name) != -1) { - add_uniform((GPUShaderInterface*)shaderface, builtin_name); + add_uniform((GPUShaderInterface *)shaderface, builtin_name); } } /* Batches ref buffer */ shaderface->batches_len = GPU_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = calloc(shaderface->batches_len, sizeof(GPUBatch*)); + shaderface->batches = calloc(shaderface->batches_len, sizeof(GPUBatch *)); return shaderface; } -void GPU_shaderinterface_discard(GPUShaderInterface* shaderface) +void GPU_shaderinterface_discard(GPUShaderInterface *shaderface) { /* Free memory used by buckets and has entries. */ buckets_free(shaderface->uniform_buckets); @@ -300,19 +304,19 @@ void GPU_shaderinterface_discard(GPUShaderInterface* shaderface) free(shaderface); } -const GPUShaderInput* GPU_shaderinterface_uniform(const GPUShaderInterface* shaderface, const char* name) +const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *shaderface, const char *name) { /* TODO: Warn if we find a matching builtin, since these can be looked up much quicker. */ - const GPUShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); + const GPUShaderInput *input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); /* If input is not found add it so it's found next time. */ if (input == NULL) { - input = add_uniform((GPUShaderInterface*)shaderface, name); + input = add_uniform((GPUShaderInterface *)shaderface, name); } return (input->location != -1) ? input : NULL; } -const GPUShaderInput* GPU_shaderinterface_uniform_builtin( - const GPUShaderInterface* shaderface, GPUUniformBuiltin builtin) +const GPUShaderInput *GPU_shaderinterface_uniform_builtin( + const GPUShaderInterface *shaderface, GPUUniformBuiltin builtin) { #if TRUST_NO_ONE assert(builtin != GPU_UNIFORM_NONE); @@ -322,17 +326,17 @@ const GPUShaderInput* GPU_shaderinterface_uniform_builtin( return shaderface->builtin_uniforms[builtin]; } -const GPUShaderInput* GPU_shaderinterface_ubo(const GPUShaderInterface* shaderface, const char* name) +const GPUShaderInput *GPU_shaderinterface_ubo(const GPUShaderInterface *shaderface, const char *name) { return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name); } -const GPUShaderInput* GPU_shaderinterface_attr(const GPUShaderInterface* shaderface, const char* name) +const GPUShaderInput *GPU_shaderinterface_attr(const GPUShaderInterface *shaderface, const char *name) { return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name); } -void GPU_shaderinterface_add_batch_ref(GPUShaderInterface* shaderface, GPUBatch* batch) +void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *shaderface, GPUBatch *batch) { int i; /* find first unused slot */ for (i = 0; i < shaderface->batches_len; ++i) { @@ -344,13 +348,13 @@ void GPU_shaderinterface_add_batch_ref(GPUShaderInterface* shaderface, GPUBatch* /* Not enough place, realloc the array. */ i = shaderface->batches_len; shaderface->batches_len += GPU_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = realloc(shaderface->batches, sizeof(GPUBatch*) * shaderface->batches_len); - memset(shaderface->batches + i, 0, sizeof(GPUBatch*) * GPU_SHADERINTERFACE_REF_ALLOC_COUNT); + shaderface->batches = realloc(shaderface->batches, sizeof(GPUBatch *) * shaderface->batches_len); + memset(shaderface->batches + i, 0, sizeof(GPUBatch *) * GPU_SHADERINTERFACE_REF_ALLOC_COUNT); } shaderface->batches[i] = batch; } -void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface* shaderface, GPUBatch* batch) +void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface *shaderface, GPUBatch *batch) { for (int i = 0; i < shaderface->batches_len; ++i) { if (shaderface->batches[i] == batch) { diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c index 588d61640bd..68d846ccfba 100644 --- a/source/blender/gpu/intern/gpu_state.c +++ b/source/blender/gpu/intern/gpu_state.c @@ -66,10 +66,11 @@ void GPU_blend_set_func_separate( GPUBlendFunction src_rgb, GPUBlendFunction dst_rgb, GPUBlendFunction src_alpha, GPUBlendFunction dst_alpha) { - glBlendFuncSeparate(gpu_get_gl_blendfunction(src_rgb), - gpu_get_gl_blendfunction(dst_rgb), - gpu_get_gl_blendfunction(src_alpha), - gpu_get_gl_blendfunction(dst_alpha)); + glBlendFuncSeparate( + gpu_get_gl_blendfunction(src_rgb), + gpu_get_gl_blendfunction(dst_rgb), + gpu_get_gl_blendfunction(src_alpha), + gpu_get_gl_blendfunction(dst_alpha)); } void GPU_depth_test(bool enable) diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 52afe17d885..4465136dd0f 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -160,9 +160,10 @@ static int gpu_get_component_count(GPUTextureFormat format) /* Definitely not complete, edit according to the gl specification. */ static void gpu_validate_data_format(GPUTextureFormat tex_format, GPUDataFormat data_format) { - if (ELEM(tex_format, GPU_DEPTH_COMPONENT24, - GPU_DEPTH_COMPONENT16, - GPU_DEPTH_COMPONENT32F)) + if (ELEM(tex_format, + GPU_DEPTH_COMPONENT24, + GPU_DEPTH_COMPONENT16, + GPU_DEPTH_COMPONENT32F)) { BLI_assert(data_format == GPU_DATA_FLOAT); } @@ -196,9 +197,10 @@ static void gpu_validate_data_format(GPUTextureFormat tex_format, GPUDataFormat static GPUDataFormat gpu_get_data_format_from_tex_format(GPUTextureFormat tex_format) { - if (ELEM(tex_format, GPU_DEPTH_COMPONENT24, - GPU_DEPTH_COMPONENT16, - GPU_DEPTH_COMPONENT32F)) + if (ELEM(tex_format, + GPU_DEPTH_COMPONENT24, + GPU_DEPTH_COMPONENT16, + GPU_DEPTH_COMPONENT32F)) { return GPU_DATA_FLOAT; } @@ -232,9 +234,10 @@ static GPUDataFormat gpu_get_data_format_from_tex_format(GPUTextureFormat tex_fo /* Definitely not complete, edit according to the gl specification. */ static GLenum gpu_get_gl_dataformat(GPUTextureFormat data_type, GPUTextureFormatFlag *format_flag) { - if (ELEM(data_type, GPU_DEPTH_COMPONENT24, - GPU_DEPTH_COMPONENT16, - GPU_DEPTH_COMPONENT32F)) + if (ELEM(data_type, + GPU_DEPTH_COMPONENT24, + GPU_DEPTH_COMPONENT16, + GPU_DEPTH_COMPONENT32F)) { *format_flag |= GPU_FORMAT_DEPTH; return GL_DEPTH_COMPONENT; @@ -1161,8 +1164,9 @@ void GPU_texture_bind(GPUTexture *tex, int number) if ((G.debug & G_DEBUG)) { for (int i = 0; i < GPU_TEX_MAX_FBO_ATTACHED; ++i) { if (tex->fb[i] && GPU_framebuffer_bound(tex->fb[i])) { - fprintf(stderr, "Feedback loop warning!: Attempting to bind " - "texture attached to current framebuffer!\n"); + fprintf(stderr, + "Feedback loop warning!: Attempting to bind " + "texture attached to current framebuffer!\n"); BLI_assert(0); /* Should never happen! */ break; } diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c index 5b29913800d..b25d9fc3a2c 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.c +++ b/source/blender/gpu/intern/gpu_vertex_buffer.c @@ -49,16 +49,16 @@ static GLenum convert_usage_type_to_gl(GPUUsageType type) return table[type]; } -GPUVertBuf* GPU_vertbuf_create(GPUUsageType usage) +GPUVertBuf *GPU_vertbuf_create(GPUUsageType usage) { - GPUVertBuf* verts = malloc(sizeof(GPUVertBuf)); + GPUVertBuf *verts = malloc(sizeof(GPUVertBuf)); GPU_vertbuf_init(verts, usage); return verts; } -GPUVertBuf* GPU_vertbuf_create_with_format_ex(const GPUVertFormat* format, GPUUsageType usage) +GPUVertBuf *GPU_vertbuf_create_with_format_ex(const GPUVertFormat *format, GPUUsageType usage) { - GPUVertBuf* verts = GPU_vertbuf_create(usage); + GPUVertBuf *verts = GPU_vertbuf_create(usage); GPU_vertformat_copy(&verts->format, format); if (!format->packed) { VertexFormat_pack(&verts->format); @@ -69,14 +69,14 @@ GPUVertBuf* GPU_vertbuf_create_with_format_ex(const GPUVertFormat* format, GPUUs /* TODO: implement those memory savings */ } -void GPU_vertbuf_init(GPUVertBuf* verts, GPUUsageType usage) +void GPU_vertbuf_init(GPUVertBuf *verts, GPUUsageType usage) { memset(verts, 0, sizeof(GPUVertBuf)); verts->usage = usage; verts->dirty = true; } -void GPU_vertbuf_init_with_format_ex(GPUVertBuf* verts, const GPUVertFormat* format, GPUUsageType usage) +void GPU_vertbuf_init_with_format_ex(GPUVertBuf *verts, const GPUVertFormat *format, GPUUsageType usage) { GPU_vertbuf_init(verts, usage); GPU_vertformat_copy(&verts->format, format); @@ -85,7 +85,7 @@ void GPU_vertbuf_init_with_format_ex(GPUVertBuf* verts, const GPUVertFormat* for } } -void GPU_vertbuf_discard(GPUVertBuf* verts) +void GPU_vertbuf_discard(GPUVertBuf *verts) { if (verts->vbo_id) { GPU_buf_id_free(verts->vbo_id); @@ -99,15 +99,15 @@ void GPU_vertbuf_discard(GPUVertBuf* verts) free(verts); } -uint GPU_vertbuf_size_get(const GPUVertBuf* verts) +uint GPU_vertbuf_size_get(const GPUVertBuf *verts) { return vertex_buffer_size(&verts->format, verts->vertex_len); } /* create a new allocation, discarding any existing data */ -void GPU_vertbuf_data_alloc(GPUVertBuf* verts, uint v_len) +void GPU_vertbuf_data_alloc(GPUVertBuf *verts, uint v_len) { - GPUVertFormat* format = &verts->format; + GPUVertFormat *format = &verts->format; if (!format->packed) { VertexFormat_pack(format); } @@ -133,7 +133,7 @@ void GPU_vertbuf_data_alloc(GPUVertBuf* verts, uint v_len) } /* resize buffer keeping existing data */ -void GPU_vertbuf_data_resize(GPUVertBuf* verts, uint v_len) +void GPU_vertbuf_data_resize(GPUVertBuf *verts, uint v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); @@ -152,7 +152,7 @@ void GPU_vertbuf_data_resize(GPUVertBuf* verts, uint v_len) /* Set vertex count but does not change allocation. * Only this many verts will be uploaded to the GPU and rendered. * This is usefull for streaming data. */ -void GPU_vertbuf_vertex_count_set(GPUVertBuf* verts, uint v_len) +void GPU_vertbuf_vertex_count_set(GPUVertBuf *verts, uint v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); /* only for dynamic data */ @@ -166,10 +166,10 @@ void GPU_vertbuf_vertex_count_set(GPUVertBuf* verts, uint v_len) verts->vertex_len = v_len; } -void GPU_vertbuf_attr_set(GPUVertBuf* verts, uint a_idx, uint v_idx, const void* data) +void GPU_vertbuf_attr_set(GPUVertBuf *verts, uint a_idx, uint v_idx, const void *data) { - const GPUVertFormat* format = &verts->format; - const GPUVertAttr* a = format->attribs + a_idx; + const GPUVertFormat *format = &verts->format; + const GPUVertAttr *a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -177,13 +177,13 @@ void GPU_vertbuf_attr_set(GPUVertBuf* verts, uint a_idx, uint v_idx, const void* assert(verts->data != NULL); #endif verts->dirty = true; - memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz); + memcpy((GLubyte *)verts->data + a->offset + v_idx * format->stride, data, a->sz); } -void GPU_vertbuf_attr_fill(GPUVertBuf* verts, uint a_idx, const void* data) +void GPU_vertbuf_attr_fill(GPUVertBuf *verts, uint a_idx, const void *data) { - const GPUVertFormat* format = &verts->format; - const GPUVertAttr* a = format->attribs + a_idx; + const GPUVertFormat *format = &verts->format; + const GPUVertAttr *a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -193,10 +193,10 @@ void GPU_vertbuf_attr_fill(GPUVertBuf* verts, uint a_idx, const void* data) GPU_vertbuf_attr_fill_stride(verts, a_idx, stride, data); } -void GPU_vertbuf_attr_fill_stride(GPUVertBuf* verts, uint a_idx, uint stride, const void* data) +void GPU_vertbuf_attr_fill_stride(GPUVertBuf *verts, uint a_idx, uint stride, const void *data) { - const GPUVertFormat* format = &verts->format; - const GPUVertAttr* a = format->attribs + a_idx; + const GPUVertFormat *format = &verts->format; + const GPUVertAttr *a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -212,15 +212,15 @@ void GPU_vertbuf_attr_fill_stride(GPUVertBuf* verts, uint a_idx, uint stride, co else { /* we must copy it per vertex */ for (uint v = 0; v < vertex_len; ++v) { - memcpy((GLubyte*)verts->data + a->offset + v * format->stride, (const GLubyte*)data + v * stride, a->sz); + memcpy((GLubyte *)verts->data + a->offset + v * format->stride, (const GLubyte *)data + v * stride, a->sz); } } } -void GPU_vertbuf_attr_get_raw_data(GPUVertBuf* verts, uint a_idx, GPUVertBufRaw *access) +void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *verts, uint a_idx, GPUVertBufRaw *access) { - const GPUVertFormat* format = &verts->format; - const GPUVertAttr* a = format->attribs + a_idx; + const GPUVertFormat *format = &verts->format; + const GPUVertAttr *a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -231,14 +231,14 @@ void GPU_vertbuf_attr_get_raw_data(GPUVertBuf* verts, uint a_idx, GPUVertBufRaw access->size = a->sz; access->stride = format->stride; - access->data = (GLubyte*)verts->data + a->offset; + access->data = (GLubyte *)verts->data + a->offset; access->data_init = access->data; #if TRUST_NO_ONE access->_data_end = access->data_init + (size_t)(verts->vertex_alloc * format->stride); #endif } -static void VertBuffer_upload_data(GPUVertBuf* verts) +static void VertBuffer_upload_data(GPUVertBuf *verts) { uint buffer_sz = GPU_vertbuf_size_get(verts); @@ -254,7 +254,7 @@ static void VertBuffer_upload_data(GPUVertBuf* verts) verts->dirty = false; } -void GPU_vertbuf_use(GPUVertBuf* verts) +void GPU_vertbuf_use(GPUVertBuf *verts) { glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id); if (verts->dirty) { diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index d0a907bcd0d..f1f75f449d4 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -40,7 +40,7 @@ #include #endif -void GPU_vertformat_clear(GPUVertFormat* format) +void GPU_vertformat_clear(GPUVertFormat *format) { #if TRUST_NO_ONE memset(format, 0, sizeof(GPUVertFormat)); @@ -56,7 +56,7 @@ void GPU_vertformat_clear(GPUVertFormat* format) #endif } -void GPU_vertformat_copy(GPUVertFormat* dest, const GPUVertFormat* src) +void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src) { /* copy regular struct fields */ memcpy(dest, src, sizeof(GPUVertFormat)); @@ -90,7 +90,7 @@ static unsigned comp_sz(GPUVertCompType type) #if TRUST_NO_ONE assert(type <= GPU_COMP_F32); /* other types have irregular sizes (not bytes) */ #endif - const GLubyte sizes[] = {1,1,2,2,4,4,4}; + const GLubyte sizes[] = {1, 1, 2, 2, 4, 4, 4}; return sizes[type]; } @@ -116,7 +116,7 @@ static unsigned attrib_align(const GPUVertAttr *a) } } -unsigned vertex_buffer_size(const GPUVertFormat* format, unsigned vertex_len) +unsigned vertex_buffer_size(const GPUVertFormat *format, unsigned vertex_len) { #if TRUST_NO_ONE assert(format->packed && format->stride > 0); @@ -124,10 +124,10 @@ unsigned vertex_buffer_size(const GPUVertFormat* format, unsigned vertex_len) return format->stride * vertex_len; } -static const char* copy_attrib_name(GPUVertFormat* format, const char* name) +static const char *copy_attrib_name(GPUVertFormat *format, const char *name) { /* strncpy does 110% of what we need; let's do exactly 100% */ - char* name_copy = format->names + format->name_offset; + char *name_copy = format->names + format->name_offset; unsigned available = GPU_VERT_ATTR_NAMES_BUF_LEN - format->name_offset; bool terminated = false; @@ -149,7 +149,9 @@ static const char* copy_attrib_name(GPUVertFormat* format, const char* name) return name_copy; } -unsigned GPU_vertformat_attr_add(GPUVertFormat* format, const char* name, GPUVertCompType comp_type, unsigned comp_len, GPUVertFetchMode fetch_mode) +unsigned GPU_vertformat_attr_add( + GPUVertFormat *format, const char *name, + GPUVertCompType comp_type, unsigned comp_len, GPUVertFetchMode fetch_mode) { #if TRUST_NO_ONE assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */ @@ -178,7 +180,7 @@ unsigned GPU_vertformat_attr_add(GPUVertFormat* format, const char* name, GPUVer format->name_len++; /* multiname support */ const unsigned attrib_id = format->attr_len++; - GPUVertAttr* attrib = format->attribs + attrib_id; + GPUVertAttr *attrib = format->attribs + attrib_id; attrib->name[attrib->name_len++] = copy_attrib_name(format, name); attrib->comp_type = comp_type; @@ -191,9 +193,9 @@ unsigned GPU_vertformat_attr_add(GPUVertFormat* format, const char* name, GPUVer return attrib_id; } -void GPU_vertformat_alias_add(GPUVertFormat* format, const char* alias) +void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias) { - GPUVertAttr* attrib = format->attribs + (format->attr_len - 1); + GPUVertAttr *attrib = format->attribs + (format->attr_len - 1); #if TRUST_NO_ONE assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */ assert(attrib->name_len < GPU_VERT_ATTR_MAX_NAMES); @@ -221,7 +223,7 @@ static void show_pack(unsigned a_idx, unsigned sz, unsigned pad) } #endif -void VertexFormat_pack(GPUVertFormat* format) +void VertexFormat_pack(GPUVertFormat *format) { /* For now, attributes are packed in the order they were added, * making sure each attrib is naturally aligned (add padding where necessary) @@ -231,7 +233,7 @@ void VertexFormat_pack(GPUVertFormat* format) /* TODO: realloc just enough to hold the final combo string. And just enough to * hold used attribs, not all 16. */ - GPUVertAttr* a0 = format->attribs + 0; + GPUVertAttr *a0 = format->attribs + 0; a0->offset = 0; unsigned offset = a0->sz; @@ -240,7 +242,7 @@ void VertexFormat_pack(GPUVertFormat* format) #endif for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) { - GPUVertAttr* a = format->attribs + a_idx; + GPUVertAttr *a = format->attribs + a_idx; unsigned mid_padding = padding(offset, attrib_align(a)); offset += mid_padding; a->offset = offset; -- cgit v1.2.3 From c64262a05ab0e9a7c5b69fc83ea53fb5825f442c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 17 Jul 2018 18:06:32 +0200 Subject: OpenSubdiv: Add API to evaluate face-varying data There are move changes along the line to keep everything working from from C. --- .../internal/opensubdiv_converter_factory.cc | 2 + .../internal/opensubdiv_converter_internal.cc | 26 ++++++++++ .../internal/opensubdiv_converter_internal.h | 5 ++ .../internal/opensubdiv_topology_refiner.cc | 60 ++++++++++++++++++++-- intern/opensubdiv/opensubdiv_capi_type.h | 15 ++++++ intern/opensubdiv/opensubdiv_converter_capi.h | 15 +----- .../opensubdiv/opensubdiv_topology_refiner_capi.h | 43 +++++++++++++++- 7 files changed, 148 insertions(+), 18 deletions(-) diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc index bd6edbb9648..48516cc80b7 100644 --- a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc +++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc @@ -383,6 +383,8 @@ TopologyRefinerFactory::assignFaceVaryingTopology( const int num_uvs = converter->getNumUVCoordinates(converter); // Fill in per-corner index of the UV. const int channel = createBaseFVarChannel(refiner, num_uvs); + // TODO(sergey): Need to check whether converter changed the winding of + // face to match OpenSubdiv's expectations. for (int face_index = 0; face_index < num_faces; ++face_index) { Far::IndexArray dst_face_uvs = getBaseFaceFVarValues(refiner, face_index, channel); diff --git a/intern/opensubdiv/internal/opensubdiv_converter_internal.cc b/intern/opensubdiv/internal/opensubdiv_converter_internal.cc index 56b5657121d..32815dc34dc 100644 --- a/intern/opensubdiv/internal/opensubdiv_converter_internal.cc +++ b/intern/opensubdiv/internal/opensubdiv_converter_internal.cc @@ -49,6 +49,10 @@ getFVarLinearInterpolationFromCAPI( return Options::FVAR_LINEAR_NONE; case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY: return Options::FVAR_LINEAR_CORNERS_ONLY; + case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1: + return Options::FVAR_LINEAR_CORNERS_PLUS1; + case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2: + return Options::FVAR_LINEAR_CORNERS_PLUS2; case OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES: return Options::FVAR_LINEAR_BOUNDARIES; case OSD_FVAR_LINEAR_INTERPOLATION_ALL: @@ -58,6 +62,28 @@ getFVarLinearInterpolationFromCAPI( return Options::FVAR_LINEAR_NONE; } +OpenSubdiv_FVarLinearInterpolation +getCAPIFVarLinearInterpolationFromOSD( + OpenSubdiv::Sdc::Options::FVarLinearInterpolation linear_interpolation) { + typedef OpenSubdiv::Sdc::Options Options; + switch (linear_interpolation) { + case Options::FVAR_LINEAR_NONE: + return OSD_FVAR_LINEAR_INTERPOLATION_NONE; + case Options::FVAR_LINEAR_CORNERS_ONLY: + return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY; + case Options::FVAR_LINEAR_CORNERS_PLUS1: + return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1; + case Options::FVAR_LINEAR_CORNERS_PLUS2: + return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2; + case Options::FVAR_LINEAR_BOUNDARIES: + return OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES; + case Options::FVAR_LINEAR_ALL: + return OSD_FVAR_LINEAR_INTERPOLATION_ALL; + } + assert(!"Unknown fvar linear interpolation passed via C-API"); + return OSD_FVAR_LINEAR_INTERPOLATION_NONE; +} + float getCompatibleEdgeSharpness(const OpenSubdiv_Converter* converter, int edge_index) { if (converter->getNumEdgeFaces(converter, edge_index) == 2) { diff --git a/intern/opensubdiv/internal/opensubdiv_converter_internal.h b/intern/opensubdiv/internal/opensubdiv_converter_internal.h index 68518d67884..c47cdd1004d 100644 --- a/intern/opensubdiv/internal/opensubdiv_converter_internal.h +++ b/intern/opensubdiv/internal/opensubdiv_converter_internal.h @@ -41,6 +41,11 @@ OpenSubdiv::Sdc::Options::FVarLinearInterpolation getFVarLinearInterpolationFromCAPI( OpenSubdiv_FVarLinearInterpolation linear_interpolation); +// Similar to above, just other way around. +OpenSubdiv_FVarLinearInterpolation +getCAPIFVarLinearInterpolationFromOSD( + OpenSubdiv::Sdc::Options::FVarLinearInterpolation linear_interpolation); + // Get edge sharpness in a way which makes OpenSubdiv happy. float getCompatibleEdgeSharpness(const OpenSubdiv_Converter* converter, int edge_index); diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc index aa6ba953ef9..93f6fdc14a1 100644 --- a/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc +++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc @@ -46,6 +46,9 @@ bool getIsAdaptive(const OpenSubdiv_TopologyRefiner* topology_refiner) { return topology_refiner->internal->settings.is_adaptive; } +//////////////////////////////////////////////////////////////////////////////// +// Query basic topology information from base level. + int getNumVertices(const OpenSubdiv_TopologyRefiner* topology_refiner) { return getOSDTopologyBaseLevel(topology_refiner)->GetNumVertices(); } @@ -58,6 +61,9 @@ int getNumFaces(const OpenSubdiv_TopologyRefiner* topology_refiner) { return getOSDTopologyBaseLevel(topology_refiner)->GetNumFaces(); } +//////////////////////////////////////////////////////////////////////////////// +// PTex face geometry queries. + int getNumFaceVertices(const OpenSubdiv_TopologyRefiner* topology_refiner, const int face_index) { const OpenSubdiv::Far::TopologyLevel* base_level = @@ -97,18 +103,59 @@ void fillFacePtexIndexOffset(const OpenSubdiv_TopologyRefiner* topology_refiner, } } +////////////////////////////////////////////////////////////////////////////// +// Face-varying data. + +int getNumFVarChannels( + const struct OpenSubdiv_TopologyRefiner* topology_refiner) { + const OpenSubdiv::Far::TopologyLevel* base_level = + getOSDTopologyBaseLevel(topology_refiner); + return base_level->GetNumFVarChannels(); +} + +OpenSubdiv_FVarLinearInterpolation getFVarLinearInterpolation( + const struct OpenSubdiv_TopologyRefiner* topology_refiner) { + return opensubdiv_capi::getCAPIFVarLinearInterpolationFromOSD( + getOSDTopologyRefiner(topology_refiner)->GetFVarLinearInterpolation()); +} + +int getNumFVarValues( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int channel) { + const OpenSubdiv::Far::TopologyLevel* base_level = + getOSDTopologyBaseLevel(topology_refiner); + return base_level->GetNumFVarValues(channel); +} + +const int* getFaceFVarValueIndices( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index, + const int channel) { + const OpenSubdiv::Far::TopologyLevel* base_level = + getOSDTopologyBaseLevel(topology_refiner); + return &base_level->GetFaceFVarValues(face_index, channel)[0]; +} + +////////////////////////////////////////////////////////////////////////////// +// Internal helpers. + void assignFunctionPointers(OpenSubdiv_TopologyRefiner* topology_refiner) { topology_refiner->getSubdivisionLevel = getSubdivisionLevel; topology_refiner->getIsAdaptive = getIsAdaptive; - + // Basic topology information. topology_refiner->getNumVertices = getNumVertices; topology_refiner->getNumEdges = getNumEdges; topology_refiner->getNumFaces = getNumFaces; topology_refiner->getNumFaceVertices = getNumFaceVertices; - + // PTex face geometry. topology_refiner->getNumFacePtexFaces = getNumFacePtexFaces; topology_refiner->getNumPtexFaces = getNumPtexFaces; topology_refiner->fillFacePtexIndexOffset = fillFacePtexIndexOffset; + // Face-varying data. + topology_refiner->getNumFVarChannels = getNumFVarChannels; + topology_refiner->getFVarLinearInterpolation = getFVarLinearInterpolation; + topology_refiner->getNumFVarValues = getNumFVarValues; + topology_refiner->getFaceFVarValueIndices = getFaceFVarValueIndices; } OpenSubdiv_TopologyRefiner* allocateTopologyRefiner() { @@ -125,9 +172,14 @@ OpenSubdiv_TopologyRefiner* allocateTopologyRefiner() { OpenSubdiv_TopologyRefiner* openSubdiv_createTopologyRefinerFromConverter( OpenSubdiv_Converter* converter, const OpenSubdiv_TopologyRefinerSettings* settings) { - OpenSubdiv_TopologyRefiner* topology_refiner = allocateTopologyRefiner(); - topology_refiner->internal->osd_topology_refiner = + OpenSubdiv::Far::TopologyRefiner* osd_topology_refiner = opensubdiv_capi::createOSDTopologyRefinerFromConverter(converter); + if (osd_topology_refiner == NULL) { + // Happens on empty or bad topology. + return NULL; + } + OpenSubdiv_TopologyRefiner* topology_refiner = allocateTopologyRefiner(); + topology_refiner->internal->osd_topology_refiner = osd_topology_refiner; // Store setting which we want to keep track of and which can not be stored // in OpenSubdiv's descriptor yet. topology_refiner->internal->settings = *settings; diff --git a/intern/opensubdiv/opensubdiv_capi_type.h b/intern/opensubdiv/opensubdiv_capi_type.h index 04fe2afff53..b326e53e168 100644 --- a/intern/opensubdiv/opensubdiv_capi_type.h +++ b/intern/opensubdiv/opensubdiv_capi_type.h @@ -34,6 +34,21 @@ typedef enum eOpenSubdivEvaluator { OPENSUBDIV_EVALUATOR_GLSL_COMPUTE = (1 << 5), } eOpenSubdivEvaluator; +typedef enum OpenSubdiv_SchemeType { + OSD_SCHEME_BILINEAR, + OSD_SCHEME_CATMARK, + OSD_SCHEME_LOOP, +} OpenSubdiv_SchemeType; + +typedef enum OpenSubdiv_FVarLinearInterpolation { + OSD_FVAR_LINEAR_INTERPOLATION_NONE, + OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY, + OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1, + OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2, + OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES, + OSD_FVAR_LINEAR_INTERPOLATION_ALL, +} OpenSubdiv_FVarLinearInterpolation; + #ifdef __cplusplus } #endif diff --git a/intern/opensubdiv/opensubdiv_converter_capi.h b/intern/opensubdiv/opensubdiv_converter_capi.h index b16d6eb6c8f..a939f1117e0 100644 --- a/intern/opensubdiv/opensubdiv_converter_capi.h +++ b/intern/opensubdiv/opensubdiv_converter_capi.h @@ -19,23 +19,12 @@ #ifndef OPENSUBDIV_CONVERTER_CAPI_H_ #define OPENSUBDIV_CONVERTER_CAPI_H_ +#include "opensubdiv_capi_type.h" + #ifdef __cplusplus extern "C" { #endif -typedef enum OpenSubdiv_SchemeType { - OSD_SCHEME_BILINEAR, - OSD_SCHEME_CATMARK, - OSD_SCHEME_LOOP, -} OpenSubdiv_SchemeType; - -typedef enum OpenSubdiv_FVarLinearInterpolation { - OSD_FVAR_LINEAR_INTERPOLATION_NONE, - OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY, - OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES, - OSD_FVAR_LINEAR_INTERPOLATION_ALL, -} OpenSubdiv_FVarLinearInterpolation; - typedef struct OpenSubdiv_Converter { OpenSubdiv_SchemeType (*getSchemeType)( const struct OpenSubdiv_Converter* converter); diff --git a/intern/opensubdiv/opensubdiv_topology_refiner_capi.h b/intern/opensubdiv/opensubdiv_topology_refiner_capi.h index 103ccd2c1f9..fe4db0ca67c 100644 --- a/intern/opensubdiv/opensubdiv_topology_refiner_capi.h +++ b/intern/opensubdiv/opensubdiv_topology_refiner_capi.h @@ -21,6 +21,8 @@ #include // for bool +#include "opensubdiv_capi_type.h" + #ifdef __cplusplus extern "C" { #endif @@ -45,7 +47,16 @@ typedef struct OpenSubdiv_TopologyRefiner { bool (*getIsAdaptive)( const struct OpenSubdiv_TopologyRefiner* topology_refiner); + // NOTE: All queries are querying base level. + // + // TODO(sergey): Consider making it more obvious in function naming, + // but since it's unlikely (or at least, will be uncommon use) for API + // which queries final geometry, we should be fine with this name for + // now. + + ////////////////////////////////////////////////////////////////////////////// // Query basic topology information from base level. + int (*getNumVertices)( const struct OpenSubdiv_TopologyRefiner* topology_refiner); int (*getNumEdges)( @@ -56,6 +67,9 @@ typedef struct OpenSubdiv_TopologyRefiner { const struct OpenSubdiv_TopologyRefiner* topology_refiner, const int face_index); + ////////////////////////////////////////////////////////////////////////////// + // PTex face geometry queries. + // Ptex face corresponds to OpenSubdiv's internal "patch" and to Blender's // subdivision grid. The rule commes as: // - Triangle face consist of 3 ptex faces, ordered in the order of @@ -79,6 +93,31 @@ typedef struct OpenSubdiv_TopologyRefiner { const struct OpenSubdiv_TopologyRefiner* topology_refiner, int* face_ptex_index_offset); + ////////////////////////////////////////////////////////////////////////////// + // Face-varying data. + + // Number of face-varying channels (or how they are called in Blender layers). + int (*getNumFVarChannels)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner); + // Get face-varying interpolation type. + OpenSubdiv_FVarLinearInterpolation (*getFVarLinearInterpolation)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner); + // Get total number of face-varying values in a particular channel. + int (*getNumFVarValues)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int channel); + // Get face-varying value indices associated with a particular face. + // + // This is an array of indices inside of face-varying array, array elements + // are aligned with face corners (or loops in Blender terminology). + const int* (*getFaceFVarValueIndices)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index, + const int channel); + + ////////////////////////////////////////////////////////////////////////////// + // Internal use. + // Internal storage for the use in this module only. // // Tease: Contains actual OpenSubdiv's refiner and (optionally) some other @@ -86,6 +125,8 @@ typedef struct OpenSubdiv_TopologyRefiner { struct OpenSubdiv_TopologyRefinerInternal* internal; } OpenSubdiv_TopologyRefiner; +// NOTE: Will return NULL in cases of bad topology. +// NOTE: Mesh without faces is considered a bad topology. OpenSubdiv_TopologyRefiner* openSubdiv_createTopologyRefinerFromConverter( struct OpenSubdiv_Converter* converter, const OpenSubdiv_TopologyRefinerSettings* settings); @@ -101,7 +142,7 @@ void openSubdiv_deleteTopologyRefiner( // complicated parts of subdivision process. bool openSubdiv_topologyRefinerCompareWithConverter( const OpenSubdiv_TopologyRefiner* topology_refiner, - const OpenSubdiv_Converter* converter); + const struct OpenSubdiv_Converter* converter); #ifdef __cplusplus } -- cgit v1.2.3 From 433bb9bbcb52fc30aa44def202ca38b4a6e7abac Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 17 Jul 2018 18:07:26 +0200 Subject: Subsurf: Begin new subdivision surface module The idea is to use this as a replacement of old CCG, now it is based on OpenSubdiv. The goal is to reduce any possible overhead which was happening with OpenSubdiv used by CCG. Currently implemented/supported: - Creation from mesh, including topology on OpenSubdiv side, its refinement. - Evaluation of limit point, first order derivatives, normal, and face-varying data for individual coarse position. - Evaluation of whole patches. Currently not optimized, uses evaluation of individual coarse positions. - Creation of Mesh from subdiv, with all geometry being real: all mvert, medge, mloop, and mpoly. This includes custom data interpolation, but all faces currently are getting separated (they are converted to ptex patches, which we need to weld back together). Still need to support lighter weights grids and such, but this is already a required part to have subsurf working in the middle of modifier stack. Annoying part is ifdef all over the place, to keep it compilable when OpenSubdiv is disabled. More cleaner approach would be to have stub API for OpenSubdiv, so everything gets ifdef-ed in a much fewer places. --- source/blender/blenkernel/BKE_subdiv.h | 184 +++++ source/blender/blenkernel/intern/subdiv.c | 114 +++ .../blender/blenkernel/intern/subdiv_converter.c | 65 ++ .../blender/blenkernel/intern/subdiv_converter.h | 57 ++ .../blenkernel/intern/subdiv_converter_mesh.c | 471 +++++++++++ source/blender/blenkernel/intern/subdiv_eval.c | 319 ++++++++ source/blender/blenkernel/intern/subdiv_mesh.c | 910 +++++++++++++++++++++ 7 files changed, 2120 insertions(+) create mode 100644 source/blender/blenkernel/BKE_subdiv.h create mode 100644 source/blender/blenkernel/intern/subdiv.c create mode 100644 source/blender/blenkernel/intern/subdiv_converter.c create mode 100644 source/blender/blenkernel/intern/subdiv_converter.h create mode 100644 source/blender/blenkernel/intern/subdiv_converter_mesh.c create mode 100644 source/blender/blenkernel/intern/subdiv_eval.c create mode 100644 source/blender/blenkernel/intern/subdiv_mesh.c diff --git a/source/blender/blenkernel/BKE_subdiv.h b/source/blender/blenkernel/BKE_subdiv.h new file mode 100644 index 00000000000..92fb1167f55 --- /dev/null +++ b/source/blender/blenkernel/BKE_subdiv.h @@ -0,0 +1,184 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 by Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __BKE_SUBDIV_H__ +#define __BKE_SUBDIV_H__ + +#include "BLI_sys_types.h" + +struct Mesh; +struct OpenSubdiv_Converter; +struct OpenSubdiv_Evaluator; +struct OpenSubdiv_TopologyRefiner; + +/** \file BKE_subdiv.h + * \ingroup bke + * \since July 2018 + * \author Sergey Sharybin + */ + +typedef enum { + SUBDIV_FVAR_LINEAR_INTERPOLATION_NONE, + SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY, + SUBDIV_FVAR_LINEAR_INTERPOLATION_BOUNDARIES, + SUBDIV_FVAR_LINEAR_INTERPOLATION_ALL, +} eSubdivFVarLinearInterpolation; + +typedef struct SubdivSettings { + bool is_simple; + bool is_adaptive; + int level; + eSubdivFVarLinearInterpolation fvar_linear_interpolation; +} SubdivSettings; + +typedef struct Subdiv { + /* Settings this subdivision surface is created for. + * + * It is read-only after assignment in BKE_subdiv_new_from_FOO(). + */ + SubdivSettings settings; + + /* Total number of ptex faces on subdivision level 0. + * + * Ptex face is what is internally used by OpenSubdiv for evaluator. It is + * a quad face, which corresponds to Blender's legacy Catmull Clark grids. + * + * Basically, here is a correspondence between polygons and ptex faces: + * - Triangle consists of 3 PTex faces. + * - Quad is a single PTex face. + * - N-gon is N PTex faces. + * + * This value is initialized in BKE_subdiv_new_from_FOO() and is read-only + * after this. + */ + int num_ptex_faces; + + /* Indexed by base face index, element indicates total number of ptex faces + * created for preceding base faces. + */ + int *face_ptex_offset; + + /* Topology refiner includes all the glue logic to feed Blender side + * topology to OpenSubdiv. It can be shared by both evaluator and GL mesh + * drawer. + */ + struct OpenSubdiv_TopologyRefiner *topology_refiner; + + /* CPU side evaluator. */ + struct OpenSubdiv_Evaluator *evaluator; +} Subdiv; + +/* ============================== CONSTRUCTION ============================== */ + +Subdiv *BKE_subdiv_new_from_converter(const SubdivSettings *settings, + struct OpenSubdiv_Converter *converter); + +Subdiv *BKE_subdiv_new_from_mesh(const SubdivSettings *settings, + struct Mesh *mesh); + +void BKE_subdiv_free(Subdiv *subdiv); + +/* ============================= EVALUATION API ============================= */ + +void BKE_subdiv_eval_begin(Subdiv *subdiv); +void BKE_subdiv_eval_update_from_mesh(Subdiv *subdiv, const struct Mesh *mesh); + +/* Single point queries. */ + +void BKE_subdiv_eval_limit_point( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float P[3]); +void BKE_subdiv_eval_limit_point_and_derivatives( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float P[3], float dPdu[3], float dPdv[3]); +void BKE_subdiv_eval_limit_point_and_normal( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float P[3], float N[3]); +void BKE_subdiv_eval_limit_point_and_short_normal( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float P[3], short N[3]); + +void BKE_subdiv_eval_face_varying( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float varying[2]); + +/* Patch queries at given resolution. + * + * Will evaluate patch at uniformly distributed (u, v) coordinates on a grid + * of given resolution, producing resolution^2 evaluation points. The order + * goes as u in rows, v in columns. + */ + +void BKE_subdiv_eval_limit_patch_resolution_point( + Subdiv *subdiv, + const int ptex_face_index, + const int resolution, + void *buffer, const int offset, const int stride); +void BKE_subdiv_eval_limit_patch_resolution_point_and_derivatives( + Subdiv *subdiv, + const int ptex_face_index, + const int resolution, + void *point_buffer, const int point_offset, const int point_stride, + void *du_buffer, const int du_offset, const int du_stride, + void *dv_buffer, const int dv_offset, const int dv_stride); +void BKE_subdiv_eval_limit_patch_resolution_point_and_normal( + Subdiv *subdiv, + const int ptex_face_index, + const int resolution, + void *point_buffer, const int point_offset, const int point_stride, + void *normal_buffer, const int normal_offset, const int normal_stride); +void BKE_subdiv_eval_limit_patch_resolution_point_and_short_normal( + Subdiv *subdiv, + const int ptex_face_index, + const int resolution, + void *point_buffer, const int point_offset, const int point_stride, + void *normal_buffer, const int normal_offset, const int normal_stride); + +/* =========================== SUBDIV TO MESH API =========================== */ + +typedef struct SubdivToMeshSettings { + /* Resolution at which ptex are being evaluated. + * This defines how many vertices final mesh will have: every ptex has + * resolution^2 vertices. + */ + int resolution; +} SubdivToMeshSettings; + +/* Create real hi-res mesh from subdivision, all geometry is "real". */ +struct Mesh *BKE_subdiv_to_mesh( + Subdiv *subdiv, + const SubdivToMeshSettings *settings, + const struct Mesh *coarse_mesh); + +#endif /* __BKE_SUBDIV_H__ */ diff --git a/source/blender/blenkernel/intern/subdiv.c b/source/blender/blenkernel/intern/subdiv.c new file mode 100644 index 00000000000..72cd39983b9 --- /dev/null +++ b/source/blender/blenkernel/intern/subdiv.c @@ -0,0 +1,114 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 by Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/subdiv.c + * \ingroup bke + */ + +#include "BKE_subdiv.h" + +#include "BLI_utildefines.h" + +#include "MEM_guardedalloc.h" + +#include "subdiv_converter.h" + +#ifdef WITH_OPENSUBDIV +# include "opensubdiv_capi.h" +# include "opensubdiv_converter_capi.h" +# include "opensubdiv_evaluator_capi.h" +# include "opensubdiv_topology_refiner_capi.h" +#endif + +#ifdef WITH_OPENSUBDIV +static void update_subdiv_after_topology_change(Subdiv *subdiv) +{ + /* Count ptex faces. */ + subdiv->num_ptex_faces = subdiv->topology_refiner->getNumPtexFaces( + subdiv->topology_refiner); + /* Initialize offset of base faces in ptex indices. */ + MEM_SAFE_FREE(subdiv->face_ptex_offset); + subdiv->face_ptex_offset = MEM_malloc_arrayN(subdiv->num_ptex_faces, + sizeof(int), + "subdiv ptex offset"); + subdiv->topology_refiner->fillFacePtexIndexOffset( + subdiv->topology_refiner, + subdiv->face_ptex_offset); +} +#endif + +Subdiv *BKE_subdiv_new_from_converter(const SubdivSettings *settings, + struct OpenSubdiv_Converter *converter) +{ +#ifdef WITH_OPENSUBDIV + OpenSubdiv_TopologyRefinerSettings topology_refiner_settings; + topology_refiner_settings.level = settings->level; + topology_refiner_settings.is_adaptive = settings->is_adaptive; + struct OpenSubdiv_TopologyRefiner *osd_topology_refiner = + openSubdiv_createTopologyRefinerFromConverter( + converter, &topology_refiner_settings); + if (osd_topology_refiner == NULL) { + return NULL; + } + Subdiv *subdiv = MEM_callocN(sizeof(Subdiv), "subdiv from converetr"); + subdiv->settings = *settings; + subdiv->topology_refiner = osd_topology_refiner; + subdiv->evaluator = NULL; + update_subdiv_after_topology_change(subdiv); + return subdiv; +#else + UNUSED_VARS(settings, converter); + return NULL; +#endif +} + +Subdiv *BKE_subdiv_new_from_mesh(const SubdivSettings *settings, + struct Mesh *mesh) +{ +#ifdef WITH_OPENSUBDIV + OpenSubdiv_Converter converter; + BKE_subdiv_converter_init_for_mesh(&converter, settings, mesh); + Subdiv *subdiv = BKE_subdiv_new_from_converter(settings, &converter); + BKE_subdiv_converter_free(&converter); + return subdiv; +#else + UNUSED_VARS(settings, mesh); + return NULL; +#endif +} + +void BKE_subdiv_free(Subdiv *subdiv) +{ +#ifdef WITH_OPENSUBDIV + if (subdiv->evaluator != NULL) { + openSubdiv_deleteEvaluator(subdiv->evaluator); + } + if (subdiv->topology_refiner != NULL) { + openSubdiv_deleteTopologyRefiner(subdiv->topology_refiner); + } + MEM_SAFE_FREE(subdiv->face_ptex_offset); + MEM_freeN(subdiv); +#endif +} diff --git a/source/blender/blenkernel/intern/subdiv_converter.c b/source/blender/blenkernel/intern/subdiv_converter.c new file mode 100644 index 00000000000..f6dabfa1c80 --- /dev/null +++ b/source/blender/blenkernel/intern/subdiv_converter.c @@ -0,0 +1,65 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 by Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "subdiv_converter.h" + +#include "BLI_utildefines.h" + +#ifdef WITH_OPENSUBDIV +# include "opensubdiv_converter_capi.h" +#endif + +void BKE_subdiv_converter_free(struct OpenSubdiv_Converter *converter) +{ +#ifdef WITH_OPENSUBDIV + if (converter->freeUserData) { + converter->freeUserData(converter); + } +#else + UNUSED_VARS(converter); +#endif +} + +/*OpenSubdiv_FVarLinearInterpolation*/ int +BKE_subdiv_converter_fvar_linear_from_settings(const SubdivSettings *settings) +{ +#ifdef WITH_OPENSUBDIV + switch (settings->fvar_linear_interpolation) { + case SUBDIV_FVAR_LINEAR_INTERPOLATION_NONE: + return OSD_FVAR_LINEAR_INTERPOLATION_NONE; + case SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY: + return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY; + case SUBDIV_FVAR_LINEAR_INTERPOLATION_BOUNDARIES: + return OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES; + case SUBDIV_FVAR_LINEAR_INTERPOLATION_ALL: + return OSD_FVAR_LINEAR_INTERPOLATION_ALL; + } + BLI_assert(!"Unknown fvar linear interpolation"); + return OSD_FVAR_LINEAR_INTERPOLATION_NONE; +#else + UNUSED_VARS(settings); + return 0; +#endif +} diff --git a/source/blender/blenkernel/intern/subdiv_converter.h b/source/blender/blenkernel/intern/subdiv_converter.h new file mode 100644 index 00000000000..748d97f4178 --- /dev/null +++ b/source/blender/blenkernel/intern/subdiv_converter.h @@ -0,0 +1,57 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 by Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BKE_SUBDIV_CONVERTER_H__ +#define __BKE_SUBDIV_CONVERTER_H__ + +#include "BKE_subdiv.h" + +/* NOTE: Was initially used to get proper enumerator types, but this makes + * it tricky to compile without OpenSubdiv. + */ +/* #include "opensubdiv_converter_capi.h" */ + +struct Mesh; +struct OpenSubdiv_Converter; +struct SubdivSettings; + +void BKE_subdiv_converter_init_for_mesh(struct OpenSubdiv_Converter *converter, + const struct SubdivSettings *settings, + const struct Mesh *mesh); + +/* NOTE: Frees converter data, but not converter itself. This means, that if + * converter was allocated on heap, it is up to the user to free that memory. + */ +void BKE_subdiv_converter_free(struct OpenSubdiv_Converter *converter); + +/* ============================ INTERNAL HELPERS ============================ */ + +/* TODO(sergey): Find a way to make it OpenSubdiv_FVarLinearInterpolation, + * without breaking compilation without OpenSubdiv. + */ +int BKE_subdiv_converter_fvar_linear_from_settings( + const SubdivSettings *settings); + +#endif /* __BKE_SUBDIV_CONVERTER_H__ */ diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c new file mode 100644 index 00000000000..1a2c26b3564 --- /dev/null +++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c @@ -0,0 +1,471 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 by Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "subdiv_converter.h" + +#include + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BLI_utildefines.h" +#include "BLI_math_vector.h" + +#include "BKE_customdata.h" +#include "BKE_mesh_mapping.h" +#include "BKE_subdiv.h" + +#include "MEM_guardedalloc.h" + +#ifdef WITH_OPENSUBDIV +# include "opensubdiv_capi.h" +# include "opensubdiv_converter_capi.h" +#endif + +/* Use mesh element mapping structures during conversion. + * Uses more memory but is much faster than naive algorithm. + */ +#define USE_MESH_ELEMENT_MAPPING + +#ifdef WITH_OPENSUBDIV +typedef struct ConverterStorage { + SubdivSettings settings; + const Mesh *mesh; + +#ifdef USE_MESH_ELEMENT_MAPPING + MeshElemMap *vert_edge_map; + MeshElemMap *vert_poly_map; + MeshElemMap *edge_poly_map; + int *vert_edge_mem; + int *vert_poly_mem; + int *edge_poly_mem; +#endif + + /* Indexed by loop index, value denotes index of face-varying vertex + * which corresponds to the UV coordinate. + */ + int *loop_uv_indices; + int num_uv_coordinates; +} ConverterStorage; + +static OpenSubdiv_SchemeType get_scheme_type( + const OpenSubdiv_Converter *converter) +{ + ConverterStorage *storage = converter->user_data; + if (storage->settings.is_simple) { + return OSD_SCHEME_BILINEAR; + } + else { + return OSD_SCHEME_CATMARK; + } +} + +static OpenSubdiv_FVarLinearInterpolation get_fvar_linear_interpolation( + const OpenSubdiv_Converter *converter) +{ + ConverterStorage *storage = converter->user_data; + return BKE_subdiv_converter_fvar_linear_from_settings(&storage->settings); +} + +static int get_num_faces(const OpenSubdiv_Converter *converter) +{ + ConverterStorage *storage = converter->user_data; + return storage->mesh->totpoly; +} + +static int get_num_edges(const OpenSubdiv_Converter *converter) +{ + ConverterStorage *storage = converter->user_data; + return storage->mesh->totedge; +} + +static int get_num_verts(const OpenSubdiv_Converter *converter) +{ + ConverterStorage *storage = converter->user_data; + return storage->mesh->totvert; +} + +static int get_num_face_verts(const OpenSubdiv_Converter *converter, int face) +{ + ConverterStorage *storage = converter->user_data; + return storage->mesh->mpoly[face].totloop; +} + +static void get_face_verts(const OpenSubdiv_Converter *converter, + int face, + int *face_verts) +{ + ConverterStorage *storage = converter->user_data; + const MPoly *mp = &storage->mesh->mpoly[face]; + const MLoop *mloop = storage->mesh->mloop; + for (int loop = 0; loop < mp->totloop; loop++) { + face_verts[loop] = mloop[mp->loopstart + loop].v; + } +} + +static void get_face_edges(const OpenSubdiv_Converter *converter, + int face, + int *face_edges) +{ + ConverterStorage *storage = converter->user_data; + const MPoly *mp = &storage->mesh->mpoly[face]; + const MLoop *mloop = storage->mesh->mloop; + for (int loop = 0; loop < mp->totloop; loop++) { + face_edges[loop] = mloop[mp->loopstart + loop].e; + } +} + +static void get_edge_verts(const OpenSubdiv_Converter *converter, + int edge, + int *edge_verts) +{ + ConverterStorage *storage = converter->user_data; + const MEdge *me = &storage->mesh->medge[edge]; + edge_verts[0] = me->v1; + edge_verts[1] = me->v2; +} + +static int get_num_edge_faces(const OpenSubdiv_Converter *converter, int edge) +{ + ConverterStorage *storage = converter->user_data; +#ifdef USE_MESH_ELEMENT_MAPPING + return storage->edge_poly_map[edge].count; +#else + const Mesh *mesh = storage->mesh; + const MPoly *mpoly = mesh->mpoly; + const MLoop *mloop = mesh->mloop; + int num = 0; + for (int poly = 0; poly < mesh->totpoly; poly++) { + const MPoly *mp = &mpoly[poly]; + for (int loop = 0; loop < mp->totloop; loop++) { + const MLoop *ml = &mloop[mp->loopstart + loop]; + if (ml->e == edge) { + ++num; + break; + } + } + } + return num; +#endif +} + +static void get_edge_faces(const OpenSubdiv_Converter *converter, + int edge, + int *edge_faces) +{ + ConverterStorage *storage = converter->user_data; +#ifdef USE_MESH_ELEMENT_MAPPING + memcpy(edge_faces, + storage->edge_poly_map[edge].indices, + sizeof(int) * storage->edge_poly_map[edge].count); +#else + const Mesh *mesh = storage->mesh; + const MPoly *mpoly = mesh->mpoly; + const MLoop *mloop = mesh->mloop; + int num = 0; + for (int poly = 0; poly < mesh->totpoly; poly++) { + const MPoly *mp = &mpoly[poly]; + for (int loop = 0; loop < mpoly->totloop; loop++) { + const MLoop *ml = &mloop[mp->loopstart + loop]; + if (ml->e == edge) { + edge_faces[num++] = poly; + break; + } + } + } +#endif +} + +static float get_edge_sharpness(const OpenSubdiv_Converter *converter, int edge) +{ + ConverterStorage *storage = converter->user_data; + const MEdge *medge = storage->mesh->medge; + const float edge_crease = (float)medge[edge].crease / 255.0f; + return edge_crease * storage->settings.level; +} + +static int get_num_vert_edges(const OpenSubdiv_Converter *converter, int vert) +{ + ConverterStorage *storage = converter->user_data; +#ifdef USE_MESH_ELEMENT_MAPPING + return storage->vert_edge_map[vert].count; +#else + const Mesh *mesh = storage->mesh; + const MEdge *medge = mesh->medge; + int num = 0; + for (int edge = 0; edge < mesh->totedge; edge++) { + const MEdge *me = &medge[edge]; + if (me->v1 == vert || me->v2 == vert) { + ++num; + } + } + return num; +#endif +} + +static void get_vert_edges(const OpenSubdiv_Converter *converter, + int vert, + int *vert_edges) +{ + ConverterStorage *storage = converter->user_data; +#ifdef USE_MESH_ELEMENT_MAPPING + memcpy(vert_edges, + storage->vert_edge_map[vert].indices, + sizeof(int) * storage->vert_edge_map[vert].count); +#else + const Mesh *mesh = storage->mesh; + const MEdge *medge = mesh->medge; + int num = 0; + for (int edge = 0; edge < mesh->totedge; edge++) { + const MEdge *me = &medge[edge]; + if (me->v1 == vert || me->v2 == vert) { + vert_edges[num++] = edge; + } + } +#endif +} + +static int get_num_vert_faces(const OpenSubdiv_Converter *converter, int vert) +{ + ConverterStorage *storage = converter->user_data; +#ifdef USE_MESH_ELEMENT_MAPPING + return storage->vert_poly_map[vert].count; +#else + const Mesh *mesh = storage->mesh; + const MPoly *mpoly = mesh->mpoly; + const MLoop *mloop = mesh->mloop; + int num = 0; + for (int poly = 0; poly < mesh->totpoly; poly++) { + const MPoly *mp = &mpoly[poly]; + for (int loop = 0; loop < mpoly->totloop; loop++) { + const MLoop *ml = &mloop[mp->loopstart + loop]; + if (ml->v == vert) { + ++num; + break; + } + } + } + return num; +#endif +} + +static void get_vert_faces(const OpenSubdiv_Converter *converter, + int vert, + int *vert_faces) +{ + ConverterStorage *storage = converter->user_data; +#ifdef USE_MESH_ELEMENT_MAPPING + memcpy(vert_faces, + storage->vert_poly_map[vert].indices, + sizeof(int) * storage->vert_poly_map[vert].count); +#else + const Mesh *mesh = storage->mesh; + const MPoly *mpoly = mesh->mpoly; + const MLoop *mloop = mesh->mloop; + int num = 0; + for (int poly = 0; poly < mesh->totpoly; poly++) { + const MPoly *mp = &mpoly[poly]; + for (int loop = 0; loop < mpoly->totloop; loop++) { + const MLoop *ml = &mloop[mp->loopstart + loop]; + if (ml->v == vert) { + vert_faces[num++] = poly; + break; + } + } + } +#endif +} + +static int get_num_uv_layers(const OpenSubdiv_Converter *converter) +{ + ConverterStorage *storage = converter->user_data; + const Mesh *mesh = storage->mesh; + return CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV); +} + +static void precalc_uv_layer(const OpenSubdiv_Converter *converter, + const int layer_index) +{ + ConverterStorage *storage = converter->user_data; + const Mesh *mesh = storage->mesh; + const MPoly *mpoly = mesh->mpoly; + const MLoop *mloop = mesh->mloop; + const MLoopUV *mloopuv = CustomData_get_layer_n( + &mesh->ldata, CD_MLOOPUV, layer_index); + const int num_poly = mesh->totpoly; + const int num_vert = mesh->totvert; + const float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT}; + /* Initialize memory required for the operations. */ + if (storage->loop_uv_indices == NULL) { + storage->loop_uv_indices = MEM_malloc_arrayN( + mesh->totloop, sizeof(int), "loop uv vertex index"); + } + UvVertMap *uv_vert_map = BKE_mesh_uv_vert_map_create( + mpoly, mloop, mloopuv, + num_poly, num_vert, + limit, + false, true); + /* NOTE: First UV vertex is supposed to be always marked as separate. */ + storage->num_uv_coordinates = -1; + for (int vertex_index = 0; vertex_index < num_vert; ++vertex_index) { + const UvMapVert *uv_vert = BKE_mesh_uv_vert_map_get_vert(uv_vert_map, + vertex_index); + while (uv_vert != NULL) { + if (uv_vert->separate) { + storage->num_uv_coordinates++; + } + const MPoly *mp = &mpoly[uv_vert->poly_index]; + const int global_loop_index = mp->loopstart + + uv_vert->loop_of_poly_index; + storage->loop_uv_indices[global_loop_index] = + storage->num_uv_coordinates; + uv_vert = uv_vert->next; + } + } + /* So far this value was used as a 0-based index, actual number of UV + * vertices is 1 more. + */ + storage->num_uv_coordinates += 1; + BKE_mesh_uv_vert_map_free(uv_vert_map); +} + +static void finish_uv_layer(const OpenSubdiv_Converter *UNUSED(converter)) +{ +} + +static int get_num_uvs(const OpenSubdiv_Converter *converter) +{ + ConverterStorage *storage = converter->user_data; + return storage->num_uv_coordinates; +} + +static int get_face_corner_uv_index(const OpenSubdiv_Converter *converter, + const int face_index, + const int corner) +{ + ConverterStorage *storage = converter->user_data; + const MPoly *mp = &storage->mesh->mpoly[face_index]; + return storage->loop_uv_indices[mp->loopstart + corner]; +} + +static void free_user_data(const OpenSubdiv_Converter *converter) +{ + ConverterStorage *user_data = converter->user_data; + MEM_SAFE_FREE(user_data->loop_uv_indices); +#ifdef USE_MESH_ELEMENT_MAPPING + MEM_freeN(user_data->vert_edge_map); + MEM_freeN(user_data->vert_edge_mem); + MEM_freeN(user_data->vert_poly_map); + MEM_freeN(user_data->vert_poly_mem); + MEM_freeN(user_data->edge_poly_map); + MEM_freeN(user_data->edge_poly_mem); +#endif + MEM_freeN(user_data); +} + +static void init_functions(OpenSubdiv_Converter *converter) +{ + converter->getSchemeType = get_scheme_type; + + converter->getFVarLinearInterpolation = get_fvar_linear_interpolation; + + converter->getNumFaces = get_num_faces; + converter->getNumEdges = get_num_edges; + converter->getNumVertices = get_num_verts; + + converter->getNumFaceVertices = get_num_face_verts; + converter->getFaceVertices = get_face_verts; + converter->getFaceEdges = get_face_edges; + + converter->getEdgeVertices = get_edge_verts; + converter->getNumEdgeFaces = get_num_edge_faces; + converter->getEdgeFaces = get_edge_faces; + converter->getEdgeSharpness = get_edge_sharpness; + + converter->getNumVertexEdges = get_num_vert_edges; + converter->getVertexEdges = get_vert_edges; + converter->getNumVertexFaces = get_num_vert_faces; + converter->getVertexFaces = get_vert_faces; + + converter->getNumUVLayers = get_num_uv_layers; + converter->precalcUVLayer = precalc_uv_layer; + converter->finishUVLayer = finish_uv_layer; + converter->getNumUVCoordinates = get_num_uvs; + converter->getFaceCornerUVIndex = get_face_corner_uv_index; + + converter->freeUserData = free_user_data; +} + +static void create_element_maps_if_needed(ConverterStorage *storage) +{ +#ifdef USE_MESH_ELEMENT_MAPPING + const Mesh *mesh = storage->mesh; + BKE_mesh_vert_edge_map_create(&storage->vert_edge_map, + &storage->vert_edge_mem, + mesh->medge, + mesh->totvert, + mesh->totedge); + BKE_mesh_vert_poly_map_create(&storage->vert_poly_map, + &storage->vert_poly_mem, + mesh->mpoly, + mesh->mloop, + mesh->totvert, + mesh->totpoly, + mesh->totloop); + BKE_mesh_edge_poly_map_create(&storage->edge_poly_map, + &storage->edge_poly_mem, + mesh->medge, mesh->totedge, + mesh->mpoly, mesh->totpoly, + mesh->mloop, mesh->totloop); +#else + (void) storage; /* Ignored. */ +#endif +} + +static void init_user_data(OpenSubdiv_Converter *converter, + const SubdivSettings *settings, + const Mesh *mesh) +{ + ConverterStorage *user_data = + MEM_mallocN(sizeof(ConverterStorage), __func__); + user_data->settings = *settings; + user_data->mesh = mesh; + user_data->loop_uv_indices = NULL; + create_element_maps_if_needed(user_data); + converter->user_data = user_data; +} +#endif + +void BKE_subdiv_converter_init_for_mesh(struct OpenSubdiv_Converter *converter, + const SubdivSettings *settings, + const Mesh *mesh) +{ +#ifdef WITH_OPENSUBDIV + init_functions(converter); + init_user_data(converter, settings, mesh); +#else + UNUSED_VARS(converter, settings, mesh); +#endif +} diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c new file mode 100644 index 00000000000..0ab19fc8df5 --- /dev/null +++ b/source/blender/blenkernel/intern/subdiv_eval.c @@ -0,0 +1,319 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 by Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/subdiv_eval.c + * \ingroup bke + */ + +#include "BKE_subdiv.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BLI_utildefines.h" +#include "BLI_math_vector.h" + +#include "BKE_customdata.h" + +#ifdef WITH_OPENSUBDIV +# include "opensubdiv_evaluator_capi.h" +# include "opensubdiv_topology_refiner_capi.h" +#endif + +void BKE_subdiv_eval_begin(Subdiv *subdiv) +{ +#ifdef WITH_OPENSUBDIV + if (subdiv->evaluator == NULL) { + subdiv->evaluator = openSubdiv_createEvaluatorFromTopologyRefiner( + subdiv->topology_refiner); + } + else { + /* TODO(sergey): Check for topology change. */ + } +#else + UNUSED_VARS(subdiv); +#endif +} + +#ifdef WITH_OPENSUBDIV +static void set_face_varying_data_from_uv(Subdiv *subdiv, + const MLoopUV *mloopuv, + const int layer_index) +{ + OpenSubdiv_TopologyRefiner *topology_refiner = subdiv->topology_refiner; + OpenSubdiv_Evaluator *evaluator = subdiv->evaluator; + const int num_faces = topology_refiner->getNumFaces(topology_refiner); + const MLoopUV *mluv = mloopuv; + /* TODO(sergey): OpenSubdiv's C-API converter can change winding of + * loops of a face, need to watch for that, to prevent wrong UVs assigned. + */ + for (int face_index = 0; face_index < num_faces; ++face_index) { + const int num_face_vertices = topology_refiner->getNumFaceVertices( + topology_refiner, face_index); + const int *uv_indicies = topology_refiner->getFaceFVarValueIndices( + topology_refiner, face_index, layer_index); + for (int vertex_index = 0; + vertex_index < num_face_vertices; + vertex_index++, mluv++) + { + evaluator->setFaceVaryingData(evaluator, + mluv->uv, + uv_indicies[vertex_index], + 1); + } + } +} +#endif + +void BKE_subdiv_eval_update_from_mesh(Subdiv *subdiv, const Mesh *mesh) +{ +#ifdef WITH_OPENSUBDIV + BKE_subdiv_eval_begin(subdiv); + /* Set coordinates of base mesh vertices. */ + subdiv->evaluator->setCoarsePositionsFromBuffer( + subdiv->evaluator, + mesh->mvert, + offsetof(MVert, co), + sizeof(MVert), + 0, mesh->totvert); + /* Set face-varyign data to UV maps. */ + const int num_uv_layers = + CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV); + for (int layer_index = 0; layer_index < num_uv_layers; layer_index++) { + const MLoopUV *mloopuv = CustomData_get_layer_n( + &mesh->ldata, CD_MLOOPUV, layer_index); + set_face_varying_data_from_uv(subdiv, mloopuv, layer_index); + /* NOTE: Currently evaluator can only handle single face varying layer. + * This is a limitation of C-API and some underlying helper classes from + * our side which will get fixed. + */ + break; + } + /* Update evaluator to the new coarse geometry. */ + subdiv->evaluator->refine(subdiv->evaluator); +#else + UNUSED_VARS(subdiv, mesh); +#endif +} + +/* ========================== Single point queries ========================== */ + +void BKE_subdiv_eval_limit_point( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float P[3]) +{ + BKE_subdiv_eval_limit_point_and_derivatives(subdiv, + ptex_face_index, + u, v, + P, NULL, NULL); +} + +void BKE_subdiv_eval_limit_point_and_derivatives( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float P[3], float dPdu[3], float dPdv[3]) +{ +#ifdef WITH_OPENSUBDIV + subdiv->evaluator->evaluateLimit(subdiv->evaluator, + ptex_face_index, + u, v, + P, dPdu, dPdv); +#else + UNUSED_VARS(subdiv, ptex_face_index, u, v, P, dPdu, dPdv); +#endif +} + +void BKE_subdiv_eval_limit_point_and_normal( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float P[3], float N[3]) +{ + float dPdu[3], dPdv[3]; + BKE_subdiv_eval_limit_point_and_derivatives(subdiv, + ptex_face_index, + u, v, + P, dPdu, dPdv); + cross_v3_v3v3(N, dPdu, dPdv); + normalize_v3(N); +} + +void BKE_subdiv_eval_limit_point_and_short_normal( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float P[3], short N[3]) +{ + float N_float[3]; + BKE_subdiv_eval_limit_point_and_normal(subdiv, + ptex_face_index, + u, v, + P, N_float); + normal_float_to_short_v3(N, N_float); +} + +void BKE_subdiv_eval_face_varying( + Subdiv *subdiv, + const int ptex_face_index, + const float u, const float v, + float face_varying[2]) +{ +#ifdef WITH_OPENSUBDIV + subdiv->evaluator->evaluateFaceVarying(subdiv->evaluator, + ptex_face_index, + u, v, + face_varying); +#else + UNUSED_VARS(subdiv, ptex_face_index, u, v, face_varying); +#endif +} + +/* =================== Patch queries at given resolution =================== */ + +/* Move buffer forward by a given number of bytes. */ +static void buffer_apply_offset(void **buffer, const int offset) +{ + *buffer = ((unsigned char *)*buffer) + offset; +} + +/* Write given number of floats to the beginning of given buffer. */ +static void buffer_write_float_value(void **buffer, + const float *values_buffer, int num_values) +{ + memcpy(*buffer, values_buffer, sizeof(float) * num_values); +} + +/* Similar to above, just operates with short values. */ +static void buffer_write_short_value(void **buffer, + const short *values_buffer, int num_values) +{ + memcpy(*buffer, values_buffer, sizeof(short) * num_values); +} + +void BKE_subdiv_eval_limit_patch_resolution_point( + Subdiv *subdiv, + const int ptex_face_index, + const int resolution, + void *buffer, const int offset, const int stride) +{ + buffer_apply_offset(&buffer, offset); + const float inv_resolution_1 = 1.0f / (float)(resolution - 1); + for (int y = 0; y < resolution; y++) { + const float v = y * inv_resolution_1; + for (int x = 0; x < resolution; x++) { + const float u = x * inv_resolution_1; + BKE_subdiv_eval_limit_point(subdiv, + ptex_face_index, + u, v, + buffer); + buffer_apply_offset(&buffer, stride); + } + } +} + +void BKE_subdiv_eval_limit_patch_resolution_point_and_derivatives( + Subdiv *subdiv, + const int ptex_face_index, + const int resolution, + void *point_buffer, const int point_offset, const int point_stride, + void *du_buffer, const int du_offset, const int du_stride, + void *dv_buffer, const int dv_offset, const int dv_stride) +{ + buffer_apply_offset(&point_buffer, point_offset); + buffer_apply_offset(&du_buffer, du_offset); + buffer_apply_offset(&dv_buffer, dv_offset); + const float inv_resolution_1 = 1.0f / (float)(resolution - 1); + for (int y = 0; y < resolution; y++) { + const float v = y * inv_resolution_1; + for (int x = 0; x < resolution; x++) { + const float u = x * inv_resolution_1; + BKE_subdiv_eval_limit_point_and_derivatives( + subdiv, + ptex_face_index, + u, v, + point_buffer, du_buffer, dv_buffer); + buffer_apply_offset(&point_buffer, point_stride); + buffer_apply_offset(&du_buffer, du_stride); + buffer_apply_offset(&dv_buffer, dv_stride); + } + } +} + +void BKE_subdiv_eval_limit_patch_resolution_point_and_normal( + Subdiv *subdiv, + const int ptex_face_index, + const int resolution, + void *point_buffer, const int point_offset, const int point_stride, + void *normal_buffer, const int normal_offset, const int normal_stride) +{ + buffer_apply_offset(&point_buffer, point_offset); + buffer_apply_offset(&normal_buffer, normal_offset); + const float inv_resolution_1 = 1.0f / (float)(resolution - 1); + for (int y = 0; y < resolution; y++) { + const float v = y * inv_resolution_1; + for (int x = 0; x < resolution; x++) { + const float u = x * inv_resolution_1; + float normal[3]; + BKE_subdiv_eval_limit_point_and_normal( + subdiv, + ptex_face_index, + u, v, + point_buffer, normal); + buffer_write_float_value(&normal_buffer, normal, 3); + buffer_apply_offset(&point_buffer, point_stride); + buffer_apply_offset(&normal_buffer, normal_stride); + } + } +} + +void BKE_subdiv_eval_limit_patch_resolution_point_and_short_normal( + Subdiv *subdiv, + const int ptex_face_index, + const int resolution, + void *point_buffer, const int point_offset, const int point_stride, + void *normal_buffer, const int normal_offset, const int normal_stride) +{ + buffer_apply_offset(&point_buffer, point_offset); + buffer_apply_offset(&normal_buffer, normal_offset); + const float inv_resolution_1 = 1.0f / (float)(resolution - 1); + for (int y = 0; y < resolution; y++) { + const float v = y * inv_resolution_1; + for (int x = 0; x < resolution; x++) { + const float u = x * inv_resolution_1; + short normal[3]; + BKE_subdiv_eval_limit_point_and_short_normal( + subdiv, + ptex_face_index, + u, v, + point_buffer, normal); + buffer_write_short_value(&normal_buffer, normal, 3); + buffer_apply_offset(&point_buffer, point_stride); + buffer_apply_offset(&normal_buffer, normal_stride); + } + } +} diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c new file mode 100644 index 00000000000..8a58605ba19 --- /dev/null +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -0,0 +1,910 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 by Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/subdiv_mesh.c + * \ingroup bke + */ + +#include "BKE_subdiv.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BLI_alloca.h" +#include "BLI_math_vector.h" +#include "BLI_task.h" + +#include "BKE_mesh.h" + +/* TODO(sergey): Somehow move this to subdiv code? */ +static int mpoly_ptex_faces_count_get(const MPoly *mp) +{ + if (mp->totloop == 4) { + return 1; + } + else { + return mp->totloop; + } +} + +static int num_edges_per_ptex_get(const int resolution) +{ + return 2 * (resolution - 1) * resolution; +} + +static int num_polys_per_ptex_get(const int resolution) +{ + return (resolution - 1) * (resolution - 1); +} + +typedef struct SubdivMeshContext { + const Mesh *coarse_mesh; + Subdiv *subdiv; + Mesh *subdiv_mesh; + const SubdivToMeshSettings *settings; + /* Cached custom data arrays for fastter access. */ + int *vert_origindex; + int *edge_origindex; + int *loop_origindex; + int *poly_origindex; + /* UV layers interpolation. */ + int num_uv_layers; + MLoopUV *uv_layers[MAX_MTFACE]; +} SubdivMeshContext; + +typedef struct LoopsOfPtex { + /* First loop of the ptex, starts at ptex (0, 0) and goes in u direction. */ + const MLoop *first_loop; + /* Last loop of the ptex, starts at ptex (0, 0) and goes in v direction. */ + const MLoop *last_loop; + /* For quad coarse faces only. */ + const MLoop *second_loop; + const MLoop *third_loop; +} LoopsOfPtex; + +static void loops_of_ptex_get( + const SubdivMeshContext *ctx, + LoopsOfPtex *loops_of_ptex, + const MPoly *coarse_poly, + const int ptex_face_index) +{ + const MLoop *coarse_mloop = ctx->coarse_mesh->mloop; + const int first_ptex_loop_index = coarse_poly->loopstart + ptex_face_index; + /* Loop which look in the (opposite) V direction of the current + * ptex face. + * + * TOOD(sergey): Get rid of using module on every iteration. + */ + const int last_ptex_loop_index = + coarse_poly->loopstart + + (ptex_face_index + coarse_poly->totloop - 1) % coarse_poly->totloop; + loops_of_ptex->first_loop = &coarse_mloop[first_ptex_loop_index]; + loops_of_ptex->last_loop = &coarse_mloop[last_ptex_loop_index]; + if (coarse_poly->totloop == 4) { + loops_of_ptex->second_loop = loops_of_ptex->first_loop + 1; + loops_of_ptex->third_loop = loops_of_ptex->first_loop + 2; + } + else { + loops_of_ptex->second_loop = NULL; + loops_of_ptex->third_loop = NULL; + } +} + +typedef struct EdgesOfPtex { + /* First edge of the ptex, starts at ptex (0, 0) and goes in u direction. */ + const MEdge *first_edge; + /* Last edge of the ptex, starts at ptex (0, 0) and goes in v direction. */ + const MEdge *last_edge; + /* For quad coarse faces only. */ + const MEdge *second_edge; + const MEdge *third_edge; +} EdgesOfPtex; + +static void edges_of_ptex_get( + const SubdivMeshContext *ctx, + EdgesOfPtex *edges_of_ptex, + const MPoly *coarse_poly, + const int ptex_face_index) +{ + const MEdge *coarse_medge = ctx->coarse_mesh->medge; + LoopsOfPtex loops_of_ptex; + loops_of_ptex_get(ctx, &loops_of_ptex, coarse_poly, ptex_face_index); + edges_of_ptex->first_edge = &coarse_medge[loops_of_ptex.first_loop->e]; + edges_of_ptex->last_edge = &coarse_medge[loops_of_ptex.last_loop->e]; + if (coarse_poly->totloop == 4) { + edges_of_ptex->second_edge = + &coarse_medge[loops_of_ptex.second_loop->e]; + edges_of_ptex->third_edge = + &coarse_medge[loops_of_ptex.third_loop->e]; + } + else { + edges_of_ptex->second_edge = NULL; + edges_of_ptex->third_edge = NULL; + } +} + +/* TODO(sergey): Somehow de-duplicate with loops storage, without too much + * exception cases all over the code. + */ + +typedef struct VerticesForInterpolation { + /* This field points to a vertex data which is to be used for interpolation. + * The idea is to avoid unnecessary allocations for regular faces, where + * we can simply + */ + const CustomData *vertex_data; + /* Vertices data calculated for ptex corners. There are always 4 elements + * in this custom data, aligned the following way: + * + * index 0 -> uv (0, 0) + * index 1 -> uv (0, 1) + * index 2 -> uv (1, 1) + * index 3 -> uv (1, 0) + * + * Is allocated for non-regular faces (triangles and n-gons). + */ + CustomData vertex_data_storage; + bool vertex_data_storage_allocated; + /* Infices within vertex_data to interpolate for. The indices are aligned + * with uv coordinates in a similar way as indices in loop_data_storage. + */ + int vertex_indices[4]; +} VerticesForInterpolation; + +static void vertex_interpolation_init( + const SubdivMeshContext *ctx, + VerticesForInterpolation *vertex_interpolation, + const MPoly *coarse_poly) +{ + const Mesh *coarse_mesh = ctx->coarse_mesh; + const MLoop *coarse_mloop = coarse_mesh->mloop; + if (coarse_poly->totloop == 4) { + vertex_interpolation->vertex_data = &coarse_mesh->vdata; + vertex_interpolation->vertex_indices[0] = + coarse_mloop[coarse_poly->loopstart + 0].v; + vertex_interpolation->vertex_indices[1] = + coarse_mloop[coarse_poly->loopstart + 1].v; + vertex_interpolation->vertex_indices[2] = + coarse_mloop[coarse_poly->loopstart + 2].v; + vertex_interpolation->vertex_indices[3] = + coarse_mloop[coarse_poly->loopstart + 3].v; + vertex_interpolation->vertex_data_storage_allocated = false; + } + else { + vertex_interpolation->vertex_data = + &vertex_interpolation->vertex_data_storage; + /* Allocate storage for loops corresponding to ptex corners. */ + CustomData_copy(&ctx->coarse_mesh->vdata, + &vertex_interpolation->vertex_data_storage, + CD_MASK_EVERYTHING, + CD_CALLOC, + 4); + /* Initialize indices. */ + vertex_interpolation->vertex_indices[0] = 0; + vertex_interpolation->vertex_indices[1] = 1; + vertex_interpolation->vertex_indices[2] = 2; + vertex_interpolation->vertex_indices[3] = 3; + vertex_interpolation->vertex_data_storage_allocated = true; + /* Interpolate center of poly right away, it stays unchanged for all + * ptex faces. + */ + const float weight = 1.0f / (float)coarse_poly->totloop; + float *weights = BLI_array_alloca(weights, coarse_poly->totloop); + int *indices = BLI_array_alloca(indices, coarse_poly->totloop); + for (int i = 0; i < coarse_poly->totloop; ++i) { + weights[i] = weight; + indices[i] = coarse_poly->loopstart + i; + } + CustomData_interp(&coarse_mesh->vdata, + &vertex_interpolation->vertex_data_storage, + indices, + weights, NULL, + coarse_poly->totloop, + 2); + } +} + +static void vertex_interpolation_from_ptex( + const SubdivMeshContext *ctx, + VerticesForInterpolation *vertex_interpolation, + const MPoly *coarse_poly, + const int ptex_face_index) +{ + if (coarse_poly->totloop == 4) { + /* Nothing to do, all indices and data is already assigned. */ + } else { + const CustomData *vertex_data = &ctx->coarse_mesh->vdata; + const Mesh *coarse_mesh = ctx->coarse_mesh; + const MLoop *coarse_mloop = coarse_mesh->mloop; + LoopsOfPtex loops_of_ptex; + loops_of_ptex_get(ctx, &loops_of_ptex, coarse_poly, ptex_face_index); + /* Ptex face corner corresponds to a poly loop with same index. */ + CustomData_copy_data( + vertex_data, + &vertex_interpolation->vertex_data_storage, + coarse_mloop[coarse_poly->loopstart + ptex_face_index].v, + 0, + 1); + /* Interpolate remaining ptex face corners, which hits loops + * middle points. + * + * TODO(sergey): Re-use one of interpolation results from previous + * iteration. + */ + const float weights[2] = {0.5f, 0.5f}; + const int first_indices[2] = { + coarse_mloop[loops_of_ptex.first_loop - coarse_mloop].v, + coarse_mloop[(loops_of_ptex.first_loop + 1 - coarse_mloop) % + coarse_poly->totloop].v}; + const int last_indices[2] = { + coarse_mloop[loops_of_ptex.last_loop - coarse_mloop].v, + coarse_mloop[loops_of_ptex.first_loop - coarse_mloop].v}; + CustomData_interp(vertex_data, + &vertex_interpolation->vertex_data_storage, + first_indices, + weights, NULL, + 2, + 1); + CustomData_interp(vertex_data, + &vertex_interpolation->vertex_data_storage, + last_indices, + weights, NULL, + 2, + 3); + } +} + +static void vertex_interpolation_end( + VerticesForInterpolation *vertex_interpolation) +{ + if (vertex_interpolation->vertex_data_storage_allocated) { + CustomData_free(&vertex_interpolation->vertex_data_storage, 4); + } +} + +typedef struct LoopsForInterpolation { + /* This field points to a loop data which is to be used for interpolation. + * The idea is to avoid unnecessary allocations for regular faces, where + * we can simply + */ + const CustomData *loop_data; + /* Loops data calculated for ptex corners. There are always 4 elements + * in this custom data, aligned the following way: + * + * index 0 -> uv (0, 0) + * index 1 -> uv (0, 1) + * index 2 -> uv (1, 1) + * index 3 -> uv (1, 0) + * + * Is allocated for non-regular faces (triangles and n-gons). + */ + CustomData loop_data_storage; + bool loop_data_storage_allocated; + /* Infices within loop_data to interpolate for. The indices are aligned with + * uv coordinates in a similar way as indices in loop_data_storage. + */ + int loop_indices[4]; +} LoopsForInterpolation; + +static void loop_interpolation_init( + const SubdivMeshContext *ctx, + LoopsForInterpolation *loop_interpolation, + const MPoly *coarse_poly) +{ + const Mesh *coarse_mesh = ctx->coarse_mesh; + if (coarse_poly->totloop == 4) { + loop_interpolation->loop_data = &coarse_mesh->ldata; + loop_interpolation->loop_indices[0] = coarse_poly->loopstart + 0; + loop_interpolation->loop_indices[1] = coarse_poly->loopstart + 1; + loop_interpolation->loop_indices[2] = coarse_poly->loopstart + 2; + loop_interpolation->loop_indices[3] = coarse_poly->loopstart + 3; + loop_interpolation->loop_data_storage_allocated = false; + } + else { + loop_interpolation->loop_data = &loop_interpolation->loop_data_storage; + /* Allocate storage for loops corresponding to ptex corners. */ + CustomData_copy(&ctx->coarse_mesh->ldata, + &loop_interpolation->loop_data_storage, + CD_MASK_EVERYTHING, + CD_CALLOC, + 4); + /* Initialize indices. */ + loop_interpolation->loop_indices[0] = 0; + loop_interpolation->loop_indices[1] = 1; + loop_interpolation->loop_indices[2] = 2; + loop_interpolation->loop_indices[3] = 3; + loop_interpolation->loop_data_storage_allocated = true; + /* Interpolate center of poly right away, it stays unchanged for all + * ptex faces. + */ + const float weight = 1.0f / (float)coarse_poly->totloop; + float *weights = BLI_array_alloca(weights, coarse_poly->totloop); + int *indices = BLI_array_alloca(indices, coarse_poly->totloop); + for (int i = 0; i < coarse_poly->totloop; ++i) { + weights[i] = weight; + indices[i] = coarse_poly->loopstart + i; + } + CustomData_interp(&coarse_mesh->ldata, + &loop_interpolation->loop_data_storage, + indices, + weights, NULL, + coarse_poly->totloop, + 2); + } +} + +static void loop_interpolation_from_ptex( + const SubdivMeshContext *ctx, + LoopsForInterpolation *loop_interpolation, + const MPoly *coarse_poly, + const int ptex_face_index) +{ + if (coarse_poly->totloop == 4) { + /* Nothing to do, all indices and data is already assigned. */ + } else { + const CustomData *loop_data = &ctx->coarse_mesh->ldata; + const Mesh *coarse_mesh = ctx->coarse_mesh; + const MLoop *coarse_mloop = coarse_mesh->mloop; + LoopsOfPtex loops_of_ptex; + loops_of_ptex_get(ctx, &loops_of_ptex, coarse_poly, ptex_face_index); + /* Ptex face corner corresponds to a poly loop with same index. */ + CustomData_copy_data(loop_data, + &loop_interpolation->loop_data_storage, + coarse_poly->loopstart + ptex_face_index, + 0, + 1); + /* Interpolate remaining ptex face corners, which hits loops + * middle points. + * + * TODO(sergey): Re-use one of interpolation results from previous + * iteration. + */ + const float weights[2] = {0.5f, 0.5f}; + const int first_indices[2] = { + loops_of_ptex.first_loop - coarse_mloop, + (loops_of_ptex.first_loop + 1 - coarse_mloop) % + coarse_poly->totloop}; + const int last_indices[2] = { + loops_of_ptex.last_loop - coarse_mloop, + loops_of_ptex.first_loop - coarse_mloop}; + CustomData_interp(loop_data, + &loop_interpolation->loop_data_storage, + first_indices, + weights, NULL, + 2, + 1); + CustomData_interp(loop_data, + &loop_interpolation->loop_data_storage, + last_indices, + weights, NULL, + 2, + 3); + } +} + +static void loop_interpolation_end(LoopsForInterpolation *loop_interpolation) +{ + if (loop_interpolation->loop_data_storage_allocated) { + CustomData_free(&loop_interpolation->loop_data_storage, 4); + } +} + +static void subdiv_copy_vertex_data( + const SubdivMeshContext *ctx, + MVert *subdiv_vertex, + const VerticesForInterpolation *vertex_interpolation, + const float u, const float v) +{ + const int subdiv_vertex_index = subdiv_vertex - ctx->subdiv_mesh->mvert; + const float weights[4] = {(1.0f - u) * (1.0f - v), + u * (1.0f - v), + u * v, + (1.0f - u) * v}; + CustomData_interp(vertex_interpolation->vertex_data, + &ctx->subdiv_mesh->vdata, + vertex_interpolation->vertex_indices, + weights, NULL, + 4, + subdiv_vertex_index); + /* TODO(sergey): Set ORIGINDEX. */ +} + +static void subdiv_evaluate_vertices(SubdivMeshContext *ctx, + const int poly_index) +{ + Subdiv *subdiv = ctx->subdiv; + const int resolution = ctx->settings->resolution; + const int resolution2 = resolution * resolution; + const float inv_resolution_1 = 1.0f / (float)(resolution - 1); + /* Base/coarse mesh information. */ + const Mesh *coarse_mesh = ctx->coarse_mesh; + const MPoly *coarse_polyoly = coarse_mesh->mpoly; + const MPoly *coarse_poly = &coarse_polyoly[poly_index]; + const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly); + /* Hi-poly subdivided mesh. */ + Mesh *subdiv_mesh = ctx->subdiv_mesh; + MVert *subdiv_vertert = subdiv_mesh->mvert; + const int ptex_face_index = subdiv->face_ptex_offset[poly_index]; + /* Actual evaluation. */ + VerticesForInterpolation vertex_interpolation; + vertex_interpolation_init(ctx, &vertex_interpolation, coarse_poly); + MVert *subdiv_vert = &subdiv_vertert[ptex_face_index * resolution2]; + for (int ptex_of_poly_index = 0; + ptex_of_poly_index < num_poly_ptex_faces; + ptex_of_poly_index++) + { + vertex_interpolation_from_ptex(ctx, + &vertex_interpolation, + coarse_poly, + ptex_of_poly_index); + const int current_ptex_face_index = + ptex_face_index + ptex_of_poly_index; + BKE_subdiv_eval_limit_patch_resolution_point_and_short_normal( + subdiv, + current_ptex_face_index, + resolution, + subdiv_vert, offsetof(MVert, co), sizeof(MVert), + subdiv_vert, offsetof(MVert, no), sizeof(MVert)); + for (int y = 0; y < resolution; y++) { + const float v = y * inv_resolution_1; + for (int x = 0; x < resolution; x++, subdiv_vert++) { + const float u = x * inv_resolution_1; + subdiv_copy_vertex_data(ctx, + subdiv_vert, + &vertex_interpolation, + u, v); + } + } + } + vertex_interpolation_end(&vertex_interpolation); +} + +static void subdiv_copy_edge_data(SubdivMeshContext *ctx, + MEdge *subdiv_edge, + const MEdge *coarse_edge) +{ + if (coarse_edge == NULL) { + subdiv_edge->crease = 0; + subdiv_edge->bweight = 0; + subdiv_edge->flag = 0; + return; + } + const int coarse_edge_index = coarse_edge - ctx->coarse_mesh->medge; + const int subdiv_edge_index = subdiv_edge - ctx->subdiv_mesh->medge; + CustomData_copy_data(&ctx->coarse_mesh->edata, + &ctx->subdiv_mesh->edata, + coarse_edge_index, + subdiv_edge_index, + 1); + if (ctx->edge_origindex != NULL) { + ctx->edge_origindex[subdiv_edge_index] = coarse_edge_index; + } +} + +static MEdge *subdiv_create_edges_row(SubdivMeshContext *ctx, + MEdge *subdiv_edge, + const MEdge *coarse_edge, + const int start_vertex_index, + const int resolution) +{ + int vertex_index = start_vertex_index; + for (int edge_index = 0; + edge_index < resolution - 1; + edge_index++, subdiv_edge++) + { + subdiv_copy_edge_data(ctx, subdiv_edge, coarse_edge); + subdiv_edge->v1 = vertex_index; + subdiv_edge->v2 = vertex_index + 1; + vertex_index += 1; + } + return subdiv_edge; +} + +static MEdge *subdiv_create_edges_column(SubdivMeshContext *ctx, + MEdge *subdiv_edge, + const MEdge *coarse_start_edge, + const MEdge *coarse_end_edge, + const int start_vertex_index, + const int resolution) +{ + int vertex_index = start_vertex_index; + for (int edge_index = 0; + edge_index < resolution; + edge_index++, subdiv_edge++) + { + const MEdge *coarse_edge = NULL; + if (edge_index == 0) { + coarse_edge = coarse_start_edge; + } + else if (edge_index == resolution - 1) { + coarse_edge = coarse_end_edge; + } + subdiv_copy_edge_data(ctx, subdiv_edge, coarse_edge); + subdiv_edge->v1 = vertex_index; + subdiv_edge->v2 = vertex_index + resolution; + vertex_index += 1; + } + return subdiv_edge; +} + +static void subdiv_create_edges(SubdivMeshContext *ctx, int poly_index) +{ + Subdiv *subdiv = ctx->subdiv; + const int resolution = ctx->settings->resolution; + const int resolution2 = resolution * resolution; + const int ptex_face_index = subdiv->face_ptex_offset[poly_index]; + const int num_edges_per_ptex = num_edges_per_ptex_get(resolution); + const int start_edge_index = ptex_face_index * num_edges_per_ptex; + /* Base/coarse mesh information. */ + const Mesh *coarse_mesh = ctx->coarse_mesh; + const MPoly *coarse_polyoly = coarse_mesh->mpoly; + const MPoly *coarse_poly = &coarse_polyoly[poly_index]; + const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly); + /* Hi-poly subdivided mesh. */ + Mesh *subdiv_mesh = ctx->subdiv_mesh; + MEdge *subdiv_medge = subdiv_mesh->medge; + MEdge *subdiv_edge = &subdiv_medge[start_edge_index]; + const int start_poly_vertex_index = ptex_face_index * resolution2; + /* Consider a subdivision of base face at level 1: + * + * y + * ^ + * | (6) ---- (7) ---- (8) + * | | | | + * | (3) ---- (4) ---- (5) + * | | | | + * | (0) ---- (1) ---- (2) + * o---------------------------> x + * + * This is illustrate which parts of geometry is created by code below. + */ + for (int i = 0; i < num_poly_ptex_faces; i++) { + const int start_ptex_face_vertex_index = + start_poly_vertex_index + i * resolution2; + EdgesOfPtex edges_of_ptex; + edges_of_ptex_get(ctx, &edges_of_ptex, coarse_poly, i); + /* Create bottom row of edges (0-1, 1-2). */ + subdiv_edge = subdiv_create_edges_row(ctx, + subdiv_edge, + edges_of_ptex.first_edge, + start_ptex_face_vertex_index, + resolution); + /* Create remaining edges. */ + for (int row = 0; row < resolution - 1; row++) { + const int start_row_vertex_index = + start_ptex_face_vertex_index + row * resolution; + /* Create vertical columns. + * + * At first iteration it will be edges (0-3. 1-4, 2-5), then it + * will be (3-6, 4-7, 5-8) and so on. + */ + subdiv_edge = subdiv_create_edges_column( + ctx, + subdiv_edge, + edges_of_ptex.last_edge, + edges_of_ptex.second_edge, + start_row_vertex_index, + resolution); + /* Create horizontal edge row. + * + * At first iteration it will be edges (3-4, 4-5), then it will be + * (6-7, 7-8) and so on. + */ + subdiv_edge = subdiv_create_edges_row( + ctx, + subdiv_edge, + (row == resolution - 2) ? edges_of_ptex.third_edge + : NULL, + start_row_vertex_index + resolution, + resolution); + } + } +} + +static void subdiv_copy_loop_data( + const SubdivMeshContext *ctx, + MLoop *subdiv_loop, + const LoopsForInterpolation *loop_interpolation, + const float u, const float v) +{ + const int subdiv_loop_index = subdiv_loop - ctx->subdiv_mesh->mloop; + const float weights[4] = {(1.0f - u) * (1.0f - v), + u * (1.0f - v), + u * v, + (1.0f - u) * v}; + CustomData_interp(loop_interpolation->loop_data, + &ctx->subdiv_mesh->ldata, + loop_interpolation->loop_indices, + weights, NULL, + 4, + subdiv_loop_index); + /* TODO(sergey): Set ORIGINDEX. */ +} + +static void subdiv_eval_uv_layer(SubdivMeshContext *ctx, + MLoop *subdiv_loop, + const int ptex_face_index, + const float u, const float v, + const float inv_resolution_1) +{ + if (ctx->num_uv_layers == 0) { + return; + } + Subdiv *subdiv = ctx->subdiv; + const int mloop_index = subdiv_loop - ctx->subdiv_mesh->mloop; + const float du = inv_resolution_1; + const float dv = inv_resolution_1; + for (int layer_index = 0; layer_index < ctx->num_uv_layers; layer_index++) { + MLoopUV *subdiv_loopuv = &ctx->uv_layers[layer_index][mloop_index]; + BKE_subdiv_eval_face_varying(subdiv, + ptex_face_index, + u, v, + subdiv_loopuv[0].uv); + BKE_subdiv_eval_face_varying(subdiv, + ptex_face_index, + u + du, v, + subdiv_loopuv[1].uv); + BKE_subdiv_eval_face_varying(subdiv, + ptex_face_index, + u + du, v + dv, + subdiv_loopuv[2].uv); + BKE_subdiv_eval_face_varying(subdiv, + ptex_face_index, + u, v + dv, + subdiv_loopuv[3].uv); + /* TODO(sergey): Currently evaluator only has single UV layer, so can + * not evaluate more than that. Need to be solved. + */ + break; + } +} + +static void subdiv_create_loops(SubdivMeshContext *ctx, int poly_index) +{ + Subdiv *subdiv = ctx->subdiv; + const int resolution = ctx->settings->resolution; + const int resolution2 = resolution * resolution; + const float inv_resolution_1 = 1.0f / (float)(resolution - 1); + const int ptex_face_index = subdiv->face_ptex_offset[poly_index]; + const int num_edges_per_ptex = num_edges_per_ptex_get(resolution); + const int start_edge_index = ptex_face_index * num_edges_per_ptex; + const int num_polys_per_ptex = num_polys_per_ptex_get(resolution); + const int start_poly_index = ptex_face_index * num_polys_per_ptex; + const int start_loop_index = 4 * start_poly_index; + const int start_vert_index = ptex_face_index * resolution2; + const float du = inv_resolution_1; + const float dv = inv_resolution_1; + /* Base/coarse mesh information. */ + const Mesh *coarse_mesh = ctx->coarse_mesh; + const MPoly *coarse_polyoly = coarse_mesh->mpoly; + const MPoly *coarse_poly = &coarse_polyoly[poly_index]; + const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly); + /* Hi-poly subdivided mesh. */ + Mesh *subdiv_mesh = ctx->subdiv_mesh; + MLoop *subdiv_loopoop = subdiv_mesh->mloop; + MLoop *subdiv_loop = &subdiv_loopoop[start_loop_index]; + LoopsForInterpolation loop_interpolation; + loop_interpolation_init(ctx, &loop_interpolation, coarse_poly); + for (int ptex_of_poly_index = 0; + ptex_of_poly_index < num_poly_ptex_faces; + ptex_of_poly_index++) + { + loop_interpolation_from_ptex(ctx, + &loop_interpolation, + coarse_poly, + ptex_of_poly_index); + const int current_ptex_face_index = + ptex_face_index + ptex_of_poly_index; + for (int y = 0; y < resolution - 1; y++) { + const float v = y * inv_resolution_1; + for (int x = 0; x < resolution - 1; x++, subdiv_loop += 4) { + const float u = x * inv_resolution_1; + /* Vertex indicies ordered counter-clockwise. */ + const int v0 = start_vert_index + + (ptex_of_poly_index * resolution2) + + (y * resolution + x); + const int v1 = v0 + 1; + const int v2 = v0 + resolution + 1; + const int v3 = v0 + resolution; + /* Edge indicies ordered counter-clockwise. */ + const int e0 = start_edge_index + + (ptex_of_poly_index * num_edges_per_ptex) + + (y * (2 * resolution - 1) + x); + const int e1 = e0 + resolution; + const int e2 = e0 + (2 * resolution - 1); + const int e3 = e0 + resolution - 1; + /* Initialize 4 loops of corresponding hi-poly poly. */ + /* TODO(sergey): For ptex boundaries we should use loops from + * coarse mesh. + */ + subdiv_copy_loop_data(ctx, + &subdiv_loop[0], + &loop_interpolation, + u, v); + subdiv_loop[0].v = v0; + subdiv_loop[0].e = e0; + subdiv_copy_loop_data(ctx, + &subdiv_loop[1], + &loop_interpolation, + u + du, v); + subdiv_loop[1].v = v1; + subdiv_loop[1].e = e1; + subdiv_copy_loop_data(ctx, + &subdiv_loop[2], + &loop_interpolation, + u + du, v + dv); + subdiv_loop[2].v = v2; + subdiv_loop[2].e = e2; + subdiv_copy_loop_data(ctx, + &subdiv_loop[3], + &loop_interpolation, + u, v + dv); + subdiv_loop[3].v = v3; + subdiv_loop[3].e = e3; + /* Interpolate UV layers using OpenSubdiv. */ + subdiv_eval_uv_layer(ctx, + subdiv_loop, + current_ptex_face_index, + u, v, + inv_resolution_1); + } + } + } + loop_interpolation_end(&loop_interpolation); +} + +static void subdiv_copy_poly_data(const SubdivMeshContext *ctx, + MPoly *subdiv_poly, + const MPoly *coarse_poly) +{ + const int coarse_poly_index = coarse_poly - ctx->coarse_mesh->mpoly; + const int subdiv_poly_index = subdiv_poly - ctx->subdiv_mesh->mpoly; + CustomData_copy_data(&ctx->coarse_mesh->pdata, + &ctx->subdiv_mesh->pdata, + coarse_poly_index, + subdiv_poly_index, + 1); + if (ctx->poly_origindex != NULL) { + ctx->poly_origindex[subdiv_poly_index] = coarse_poly_index; + } +} + +static void subdiv_create_polys(SubdivMeshContext *ctx, int poly_index) +{ + Subdiv *subdiv = ctx->subdiv; + const int resolution = ctx->settings->resolution; + const int ptex_face_index = subdiv->face_ptex_offset[poly_index]; + const int num_polys_per_ptex = num_polys_per_ptex_get(resolution); + const int num_loops_per_ptex = 4 * num_polys_per_ptex; + const int start_poly_index = ptex_face_index * num_polys_per_ptex; + const int start_loop_index = 4 * start_poly_index; + /* Base/coarse mesh information. */ + const Mesh *coarse_mesh = ctx->coarse_mesh; + const MPoly *coarse_polyoly = coarse_mesh->mpoly; + const MPoly *coarse_poly = &coarse_polyoly[poly_index]; + const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly); + /* Hi-poly subdivided mesh. */ + Mesh *subdiv_mesh = ctx->subdiv_mesh; + MPoly *subdiv_mpoly = subdiv_mesh->mpoly; + MPoly *subdiv_mp = &subdiv_mpoly[start_poly_index]; + for (int ptex_of_poly_index = 0; + ptex_of_poly_index < num_poly_ptex_faces; + ptex_of_poly_index++) + { + for (int subdiv_poly_index = 0; + subdiv_poly_index < num_polys_per_ptex; + subdiv_poly_index++, subdiv_mp++) + { + subdiv_copy_poly_data(ctx, subdiv_mp, coarse_poly); + subdiv_mp->loopstart = start_loop_index + + (ptex_of_poly_index * num_loops_per_ptex) + + (subdiv_poly_index * 4); + subdiv_mp->totloop = 4; + } + } +} + +static void subdiv_eval_task( + void *__restrict userdata, + const int poly_index, + const ParallelRangeTLS *__restrict UNUSED(tls)) +{ + SubdivMeshContext *data = userdata; + /* Evaluate hi-poly vertex coordinates and normals. */ + subdiv_evaluate_vertices(data, poly_index); + /* Create mesh geometry for the given base poly index. */ + subdiv_create_edges(data, poly_index); + subdiv_create_loops(data, poly_index); + subdiv_create_polys(data, poly_index); +} + +static void cache_uv_layers(SubdivMeshContext *ctx) +{ + Mesh *subdiv_mesh = ctx->subdiv_mesh; + ctx->num_uv_layers = + CustomData_number_of_layers(&subdiv_mesh->ldata, CD_MLOOPUV); + for (int layer_index = 0; layer_index < ctx->num_uv_layers; ++layer_index) { + ctx->uv_layers[layer_index] = CustomData_get_layer_n( + &subdiv_mesh->ldata, CD_MLOOPUV, layer_index); + } +} + +static void cache_custom_data_layers(SubdivMeshContext *ctx) +{ + Mesh *subdiv_mesh = ctx->subdiv_mesh; + /* Pointers to original indices layers. */ + ctx->vert_origindex = CustomData_get_layer( + &subdiv_mesh->vdata, CD_ORIGINDEX); + ctx->edge_origindex = CustomData_get_layer( + &subdiv_mesh->edata, CD_ORIGINDEX); + ctx->loop_origindex = CustomData_get_layer( + &subdiv_mesh->ldata, CD_ORIGINDEX); + ctx->poly_origindex = CustomData_get_layer( + &subdiv_mesh->pdata, CD_ORIGINDEX); + /* UV layers interpolation. */ + cache_uv_layers(ctx); +} + +Mesh *BKE_subdiv_to_mesh( + Subdiv *subdiv, + const SubdivToMeshSettings *settings, + const Mesh *coarse_mesh) +{ + /* Make sure evaluator is up to date with possible new topology, and that + * is is refined for the new positions of coarse vertices. + */ + BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh); + const int resolution = settings->resolution; + const int resolution2 = resolution * resolution; + const int num_result_verts = subdiv->num_ptex_faces * resolution2; + const int num_result_edges = + subdiv->num_ptex_faces * num_edges_per_ptex_get(resolution); + const int num_result_polys = + subdiv->num_ptex_faces * num_polys_per_ptex_get(resolution); + const int num_result_loops = 4 * num_result_polys; + /* Create mesh and its arrays. */ + Mesh *result = BKE_mesh_new_nomain_from_template( + coarse_mesh, + num_result_verts, + num_result_edges, + 0, + num_result_loops, + num_result_polys); + /* Evaluate subdivisions of base faces in threads. */ + SubdivMeshContext ctx; + ctx.coarse_mesh = coarse_mesh; + ctx.subdiv = subdiv; + ctx.subdiv_mesh = result; + ctx.settings = settings; + cache_custom_data_layers(&ctx); + /* Multi-threaded evaluation. */ + ParallelRangeSettings parallel_range_settings; + BLI_parallel_range_settings_defaults(¶llel_range_settings); + BLI_task_parallel_range(0, coarse_mesh->totpoly, + &ctx, + subdiv_eval_task, + ¶llel_range_settings); + return result; +} -- cgit v1.2.3 From 5fd677c83c80aa33cac9f4fe47dc149e61b96f67 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 17 Jul 2018 18:09:18 +0200 Subject: Subsurf: Add subdivision code which uses new module The code is ifdef-ed for now, since there is more work needed to be done before we can officially switch to it. Uses new subdiv module. --- source/blender/blenkernel/CMakeLists.txt | 9 +++- source/blender/makesdna/DNA_modifier_types.h | 19 ++++--- source/blender/makesrna/intern/rna_modifier.c | 4 +- source/blender/modifiers/intern/MOD_subsurf.c | 75 ++++++++++++++++++++++++++- 4 files changed, 95 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 0578a3ecc69..0517eb8e732 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -186,6 +186,11 @@ set(SRC intern/sound.c intern/speaker.c intern/studiolight.c + intern/subdiv.c + intern/subdiv_converter.c + intern/subdiv_converter_mesh.c + intern/subdiv_eval.c + intern/subdiv_mesh.c intern/subsurf_ccg.c intern/suggestions.c intern/text.c @@ -306,6 +311,7 @@ set(SRC BKE_sound.h BKE_speaker.h BKE_studiolight.h + BKE_subdiv.h BKE_subsurf.h BKE_suggestions.h BKE_text.h @@ -323,8 +329,9 @@ set(SRC intern/CCGSubSurf.h intern/CCGSubSurf_inline.h intern/CCGSubSurf_intern.h - intern/pbvh_intern.h intern/data_transfer_intern.h + intern/pbvh_intern.h + intern/subdiv_converter.h ) if(WITH_BINRELOC) diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index ecece648ce1..803be15f03e 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -123,13 +123,6 @@ typedef enum { eModifierFlag_SharedCaches = (1 << 1), } ModifierFlag; -typedef enum { - eSubsurfModifierFlag_Incremental = (1 << 0), - eSubsurfModifierFlag_DebugIncr = (1 << 1), - eSubsurfModifierFlag_ControlEdges = (1 << 2), - eSubsurfModifierFlag_SubsurfUv = (1 << 3), -} SubsurfModifierFlag; - /* not a real modifier */ typedef struct MappingInfoModifierData { ModifierData modifier; @@ -141,6 +134,18 @@ typedef struct MappingInfoModifierData { int texmapping; } MappingInfoModifierData; +typedef enum { + eSubsurfModifierFlag_Incremental = (1 << 0), + eSubsurfModifierFlag_DebugIncr = (1 << 1), + eSubsurfModifierFlag_ControlEdges = (1 << 2), + eSubsurfModifierFlag_SubsurfUv = (1 << 3), +} SubsurfModifierFlag; + +typedef enum { + SUBSURF_TYPE_CATMULL_CLARK = 0, + SUBSURF_TYPE_SIMPLE = 1, +} eSubsurfModifierType; + typedef struct SubsurfModifierData { ModifierData modifier; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 57b12d6a3fd..d90a578d9f2 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1175,8 +1175,8 @@ static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr, co static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[]) { static const EnumPropertyItem prop_subdivision_type_items[] = { - {0, "CATMULL_CLARK", 0, "Catmull-Clark", ""}, - {1, "SIMPLE", 0, "Simple", ""}, + {SUBSURF_TYPE_CATMULL_CLARK, "CATMULL_CLARK", 0, "Catmull-Clark", ""}, + {SUBSURF_TYPE_SIMPLE, "SIMPLE", 0, "Simple", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index f532c168b04..c92845a24eb 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -35,8 +35,9 @@ #include -#include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_mesh_types.h" #ifdef WITH_OPENSUBDIV # include "DNA_userdef_types.h" @@ -44,9 +45,9 @@ #include "BLI_utildefines.h" - #include "BKE_cdderivedmesh.h" #include "BKE_scene.h" +#include "BKE_subdiv.h" #include "BKE_subsurf.h" #include "DEG_depsgraph.h" @@ -56,6 +57,8 @@ #include "intern/CCGSubSurf.h" +// #define USE_OPENSUBDIV + static void initData(ModifierData *md) { SubsurfModifierData *smd = (SubsurfModifierData *) md; @@ -181,9 +184,73 @@ static DerivedMesh *applyModifierEM( #endif result = subsurf_make_derived_from_derived(derivedData, smd, scene, NULL, ss_flags); + return result; +} + +#ifdef USE_OPENSUBDIV +static int subdiv_levels_for_modifier_get(const SubsurfModifierData *smd, + const ModifierEvalContext *ctx) +{ + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + const bool use_render_params = (ctx->flag & MOD_APPLY_RENDER); + const int requested_levels = (use_render_params) ? smd->renderLevels + : smd->levels; + return get_render_subsurf_level(&scene->r, + requested_levels, + use_render_params); +} + +static void subdiv_settings_init(SubdivSettings *settings, + const SubsurfModifierData *smd, + const ModifierEvalContext *ctx) +{ + settings->is_simple = (smd->subdivType == SUBSURF_TYPE_SIMPLE); + settings->is_adaptive = !settings->is_simple; + settings->level = subdiv_levels_for_modifier_get(smd, ctx); + settings->fvar_linear_interpolation = + (smd->flags & eSubsurfModifierFlag_SubsurfUv) + ? SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY + : SUBDIV_FVAR_LINEAR_INTERPOLATION_ALL; +} + +static void subdiv_mesh_settings_init(SubdivToMeshSettings *settings, + const SubdivSettings *subdiv_settings) +{ + settings->resolution = (1 << subdiv_settings->level) + 1; +} +static Mesh *applyModifier_subdiv(ModifierData *md, + const ModifierEvalContext *ctx, + Mesh *mesh) +{ + Mesh *result = mesh; + SubsurfModifierData *smd = (SubsurfModifierData *) md; + SubdivSettings subdiv_settings; + subdiv_settings_init(&subdiv_settings, smd, ctx); + if (subdiv_settings.level == 0) { + /* NOTE: Shouldn't really happen, is supposed to be catched by + * isDisabled() callback. + */ + return result; + } + /* TODO(sergey): Try to re-use subdiv when possible. */ + Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, mesh); + if (subdiv == NULL) { + /* Happens on bad topology. */ + /* TODO(sergey): This also happens on meshes without faces, so probably + * need to handle those differently (i.e. set modifier error when + * topology itself is bad, and not do anything when there are no faces). + */ + return result; + } + SubdivToMeshSettings mesh_settings; + subdiv_mesh_settings_init(&mesh_settings, &subdiv_settings); + result = BKE_subdiv_to_mesh(subdiv, &mesh_settings, mesh); + /* TODO(sergey): Cache subdiv somehow. */ + BKE_subdiv_free(subdiv); return result; } +#endif static bool dependsOnNormals(ModifierData *md) { @@ -222,7 +289,11 @@ ModifierTypeInfo modifierType_Subsurf = { /* deformMatrices */ NULL, /* deformVertsEM */ NULL, /* deformMatricesEM */ NULL, +#ifdef USE_OPENSUBDIV + /* applyModifier */ applyModifier_subdiv, +#else /* applyModifier */ NULL, +#endif /* applyModifierEM */ NULL, /* initData */ initData, -- cgit v1.2.3 From 2604f281b7bd74f396b2479fbdb97cbf9dc27689 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 18 Jul 2018 16:09:19 +0200 Subject: Cycles: Fix missing nested particle systems when instanced multiple times Was only visible when doing command line, since it was happening due to cache-free policy which was aimed to bring memory usage down. The issue is that if object with particle system is used as a nested duplicator multiple times, it will only generate children first time, and after that its caches are freed. After that duplication system can not generate any instances, since the path cache is lost. Now we delay caches free to after all objects are synchronized, which ensures all instances are generated. This will increase a memory peak a bit during object synchronization time, but overall it shouldn't be that bad, since memory footprint after synchronization will stay the same as before this change. The ultimate thing to do here would be to drop the whole dependency graph away, but this will require: - API on engine side, to inform it to drop the dependency graph. - Changes in Cycles report system to NOT use evaluated scene to get scene name (evaluated scene will be gone with dependency graph). --- intern/cycles/blender/blender_mesh.cpp | 12 ------------ intern/cycles/blender/blender_sync.cpp | 26 ++++++++++++++++++++++++++ intern/cycles/blender/blender_sync.h | 3 +++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index b7d6c1bb36d..08206dd5521 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -1077,14 +1077,6 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph, bool object_updated, bool hide_tris) { - /* When viewport display is not needed during render we can force some - * caches to be releases from blender side in order to reduce peak memory - * footprint during synchronization process. - */ - const bool is_interface_locked = b_engine.render() && - b_engine.render().use_lock_interface(); - const bool can_free_caches = BlenderSession::headless || is_interface_locked; - /* test if we can instance or if the object is modified */ BL::ID b_ob_data = b_ob.data(); BL::ID key = (BKE_object_is_modified(b_ob))? b_ob_instance: b_ob_data; @@ -1209,10 +1201,6 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph, if(view_layer.use_hair && mesh->subdivision_type == Mesh::SUBDIVISION_NONE) sync_curves(mesh, b_mesh, b_ob, false); - if(can_free_caches) { - b_ob.cache_release(); - } - /* free derived mesh */ b_data.meshes.remove(b_mesh, false, true, false); } diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index cbca623ece7..3204e0cd3f2 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -207,6 +207,8 @@ void BlenderSync::sync_data(BL::RenderSettings& b_render, python_thread_state); mesh_synced.clear(); + + free_data_after_sync(b_depsgraph); } /* Integrator */ @@ -566,6 +568,30 @@ array BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay, return passes; } +void BlenderSync::free_data_after_sync(BL::Depsgraph& b_depsgraph) +{ + /* When viewport display is not needed during render we can force some + * caches to be releases from blender side in order to reduce peak memory + * footprint during synchronization process. + */ + const bool is_interface_locked = b_engine.render() && + b_engine.render().use_lock_interface(); + const bool can_free_caches = BlenderSession::headless || is_interface_locked; + if (!can_free_caches) { + return; + } + /* TODO(sergey): We can actually remove the whole dependency graph, + * but that will need some API support first. + */ + BL::Depsgraph::objects_iterator b_ob; + for(b_depsgraph.objects.begin(b_ob); + b_ob != b_depsgraph.objects.end(); + ++b_ob) + { + b_ob->cache_release(); + } +} + /* Scene Parameters */ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene, diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index cd1a37d3f13..0465f703c51 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -157,6 +157,9 @@ private: /* Images. */ void sync_images(); + /* Early data free. */ + void free_data_after_sync(BL::Depsgraph& b_depsgraph); + /* util */ void find_shader(BL::ID& id, vector& used_shaders, Shader *default_shader); bool BKE_object_is_modified(BL::Object& b_ob); -- cgit v1.2.3 From 9d514a4e6f12563426a94a682f70f3f51435c9fa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 18 Jul 2018 18:11:59 +0200 Subject: Cleanup: remove debug comment. --- source/blender/draw/engines/workbench/workbench_deferred.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index cf53004e126..ce209af8527 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -842,7 +842,6 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) WORKBENCH_PrivateData *wpd = stl->g_data; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - /* TODO. */ if (TAA_ENABLED(wpd)) { workbench_taa_draw_scene_start(vedata); } @@ -886,7 +885,6 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) DRW_draw_pass(psl->volume_pass); } - /* TODO */ workbench_aa_draw_pass(vedata, e_data.composite_buffer_tx); } -- cgit v1.2.3 From 057b4a6acf974e7729cd3548e32e3441986c795f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 18 Jul 2018 18:45:36 +0200 Subject: Fix/workaround T56019: memory leak with preview renders. I would not expect the order of registration to matter, and ideally we want to order the engines in the UI menu differently, but this helps for now. --- source/blender/draw/intern/draw_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 92603a0ce53..2793410cd8e 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2240,8 +2240,8 @@ void DRW_engine_register(DrawEngineType *draw_engine_type) void DRW_engines_register(void) { - RE_engines_register(&DRW_engine_viewport_opengl_type); RE_engines_register(&DRW_engine_viewport_eevee_type); + RE_engines_register(&DRW_engine_viewport_opengl_type); DRW_engine_register(&draw_engine_workbench_solid); DRW_engine_register(&draw_engine_workbench_transparent); -- cgit v1.2.3 From c05a8460a6493429a8bd08973eec4615ed0c066f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 18 Jul 2018 19:09:05 +0200 Subject: Icon/Render Preview: Fix Race condition with BKE_*_localize When editing a Material the depsgraph can throw away the evaluated ID before the preview job localized the said ID. To fix this we localize the ID from the main thread. Also fix WM_OT_previews_ensure crashing because of no depsgraph. --- source/blender/editors/render/render_preview.c | 86 +++++++++++++++++++++----- 1 file changed, 72 insertions(+), 14 deletions(-) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 04632838cf3..6ced3f2e430 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -158,7 +158,7 @@ typedef struct ShaderPreview { Scene *scene; Depsgraph *depsgraph; - ID *id; + ID *id, *id_copy; ID *parent; MTex *slot; @@ -189,7 +189,7 @@ typedef struct IconPreview { Scene *scene; Depsgraph *depsgraph; void *owner; - ID *id; + ID *id, *id_copy; ListBase sizes; } IconPreview; @@ -312,6 +312,29 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world) return sp->worldcopy; } +static ID *duplicate_ids(ID *id, Depsgraph *depsgraph) +{ + ID *id_eval = id; + + if (depsgraph) { + id_eval = DEG_get_evaluated_id(depsgraph, id); + } + + switch (GS(id->name)) { + case ID_MA: + return (ID *)BKE_material_localize((Material *)id_eval); + case ID_TE: + return (ID *)BKE_texture_localize((Tex *)id_eval); + case ID_LA: + return (ID *)BKE_lamp_localize((Lamp *)id_eval); + case ID_WO: + return (ID *)BKE_world_localize((World *)id_eval); + default: + BLI_assert(!"ID type preview not supported."); + return NULL; + } +} + /* call this with a pointer to initialize preview scene */ /* call this with NULL to restore assigned ID pointers in preview scene */ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_type, ShaderPreview *sp) @@ -373,8 +396,9 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty if (origmat) { /* work on a copy */ - mat = BKE_material_localize(origmat); - sp->matcopy = mat; + BLI_assert(sp->id_copy != NULL); + mat = sp->matcopy = (Material *)sp->id_copy; + sp->id_copy = NULL; BLI_addtail(&pr_main->mat, mat); /* use current scene world to light sphere */ @@ -400,13 +424,13 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty if (mat->nodetree && sp->pr_method == PR_NODE_RENDER) { /* two previews, they get copied by wmJob */ BKE_node_preview_init_tree(mat->nodetree, sp->sizex, sp->sizey, true); + /* WATCH: Accessing origmat is not safe! */ BKE_node_preview_init_tree(origmat->nodetree, sp->sizex, sp->sizey, true); } } } else { sce->r.mode &= ~(R_OSA); - } for (Base *base = view_layer->object_bases.first; base; base = base->next) { @@ -432,16 +456,18 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty Tex *tex = NULL, *origtex = (Tex *)id; if (origtex) { - tex = BKE_texture_localize(origtex); - sp->texcopy = tex; + BLI_assert(sp->id_copy != NULL); + tex = sp->texcopy = (Tex *)sp->id_copy; + sp->id_copy = NULL; BLI_addtail(&pr_main->tex, tex); } set_preview_collection(sce, view_layer, MA_TEXTURE); if (tex && tex->nodetree && sp->pr_method == PR_NODE_RENDER) { /* two previews, they get copied by wmJob */ - BKE_node_preview_init_tree(origtex->nodetree, sp->sizex, sp->sizey, true); BKE_node_preview_init_tree(tex->nodetree, sp->sizex, sp->sizey, true); + /* WATCH: Accessing origtex is not safe! */ + BKE_node_preview_init_tree(origtex->nodetree, sp->sizex, sp->sizey, true); } } else if (id_type == ID_LA) { @@ -449,8 +475,9 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty /* work on a copy */ if (origla) { - la = BKE_lamp_localize(origla); - sp->lampcopy = la; + BLI_assert(sp->id_copy != NULL); + la = sp->lampcopy = (Lamp *)sp->id_copy; + sp->id_copy = NULL; BLI_addtail(&pr_main->lamp, la); } @@ -473,16 +500,18 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty if (la && la->nodetree && sp->pr_method == PR_NODE_RENDER) { /* two previews, they get copied by wmJob */ - BKE_node_preview_init_tree(origla->nodetree, sp->sizex, sp->sizey, true); BKE_node_preview_init_tree(la->nodetree, sp->sizex, sp->sizey, true); + /* WATCH: Accessing origla is not safe! */ + BKE_node_preview_init_tree(origla->nodetree, sp->sizex, sp->sizey, true); } } else if (id_type == ID_WO) { World *wrld = NULL, *origwrld = (World *)id; if (origwrld) { - wrld = BKE_world_localize(origwrld); - sp->worldcopy = wrld; + BLI_assert(sp->id_copy != NULL); + wrld = sp->worldcopy = (World *)sp->id_copy; + sp->id_copy = NULL; BLI_addtail(&pr_main->world, wrld); } @@ -492,6 +521,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty if (wrld && wrld->nodetree && sp->pr_method == PR_NODE_RENDER) { /* two previews, they get copied by wmJob */ BKE_node_preview_init_tree(wrld->nodetree, sp->sizex, sp->sizey, true); + /* WATCH: Accessing origwrld is not safe! */ BKE_node_preview_init_tree(origwrld->nodetree, sp->sizex, sp->sizey, true); } } @@ -685,7 +715,11 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs char name[32]; int sizex; Main *pr_main = sp->pr_main; - ID *id_eval = DEG_get_evaluated_id(sp->depsgraph, id); + ID *id_eval = id; + + if (sp->depsgraph) { + id_eval = DEG_get_evaluated_id(sp->depsgraph, id); + } /* in case of split preview, use border render */ if (split) { @@ -794,6 +828,26 @@ static void shader_preview_free(void *customdata) ShaderPreview *sp = customdata; Main *pr_main = sp->pr_main; + if (sp->id_copy){ + switch (GS(sp->id_copy->name)) { + case ID_MA: + BKE_material_free((Material *)sp->id_copy); + break; + case ID_TE: + BKE_texture_free((Tex *)sp->id_copy); + break; + case ID_LA: + BKE_lamp_free((Lamp *)sp->id_copy); + break; + case ID_WO: + BKE_world_free((World *)sp->id_copy); + break; + default: + BLI_assert(!"ID type preview not supported."); + break; + } + MEM_freeN(sp->id_copy); + } if (sp->matcopy) { struct IDProperty *properties; @@ -1074,6 +1128,7 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short sp->pr_method = is_render ? PR_ICON_RENDER : PR_ICON_DEFERRED; sp->pr_rect = cur_size->rect; sp->id = ip->id; + sp->id_copy = ip->id_copy; sp->bmain = ip->bmain; if (is_render) { @@ -1149,6 +1204,7 @@ void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, unsigned int *rec ip.scene = scene; ip.owner = BKE_previewimg_id_ensure(id); ip.id = id; + ip.id_copy = duplicate_ids(id, NULL); icon_preview_add_size(&ip, rect, sizex, sizey); @@ -1183,6 +1239,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r ip->depsgraph = CTX_data_depsgraph(C); ip->owner = owner; ip->id = id; + ip->id_copy = duplicate_ids(id, ip->depsgraph); icon_preview_add_size(ip, rect, sizex, sizey); @@ -1231,6 +1288,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M sp->sizey = sizey; sp->pr_method = method; sp->id = id; + sp->id_copy = duplicate_ids(id, sp->depsgraph); sp->parent = parent; sp->slot = slot; sp->bmain = CTX_data_main(C); -- cgit v1.2.3 From e81dc0b7bc1c9373b5b4029c32b1d066429e5db8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 18 Jul 2018 22:23:29 +0200 Subject: Fix E key in Python console not working after recent changes. --- source/blender/editors/interface/interface_eyedropper_color.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index bcb60013eda..5eb4359607a 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -297,7 +297,7 @@ static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( } else { eyedropper_exit(C, op); - return OPERATOR_CANCELLED; + return OPERATOR_PASS_THROUGH; } } @@ -315,7 +315,7 @@ static int eyedropper_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } else { - return OPERATOR_CANCELLED; + return OPERATOR_PASS_THROUGH; } } -- cgit v1.2.3 From 20191980f49dd8d348c1065461060963b15ea64b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 18 Jul 2018 22:58:52 +0200 Subject: Cycles: increase volume stack to support 32 overlapping volumes. This increases stack memory usage some, and ideally we'd support a dynamic size. But this is quite difficult on the GPU and hopefully 32 is enough even for very complex cases. --- intern/cycles/kernel/kernel_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 69ee66b3dd5..85548484873 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -54,7 +54,7 @@ CCL_NAMESPACE_BEGIN #define PRIM_NONE (~0) #define LAMP_NONE (~0) -#define VOLUME_STACK_SIZE 16 +#define VOLUME_STACK_SIZE 32 /* Split kernel constants */ #define WORK_POOL_SIZE_GPU 64 -- cgit v1.2.3 From 51f14cfa43e5fe4bdea6fbd5c668a44919657f99 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Wed, 18 Jul 2018 20:00:34 -0600 Subject: make.bat : restore msvc2015 support. broke when i removed the 2013 support. --- build_files/windows/detect_msvc_classic.cmd | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 build_files/windows/detect_msvc_classic.cmd diff --git a/build_files/windows/detect_msvc_classic.cmd b/build_files/windows/detect_msvc_classic.cmd new file mode 100644 index 00000000000..61bfcf92ddf --- /dev/null +++ b/build_files/windows/detect_msvc_classic.cmd @@ -0,0 +1,69 @@ +if NOT "%verbose%" == "" ( + echo Detecting msvc %BUILD_VS_YEAR% +) +set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC" +for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v ProductDir 2^>nul`) DO set MSVC_VC_DIR=%%C +if DEFINED MSVC_VC_DIR ( + if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% on Win64 detected at "%MSVC_VC_DIR%" + ) + goto msvc_detect_finally +) + +REM Check 32 bits +set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC" +for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v ProductDir 2^>nul`) DO set MSVC_VC_DIR=%%C +if DEFINED MSVC_VC_DIR ( + if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% on Win32 detected at "%MSVC_VC_DIR%" + ) + goto msvc_detect_finally +) +if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% not found. +) +goto FAIL +:msvc_detect_finally +set VCVARS=%MSVC_VC_DIR%\vcvarsall.bat +if not exist "%VCVARS%" ( + echo "%VCVARS%" not found. + goto FAIL +) + +call "%vcvars%" %BUILD_ARCH% + +rem try msbuild +msbuild /version > NUL +if errorlevel 1 ( + if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% msbuild not found + ) + goto FAIL +) + +if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% msbuild found +) + +REM try the c++ compiler +cl 2> NUL 1>&2 +if errorlevel 1 ( + if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler not found + ) + goto FAIL +) + +if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler found +) +goto DetectionComplete + +:FAIL +exit /b 1 + +:DetectionComplete +if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% Detected successfuly +) +exit /b 0 -- cgit v1.2.3 From 9df1e54079344ed4e2becef9e57cf1b925b46dff Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 19 Jul 2018 16:06:37 +1000 Subject: Cleanup: style --- release/scripts/modules/rna_prop_ui.py | 2 +- release/scripts/startup/bl_operators/wm.py | 6 +-- .../startup/bl_ui/properties_physics_common.py | 6 +-- release/scripts/startup/bl_ui/properties_scene.py | 6 +-- .../blender/blenkernel/intern/subdiv_converter.h | 6 +-- source/blender/blenkernel/intern/subdiv_mesh.c | 32 ++++++------ source/blender/blenlib/intern/hash_mm3.c | 18 +++---- .../compositor/nodes/COM_CryptomatteNode.cpp | 10 ++-- .../operations/COM_CryptomatteOperation.cpp | 2 +- source/blender/depsgraph/DEG_depsgraph.h | 6 +-- .../depsgraph/intern/builder/deg_builder_map.cc | 15 ++++-- .../depsgraph/intern/builder/deg_builder_nodes.h | 2 +- .../draw/engines/workbench/workbench_data.c | 4 +- .../draw/engines/workbench/workbench_volume.c | 2 +- source/blender/draw/intern/draw_cache.c | 2 +- source/blender/editors/render/render_preview.c | 2 +- source/blender/gpu/GPU_common.h | 8 +-- source/blender/gpu/intern/gpu_attr_binding.c | 2 +- .../blender/gpu/intern/gpu_attr_binding_private.h | 8 +-- source/blender/gpu/intern/gpu_batch_private.h | 6 +-- source/blender/gpu/intern/gpu_buffer_id.cpp | 2 +- source/blender/gpu/intern/gpu_immediate.c | 12 ++--- source/blender/gpu/intern/gpu_immediate_util.c | 2 +- source/blender/gpu/intern/gpu_shader_interface.c | 2 +- source/blender/gpu/intern/gpu_vertex_array_id.cpp | 26 +++++----- source/blender/gpu/intern/gpu_vertex_format.c | 2 +- .../blender/gpu/intern/gpu_vertex_format_private.h | 4 +- source/blender/makesrna/intern/rna_nodetree.c | 5 +- .../composite/nodes/node_composite_cryptomatte.c | 58 +++++++++++----------- .../nodes/node_shader_bsdf_hair_principled.c | 2 +- source/blender/python/gpu/gpu_py_types.c | 2 - 31 files changed, 136 insertions(+), 126 deletions(-) diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 8453077be85..0d17c11456e 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -170,7 +170,7 @@ def draw(layout, context, context_member, property_type, use_edit=True): else: row = box.row(align=True) - row.alignment = "RIGHT" + row.alignment = 'RIGHT' row.label(text=key, translate=False) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 3f0cdfa606b..0ccdd3cf5c6 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -2440,9 +2440,9 @@ class WM_OT_studiolight_install(Operator): ) orientation: EnumProperty( items=( - ("MATCAP", "MatCap", ""), - ("WORLD", "World", ""), - ("CAMERA", "Camera", ""), + ('MATCAP', "MatCap", ""), + ('WORLD', "World", ""), + ('CAMERA', "Camera", ""), ) ) diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index bed5617c76c..2da84ad84da 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -132,7 +132,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): cache_info = cache.info if cache_info: col = layout.column() - col.alignment = "RIGHT" + col.alignment = 'RIGHT' col.label(text=cache_info) else: if cachetype in {'SMOKE', 'DYNAMIC_PAINT'}: @@ -156,7 +156,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): cache_info = cache.info if cachetype != 'SMOKE' and cache_info: # avoid empty space. col = layout.column(align=True) - col.alignment = "RIGHT" + col.alignment = 'RIGHT' col.label(text=cache_info) can_bake = True @@ -186,7 +186,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): can_bake = False col = layout.column(align=True) - col.alignment = "RIGHT" + col.alignment = 'RIGHT' col.separator() diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 1b21ac8fcdf..38bfc6ad294 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -215,7 +215,7 @@ class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Pane flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) col = flow.column(align=True) - col.alignment = "RIGHT" + col.alignment = 'RIGHT' col.label(text="General Override") self.draw_keyframing_settings(context, col, ks, None) @@ -225,7 +225,7 @@ class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Pane col.separator() col = flow.column(align=True) - col.alignment = "RIGHT" + col.alignment = 'RIGHT' col.label(text="Active Set Override") self.draw_keyframing_settings(context, col, ks, ksp) @@ -272,7 +272,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel): ksp = ks.paths.active if ksp: col = flow.column(align=True) - col.alignment = "RIGHT" + col.alignment = 'RIGHT' col.template_any_ID(ksp, "id", "id_type", text="Target ID-Block") diff --git a/source/blender/blenkernel/intern/subdiv_converter.h b/source/blender/blenkernel/intern/subdiv_converter.h index 748d97f4178..4c552a9164e 100644 --- a/source/blender/blenkernel/intern/subdiv_converter.h +++ b/source/blender/blenkernel/intern/subdiv_converter.h @@ -23,8 +23,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef __BKE_SUBDIV_CONVERTER_H__ -#define __BKE_SUBDIV_CONVERTER_H__ +#ifndef __SUBDIV_CONVERTER_H__ +#define __SUBDIV_CONVERTER_H__ #include "BKE_subdiv.h" @@ -54,4 +54,4 @@ void BKE_subdiv_converter_free(struct OpenSubdiv_Converter *converter); int BKE_subdiv_converter_fvar_linear_from_settings( const SubdivSettings *settings); -#endif /* __BKE_SUBDIV_CONVERTER_H__ */ +#endif /* __SUBDIV_CONVERTER_H__ */ diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index 8a58605ba19..c2a10483e26 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -152,7 +152,7 @@ static void edges_of_ptex_get( typedef struct VerticesForInterpolation { /* This field points to a vertex data which is to be used for interpolation. * The idea is to avoid unnecessary allocations for regular faces, where - * we can simply + * we can simply */ const CustomData *vertex_data; /* Vertices data calculated for ptex corners. There are always 4 elements @@ -176,7 +176,7 @@ typedef struct VerticesForInterpolation { static void vertex_interpolation_init( const SubdivMeshContext *ctx, VerticesForInterpolation *vertex_interpolation, - const MPoly *coarse_poly) + const MPoly *coarse_poly) { const Mesh *coarse_mesh = ctx->coarse_mesh; const MLoop *coarse_mloop = coarse_mesh->mloop; @@ -234,7 +234,8 @@ static void vertex_interpolation_from_ptex( { if (coarse_poly->totloop == 4) { /* Nothing to do, all indices and data is already assigned. */ - } else { + } + else { const CustomData *vertex_data = &ctx->coarse_mesh->vdata; const Mesh *coarse_mesh = ctx->coarse_mesh; const MLoop *coarse_mloop = coarse_mesh->mloop; @@ -287,7 +288,7 @@ static void vertex_interpolation_end( typedef struct LoopsForInterpolation { /* This field points to a loop data which is to be used for interpolation. * The idea is to avoid unnecessary allocations for regular faces, where - * we can simply + * we can simply */ const CustomData *loop_data; /* Loops data calculated for ptex corners. There are always 4 elements @@ -311,7 +312,7 @@ typedef struct LoopsForInterpolation { static void loop_interpolation_init( const SubdivMeshContext *ctx, LoopsForInterpolation *loop_interpolation, - const MPoly *coarse_poly) + const MPoly *coarse_poly) { const Mesh *coarse_mesh = ctx->coarse_mesh; if (coarse_poly->totloop == 4) { @@ -363,7 +364,8 @@ static void loop_interpolation_from_ptex( { if (coarse_poly->totloop == 4) { /* Nothing to do, all indices and data is already assigned. */ - } else { + } + else { const CustomData *loop_data = &ctx->coarse_mesh->ldata; const Mesh *coarse_mesh = ctx->coarse_mesh; const MLoop *coarse_mloop = coarse_mesh->mloop; @@ -481,9 +483,10 @@ static void subdiv_evaluate_vertices(SubdivMeshContext *ctx, vertex_interpolation_end(&vertex_interpolation); } -static void subdiv_copy_edge_data(SubdivMeshContext *ctx, - MEdge *subdiv_edge, - const MEdge *coarse_edge) +static void subdiv_copy_edge_data( + SubdivMeshContext *ctx, + MEdge *subdiv_edge, + const MEdge *coarse_edge) { if (coarse_edge == NULL) { subdiv_edge->crease = 0; @@ -586,11 +589,12 @@ static void subdiv_create_edges(SubdivMeshContext *ctx, int poly_index) EdgesOfPtex edges_of_ptex; edges_of_ptex_get(ctx, &edges_of_ptex, coarse_poly, i); /* Create bottom row of edges (0-1, 1-2). */ - subdiv_edge = subdiv_create_edges_row(ctx, - subdiv_edge, - edges_of_ptex.first_edge, - start_ptex_face_vertex_index, - resolution); + subdiv_edge = subdiv_create_edges_row( + ctx, + subdiv_edge, + edges_of_ptex.first_edge, + start_ptex_face_vertex_index, + resolution); /* Create remaining edges. */ for (int row = 0; row < resolution - 1; row++) { const int start_row_vertex_index = diff --git a/source/blender/blenlib/intern/hash_mm3.c b/source/blender/blenlib/intern/hash_mm3.c index 5ead9ceca63..105c1f46832 100644 --- a/source/blender/blenlib/intern/hash_mm3.c +++ b/source/blender/blenlib/intern/hash_mm3.c @@ -92,7 +92,7 @@ BLI_INLINE uint64_t fmix64(uint64_t k) uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed) { - const uint8_t *data = (const uint8_t*)in; + const uint8_t *data = (const uint8_t *)in; const int nblocks = len / 4; uint32_t h1 = seed; @@ -102,23 +102,23 @@ uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed) /* body */ - const uint32_t *blocks = (const uint32_t *)(data + nblocks*4); + const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4); for (int i = -nblocks; i; i++) { - uint32_t k1 = getblock32(blocks,i); + uint32_t k1 = getblock32(blocks, i); k1 *= c1; - k1 = ROTL32(k1,15); + k1 = ROTL32(k1, 15); k1 *= c2; h1 ^= k1; - h1 = ROTL32(h1,13); - h1 = h1*5+0xe6546b64; + h1 = ROTL32(h1, 13); + h1 = h1 * 5 + 0xe6546b64; } /* tail */ - const uint8_t *tail = (const uint8_t*)(data + nblocks*4); + const uint8_t *tail = (const uint8_t *)(data + nblocks * 4); uint32_t k1 = 0; @@ -132,10 +132,10 @@ uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed) case 1: k1 ^= tail[0]; k1 *= c1; - k1 = ROTL32(k1,15); + k1 = ROTL32(k1, 15); k1 *= c2; h1 ^= k1; - }; + } /* finalization */ diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp index bc115e66c20..648ea4556ad 100644 --- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp +++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp @@ -62,7 +62,7 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos bNode *node = this->getbNode(); NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage; - CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets()-1); + CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1); if (cryptoMatteSettings) { if (cryptoMatteSettings->matte_id) { /* Split the string by commas, ignoring white space. */ @@ -83,7 +83,7 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos operation->addObjectIndex(atof(token.substr(1, token.length() - 2).c_str())); } else { - uint32_t hash = BLI_hash_mm3((const unsigned char*)token.c_str(), token.length(), 0); + uint32_t hash = BLI_hash_mm3((const unsigned char *)token.c_str(), token.length(), 0); operation->addObjectIndex(hash_to_float(hash)); } } @@ -93,14 +93,14 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos converter.addOperation(operation); - for (int i = 0; i < getNumberOfInputSockets()-1; ++i) { + for (int i = 0; i < getNumberOfInputSockets() - 1; ++i) { converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i)); } SeparateChannelOperation *separateOperation = new SeparateChannelOperation; separateOperation->setChannel(3); converter.addOperation(separateOperation); - + SetAlphaOperation *operationAlpha = new SetAlphaOperation(); converter.addOperation(operationAlpha); @@ -117,5 +117,5 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0)); converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0)); converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0)); - + } diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp index 9dd36863d37..f3fa81075c6 100644 --- a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp +++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp @@ -63,7 +63,7 @@ void CryptomatteOperation::executePixel(float output[4], output[1] = ((float) ((m3hash << 8)) / (float) UINT32_MAX); output[2] = ((float) ((m3hash << 16)) / (float) UINT32_MAX); } - for(size_t i = 0; i < m_objectIndex.size(); i++) { + for (size_t i = 0; i < m_objectIndex.size(); i++) { if (m_objectIndex[i] == input[0]) { output[3] += input[1]; } diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index 71376d94ca8..2e566752a6f 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -269,9 +269,9 @@ void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph, const void *parent_address); void DEG_debug_print_eval_time(struct Depsgraph *depsgraph, - const char* function_name, - const char* object_name, - const void* object_address, + const char *function_name, + const char *object_name, + const void *object_address, float time); #ifdef __cplusplus diff --git a/source/blender/depsgraph/intern/builder/deg_builder_map.cc b/source/blender/depsgraph/intern/builder/deg_builder_map.cc index 218483d1dc5..cde7b9721b7 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_map.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_map.cc @@ -37,24 +37,29 @@ namespace DEG { -BuilderMap::BuilderMap() { +BuilderMap::BuilderMap() +{ set = BLI_gset_ptr_new("deg builder gset"); } -BuilderMap::~BuilderMap() { +BuilderMap::~BuilderMap() +{ BLI_gset_free(set, NULL); } -bool BuilderMap::checkIsBuilt(ID *id) { +bool BuilderMap::checkIsBuilt(ID *id) +{ return BLI_gset_haskey(set, id); } -void BuilderMap::tagBuild(ID *id) { +void BuilderMap::tagBuild(ID *id) +{ BLI_gset_insert(set, id); } -bool BuilderMap::checkIsBuiltAndTag(ID *id) { +bool BuilderMap::checkIsBuiltAndTag(ID *id) +{ void **key_p; if (!BLI_gset_ensure_p_ex(set, id, &key_p)) { *key_p = id; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 6899a86b3e9..66293a91e85 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -158,7 +158,7 @@ struct DepsgraphNodeBuilder { const char *name = "", int name_tag = -1); - void build_id(ID* id); + void build_id(ID *id); void build_layer_collections(ListBase *lb); void build_view_layer(Scene *scene, ViewLayer *view_layer, diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index 07df067f324..5c3ab5f6688 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -33,11 +33,11 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) if (wpd->shading.light == V3D_LIGHTING_MATCAP) { wpd->studio_light = BKE_studiolight_find( - wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL); + wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL); } else { wpd->studio_light = BKE_studiolight_find( - wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD); + wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD); } wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity; diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index f28bfd01ae8..ea4152486af 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -19,7 +19,7 @@ * */ -/** \file workbench_volumed.c +/** \file workbench_volume.c * \ingroup draw_engine */ diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index bb73a8c1b19..dff863b11bb 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -901,7 +901,7 @@ GPUBatch *DRW_cache_empty_capsule_cap_get(void) float v[3] = {0.0f, 0.0f, 0.0f}; copy_v2_v2(v, p[(i) % NSEGMENTS]); GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); - copy_v2_v2(v, p[(i+1) % NSEGMENTS]); + copy_v2_v2(v, p[(i + 1) % NSEGMENTS]); GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 6ced3f2e430..450897382dd 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -828,7 +828,7 @@ static void shader_preview_free(void *customdata) ShaderPreview *sp = customdata; Main *pr_main = sp->pr_main; - if (sp->id_copy){ + if (sp->id_copy) { switch (GS(sp->id_copy->name)) { case ID_MA: BKE_material_free((Material *)sp->id_copy); diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h index 7d86a6ec8a5..3acc7fad5c2 100644 --- a/source/blender/gpu/GPU_common.h +++ b/source/blender/gpu/GPU_common.h @@ -33,14 +33,14 @@ #define PROGRAM_NO_OPTI 0 #if defined(NDEBUG) - #define TRUST_NO_ONE 0 +# define TRUST_NO_ONE 0 #else /* strict error checking, enabled for debug builds during early development */ - #define TRUST_NO_ONE 1 +# define TRUST_NO_ONE 1 #endif #if defined(WITH_OPENGL) - #include +# include #endif #include @@ -48,7 +48,7 @@ #include "BLI_sys_types.h" #if TRUST_NO_ONE - #include +# include #endif /* GPU_INLINE */ diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c index e66fac390f1..398b97c7f9d 100644 --- a/source/blender/gpu/intern/gpu_attr_binding.c +++ b/source/blender/gpu/intern/gpu_attr_binding.c @@ -35,7 +35,7 @@ #include #if GPU_VERT_ATTR_MAX_LEN != 16 - #error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16" +# error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16" #endif void AttribBinding_clear(GPUAttrBinding *binding) diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h index 240509de0d4..cb338b10aa4 100644 --- a/source/blender/gpu/intern/gpu_attr_binding_private.h +++ b/source/blender/gpu/intern/gpu_attr_binding_private.h @@ -35,9 +35,11 @@ #include "GPU_vertex_format.h" #include "GPU_shader_interface.h" -void AttribBinding_clear(GPUAttrBinding*); +void AttribBinding_clear(GPUAttrBinding *binding); -void get_attrib_locations(const GPUVertFormat*, GPUAttrBinding*, const GPUShaderInterface*); -unsigned read_attrib_location(const GPUAttrBinding*, unsigned a_idx); +void get_attrib_locations( + const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface); +unsigned read_attrib_location( + const GPUAttrBinding *binding, unsigned a_idx); #endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch_private.h b/source/blender/gpu/intern/gpu_batch_private.h index 0b25c0aef05..51040ff751a 100644 --- a/source/blender/gpu/intern/gpu_batch_private.h +++ b/source/blender/gpu/intern/gpu_batch_private.h @@ -41,10 +41,10 @@ extern "C" { #include "GPU_context.h" #include "GPU_shader_interface.h" -void gpu_batch_remove_interface_ref(GPUBatch*, const GPUShaderInterface*); +void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface); -void gpu_context_add_batch(GPUContext*, GPUBatch*); -void gpu_context_remove_batch(GPUContext*, GPUBatch*); +void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch); +void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch); #ifdef __cplusplus } diff --git a/source/blender/gpu/intern/gpu_buffer_id.cpp b/source/blender/gpu/intern/gpu_buffer_id.cpp index c1aaf1945aa..f3faba9c766 100644 --- a/source/blender/gpu/intern/gpu_buffer_id.cpp +++ b/source/blender/gpu/intern/gpu_buffer_id.cpp @@ -37,7 +37,7 @@ #define ORPHAN_DEBUG 0 #if ORPHAN_DEBUG - #include +# include #endif static std::vector orphaned_buffer_ids; diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index 06b487fbb25..66a467e339e 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -701,17 +701,17 @@ void immVertex2iv(uint attrib_id, const int data[2]) /* --- generic uniform functions --- */ #if 0 - #if TRUST_NO_ONE - #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform); - #else - #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); - #endif +# if TRUST_NO_ONE +# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform); +# else +# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); +# endif #else /* NOTE: It is possible to have uniform fully optimized out from the shader. * In this case we can't assert failure or allow NULL-pointer dereference. * TODO(sergey): How can we detect existing-but-optimized-out uniform but still * catch typos in uniform names passed to immUniform*() functions? */ - #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; +# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; #endif void immUniform1f(const char *name, float x) diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index cf594367bdf..8384ef3b5d0 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -18,7 +18,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gpu_imm_util.c +/** \file blender/gpu/intern/gpu_immediate_util.c * \ingroup gpu * * GPU immediate mode drawing utilities diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 7e1d942da2d..4b8413d0cc3 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -39,7 +39,7 @@ #define DEBUG_SHADER_INTERFACE 0 #if DEBUG_SHADER_INTERFACE - #include +# include #endif static const char *BuiltinUniform_name(GPUUniformBuiltin u) diff --git a/source/blender/gpu/intern/gpu_vertex_array_id.cpp b/source/blender/gpu/intern/gpu_vertex_array_id.cpp index 2f29bbfbc33..64f704bb107 100644 --- a/source/blender/gpu/intern/gpu_vertex_array_id.cpp +++ b/source/blender/gpu/intern/gpu_vertex_array_id.cpp @@ -23,7 +23,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gpu_vertex_array_id.cpp +/** \file blender/gpu/intern/gpu_vertex_array_id.cpp * \ingroup gpu * * Manage GL vertex array IDs in a thread-safe way @@ -58,7 +58,7 @@ static bool thread_is_main() { struct GPUContext { GLuint default_vao; - std::unordered_set batches; /* Batches that have VAOs from this context */ + std::unordered_set batches; /* Batches that have VAOs from this context */ std::vector orphaned_vertarray_ids; std::mutex orphans_mutex; /* todo: try spinlock instead */ #if TRUST_NO_ONE @@ -73,12 +73,12 @@ struct GPUContext { #if defined(_MSC_VER) && (_MSC_VER == 1800) #define thread_local __declspec(thread) -thread_local GPUContext* active_ctx = NULL; +thread_local GPUContext *active_ctx = NULL; #else -static thread_local GPUContext* active_ctx = NULL; +static thread_local GPUContext *active_ctx = NULL; #endif -static void clear_orphans(GPUContext* ctx) +static void clear_orphans(GPUContext *ctx) { ctx->orphans_mutex.lock(); if (!ctx->orphaned_vertarray_ids.empty()) { @@ -89,19 +89,19 @@ static void clear_orphans(GPUContext* ctx) ctx->orphans_mutex.unlock(); } -GPUContext* GPU_context_create(void) +GPUContext *GPU_context_create(void) { #if TRUST_NO_ONE /* assert(thread_is_main()); */ #endif - GPUContext* ctx = new GPUContext; + GPUContext *ctx = new GPUContext; glGenVertexArrays(1, &ctx->default_vao); GPU_context_active_set(ctx); return ctx; } /* to be called after GPU_context_active_set(ctx_to_destroy) */ -void GPU_context_discard(GPUContext* ctx) +void GPU_context_discard(GPUContext *ctx) { #if TRUST_NO_ONE /* Make sure no other thread has locked it. */ @@ -120,7 +120,7 @@ void GPU_context_discard(GPUContext* ctx) } /* ctx can be NULL */ -void GPU_context_active_set(GPUContext* ctx) +void GPU_context_active_set(GPUContext *ctx) { #if TRUST_NO_ONE if (active_ctx) { @@ -140,7 +140,7 @@ void GPU_context_active_set(GPUContext* ctx) active_ctx = ctx; } -GPUContext* GPU_context_active_get(void) +GPUContext *GPU_context_active_get(void) { return active_ctx; } @@ -168,7 +168,7 @@ GLuint GPU_vao_alloc(void) } /* this can be called from multiple thread */ -void GPU_vao_free(GLuint vao_id, GPUContext* ctx) +void GPU_vao_free(GLuint vao_id, GPUContext *ctx) { #if TRUST_NO_ONE assert(ctx); @@ -183,12 +183,12 @@ void GPU_vao_free(GLuint vao_id, GPUContext* ctx) } } -void gpu_context_add_batch(GPUContext* ctx, GPUBatch* batch) +void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch) { ctx->batches.emplace(batch); } -void gpu_context_remove_batch(GPUContext* ctx, GPUBatch* batch) +void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch) { ctx->orphans_mutex.lock(); ctx->batches.erase(batch); diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index f1f75f449d4..eef4945d9ef 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -37,7 +37,7 @@ #define PACK_DEBUG 0 #if PACK_DEBUG - #include +# include #endif void GPU_vertformat_clear(GPUVertFormat *format) diff --git a/source/blender/gpu/intern/gpu_vertex_format_private.h b/source/blender/gpu/intern/gpu_vertex_format_private.h index 4ce3ebba714..e4fe61e8697 100644 --- a/source/blender/gpu/intern/gpu_vertex_format_private.h +++ b/source/blender/gpu/intern/gpu_vertex_format_private.h @@ -32,8 +32,8 @@ #ifndef __GPU_VERTEX_FORMAT_PRIVATE_H__ #define __GPU_VERTEX_FORMAT_PRIVATE_H__ -void VertexFormat_pack(GPUVertFormat*); +void VertexFormat_pack(GPUVertFormat *format); uint padding(uint offset, uint alignment); -uint vertex_buffer_size(const GPUVertFormat*, uint vertex_len); +uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len); #endif /* __GPU_VERTEX_FORMAT_PRIVATE_H__ */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index e672ae0e6f7..b9a8f306baf 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -6976,8 +6976,9 @@ static void def_cmp_cryptomatte(StructRNA *srna) RNA_def_struct_sdna_from(srna, "NodeCryptomatte", "storage"); prop = RNA_def_property(srna, "matte_id", PROP_STRING, PROP_NONE); - RNA_def_property_string_funcs(prop, "rna_NodeCryptomatte_matte_get", "rna_NodeCryptomatte_matte_length", - "rna_NodeCryptomatte_matte_set"); + RNA_def_property_string_funcs( + prop, "rna_NodeCryptomatte_matte_get", "rna_NodeCryptomatte_matte_length", + "rna_NodeCryptomatte_matte_set"); RNA_def_property_ui_text(prop, "Matte Objects", "List of object and material crypto IDs to include in matte"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c index 0231e4717b2..bf9ab4a5064 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c @@ -39,10 +39,10 @@ static inline float hash_to_float(uint32_t hash) { - uint32_t mantissa = hash & (( 1 << 23) - 1); + uint32_t mantissa = hash & ((1 << 23) - 1); uint32_t exponent = (hash >> 23) & ((1 << 8) - 1); - exponent = MAX2(exponent, (uint32_t) 1); - exponent = MIN2(exponent, (uint32_t) 254); + exponent = MAX2(exponent, (uint32_t)1); + exponent = MIN2(exponent, (uint32_t)254); exponent = exponent << 23; uint32_t sign = (hash >> 31); sign = sign << 31; @@ -54,7 +54,7 @@ static inline float hash_to_float(uint32_t hash) return f; } -static void cryptomatte_add(NodeCryptomatte* n, float f) +static void cryptomatte_add(NodeCryptomatte *n, float f) { /* Turn the number into a string. */ char number[32]; @@ -72,16 +72,16 @@ static void cryptomatte_add(NodeCryptomatte* n, float f) } /* Find the next seprator. */ - char* token_end = strchr(n->matte_id+start, ','); - if (token_end == NULL || token_end == n->matte_id+start) { - token_end = n->matte_id+end; + char *token_end = strchr(n->matte_id + start, ','); + if (token_end == NULL || token_end == n->matte_id + start) { + token_end = n->matte_id + end; } /* Be aware that token_len still contains any trailing white space. */ token_len = token_end - (n->matte_id + start); /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */ if (n->matte_id[start] == '<') { - if (strncmp(n->matte_id+start, number, strlen(number)) == 0) { + if (strncmp(n->matte_id + start, number, strlen(number)) == 0) { /* This number is already there, so continue. */ return; } @@ -89,16 +89,16 @@ static void cryptomatte_add(NodeCryptomatte* n, float f) else { /* Remove trailing white space */ size_t name_len = token_len; - while (n->matte_id[start+name_len] == ' ' && name_len > 0) { + while (n->matte_id[start + name_len] == ' ' && name_len > 0) { name_len--; } /* Calculate the hash of the token and compare. */ - uint32_t hash = BLI_hash_mm3((const unsigned char*)(n->matte_id+start), name_len, 0); + uint32_t hash = BLI_hash_mm3((const unsigned char *)(n->matte_id + start), name_len, 0); if (f == hash_to_float(hash)) { return; } } - start += token_len+1; + start += token_len + 1; } } @@ -107,12 +107,12 @@ static void cryptomatte_add(NodeCryptomatte* n, float f) return; } - if(n->matte_id) { + if (n->matte_id) { BLI_dynstr_append(new_matte, n->matte_id); MEM_freeN(n->matte_id); } - if(BLI_dynstr_get_len(new_matte) > 0) { + if (BLI_dynstr_get_len(new_matte) > 0) { BLI_dynstr_append(new_matte, ","); } BLI_dynstr_append(new_matte, number); @@ -120,7 +120,7 @@ static void cryptomatte_add(NodeCryptomatte* n, float f) BLI_dynstr_free(new_matte); } -static void cryptomatte_remove(NodeCryptomatte*n, float f) +static void cryptomatte_remove(NodeCryptomatte *n, float f) { if (n->matte_id == NULL || strlen(n->matte_id) == 0) { /* Empty string, nothing to remove. */ @@ -150,9 +150,9 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f) } /* Find the next seprator. */ - char* token_end = strchr(n->matte_id+start+1, ','); - if (token_end == NULL || token_end == n->matte_id+start) { - token_end = n->matte_id+end; + char *token_end = strchr(n->matte_id + start + 1, ','); + if (token_end == NULL || token_end == n->matte_id + start) { + token_end = n->matte_id + end; } /* Be aware that token_len still contains any trailing white space. */ token_len = token_end - (n->matte_id + start); @@ -162,7 +162,7 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f) } /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */ else if (n->matte_id[start] == '<') { - if (strncmp(n->matte_id+start, number, strlen(number)) == 0) { + if (strncmp(n->matte_id + start, number, strlen(number)) == 0) { /* This number is already there, so skip it. */ skip = true; } @@ -170,11 +170,11 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f) else { /* Remove trailing white space */ size_t name_len = token_len; - while (n->matte_id[start+name_len] == ' ' && name_len > 0) { + while (n->matte_id[start + name_len] == ' ' && name_len > 0) { name_len--; } /* Calculate the hash of the token and compare. */ - uint32_t hash = BLI_hash_mm3((const unsigned char*)(n->matte_id+start), name_len, 0); + uint32_t hash = BLI_hash_mm3((const unsigned char *)(n->matte_id + start), name_len, 0); if (f == hash_to_float(hash)) { skip = true; } @@ -186,26 +186,26 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f) else { BLI_dynstr_append(new_matte, ", "); } - BLI_dynstr_nappend(new_matte, n->matte_id+start, token_len); + BLI_dynstr_nappend(new_matte, n->matte_id + start, token_len); } - start += token_len+1; + start += token_len + 1; } - if(n->matte_id) { + if (n->matte_id) { MEM_freeN(n->matte_id); n->matte_id = NULL; } - if(BLI_dynstr_get_len(new_matte) > 0) { + if (BLI_dynstr_get_len(new_matte) > 0) { n->matte_id = BLI_dynstr_get_cstring(new_matte); } BLI_dynstr_free(new_matte); } static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Image")}, - { SOCK_FLOAT, 0, N_("Matte")}, - { SOCK_RGBA, 0, N_("Pick")}, - { -1, 0, "" } + { SOCK_RGBA, 0, N_("Image")}, + { SOCK_FLOAT, 0, N_("Matte")}, + { SOCK_RGBA, 0, N_("Pick")}, + { -1, 0, "" } }; void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *UNUSED(ntree), bNode *node) @@ -235,7 +235,7 @@ bNodeSocket *ntreeCompositCryptomatteAddSocket(bNodeTree *ntree, bNode *node) NodeCryptomatte *n = node->storage; char sockname[32]; n->num_inputs++; - BLI_snprintf(sockname, sizeof(sockname), "Crypto %.2d", n->num_inputs-1); + BLI_snprintf(sockname, sizeof(sockname), "Crypto %.2d", n->num_inputs - 1); bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, sockname); return sock; } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c index 5fff2548ba1..83e4bf1731b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c @@ -40,7 +40,7 @@ static bNodeSocketTemplate sh_node_bsdf_hair_principled_in[] = { { SOCK_FLOAT, 1, N_("Radial Roughness"), 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("IOR"), 1.55f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { SOCK_FLOAT, 1, N_("Offset"), 2.f*((float)M_PI)/180.f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE}, + { SOCK_FLOAT, 1, N_("Offset"), 2.0f * ((float)M_PI) / 180.f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE}, { SOCK_FLOAT, 1, N_("Random Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("Random Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("Random"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, diff --git a/source/blender/python/gpu/gpu_py_types.c b/source/blender/python/gpu/gpu_py_types.c index 0a21da5682b..4e564fdf849 100644 --- a/source/blender/python/gpu/gpu_py_types.c +++ b/source/blender/python/gpu/gpu_py_types.c @@ -32,8 +32,6 @@ #include "BLI_math.h" -#include "GPU_batch.h" - #include "MEM_guardedalloc.h" #include "../generic/py_capi_utils.h" -- cgit v1.2.3 From 64bbfaf42144e26718bfb789cba81a409536cf73 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 18 Jul 2018 17:34:44 +0200 Subject: Subsurf: Set original index for high-poly vertices --- source/blender/blenkernel/BKE_subdiv.h | 1 + source/blender/blenkernel/intern/subdiv_mesh.c | 39 ++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_subdiv.h b/source/blender/blenkernel/BKE_subdiv.h index 92fb1167f55..45316e3cc91 100644 --- a/source/blender/blenkernel/BKE_subdiv.h +++ b/source/blender/blenkernel/BKE_subdiv.h @@ -22,6 +22,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ + #ifndef __BKE_SUBDIV_H__ #define __BKE_SUBDIV_H__ diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index c2a10483e26..9090ebe9f0f 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -416,7 +416,10 @@ static void loop_interpolation_end(LoopsForInterpolation *loop_interpolation) static void subdiv_copy_vertex_data( const SubdivMeshContext *ctx, MVert *subdiv_vertex, + const Mesh *coarse_mesh, + const MPoly *coarse_poly, const VerticesForInterpolation *vertex_interpolation, + const int ptex_of_poly_index, const float u, const float v) { const int subdiv_vertex_index = subdiv_vertex - ctx->subdiv_mesh->mvert; @@ -430,7 +433,34 @@ static void subdiv_copy_vertex_data( weights, NULL, 4, subdiv_vertex_index); - /* TODO(sergey): Set ORIGINDEX. */ + if (ctx->vert_origindex != NULL) { + ctx->vert_origindex[subdiv_vertex_index] = ORIGINDEX_NONE; + if (coarse_poly->totloop == 4) { + if (u == 0.0f && v == 0.0f) { + ctx->vert_origindex[subdiv_vertex_index] = + vertex_interpolation->vertex_indices[0]; + } + else if (u == 1.0f && v == 0.0f) { + ctx->vert_origindex[subdiv_vertex_index] = + vertex_interpolation->vertex_indices[1]; + } + else if (u == 1.0f && v == 1.0f) { + ctx->vert_origindex[subdiv_vertex_index] = + vertex_interpolation->vertex_indices[2]; + } + else if (u == 0.0f && v == 1.0f) { + ctx->vert_origindex[subdiv_vertex_index] = + vertex_interpolation->vertex_indices[3]; + } + } else { + if (u == 0.0f && v == 0.0f) { + const MLoop *coarse_mloop = coarse_mesh->mloop; + ctx->vert_origindex[subdiv_vertex_index] = + coarse_mloop[coarse_poly->loopstart + + ptex_of_poly_index].v; + } + } + } } static void subdiv_evaluate_vertices(SubdivMeshContext *ctx, @@ -447,12 +477,12 @@ static void subdiv_evaluate_vertices(SubdivMeshContext *ctx, const int num_poly_ptex_faces = mpoly_ptex_faces_count_get(coarse_poly); /* Hi-poly subdivided mesh. */ Mesh *subdiv_mesh = ctx->subdiv_mesh; - MVert *subdiv_vertert = subdiv_mesh->mvert; + MVert *subdiv_vertex = subdiv_mesh->mvert; const int ptex_face_index = subdiv->face_ptex_offset[poly_index]; /* Actual evaluation. */ VerticesForInterpolation vertex_interpolation; vertex_interpolation_init(ctx, &vertex_interpolation, coarse_poly); - MVert *subdiv_vert = &subdiv_vertert[ptex_face_index * resolution2]; + MVert *subdiv_vert = &subdiv_vertex[ptex_face_index * resolution2]; for (int ptex_of_poly_index = 0; ptex_of_poly_index < num_poly_ptex_faces; ptex_of_poly_index++) @@ -475,7 +505,10 @@ static void subdiv_evaluate_vertices(SubdivMeshContext *ctx, const float u = x * inv_resolution_1; subdiv_copy_vertex_data(ctx, subdiv_vert, + coarse_mesh, + coarse_poly, &vertex_interpolation, + ptex_of_poly_index, u, v); } } -- cgit v1.2.3 From 3882d0943b33c42d1dbe67d10d2432c0e7191959 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 18 Jul 2018 17:49:12 +0200 Subject: Subsurf: Fix wrong edge original index --- source/blender/blenkernel/intern/subdiv_mesh.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index 9090ebe9f0f..7baf03e7265 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -521,14 +521,17 @@ static void subdiv_copy_edge_data( MEdge *subdiv_edge, const MEdge *coarse_edge) { + const int subdiv_edge_index = subdiv_edge - ctx->subdiv_mesh->medge; if (coarse_edge == NULL) { subdiv_edge->crease = 0; subdiv_edge->bweight = 0; subdiv_edge->flag = 0; + if (ctx->edge_origindex != NULL) { + ctx->edge_origindex[subdiv_edge_index] = ORIGINDEX_NONE; + } return; } const int coarse_edge_index = coarse_edge - ctx->coarse_mesh->medge; - const int subdiv_edge_index = subdiv_edge - ctx->subdiv_mesh->medge; CustomData_copy_data(&ctx->coarse_mesh->edata, &ctx->subdiv_mesh->edata, coarse_edge_index, -- cgit v1.2.3 From 5037dd8abdf9335e998141336d4e15f81580c491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 19 Jul 2018 15:48:13 +0200 Subject: GPU: Add GC to FBOs and UBOs and centralize all GCs GPUFrameBuffers were being free when no context was attached or in the wrong gl context. This make sure this does not happen again. You can now safely free any gl resource from any thread (well as long as it's not used anymore!). --- source/blender/draw/DRW_engine.h | 4 + source/blender/draw/intern/draw_manager.c | 20 +- source/blender/gpu/CMakeLists.txt | 6 +- source/blender/gpu/GPU_buffer_id.h | 53 ---- source/blender/gpu/GPU_material.h | 5 - source/blender/gpu/GPU_texture.h | 5 - source/blender/gpu/GPU_vertex_array_id.h | 55 ---- source/blender/gpu/intern/gpu_batch.c | 3 +- source/blender/gpu/intern/gpu_batch_private.h | 3 - source/blender/gpu/intern/gpu_buffer_id.cpp | 90 ------ source/blender/gpu/intern/gpu_context.cpp | 315 +++++++++++++++++++++ source/blender/gpu/intern/gpu_context_private.h | 68 +++++ source/blender/gpu/intern/gpu_element.c | 7 +- source/blender/gpu/intern/gpu_framebuffer.c | 15 +- source/blender/gpu/intern/gpu_immediate.c | 7 +- source/blender/gpu/intern/gpu_init_exit.c | 5 - source/blender/gpu/intern/gpu_material.c | 39 +-- source/blender/gpu/intern/gpu_private.h | 3 + source/blender/gpu/intern/gpu_shader.c | 2 + source/blender/gpu/intern/gpu_shader_interface.c | 6 +- source/blender/gpu/intern/gpu_texture.c | 58 +--- source/blender/gpu/intern/gpu_uniformbuffer.c | 7 +- source/blender/gpu/intern/gpu_vertex_array_id.cpp | 196 ------------- source/blender/gpu/intern/gpu_vertex_buffer.c | 8 +- source/blender/windowmanager/intern/wm_init_exit.c | 5 +- source/blender/windowmanager/intern/wm_window.c | 2 - 26 files changed, 458 insertions(+), 529 deletions(-) delete mode 100644 source/blender/gpu/GPU_buffer_id.h delete mode 100644 source/blender/gpu/GPU_vertex_array_id.h delete mode 100644 source/blender/gpu/intern/gpu_buffer_id.cpp create mode 100644 source/blender/gpu/intern/gpu_context.cpp create mode 100644 source/blender/gpu/intern/gpu_context_private.h delete mode 100644 source/blender/gpu/intern/gpu_vertex_array_id.cpp diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index eb037d081e1..4d4b486d247 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -136,6 +136,10 @@ void DRW_opengl_context_destroy(void); void DRW_opengl_context_enable(void); void DRW_opengl_context_disable(void); +/* Never use this. Only for closing blender. */ +void DRW_opengl_context_enable_ex(bool restore); +void DRW_opengl_context_disable_ex(bool restore); + void DRW_opengl_render_context_enable(void *re_gl_context); void DRW_opengl_render_context_disable(void *re_gl_context); void DRW_gawain_render_context_enable(void *re_gpu_context); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 2793410cd8e..cc4f8ec7947 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2374,21 +2374,21 @@ void DRW_opengl_context_destroy(void) } } -void DRW_opengl_context_enable(void) +void DRW_opengl_context_enable_ex(bool restore) { if (DST.gl_context != NULL) { /* IMPORTANT: We dont support immediate mode in render mode! * This shall remain in effect until immediate mode supports * multiple threads. */ BLI_ticket_mutex_lock(DST.gl_context_mutex); - if (BLI_thread_is_main()) { + if (BLI_thread_is_main() && restore) { if (!G.background) { immDeactivate(); } } WM_opengl_context_activate(DST.gl_context); GPU_context_active_set(DST.gpu_context); - if (BLI_thread_is_main()) { + if (BLI_thread_is_main() && restore) { if (!G.background) { immActivate(); } @@ -2397,7 +2397,7 @@ void DRW_opengl_context_enable(void) } } -void DRW_opengl_context_disable(void) +void DRW_opengl_context_disable_ex(bool restore) { if (DST.gl_context != NULL) { #ifdef __APPLE__ @@ -2406,7 +2406,7 @@ void DRW_opengl_context_disable(void) glFlush(); #endif - if (BLI_thread_is_main()) { + if (BLI_thread_is_main() && restore) { wm_window_reset_drawable(); } else { @@ -2418,6 +2418,16 @@ void DRW_opengl_context_disable(void) } } +void DRW_opengl_context_enable(void) +{ + DRW_opengl_context_enable_ex(true); +} + +void DRW_opengl_context_disable(void) +{ + DRW_opengl_context_disable_ex(true); +} + void DRW_opengl_render_context_enable(void *re_gl_context) { /* If thread is main you should use DRW_opengl_context_enable(). */ diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 58295ae9329..8273f3f1992 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -62,9 +62,9 @@ set(SRC intern/gpu_batch.c intern/gpu_batch_presets.c intern/gpu_batch_utils.c - intern/gpu_buffer_id.cpp intern/gpu_buffers.c intern/gpu_codegen.c + intern/gpu_context.cpp intern/gpu_debug.c intern/gpu_draw.c intern/gpu_element.c @@ -84,7 +84,6 @@ set(SRC intern/gpu_state.c intern/gpu_texture.c intern/gpu_uniformbuffer.c - intern/gpu_vertex_array_id.cpp intern/gpu_vertex_buffer.c intern/gpu_vertex_format.c intern/gpu_viewport.c @@ -113,7 +112,6 @@ set(SRC GPU_attr_binding.h GPU_basic_shader.h GPU_batch.h - GPU_buffer_id.h GPU_buffers.h GPU_common.h GPU_debug.h @@ -135,7 +133,6 @@ set(SRC GPU_state.h GPU_texture.h GPU_uniformbuffer.h - GPU_vertex_array_id.h GPU_vertex_buffer.h GPU_vertex_format.h GPU_viewport.h @@ -143,6 +140,7 @@ set(SRC intern/gpu_attr_binding_private.h intern/gpu_batch_private.h intern/gpu_codegen.h + intern/gpu_context_private.h intern/gpu_primitive_private.h intern/gpu_private.h intern/gpu_select_private.h diff --git a/source/blender/gpu/GPU_buffer_id.h b/source/blender/gpu/GPU_buffer_id.h deleted file mode 100644 index 4615e9e2c66..00000000000 --- a/source/blender/gpu/GPU_buffer_id.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/GPU_buffer_id.h - * \ingroup gpu - * - * GPU buffer IDs - */ - -#ifndef __GPU_BUFFER_ID_H__ -#define __GPU_BUFFER_ID_H__ - -/* Manage GL buffer IDs in a thread-safe way - * Use these instead of glGenBuffers & its friends - * - alloc must be called from main thread - * - free can be called from any thread */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "GPU_common.h" - -GLuint GPU_buf_id_alloc(void); -void GPU_buf_id_free(GLuint buffer_id); - -#ifdef __cplusplus -} -#endif - -#endif /* __GPU_BUFFER_ID_H__ */ diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 4e264defbd4..f2c029f643e 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -254,11 +254,6 @@ void GPU_material_free(struct ListBase *gpumaterial); void GPU_materials_free(struct Main *bmain); -void GPU_material_orphans_init(void); -void GPU_material_orphans_exit(void); -/* This has to be called from a thread with an ogl context bound. */ -void GPU_material_orphans_delete(void); - struct Scene *GPU_material_scene(GPUMaterial *material); GPUMatType GPU_Material_get_type(GPUMaterial *material); struct GPUPass *GPU_material_get_pass(GPUMaterial *material); diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index e3db18f1358..1ddf801e166 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -198,11 +198,6 @@ void GPU_invalid_tex_free(void); void GPU_texture_free(GPUTexture *tex); -void GPU_texture_orphans_init(void); -void GPU_texture_orphans_exit(void); -/* This has to be called from a thread with an ogl context bound. */ -void GPU_texture_orphans_delete(void); - void GPU_texture_ref(GPUTexture *tex); void GPU_texture_bind(GPUTexture *tex, int number); void GPU_texture_unbind(GPUTexture *tex); diff --git a/source/blender/gpu/GPU_vertex_array_id.h b/source/blender/gpu/GPU_vertex_array_id.h deleted file mode 100644 index ff84a290a5a..00000000000 --- a/source/blender/gpu/GPU_vertex_array_id.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/GPU_vertex_array_id.h - * \ingroup gpu - * - * Manage GL vertex array IDs in a thread-safe way - * Use these instead of glGenBuffers & its friends - * - alloc must be called from a thread that is bound - * to the context that will be used for drawing with - * this vao. - * - free can be called from any thread - */ - -#ifndef __GPU_VERTEX_ARRAY_ID_H__ -#define __GPU_VERTEX_ARRAY_ID_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "GPU_common.h" -#include "GPU_context.h" - -GLuint GPU_vao_default(void); -GLuint GPU_vao_alloc(void); -void GPU_vao_free(GLuint vao_id, GPUContext *); - -#ifdef __cplusplus -} -#endif - -#endif /* __GPU_VERTEX_ARRAY_ID_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index a11eefee078..9b433a37a72 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -32,12 +32,11 @@ #include "GPU_batch.h" #include "GPU_batch_presets.h" -#include "GPU_buffer_id.h" #include "GPU_matrix.h" #include "GPU_shader.h" -#include "GPU_vertex_array_id.h" #include "gpu_batch_private.h" +#include "gpu_context_private.h" #include "gpu_primitive_private.h" #include "gpu_shader_private.h" diff --git a/source/blender/gpu/intern/gpu_batch_private.h b/source/blender/gpu/intern/gpu_batch_private.h index 51040ff751a..3a05e243065 100644 --- a/source/blender/gpu/intern/gpu_batch_private.h +++ b/source/blender/gpu/intern/gpu_batch_private.h @@ -43,9 +43,6 @@ extern "C" { void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface); -void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch); -void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch); - #ifdef __cplusplus } #endif diff --git a/source/blender/gpu/intern/gpu_buffer_id.cpp b/source/blender/gpu/intern/gpu_buffer_id.cpp deleted file mode 100644 index f3faba9c766..00000000000 --- a/source/blender/gpu/intern/gpu_buffer_id.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gpu_buffer_id.cpp - * \ingroup gpu - * - * GPU buffer IDs - */ - -#include "GPU_buffer_id.h" - -#include -#include - -#define ORPHAN_DEBUG 0 - -#if ORPHAN_DEBUG -# include -#endif - -static std::vector orphaned_buffer_ids; - -static std::mutex orphan_mutex; - -extern "C" { -extern int BLI_thread_is_main(void); /* Blender-specific function */ -} - -static bool thread_is_main() -{ - /* "main" here means the GL context's thread */ - return BLI_thread_is_main(); -} - -GLuint GPU_buf_id_alloc() -{ - /* delete orphaned IDs */ - orphan_mutex.lock(); - if (!orphaned_buffer_ids.empty()) { - const auto orphaned_buffer_len = (uint)orphaned_buffer_ids.size(); -#if ORPHAN_DEBUG - printf("deleting %u orphaned VBO%s\n", orphaned_buffer_len, orphaned_buffer_len == 1 ? "" : "s"); -#endif - glDeleteBuffers(orphaned_buffer_len, orphaned_buffer_ids.data()); - orphaned_buffer_ids.clear(); - } - orphan_mutex.unlock(); - - GLuint new_buffer_id = 0; - glGenBuffers(1, &new_buffer_id); - return new_buffer_id; -} - -void GPU_buf_id_free(GLuint buffer_id) -{ - if (thread_is_main()) { - glDeleteBuffers(1, &buffer_id); - } - else { - /* add this ID to the orphaned list */ - orphan_mutex.lock(); -#if ORPHAN_DEBUG - printf("orphaning VBO %u\n", buffer_id); -#endif - orphaned_buffer_ids.emplace_back(buffer_id); - orphan_mutex.unlock(); - } -} diff --git a/source/blender/gpu/intern/gpu_context.cpp b/source/blender/gpu/intern/gpu_context.cpp new file mode 100644 index 00000000000..6a42552c2fd --- /dev/null +++ b/source/blender/gpu/intern/gpu_context.cpp @@ -0,0 +1,315 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation, Clément Foucault + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gpu_vertex_array_id.cpp + * \ingroup gpu + * + * Manage GL vertex array IDs in a thread-safe way + * Use these instead of glGenBuffers & its friends + * - alloc must be called from a thread that is bound + * to the context that will be used for drawing with + * this vao. + * - free can be called from any thread + */ + +#include "BLI_assert.h" +#include "BLI_utildefines.h" + +#include "GPU_context.h" +#include "GPU_framebuffer.h" + +#include "gpu_batch_private.h" +#include "gpu_context_private.h" + +#include +#include +#include +#include +#include + +#if TRUST_NO_ONE +#if 0 +extern "C" { +extern int BLI_thread_is_main(void); /* Blender-specific function */ +} + +static bool thread_is_main() { + /* "main" here means the GL context's thread */ + return BLI_thread_is_main(); +} +#endif +#endif + +static std::vector orphaned_buffer_ids; +static std::vector orphaned_texture_ids; + +static std::mutex orphans_mutex; + +struct GPUContext { + GLuint default_vao; + std::unordered_set batches; /* Batches that have VAOs from this context */ +#ifdef DEBUG + std::unordered_set framebuffers; /* Framebuffers that have FBO from this context */ +#endif + std::vector orphaned_vertarray_ids; + std::vector orphaned_framebuffer_ids; + std::mutex orphans_mutex; /* todo: try spinlock instead */ +#if TRUST_NO_ONE + pthread_t thread; /* Thread on which this context is active. */ + bool thread_is_used; + + GPUContext() { + thread_is_used = false; + } +#endif +}; + +#if defined(_MSC_VER) && (_MSC_VER == 1800) +#define thread_local __declspec(thread) +thread_local GPUContext *active_ctx = NULL; +#else +static thread_local GPUContext *active_ctx = NULL; +#endif + +static void orphans_add(GPUContext *ctx, std::vector *orphan_list, GLuint id) +{ + std::mutex *mutex = (ctx) ? &ctx->orphans_mutex : &orphans_mutex; + + mutex->lock(); + orphan_list->emplace_back(id); + mutex->unlock(); +} + +static void orphans_clear(GPUContext *ctx) +{ + BLI_assert(ctx); /* need at least an active context */ + BLI_assert(pthread_equal(pthread_self(), ctx->thread)); /* context has been activated by another thread! */ + + ctx->orphans_mutex.lock(); + if (!ctx->orphaned_vertarray_ids.empty()) { + uint orphan_len = (uint)ctx->orphaned_vertarray_ids.size(); + glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data()); + ctx->orphaned_vertarray_ids.clear(); + } + if (!ctx->orphaned_framebuffer_ids.empty()) { + uint orphan_len = (uint)ctx->orphaned_framebuffer_ids.size(); + glDeleteFramebuffers(orphan_len, ctx->orphaned_framebuffer_ids.data()); + ctx->orphaned_framebuffer_ids.clear(); + } + + ctx->orphans_mutex.unlock(); + + orphans_mutex.lock(); + if (!orphaned_buffer_ids.empty()) { + uint orphan_len = (uint)orphaned_buffer_ids.size(); + glDeleteBuffers(orphan_len, orphaned_buffer_ids.data()); + orphaned_buffer_ids.clear(); + } + if (!orphaned_texture_ids.empty()) { + uint orphan_len = (uint)orphaned_texture_ids.size(); + glDeleteTextures(orphan_len, orphaned_texture_ids.data()); + orphaned_texture_ids.clear(); + } + orphans_mutex.unlock(); +} + +GPUContext *GPU_context_create(void) +{ + /* BLI_assert(thread_is_main()); */ + GPUContext *ctx = new GPUContext; + glGenVertexArrays(1, &ctx->default_vao); + GPU_context_active_set(ctx); + return ctx; +} + +/* to be called after GPU_context_active_set(ctx_to_destroy) */ +void GPU_context_discard(GPUContext *ctx) +{ + /* Make sure no other thread has locked it. */ + BLI_assert(ctx == active_ctx); + BLI_assert(pthread_equal(pthread_self(), ctx->thread)); + BLI_assert(ctx->orphaned_vertarray_ids.empty()); + /* For now don't allow GPUFrameBuffers to be reuse in another ctx. */ + BLI_assert(ctx->framebuffers.empty()); + /* delete remaining vaos */ + while (!ctx->batches.empty()) { + /* this removes the array entry */ + GPU_batch_vao_cache_clear(*ctx->batches.begin()); + } + glDeleteVertexArrays(1, &ctx->default_vao); + delete ctx; + active_ctx = NULL; +} + +/* ctx can be NULL */ +void GPU_context_active_set(GPUContext *ctx) +{ +#if TRUST_NO_ONE + if (active_ctx) { + active_ctx->thread_is_used = false; + } + /* Make sure no other context is already bound to this thread. */ + if (ctx) { + /* Make sure no other thread has locked it. */ + assert(ctx->thread_is_used == false); + ctx->thread = pthread_self(); + ctx->thread_is_used = true; + } +#endif + if (ctx) { + orphans_clear(ctx); + } + active_ctx = ctx; +} + +GPUContext *GPU_context_active_get(void) +{ + return active_ctx; +} + +GLuint GPU_vao_default(void) +{ + BLI_assert(active_ctx); /* need at least an active context */ + BLI_assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ + return active_ctx->default_vao; +} + +GLuint GPU_vao_alloc(void) +{ + GLuint new_vao_id = 0; + orphans_clear(active_ctx); + glGenVertexArrays(1, &new_vao_id); + return new_vao_id; +} + +GLuint GPU_fbo_alloc(void) +{ + GLuint new_fbo_id = 0; + orphans_clear(active_ctx); + glGenFramebuffers(1, &new_fbo_id); + return new_fbo_id; +} + +GLuint GPU_buf_alloc(void) +{ + GLuint new_buffer_id = 0; + orphans_clear(active_ctx); + glGenBuffers(1, &new_buffer_id); + return new_buffer_id; +} + +GLuint GPU_tex_alloc(void) +{ + GLuint new_texture_id = 0; + orphans_clear(active_ctx); + glGenTextures(1, &new_texture_id); + return new_texture_id; +} + +void GPU_vao_free(GLuint vao_id, GPUContext *ctx) +{ + BLI_assert(ctx); + if (ctx == active_ctx) { + glDeleteVertexArrays(1, &vao_id); + } + else { + orphans_add(ctx, &ctx->orphaned_vertarray_ids, vao_id); + } +} + +void GPU_fbo_free(GLuint fbo_id, GPUContext *ctx) +{ + BLI_assert(ctx); + if (ctx == active_ctx) { + glDeleteFramebuffers(1, &fbo_id); + } + else { + orphans_add(ctx, &ctx->orphaned_framebuffer_ids, fbo_id); + } +} + +void GPU_buf_free(GLuint buf_id) +{ + if (active_ctx) { + glDeleteBuffers(1, &buf_id); + } + else { + orphans_add(NULL, &orphaned_buffer_ids, buf_id); + } +} + +void GPU_tex_free(GLuint tex_id) +{ + if (active_ctx) { + glDeleteTextures(1, &tex_id); + } + else { + orphans_add(NULL, &orphaned_texture_ids, tex_id); + } +} + +/* GPUBatch & GPUFrameBuffer contains respectively VAO & FBO indices + * which are not shared across contexts. So we need to keep track of + * ownership. */ + +void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch) +{ + BLI_assert(ctx); + ctx->orphans_mutex.lock(); + ctx->batches.emplace(batch); + ctx->orphans_mutex.unlock(); +} + +void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch) +{ + BLI_assert(ctx); + ctx->orphans_mutex.lock(); + ctx->batches.erase(batch); + ctx->orphans_mutex.unlock(); +} + +void gpu_context_add_framebuffer(GPUContext *ctx, GPUFrameBuffer *fb) +{ +#ifdef DEBUG + BLI_assert(ctx); + ctx->orphans_mutex.lock(); + ctx->framebuffers.emplace(fb); + ctx->orphans_mutex.unlock(); +#else + UNUSED_VARS(ctx, fb); +#endif +} + +void gpu_context_remove_framebuffer(GPUContext *ctx, GPUFrameBuffer *fb) +{ +#ifdef DEBUG + BLI_assert(ctx); + ctx->orphans_mutex.lock(); + ctx->framebuffers.erase(fb); + ctx->orphans_mutex.unlock(); +#else + UNUSED_VARS(ctx, fb); +#endif +} diff --git a/source/blender/gpu/intern/gpu_context_private.h b/source/blender/gpu/intern/gpu_context_private.h new file mode 100644 index 00000000000..4881a892e38 --- /dev/null +++ b/source/blender/gpu/intern/gpu_context_private.h @@ -0,0 +1,68 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 by Mike Erwin. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/gpu/intern/gpu_context_private.h + * \ingroup gpu + * + * This interface allow GPU to manage GL objects for mutiple context and threads. + */ + +#ifndef __GPU_CONTEXT_PRIVATE_H__ +#define __GPU_CONTEXT_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "GPU_context.h" + +struct GPUFrameBuffer; + +GLuint GPU_vao_default(void); + +/* These require a gl ctx bound. */ +GLuint GPU_buf_alloc(void); +GLuint GPU_tex_alloc(void); +GLuint GPU_vao_alloc(void); +GLuint GPU_fbo_alloc(void); + +/* These can be called any threads even without gl ctx. */ +void GPU_buf_free(GLuint buf_id); +void GPU_tex_free(GLuint tex_id); +/* These two need the ctx the id was created with. */ +void GPU_vao_free(GLuint vao_id, GPUContext *ctx); +void GPU_fbo_free(GLuint fbo_id, GPUContext *ctx); + +void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch); +void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch); + +void gpu_context_add_framebuffer(GPUContext *ctx, struct GPUFrameBuffer *fb); +void gpu_context_remove_framebuffer(GPUContext *ctx, struct GPUFrameBuffer *fb); + +#ifdef __cplusplus +} +#endif + +#endif /* __GPU_CONTEXT_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_element.c b/source/blender/gpu/intern/gpu_element.c index 9abfed2db05..901e09443d1 100644 --- a/source/blender/gpu/intern/gpu_element.c +++ b/source/blender/gpu/intern/gpu_element.c @@ -30,7 +30,8 @@ */ #include "GPU_element.h" -#include "GPU_buffer_id.h" + +#include "gpu_context_private.h" #include @@ -279,7 +280,7 @@ void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *builder, GPUIndexBuf *elem) #endif if (elem->vbo_id == 0) { - elem->vbo_id = GPU_buf_id_alloc(); + elem->vbo_id = GPU_buf_alloc(); } /* send data to GPU */ /* GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound, @@ -302,7 +303,7 @@ void GPU_indexbuf_use(GPUIndexBuf *elem) void GPU_indexbuf_discard(GPUIndexBuf *elem) { if (elem->vbo_id) { - GPU_buf_id_free(elem->vbo_id); + GPU_buf_free(elem->vbo_id); } free(elem); } diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index d28b82ac3cd..ba8dcb04269 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -42,7 +42,8 @@ #include "GPU_shader.h" #include "GPU_texture.h" -#include "intern/gpu_private.h" +#include "gpu_private.h" +#include "gpu_context_private.h" static ThreadLocal(void *) g_currentfb; @@ -69,6 +70,7 @@ typedef enum { #define GPU_FB_ATTACHEMENT_SET_DIRTY(flag, type) (flag |= (1 << type)) struct GPUFrameBuffer { + GPUContext *ctx; GLuint object; GPUAttachment attachments[GPU_FB_MAX_ATTACHEMENT]; uint16_t dirty_flag; @@ -196,7 +198,9 @@ GPUFrameBuffer *GPU_framebuffer_create(void) static void gpu_framebuffer_init(GPUFrameBuffer *fb) { - glGenFramebuffers(1, &fb->object); + fb->object = GPU_fbo_alloc(); + fb->ctx = GPU_context_active_get(); + gpu_context_add_framebuffer(fb->ctx, fb); } void GPU_framebuffer_free(GPUFrameBuffer *fb) @@ -207,8 +211,11 @@ void GPU_framebuffer_free(GPUFrameBuffer *fb) } } - /* This restores the framebuffer if it was bound */ - glDeleteFramebuffers(1, &fb->object); + if (fb->object != 0) { + /* This restores the framebuffer if it was bound */ + GPU_fbo_free(fb->object, fb->ctx); + gpu_context_remove_framebuffer(fb->ctx, fb); + } if (gpu_framebuffer_current_get() == fb->object) { gpu_framebuffer_current_set(0); diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index 66a467e339e..9674cf0b9f7 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -32,11 +32,10 @@ #include "UI_resources.h" #include "GPU_attr_binding.h" -#include "GPU_buffer_id.h" #include "GPU_immediate.h" -#include "GPU_vertex_array_id.h" #include "gpu_attr_binding_private.h" +#include "gpu_context_private.h" #include "gpu_primitive_private.h" #include "gpu_shader_private.h" #include "gpu_vertex_format_private.h" @@ -91,7 +90,7 @@ void immInit(void) #endif memset(&imm, 0, sizeof(Immediate)); - imm.vbo_id = GPU_buf_id_alloc(); + imm.vbo_id = GPU_buf_alloc(); glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); @@ -127,7 +126,7 @@ void immDeactivate(void) void immDestroy(void) { - GPU_buf_id_free(imm.vbo_id); + GPU_buf_free(imm.vbo_id); initialized = false; } diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c index 78d4f491b66..55d0466c929 100644 --- a/source/blender/gpu/intern/gpu_init_exit.c +++ b/source/blender/gpu/intern/gpu_init_exit.c @@ -57,8 +57,6 @@ void GPU_init(void) gpu_extensions_init(); /* must come first */ - GPU_texture_orphans_init(); - GPU_material_orphans_init(); gpu_codegen_init(); gpu_framebuffer_module_init(); @@ -84,9 +82,6 @@ void GPU_exit(void) gpu_batch_exit(); - GPU_texture_orphans_exit(); - GPU_material_orphans_exit(); - if (G.debug & G_DEBUG_GPU) gpu_debug_exit(); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 9566f091ada..92aff91da32 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -75,9 +75,6 @@ # include "BKE_DerivedMesh.h" #endif -static ListBase g_orphaned_mat = {NULL, NULL}; -static ThreadMutex g_orphan_lock; - /* Structs */ struct GPUMaterial { @@ -175,44 +172,12 @@ void GPU_material_free(ListBase *gpumaterial) { for (LinkData *link = gpumaterial->first; link; link = link->next) { GPUMaterial *material = link->data; - - /* TODO(fclem): Check if the thread has an ogl context. */ - if (BLI_thread_is_main()) { - gpu_material_free_single(material); - MEM_freeN(material); - } - else { - BLI_mutex_lock(&g_orphan_lock); - BLI_addtail(&g_orphaned_mat, BLI_genericNodeN(material)); - BLI_mutex_unlock(&g_orphan_lock); - } + gpu_material_free_single(material); + MEM_freeN(material); } BLI_freelistN(gpumaterial); } -void GPU_material_orphans_init(void) -{ - BLI_mutex_init(&g_orphan_lock); -} - -void GPU_material_orphans_delete(void) -{ - BLI_mutex_lock(&g_orphan_lock); - LinkData *link; - while ((link = BLI_pophead(&g_orphaned_mat))) { - gpu_material_free_single((GPUMaterial *)link->data); - MEM_freeN(link->data); - MEM_freeN(link); - } - BLI_mutex_unlock(&g_orphan_lock); -} - -void GPU_material_orphans_exit(void) -{ - GPU_material_orphans_delete(); - BLI_mutex_end(&g_orphan_lock); -} - GPUBuiltin GPU_get_material_builtins(GPUMaterial *material) { return material->builtins; diff --git a/source/blender/gpu/intern/gpu_private.h b/source/blender/gpu/intern/gpu_private.h index 996ba9c63a1..df55f7922b3 100644 --- a/source/blender/gpu/intern/gpu_private.h +++ b/source/blender/gpu/intern/gpu_private.h @@ -25,6 +25,9 @@ #ifndef __GPU_PRIVATE_H__ #define __GPU_PRIVATE_H__ +struct GPUContext; +struct GPUFrameBuffer; + /* call this before running any of the functions below */ void gpu_extensions_init(void); void gpu_extensions_exit(void); diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 1eae073d9c0..04b43d03c83 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -38,6 +38,7 @@ #include "DNA_space_types.h" #include "GPU_extensions.h" +#include "GPU_context.h" #include "GPU_matrix.h" #include "GPU_shader.h" #include "GPU_texture.h" @@ -572,6 +573,7 @@ void GPU_shader_transform_feedback_disable(GPUShader *UNUSED(shader)) void GPU_shader_free(GPUShader *shader) { + BLI_assert(GPU_context_active_get() != NULL); BLI_assert(shader); if (shader->vertex) diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 4b8413d0cc3..54c5f41bbd3 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -29,9 +29,11 @@ * GPU shader interface (C --> GLSL) */ -#include "gpu_batch_private.h" #include "GPU_shader_interface.h" -#include "GPU_vertex_array_id.h" + +#include "gpu_batch_private.h" +#include "gpu_context_private.h" + #include #include #include diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 4465136dd0f..5ac746ec9c1 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -38,22 +38,22 @@ #include "BKE_global.h" #include "GPU_batch.h" +#include "GPU_context.h" #include "GPU_debug.h" #include "GPU_draw.h" #include "GPU_extensions.h" -#include "GPU_framebuffer.h" #include "GPU_glew.h" +#include "GPU_framebuffer.h" #include "GPU_texture.h" +#include "gpu_context_private.h" + static struct GPUTextureGlobal { GPUTexture *invalid_tex_1D; /* texture used in place of invalid textures (not loaded correctly, missing) */ GPUTexture *invalid_tex_2D; GPUTexture *invalid_tex_3D; } GG = {NULL, NULL, NULL}; -static ListBase g_orphaned_tex = {NULL, NULL}; -static ThreadMutex g_orphan_lock; - /* Maximum number of FBOs a texture can be attached to. */ #define GPU_TEX_MAX_FBO_ATTACHED 8 @@ -535,7 +535,7 @@ GPUTexture *GPU_texture_create_nD( gpu_texture_memory_footprint_add(tex); /* Generate Texture object */ - glGenTextures(1, &tex->bindcode); + tex->bindcode = GPU_tex_alloc(); if (!tex->bindcode) { if (err_out) @@ -668,7 +668,7 @@ static GPUTexture *GPU_texture_cube_create( gpu_texture_memory_footprint_add(tex); /* Generate Texture object */ - glGenTextures(1, &tex->bindcode); + tex->bindcode = GPU_tex_alloc(); if (!tex->bindcode) { if (err_out) @@ -752,7 +752,7 @@ GPUTexture *GPU_texture_create_buffer(GPUTextureFormat tex_format, const GLuint } /* Generate Texture object */ - glGenTextures(1, &tex->bindcode); + tex->bindcode = GPU_tex_alloc(); if (!tex->bindcode) { fprintf(stderr, "GPUTexture: texture create failed\n"); @@ -1301,17 +1301,6 @@ void GPU_texture_filters(GPUTexture *tex, GPUFilterFunction min_filter, GPUFilte glTexParameteri(tex->target_base, GL_TEXTURE_MAG_FILTER, gpu_get_gl_filterfunction(mag_filter)); } - -static void gpu_texture_delete(GPUTexture *tex) -{ - if (tex->bindcode) - glDeleteTextures(1, &tex->bindcode); - - gpu_texture_memory_footprint_remove(tex); - - MEM_freeN(tex); -} - void GPU_texture_free(GPUTexture *tex) { tex->refcount--; @@ -1326,38 +1315,13 @@ void GPU_texture_free(GPUTexture *tex) } } - /* TODO(fclem): Check if the thread has an ogl context. */ - if (BLI_thread_is_main()) { - gpu_texture_delete(tex); - } - else { - BLI_mutex_lock(&g_orphan_lock); - BLI_addtail(&g_orphaned_tex, BLI_genericNodeN(tex)); - BLI_mutex_unlock(&g_orphan_lock); - } - } -} + if (tex->bindcode) + GPU_tex_free(tex->bindcode); -void GPU_texture_orphans_init(void) -{ - BLI_mutex_init(&g_orphan_lock); -} + gpu_texture_memory_footprint_remove(tex); -void GPU_texture_orphans_delete(void) -{ - BLI_mutex_lock(&g_orphan_lock); - LinkData *link; - while ((link = BLI_pophead(&g_orphaned_tex))) { - gpu_texture_delete((GPUTexture *)link->data); - MEM_freeN(link); + MEM_freeN(tex); } - BLI_mutex_unlock(&g_orphan_lock); -} - -void GPU_texture_orphans_exit(void) -{ - GPU_texture_orphans_delete(); - BLI_mutex_end(&g_orphan_lock); } void GPU_texture_ref(GPUTexture *tex) diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c index 1e39b2ea5b7..9b8441efd08 100644 --- a/source/blender/gpu/intern/gpu_uniformbuffer.c +++ b/source/blender/gpu/intern/gpu_uniformbuffer.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "gpu_codegen.h" +#include "gpu_context_private.h" #include "GPU_extensions.h" #include "GPU_glew.h" @@ -88,7 +89,7 @@ GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_ ubo->bindpoint = -1; /* Generate Buffer object */ - glGenBuffers(1, &ubo->bindcode); + ubo->bindcode = GPU_buf_alloc(); if (!ubo->bindcode) { if (err_out) @@ -127,7 +128,7 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou ubo->flag = GPU_UBO_FLAG_DIRTY; /* Generate Buffer object. */ - glGenBuffers(1, &ubo->buffer.bindcode); + ubo->buffer.bindcode = GPU_buf_alloc(); if (!ubo->buffer.bindcode) { if (err_out) @@ -190,7 +191,7 @@ void GPU_uniformbuffer_free(GPUUniformBuffer *ubo) gpu_uniformbuffer_dynamic_free(ubo); } - glDeleteBuffers(1, &ubo->bindcode); + GPU_buf_free(ubo->bindcode); MEM_freeN(ubo); } diff --git a/source/blender/gpu/intern/gpu_vertex_array_id.cpp b/source/blender/gpu/intern/gpu_vertex_array_id.cpp deleted file mode 100644 index 64f704bb107..00000000000 --- a/source/blender/gpu/intern/gpu_vertex_array_id.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 by Mike Erwin. - * All rights reserved. - * - * Contributor(s): Blender Foundation, Clément Foucault - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/gpu/intern/gpu_vertex_array_id.cpp - * \ingroup gpu - * - * Manage GL vertex array IDs in a thread-safe way - * Use these instead of glGenBuffers & its friends - * - alloc must be called from a thread that is bound - * to the context that will be used for drawing with - * this vao. - * - free can be called from any thread - */ - -#include "gpu_batch_private.h" -#include "GPU_vertex_array_id.h" -#include "GPU_context.h" -#include -#include -#include -#include -#include - -#if TRUST_NO_ONE -#if 0 -extern "C" { -extern int BLI_thread_is_main(void); /* Blender-specific function */ -} - -static bool thread_is_main() { - /* "main" here means the GL context's thread */ - return BLI_thread_is_main(); -} -#endif -#endif - -struct GPUContext { - GLuint default_vao; - std::unordered_set batches; /* Batches that have VAOs from this context */ - std::vector orphaned_vertarray_ids; - std::mutex orphans_mutex; /* todo: try spinlock instead */ -#if TRUST_NO_ONE - pthread_t thread; /* Thread on which this context is active. */ - bool thread_is_used; - - GPUContext() { - thread_is_used = false; - } -#endif -}; - -#if defined(_MSC_VER) && (_MSC_VER == 1800) -#define thread_local __declspec(thread) -thread_local GPUContext *active_ctx = NULL; -#else -static thread_local GPUContext *active_ctx = NULL; -#endif - -static void clear_orphans(GPUContext *ctx) -{ - ctx->orphans_mutex.lock(); - if (!ctx->orphaned_vertarray_ids.empty()) { - uint orphan_len = (uint)ctx->orphaned_vertarray_ids.size(); - glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data()); - ctx->orphaned_vertarray_ids.clear(); - } - ctx->orphans_mutex.unlock(); -} - -GPUContext *GPU_context_create(void) -{ -#if TRUST_NO_ONE - /* assert(thread_is_main()); */ -#endif - GPUContext *ctx = new GPUContext; - glGenVertexArrays(1, &ctx->default_vao); - GPU_context_active_set(ctx); - return ctx; -} - -/* to be called after GPU_context_active_set(ctx_to_destroy) */ -void GPU_context_discard(GPUContext *ctx) -{ -#if TRUST_NO_ONE - /* Make sure no other thread has locked it. */ - assert(ctx == active_ctx); - assert(pthread_equal(pthread_self(), ctx->thread)); - assert(ctx->orphaned_vertarray_ids.empty()); -#endif - /* delete remaining vaos */ - while (!ctx->batches.empty()) { - /* this removes the array entry */ - GPU_batch_vao_cache_clear(*ctx->batches.begin()); - } - glDeleteVertexArrays(1, &ctx->default_vao); - delete ctx; - active_ctx = NULL; -} - -/* ctx can be NULL */ -void GPU_context_active_set(GPUContext *ctx) -{ -#if TRUST_NO_ONE - if (active_ctx) { - active_ctx->thread_is_used = false; - } - /* Make sure no other context is already bound to this thread. */ - if (ctx) { - /* Make sure no other thread has locked it. */ - assert(ctx->thread_is_used == false); - ctx->thread = pthread_self(); - ctx->thread_is_used = true; - } -#endif - if (ctx) { - clear_orphans(ctx); - } - active_ctx = ctx; -} - -GPUContext *GPU_context_active_get(void) -{ - return active_ctx; -} - -GLuint GPU_vao_default(void) -{ -#if TRUST_NO_ONE - assert(active_ctx); /* need at least an active context */ - assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ -#endif - return active_ctx->default_vao; -} - -GLuint GPU_vao_alloc(void) -{ -#if TRUST_NO_ONE - assert(active_ctx); /* need at least an active context */ - assert(pthread_equal(pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */ -#endif - clear_orphans(active_ctx); - - GLuint new_vao_id = 0; - glGenVertexArrays(1, &new_vao_id); - return new_vao_id; -} - -/* this can be called from multiple thread */ -void GPU_vao_free(GLuint vao_id, GPUContext *ctx) -{ -#if TRUST_NO_ONE - assert(ctx); -#endif - if (ctx == active_ctx) { - glDeleteVertexArrays(1, &vao_id); - } - else { - ctx->orphans_mutex.lock(); - ctx->orphaned_vertarray_ids.emplace_back(vao_id); - ctx->orphans_mutex.unlock(); - } -} - -void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch) -{ - ctx->batches.emplace(batch); -} - -void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch) -{ - ctx->orphans_mutex.lock(); - ctx->batches.erase(batch); - ctx->orphans_mutex.unlock(); -} diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c index b25d9fc3a2c..d605378bf0e 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.c +++ b/source/blender/gpu/intern/gpu_vertex_buffer.c @@ -30,8 +30,10 @@ */ #include "GPU_vertex_buffer.h" -#include "GPU_buffer_id.h" + +#include "gpu_context_private.h" #include "gpu_vertex_format_private.h" + #include #include @@ -88,7 +90,7 @@ void GPU_vertbuf_init_with_format_ex(GPUVertBuf *verts, const GPUVertFormat *for void GPU_vertbuf_discard(GPUVertBuf *verts) { if (verts->vbo_id) { - GPU_buf_id_free(verts->vbo_id); + GPU_buf_free(verts->vbo_id); #if VRAM_USAGE vbo_memory_usage -= GPU_vertbuf_size_get(verts); #endif @@ -117,7 +119,7 @@ void GPU_vertbuf_data_alloc(GPUVertBuf *verts, uint v_len) #endif /* only create the buffer the 1st time */ if (verts->vbo_id == 0) { - verts->vbo_id = GPU_buf_id_alloc(); + verts->vbo_id = GPU_buf_alloc(); } /* discard previous data if any */ if (verts->data) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 0c7c85e0d94..f7d6561e17f 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -119,6 +119,7 @@ #include "GPU_material.h" #include "GPU_draw.h" +#include "GPU_immediate.h" #include "GPU_init_exit.h" #include "BKE_sound.h" @@ -515,9 +516,11 @@ void WM_exit_ext(bContext *C, const bool do_python) BLF_exit(); if (opengl_is_init) { + DRW_opengl_context_enable_ex(false); GPU_pass_cache_free(); - DRW_opengl_context_destroy(); GPU_exit(); + DRW_opengl_context_disable_ex(false); + DRW_opengl_context_destroy(); } #ifdef WITH_INTERNATIONAL diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index b87ae7e076c..c1006db34ef 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1921,8 +1921,6 @@ void wm_window_raise(wmWindow *win) void wm_window_swap_buffers(wmWindow *win) { - GPU_texture_orphans_delete(); /* XXX should be done elsewhere. */ - GPU_material_orphans_delete(); /* XXX Amen to that. */ GHOST_SwapWindowBuffers(win->ghostwin); } -- cgit v1.2.3 From ca0ecf4c08681753b640482c03dfb3239a37157e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 19 Jul 2018 16:27:44 +0200 Subject: Fix crash with previews of non-IDs, like pose library thumbnails. --- source/blender/editors/render/render_preview.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 450897382dd..884e8d6625b 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -314,6 +314,11 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world) static ID *duplicate_ids(ID *id, Depsgraph *depsgraph) { + if (id == NULL) { + /* Non-ID preview render. */ + return NULL; + } + ID *id_eval = id; if (depsgraph) { -- cgit v1.2.3 From 0bf8096501a8e7883f4061ba3e425966ba7517cd Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 7 Jul 2018 23:21:20 +0300 Subject: Resolve the opposite vector ambiguity in Damped Track constraint. Damped Track by specification attempts to arrive at the desired direction via the shortest rotation. However with opposite vectors there are infinitely many valid 180 degree rotations. Currently it gives up and does nothing. I think that it would be more reasonable to resolve the ambiguity arbitrarily, so that Damped Track won't have a weird dead zone. To make it more predictable I use a local axis. In addition, the singularity area vicinity has some floating point precision problems that result in significant jitter. This applies workarounds for two causes of instability. Differential Revision: https://developer.blender.org/D3530 --- source/blender/blenkernel/intern/constraint.c | 32 ++++++++++++++++++++-- source/blender/blenlib/BLI_math_vector.h | 1 + source/blender/blenlib/intern/math_vector_inline.c | 10 +++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 2a5a0cf9ae7..7d861658993 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3709,7 +3709,7 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t * - the min/max wrappers around (obvec . tarvec) result (stored temporarily in rangle) * are used to ensure that the smallest angle is chosen */ - cross_v3_v3v3(raxis, obvec, tarvec); + cross_v3_v3v3_hi_prec(raxis, obvec, tarvec); rangle = dot_v3v3(obvec, tarvec); rangle = acosf(max_ff(-1.0f, min_ff(1.0f, rangle))); @@ -3717,7 +3717,35 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first */ - axis_angle_to_mat3(rmat, raxis, rangle); + float norm = normalize_v3(raxis); + + if (norm < FLT_EPSILON) { + /* if dot product is nonzero, while cross is zero, we have two opposite vectors! + * - this is an ambiguity in the math that needs to be resolved arbitrarily, + * or there will be a case where damped track strangely does nothing + * - to do that, rotate around a different local axis + */ + float tmpvec[3]; + + if (fabsf(rangle) < M_PI - 0.01f) { + return; + } + + rangle = M_PI; + copy_v3_v3(tmpvec, track_dir_vecs[(data->trackflag + 1) % 6]); + mul_mat3_m4_v3(cob->matrix, tmpvec); + cross_v3_v3v3(raxis, obvec, tmpvec); + + if (normalize_v3(raxis) == 0.0f) { + return; + } + } + else if (norm < 0.1f) { + /* near 0 and Pi arcsin has way better precision than arccos */ + rangle = (rangle > M_PI_2) ? M_PI - asinf(norm) : asinf(norm); + } + + axis_angle_normalized_to_mat3(rmat, raxis, rangle); /* rotate the owner in the way defined by this rotation matrix, then reapply the location since * we may have destroyed that in the process of multiplying the matrix diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 3f603311530..39625346756 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -169,6 +169,7 @@ MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) ATTR_WARN_UNUS MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT; MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]); +MINLINE void cross_v3_v3v3_hi_prec(float r[3], const float a[3], const float b[3]); MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3]); diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 08687a1ab47..715e2e65c96 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -753,6 +753,16 @@ MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]) r[2] = a[0] * b[1] - a[1] * b[0]; } +/* cross product suffers from severe precision loss when vectors are + * nearly parallel or opposite; doing the computation in double helps a lot */ +MINLINE void cross_v3_v3v3_hi_prec(float r[3], const float a[3], const float b[3]) +{ + BLI_assert(r != a && r != b); + r[0] = (float)((double)a[1] * (double)b[2] - (double)a[2] * (double)b[1]); + r[1] = (float)((double)a[2] * (double)b[0] - (double)a[0] * (double)b[2]); + r[2] = (float)((double)a[0] * (double)b[1] - (double)a[1] * (double)b[0]); +} + /* Newell's Method */ /* excuse this fairly specific function, * its used for polygon normals all over the place -- cgit v1.2.3 From 44c7a7cf8bb64f58739b808ef6e80a224bfa9015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 19 Jul 2018 17:18:08 +0200 Subject: Fix compilation error with MSVC --- source/blender/windowmanager/intern/wm_init_exit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index f7d6561e17f..7643086e30a 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -36,6 +36,7 @@ #ifdef _WIN32 # include +# undef interface /* fix conflict with GPU_batch.h */ #endif #include "MEM_guardedalloc.h" -- cgit v1.2.3 From 94722121e572bc8ac4863ae7cdaf26386695202d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 19 Jul 2018 17:20:48 +0200 Subject: Fix MSVC compilation error in a less hacky way --- source/blender/windowmanager/intern/wm_init_exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 7643086e30a..c51d4c5534a 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -35,8 +35,8 @@ #include #ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN # include -# undef interface /* fix conflict with GPU_batch.h */ #endif #include "MEM_guardedalloc.h" -- cgit v1.2.3 From 8a42b3909f33d90b065eec2b8eb342df0a1fb659 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 19 Jul 2018 16:27:18 +0200 Subject: Subsurf: Add basic statistics to help benchmarking --- source/blender/blenkernel/BKE_subdiv.h | 45 ++++++++++++++ source/blender/blenkernel/CMakeLists.txt | 1 + source/blender/blenkernel/intern/subdiv.c | 5 ++ source/blender/blenkernel/intern/subdiv_eval.c | 4 ++ source/blender/blenkernel/intern/subdiv_mesh.c | 2 + source/blender/blenkernel/intern/subdiv_stats.c | 80 +++++++++++++++++++++++++ source/blender/modifiers/intern/MOD_subsurf.c | 1 + 7 files changed, 138 insertions(+) create mode 100644 source/blender/blenkernel/intern/subdiv_stats.c diff --git a/source/blender/blenkernel/BKE_subdiv.h b/source/blender/blenkernel/BKE_subdiv.h index 45316e3cc91..a1792866255 100644 --- a/source/blender/blenkernel/BKE_subdiv.h +++ b/source/blender/blenkernel/BKE_subdiv.h @@ -53,6 +53,40 @@ typedef struct SubdivSettings { eSubdivFVarLinearInterpolation fvar_linear_interpolation; } SubdivSettings; +/* NOTE: Order of enumerators MUST match order of values in SubdivStats. */ +typedef enum eSubdivStatsValue { + SUBDIV_STATS_TOPOLOGY_REFINER_CREATION_TIME = 0, + SUBDIV_STATS_SUBDIV_TO_MESH, + SUBDIV_STATS_EVALUATOR_CREATE, + SUBDIV_STATS_EVALUATOR_REFINE, + + NUM_SUBDIV_STATS_VALUES, +} eSubdivStatsValue; + +typedef struct SubdivStats { + union { + struct { + /* Time spend on creating topology refiner, which includes time + * spend on conversion from Blender data to OpenSubdiv data, and + * time spend on topology orientation on OpenSubdiv C-API side. + */ + double topology_refiner_creation_time; + /* Total time spent in BKE_subdiv_to_mesh(). */ + double subdiv_to_mesh_time; + /* Time spent on evaluator creation from topology refiner. */ + double evaluator_creation_time; + /* Time spent on evaluator->refine(). */ + double evaluator_refine_time; + }; + double values_[NUM_SUBDIV_STATS_VALUES]; + }; + + /* Per-value timestamp on when corresponding BKE_subdiv_stats_begin() was + * called. + */ + double begin_timestamp_[NUM_SUBDIV_STATS_VALUES]; +} SubdivStats; + typedef struct Subdiv { /* Settings this subdivision surface is created for. * @@ -88,8 +122,19 @@ typedef struct Subdiv { /* CPU side evaluator. */ struct OpenSubdiv_Evaluator *evaluator; + + SubdivStats stats; } Subdiv; +/* =============================== STATISTICS =============================== */ + +void BKE_subdiv_stats_init(SubdivStats *stats); + +void BKE_subdiv_stats_begin(SubdivStats *stats, eSubdivStatsValue value); +void BKE_subdiv_stats_end(SubdivStats *stats, eSubdivStatsValue value); + +void BKE_subdiv_stats_print(const SubdivStats *stats); + /* ============================== CONSTRUCTION ============================== */ Subdiv *BKE_subdiv_new_from_converter(const SubdivSettings *settings, diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 0517eb8e732..01910bffdb0 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -191,6 +191,7 @@ set(SRC intern/subdiv_converter_mesh.c intern/subdiv_eval.c intern/subdiv_mesh.c + intern/subdiv_stats.c intern/subsurf_ccg.c intern/suggestions.c intern/text.c diff --git a/source/blender/blenkernel/intern/subdiv.c b/source/blender/blenkernel/intern/subdiv.c index 72cd39983b9..794da2d3477 100644 --- a/source/blender/blenkernel/intern/subdiv.c +++ b/source/blender/blenkernel/intern/subdiv.c @@ -63,6 +63,9 @@ Subdiv *BKE_subdiv_new_from_converter(const SubdivSettings *settings, struct OpenSubdiv_Converter *converter) { #ifdef WITH_OPENSUBDIV + SubdivStats stats; + BKE_subdiv_stats_init(&stats); + BKE_subdiv_stats_begin(&stats, SUBDIV_STATS_TOPOLOGY_REFINER_CREATION_TIME); OpenSubdiv_TopologyRefinerSettings topology_refiner_settings; topology_refiner_settings.level = settings->level; topology_refiner_settings.is_adaptive = settings->is_adaptive; @@ -77,6 +80,8 @@ Subdiv *BKE_subdiv_new_from_converter(const SubdivSettings *settings, subdiv->topology_refiner = osd_topology_refiner; subdiv->evaluator = NULL; update_subdiv_after_topology_change(subdiv); + BKE_subdiv_stats_end(&stats, SUBDIV_STATS_TOPOLOGY_REFINER_CREATION_TIME); + subdiv->stats = stats; return subdiv; #else UNUSED_VARS(settings, converter); diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c index 0ab19fc8df5..4c2ed07cdfa 100644 --- a/source/blender/blenkernel/intern/subdiv_eval.c +++ b/source/blender/blenkernel/intern/subdiv_eval.c @@ -46,8 +46,10 @@ void BKE_subdiv_eval_begin(Subdiv *subdiv) { #ifdef WITH_OPENSUBDIV if (subdiv->evaluator == NULL) { + BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_EVALUATOR_CREATE); subdiv->evaluator = openSubdiv_createEvaluatorFromTopologyRefiner( subdiv->topology_refiner); + BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_EVALUATOR_CREATE); } else { /* TODO(sergey): Check for topology change. */ @@ -112,7 +114,9 @@ void BKE_subdiv_eval_update_from_mesh(Subdiv *subdiv, const Mesh *mesh) break; } /* Update evaluator to the new coarse geometry. */ + BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_EVALUATOR_REFINE); subdiv->evaluator->refine(subdiv->evaluator); + BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_EVALUATOR_REFINE); #else UNUSED_VARS(subdiv, mesh); #endif diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index 7baf03e7265..83f2069ea0f 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -912,6 +912,7 @@ Mesh *BKE_subdiv_to_mesh( const SubdivToMeshSettings *settings, const Mesh *coarse_mesh) { + BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH); /* Make sure evaluator is up to date with possible new topology, and that * is is refined for the new positions of coarse vertices. */ @@ -946,5 +947,6 @@ Mesh *BKE_subdiv_to_mesh( &ctx, subdiv_eval_task, ¶llel_range_settings); + BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH); return result; } diff --git a/source/blender/blenkernel/intern/subdiv_stats.c b/source/blender/blenkernel/intern/subdiv_stats.c new file mode 100644 index 00000000000..5da63fdbacb --- /dev/null +++ b/source/blender/blenkernel/intern/subdiv_stats.c @@ -0,0 +1,80 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 by Blender Foundation. + * All rights reserved. + * + * Contributor(s): Sergey Sharybin. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/subdiv_stats.c + * \ingroup bke + */ + +#include "BKE_subdiv.h" + +#include + +#include "PIL_time.h" + +void BKE_subdiv_stats_init(SubdivStats *stats) +{ + stats->topology_refiner_creation_time = 0.0; + stats->subdiv_to_mesh_time = 0.0; + stats->evaluator_creation_time = 0.0; + stats->evaluator_refine_time = 0.0; +} + +void BKE_subdiv_stats_begin(SubdivStats *stats, eSubdivStatsValue value) +{ + stats->begin_timestamp_[value] = PIL_check_seconds_timer(); +} + +void BKE_subdiv_stats_end(SubdivStats *stats, eSubdivStatsValue value) +{ + stats->values_[value] = + PIL_check_seconds_timer() - stats->begin_timestamp_[value]; +} + +void BKE_subdiv_stats_print(const SubdivStats *stats) +{ +#define STATS_PRINT_TIME(stats, value, description) \ + do { \ + if ((stats)->value > 0.0) { \ + printf(" %s: %f (sec)\n", description, (stats)->value); \ + } \ + } while (false) + + printf("Subdivision surface statistics:\n"); + + STATS_PRINT_TIME(stats, + topology_refiner_creation_time, + "Topology refiner creation time"); + STATS_PRINT_TIME(stats, + subdiv_to_mesh_time, + "Subdivision to mesh time"); + STATS_PRINT_TIME(stats, + evaluator_creation_time, + "Evaluator creation time"); + STATS_PRINT_TIME(stats, + evaluator_refine_time, + "Evaluator refine time"); + +#undef STATS_PRINT_TIME +} diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index c92845a24eb..08dc7c92693 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -247,6 +247,7 @@ static Mesh *applyModifier_subdiv(ModifierData *md, subdiv_mesh_settings_init(&mesh_settings, &subdiv_settings); result = BKE_subdiv_to_mesh(subdiv, &mesh_settings, mesh); /* TODO(sergey): Cache subdiv somehow. */ + // BKE_subdiv_stats_print(&subdiv->stats); BKE_subdiv_free(subdiv); return result; } -- cgit v1.2.3 From c205de020365eddbbc0f0cde0ad02dda91126807 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 19 Jul 2018 16:48:21 +0200 Subject: Fix T55973: [2.8] Crash when 'apply pose as rest pose' when bone scale is 0,0,0. `BKE_pose_rebuild()` should (ideally) always trigger a rebuild of the depsgraph, since it can add or remove posechannels. This function now takes a Main parameter to ensure that related depsgraphes are tagged as dirty (kept it optional, for some corner cases). We should also probably double-check calls to that function, think in theory it should only be called from depsgraph itself? But for now... --- source/blender/blenkernel/BKE_armature.h | 2 +- source/blender/blenkernel/BKE_object.h | 2 +- source/blender/blenkernel/intern/armature.c | 32 ++++++++++++++++------ source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/object.c | 14 ++++++---- source/blender/blenkernel/intern/scene.c | 2 +- .../intern/builder/deg_builder_nodes_rig.cc | 3 +- source/blender/draw/intern/draw_armature.c | 2 +- source/blender/editors/armature/armature_utils.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_relations.c | 4 +-- source/blender/makesrna/intern/rna_object.c | 8 ++++-- 12 files changed, 47 insertions(+), 28 deletions(-) diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index e1bfb05fb59..21d880cf2a7 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -100,7 +100,7 @@ void BKE_armature_where_is(struct bArmature *arm); void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion); void BKE_pose_clear_pointers(struct bPose *pose); void BKE_pose_remap_bone_pointers(struct bArmature *armature, struct bPose *pose); -void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm); +void BKE_pose_rebuild(struct Main *bmain, struct Object *ob, struct bArmature *arm); void BKE_pose_where_is(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); void BKE_pose_where_is_bone(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra); void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 0122185fd2a..79e4f1d448a 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -75,7 +75,7 @@ bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifie void BKE_object_link_modifiers(struct Scene *scene, struct Object *ob_dst, const struct Object *ob_src); void BKE_object_free_modifiers(struct Object *ob, const int flag); -void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); +void BKE_object_make_proxy(struct Main *bmain, struct Object *ob, struct Object *target, struct Object *gob); void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target); bool BKE_object_exists_check(struct Main *bmain, const struct Object *obtest); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index bd9ee7c9e5f..6be4574a62e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -71,6 +71,8 @@ #include "BKE_object.h" #include "BKE_scene.h" +#include "DEG_depsgraph_build.h" + #include "BIK_api.h" /* **************** Generic Functions, data level *************** */ @@ -1951,9 +1953,14 @@ void BKE_pose_remap_bone_pointers(bArmature *armature, bPose *pose) BLI_ghash_free(bone_hash, NULL, NULL); } -/* only after leave editmode, duplicating, validating older files, library syncing */ -/* NOTE: pose->flag is set for it */ -void BKE_pose_rebuild(Object *ob, bArmature *arm) +/** + * Only after leave editmode, duplicating, validating older files, library syncing. + * + * \note pose->flag is set for it. + * + * \param bmain May be NULL, only used to tag depsgraph as being dirty... + */ +void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm) { Bone *bone; bPose *pose; @@ -1998,12 +2005,17 @@ void BKE_pose_rebuild(Object *ob, bArmature *arm) pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected); } - BKE_pose_update_constraint_flags(ob->pose); /* for IK detection for example */ + BKE_pose_update_constraint_flags(pose); /* for IK detection for example */ + + pose->flag &= ~POSE_RECALC; + pose->flag |= POSE_WAS_REBUILT; - ob->pose->flag &= ~POSE_RECALC; - ob->pose->flag |= POSE_WAS_REBUILT; + BKE_pose_channels_hash_make(pose); - BKE_pose_channels_hash_make(ob->pose); + /* Rebuilding poses forces us to also rebuild the dependency graph, since there is one node per pose/bone... */ + if (bmain != NULL) { + DEG_relations_tag_update(bmain); + } } /* ********************** THE POSE SOLVER ******************* */ @@ -2277,8 +2289,10 @@ void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob) if (ELEM(NULL, arm, scene)) return; - if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) - BKE_pose_rebuild(ob, arm); + if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) { + /* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty - hopefully this is OK. */ + BKE_pose_rebuild(NULL, ob, arm); + } ctime = BKE_scene_frame_get(scene); /* not accurate... */ diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index c2cdc8df1e6..351214ed72b 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -2464,7 +2464,7 @@ void BKE_library_make_local( * Try "make all local" in 04_01_H.lighting.blend from Agent327 without this, e.g. */ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->data != NULL && ob->type == OB_ARMATURE && ob->pose != NULL && ob->pose->flag & POSE_RECALC) { - BKE_pose_rebuild(ob, ob->data); + BKE_pose_rebuild(bmain, ob, ob->data); } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 14794bd7061..33ea13c9a38 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1150,7 +1150,7 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src) * * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ -void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_src, const int flag) +void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, const int flag) { ModifierData *md; @@ -1180,7 +1180,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_ copy_object_pose(ob_dst, ob_src, flag_subdata); /* backwards compat... non-armatures can get poses in older files? */ if (ob_src->type == OB_ARMATURE) - BKE_pose_rebuild(ob_dst, ob_dst->data); + BKE_pose_rebuild(bmain, ob_dst, ob_dst->data); } defgroup_copy_list(&ob_dst->defbase, &ob_src->defbase); BKE_object_facemap_copy_list(&ob_dst->fmaps, &ob_src->fmaps); @@ -1359,7 +1359,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target) /* local_object->proxy == pointer to library object, saved in files and read */ /* local_object->proxy_group == pointer to collection dupli-object, saved in files and read */ -void BKE_object_make_proxy(Object *ob, Object *target, Object *cob) +void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob) { /* paranoia checks */ if (ID_IS_LINKED(ob) || !ID_IS_LINKED(target)) { @@ -1434,7 +1434,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *cob) if (target->type == OB_ARMATURE) { copy_object_pose(ob, target, 0); /* data copy, object pointers in constraints */ BKE_pose_rest(ob->pose); /* clear all transforms in channels */ - BKE_pose_rebuild(ob, ob->data); /* set all internal links */ + BKE_pose_rebuild(bmain, ob, ob->data); /* set all internal links */ armature_set_id_extern(ob); } @@ -2698,8 +2698,10 @@ void BKE_object_handle_update_ex(Depsgraph *depsgraph, * with poses we do it ahead of BKE_object_where_is_calc to ensure animation * is evaluated on the rebuilt pose, otherwise we get incorrect poses * on file load */ - if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) - BKE_pose_rebuild(ob, ob->data); + if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) { + /* No need to pass bmain here, we assume we do not need to rebuild DEG from here... */ + BKE_pose_rebuild(NULL, ob, ob->data); + } } } /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index f99a30b75d0..3650fa21c1c 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1288,7 +1288,7 @@ static void scene_armature_depsgraph_workaround(Main *bmain, Depsgraph *depsgrap for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->type == OB_ARMATURE && ob->adt && ob->adt->recalc & ADT_RECALC_ANIM) { if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) { - BKE_pose_rebuild(ob, ob->data); + BKE_pose_rebuild(bmain, ob, ob->data); } } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc index 00d7a5da455..043148a0f70 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -161,7 +161,8 @@ void DepsgraphNodeBuilder::build_rig(Object *object) build_armature(armature); /* Rebuild pose if not up to date. */ if (object->pose == NULL || (object->pose->flag & POSE_RECALC)) { - BKE_pose_rebuild(object, armature); + /* By definition, no need to tag depsgraph as dirty from here, so we can pass NULL bmain. */ + BKE_pose_rebuild(NULL, object, armature); /* XXX: Without this animation gets lost in certain circumstances * after loading file. Need to investigate further since it does * not happen with simple scenes.. diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index b49ca4d0d00..8b90d328541 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -1623,7 +1623,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4]) /* We can't safely draw non-updated pose, might contain NULL bone pointers... */ if (ob->pose->flag & POSE_RECALC) { - BKE_pose_rebuild(ob, arm); + BKE_pose_rebuild(NULL, ob, arm); } // if (!(base->flag & OB_FROMDUPLI)) // TODO diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 02d45a4e041..c93bfb5d8c3 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -681,7 +681,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) /* so all users of this armature should get rebuilt */ for (obt = bmain->object.first; obt; obt = obt->id.next) { if (obt->data == arm) { - BKE_pose_rebuild(obt, arm); + BKE_pose_rebuild(bmain, obt, arm); } } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index a8917f4c4aa..8c60dd01e89 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -2222,7 +2222,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer ID_NEW_REMAP_US2(obn->data) else { obn->data = ID_NEW_SET(obn->data, BKE_armature_copy(bmain, obn->data)); - BKE_pose_rebuild(obn, obn->data); + BKE_pose_rebuild(bmain, obn, obn->data); didit = 1; } id_us_min(id); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 324b6eca34a..2c3ff8b6afe 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -360,7 +360,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op) newob = BKE_object_add_from(bmain, scene, view_layer, OB_EMPTY, name, gob ? gob : ob); /* set layers OK */ - BKE_object_make_proxy(newob, ob, gob); + BKE_object_make_proxy(bmain, newob, ob, gob); /* Set back pointer immediately so dependency graph knows that this is * is a proxy and will act accordingly. Otherwise correctness of graph @@ -1809,7 +1809,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer case OB_ARMATURE: DEG_id_tag_update(&ob->id, OB_RECALC_DATA); ob->data = ID_NEW_SET(ob->data, BKE_armature_copy(bmain, ob->data)); - BKE_pose_rebuild(ob, ob->data); + BKE_pose_rebuild(bmain, ob, ob->data); break; case OB_SPEAKER: ob->data = ID_NEW_SET(ob->data, BKE_speaker_copy(bmain, ob->data)); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 2bdfbade53a..ac1a6d512c3 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -356,10 +356,12 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) ob->data = id; test_object_materials(G_MAIN, ob, id); - if (GS(id->name) == ID_CU) + if (GS(id->name) == ID_CU) { BKE_curve_type_test(ob); - else if (ob->type == OB_ARMATURE) - BKE_pose_rebuild(ob, ob->data); + } + else if (ob->type == OB_ARMATURE) { + BKE_pose_rebuild(G_MAIN, ob, ob->data); + } } } -- cgit v1.2.3 From 2de283615f081fa76fb05ac0bf81f831651f9e51 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 19 Jul 2018 16:52:49 +0200 Subject: Make `draw_armature()` abort in case pose is not up-to-date. Previously it was calling `BKE_pose_rebuild()`, such thing shall never be called from drawing code! Hopefully this now works as expected and that horrible hack is not needed anymore. --- source/blender/draw/intern/draw_armature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index 8b90d328541..f0a32dfc8e0 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -1623,7 +1623,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4]) /* We can't safely draw non-updated pose, might contain NULL bone pointers... */ if (ob->pose->flag & POSE_RECALC) { - BKE_pose_rebuild(NULL, ob, arm); + return; } // if (!(base->flag & OB_FROMDUPLI)) // TODO -- cgit v1.2.3 From f48e81e720c1e5fcc93ba6da11f862263da9cadc Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 20 Jul 2018 12:01:38 +0200 Subject: Fix T55414: waveforms are reprocessed when undoing Add new tag to bSound (runtime flags), and make read code to set a 'no reload waveform' new tag, since it uses a mapping to get existing waveform in undo case... --- source/blender/blenkernel/intern/sound.c | 18 +++++++++++------- source/blender/blenloader/intern/readfile.c | 2 ++ source/blender/makesdna/DNA_sound_types.h | 10 +++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 6aa44cde0e0..709a0022767 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -757,15 +757,19 @@ int BKE_sound_scene_playing(struct Scene *scene) void BKE_sound_free_waveform(bSound *sound) { - SoundWaveform *waveform = sound->waveform; - if (waveform) { - if (waveform->data) { - MEM_freeN(waveform->data); + if ((sound->tags & SOUND_TAGS_WAVEFORM_NO_RELOAD) == 0) { + SoundWaveform *waveform = sound->waveform; + if (waveform) { + if (waveform->data) { + MEM_freeN(waveform->data); + } + MEM_freeN(waveform); } - MEM_freeN(waveform); - } - sound->waveform = NULL; + sound->waveform = NULL; + } + /* This tag is only valid once. */ + sound->tags &= ~SOUND_TAGS_WAVEFORM_NO_RELOAD; } void BKE_sound_read_waveform(bSound *sound, short *stop) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1def462b1ca..1d772a15efd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7542,6 +7542,7 @@ static void direct_link_speaker(FileData *fd, Speaker *spk) static void direct_link_sound(FileData *fd, bSound *sound) { + sound->tags = 0; sound->handle = NULL; sound->playback_handle = NULL; @@ -7553,6 +7554,7 @@ static void direct_link_sound(FileData *fd, bSound *sound) if (fd->soundmap) { sound->waveform = newsoundadr(fd, sound->waveform); + sound->tags |= SOUND_TAGS_WAVEFORM_NO_RELOAD; } else { sound->waveform = NULL; diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index aefe1a7d5a3..7778582b82d 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -65,13 +65,15 @@ typedef struct bSound { */ struct PackedFile *newpackedfile; struct Ipo *ipo; + float volume; float attenuation; float pitch; float min_gain; float max_gain; float distance; - int flags; + short flags; + short tags; /* Runtime only, always reset in readfile. */ int pad; /* unused currently @@ -116,6 +118,7 @@ enum { SND_CFRA_NUM = 2, }; +/* bSound->flags */ enum { #ifdef DNA_DEPRECATED SOUND_FLAGS_3D = (1 << 3), /* deprecated! used for sound actuator loading */ @@ -125,6 +128,11 @@ enum { SOUND_FLAGS_WAVEFORM_LOADING = (1 << 6), }; +/* bSound->tags */ +enum { + SOUND_TAGS_WAVEFORM_NO_RELOAD = 1 << 0, /* Do not free/reset waveform on sound load, only used by undo code. */ +}; + /* to DNA_sound_types.h*/ #endif -- cgit v1.2.3 From 710a05954990c347932b9f540a1b220ea2c5c0da Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 20 Jul 2018 12:11:34 +0200 Subject: Cleanup: Move 'WAVEFORM_LOADING' of sounds from flags to tags. This is purely runtime data, so move it to new tags. ;) --- source/blender/blenkernel/intern/sound.c | 4 ++-- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/editors/space_sequencer/sequencer_draw.c | 4 ++-- source/blender/editors/space_sequencer/sequencer_preview.c | 2 +- source/blender/makesdna/DNA_sound_types.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 709a0022767..d21055ada6a 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -798,7 +798,7 @@ void BKE_sound_read_waveform(bSound *sound, short *stop) } MEM_freeN(waveform); BLI_spin_lock(sound->spinlock); - sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING; + sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING; BLI_spin_unlock(sound->spinlock); return; } @@ -807,7 +807,7 @@ void BKE_sound_read_waveform(bSound *sound, short *stop) BLI_spin_lock(sound->spinlock); sound->waveform = waveform; - sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING; + sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING; BLI_spin_unlock(sound->spinlock); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1d772a15efd..bdfae79a1d0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7565,7 +7565,7 @@ static void direct_link_sound(FileData *fd, bSound *sound) BLI_spin_init(sound->spinlock); } /* clear waveform loading flag */ - sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING; + sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING; sound->packedfile = direct_link_packedfile(fd, sound->packedfile); sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 97c42cc11e0..915e2466d54 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -220,9 +220,9 @@ static void drawseqwave(const bContext *C, SpaceSeq *sseq, Scene *scene, Sequenc BLI_spin_lock(sound->spinlock); if (!sound->waveform) { - if (!(sound->flags & SOUND_FLAGS_WAVEFORM_LOADING)) { + if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) { /* prevent sounds from reloading */ - sound->flags |= SOUND_FLAGS_WAVEFORM_LOADING; + sound->tags |= SOUND_TAGS_WAVEFORM_LOADING; BLI_spin_unlock(sound->spinlock); sequencer_preview_add_sound(C, seq); } diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c index c58c05b67c0..ae011e48538 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.c +++ b/source/blender/editors/space_sequencer/sequencer_preview.c @@ -96,7 +96,7 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p /* make sure we cleanup the loading flag! */ BLI_spin_lock(sound->spinlock); - sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING; + sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING; BLI_spin_unlock(sound->spinlock); BLI_mutex_lock(pj->mutex); diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index 7778582b82d..02d3aa928c7 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -125,12 +125,12 @@ enum { #endif SOUND_FLAGS_CACHING = (1 << 4), SOUND_FLAGS_MONO = (1 << 5), - SOUND_FLAGS_WAVEFORM_LOADING = (1 << 6), }; /* bSound->tags */ enum { SOUND_TAGS_WAVEFORM_NO_RELOAD = 1 << 0, /* Do not free/reset waveform on sound load, only used by undo code. */ + SOUND_TAGS_WAVEFORM_LOADING = (1 << 6), }; /* to DNA_sound_types.h*/ -- cgit v1.2.3 From 61c00802d0a9d1698f85633ba1c121b1a17e6425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 12:30:23 +0200 Subject: Basic Draw Engine: Cleanup unused code. This engine is only used for selection and draw depth so no need for anything else. Also add backface culling support to selection. --- source/blender/draw/engines/basic/basic_engine.c | 65 ++---------------------- 1 file changed, 3 insertions(+), 62 deletions(-) diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index a9c758d5b6f..57553d98d5d 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -42,9 +42,6 @@ #define BASIC_ENGINE "BLENDER_BASIC" -/* we may want this later? */ -#define USE_DEPTH - /* *********** LISTS *********** */ /* GPUViewport.storage @@ -54,11 +51,8 @@ typedef struct BASIC_StorageList { } BASIC_StorageList; typedef struct BASIC_PassList { -#ifdef USE_DEPTH struct DRWPass *depth_pass; struct DRWPass *depth_pass_cull; -#endif - struct DRWPass *color_pass; } BASIC_PassList; typedef struct BASIC_Data { @@ -72,38 +66,24 @@ typedef struct BASIC_Data { /* *********** STATIC *********** */ static struct { -#ifdef USE_DEPTH /* Depth Pre Pass */ struct GPUShader *depth_sh; -#endif - /* Shading Pass */ - struct GPUShader *color_sh; } e_data = {NULL}; /* Engine data */ typedef struct BASIC_PrivateData { -#ifdef USE_DEPTH DRWShadingGroup *depth_shgrp; DRWShadingGroup *depth_shgrp_cull; DRWShadingGroup *depth_shgrp_hair; -#endif - DRWShadingGroup *color_shgrp; } BASIC_PrivateData; /* Transient data */ /* Functions */ static void basic_engine_init(void *UNUSED(vedata)) { -#ifdef USE_DEPTH /* Depth prepass */ if (!e_data.depth_sh) { e_data.depth_sh = DRW_shader_create_3D_depth_only(); } -#endif - - /* Shading pass */ - if (!e_data.color_sh) { - e_data.color_sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR); - } } static void basic_cache_init(void *vedata) @@ -116,8 +96,6 @@ static void basic_cache_init(void *vedata) stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__); } -#ifdef USE_DEPTH - /* Depth Pass */ { psl->depth_pass = DRW_pass_create( "Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WIRE); @@ -128,13 +106,6 @@ static void basic_cache_init(void *vedata) DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK); stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull); } -#endif - - /* Color Pass */ - { - psl->color_pass = DRW_pass_create("Color Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); - stl->g_data->color_shgrp = DRW_shgroup_create(e_data.color_sh, psl->color_pass); - } } static void basic_cache_populate(void *vedata, Object *ob) @@ -168,13 +139,9 @@ static void basic_cache_populate(void *vedata, Object *ob) struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { - bool do_cull = false; /* TODO (we probably wan't to take this from the viewport?) */ -#ifdef USE_DEPTH + const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING)); /* Depth Prepass */ DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat); -#endif - /* Shading */ - DRW_shgroup_call_add(stl->g_data->color_shgrp, geom, ob->obmat); } } @@ -187,36 +154,10 @@ static void basic_cache_finish(void *vedata) static void basic_draw_scene(void *vedata) { - BASIC_PassList *psl = ((BASIC_Data *)vedata)->psl; - const bool is_select = DRW_state_is_select(); - - bool use_color = true; - bool use_depth = true; - bool use_depth_cull = true; - if (is_select) { - /* Needed for depth-picking, - * for other selection types there are no need for extra passes either. */ - use_color = false; - use_depth_cull = false; - } - -#ifdef USE_DEPTH - /* Pass 1 : Depth pre-pass */ - if (use_depth) { - DRW_draw_pass(psl->depth_pass); - } - - if (use_depth_cull) { - DRW_draw_pass(psl->depth_pass_cull); - } -#endif - - /* Pass 3 : Shading */ - if (use_color) { - DRW_draw_pass(psl->color_pass); - } + DRW_draw_pass(psl->depth_pass); + DRW_draw_pass(psl->depth_pass_cull); } static void basic_engine_free(void) -- cgit v1.2.3 From a185bf3b856846b2e300542bacdca3bc119e1bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 12:40:35 +0200 Subject: Workbench: Add backface culling support --- source/blender/draw/engines/workbench/workbench_deferred.c | 6 ++++-- source/blender/draw/engines/workbench/workbench_forward.c | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index ce209af8527..4e90a08a543 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -272,6 +272,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + const DRWContextState *draw_ctx = DRW_context_state_get(); if (!stl->g_data) { /* Alloc transient pointers */ @@ -381,7 +382,6 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) } { - const DRWContextState *draw_ctx = DRW_context_state_get(); Scene *scene = draw_ctx->scene; /* AO Samples Tex */ int num_iterations = workbench_taa_calculate_num_iterations(vedata); @@ -405,8 +405,10 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) /* Prepass */ { + const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING)); + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; - psl->prepass_pass = DRW_pass_create("Prepass", state); + psl->prepass_pass = DRW_pass_create("Prepass", (do_cull) ? state | DRW_STATE_CULL_BACK : state); psl->prepass_hair_pass = DRW_pass_create("Prepass", state); } diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 2a65feeb28c..825b80ace52 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -243,6 +243,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) WORKBENCH_PassList *psl = vedata->psl; WORKBENCH_StorageList *stl = vedata->stl; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + const DRWContextState *draw_ctx = DRW_context_state_get(); DRWShadingGroup *grp; if (!stl->g_data) { @@ -322,15 +323,17 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) }); workbench_volume_cache_init(vedata); + const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING)); + const int cull_state = (do_cull) ? DRW_STATE_CULL_BACK : 0; /* Transparency Accum */ { - int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT; + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT | cull_state; psl->transparent_accum_pass = DRW_pass_create("Transparent Accum", state); } /* Depth */ { - int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | cull_state; psl->object_outline_pass = DRW_pass_create("Object Outline Pass", state); } /* Composite */ -- cgit v1.2.3 From 244b825ccd563672516b985348361b7a311e0f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 12:54:57 +0200 Subject: Fix assert for Image & Brush icon preview --- source/blender/editors/render/render_preview.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 884e8d6625b..7270eb03c2e 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -334,6 +334,10 @@ static ID *duplicate_ids(ID *id, Depsgraph *depsgraph) return (ID *)BKE_lamp_localize((Lamp *)id_eval); case ID_WO: return (ID *)BKE_world_localize((World *)id_eval); + case ID_IM: + case ID_BR: + case ID_SCR: + return NULL; default: BLI_assert(!"ID type preview not supported."); return NULL; -- cgit v1.2.3 From 4a79b46b9c7a7800e7e333163e6e4d3f30285d28 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 20 Jul 2018 13:35:08 +0200 Subject: Fix build error with release + debug info build. --- source/blender/gpu/intern/gpu_context.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/gpu/intern/gpu_context.cpp b/source/blender/gpu/intern/gpu_context.cpp index 6a42552c2fd..3f2ce958332 100644 --- a/source/blender/gpu/intern/gpu_context.cpp +++ b/source/blender/gpu/intern/gpu_context.cpp @@ -151,8 +151,10 @@ void GPU_context_discard(GPUContext *ctx) BLI_assert(ctx == active_ctx); BLI_assert(pthread_equal(pthread_self(), ctx->thread)); BLI_assert(ctx->orphaned_vertarray_ids.empty()); +#ifdef DEBUG /* For now don't allow GPUFrameBuffers to be reuse in another ctx. */ BLI_assert(ctx->framebuffers.empty()); +#endif /* delete remaining vaos */ while (!ctx->batches.empty()) { /* this removes the array entry */ -- cgit v1.2.3 From 72cbf966fb9194edbe6fa82cfd02540dc306184a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 20 Jul 2018 15:13:48 +0200 Subject: Depsgraph: Fix missing relation from proxy_form's ID properties Hopefully this will fix issue with camera rig where camera properties (like, near/far clip) are driven by custom properties from bones, and those bones are actually belong to proxied armature. --- .../blender/depsgraph/intern/builder/deg_builder_nodes.cc | 11 +++++++++++ .../depsgraph/intern/builder/deg_builder_relations.cc | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index ab7ddb507a0..1b68a73bbd7 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -829,8 +829,19 @@ void DepsgraphNodeBuilder::build_driver_variables(ID * id, FCurve *fcurve) LISTBASE_FOREACH (DriverVar *, dvar, &fcurve->driver->variables) { DRIVER_TARGETS_USED_LOOPER(dvar) { + if (dtar->id == NULL) { + continue; + } build_id(dtar->id); build_driver_id_property(dtar->id, dtar->rna_path); + /* Corresponds to dtar_id_ensure_proxy_from(). */ + if ((GS(dtar->id->name) == ID_OB) && + (((Object *)dtar->id)->proxy_from != NULL)) + { + Object *proxy_from = ((Object *)dtar->id)->proxy_from; + build_id(&proxy_from->id); + build_driver_id_property(&proxy_from->id, dtar->rna_path); + } } DRIVER_TARGETS_LOOPER_END } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index bba1ba67962..1a0c621ab43 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1351,6 +1351,14 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu) continue; } build_id(dtar->id); + /* Initialize relations coming to proxy_from. */ + Object *proxy_from = NULL; + if ((GS(dtar->id->name) == ID_OB) && + (((Object *)dtar->id)->proxy_from != NULL)) + { + proxy_from = ((Object *)dtar->id)->proxy_from; + build_id(&proxy_from->id); + } /* Special handling for directly-named bones. */ if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (((Object *)dtar->id)->type == OB_ARMATURE) && @@ -1398,6 +1406,13 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu) continue; } add_relation(variable_key, driver_key, "RNA Target -> Driver"); + if (proxy_from != NULL) { + RNAPathKey proxy_from_variable_key(&proxy_from->id, + dtar->rna_path); + add_relation(proxy_from_variable_key, + variable_key, + "Proxy From -> Variable"); + } } else { if (dtar->id == id) { -- cgit v1.2.3 From b3b4b9fb8c255d2ec7cc7433ffcafef6311da6e9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 20 Jul 2018 15:12:36 +0200 Subject: Fix WITH_HEADLESS build. --- intern/ghost/intern/GHOST_SystemNULL.h | 2 ++ source/blender/windowmanager/intern/wm_event_system.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/intern/ghost/intern/GHOST_SystemNULL.h b/intern/ghost/intern/GHOST_SystemNULL.h index 7c8d26d7486..ac3dfd71d63 100644 --- a/intern/ghost/intern/GHOST_SystemNULL.h +++ b/intern/ghost/intern/GHOST_SystemNULL.h @@ -53,6 +53,8 @@ public: void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const { /* nop */ } void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const { /* nop */ } bool supportsNativeDialogs(void) { return false;} + GHOST_IContext *createOffscreenContext() { return NULL; } + GHOST_TSuccess disposeContext(GHOST_IContext *context) { return GHOST_kFailure; } GHOST_TSuccess init() { GHOST_TSuccess success = GHOST_System::init(); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index e2247b2adff..8b1cce27502 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -4569,7 +4569,11 @@ bool WM_window_modal_keymap_status_draw( continue; } int icon_mod[4]; +#ifdef WITH_HEADLESS + int icon = 0; +#else int icon = UI_icon_from_keymap_item(kmi, icon_mod); +#endif if (icon != 0) { for (int j = 0; j < ARRAY_SIZE(icon_mod) && icon_mod[j]; j++) { uiItemL(row, "", icon_mod[j]); -- cgit v1.2.3 From 9ad5eafe465e4ab0c9945e234b187dc210ac608a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 20 Jul 2018 17:38:24 +0200 Subject: Fix incorrect magnification filter for text texture. Barely any visible difference, except when drawing big custom text with the Python API. --- source/blender/blenfont/intern/blf_glyph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 30e31bb2580..99be8539d24 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -244,7 +244,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) gc->textures[gc->texture_current] = tex; GPU_texture_bind(tex, 0); GPU_texture_wrap_mode(tex, false); - GPU_texture_filters(tex, GPU_NEAREST, GPU_LINEAR); + GPU_texture_filters(tex, GPU_NEAREST, GPU_NEAREST); GPU_texture_unbind(tex); } -- cgit v1.2.3 From e7d8908f1405bbe54df2b5b51b4c1078200e5020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 15:25:20 +0200 Subject: GPUMaterial: Optimize and fix blending in box mapping Blending was done in srgb space and was not matching cycles. Optimized by using less branches and more vector operations. --- .../blender/gpu/shaders/gpu_shader_material.glsl | 116 ++++++++++----------- .../nodes/shader/nodes/node_shader_tex_image.c | 31 ++++-- 2 files changed, 78 insertions(+), 69 deletions(-) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index d1183c792f5..4b376160105 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1804,18 +1804,46 @@ void node_tex_image(vec3 co, sampler2D ima, out vec4 color, out float alpha) alpha = color.a; } +void tex_box_sample(vec3 texco, + vec3 N, + sampler2D ima, + out vec4 color1, + out vec4 color2, + out vec4 color3) +{ + /* X projection */ + vec2 uv = texco.yz; + if (N.x < 0.0) { + uv.x = 1.0 - uv.x; + } + color1 = texture(ima, uv); + /* Y projection */ + uv = texco.xz; + if (N.y > 0.0) { + uv.x = 1.0 - uv.x; + } + color2 = texture(ima, uv); + /* Z projection */ + uv = texco.yx; + if (N.z > 0.0) { + uv.x = 1.0 - uv.x; + } + color3 = texture(ima, uv); +} + void node_tex_image_box(vec3 texco, vec3 N, + vec4 color1, + vec4 color2, + vec4 color3, sampler2D ima, float blend, out vec4 color, out float alpha) { - vec3 signed_N = N; - /* project from direction vector to barycentric coordinates in triangles */ - N = vec3(abs(N.x), abs(N.y), abs(N.z)); - N /= (N.x + N.y + N.z); + N = abs(N); + N /= dot(N, vec3(1.0)); /* basic idea is to think of this as a triangle, each corner representing * one of the 3 faces of the cube. in the corners we have single textures, @@ -1825,72 +1853,36 @@ void node_tex_image_box(vec3 texco, * the Nxyz values are the barycentric coordinates in an equilateral * triangle, which in case of blending, in the middle has a smaller * equilateral triangle where 3 textures blend. this divides things into - * 7 zones, with an if () test for each zone */ + * 7 zones, with an if () test for each zone + * EDIT: Now there is only 4 if's. */ - vec3 weight = vec3(0.0, 0.0, 0.0); - float limit = 0.5 * (1.0 + blend); + float limit = 0.5 + 0.5 * blend; - /* first test for corners with single texture */ - if (N.x > limit * (N.x + N.y) && N.x > limit * (N.x + N.z)) { - weight.x = 1.0; - } - else if (N.y > limit * (N.x + N.y) && N.y > limit * (N.y + N.z)) { - weight.y = 1.0; + vec3 weight; + weight.x = N.x / (N.x + N.y); + weight.y = N.y / (N.y + N.z); + weight.z = N.z / (N.x + N.z); + weight = clamp((weight - 0.5 * (1.0 - blend)) / max(1e-8, blend), 0.0, 1.0); + + /* test for mixes between two textures */ + if (N.z < (1.0 - limit) * (N.y + N.x)) { + weight.z = 0.0; + weight.y = 1.0 - weight.x; } - else if (N.z > limit * (N.x + N.z) && N.z > limit * (N.y + N.z)) { - weight.z = 1.0; + else if (N.x < (1.0 - limit) * (N.y + N.z)) { + weight.x = 0.0; + weight.z = 1.0 - weight.y; } - else if (blend > 0.0) { - /* in case of blending, test for mixes between two textures */ - if (N.z < (1.0 - limit) * (N.y + N.x)) { - weight.x = N.x / (N.x + N.y); - weight.x = clamp((weight.x - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0); - weight.y = 1.0 - weight.x; - } - else if (N.x < (1.0 - limit) * (N.y + N.z)) { - weight.y = N.y / (N.y + N.z); - weight.y = clamp((weight.y - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0); - weight.z = 1.0 - weight.y; - } - else if (N.y < (1.0 - limit) * (N.x + N.z)) { - weight.x = N.x / (N.x + N.z); - weight.x = clamp((weight.x - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0); - weight.z = 1.0 - weight.x; - } - else { - /* last case, we have a mix between three */ - weight.x = ((2.0 - limit) * N.x + (limit - 1.0)) / (2.0 * limit - 1.0); - weight.y = ((2.0 - limit) * N.y + (limit - 1.0)) / (2.0 * limit - 1.0); - weight.z = ((2.0 - limit) * N.z + (limit - 1.0)) / (2.0 * limit - 1.0); - } + else if (N.y < (1.0 - limit) * (N.x + N.z)) { + weight.y = 0.0; + weight.x = 1.0 - weight.z; } else { - /* Desperate mode, no valid choice anyway, fallback to one side.*/ - weight.x = 1.0; - } - color = vec4(0); - if (weight.x > 0.0) { - vec2 uv = texco.yz; - if(signed_N.x < 0.0) { - uv.x = 1.0 - uv.x; - } - color += weight.x * texture(ima, uv); - } - if (weight.y > 0.0) { - vec2 uv = texco.xz; - if(signed_N.y > 0.0) { - uv.x = 1.0 - uv.x; - } - color += weight.y * texture(ima, uv); - } - if (weight.z > 0.0) { - vec2 uv = texco.yx; - if(signed_N.z > 0.0) { - uv.x = 1.0 - uv.x; - } - color += weight.z * texture(ima, uv); + /* last case, we have a mix between three */ + weight = ((2.0 - limit) * N + (limit - 1.0)) / max(1e-8, 2.0 * limit - 1.0); } + color = weight.x * color1 + weight.y * color2 + weight.z * color3; alpha = color.a; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index 2bbe3617bee..20753445aa6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -58,8 +58,9 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat Image *ima = (Image *)node->id; ImageUser *iuser = NULL; NodeTexImage *tex = node->storage; + bool do_color_correction = false; - GPUNodeLink *norm; + GPUNodeLink *norm, *col1, *col2, *col3; int isdata = tex->color_space == SHD_COLORSPACE_NONE; float blend = tex->projection_blend; @@ -67,6 +68,15 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat if (!ima) return GPU_stack_link(mat, node, "node_tex_image_empty", in, out); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); + if ((tex->color_space == SHD_COLORSPACE_COLOR) && + ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && + GPU_material_do_color_management(mat)) + { + do_color_correction = true; + } + BKE_image_release_ibuf(ima, ibuf, NULL); + if (!in[0].link) in[0].link = GPU_attribute(CD_MTFACE, ""); @@ -83,8 +93,20 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat GPU_link(mat, "direction_transform_m4v3", norm, GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), &norm); + GPU_link(mat, "tex_box_sample", in[0].link, + norm, + GPU_image(ima, iuser, isdata), + &col1, + &col2, + &col3); + if (do_color_correction) { + GPU_link(mat, "srgb_to_linearrgb", col1, &col1); + GPU_link(mat, "srgb_to_linearrgb", col2, &col2); + GPU_link(mat, "srgb_to_linearrgb", col3, &col3); + } GPU_link(mat, "node_tex_image_box", in[0].link, norm, + col1, col2, col3, GPU_image(ima, iuser, isdata), GPU_uniform(&blend), &out[0].link, @@ -102,14 +124,9 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat break; } - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); - if ((tex->color_space == SHD_COLORSPACE_COLOR) && - ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && - GPU_material_do_color_management(mat)) - { + if (do_color_correction && (tex->projection != SHD_PROJ_BOX)) { GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); } - BKE_image_release_ibuf(ima, ibuf, NULL); return true; } -- cgit v1.2.3 From 26b6b5871ea83dea372495b56ac2768bb63e88b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 15:45:59 +0200 Subject: GPUMaterial: Texture Node: support for nearest (closest) filtering method Add placeholder for cubic and smart filtering for now. --- .../blender/gpu/shaders/gpu_shader_material.glsl | 72 +++++++++++++++++++++- .../nodes/shader/nodes/node_shader_tex_image.c | 34 +++++++--- 2 files changed, 95 insertions(+), 11 deletions(-) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 4b376160105..7f2475f0aab 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1798,13 +1798,31 @@ void node_tex_environment_empty(vec3 co, out vec4 color) color = vec4(1.0, 0.0, 1.0, 1.0); } -void node_tex_image(vec3 co, sampler2D ima, out vec4 color, out float alpha) +void node_tex_image_linear(vec3 co, sampler2D ima, out vec4 color, out float alpha) { color = texture(ima, co.xy); alpha = color.a; } -void tex_box_sample(vec3 texco, +void node_tex_image_nearest(vec3 co, sampler2D ima, out vec4 color, out float alpha) +{ + ivec2 pix = ivec2(co.xy * textureSize(ima, 0).xy); + color = texelFetch(ima, pix, 0); + alpha = color.a; +} + +void node_tex_image_cubic(vec3 co, sampler2D ima, out vec4 color, out float alpha) +{ + node_tex_image_linear(co, ima, color, alpha); +} + +void node_tex_image_smart(vec3 co, sampler2D ima, out vec4 color, out float alpha) +{ + /* use cubic for now */ + node_tex_image_cubic(co, ima, color, alpha); +} + +void tex_box_sample_linear(vec3 texco, vec3 N, sampler2D ima, out vec4 color1, @@ -1831,6 +1849,56 @@ void tex_box_sample(vec3 texco, color3 = texture(ima, uv); } +void tex_box_sample_nearest(vec3 texco, + vec3 N, + sampler2D ima, + out vec4 color1, + out vec4 color2, + out vec4 color3) +{ + /* X projection */ + vec2 uv = texco.yz; + if (N.x < 0.0) { + uv.x = 1.0 - uv.x; + } + ivec2 pix = ivec2(uv.xy * textureSize(ima, 0).xy); + color1 = texelFetch(ima, pix, 0); + /* Y projection */ + uv = texco.xz; + if (N.y > 0.0) { + uv.x = 1.0 - uv.x; + } + pix = ivec2(uv.xy * textureSize(ima, 0).xy); + color2 = texelFetch(ima, pix, 0); + /* Z projection */ + uv = texco.yx; + if (N.z > 0.0) { + uv.x = 1.0 - uv.x; + } + pix = ivec2(uv.xy * textureSize(ima, 0).xy); + color3 = texelFetch(ima, pix, 0); +} + +void tex_box_sample_cubic(vec3 texco, + vec3 N, + sampler2D ima, + out vec4 color1, + out vec4 color2, + out vec4 color3) +{ + tex_box_sample_linear(texco, N, ima, color1, color2, color3); +} + +void tex_box_sample_smart(vec3 texco, + vec3 N, + sampler2D ima, + out vec4 color1, + out vec4 color2, + out vec4 color3) +{ + tex_box_sample_cubic(texco, N, ima, color1, color2, color3); +} + void node_tex_image_box(vec3 texco, vec3 N, vec4 color1, diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index 20753445aa6..9782df2638f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -55,9 +55,25 @@ static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node) static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) { + static const char *names[] = { + "node_tex_image_linear", + "node_tex_image_nearest", + "node_tex_image_cubic", + "node_tex_image_smart" + }; + static const char *names_box[] = { + "tex_box_sample_linear", + "tex_box_sample_nearest", + "tex_box_sample_cubic", + "tex_box_sample_smart" + }; + Image *ima = (Image *)node->id; ImageUser *iuser = NULL; NodeTexImage *tex = node->storage; + const char *gpu_node_name = (tex->projection == SHD_PROJ_BOX) + ? names_box[tex->interpolation] + : names[tex->interpolation]; bool do_color_correction = false; GPUNodeLink *norm, *col1, *col2, *col3; @@ -84,7 +100,7 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat switch (tex->projection) { case SHD_PROJ_FLAT: - GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); + GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata)); break; case SHD_PROJ_BOX: GPU_link(mat, "direction_transform_m4v3", GPU_builtin(GPU_VIEW_NORMAL), @@ -93,12 +109,12 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat GPU_link(mat, "direction_transform_m4v3", norm, GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), &norm); - GPU_link(mat, "tex_box_sample", in[0].link, - norm, - GPU_image(ima, iuser, isdata), - &col1, - &col2, - &col3); + GPU_link(mat, gpu_node_name, in[0].link, + norm, + GPU_image(ima, iuser, isdata), + &col1, + &col2, + &col3); if (do_color_correction) { GPU_link(mat, "srgb_to_linearrgb", col1, &col1); GPU_link(mat, "srgb_to_linearrgb", col2, &col2); @@ -115,12 +131,12 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat case SHD_PROJ_SPHERE: GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link); GPU_link(mat, "point_map_to_sphere", in[0].link, &in[0].link); - GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); + GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata)); break; case SHD_PROJ_TUBE: GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link); GPU_link(mat, "point_map_to_tube", in[0].link, &in[0].link); - GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); + GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata)); break; } -- cgit v1.2.3 From 28fa79219df8d103ccc4af9433c581be50ae2bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 19:16:33 +0200 Subject: GPUMaterial: Texture Node: Add support for Cubic filtering Like in cycles it's a bit more slower than linear but it's smoother. Works for all projection type. --- .../blender/gpu/shaders/gpu_shader_material.glsl | 76 +++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 7f2475f0aab..961837f6b16 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1813,7 +1813,61 @@ void node_tex_image_nearest(vec3 co, sampler2D ima, out vec4 color, out float al void node_tex_image_cubic(vec3 co, sampler2D ima, out vec4 color, out float alpha) { - node_tex_image_linear(co, ima, color, alpha); + vec2 tex_size = vec2(textureSize(ima, 0).xy); + + co.xy *= tex_size; + /* texel center */ + vec2 tc = floor(co.xy - 0.5) + 0.5; + vec2 f = co.xy - tc; + vec2 f2 = f * f; + vec2 f3 = f2 * f; + /* Bspline coefs (optimized) */ + vec2 w3 = f3 / 6.0; + vec2 w0 = -w3 + f2 * 0.5 - f * 0.5 + 1.0 / 6.0; + vec2 w1 = f3 * 0.5 - f2 * 1.0 + 2.0 / 3.0; + vec2 w2 = 1.0 - w0 - w1 - w3; + +#if 1 /* Optimized version using 4 filtered tap. */ + vec2 s0 = w0 + w1; + vec2 s1 = w2 + w3; + + vec2 f0 = w1 / (w0 + w1); + vec2 f1 = w3 / (w2 + w3); + + vec4 final_co; + final_co.xy = tc - 1.0 + f0; + final_co.zw = tc + 1.0 + f1; + + final_co /= tex_size.xyxy; + + color = texture(ima, final_co.xy) * s0.x * s0.y; + color += texture(ima, final_co.zy) * s1.x * s0.y; + color += texture(ima, final_co.xw) * s0.x * s1.y; + color += texture(ima, final_co.zw) * s1.x * s1.y; + +#else /* Reference bruteforce 16 tap. */ + color = texelFetch(ima, ivec2(tc + vec2(-1.0, -1.0)), 0) * w0.x * w0.y; + color += texelFetch(ima, ivec2(tc + vec2( 0.0, -1.0)), 0) * w1.x * w0.y; + color += texelFetch(ima, ivec2(tc + vec2( 1.0, -1.0)), 0) * w2.x * w0.y; + color += texelFetch(ima, ivec2(tc + vec2( 2.0, -1.0)), 0) * w3.x * w0.y; + + color += texelFetch(ima, ivec2(tc + vec2(-1.0, 0.0)), 0) * w0.x * w1.y; + color += texelFetch(ima, ivec2(tc + vec2( 0.0, 0.0)), 0) * w1.x * w1.y; + color += texelFetch(ima, ivec2(tc + vec2( 1.0, 0.0)), 0) * w2.x * w1.y; + color += texelFetch(ima, ivec2(tc + vec2( 2.0, 0.0)), 0) * w3.x * w1.y; + + color += texelFetch(ima, ivec2(tc + vec2(-1.0, 1.0)), 0) * w0.x * w2.y; + color += texelFetch(ima, ivec2(tc + vec2( 0.0, 1.0)), 0) * w1.x * w2.y; + color += texelFetch(ima, ivec2(tc + vec2( 1.0, 1.0)), 0) * w2.x * w2.y; + color += texelFetch(ima, ivec2(tc + vec2( 2.0, 1.0)), 0) * w3.x * w2.y; + + color += texelFetch(ima, ivec2(tc + vec2(-1.0, 2.0)), 0) * w0.x * w3.y; + color += texelFetch(ima, ivec2(tc + vec2( 0.0, 2.0)), 0) * w1.x * w3.y; + color += texelFetch(ima, ivec2(tc + vec2( 1.0, 2.0)), 0) * w2.x * w3.y; + color += texelFetch(ima, ivec2(tc + vec2( 2.0, 2.0)), 0) * w3.x * w3.y; +#endif + + alpha = color.a; } void node_tex_image_smart(vec3 co, sampler2D ima, out vec4 color, out float alpha) @@ -1886,7 +1940,25 @@ void tex_box_sample_cubic(vec3 texco, out vec4 color2, out vec4 color3) { - tex_box_sample_linear(texco, N, ima, color1, color2, color3); + float alpha; + /* X projection */ + vec2 uv = texco.yz; + if (N.x < 0.0) { + uv.x = 1.0 - uv.x; + } + node_tex_image_cubic(uv.xyy, ima, color1, alpha); + /* Y projection */ + uv = texco.xz; + if (N.y > 0.0) { + uv.x = 1.0 - uv.x; + } + node_tex_image_cubic(uv.xyy, ima, color2, alpha); + /* Z projection */ + uv = texco.yx; + if (N.z > 0.0) { + uv.x = 1.0 - uv.x; + } + node_tex_image_cubic(uv.xyy, ima, color3, alpha); } void tex_box_sample_smart(vec3 texco, -- cgit v1.2.3 From 4609205a3f1b02abafeba80f542c8aa21d86bf68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 20:06:39 +0200 Subject: GPUMaterial: Cleanup unused headers --- source/blender/gpu/intern/gpu_material.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 92aff91da32..2264836f24a 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -36,32 +36,18 @@ #include "MEM_guardedalloc.h" -#include "DNA_lamp_types.h" #include "DNA_material_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_world_types.h" #include "BLI_math.h" -#include "BLI_blenlib.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLI_rand.h" -#include "BLI_threads.h" - -#include "BKE_anim.h" -#include "BKE_colorband.h" -#include "BKE_colortools.h" -#include "BKE_global.h" -#include "BKE_image.h" -#include "BKE_layer.h" + #include "BKE_main.h" #include "BKE_node.h" #include "BKE_scene.h" -#include "IMB_imbuf_types.h" - -#include "GPU_extensions.h" -#include "GPU_framebuffer.h" #include "GPU_material.h" #include "GPU_shader.h" #include "GPU_texture.h" -- cgit v1.2.3 From a987daa18dc66b726cef3e502b26e13ff002d894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 20:36:14 +0200 Subject: Render Preview: Fix problem with multi size icon preview The id was free after each size. We now only free after the job has finished. --- source/blender/editors/render/render_preview.c | 39 +++++++++++++++++++------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 7270eb03c2e..7459868d835 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -173,6 +173,7 @@ typedef struct ShaderPreview { int sizex, sizey; unsigned int *pr_rect; int pr_method; + bool own_id_copy; Main *bmain; Main *pr_main; @@ -837,7 +838,7 @@ static void shader_preview_free(void *customdata) ShaderPreview *sp = customdata; Main *pr_main = sp->pr_main; - if (sp->id_copy) { + if (sp->id_copy && sp->own_id_copy) { switch (GS(sp->id_copy->name)) { case ID_MA: BKE_material_free((Material *)sp->id_copy); @@ -866,14 +867,15 @@ static void shader_preview_free(void *customdata) /* get rid of copied material */ BLI_remlink(&pr_main->mat, sp->matcopy); - BKE_material_free(sp->matcopy); - properties = IDP_GetProperties((ID *)sp->matcopy, false); if (properties) { IDP_FreeProperty(properties); MEM_freeN(properties); } - MEM_freeN(sp->matcopy); + if (sp->own_id_copy) { + BKE_material_free(sp->matcopy); + MEM_freeN(sp->matcopy); + } } if (sp->texcopy) { struct IDProperty *properties; @@ -882,14 +884,16 @@ static void shader_preview_free(void *customdata) /* get rid of copied texture */ BLI_remlink(&pr_main->tex, sp->texcopy); - BKE_texture_free(sp->texcopy); properties = IDP_GetProperties((ID *)sp->texcopy, false); if (properties) { IDP_FreeProperty(properties); MEM_freeN(properties); } - MEM_freeN(sp->texcopy); + if (sp->own_id_copy) { + BKE_texture_free(sp->texcopy); + MEM_freeN(sp->texcopy); + } } if (sp->worldcopy) { struct IDProperty *properties; @@ -898,14 +902,16 @@ static void shader_preview_free(void *customdata) /* get rid of copied world */ BLI_remlink(&pr_main->world, sp->worldcopy); - BKE_world_free(sp->worldcopy); properties = IDP_GetProperties((ID *)sp->worldcopy, false); if (properties) { IDP_FreeProperty(properties); MEM_freeN(properties); } - MEM_freeN(sp->worldcopy); + if (sp->own_id_copy) { + BKE_world_free(sp->worldcopy); + MEM_freeN(sp->worldcopy); + } } if (sp->lampcopy) { struct IDProperty *properties; @@ -914,14 +920,16 @@ static void shader_preview_free(void *customdata) /* get rid of copied lamp */ BLI_remlink(&pr_main->lamp, sp->lampcopy); - BKE_lamp_free(sp->lampcopy); properties = IDP_GetProperties((ID *)sp->lampcopy, false); if (properties) { IDP_FreeProperty(properties); MEM_freeN(properties); } - MEM_freeN(sp->lampcopy); + if (sp->own_id_copy) { + BKE_lamp_free(sp->lampcopy); + MEM_freeN(sp->lampcopy); + } } MEM_freeN(sp); @@ -1139,6 +1147,7 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short sp->id = ip->id; sp->id_copy = ip->id_copy; sp->bmain = ip->bmain; + sp->own_id_copy = false; if (is_render) { BLI_assert(ip->id); @@ -1183,6 +1192,15 @@ static void icon_preview_endjob(void *customdata) #endif } + if (ip->id_copy) { + /* Feels a bit hacky just to reuse shader_preview_free() */ + ShaderPreview *sp = MEM_callocN(sizeof(ShaderPreview), "Icon ShaderPreview"); + sp->id_copy = ip->id_copy; + sp->own_id_copy = true; + shader_preview_free(sp); + ip->id_copy = NULL; + } + if (ip->owner) { PreviewImage *prv_img = ip->owner; prv_img->tag &= ~PRV_TAG_DEFFERED_RENDERING; @@ -1298,6 +1316,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M sp->pr_method = method; sp->id = id; sp->id_copy = duplicate_ids(id, sp->depsgraph); + sp->own_id_copy = true; sp->parent = parent; sp->slot = slot; sp->bmain = CTX_data_main(C); -- cgit v1.2.3 From 33c4ffdf46844e90a11896c0ff160dc4e01a6fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 21:31:36 +0200 Subject: Render Preview: Fix memory leak --- source/blender/editors/render/render_preview.c | 100 +++++++------------------ 1 file changed, 27 insertions(+), 73 deletions(-) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 7459868d835..daff5eee4c0 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -838,7 +838,34 @@ static void shader_preview_free(void *customdata) ShaderPreview *sp = customdata; Main *pr_main = sp->pr_main; + if (sp->matcopy) { + sp->id_copy = (ID *)sp->matcopy; + BLI_remlink(&pr_main->mat, sp->matcopy); + } + if (sp->texcopy) { + sp->id_copy = (ID *)sp->texcopy; + BLI_remlink(&pr_main->tex, sp->texcopy); + } + if (sp->worldcopy) { + sp->id_copy = (ID *)sp->worldcopy; + BLI_remlink(&pr_main->world, sp->worldcopy); + } + if (sp->lampcopy) { + sp->id_copy = (ID *)sp->lampcopy; + BLI_remlink(&pr_main->lamp, sp->lampcopy); + } + if (sp->id_copy) { + /* node previews */ + shader_preview_updatejob(sp); + } if (sp->id_copy && sp->own_id_copy) { + struct IDProperty *properties; + /* get rid of copied ID */ + properties = IDP_GetProperties(sp->id_copy, false); + if (properties) { + IDP_FreeProperty(properties); + MEM_freeN(properties); + } switch (GS(sp->id_copy->name)) { case ID_MA: BKE_material_free((Material *)sp->id_copy); @@ -858,79 +885,6 @@ static void shader_preview_free(void *customdata) } MEM_freeN(sp->id_copy); } - if (sp->matcopy) { - struct IDProperty *properties; - - /* node previews */ - shader_preview_updatejob(sp); - - /* get rid of copied material */ - BLI_remlink(&pr_main->mat, sp->matcopy); - - properties = IDP_GetProperties((ID *)sp->matcopy, false); - if (properties) { - IDP_FreeProperty(properties); - MEM_freeN(properties); - } - if (sp->own_id_copy) { - BKE_material_free(sp->matcopy); - MEM_freeN(sp->matcopy); - } - } - if (sp->texcopy) { - struct IDProperty *properties; - /* node previews */ - shader_preview_updatejob(sp); - - /* get rid of copied texture */ - BLI_remlink(&pr_main->tex, sp->texcopy); - - properties = IDP_GetProperties((ID *)sp->texcopy, false); - if (properties) { - IDP_FreeProperty(properties); - MEM_freeN(properties); - } - if (sp->own_id_copy) { - BKE_texture_free(sp->texcopy); - MEM_freeN(sp->texcopy); - } - } - if (sp->worldcopy) { - struct IDProperty *properties; - /* node previews */ - shader_preview_updatejob(sp); - - /* get rid of copied world */ - BLI_remlink(&pr_main->world, sp->worldcopy); - - properties = IDP_GetProperties((ID *)sp->worldcopy, false); - if (properties) { - IDP_FreeProperty(properties); - MEM_freeN(properties); - } - if (sp->own_id_copy) { - BKE_world_free(sp->worldcopy); - MEM_freeN(sp->worldcopy); - } - } - if (sp->lampcopy) { - struct IDProperty *properties; - /* node previews */ - shader_preview_updatejob(sp); - - /* get rid of copied lamp */ - BLI_remlink(&pr_main->lamp, sp->lampcopy); - - properties = IDP_GetProperties((ID *)sp->lampcopy, false); - if (properties) { - IDP_FreeProperty(properties); - MEM_freeN(properties); - } - if (sp->own_id_copy) { - BKE_lamp_free(sp->lampcopy); - MEM_freeN(sp->lampcopy); - } - } MEM_freeN(sp); } -- cgit v1.2.3 From eae9228a4d6b359d082324dd2b0f39116754bf8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 21:54:48 +0200 Subject: Eevee: Lamps: Fix RNA defaults and change defaults for contact shadows --- source/blender/blenkernel/intern/lamp.c | 4 ++-- source/blender/blenloader/intern/versioning_280.c | 4 ++-- source/blender/makesrna/intern/rna_lamp.c | 24 ++++++++++++++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 1d5b6de22f4..2c1b36d3496 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -84,10 +84,10 @@ void BKE_lamp_init(Lamp *la) la->cascade_count = 4; la->cascade_exponent = 0.8f; la->cascade_fade = 0.1f; - la->contact_dist = 1.0f; + la->contact_dist = 0.2f; la->contact_bias = 0.03f; la->contact_spread = 0.2f; - la->contact_thickness = 0.5f; + la->contact_thickness = 0.2f; la->spec_fac = 1.0f; curvemapping_initialize(la->curfalloff); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index d1ed166ba89..09a940436ef 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -804,10 +804,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "contact_dist")) { for (Lamp *la = bmain->lamp.first; la; la = la->id.next) { - la->contact_dist = 1.0f; + la->contact_dist = 0.2f; la->contact_bias = 0.03f; la->contact_spread = 0.2f; - la->contact_thickness = 0.5f; + la->contact_thickness = 0.2f; } } diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 573540ee641..126c5e82206 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -124,6 +124,7 @@ static void rna_def_light(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + static float default_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; srna = RNA_def_struct(brna, "Light", "ID"); RNA_def_struct_sdna(srna, "Lamp"); @@ -146,6 +147,7 @@ static void rna_def_light(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 10.0f); RNA_def_property_ui_range(prop, 0, 10, 1, 3); RNA_def_property_ui_text(prop, "Energy", "Amount of light emitted"); RNA_def_property_update(prop, 0, "rna_Light_draw_update"); @@ -153,11 +155,13 @@ static void rna_def_light(BlenderRNA *brna) prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); + RNA_def_property_float_array_default(prop, default_color); RNA_def_property_ui_text(prop, "Color", "Light color"); RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "spec_fac"); + RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2); RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier"); @@ -256,6 +260,7 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); + RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start", "Shadow map clip start, below which objects will not generate shadows"); @@ -263,6 +268,7 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) prop = RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipend"); + RNA_def_property_float_default(prop, 40.0f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip End", "Shadow map clip end, beyond which objects will not generate shadows"); @@ -270,6 +276,7 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bias"); + RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.001f, 9999.0f); RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3); RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Bias for reducing self shadowing"); @@ -283,12 +290,14 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) prop = RNA_def_property(srna, "shadow_buffer_exp", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bleedexp"); + RNA_def_property_float_default(prop, 2.5f); RNA_def_property_range(prop, 1.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Exponent", "Bias for reducing light-bleed on exponential shadow maps"); RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_soft", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "soft"); + RNA_def_property_float_default(prop, 3.0f); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Soft", "Size of shadow buffer sampling area"); RNA_def_property_update(prop, 0, "rna_Light_update"); @@ -307,6 +316,7 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) prop = RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_size"); + RNA_def_property_float_default(prop, 0.25f); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)"); @@ -322,6 +332,7 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) prop = RNA_def_property(srna, "contact_shadow_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "contact_dist"); + RNA_def_property_float_default(prop, 0.2f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Contact Shadow Distance", "World space distance in which to search for " "screen space occluder"); @@ -329,6 +340,7 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) prop = RNA_def_property(srna, "contact_shadow_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "contact_bias"); + RNA_def_property_float_default(prop, 0.03f); RNA_def_property_range(prop, 0.001f, 9999.0f); RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3); RNA_def_property_ui_text(prop, "Contact Shadow Bias", "Bias to avoid self shadowing"); @@ -336,12 +348,14 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) prop = RNA_def_property(srna, "contact_shadow_soft_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "contact_spread"); + RNA_def_property_float_default(prop, 0.2f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Contact Shadow Soft", "Control how soft the contact shadows will be"); RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "contact_shadow_thickness", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "contact_thickness"); + RNA_def_property_float_default(prop, 0.2f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Contact Shadow Thickness", "Pixel thickness used to detect occlusion"); @@ -350,24 +364,28 @@ static void rna_def_light_shadow(StructRNA *srna, int sun) if (sun) { prop = RNA_def_property(srna, "shadow_cascade_max_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "cascade_max_dist"); + RNA_def_property_float_default(prop, 1000.0f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Cascade Max Distance", "End distance of the cascaded shadow map (only in perspective view)"); RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_cascade_count", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "cascade_count"); + RNA_def_property_int_default(prop, 4); RNA_def_property_range(prop, 1, 4); RNA_def_property_ui_text(prop, "Cascade Count", "Number of texture used by the cascaded shadow map"); RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_cascade_exponent", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "cascade_exponent"); + RNA_def_property_float_default(prop, 0.8f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Exponential Distribution", "Higher value increase resolution towards the viewpoint"); RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_cascade_fade", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "cascade_fade"); + RNA_def_property_float_default(prop, 0.1f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Cascade Fade", "How smooth is the transition between each cascade"); RNA_def_property_update(prop, 0, "rna_Light_update"); @@ -416,14 +434,16 @@ static void rna_def_area_light(BlenderRNA *brna) prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_size"); + RNA_def_property_float_default(prop, 0.25f); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Size", "Size of the area of the area light, X direction size for rectangle shapes"); RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_float_sdna(prop, NULL, "area_sizey"); + RNA_def_property_float_default(prop, 0.25f); + RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Size Y", "Size of the area of the area light in the Y direction for rectangle shapes"); @@ -450,12 +470,14 @@ static void rna_def_spot_light(BlenderRNA *brna) prop = RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "spotblend"); + RNA_def_property_float_default(prop, 0.15f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge"); RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "spotsize"); + RNA_def_property_float_default(prop, DEG2RADF(45.0f)); RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f)); RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam"); RNA_def_property_update(prop, 0, "rna_Light_draw_update"); -- cgit v1.2.3 From 3005c2e2be3d0711649e4dd10697fc43ca88f50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 22:22:30 +0200 Subject: Eevee: LightProbes: Fix RNA defaults and remove unused data_draw_size --- .../scripts/startup/bl_ui/properties_data_lightprobe.py | 7 ++----- source/blender/blenkernel/intern/lightprobe.c | 1 - source/blender/draw/modes/object_mode.c | 6 +++--- source/blender/makesdna/DNA_lightprobe_types.h | 4 +--- source/blender/makesrna/intern/rna_lightprobe.c | 17 ++++++++++++----- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_lightprobe.py b/release/scripts/startup/bl_ui/properties_data_lightprobe.py index 10b66dd0033..5924a796b65 100644 --- a/release/scripts/startup/bl_ui/properties_data_lightprobe.py +++ b/release/scripts/startup/bl_ui/properties_data_lightprobe.py @@ -155,12 +155,9 @@ class DATA_PT_lightprobe_display(DataButtonsPanel, Panel): col = layout.column() - if probe.type != 'PLANAR': - col.prop(probe, "data_draw_size", text="Size") - else: + if probe.type == 'PLANAR': col.prop(ob, "empty_draw_size", text="Arrow Size") - - col.prop(probe, "show_data") + col.prop(probe, "show_data") if probe.type in {'GRID', 'CUBEMAP'}: col.prop(probe, "show_influence") diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c index 057b6aaaf65..baf0cdbe62f 100644 --- a/source/blender/blenkernel/intern/lightprobe.c +++ b/source/blender/blenkernel/intern/lightprobe.c @@ -53,7 +53,6 @@ void BKE_lightprobe_init(LightProbe *probe) probe->vis_bias = 1.0f; probe->vis_blur = 0.2f; probe->intensity = 1.0f; - probe->data_draw_size = 1.0f; probe->flag = LIGHTPROBE_FLAG_SHOW_INFLUENCE | LIGHTPROBE_FLAG_SHOW_DATA; } diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index dc499987c8a..9e9785f5e5c 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1906,9 +1906,9 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl DRW_shgroup_call_procedural_points_add(grp, prb_data->cell_count, NULL); } else if (prb->type == LIGHTPROBE_TYPE_CUBE) { - prb_data->draw_size = prb->data_draw_size * 0.1f; - unit_m4(prb_data->probe_cube_mat); - copy_v3_v3(prb_data->probe_cube_mat[3], ob->obmat[3]); + // prb_data->draw_size = prb->data_draw_size * 0.1f; + // unit_m4(prb_data->probe_cube_mat); + // copy_v3_v3(prb_data->probe_cube_mat[3], ob->obmat[3]); DRWShadingGroup *grp = shgroup_theme_id_to_probe_cube_outline_shgrp(stl, theme_id); /* TODO remove or change the drawing of the cube probes. Theses line draws nothing on purpose diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h index 81286e5e4d0..490e2574a33 100644 --- a/source/blender/makesdna/DNA_lightprobe_types.h +++ b/source/blender/makesdna/DNA_lightprobe_types.h @@ -68,11 +68,9 @@ typedef struct LightProbe { struct Image *image; /* Image to use on as lighting data */ struct Collection *visibility_grp; /* Object visibility group, inclusive or exclusive */ - float data_draw_size; - /* Runtime display data */ float distfalloff, distgridinf; - float pad; + float pad[2]; } LightProbe; /* Probe->type */ diff --git a/source/blender/makesrna/intern/rna_lightprobe.c b/source/blender/makesrna/intern/rna_lightprobe.c index a14699691a6..f54c01fab8e 100644 --- a/source/blender/makesrna/intern/rna_lightprobe.c +++ b/source/blender/makesrna/intern/rna_lightprobe.c @@ -83,6 +83,7 @@ static void rna_def_lightprobe(BlenderRNA *brna) prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); + RNA_def_property_float_default(prop, 0.8f); RNA_def_property_range(prop, 1e-6f, FLT_MAX); RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3); RNA_def_property_ui_text(prop, "Clip Start", @@ -91,6 +92,7 @@ static void rna_def_lightprobe(BlenderRNA *brna) prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipend"); + RNA_def_property_float_default(prop, 40.0f); RNA_def_property_range(prop, 1e-6f, FLT_MAX); RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3); RNA_def_property_ui_text(prop, "Clip End", @@ -115,11 +117,13 @@ static void rna_def_lightprobe(BlenderRNA *brna) prop = RNA_def_property(srna, "influence_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "distinf"); + RNA_def_property_float_default(prop, 2.5f); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Influence Distance", "Influence distance of the probe"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.2f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Falloff", "Control how fast the probe influence decreases"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); @@ -141,6 +145,7 @@ static void rna_def_lightprobe(BlenderRNA *brna) prop = RNA_def_property(srna, "parallax_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "distpar"); + RNA_def_property_float_default(prop, 2.5f); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Parallax Radius", "Lowest corner of the parallax bounding box"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); @@ -148,21 +153,25 @@ static void rna_def_lightprobe(BlenderRNA *brna) /* irradiance grid */ prop = RNA_def_property(srna, "grid_resolution_x", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, 256); + RNA_def_property_int_default(prop, 4); RNA_def_property_ui_text(prop, "Resolution X", "Number of sample along the x axis of the volume"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); prop = RNA_def_property(srna, "grid_resolution_y", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, 256); + RNA_def_property_int_default(prop, 4); RNA_def_property_ui_text(prop, "Resolution Y", "Number of sample along the y axis of the volume"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); prop = RNA_def_property(srna, "grid_resolution_z", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, 256); + RNA_def_property_int_default(prop, 4); RNA_def_property_ui_text(prop, "Resolution Z", "Number of sample along the z axis of the volume"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); prop = RNA_def_property(srna, "visibility_buffer_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vis_bias"); + RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.001f, 9999.0f); RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3); RNA_def_property_ui_text(prop, "Visibility Bias", "Bias for reducing self shadowing"); @@ -170,18 +179,21 @@ static void rna_def_lightprobe(BlenderRNA *brna) prop = RNA_def_property(srna, "visibility_bleed_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vis_bleedbias"); + RNA_def_property_float_default(prop, 0.0f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Visibility Bleed Bias", "Bias for reducing light-bleed on variance shadow maps"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); prop = RNA_def_property(srna, "visibility_blur", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vis_blur"); + RNA_def_property_float_default(prop, 0.2f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Visibility Blur", "Filter size of the visibilty blur"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "intensity"); + RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0.0f, 3.0f, 1.0, 3); RNA_def_property_ui_text(prop, "Intensity", "Modify the intensity of the lighting captured by this probe"); @@ -206,11 +218,6 @@ static void rna_def_lightprobe(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Data", "Show captured lighting data into the 3D view for debuging purpose"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); - prop = RNA_def_property(srna, "data_draw_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.05f, 10.0f); - RNA_def_property_ui_text(prop, "Data Draw Size", "Size of the spheres to debug captured light"); - RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); - /* common */ rna_def_animdata_common(srna); } -- cgit v1.2.3 From a1689fb091a9e57336d2ac9a013a44d804cd29ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Jul 2018 22:43:30 +0200 Subject: Eevee: Fix wrong SSR reprojection when switching orthographic view We just reset the temporal sampling and avoid using the previous frame for SSR at all. --- source/blender/draw/engines/eevee/eevee_private.h | 2 ++ source/blender/draw/engines/eevee/eevee_screen_raytrace.c | 8 ++++++++ source/blender/draw/engines/eevee/eevee_temporal_sampling.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 6ef24d03df8..5aa331a9b99 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -515,6 +515,7 @@ typedef struct EEVEE_EffectsInfo { int volume_current_sample; /* SSR */ bool reflection_trace_full; + bool ssr_was_persp; int ssr_neighbor_ofs; int ssr_halfres_ofs[2]; struct GPUTexture *ssr_normal_input; /* Textures from pool */ @@ -908,6 +909,7 @@ void EEVEE_mist_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat void EEVEE_mist_free(void); /* eevee_temporal_sampling.c */ +void EEVEE_temporal_sampling_reset(EEVEE_Data *vedata); int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_temporal_sampling_matrices_calc( EEVEE_EffectsInfo *effects, float viewmat[4][4], float persmat[4][4], const double ht_point[2]); diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c index 204b730f8da..b882db174b0 100644 --- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c +++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c @@ -132,6 +132,14 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) }); } + const bool is_persp = DRW_viewport_is_persp_get(); + if (effects->ssr_was_persp != is_persp) { + effects->ssr_was_persp = is_persp; + DRW_viewport_request_redraw(); + EEVEE_temporal_sampling_reset(vedata); + stl->g_data->valid_double_buffer = false; + } + effects->reflection_trace_full = (scene_eval->eevee.flag & SCE_EEVEE_SSR_HALF_RESOLUTION) == 0; common_data->ssr_thickness = scene_eval->eevee.ssr_thickness; common_data->ssr_border_fac = scene_eval->eevee.ssr_border_fade; diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index 7cd76669fe4..76e11e02d26 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -174,6 +174,11 @@ void EEVEE_temporal_sampling_matrices_calc( invert_m4_m4(effects->overide_wininv, effects->overide_winmat); } +void EEVEE_temporal_sampling_reset(EEVEE_Data *vedata) +{ + vedata->stl->effects->taa_render_sample = 1; +} + int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) { EEVEE_StorageList *stl = vedata->stl; -- cgit v1.2.3 From e361e9e99c5b6140b6284e81fa315bdcc48cee58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 21 Jul 2018 14:16:29 +0200 Subject: Render Preview: Fix ID freeing in wrong function --- source/blender/editors/render/render_preview.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index daff5eee4c0..3423eedf7ca 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1146,15 +1146,6 @@ static void icon_preview_endjob(void *customdata) #endif } - if (ip->id_copy) { - /* Feels a bit hacky just to reuse shader_preview_free() */ - ShaderPreview *sp = MEM_callocN(sizeof(ShaderPreview), "Icon ShaderPreview"); - sp->id_copy = ip->id_copy; - sp->own_id_copy = true; - shader_preview_free(sp); - ip->id_copy = NULL; - } - if (ip->owner) { PreviewImage *prv_img = ip->owner; prv_img->tag &= ~PRV_TAG_DEFFERED_RENDERING; @@ -1169,6 +1160,15 @@ static void icon_preview_free(void *customdata) { IconPreview *ip = (IconPreview *)customdata; + if (ip->id_copy) { + /* Feels a bit hacky just to reuse shader_preview_free() */ + ShaderPreview *sp = MEM_callocN(sizeof(ShaderPreview), "Icon ShaderPreview"); + sp->id_copy = ip->id_copy; + sp->own_id_copy = true; + shader_preview_free(sp); + ip->id_copy = NULL; + } + BLI_freelistN(&ip->sizes); MEM_freeN(ip); } -- cgit v1.2.3